RcTrainer
Public Member Functions | List of all members
RcTrainer Class Reference

Read servo positions from RC Transmitter in Trainer mode. More...

#include <RcTrainer.h>

Public Member Functions

 RcTrainer (uint8_t interrupt=0)
 
int16_t getChannelRaw (uint16_t channel)
 
int16_t getChannel (int16_t channel, int16_t mapFromLow=1096, int16_t mapFromHigh=1916, int16_t mapToLow=0, int16_t mapToHigh=1023)
 

Detailed Description

Read servo positions from RC Transmitter in Trainer mode.

This class provides the ability to read servo positions from a PPM encoded digital signal, such as the one emitted by an RC traansmitter in Trainer mode.

Examples:
dx6i.ino.

Constructor & Destructor Documentation

RcTrainer::RcTrainer ( uint8_t  interrupt = 0)

Constructor Creates a new RcTrainer. You have multiple RcTrainer instances connected to different inputs. If the interrupt number is out of range for your processor, RcTrainer will silently fail to work correctly.

Parameters
[in]interruptThis is the number of the interrupt pin (not the digital input pin number) that is connected to the transmitter. The mapping from interrupt number to digital pin number depends on your Arduino. See http://arduino.cc/en/Reference/attachInterrupt for details

Member Function Documentation

int16_t RcTrainer::getChannel ( int16_t  channel,
int16_t  mapFromLow = 1096,
int16_t  mapFromHigh = 1916,
int16_t  mapToLow = 0,
int16_t  mapToHigh = 1023 
)

Reads a scaled channel value The raw channel value for the selected channel is mapped according to the specified parameters so that the result always lies in the range mapToLow to mapToHigh. Raw alues are scaled using the Arduino map() function, so that raw values in the range mapFromLow to mapFromHigh are scaled to lie in the range mapToLow to mapToHigh. The result is contrained to lie in the range mapToLow to mapToHigh. The default values are suitable for use with the DX6i, and scale the channels to the range 0-1023.

Parameters
[in]channelThe number of the channel to get.
[in]mapFromLow
[in]mapFromHigh
[in]mapToLow
[in]mapToHigh
Returns
The raw channel value scaled according to the map arguments. If the channel number is out of range for that transmitter, or if it is more than RCTRAINER_MAX_CHANNELS, returns 0 scaled as per the map arguments
Examples:
dx6i.ino.

References getChannelRaw().

int16_t RcTrainer::getChannelRaw ( uint16_t  channel)

Read the raw channel value for the specified channel. The raw channel value is the length of the PPM pulse for that channel in microseconds The range of values seen will depend on your transmitter, and the position of the stick connected to that channel, and the configuration of the transmitter. On the DX6i, the range of raw channel values varies from about 1096 to 1916, with the stick midpoints at about 1512.

Parameters
[in]channelThe number of the channel to get.
Returns
The raw channel value in microseconds. If the channel number is out of range for that transmitter, or if it is more than RCTRAINER_MAX_CHANNELS, returns 0.

Referenced by getChannel().


The documentation for this class was generated from the following files: