Going crazy over Gpio....

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
notso2slo
Posts: 12
Joined: Wed Jan 06, 2016 8:55 pm
Contact:

Going crazy over Gpio....

Post by notso2slo »

So I have been trying to get my oil warning light working, and have been really struggling... No matter what I do, the Gpio seems to be in a state of 0.

So I finally simplified my code down to this:

Code: Select all

function onTick&#40;&#41;
   setGpio&#40;0, 1&#41;
   println&#40;"Oil Warn " ..getGpio&#40;0&#41;&#41;
 end
And still, all I see returned is:
Oil Warn 0.0

What am I doing wrong??? The channel is on, the sample rate is 1hz, and the mode is output....

Going crazy here!

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

Post by ross2004 »

You have no scripting for checking the oil pressure/temp it looks like. From the Wiki, you'd need something like this:

Code: Select all

function onTick&#40;&#41;
 if getAnalog&#40;0&#41; > 212 then
   setGpio&#40;0, 1&#41;
 else
   setGpio&#40;0, 0&#41;
 end
end

notso2slo
Posts: 12
Joined: Wed Jan 06, 2016 8:55 pm
Contact:

Post by notso2slo »

I was attempting to eliminate excess steps, so instead of using logic to determine whether or not to set the Gpio to 0 or 1, I just go ahead and set it to 1.

It wasn't working with the logic, so I just set it as a constant.

notso2slo
Posts: 12
Joined: Wed Jan 06, 2016 8:55 pm
Contact:

Post by notso2slo »

So I think the problem goes deeper....

I have a race capture MK1, and I plugged that in and loaded that code. I get a return of 1 instead of 0 now....

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

Post by brentp »

For MK1, you have to set the GPIO to output mode via the internal jumpers, and set the configuration to 'output'.

When GPIO is activated (1) it connects the output to ground. You can test it by driving a relay where the ground side of the relay is powered via the GPIO.

Hope this helps!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply