Skip to content

Commit 4f22a07

Browse files
committed
DM: fix tone 0 frequency
1 parent 6ead93c commit 4f22a07

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cores/arduino/Tone.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ void toneAccurateClock (uint32_t accurateSystemCoreClockFrequency)
6969
toneMaxFrequency = accurateSystemCoreClockFrequency / 2;
7070
}
7171

72-
//DM TODO: make this work as a rest when frequency 0 is passed
7372
void tone (uint32_t outputPin, uint32_t frequency, uint32_t duration)
7473
{
7574
// Configure interrupt request
@@ -90,6 +89,9 @@ void tone (uint32_t outputPin, uint32_t frequency, uint32_t duration)
9089
while (GCLK->STATUS.bit.SYNCBUSY);
9190
#endif
9291
}
92+
93+
//if it's a rest, set to 1Hz (below audio range)
94+
frequency = (frequency > 0 ? frequency : 1);
9395

9496
if (toneIsActive && (outputPin != lastOutputPin))
9597
noTone(lastOutputPin);

0 commit comments

Comments
 (0)