summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/clock.c801
1 files changed, 327 insertions, 474 deletions
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c
index c3df3ba472..73b21fcddd 100644
--- a/apps/plugins/clock.c
+++ b/apps/plugins/clock.c
@@ -200,7 +200,6 @@ bool counting = false;
200 * Everything else... 200 * Everything else...
201 *******************/ 201 *******************/
202bool idle_poweroff = true; /* poweroff activated or not? */ 202bool idle_poweroff = true; /* poweroff activated or not? */
203bool done = false; /* used for most of the while loops */
204bool exit_clock = false; /* when true, the main plugin loop will exit */ 203bool exit_clock = false; /* when true, the main plugin loop will exit */
205 204
206static struct plugin_api* rb; 205static struct plugin_api* rb;
@@ -224,10 +223,10 @@ static const char default_filename[] = "/.rockbox/rocks/.clock_settings";
224 * Some arrays/definitions for drawing settings/menu text. 223 * Some arrays/definitions for drawing settings/menu text.
225 ********************************************************/ 224 ********************************************************/
226#define ANALOG 1 225#define ANALOG 1
227#define DIGITAL 2 226#define FULLSCREEN 2
228#define FULLSCREEN 3 227#define DIGITAL 3
229#define BINARY 4 228#define PLAIN 4
230#define PLAIN 5 229#define BINARY 5
231#define CLOCK_MODES 5 230#define CLOCK_MODES 5
232 231
233#define analog_date 0 232#define analog_date 0
@@ -248,70 +247,22 @@ static const char default_filename[] = "/.rockbox/rocks/.clock_settings";
248#define general_savesetting 1 247#define general_savesetting 1
249#define general_backlight 2 248#define general_backlight 2
250 249
251/* Menu structs (lists of menu items) */
252static const struct menu_item main_menu_items[] = {
253 { "View Clock", NULL },
254 { "Mode Selector", NULL },
255 { "Mode Settings", NULL },
256 { "General Settings", NULL },
257 { "Exit Plugin", NULL }
258};
259static const struct menu_item mode_selector_items[] = {
260 { "Analog", NULL },
261 { "Digital/LCD", NULL },
262 { "Full-screen", NULL },
263 { "Binary", NULL },
264 { "Plain", NULL }
265};
266static const struct menu_item general_settings_items[] = {
267 { "Reset Settings", NULL },
268 { "Save Settings Now", NULL },
269 { "Save On Exit", NULL },
270 { "Show Counter", NULL },
271 { "Backlight Settings", NULL },
272 { "Idle Poweroff (temporary)", NULL }
273};
274static const struct menu_item analog_items[] = {
275 { "Show Date", NULL },
276 { "Show Second Hand", NULL },
277 { "Show Time Readout", NULL }
278};
279static const struct menu_item digital_items[] = {
280 { "Show Seconds", NULL },
281 { "Show Date", NULL },
282 { "Blinking Colon", NULL },
283 { "Time Format", NULL }
284};
285static const struct menu_item fullscreen_items[] = {
286 { "Show Border", NULL },
287 { "Show Second Hand", NULL }
288};
289static const struct menu_item binary_items[] = {
290 { "Display Mode", NULL }
291};
292static const struct menu_item plain_items[] = {
293 { "Show Date", NULL },
294 { "Show Seconds", NULL },
295 { "Blinking Colon", NULL },
296 { "Time Format", NULL }
297};
298
299/* Option structs (possible selections per each option) */ 250/* Option structs (possible selections per each option) */
300static const struct opt_items noyes_text[2] = { 251static const struct opt_items noyes_text[] = {
301 { "No", -1 }, 252 { "No", -1 },
302 { "Yes", -1 } 253 { "Yes", -1 }
303}; 254};
304 255
305static const struct opt_items backlight_settings_text[3] = { 256static const struct opt_items backlight_settings_text[] = {
306 { "Always Off", -1 }, 257 { "Always Off", -1 },
307 { "Rockbox setting", -1 }, 258 { "Rockbox setting", -1 },
308 { "Always On", -1 } 259 { "Always On", -1 }
309}; 260};
310static const struct opt_items idle_poweroff_text[2] = { 261static const struct opt_items idle_poweroff_text[] = {
311 { "Disabled", -1 }, 262 { "Disabled", -1 },
312 { "Enabled", -1 } 263 { "Enabled", -1 }
313}; 264};
314static const struct opt_items counting_direction_text[2] = { 265static const struct opt_items counting_direction_text[] = {
315 {"Down", -1}, 266 {"Down", -1},
316 {"Up", -1} 267 {"Up", -1}
317}; 268};
@@ -321,18 +272,18 @@ static const struct opt_items date_format_text[] = {
321 { "European format", -1 } 272 { "European format", -1 }
322}; 273};
323 274
324static const struct opt_items analog_time_text[3] = { 275static const struct opt_items analog_time_text[] = {
325 { "No", -1 }, 276 { "No", -1 },
326 { "24-hour Format", -1 }, 277 { "24-hour Format", -1 },
327 { "12-hour Format", -1 } 278 { "12-hour Format", -1 }
328}; 279};
329 280
330static const struct opt_items time_format_text[2] = { 281static const struct opt_items time_format_text[] = {
331 { "24-hour Format", -1 }, 282 { "24-hour Format", -1 },
332 { "12-hour Format", -1 } 283 { "12-hour Format", -1 }
333}; 284};
334 285
335static const struct opt_items binary_mode_text[2] = { 286static const struct opt_items binary_mode_text[] = {
336 { "Numbers", -1 }, 287 { "Numbers", -1 },
337 { "Dots", -1 } 288 { "Dots", -1 }
338}; 289};
@@ -558,6 +509,50 @@ void load_settings(void)
558 rb->sleep(HZ); 509 rb->sleep(HZ);
559} 510}
560 511
512void polar_to_cartesian(int a, int r, int* x, int* y)
513{
514 *x = (sin_int(a) * r) >> 14;
515 *y = (sin_int(a-90) * r) >> 14;
516}
517
518void polar_to_cartesian_screen_centered(struct screen * display,
519 int a, int r, int* x, int* y)
520{
521 polar_to_cartesian(a, r, x, y);
522 *x+=display->width/2;
523 *y+=display->height/2;
524}
525
526void angle_to_square(struct screen * display,
527 int square_width, int square_height,
528 int a, int* x, int* y)
529{
530 a = (a+360-90)%360;
531 if(a>45 && a<=135){/* top line */
532 a-=45;
533 *x=square_width-(square_width*2*a)/90;
534 *y=square_height;
535 }else if(a>135 && a<=225){/* left line */
536 a-=135;
537 *x=-square_width;
538 *y=square_height-(square_height*2*a)/90;
539 }else if(a>225 && a<=315){/* bottom line */
540 a-=225;
541 *x=(square_width*2*a)/90-square_width;
542 *y=-square_height;
543 }else if(a>315 || a<=45){/* right line */
544 if(a>315)
545 a-=315;
546 else
547 a+=45;
548 *x=square_width;
549 *y=(square_height*2*a)/90-square_height;
550 }
551 /* recenter */
552 *x+=display->width/2;
553 *y+=display->height/2;
554}
555
561/******************************* 556/*******************************
562 * Init clock, set up x/y tables 557 * Init clock, set up x/y tables
563 ******************************/ 558 ******************************/
@@ -586,54 +581,19 @@ void init_clock(void)
586 581
587 for(i=0; i<ANALOG_VALUES; i++) 582 for(i=0; i<ANALOG_VALUES; i++)
588 { 583 {
589 xminute[i] = ((sin_int(360 * i / ANALOG_VALUES) 584 int angle=360 * i / ANALOG_VALUES;
590 * ANALOG_MIN_RADIUS) >> 14) + ANALOG_XCENTER; 585 polar_to_cartesian_screen_centered(
591 yminute[i] = ((sin_int(360*i/ ANALOG_VALUES-90) 586 rb->screens[0], angle, ANALOG_MIN_RADIUS,
592 * ANALOG_MIN_RADIUS) >> 14) + ANALOG_YCENTER; 587 &(xminute[i]), &(yminute[i]));
593 xhour[i] = ((sin_int(360 * i / ANALOG_VALUES) 588 polar_to_cartesian_screen_centered(
594 * ANALOG_HR_RADIUS) >> 14) + ANALOG_XCENTER; 589 rb->screens[0], angle, ANALOG_HR_RADIUS,
595 yhour[i] = ((sin_int(360 * i / ANALOG_VALUES-90) 590 &(xhour[i]), &(yhour[i]));
596 * ANALOG_HR_RADIUS) >> 14) + ANALOG_YCENTER;
597 591
598 /* Fullscreen initialization */ 592 /* Fullscreen initialization */
599 if(i==0) 593 angle_to_square(rb->screens[0], LCD_WIDTH/2, LCD_HEIGHT/2, angle,
600 { 594 &(xminute_full[i]), &(yminute_full[i]));
601 xminute_full[i] = LCD_WIDTH/2; 595 angle_to_square(rb->screens[0], LCD_WIDTH/3, LCD_HEIGHT/3, angle,
602 xhour_full[i] = LCD_WIDTH/2; 596 &(xhour_full[i]), &(yhour_full[i]));
603 yminute_full[i] = 1;
604 yhour_full[i] = LCD_HEIGHT/6;
605 }
606 else if(i<10 || (i>50 && i <60) )
607 {
608 xminute_full[i] = xminute_full[i-1]+LCD_WIDTH/20;
609 xhour_full[i] = xhour_full[i-1]+(LCD_WIDTH/30);
610 yminute_full[i] = 1;
611 yhour_full[i] = LCD_HEIGHT/6;
612 }
613
614 else if (i>=10 && i < 20)
615 {
616 xminute_full[i] = LCD_WIDTH-2;
617 xhour_full[i] = (5*LCD_WIDTH)/6;
618 yminute_full[i] = ((i-10)*LCD_HEIGHT)/10;
619 yhour_full[i] = (LCD_HEIGHT/6)+((i-10)*(LCD_HEIGHT))/15;
620 }
621
622 else if(i>=20&&i<40)
623 {
624 xminute_full[i] = ((40-i)*LCD_WIDTH)/20;
625 xhour_full[i] = (LCD_WIDTH/6)+((40-i)*(LCD_WIDTH))/30;
626 yminute_full[i] = LCD_HEIGHT-2;
627 yhour_full[i] = (5*LCD_HEIGHT)/6;
628
629 }
630 else
631 {
632 xminute_full[i] = 1;
633 xhour_full[i] = LCD_WIDTH/6;
634 yminute_full[i] = ((50-i)*LCD_HEIGHT)/10;
635 yhour_full[i] = LCD_HEIGHT/6 + ((50-i)*LCD_HEIGHT)/15;
636 }
637 } 597 }
638} 598}
639 599
@@ -938,329 +898,7 @@ void plain_clock(int hour, int minute, int second, bool colon)
938 } 898 }
939} 899}
940 900
941/**********************
942 * Analog settings menu
943 *********************/
944void analog_settings_menu(void)
945{
946 int m=0, result;
947
948 done = false;
949
950#ifdef HAVE_LCD_COLOR
951 rb->lcd_set_background(LCD_RGBPACK(180,200,230));
952 rb->lcd_set_foreground(LCD_BLACK);
953#endif
954
955 m = menu_init(rb, analog_items, sizeof(analog_items) / sizeof(*analog_items),
956 NULL, NULL, NULL, NULL);
957
958 while(!done)
959 {
960 result = menu_show(m);
961
962 switch(result)
963 {
964 case 0:
965 rb->set_option("Show Date", &settings.analog[analog_date],
966 INT, date_format_text, 3, NULL);
967 break;
968 case 1:
969 rb->set_option("Show Second Hand", &settings.analog[analog_secondhand],
970 INT, noyes_text, 2, NULL);
971 break;
972 case 2:
973 rb->set_option("Show Time", &settings.analog[analog_time],
974 INT, analog_time_text, 3, NULL);
975 break;
976
977 default:
978 done = true;
979 break;
980 }
981
982 menu_exit(m);
983 }
984}
985
986/***********************
987 * Digital settings menu
988 **********************/
989void digital_settings_menu(void)
990{
991 int m=0, result;
992
993 done = false;
994
995#ifdef HAVE_LCD_COLOR
996 rb->lcd_set_background(LCD_RGBPACK(180,200,230));
997 rb->lcd_set_foreground(LCD_BLACK);
998#endif
999
1000 m = menu_init(rb, digital_items, sizeof(digital_items) / sizeof(*digital_items),
1001 NULL, NULL, NULL, NULL);
1002
1003 while(!done)
1004 {
1005 result = menu_show(m);
1006
1007 switch(result)
1008 {
1009 case 0:
1010 rb->set_option("Show Seconds", &settings.digital[digital_seconds],
1011 INT, noyes_text, 2, NULL);
1012 break;
1013 case 1:
1014 rb->set_option("Show Date", &settings.digital[digital_date],
1015 INT, date_format_text, 3, NULL);
1016 break;
1017 case 2:
1018 rb->set_option("Blinking Colon", &settings.digital[digital_blinkcolon],
1019 INT, noyes_text, 2, NULL);
1020 break;
1021 case 3:
1022 rb->set_option("Time Format", &settings.digital[digital_format],
1023 INT, time_format_text, 2, NULL);
1024 break;
1025
1026 default:
1027 done = true;
1028 break;
1029 }
1030
1031 menu_exit(m);
1032 }
1033}
1034
1035/**************************
1036 * Fullscreen settings menu
1037 *************************/
1038void fullscreen_settings_menu(void)
1039{
1040 int m=0, result;
1041
1042 done = false;
1043
1044#ifdef HAVE_LCD_COLOR
1045 rb->lcd_set_background(LCD_RGBPACK(180,200,230));
1046 rb->lcd_set_foreground(LCD_BLACK);
1047#endif
1048
1049 m = menu_init(rb, fullscreen_items, sizeof(fullscreen_items) / sizeof(*fullscreen_items),
1050 NULL, NULL, NULL, NULL);
1051
1052 while(!done)
1053 {
1054 result = menu_show(m);
1055
1056 switch(result)
1057 {
1058 case 0:
1059 rb->set_option("Show Border", &settings.fullscreen[fullscreen_border],
1060 INT, noyes_text, 2, NULL);
1061 break;
1062 case 1:
1063 rb->set_option("Show Second Hand", &settings.fullscreen[fullscreen_secondhand],
1064 INT, noyes_text, 2, NULL);
1065 break;
1066
1067 default:
1068 done = true;
1069 break;
1070 }
1071
1072 menu_exit(m);
1073 }
1074}
1075
1076/**********************
1077 * Binary settings menu
1078 *********************/
1079void binary_settings_menu(void)
1080{
1081 int m=0, result;
1082
1083 done = false;
1084
1085#ifdef HAVE_LCD_COLOR
1086 rb->lcd_set_background(LCD_RGBPACK(180,200,230));
1087 rb->lcd_set_foreground(LCD_BLACK);
1088#endif
1089
1090 m = menu_init(rb,binary_items, sizeof(binary_items) / sizeof(*binary_items),
1091 NULL, NULL, NULL, NULL);
1092
1093 while(!done)
1094 {
1095 result = menu_show(m);
1096
1097 switch(result)
1098 {
1099 case 0:
1100 rb->set_option("Display Mode", &settings.binary[binary_mode],
1101 INT, binary_mode_text, 2, NULL);
1102 break;
1103
1104 default:
1105 done = true;
1106 break;
1107 }
1108
1109 menu_exit(m);
1110 }
1111}
1112
1113/*********************
1114 * Plain settings menu
1115 ********************/
1116void plain_settings_menu(void)
1117{
1118 int m=0, result;
1119
1120 done = false;
1121
1122#ifdef HAVE_LCD_COLOR
1123 rb->lcd_set_background(LCD_RGBPACK(180,200,230));
1124 rb->lcd_set_foreground(LCD_BLACK);
1125#endif
1126
1127 m = menu_init(rb,plain_items, sizeof(plain_items) / sizeof(*plain_items),
1128 NULL, NULL, NULL, NULL);
1129 901
1130 while(!done)
1131 {
1132 result = menu_show(m);
1133
1134 switch(result)
1135 {
1136 case 0:
1137 rb->set_option("Show Date", &settings.plain[plain_date],
1138 INT, date_format_text, 3, NULL);
1139 break;
1140 case 1:
1141 rb->set_option("Show Seconds", &settings.plain[plain_seconds],
1142 INT, noyes_text, 2, NULL);
1143 break;
1144 case 2:
1145 rb->set_option("Blinking Colon", &settings.plain[plain_blinkcolon],
1146 INT, noyes_text, 2, NULL);
1147 break;
1148 case 3:
1149 rb->set_option("Time Format", &settings.plain[plain_format],
1150 INT, time_format_text, 2, NULL);
1151 break;
1152
1153 default:
1154 done = true;
1155 break;
1156 }
1157
1158 menu_exit(m);
1159 }
1160}
1161
1162/**************************************
1163 * Settings screen for the current mode
1164 *************************************/
1165void settings_screen(void)
1166{
1167 set_standard_colors();
1168
1169 if(settings.clock == ANALOG)
1170 analog_settings_menu();
1171 else if(settings.clock == DIGITAL)
1172 digital_settings_menu();
1173 else if(settings.clock == FULLSCREEN)
1174 fullscreen_settings_menu();
1175 else if(settings.clock == BINARY)
1176 binary_settings_menu();
1177 else if(settings.clock == PLAIN)
1178 plain_settings_menu();
1179
1180 set_digital_colors();
1181
1182}
1183
1184/***********************************************************
1185 * Confirm resetting of settings, used in general_settings()
1186 **********************************************************/
1187void confirm_reset(void)
1188{
1189 int result=0;
1190
1191 rb->set_option("Reset all settings?", &result, INT, noyes_text, 2, NULL);
1192
1193 if(result == 1) /* reset! */
1194 {
1195 reset_settings();
1196 rb->splash(HZ, "Settings reset!");
1197 }
1198 else
1199 rb->splash(HZ, "Settings NOT reset.");
1200}
1201
1202/************************************
1203 * General settings. Reset, save, etc
1204 ***********************************/
1205void general_settings(void)
1206{
1207 int m, result;
1208 done = false;
1209
1210 set_standard_colors();
1211
1212 m = menu_init(rb,general_settings_items, sizeof(general_settings_items) / sizeof(*general_settings_items),
1213 NULL, NULL, NULL, NULL);
1214
1215 while(!done)
1216 {
1217 result = menu_show(m);
1218
1219 switch(result)
1220 {
1221 case 0:
1222 confirm_reset();
1223 break;
1224
1225 case 1:
1226 save_settings(false);
1227 rb->splash(HZ, "Settings saved");
1228 break;
1229
1230 case 2:
1231 rb->set_option("Save On Exit", &settings.general[general_savesetting],
1232 INT, noyes_text, 2, NULL);
1233
1234 /* if we no longer save on exit, we better save now to remember that */
1235 if(settings.general[general_savesetting] == 0)
1236 save_settings(false);
1237 break;
1238
1239 case 3:
1240 rb->set_option("Show Counter", &settings.general[general_counter],
1241 INT, noyes_text, 2, NULL);
1242 break;
1243
1244 case 4:
1245 rb->set_option("Backlight Settings", &settings.general[general_backlight],
1246 INT, backlight_settings_text, 3, NULL);
1247 break;
1248
1249 case 5:
1250 rb->set_option("Idle Poweroff (temporary)", &idle_poweroff,
1251 BOOL, idle_poweroff_text, 2, NULL);
1252 break;
1253
1254 default:
1255 done=true;
1256 break;
1257 }
1258
1259 menu_exit(m);
1260 }
1261
1262 set_digital_colors();
1263}
1264 902
1265/**************************************** 903/****************************************
1266 * Draws the extras, IE border, digits... 904 * Draws the extras, IE border, digits...
@@ -1465,36 +1103,6 @@ void draw_extras(int year, int day, int month, int hour, int minute, int second)
1465 } 1103 }
1466} 1104}
1467 1105
1468/***************
1469 * Select a mode
1470 **************/
1471void mode_selector(void)
1472{
1473 int m, result;
1474 done = false;
1475
1476 set_standard_colors();
1477
1478 m = menu_init(rb,mode_selector_items, sizeof(mode_selector_items) / sizeof(*mode_selector_items),
1479 NULL, NULL, NULL, NULL);
1480
1481 while(!done)
1482 {
1483 result = menu_show(m);
1484
1485 /* check for this, so if the user exits the menu without
1486 * making a selection, it won't change to some weird value. */
1487 if(result >= 0)
1488 settings.clock = result+1;
1489
1490 done = true;
1491
1492 menu_exit(m);
1493 }
1494
1495 set_digital_colors();
1496}
1497
1498/********************* 1106/*********************
1499 * Display the counter 1107 * Display the counter
1500 ********************/ 1108 ********************/
@@ -1595,24 +1203,266 @@ void show_counter(void)
1595 } 1203 }
1596} 1204}
1597 1205
1206/* Menus */
1207
1208/***************
1209 * Select a mode
1210 **************/
1211bool menu_mode_selector(void)
1212{
1213 int selection=settings.clock-1;
1214
1215 set_standard_colors();
1216
1217 MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog", "Full-screen",
1218 "Digital/LCD","Plain","Binary");
1219
1220 /* check for this, so if the user exits the menu without
1221 * making a selection, it won't change to some weird value. */
1222 if(rb->do_menu(&menu, &selection) >=0){
1223 settings.clock = selection+1;
1224 return(true);
1225 }
1226 return(false);
1227}
1228
1229/**********************
1230 * Analog settings menu
1231 *********************/
1232void menu_analog_settings(void)
1233{
1234 int selection=0, result=0;
1235
1236 MENUITEM_STRINGLIST(menu,"Analog Mode Settings",NULL,"Show Date",
1237 "Show Second Hand","Show Time Readout");
1238
1239 while(result>=0)
1240 {
1241 result=rb->do_menu(&menu, &selection);
1242 switch(result)
1243 {
1244 case 0:
1245 rb->set_option("Show Date", &settings.analog[analog_date],
1246 INT, date_format_text, 3, NULL);
1247 break;
1248 case 1:
1249 rb->set_option("Show Second Hand", &settings.analog[analog_secondhand],
1250 INT, noyes_text, 2, NULL);
1251 break;
1252 case 2:
1253 rb->set_option("Show Time", &settings.analog[analog_time],
1254 INT, analog_time_text, 3, NULL);
1255 break;
1256 }
1257 }
1258}
1259
1260/***********************
1261 * Digital settings menu
1262 **********************/
1263void menu_digital_settings(void)
1264{
1265 int selection=0, result=0;
1266
1267 MENUITEM_STRINGLIST(menu,"Digital/LCD Mode Settings",NULL,"Show Date",
1268 "Show Seconds","Blinking Colon","Time Format");
1269
1270 while(result>=0)
1271 {
1272 result=rb->do_menu(&menu, &selection);
1273 switch(result)
1274 {
1275 case 0:
1276 rb->set_option("Show Date", &settings.digital[digital_date],
1277 INT, date_format_text, 3, NULL);
1278 break;
1279 case 1:
1280 rb->set_option("Show Seconds", &settings.digital[digital_seconds],
1281 INT, noyes_text, 2, NULL);
1282 break;
1283 case 2:
1284 rb->set_option("Blinking Colon", &settings.digital[digital_blinkcolon],
1285 INT, noyes_text, 2, NULL);
1286 break;
1287 case 3:
1288 rb->set_option("Time Format", &settings.digital[digital_format],
1289 INT, time_format_text, 2, NULL);
1290 break;
1291 }
1292 }
1293}
1294
1295/**************************
1296 * Fullscreen settings menu
1297 *************************/
1298void menu_fullscreen_settings(void)
1299{
1300 int selection=0, result=0;
1301
1302 MENUITEM_STRINGLIST(menu,"Fullscreen Mode Settings",NULL,
1303 "Show Border","Show Second Hand");
1304
1305 while(result>=0)
1306 {
1307 result=rb->do_menu(&menu, &selection);
1308 switch(result)
1309 {
1310 case 0:
1311 rb->set_option("Show Border", &settings.fullscreen[fullscreen_border],
1312 INT, noyes_text, 2, NULL);
1313 break;
1314 case 1:
1315 rb->set_option("Show Second Hand", &settings.fullscreen[fullscreen_secondhand],
1316 INT, noyes_text, 2, NULL);
1317 break;
1318 }
1319 }
1320}
1321
1322/**********************
1323 * Binary settings menu
1324 *********************/
1325void menu_binary_settings(void)
1326{
1327 int selection=0, result=0;
1328
1329 MENUITEM_STRINGLIST(menu,"Binary Mode Settings",NULL,"Display Mode");
1330
1331 while(result>=0)
1332 {
1333 result=rb->do_menu(&menu, &selection);
1334 switch(result)
1335 {
1336 case 0:
1337 rb->set_option("Display Mode", &settings.binary[binary_mode],
1338 INT, binary_mode_text, 2, NULL);
1339 }
1340
1341 }
1342}
1343
1344/*********************
1345 * Plain settings menu
1346 ********************/
1347void menu_plain_settings(void)
1348{
1349 int selection=0, result=0;
1350
1351 MENUITEM_STRINGLIST(menu,"Plain Mode Settings",NULL,"Show Date",
1352 "Show Seconds","Blinking Colon","Time Format");
1353
1354 while(result>=0)
1355 {
1356 result=rb->do_menu(&menu, &selection);
1357 switch(result)
1358 {
1359 case 0:
1360 rb->set_option("Show Date", &settings.plain[plain_date],
1361 INT, date_format_text, 3, NULL);
1362 break;
1363 case 1:
1364 rb->set_option("Show Seconds", &settings.plain[plain_seconds],
1365 INT, noyes_text, 2, NULL);
1366 break;
1367 case 2:
1368 rb->set_option("Blinking Colon", &settings.plain[plain_blinkcolon],
1369 INT, noyes_text, 2, NULL);
1370 break;
1371 case 3:
1372 rb->set_option("Time Format", &settings.plain[plain_format],
1373 INT, time_format_text, 2, NULL);
1374 break;
1375 }
1376 }
1377}
1378
1379/***********************************************************
1380 * Confirm resetting of settings, used in general_settings()
1381 **********************************************************/
1382void confirm_reset(void)
1383{
1384 int result=0;
1385
1386 rb->set_option("Reset all settings?", &result, INT, noyes_text, 2, NULL);
1387
1388 if(result == 1) /* reset! */
1389 {
1390 reset_settings();
1391 rb->splash(HZ, "Settings reset!");
1392 }
1393 else
1394 rb->splash(HZ, "Settings NOT reset.");
1395}
1396
1397/************************************
1398 * General settings. Reset, save, etc
1399 ***********************************/
1400void menu_general_settings(void)
1401{
1402 int selection=0, result=0;
1403
1404 MENUITEM_STRINGLIST(menu,"General Settings",NULL,"Reset Settings",
1405 "Save Settings Now","Save On Exit","Show Counter",
1406 "Backlight Settings","Idle Poweroff (temporary)");
1407
1408 while(result>=0)
1409 {
1410 result=rb->do_menu(&menu, &selection);
1411 switch(result)
1412 {
1413 case 0:
1414 confirm_reset();
1415 break;
1416
1417 case 1:
1418 save_settings(false);
1419 rb->splash(HZ, "Settings saved");
1420 break;
1421
1422 case 2:
1423 rb->set_option("Save On Exit", &settings.general[general_savesetting],
1424 INT, noyes_text, 2, NULL);
1425
1426 /* if we no longer save on exit, we better save now to remember that */
1427 if(settings.general[general_savesetting] == 0)
1428 save_settings(false);
1429 break;
1430
1431 case 3:
1432 rb->set_option("Show Counter", &settings.general[general_counter],
1433 INT, noyes_text, 2, NULL);
1434 break;
1435
1436 case 4:
1437 rb->set_option("Backlight Settings", &settings.general[general_backlight],
1438 INT, backlight_settings_text, 3, NULL);
1439 break;
1440
1441 case 5:
1442 rb->set_option("Idle Poweroff (temporary)", &idle_poweroff,
1443 BOOL, idle_poweroff_text, 2, NULL);
1444 break;
1445 }
1446
1447 }
1448}
1449
1598/*********** 1450/***********
1599 * Main menu 1451 * Main menu
1600 **********/ 1452 **********/
1601void main_menu(void) 1453void main_menu(void)
1602{ 1454{
1603 int m, result; 1455 int selection=0;
1604 done = false; 1456 bool done = false;
1605 1457
1606 set_standard_colors(); 1458 set_standard_colors();
1607 1459
1608 m = menu_init(rb,main_menu_items, sizeof(main_menu_items) / sizeof(*main_menu_items), 1460 MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector",
1609 NULL, NULL, NULL, NULL); 1461 "Mode Settings","General Settings","Quit");
1610 1462
1611 while(!done) 1463 while(!done)
1612 { 1464 {
1613 result = menu_show(m); 1465 switch(rb->do_menu(&menu, &selection))
1614
1615 switch(result)
1616 { 1466 {
1617 case 0: 1467 case 0:
1618 rb->lcd_setfont(FONT_SYSFIXED); 1468 rb->lcd_setfont(FONT_SYSFIXED);
@@ -1620,15 +1470,22 @@ void main_menu(void)
1620 break; 1470 break;
1621 1471
1622 case 1: 1472 case 1:
1623 mode_selector(); 1473 done=menu_mode_selector();
1624 break; 1474 break;
1625 1475
1626 case 2: 1476 case 2:
1627 settings_screen(); 1477 switch(settings.clock)
1478 {
1479 case ANALOG: menu_analog_settings();break;
1480 case DIGITAL: menu_digital_settings();break;
1481 case FULLSCREEN: menu_fullscreen_settings();break;
1482 case BINARY: menu_binary_settings();break;
1483 case PLAIN: menu_plain_settings();break;
1484 }
1628 break; 1485 break;
1629 1486
1630 case 3: 1487 case 3:
1631 general_settings(); 1488 menu_general_settings();
1632 break; 1489 break;
1633 1490
1634 case 4: 1491 case 4:
@@ -1640,8 +1497,6 @@ void main_menu(void)
1640 done=true; 1497 done=true;
1641 break; 1498 break;
1642 } 1499 }
1643
1644 menu_exit(m);
1645 } 1500 }
1646 1501
1647 rb->lcd_setfont(FONT_SYSFIXED); 1502 rb->lcd_setfont(FONT_SYSFIXED);
@@ -1697,8 +1552,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1697 day = current_time->tm_mday; 1552 day = current_time->tm_mday;
1698 month = current_time->tm_mon + 1; 1553 month = current_time->tm_mon + 1;
1699 1554
1700 done = false;
1701
1702 if(second != last_second) 1555 if(second != last_second)
1703 { 1556 {
1704 rb->lcd_clear_display(); 1557 rb->lcd_clear_display();
@@ -1799,11 +1652,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1799 set_digital_colors(); 1652 set_digital_colors();
1800 break; 1653 break;
1801 1654
1802 case ACTION_MENU: /* main menu */ 1655 case ACTION_MENU:
1803 main_menu(); 1656 main_menu();
1804 break; 1657 break;
1805 1658
1806 case ACTION_EXIT: /* main menu */ 1659 case ACTION_EXIT:
1807 exit_clock=true; 1660 exit_clock=true;
1808 break; 1661 break;
1809 1662