add pause feat for protoView app (#2267)

This commit is contained in:
zxkmm 2024-09-25 23:45:45 +08:00 committed by GitHub
parent 24ab2f29fa
commit 967506fb97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 8 deletions

View File

@ -1,6 +1,5 @@
/* /*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2024 HTotoo
* Copyright (C) 2017 Furrtek
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
@ -49,10 +48,12 @@ ProtoView::ProtoView(NavigationView& nav)
&field_vga, &field_vga,
&field_volume, &field_volume,
&field_frequency, &field_frequency,
&labels, &label_zoom,
&label_shift,
&options_zoom, &options_zoom,
&number_shift, &number_shift,
&button_reset, &button_reset,
&button_pause,
&waveform, &waveform,
&waveform2, &waveform2,
&waveform3, &waveform3,
@ -72,6 +73,10 @@ ProtoView::ProtoView(NavigationView& nav)
button_reset.on_select = [this](Button&) { button_reset.on_select = [this](Button&) {
reset(); 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()); baseband::set_subghzd_config(0, receiver_model.sampling_rate());
audio::set_rate(audio::Rate::Hz_24000); audio::set_rate(audio::Rate::Hz_24000);
audio::output::start(); audio::output::start();
@ -80,6 +85,7 @@ ProtoView::ProtoView(NavigationView& nav)
void ProtoView::reset() { void ProtoView::reset() {
cnt = 0; cnt = 0;
set_pause(false);
number_shift.set_value(0); number_shift.set_value(0);
waveform_shift = 0; waveform_shift = 0;
for (uint16_t i = 0; i < MAXSIGNALBUFFER; i++) time_buffer[i] = 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) { void ProtoView::on_data(const ProtoViewDataMessage* message) {
if (paused) return;
// filter out invalid ones. // filter out invalid ones.
uint16_t start = 0; uint16_t start = 0;
uint16_t stop = 0; uint16_t stop = 0;
@ -207,6 +214,20 @@ void ProtoView::on_freqchg(int64_t freq) {
field_frequency.set_value(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() { ProtoView::~ProtoView() {
audio::output::stop(); audio::output::stop();
receiver_model.disable(); receiver_model.disable();

View File

@ -74,8 +74,11 @@ class ProtoView : public View {
RxFrequencyField field_frequency{ RxFrequencyField field_frequency{
{0 * 8, 0 * 16}, {0 * 8, 0 * 16},
nav_}; 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}}; {{0 * 8, 2 * 16}, "Shift: ", Theme::getInstance()->fg_light->foreground}};
OptionsField options_zoom{ OptionsField options_zoom{
@ -103,6 +106,10 @@ class ProtoView : public View {
{screen_width - 12 * 8, 1 * 16, 96, 24}, {screen_width - 12 * 8, 1 * 16, 96, 24},
LanguageHelper::currentMessages[LANG_RESET]}; LanguageHelper::currentMessages[LANG_RESET]};
Button button_pause{
{screen_width - 12 * 8, 1 * 16 + 24, 96, 24},
LanguageHelper::currentMessages[LANG_PAUSE]};
Waveform waveform{ Waveform waveform{
{0, 8 * 8, 240, 50}, {0, 8 * 8, 240, 50},
waveform_buffer, waveform_buffer,
@ -136,6 +143,7 @@ class ProtoView : public View {
Theme::getInstance()->fg_yellow->foreground}; Theme::getInstance()->fg_yellow->foreground};
bool needCntReset = false; bool needCntReset = false;
bool paused = false;
int16_t zoom = 1; // one value in ms int16_t zoom = 1; // one value in ms
int16_t waveform_shift = 0; int16_t waveform_shift = 0;
@ -151,6 +159,7 @@ class ProtoView : public View {
void on_data(const ProtoViewDataMessage* message); void on_data(const ProtoViewDataMessage* message);
void draw(); void draw();
void draw2(); void draw2();
void set_pause(bool pause);
void reset(); void reset();
MessageHandlerRegistration message_handler_packet{ MessageHandlerRegistration message_handler_packet{
@ -178,4 +187,4 @@ class ProtoView : public View {
} // namespace ui::external_app::protoview } // namespace ui::external_app::protoview
#endif /*__UI_PROTOVIEW_H__*/ #endif /*__UI_PROTOVIEW_H__*/

View File

@ -1,6 +1,6 @@
#include "ui_language.hpp" #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; const char** LanguageHelper::currentMessages = englishMessages;

View File

@ -20,7 +20,9 @@ enum LangConsts {
LANG_READY, LANG_READY,
LANG_DATADP, LANG_DATADP,
LANG_LOOP, LANG_LOOP,
LANG_RESET LANG_RESET,
LANG_PAUSE,
LANG_RESUME
}; };
class LanguageHelper { class LanguageHelper {