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
Allow for optional delay before the start of a move. Especially useful for sequences of moves where pauses with no movement are desired between moves. Corresponding and general fixes to examples.
Copy file name to clipboardexpand all lines: README.md
+17-9
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@
3
3
## Description
4
4
This Python library is descended from the VarspeedServo library (https://github.com/netlabtoolkit/VarSpeedServo), originally written for the Arduino in C++ (which was itself built on an early Arduino servo library). Unlike the old Arduino library, VarSpeedPython is not tied to servos, and can be used more generally for timed moves from one value to another. It is also **not** bound to any processor architecture with hardware interrupts etc.
5
5
6
-
The library is designed for projects that need to control values over time. For example: setting the new angle of a servo in 1.5 seconds; setting the brightness of an LED by fading up; or moving a graphic on a screen. You can set the amount of time for a change in value, and apply easing to each move. It also provides a function for running sequences of moves (that can be looped or repeated if desired), where each move in the sequence has a new position and speed. More than one move or sequence can be run at the same time.
6
+
The library is designed for projects that need to control values over time. For example: setting the new angle of a servo in 3.0 seconds; setting the brightness of an LED by fading up in 2.5 seconds; or moving a graphic on a screen. You can set the amount of time for a change in value, and apply easing to each move to make it seem more natural.
7
+
8
+
It also provides a function for running **sequences** of moves (that can be looped or repeated if desired), where each move in the sequence has a new position and speed. More than one move or sequence can be run at the same time.
7
9
8
10
VarSpeedPython objects are designed to be called repeatedly from within an event loop and do not block execution.
9
11
@@ -25,11 +27,11 @@ VarSpeedPython objects are designed to be called repeatedly from within an event
25
27
26
28
## Circuit Python Setup
27
29
28
-
To set up on CircuitPython:
30
+
To set up on a CircuitPython hardware device:
29
31
30
-
* Put varspeed.py in the lib directory on CIRCUITPY
31
-
* Put easing_functions.py in the lib directory on CIRCUITPY
32
-
* Copy the python from any of the examples into code.py at the top of CIRCUITPY
32
+
* Put varspeed/varspeed.py in the **lib** directory on CIRCUITPY
33
+
* Put varspeed/easing_functions.py in the **lib** directory on CIRCUITPY
34
+
* Copy the python code from any of the examples/ into code.py or main.py at the top of CIRCUITPY
33
35
34
36
## Code Examples - non-CircuitPython
35
37
@@ -46,10 +48,10 @@ To set up on CircuitPython:
46
48
47
49
## Easing Types
48
50
49
-
For any move (even within a sequence), you can set an easing function using the following classic Robert Penner easing types. For an animated and graphed visualization of each easing type, see https://easings.net. For an explanation of the use of easing, see this article: [Animation Principles in UI Design: Understanding Easing](https://medium.com/motion-in-interaction/animation-principles-in-ui-design-understanding-easing-bea05243fe3)
51
+
For any move (even within a sequence), you can set an easing function using the following classic Robert Penner easing types. For an animated and graphed visualization of each easing type, see [https://easings.net](https://easings.net). For an explanation of the use of easing, see this article: [Animation Principles in UI Design: Understanding Easing](https://medium.com/motion-in-interaction/animation-principles-in-ui-design-understanding-easing-bea05243fe3)
50
52
51
53
> [!WARNING]
52
-
> The names on https://easings.net do not reflect the names used in the `easing_functions.py` file. The names used in this project start with the type of easing used by the function (e.g Linear, Quad, Circular) followed by the word _Ease_ and finally whether it's "In", "Out" or "InOut". For example: the function listed on the website as _easeInOutCubic_ is called _CubicEaseInOut_ in this library. The reason behind this naming scheme is to be consistent with python classes naming conventions. The list with all easing functions with the correct names is listed here below.
54
+
> The names on https://easings.net do not reflect the names used in the `easing_functions.py` file. The names used in this project start with the type of easing used by the function (e.g Linear, Quad, Circular) followed by the word _Ease_ and finally whether it's "In", "Out" or "InOut". For example: the function listed on the website as _easeInOutCubic_ is called _CubicEaseInOut_ in this library. The reason behind this naming scheme is to be consistent with python classes naming conventions. The list with all this library's easing functions with the correct names are listed below. Note also that the new gamma functions are not listed on the easings.net page
53
55
54
56
* LinearInOut (essentially no easing)
55
57
* QuadEaseInOut, QuadEaseIn, QuadEaseOut
@@ -62,6 +64,11 @@ For any move (even within a sequence), you can set an easing function using the
62
64
* ElasticEaseIn, ElasticEaseOut, ElasticEaseInOut
63
65
* BackEaseIn, BackEaseOut, BackEaseInOut
64
66
* BounceEaseIn, BounceEaseOut, BounceEaseInOut
67
+
* GammaEaseIn, GammaEaseOut, GammaEaseInOut
68
+
69
+
70
+
***NEW: GAMMA EASING** - provides gamma correction of 2.8 for dimming LEDs and other lighting to match human vision characteristics. **EXPLANATION** of gamma correction: https://www.advateklighting.com/blog/guides/dithering-and-gamma-correction
71
+
65
72
66
73
## CLASS: Vspeed
67
74
```python
@@ -92,7 +99,7 @@ Creates and initializes a Vspeed object.
@@ -104,6 +111,7 @@ Generates a series of values that transition from the current position to a new_
104
111
***time_secs** (int) : time for the transition to the new_position
105
112
***steps** (int) : number of steps to change from the start position to the new_position
106
113
***easing** (string) : the easing function to use for the transition
114
+
***delay_start** (float) : the number of seconds to delay the start of the move - this helps when putting several moves together in a sequence so there can be pauses between moves
107
115
108
116
### Returns
109
117
***position** (int or float) : each new position, marked by changed being True
0 commit comments