Skip to content

Commit bf9870f

Browse files
ArcaneNibbledlech
authored andcommitted
pbio/drv/sound/sound_ev3: Fix playing a frequency of 0
A frequency of 0 turns the sound off. It would previously play a minimum-frequency 64 Hz sound instead.
1 parent 16e7a48 commit bf9870f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/pbio/drv/sound/sound_ev3.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ void pbdrv_sound_stop() {
4343
}
4444

4545
void pbdrv_beep_start(uint32_t frequency, uint16_t sample_attenuator) {
46+
// A frequency of 0 is equivalent to turning the sound off
47+
if (frequency == 0) {
48+
pbdrv_sound_stop();
49+
return;
50+
}
51+
4652
// Clamp the frequency into the supported range
4753
if (frequency < 64) {
4854
frequency = 64;

0 commit comments

Comments
 (0)