• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/jgoppert/Projects/ap/libraries/RC_Channel/RC_Channel.h

Go to the documentation of this file.
00001 // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
00002 
00005 
00006 #ifndef RC_Channel_h
00007 #define RC_Channel_h
00008 
00009 #include <stdint.h>
00010 #include <AP_EEPROMB.h>
00011 
00014 class RC_Channel{
00015   public:       
00020         RC_Channel() :
00021                 _address(0)
00022         {}
00023 
00030         RC_Channel(uint16_t address) :
00031                 _address(address),
00032                 _high(1),
00033                 _filter(true),
00034                 _reverse(1)
00035         {}
00036 
00037         // setup min and max radio values in CLI
00038         void            update_min_max();
00039         void            zero_min_max();
00040         
00041         // startup
00042         void            load_eeprom(void);
00043         void            save_eeprom(void);              
00044         void            save_trim(void);                
00045         void            set_filter(bool filter);
00046 
00047         // setup the control preferences
00048         void            set_range(int low, int high);
00049         void            set_angle(int angle);
00050         void            set_reverse(bool reverse);
00051 
00052         // read input from APM_RC - create a control_in value
00053         void            set_pwm(int pwm);
00054         
00055         // pwm is stored here
00056         int16_t         radio_in;
00057 
00058         // call after first set_pwm
00059         void            trim();
00060         
00061         // did our read come in 50µs below the min?
00062         bool            get_failsafe(void);
00063         
00064         // value generated from PWM
00065         int16_t         control_in;
00066         int16_t         dead_zone; // used to keep noise down and create a dead zone.
00067         
00068         int                     control_mix(float value);
00069         
00070         // current values to the servos - degrees * 100 (approx assuming servo is -45 to 45 degrees except [3] is 0 to 100
00071         int16_t         servo_out;
00072 
00073         // generate PWM from servo_out value
00074         void            calc_pwm(void);
00075 
00076         // PWM is without the offset from radio_min
00077         int16_t         pwm_out;
00078         int16_t         radio_out;
00079 
00080         int16_t         radio_min;
00081         int16_t         radio_trim;
00082         int16_t         radio_max;
00083         
00084         // includes offset from PWM
00085         //int16_t       get_radio_out(void);
00086 
00087         int16_t         pwm_to_angle();
00088         float           norm_input();
00089         float           norm_output();
00090         int16_t         angle_to_pwm();
00091         int16_t         pwm_to_range();
00092         int16_t         range_to_pwm();
00093 
00094         float           scale_output;
00095         
00096   private:
00097         bool            _filter;
00098         int8_t          _reverse;
00099 
00100         int16_t         _address;                       
00101         bool            _type;                          
00102         int16_t         _high;
00103         int16_t         _low;
00104         AP_EEPROMB      _ee;
00105 };
00106 
00107 #endif  
00108 
00109 
00110 
00111 

Generated for ArduPilot Libraries by doxygen