forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
User "Tosche" reported on Discord that their chosen pins for IncrementalEncoder didn't work, but it should have worked:
import microcontroller
import rotaryio
enc = rotaryio.IncrementalEncoder(board.GP14,board.GP15)
StateMachine.c's internal routine mask_and_rotate
may be dealing incorrectly with NULL pins & zero bit_counts. However, while trying to diagnose this I ran into #4555 and don't have a fix I'm confident of. Here's what I tried:
static uint32_t mask_and_rotate(const mcu_pin_obj_t *first_pin, uint32_t bit_count, uint32_t value) {
+ if (!first_pin || !bit_count) {
+ return 0;
+ }
value = value & ((1 << bit_count) - 1);
uint32_t shift = first_pin->number;
return value << shift | value >> (32 - shift);