From 43830d0128ed9483db769f0d29f3d6071e620144 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 30 Mar 2022 08:53:40 -0400 Subject: alarm_menu share setter with settime share the time picker with the alarm block the date portion, seconds are ignored Change-Id: Idc6974466772c33248ff532c8f3c62c744ee06d9 --- apps/screens.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'apps/screens.c') diff --git a/apps/screens.c b/apps/screens.c index f3a969a838..2d3a521a88 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -123,7 +123,7 @@ static void say_time(int cursorpos, const struct tm *tm) #define OFF_YEAR 9 #define OFF_DAY 14 -bool set_time_screen(const char* title, struct tm *tm) +bool set_time_screen(const char* title, struct tm *tm, bool set_date) { struct viewport viewports[NB_SCREENS]; bool done = false, usb = false; @@ -139,6 +139,10 @@ bool set_time_screen(const char* title, struct tm *tm) offsets_ptr[IDX_DAY] = OFF_YEAR; } + int last_item = IDX_DAY; /*time & date*/ + if (!set_date) + last_item = IDX_SECONDS; /*time*/ + /* speak selection when screen is entered */ say_time(cursorpos, tm); @@ -161,6 +165,7 @@ bool set_time_screen(const char* title, struct tm *tm) unsigned char buffer[20]; #endif int *valptr = NULL; + static unsigned char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; @@ -320,11 +325,11 @@ bool set_time_screen(const char* title, struct tm *tm) button = get_action(CONTEXT_SETTINGS_TIME, TIMEOUT_BLOCK); switch ( button ) { case ACTION_STD_PREV: - cursorpos = clamp_value_wrap(--cursorpos, 5, 0); + cursorpos = clamp_value_wrap(--cursorpos, last_item, 0); say_time(cursorpos, tm); break; case ACTION_STD_NEXT: - cursorpos = clamp_value_wrap(++cursorpos, 5, 0); + cursorpos = clamp_value_wrap(++cursorpos, last_item, 0); say_time(cursorpos, tm); break; case ACTION_SETTINGS_INC: -- cgit v1.2.3