|
RSeries astromech firmware
|
|
Go to the documentation of this file.
12 #define ANIMATION_FUNC_DECL(name) static signed char Animation_##name(class AnimationPlayer& animation,\
13 unsigned step, unsigned long num, unsigned long elapsedMillis)
14 #define ANIMATION(name) ANIMATION_FUNC_DECL(name) { enum { _firstStep = __COUNTER__ };
15 #define DO_START() UNUSED_ARG(num) UNUSED_ARG(elapsedMillis) switch (step+1) {
16 #define DO_CASE() case __COUNTER__-_firstStep:
17 #define DO_LABEL(label) enum { label = __COUNTER__-_firstStep }; case label: { return true; }
18 #define DO_ONCE_LABEL(label, p) enum { label = __COUNTER__-_firstStep }; case label: { p; return true; }
19 #define DO_ONCE(p) DO_CASE() { p; return true; }
20 #define DO_ONCE_AND_WAIT(p, ms) DO_CASE() { if (!animation.fRepeatStep) { p; } return (ms < elapsedMillis); }
21 #define DO_FOREVER(p) DO_CASE() { p; return false; }
22 #define DO_DURATION(ms, p) DO_CASE() { if (animation.getCurrentTimeMillis() < ms) { p; return false; } return true; }
23 #define DO_DURATION_STEP(ms, p) DO_CASE() { if (elapsedMillis < ms) { p; return false; } return true; }
24 #define DO_WAIT_MILLIS(ms) DO_CASE() { return (ms < elapsedMillis); }
25 #define DO_WAIT_SEC(sec) DO_CASE() { return (sec*1000L < long(elapsedMillis)); }
26 #define DO_GOTO(label) DO_CASE() { animation.gotoStep(label); return -1; }
27 #define DO_WHILE(cond,label) DO_CASE() { if (cond) { animation.gotoStep(label); return -1; } return true; }
28 #define DO_SEQUENCE(seq,mask) DO_CASE() { SEQUENCE_PLAY_ONCE(*animation.fServoSequencer, seq, mask); return true; }
29 #define DO_SEQUENCE_SPEED(seq,mask,speed) DO_CASE() { SEQUENCE_PLAY_ONCE_SPEED(*animation.fServoSequencer, seq, mask, speed); return true; }
30 #define DO_SEQUENCE_VARSPEED(seq,mask,minspeed, maxspeed) DO_CASE() { SEQUENCE_PLAY_ONCE_VARSPEED(*animation.fServoSequencer, seq, mask, minspeed, maxspeed); return true; }
31 #define DO_SEQUENCE_RANDOM_STEP(seq,mask) DO_CASE() { SEQUENCE_PLAY_RANDOM_STEP(*animation.fServoSequencer, seq, mask); return true; }
32 #define DO_WAIT_SEQUENCE() DO_CASE() { return animation.fServoSequencer->isFinished(); }
33 #define DO_WHILE_SEQUENCE(label) DO_CASE() { if (!animation.fServoSequencer->isFinished()) { animation.gotoStep(label); return -1; } return true; }
34 #define DO_COMMAND(cmd) DO_CASE() { CommandEvent::process(cmd); return true; }
35 #define DO_COMMAND_AND_WAIT(cmd, ms) DO_CASE() { if (!animation.fRepeatStep) { CommandEvent::process(cmd); } return (ms < elapsedMillis); }
36 #define DO_MARCDUINO(cmd) DO_CASE() { Marcduino::send(cmd); return true; }
37 #define DO_MARCDUINO_AND_WAIT(cmd, ms) DO_CASE() { if (!animation.fRepeatStep) { Marcduino::send(cmd); } return (ms < elapsedMillis); }
38 #define DO_RESET(p) case 0: { p; return true; }
39 #define DO_END() default: animation.end(); return false; } }
40 #define ANIMATION_PLAY_ONCE(player, name) player.animateOnce(Animation_##name)
107 unsigned long currentMillis = millis();
196 fStep = (step > 0) ? step-1 : 0;
uint8_t fFlags
Definition: Animation.h:227
ServoSequencer * fServoSequencer
Definition: Animation.h:218
Player of animation scripts.
Definition: Animation.h:79
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
void gotoStep(unsigned step)
Go to to the specified step in the active animation script.
Definition: Animation.h:193
bool fRepeatStep
Definition: Animation.h:217
unsigned long fNum
Definition: Animation.h:228
Plays a sequence of servo commands using a servo group mask.
Definition: ServoSequencer.h:389
unsigned fStep
Definition: Animation.h:216
void previousStep()
Rewind to the previous step in the active animation script.
Definition: Animation.h:159
long getCurrentTimeMillis()
Definition: Animation.h:143
void rewind()
Rewind to the beginning in the active animation script.
Definition: Animation.h:168
@ kRunning
Definition: Animation.h:224
AnimationStep fAnimation
Definition: Animation.h:231
unsigned fNumSteps
Definition: Animation.h:215
unsigned long fStartMillis
Definition: Animation.h:230
void end()
Stop the active animation script.
Definition: Animation.h:176
@ kWaiting
Definition: Animation.h:223
AnimationPlayer()
Default Constructor.
Definition: Animation.h:85
signed char(* AnimationStep)(class AnimationPlayer &animation, unsigned step, unsigned long num, unsigned long elapsedMillis)
Definition: Animation.h:10
unsigned long fStepMillis
Definition: Animation.h:229
AnimationPlayer(ServoSequencer &sequencer)
Default Constructor.
Definition: Animation.h:94
virtual void animate() override
Runs through a single step of any active animation script.
Definition: Animation.h:103
void reset()
Reset the animation player and stop any active animation script.
Definition: Animation.h:205
void animateOnce(AnimationStep animation)
Play the specified animation script once.
Definition: Animation.h:135
@ kEnded
Definition: Animation.h:225
void nextStep()
Advance to the next step in the active animation script.
Definition: Animation.h:151