From f97cd5c5abca522125f1503cf92a5bbed357afac Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Thu, 23 Feb 2023 12:35:05 +0000 Subject: [PATCH] AP_HAL: add helper functions for LEDs add PRIORITY_LED for led output thread --- libraries/AP_HAL/RCOutput.h | 12 ++++++++++++ libraries/AP_HAL/Scheduler.h | 1 + 2 files changed, 13 insertions(+) diff --git a/libraries/AP_HAL/RCOutput.h b/libraries/AP_HAL/RCOutput.h index b77d740d6d..a42ab430f4 100644 --- a/libraries/AP_HAL/RCOutput.h +++ b/libraries/AP_HAL/RCOutput.h @@ -222,6 +222,15 @@ public: // static to allow use in the ChibiOS thread stuff static bool is_dshot_protocol(const enum output_mode mode); + static bool is_led_protocol(const enum output_mode mode) { + switch (mode) { + case MODE_NEOPIXEL: + case MODE_PROFILED: + return true; + default: + return false; + } + } // BLHeli32: https://github.com/bitdump/BLHeli/blob/master/BLHeli_32%20ARM/BLHeli_32%20Firmware%20specs/Digital_Cmd_Spec.txt // BLHeli_S: https://github.com/bitdump/BLHeli/blob/master/BLHeli_S%20SiLabs/Dshotprog%20spec%20BLHeli_S.txt @@ -382,6 +391,9 @@ public: static constexpr uint32_t PROFI_BIT_0_TICKS = 7; static constexpr uint32_t PROFI_BIT_1_TICKS = 14; + // suitably long LED output period to support high LED counts + static constexpr uint32_t LED_OUTPUT_PERIOD_US = 10000; + protected: // helper functions for implementation of get_output_mode_banner diff --git a/libraries/AP_HAL/Scheduler.h b/libraries/AP_HAL/Scheduler.h index 0345138d5d..eb580ebe0d 100644 --- a/libraries/AP_HAL/Scheduler.h +++ b/libraries/AP_HAL/Scheduler.h @@ -109,6 +109,7 @@ public: PRIORITY_CAN, PRIORITY_TIMER, PRIORITY_RCOUT, + PRIORITY_LED, PRIORITY_RCIN, PRIORITY_IO, PRIORITY_UART,