/** * @brief Display the current date on the Hyperterminal. * @param None * @retval None */ void RTC_DateShow(void) { /* Get the current Date */ RTC_GetDate(RTC_Format_BCD, &RTC_DateStructure); /* Set the Back Color */ LCD_SetBackColor(LCD_COLOR_WHITE); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_BLUE); LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)"Current Date Display"); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_BLACK); RTC_Time_display( LCD_LINE_7, Black, RTC_Get_Date( &RTC_DateStructure)); }
/** * @brief Display the current TimeStamp (time and date) on the Hyperterminal. * @param None * @retval None */ void RTC_TimeStampShow(void) { /* Get the current TimeStamp */ RTC_GetTimeStamp(RTC_Format_BCD, &RTC_TimeStampStructure, &RTC_TimeStampDateStructure); /* Set the Back Color */ LCD_SetBackColor(LCD_COLOR_WHITE); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_BLUE); LCD_DisplayStringLine(LCD_LINE_8, (uint8_t *)"TimeStamp Display"); /* Display the curent time and the sub second on the LCD */ LCD_DisplayStringLine(LCD_LINE_9, (uint8_t *) " Time"); RTC_Time_display(LCD_LINE_9, Black , RTC_Get_Time(uwSecondfraction , &RTC_TimeStampStructure)); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_BLUE); LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *) " Date"); RTC_Time_display(LCD_LINE_10, Black, RTC_Get_Date( &RTC_TimeStampDateStructure)); }
/** * @brief Display the current TimeStamp (time and date) on the Hyperterminal. * @param None * @retval None */ static void RTC_TimeStampShow(void) { RTC_TimeTypeDef RTC_TimeStampStructure; RTC_DateTypeDef RTC_TimeStampDateStructure; /* Get the current TimeStamp */ RTC_GetTimeStamp(RTC_Format_BCD, &RTC_TimeStampStructure, &RTC_TimeStampDateStructure); /* Set the Back Color */ LCD_SetBackColor(LCD_COLOR_WHITE); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_BLUE); LCD_SetFont(&Font16x24); LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"TimeStamp Display"); /* Display the curent time and the sub second on the LCD */ LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *) "Time"); RTC_Time_display(LCD_LINE_5, Black , RTC_Get_Time(Secondfraction , &RTC_TimeStampStructure)); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_BLUE); LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *) "Date"); RTC_Time_display(LCD_LINE_6, Black, RTC_Get_Date( &RTC_TimeStampDateStructure)); }
/*********************************************************************** module : [机器设置操作] function : [设置时间] return : [0:成功 其它:失败] comment : [全局普通函数] machine : [EH-0818] language : [CHN] keyword : [MAC_SET] date : [11/07/21] author : [chen-zhengkai] ************************************************************************/ int setDate() { typ_DATE tdate; const char returnStr[] = "按任意键返回"; const char cueStr[] = "请输入日期:"; char dBuf[40] = {0}; int ret = 0; int year = 0; int month = 0; int day = 0; int day_max = 0; char str1[20] = {0}; char str2[20] = {0}; char str3[20] = {0}; RTC_Get_Date(&tdate); year = tdate.year; month = tdate.month; day = tdate.day; strcpy(str1,"年:"); strcpy(str2,"月:"); strcpy(str3,"日:"); while (1) { // sprintf(dBuf,"%04d/%02d/%02d",year,month,day); // DispStr_CE(0,0,dBuf,DISP_CENTER|DISP_CLRSCR); DispStr_CE(0,0,cueStr,DISP_CENTER|DISP_CLRSCR); DispStr_CE(0,4,str1,DISP_POSITION); DispStr_CE(0,8,str2,DISP_POSITION); DispStr_CE(0,12,str3,DISP_POSITION); ret = input_date_time(4,4,4,1980,2100,str1,&year); if (ret == -1) { return ret; } ret = input_date_time(8,2,1,1,12,str2,&month); if (ret == -1) { continue; } //判断每个月的天数 switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day_max = 31; break; case 4: case 6: case 9: case 11: day_max = 30; break; case 2: if ( ( ((year%4)==0)&&(year%100!=0) ) ||( (year%400)==0 ) ) { day_max = 29; } else { day_max = 28; } break; default: return -1; } ret = input_date_time(12,2,1,1,day_max,str3,&day); if (ret != -1) { tdate.year = year; tdate.month = month; tdate.day = day; tdate.week = RTC_get_week(year,month,day); RTC_Set_Date(&tdate); sprintf(dBuf,"%04d/%02d/%02d",year,month,day); DispStr_CE(0,6,dBuf,DISP_CENTER|DISP_CLRSCR); DispStr_CE(0,8,returnStr,DISP_CENTER); delay_and_wait_key( 3, EXIT_KEY_ALL, 0 ); return 0; } } }