RcTrainer
|
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) |
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.
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.
[in] | interrupt | This 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 |
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.
[in] | channel | The number of the channel to get. |
[in] | mapFromLow | |
[in] | mapFromHigh | |
[in] | mapToLow | |
[in] | mapToHigh |
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.
[in] | channel | The number of the channel to get. |
Referenced by getChannel().