|
RSeries astromech firmware
|
|
Go to the documentation of this file.
25 return fProvider.
ready();
37 return fDomeDefaultMode;
43 fLastChangeMS = millis();
48 fDomeDefaultMode = mode;
75 return float(fDomeSpeedHome) / 100.0;
80 return float(fDomeSpeedTarget) / 100.0;
85 return float(fDomeSpeedMin) / 100.0;
90 return float(fDomeSpeedAuto) / 100.0;
100 return fDomeAutoLeft;
105 return fDomeAutoRight;
110 return fDomeAutoMinDelay;
115 return fDomeAutoMaxDelay;
120 return fDomeHomeMinDelay;
125 return fDomeHomeMaxDelay;
130 return fDomeTargetMinDelay;
135 return fDomeTargetMaxDelay;
177 return fDomeTargetPos;
182 return fDomeRelativeTargetPos;
188 int diff = fmod(fmod(abs(origin - target), 360), 360);
193 result = (360 - diff);
208 unsigned angle = fProvider.
getAngle();
209 if (angle != fLastAngle)
211 if (fLastAngle < angle)
215 fLastChangeMS = millis();
223 return fRelativeDegrees;
229 fDomeRelativeTargetPos = 0;
230 fRelativeDegrees = 0;
235 fLastChangeMS = millis();
245 return (
ready() && fLastAngle != ~0u) ? uint32_t(fTimeout)*1000 < millis() - fLastChangeMS :
true;
255 degrees = (long)fmod(degrees, 360);
271 degrees = (long)fmod(degrees, 360);
279 degrees = (long)fmod(degrees, 360);
283 fDomeRelativeTargetPos = 0;
290 fDomeRelativeTargetPos = degrees;
291 fRelativeDegrees = 0;
301 degrees = (long)fmod(degrees +
getDomeHome(), 360);
309 fDomeSpeedHome = speed;
314 fDomeSpeedTarget = speed;
319 fDomeSpeedMin = speed;
324 fDomeSpeedAuto = speed;
329 fDomeAutoMinDelay = sec;
334 fDomeAutoMaxDelay = sec;
339 fDomeHomeMinDelay = sec;
344 fDomeHomeMaxDelay = sec;
349 fDomeTargetMinDelay = sec;
354 fDomeTargetMaxDelay = sec;
364 fDomeAutoLeft = degrees;
369 fDomeAutoRight = degrees;
374 fTargetReached = reached;
379 fHomeTargetReached = reached;
384 fAutoTargetReached = reached;
389 if (fTargetReached !=
nullptr)
392 fTargetReached =
nullptr;
398 if (fHomeTargetReached !=
nullptr)
399 fHomeTargetReached();
404 if (fAutoTargetReached !=
nullptr)
405 fAutoTargetReached();
412 bool fDomeFlip =
false;
413 uint16_t fDomeHome = 0;
414 uint16_t fDomeTargetPos = fDomeHome;
415 long fDomeRelativeTargetPos = 0;
416 uint8_t fDomeAutoMinDelay = 6;
417 uint8_t fDomeAutoMaxDelay = 8;
418 uint8_t fDomeHomeMinDelay = 6;
419 uint8_t fDomeHomeMaxDelay = 8;
420 uint8_t fDomeTargetMinDelay = 6;
421 uint8_t fDomeTargetMaxDelay = 8;
422 uint8_t fDomeAutoRight = 80;
423 uint8_t fDomeAutoLeft = 80;
424 uint8_t fDomeFudge = 5;
425 uint8_t fDomeSpeedHome = 40;
426 uint8_t fDomeSpeedTarget = 40;
427 uint8_t fDomeSpeedMin = 15;
428 uint8_t fDomeSpeedAuto = 30;
429 uint8_t fTimeout = 5;
430 unsigned fLastAngle = ~0;
431 uint32_t fLastChangeMS = 0;
432 unsigned fRelativeDegrees = 0;
433 void (*fTargetReached)() =
nullptr;
434 void (*fHomeTargetReached)() =
nullptr;
435 void (*fAutoTargetReached)() =
nullptr;
437 static bool withinArc(
double p1,
double p2,
double p3)
439 return fmod(p2 - p1 + 2*360, 360) >= fmod(p3 - p1 + 2*360, 360);
void setTargetReached(void(*reached)())
Definition: DomePosition.h:372
unsigned getDomeMaxDelay()
Definition: DomePosition.h:154
void reachedHomeTarget()
Definition: DomePosition.h:396
Mode
Definition: DomePosition.h:10
void setHomeTargetReached(void(*reached)())
Definition: DomePosition.h:377
@ kOff
Definition: DomePosition.h:12
void resetWatchdog()
Definition: DomePosition.h:233
void setDomeHomeMaxDelay(uint8_t sec)
Definition: DomePosition.h:342
void reachedTarget()
Definition: DomePosition.h:387
bool ready()
Definition: DomePosition.h:23
unsigned getDomeAutoRight()
Definition: DomePosition.h:103
void setDomeMinSpeed(uint8_t speed)
Definition: DomePosition.h:317
@ kHome
Definition: DomePosition.h:13
void setDomeAutoSpeed(uint8_t speed)
Definition: DomePosition.h:322
@ kTarget
Definition: DomePosition.h:15
Definition: DomePosition.h:7
void setDomeAutoMaxDelay(uint8_t sec)
Definition: DomePosition.h:332
unsigned getDomeMinDelay()
Definition: DomePosition.h:138
unsigned getDomeHome()
Definition: DomePosition.h:170
@ kRandom
Definition: DomePosition.h:14
void setDomeHomeRelativeHomePosition(long degrees)
Definition: DomePosition.h:299
unsigned getDomeTargetPosition()
Definition: DomePosition.h:175
unsigned getDomeTargetMinDelay()
Definition: DomePosition.h:128
unsigned getDomeHomeMaxDelay()
Definition: DomePosition.h:123
void setDomeRelativeTargetPosition(long degrees)
Definition: DomePosition.h:286
bool isAtPosition(long degrees)
Definition: DomePosition.h:261
unsigned getDomeAutoMinDelay()
Definition: DomePosition.h:108
float getDomeMinSpeed()
Definition: DomePosition.h:83
unsigned getDomeAutoLeft()
Definition: DomePosition.h:98
void setDomeDefaultMode(Mode mode)
Definition: DomePosition.h:46
void setDomeHomeMinDelay(uint8_t sec)
Definition: DomePosition.h:337
bool getDomeFlip()
Definition: DomePosition.h:52
long getDomeRelativeTargetPosition()
Definition: DomePosition.h:180
Definition: DomePositionProvider.h:4
unsigned getDomeTargetMaxDelay()
Definition: DomePosition.h:133
unsigned getDomePosition()
Definition: DomePosition.h:206
Mode getDomeMode()
Definition: DomePosition.h:28
void setDomeHomePosition(long degrees)
Definition: DomePosition.h:269
void setDomeTargetMaxDelay(uint8_t sec)
Definition: DomePosition.h:352
void resetDefaultMode()
Definition: DomePosition.h:226
unsigned getDomeHomeMinDelay()
Definition: DomePosition.h:118
float getDomeSpeed()
Definition: DomePosition.h:57
float getDomeSpeedHome()
Definition: DomePosition.h:73
void setDomeFudgeFactor(uint8_t fudge)
Definition: DomePosition.h:357
void setDomeAutoMinDelay(uint8_t sec)
Definition: DomePosition.h:327
void setAutoTargetReached(void(*reached)())
Definition: DomePosition.h:382
float getDomeSpeedTarget()
Definition: DomePosition.h:78
void setDomeMode(Mode mode)
Definition: DomePosition.h:40
void setDomeTargetPosition(long degrees)
Definition: DomePosition.h:277
unsigned getHomeRelativeDomePosition()
Definition: DomePosition.h:248
unsigned getDomeFudge()
Definition: DomePosition.h:93
int shortestDistance(int origin, int target)
Definition: DomePosition.h:185
Mode getDomeDefaultMode()
Definition: DomePosition.h:35
bool isTimeout()
Definition: DomePosition.h:243
void setDomeTargetMinDelay(uint8_t sec)
Definition: DomePosition.h:347
void reachedAutoTarget()
Definition: DomePosition.h:402
void setDomeAutoRightDegrees(uint8_t degrees)
Definition: DomePosition.h:367
void setDomeAutoLeftDegrees(uint8_t degrees)
Definition: DomePosition.h:362
void setDomeHomeSpeed(uint8_t speed)
Definition: DomePosition.h:307
DomePosition(DomePositionProvider &provider)
Definition: DomePosition.h:18
int getRelativeDegrees()
Definition: DomePosition.h:221
long normalize(long degrees)
Definition: DomePosition.h:253
void setDomeHomeRelativeTargetPosition(long degrees)
Definition: DomePosition.h:294
float getDomeAutoSpeed()
Definition: DomePosition.h:88
void setDomeTargetSpeed(uint8_t speed)
Definition: DomePosition.h:312
unsigned getDomeAutoMaxDelay()
Definition: DomePosition.h:113
void setTimeout(uint8_t timeout)
Definition: DomePosition.h:238