From 0f5cfe56a9ece7847b9386dc41238a07cc8050c6 Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 21 Jul 2024 15:51:22 +0200 Subject: [PATCH] Add VDE --- Core/Inc/ui.h | 2 +- Core/Src/ui.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Core/Inc/ui.h b/Core/Inc/ui.h index 0dcffc9..2f5625f 100644 --- a/Core/Inc/ui.h +++ b/Core/Inc/ui.h @@ -7,7 +7,7 @@ extern "C" { #endif -#define NUM_BUTTONS 6 +#define NUM_BUTTONS 7 #define NUM_ENCS 2 #define BUTTON_MIN_INTERVAL 50 // ms #define ENC_MAX_PHASE 50 // ms diff --git a/Core/Src/ui.c b/Core/Src/ui.c index a0a2c75..21e964c 100644 --- a/Core/Src/ui.c +++ b/Core/Src/ui.c @@ -10,12 +10,14 @@ #include "tx_api.h" #include "vehicle.h" +#include "leds.h" + void ui_thread_entry(ULONG _) { GPIO_TypeDef *button_ports[NUM_BUTTONS] = {BTN1_GPIO_Port, BTN2_GPIO_Port, BTN3_GPIO_Port, BTN4_GPIO_Port, - BTN5_GPIO_Port, BTN6_GPIO_Port}; + BTN5_GPIO_Port, BTN6_GPIO_Port, SW_DRS_GPIO_Port}; uint16_t button_pins[NUM_BUTTONS] = {BTN1_Pin, BTN2_Pin, BTN3_Pin, - BTN4_Pin, BTN5_Pin, BTN6_Pin}; + BTN4_Pin, BTN5_Pin, BTN6_Pin, SW_DRS_Pin}; GPIO_PinState button_states[NUM_BUTTONS] = {GPIO_PIN_RESET}; uint32_t button_press_times[NUM_BUTTONS] = {HAL_GetTick()}; @@ -44,6 +46,14 @@ void ui_thread_entry(ULONG _) { tx_event_flags_set(&gui_update_events, GUI_UPDATE_NEXT_SCREEN, TX_OR); } + if (button_states[6] == GPIO_PIN_SET) { + // Set leftmost led to blue to indicate DRS activation + led_set(0, 0, 0, 255); + } else { + // Turn it off if not active + led_set(0, 0, 0, 0); + } + vehicle_broadcast_buttons(button_states); // Release so other threads can get scheduled