fix(lua): LED_STRIP_LENGTH is decorative LEDs only - #7716
Conversation
Lua index 0 is already the first bling LED. Reporting bling+CFS as LED_STRIP_LENGTH made strip scripts walk function-switch LEDs and split dual-ring patterns at the wrong index. Export BLING_LED_STRIP_LENGTH, CFS_LED_STRIP_LENGTH, and FUNC_RGB_LED so scripts can address each range and install the RGB LED special function without hardcoding the enum value.
|
May break existing scripts that use LED_STRIP_LENGTH. |
There was a problem hiding this comment.
Thanks... it looks like FUNC_RGB_LED was missing right from the start in #3909.
You can't just change what existing API calls do as it will break all the pre-existing scripts... so doing what you did will not only not get merged in it's current form, but is wasteful... every entry in the lua table costs memory regardless if you use the feature or not, so there is no point having duplicated entires doing the same thing.
| // LED_STRIP_LENGTH matches the Lua index space of setRGBLedColor() for | ||
| // decorative LEDs (index 0 is the first bling LED). CFS LEDs are separate | ||
| // and should be driven with setCFSLedColor(). | ||
| LROT_NUMENTRY( LED_STRIP_LENGTH, BLING_LED_STRIP_LENGTH ) |
There was a problem hiding this comment.
Revert this to it's prior form.
|
CFS_LED_STRIP_LENGTH can be calculated so probably does not need to explicitly defined. |
Summary of changes:
Lua
setRGBLedColor(0, ...)is already the first decorative ("bling") LED, not hardware index 0.LED_STRIP_LENGTHwas stillbling + CFS, so strip scripts that loop0 .. LED_STRIP_LENGTH-1also walked function-switch LEDs. On TX16S Mk3 / GX15 / TX15 that is 26 instead of 20, and dual-ring math (HALF = N/2) splits at 13 instead of 10. Configured CFS LEDs are already rejected bysetRGBLedColor(); they belong tosetCFSLedColor()/ model on-off colours.LED_STRIP_LENGTHis now the decorative count (BLING_LED_STRIP_LENGTH)BLING_LED_STRIP_LENGTHandCFS_LED_STRIP_LENGTHso scripts can see both rangesFUNC_RGB_LEDso tools do not have to hardcode enum value 25setRGBLedColor()This matches the index mapping from #7304. Existing scripts that iterate
LED_STRIP_LENGTHwill now paint only the gimbal/bling LEDs, which is what they intend. Function-switch LEDs are unchanged for configured switches.Companion change: no
Radio: TX16S Mk3 / GX15 / TX15 (20 bling + 6 CFS); also radios that only have one of the two ranges
Related: https://github.com/pigd0g/EdgeTx-RGB-Toolbox