mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Allow indefinite duration for tone()
Bugfix: the `duration` parameter should be optional, per [`tone()`](https://www.arduino.cc/en/Reference/Tone) docs.
This commit is contained in:
parent
5cec3345ad
commit
4b55ee14ef
@ -114,10 +114,14 @@ void noTone(uint8_t _pin) {
|
||||
}
|
||||
|
||||
void t1IntHandler() {
|
||||
if (toggle_counts[T1INDEX] > 0){
|
||||
if (toggle_counts[T1INDEX] != 0){
|
||||
// toggle the pin
|
||||
digitalWrite(tone_pins[T1INDEX], toggle_counts[T1INDEX] % 2);
|
||||
toggle_counts[T1INDEX]--;
|
||||
// handle the case of indefinite duration
|
||||
if (toggle_counts[T1INDEX] < -2){
|
||||
toggle_counts[T1INDEX] = -1;
|
||||
}
|
||||
}else{
|
||||
disableTimer(T1INDEX);
|
||||
digitalWrite(tone_pins[T1INDEX], LOW);
|
||||
|
Loading…
x
Reference in New Issue
Block a user