diff --git a/libraries/AP_Scripting/examples/get_notify_RGB.lua b/libraries/AP_Scripting/examples/get_notify_RGB.lua new file mode 100644 index 0000000000..e882d9670a --- /dev/null +++ b/libraries/AP_Scripting/examples/get_notify_RGB.lua @@ -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() diff --git a/libraries/AP_Scripting/generator/description/bindings.desc b/libraries/AP_Scripting/generator/description/bindings.desc index bf43dc299b..877562f7c4 100644 --- a/libraries/AP_Scripting/generator/description/bindings.desc +++ b/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 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