refactor: simplify audio volume handling in AudioVolumeField (#3246)

This commit is contained in:
Pezsma
2026-07-04 08:53:28 +02:00
committed by GitHub
parent b5d84fcc4d
commit fe2ba80a10
+2 -10
View File
@@ -26,10 +26,7 @@
#include "string_format.hpp"
#include "ui_receiver.hpp"
#include "ui_freqman.hpp"
#ifndef PRALINE
#include "audio.hpp"
#endif
using namespace portapack;
@@ -595,18 +592,13 @@ AudioVolumeField::AudioVolumeField(
/* fill char */ ' '} {
set_value(receiver_model.normalized_headphone_volume());
#ifdef PRALINE
on_change = [](int32_t v) {
receiver_model.set_normalized_headphone_volume(v);
#else
on_change = [](int32_t vol) {
// don't call receiver model, because this widget shuld be able to handle volume settinsg from any app, regardless of the receiver model's enables state. like the tx apps should be able to set volume too.
// this is identical to the receiver model's method
// Don't call receiver_model here so volume can be adjusted even when ReceiverModel is disabled (e.g. TX apps/games).
// The dB mapping mirrors ReceiverModel::set_normalized_headphone_volume().
uint8_t v = clip<uint8_t>(vol, 0, 99);
auto new_volume = volume_t::decibel(v - 99) + audio::headphone::volume_range().max;
persistent_memory::set_headphone_volume(new_volume);
audio::headphone::set_volume(new_volume);
#endif
};
}