From a612e885abe04a2fa86f083d95da3852cd768149 Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Sat, 30 Jan 2021 11:57:00 +0100 Subject: [PATCH] UI: Add about screen --- openrtx/include/ui.h | 7 +++++- openrtx/src/main.c | 2 +- openrtx/src/ui/ui.c | 47 ++++++++++++++++++++++++++++++++++------ openrtx/src/ui/ui_menu.c | 15 +++++++++++++ 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/openrtx/include/ui.h b/openrtx/include/ui.h index 9777a3c6..d2eff89c 100644 --- a/openrtx/include/ui.h +++ b/openrtx/include/ui.h @@ -50,6 +50,7 @@ enum uiScreen MENU_MACRO, MENU_SETTINGS, MENU_INFO, + MENU_ABOUT, SETTINGS_TIMEDATE, SETTINGS_TIMEDATE_SET, SETTINGS_DISPLAY, @@ -128,10 +129,12 @@ extern const char *menu_items[]; extern const char *settings_items[]; extern const char *display_items[]; extern const char *info_items[]; +extern const char *authors[]; extern const uint8_t menu_num; extern const uint8_t settings_num; extern const uint8_t display_num; extern const uint8_t info_num; +extern const uint8_t author_num; extern const color_t color_black; extern const color_t color_grey; extern const color_t color_white; @@ -145,8 +148,10 @@ void ui_init(); /** * This function writes the OpenRTX splash screen image into the framebuffer. + * @param centered: if true the logo will be printed at the center of + * the screen, otherwise it will be printed at the top of the screen. */ -void ui_drawSplashScreen(); +void ui_drawSplashScreen(bool centered); /** * This function updates the local copy of the radio state diff --git a/openrtx/src/main.c b/openrtx/src/main.c index d51bb76d..5915cd5e 100644 --- a/openrtx/src/main.c +++ b/openrtx/src/main.c @@ -42,7 +42,7 @@ int main(void) ui_init(); // Display splash screen - ui_drawSplashScreen(); + ui_drawSplashScreen(true); gfx_render(); // Wait 30ms before turning on backlight to hide random pixels on screen diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 4af10806..b541b29b 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -93,6 +93,7 @@ extern void _ui_drawMenuChannel(ui_state_t* ui_state); extern void _ui_drawMenuContacts(ui_state_t* ui_state); extern void _ui_drawMenuSettings(ui_state_t* ui_state); extern void _ui_drawMenuInfo(ui_state_t* ui_state); +extern void _ui_drawMenuAbout(ui_state_t* ui_state); #ifdef HAS_RTC extern void _ui_drawSettingsTimeDate(); extern void _ui_drawSettingsTimeDateSet(ui_state_t* ui_state); @@ -100,7 +101,7 @@ extern void _ui_drawSettingsTimeDateSet(ui_state_t* ui_state); extern void _ui_drawSettingsDisplay(ui_state_t* ui_state); extern bool _ui_drawMacroMenu(); -const char *menu_items[7] = +const char *menu_items[8] = { "Zone", "Channels", @@ -108,7 +109,8 @@ const char *menu_items[7] = "Messages", "GPS", "Settings", - "Info" + "Info", + "About" }; #ifdef HAS_RTC @@ -143,7 +145,13 @@ const char *info_items[4] = "Bat. Charge", "RSSI", }; - +const char *authors[4] = +{ + "Niccolo' IU2KIN", + "Silvano IU2KWO", + "Federico IU2NUO", + "Fred IU2NRO", +}; // Calculate number of main menu entries const uint8_t menu_num = sizeof(menu_items)/sizeof(menu_items[0]); // Calculate number of settings menu entries @@ -152,6 +160,8 @@ const uint8_t settings_num = sizeof(settings_items)/sizeof(settings_items[0]); const uint8_t display_num = sizeof(display_items)/sizeof(display_items[0]); // Calculate number of info menu entries const uint8_t info_num = sizeof(info_items)/sizeof(info_items[0]); +// Calculate number of authors +const uint8_t author_num = sizeof(authors)/sizeof(authors[0]); const color_t color_black = {0, 0, 0, 255}; const color_t color_grey = {60, 60, 60, 255}; @@ -303,16 +313,22 @@ void ui_init() settings.contrast = 84; } -void ui_drawSplashScreen() +void ui_drawSplashScreen(bool centered) { gfx_clearScreen(); - + point_t splash_origin = {0,0}; #ifdef OLD_SPLASH - point_t splash_origin = {0, SCREEN_HEIGHT / 2 + 6}; + if(centered) + splash_origin.y = SCREEN_HEIGHT / 2 + 6; + else + splash_origin.y = SCREEN_HEIGHT / 4; gfx_print(splash_origin, "OpenRTX", FONT_SIZE_12PT, TEXT_ALIGN_CENTER, yellow_fab413); #else - point_t splash_origin = {0, SCREEN_HEIGHT / 2 - 6}; + if(centered) + splash_origin.y = SCREEN_HEIGHT / 2 - 6; + else + splash_origin.y = SCREEN_HEIGHT / 5; gfx_print(splash_origin, "O P N\nR T X", FONT_SIZE_12PT, TEXT_ALIGN_CENTER, yellow_fab413); #endif @@ -797,6 +813,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx) case 6: state.ui_screen = MENU_INFO; break; + case 7: + state.ui_screen = MENU_ABOUT; + break; default: state.ui_screen = MENU_TOP; } @@ -950,6 +969,16 @@ void ui_updateFSM(event_t event, bool *sync_rtx) ui_state.menu_selected = 0; } break; + // About screen + case MENU_ABOUT: + if(msg.keys & KEY_ESC) + { + // Return to top menu + state.ui_screen = MENU_TOP; + // Reset menu selection + ui_state.menu_selected = 0; + } + break; #ifdef HAS_RTC // Time&Date settings screen case SETTINGS_TIMEDATE: @@ -1095,6 +1124,10 @@ void ui_updateGUI() case MENU_INFO: _ui_drawMenuInfo(&ui_state); break; + // About menu screen + case MENU_ABOUT: + _ui_drawMenuAbout(&ui_state); + break; #ifdef HAS_RTC // Time&Date settings screen case SETTINGS_TIMEDATE: diff --git a/openrtx/src/ui/ui_menu.c b/openrtx/src/ui/ui_menu.c index 332de9a2..0a577722 100644 --- a/openrtx/src/ui/ui_menu.c +++ b/openrtx/src/ui/ui_menu.c @@ -233,6 +233,21 @@ void _ui_drawMenuInfo(ui_state_t* ui_state) _ui_getInfoValueName); } +void _ui_drawMenuAbout(ui_state_t* ui_state) +{ + gfx_clearScreen(); + ui_drawSplashScreen(false); + char author_buf[MAX_ENTRY_LEN] = ""; + uint8_t line_h = layout.top_h; + point_t pos = {SCREEN_WIDTH / 7, SCREEN_HEIGHT - (line_h * (author_num - 1)) - 5}; + for(int author = 0; author < author_num; author++) + { + snprintf(author_buf, MAX_ENTRY_LEN, "%s", authors[author]); + gfx_print(pos, author_buf, layout.top_font, TEXT_ALIGN_LEFT, color_white); + pos.y += line_h; + } +} + void _ui_drawSettingsDisplay(ui_state_t* ui_state) { gfx_clearScreen();