mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-08 14:42:33 -04:00
ui new coord system examples and macros (#2672)
This commit is contained in:
parent
aa1264cf91
commit
2602c417be
4 changed files with 57 additions and 32 deletions
|
@ -131,7 +131,7 @@ void NoaaAptRxView::on_status(NoaaAptRxStatusDataMessage msg) {
|
||||||
|
|
||||||
// this stores and displays the image. keep it as simple as you can. a bit more complexity will kill the sync
|
// this stores and displays the image. keep it as simple as you can. a bit more complexity will kill the sync
|
||||||
void NoaaAptRxView::on_image(NoaaAptRxImageDataMessage msg) {
|
void NoaaAptRxView::on_image(NoaaAptRxImageDataMessage msg) {
|
||||||
if ((line_num) >= screen_height - NOAA_IMG_START_ROW * 16) line_num = 0; // for draw reset
|
if ((line_num) >= UI_POS_HEIGHT_REMAINING(NOAA_IMG_START_ROW)) line_num = 0; // for draw reset
|
||||||
|
|
||||||
for (uint16_t i = 0; i < msg.cnt; i += 1) {
|
for (uint16_t i = 0; i < msg.cnt; i += 1) {
|
||||||
Color pxl = {msg.image[i], msg.image[i], msg.image[i]};
|
Color pxl = {msg.image[i], msg.image[i], msg.image[i]};
|
||||||
|
|
|
@ -81,22 +81,22 @@ class NoaaAptRxView : public View {
|
||||||
{}};
|
{}};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{UI_POS_X(13), UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{UI_POS_X(15), UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(21), UI_POS_Y(0), UI_POS_WIDTH(6), 4}};
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
RecordView record_view{
|
RecordView record_view{
|
||||||
{0 * 8, 2 * 16, screen_width, 1 * 16},
|
{UI_POS_X(0), UI_POS_Y(2), UI_POS_MAXWIDTH, UI_POS_DEFAULT_HEIGHT},
|
||||||
u"AUD",
|
u"AUD",
|
||||||
u"AUDIO",
|
u"AUDIO",
|
||||||
RecordView::FileType::WAV,
|
RecordView::FileType::WAV,
|
||||||
|
@ -104,22 +104,17 @@ class NoaaAptRxView : public View {
|
||||||
4};
|
4};
|
||||||
|
|
||||||
Checkbox check_wav{
|
Checkbox check_wav{
|
||||||
{0 * 8, 2 * 16},
|
{UI_POS_X(0), UI_POS_Y(2)},
|
||||||
12,
|
12,
|
||||||
"Save WAV too",
|
"Save WAV too",
|
||||||
true};
|
true};
|
||||||
|
|
||||||
/*Labels labels{
|
|
||||||
{{1 * 8, 1 * 16}, "LPM:", Theme::getInstance()->fg_light->foreground},
|
|
||||||
{{13 * 8, 1 * 16}, "IOC:", Theme::getInstance()->fg_light->foreground},
|
|
||||||
};*/
|
|
||||||
|
|
||||||
Text txt_status{
|
Text txt_status{
|
||||||
{0 * 8, 1 * 16, 20 * 8, 16},
|
{UI_POS_X(0), UI_POS_Y(1), UI_POS_WIDTH(20), UI_POS_DEFAULT_HEIGHT},
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_ss{
|
Button button_ss{
|
||||||
{190, 1 * 16, 5 * 8, 16},
|
{UI_POS_X_RIGHT(6), UI_POS_Y(1), UI_POS_WIDTH(5), UI_POS_DEFAULT_HEIGHT},
|
||||||
LanguageHelper::currentMessages[LANG_START]};
|
LanguageHelper::currentMessages[LANG_START]};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_stats{
|
MessageHandlerRegistration message_handler_stats{
|
||||||
|
|
|
@ -60,29 +60,29 @@ class ProtoView : public View {
|
||||||
"rx_protoview", app_settings::Mode::RX};
|
"rx_protoview", app_settings::Mode::RX};
|
||||||
|
|
||||||
RFAmpField field_rf_amp{
|
RFAmpField field_rf_amp{
|
||||||
{13 * 8, 0 * 16}};
|
{UI_POS_X(13), UI_POS_Y(0)}};
|
||||||
LNAGainField field_lna{
|
LNAGainField field_lna{
|
||||||
{15 * 8, 0 * 16}};
|
{UI_POS_X(15), UI_POS_Y(0)}};
|
||||||
VGAGainField field_vga{
|
VGAGainField field_vga{
|
||||||
{18 * 8, 0 * 16}};
|
{UI_POS_X(18), UI_POS_Y(0)}};
|
||||||
RSSI rssi{
|
RSSI rssi{
|
||||||
{21 * 8, 0, 6 * 8, 4}};
|
{UI_POS_X(21), UI_POS_Y(0), UI_POS_WIDTH(6), 4}};
|
||||||
|
|
||||||
AudioVolumeField field_volume{
|
AudioVolumeField field_volume{
|
||||||
{screen_width - 2 * 8, 0 * 16}};
|
{UI_POS_X_RIGHT(2), UI_POS_Y(0)}};
|
||||||
|
|
||||||
RxFrequencyField field_frequency{
|
RxFrequencyField field_frequency{
|
||||||
{0 * 8, 0 * 16},
|
{UI_POS_X(0), UI_POS_Y(0)},
|
||||||
nav_};
|
nav_};
|
||||||
|
|
||||||
// need to seperate because label shift need to hide independently
|
// need to seperate because label shift need to hide independently
|
||||||
Labels label_zoom{
|
Labels label_zoom{
|
||||||
{{0 * 8, 1 * 16}, "Zoom: ", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(1)}, "Zoom: ", Theme::getInstance()->fg_light->foreground}};
|
||||||
Labels label_shift{
|
Labels label_shift{
|
||||||
{{0 * 8, 2 * 16}, "Shift: ", Theme::getInstance()->fg_light->foreground}};
|
{{UI_POS_X(0), UI_POS_Y(2)}, "Shift: ", Theme::getInstance()->fg_light->foreground}};
|
||||||
|
|
||||||
OptionsField options_zoom{
|
OptionsField options_zoom{
|
||||||
{7 * 8, 1 * 16},
|
{UI_POS_X(7), UI_POS_Y(1)},
|
||||||
4,
|
4,
|
||||||
{{"1", 1},
|
{{"1", 1},
|
||||||
{"2", 2},
|
{"2", 2},
|
||||||
|
@ -96,22 +96,22 @@ class ProtoView : public View {
|
||||||
{"1000", 1000}}};
|
{"1000", 1000}}};
|
||||||
|
|
||||||
NumberField number_shift{
|
NumberField number_shift{
|
||||||
{7 * 8, 2 * 16},
|
{UI_POS_X(7), UI_POS_Y(2)},
|
||||||
5,
|
5,
|
||||||
{-MAXSIGNALBUFFER, MAXSIGNALBUFFER},
|
{-MAXSIGNALBUFFER, MAXSIGNALBUFFER},
|
||||||
1,
|
1,
|
||||||
' '};
|
' '};
|
||||||
|
|
||||||
Button button_reset{
|
Button button_reset{
|
||||||
{screen_width - 12 * 8, 1 * 16, 96, 24},
|
{UI_POS_X_RIGHT(12), UI_POS_Y(1), UI_POS_WIDTH(12), UI_POS_HEIGHT(1.5)},
|
||||||
LanguageHelper::currentMessages[LANG_RESET]};
|
LanguageHelper::currentMessages[LANG_RESET]};
|
||||||
|
|
||||||
Button button_pause{
|
Button button_pause{
|
||||||
{screen_width - 12 * 8, 1 * 16 + 24, 96, 24},
|
{UI_POS_X_RIGHT(12), UI_POS_Y(2.5), UI_POS_WIDTH(12), UI_POS_HEIGHT(1.5)},
|
||||||
LanguageHelper::currentMessages[LANG_PAUSE]};
|
LanguageHelper::currentMessages[LANG_PAUSE]};
|
||||||
|
|
||||||
Waveform waveform{
|
Waveform waveform{
|
||||||
{0, 8 * 8, screen_width, 50},
|
{UI_POS_X(0), UI_POS_Y(4), UI_POS_MAXWIDTH, (UI_POS_HEIGHT_REMAINING(5) / 4) - 4},
|
||||||
waveform_buffer,
|
waveform_buffer,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -119,7 +119,7 @@ class ProtoView : public View {
|
||||||
Theme::getInstance()->fg_yellow->foreground};
|
Theme::getInstance()->fg_yellow->foreground};
|
||||||
|
|
||||||
Waveform waveform2{
|
Waveform waveform2{
|
||||||
{0, 8 * 8 + 55, screen_width, 50},
|
{UI_POS_X(0), UI_POS_Y(4) + (UI_POS_HEIGHT_REMAINING(5) / 4), UI_POS_MAXWIDTH, (UI_POS_HEIGHT_REMAINING(5) / 4) - 4},
|
||||||
&waveform_buffer[MAXDRAWCNTPERWF],
|
&waveform_buffer[MAXDRAWCNTPERWF],
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -127,7 +127,7 @@ class ProtoView : public View {
|
||||||
Theme::getInstance()->fg_yellow->foreground};
|
Theme::getInstance()->fg_yellow->foreground};
|
||||||
|
|
||||||
Waveform waveform3{
|
Waveform waveform3{
|
||||||
{0, 8 * 8 + 110, screen_width, 50},
|
{UI_POS_X(0), UI_POS_Y(4) + 2 * (UI_POS_HEIGHT_REMAINING(5) / 4), UI_POS_MAXWIDTH, (UI_POS_HEIGHT_REMAINING(5) / 4) - 4},
|
||||||
&waveform_buffer[MAXDRAWCNTPERWF * 2],
|
&waveform_buffer[MAXDRAWCNTPERWF * 2],
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -135,7 +135,7 @@ class ProtoView : public View {
|
||||||
Theme::getInstance()->fg_yellow->foreground};
|
Theme::getInstance()->fg_yellow->foreground};
|
||||||
|
|
||||||
Waveform waveform4{
|
Waveform waveform4{
|
||||||
{0, 8 * 8 + 165, screen_width, 50},
|
{UI_POS_X(0), UI_POS_Y(4) + 3 * (UI_POS_HEIGHT_REMAINING(5) / 4), UI_POS_MAXWIDTH, (UI_POS_HEIGHT_REMAINING(5) / 4) - 4},
|
||||||
&waveform_buffer[MAXDRAWCNTPERWF * 3],
|
&waveform_buffer[MAXDRAWCNTPERWF * 3],
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -26,6 +26,36 @@
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
|
// Positioning helpers PER CHARACTERS (8*16)
|
||||||
|
// EACH parameters must be used az CHAR position, not PX coordinates. So If you wanna use the 8,16 coordinates (that is the second character in X and second character in Y you must use UI_POS_X(1) UI_POS_Y(1) (since we count from 0)
|
||||||
|
|
||||||
|
// default font height
|
||||||
|
#define UI_POS_DEFAULT_HEIGHT 16
|
||||||
|
// default font width
|
||||||
|
#define UI_POS_DEFAULT_WIDTH 8
|
||||||
|
// px position of the linenum-th character (Y)
|
||||||
|
#define UI_POS_Y(linenum) ((int)((linenum)*UI_POS_DEFAULT_HEIGHT))
|
||||||
|
// px position of the linenum-th character from the bottom of the screen (Y) (please calculate the +1 line top-bar to it too if that is visible!)
|
||||||
|
#define UI_POS_Y_BOTTOM(linenum) ((int)(screen_height - (linenum)*UI_POS_DEFAULT_HEIGHT))
|
||||||
|
// px position of the linenum-th character from the left of the screen (X)
|
||||||
|
#define UI_POS_X(charnum) ((int)((charnum)*UI_POS_DEFAULT_WIDTH))
|
||||||
|
// px position of the linenum-th character from the right of the screen (X)
|
||||||
|
#define UI_POS_X_RIGHT(charnum) ((int)(screen_width - ((charnum)*UI_POS_DEFAULT_WIDTH)))
|
||||||
|
// px position of the left character from the center of the screen (X) (for N character wide string)
|
||||||
|
#define UI_POS_X_CENTER(charnum) ((int)((screen_width / 2) - ((charnum)*UI_POS_DEFAULT_WIDTH / 2)))
|
||||||
|
// px width of N characters
|
||||||
|
#define UI_POS_WIDTH(charnum) ((int)((charnum)*UI_POS_DEFAULT_WIDTH))
|
||||||
|
// px width of the screen
|
||||||
|
#define UI_POS_MAXWIDTH (screen_width)
|
||||||
|
// px height of N line
|
||||||
|
#define UI_POS_HEIGHT(linecount) ((int)((linecount)*UI_POS_DEFAULT_HEIGHT))
|
||||||
|
// px height of the screen's percent
|
||||||
|
#define UI_POS_HEIGHT_PERCENT(percent) ((int)(screen_height * (percent) / 100))
|
||||||
|
// remaining px from the linenum-th line to the bottom of the screen. (please calculate the +1 line top-bar to it too if that is visible!)
|
||||||
|
#define UI_POS_HEIGHT_REMAINING(linenum) ((int)(screen_height - ((linenum)*UI_POS_DEFAULT_HEIGHT)))
|
||||||
|
// remaining px from the charnum-th character to the right of the screen
|
||||||
|
#define UI_POS_WIDTH_REMAINING(charnum) ((int)(screen_width - ((charnum)*UI_POS_DEFAULT_WIDTH)))
|
||||||
|
|
||||||
// Escape sequences for colored text; second character is index into term_colors[]
|
// Escape sequences for colored text; second character is index into term_colors[]
|
||||||
#define STR_COLOR_BLACK "\x1B\x00"
|
#define STR_COLOR_BLACK "\x1B\x00"
|
||||||
#define STR_COLOR_DARK_BLUE "\x1B\x01"
|
#define STR_COLOR_DARK_BLUE "\x1B\x01"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue