preset_selector: rotary encoder direction reversed (clockwise decrements the preset)
amyboard
Reported in #amyboard (Discord) on 2026-06-02 by **@chad.eby**:
> In the AMYboard World `preset_selector` sketch, turning the encoder clockwise *decrements* the preset, when I'd expect it to increment it.
**Expected:** turning the rotary encoder clockwise advances to the *next* preset (increment).
**Actual:** clockwise *decrements* the preset.
### Where to look
The `preset_selector` AMYboard World example (`/editor/?env=preset_selector&user=shorepine`) reads the rotary encoder via `read_encoder()` in [`tulip/shared/amyboard-py/amyboard.py`](https://github.com/shorepine/tulipcc/blob/main/tulip/shared/amyboard-py/amyboard.py#L734-L754), which returns the raw cumulative seesaw position:
```python
return struct.unpack(">i", result)[0]
```
The Adafruit seesaw quad encoder typically reports *decreasing* values for clockwise rotation, so a sketch that maps an increasing encoder value to "next preset" will move backwards on CW. Likely fixes:
- Flip the sign where `preset_selector` consumes the encoder value, **or**
- Normalize direction once in `read_encoder()` so CW increases — but note that would flip direction for every existing sketch (`house_generator`, `acid_generator`, etc.), so it's a behavior change to weigh.
Also worth checking the web/simulator path (`_web_encoder_turn(delta)` / `_web_encoder_pos`) so hardware and sim agree after the fix.
_Filed from the community digest (item #1)._
0 条评论