Module17 UI: small improvements to callsign input

pull/139/head
Silvano Seva 2023-05-27 10:05:00 +02:00
rodzic 40b82e3169
commit f038603bed
2 zmienionych plików z 21 dodań i 24 usunięć

Wyświetl plik

@ -173,7 +173,7 @@ static const char *symbols_ITU_T_E161_callsign[] =
""
};
static const char symbols_callsign[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/- ";
static const char symbols_callsign[] = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/- ";
// Calculate number of menu entries
const uint8_t menu_num = sizeof(menu_items)/sizeof(menu_items[0]);
@ -671,7 +671,6 @@ void _ui_textInputReset(char *buf)
ui_state.input_set = 0;
ui_state.last_keypress = 0;
memset(buf, 0, 9);
buf[0] = '_';
}
void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, bool callsign)
@ -727,7 +726,10 @@ void _ui_textInputArrows(char *buf, uint8_t max_len, kbd_msg_t msg)
ui_state.input_set = 0;
}
else if (msg.keys & KEY_LEFT)
{
ui_state.input_position = (ui_state.input_position - 1) % max_len;
ui_state.input_set = 0;
}
else if (msg.keys & KEY_UP)
ui_state.input_set = (ui_state.input_set + 1) % num_symbols;
else if (msg.keys & KEY_DOWN)
@ -929,14 +931,13 @@ void ui_updateFSM(bool *sync_rtx)
ui_state.edit_mode = false;
}
else if(msg.keys & KEY_ESC)
// Discard selected callsign and disable input mode
ui_state.edit_mode = false;
else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN ||
msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT)
else
_ui_textInputArrows(ui_state.new_callsign, 9, msg);
}
else
{
// Not in edit mode: handle CAN setting
if(msg.keys & KEY_LEFT)
{
switch(ui_state.menu_selected)
@ -963,10 +964,9 @@ void ui_updateFSM(bool *sync_rtx)
{
switch(ui_state.menu_selected)
{
// Enable callsign input
case M_CALLSIGN:
// Enable callsign input
ui_state.edit_mode = true;
// Reset text input variables
_ui_textInputReset(ui_state.new_callsign);
break;
default:

Wyświetl plik

@ -542,33 +542,30 @@ void _ui_drawSettingsTimeDateSet(ui_state_t* ui_state)
void _ui_drawSettingsM17(ui_state_t* ui_state)
{
gfx_clearScreen();
// Print "M17 Settings" on top bar
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
color_white, "M17 Settings");
/* gfx_printLine(1, 4, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.menu_font,
TEXT_ALIGN_LEFT, color_white, "Callsign:"); */
_ui_drawMenuListValue(ui_state, ui_state->menu_selected, _ui_getM17EntryName,
_ui_getM17ValueName);
if(ui_state->edit_mode)
{
uint16_t rect_width = SCREEN_WIDTH - (layout.horizontal_pad * 2);
uint16_t rect_height = (SCREEN_HEIGHT - (layout.top_h + layout.bottom_h))/2;
point_t rect_origin = {(SCREEN_WIDTH - rect_width) / 2,
(SCREEN_HEIGHT - rect_height) / 2};
gfx_drawRect(rect_origin, rect_width, rect_height, color_white, false);
gfx_printLine(1, 4, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.menu_font,
TEXT_ALIGN_LEFT, color_white, "Callsign:");
// uint16_t rect_width = SCREEN_WIDTH - (layout.horizontal_pad * 2);
// uint16_t rect_height = (SCREEN_HEIGHT - (layout.top_h + layout.bottom_h))/2;
// point_t rect_origin = {(SCREEN_WIDTH - rect_width) / 2,
// (SCREEN_HEIGHT - rect_height) / 2};
// gfx_drawRect(rect_origin, rect_width, rect_height, color_white, false);
// Print M17 callsign being typed
gfx_printLine(1, 1, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.input_font,
TEXT_ALIGN_CENTER, color_white, ui_state->new_callsign);
}
/*else
else
{
// Print M17 current callsign
gfx_printLine(1, 1, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.input_font,
TEXT_ALIGN_CENTER, color_white, last_state.settings.callsign);
}*/
_ui_drawMenuListValue(ui_state, ui_state->menu_selected, _ui_getM17EntryName,
_ui_getM17ValueName);
}
}
void _ui_drawSettingsModule17(ui_state_t* ui_state)