chore(radio): remove 20% deadband for low volume (#7347)

This commit is contained in:
3djc
2026-06-12 13:20:09 +10:00
committed by GitHub
parent 704f31a69c
commit 15921e18ae
6 changed files with 32 additions and 22 deletions
+10 -9
View File
@@ -614,19 +614,20 @@ void calcBacklightValue(int16_t source)
#endif
}
#define VOLUME_HYSTERESIS 10 // how much must a input value change to actually be considered for new volume setting
getvalue_t requiredSpeakerVolumeRawLast = 1024 + 1; //initial value must be outside normal range
#define VOLUME_SOURCE_DEADZONE 10 // how much must a input value change to actually be considered for new volume setting
void calcVolumeValue(int16_t source)
{
getvalue_t raw = getValue(source);
// only set volume if input changed more than hysteresis
if (abs(requiredSpeakerVolumeRawLast - raw) > VOLUME_HYSTERESIS) {
requiredSpeakerVolumeRawLast = raw;
int32_t shifted = 1024 + getValue(source);
int32_t v;
if (shifted < VOLUME_SOURCE_DEADZONE) {
v = 0;
} else {
v = 1 + ((shifted - VOLUME_SOURCE_DEADZONE) * (VOLUME_LEVEL_MAX - 1)) /
(2048 - VOLUME_SOURCE_DEADZONE);
if (v > VOLUME_LEVEL_MAX) v = VOLUME_LEVEL_MAX;
}
requiredSpeakerVolume =
((1024 + requiredSpeakerVolumeRawLast) * VOLUME_LEVEL_MAX) /
2048;
requiredSpeakerVolume = (int16_t)v;
}
void checkBacklight()