From 4eb5c4603e8c761f16dbf5b0964c2f465c0370c0 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Sun, 24 Dec 2023 01:55:15 -0600 Subject: [PATCH] Simplify CLKOUT frequency entry (#1668) --- firmware/application/apps/ui_settings.cpp | 30 +++++------------------ firmware/application/apps/ui_settings.hpp | 10 ++------ 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/firmware/application/apps/ui_settings.cpp b/firmware/application/apps/ui_settings.cpp index c57f3220..c2642b04 100644 --- a/firmware/application/apps/ui_settings.cpp +++ b/firmware/application/apps/ui_settings.cpp @@ -133,7 +133,6 @@ SetRadioView::SetRadioView( &check_clkout, &field_clkout_freq, &labels_clkout_khz, - &value_freq_step, &labels_bias, &check_bias, &disable_external_tcxo, // TODO: always show? @@ -186,28 +185,11 @@ SetRadioView::SetRadioView( }; field_clkout_freq.set_value(pmem::clkout_freq()); - value_freq_step.set_style(&Styles::light_grey); - - field_clkout_freq.on_select = [this](NumberField&) { - freq_step_khz++; - if (freq_step_khz > 3) { - freq_step_khz = 0; - } - switch (freq_step_khz) { - case 0: - value_freq_step.set(" |"); - break; - case 1: - value_freq_step.set(" | "); - break; - case 2: - value_freq_step.set(" | "); - break; - case 3: - value_freq_step.set("| "); - break; - } - field_clkout_freq.set_step(pow(10, freq_step_khz)); + field_clkout_freq.on_change = [this](SymField&) { + if (field_clkout_freq.to_integer() < 10) + field_clkout_freq.set_value(10); + if (field_clkout_freq.to_integer() > 60000) + field_clkout_freq.set_value(60000); }; check_bias.set_value(get_antenna_bias()); @@ -248,7 +230,7 @@ void SetRadioView::form_init(const SetFrequencyCorrectionModel& model) { SetFrequencyCorrectionModel SetRadioView::form_collect() { return { .ppm = static_cast(field_ppm.value()), - .freq = static_cast(field_clkout_freq.value()), + .freq = static_cast(field_clkout_freq.to_integer()), }; } diff --git a/firmware/application/apps/ui_settings.hpp b/firmware/application/apps/ui_settings.hpp index 3473d219..be9ce532 100644 --- a/firmware/application/apps/ui_settings.hpp +++ b/firmware/application/apps/ui_settings.hpp @@ -163,20 +163,14 @@ class SetRadioView : public View { 13, "Enable CLKOUT"}; - NumberField field_clkout_freq{ + SymField field_clkout_freq{ {20 * 8, 6 * 16}, 5, - {10, 60000}, - 1000, - ' '}; + SymField::Type::Dec}; Labels labels_clkout_khz{ {{26 * 8, 6 * 16}, "kHz", Color::light_grey()}}; - Text value_freq_step{ - {21 * 8, (7 * 16), 4 * 8, 16}, - "| "}; - Labels labels_bias{ {{4 * 8 + 4, 8 * 16}, "CAUTION: Ensure that all", Color::red()}, {{5 * 8 + 0, 9 * 16}, "devices attached to the", Color::red()},