RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
LUA Script for remote start/stop and status led
Author Message
Reply with quote
Post LUA Script for remote start/stop and status led 
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?

View user's profile Send private message
Reply with quote
Post  
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:

Code:
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:
function onTick()
    if getGpio( <switch channel> ) > 0 or getGpsSpeed() > 10  then
        startLogging()
        setGpio( <LED channel>, 1 )
    else
        stopLogging()
        setGpio( <LED channel>, 0 )
    end
end


or log if you're above 10mph AND the switch is on
Code:
function onTick()
    if getGpio( <switch channel> ) > 0 and getGpsSpeed() > 10  then
        startLogging()
        setGpio( <LED channel>, 1 )
    else
        stopLogging()
        setGpio( <LED channel>, 0 )
    end
end


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



Last edited by redparchel on Wed Nov 13, 2013 6:06 am; edited 1 time in total
View user's profile Send private message
Reply with quote
Post  
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

Code:
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
View user's profile Send private message
Reply with quote
Post  
if you're concerned whether the system is logging or not, you could use the bluetooth connected dash as an indicator - if the data is not updating, then you will know!


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Reply with quote
Post  
Thank you redparchel for the scripts. I will look to make it work.
I also consider start logging wenn the unit is powered, as I only start the motor 2 minutes before going to the track.

@Brent: this is a good idea, but on my motorcycle it is difficult to put a smartphone or a tablet.

View user's profile Send private message
Reply with quote
Post  
neoraptor wrote:
Thank you redparchel for the scripts. I will look to make it work.

sure thing! hope something works for ya

neoraptor wrote:
@Brent: this is a good idea, but on my motorcycle it is difficult to put a smartphone or a tablet.


I think there may be a solution to that problem Wink that autosportslabs just posted on their Facebook page (bretp do you manage that page?) http://www.autoblog.com/2013/10/23/skully-hud-motorcycle-helmet-video/

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum