RSeries astromech firmware
DomeDrivePWM.h
Go to the documentation of this file.
1 #ifndef DomeDrivePWM_h
2 #define DomeDrivePWM_h
3 
4 #include "ServoDispatch.h"
5 #include "drive/DomeDrive.h"
6 
22 class DomeDrivePWM : public DomeDrive
23 {
24 public:
29  DomeDrivePWM(ServoDispatch& dispatch, uint8_t pwmNum, JoystickController& domeStick) :
31  fDispatch(dispatch),
32  fPWM(pwmNum)
33  {
34  setMaxSpeed(1.0f);
35  }
36 
37  virtual void setup() override
38  {
39  }
40 
41  virtual void stop() override
42  {
43  fDispatch.moveTo(fPWM, 0.5);
45  }
46 
47 protected:
49  uint8_t fPWM;
50 
51  virtual void motor(float m) override
52  {
53  m = map(m, -1.0f, 1.0f, 0.0f, 1.0f);
54  fDispatch.moveTo(fPWM, m);
55  }
56 
57  static float map(float x, float in_min, float in_max, float out_min, float out_max)
58  {
59  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
60  }
61 };
62 #endif
ServoDispatch.h
DomeDrivePWM::setup
virtual void setup() override
Subclasses must implement this function to perform any necessary setup that cannot happen in the cons...
Definition: DomeDrivePWM.h:37
DomeDrive::stop
virtual void stop()
Definition: DomeDrive.h:225
ServoDispatch::moveTo
void moveTo(uint16_t num, uint32_t startDelay, uint32_t moveTime, float pos)
Definition: ServoDispatch.h:132
DomeDrivePWM::stop
virtual void stop() override
Definition: DomeDrivePWM.h:41
DomeDrive.h
DomeDrivePWM::DomeDrivePWM
DomeDrivePWM(ServoDispatch &dispatch, uint8_t pwmNum, JoystickController &domeStick)
Constructor.
Definition: DomeDrivePWM.h:29
DomeDrive::setMaxSpeed
void setMaxSpeed(float modifier)
Definition: DomeDrive.h:153
ServoDispatch
Servo interace implemented eitehr by ServoDispatchPCA9685 or ServoDispatchDirect.
Definition: ServoDispatch.h:83
DomeDrivePWM::fDispatch
ServoDispatch & fDispatch
Definition: DomeDrivePWM.h:48
DomeDrive::domeStick
void domeStick(JoystickController *stick, float speedModifier)
Definition: DomeDrive.h:370
JoystickController
Definition: JoystickController.h:4
DomeDrivePWM
Base template of automatic forwarder from i2c to CommandEvent.
Definition: DomeDrivePWM.h:22
DomeDrivePWM::motor
virtual void motor(float m) override
Definition: DomeDrivePWM.h:51
DomeDrivePWM::fPWM
uint8_t fPWM
Definition: DomeDrivePWM.h:49
DomeDrive
Base template of automatic forwarder from i2c to CommandEvent.
Definition: DomeDrive.h:66
DomeDrivePWM::map
static float map(float x, float in_min, float in_max, float out_min, float out_max)
Definition: DomeDrivePWM.h:57