main: draw current time with the colon heartbeating every second
This commit is contained in:
parent
6799fa2de2
commit
4d3ea331f2
1 changed files with 18 additions and 4 deletions
22
Src/main.c
22
Src/main.c
|
@ -301,8 +301,10 @@ static void MX_RTC_Init(void)
|
||||||
/* USER CODE BEGIN RTC_Init 0 */
|
/* USER CODE BEGIN RTC_Init 0 */
|
||||||
|
|
||||||
/* USER CODE END RTC_Init 0 */
|
/* USER CODE END RTC_Init 0 */
|
||||||
RTC_DateTypeDef DateToUpdate = {0};
|
|
||||||
RTC_TimeTypeDef sTime = {0};
|
RTC_TimeTypeDef sTime = {0};
|
||||||
|
RTC_DateTypeDef DateToUpdate = {0};
|
||||||
|
|
||||||
/* USER CODE BEGIN RTC_Init 1 */
|
/* USER CODE BEGIN RTC_Init 1 */
|
||||||
|
|
||||||
/* USER CODE END RTC_Init 1 */
|
/* USER CODE END RTC_Init 1 */
|
||||||
|
@ -332,7 +334,7 @@ static void MX_RTC_Init(void)
|
||||||
}
|
}
|
||||||
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||||
DateToUpdate.Month = RTC_MONTH_JANUARY;
|
DateToUpdate.Month = RTC_MONTH_JANUARY;
|
||||||
DateToUpdate.Date = 0x2;
|
DateToUpdate.Date = 0x1;
|
||||||
DateToUpdate.Year = 0x0;
|
DateToUpdate.Year = 0x0;
|
||||||
|
|
||||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK)
|
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK)
|
||||||
|
@ -495,9 +497,21 @@ void Paint_DrawCurrent(){
|
||||||
sPaint_time.Sec = sTimeSet.Seconds;
|
sPaint_time.Sec = sTimeSet.Seconds;
|
||||||
weekday = setWeekday;
|
weekday = setWeekday;
|
||||||
}
|
}
|
||||||
|
|
||||||
Paint_ClearWindows(50, 175, 50 + Font24.Width * 7, 175 + Font24.Height, WHITE);
|
Paint_ClearWindows(50, 175, 50 + Font24.Width * 7, 175 + Font24.Height, WHITE);
|
||||||
Paint_DrawTime(50,175, &sPaint_time, &Font24, WHITE, BLACK);
|
|
||||||
|
uint8_t value[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||||
|
UWORD Dx = Font24.Width;
|
||||||
|
//Write data into the cache
|
||||||
|
Paint_DrawChar(50 , 175, value[sPaint_time.Hour / 10], &Font24, WHITE, BLACK);
|
||||||
|
Paint_DrawChar(50 + Dx , 175, value[sPaint_time.Hour % 10], &Font24, WHITE, BLACK);
|
||||||
|
if(System_CustomHeartbeat(2)){
|
||||||
|
Paint_DrawChar(50 + Dx + Dx / 4 + Dx / 2 , 175, ':' , &Font24, WHITE, BLACK);
|
||||||
|
}else{
|
||||||
|
Paint_ClearWindows(80 , 175, 80 + Font24.Width * 7, 175 + Font24.Height, WHITE);
|
||||||
|
}
|
||||||
|
Paint_DrawChar(50 + Dx * 2 + Dx / 2 , 175, value[sPaint_time.Min / 10] , &Font24, WHITE, BLACK);
|
||||||
|
Paint_DrawChar(50 + Dx * 3 + Dx / 2 , 175, value[sPaint_time.Min % 10] , &Font24, WHITE, BLACK);
|
||||||
|
// Paint_DrawTime(50,175, &sPaint_time, &Font24, WHITE, BLACK);
|
||||||
Paint_DrawChar(140,175,WeekLetter[weekday][0],&Font20,WHITE,BLACK);
|
Paint_DrawChar(140,175,WeekLetter[weekday][0],&Font20,WHITE,BLACK);
|
||||||
Paint_DrawChar(152,175,WeekLetter[weekday][1],&Font20,WHITE,BLACK);
|
Paint_DrawChar(152,175,WeekLetter[weekday][1],&Font20,WHITE,BLACK);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue