diff --git a/firmware/application/external/morse_tx/ui_morse.cpp b/firmware/application/external/morse_tx/ui_morse.cpp index df7576511..66197f804 100644 --- a/firmware/application/external/morse_tx/ui_morse.cpp +++ b/firmware/application/external/morse_tx/ui_morse.cpp @@ -98,6 +98,25 @@ static msg_t loopthread_fn(void* arg) { return 0; } +void MorseView::on_set_tone(NavigationView& nav) { + tone_input_buffer = to_string_dec_uint(tone); + + text_prompt(nav, tone_input_buffer, 4, ENTER_KEYBOARD_MODE_DIGITS, [this](std::string& buffer) { + if (!buffer.empty() && std::all_of(buffer.begin(), buffer.end(), ::isdigit)) { + int new_tone = std::stoi(buffer); + if (new_tone >= 100 && new_tone <= 9999) { + tone = new_tone; + field_tone.set_value(tone); + update_tx_duration(); + } else { + nav_.display_modal("Out of range", "Tone must be between 100 and 9999 Hz"); + } + } else { + nav_.display_modal("Invalid input", "Please enter digits only"); + } + }); +} + void MorseView::on_set_text(NavigationView& nav) { text_prompt(nav, buffer, 28, ENTER_KEYBOARD_MODE_ALPHA); } @@ -250,6 +269,10 @@ MorseView::MorseView( tone = value; }; + field_tone.on_select = [this, &nav](NumberField&) { + this->on_set_tone(nav); + }; + button_message.on_select = [this, &nav](Button&) { this->on_set_text(nav); }; diff --git a/firmware/application/external/morse_tx/ui_morse.hpp b/firmware/application/external/morse_tx/ui_morse.hpp index 57da2cad7..fb54fcd7a 100644 --- a/firmware/application/external/morse_tx/ui_morse.hpp +++ b/firmware/application/external/morse_tx/ui_morse.hpp @@ -72,6 +72,7 @@ class MorseView : public View { NavigationView& nav_; std::string message{}; uint32_t time_units{0}; + std::string tone_input_buffer{}; // Holds the tone value while the text prompt is open TxRadioState radio_state_{ 0 /* frequency */, @@ -100,6 +101,7 @@ class MorseView : public View { bool start_tx(); void update_tx_duration(); + void on_set_tone(NavigationView& nav); void on_set_text(NavigationView& nav); void set_foxhunt(size_t i);