diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 76 | ||||
-rw-r--r-- | apps/settings.c | 37 | ||||
-rw-r--r-- | apps/settings.h | 2 |
3 files changed, 113 insertions, 2 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 4dd98e0498..ae660d49c5 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "font.h" | 38 | #include "font.h" |
39 | #include "disk.h" | 39 | #include "disk.h" |
40 | #include "mpeg.h" | 40 | #include "mpeg.h" |
41 | #include "settings.h" | ||
41 | #ifdef HAVE_LCD_BITMAP | 42 | #ifdef HAVE_LCD_BITMAP |
42 | #include "widgets.h" | 43 | #include "widgets.h" |
43 | #include "peakmeter.h" | 44 | #include "peakmeter.h" |
@@ -1005,6 +1006,80 @@ bool dbg_mas_info(void) | |||
1005 | } | 1006 | } |
1006 | #endif | 1007 | #endif |
1007 | 1008 | ||
1009 | static bool view_runtime(void) | ||
1010 | { | ||
1011 | char s[32]; | ||
1012 | bool done = false; | ||
1013 | int state = 1; | ||
1014 | |||
1015 | while(!done) | ||
1016 | { | ||
1017 | int y=0; | ||
1018 | int t; | ||
1019 | int key; | ||
1020 | lcd_clear_display(); | ||
1021 | #ifdef HAVE_LCD_BITMAP | ||
1022 | lcd_puts(0, y++, "Running time:"); | ||
1023 | y++; | ||
1024 | #endif | ||
1025 | |||
1026 | if (state & 1) { | ||
1027 | t = global_settings.runtime; | ||
1028 | lcd_puts(0, y++, "Current time"); | ||
1029 | } | ||
1030 | else { | ||
1031 | t = global_settings.topruntime; | ||
1032 | lcd_puts(0, y++, "Top time"); | ||
1033 | } | ||
1034 | |||
1035 | snprintf(s, sizeof(s), "%dh %dm %ds", | ||
1036 | t / 3600, (t % 3600) / 60, t % 60); | ||
1037 | lcd_puts(0, y++, s); | ||
1038 | lcd_update(); | ||
1039 | |||
1040 | /* Wait for a key to be pushed */ | ||
1041 | key = button_get_w_tmo(HZ*5); | ||
1042 | switch(key) { | ||
1043 | #ifdef HAVE_PLAYER_KEYPAD | ||
1044 | case BUTTON_STOP | BUTTON_REL: | ||
1045 | #else | ||
1046 | case BUTTON_OFF | BUTTON_REL: | ||
1047 | #endif | ||
1048 | done = true; | ||
1049 | break; | ||
1050 | |||
1051 | case BUTTON_LEFT: | ||
1052 | case BUTTON_RIGHT: | ||
1053 | if (state == 1) | ||
1054 | state = 2; | ||
1055 | else | ||
1056 | state = 1; | ||
1057 | break; | ||
1058 | |||
1059 | case BUTTON_PLAY: | ||
1060 | lcd_clear_display(); | ||
1061 | lcd_puts(0,0,"Clear time?"); | ||
1062 | lcd_puts(0,1,"PLAY = Yes"); | ||
1063 | lcd_update(); | ||
1064 | while (1) { | ||
1065 | key = button_get_w_tmo(HZ*10); | ||
1066 | if ( key & BUTTON_REL ) | ||
1067 | continue; | ||
1068 | if ( key == BUTTON_PLAY ) { | ||
1069 | if ( state == 1 ) | ||
1070 | global_settings.runtime = 0; | ||
1071 | else | ||
1072 | global_settings.topruntime = 0; | ||
1073 | } | ||
1074 | break; | ||
1075 | } | ||
1076 | break; | ||
1077 | } | ||
1078 | } | ||
1079 | |||
1080 | return false; | ||
1081 | } | ||
1082 | |||
1008 | bool debug_menu(void) | 1083 | bool debug_menu(void) |
1009 | { | 1084 | { |
1010 | int m; | 1085 | int m; |
@@ -1036,6 +1111,7 @@ bool debug_menu(void) | |||
1036 | { "pm histogram", peak_meter_histogram}, | 1111 | { "pm histogram", peak_meter_histogram}, |
1037 | #endif /* PM_DEBUG */ | 1112 | #endif /* PM_DEBUG */ |
1038 | #endif /* HAVE_LCD_BITMAP */ | 1113 | #endif /* HAVE_LCD_BITMAP */ |
1114 | { "View runtime", view_runtime }, | ||
1039 | }; | 1115 | }; |
1040 | 1116 | ||
1041 | m=menu_init( items, sizeof items / sizeof(struct menu_items) ); | 1117 | m=menu_init( items, sizeof items / sizeof(struct menu_items) ); |
diff --git a/apps/settings.c b/apps/settings.c index ead61d88f8..3bfbd9670f 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include "lang.h" | 51 | #include "lang.h" |
52 | #include "language.h" | 52 | #include "language.h" |
53 | #include "wps-display.h" | 53 | #include "wps-display.h" |
54 | #include "powermgmt.h" | ||
54 | 55 | ||
55 | struct user_settings global_settings; | 56 | struct user_settings global_settings; |
56 | char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ | 57 | char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ |
@@ -105,8 +106,10 @@ offset abs | |||
105 | 0x23 0x37 <rec. left gain (bit 0-3)> | 106 | 0x23 0x37 <rec. left gain (bit 0-3)> |
106 | 0x24 0x38 <rec. right gain (bit 0-3)> | 107 | 0x24 0x38 <rec. right gain (bit 0-3)> |
107 | 0x25 0x39 <disk_spindown flag> | 108 | 0x25 0x39 <disk_spindown flag> |
108 | 109 | 0x26 0x40 <runtime low byte> | |
109 | <all unused space filled with 0xff> | 110 | 0x27 0x41 <runtime high byte> |
111 | 0x28 0x42 <topruntime low byte> | ||
112 | 0x29 0x43 <topruntime high byte> | ||
110 | 113 | ||
111 | 0x2a <checksum 2 bytes: xor of 0x0-0x29> | 114 | 0x2a <checksum 2 bytes: xor of 0x0-0x29> |
112 | 115 | ||
@@ -343,6 +346,26 @@ int settings_save( void ) | |||
343 | config_block[0x24] = (unsigned char)global_settings.rec_right_gain; | 346 | config_block[0x24] = (unsigned char)global_settings.rec_right_gain; |
344 | config_block[0x25] = (unsigned char)global_settings.disk_poweroff & 1; | 347 | config_block[0x25] = (unsigned char)global_settings.disk_poweroff & 1; |
345 | 348 | ||
349 | { | ||
350 | static long lasttime = 0; | ||
351 | |||
352 | /* reset counter if charger is inserted */ | ||
353 | if ( charger_inserted() ) { | ||
354 | global_settings.runtime = 0; | ||
355 | } | ||
356 | else { | ||
357 | global_settings.runtime += (current_tick - lasttime) / HZ; | ||
358 | lasttime = current_tick; | ||
359 | } | ||
360 | if ( global_settings.runtime > global_settings.topruntime ) | ||
361 | global_settings.topruntime = global_settings.runtime; | ||
362 | |||
363 | config_block[0x26]=(unsigned char)(global_settings.runtime & 0xff); | ||
364 | config_block[0x27]=(unsigned char)(global_settings.runtime >> 8); | ||
365 | config_block[0x28]=(unsigned char)(global_settings.topruntime & 0xff); | ||
366 | config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8); | ||
367 | } | ||
368 | |||
346 | strncpy(&config_block[0xb8], global_settings.wps_file, MAX_FILENAME); | 369 | strncpy(&config_block[0xb8], global_settings.wps_file, MAX_FILENAME); |
347 | strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME); | 370 | strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME); |
348 | strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME); | 371 | strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME); |
@@ -602,6 +625,14 @@ void settings_load(void) | |||
602 | if (config_block[0x25] != 0xFF) | 625 | if (config_block[0x25] != 0xFF) |
603 | global_settings.disk_poweroff = config_block[0x25] & 1; | 626 | global_settings.disk_poweroff = config_block[0x25] & 1; |
604 | 627 | ||
628 | if (config_block[0x27] != 0xff) | ||
629 | global_settings.runtime = | ||
630 | config_block[0x26] | (config_block[0x27] << 8); | ||
631 | |||
632 | if (config_block[0x29] != 0xff) | ||
633 | global_settings.topruntime = | ||
634 | config_block[0x28] | (config_block[0x29] << 8); | ||
635 | |||
605 | memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); | 636 | memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); |
606 | memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); | 637 | memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); |
607 | 638 | ||
@@ -805,6 +836,8 @@ void settings_reset(void) { | |||
805 | global_settings.wps_file[0] = 0; | 836 | global_settings.wps_file[0] = 0; |
806 | global_settings.font_file[0] = 0; | 837 | global_settings.font_file[0] = 0; |
807 | global_settings.lang_file[0] = 0; | 838 | global_settings.lang_file[0] = 0; |
839 | global_settings.runtime = 0; | ||
840 | global_settings.topruntime = 0; | ||
808 | } | 841 | } |
809 | 842 | ||
810 | 843 | ||
diff --git a/apps/settings.h b/apps/settings.h index 8399874016..6d3678f44c 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -131,6 +131,8 @@ struct user_settings | |||
131 | bool browse_current; /* 1=goto current song, | 131 | bool browse_current; /* 1=goto current song, |
132 | 0=goto previous location */ | 132 | 0=goto previous location */ |
133 | 133 | ||
134 | int runtime; /* current runtime since last charge */ | ||
135 | int topruntime; /* top known runtime */ | ||
134 | }; | 136 | }; |
135 | 137 | ||
136 | /* prototypes */ | 138 | /* prototypes */ |