Page 1 of 1
Can't Get Action Button State and Only Controls Logging?
Posted: Wed Oct 04, 2017 3:02 am
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?
Posted: Wed Oct 04, 2017 5:36 pm
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
Button ------- RCP GPIO input
Posted: Wed Oct 04, 2017 11:13 pm
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.
Posted: Tue Oct 17, 2017 2:26 pm
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.