From cc32a3092a9962f60f1580f27d4b8a125a7b7884 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Sat, 19 Apr 2025 14:50:28 +0300 Subject: [PATCH] [main] add macros for checking specific buttons --- Core/Src/main.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index 73d6863..230e8a5 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -79,7 +79,7 @@ extern size_t display_current_frame; /* USER CODE BEGIN PV */ -const int ((*executors[])(void)) = { +static const int ((*executors[])(void)) = { DNI_show_celsius, PCA9685_run_test, EEPROM_24AA02E48_run_test, @@ -91,7 +91,7 @@ const int ((*executors[])(void)) = { LSM9DS1_test_magnet }; -const void ((*cleanup_functions[])(void)) = { +static const void ((*cleanup_functions[])(void)) = { NULL, PCA9685_cleanup, NULL, @@ -103,8 +103,6 @@ const void ((*cleanup_functions[])(void)) = { NULL }; -size_t current_executor_id = 0; - /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ @@ -122,7 +120,7 @@ static void MX_I2S2_Init(void); /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ -void button_init_and_test(void) +static void button_init_and_test(void) { // letting the buttons be tested display_write_data_seq("Fill any bar:"); @@ -300,33 +298,24 @@ int main(void) while (1) { // go to next report - if ( - (GPIOA->IDR & GPIO_PIN_0) || - !(GPIOC->IDR & GPIO_PIN_11) || - !(GPIOC->IDR & GPIO_PIN_8) - ) { + if (UB || SWT1 || SWT5) { display_current_frame += 1; display_current_frame %= LEN(executors)+1; break; } // go to previous report - else if ( - !(GPIOC->IDR & GPIO_PIN_9) || - !(GPIOC->IDR & GPIO_PIN_6) - ) { + else if (SWT3 || SWT4) { display_current_frame -= 1; - if (display_current_frame == 0xFFFFFFFFU) + if ((int) display_current_frame == -1) display_current_frame = LEN(executors); break; } // return to summary frame - else if ( - !(GPIOA->IDR & GPIO_PIN_15) - ) { + else if (SWT2) { display_current_frame = 0; break; }