Switch off - on lua script and sellect 2nd script.to control LEDs

I am using lua script “poslight”
I now have green and red lights, which flash when armed.
The question now is, how to switch them off, as they are not needed during daylight hours?

Can the script read a switch position (e.g. 1000, 1500, 2000) if the switch is 1000 do nothing, if 1500 run script, if 2000 turn all LEDs on to white.?

Look at the binding for get_aux_switch_pos

Relevant example:
ardupilot/RCIN_test.lua at master · ArduPilot/ardupilot (github.com)

It looks like i need to compind the two lua scripts
This one : https://github.com/ArduPilot/ardupil…D_poslight.lua
And example:
ardupilot/RCIN_test.lua at master · ArduPilot/ardupilot (github.com)
I am not sure how.
I think i need to check the position of the 3 way switch, if in 1 position return. If in 2 position run a modified poslight code, return. If in 3 position turn all LEDs to white, return.

This is untested but should get you pretty close.
poslights_sw.lua (3.3 KB)

It works perfectly. Now I can go fishing at night.

Thank you so much.

1 Like