diff --git a/Inc/main.h b/Inc/main.h index 4b6b464..1789065 100644 --- a/Inc/main.h +++ b/Inc/main.h @@ -92,6 +92,8 @@ void Error_Handler(void); #define ButtonPress_GPIO_Port GPIOB #define ButtonRight_Pin GPIO_PIN_14 #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_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ diff --git a/Src/main.c b/Src/main.c index 03086aa..65a605b 100644 --- a/Src/main.c +++ b/Src/main.c @@ -229,6 +229,13 @@ int main(void) if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14)){ 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; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : ButtonLeft_Pin ButtonPress_Pin ButtonRight_Pin */ - GPIO_InitStruct.Pin = 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|system_mode_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);