Implement macro menu without keyboard
Adapt UI for radios that do not have a keyboard, add macro menu UI code that can only use KEY_ENTER and KEY_UP, KEY_DOWN. TG-553
This commit is contained in:
parent
5ea94ee1af
commit
3860894bff
|
|
@ -214,6 +214,9 @@ typedef struct ui_state_t
|
||||||
char new_callsign[10];
|
char new_callsign[10];
|
||||||
// Which state to return to when we exit menu
|
// Which state to return to when we exit menu
|
||||||
uint8_t last_main_state;
|
uint8_t last_main_state;
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
uint8_t macro_menu_selected;
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
}
|
}
|
||||||
ui_state_t;
|
ui_state_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ extern void _ui_drawSettingsDisplay(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsM17(ui_state_t* ui_state);
|
extern void _ui_drawSettingsM17(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsVoicePrompts(ui_state_t* ui_state);
|
extern void _ui_drawSettingsVoicePrompts(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state);
|
extern void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state);
|
||||||
extern bool _ui_drawMacroMenu();
|
extern bool _ui_drawMacroMenu(ui_state_t* ui_state);
|
||||||
extern void _ui_reset_menu_anouncement_tracking();
|
extern void _ui_reset_menu_anouncement_tracking();
|
||||||
|
|
||||||
const char *menu_items[] =
|
const char *menu_items[] =
|
||||||
|
|
@ -861,8 +861,26 @@ static bool _ui_exitStandby(long long now)
|
||||||
|
|
||||||
static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
|
static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
|
||||||
{
|
{
|
||||||
|
// If there is no keyboard left and right select the menu entry to edit
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (msg.keys & KNOB_LEFT)
|
||||||
|
{
|
||||||
|
ui_state.macro_menu_selected--;
|
||||||
|
ui_state.macro_menu_selected += 9;
|
||||||
|
ui_state.macro_menu_selected %= 9;
|
||||||
|
}
|
||||||
|
if (msg.keys & KNOB_RIGHT)
|
||||||
|
{
|
||||||
|
ui_state.macro_menu_selected++;
|
||||||
|
ui_state.macro_menu_selected %= 9;
|
||||||
|
}
|
||||||
|
if ((msg.keys & KEY_ENTER) && !msg.long_press)
|
||||||
|
ui_state.input_number = ui_state.macro_menu_selected + 1;
|
||||||
|
else
|
||||||
|
ui_state.input_number = 0;
|
||||||
|
#else // UI_NO_KEYBOARD
|
||||||
ui_state.input_number = input_getPressedNumber(msg);
|
ui_state.input_number = input_getPressedNumber(msg);
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
// CTCSS Encode/Decode Selection
|
// CTCSS Encode/Decode Selection
|
||||||
bool tone_tx_enable = state.channel.fm.txToneEn;
|
bool tone_tx_enable = state.channel.fm.txToneEn;
|
||||||
bool tone_rx_enable = state.channel.fm.rxToneEn;
|
bool tone_rx_enable = state.channel.fm.rxToneEn;
|
||||||
|
|
@ -2257,7 +2275,7 @@ bool ui_updateGUI()
|
||||||
if(macro_menu)
|
if(macro_menu)
|
||||||
{
|
{
|
||||||
_ui_drawDarkOverlay();
|
_ui_drawDarkOverlay();
|
||||||
_ui_drawMacroMenu(&last_state);
|
_ui_drawMacroMenu(&ui_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw_needed = false;
|
redraw_needed = false;
|
||||||
|
|
|
||||||
|
|
@ -896,13 +896,20 @@ void _ui_drawMacroTop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _ui_drawMacroMenu()
|
bool _ui_drawMacroMenu(ui_state_t* ui_state)
|
||||||
{
|
{
|
||||||
// Header
|
// Header
|
||||||
_ui_drawMacroTop();
|
_ui_drawMacroTop();
|
||||||
// First row
|
// First row
|
||||||
if (last_state.channel.mode == OPMODE_FM)
|
if (last_state.channel.mode == OPMODE_FM)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* If we have a keyboard installed draw all numbers, otherwise draw only the
|
||||||
|
* currently selected number.
|
||||||
|
*/
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 0)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||||
yellow_fab413, "1");
|
yellow_fab413, "1");
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||||
|
|
@ -910,6 +917,9 @@ bool _ui_drawMacroMenu()
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||||
color_white, " %7.1f",
|
color_white, " %7.1f",
|
||||||
ctcss_tone[last_state.channel.fm.txTone]/10.0f);
|
ctcss_tone[last_state.channel.fm.txTone]/10.0f);
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 1)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
yellow_fab413, "2");
|
yellow_fab413, "2");
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
|
|
@ -924,6 +934,9 @@ bool _ui_drawMacroMenu()
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
yellow_fab413, "2");
|
yellow_fab413, "2");
|
||||||
}
|
}
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 2)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
yellow_fab413, "3 ");
|
yellow_fab413, "3 ");
|
||||||
if (last_state.channel.mode == OPMODE_FM)
|
if (last_state.channel.mode == OPMODE_FM)
|
||||||
|
|
@ -952,6 +965,9 @@ bool _ui_drawMacroMenu()
|
||||||
// Calculate symmetric second row position, line2_pos is asymmetric like main screen
|
// Calculate symmetric second row position, line2_pos is asymmetric like main screen
|
||||||
point_t pos_2 = {layout.line1_pos.x, layout.line1_pos.y +
|
point_t pos_2 = {layout.line1_pos.x, layout.line1_pos.y +
|
||||||
(layout.line3_large_pos.y - layout.line1_pos.y)/2};
|
(layout.line3_large_pos.y - layout.line1_pos.y)/2};
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 3)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_LEFT,
|
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_LEFT,
|
||||||
yellow_fab413, "4");
|
yellow_fab413, "4");
|
||||||
if (last_state.channel.mode == OPMODE_FM)
|
if (last_state.channel.mode == OPMODE_FM)
|
||||||
|
|
@ -978,6 +994,9 @@ bool _ui_drawMacroMenu()
|
||||||
color_white, " ");
|
color_white, " ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 4)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
yellow_fab413, "5");
|
yellow_fab413, "5");
|
||||||
char mode_str[12] = "";
|
char mode_str[12] = "";
|
||||||
|
|
@ -995,11 +1014,17 @@ bool _ui_drawMacroMenu()
|
||||||
}
|
}
|
||||||
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
color_white, mode_str);
|
color_white, mode_str);
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 5)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
yellow_fab413, "6 ");
|
yellow_fab413, "6 ");
|
||||||
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
color_white, "%.1gW", dBmToWatt(last_state.channel.power));
|
color_white, "%.1gW", dBmToWatt(last_state.channel.power));
|
||||||
// Third row
|
// Third row
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 6)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||||
yellow_fab413, "7");
|
yellow_fab413, "7");
|
||||||
#ifdef SCREEN_BRIGHTNESS
|
#ifdef SCREEN_BRIGHTNESS
|
||||||
|
|
@ -1009,12 +1034,18 @@ bool _ui_drawMacroMenu()
|
||||||
color_white, " %5d",
|
color_white, " %5d",
|
||||||
state.settings.brightness);
|
state.settings.brightness);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 7)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
yellow_fab413, "8");
|
yellow_fab413, "8");
|
||||||
#ifdef SCREEN_BRIGHTNESS
|
#ifdef SCREEN_BRIGHTNESS
|
||||||
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||||
color_white, " B+");
|
color_white, " B+");
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(UI_NO_KEYBOARD)
|
||||||
|
if (ui_state->macro_menu_selected == 8)
|
||||||
|
#endif // UI_NO_KEYBOARD
|
||||||
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
yellow_fab413, "9 ");
|
yellow_fab413, "9 ");
|
||||||
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(layout.line3_large_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ extern void _ui_drawSettingsDisplay(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsM17(ui_state_t* ui_state);
|
extern void _ui_drawSettingsM17(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsModule17(ui_state_t* ui_state);
|
extern void _ui_drawSettingsModule17(ui_state_t* ui_state);
|
||||||
extern void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state);
|
extern void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state);
|
||||||
extern bool _ui_drawMacroMenu();
|
extern bool _ui_drawMacroMenu(ui_state_t* ui_state);
|
||||||
|
|
||||||
const char *menu_items[] =
|
const char *menu_items[] =
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue