/*
Using the standard Arduino servo library to send servo positions.
Note the namespace BlenderServoAnimation which helps to distinguish
between the standard library servo class (Servo) and the servo
class of this library (BlenderServoAnimation::Servo).
*/
#include "simple.h"
#include <BlenderServoAnimation.h>
#include <Servo.h>
// Frames per second - see original Blender animation / simple.h
#define FPS 30
// Total animation frames - see original Blender animation / simple.h
#define FRAMES 100
// Servo object to send positions
Servo myServo;
Servo myServo1;
// external to library Callback function which is called whenever a servo needs to be moved
void move(byte servoID, int angle) {
myServo.write(angle);
}
// Library Animation object to represent the original Blender animation
BlenderServoAnimation::Animation animation(FPS, FRAMES);
// Library Servo object to manage the positions (id, positions array in file,callback funtion)
BlenderServoAnimation::Servo myBlenderServo(0, Bone, move);
BlenderServoAnimation::Servo myBlenderServo1(1, Bone1, move);
void setup() {
// Arduino Attach the servo to pin 9
myServo.attach(9);
myServo1.attach(10);
// Library Add the Blender servo object to the animation
animation.addServo(myBlenderServo);
animation.addServo(myBlenderServo1);
// Library Trigger the animation loop mode
animation.loop();
}
void loop() {
// Library Update the animation state on each loop
animation.run();
}