chumicro-knobs 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/PKG-INFO +18 -1
  2. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/README.md +17 -0
  3. chumicro_knobs-0.1.2/VERSION +1 -0
  4. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/docs/guide.md +32 -0
  5. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/docs/index.md +17 -0
  6. chumicro_knobs-0.1.0/VERSION +0 -1
  7. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/.gitignore +0 -0
  8. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/LICENSE +0 -0
  9. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/docs/api.md +0 -0
  10. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/docs/testing.md +0 -0
  11. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/examples/circuitpython_encoder_volume.py +0 -0
  12. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/examples/micropython_encoder_volume.py +0 -0
  13. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/pyproject.toml +0 -0
  14. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/__init__.py +0 -0
  15. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/_adapters/__init__.py +0 -0
  16. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/_adapters/base.py +0 -0
  17. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/_adapters/cp.py +0 -0
  18. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/_adapters/mp.py +0 -0
  19. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/analog.py +0 -0
  20. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/encoder.py +0 -0
  21. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/src/chumicro_knobs/testing.py +0 -0
  22. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/tests/_mp_helpers.py +0 -0
  23. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/tests/conftest.py +0 -0
  24. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/tests/test_analog.py +0 -0
  25. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/tests/test_encoder.py +0 -0
  26. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/tests/test_mp_adapter.py +0 -0
  27. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/tests/test_source_selection_host.py +0 -0
  28. {chumicro_knobs-0.1.0 → chumicro_knobs-0.1.2}/tests/test_sources.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: chumicro-knobs
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Rotary encoders and analog knobs, read as a position that holds still
5
5
  Project-URL: Homepage, https://github.com/ChuMicro/ChuMicro
6
6
  Project-URL: Documentation, https://chumicro.com/ChuMicro/knobs/stable/
@@ -74,6 +74,23 @@ while True:
74
74
 
75
75
  The loop never pauses, so the rest of your program keeps running between turns. `just_moved` is true for exactly one pass, which means you can read it as many times as you like without it firing twice.
76
76
 
77
+ In a program with more going on, hand the loop to [`chumicro-runner`](https://github.com/ChuMicro/ChuMicro/tree/main/libraries/runner) and let the callback do the reading:
78
+
79
+ ```python
80
+ from chumicro_runner import Runner
81
+
82
+ volume.on_change = lambda detents: print("volume", volume.position)
83
+
84
+ runner = Runner()
85
+ runner.add(volume)
86
+
87
+ while True:
88
+ now = runner.tick()
89
+ runner.wait(now)
90
+ ```
91
+
92
+ Every service in your program shares those same two lines.
93
+
77
94
  ## A fast spin arrives whole
78
95
 
79
96
  An encoder reports movement as pulses on two signal pins, and one brisk flick of the wrist sends dozens of them. If your loop stalls on a socket read or a flash write, a plain pin read looks at the wrong moments and most of the turn is gone. The counting here happens outside your loop, so a tick that arrives late still reads the whole spin.
@@ -47,6 +47,23 @@ while True:
47
47
 
48
48
  The loop never pauses, so the rest of your program keeps running between turns. `just_moved` is true for exactly one pass, which means you can read it as many times as you like without it firing twice.
49
49
 
50
+ In a program with more going on, hand the loop to [`chumicro-runner`](https://github.com/ChuMicro/ChuMicro/tree/main/libraries/runner) and let the callback do the reading:
51
+
52
+ ```python
53
+ from chumicro_runner import Runner
54
+
55
+ volume.on_change = lambda detents: print("volume", volume.position)
56
+
57
+ runner = Runner()
58
+ runner.add(volume)
59
+
60
+ while True:
61
+ now = runner.tick()
62
+ runner.wait(now)
63
+ ```
64
+
65
+ Every service in your program shares those same two lines.
66
+
50
67
  ## A fast spin arrives whole
51
68
 
52
69
  An encoder reports movement as pulses on two signal pins, and one brisk flick of the wrist sends dozens of them. If your loop stalls on a socket read or a flash write, a plain pin read looks at the wrong moments and most of the turn is gone. The counting here happens outside your loop, so a tick that arrives late still reads the whole spin.
@@ -0,0 +1 @@
1
+ 0.1.2
@@ -37,6 +37,23 @@ from machine import Pin
37
37
  volume = Encoder(Pin(16), Pin(17))
38
38
  ```
39
39
 
40
+ In a program with more going on, hand the loop to `chumicro-runner` and let the callback do the reading:
41
+
42
+ ```python
43
+ from chumicro_runner import Runner
44
+
45
+ volume.on_change = lambda detents: print("volume", volume.position)
46
+
47
+ runner = Runner()
48
+ runner.add(volume)
49
+
50
+ while True:
51
+ now = runner.tick()
52
+ runner.wait(now)
53
+ ```
54
+
55
+ The [runner section](#runner-pattern) below covers pacing an analog knob's conversions with `period_ms`.
56
+
40
57
  ## Reading the encoder
41
58
 
42
59
  Every reading is a plain attribute, refreshed by `check()`:
@@ -154,6 +171,21 @@ while True:
154
171
  print("brightness", brightness.value) # 0 through 9
155
172
  ```
156
173
 
174
+ Or on the runner, paced to fifty conversions a second:
175
+
176
+ ```python
177
+ from chumicro_runner import Runner
178
+
179
+ brightness.on_change = lambda step: print("brightness", step)
180
+
181
+ runner = Runner()
182
+ runner.add(brightness, period_ms=20)
183
+
184
+ while True:
185
+ now = runner.tick()
186
+ runner.wait(now)
187
+ ```
188
+
157
189
  `steps` defaults to 100, held in `DEFAULT_STEPS`, which puts the middle of the sweep at 50 and the top at 99. `delta` is the change for this tick, negative when the knob comes back down, and `raw` is the settled reading on the 0 to 65535 scale that `value` was worked out from:
158
190
 
159
191
  ```python
@@ -23,6 +23,23 @@ while True:
23
23
 
24
24
  `just_moved` is true for exactly one pass of the loop, so you can read it as often as you like without it firing twice. `bounds` walks the number between 0 and 20 and stops it at both ends.
25
25
 
26
+ In a program with more going on, hand the loop to `chumicro-runner` and let the callback do the reading:
27
+
28
+ ```python
29
+ from chumicro_runner import Runner
30
+
31
+ volume.on_change = lambda detents: print("volume", volume.position)
32
+
33
+ runner = Runner()
34
+ runner.add(volume)
35
+
36
+ while True:
37
+ now = runner.tick()
38
+ runner.wait(now)
39
+ ```
40
+
41
+ Every service in your program shares those same two lines.
42
+
26
43
  ## Documentation
27
44
 
28
45
  - [User Guide](guide.md): wiring an encoder, bounds and wrap, reading a potentiometer, the deadband that holds it still, callbacks, and wiring into a runner
@@ -1 +0,0 @@
1
- 0.1.0
File without changes