Skip to content

Commit d1fa1d4

Browse files
committed
zephyrCommon: Make configurable the max number of tones
Allows you to change the maximum number of notes that can be played with `tone()`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent 9c4ef9b commit d1fa1d4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ config ARDUINO_ENTRY
3434
bool "Provide arduino setup and loop entry points"
3535
default y
3636

37+
config ARDUINO_MAX_TONES
38+
int "Specify the number of sounds that can be played simultaneously with tone()"
39+
default -1
40+
3741
endif

cores/arduino/zephyrCommon.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ PinStatus digitalRead(pin_size_t pinNumber) {
212212
return (gpio_pin_get_dt(&arduino_pins[pinNumber]) == 1) ? HIGH : LOW;
213213
}
214214

215-
#ifndef MAX_TONE_PINS
216-
#define MAX_TONE_PINS DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios)
215+
#if CONFIG_MAX_TONES == -1
216+
#define CONFIG_MAX_TONES DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios)
217217
#endif
218218

219219
#define TOGGLES_PER_CYCLE 2ULL
@@ -223,7 +223,7 @@ static struct pin_timer {
223223
uint32_t count;
224224
pin_size_t pin{pin_size_t(-1)};
225225
bool infinity;
226-
} arduino_pin_timers[MAX_TONE_PINS];
226+
} arduino_pin_timers[CONFIG_MAX_TONES];
227227

228228
void tone_expiry_cb(struct k_timer *timer) {
229229
struct pin_timer *pt = CONTAINER_OF(timer, struct pin_timer, timer);

0 commit comments

Comments
 (0)