rotaryio.IncrementalEncoder(pin_a, pin_b) refuses when the two pins are on different
AVR ports:
import board
import rotaryio
encoder = rotaryio.IncrementalEncoder(board.D2, board.D8)
error: CompileError: an encoder's two lines have to be on the same port. The handler
that decodes them reads one port register, and a register address has to be known when
the firmware is built, so it cannot read a second port chosen at run time. ...
This is a deliberate, well-explained hardware constraint
(pymcu/hal/avr/encoder/atmega328p.py, encoder_check_same_port) -- not a bug -- but
it is not written down anywhere a user would find it before hitting it: neither the
README's rotaryio row (which, additionally, is stale -- it still lists rotaryio under
"not implemented yet" even though IncrementalEncoder has shipped) nor
docs/language/limitations.md mentions it.
Ask
Document the same-port requirement next to rotaryio in the README (and drop the
"not implemented yet" line, which no longer matches rotaryio.py), so a user picks
board.D2, board.D3 instead of discovering the constraint from a build failure.
Corpus program (pymcu-circuitpython test corpus)
39_rotary_diff_ports_refuse.py -- rotaryio.IncrementalEncoder(board.D2, board.D8),
a pin pair that reads naturally from the docs' own knob wiring diagrams (D2/D8 are
both digital pins) but happens to straddle PORTD/PORTB.
rotaryio.IncrementalEncoder(pin_a, pin_b)refuses when the two pins are on differentAVR ports:
This is a deliberate, well-explained hardware constraint
(
pymcu/hal/avr/encoder/atmega328p.py,encoder_check_same_port) -- not a bug -- butit is not written down anywhere a user would find it before hitting it: neither the
README's
rotaryiorow (which, additionally, is stale -- it still listsrotaryiounder"not implemented yet" even though
IncrementalEncoderhas shipped) nordocs/language/limitations.mdmentions it.Ask
Document the same-port requirement next to
rotaryioin the README (and drop the"not implemented yet" line, which no longer matches
rotaryio.py), so a user picksboard.D2, board.D3instead of discovering the constraint from a build failure.Corpus program (pymcu-circuitpython test corpus)
39_rotary_diff_ports_refuse.py--rotaryio.IncrementalEncoder(board.D2, board.D8),a pin pair that reads naturally from the docs' own knob wiring diagrams (D2/D8 are
both digital pins) but happens to straddle PORTD/PORTB.