You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-6Lines changed: 5 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,8 @@ Servo(id, callback, threshold);
71
71
| callback | void (byte, int) | Function to trigger when a servo is moved |
72
72
| threshold | byte | Max allowed position diff (default=0 / no threshold handling) |
73
73
74
+
> Note: the threshold is also used to define the speed for moving a servo to its neutral position when stopping an animation.
75
+
74
76
### Callback Function
75
77
76
78
The callback function is used to specify what should happen when a servo needs to be moved to a new position. It will be automatically triggered by the animation instance and receives 2 arguments - the servo ID as `byte` and the new position as `int`:
> Note: the default mode can not be triggered as it is only handled internally.
185
187
186
-
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`.
myBlenderAnimation.stop(30); // Servos will reset slower
191
-
```
188
+
When calling the `stop` method, the threshold values of the animation's servos are considered to control how fast or smooth they are moving towards their neutral position. Keep in mind that the servos will not have a threshold value by default which results in the stop mode to immediately trigger the neutral position of the servos. A slower and safer movement can be achieved by setting the threshold values as low as possible with the actual animation still able to run properly.
192
189
193
190
To use the `live` method, we have to pass a stream instance which will be used for reading serial commands. For example, we can pass `Serial` if we want to use the standard USB connection of an Arduino compatible board:
194
191
@@ -199,6 +196,8 @@ void setup() {
199
196
}
200
197
```
201
198
199
+
This library also comes with a `LiveStream` class which allows for a more generic way to listen to live commands. For example, it can be used as part of the web socket based live mode for which you can find a dedicated example [here](examples/WebSocketLiveMode).
200
+
202
201
To get the current animation mode, we can simply call the `getMode` method. This will return a `byte` representing one of the mode constants mentioned in the table above. We can then compare the return value to those constants to act according to the current mode:
0 commit comments