Refactor FLEX RX UI to use console for messages (#2890)

This commit is contained in:
RocketGod
2025-12-14 10:08:39 -08:00
committed by GitHub
parent 7e8ad83537
commit c53adfc765
3 changed files with 57 additions and 198 deletions
+11 -30
View File
@@ -11,7 +11,6 @@
#include <string>
#include <vector>
#include <array>
namespace ui::external_app::flex_rx {
@@ -28,28 +27,17 @@ class FlexAppView : public View {
// Saved settings
rf::Frequency frequency_value{931740000}; // Default FLEX frequency
uint32_t current_color_index{0}; // Current text color selection
// Available text colors for message display
static constexpr std::array<Color, 7> text_colors = {{Color::green(),
Color::white(),
Color::cyan(),
Color::magenta(),
Color::yellow(),
Color::blue(),
Color::red()}};
RxRadioState radio_state_{};
// Message log settings
static constexpr size_t MAX_LOG_LINES = 32; // Limit to prevent memory issues
std::vector<std::string> log_messages{}; // Stored log lines
// Message storage for console redraw
static constexpr size_t MAX_MESSAGES = 20;
std::vector<std::string> messages{};
// Helper methods
void log_message(const std::string& message); // Add message with word wrap
void rebuild_menu(); // Rebuild menu after color change or overflow
void update_freq(rf::Frequency f); // Update tuned frequency
void cycle_color(); // Cycle through text colors
void log_message(const std::string& message);
void redraw_console();
void update_freq(rf::Frequency f);
// UI Elements - Row 0, dynamically positioned
RxFrequencyField field_frequency{
@@ -63,25 +51,18 @@ class FlexAppView : public View {
VGAGainField field_vga{
{UI_POS_X(18), UI_POS_Y(0)}};
// Color cycle button
Button button_color{
{UI_POS_X(21), UI_POS_Y(0), UI_POS_WIDTH(5), UI_POS_HEIGHT(1)},
"COLOR"};
RSSI rssi{
{UI_POS_X(26), 0, UI_POS_WIDTH(4), 4}};
{UI_POS_X(21), 0, UI_POS_WIDTH(9), 4}};
// Message display area - scrollable menu view
MenuView menu_view{
{0, 1 * 16, screen_width, screen_height - 1 * 16},
true};
// Message display area (below controls, account for status bar)
Console console{
{0, 1 * 16, screen_width, screen_height - 2 * 16}};
// Persistent settings manager
app_settings::SettingsManager settings_{
"rx_flex",
app_settings::Mode::RX,
{{"frequency", &frequency_value},
{"color_index", &current_color_index}}};
{{"frequency", &frequency_value}}};
// Message handlers
void on_packet(const FlexPacketMessage* message);