From 26ba1243521435ee4f2f1dff7625d5e3a1e2a254 Mon Sep 17 00:00:00 2001 From: R Date: Sat, 19 Jul 2025 12:38:57 +0100 Subject: [PATCH] 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. --- lib/pbio/drv/sound/sound_ev3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pbio/drv/sound/sound_ev3.c b/lib/pbio/drv/sound/sound_ev3.c index f4b94d0e7..4c6dae3bb 100644 --- a/lib/pbio/drv/sound/sound_ev3.c +++ b/lib/pbio/drv/sound/sound_ev3.c @@ -43,6 +43,12 @@ void pbdrv_sound_stop() { } void pbdrv_beep_start(uint32_t frequency, uint16_t sample_attenuator) { + // A frequency of 0 is equivalent to turning the sound off + if (frequency == 0) { + pbdrv_sound_stop(); + return; + } + // Clamp the frequency into the supported range if (frequency < 64) { frequency = 64;