|
RCKit
|
Remote Control Receiver module for RCOIP protocol on Arduino. More...
#include <RCRx.h>
Public Member Functions | |
| RCRx () | |
| Constructor. After contruction and initialisation, call the init() and run() functions. | |
| void | setOutputs (Setter **analogOutputs, uint8_t numAnalogOutputs) |
| virtual void | setAnalogOutput (uint8_t channel, int value) |
| void | init () |
| void | run () |
| void | handleRequest (uint8_t *msg, uint16_t len, uint16_t rssi) |
| void | failsafe () |
| void | periodicTask () |
| boolean | connected () |
| void | sendReply () |
Remote Control Receiver module for RCOIP protocol on Arduino.
Support of RSSI (receiver signal strength indicator) requires mods to WiShield library g2100.c as per http://asynclabs.com/forums/viewtopic.php?f=10&t=385&start=0. You dont have to add this but its a good feature. It is included in the prebuilt WiShield library mentioned below.
Correct operation of the WiShield requires you to set the jumper on the WiShield to INT0 or DIG8 to select the arduino pin to use for WiShield interrupts, and also to make sure it agrees with the settings of USE_DIG0_INTR or USE_DIG8_INTR in spi.h in the WiShield library (which defaults to using Arduino digital pin 2, and which means setting the WiShield jumper to INT0 setting). Yes, the naming conventions are inconsistent :-(. In summary:
WiShield jumper spi.h Arduino
INT0 USE_DIG0_INTR Digital pin 2
D8 USE_DIG8_INTR Digital pin 8
For YellowJacket (which has no jumper), leave it as USE_DIG0_INTR.
In order for WiShield library to support UDP (as needed by this module), you MUST set UIP_CONF_UDP to 1 in uip-conf.h. This is an unfortunate but necessary requirement, otherwise UDP support will not be compiled into the WiShield library. Further, you must edit apps-conf.h and make sure the only APP_* defined is APP_UDPAPP. Failure to do this will cause compile errors. A modified version of the WiShield library already modified for use with RCKit (including RSSI support) is available at http://www.open.com.au/mikem/arduino/WiShield-v1.3.0-0-mikem-RCKit.zip
WiShield will work with Arduino Mega, but with difficulty. The problem is that with the Mega, the SPI pins that are required for interface with WiShield come out on different pins to the smaller form factor arduinos like Diecimila and Duemilanove. So, to make the Mega work with the WiShield, you have to reroute the SPI pin to different Arduino pins, as per http://asynclabs.com/forums/viewtopic.php?f=13&t=19&hilit=mega&start=10
This library has been tested with Duemilanove and WiShield 1.0 and iPhone 3.0
Install in the usual way: unzip the distribution zip file to the libraries sub-folder of your sketchbook. Dont foget the prerequisites too.
DifferentialRCRx.pde, HBridge2RCRx.pde, HBridgeRCRx.pde, and RCRx.pde.
| boolean RCRx::connected | ( | ) |
Returns whether the RCRx considers itself to be connected to the transmitter. Initialsed to false. Whenever an RCOIP request is receved, set to true. If no RCOIP request is receved for more than failInterval miliseconds, set to false.
| void RCRx::failsafe | ( | ) |
Called by RCRx when no RCOIP message has been received for more than failInterval miliseconds. Calls the failsafe function for all configured output Setters.
References Setter::failsafe().
Referenced by periodicTask().
| void RCRx::handleRequest | ( | uint8_t * | msg, |
| uint16_t | len, | ||
| uint16_t | rssi | ||
| ) |
Call to handle an incoming UDP message containing an RCOIP command message. This is usually only called from within RCRx, but could be called externally for testing purposes etc.
| [in] | msg | Pointer to the UDP message |
| [in] | len | Length of the UDP mesage in bytes |
| [in] | rssi | Receiver Signal Strength as reported by the WiFi receiver when the message was received. |
References RCOIPv1CmdSetAnalogChannels::channels, RC_VERSION1, sendReply(), setAnalogOutput(), and RCOIPv1CmdSetAnalogChannels::version.
| void RCRx::init | ( | ) |
Initialises the wireless WiFi receiver Call once at startup time after addresses etc have been configured.
| void RCRx::periodicTask | ( | ) |
Called by RCRx periodically (typically twice per second) to do period processing such as detecting loss of messages
References failsafe().
| void RCRx::run | ( | ) |
Call this to process pending Wireless events. Call this as often as possible in your main loop. Runs the wireless driver stack.
| void RCRx::sendReply | ( | ) |
Sends an RCOIP reply message Usually called internally at most once every _replyInterval milliseconds.
References RCOIPv1ReplyReceiverStatus::batteryVoltage, RC_VERSION, RCOIPv1ReplyReceiverStatus::RSSI, and RCOIPv1ReplyReceiverStatus::version.
Referenced by handleRequest().
| void RCRx::setAnalogOutput | ( | uint8_t | channel, |
| int | value | ||
| ) | [virtual] |
Set the output for channel n. Calls the Setter at index n of the analogOutputs array. Not usuallly called exernally, this is usually only called from within RCRx. Subclasses can override this to get control when new analog output values become available
| [in] | channel | The analog channel number output to set |
| [in] | value | The new value to set |
References Setter::input().
Referenced by handleRequest().
| void RCRx::setOutputs | ( | Setter ** | analogOutputs, |
| uint8_t | numAnalogOutputs | ||
| ) |
Specifies the Setters that will be used by this receiver to set its output values Whenever a RCOIP message is received with a new value for channel n, it will be passed to the Setter at index n by calling the Setters input() function.
| [in] | analogOutputs | Pointer to an array pointers to Setter objects. |
| [in] | numAnalogOutputs | Number of elements in analogOutputs |
1.7.5.1