main.c: added buttons
This commit is contained in:
parent
e70abcd005
commit
afe2d53178
1 changed files with 43 additions and 0 deletions
43
Src/main.c
43
Src/main.c
|
@ -107,6 +107,9 @@ void Paint_DrawWeekday(void);
|
|||
void Paint_DrawCurrent(uint8_t weekday);
|
||||
void Paint_DrawLoad(bool draw_yes);
|
||||
bool System_SecondHeartbeat(void);
|
||||
void ButtonLeft_Pressed(void);
|
||||
void ButtonPress_Pressed(void);
|
||||
void ButtonRight_Pressed(void);
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
|
@ -469,6 +472,46 @@ static void MX_GPIO_Init(void)
|
|||
|
||||
/* USER CODE BEGIN 4 */
|
||||
|
||||
//keep it short, executed in ISR
|
||||
void ButtonLeft_Pressed(void){
|
||||
if(system_mode==Choose){
|
||||
Change_selectorpos(true);
|
||||
}
|
||||
if(system_mode==Set){
|
||||
Change_time(selector_pos,true);
|
||||
}
|
||||
};
|
||||
//keep it short, executed in ISR
|
||||
void ButtonPress_Pressed(void){
|
||||
if(selector_pos==28 || selector_pos == 29 || selector_pos == 30){
|
||||
if(system_mode == Choose){ //read time to sTimeSet
|
||||
Read_intosettime();
|
||||
}
|
||||
if(system_mode == Set){ //write time back to RTC
|
||||
Write_intostime();
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Change_systemmode();
|
||||
};
|
||||
//keep it short, executed in ISR
|
||||
void ButtonRight_Pressed(void){
|
||||
if(system_mode==Choose){
|
||||
Change_selectorpos(false);
|
||||
}
|
||||
if(system_mode==Set){
|
||||
Change_time(selector_pos,false);
|
||||
}
|
||||
};
|
||||
|
||||
int __io_putchar(int ch){
|
||||
uint8_t c[1];
|
||||
c[0] = ch & 0x00FF;
|
||||
|
|
Loading…
Reference in a new issue