solving_Audio_App_AM_GUI_Problem_issue_2604 (#2609)

This commit is contained in:
Brumi-2021 2025-04-04 14:04:06 +02:00 committed by GitHub
parent 4bbe1175c1
commit 4162820409
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 9 deletions

View File

@ -37,6 +37,9 @@ using namespace tonekey;
namespace ui {
int16_t previous_AM_mode_option = 0; // GUI 5 AM modes : (0..4 ) (DSB9K, DSB6K, USB,LSB, CW). Used to select proper FIR filter (0..11) AM mode + offset 0 (zoom+1) or +6 (if zoom+2)
int16_t previous_zoom = 0; // GUI ZOOM+1, ZOOM+2 , equivalent to two values offset 0 (zoom+1) or +6 (if zoom+2)
/* AMOptionsView *********************************************************/
AMOptionsView::AMOptionsView(
@ -52,20 +55,21 @@ AMOptionsView::AMOptionsView(
&zoom_config,
});
zoom_config.on_change = [this, view](size_t, OptionsField::value_t n) {
receiver_model.set_am_configuration(previous_filter_array_index + n);
zoom_config.on_change = [this, view](size_t, OptionsField::value_t n) { // n , has two option values. when GUI =zoom+1 => (0), when GUI=zoom+2 (6)
receiver_model.set_am_configuration(previous_AM_mode_option + n); // n (0 or 6)
view->set_zoom_factor(AM_MODULATION, n);
previous_zoom = n;
};
// restore zoom selection
zoom_config.set_by_value(view->get_zoom_factor(AM_MODULATION));
view->get_zoom_factor(AM_MODULATION);
freqman_set_bandwidth_option(AM_MODULATION, options_config); // adding the common message from freqman.cpp to the options_config
options_config.set_by_value(receiver_model.am_configuration());
freqman_set_bandwidth_option(AM_MODULATION, options_config); // freqman.cpp to the options_config, only allowing 5 modes freqman_bandwidths[AM] {"DSB 9k", 0}, {"DSB 6k", 1}, {"USB+3k", 2}, {"LSB-3k", 3}, {"CW", 4},
options_config.set_by_value(receiver_model.am_configuration() - previous_zoom); // restore AM GUI option mode , AM FIR index filters (0..11) values , <baseband::AMConfig, 12> am_configs has 12 fir index elements.
options_config.on_change = [this, view](size_t, OptionsField::value_t n) {
receiver_model.set_am_configuration(n);
previous_filter_array_index = n;
zoom_config.set_by_value(view->get_zoom_factor(AM_MODULATION));
receiver_model.set_am_configuration(n + previous_zoom); // we select proper FIR AM filter (0..11), = 0..4 GUI AM modes + offset +6 (if zoom+2)
previous_AM_mode_option = n; // (0..4) allowing 5 AM modes (DSB9K, DSB6K, USB,LSB, CW)
};
}

View File

@ -40,7 +40,6 @@ class AnalogAudioView;
class AMOptionsView : public View {
public:
AMOptionsView(AnalogAudioView* view, Rect parent_rect, const Style* style);
int16_t previous_filter_array_index = 0;
private:
Text label_config{
@ -59,7 +58,7 @@ class AMOptionsView : public View {
{23 * 8, 0 * 16},
7,
{{"ZOOM x1", 0},
{"ZOOM x2", 6}} // offset index array filters.
{"ZOOM x2", 6}} // offset index AM modes array FIR filters.
};
};