From: Leo C Date: Mon, 1 Dec 2014 10:13:52 +0000 (+0100) Subject: put weekdays[] in flash, workaround for wrong weekday display X-Git-Tag: hexrel-4~12 X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/commitdiff_plain/c93a1fd4f52e215c7fde5a207fff66015d0c4822 put weekdays[] in flash, workaround for wrong weekday display --- 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 -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); } - diff --git a/avr/date.c b/avr/date.c index c85361f..5caee2f 100644 --- a/avr/date.c +++ b/avr/date.c @@ -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 */ } - diff --git a/include/config.h b/include/config.h index 82dbf81..d0749b3 100644 --- a/include/config.h +++ b/include/config.h @@ -1,11 +1,11 @@ -#ifndef CONFIG_H +#ifndef CONFIG_H #define CONFIG_H /* Environment variables */ #define ENV_BAUDRATE "baudrate" #define ENV_BOOTDELAY "bootdelay" -#define ENV_BOOTCMD "bootcmd" +#define ENV_BOOTCMD "bootcmd" #define ENV_PINALIAS "pin_alias" #define CONFIG_ENV_SIZE 1600 @@ -13,7 +13,7 @@ #define CONFIG_ENVVAR_MAX 20 #define CONFIG_BAUDRATE 115200L -#define CONFIG_PWRON_DELAY 2000 /* ms to wait after power on */ +#define CONFIG_PWRON_DELAY 2000 /* ms to wait after power on */ #define CONFIG_BOOTDELAY 4 //#define CONFIG_ZERO_BOOTDELAY_CHECK 1 @@ -42,4 +42,3 @@ #define CONFIG_SYS_LONGHELP 1 #endif /* CONFIG_H */ -