RSeries astromech firmware
DomeDriveSerial.h
Go to the documentation of this file.
1 #ifndef DomeDriveSerial_h
2 #define DomeDriveSerial_h
3 
4 #include "ServoDispatch.h"
5 #include "drive/DomeDrive.h"
6 
22 class DomeDriveSerial : public DomeDrive
23 {
24 public:
31  fSerial(&stream),
32  fStopped(false)
33  {
34  setMaxSpeed(1.0f);
35  }
36 
37  virtual void setup() override
38  {
39  }
40 
41  virtual void stop() override
42  {
43  if (!fStopped)
44  {
45  if (fSerial != nullptr)
46  fSerial->println("~DOMESTOP");
47  fStopped = true;
48  }
50  }
51 
52 protected:
53  Stream* fSerial;
54  bool fStopped;
55 
56  virtual void motor(float m) override
57  {
58  if (fSerial != nullptr)
59  {
60  fSerial->print("~DOME");
61  printNumZeroPad(unsigned(100+m*100));
62  fSerial->println();
63  }
64  fStopped = false;
65  }
66 
67  void printNumZeroPad(unsigned num)
68  {
69  if (num < 100)
70  fSerial->print(0);
71  if (num < 10)
72  fSerial->print(0);
73  fSerial->print(num);
74  }
75 };
76 #endif
ServoDispatch.h
DomeDriveSerial::setup
virtual void setup() override
Subclasses must implement this function to perform any necessary setup that cannot happen in the cons...
Definition: DomeDriveSerial.h:37
DomeDriveSerial::printNumZeroPad
void printNumZeroPad(unsigned num)
Definition: DomeDriveSerial.h:67
DomeDriveSerial::fStopped
bool fStopped
Definition: DomeDriveSerial.h:54
DomeDriveSerial::motor
virtual void motor(float m) override
Definition: DomeDriveSerial.h:56
DomeDrive::stop
virtual void stop()
Definition: DomeDrive.h:225
DomeDriveSerial
Base template of automatic forwarder from i2c to CommandEvent.
Definition: DomeDriveSerial.h:22
DomeDrive.h
DomeDriveSerial::stop
virtual void stop() override
Definition: DomeDriveSerial.h:41
DomeDrive::setMaxSpeed
void setMaxSpeed(float modifier)
Definition: DomeDrive.h:153
DomeDrive::domeStick
void domeStick(JoystickController *stick, float speedModifier)
Definition: DomeDrive.h:370
JoystickController
Definition: JoystickController.h:4
DomeDriveSerial::fSerial
Stream * fSerial
Definition: DomeDriveSerial.h:53
DomeDriveSerial::DomeDriveSerial
DomeDriveSerial(Stream &stream, JoystickController &domeStick)
Constructor.
Definition: DomeDriveSerial.h:29
DomeDrive
Base template of automatic forwarder from i2c to CommandEvent.
Definition: DomeDrive.h:66