encoder_rp2.py: Add code comment re pullups.

master
Peter Hinch 2024-09-16 17:59:33 +01:00
rodzic d2e4f2408c
commit 7296d5c22b
1 zmienionych plików z 13 dodań i 9 usunięć

Wyświetl plik

@ -21,7 +21,8 @@ import rp2
# work: https://github.com/micropython/micropython/issues/8086
# so using arrays.
def make_isr(pos):
old_x = array('i', (0,))
old_x = array("i", (0,))
@micropython.viper
def isr(sm):
i = ptr32(pos)
@ -33,11 +34,14 @@ def make_isr(pos):
s: int = 1 if (x ^ y) else -1
i[0] = i[0] + (s if (x ^ p[0]) else (0 - s))
p[0] = x
return isr
# Args:
# StateMachine no. (0-7): each instance must have a different sm_no.
# An initialised input Pin: this and the next pin are the encoder interface.
# Pins must have pullups (internal or, preferably, low value 1KΩ to 3.3V).
class Encoder:
def __init__(self, sm_no, base_pin, scale=1):
self.scale = scale