#include "ReelTwo.h"
#include "ServoDispatchDirect.h"
#include "ServoSequencer.h"
#include "ServoEasing.h"
#include "core/Animation.h"
#include "core/PushButton.h"
#define ANTS_BUTTON_PIN A0
#define FLUTTER_BUTTON_PIN A1
#define MY_SERVOS 0b000001
#define MY_OTHER_SERVOS 0b000010
#define ALL_MY_SERVOS (MY_SERVOS|MY_OTHER_SERVOS)
const ServoSettings servoSettings[] PROGMEM = {
{ 2, 800, 2200, MY_SERVOS }, /* 0: my servo */
{ 3, 800, 2200, MY_SERVOS }, /* 1: my servo */
{ 4, 800, 2200, MY_SERVOS }, /* 2: my servo */
{ 5, 800, 2200, MY_SERVOS }, /* 3: my servo */
{ 6, 800, 2200, MY_SERVOS }, /* 4: my servo */
{ 7, 800, 2200, MY_OTHER_SERVOS }, /* 5: my servo */
{ 8, 800, 2200, MY_OTHER_SERVOS }, /* 6: my servo */
{ 9, 800, 2200, MY_OTHER_SERVOS }, /* 7: my servo */
};
ServoDispatchDirect<SizeOfArray(servoSettings)> servoDispatch(servoSettings);
ServoSequencer servoSequencer(servoDispatch);
AnimationPlayer player(servoSequencer);
PushButton antsButton(ANTS_BUTTON_PIN);
PushButton flutterButton(FLUTTER_BUTTON_PIN);
void setup()
{
REELTWO_READY();
SetupEvent::ready();
// Attach function marchingAnts to the 'ants' button
antsButton.attachClick(marchingAnts);
// Attach function flutter to the 'flutter' button
flutterButton.attachClick(wave);
}
void marchingAnts()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelMarchingAnts, ALL_MY_SERVOS);
}
void flutter()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelAllFlutter, ALL_MY_SERVOS);
}
void drunk()
{
SEQUENCE_PLAY_ONCE_VARSPEED_EASING(servoSequencer,
SeqPanelAllOpenClose,
ALL_MY_SERVOS,
1000, // minumum delay 1000ms
4000, // maximum delay 4000ms
Easing::BounceEaseIn, // easing during 'on' movement 0% -> 100%
Easing::BounceEaseOut); // easing during 'off' movement 100% -> 0%
}
void open()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelAllOpen, ALL_MY_SERVOS);
}
void close()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelAllClose, ALL_MY_SERVOS);
}
void openClose()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelAllOpenClose, ALL_MY_SERVOS);
}
void openCloseLong()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelAllOpenCloseLong, ALL_MY_SERVOS);
}
void openCloseRepeat()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelAllFOpenCloseRepeat, ALL_MY_SERVOS);
}
void wave()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelWave, ALL_MY_SERVOS);
}
void waveFast()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelWaveFast, ALL_MY_SERVOS);
}
void openCloseWave()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelOpenCloseWave, ALL_MY_SERVOS);
}
void alternate()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelAlternate, ALL_MY_SERVOS);
}
void dance()
{
SEQUENCE_PLAY_ONCE(servoSequencer, SeqPanelDance, ALL_MY_SERVOS);
}
void loop()
{
AnimatedEvent::process();
}