RSeries astromech firmware
DomeDrive.h
Go to the documentation of this file.
1 #ifndef DomeDrive_h
2 #define DomeDrive_h
3 
4 #include "ReelTwo.h"
5 #include "core/AnimatedEvent.h"
6 #include "core/SetupEvent.h"
7 #include "JoystickController.h"
8 #include "ServoEasing.h"
9 #include "drive/DomePosition.h"
10 
11 #ifdef USE_DOME_DEBUG
12 #define DOME_DEBUG_PRINT(s) DEBUG_PRINT(s)
13 #define DOME_DEBUG_PRINTLN(s) DEBUG_PRINTLN(s)
14 #define DOME_DEBUG_PRINT_HEX(s) DEBUG_PRINT_HEX(s)
15 #define DOME_DEBUG_PRINTLN_HEX(s) DEBUG_PRINTLN_HEX(s)
16 #else
17 #define DOME_DEBUG_PRINT(s)
18 #define DOME_DEBUG_PRINTLN(s)
19 #define DOME_DEBUG_PRINT_HEX(s)
20 #define DOME_DEBUG_PRINTLN_HEX(s)
21 #endif
22 
23 #ifdef USE_VERBOSE_DOME_DEBUG
24 #if !defined(__AVR__)
25 static bool sVerboseDomeDebug;
26 #define VERBOSE_DOME_DEBUG_PRINT(s) { if (sVerboseDomeDebug) { DEBUG_PRINT(s); } }
27 #define VERBOSE_DOME_DEBUG_PRINTLN(s) { if (sVerboseDomeDebug) { DEBUG_PRINTLN(s); } }
28 #define VERBOSE_DOME_DEBUG_PRINT_HEX(s) DEBUG_PRINT_HEX(s)
29 #define VERBOSE_DOME_DEBUG_PRINTLN_HEX(s) DEBUG_PRINTLN_HEX(s)
30 #else
31 #define VERBOSE_DOME_DEBUG_PRINT(s) DEBUG_PRINT(s)
32 #define VERBOSE_DOME_DEBUG_PRINTLN(s) DEBUG_PRINTLN(s)
33 #define VERBOSE_DOME_DEBUG_PRINT_HEX(s) DEBUG_PRINT_HEX(s)
34 #define VERBOSE_DOME_DEBUG_PRINTLN_HEX(s) DEBUG_PRINTLN_HEX(s)
35 #endif
36 #else
37 #define VERBOSE_DOME_DEBUG_PRINT(s)
38 #define VERBOSE_DOME_DEBUG_PRINTLN(s)
39 #define VERBOSE_DOME_DEBUG_PRINT_HEX(s)
40 #define VERBOSE_DOME_DEBUG_PRINTLN_HEX(s)
41 #endif
42 
43 #ifndef DOME_DIRECTION_CHANGE_THRESHOLD
44 #define DOME_DIRECTION_CHANGE_THRESHOLD 5
45 #endif
46 
47 #ifndef DOME_RANDOM_MOVE_MIN_DEGREES
48 #define DOME_RANDOM_MOVE_MIN_DEGREES 5
49 #endif
50 
66 class DomeDrive : public SetupEvent, public AnimatedEvent
67 {
68 public:
77  {
78  // Default enabled
79  setEnable(true);
80  // Default to half speed max
81  setMaxSpeed(0.5);
82  // Default 25ms
83  //setSerialLatency(25);
86  setInverted(false);
87  setScaling(true);
89  setUseThrottle(true);
90  }
91 
92  virtual void setup() override
93  {
94  }
95 
96  inline void setDomePosition(DomePosition* domePosition)
97  {
98  fDomePosition = domePosition;
99  }
100 
101  bool checkError()
102  {
103  bool error = fError;
104  fError = false;
105  return error;
106  }
107 
108  bool getEnable() const
109  {
110  return fEnabled;
111  }
112 
113  void setEnable(bool enable)
114  {
115  fEnabled = enable;
116  }
117 
118  uint32_t getSerialLatency() const
119  {
120  return fSerialLatency;
121  }
122 
123  void setSerialLatency(uint32_t ms)
124  {
125  fSerialLatency = ms;
126  }
127 
128  bool getInverted() const
129  {
130  return fInverted;
131  }
132 
133  void setInverted(bool invert)
134  {
135  fInverted = invert;
136  }
137 
138  bool getScaling() const
139  {
140  return fScaling;
141  }
142 
143  void setScaling(bool scaling)
144  {
145  fScaling = scaling;
146  }
147 
148  float getMaxSpeed() const
149  {
150  return fSpeedModifier;
151  }
152 
153  void setMaxSpeed(float modifier)
154  {
155  if (fDomeStick.isConnected())
156  stop();
157  fSpeedModifier = min(max(modifier, 0.0f), 1.0f);
158  }
159 
161  {
163  }
164 
165  void setThrottleAccelerationScale(unsigned scale)
166  {
168  }
169 
171  {
173  }
174 
175  void setThrottleDecelerationScale(unsigned scale)
176  {
178  }
179 
181  {
183  }
184 
185  bool useThrottle()
186  {
187  return fUseThrottle;
188  }
189 
190  bool useHardStop()
191  {
192  return fUseHardStop;
193  }
194 
196  {
197  return fUseLeftStick;
198  }
199 
201  {
202  return !fUseLeftStick;
203  }
204 
205  void setUseThrottle(bool use)
206  {
207  fUseThrottle = use;
208  }
209 
210  void setUseHardStop(bool use)
211  {
212  fUseHardStop = use;
213  }
214 
216  {
217  fUseLeftStick = true;
218  }
219 
221  {
222  fUseLeftStick = false;
223  }
224 
225  virtual void stop()
226  {
227  fMotorStopped = true;
228  fDrive = 0;
229  fAutoDrive = 0;
230  fMoving = false;
231  }
232 
233  inline bool isMoving()
234  {
235  return fMoving;
236  }
237 
239  {
240  if (fDomeStick.isConnected())
241  {
242  return &fDomeStick;
243  }
244  return nullptr;
245  }
246 
247  virtual void animate() override
248  {
249  if (fDomeStick.isConnected())
250  {
252  }
253  else if (fWasConnected)
254  {
255  stop();
256  DOME_DEBUG_PRINTLN("Waiting to reconnect");
257  fWasConnected = false;
258  }
259  }
260 
261  virtual void driveDome(float m)
262  {
263  fDrive = getInverted() ? -m : m;
264  }
265 
266  virtual void autonomousDriveDome(float m)
267  {
268  fAutoDrive = getInverted() ? -m : m;
269  }
270 
271  virtual bool idle()
272  {
273  return fIdle;
274  }
275 
276 protected:
277  virtual void motor(float m) = 0;
278 
279  virtual float getThrottle()
280  {
282  {
283  if (useLeftStick())
284  return float(fDomeStick.state.analog.button.l2)/255.0f;
285  if (useRightStick())
286  return float(fDomeStick.state.analog.button.r2)/255.0f;
287  }
288  return 0.0f;
289  }
290 
291  virtual float throttleSpeed(float speedModifier)
292  {
293  if (useThrottle())
294  {
295  if (fDomeStick.isConnected())
296  {
297  speedModifier += getThrottle() * ((1.0f-speedModifier));
298  }
299  return min(max(speedModifier,0.0f),1.0f) * -1.0f;
300  }
301  return 0.0f;
302  }
303 
304  static bool withinArc(double p1, double p2, double p3)
305  {
306  return fmod(p2 - p1 + 2*360, 360) >= fmod(p3 - p1 + 2*360, 360);
307  }
308 
309  int normalize(int degrees)
310  {
311  degrees = fmod(degrees, 360);
312  if (degrees < 0)
313  degrees += 360;
314  return degrees;
315  }
316 
317  int shortestDistance(int origin, int target)
318  {
319  int result = 0.0;
320  int diff = fmod(fmod(abs(origin - target), 360), 360);
321 
322  if (diff > 180)
323  {
324  //There is a shorter path in opposite direction
325  result = (360 - diff);
326  if (target > origin)
327  result *= -1;
328  }
329  else
330  {
331  result = diff;
332  if (origin > target)
333  result *= -1;
334  }
335  return result;
336  }
337 
338  float getSpeed(float percentage)
339  {
340  if (fDomePosition != nullptr)
341  return max(getMaxSpeed() * percentage, fDomePosition->getDomeMinSpeed());
342  return getMaxSpeed() * percentage;
343  }
344 
345  bool moveDomeToTarget(int pos, int target, int fudge, float speed, float &m)
346  {
347  if (!withinArc(target - fudge, target + fudge, pos))
348  {
349  int dist = shortestDistance(pos, target);
350  float decelerationScale = getThrottleDecelerationScale();
351  if (abs(dist) <= decelerationScale)
352  speed *= (abs(dist) / decelerationScale);
353  speed = getSpeed(speed);
357  if (dist > 0)
358  {
359  m = -speed;
360  }
361  else
362  {
363  m = speed;
364  }
365  return false;
366  }
367  return true;
368  }
369 
370  void domeStick(JoystickController* stick, float speedModifier)
371  {
372  fWasConnected = true;
373  if (!fEnabled)
374  {
375  stop();
376  }
377  else if (useHardStop() &&
378  ((useLeftStick() && stick->state.button.l1) ||
379  (useRightStick() && stick->state.button.r1)))
380  {
381  if (!fMotorStopped)
382  {
383  DOME_DEBUG_PRINTLN("STOP");
384  stop();
385  }
386  }
387  else
388  {
389  uint32_t currentMillis = millis();
390  if (currentMillis - fLastCommand > fSerialLatency)
391  {
392  auto stickx = useLeftStick() ? stick->state.analog.stick.lx : stick->state.analog.stick.rx;
393  auto drive_mod = throttleSpeed(speedModifier);
394  auto m = (float)(stickx + 128) / 127.5f - 1.0f;
395 
396  if (abs(m) < 0.2)
397  m = 0;
398  else
399  m = pow(abs(m)-0.2, 1.4) * ((m < 0) ? -1 : 1);
400  if (m != 0)
401  {
402  // Any movement of joysticks will disable programmatic drive
403  fDrive = 0;
404  fAutoDrive = 0;
405  }
406  else if (fDrive != 0)
407  {
408  // Use programmatic drive if active
409  m = fDrive;
410  fAutoDrive = 0;
411  }
412  else
413  {
414  // Use lowest priorty programmatic drive if active
415  m = fAutoDrive;
416  }
417 
418  // clamp to -1/+1 and apply max speed limit
419  m = max(-1.0f, min(m, 1.0f)) * drive_mod;
420 
421  if (abs(m) != 0.0 || fAutoDrive != 0)
422  {
423  if (fIdle)
424  {
425  if (fDomePosition != nullptr)
426  {
429  }
430  fLastDomeMovement = currentMillis;
431  fDomeMovementStarted = false;
432  DOME_DEBUG_PRINTLN("DOME NO LONGER IDLE");
433  }
434  fIdle = false;
435  }
436 
437  bool scaling = fScaling;
438  DomePosition::Mode domeMode = (fDomePosition != nullptr) ?
440  if (domeMode != DomePosition::kOff && abs(m) == 0.0)
441  {
442  // No joystick movement - check auto dome
443  uint32_t minDelay = uint32_t(fDomePosition->getDomeMinDelay()) * 1000L;
444  uint32_t maxDelay = uint32_t(fDomePosition->getDomeMaxDelay()) * 1000L;
445  if (fLastDomeMovement + minDelay < currentMillis)
446  {
447  if (!fIdle)
448  {
449  DOME_DEBUG_PRINTLN("DOME IDLE.");
450  }
451  fIdle = true;
452  int pos = fDomePosition->getDomePosition();
453  int home = fDomePosition->getDomeHome();
454  int targetpos = fDomePosition->getDomeTargetPosition();
455  int fudge = fDomePosition->getDomeFudge();
456  bool newMode = (fLastDomeMode != domeMode);
457  if (!newMode)
458  {
460  {
462  fDomeMovementStarted = true;
463  }
464  else if (fDomePosition->isTimeout())
465  {
466  DOME_DEBUG_PRINTLN("TIMEOUT: NO DOME MOVEMENT DETECTED");
468  fDomeMovementStarted = false;
469  fError = true;
470  }
471  }
472  else
473  {
474  fDomeMovementStarted = false;
475  DEBUG_PRINTLN("NEW DOME MODE");
476  }
477  switch (fLastDomeMode = domeMode)
478  {
479  case DomePosition::kOff:
480  m = 0;
481  break;
482  case DomePosition::kHome:
483  {
484  float speed = fDomePosition->getDomeSpeed();
485  if (moveDomeToTarget(pos, home, fudge, speed, m))
486  {
487  // Reached target set mode back to default
490  fLastDomeMovement = currentMillis;
491  fDomeMovementStarted = false;
492  }
493  break;
494  }
496  {
497  float speed = fDomePosition->getDomeSpeed();
498  if (newMode)
499  {
500  uint32_t r = random(minDelay, maxDelay);
501  DOME_DEBUG_PRINT("RANDOM START IN "); DOME_DEBUG_PRINTLN(r);
502  fNextAutoDomeMovement = millis() + r;
503  fAutoDomeTargetPos = -1;
504  fAutoDomeLeft = random(1);
505  }
506  if (fAutoDomeTargetPos == -1 && fNextAutoDomeMovement < millis())
507  {
508  if (fAutoDomeGoHome)
509  {
510  DOME_DEBUG_PRINTLN("RANDOM GO HOME: "+String(home));
511  fAutoDomeTargetPos = home;
512  fAutoDomeGoHome = false;
513  fAutoDomeLeft = random(1);
514  }
515  else if (random(100) < 10)
516  {
517  uint32_t r = random(minDelay, maxDelay);
518  DOME_DEBUG_PRINTLN("RANDOM DO NOTHING NEXT: "+String(r));
519  fNextAutoDomeMovement = millis() + r;
520  }
521  else if (fAutoDomeLeft)
522  {
523  int distance = random(fDomePosition->getDomeAutoLeft());
524  distance = max(DOME_RANDOM_MOVE_MIN_DEGREES, distance);
525  fAutoDomeTargetPos = normalize(home - distance);
526  fAutoDomeGoHome = (random(100) < 10);
527  DOME_DEBUG_PRINTLN("RANDOM TURN LEFT: "+String(distance)+" newpos: "+String(fAutoDomeTargetPos));
528  fAutoDomeLeft = (random(100) < 10);
529  }
530  else
531  {
532  int distance = random(fDomePosition->getDomeAutoRight());
533  distance = max(DOME_RANDOM_MOVE_MIN_DEGREES, distance);
534  fAutoDomeTargetPos = normalize(home + distance);
535  fAutoDomeGoHome = (random(100) < 10);
536  DOME_DEBUG_PRINTLN("RANDOM TURN RIGHT: "+String(distance)+" newpos: "+String(fAutoDomeTargetPos));
537  fAutoDomeLeft = !(random(100) < 10);
538  }
539  if (fAutoDomeTargetPos != -1)
540  {
542  }
543  }
544  if (fAutoDomeTargetPos != -1)
545  {
546  if (moveDomeToTarget(pos, fAutoDomeTargetPos, fudge, speed, m))
547  {
548  // Set next autodome movement time
549  uint32_t r = random(minDelay, maxDelay);
550  DOME_DEBUG_PRINTLN("RANDOM ARRIVED NEXT: "+String(r));
552  fNextAutoDomeMovement = millis() + r;
553  fAutoDomeTargetPos = -1;
554  fDomeMovementStarted = false;
555  }
556  }
557  else
558  {
560  }
561  break;
562  }
564  {
565  float speed = fDomePosition->getDomeSpeed();
566  long relativeDegrees = fDomePosition->getDomeRelativeTargetPosition();
567  if (relativeDegrees != 0)
568  {
569  int dist = abs(relativeDegrees - fDomePosition->getRelativeDegrees());
570  if (abs(fDomePosition->getRelativeDegrees()) < abs(relativeDegrees))
571  {
572  float decelerationScale = getThrottleDecelerationScale();
573  if (dist <= decelerationScale)
574  {
575  speed *= (dist / decelerationScale);
576  }
577  speed = getSpeed(speed);
578  if (relativeDegrees > 0)
579  {
580  m = -speed;
581  }
582  else
583  {
584  m = speed;
585  }
586  }
587  else
588  {
589  // Reached target set mode back to default
592  fLastDomeMovement = currentMillis;
593  fDomeMovementStarted = false;
594  }
595  }
596  else if (moveDomeToTarget(pos, targetpos, fudge, speed, m))
597  {
598  // Reached target set mode back to default
601  fLastDomeMovement = currentMillis;
602  fDomeMovementStarted = false;
603  }
604  break;
605  }
606  }
607  }
608  // Always scale auto dome
609  scaling = true;
610  }
611  else
612  {
613  fLastDomeMovement = currentMillis;
614  }
615  if (scaling)
616  {
617  if (m > fDomeThrottle)
618  {
619  float scale = fThrottleAccelerationScale;
620  if (fDomeThrottle < 0)
621  {
622  VERBOSE_DOME_DEBUG_PRINT("DECELERATING ");
624  fDomeThrottle = m;
625  }
626  else
627  {
628  VERBOSE_DOME_DEBUG_PRINT("ACCELERATING REVERSE ");
629  }
630  float val = max(abs(m - fDomeThrottle) / scale, 0.01f);
632  VERBOSE_DOME_DEBUG_PRINT(" m: ");
634  VERBOSE_DOME_DEBUG_PRINT(" drive : ");
636  VERBOSE_DOME_DEBUG_PRINT(" => ");
637  fDomeThrottle = ((int)round(min(fDomeThrottle + val, m)*100))/100.0f;
639  }
640  else if (m < fDomeThrottle)
641  {
642  float scale = fThrottleAccelerationScale;
643  if (fDomeThrottle > 0)
644  {
645  VERBOSE_DOME_DEBUG_PRINT("DECELERATING REVERSE ");
647  fDomeThrottle = m;
648  }
649  else
650  {
651  VERBOSE_DOME_DEBUG_PRINT("ACCELERATING ");
652  }
653  float val = abs(m - fDomeThrottle) / scale;
655  VERBOSE_DOME_DEBUG_PRINT(" m: ");
657  VERBOSE_DOME_DEBUG_PRINT(" drive : ");
659  VERBOSE_DOME_DEBUG_PRINT(" => ");
660  fDomeThrottle = ((int)floor(max(fDomeThrottle - val, m)*100))/100.0f;
662  }
663  m = fDomeThrottle;
664  if (fDomePosition != nullptr)
665  {
666  float minspeed = fDomePosition->getDomeMinSpeed();
667  if (abs(m) < minspeed)
668  {
669  m = 0;
670  }
671  }
672  }
673  motor(getInverted() ? -m : m);
674  fLastCommand = currentMillis;
675  fMoving = (abs(m) != 0.0);
676  fMotorStopped = false;
677  }
678  }
679  }
680 
681  enum DomeMode
682  {
686  };
687 
689  bool fError = false;
690  bool fEnabled = false;
691  bool fWasConnected = false;
692  bool fMotorStopped = false;
693  bool fIdle = true;
694  bool fScaling = false;
695  bool fUseLeftStick = false;
696  bool fUseThrottle = true;
697  bool fUseHardStop = false;
698  bool fInverted = false;
699  bool fMoving = false;
701  float fDrive = 0;
702  float fAutoDrive = 0;
704  uint32_t fSerialLatency = 0;
705  uint32_t fLastCommand = 0;
706  uint32_t fLastDomeMovement = 0;
707  bool fDomeMovementStarted = false;
710  float fDomeThrottle = 0;
711  int fLastDomeMode = -1;
713  bool fAutoDomeGoHome = false;
714  bool fAutoDomeLeft = random(1);
715  uint32_t fNextAutoDomeMovement = 0;
717  uint32_t fMovementStartTime = 0;
718  uint32_t fMovementFinishTime = 0;
719  void (*fComplete)() = nullptr;
720 };
721 #endif
DomePosition::getDomeMaxDelay
unsigned getDomeMaxDelay()
Definition: DomePosition.h:154
DomeDrive::throttleSpeed
virtual float throttleSpeed(float speedModifier)
Definition: DomeDrive.h:291
DomePosition::reachedHomeTarget
void reachedHomeTarget()
Definition: DomePosition.h:396
DomeDrive::autonomousDriveDome
virtual void autonomousDriveDome(float m)
Definition: DomeDrive.h:266
DomePosition::Mode
Mode
Definition: DomePosition.h:10
DomeDrive::useLeftStick
bool useLeftStick()
Definition: DomeDrive.h:195
JoystickController::state
State state
Definition: JoystickController.h:136
JoystickController::AnalogButton::l2
uint8_t l2
Definition: JoystickController.h:22
DomePosition::kOff
@ kOff
Definition: DomePosition.h:12
DomeDrive::driveDome
virtual void driveDome(float m)
Definition: DomeDrive.h:261
DomeDrive::getThrottleAccelerationScale
unsigned getThrottleAccelerationScale() const
Definition: DomeDrive.h:160
DomeDrive::getScaling
bool getScaling() const
Definition: DomeDrive.h:138
DomeDrive::setThrottleDecelerationScale
void setThrottleDecelerationScale(unsigned scale)
Definition: DomeDrive.h:175
DomeDrive::getActiveStick
JoystickController * getActiveStick()
Definition: DomeDrive.h:238
DomePosition::resetWatchdog
void resetWatchdog()
Definition: DomePosition.h:233
DomePosition::reachedTarget
void reachedTarget()
Definition: DomePosition.h:387
DomeDrive::fUseLeftStick
bool fUseLeftStick
Definition: DomeDrive.h:695
DomePosition::getDomeAutoRight
unsigned getDomeAutoRight()
Definition: DomePosition.h:103
DomeDrive::fEnabled
bool fEnabled
Definition: DomeDrive.h:690
DomeDrive::fSerialLatency
uint32_t fSerialLatency
Definition: DomeDrive.h:704
JoystickController::AnalogStick::lx
int8_t lx
Definition: JoystickController.h:9
ReelTwo.h
DomeDrive::fMovementFinishTime
uint32_t fMovementFinishTime
Definition: DomeDrive.h:718
SetupEvent.h
DOME_RANDOM_MOVE_MIN_DEGREES
#define DOME_RANDOM_MOVE_MIN_DEGREES
Definition: DomeDrive.h:48
DomeDrive::getSpeed
float getSpeed(float percentage)
Definition: DomeDrive.h:338
DomePosition::kHome
@ kHome
Definition: DomePosition.h:13
AnimatedEvent
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
DomeDrive::fDomeStick
JoystickController & fDomeStick
Definition: DomeDrive.h:688
DomePosition::kTarget
@ kTarget
Definition: DomePosition.h:15
DomePosition
Definition: DomePosition.h:7
SetupEvent
Base class for all devices that require setup that cannot happen in the constructor....
Definition: SetupEvent.h:15
DomeDrive::fLastDomeMode
int fLastDomeMode
Definition: DomeDrive.h:711
DomeDrive::kRandom
@ kRandom
Definition: DomeDrive.h:685
JoystickController::isConnected
bool isConnected() const
Definition: JoystickController.h:146
DomePosition::getDomeMinDelay
unsigned getDomeMinDelay()
Definition: DomePosition.h:138
AnimatedEvent.h
DomeDrive::getMaxSpeed
float getMaxSpeed() const
Definition: DomeDrive.h:148
DomeDrive::fDomeMovementStarted
bool fDomeMovementStarted
Definition: DomeDrive.h:707
DomeDrive::useThrottle
bool useThrottle()
Definition: DomeDrive.h:185
DomeDrive::fUseThrottle
bool fUseThrottle
Definition: DomeDrive.h:696
DomePosition::getDomeHome
unsigned getDomeHome()
Definition: DomePosition.h:170
DomeDrive::fInverted
bool fInverted
Definition: DomeDrive.h:698
DomeDrive::isMoving
bool isMoving()
Definition: DomeDrive.h:233
DomePosition::kRandom
@ kRandom
Definition: DomePosition.h:14
DomePosition::getDomeTargetPosition
unsigned getDomeTargetPosition()
Definition: DomePosition.h:175
DomeDrive::setDomeStick
void setDomeStick(JoystickController &domeStick)
Definition: DomeDrive.h:180
DOME_DEBUG_PRINTLN
#define DOME_DEBUG_PRINTLN(s)
Definition: DomeDrive.h:18
DomeDrive::fSpeedModifier
float fSpeedModifier
Definition: DomeDrive.h:700
DEBUG_PRINTLN
#define DEBUG_PRINTLN(s)
Definition: ReelTwo.h:188
JoystickController::State::analog
Analog analog
Definition: JoystickController.h:130
DomeDrive::fDomeThrottle
float fDomeThrottle
Definition: DomeDrive.h:710
DomeDrive::fError
bool fError
Definition: DomeDrive.h:689
DomeDrive::setUseLeftStick
void setUseLeftStick()
Definition: DomeDrive.h:215
JoystickController::Button::r1
uint8_t r1
Definition: JoystickController.h:59
DomeDrive::checkError
bool checkError()
Definition: DomeDrive.h:101
DomeDrive::stop
virtual void stop()
Definition: DomeDrive.h:225
DomePosition::getDomeMinSpeed
float getDomeMinSpeed()
Definition: DomePosition.h:83
DomeDrive::fWasConnected
bool fWasConnected
Definition: DomeDrive.h:691
DomePosition.h
DomeDrive::moveDomeToTarget
bool moveDomeToTarget(int pos, int target, int fudge, float speed, float &m)
Definition: DomeDrive.h:345
DomeDrive::kOff
@ kOff
Definition: DomeDrive.h:683
DomePosition::getDomeAutoLeft
unsigned getDomeAutoLeft()
Definition: DomePosition.h:98
JoystickController::State::button
Button button
Definition: JoystickController.h:131
JoystickController::AnalogStick::rx
int8_t rx
Definition: JoystickController.h:11
VERBOSE_DOME_DEBUG_PRINTLN
#define VERBOSE_DOME_DEBUG_PRINTLN(s)
Definition: DomeDrive.h:38
DomeDrive::getThrottleDecelerationScale
unsigned getThrottleDecelerationScale() const
Definition: DomeDrive.h:170
DomePosition::getDomeRelativeTargetPosition
long getDomeRelativeTargetPosition()
Definition: DomePosition.h:180
DomeDrive::setUseThrottle
void setUseThrottle(bool use)
Definition: DomeDrive.h:205
DomeDrive::fAutoDomeTargetPos
int fAutoDomeTargetPos
Definition: DomeDrive.h:712
JoystickController::Analog::stick
AnalogStick stick
Definition: JoystickController.h:35
DomeDrive::kHome
@ kHome
Definition: DomeDrive.h:684
DomeDrive::fThrottleAccelerationScale
unsigned fThrottleAccelerationScale
Definition: DomeDrive.h:708
DomePosition::getDomePosition
unsigned getDomePosition()
Definition: DomePosition.h:206
DomeDrive::motor
virtual void motor(float m)=0
DomeDrive::useRightStick
bool useRightStick()
Definition: DomeDrive.h:200
DomeDrive::fDomePosition
DomePosition * fDomePosition
Definition: DomeDrive.h:716
DomePosition::getDomeMode
Mode getDomeMode()
Definition: DomePosition.h:28
DomeDrive::getSerialLatency
uint32_t getSerialLatency() const
Definition: DomeDrive.h:118
DomeDrive::fAutoDomeGoHome
bool fAutoDomeGoHome
Definition: DomeDrive.h:713
DomeDrive::fUseHardStop
bool fUseHardStop
Definition: DomeDrive.h:697
DomeDrive::getThrottle
virtual float getThrottle()
Definition: DomeDrive.h:279
DomePosition::resetDefaultMode
void resetDefaultMode()
Definition: DomePosition.h:226
DomePosition::getDomeSpeed
float getDomeSpeed()
Definition: DomePosition.h:57
JoystickController.h
DomeDrive::setUseHardStop
void setUseHardStop(bool use)
Definition: DomeDrive.h:210
DomePosition::setDomeMode
void setDomeMode(Mode mode)
Definition: DomePosition.h:40
DomeDrive::setup
virtual void setup() override
Subclasses must implement this function to perform any necessary setup that cannot happen in the cons...
Definition: DomeDrive.h:92
DomePosition::getDomeFudge
unsigned getDomeFudge()
Definition: DomePosition.h:93
DomeDrive::setEnable
void setEnable(bool enable)
Definition: DomeDrive.h:113
JoystickController::Button::l1
uint8_t l1
Definition: JoystickController.h:58
DomeDrive::fIdle
bool fIdle
Definition: DomeDrive.h:693
DomeDrive::animate
virtual void animate() override
Subclasses must implement this function to run through a single frame of animation/activity.
Definition: DomeDrive.h:247
DomeDrive::idle
virtual bool idle()
Definition: DomeDrive.h:271
DomeDrive::fLastCommand
uint32_t fLastCommand
Definition: DomeDrive.h:705
JoystickController::Analog::button
AnalogButton button
Definition: JoystickController.h:36
DomeDrive::fDrive
float fDrive
Definition: DomeDrive.h:701
DomeDrive::getInverted
bool getInverted() const
Definition: DomeDrive.h:128
DomeDrive::fScaling
bool fScaling
Definition: DomeDrive.h:694
DomeDrive::fLastDomePosition
int fLastDomePosition
Definition: DomeDrive.h:703
DomeDrive::fNextAutoDomeMovement
uint32_t fNextAutoDomeMovement
Definition: DomeDrive.h:715
DomePosition::isTimeout
bool isTimeout()
Definition: DomePosition.h:243
DomeDrive::setMaxSpeed
void setMaxSpeed(float modifier)
Definition: DomeDrive.h:153
DomePosition::reachedAutoTarget
void reachedAutoTarget()
Definition: DomePosition.h:402
DomeDrive::fThrottleDecelerationScale
unsigned fThrottleDecelerationScale
Definition: DomeDrive.h:709
DomeDrive::fAutoDomeLeft
bool fAutoDomeLeft
Definition: DomeDrive.h:714
DomeDrive::setUseRightStick
void setUseRightStick()
Definition: DomeDrive.h:220
DomeDrive::withinArc
static bool withinArc(double p1, double p2, double p3)
Definition: DomeDrive.h:304
DomeDrive::shortestDistance
int shortestDistance(int origin, int target)
Definition: DomeDrive.h:317
DomeDrive::useHardStop
bool useHardStop()
Definition: DomeDrive.h:190
DomeDrive::normalize
int normalize(int degrees)
Definition: DomeDrive.h:309
DomeDrive::fAutoDrive
float fAutoDrive
Definition: DomeDrive.h:702
DomeDrive::getEnable
bool getEnable() const
Definition: DomeDrive.h:108
DomeDrive::domeStick
void domeStick(JoystickController *stick, float speedModifier)
Definition: DomeDrive.h:370
DomeDrive::DomeMode
DomeMode
Definition: DomeDrive.h:681
DomePosition::getRelativeDegrees
int getRelativeDegrees()
Definition: DomePosition.h:221
JoystickController
Definition: JoystickController.h:4
DomeDrive::fMovementStartTime
uint32_t fMovementStartTime
Definition: DomeDrive.h:717
DOME_DEBUG_PRINT
#define DOME_DEBUG_PRINT(s)
Definition: DomeDrive.h:17
DomeDrive::fComplete
void(* fComplete)()
Definition: DomeDrive.h:719
DomeDrive::setInverted
void setInverted(bool invert)
Definition: DomeDrive.h:133
DomeDrive::setSerialLatency
void setSerialLatency(uint32_t ms)
Definition: DomeDrive.h:123
DomeDrive::setDomePosition
void setDomePosition(DomePosition *domePosition)
Definition: DomeDrive.h:96
DomeDrive::fMoving
bool fMoving
Definition: DomeDrive.h:699
ServoEasing.h
DomeDrive::fMotorStopped
bool fMotorStopped
Definition: DomeDrive.h:692
JoystickController::AnalogButton::r2
uint8_t r2
Definition: JoystickController.h:23
DomeDrive::setScaling
void setScaling(bool scaling)
Definition: DomeDrive.h:143
DomeDrive::setThrottleAccelerationScale
void setThrottleAccelerationScale(unsigned scale)
Definition: DomeDrive.h:165
DomeDrive::DomeDrive
DomeDrive(JoystickController &domeStick)
Constructor.
Definition: DomeDrive.h:75
DomeDrive
Base template of automatic forwarder from i2c to CommandEvent.
Definition: DomeDrive.h:66
VERBOSE_DOME_DEBUG_PRINT
#define VERBOSE_DOME_DEBUG_PRINT(s)
Definition: DomeDrive.h:37
DomeDrive::fLastDomeMovement
uint32_t fLastDomeMovement
Definition: DomeDrive.h:706