From 1a2861303e399725a73e1e519843d3efe65b3b94 Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Fri, 5 Apr 2024 15:01:55 -0300 Subject: [PATCH] scripts: update navlight script to support both Rover 4.2 and 4.5 --- scripts/ardupilot/ArduRover/4.x/navlight.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/ardupilot/ArduRover/4.x/navlight.lua b/scripts/ardupilot/ArduRover/4.x/navlight.lua index 73aa736..66483b5 100644 --- a/scripts/ardupilot/ArduRover/4.x/navlight.lua +++ b/scripts/ardupilot/ArduRover/4.x/navlight.lua @@ -1,6 +1,7 @@ -- This scripts is used to control Blue Robotics`s NavLight on the Blue Boat -local RELAY_NUM = 0 +local LIGHT_PIN = 18 +gpio:pinMode(LIGHT_PIN, 1) local MODES = { "MANU", @@ -107,7 +108,7 @@ function update() -- this is the loop which periodically runs if interval == 0 then -- Special case, light always on if not is_light_on_tm then - relay:on(RELAY_NUM) + gpio:write(LIGHT_PIN,1) is_light_on_tm = true end return update, 50 -- reschedules @@ -121,11 +122,12 @@ function update() -- this is the loop which periodically runs -- Check if it's time to toggle the light if blink_counter < times and now - last_blink >= (is_light_on_tm and high or low) then + gpio:toggle(LIGHT_PIN) is_light_on_tm = not is_light_on_tm if is_light_on_tm then - relay:on(RELAY_NUM) + gpio:write(LIGHT_PIN, 1) else - relay:off(RELAY_NUM) + gpio:write(LIGHT_PIN, 0) end last_blink = now if not is_light_on_tm then -- Increment the counter when the light turns off @@ -135,7 +137,7 @@ function update() -- this is the loop which periodically runs -- Turn off the light at the end of the cycle if blink_counter >= times and is_light_on_tm then - relay:off(RELAY_NUM) + gpio:write(LIGHT_PIN, 0) is_light_on_tm = false end