RSeries astromech firmware
Servo Sequencer

Servo Sequencer works in conjunction with ServoDispatcher. The sequence is held on a matrix, each line representing a step. The first entry is the length of the step in centiseconds (1/100th of a second). The bitmap representing on/off for each servo in order in the target servo group.

#include "ReelTwo.h"
#include "ServoSequencer.h"
#define SMALL_PANEL 0x0001
#define MEDIUM_PANEL 0x0002
#define BIG_PANEL 0x0004
#define PIE_PANEL 0x0008
#define TOP_PIE_PANEL 0x0010
#define MINI_PANEL 0x0020
#define HOLO_HSERVO 0x1000
#define HOLO_VSERVO 0x2000
#define DOME_PANELS_MASK (SMALL_PANEL|MEDIUM_PANEL|BIG_PANEL)
#define PIE_PANELS_MASK (PIE_PANEL)
#define ALL_DOME_PANELS_MASK (MINI_PANEL|DOME_PANELS_MASK|PIE_PANELS_MASK|TOP_PIE_PANEL)
#define HOLO_SERVOS_MASK (HOLO_HSERVO|HOLO_VSERVO)
const ServoSettings servoSettings[] PROGMEM = {
{ 1, 1000, 1650, SMALL_PANEL }, /* 0: door 4 */
{ 2, 1500, 2300, SMALL_PANEL }, /* 1: door 3 */
{ 4, 900, 1650, SMALL_PANEL }, /* 2: door 2 */
{ 6, 1200, 1900, SMALL_PANEL }, /* 3: door 1 */
{ 17, 1200, 2000, MEDIUM_PANEL }, /* 4: door 5 */
{ 9, 1200, 2000, BIG_PANEL }, /* 5: door 9 */
{ 8, 1275, 1975, MINI_PANEL }, /* 6: mini door 2 */
{ 7, 1550, 1900, MINI_PANEL }, /* 7: mini front psi door */
{ 3, 1250, 1900, PIE_PANEL }, /* 8: pie panel 1 */
{ 10, 1075, 1700, PIE_PANEL }, /* 9: pie panel 2 */
{ 11, 1200, 2000, PIE_PANEL }, /* 10: pie panel 3 */
{ 12, 750, 1450, PIE_PANEL }, /* 11: pie panel 4 */
{ 5, 1250, 1850, TOP_PIE_PANEL }, /* 12: dome top panel */
{ 13, 800, 1600, HOLO_HSERVO }, /* 13: horizontal front holo */
{ 14, 800, 1800, HOLO_VSERVO }, /* 14: vertical front holo */
{ 15, 800, 1600, HOLO_HSERVO }, /* 15: horizontal top holo */
{ 16, 800, 1325, HOLO_VSERVO }, /* 16: vertical top holo */
{ 25, 900, 1000, HOLO_VSERVO }, /* 17: vertical rear holo */
{ 26, 1300, 1600, HOLO_HSERVO }, /* 18: horizontal rear holo */
};
ServoDispatchPCA9685<SizeOfArray(servoSettings)> servoDispatch(servoSettings);
ServoSequencer servoSequencer(servoDispatch);
static const ServoSequence sMySeqPanelAllOpen PROGMEM =
{
{ 20, B00000000, B00000000, B00000000, B00000000 },
{ 300, B11111111, B11000000, B00000000, B00000000 },
{ 150, B00000000, B00000000, B00000000, B00000000 },
};
void setup()
{
servoSequencer.play(sMySeqPanelAllOpen, SizeOfArray(sMySeqPanelAllOpen), (DOME_PANELS_MASK | PIE_PANELS_MASK));
}
void loop()
{
}
+ Collaboration diagram for Servo Sequencer:
REELTWO_READY
#define REELTWO_READY()
Definition: ReelTwo.h:228
ReelTwo.h
ServoSequencer
Plays a sequence of servo commands using a servo group mask.
Definition: ServoSequencer.h:389
AnimatedEvent::process
static void process()
Calls animate() for each created AnimatedEvent subclass.
Definition: AnimatedEvent.h:38
SetupEvent::ready
static void ready()
Calls setup() for each created AnimatedEvent subclass.
Definition: SetupEvent.h:35
ServoDispatchPCA9685.h
ServoDispatchPCA9685
Implements ServoDispatch over i2c to PCA9685.
Definition: ServoDispatchPCA9685.h:83
ServoSettings
Settings for individual servos.
Definition: ServoDispatch.h:55
ServoSequence
struct ServoStep ServoSequence[]
Definition: ServoSequencer.h:26
ServoSequencer.h
SizeOfArray
#define SizeOfArray(arr)
Definition: ReelTwo.h:213