From 853db877e9027927dd25d7e8624a901362af7192 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Sat, 10 Sep 2022 10:24:45 +1000 Subject: [PATCH] Link beep to volume knob appropriately. --- platform/targets/MD-3x0/platform.c | 10 +++++++++- platform/targets/MD-UV3x0/platform.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/platform/targets/MD-3x0/platform.c b/platform/targets/MD-3x0/platform.c index ad5ad5c7..b4b317cf 100644 --- a/platform/targets/MD-3x0/platform.c +++ b/platform/targets/MD-3x0/platform.c @@ -184,7 +184,15 @@ void platform_ledOff(led_t led) void platform_beepStart(uint16_t freq) { - toneGen_beepOn((float)freq, 64, 0); + // calculate appropriate volume. + uint8_t vol = platform_getVolumeLevel(); + // Since beeps have been requested, we do not want to have 0 volume. + // We also do not want the volume to be excessive. + if (vol < 10) + vol = 5; + if (vol > 176) + vol = 176; + toneGen_beepOn((float)freq, vol, 0); } void platform_beepStop() diff --git a/platform/targets/MD-UV3x0/platform.c b/platform/targets/MD-UV3x0/platform.c index c4fcf314..faffc612 100644 --- a/platform/targets/MD-UV3x0/platform.c +++ b/platform/targets/MD-UV3x0/platform.c @@ -184,7 +184,15 @@ void platform_ledOff(led_t led) void platform_beepStart(uint16_t freq) { - toneGen_beepOn((float)freq, 64, 0); + // calculate appropriate volume. + uint8_t vol = platform_getVolumeLevel(); + // Since beeps have been requested, we do not want to have 0 volume. + // We also do not want the volume to be excessive. + if (vol < 10) + vol = 5; + if (vol > 176) + vol = 176; + toneGen_beepOn((float)freq, vol, 0); } void platform_beepStop()