Skip to content

Commit c3df1ff

Browse files
committed
directly allow animation live stream write
1 parent 95771ed commit c3df1ff

23 files changed

+67
-53
lines changed

examples/AdafruitPCA9685/AdafruitPCA9685.ino

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#include <Adafruit_PWMServoDriver.h>
1111
#include <BlenderServoAnimation.h>
1212

13-
// Using the namespace to have short class references (Animation and Servo)
14-
using namespace BlenderServoAnimation;
15-
1613
// PWM driver instance to set PWM output
1714
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
1815

@@ -22,10 +19,16 @@ void move(byte servoID, int position) {
2219
pwm.setPWM(servoID, 0, position);
2320
}
2421

25-
// Animation object to represent the original Blender animation
26-
Animation animation;
22+
// Animation object to control the animation
23+
BlenderServoAnimation::Animation animation;
24+
25+
#define POWER_PIN 19
2726

2827
void setup() {
28+
// Set power pin
29+
pinMode(POWER_PIN, OUTPUT);
30+
digitalWrite(POWER_PIN, HIGH);
31+
2932
// Set the position callback
3033
animation.onPositionChange(move);
3134

examples/MultiplePCA9685/MultiplePCA9685.ino

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010
#include <Adafruit_PWMServoDriver.h>
1111
#include <BlenderServoAnimation.h>
1212

13-
// Using the namespace to have short class references (Animation and Servo)
14-
using namespace BlenderServoAnimation;
15-
1613
// PWM driver instances to set PWM output
1714
Adafruit_PWMServoDriver pwmA(0x40);
1815
Adafruit_PWMServoDriver pwmB(0x41);
1916

20-
// Animation object to represent the original Blender animation
21-
Animation animation;
17+
// Animation object to control the animation
18+
BlenderServoAnimation::Animation animation;
2219

2320
// We use a struct to map a servo to a PCA9685 board and channel
2421
struct servoMapping {

examples/MultipleScenes/MultipleScenes.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void move(byte servoID, int position) {
2727
myServo.writeMicroseconds(position);
2828
}
2929

30-
// Animation object to represent the original Blender animation
30+
// Animation object to control the animation
3131
BlenderServoAnimation::Animation animation;
3232

3333
void setup() {

examples/MultipleScenesSD/MultipleScenesSD.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void changeSceneFile(byte prevSceneIndex, byte nextSceneIndex) {
6060
}
6161
}
6262

63-
// Animation object to represent the original Blender animation
63+
// Animation object to control the animation
6464
BlenderServoAnimation::Animation animation;
6565

6666
void setup() {

examples/MultipleScenesSD/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Setting up a show consisting of 2 animations.
44

55
By default, the 2 animations will be played synchronously in a loop.
66

7-
![Arduino Nano with servo](../../images/arduino-nano-with-servo.png)
7+
![Arduino Nano with servo](../../images/arduino-nano-with-sd-module.png)

examples/SDAnimation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Using the standard Arduino servo library to send servo positions.
44

55
The setup requires nothing but a micro controller and a single servo.
66

7-
![Arduino Nano with servo](../../images/arduino-nano-with-servo.png)
7+
![Arduino Nano with servo](../../images/arduino-nano-with-sd-module.png)

examples/SDAnimation/SDAnimation.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void resetFile(byte prevSceneIndex, byte nextSceneIndex) {
3636
animationFile.seek(0);
3737
}
3838

39-
// Animation object to represent the original Blender animation
39+
// Animation object to control the animation
4040
BlenderServoAnimation::Animation animation;
4141

4242
void setup() {

examples/SerialLiveMode/SerialLiveMode.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <Servo.h>
1515
#endif
1616

17+
#define SERVO_PIN 12
18+
1719
// Servo object to send positions
1820
Servo myServo;
1921

@@ -23,15 +25,15 @@ void move(byte servoID, int position) {
2325
myServo.writeMicroseconds(position);
2426
}
2527

26-
// Animation object to represent the original Blender animation
28+
// Animation object to control the animation
2729
BlenderServoAnimation::Animation animation;
2830

2931
void setup() {
3032
// Initialize serial communication
3133
Serial.begin(115200);
3234

33-
// Attach the servo to pin 12
34-
myServo.attach(12);
35+
// Attach the servo to the defined servo pin
36+
myServo.attach(SERVO_PIN);
3537

3638
// Set the position callback
3739
animation.onPositionChange(move);

examples/StandardServoLib/StandardServoLib.ino

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/*
22
Using the standard Arduino servo library to send servo positions.
3-
4-
Note the namespace BlenderServoAnimation which helps to distinguish
5-
between the standard library servo class (Servo) and the servo
6-
class of this library (BlenderServoAnimation::Servo).
3+
The animation is played in a loop.
74
*/
85

96
#include "simple.h"
@@ -15,6 +12,8 @@
1512
#include <Servo.h>
1613
#endif
1714

15+
#define SERVO_PIN 12
16+
1817
// Servo object to send positions
1918
Servo myServo;
2019

@@ -24,12 +23,12 @@ void move(byte servoID, int position) {
2423
myServo.writeMicroseconds(position);
2524
}
2625

27-
// Animation object to represent the original Blender animation
26+
// Animation object to control the animation
2827
BlenderServoAnimation::Animation animation;
2928

3029
void setup() {
31-
// Attach the servo to pin 12
32-
myServo.attach(12);
30+
// Attach the servo to the defined servo pin
31+
myServo.attach(SERVO_PIN);
3332

3433
// Set the position callback
3534
animation.onPositionChange(move);

examples/SwitchModeButton/SwitchModeButton.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void modeChanged(byte prevMode, byte newMode) {
6262
}
6363
}
6464

65-
// Animation object to represent the original Blender animation
65+
// Animation object to control the animation
6666
BlenderServoAnimation::Animation animation;
6767

6868
// Callback to be triggered on a short button press

0 commit comments

Comments
 (0)