todbot / qtpy-knob

QT Py Media Knob using rotary encoder & neopixel ring
74 stars 11 forks source link

Renaming to avoid "-" and use "_". #1

Closed dglaude closed 3 years ago

dglaude commented 3 years ago

Thank you for this piece of code and great idea.

Just a suggestion to avoid "-" into python file name and user "_" instead.

This permit to never rename the original file from the project and have a code.py like this:

import qtpy_knob_simple
#import qtpy_knob_scroller
#import qtpy_knob

PS: I have both QT-Py and Seeduino XIAO in the same form factor... my QT-Py is more precious because it has reset button, Stemma-QT pin, RGB. So I wanted to rename the pin for XIAO use... but there is no need, your code works out of the box on the same physical pin with the same code. Only the through hole seems smaller on the XIAO so it does not fit perfectly flush. Did I mention it does also kind of work without soldering!!!

todbot commented 3 years ago

Hi David! Thanks, but I wasn't intending any of these .py to be used straight but to be copied over as the code.py. How can it work if you're importing them? Wouldn't the while True: mess it up?

todbot commented 3 years ago

Oh and yes we are fortunate that the CircuitPython config for the XIAO contains both the pin names it has on the bottom as well as the pin names of the QT Py in its 'board' object. I was pleasantly surprised too! (because I have a pile of XIAOs and have been wanting to use them up, so in the video, both of the enclosed units are actually XIAO boards :-)

dglaude commented 3 years ago

The import from code.py works fine. That is what Info all the time, my code.py is just a program selector or choose the test I want to run.

To answer your question, you just never return from the import.

One may also want to import directly from REPL and have no code.py and no main.py.

I see no good reason to use character that block that.

todbot commented 3 years ago

Interesting! Okay, sounds like a good change to make then. Do you have a link to your program selector? Sounds pretty useful.

dglaude commented 3 years ago

My program selector is to put a # in front of all but the code I want to test. :-)

But there was a menu system I once saw for board with a screen, there is a feature to select what will be the "code.py" or "main.py" at next boot. This is useful if you have multiple games on a PyGamer.

What I made is a magtag boot selector: https://gist.github.com/dglaude/4bf8d0a13c9c8ca8b05d6c0e9176bd20 Later that was turned into a guide with a GUI: https://learn.adafruit.com/adafruit-magtag-project-selector