From 901a71b7e4033b9d26c99b6ad2495db3f0a0021e Mon Sep 17 00:00:00 2001 From: Michael-ango Date: Fri, 11 Sep 2026 17:46:00 -0600 Subject: [PATCH] Initialize the beeper before setting up LEDs beeper_init() configures VESC_PIN_PPM as a GPIO output, which is the same pad as LED_PIN_B6. Since d31ce1d moved the leds_setup() call into data_init(), beeper_init() runs afterwards and takes the pad back from the LED timer, silently disabling LEDs configured on B6. Move the beeper initialization into data_init(), after the config is read and before leds_setup(), restoring the previous ordering. It cannot go earlier, as the condition reads the configuration. Fix: Fix LEDs configured on pin B6 not working --- src/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 1e44c9df..ed5b7746 100644 --- a/src/main.c +++ b/src/main.c @@ -1212,6 +1212,14 @@ static void data_init(Data *d) { alert_tracker_init(&d->alert_tracker); reverse_stop_init(&d->reverse_stop); + // Must run before leds_setup(): beeper_init() configures VESC_PIN_PPM as a GPIO + // output, which on some hardware is the same pad as LED_PIN_B6. Whichever is + // configured last owns the pin, so the LED driver has to come second. + if ((d->float_conf.is_beeper_enabled) || + (d->float_conf.inputtilt_remote_type != INPUTTILT_PPM)) { + beeper_init(); + } + leds_init(&d->leds); leds_setup(&d->leds, &d->float_conf.hardware.leds, &d->float_conf.leds); lcm_init(&d->lcm, &d->float_conf.hardware.leds); @@ -2689,11 +2697,6 @@ INIT_FUN(lib_info *info) { &d->motor, d->float_conf.tiltback_lv, d->float_conf.tiltback_hv ); - if ((d->float_conf.is_beeper_enabled) || - (d->float_conf.inputtilt_remote_type != INPUTTILT_PPM)) { - beeper_init(); - } - d->main_thread = VESC_IF->spawn(refloat_thd, 1536, "Refloat Main", d); if (!d->main_thread) { log_error("Failed to spawn Refloat Main thread.");