/* * 函数名:Time_Display * 描述 :显示当前时间值 * 输入 :-TimeVar RTC计数值,单位为 s * 输出 :无 * 调用 :内部调用 */ void Time_Display(uint32_t TimeVar,struct rtc_time *tm) { static uint32_t FirstDisplay = 1; uint32_t BJ_TimeVar; uint8_t str[15]; // 字符串暂存 /* 把标准时间转换为北京时间*/ BJ_TimeVar =TimeVar + 8*60*60; to_tm(BJ_TimeVar, tm);/*把定时器的值转换为北京时间*/ if((!tm->tm_hour && !tm->tm_min && !tm->tm_sec) || (FirstDisplay)) { GetChinaCalendar((u16)tm->tm_year, (u8)tm->tm_mon, (u8)tm->tm_mday, str); printf("\r\n\r\n 今天农历:%0.2d%0.2d,%0.2d,%0.2d", str[0], str[1], str[2], str[3]); GetChinaCalendarStr((u16)tm->tm_year,(u8)tm->tm_mon,(u8)tm->tm_mday,str); printf(" %s", str); if(GetJieQiStr((u16)tm->tm_year, (u8)tm->tm_mon, (u8)tm->tm_mday, str)) printf(" %s\n\r", str); FirstDisplay = 0; } /* 输出时间戳,公历时间 */ printf("\r UNIX时间戳 = %d ,当前时间为: %d年(%s年) %d月 %d日 (星期%s) %0.2d:%0.2d:%0.2d",TimeVar, tm->tm_year, zodiac_sign[(tm->tm_year-3)%12], tm->tm_mon, tm->tm_mday, WEEK_STR[tm->tm_wday], tm->tm_hour, tm->tm_min, tm->tm_sec); }
/* * 函数名:Time_Display * 描述 :显示当前时间值 * 输入 :-TimeVar RTC计数值,单位为 s * 输出 :无 * 调用 :内部调用 */ void Time_Display(uint32_t TimeVar,struct rtc_time *tm) { static uint32_t FirstDisplay = 1; uint32_t BJ_TimeVar; uint8_t str[15]; // 字符串暂存 #ifdef LCD_DISPLAY uint8_t lcd_char[70]; #endif /* 把标准时间转换为北京时间*/ BJ_TimeVar =TimeVar + 8*60*60; to_tm(BJ_TimeVar, tm);/*把定时器的值转换为北京时间*/ if((!tm->tm_hour && !tm->tm_min && !tm->tm_sec) || (FirstDisplay)) { GetChinaCalendar((u16)tm->tm_year, (u8)tm->tm_mon, (u8)tm->tm_mday, str); printf("\r\n 今天新历:%0.2d%0.2d,%0.2d,%0.2d", str[0], str[1], str[2], str[3]); GetChinaCalendarStr((u16)tm->tm_year,(u8)tm->tm_mon,(u8)tm->tm_mday,str); printf("\r\n 今天农历:%s\r\n", str); if(GetJieQiStr((u16)tm->tm_year, (u8)tm->tm_mon, (u8)tm->tm_mday, str)) printf("\r\n 今天农历:%s\r\n", str); FirstDisplay = 0; } #ifdef LCD_DISPLAY sprintf(lcd_char,"%d年(%s年)%d月%d日(星期%s) %0.2d:%0.2d:%0.2d" ,tm->tm_year, zodiac_sign[(tm->tm_year-3)%12], tm->tm_mon, tm->tm_mday, WEEK_STR[tm->tm_wday], tm->tm_hour, tm->tm_min, tm->tm_sec); LCD_DispEnCh(20,180,lcd_char,BLUE); #endif /* 输出时间戳,公历时间 */ printf(" UNIX时间戳 = %d 当前时间为: %d年(%s年) %d月 %d日 (星期%s) %0.2d:%0.2d:%0.2d\r",TimeVar, tm->tm_year, zodiac_sign[(tm->tm_year-3)%12], tm->tm_mon, tm->tm_mday, WEEK_STR[tm->tm_wday], tm->tm_hour, tm->tm_min, tm->tm_sec); }