Add destination callsign input for M17, Add -/ to keypad input

This commit is contained in:
Federico Amedeo Izzo 2021-10-09 18:35:42 +02:00 committed by silseva
parent 70b37b7f81
commit 1e19574fd6
5 changed files with 166 additions and 41 deletions

View File

@ -73,9 +73,9 @@ static const uint16_t kbd_long_interval = TICK_FREQ * 0.7;
/** /**
* Mask for the numeric keys in a key map * Mask for the numeric keys in a key map
* Numeric keys: bit0->bit9 = 0x3FF * Numeric keys: bit0->bit11 = 0xFFF
*/ */
static const uint32_t kbd_num_mask = 0x3FF; static const uint32_t kbd_num_mask = 0xFFF;
/** /**
* Structure that represents a keyboard event payload * Structure that represents a keyboard event payload

View File

@ -66,6 +66,7 @@ gps_t;
typedef struct typedef struct
{ {
char callsign[10]; char callsign[10];
char dst_addr[10];
} }
m17_t; m17_t;

View File

@ -106,7 +106,7 @@ void *ui_task(void *arg)
// Copy new M17 source and destination addresses // Copy new M17 source and destination addresses
strncpy(rtx_cfg.source_address, state.m17_data.callsign, 10); strncpy(rtx_cfg.source_address, state.m17_data.callsign, 10);
strncpy(rtx_cfg.destination_address, "", 10); strncpy(rtx_cfg.destination_address, state.m17_data.dst_addr, 10);
rtx_configure(&rtx_cfg); rtx_configure(&rtx_cfg);
sync_rtx = false; sync_rtx = false;

View File

@ -183,7 +183,7 @@ const char *symbols_ITU_T_E161[] =
"pqrs7PQRS", "pqrs7PQRS",
"tuv8TUV", "tuv8TUV",
"wxyz9WXYZ", "wxyz9WXYZ",
"*", "-/*",
"#" "#"
}; };
@ -199,7 +199,7 @@ const char *symbols_ITU_T_E161_callsign[] =
"PQRS7", "PQRS7",
"TUV8", "TUV8",
"WXYZ9", "WXYZ9",
"", "-/",
"" ""
}; };
@ -973,6 +973,11 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
// Switch to VFO screen // Switch to VFO screen
state.ui_screen = MAIN_VFO; state.ui_screen = MAIN_VFO;
} }
else if(msg.keys & KEY_F1)
{
// Switch to Digital Mode MEM screen
state.ui_screen = MODE_MEM;
}
else if(msg.keys & KEY_UP || msg.keys & KNOB_RIGHT) else if(msg.keys & KEY_UP || msg.keys & KNOB_RIGHT)
{ {
_ui_fsm_loadChannel(state.channel_index + 1, sync_rtx); _ui_fsm_loadChannel(state.channel_index + 1, sync_rtx);
@ -984,42 +989,152 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
break; break;
// Digital Mode VFO screen // Digital Mode VFO screen
case MODE_VFO: case MODE_VFO:
if(msg.keys & KEY_ENTER) if(state.channel.mode == M17)
{ {
// Save current main state // Dst ID input
ui_state.last_main_state = state.ui_screen; if(ui_state.edit_mode)
// Open Menu {
state.ui_screen = MENU_TOP; if(msg.keys & KEY_ENTER)
{
_ui_textInputConfirm(ui_state.new_callsign);
// Save selected dst ID and disable input mode
strncpy(state.m17_data.dst_addr, ui_state.new_callsign, 10);
ui_state.edit_mode = false;
*sync_rtx = true;
}
else if(msg.keys & KEY_ESC)
// Discard selected dst ID 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)
_ui_textInputDel(ui_state.new_callsign);
else if(input_isNumberPressed(msg))
_ui_textInputKeypad(ui_state.new_callsign, 9, msg, true);
}
else
{
if(msg.keys & KEY_ENTER)
{
// Save current main state
ui_state.last_main_state = state.ui_screen;
// Open Menu
state.ui_screen = MENU_TOP;
}
else if(msg.keys & KEY_ESC)
{
// Switch to VFO screen
state.ui_screen = MAIN_VFO;
}
else if(msg.keys & KEY_F1)
{
// Switch to Main VFO screen
state.ui_screen = MAIN_VFO;
}
else if(input_isNumberPressed(msg))
{
// Enable dst ID input
ui_state.edit_mode = true;
// Reset text input variables
_ui_textInputReset(ui_state.new_callsign);
// Type first character
_ui_textInputKeypad(ui_state.new_callsign, 9, msg, true);
}
}
} }
else if(msg.keys & KEY_ESC) else
{ {
// Switch to VFO screen if(msg.keys & KEY_ENTER)
state.ui_screen = MAIN_VFO; {
} // Save current main state
else if(msg.keys & KEY_F1) ui_state.last_main_state = state.ui_screen;
{ // Open Menu
// Switch to Main VFO screen state.ui_screen = MENU_TOP;
state.ui_screen = MAIN_VFO; }
else if(msg.keys & KEY_ESC)
{
// Switch to VFO screen
state.ui_screen = MAIN_VFO;
}
else if(msg.keys & KEY_F1)
{
// Switch to Main VFO screen
state.ui_screen = MAIN_VFO;
}
} }
break; break;
// Digital Mode MEM screen // Digital Mode MEM screen
case MODE_MEM: case MODE_MEM:
if(msg.keys & KEY_ENTER) if(state.channel.mode == M17)
{ {
// Save current main state // Dst ID input
ui_state.last_main_state = state.ui_screen; if(ui_state.edit_mode)
// Open Menu {
state.ui_screen = MENU_TOP; if(msg.keys & KEY_ENTER)
{
_ui_textInputConfirm(ui_state.new_callsign);
// Save selected dst ID and disable input mode
strncpy(state.m17_data.dst_addr, ui_state.new_callsign, 10);
ui_state.edit_mode = false;
*sync_rtx = true;
}
else if(msg.keys & KEY_ESC)
// Discard selected dst ID 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)
_ui_textInputDel(ui_state.new_callsign);
else if(input_isNumberPressed(msg))
_ui_textInputKeypad(ui_state.new_callsign, 9, msg, true);
}
else
{
if(msg.keys & KEY_ENTER)
{
// Save current main state
ui_state.last_main_state = state.ui_screen;
// Open Menu
state.ui_screen = MENU_TOP;
}
else if(msg.keys & KEY_ESC)
{
// Switch to MEM screen
state.ui_screen = MAIN_MEM;
}
else if(msg.keys & KEY_F1)
{
// Switch to Main MEM screen
state.ui_screen = MAIN_MEM;
}
else if(input_isNumberPressed(msg))
{
// Enable dst ID input
ui_state.edit_mode = true;
// Reset text input variables
_ui_textInputReset(ui_state.new_callsign);
// Type first character
_ui_textInputKeypad(ui_state.new_callsign, 9, msg, true);
}
}
} }
else if(msg.keys & KEY_ESC) else
{ {
// Switch to MEM screen if(msg.keys & KEY_ENTER)
state.ui_screen = MAIN_MEM; {
} // Save current main state
else if(msg.keys & KEY_F1) ui_state.last_main_state = state.ui_screen;
{ // Open Menu
// Switch to Main MEM screen state.ui_screen = MENU_TOP;
state.ui_screen = MAIN_MEM; }
else if(msg.keys & KEY_ESC)
{
// Switch to MEM screen
state.ui_screen = MAIN_MEM;
}
else if(msg.keys & KEY_F1)
{
// Switch to Main MEM screen
state.ui_screen = MAIN_MEM;
}
} }
break; break;
// Top menu screen // Top menu screen
@ -1387,11 +1502,11 @@ void ui_updateGUI()
break; break;
// Digital Mode VFO screen // Digital Mode VFO screen
case MODE_VFO: case MODE_VFO:
_ui_drawModeVFO(); _ui_drawModeVFO(&ui_state);
break; break;
// Digital Mode MEM screen // Digital Mode MEM screen
case MODE_MEM: case MODE_MEM:
_ui_drawModeMEM(); _ui_drawModeMEM(&ui_state);
break; break;
// Top menu screen // Top menu screen
case MENU_TOP: case MENU_TOP:

View File

@ -47,7 +47,7 @@ void _ui_drawMEMChannel()
last_state.channel_index, last_state.channel.name); last_state.channel_index, last_state.channel.name);
} }
void _ui_drawModeDetails() void _ui_drawModeDetails(ui_state_t* ui_state)
{ {
char bw_str[8] = { 0 }; char bw_str[8] = { 0 };
char encdec_str[9] = { 0 }; char encdec_str[9] = { 0 };
@ -103,27 +103,36 @@ void _ui_drawModeDetails()
layout.horizontal_pad, layout.mode_font_small, layout.horizontal_pad, layout.mode_font_small,
TEXT_ALIGN_LEFT, color_white, "Src ID: %s", cfg.source_address); TEXT_ALIGN_LEFT, color_white, "Src ID: %s", cfg.source_address);
// Print M17 Destination ID on line 3 of 3 // Print M17 Destination ID on line 3 of 3
gfx_printLine(3, 3, layout.top_h, SCREEN_HEIGHT - layout.bottom_h, if(ui_state->edit_mode)
layout.horizontal_pad, layout.mode_font_small, {
TEXT_ALIGN_LEFT, color_white, "Dst ID: %s", cfg.destination_address); gfx_printLine(3, 3, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.mode_font_small,
TEXT_ALIGN_LEFT, color_white, "Dst ID: %s_", ui_state->new_callsign);
}
else
{
gfx_printLine(3, 3, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.mode_font_small,
TEXT_ALIGN_LEFT, color_white, "Dst ID: %s", cfg.destination_address);
}
break; break;
} }
} }
void _ui_drawModeVFO() void _ui_drawModeVFO(ui_state_t* ui_state)
{ {
gfx_clearScreen(); gfx_clearScreen();
_ui_drawMainTop(); _ui_drawMainTop();
_ui_drawModeVFOFreq(); _ui_drawModeVFOFreq();
_ui_drawModeDetails(); _ui_drawModeDetails(ui_state);
_ui_drawMainBottom(); _ui_drawMainBottom();
} }
void _ui_drawModeMEM() void _ui_drawModeMEM(ui_state_t* ui_state)
{ {
gfx_clearScreen(); gfx_clearScreen();
_ui_drawMainTop(); _ui_drawMainTop();
_ui_drawMEMChannel(); _ui_drawMEMChannel();
_ui_drawModeDetails(); _ui_drawModeDetails(ui_state);
_ui_drawMainBottom(); _ui_drawMainBottom();
} }