From 85b15c7e9f353a97b0ab7b77701b8b7efc520091 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Wed, 18 Dec 2024 23:44:28 +0100 Subject: [PATCH] feat(arm07): add led indication of auto toggle --- arm07/src/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arm07/src/main.c b/arm07/src/main.c index 10ec593..9dbdf6a 100644 --- a/arm07/src/main.c +++ b/arm07/src/main.c @@ -77,6 +77,7 @@ void SystemCoreClockSetHSI(void) { pin_t user_button; timer_t button_timer; exti_t button_exti; +pin_t led; // Display matrix_t matrix; @@ -131,6 +132,7 @@ void handle_command(char* cmd, uint16_t len) { case 'N': // auto toggle if (len == 1) { + handled = true; auto_toggle = !auto_toggle; if (auto_toggle) { @@ -220,6 +222,13 @@ void next_image() void app_loop() { while (1) { + + if (auto_toggle) { + pin_set(&led); + } else { + pin_reset(&led); + } + if (auto_toggle && cycle >= AUTO_TOGGLE_CYCLES) { next_image(); cycle = 0; @@ -363,6 +372,9 @@ void main() pin_init(&user_button, GPIOC, 13); pin_into_input(&user_button); + pin_init(&led, GPIOA, 5); + pin_into_output(&led); + exti_init(&button_exti, 13, EXTI, SYSCFG); exti_external_interrupt(&button_exti, 2); exti_falling_interrupt(&button_exti); @@ -419,6 +431,7 @@ void TIM2_handler(void) { if (count > 10) { // at least 50 ms if (count > 400) { // at least 2 s auto_toggle = !auto_toggle; + cycle = 0; } else { // less than 2 s if (auto_toggle) { auto_toggle = false; -- 2.48.1