RSeries astromech firmware
Animation.h File Reference
#include "ReelTwo.h"
#include "core/SetupEvent.h"
#include "core/AnimatedEvent.h"
#include "core/CommandEvent.h"
#include "ServoSequencer.h"
+ Include dependency graph for Animation.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  AnimationPlayer
 Player of animation scripts. More...
 

Macros

#define ANIMATION_FUNC_DECL(name)
 
#define ANIMATION(name)   ANIMATION_FUNC_DECL(name) { enum { _firstStep = __COUNTER__ };
 
#define DO_START()   UNUSED_ARG(num) UNUSED_ARG(elapsedMillis) switch (step+1) {
 
#define DO_CASE()   case __COUNTER__-_firstStep:
 
#define DO_LABEL(label)   enum { label = __COUNTER__-_firstStep }; case label: { return true; }
 
#define DO_ONCE_LABEL(label, p)   enum { label = __COUNTER__-_firstStep }; case label: { p; return true; }
 
#define DO_ONCE(p)   DO_CASE() { p; return true; }
 
#define DO_ONCE_AND_WAIT(p, ms)   DO_CASE() { if (!animation.fRepeatStep) { p; } return (ms < elapsedMillis); }
 
#define DO_FOREVER(p)   DO_CASE() { p; return false; }
 
#define DO_DURATION(ms, p)   DO_CASE() { if (animation.getCurrentTimeMillis() < ms) { p; return false; } return true; }
 
#define DO_DURATION_STEP(ms, p)   DO_CASE() { if (elapsedMillis < ms) { p; return false; } return true; }
 
#define DO_WAIT_MILLIS(ms)   DO_CASE() { return (ms < elapsedMillis); }
 
#define DO_WAIT_SEC(sec)   DO_CASE() { return (sec*1000L < long(elapsedMillis)); }
 
#define DO_GOTO(label)   DO_CASE() { animation.gotoStep(label); return -1; }
 
#define DO_WHILE(cond, label)   DO_CASE() { if (cond) { animation.gotoStep(label); return -1; } return true; }
 
#define DO_SEQUENCE(seq, mask)   DO_CASE() { SEQUENCE_PLAY_ONCE(*animation.fServoSequencer, seq, mask); return true; }
 
#define DO_SEQUENCE_SPEED(seq, mask, speed)   DO_CASE() { SEQUENCE_PLAY_ONCE_SPEED(*animation.fServoSequencer, seq, mask, speed); return true; }
 
#define DO_SEQUENCE_VARSPEED(seq, mask, minspeed, maxspeed)   DO_CASE() { SEQUENCE_PLAY_ONCE_VARSPEED(*animation.fServoSequencer, seq, mask, minspeed, maxspeed); return true; }
 
#define DO_SEQUENCE_RANDOM_STEP(seq, mask)   DO_CASE() { SEQUENCE_PLAY_RANDOM_STEP(*animation.fServoSequencer, seq, mask); return true; }
 
#define DO_WAIT_SEQUENCE()   DO_CASE() { return animation.fServoSequencer->isFinished(); }
 
#define DO_WHILE_SEQUENCE(label)   DO_CASE() { if (!animation.fServoSequencer->isFinished()) { animation.gotoStep(label); return -1; } return true; }
 
#define DO_COMMAND(cmd)   DO_CASE() { CommandEvent::process(cmd); return true; }
 
#define DO_COMMAND_AND_WAIT(cmd, ms)   DO_CASE() { if (!animation.fRepeatStep) { CommandEvent::process(cmd); } return (ms < elapsedMillis); }
 
#define DO_MARCDUINO(cmd)   DO_CASE() { Marcduino::send(cmd); return true; }
 
#define DO_MARCDUINO_AND_WAIT(cmd, ms)   DO_CASE() { if (!animation.fRepeatStep) { Marcduino::send(cmd); } return (ms < elapsedMillis); }
 
#define DO_RESET(p)   case 0: { p; return true; }
 
#define DO_END()   default: animation.end(); return false; } }
 
#define ANIMATION_PLAY_ONCE(player, name)   player.animateOnce(Animation_##name)
 

Typedefs

typedef signed char(* AnimationStep) (class AnimationPlayer &animation, unsigned step, unsigned long num, unsigned long elapsedMillis)
 

Macro Definition Documentation

◆ ANIMATION

#define ANIMATION (   name)    ANIMATION_FUNC_DECL(name) { enum { _firstStep = __COUNTER__ };

◆ ANIMATION_FUNC_DECL

#define ANIMATION_FUNC_DECL (   name)
Value:
static signed char Animation_##name(class AnimationPlayer& animation,\
unsigned step, unsigned long num, unsigned long elapsedMillis)

◆ ANIMATION_PLAY_ONCE

