-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced Remote Functionality
RobotC's support for the remote only gives a signal based on whether buttons are pressed or not. There is no native support if a user wants to execute only one function every time a button is pressed (push-release functionality) and the user cannot detect if a button is long held.
In config.c:
#define USE_PR_BUTTONS 1
#define NUM_PR_BUTTONS [insert the number of buttons you want to track here]
You also need to define a method setUpButtons()
which tells the library which buttons you want to track.
void setUpButtons(){
addPrButton(0, Btn5D);
addPrButton(1, Btn5U);
...
}
This method should be filled up with addPrButton()
calls to properly initialize each button.
- The first parameter of
addPrButton
is the INDEX. This is a number in the range [0, NUM_PR_BUTTONS), that is not already the index of another button. It will be used to access this specific button's value later. - The second parameter of
addPrButton
is the BUTTON NAME. This tells the library which button on the remote you want to be mapped. Only use buttons, not channels.
To actually access the values of each button, call getPrButton(INDEX)
which returns three possible values:
- 0: The button is not any of the other states
- PUSHED_RELEASED (which equals 1): The button has been pushed and released
- LONG_HELD (which equals 2): The button has been held for at least 1 second and then released
After the button's value has been accessed, and a function is performed, the value of the button must be reset by calling resetPrButton(INDEX)
. This ensures that the remote functions continue working as normal.
Inside while loop in user control:
if(getPrButton(0) == LONG_HELD){
//Execute amazing function here!
resetPrButton(0);
}
Beginner Features:
Intermediate Features:
Advanced Features:
Controlling the LCD
Using Autonomous Modes
Custom Pre Auton Procedure
Using Autonomous Modes in User Control
More Remote Functionality
Configuring Bailout Button
Custom User Control Procedure
PID Control
Drive Train Control