main: added button for changing system_mode to offscreen
This commit is contained in:
parent
e0fb9cd4ab
commit
ebae8286fc
2 changed files with 11 additions and 2 deletions
|
@ -92,6 +92,8 @@ void Error_Handler(void);
|
||||||
#define ButtonPress_GPIO_Port GPIOB
|
#define ButtonPress_GPIO_Port GPIOB
|
||||||
#define ButtonRight_Pin GPIO_PIN_14
|
#define ButtonRight_Pin GPIO_PIN_14
|
||||||
#define ButtonRight_GPIO_Port GPIOB
|
#define ButtonRight_GPIO_Port GPIOB
|
||||||
|
#define system_mode_Pin GPIO_PIN_15
|
||||||
|
#define system_mode_GPIO_Port GPIOB
|
||||||
#define LED_Pin GPIO_PIN_8
|
#define LED_Pin GPIO_PIN_8
|
||||||
#define LED_GPIO_Port GPIOB
|
#define LED_GPIO_Port GPIOB
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
11
Src/main.c
11
Src/main.c
|
@ -229,6 +229,13 @@ int main(void)
|
||||||
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14)){
|
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14)){
|
||||||
ButtonRight_Pressed();
|
ButtonRight_Pressed();
|
||||||
}
|
}
|
||||||
|
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_15)){
|
||||||
|
if(system_mode == Running){
|
||||||
|
system_mode = Offscreen;
|
||||||
|
}else{
|
||||||
|
system_mode = Running;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -443,8 +450,8 @@ static void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : ButtonLeft_Pin ButtonPress_Pin ButtonRight_Pin */
|
/*Configure GPIO pins : ButtonLeft_Pin ButtonPress_Pin ButtonRight_Pin system_mode_Pin */
|
||||||
GPIO_InitStruct.Pin = ButtonLeft_Pin|ButtonPress_Pin|ButtonRight_Pin;
|
GPIO_InitStruct.Pin = ButtonLeft_Pin|ButtonPress_Pin|ButtonRight_Pin|system_mode_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
Loading…
Reference in a new issue