modify RC_Channel for AP_Param

This commit is contained in:
Andrew Tridgell 2012-02-11 22:54:21 +11:00
parent 013d66527d
commit fc0f1c52ca
4 changed files with 41 additions and 24 deletions

View File

@ -24,6 +24,15 @@
APM_RC_Class *RC_Channel::_apm_rc;
const AP_Param::GroupInfo RC_Channel::var_info[] PROGMEM = {
{ AP_PARAM_INT16, "MIN", VAROFFSET(RC_Channel, radio_min) },
{ AP_PARAM_INT16, "TRIM", VAROFFSET(RC_Channel, radio_trim) },
{ AP_PARAM_INT16, "MAX", VAROFFSET(RC_Channel, radio_max) },
{ AP_PARAM_INT8, "REV", VAROFFSET(RC_Channel, _reverse) },
{ AP_PARAM_INT16, "DZ", VAROFFSET(RC_Channel, _dead_zone) },
{ AP_PARAM_NONE, "" }
};
// setup the control preferences
void
RC_Channel::set_range(int low, int high)
@ -163,13 +172,19 @@ RC_Channel::calc_pwm(void)
void
RC_Channel::load_eeprom(void)
{
_group.load();
radio_min.load();
radio_trim.load();
radio_max.load();
_reverse.load();
}
void
RC_Channel::save_eeprom(void)
{
_group.save();
radio_min.save();
radio_trim.save();
radio_max.save();
_reverse.save();
}
// ------------------------------------------

View File

@ -12,26 +12,13 @@
/// @class RC_Channel
/// @brief Object managing one RC channel
class RC_Channel{
protected:
AP_Var_group _group; // must be before all vars to keep ctor init order correct
public:
/// Constructor
///
/// @param key EEPROM storage key for the channel trim parameters.
/// @param name Optional name for the group.
///
RC_Channel(AP_Var::Key key, const prog_char_t *name) :
_group(key, name),
radio_min (&_group, 0, 1100, name ? PSTR("MIN") : 0), // suppress name if group has no name
radio_trim(&_group, 1, 1500, name ? PSTR("TRIM") : 0),
radio_max (&_group, 2, 1900, name ? PSTR("MAX") : 0),
_high(1),
_filter(false),
_reverse (&_group, 3, 1, name ? PSTR("REV") : 0),
_dead_zone (&_group, 4, 0, name ? PSTR("DZ") : 0),
//_dead_zone(0),
scale_output(1.0)
RC_Channel()
{}
// setup min and max radio values in CLI
@ -97,11 +84,13 @@ class RC_Channel{
static void set_apm_rc(APM_RC_Class * apm_rc);
static APM_RC_Class *_apm_rc;
static const struct AP_Param::GroupInfo var_info[];
AP_Int8 _reverse;
AP_Int16 _dead_zone;
private:
bool _filter;
AP_Int8 _reverse;
AP_Int16 _dead_zone;
//int16_t _dead_zone; // used to keep noise down and create a dead zone.
uint8_t _type;
int16_t _high;

View File

@ -3,6 +3,18 @@
#include <APM_RC.h>
#include "RC_Channel_aux.h"
const AP_Param::GroupInfo RC_Channel_aux::var_info[] PROGMEM = {
{ AP_PARAM_INT16, "MIN", VAROFFSET(RC_Channel_aux, radio_min) },
{ AP_PARAM_INT16, "TRIM", VAROFFSET(RC_Channel_aux, radio_trim) },
{ AP_PARAM_INT16, "MAX", VAROFFSET(RC_Channel_aux, radio_max) },
{ AP_PARAM_INT8, "REV", VAROFFSET(RC_Channel_aux, _reverse) },
{ AP_PARAM_INT16, "DZ", VAROFFSET(RC_Channel_aux, _dead_zone) },
{ AP_PARAM_INT8, "FUNCTION", VAROFFSET(RC_Channel_aux, function) },
{ AP_PARAM_INT8, "ANGLE_MIN", VAROFFSET(RC_Channel_aux, angle_min) },
{ AP_PARAM_INT8, "ANGLE_MAX", VAROFFSET(RC_Channel_aux, angle_max) },
{ AP_PARAM_NONE, "" }
};
RC_Channel_aux* g_rc_function[RC_Channel_aux::k_nr_aux_servo_functions]; // the aux. servo ch. assigned to each function
int16_t

View File

@ -22,11 +22,11 @@ public:
/// @param key EEPROM storage key for the channel trim parameters.
/// @param name Optional name for the group.
///
RC_Channel_aux(AP_Var::Key key, const prog_char_t *name) :
RC_Channel(key, name),
function (&_group, 4, k_none, name ? PSTR("FUNCTION") : 0), // suppress name if group has no name
angle_min (&_group, 5, -4500, name ? PSTR("ANGLE_MIN") : 0), // assume -45 degrees min deflection
angle_max (&_group, 6, 4500, name ? PSTR("ANGLE_MAX") : 0) // assume 45 degrees max deflection
RC_Channel_aux() :
RC_Channel(),
function (0),
angle_min (-4500), // assume -45 degrees min deflection
angle_max (4500) // assume 45 degrees max deflection
{}
typedef enum
@ -52,6 +52,7 @@ public:
void output_ch(unsigned char ch_nr); // map a function to a servo channel and output it
static const struct AP_Param::GroupInfo var_info[];
};
void update_aux_servo_function(RC_Channel_aux* rc_5, RC_Channel_aux* rc_6, RC_Channel_aux* rc_7, RC_Channel_aux* rc_8);