#include "ReelTwo.h"
#include "ServoDispatchDirect.h"
#include "ServoEasing.h"
#include "core/PushButton.h"
#define CLOSE_BUTTON_PIN A0
#define OPEN_BUTTON_PIN A1
const ServoSettings servoSettings[] PROGMEM = {
{ 2, 800, 2200, 0 }, /* 0: my servo */
};
ServoDispatchDirect<SizeOfArray(servoSettings)> servoDispatch(servoSettings);
PushButton closeButton(CLOSE_BUTTON_PIN);
PushButton openButton(OPEN_BUTTON_PIN);
void setup()
{
REELTWO_READY();
SetupEvent::ready();
// Attach function closeServo to the 'close' button
closeButton.attachClick(closeServo);
// Attach function openServo to the 'open' button
openButton.attachClick(openServo);
// Set servo easing for all servos to BounceEaseOut
servoDispatch.setEasingMethod(Easing::BounceEaseOut);
}
void openServo()
{
// Move servo#0 to 100% over 2000ms
servoDispatch.moveTo(0, 2000, 1.0);
}
void closeServo()
{
// Move servo#0 to 0% over 2000ms
servoDispatch.moveTo(0, 2000, 0.0);
}
void loop()
{
AnimatedEvent::process();
}