From d742d027b7e1d0c93ff943724531916809804658 Mon Sep 17 00:00:00 2001 From: Alessio Caiazza Date: Mon, 13 Dec 2021 23:18:01 +0100 Subject: [PATCH] Display timer UI --- openrtx/include/ui.h | 1 + openrtx/src/ui/ui.c | 20 +++++++++++++++++++- openrtx/src/ui/ui_menu.c | 24 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/openrtx/include/ui.h b/openrtx/include/ui.h index 2322bb2e..030f786b 100644 --- a/openrtx/include/ui.h +++ b/openrtx/include/ui.h @@ -97,6 +97,7 @@ enum displayItems #ifdef SCREEN_CONTRAST ,D_CONTRAST #endif + ,D_TIMER }; #ifdef HAS_GPS diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index eb85028f..808a9ec0 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -137,8 +137,9 @@ const char *display_items[] = { "Brightness", #ifdef SCREEN_CONTRAST - "Contrast" + "Contrast", #endif + "Timer" }; #ifdef HAS_GPS @@ -644,6 +645,17 @@ void _ui_changeContrast(int variation) display_setContrast(state.settings.contrast); } +void _ui_changeTimer(int variation) +{ + if ((state.settings.brightness_timer == TIMER_OFF && variation < 0) || + (state.settings.brightness_timer == TIMER_1H && variation > 0)) + { + return; + } + + state.settings.brightness_timer += variation; +} + bool _ui_checkStandby(long long time_since_last_event) { if (standby) @@ -1449,6 +1461,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx) _ui_changeContrast(-4); break; #endif + case D_TIMER: + _ui_changeTimer(-1); + break; default: state.ui_screen = SETTINGS_DISPLAY; } @@ -1466,6 +1481,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx) _ui_changeContrast(+4); break; #endif + case D_TIMER: + _ui_changeTimer(+1); + break; default: state.ui_screen = SETTINGS_DISPLAY; } diff --git a/openrtx/src/ui/ui_menu.c b/openrtx/src/ui/ui_menu.c index 26790ae7..169d3014 100644 --- a/openrtx/src/ui/ui_menu.c +++ b/openrtx/src/ui/ui_menu.c @@ -28,6 +28,26 @@ /* UI main screen helper functions, their implementation is in "ui_main.c" */ extern void _ui_drawMainBottom(); +const char *display_timer_values[] = +{ + "Off", + "5 s", + "10 s", + "15 s", + "20 s", + "25 s", + "30 s", + "1 min", + "2 min", + "3 min", + "4 min", + "5 min", + "15 min", + "30 min", + "45 min", + "1 hour" +}; + void _ui_drawMenuList(uint8_t selected, int (*getCurrentEntry)(char *buf, uint8_t max_len, uint8_t index)) { point_t pos = layout.line1_pos; @@ -138,6 +158,10 @@ int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index) value = last_state.settings.contrast; break; #endif + case D_TIMER: + snprintf(buf, max_len, "%s", + display_timer_values[last_state.settings.brightness_timer]); + return 0; } snprintf(buf, max_len, "%d", value); return 0;