|
RSeries astromech firmware
|
|
Go to the documentation of this file.
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)
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)
23 #ifdef USE_VERBOSE_DOME_DEBUG
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)
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)
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)
43 #ifndef DOME_DIRECTION_CHANGE_THRESHOLD
44 #define DOME_DIRECTION_CHANGE_THRESHOLD 5
47 #ifndef DOME_RANDOM_MOVE_MIN_DEGREES
48 #define DOME_RANDOM_MOVE_MIN_DEGREES 5
277 virtual void motor(
float m) = 0;
297 speedModifier +=
getThrottle() * ((1.0f-speedModifier));
299 return min(max(speedModifier,0.0f),1.0f) * -1.0f;
306 return fmod(p2 - p1 + 2*360, 360) >= fmod(p3 - p1 + 2*360, 360);
311 degrees = fmod(degrees, 360);
320 int diff = fmod(fmod(abs(origin - target), 360), 360);
325 result = (360 - diff);
347 if (!
withinArc(target - fudge, target + fudge, pos))
351 if (abs(dist) <= decelerationScale)
352 speed *= (abs(dist) / decelerationScale);
389 uint32_t currentMillis = millis();
394 auto m = (float)(stickx + 128) / 127.5f - 1.0f;
399 m = pow(abs(m)-0.2, 1.4) * ((m < 0) ? -1 : 1);
419 m = max(-1.0f, min(m, 1.0f)) * drive_mod;
500 uint32_t r = random(minDelay, maxDelay);
515 else if (random(100) < 10)
517 uint32_t r = random(minDelay, maxDelay);
549 uint32_t r = random(minDelay, maxDelay);
567 if (relativeDegrees != 0)
573 if (dist <= decelerationScale)
575 speed *= (dist / decelerationScale);
578 if (relativeDegrees > 0)
667 if (abs(m) < minspeed)
unsigned getDomeMaxDelay()
Definition: DomePosition.h:154
virtual float throttleSpeed(float speedModifier)
Definition: DomeDrive.h:291
void reachedHomeTarget()
Definition: DomePosition.h:396
virtual void autonomousDriveDome(float m)
Definition: DomeDrive.h:266
Mode
Definition: DomePosition.h:10
bool useLeftStick()
Definition: DomeDrive.h:195
State state
Definition: JoystickController.h:136
@ kOff
Definition: DomePosition.h:12
virtual void driveDome(float m)
Definition: DomeDrive.h:261
unsigned getThrottleAccelerationScale() const
Definition: DomeDrive.h:160
bool getScaling() const
Definition: DomeDrive.h:138
void setThrottleDecelerationScale(unsigned scale)
Definition: DomeDrive.h:175
JoystickController * getActiveStick()
Definition: DomeDrive.h:238
void resetWatchdog()
Definition: DomePosition.h:233
void reachedTarget()
Definition: DomePosition.h:387
bool fUseLeftStick
Definition: DomeDrive.h:695
unsigned getDomeAutoRight()
Definition: DomePosition.h:103
bool fEnabled
Definition: DomeDrive.h:690
uint32_t fSerialLatency
Definition: DomeDrive.h:704
int8_t lx
Definition: JoystickController.h:9
uint32_t fMovementFinishTime
Definition: DomeDrive.h:718
#define DOME_RANDOM_MOVE_MIN_DEGREES
Definition: DomeDrive.h:48
float getSpeed(float percentage)
Definition: DomeDrive.h:338
@ kHome
Definition: DomePosition.h:13
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
JoystickController & fDomeStick
Definition: DomeDrive.h:688
@ kTarget
Definition: DomePosition.h:15
Definition: DomePosition.h:7
Base class for all devices that require setup that cannot happen in the constructor....
Definition: SetupEvent.h:15
int fLastDomeMode
Definition: DomeDrive.h:711
@ kRandom
Definition: DomeDrive.h:685
bool isConnected() const
Definition: JoystickController.h:146
unsigned getDomeMinDelay()
Definition: DomePosition.h:138
float getMaxSpeed() const
Definition: DomeDrive.h:148
bool fDomeMovementStarted
Definition: DomeDrive.h:707
bool useThrottle()
Definition: DomeDrive.h:185
bool fUseThrottle
Definition: DomeDrive.h:696
unsigned getDomeHome()
Definition: DomePosition.h:170
bool fInverted
Definition: DomeDrive.h:698
bool isMoving()
Definition: DomeDrive.h:233
@ kRandom
Definition: DomePosition.h:14
unsigned getDomeTargetPosition()
Definition: DomePosition.h:175
void setDomeStick(JoystickController &domeStick)
Definition: DomeDrive.h:180
#define DOME_DEBUG_PRINTLN(s)
Definition: DomeDrive.h:18
float fSpeedModifier
Definition: DomeDrive.h:700
#define DEBUG_PRINTLN(s)
Definition: ReelTwo.h:188
Analog analog
Definition: JoystickController.h:130
float fDomeThrottle
Definition: DomeDrive.h:710
bool fError
Definition: DomeDrive.h:689
void setUseLeftStick()
Definition: DomeDrive.h:215
bool checkError()
Definition: DomeDrive.h:101
virtual void stop()
Definition: DomeDrive.h:225
float getDomeMinSpeed()
Definition: DomePosition.h:83
bool fWasConnected
Definition: DomeDrive.h:691
bool moveDomeToTarget(int pos, int target, int fudge, float speed, float &m)
Definition: DomeDrive.h:345
@ kOff
Definition: DomeDrive.h:683
unsigned getDomeAutoLeft()
Definition: DomePosition.h:98
Button button
Definition: JoystickController.h:131
int8_t rx
Definition: JoystickController.h:11
#define VERBOSE_DOME_DEBUG_PRINTLN(s)
Definition: DomeDrive.h:38
unsigned getThrottleDecelerationScale() const
Definition: DomeDrive.h:170
long getDomeRelativeTargetPosition()
Definition: DomePosition.h:180
void setUseThrottle(bool use)
Definition: DomeDrive.h:205
int fAutoDomeTargetPos
Definition: DomeDrive.h:712
AnalogStick stick
Definition: JoystickController.h:35
@ kHome
Definition: DomeDrive.h:684
unsigned fThrottleAccelerationScale
Definition: DomeDrive.h:708
unsigned getDomePosition()
Definition: DomePosition.h:206
virtual void motor(float m)=0
bool useRightStick()
Definition: DomeDrive.h:200
DomePosition * fDomePosition
Definition: DomeDrive.h:716
Mode getDomeMode()
Definition: DomePosition.h:28
uint32_t getSerialLatency() const
Definition: DomeDrive.h:118
bool fAutoDomeGoHome
Definition: DomeDrive.h:713
bool fUseHardStop
Definition: DomeDrive.h:697
virtual float getThrottle()
Definition: DomeDrive.h:279
void resetDefaultMode()
Definition: DomePosition.h:226
float getDomeSpeed()
Definition: DomePosition.h:57
void setUseHardStop(bool use)
Definition: DomeDrive.h:210
void setDomeMode(Mode mode)
Definition: DomePosition.h:40
virtual void setup() override
Subclasses must implement this function to perform any necessary setup that cannot happen in the cons...
Definition: DomeDrive.h:92
unsigned getDomeFudge()
Definition: DomePosition.h:93
void setEnable(bool enable)
Definition: DomeDrive.h:113
bool fIdle
Definition: DomeDrive.h:693
virtual void animate() override
Subclasses must implement this function to run through a single frame of animation/activity.
Definition: DomeDrive.h:247
virtual bool idle()
Definition: DomeDrive.h:271
uint32_t fLastCommand
Definition: DomeDrive.h:705
AnalogButton button
Definition: JoystickController.h:36
float fDrive
Definition: DomeDrive.h:701
bool getInverted() const
Definition: DomeDrive.h:128
bool fScaling
Definition: DomeDrive.h:694
int fLastDomePosition
Definition: DomeDrive.h:703
uint32_t fNextAutoDomeMovement
Definition: DomeDrive.h:715
bool isTimeout()
Definition: DomePosition.h:243
void setMaxSpeed(float modifier)
Definition: DomeDrive.h:153
void reachedAutoTarget()
Definition: DomePosition.h:402
unsigned fThrottleDecelerationScale
Definition: DomeDrive.h:709
bool fAutoDomeLeft
Definition: DomeDrive.h:714
void setUseRightStick()
Definition: DomeDrive.h:220
static bool withinArc(double p1, double p2, double p3)
Definition: DomeDrive.h:304
int shortestDistance(int origin, int target)
Definition: DomeDrive.h:317
bool useHardStop()
Definition: DomeDrive.h:190
int normalize(int degrees)
Definition: DomeDrive.h:309
float fAutoDrive
Definition: DomeDrive.h:702
bool getEnable() const
Definition: DomeDrive.h:108
void domeStick(JoystickController *stick, float speedModifier)
Definition: DomeDrive.h:370
DomeMode
Definition: DomeDrive.h:681
int getRelativeDegrees()
Definition: DomePosition.h:221
Definition: JoystickController.h:4
uint32_t fMovementStartTime
Definition: DomeDrive.h:717
#define DOME_DEBUG_PRINT(s)
Definition: DomeDrive.h:17
void(* fComplete)()
Definition: DomeDrive.h:719
void setInverted(bool invert)
Definition: DomeDrive.h:133
void setSerialLatency(uint32_t ms)
Definition: DomeDrive.h:123
void setDomePosition(DomePosition *domePosition)
Definition: DomeDrive.h:96
bool fMoving
Definition: DomeDrive.h:699
bool fMotorStopped
Definition: DomeDrive.h:692
void setScaling(bool scaling)
Definition: DomeDrive.h:143
void setThrottleAccelerationScale(unsigned scale)
Definition: DomeDrive.h:165
DomeDrive(JoystickController &domeStick)
Constructor.
Definition: DomeDrive.h:75
Base template of automatic forwarder from i2c to CommandEvent.
Definition: DomeDrive.h:66
#define VERBOSE_DOME_DEBUG_PRINT(s)
Definition: DomeDrive.h:37
uint32_t fLastDomeMovement
Definition: DomeDrive.h:706