summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2007-10-24 15:34:36 +0000
committerSteve Bavin <pondlife@pondlife.me>2007-10-24 15:34:36 +0000
commitfda41b892eba8a72cdf221ff32608656a1c036cc (patch)
tree201072ded9067f4315e26ba7eefd4947610c4a1a
parent1e45eecb230ceb46d03f3c480450e13913ad9a52 (diff)
downloadrockbox-fda41b892eba8a72cdf221ff32608656a1c036cc.tar.gz
rockbox-fda41b892eba8a72cdf221ff32608656a1c036cc.zip
Try and save some bytes, seeing as we already assumed LANG_ constants for month and weekday names are contiguous.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15289 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/gwps-common.c4
-rw-r--r--apps/menus/main_menu.c69
-rw-r--r--apps/screens.c9
-rw-r--r--firmware/export/rtc.h4
4 files changed, 13 insertions, 73 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index a2f1aa660b..fec13d564f 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -1160,12 +1160,12 @@ static char *get_token_value(struct gui_wps *gwps,
1160 1160
1161 case WPS_TOKEN_RTC_WEEKDAY_NAME: 1161 case WPS_TOKEN_RTC_WEEKDAY_NAME:
1162 /* a: abbreviated weekday name (Sun..Sat) */ 1162 /* a: abbreviated weekday name (Sun..Sat) */
1163 snprintf(buf, buf_size, "%s",str(dayname[tm->tm_wday])); 1163 snprintf(buf, buf_size, "%s",str(LANG_WEEKDAY_SUNDAY + tm->tm_wday));
1164 return buf; 1164 return buf;
1165 1165
1166 case WPS_TOKEN_RTC_MONTH_NAME: 1166 case WPS_TOKEN_RTC_MONTH_NAME:
1167 /* b: abbreviated month name (Jan..Dec) */ 1167 /* b: abbreviated month name (Jan..Dec) */
1168 snprintf(buf, buf_size, "%s",str(monthname[tm->tm_mon])); 1168 snprintf(buf, buf_size, "%s",str(LANG_MONTH_JANUARY + tm->tm_mon));
1169 return buf; 1169 return buf;
1170 1170
1171 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON: 1171 case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index ea223d9702..5231181296 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -131,46 +131,17 @@ struct info_data
131enum infoscreenorder 131enum infoscreenorder
132{ 132{
133 INFO_VERSION = 0, 133 INFO_VERSION = 0,
134 INFO_GAP1,
135#if CONFIG_RTC 134#if CONFIG_RTC
136 INFO_TIME, 135 INFO_TIME,
137 INFO_DATE, 136 INFO_DATE,
138 INFO_GAP2,
139#endif 137#endif
140 INFO_BUFFER, 138 INFO_BUFFER,
141 INFO_BATTERY, 139 INFO_BATTERY,
142 INFO_DISK1, /* capacity or internal capacity/free on hotswap */ 140 INFO_DISK1, /* capacity or internal capacity/free on hotswap */
143 INFO_DISK2, /* free space or external capacity/free on hotswap */ 141 INFO_DISK2, /* free space or external capacity/free on hotswap */
144 INFO_COUNT 142 INFO_COUNT
145}; 143};
146#if CONFIG_RTC
147const int dayname[] =
148{
149 LANG_WEEKDAY_SUNDAY,
150 LANG_WEEKDAY_MONDAY,
151 LANG_WEEKDAY_TUESDAY,
152 LANG_WEEKDAY_WEDNESDAY,
153 LANG_WEEKDAY_THURSDAY,
154 LANG_WEEKDAY_FRIDAY,
155 LANG_WEEKDAY_SATURDAY
156};
157 144
158const int monthname[] =
159{
160 LANG_MONTH_JANUARY,
161 LANG_MONTH_FEBRUARY,
162 LANG_MONTH_MARCH,
163 LANG_MONTH_APRIL,
164 LANG_MONTH_MAY,
165 LANG_MONTH_JUNE,
166 LANG_MONTH_JULY,
167 LANG_MONTH_AUGUST,
168 LANG_MONTH_SEPTEMBER,
169 LANG_MONTH_OCTOBER,
170 LANG_MONTH_NOVEMBER,
171 LANG_MONTH_DECEMBER
172};
173#endif
174static char* info_getname(int selected_item, void *data, char *buffer) 145static char* info_getname(int selected_item, void *data, char *buffer)
175{ 146{
176 struct info_data *info = (struct info_data*)data; 147 struct info_data *info = (struct info_data*)data;
@@ -204,11 +175,6 @@ static char* info_getname(int selected_item, void *data, char *buffer)
204 snprintf(buffer, MAX_PATH, "%s: %s", 175 snprintf(buffer, MAX_PATH, "%s: %s",
205 str(LANG_VERSION), appsversion); 176 str(LANG_VERSION), appsversion);
206 break; 177 break;
207 case INFO_GAP1:
208#if CONFIG_RTC
209 case INFO_GAP2:
210#endif
211 return "";
212#if CONFIG_RTC 178#if CONFIG_RTC
213 case INFO_TIME: 179 case INFO_TIME:
214 tm = get_time(); 180 tm = get_time();
@@ -220,11 +186,10 @@ static char* info_getname(int selected_item, void *data, char *buffer)
220 break; 186 break;
221 case INFO_DATE: 187 case INFO_DATE:
222 tm = get_time(); 188 tm = get_time();
223 snprintf(buffer, MAX_PATH, "%s %d %s %d", 189 snprintf(buffer, MAX_PATH, "%s %d %d",
224 str(dayname[tm->tm_wday]), 190 str(LANG_MONTH_JANUARY + tm->tm_mon),
225 tm->tm_year+1900, 191 tm->tm_mday,
226 str(monthname[tm->tm_mon]), 192 tm->tm_year+1900);
227 tm->tm_mday);
228 break; 193 break;
229#endif 194#endif
230 case INFO_BUFFER: /* buffer */ 195 case INFO_BUFFER: /* buffer */
@@ -379,30 +344,12 @@ static int info_action_callback(int action, struct gui_synclist *lists)
379#ifdef HAVE_MULTIVOLUME 344#ifdef HAVE_MULTIVOLUME
380 if (fat_ismounted(1)) 345 if (fat_ismounted(1))
381 fat_recalc_free(1); 346 fat_recalc_free(1);
382#endif 347#endif
348#else
349 (void) lists;
383#endif 350#endif
384 return ACTION_REDRAW; 351 return ACTION_REDRAW;
385 } 352 }
386 else if (lists->gui_list[SCREEN_MAIN].show_selection_marker == true)
387 {
388 if (lists->gui_list[SCREEN_MAIN].selected_item == INFO_GAP1
389#if CONFIG_RTC
390 || lists->gui_list[SCREEN_MAIN].selected_item == INFO_GAP2
391#endif
392 )
393 {
394 if (action == ACTION_STD_PREV)
395 {
396 gui_synclist_select_item(lists, lists->gui_list[SCREEN_MAIN].selected_item-1);
397 return ACTION_REDRAW;
398 }
399 else if (action == ACTION_STD_NEXT)
400 {
401 gui_synclist_select_item(lists, lists->gui_list[SCREEN_MAIN].selected_item+1);
402 return ACTION_REDRAW;
403 }
404 }
405 }
406 return action; 353 return action;
407} 354}
408static bool show_info(void) 355static bool show_info(void)
diff --git a/apps/screens.c b/apps/screens.c
index f890f62eab..703ec7badb 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -791,9 +791,6 @@ void charging_splash(void)
791 791
792#if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) 792#if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
793 793
794extern const int dayname[];
795extern const int monthname[];
796
797/* little helper function for voice output */ 794/* little helper function for voice output */
798static void say_time(int cursorpos, const struct tm *tm) 795static void say_time(int cursorpos, const struct tm *tm)
799{ 796{
@@ -870,7 +867,7 @@ bool set_time_screen(const char* title, struct tm *tm)
870 ptr[1] = buffer + 3; /* minutes */ 867 ptr[1] = buffer + 3; /* minutes */
871 ptr[2] = buffer + 6; /* seconds */ 868 ptr[2] = buffer + 6; /* seconds */
872 ptr[3] = buffer + 9; /* year */ 869 ptr[3] = buffer + 9; /* year */
873 ptr[4] = str(monthname[tm->tm_mon]); /* monthname */ 870 ptr[4] = str(LANG_MONTH_JANUARY + tm->tm_mon); /* monthname */
874 ptr[5] = buffer + 14; /* day of month */ 871 ptr[5] = buffer + 14; /* day of month */
875 872
876 /* calculate the number of days in febuary */ 873 /* calculate the number of days in febuary */
@@ -949,7 +946,7 @@ bool set_time_screen(const char* title, struct tm *tm)
949 cursor[2][INDEX_Y] = prev_line_height + statusbar_height; 946 cursor[2][INDEX_Y] = prev_line_height + statusbar_height;
950 947
951 /* weekday */ 948 /* weekday */
952 screens[s].getstringsize(str(dayname[tm->tm_wday]), &weekday_width, NULL); 949 screens[s].getstringsize(str(LANG_WEEKDAY_SUNDAY + tm->tm_wday), &weekday_width, NULL);
953 screens[s].getstringsize(" ", &separator_width, NULL); 950 screens[s].getstringsize(" ", &separator_width, NULL);
954 951
955 /* year */ 952 /* year */
@@ -974,7 +971,7 @@ bool set_time_screen(const char* title, struct tm *tm)
974 screens[s].puts_scroll(0, 0, title); 971 screens[s].puts_scroll(0, 0, title);
975 972
976 /* these are not selectable, so we draw them outside the loop */ 973 /* these are not selectable, so we draw them outside the loop */
977 screens[s].putsxy(0, cursor[3][INDEX_Y], str(dayname[tm->tm_wday])); /* name of the week day */ 974 screens[s].putsxy(0, cursor[3][INDEX_Y], str(LANG_WEEKDAY_SUNDAY + tm->tm_wday)); /* name of the week day */
978 screens[s].putsxy(cursor[1][INDEX_X] - separator_width, 975 screens[s].putsxy(cursor[1][INDEX_X] - separator_width,
979 cursor[0][INDEX_Y], SEPARATOR); 976 cursor[0][INDEX_Y], SEPARATOR);
980 screens[s].putsxy(cursor[2][INDEX_X] - separator_width, 977 screens[s].putsxy(cursor[2][INDEX_X] - separator_width,
diff --git a/firmware/export/rtc.h b/firmware/export/rtc.h
index 3d7a6d6ead..8d54e8b442 100644
--- a/firmware/export/rtc.h
+++ b/firmware/export/rtc.h
@@ -25,10 +25,6 @@
25 25
26#if CONFIG_RTC 26#if CONFIG_RTC
27 27
28extern const int dayname[];
29
30extern const int monthname[];
31
32/* Common functions for all targets */ 28/* Common functions for all targets */
33void rtc_init(void); 29void rtc_init(void);
34int rtc_read_datetime(unsigned char* buf); 30int rtc_read_datetime(unsigned char* buf);