1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Merge pull request #1760 from urish/patch-2

Allow indefinite duration for `tone()`
This commit is contained in:
Ivan Grokhotkov 2016-03-13 20:06:43 +03:00
commit 9d4208ef3b

View File

@ -113,11 +113,15 @@ void noTone(uint8_t _pin) {
digitalWrite(_pin, LOW);
}
void t1IntHandler() {
if (toggle_counts[T1INDEX] > 0){
ICACHE_RAM_ATTR void t1IntHandler() {
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);