Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023 - circuit python 8.0.3 - sequential pins rotaryio? #4

Open
xgpt opened this issue Mar 9, 2023 · 13 comments
Open

2023 - circuit python 8.0.3 - sequential pins rotaryio? #4

xgpt opened this issue Mar 9, 2023 · 13 comments

Comments

@xgpt
Copy link

xgpt commented Mar 9, 2023

le.
main.py output:
Traceback (most recent call last):
File "main.py", line 30, in
RuntimeError: Pins must be sequential GPIO pins

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.

@todbot
Copy link
Owner

todbot commented Mar 9, 2023

Looks like you're using a QT Py RP2040. This project was created before those existed, and only works with the original QT Py M0.

@xgpt
Copy link
Author

xgpt commented Mar 11, 2023

Oh interesting, I wasn't sure why that might be happening!

@xgpt xgpt closed this as completed Mar 11, 2023
@adalovebass
Copy link

Sorry to bump, but @xgpt , did you find a workaround? I may just cut my pins and bridge with wires to sequential pins... :/

And @todbot , would you be willing to update the "components" section to call out the M0? I didn't realize there were different versions of the QT Pi and I didn't order directly from the link. Thank you both!

@todbot
Copy link
Owner

todbot commented Oct 14, 2023

@adalovebass Yep I'll do that. I'll also see about a solution for the RP2040.

@adalovebass
Copy link

adalovebass commented Oct 14, 2023

That's awesome! Technically I'm on a xiao-rp2040, but all the pins are in the same spot as the QT Pi, I just have less memory (and need to cherry-pick my python modules).

@xgpt
Copy link
Author

xgpt commented Oct 14, 2023

Sorry to bump, but @xgpt , did you find a workaround? I may just cut my pins and bridge with wires to sequential pins... :/

And @todbot , would you be willing to update the "components" section to call out the M0? I didn't realize there were different versions of the QT Pi and I didn't order directly from the link. Thank you both!

I'm out of town and away from my desk, but I can look at the prototype I ended up with and send you a schematic of the pinout when I get back from my trip!

@todbot
Copy link
Owner

todbot commented Oct 14, 2023

Ooo, @xgpt, I'd love to see that!

I also just updated qtpy_knob.py to use a new fakerotaryio module I created and put in this repo that will let you do rotaryio stuff on non-sequential pins. It's not as good as real rotaryio but should work for this application.

@adalovebass
Copy link

Omgosh thank you both! I am kind of new, so figured I could remove the rotary encoder lead from D1 and wire it to D4 instead, so the pins used were D3 and D4:
image

But apparently in the GPIO sense D3 and D4 are not actually sequential. I found this thread that mentions help(microcontroller.pin), the output of which indicates that on the Adafruit QT Py proper, D3 and D5 are actually GPIO sequential (link and screenshot):
adafruit/circuitpython#5334
image

This seems like a potential location for the rotary encoder, if you can do a fake ground on D10 for the push-button.

Unfortunately, between my D3/D4 attempt, and moving the bridging wire from D4 to D5, my board doesn't seem to be recognized by Windows any more (have tried unsoldering everything, and boot mode, to no avail) (and it was a comparatively clean, cool, and successful desoldering and resoldering, so not sure what's happening with that). 😄 Regardless, I haven't been able to run help(microcontroller.pin), nor test the concept.

In the meantime, thanks for the update to use fakerotaryio, I'll check it out when my new board shows up 😭 (I bought 2 so I can put header pins in one and prototype on a breadboard this time!)

@todbot
Copy link
Owner

todbot commented Oct 14, 2023

@adalovebass looks like you're running Adafruit QTPy firmware on that XIAO. They're pretty different internally, I'd recommend installing XIAO RP2040 CircuitPython

@adalovebass
Copy link

Thanks for lookin' out for me! To clarify, I am running the firmware you linked, the output of the help(microcontroller.pin) command was not my own, but from a QTPy user in the linked thread, which supports my hypothesis about pins D3 and D5 being sequential. I'll run it on my own board to make sure, or to find a similar pattern, when I get my replacement board :)

@todbot
Copy link
Owner

todbot commented Oct 15, 2023

@adalovebass ahh got it! In the XIAO pinout diagram, the gray labels are the chip GPIO pin numbers and it's those that must be sequential. (e.g. D3 & D5 are GPIO P29 & P7) It's confusing and I've been bit by it multiple times too, with both rotary encoders and I2S audio. And it doesn't help that rotaryio's error message isn't clear on this even with the fix (most users I think don't get the difference between silkscreen pin names and GPIO pin names)

@adalovebass
Copy link

adalovebass commented Oct 15, 2023

Oh gosh! :D Yeah, the message about GPIO pins meaning "micropython pin numbers" was certainly not clear! But it does seem like D10 and D8 would be sequential, as their micropython pin numbers are P3 and P2. I figure I can get D9 to do the "fake ground." Then I see your code uses MISO and MOSI (shared with D8 and D9) for the Neopixel Ring and Rotary Encoder's button, but I am pretty sure those can use any digital pin based on some other example I've seen. I'll let you know if I find a solution that works with the standard rotaryio library. I really appreciate you sharing your expertise, and hope this is all still relevant to this ticket :)

@adalovebass
Copy link

adalovebass commented Oct 16, 2023

So I did find a solution that works:

             +--------+
    LED Din--|D0    5V|--LED 5v
             |D1     G|--LED G
             |D2    3V|
           +-|D3   D10|-+
           | |D4    D9|-)-+
         +-)-|D5    D8|-)-)-+
         | | |D6    D7| | | |
         | | +--------+ | | | 
         | | XIAO RP2040| | |
         | |            | | |
         | | Rotary Enc | | |
         | |  +------+  | | |
         | +--|SW1  A|--+ | |
         |    |     G|----+ |
         +----|SW2  B|------+
              +------+

Code changes:

  • Button to D3
  • LED data pin to D0
  • Fakeground D5 and D9

Since I have limited storage space I manually added these to /lib directory:

  • adafruit_hid/
  • adafruit_led_animation/
  • digitalio.mpy
  • neopixel.mpy
  • rotaryio.mpy

Zip file with libraries here: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/tag/20231013

Specifically I used the 8.x bundle from there (direct link here: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/download/20231013/adafruit-circuitpython-bundle-8.x-mpy-20231013.zip )

Of course the .stl's won't necessarily fit, as the USB port and encoder knob are now on opposite sides of the board. BUT, it's possible to run this on the XIAO RP2040, using the elegant direct-mounting-of-encoder-to-board solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants