common: lua: correct the serialLED library documentation - #8014
Open
Hwurzburg wants to merge 2 commits into
Open
common: lua: correct the serialLED library documentation#8014Hwurzburg wants to merge 2 commits into
Hwurzburg wants to merge 2 commits into
Conversation
The documented API did not match the code. set_num_LEDs() does not exist - the length of a string is set with set_num_neopixel(), set_num_neopixel_rgb() or set_num_profiled(), depending on the LED type. send() was shown with no argument when it takes the output channel. set_RGB was described as taking "LED_number (1-32)". The index is zero based, not one based, -1 sets the whole string, and the 32 LED limit is long gone: AP_SERIALLED_MAX_LEDS is 128, which set_num_neopixel and set_num_neopixel_rgb accept in full while set_num_profiled is capped two lower at 126. Lifting that 32 LED limit is the outstanding item on issue ArduPilot#2783. Also record that set_num_profiled() fails unless an output has SERVOx_FUNCTION = 132 (ProfiLEDClock) assigned, and drop the claim that the library is specific to WS8212B strings. Verified against libraries/AP_Scripting/docs/docs.lua, AP_SerialLED.cpp and the ranges declared in AP_Scripting/generator/description/bindings.desc. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
IamPete1
reviewed
Aug 29, 2026
Co-authored-by: Peter Hall <33176108+IamPete1@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
serialLED:section of the Lua bindings page documented an API that no longer exists. A script written from it would not run.set_num_LEDs( output_number , number_of_LEDs )set_num_neopixel(),set_num_neopixel_rgb()orset_num_profiled(), depending on LED typeset_RGB( ... )withLED_number (1-32)led_indexis zero based,-1sets the whole string, and the limit is not 32send()send( chan )- it takes the output channelThe zero-based indexing is the one most likely to bite: a script following the old page would silently skip the first LED and run one off the end.
The 32 LED limit
Lifting it is the outstanding checkbox on #2783 ("changed LED scripting API to allow more than 32 LEDs on a pin").
AP_SERIALLED_MAX_LEDSis 128, but not uniformly -set_num_neopixel()andset_num_neopixel_rgb()accept the full 128, whileset_num_profiled()is capped at 126 (AP_SERIALLED_MAX_LEDS - 2), since ProfiLED reserves two for framing. Both figures are documented rather than quoting a single number.Also added
set_num_profiled()returns false unless an output hasSERVOx_FUNCTION= 132 (ProfiLEDClock) assigned - it checksfunction_assigned(k_ProfiLED_Clock)and bails out. That was not mentioned anywhere and is easy to hit. The function label is taken from generatedapm.pdef.xmlso it matches the GCS dropdown.Verification
Checked against
libraries/AP_Scripting/docs/docs.lua(signatures and theled_indexsemantics),libraries/AP_SerialLED/AP_SerialLED.cpp(the limits and the clock check), andlibraries/AP_Scripting/generator/description/bindings.desc(the declared argument ranges).Built with
python3 update.py --fast --site copter.Note this does not close #2783 - its other remaining item is the R9Pilot autopilot, which has an hwdef in ArduPilot but no wiki page and no README.md in its hwdef directory, so that one needs board information rather than an edit.
🤖 Generated with Claude Code