summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-12-01 09:28:14 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-12-01 09:28:14 +0000
commitc7fec13fd87d80bb38e71e84462f0081b0678db0 (patch)
treea12ddf829ab3d8167fdd2da9ee74e5988a80eda3 /apps
parenta783453ff91c19d5d9302a9479363a9a5f985cdf (diff)
downloadrockbox-c7fec13fd87d80bb38e71e84462f0081b0678db0.tar.gz
rockbox-c7fec13fd87d80bb38e71e84462f0081b0678db0.zip
FS#9173 - move all time/clock related settings in the menus into system > "time & date" (this includes sleep timer, alarm settings)
The time/date dispaly has been moved out of the "rockbox info" screen and into this screen also (only displayed if there is at least 3 lines of text on the screen though) The time/date is talked in this screen by pressing the usual context-menu button (usually long-select) Targets without a RTC are not changed (i.e sleep timer isnt moved) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19282 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/SOURCES3
-rw-r--r--apps/menu.c3
-rw-r--r--apps/menus/main_menu.c101
-rw-r--r--apps/menus/settings_menu.c109
-rw-r--r--apps/menus/time_menu.c294
-rw-r--r--apps/root_menu.c1
-rw-r--r--apps/root_menu.h1
7 files changed, 320 insertions, 192 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 84f2eecbe2..2ea41c290a 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -29,6 +29,9 @@ menus/recording_menu.c
29#endif 29#endif
30menus/settings_menu.c 30menus/settings_menu.c
31menus/sound_menu.c 31menus/sound_menu.c
32#if CONFIG_RTC
33menus/time_menu.c
34#endif
32misc.c 35misc.c
33mp3data.c 36mp3data.c
34onplay.c 37onplay.c
diff --git a/apps/menu.c b/apps/menu.c
index 8edec58587..3fb1749073 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -433,6 +433,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
433 redraw_lists = false; 433 redraw_lists = false;
434 if (!hide_bars) 434 if (!hide_bars)
435 { 435 {
436#ifdef HAVE_BUTTONBAR
437 gui_buttonbar_draw(&buttonbar);
438#endif
436 gui_syncstatusbar_draw(&statusbars, true); 439 gui_syncstatusbar_draw(&statusbars, true);
437 } 440 }
438 action = get_action(CONTEXT_MAINMENU, 441 action = get_action(CONTEXT_MAINMENU,
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index 77322c6ef4..41e25e30f5 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -147,10 +147,6 @@ enum infoscreenorder
147 INFO_ALBUMART, 147 INFO_ALBUMART,
148#endif 148#endif
149 INFO_VERSION, 149 INFO_VERSION,
150#if CONFIG_RTC
151 INFO_DATE,
152 INFO_TIME,
153#endif
154 INFO_COUNT 150 INFO_COUNT
155}; 151};
156 152
@@ -165,9 +161,6 @@ static char* info_getname(int selected_item, void *data,
165 char *buffer, size_t buffer_len) 161 char *buffer, size_t buffer_len)
166{ 162{
167 struct info_data *info = (struct info_data*)data; 163 struct info_data *info = (struct info_data*)data;
168#if CONFIG_RTC
169 struct tm *tm;
170#endif
171 char s1[32]; 164 char s1[32];
172#ifdef HAVE_MULTIVOLUME 165#ifdef HAVE_MULTIVOLUME
173 char s2[32]; 166 char s2[32];
@@ -189,39 +182,7 @@ static char* info_getname(int selected_item, void *data,
189 snprintf(buffer, buffer_len, "%s: %s", 182 snprintf(buffer, buffer_len, "%s: %s",
190 str(LANG_VERSION), appsversion); 183 str(LANG_VERSION), appsversion);
191 break; 184 break;
192#if CONFIG_RTC 185
193 case INFO_TIME:
194 tm = get_time();
195 if (valid_time(tm))
196 {
197 snprintf(buffer, buffer_len, "%02d:%02d:%02d %s",
198 global_settings.timeformat == 0 ? tm->tm_hour :
199 ((tm->tm_hour + 11) % 12) + 1,
200 tm->tm_min,
201 tm->tm_sec,
202 global_settings.timeformat == 0 ? "" :
203 tm->tm_hour>11 ? "P" : "A");
204 }
205 else
206 {
207 strncpy(buffer, "--:--:--", buffer_len);
208 }
209 break;
210 case INFO_DATE:
211 tm = get_time();
212 if (valid_time(tm))
213 {
214 snprintf(buffer, buffer_len, "%s %d %d",
215 str(LANG_MONTH_JANUARY + tm->tm_mon),
216 tm->tm_mday,
217 tm->tm_year+1900);
218 }
219 else
220 {
221 strncpy(buffer, str(LANG_UNKNOWN), buffer_len);
222 }
223 break;
224#endif
225 case INFO_BUFFER: /* buffer */ 186 case INFO_BUFFER: /* buffer */
226 { 187 {
227 long kib = (audiobufend - audiobuf) / 1024; /* to KiB */ 188 long kib = (audiobufend - audiobuf) / 1024; /* to KiB */
@@ -305,41 +266,13 @@ static int info_speak_item(int selected_item, void * data)
305{ 266{
306 struct info_data *info = (struct info_data*)data; 267 struct info_data *info = (struct info_data*)data;
307 268
308#if CONFIG_RTC
309 struct tm *tm;
310#endif
311
312 switch (selected_item) 269 switch (selected_item)
313 { 270 {
314 case INFO_VERSION: /* version */ 271 case INFO_VERSION: /* version */
315 talk_id(LANG_VERSION, false); 272 talk_id(LANG_VERSION, false);
316 talk_spell(appsversion, true); 273 talk_spell(appsversion, true);
317 break; 274 break;
318#if CONFIG_RTC 275
319 case INFO_TIME:
320 tm = get_time();
321 talk_id(VOICE_CURRENT_TIME, false);
322 if (valid_time(tm))
323 {
324 talk_time(tm, true);
325 }
326 else
327 {
328 talk_id(LANG_UNKNOWN, true);
329 }
330 break;
331 case INFO_DATE:
332 tm = get_time();
333 if (valid_time(tm))
334 {
335 talk_date(get_time(), true);
336 }
337 else
338 {
339 talk_id(LANG_UNKNOWN, true);
340 }
341 break;
342#endif
343 case INFO_BUFFER: /* buffer */ 276 case INFO_BUFFER: /* buffer */
344 { 277 {
345 talk_id(LANG_BUFFER_STAT, false); 278 talk_id(LANG_BUFFER_STAT, false);
@@ -447,18 +380,6 @@ static int info_action_callback(int action, struct gui_synclist *lists)
447 gui_synclist_speak_item(lists); 380 gui_synclist_speak_item(lists);
448 return ACTION_REDRAW; 381 return ACTION_REDRAW;
449 } 382 }
450#if CONFIG_RTC
451 else if (action == ACTION_NONE)
452 {
453 static int last_redraw = 0;
454 if (gui_synclist_item_is_onscreen(lists, 0, INFO_TIME)
455 && TIME_AFTER(current_tick, last_redraw + HZ*5))
456 {
457 last_redraw = current_tick;
458 return ACTION_REDRAW;
459 }
460 }
461#endif
462 return action; 383 return action;
463} 384}
464static bool show_info(void) 385static bool show_info(void)
@@ -501,16 +422,24 @@ static void sleep_timer_set(int minutes)
501 set_sleep_timer(minutes * 60); 422 set_sleep_timer(minutes * 60);
502} 423}
503 424
504static int sleep_timer(void) 425int sleep_timer(void)
505{ 426{
506 int minutes = (get_sleep_timer() + 59) / 60; /* round up */ 427 int minutes = (get_sleep_timer() + 59) / 60; /* round up */
507 return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, 428 return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
508 &sleep_timer_set, -5, 300, 0, sleep_timer_formatter); 429 &sleep_timer_set, -5, 300, 0, sleep_timer_formatter);
509} 430}
510 431
432
433#if CONFIG_RTC
434int time_screen(void* ignored);
435MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), time_screen,
436 NULL, NULL, Icon_Menu_setting );
437#endif
438/* This item is in the time/date screen if there is a RTC */
511MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer, 439MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer,
512 NULL, NULL, Icon_Menu_setting); /* make it look like a 440 NULL, NULL, Icon_Menu_setting); /* make it look like a
513 setting to the user */ 441 setting to the user */
442
514MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_VERSION), 443MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_VERSION),
515 (menu_function)show_credits, NULL, NULL, Icon_NOICON); 444 (menu_function)show_credits, NULL, NULL, Icon_NOICON);
516MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME), 445MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME),
@@ -519,8 +448,14 @@ MENUITEM_FUNCTION(debug_menu_item, 0, ID2P(LANG_DEBUG),
519 (menu_function)debug_menu, NULL, NULL, Icon_NOICON); 448 (menu_function)debug_menu, NULL, NULL, Icon_NOICON);
520 449
521MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_Questionmark, 450MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_Questionmark,
451#if CONFIG_RTC
452 &timedate_item,
453#endif
522 &show_info_item, &show_credits_item, &show_runtime_item, 454 &show_info_item, &show_credits_item, &show_runtime_item,
523 &sleep_timer_call, &debug_menu_item); 455#if CONFIG_RTC == 0
456 &sleep_timer_call,
457#endif
458 &debug_menu_item);
524/* INFO MENU */ 459/* INFO MENU */
525/***********************************/ 460/***********************************/
526 461
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index ebba295570..6bb032d169 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -212,109 +212,9 @@ MAKE_MENU(disk_menu, ID2P(LANG_DISK_MENU), 0, Icon_NOICON,
212 ); 212 );
213#endif 213#endif
214 214
215/* Time & Date */
216#if CONFIG_RTC
217static int timedate_set(void)
218{
219 struct tm tm;
220 int result;
221
222 /* Make a local copy of the time struct */
223 memcpy(&tm, get_time(), sizeof(struct tm));
224
225 /* do some range checks */
226 /* This prevents problems with time/date setting after a power loss */
227 if (!valid_time(&tm))
228 {
229/* Macros to convert a 2-digit string to a decimal constant.
230 (YEAR), MONTH and DAY are set by the date command, which outputs
231 DAY as 00..31 and MONTH as 01..12. The leading zero would lead to
232 misinterpretation as an octal constant. */
233#define S100(x) 1 ## x
234#define C2DIG2DEC(x) (S100(x)-100)
235
236 tm.tm_hour = 0;
237 tm.tm_min = 0;
238 tm.tm_sec = 0;
239 tm.tm_mday = C2DIG2DEC(DAY);
240 tm.tm_mon = C2DIG2DEC(MONTH)-1;
241 tm.tm_wday = 1;
242 tm.tm_year = YEAR-1900;
243 }
244
245 result = (int)set_time_screen(str(LANG_SET_TIME), &tm);
246
247 if(tm.tm_year != -1) {
248 set_time(&tm);
249 }
250 return result;
251}
252
253MENUITEM_FUNCTION(time_set, 0, ID2P(LANG_SET_TIME),
254 timedate_set, NULL, NULL, Icon_NOICON);
255MENUITEM_SETTING(timeformat, &global_settings.timeformat, NULL);
256MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), 0, Icon_NOICON, &time_set, &timeformat);
257#endif
258
259/* System menu */ 215/* System menu */
260MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL); 216MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL);
261 217
262#ifdef HAVE_RTC_ALARM
263MENUITEM_FUNCTION(alarm_screen_call, 0, ID2P(LANG_ALARM_MOD_ALARM_MENU),
264 (menu_function)alarm_screen, NULL, NULL, Icon_NOICON);
265#if CONFIG_TUNER || defined(HAVE_RECORDING)
266
267#if CONFIG_TUNER && !defined(HAVE_RECORDING)
268/* This need only be shown if we dont have recording, because if we do
269 then always show the setting item, because there will always be at least
270 2 items */
271static int alarm_callback(int action,const struct menu_item_ex *this_item)
272{
273 (void)this_item;
274 switch (action)
275 {
276 case ACTION_REQUEST_MENUITEM:
277 if (radio_hardware_present() == 0)
278 return ACTION_EXIT_MENUITEM;
279 break;
280 }
281 return action;
282}
283#else
284#define alarm_callback NULL
285#endif /* CONFIG_TUNER && !HAVE_RECORDING */
286/* have to do this manually because the setting screen
287 doesnt handle variable item count */
288static int alarm_setting(void)
289{
290 struct opt_items items[ALARM_START_COUNT];
291 int i = 0;
292 items[i].string = str(LANG_RESUME_PLAYBACK);
293 items[i].voice_id = LANG_RESUME_PLAYBACK;
294 i++;
295#if CONFIG_TUNER
296 if (radio_hardware_present())
297 {
298 items[i].string = str(LANG_FM_RADIO);
299 items[i].voice_id = LANG_FM_RADIO;
300 i++;
301 }
302#endif
303#ifdef HAVE_RECORDING
304 items[i].string = str(LANG_RECORDING);
305 items[i].voice_id = LANG_RECORDING;
306 i++;
307#endif
308 return set_option(str(LANG_ALARM_WAKEUP_SCREEN),
309 &global_settings.alarm_wake_up_screen,
310 INT, items, i, NULL);
311}
312
313MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN),
314 alarm_setting, NULL, alarm_callback, Icon_Menu_setting);
315#endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */
316#endif /* HAVE_RTC_ALARM */
317
318/* Limits menu */ 218/* Limits menu */
319MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL); 219MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL);
320MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL); 220MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL);
@@ -378,16 +278,7 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
378#if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE) 278#if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
379 &disk_menu, 279 &disk_menu,
380#endif 280#endif
381#if CONFIG_RTC
382 &time_menu,
383#endif
384 &poweroff, 281 &poweroff,
385#ifdef HAVE_RTC_ALARM
386 &alarm_screen_call,
387#if defined(HAVE_RECORDING) || CONFIG_TUNER
388 &alarm_wake_up_screen,
389#endif
390#endif
391 &limits_menu, 282 &limits_menu,
392#if CONFIG_CODEC == MAS3507D 283#if CONFIG_CODEC == MAS3507D
393 &line_in, 284 &line_in,
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
new file mode 100644
index 0000000000..02c6ae4ffe
--- /dev/null
+++ b/apps/menus/time_menu.c
@@ -0,0 +1,294 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: main_menu.c 17985 2008-07-08 02:30:58Z jdgordon $
9 *
10 * Copyright (C) 2007 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include <stddef.h>
24#include <limits.h>
25#include "config.h"
26#include "string.h"
27#include "sprintf.h"
28#include "lang.h"
29#include "action.h"
30#include "settings.h"
31#include "powermgmt.h"
32#include "menu.h"
33#include "misc.h"
34#include "exported_menus.h"
35#include "yesno.h"
36#include "keyboard.h"
37#include "talk.h"
38#include "splash.h"
39#include "version.h"
40#include "time.h"
41#include "viewport.h"
42#include "list.h"
43#include "alarm_menu.h"
44#include "screens.h"
45
46static int timedate_set(void)
47{
48 struct tm tm;
49 int result;
50
51 /* Make a local copy of the time struct */
52 memcpy(&tm, get_time(), sizeof(struct tm));
53
54 /* do some range checks */
55 /* This prevents problems with time/date setting after a power loss */
56 if (!valid_time(&tm))
57 {
58/* Macros to convert a 2-digit string to a decimal constant.
59 (YEAR), MONTH and DAY are set by the date command, which outputs
60 DAY as 00..31 and MONTH as 01..12. The leading zero would lead to
61 misinterpretation as an octal constant. */
62#define S100(x) 1 ## x
63#define C2DIG2DEC(x) (S100(x)-100)
64
65 tm.tm_hour = 0;
66 tm.tm_min = 0;
67 tm.tm_sec = 0;
68 tm.tm_mday = C2DIG2DEC(DAY);
69 tm.tm_mon = C2DIG2DEC(MONTH)-1;
70 tm.tm_wday = 1;
71 tm.tm_year = YEAR-1900;
72 }
73
74 result = (int)set_time_screen(str(LANG_SET_TIME), &tm);
75
76 if(tm.tm_year != -1) {
77 set_time(&tm);
78 }
79 return result;
80}
81
82MENUITEM_FUNCTION(time_set, 0, ID2P(LANG_SET_TIME),
83 timedate_set, NULL, NULL, Icon_NOICON);
84MENUITEM_SETTING(timeformat, &global_settings.timeformat, NULL);
85
86/* in main_menu.c */
87extern const struct menu_item_ex sleep_timer_call;
88
89#ifdef HAVE_RTC_ALARM
90MENUITEM_FUNCTION(alarm_screen_call, 0, ID2P(LANG_ALARM_MOD_ALARM_MENU),
91 (menu_function)alarm_screen, NULL, NULL, Icon_NOICON);
92#if CONFIG_TUNER || defined(HAVE_RECORDING)
93
94#if CONFIG_TUNER && !defined(HAVE_RECORDING)
95/* This need only be shown if we dont have recording, because if we do
96 then always show the setting item, because there will always be at least
97 2 items */
98static int alarm_callback(int action,const struct menu_item_ex *this_item)
99{
100 (void)this_item;
101 switch (action)
102 {
103 case ACTION_REQUEST_MENUITEM:
104 if (radio_hardware_present() == 0)
105 return ACTION_EXIT_MENUITEM;
106 break;
107 }
108 return action;
109}
110#else
111#define alarm_callback NULL
112#endif /* CONFIG_TUNER && !HAVE_RECORDING */
113/* have to do this manually because the setting screen
114 doesnt handle variable item count */
115static int alarm_setting(void)
116{
117 struct opt_items items[ALARM_START_COUNT];
118 int i = 0;
119 items[i].string = str(LANG_RESUME_PLAYBACK);
120 items[i].voice_id = LANG_RESUME_PLAYBACK;
121 i++;
122#if CONFIG_TUNER
123 if (radio_hardware_present())
124 {
125 items[i].string = str(LANG_FM_RADIO);
126 items[i].voice_id = LANG_FM_RADIO;
127 i++;
128 }
129#endif
130#ifdef HAVE_RECORDING
131 items[i].string = str(LANG_RECORDING);
132 items[i].voice_id = LANG_RECORDING;
133 i++;
134#endif
135 return set_option(str(LANG_ALARM_WAKEUP_SCREEN),
136 &global_settings.alarm_wake_up_screen,
137 INT, items, i, NULL);
138}
139
140MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN),
141 alarm_setting, NULL, alarm_callback, Icon_Menu_setting);
142#endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */
143
144#endif /* HAVE_RTC_ALARM */
145static void talk_timedate(void)
146{
147 struct tm *tm = get_time();
148 if (!global_settings.talk_menu)
149 return;
150 talk_id(VOICE_CURRENT_TIME, false);
151 if (valid_time(tm))
152 {
153 talk_time(tm, true);
154 talk_date(get_time(), true);
155 }
156 else
157 {
158 talk_id(LANG_UNKNOWN, true);
159 }
160}
161
162static void draw_timedate(struct viewport *vp, struct screen *display)
163{
164 struct tm *tm = get_time();
165 int w, line;
166 char time[16], date[16];
167 if (vp->height == 0)
168 return;
169 display->set_viewport(vp);
170 display->clear_viewport();
171 if (viewport_get_nb_lines(vp) > 3)
172 line = 1;
173 else
174 line = 0;
175
176 if (valid_time(tm))
177 {
178 snprintf(time, 16, "%02d:%02d:%02d %s",
179 global_settings.timeformat == 0 ? tm->tm_hour :
180 ((tm->tm_hour + 11) % 12) + 1,
181 tm->tm_min,
182 tm->tm_sec,
183 global_settings.timeformat == 0 ? "" :
184 tm->tm_hour>11 ? "P" : "A");
185 snprintf(date, 16, "%s %d %d",
186 str(LANG_MONTH_JANUARY + tm->tm_mon),
187 tm->tm_mday,
188 tm->tm_year+1900);
189 }
190 else
191 {
192 snprintf(time, 16, "%s", "--:--:--");
193 snprintf(date, 16, "%s", str(LANG_UNKNOWN));
194 }
195 display->getstringsize(time, &w, NULL);
196 if (w > vp->width)
197 display->puts_scroll(0, line, time);
198 else
199 display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, time);
200 line++;
201
202 display->getstringsize(date, &w, NULL);
203 if (w > vp->width)
204 display->puts_scroll(0, line, date);
205 else
206 display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, date);
207 display->update_viewport();
208}
209
210struct viewport clock[NB_SCREENS], menu[NB_SCREENS];
211int time_menu_callback(int action,
212 const struct menu_item_ex *this_item)
213{
214 (void)this_item;
215 int i;
216 static int last_redraw = 0;
217 bool redraw = false;
218
219 if (TIME_BEFORE(last_redraw+HZ/2, current_tick))
220 redraw = true;
221 switch (action)
222 {
223 case ACTION_REDRAW:
224 redraw = true;
225 break;
226 case ACTION_STD_CONTEXT:
227 talk_timedate();
228 action = ACTION_NONE;
229 break;
230 }
231 if (redraw)
232 {
233 last_redraw = current_tick;
234 FOR_NB_SCREENS(i)
235 draw_timedate(&clock[i], &screens[i]);
236 }
237 return action;
238}
239
240
241MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
242 &time_set, &sleep_timer_call,
243#ifdef HAVE_RTC_ALARM
244 &alarm_screen_call,
245#if defined(HAVE_RECORDING) || CONFIG_TUNER
246 &alarm_wake_up_screen,
247#endif
248#endif
249 &timeformat);
250
251int time_screen(void* ignored)
252{
253 (void)ignored;
254 int i, nb_lines, font_h;
255
256 FOR_NB_SCREENS(i)
257 {
258 viewport_set_defaults(&clock[i], i);
259#ifdef HAVE_BUTTONBAR
260 if (global_settings.buttonbar)
261 {
262 clock[i].height -= BUTTONBAR_HEIGHT;
263 }
264#endif
265 nb_lines = viewport_get_nb_lines(&clock[i]);
266 menu[i] = clock[i];
267 font_h = font_get(clock[i].font)->height;
268 if (nb_lines > 3)
269 {
270 if (nb_lines >= 5)
271 {
272 clock[i].height = 3*font_h;
273 if (nb_lines > 5)
274 clock[i].height += font_h;
275 }
276 else
277 {
278 clock[i].height = 2*font_h;
279 }
280 }
281 else /* disable the clock drawing */
282 clock[i].height = 0;
283 menu[i].y = clock[i].y + clock[i].height;
284 menu[i].height = screens[i].lcdheight - menu[i].y;
285#ifdef HAVE_BUTTONBAR
286 if (global_settings.buttonbar)
287 menu[i].height -= BUTTONBAR_HEIGHT;
288#endif
289 screens[i].clear_display();
290 draw_timedate(&clock[i], &screens[i]);
291 screens[i].update();
292 }
293 return do_menu(&time_menu, NULL, menu, false);
294}
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 4b9be39a8c..9d4f256370 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -310,6 +310,7 @@ static int plugins_menu(void* param)
310 } 310 }
311 return retval; 311 return retval;
312} 312}
313int time_screen(void* ignored);
313 314
314/* These are all static const'd from apps/menus/ *.c 315/* These are all static const'd from apps/menus/ *.c
315 so little hack so we can use them */ 316 so little hack so we can use them */
diff --git a/apps/root_menu.h b/apps/root_menu.h
index c4cb466c99..dbc75efbca 100644
--- a/apps/root_menu.h
+++ b/apps/root_menu.h
@@ -49,6 +49,7 @@ enum {
49 be the "start screen" after a boot up. The setting in settings_list.c 49 be the "start screen" after a boot up. The setting in settings_list.c
50 will need editing if this is the case. */ 50 will need editing if this is the case. */
51 GO_TO_BROWSEPLUGINS, 51 GO_TO_BROWSEPLUGINS,
52 GO_TO_TIMESCREEN,
52}; 53};
53 54
54extern const struct menu_item_ex root_menu_; 55extern const struct menu_item_ex root_menu_;