From 967506fb975a45cef922abd3096719d0c43938bf Mon Sep 17 00:00:00 2001 From: zxkmm <24917424+zxkmm@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:45:45 +0800 Subject: [PATCH] add pause feat for protoView app (#2267) --- .../external/protoview/ui_protoview.cpp | 27 ++++++++++++++++--- .../external/protoview/ui_protoview.hpp | 15 ++++++++--- firmware/common/ui_language.cpp | 2 +- firmware/common/ui_language.hpp | 4 ++- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/firmware/application/external/protoview/ui_protoview.cpp b/firmware/application/external/protoview/ui_protoview.cpp index d4c9cf18..74263c5c 100644 --- a/firmware/application/external/protoview/ui_protoview.cpp +++ b/firmware/application/external/protoview/ui_protoview.cpp @@ -1,6 +1,5 @@ /* - * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. - * Copyright (C) 2017 Furrtek + * Copyright (C) 2024 HTotoo * * This file is part of PortaPack. * @@ -49,10 +48,12 @@ ProtoView::ProtoView(NavigationView& nav) &field_vga, &field_volume, &field_frequency, - &labels, + &label_zoom, + &label_shift, &options_zoom, &number_shift, &button_reset, + &button_pause, &waveform, &waveform2, &waveform3, @@ -72,6 +73,10 @@ ProtoView::ProtoView(NavigationView& nav) button_reset.on_select = [this](Button&) { reset(); }; + button_pause.on_select = [this](Button&) { + set_pause(!paused); + }; + set_pause(false); // need to use this to default hide shift functionality baseband::set_subghzd_config(0, receiver_model.sampling_rate()); audio::set_rate(audio::Rate::Hz_24000); audio::output::start(); @@ -80,6 +85,7 @@ ProtoView::ProtoView(NavigationView& nav) void ProtoView::reset() { cnt = 0; + set_pause(false); number_shift.set_value(0); waveform_shift = 0; for (uint16_t i = 0; i < MAXSIGNALBUFFER; i++) time_buffer[i] = 0; @@ -175,6 +181,7 @@ void ProtoView::add_time(int32_t time) { } void ProtoView::on_data(const ProtoViewDataMessage* message) { + if (paused) return; // filter out invalid ones. uint16_t start = 0; uint16_t stop = 0; @@ -207,6 +214,20 @@ void ProtoView::on_freqchg(int64_t freq) { field_frequency.set_value(freq); } +void ProtoView::set_pause(bool pause) { + paused = pause; + if (pause) { + label_shift.hidden(false); + number_shift.hidden(false); + button_pause.set_text("Resume"); + } else { + label_shift.hidden(true); + number_shift.hidden(true); + button_pause.set_text("Pause"); + } + set_dirty(); +} + ProtoView::~ProtoView() { audio::output::stop(); receiver_model.disable(); diff --git a/firmware/application/external/protoview/ui_protoview.hpp b/firmware/application/external/protoview/ui_protoview.hpp index 0af34b1b..b356bcf8 100644 --- a/firmware/application/external/protoview/ui_protoview.hpp +++ b/firmware/application/external/protoview/ui_protoview.hpp @@ -74,8 +74,11 @@ class ProtoView : public View { RxFrequencyField field_frequency{ {0 * 8, 0 * 16}, nav_}; - Labels labels{ - {{0 * 8, 1 * 16}, "Zoom: ", Theme::getInstance()->fg_light->foreground}, + + // need to seperate because label shift need to hide independently + Labels label_zoom{ + {{0 * 8, 1 * 16}, "Zoom: ", Theme::getInstance()->fg_light->foreground}}; + Labels label_shift{ {{0 * 8, 2 * 16}, "Shift: ", Theme::getInstance()->fg_light->foreground}}; OptionsField options_zoom{ @@ -103,6 +106,10 @@ class ProtoView : public View { {screen_width - 12 * 8, 1 * 16, 96, 24}, LanguageHelper::currentMessages[LANG_RESET]}; + Button button_pause{ + {screen_width - 12 * 8, 1 * 16 + 24, 96, 24}, + LanguageHelper::currentMessages[LANG_PAUSE]}; + Waveform waveform{ {0, 8 * 8, 240, 50}, waveform_buffer, @@ -136,6 +143,7 @@ class ProtoView : public View { Theme::getInstance()->fg_yellow->foreground}; bool needCntReset = false; + bool paused = false; int16_t zoom = 1; // one value in ms int16_t waveform_shift = 0; @@ -151,6 +159,7 @@ class ProtoView : public View { void on_data(const ProtoViewDataMessage* message); void draw(); void draw2(); + void set_pause(bool pause); void reset(); MessageHandlerRegistration message_handler_packet{ @@ -178,4 +187,4 @@ class ProtoView : public View { } // namespace ui::external_app::protoview -#endif /*__UI_PROTOVIEW_H__*/ \ No newline at end of file +#endif /*__UI_PROTOVIEW_H__*/ diff --git a/firmware/common/ui_language.cpp b/firmware/common/ui_language.cpp index 73b8a9e7..856452e4 100644 --- a/firmware/common/ui_language.cpp +++ b/firmware/common/ui_language.cpp @@ -1,6 +1,6 @@ #include "ui_language.hpp" -const char* LanguageHelper::englishMessages[] = {"OK", "Cancel", "Error", "Modem setup", "Debug", "Log", "Done", "Start", "Stop", "Scan", "Clear", "Ready", "Data:", "Loop", "Reset"}; +const char* LanguageHelper::englishMessages[] = {"OK", "Cancel", "Error", "Modem setup", "Debug", "Log", "Done", "Start", "Stop", "Scan", "Clear", "Ready", "Data:", "Loop", "Reset", "Pause", "Resume"}; const char** LanguageHelper::currentMessages = englishMessages; diff --git a/firmware/common/ui_language.hpp b/firmware/common/ui_language.hpp index 4b39e17a..c824359d 100644 --- a/firmware/common/ui_language.hpp +++ b/firmware/common/ui_language.hpp @@ -20,7 +20,9 @@ enum LangConsts { LANG_READY, LANG_DATADP, LANG_LOOP, - LANG_RESET + LANG_RESET, + LANG_PAUSE, + LANG_RESUME }; class LanguageHelper {