Can't Get Action Button State and Only Controls Logging?

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
wizrd54
Posts: 23
Joined: Sat Apr 15, 2017 6:56 pm

Can't Get Action Button State and Only Controls Logging?

Post by wizrd54 »

I was trying to have a script that would do some action when the action button on the RCP was pressed. It doesn't seem that I'm able to get the state of the action button. I tried just doing println(getButton()), but nothing showed up.

Also noticed that by default the action button starts and stops logging. Is there anyway to have the button do some other function and not control logging?

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

Post by brentp »

Hi,

Right now the button it hard-wired to control logging, correct.

So you're saying 'println(getButton())' outputs nothing at all, or always 0?

Alternatively, you can wire a button to one of the GPIO inputs, with a pullup resistor to have an external button. Then, you can trigger some logic off of the GPIO state.

You'd wire it this way: one leg of the button to ground, the other to the input, tied with a pullup resistor (1K-100k)

Code: Select all

                               
          5v or 12v pullup
          |
         resistor
          |
Button ------- RCP GPIO input
  |
  |
  |                        
Ground


wizrd54
Posts: 23
Joined: Sat Apr 15, 2017 6:56 pm

Post by wizrd54 »

I will play around with it more tomorrow and this weekend, but I get no 0s or 1s when trying println(getButton()). Debugging worked fine for the rest of the script.

The rest of my script worked though. I was originally going to make a timer for the driver to know how long they have been in the car for our Chump Car event. This would be reset by the button and an external battery pack would keep the RCP on when the kill switch turns off the main power. I don't want to accidentally stop logging by pressing the button, so I'll avoid that route.

I decided to just have the RCP turn off with the kill switch and then the timer resets when they turn it back on. Hopefully GPS lock comes back reliably and that works out. Right now I've formatted the timer to be "A.BCDE" where A is hours, BC is minutes, and DE is seconds since a string can't be output to a channel.

It will be our first race event with the RCP, so I'm excited to see how it performs. Worked like a charm in our test last weekend.

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

Post by brentp »

Hi - great you're making progress!

To test the GPIO:

Make sure the config for that port is set to 'input' and then try this test, disconnecting the input from anything else:

* connect the input to the 5v reference and then run your script. you should see '1' as a result.
* connect the input ground. you should see '0' as a result.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply