Apr 1, 2021
4
0
10
0
I ported one of my "Community Project" Arduino IDE Raspberry Pico (RP2040) sketches to the Official (2.0 Beta), MacOSX-hosted Arduino IDE.

It mostly worked, noting that varargs is treated differently within the two different ARM C compilers. "Community Project" implements VA_OPT(,) where "2.0 Beta" uses ##VA_ARGS (gcc cludge).

In more detail:
C:
#if defined(RASPBERRY_PICO) /* printf macro messes up one-line if statements (with no section brackets) that use an else. */
# define MAXMSGLINE    1000
# if !defined(MACOSX)
#  define printf(format, ...) { char msg[MAXMSGLINE]; sprintf(msg, format __VA_OPT__(,) __VA_ARGS__); Serial.print(msg); }
# else /* !defined(MACOSX) */
#  define printf(format, ...) { char msg[MAXMSGLINE]; sprintf(msg, format, ##__VA_ARGS__); Serial.print(msg); }
# endif /* !defined(MACOSX) */
#endif /* defined(RASPBERRY_PICO) */

More importantly though (burying the lede), reading analog pin data using "analogRead()" in "2.0 Beta", by default, masks off the top two, most significant, bits (returning 10 bits instead of 12). It is necessary to call:
C:
analogReadResolution(12);
to get sensible analog pin readings off the board.
 

ASK THE COMMUNITY