Skip to content

Commit

Permalink
add pause feat for protoView app (#2267)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxkmm authored Sep 25, 2024
1 parent 24ab2f2 commit 967506f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
27 changes: 24 additions & 3 deletions firmware/application/external/protoview/ui_protoview.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
15 changes: 12 additions & 3 deletions firmware/application/external/protoview/ui_protoview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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{
Expand Down Expand Up @@ -178,4 +187,4 @@ class ProtoView : public View {

} // namespace ui::external_app::protoview

#endif /*__UI_PROTOVIEW_H__*/
#endif /*__UI_PROTOVIEW_H__*/
2 changes: 1 addition & 1 deletion firmware/common/ui_language.cpp
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 3 additions & 1 deletion firmware/common/ui_language.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ enum LangConsts {
LANG_READY,
LANG_DATADP,
LANG_LOOP,
LANG_RESET
LANG_RESET,
LANG_PAUSE,
LANG_RESUME
};

class LanguageHelper {
Expand Down

0 comments on commit 967506f

Please sign in to comment.