add __DATA__ for rt_calendar

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@429 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
gary.li.wenchao.4 2010-02-21 02:34:28 +00:00
parent faffc442b9
commit ab13173bf8
2 changed files with 24 additions and 7 deletions

View File

@ -42,7 +42,7 @@ if rtconfig.RT_USING_RTGUI:
objs = objs + SConscript(RTT_ROOT + '/rtgui/SConscript', variant_dir='build/rtgui', duplicate=0)
objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript', variant_dir='build/examples/gui', duplicate=0)
src_bsp = ['application.c', 'startup.c', 'board.c']
src_bsp = ['application.c', 'startup.c', 'board.c', 'rtc_calendar.c' ]
src_drv = ['console.c', 'led.c']
if rtconfig.RT_USING_DFS:

View File

@ -10,6 +10,7 @@
* Change Logs:
* Date Author Notes
* 2010-02-10 Gary Lee first implementation
* 2010-02-21 Gary Lee add __DATA__
*/
#include "rtc_calendar.h"
@ -209,18 +210,35 @@ void rt_rtc_weekdate_calculate(void)
}
extern char *rt_strlcpy(char *dest, const char *src, rt_ubase_t n);
rt_uint8_t *list_month[12]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
void rt_calendar(void)
{
rt_uint32_t year;
//static rt_uint8_t receive_char;
static rt_int32_t year;
rt_uint8_t i = 0;
rt_int32_t result, num_month, num_year;
rt_uint8_t date_year[7], date_month[3], *date = __DATE__;
rt_strlcpy((char *)date_month, (const char *)date, 3);
date += 7;
rt_strlcpy((char *)date_year, (const char *)date, 4);
date = RT_NULL;
num_year = atoi(date_year);
do{
result = strcmp((const char *)date_month, (const char *)list_month[i++]);
if(result !=0)
result = 1;
else
num_month = i;
}while(result);
i = 0;
result = 1;
year = num_year*100 + num_month;
//year = Uart_GetIntNum_MT();
year = 201002;
//rt_kprintf("\nThe date is %d\n", year);
rt_rtc_year_month_day_seperate(year);
if (day_seprt == 0 && month_seprt == 0) {
//rt_kprintf("\nYear: %d\n", year_seprt);
rt_rtc_print_calendar(year_seprt);
@ -232,7 +250,6 @@ void rt_calendar(void)
} else {
//rt_kprintf("\n%d/%d/%d\n", year_seprt, month_seprt, day_seprt);
rt_rtc_weekdate_calculate();
}
}
#ifdef RT_USING_FINSH