Skip to content

Commit cf402fd

Browse files
committed
Clarify encoder acceleration usage
Signed-off-by: Christopher Arndt <[email protected]>
1 parent 69283a5 commit cf402fd

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

encoder/README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,24 @@ If you have a large value range (you can set the range with the `min_val` and
6262
can be very cumbersome. You can enable acceleration by passing a positive
6363
integer to the `accel` keyword argument. The proper value depends on value
6464
range and the type of the encoder, but usually low one-digit numbers like 3-5
65-
work well. With acceleration enabled the increment/decrement per click increases
66-
the faster your turn the encoder. You can still make fine adjustment by turning
67-
the encoder slowly.
65+
work well. With acceleration enabled the increment/decrement per click
66+
increases the faster your turn the encoder. You can still make fine adjustment
67+
by turning the encoder slowly.
68+
69+
Currently, if you use the acceleration feature, you need to take care of
70+
decreasing the the current acceleration, which increases everytime a valid
71+
pulse is read from the encoder. Normally you would do this at the end of your
72+
main loop, i.e. once per poll interval:
73+
74+
oldval = 0
75+
while True:
76+
val = enc.value
77+
if oldval != val:
78+
print(val)
79+
oldval = val
80+
81+
enc.cur_accel = max(0, enc.cur_accel - enc.accel)
82+
sleep_ms(50)
6883

6984

7085
TODO

0 commit comments

Comments
 (0)