#define ANIMATION_PLAY_ONCE (   player,
  name 
)    player.animateOnce(Animation_##name)

◆ DO_CASE

#define DO_CASE ( )    case __COUNTER__-_firstStep:

◆ DO_COMMAND

#define DO_COMMAND (   cmd)    DO_CASE() { CommandEvent::process(cmd); return true; }

◆ DO_COMMAND_AND_WAIT

#define DO_COMMAND_AND_WAIT (   cmd,
  ms 
)    DO_CASE() { if (!animation.fRepeatStep) { CommandEvent::process(cmd); } return (ms < elapsedMillis); }

◆ DO_DURATION

#define DO_DURATION (   ms,
 
)    DO_CASE() { if (animation.getCurrentTimeMillis() < ms) { p; return false; } return true; }

◆ DO_DURATION_STEP

#define DO_DURATION_STEP (   ms,
 
)    DO_CASE() { if (elapsedMillis < ms) { p; return false; } return true; }

◆ DO_END

#define DO_END ( )    default: animation.end(); return false; } }

◆ DO_FOREVER

#define DO_FOREVER (   p)    DO_CASE() { p; return false; }

◆ DO_GOTO

#define DO_GOTO (   label)    DO_CASE() { animation.gotoStep(label); return -1; }

◆ DO_LABEL

#define DO_LABEL (   label)    enum { label = __COUNTER__-_firstStep }; case label: { return true; }

◆ DO_MARCDUINO

#define DO_MARCDUINO (   cmd)    DO_CASE() { Marcduino::send(cmd); return true; }

◆ DO_MARCDUINO_AND_WAIT

#define DO_MARCDUINO_AND_WAIT (   cmd,
  ms 
)    DO_CASE() { if (!animation.fRepeatStep) { Marcduino::send(cmd); } return (ms < elapsedMillis); }

◆ DO_ONCE

#define DO_ONCE (   p)    DO_CASE() { p; return true; }

◆ DO_ONCE_AND_WAIT

#define DO_ONCE_AND_WAIT (   p,
  ms 
)    DO_CASE() { if (!animation.fRepeatStep) { p; } return (ms < elapsedMillis); }

◆ DO_ONCE_LABEL

#define DO_ONCE_LABEL (   label,
 
)    enum { label = __COUNTER__-_firstStep }; case label: { p; return true; }

◆ DO_RESET

#define DO_RESET (   p)    case 0: { p; return true; }

◆ DO_SEQUENCE

#define DO_SEQUENCE (   seq,
  mask 
)    DO_CASE() { SEQUENCE_PLAY_ONCE(*animation.fServoSequencer, seq, mask); return true; }

◆ DO_SEQUENCE_RANDOM_STEP

#define DO_SEQUENCE_RANDOM_STEP (   seq,
  mask 
)    DO_CASE() { SEQUENCE_PLAY_RANDOM_STEP(*animation.fServoSequencer, seq, mask); return true; }

◆ DO_SEQUENCE_SPEED

#define DO_SEQUENCE_SPEED (   seq,
  mask,
  speed 
)    DO_CASE() { SEQUENCE_PLAY_ONCE_SPEED(*animation.fServoSequencer, seq, mask, speed); return true; }

◆ DO_SEQUENCE_VARSPEED

#define DO_SEQUENCE_VARSPEED (   seq,
  mask,
  minspeed,
  maxspeed 
)    DO_CASE() { SEQUENCE_PLAY_ONCE_VARSPEED(*animation.fServoSequencer, seq, mask, minspeed, maxspeed); return true; }

◆ DO_START

#define DO_START ( )    UNUSED_ARG(num) UNUSED_ARG(elapsedMillis) switch (step+1) {

◆ DO_WAIT_MILLIS

#define DO_WAIT_MILLIS (   ms)    DO_CASE() { return (ms < elapsedMillis); }

◆ DO_WAIT_SEC

#define DO_WAIT_SEC (   sec)    DO_CASE() { return (sec*1000L < long(elapsedMillis)); }

◆ DO_WAIT_SEQUENCE

#define DO_WAIT_SEQUENCE ( )    DO_CASE() { return animation.fServoSequencer->isFinished(); }

◆ DO_WHILE

#define DO_WHILE (   cond,
  label 
)    DO_CASE() { if (cond) { animation.gotoStep(label); return -1; } return true; }

◆ DO_WHILE_SEQUENCE

#define DO_WHILE_SEQUENCE (   label)    DO_CASE() { if (!animation.fServoSequencer->isFinished()) { animation.gotoStep(label); return -1; } return true; }

Typedef Documentation

◆ AnimationStep

typedef signed char(* AnimationStep) (class AnimationPlayer &animation, unsigned step, unsigned long num, unsigned long elapsedMillis)
AnimationPlayer
Player of animation scripts.
Definition: Animation.h:79