main: added functions for drawing different elements
This commit is contained in:
parent
9c94b39c14
commit
a46b9b0023
1 changed files with 42 additions and 1 deletions
43
Src/main.c
43
Src/main.c
|
@ -76,6 +76,8 @@ UART_HandleTypeDef huart1;
|
||||||
|
|
||||||
PAINT_TIME sPaint_time;
|
PAINT_TIME sPaint_time;
|
||||||
RTC_TimeTypeDef sTime;
|
RTC_TimeTypeDef sTime;
|
||||||
|
RTC_TimeTypeDef sSetStart[7] = {{1,2,3},{13,2,3},{21,2,3},{25,2,3},{1,2,3},{1,2,3},{1,2,3}};
|
||||||
|
RTC_TimeTypeDef sSetEnd[7] = {{22,22,23},{23,2,23},{2,22,3},{25,22,3},{21,2,3},{21,2,3},{21,2,3}};
|
||||||
RTC_DateTypeDef sDate;
|
RTC_DateTypeDef sDate;
|
||||||
const uint8_t WeekLetter[7][2]={
|
const uint8_t WeekLetter[7][2]={
|
||||||
"Mo",
|
"Mo",
|
||||||
|
@ -86,7 +88,6 @@ const uint8_t WeekLetter[7][2]={
|
||||||
"Sa",
|
"Sa",
|
||||||
"So"
|
"So"
|
||||||
};
|
};
|
||||||
|
|
||||||
//Create a new image cache
|
//Create a new image cache
|
||||||
UBYTE *BlackImage;
|
UBYTE *BlackImage;
|
||||||
UWORD Imagesize = ((EPD_WIDTH % 8 == 0) ? (EPD_WIDTH / 8) : (EPD_WIDTH / 8 + 1)) * EPD_HEIGHT;
|
UWORD Imagesize = ((EPD_WIDTH % 8 == 0) ? (EPD_WIDTH / 8) : (EPD_WIDTH / 8 + 1)) * EPD_HEIGHT;
|
||||||
|
@ -102,6 +103,9 @@ static void MX_USART1_UART_Init(void);
|
||||||
static void MX_RTC_Init(void);
|
static void MX_RTC_Init(void);
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
void Paint_DrawTimeArray(void);
|
void Paint_DrawTimeArray(void);
|
||||||
|
void Paint_DrawWeekday(void);
|
||||||
|
void Paint_DrawCurrent(uint8_t weekday);
|
||||||
|
void Paint_DrawLoad(bool draw_yes);
|
||||||
bool System_SecondHeartbeat(void);
|
bool System_SecondHeartbeat(void);
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
@ -182,6 +186,9 @@ int main(void)
|
||||||
|
|
||||||
|
|
||||||
Paint_DrawTimeArray();
|
Paint_DrawTimeArray();
|
||||||
|
Paint_DrawWeekday();
|
||||||
|
Paint_DrawCurrent(0);
|
||||||
|
Paint_DrawLoad(System_SecondHeartbeat());
|
||||||
EPD_Display(BlackImage);
|
EPD_Display(BlackImage);
|
||||||
DEV_Delay_ms(1000); //Analog clock 1s
|
DEV_Delay_ms(1000); //Analog clock 1s
|
||||||
// printf("500ms..\r\n");
|
// printf("500ms..\r\n");
|
||||||
|
@ -202,13 +209,43 @@ int main(void)
|
||||||
}
|
}
|
||||||
void Paint_DrawTimeArray(){
|
void Paint_DrawTimeArray(){
|
||||||
for(int i=0; i<7; i++){
|
for(int i=0; i<7; i++){
|
||||||
|
sPaint_time.Hour = sSetStart[i].Hours;
|
||||||
|
sPaint_time.Min = sSetStart[i].Minutes;
|
||||||
|
sPaint_time.Sec = sSetStart[i].Seconds;
|
||||||
Paint_ClearWindows(5, i*20 + 5, 5 + Font20.Width * 7, i*20 + 5 + Font20.Height, WHITE);
|
Paint_ClearWindows(5, i*20 + 5, 5 + Font20.Width * 7, i*20 + 5 + Font20.Height, WHITE);
|
||||||
Paint_DrawTime(5, i*20 + 5, &sPaint_time, &Font20, WHITE, BLACK);
|
Paint_DrawTime(5, i*20 + 5, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
sPaint_time.Hour = sSetEnd[i].Hours;
|
||||||
|
sPaint_time.Min = sSetEnd[i].Minutes;
|
||||||
|
sPaint_time.Sec = sSetEnd[i].Seconds;
|
||||||
Paint_ClearWindows(100, i*20 + 5, 100 + Font20.Width * 7, i*20 + 5 + Font20.Height, WHITE);
|
Paint_ClearWindows(100, i*20 + 5, 100 + Font20.Width * 7, i*20 + 5 + Font20.Height, WHITE);
|
||||||
Paint_DrawTime(100, i*20 + 5, &sPaint_time, &Font20, WHITE, BLACK);
|
Paint_DrawTime(100, i*20 + 5, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Paint_DrawWeekday(){
|
||||||
|
for(uint8_t i=0; i<7 ; i++){
|
||||||
|
Paint_DrawChar(176,20*i+5,WeekLetter[i][0],&Font20,WHITE,BLACK);
|
||||||
|
Paint_DrawChar(187,20*i+5,WeekLetter[i][1],&Font20,WHITE,BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Paint_DrawCurrent(uint8_t weekday){
|
||||||
|
sPaint_time.Hour = sTime.Hours;
|
||||||
|
sPaint_time.Min = sTime.Minutes;
|
||||||
|
sPaint_time.Sec = sTime.Seconds;
|
||||||
|
Paint_ClearWindows(50, 150, 50 + Font24.Width * 7, 150 + Font24.Height, WHITE);
|
||||||
|
Paint_DrawTime(50,150, &sPaint_time, &Font24, WHITE, BLACK);
|
||||||
|
Paint_DrawChar(140,150,WeekLetter[weekday][0],&Font20,WHITE,BLACK);
|
||||||
|
Paint_DrawChar(152,150,WeekLetter[weekday][1],&Font20,WHITE,BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Paint_DrawLoad(bool draw_yes){
|
||||||
|
Paint_ClearWindows(50, 180, 70, 200, WHITE);
|
||||||
|
Paint_DrawRectangle(50, 180, 70, 200, BLACK, draw_yes, DOT_PIXEL_1X1);
|
||||||
|
}
|
||||||
|
|
||||||
bool System_SecondHeartbeat(){
|
bool System_SecondHeartbeat(){
|
||||||
if(sTime.Seconds%2 == 0){
|
if(sTime.Seconds%2 == 0){
|
||||||
return true;
|
return true;
|
||||||
|
@ -274,6 +311,10 @@ static void MX_RTC_Init(void)
|
||||||
/* USER CODE END RTC_Init 0 */
|
/* USER CODE END RTC_Init 0 */
|
||||||
|
|
||||||
RTC_TimeTypeDef sTime = {0};
|
RTC_TimeTypeDef sTime = {0};
|
||||||
|
// RTC_TimeTypeDef sSet[7] = {{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3}};
|
||||||
|
// sSet[0].Hours=1;
|
||||||
|
// sSet[0].Minutes=2;
|
||||||
|
// sSet[0].Seconds=3;
|
||||||
RTC_DateTypeDef DateToUpdate = {0};
|
RTC_DateTypeDef DateToUpdate = {0};
|
||||||
|
|
||||||
/* USER CODE BEGIN RTC_Init 1 */
|
/* USER CODE BEGIN RTC_Init 1 */
|
||||||
|
|
Loading…
Reference in a new issue