mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
add shift feat for protcol view tool (#2258)
* add shift * add shift * format * add padding (wrote by AI) * layout fine tune * remove debug thing * edit per request * remove torjan (jk) * int 16 should be good enough for it
This commit is contained in:
parent
89b51095bf
commit
9390317a75
@ -51,6 +51,7 @@ ProtoView::ProtoView(NavigationView& nav)
|
|||||||
&field_frequency,
|
&field_frequency,
|
||||||
&labels,
|
&labels,
|
||||||
&options_zoom,
|
&options_zoom,
|
||||||
|
&number_shift,
|
||||||
&button_reset,
|
&button_reset,
|
||||||
&waveform,
|
&waveform,
|
||||||
&waveform2,
|
&waveform2,
|
||||||
@ -63,6 +64,11 @@ ProtoView::ProtoView(NavigationView& nav)
|
|||||||
draw();
|
draw();
|
||||||
draw2();
|
draw2();
|
||||||
};
|
};
|
||||||
|
number_shift.on_change = [this](int32_t value) {
|
||||||
|
waveform_shift = value;
|
||||||
|
draw();
|
||||||
|
draw2();
|
||||||
|
};
|
||||||
button_reset.on_select = [this](Button&) {
|
button_reset.on_select = [this](Button&) {
|
||||||
reset();
|
reset();
|
||||||
};
|
};
|
||||||
@ -74,6 +80,8 @@ ProtoView::ProtoView(NavigationView& nav)
|
|||||||
|
|
||||||
void ProtoView::reset() {
|
void ProtoView::reset() {
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
|
number_shift.set_value(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;
|
||||||
needCntReset = false;
|
needCntReset = false;
|
||||||
draw();
|
draw();
|
||||||
@ -126,9 +134,19 @@ void ProtoView::draw() {
|
|||||||
drawcnt = 0;
|
drawcnt = 0;
|
||||||
for (uint16_t i = 0; i < MAXDRAWCNT; i++) waveform_buffer[i] = 0; // reset
|
for (uint16_t i = 0; i < MAXDRAWCNT; i++) waveform_buffer[i] = 0; // reset
|
||||||
|
|
||||||
for (uint16_t i = 0; i < MAXSIGNALBUFFER; ++i) {
|
// add empty data for padding (so you can shift left/nagetive)
|
||||||
state = time_buffer[i] >= 0;
|
for (int32_t i = 0;
|
||||||
int32_t timeabs = state ? time_buffer[i] : -1 * time_buffer[i];
|
i < ((waveform_shift > 0) ? 0 : -waveform_shift) && drawcnt < MAXDRAWCNT; // this is for shift nagetive (left side)
|
||||||
|
++i) {
|
||||||
|
waveform_buffer[drawcnt++] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t i = ((waveform_shift < 0) ? -waveform_shift : 0); // this is for shift positive aka right side
|
||||||
|
i < MAXSIGNALBUFFER && drawcnt < MAXDRAWCNT; // prevent out of ranging
|
||||||
|
++i) {
|
||||||
|
uint16_t buffer_index = (i + waveform_shift + MAXSIGNALBUFFER) % MAXSIGNALBUFFER;
|
||||||
|
state = time_buffer[buffer_index] >= 0;
|
||||||
|
int32_t timeabs = state ? time_buffer[buffer_index] : -1 * time_buffer[buffer_index];
|
||||||
int32_t timesize = timeabs / zoom;
|
int32_t timesize = timeabs / zoom;
|
||||||
if (timesize == 0) {
|
if (timesize == 0) {
|
||||||
remain += timeabs;
|
remain += timeabs;
|
||||||
@ -145,9 +163,8 @@ void ProtoView::draw() {
|
|||||||
}
|
}
|
||||||
remain = 0;
|
remain = 0;
|
||||||
lmax = 0;
|
lmax = 0;
|
||||||
for (int32_t ii = 0; ii < timesize; ++ii) {
|
for (int32_t ii = 0; ii < timesize && drawcnt < MAXDRAWCNT; ++ii) {
|
||||||
waveform_buffer[drawcnt++] = state;
|
waveform_buffer[drawcnt++] = state;
|
||||||
if (drawcnt >= MAXDRAWCNT) return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
*
|
*
|
||||||
@ -76,7 +75,8 @@ class ProtoView : public View {
|
|||||||
{0 * 8, 0 * 16},
|
{0 * 8, 0 * 16},
|
||||||
nav_};
|
nav_};
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{0 * 8, 1 * 16}, "Zoom: ", Theme::getInstance()->fg_light->foreground}};
|
{{0 * 8, 1 * 16}, "Zoom: ", Theme::getInstance()->fg_light->foreground},
|
||||||
|
{{0 * 8, 2 * 16}, "Shift: ", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
OptionsField options_zoom{
|
OptionsField options_zoom{
|
||||||
{7 * 8, 1 * 16},
|
{7 * 8, 1 * 16},
|
||||||
@ -92,12 +92,19 @@ class ProtoView : public View {
|
|||||||
{"500", 500},
|
{"500", 500},
|
||||||
{"1000", 1000}}};
|
{"1000", 1000}}};
|
||||||
|
|
||||||
|
NumberField number_shift{
|
||||||
|
{7 * 8, 2 * 16},
|
||||||
|
5,
|
||||||
|
{-MAXSIGNALBUFFER, MAXSIGNALBUFFER},
|
||||||
|
1,
|
||||||
|
' '};
|
||||||
|
|
||||||
Button button_reset{
|
Button button_reset{
|
||||||
{screen_width - 12 * 8, 1 * 16, 96, 24},
|
{screen_width - 12 * 8, 1 * 16, 96, 24},
|
||||||
LanguageHelper::currentMessages[LANG_RESET]};
|
LanguageHelper::currentMessages[LANG_RESET]};
|
||||||
|
|
||||||
Waveform waveform{
|
Waveform waveform{
|
||||||
{0, 5 * 8, 240, 50},
|
{0, 8 * 8, 240, 50},
|
||||||
waveform_buffer,
|
waveform_buffer,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -105,7 +112,7 @@ class ProtoView : public View {
|
|||||||
Theme::getInstance()->fg_yellow->foreground};
|
Theme::getInstance()->fg_yellow->foreground};
|
||||||
|
|
||||||
Waveform waveform2{
|
Waveform waveform2{
|
||||||
{0, 5 * 8 + 55, 240, 50},
|
{0, 8 * 8 + 55, 240, 50},
|
||||||
&waveform_buffer[MAXDRAWCNTPERWF],
|
&waveform_buffer[MAXDRAWCNTPERWF],
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -113,7 +120,7 @@ class ProtoView : public View {
|
|||||||
Theme::getInstance()->fg_yellow->foreground};
|
Theme::getInstance()->fg_yellow->foreground};
|
||||||
|
|
||||||
Waveform waveform3{
|
Waveform waveform3{
|
||||||
{0, 5 * 8 + 110, 240, 50},
|
{0, 8 * 8 + 110, 240, 50},
|
||||||
&waveform_buffer[MAXDRAWCNTPERWF * 2],
|
&waveform_buffer[MAXDRAWCNTPERWF * 2],
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -121,7 +128,7 @@ class ProtoView : public View {
|
|||||||
Theme::getInstance()->fg_yellow->foreground};
|
Theme::getInstance()->fg_yellow->foreground};
|
||||||
|
|
||||||
Waveform waveform4{
|
Waveform waveform4{
|
||||||
{0, 5 * 8 + 165, 240, 50},
|
{0, 8 * 8 + 165, 240, 50},
|
||||||
&waveform_buffer[MAXDRAWCNTPERWF * 3],
|
&waveform_buffer[MAXDRAWCNTPERWF * 3],
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -131,6 +138,7 @@ class ProtoView : public View {
|
|||||||
bool needCntReset = false;
|
bool needCntReset = false;
|
||||||
|
|
||||||
int16_t zoom = 1; // one value in ms
|
int16_t zoom = 1; // one value in ms
|
||||||
|
int16_t waveform_shift = 0;
|
||||||
|
|
||||||
uint16_t cnt = 0; // pointer to next element
|
uint16_t cnt = 0; // pointer to next element
|
||||||
uint16_t drawcnt = 0; // pointer to draw next element
|
uint16_t drawcnt = 0; // pointer to draw next element
|
||||||
@ -170,4 +178,4 @@ class ProtoView : public View {
|
|||||||
|
|
||||||
} // namespace ui::external_app::protoview
|
} // namespace ui::external_app::protoview
|
||||||
|
|
||||||
#endif /*__UI_PROTOVIEW_H__*/
|
#endif /*__UI_PROTOVIEW_H__*/
|
Loading…
Reference in New Issue
Block a user