OpenVex  0.5.0
Functions
Remote Control

Functions

unsigned char rc_read_status (void)
 
signed char rc_read_data (unsigned char channel)
 
signed char rc_button_sequence (unsigned char channel, unsigned char len)
 
unsigned char rc_new_data_available (void)
 

Detailed Description

Function Documentation

◆ rc_button_sequence()

signed char rc_button_sequence ( unsigned char  channel,
unsigned char  len 
)

Return a value indicating a binary sequence on RC button 'channel'. This function allows a single button pair to be used to trigger up to 127 different actions.

This function keeps a static internal value and counter. Each time this function is called, the buttons on channel are sampled. If the lower button is pressed, a 0 is inserted into least significant bit of the value, and the counter incremented. If the upper button is pressed, a 1 is inserted and the counter is incremented. If neither button is pressed, neither the value nor counter are changed.

A button being held down will only be counted once. It must be released and pressed again to advance the sequence.

When the counter reaches 'len', the function returns the value based on the binary sequence of button presses. For example, if the sequence length is 3, and the user presses the sequence lower, upper, upper, then the value returned is 011 binary (3 in decimal).

Until then, it returns -1, indicating that the sequence is not yet complete.

Parameters
channelChannel of button pair to read.
lenLength of button sequence.
Returns
-1 if sequence is not complete, or value of binary sequence.

◆ rc_new_data_available()

unsigned char rc_new_data_available ( void  )

Determine whether new data is available from the remote control unit.

Returns
TRUE when new data is available, FALSE if not.

◆ rc_read_data()

signed char rc_read_data ( unsigned char  channel)

Retrieve most recently sampled data from the specified channel on the remote control unit. All values returned range from -127 to +127. For joysticks, 0 is the center positionm, full left or full up is -127, and full down or full right is +127. For buttons, 0 indicates that neither button for the channel is pressed, -127 indicates the lower button, and 127 indicates the upper.

Parameters
channelChannel (joystick axis or button pair) to read.
Returns
Value read from channel (-127 to +127)

◆ rc_read_status()

unsigned char rc_read_status ( void  )

Determine current state of remote control unit.

Returns
1 if the remote control is on, 0 if off, 4 if disabled (controller is in autonomous mode).