From 86d53c96d1106810fb83a96991db39207519ac38 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 31 May 2020 13:55:46 +1000 Subject: [PATCH] AP_Scripting: added opendog lua demo --- .../AP_Scripting/examples/opendog_demo.lua | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 libraries/AP_Scripting/examples/opendog_demo.lua diff --git a/libraries/AP_Scripting/examples/opendog_demo.lua b/libraries/AP_Scripting/examples/opendog_demo.lua new file mode 100644 index 0000000000..469a3e1c6d --- /dev/null +++ b/libraries/AP_Scripting/examples/opendog_demo.lua @@ -0,0 +1,23 @@ +-- demo of waving paw of opendog +-- +local flipflop = true + +pwm = { 1500, 1500, 2000, + 1500, 1500, 1000, + 1500, 1500, 1500, + 1500, 1500, 1500 } + +local angle = 0.0 + +function update() + local t = 0.001 * millis():tofloat() + local angle = math.sin(t) * 0.5 + pwm[6] = math.floor(1500.0 + angle*500.0) + for i = 1, 12 do + SRV_Channels:set_output_pwm_chan_timeout(i-1, pwm[i], 1000) + end + return update, 200 +end + +gcs:send_text(0, "opendog demo starting") +return update, 1000