make calc nicer ish
This commit is contained in:
@@ -152,19 +152,7 @@ int main(void)
|
||||
// userloop
|
||||
while (1)
|
||||
{
|
||||
bool A_pressed = (HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_7) == GPIO_PIN_SET);
|
||||
bool B_pressed = (HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_9) == GPIO_PIN_SET);
|
||||
|
||||
if (A_pressed && B_pressed == true)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET);
|
||||
} else
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||
}
|
||||
//
|
||||
|
||||
HAL_DELAY(200); // milliseconds
|
||||
userloop(200); // 200 millisecond delay before repeat
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
||||
22
Calculator/Core/Src/userloop.c
Normal file
22
Calculator/Core/Src/userloop.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* userloop.c
|
||||
*
|
||||
* Created on: Sep 10, 2025
|
||||
* Author: ja
|
||||
*/
|
||||
void userloop(int DELAY_MS)
|
||||
{
|
||||
bool A_pressed = (HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_7) == GPIO_PIN_SET);
|
||||
bool B_pressed = (HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_9) == GPIO_PIN_SET);
|
||||
|
||||
if (A_pressed && B_pressed == true)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET);
|
||||
} else
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||
}
|
||||
//
|
||||
|
||||
HAL_DELAY(DELAY_MS); // milliseconds
|
||||
}
|
||||
Reference in New Issue
Block a user