This commit is contained in:
Julian 2024-07-21 15:51:22 +02:00
parent f5027348d7
commit 0f5cfe56a9
2 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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