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:
commit
9d4208ef3b
@ -113,11 +113,15 @@ void noTone(uint8_t _pin) {
|
|||||||
digitalWrite(_pin, LOW);
|
digitalWrite(_pin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void t1IntHandler() {
|
ICACHE_RAM_ATTR void t1IntHandler() {
|
||||||
if (toggle_counts[T1INDEX] > 0){
|
if (toggle_counts[T1INDEX] != 0){
|
||||||
// toggle the pin
|
// toggle the pin
|
||||||
digitalWrite(tone_pins[T1INDEX], toggle_counts[T1INDEX] % 2);
|
digitalWrite(tone_pins[T1INDEX], toggle_counts[T1INDEX] % 2);
|
||||||
toggle_counts[T1INDEX]--;
|
toggle_counts[T1INDEX]--;
|
||||||
|
// handle the case of indefinite duration
|
||||||
|
if (toggle_counts[T1INDEX] < -2){
|
||||||
|
toggle_counts[T1INDEX] = -1;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
disableTimer(T1INDEX);
|
disableTimer(T1INDEX);
|
||||||
digitalWrite(tone_pins[T1INDEX], LOW);
|
digitalWrite(tone_pins[T1INDEX], LOW);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user