Skip to content

Commit 5e4b4d3

Browse files
committed
update examples and readme
1 parent 51b6509 commit 5e4b4d3

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,26 @@ void loop() {
153153

154154
At first, an animation will be in the default mode. In this mode, the animation is simply not doing anything and waits until the mode has changed.
155155

156-
| Mode | Constant | Description |
157-
|------|----------|-------------|
158-
| default | MODE_DEFAULT | Not playing / waiting |
159-
| play | MODE_PLAY | Playing back the animation |
160-
| pause | MODE_PAUSE | Pausing the animation at the current frame |
161-
| stop | MODE_STOP | Slowly moving the servos to their neutral position |
162-
| live | MODE_LIVE | Reading serial commands to move the servos in real-time |
156+
| Constant | Method | Description |
157+
|----------|--------|-------------|
158+
| MODE_DEFAULT | | Not playing / waiting |
159+
| MODE_PLAY | play() | Start or resume playing the animation once |
160+
| MODE_PAUSE | pause() | Pausing the animation at the current frame |
161+
| MODE_STOP | stop() | Slowly moving the servos to their neutral position |
162+
| MODE_LOOP | loop() | Start or resume playing the animation in a loop |
163+
| MODE_LIVE | live(stream) | Reading serial commands to move the servos in real-time |
163164

164-
The modes can be changed or triggered via the following methods:
165+
The modes can be changed or triggered by calling the above methods on the animation object:
165166

166167
```ino
167168
myBlenderAnimation.play();
168169
myBlenderAnimation.pause();
169-
myBlenderAnimation.stop(stepDelay);
170+
myBlenderAnimation.loop();
171+
myBlenderAnimation.stop();
170172
myBlenderAnimation.live(stream);
171173
```
172174

173-
> Note: the default mode is only handled internally.
175+
> Note: the default mode can not be triggered as it is only handled internally.
174176
175177
When calling the `stop` method, it is possible to pass a delay in milliseconds. This delay will be used when the servos are moved to their neutral position during the stop mode. To get to the neutral position, the current position will either be increased or decreased by 1. The delay therefore controls how fast or smooth this movement will take place. The default value for this parameter is `20`.
176178

examples/AdafruitPCA9685/AdafruitPCA9685.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ void setup() {
4040
animation.addServo(neckLeftServo);
4141
animation.addServo(neckRightServo);
4242

43-
// Trigger the animation play mode
44-
animation.play();
43+
// Trigger the animation loop mode
44+
animation.loop();
4545

4646
// Initialize servo driver
4747
pwm.begin();

examples/MultiplePCA9685/MultiplePCA9685.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ void setup() {
7373
animation.addServo(servoMaps[i].servo);
7474
}
7575

76-
// Trigger the animation play mode
77-
animation.play();
76+
// Trigger the animation loop mode
77+
animation.loop();
7878

7979
// Initialize servo drivers
8080
pwmA.begin();

examples/StandardServoLib/StandardServoLib.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void setup() {
3838
// Add the Blender servo object to the animation
3939
animation.addServo(myBlenderServo);
4040

41-
// Trigger the animation play mode
42-
animation.play();
41+
// Trigger the animation loop mode
42+
animation.loop();
4343
}
4444

4545
void loop() {

examples/SwitchModeButton/SwitchModeButton.ino

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
changes. For example, this can be used to control the animation audio. See the
1111
comments below to understand what happens on a short or long button press
1212
based on the current mode.
13+
14+
Starting the animation will only play it once, so another button press is
15+
required to play it again. Alternatively, you can also use MODE_LOOP instead
16+
of MODE_PLAY and loop() instead of play(). This will keep the animation
17+
running until the button is short or long pressed again, thus pausing or
18+
stopping the animation.
1319
*/
1420

1521
#include "simple.h"

0 commit comments

Comments
 (0)