Displaying failsafe state with Neopixel LEDs

Good Morning! :sun:

So now, even i got self taught at Lua scripting! And I have even prepared this WS2812B LED Effects controlling firmware all on my own! =>

WS2812 LED Firmware.lua (7.6 KB)

So in this, I want the LEDs to flash in a certain emergency manner, which will depict that ANY kind of failsafe has occured. But even after searching a lot, On docs, in the API, in many bindings searching for symbols, I can’t find any binding which returns a “true” if ANY kind of failsafe is activated, or at least returns the number of failsafes currently active. Do you know any such binding or method which can help me detect if ANY kind of failsafe has got activated?

I can see vehicle:has_ekf_failsafed() and battery:has_failsafed()
arming:pre_arm_checks() may help too.

I also cant see any overall “there has been a failsafe”

I don’t think we expose all possible failsafe states in Lua, but there is a workaround.

Either connect the LEDs as simple external notification LEDs or use the LED:get_rgb() binding to get the current notification LED color and display it as needed.

1 Like

But then shouldn’t the developers add the required code to expose all failsafes and failsafe related bindings?

Getting failsafes status and activated failsafe count/types and some other failsafe related functionalities is necessary, isn’t it?

Ok, i understood it, and then i tried using it in code, and for safety check, i sent the r, g, b values to the gcs messages tab to see whether what colour is being sent for failsafe.
But this error came:
”23-02-2026 16:56:24 : his firmware)

23-02-2026 16:56:24 : ling ‘get_rgb’ on bad self (LED not supported on t

23-02-2026 16:56:24 : Lua: /APM/scripts/WS2812 LED Firmware.lua:176: cal

23-02-2026 16:56:14 : his firmware)

23-02-2026 16:56:14 : ling ‘get_rgb’ on bad self (LED not supported on t

23-02-2026 16:56:14 : Lua: /APM/scripts/WS2812 LED Firmware.lua:176: cal

23-02-2026 16:56:04 : his firmware)

23-02-2026 16:56:04 : ling ‘get_rgb’ on bad self (LED not supported on t

23-02-2026 16:56:04 : Lua: /APM/scripts/WS2812 LED Firmware.lua:176: cal

23-02-2026 16:55:55 : e.lua:17

23-02-2026 16:55:55 : PreArm: Scripting: /APM/scripts/WS2812 LED Firmwar

23-02-2026 16:55:55 : PreArm: RC not found” //Here i made an rc failsafe.

It says LED Not supported on this firmware?!?

You need to share the script (or at least line 176 of it). And however you tried to share above didn’t work - there’s an access requirement.

Hehe, actually after that, i changed the code a bit to at least make the LEDs aware of the rc/battery failsafe. But here are those lines which i wrote at the time of the error:

local r_fs, g_fs, b_fs = LED:get_rgb() –Line 176
gcs:send_text(6, “Failsafe RGB:“..”r:”..tostring(r_fs)..” g: ”..tostring(r_fs)..” b: “..tostring(r_fs))

(And i have uploaded the “latest” .lua file for the lua code i have written

The error you’re getting indicates that the binding exists but is not supported. I didn’t chase the source any farther than that, but it appears you can’t use LED:get_rgb() on that board.

Try setting an RGB LED as a notify option even if you dont really have one. There’s a couple of different types to try:

Try this LUA scripting function to see if the output changes to false whenever there’s a failure.
arming:pre_arm_checks()

Yes sir. I have already made the use of this function in my code, so that the lights flash VIBGYOR whenever done is not ready to arm and disarmed.

But if the drone is armed and flying and a kind of failsafe occurs, then this pre arm check won’t work.

.

Will try setting up the enabled led bitmask too

Built-in LED or DiscreteRGB may do it, any of them really.