Hello,
The unit is mounted under my seat, and it is actually quite annoying to open it to start the logging before each session.
In order to improve that, I would like to have :
* a remote LED to see whether the unit is logging or not
* a button to start/stop the logging manually (GPS script does not seems to work, and I can't see the logging status)
So which functions should I use to switch an output and to read an input?
Is there already a script defined?
LUA Script for remote start/stop and status led
-
- Posts: 22
- Joined: Fri Nov 01, 2013 9:48 pm
- Location: Bay Area, CA
I don't have my RCP yet but I was hoping to do something similar looking at the lua guide and some examples I THINK you should be able to hook up a switch to one of the digital inputs and an LED to one of the digital outputs with proper voltage to each and do something like this in lua:
If that works you can do other things things (Assuming you got the gps part to work) log if the switch is on or if going above 10 mph:
or log if you're above 10mph AND the switch is on
I'll test these once my RCP arrives, I only verified the lua syntax using http://doris.sourceforge.net/lua/weblua.php
Another option is to use one of the analog inputs and a resistor ladder to be able to use more than one switch and only one input.
EDIT: updated examples as this version of Lua doesnt want to support "greater than or equal to" operators
Code: Select all
function onTick()
if getGpio( <switch channel> ) > 0 then
startLogging()
setGpio( <LED channel>, 1 )
else
stopLogging()
setGpio( <LED channel>, 0 )
end
end
If that works you can do other things things (Assuming you got the gps part to work) log if the switch is on or if going above 10 mph:
Code: Select all
function onTick()
if getGpio( <switch channel> ) > 0 or getGpsSpeed() > 10 then
startLogging()
setGpio( <LED channel>, 1 )
else
stopLogging()
setGpio( <LED channel>, 0 )
end
end
Code: Select all
function onTick()
if getGpio( <switch channel> ) > 0 and getGpsSpeed() > 10 then
startLogging()
setGpio( <LED channel>, 1 )
else
stopLogging()
setGpio( <LED channel>, 0 )
end
end
Another option is to use one of the analog inputs and a resistor ladder to be able to use more than one switch and only one input.
EDIT: updated examples as this version of Lua doesnt want to support "greater than or equal to" operators
Last edited by redparchel on Wed Nov 13, 2013 6:06 am, edited 1 time in total.
-
- Posts: 22
- Joined: Fri Nov 01, 2013 9:48 pm
- Location: Bay Area, CA
While looking at this and the lua guide for RCP I wish there was a isLogging() or getLogging() that would return whether the system was logging or not .. this could be used like the below to show logging status or errors on a remote LED
then again you're probably not going to "pull over" on the track to fix it mid race, but you or a co-driver could try flipping the switch again to see if it starts logging again
sorry for the thread jack
EDIT: updated examples as this version of Lua doesnt want to support "greater than or equal to" operators
Code: Select all
function onTick()
if getLogging > 0 then
setGpio( <LED channel>, 1 )
else
setGpio( <LED channel>, 0 )
end
end
then again you're probably not going to "pull over" on the track to fix it mid race, but you or a co-driver could try flipping the switch again to see if it starts logging again
sorry for the thread jack
EDIT: updated examples as this version of Lua doesnt want to support "greater than or equal to" operators
Last edited by redparchel on Wed Nov 13, 2013 6:07 am, edited 2 times in total.
-
- Posts: 22
- Joined: Fri Nov 01, 2013 9:48 pm
- Location: Bay Area, CA
sure thing! hope something works for yaneoraptor wrote:Thank you redparchel for the scripts. I will look to make it work.
I think there may be a solution to that problem that autosportslabs just posted on their Facebook page (bretp do you manage that page?) http://www.autoblog.com/2013/10/23/skul ... met-video/neoraptor wrote:@Brent: this is a good idea, but on my motorcycle it is difficult to put a smartphone or a tablet.