From 2d85e73f0d5243f37eaa4b39ead94b8885574daa Mon Sep 17 00:00:00 2001 From: sommermorgentraum <24917424+zxkmm@users.noreply.github.com> Date: Wed, 12 Mar 2025 04:17:47 +0800 Subject: [PATCH] OokBrute app opt (#2561) --- .../external/ookbrute/ui_ookbrute.cpp | 39 +++++++++++++++++++ .../external/ookbrute/ui_ookbrute.hpp | 25 ++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/firmware/application/external/ookbrute/ui_ookbrute.cpp b/firmware/application/external/ookbrute/ui_ookbrute.cpp index c997fb6bd..a57a93b1a 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.cpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2024 HTotoo + * copyleft Whiterose of the Dark Army * * This file is part of PortaPack. * @@ -25,6 +26,7 @@ #include "baseband_api.hpp" #include "string_format.hpp" #include "portapack_persistent_memory.hpp" +#include "ui_textentry.hpp" using namespace portapack; using namespace ui; @@ -39,6 +41,9 @@ OOKBruteView::OOKBruteView(NavigationView& nav) : nav_{nav} { add_children({ &button_startstop, + &button_input_stop_position, + &button_input_start_position, + &labels, &field_frequency, &tx_view, &options_atkmode, @@ -66,6 +71,40 @@ OOKBruteView::OOKBruteView(NavigationView& nav) field_stop.on_change = [this](int32_t) { validate_start_stop(); }; + button_input_start_position.on_select = [this](Button&) { + stop(); // prevent mess count var up + + text_input_buffer = to_string_dec_uint(field_start.value()); + if (text_input_buffer == "0") { + text_input_buffer = ""; + } + + text_prompt( + nav_, + text_input_buffer, + 8, // currently longest is princeton + [this](std::string& buffer) { + field_start.set_value(atoi(buffer.c_str())); + validate_start_stop(); + }); + }; + button_input_stop_position.on_select = [this](Button&) { + stop(); // prevent mess count var up + + text_input_buffer = to_string_dec_uint(field_stop.value()); + if (text_input_buffer == "0") { + text_input_buffer = ""; + } + + text_prompt( + nav_, + text_input_buffer, + 8, // currently longest is princeton + [this](std::string& buffer) { + field_stop.set_value(atoi(buffer.c_str())); + validate_start_stop(); + }); + }; update_start_stop(0); } diff --git a/firmware/application/external/ookbrute/ui_ookbrute.hpp b/firmware/application/external/ookbrute/ui_ookbrute.hpp index d5a4c8d8a..fa547a7b6 100644 --- a/firmware/application/external/ookbrute/ui_ookbrute.hpp +++ b/firmware/application/external/ookbrute/ui_ookbrute.hpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2024 HTotoo + * copyleft Whiterose of the Dark Army * * This file is part of PortaPack. * @@ -52,12 +53,25 @@ class OOKBruteView : public View { app_settings::SettingsManager settings_{ "tx_ookbrute", app_settings::Mode::TX}; + Labels labels{ + {{0 * 8, 2 * 16}, "Start Position:", Theme::getInstance()->fg_light->foreground}, + {{0 * 8, 7 * 16}, "Stop Position:", Theme::getInstance()->fg_light->foreground}, + {{0 * 8, 13 * 16}, "Encoder Type:", Theme::getInstance()->fg_light->foreground}}; + Button button_startstop{ - {0, 3 * 16, 96, 24}, + {8, screen_height - 48 - 16, screen_width - 2 * 8, 48}, LanguageHelper::currentMessages[LANG_START]}; + Button button_input_start_position{ + {8, 4 * 16, screen_width - 2 * 8, 24}, + "Input Start Pos"}; + + Button button_input_stop_position{ + {8, 9 * 16, screen_width - 2 * 8, 24}, + "Input Stop Pos"}; + NumberField field_start{ - {0 * 8, 1 * 16}, + {0 * 8, 3 * 16}, 8, {0, 2500}, 1, @@ -65,15 +79,16 @@ class OOKBruteView : public View { true}; NumberField field_stop{ - {11 * 8, 1 * 16}, + {0, 8 * 16}, 9, {0, 2500}, 1, ' ', true}; + // NB: when add new encoder here you should also change the char count limit for input range buttons by it's digits in DEC OptionsField options_atkmode{ - {0 * 8, 2 * 16}, + {0, 14 * 16}, 12, {{"Came12", 0}, {"Came24", 1}, @@ -86,6 +101,8 @@ class OOKBruteView : public View { uint32_t counter = 0; // for packet change + std::string text_input_buffer{}; // this is needed by the text_prompt func + void start(); void stop();