-
-
Save billbonney/3a3d35fde2f72fa90060 to your computer and use it in GitHub Desktop.
RC_Channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class channel_data { | |
public: | |
channel_data():radio_in(0), radio_min(0), radio_max(0){} | |
int16_t radio_in; | |
int16_t radio_min; | |
int16_t radio_max; | |
} | |
class RC_Channels { | |
static const int MAX_CHANNEL = 12; | |
static const int MIN_CHANNEL = 1; | |
void setChannelMin(int channelNumber, int pwmValue); | |
void setChannelMax(int channelNumber, int pwmValue); | |
channel_data at(int index); | |
channel_data &operator[](int index); | |
private: | |
int16_t[11] channel_data; | |
} | |
void RC_Channels::setChannelMin(int channelnumber, int pwmValue){ | |
if (channelNumber >= MAX_CHANNEL)|| channelNumber < MIN_CHANNEL){ | |
log("error)"); | |
return; | |
} | |
channel_data[channelnumber-1].radio_min = pwmValue; | |
} | |
void RC_Channels::setChannelMax(int channelnumber, int pwmValue){ | |
if (channelNumber >= MAX_CHANNEL)|| channelNumber < MIN_CHANNEL){ | |
log("error)"); | |
return; | |
} | |
channel_data[channelnumber-1].radio_max = pwmValue; | |
} | |
channel_data RC_Channels::at(int index){ | |
if (channelNumber >= MAX_CHANNEL)|| channelNumber < MIN_CHANNEL){ | |
log("error)"); | |
return; | |
} | |
return channel_data[index-1]; | |
} | |
channel_data& RC_Channels::operator[](int index) | |
{ | |
return this.at(index); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment