Browse Source

AP_Scripting: add notify LED get RGB binding and example

c415-sdk
Iampete1 4 years ago committed by WickedShell
parent
commit
e95376fbef
  1. 26
      libraries/AP_Scripting/examples/get_notify_RGB.lua
  2. 5
      libraries/AP_Scripting/generator/description/bindings.desc

26
libraries/AP_Scripting/examples/get_notify_RGB.lua

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
-- example of getting the current notify LED colour
function update() -- this is the loop which periodically runs
local r, g, b = LED:get_rgb()
gcs:send_text(0, "Notify LED: r: " .. tostring(r) .. ", g: " .. tostring(g) ..", b:" .. tostring(b))
return update, 1000 -- reschedules the loop
end
-- make sure Scripting LED is enabled
local led_parm = param:get('NTF_LED_TYPES')
if not led_parm then
error('Could not find NTF_LED_TYPES param')
end
if (led_parm & (1 << 10)) == 0 then
-- try and enable it
if param:set_and_save('NTF_LED_TYPES',led_parm | (1 << 10)) then
error('Enabled Notify Scripting LED, please reboot')
else
error('Could not set NTF_LED_TYPES param')
end
end
return update()

5
libraries/AP_Scripting/generator/description/bindings.desc

@ -280,3 +280,8 @@ singleton AP_RPM method get_rpm boolean uint8_t 0 RPM_MAX_INSTANCES float'Null @@ -280,3 +280,8 @@ singleton AP_RPM method get_rpm boolean uint8_t 0 RPM_MAX_INSTANCES float'Null
include AP_Button/AP_Button.h
singleton AP_Button alias button
singleton AP_Button method get_button_state boolean uint8_t 1 AP_BUTTON_NUM_PINS
include AP_Notify/ScriptingLED.h
singleton ScriptingLED alias LED
singleton ScriptingLED method get_rgb void uint8_t'Ref uint8_t'Ref uint8_t'Ref

Loading…
Cancel
Save