rcProtocol
V.0.3.0
A protocol for diy transmitters/receivers
|
#include <rcSettings.h>
Public Member Functions | |
RCSettings () | |
void | setSettings (const uint8_t *settings) |
uint8_t * | getSettings () |
void | setEnableDynamicPayload (bool enable) |
bool | getEnableDynamicPayload () |
void | setEnableAck (bool enable) |
bool | getEnableAck () |
void | setEnableAckPayload (bool enable) |
bool | getEnableAckPayload () |
void | setDataRate (rf24_datarate_e datarate) |
rf24_datarate_e | getDataRate () |
void | setStartChannel (uint8_t channel) |
uint8_t | getStartChannel () |
void | setPayloadSize (uint8_t payload) |
uint8_t | getPayloadSize () |
void | setCommsFrequency (uint8_t frequency) |
uint8_t | getCommsFrequency () |
void | setRetryDelay (uint8_t time) |
uint8_t | getRetryDelay () |
void | setNumChannels (uint8_t numChannels) |
uint8_t | getNumChannels () |
void | printSettings () |
Definition at line 6 of file rcSettings.h.
RCSettings::RCSettings | ( | ) |
Create a new instance of RCSettings.
When you create RCSettings all of the default values will be set.
This object is used by DeviceProtocol::begin()
Definition at line 5 of file rcSettings.cpp.
void RCSettings::setSettings | ( | const uint8_t * | settings | ) |
Set all of the settings at once with one array of settings.
settings | 32 byte array |
Definition at line 17 of file rcSettings.cpp.
uint8_t * RCSettings::getSettings | ( | ) |
Get all of the settings as one array of settings
Definition at line 23 of file rcSettings.cpp.
void RCSettings::setEnableDynamicPayload | ( | bool | enable | ) |
Enable/Disable Dynamic payloads
Dynamic payloads don't have a specific payload size, and will vary from transaction to transaction.
If you disable dynamic payloads, see setPayloadSize()
Uses 0b00000001
of byte 0
Default: false
enable |
Definition at line 27 of file rcSettings.cpp.
bool RCSettings::getEnableDynamicPayload | ( | ) |
get the currently set value from setEnableDynamicPayload()
Definition at line 33 of file rcSettings.cpp.
void RCSettings::setEnableAck | ( | bool | enable | ) |
Enable/Disable Acknowledgements
Acknowledgements are used so the sender can know if the receiver received the message.
You can disable this if you want but that comes at the cost of not getting telemetry data.
Uses 0b00000010
of byte 0
Default: true
enable |
Definition at line 37 of file rcSettings.cpp.
bool RCSettings::getEnableAck | ( | ) |
get the currently set value from setEnableAck()
Definition at line 43 of file rcSettings.cpp.
void RCSettings::setEnableAckPayload | ( | bool | enable | ) |
Enable/Disable Custom Ack Paylaods
Custom ack payloads allow acknowledgments to be filled with custom data. setEnableAck() needs to be enabled for this to work.
This should be set to true to enable telemetry data.
Uses 0b00000100
0f byte 0
Default: true
enable |
Definition at line 47 of file rcSettings.cpp.
bool RCSettings::getEnableAckPayload | ( | ) |
Get the currently set value from setEnableAckPayload()
Definition at line 53 of file rcSettings.cpp.
void RCSettings::setDataRate | ( | rf24_datarate_e | datarate | ) |
DataRate
There are two options for datarate, three if you have a (+) model
Uses 0b00011000
of byte 0
Default: RF24_1MBPS
datarate | see rf24_datarate_e |
Definition at line 57 of file rcSettings.cpp.
rf24_datarate_e RCSettings::getDataRate | ( | ) |
Get the currently set value from setDataRate()
Definition at line 63 of file rcSettings.cpp.
void RCSettings::setStartChannel | ( | uint8_t | channel | ) |
Starting radio Channel.
There are 128 channels (0-127) to choose from. Selecting an arbitrary number can help lower the chances of interference.
Uses byte 1
Default: 0
channel | 0-127 |
Definition at line 76 of file rcSettings.cpp.
uint8_t RCSettings::getStartChannel | ( | ) |
Get the currently set value from setStartChannel()
Definition at line 80 of file rcSettings.cpp.
void RCSettings::setPayloadSize | ( | uint8_t | payload | ) |
Payload Size
Set the size of the payload in bytes
Uses byte 2
Default: 32
payload |
Definition at line 84 of file rcSettings.cpp.
uint8_t RCSettings::getPayloadSize | ( | ) |
Get the currently set value from setPayloadSize()
Definition at line 88 of file rcSettings.cpp.
void RCSettings::setCommsFrequency | ( | uint8_t | frequency | ) |
Communication Frequency
Set the number of transactions the transmitter will send per second. The max frequency is 255hz.
Uses byte 3
Default: 60
Definition at line 92 of file rcSettings.cpp.
uint8_t RCSettings::getCommsFrequency | ( | ) |
Get the currently set value from setCommsFrequency()
Definition at line 96 of file rcSettings.cpp.
void RCSettings::setRetryDelay | ( | uint8_t | time | ) |
Retry Delay
Set the time before the transmission is resent.
(x): time value
DataRate | Min Time for Full Packet | Ack Size at 250 us (0) |
---|---|---|
2MBPS | 500 us (1) | 15 bytes |
1MBPS | 500 us (1) | 5 bytes |
250KBPS | 1500 us (5) | None (500us (1) min for empty packet) |
Uses 0b00001111
of byte 4
Default: 15
time | How long to wait between each retry, in multiples of 250us, max is 15. 0 means 250us, 15 means 4000us. |
Definition at line 100 of file rcSettings.cpp.
uint8_t RCSettings::getRetryDelay | ( | ) |
Get the currently set value from setRetryDelay()
Definition at line 106 of file rcSettings.cpp.
void RCSettings::setNumChannels | ( | uint8_t | numChannels | ) |
Number of channels in a packet
Set the number of channels in a packet, each channel uses 2 bytes default, so a 32 byte packet can hold up to 15 channels.
Uses byte 5
Default: 6
numChannels | number of channels to send (1 to 15) |
Definition at line 110 of file rcSettings.cpp.
uint8_t RCSettings::getNumChannels | ( | ) |
Get the currently set value from setNumChannels()
Definition at line 114 of file rcSettings.cpp.
void RCSettings::printSettings | ( | ) |
Print the settings to Serial.
Definition at line 118 of file rcSettings.cpp.