Flashing Warning Light

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="http://autosportlabs.net/RaceCapturePro_Lua_Scripting">Lua Scripting Guide</a>

Moderators: JeffC, stieg

Post Reply
ross2004
Posts: 24
Joined: Mon Sep 18, 2017 3:58 pm
Location: Staunton, VA

Flashing Warning Light

Post by ross2004 »

Preface: noob here when it comes to scripting.

I've seen the wiki example script for a warning light for say temperature, low pressure, etc.- is it possible to have this light flash, and what would that code look like? Thanks!

Standard:

--Analog 0 is engine temp, in degrees F
--Analog 1 is oil pressure, in PSI

function onTick()
if getAnalog(0) > 212 or getAnalog(1) < 10 then
setGpio(0, 1)
else
setGpio(0, 0)
end
end

brentp
Site Admin
Posts: 5986
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi, you'd have to have a separate counter that increments on every onTick(). A simple way is, if that value is odd, then make sure the output is off.

There are some shift light examples in our example library that implement something like this.

Let us know what you come up with!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

PS14
Posts: 97
Joined: Fri Feb 12, 2016 11:27 pm
Location: NY

Post by PS14 »

Here's a script to make a light wired to GPIO(0) come on at a certain point and flash at a different point (like water temp). thanks to David Alexander.

--point at which light comes on
local waterOn = 195
--point at which light flashes
local waterBlink = 200

local timer = 1

function warningLed()
if getAnalog(0) > waterOn then
setGpio(1, 1)
else
setGpio(1, 0)
end
if getAnalog(0) > waterBlink then
if timer == 1 then
setGpio(1, 0)
timer = 2
else timer = 1
end
end
end

function onTick()
warningLed()
end

ross2004
Posts: 24
Joined: Mon Sep 18, 2017 3:58 pm
Location: Staunton, VA

Post by ross2004 »

Nice, I'm going to try and implement that this weekend. I like the simple "on" along with "flashing" combo.

PS14
Posts: 97
Joined: Fri Feb 12, 2016 11:27 pm
Location: NY

Post by PS14 »

Just a thought. I've always used a redundant water pressure sender to a lite, completely independent of the digital gauges/sender. in dirt racing we are usually blowing hoses or poking holes in the radiator so you'll see a loss of pressure long before any rise in temp. sometimes you wont even see a rise in temp since a typical water temp gauge cant measure air temp (i.e no water in block). just food for thought.

Post Reply