1
0
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:
Uri Shaked 2016-03-12 17:42:30 +02:00
parent 5cec3345ad
commit 4b55ee14ef

View File

@ -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);