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

/home/jgoppert/Projects/ap/libraries/AP_RcChannel/AP_RcChannel.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 AP_RcChannel_h
00007 #define AP_RcChannel_h
00008 
00009 #include <stdint.h>
00010 #include <FastSerial.h>
00011 #include <APM_RC.h>
00012 
00015 class AP_RcChannel{
00016  
00017 public: 
00018 
00020         AP_RcChannel(const APM_RC_Class & rc, const uint16_t & ch,
00021                         const float & scale, const uint16_t & pwmMin, const uint16_t & pwmNeutral,
00022                         const uint16_t & pwmMax, const uint16_t & pwmDeadZone,
00023                         const bool & filter, const bool & reverse) :
00024                 _rc(rc),
00025                 _ch(ch),
00026                 _scale(scale),
00027                 _pwmMin(pwmMin),
00028                 _pwmMax(pwmMax),
00029                 _pwmNeutral(pwmNeutral),
00030                 _pwmDeadZone(pwmDeadZone),
00031                 _pwm(0),
00032                 _filter(filter),
00033                 _reverse(reverse)
00034         {
00035         }
00036 
00037         // set servo state
00038         void readRadio();
00039         void setPwm(uint16_t pwm);
00040         void setPosition(float position);
00041         void mixRadio(uint16_t infStart);
00042 
00043         // get servo state
00044         uint16_t getPwm() { return _pwm; }
00045         float getPosition() { return _pwmToPosition(_pwm); }
00046         float getNormalized() { return getPosition()/_scale; }
00047         
00048         // did our read come in 50µs below the min?
00049         bool failSafe() { _pwm < (_pwmMin - 50); }
00050 
00051 private:
00052 
00053         // configuration
00054         const APM_RC_Class & _rc;
00055         const uint16_t _ch;
00056         const float & _scale;
00057         const uint16_t & _pwmMin;
00058         const uint16_t & _pwmNeutral;
00059         const uint16_t & _pwmMax;
00060         const uint16_t & _pwmDeadZone;
00061         const bool & _filter;
00062         const bool & _reverse;
00063 
00064         // internal states
00065         uint16_t _pwm; // this is the internal state, position is just created when needed
00066 
00067         // private methods
00068         uint16_t _positionToPwm(const float & position);
00069         float _pwmToPosition(const uint16_t & pwm);
00070 };
00071 
00072 #endif  
00073 
00074 
00075 
00076 

Generated for ArduPilot Libraries by doxygen