The shield's rotary encoder (ENC1) and its push switch. More...
Public Member Functions | |
| position (self) | |
| Gets the number of clicks turned since the start or set_position(). | |
| steps (self) | |
| Gets the raw count: four steps per click. | |
| set_position (self, clicks=0) | |
| Sets the count, e.g. | |
| pressed (self) | |
| Reads the push switch now. | |
| on_press (self, callback) | |
| Calls a function each time the knob is pressed. | |
The shield's rotary encoder (ENC1) and its push switch.
A and B (D3, D4) and the switch (D2) have pull-ups and RC filters on the shield, so the pins are inputs with no pull of their own. Pin interrupts count each change of A and B, so no turn is missed while your program does something else. Use encoder() to get the shield's instance rather than making another.
Turning clockwise counts up, one per click.
| position | ( | self | ) |
Gets the number of clicks turned since the start or set_position().
| steps | ( | self | ) |
Gets the raw count: four steps per click.
| set_position | ( | self, | |
| clicks = 0 ) |
| pressed | ( | self | ) |
Reads the push switch now.
| on_press | ( | self, | |
| callback ) |
Calls a function each time the knob is pressed.
The function runs soon after the press, between lines of your program (MicroPython's micropython.schedule()), and takes no arguments. A press within 100 ms of the switch last changing, pressed or released, is taken as switch bounce.
| callback | A function, or None to stop. |