From c96c89ac2925f1243860e4cd0cfb997bceae9efe Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Tue, 2 Apr 2024 22:07:55 +0100 Subject: [PATCH] AP_Scripting: examples: update servo scan --- libraries/AP_Scripting/examples/servo_scan.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Scripting/examples/servo_scan.lua b/libraries/AP_Scripting/examples/servo_scan.lua index 0e02d8b1d91cc..87ec7f9cb2472 100644 --- a/libraries/AP_Scripting/examples/servo_scan.lua +++ b/libraries/AP_Scripting/examples/servo_scan.lua @@ -1,12 +1,11 @@ --- move a servo in a sinisoidal fashion +-- move a servo in a sinusoidal fashion local SERVO_FUNCTION = 94 -local PERIOD = 0.5 +local FREQUENCY = 0.125 function update() -- this is the loop which periodically runs local t = 0.001 * millis():tofloat() - local pi = 3.1415 - local output = math.sin(pi * t * PERIOD * 2.0) + local output = math.sin(math.pi * t * FREQUENCY * 2.0) local pwm = math.floor(1500 + 500 * output) SRV_Channels:set_output_pwm(SERVO_FUNCTION, pwm) return update, 20 -- reschedules the loop at 50Hz