-
Notifications
You must be signed in to change notification settings - Fork 59
zephyrCommon: Make configurable the max number of tones #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
d1fa1d4 to
41a8a6b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the Zephyr Arduino core’s tone() implementation to support more flexible timer allocation by dynamically selecting unused timers, and adds a Kconfig option to control the maximum number of concurrent tones.
Changes:
- Add
CONFIG_ARDUINO_MAX_TONES(default-1) to configure the tone timer pool size. - Track timer usage via a per-timer
pinfield and allocate/release timers dynamically intone()/noTone().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cores/arduino/zephyrCommon.cpp | Implements dynamic allocation/release of tone timers and makes the pool size configurable. |
| Kconfig | Adds ARDUINO_MAX_TONES configuration option (default -1 for auto sizing). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f424836 to
2c4afe2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
13e2210 to
2c0babd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
cores/arduino/zephyrCommon.cpp:281
- When frequency is 0, the function returns early without clearing the timer state (setting pt->pin = pin_size_t(-1)). This means the timer slot remains allocated to this pin even though it's no longer active. If this pin calls tone() again later, it will find and reuse the same timer, which is fine. However, if the maximum number of timers is reached and this pin's timer is not properly freed, it could prevent other pins from allocating timers. Consider adding
pt->pin = pin_size_t(-1);before the return on line 281 to properly free the timer slot.
if (frequency == 0) {
gpio_pin_set_dt(spec, 0);
return;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3d7c27c to
06b1038
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ca91026 to
00dc900
Compare
4c268f9 to
1bd995c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1bd995c to
87ba62e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4c268f9 to
87ba62e
Compare
Fixed a bug where tone() with duration=0 would stop the tone immediately instead of ringing infinitely. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
8bac16b to
05e7930
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
05e7930 to
309b112
Compare
Allows you to change the maximum number of notes that can be played with `tone()`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add a tone_doremi sample to demonstrate how to sounding with tone API Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
309b112 to
73f66c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
DhruvaG2000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one final comment
| pt->pin = pin_size_t(-1); | ||
| } else { | ||
| if (pin >= 0) { | ||
| if (pin != pin_size_t(-1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these changes inside add tone_doremi sample? Can be very misleading, please split into another commit.
Fixed a bug where tone() with duration=0 would stop the tone immediately instead of ringing infinitely.
Allows you to change the maximum number of notes that can be played with
tone().Add a tone_doremi sample to demonstrate how to sounding with tone API