rcProtocol  V.0.3.0
A protocol for diy transmitters/receivers
Public Member Functions | List of all members
RCSettings Class Reference

#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 ()
 

Detailed Description

Definition at line 6 of file rcSettings.h.

Constructor & Destructor Documentation

◆ RCSettings()

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.

Member Function Documentation

◆ setSettings()

void RCSettings::setSettings ( const uint8_t *  settings)

Set all of the settings at once with one array of settings.

Parameters
settings32 byte array

Definition at line 17 of file rcSettings.cpp.

◆ getSettings()

uint8_t * RCSettings::getSettings ( )

Get all of the settings as one array of settings

Returns
32 byte array

Definition at line 23 of file rcSettings.cpp.

◆ setEnableDynamicPayload()

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.

Warning
DynamicPayloads are not currently implemented

If you disable dynamic payloads, see setPayloadSize()

Uses 0b00000001 of byte 0

Default: false

Parameters
enable

Definition at line 27 of file rcSettings.cpp.

◆ getEnableDynamicPayload()

bool RCSettings::getEnableDynamicPayload ( )

get the currently set value from setEnableDynamicPayload()

Returns
enable dynamic payload

Definition at line 33 of file rcSettings.cpp.

◆ setEnableAck()

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

Parameters
enable

Definition at line 37 of file rcSettings.cpp.

◆ getEnableAck()

bool RCSettings::getEnableAck ( )

get the currently set value from setEnableAck()

Returns
enable acknowledgements

Definition at line 43 of file rcSettings.cpp.

◆ setEnableAckPayload()

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.

Warning
Disabling AckPayloads is not yet implemented

This should be set to true to enable telemetry data.

Uses 0b00000100 0f byte 0

Default: true

Note
once this is set to true, it can not be turned off until the next power cycle. Though not much is affected with it enabled.
Parameters
enable

Definition at line 47 of file rcSettings.cpp.

◆ getEnableAckPayload()

bool RCSettings::getEnableAckPayload ( )

Get the currently set value from setEnableAckPayload()

Returns
enable ack payloads

Definition at line 53 of file rcSettings.cpp.

◆ setDataRate()

void RCSettings::setDataRate ( rf24_datarate_e  datarate)

DataRate

There are two options for datarate, three if you have a (+) model

  • RF24_1MBPS
  • RF24_2MBPS
  • RF24_250KBPS (+)

Uses 0b00011000 of byte 0

Default: RF24_1MBPS

Parameters
dataratesee rf24_datarate_e

Definition at line 57 of file rcSettings.cpp.

◆ getDataRate()

rf24_datarate_e RCSettings::getDataRate ( )

Get the currently set value from setDataRate()

Returns
datarate

Definition at line 63 of file rcSettings.cpp.

◆ setStartChannel()

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

Parameters
channel0-127

Definition at line 76 of file rcSettings.cpp.

◆ getStartChannel()

uint8_t RCSettings::getStartChannel ( )

Get the currently set value from setStartChannel()

Returns
channel

Definition at line 80 of file rcSettings.cpp.

◆ setPayloadSize()

void RCSettings::setPayloadSize ( uint8_t  payload)

Payload Size

Set the size of the payload in bytes

Note
This can't be set higher than 32
Warning
Values other than 32 are not fully implemented, use at your own risk!

Uses byte 2

Default: 32

Parameters
payload

Definition at line 84 of file rcSettings.cpp.

◆ getPayloadSize()

uint8_t RCSettings::getPayloadSize ( )

Get the currently set value from setPayloadSize()

Returns
payload

Definition at line 88 of file rcSettings.cpp.

◆ setCommsFrequency()

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

Note
the actual frequency will become more innacurate as the set frequency is increased.

Definition at line 92 of file rcSettings.cpp.

◆ getCommsFrequency()

uint8_t RCSettings::getCommsFrequency ( )

Get the currently set value from setCommsFrequency()

Returns
frequency

Definition at line 96 of file rcSettings.cpp.

◆ setRetryDelay()

void RCSettings::setRetryDelay ( uint8_t  time)

Retry Delay

Set the time before the transmission is resent.

Note
The shorter the delay, the smaller the ack packet can be. see the table below for more information

(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

Parameters
timeHow 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.

◆ getRetryDelay()

uint8_t RCSettings::getRetryDelay ( )

Get the currently set value from setRetryDelay()

Returns
retryDelay

Definition at line 106 of file rcSettings.cpp.

◆ setNumChannels()

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.

Note
In the future, I may support multi-packet transmissions to allow more channels.

Uses byte 5

Default: 6

Parameters
numChannelsnumber of channels to send (1 to 15)

Definition at line 110 of file rcSettings.cpp.

◆ getNumChannels()

uint8_t RCSettings::getNumChannels ( )

Get the currently set value from setNumChannels()

Returns
numChannels

Definition at line 114 of file rcSettings.cpp.

◆ printSettings()

void RCSettings::printSettings ( )

Print the settings to Serial.

Definition at line 118 of file rcSettings.cpp.


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