forked from len0rd/rockbox
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
This commit is contained in:
parent
1e45eecb23
commit
fda41b892e
4 changed files with 13 additions and 73 deletions
|
@ -1160,12 +1160,12 @@ static char *get_token_value(struct gui_wps *gwps,
|
||||||
|
|
||||||
case WPS_TOKEN_RTC_WEEKDAY_NAME:
|
case WPS_TOKEN_RTC_WEEKDAY_NAME:
|
||||||
/* a: abbreviated weekday name (Sun..Sat) */
|
/* a: abbreviated weekday name (Sun..Sat) */
|
||||||
snprintf(buf, buf_size, "%s",str(dayname[tm->tm_wday]));
|
snprintf(buf, buf_size, "%s",str(LANG_WEEKDAY_SUNDAY + tm->tm_wday));
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
case WPS_TOKEN_RTC_MONTH_NAME:
|
case WPS_TOKEN_RTC_MONTH_NAME:
|
||||||
/* b: abbreviated month name (Jan..Dec) */
|
/* b: abbreviated month name (Jan..Dec) */
|
||||||
snprintf(buf, buf_size, "%s",str(monthname[tm->tm_mon]));
|
snprintf(buf, buf_size, "%s",str(LANG_MONTH_JANUARY + tm->tm_mon));
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
|
case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
|
||||||
|
|
|
@ -131,11 +131,9 @@ struct info_data
|
||||||
enum infoscreenorder
|
enum infoscreenorder
|
||||||
{
|
{
|
||||||
INFO_VERSION = 0,
|
INFO_VERSION = 0,
|
||||||
INFO_GAP1,
|
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
INFO_TIME,
|
INFO_TIME,
|
||||||
INFO_DATE,
|
INFO_DATE,
|
||||||
INFO_GAP2,
|
|
||||||
#endif
|
#endif
|
||||||
INFO_BUFFER,
|
INFO_BUFFER,
|
||||||
INFO_BATTERY,
|
INFO_BATTERY,
|
||||||
|
@ -143,34 +141,7 @@ enum infoscreenorder
|
||||||
INFO_DISK2, /* free space or external capacity/free on hotswap */
|
INFO_DISK2, /* free space or external capacity/free on hotswap */
|
||||||
INFO_COUNT
|
INFO_COUNT
|
||||||
};
|
};
|
||||||
#if CONFIG_RTC
|
|
||||||
const int dayname[] =
|
|
||||||
{
|
|
||||||
LANG_WEEKDAY_SUNDAY,
|
|
||||||
LANG_WEEKDAY_MONDAY,
|
|
||||||
LANG_WEEKDAY_TUESDAY,
|
|
||||||
LANG_WEEKDAY_WEDNESDAY,
|
|
||||||
LANG_WEEKDAY_THURSDAY,
|
|
||||||
LANG_WEEKDAY_FRIDAY,
|
|
||||||
LANG_WEEKDAY_SATURDAY
|
|
||||||
};
|
|
||||||
|
|
||||||
const int monthname[] =
|
|
||||||
{
|
|
||||||
LANG_MONTH_JANUARY,
|
|
||||||
LANG_MONTH_FEBRUARY,
|
|
||||||
LANG_MONTH_MARCH,
|
|
||||||
LANG_MONTH_APRIL,
|
|
||||||
LANG_MONTH_MAY,
|
|
||||||
LANG_MONTH_JUNE,
|
|
||||||
LANG_MONTH_JULY,
|
|
||||||
LANG_MONTH_AUGUST,
|
|
||||||
LANG_MONTH_SEPTEMBER,
|
|
||||||
LANG_MONTH_OCTOBER,
|
|
||||||
LANG_MONTH_NOVEMBER,
|
|
||||||
LANG_MONTH_DECEMBER
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
static char* info_getname(int selected_item, void *data, char *buffer)
|
static char* info_getname(int selected_item, void *data, char *buffer)
|
||||||
{
|
{
|
||||||
struct info_data *info = (struct info_data*)data;
|
struct info_data *info = (struct info_data*)data;
|
||||||
|
@ -204,11 +175,6 @@ static char* info_getname(int selected_item, void *data, char *buffer)
|
||||||
snprintf(buffer, MAX_PATH, "%s: %s",
|
snprintf(buffer, MAX_PATH, "%s: %s",
|
||||||
str(LANG_VERSION), appsversion);
|
str(LANG_VERSION), appsversion);
|
||||||
break;
|
break;
|
||||||
case INFO_GAP1:
|
|
||||||
#if CONFIG_RTC
|
|
||||||
case INFO_GAP2:
|
|
||||||
#endif
|
|
||||||
return "";
|
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
case INFO_TIME:
|
case INFO_TIME:
|
||||||
tm = get_time();
|
tm = get_time();
|
||||||
|
@ -220,11 +186,10 @@ static char* info_getname(int selected_item, void *data, char *buffer)
|
||||||
break;
|
break;
|
||||||
case INFO_DATE:
|
case INFO_DATE:
|
||||||
tm = get_time();
|
tm = get_time();
|
||||||
snprintf(buffer, MAX_PATH, "%s %d %s %d",
|
snprintf(buffer, MAX_PATH, "%s %d %d",
|
||||||
str(dayname[tm->tm_wday]),
|
str(LANG_MONTH_JANUARY + tm->tm_mon),
|
||||||
tm->tm_year+1900,
|
tm->tm_mday,
|
||||||
str(monthname[tm->tm_mon]),
|
tm->tm_year+1900);
|
||||||
tm->tm_mday);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case INFO_BUFFER: /* buffer */
|
case INFO_BUFFER: /* buffer */
|
||||||
|
@ -380,29 +345,11 @@ static int info_action_callback(int action, struct gui_synclist *lists)
|
||||||
if (fat_ismounted(1))
|
if (fat_ismounted(1))
|
||||||
fat_recalc_free(1);
|
fat_recalc_free(1);
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
(void) lists;
|
||||||
#endif
|
#endif
|
||||||
return ACTION_REDRAW;
|
return ACTION_REDRAW;
|
||||||
}
|
}
|
||||||
else if (lists->gui_list[SCREEN_MAIN].show_selection_marker == true)
|
|
||||||
{
|
|
||||||
if (lists->gui_list[SCREEN_MAIN].selected_item == INFO_GAP1
|
|
||||||
#if CONFIG_RTC
|
|
||||||
|| lists->gui_list[SCREEN_MAIN].selected_item == INFO_GAP2
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (action == ACTION_STD_PREV)
|
|
||||||
{
|
|
||||||
gui_synclist_select_item(lists, lists->gui_list[SCREEN_MAIN].selected_item-1);
|
|
||||||
return ACTION_REDRAW;
|
|
||||||
}
|
|
||||||
else if (action == ACTION_STD_NEXT)
|
|
||||||
{
|
|
||||||
gui_synclist_select_item(lists, lists->gui_list[SCREEN_MAIN].selected_item+1);
|
|
||||||
return ACTION_REDRAW;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
static bool show_info(void)
|
static bool show_info(void)
|
||||||
|
|
|
@ -791,9 +791,6 @@ void charging_splash(void)
|
||||||
|
|
||||||
#if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
|
#if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
|
||||||
|
|
||||||
extern const int dayname[];
|
|
||||||
extern const int monthname[];
|
|
||||||
|
|
||||||
/* little helper function for voice output */
|
/* little helper function for voice output */
|
||||||
static void say_time(int cursorpos, const struct tm *tm)
|
static void say_time(int cursorpos, const struct tm *tm)
|
||||||
{
|
{
|
||||||
|
@ -870,7 +867,7 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
ptr[1] = buffer + 3; /* minutes */
|
ptr[1] = buffer + 3; /* minutes */
|
||||||
ptr[2] = buffer + 6; /* seconds */
|
ptr[2] = buffer + 6; /* seconds */
|
||||||
ptr[3] = buffer + 9; /* year */
|
ptr[3] = buffer + 9; /* year */
|
||||||
ptr[4] = str(monthname[tm->tm_mon]); /* monthname */
|
ptr[4] = str(LANG_MONTH_JANUARY + tm->tm_mon); /* monthname */
|
||||||
ptr[5] = buffer + 14; /* day of month */
|
ptr[5] = buffer + 14; /* day of month */
|
||||||
|
|
||||||
/* calculate the number of days in febuary */
|
/* calculate the number of days in febuary */
|
||||||
|
@ -949,7 +946,7 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
cursor[2][INDEX_Y] = prev_line_height + statusbar_height;
|
cursor[2][INDEX_Y] = prev_line_height + statusbar_height;
|
||||||
|
|
||||||
/* weekday */
|
/* weekday */
|
||||||
screens[s].getstringsize(str(dayname[tm->tm_wday]), &weekday_width, NULL);
|
screens[s].getstringsize(str(LANG_WEEKDAY_SUNDAY + tm->tm_wday), &weekday_width, NULL);
|
||||||
screens[s].getstringsize(" ", &separator_width, NULL);
|
screens[s].getstringsize(" ", &separator_width, NULL);
|
||||||
|
|
||||||
/* year */
|
/* year */
|
||||||
|
@ -974,7 +971,7 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
screens[s].puts_scroll(0, 0, title);
|
screens[s].puts_scroll(0, 0, title);
|
||||||
|
|
||||||
/* these are not selectable, so we draw them outside the loop */
|
/* these are not selectable, so we draw them outside the loop */
|
||||||
screens[s].putsxy(0, cursor[3][INDEX_Y], str(dayname[tm->tm_wday])); /* name of the week day */
|
screens[s].putsxy(0, cursor[3][INDEX_Y], str(LANG_WEEKDAY_SUNDAY + tm->tm_wday)); /* name of the week day */
|
||||||
screens[s].putsxy(cursor[1][INDEX_X] - separator_width,
|
screens[s].putsxy(cursor[1][INDEX_X] - separator_width,
|
||||||
cursor[0][INDEX_Y], SEPARATOR);
|
cursor[0][INDEX_Y], SEPARATOR);
|
||||||
screens[s].putsxy(cursor[2][INDEX_X] - separator_width,
|
screens[s].putsxy(cursor[2][INDEX_X] - separator_width,
|
||||||
|
|
|
@ -25,10 +25,6 @@
|
||||||
|
|
||||||
#if CONFIG_RTC
|
#if CONFIG_RTC
|
||||||
|
|
||||||
extern const int dayname[];
|
|
||||||
|
|
||||||
extern const int monthname[];
|
|
||||||
|
|
||||||
/* Common functions for all targets */
|
/* Common functions for all targets */
|
||||||
void rtc_init(void);
|
void rtc_init(void);
|
||||||
int rtc_read_datetime(unsigned char* buf);
|
int rtc_read_datetime(unsigned char* buf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue