diff options
author | Leo C | 2014-12-01 11:13:52 +0100 |
---|---|---|
committer | Leo C | 2014-12-01 11:13:52 +0100 |
commit | c93a1fd4f52e215c7fde5a207fff66015d0c4822 (patch) | |
tree | 8c98c7d76c623951c2735c457ac1ca65a990161f /avr | |
parent | 4565be9a755c4de8ffdbc8b9a7b2d87c87f7a9e1 (diff) | |
download | z180-stamp-c93a1fd4f52e215c7fde5a207fff66015d0c4822.zip |
put weekdays[] in flash, workaround for wrong weekday display
Diffstat (limited to 'avr')
-rw-r--r-- | avr/cmd_date.c | 25 | ||||
-rw-r--r-- | avr/date.c | 3 |
2 files changed, 16 insertions, 12 deletions
diff --git a/avr/cmd_date.c b/avr/cmd_date.c index ad0d3ac..337d720 100644 --- a/avr/cmd_date.c +++ b/avr/cmd_date.c @@ -15,8 +15,14 @@ #include <i2c.h> -static const char * const weekdays[] = { - "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", +static const FLASH char * const FLASH weekdays[] = { + FSTR("Mon"), + FSTR("Tues"), + FSTR("Wednes"), + FSTR("Thurs"), + FSTR("Fri"), + FSTR("Satur"), + FSTR("Sun") }; int mk_date (const char *, struct rtc_time *); @@ -25,7 +31,7 @@ command_ret_t do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { struct rtc_time tm; int rcode = CMD_RET_SUCCESS; - + (void) cmdtp; (void) flag; switch (argc) { @@ -54,14 +60,14 @@ command_ret_t do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) my_puts_P(PSTR("## Get date failed\n")); break; } - /* TODO: put weekdays[] in flash */ - printf_P(PSTR("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n"), - tm.tm_year, tm.tm_mon, tm.tm_mday, - (tm.tm_wday<0 || tm.tm_wday>6) ? - "unknown " : weekdays[tm.tm_wday], + printf_P(PSTR("Date: %4d-%02d-%02d ("), + tm.tm_year, tm.tm_mon, tm.tm_mday); + my_puts_P( (tm.tm_wday<0 || tm.tm_wday>6) ? + PSTR("unknown ") : weekdays[tm.tm_wday]); + printf_P(PSTR("day) Time: %2d:%02d:%02d\n"), tm.tm_hour, tm.tm_min, tm.tm_sec); - break; + default: rcode = CMD_RET_USAGE; } @@ -179,4 +185,3 @@ int mk_date (const char *datestr, struct rtc_time *tmp) return (-1); } - @@ -23,7 +23,7 @@ #define days_in_month(a) (month_days[(a) - 1]) -static const FLASH int MonthOffset[] = { +static const FLASH int MonthOffset[] = { 0,31,59,90,120,151,181,212,243,273,304,334 }; @@ -136,4 +136,3 @@ mktime (unsigned int year, unsigned int mon, )*60 + min /* now have minutes */ )*60 + sec; /* finally seconds */ } - |