From 7bae3f0989b5666bfd359d33f915c2a77f981d2f Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Mon, 14 Apr 2025 18:21:48 +0300 Subject: [PATCH] [main] add simple navigation between test reports --- Core/Src/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index 998cd4e..ef4a826 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -315,13 +315,53 @@ int main(void) } display_to_direct(); + display_current_frame = 0; + if (buttons_interrupt_enabled) + buttons_switch_to_input(); + while (1) { + // wait until all buttons are released + while ( + (GPIOA->IDR & GPIO_PIN_0) || + !(GPIOC->IDR & GPIO_PIN_11) || + !(GPIOC->IDR & GPIO_PIN_8) || + !(GPIOC->IDR & GPIO_PIN_9) || + !(GPIOC->IDR & GPIO_PIN_6) || + !(GPIOA->IDR & GPIO_PIN_15) + ) { asm("nop"); } + display_load(display_current_frame); - display_current_frame++; - display_current_frame %= 11; - HAL_Delay(1000); + + while (1) { + // go to next report + if ( + (GPIOA->IDR & GPIO_PIN_0) || + !(GPIOC->IDR & GPIO_PIN_11) || + !(GPIOC->IDR & GPIO_PIN_8) + ) { + display_current_frame += 1; + break; + } + + // go to previous report + else if ( + !(GPIOC->IDR & GPIO_PIN_9) || + !(GPIOC->IDR & GPIO_PIN_6) + ) { + display_current_frame -= 1; + break; + } + + // execute this test live + else if ( + !(GPIOA->IDR & GPIO_PIN_15) + ) { + // not implemented + continue; + } + } } /* USER CODE END 2 */