mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-23 14:29:23 -05:00
add pause feat for protoView app (#2267)
This commit is contained in:
parent
24ab2f29fa
commit
967506fb97
@ -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();
|
||||
|
@ -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__*/
|
||||
#endif /*__UI_PROTOVIEW_H__*/
|
||||
|
@ -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;
|
||||
|
||||
|
@ -20,7 +20,9 @@ enum LangConsts {
|
||||
LANG_READY,
|
||||
LANG_DATADP,
|
||||
LANG_LOOP,
|
||||
LANG_RESET
|
||||
LANG_RESET,
|
||||
LANG_PAUSE,
|
||||
LANG_RESUME
|
||||
};
|
||||
|
||||
class LanguageHelper {
|
||||
|
Loading…
Reference in New Issue
Block a user