Repository navigation
Expand file tree
/
Copy pathOSCBoards.h
More file actions
182 lines (156 loc) · 7.96 KB
/
Copy pathOSCBoards.h
File metadata and controls
182 lines (156 loc) · 7.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//
// OSCBoards.h
//
//
// Created by AdrianFreed on 5/26/13.
//
//
#ifndef _OSCBoards_h
#define _OSCBoards_h
#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) || defined(__MK66FX1M0__)
// Teensy 3.0 3.1 3.1LC 3.2 3.6
#define BOARD_HAS_CAPACITANCE_SENSING
#endif
#if defined(__AVR_ATmega32U4__) || defined(__MKL26Z64__) || defined(__MK20DX128__)|| defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__)
#define BOARD_HAS_DIE_TEMPERATURE_SENSOR
#endif
#if defined(__AVR_ATmega32U4__) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK66FX1M0__) || defined(__MKL26Z64__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__)
#define BOARD_HAS_DIE_POWER_SUPPLY_MEASUREMENT
#endif
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__)
#define BOARD_HAS_ANALOG_PULLUP
#endif
// The Oscuino examples guard their /tone handler with #ifdef BOARD_HAS_TONE,
// but nothing in the library ever defined it, so /tone was dead code in every
// one of them. Define it where tone()/noTone() actually exist.
//
// Checked by compiling a tone()/noTone() probe against every installed core:
// arduino:avr, arduino:megaavr, arduino:renesas_uno, arduino:samd,
// adafruit:samd, adafruit:nrf52, teensy:avr, esp32:esp32 and rp2040:rp2040 all
// provide it. arduino:sam (SAM3X8E / Due) is the one that does not.
// Define OSC_NO_TONE before including the library to force it off elsewhere.
#if !defined(OSC_NO_TONE) && !defined(__SAM3X8E__)
#define BOARD_HAS_TONE
#endif
// missing specs for PIC32
#if (defined(__PIC32MX__) || defined(__PIC32MZ__))
#define NUM_ANALOG_INPUTS NUM_ANALOG_PINS
#define NUM_DIGITAL_INPUTS NUM_DIGITAL_PINS
#define LED_BUILTIN PIN_LED1
#endif
// The Zephyr core (Arduino UNO Q and the zephyr_main boards) spells the pin
// count NUM_OF_DIGITAL_PINS and gives the analog pins an enum with no count
// sentinel at all, so the Oscuino-style examples that iterate pins do not
// compile there. Both counts come from the board's own devicetree rather than
// from a table here, so they follow the variant instead of needing one entry
// per board.
#if defined(ARDUINO_ARCH_ZEPHYR)
#ifndef NUM_DIGITAL_PINS
#define NUM_DIGITAL_PINS NUM_OF_DIGITAL_PINS
#endif
#ifndef NUM_ANALOG_INPUTS
#ifdef CONFIG_ADC
#define NUM_ANALOG_INPUTS DT_PROP_LEN(DT_PATH(zephyr_user), adc_pin_gpios)
#else
#define NUM_ANALOG_INPUTS 0
#endif
#endif
#endif
// Onboard LEDs. No Arduino core defines a capability macro for these — checked
// by grepping all 27 installed cores for anything shaped like ARDUINO_HAS_LED,
// zero hits — so the presence of the pin macro itself is the only signal there
// is. Established the same way as BOARD_HAS_TONE above: a #pragma message probe
// compiled against 42 boards, every one of which built.
//
// Only defined() is safe here. LED_BUILTIN is NOT always a preprocessor
// constant: esp32 variants declare it `static const uint8_t` and then write
// `#define LED_BUILTIN LED_BUILTIN` purely so #ifdef works (it evaluates to 0
// inside #if), and the Zephyr core builds it from the board's devicetree as a
// ~70-term expression. Compare values in C++, never in #if.
//
// Three boards this library has run on define no LED_BUILTIN at all — M5Dial,
// M5StampS3 and the LilyGO T-Display-S3 — which is what BOARD_HAS_LED is for.
// Guessing a pin there is not harmless: GPIO 13, the obvious guess, is SDA on
// the M5Dial and MISO on the T-Display-S3.
//
// One exception, narrow and named. esp32:esp32:esp32 is a generic FQBN standing
// for a family of dev modules whose variant names no LED, but which by
// convention wire one to GPIO 2 (DOIT DevKit and its clones). Several examples
// used to carry this as a blanket `#ifndef LED_BUILTIN -> 2`, which also fired
// on boards that genuinely have none; scoped to ARDUINO_ESP32_DEV it does not,
// since the M5Dial, M5StampS3 and T-Display-S3 each carry their own board
// define. Inherited from those examples as a convention and NOT measured here —
// no plain ESP32 devkit appears in BOARDS.md. OSC_NO_LED forces it off.
#if !defined(LED_BUILTIN) && defined(ARDUINO_ESP32_DEV) && !defined(OSC_NO_LED)
#define LED_BUILTIN 2
#endif
#if defined(LED_BUILTIN) && !defined(OSC_NO_LED)
#define BOARD_HAS_LED
#endif
// RGB onboard LEDs, in the four spellings the cores actually use. Ordered by
// how much the core does for you: RGB_BUILTIN is the only one with a driver
// behind it (esp32's rgbLedWrite(), which digitalWrite() also routes to), the
// rest are bare pin numbers wanting Adafruit_NeoPixel or equivalent.
//
// Treat a negative as "no macro said so", not as "no RGB LED". The M5Stack
// NanoC6 has a WS2812 whose pins its own variant names (RGB_LED_DATA_PIN 20,
// RGB_LED_PWR_PIN 19) while defining none of these four. It can also read
// positive on a board without one: m5stack_atoms3 declares RGB_BUILTIN = 48,
// but that variant is shared with the AtomS3 Lite and 48 is the Lite's pixel.
// OSC_NO_RGB forces it off; a sketch that knows its board should just say so.
//
// LED_RED/LED_GREEN/LED_BLUE are deliberately not consulted: on every UNO R4,
// the RGB-less Minima included, they leak in from the Renesas FSP's generated
// bsp_pin_cfg.h in FSP port-pin encoding, which is not an Arduino pin number.
// Two boards whose cores under-describe a pixel that is certainly there, named
// the same narrow way as the ESP32_DEV rule above. Both must precede the test
// below, since that is what they exist to correct.
//
// Circuit Playground Express: both cores that build it use the same
// `circuitplay` variant and the same board define, but only adafruit:samd names
// the ring — its variant.h says PIN_NEOPIXEL D8 / NEOPIXEL_NUM 10, expanding to
// (8u), while arduino:samd's copy omits both. Measured: without this,
// BOARD_HAS_RGB is false on arduino:samd for a board carrying ten pixels, and
// anything guarded on it would compile away.
#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) && !defined(PIN_NEOPIXEL)
#define PIN_NEOPIXEL 8
#ifndef NEOPIXEL_NUM
#define NEOPIXEL_NUM 10
#endif
#endif
// M5Stack NanoC6: its variant names the WS2812 and the power gate that feeds
// it, but under names no convention looks for, so all four spellings below miss
// it. Pointed at the variant's own constants rather than literals, so the pins
// stay the variant's to state. From that naming, not from hardware — BOARDS.md
// records this board as having stopped responding before any suite ran.
#if defined(ARDUINO_M5STACK_NANOC6) && !defined(PIN_NEOPIXEL)
#define PIN_NEOPIXEL RGB_LED_DATA_PIN
#ifndef NEOPIXEL_POWER
#define NEOPIXEL_POWER RGB_LED_PWR_PIN
#endif
#endif
#if !defined(OSC_NO_RGB)
#if defined(RGB_BUILTIN)
#define BOARD_HAS_RGB
#define BOARD_RGB_CORE_DRIVEN
#elif defined(PIN_NEOPIXEL)
#define BOARD_HAS_RGB
#define BOARD_RGB_NEOPIXEL
#elif defined(PIN_DOTSTAR_DATA) && (defined(PIN_DOTSTAR_CLOCK) || defined(PIN_DOTSTAR_CLK))
#define BOARD_HAS_RGB
#define BOARD_RGB_DOTSTAR
#elif defined(LEDR) && defined(LEDG) && defined(LEDB)
#define BOARD_HAS_RGB
#define BOARD_RGB_DISCRETE
#endif
#endif
#ifndef analogInputToDigitalPin
int analogInputToDigitalPin(int i);
#endif
#ifdef BOARD_HAS_DIE_TEMPERATURE_SENSOR
float getTemperature();
#endif
#ifdef BOARD_HAS_DIE_POWER_SUPPLY_MEASUREMENT
float getSupplyVoltage();
#endif
#endif