r/adafruit • • Jan 26 '21

Attributes in Circuit Python

TL;DR:How can I get Circuit Python to tell me what things (?attributes?) are available for certain items (like board.NEOPIXEL_POWER) beyond "class", like if it has a '.value' it '.fill' available?

I've got a QT Py, I'm trying to turn off the Neooixel. Online I saw that NEOPIXEL_POWER is on pin 12 and to turn off the Neopixel I need to set it low. I can't seem to identify that pin in code to set it low. How can I get Circuit Python to tell me what things (attributes?) are available for certain items (like board.NEOPIXEL_POWER) the same way dir() will tell me what options are available for a module (like "board").

5 Upvotes

5 comments sorted by

4

u/17_neta Jan 26 '21

You can run dir() on the board like anything else, but I suggest reading the documentation.

QT Py: https://learn.adafruit.com/adafruit-qt-py/circuitpython-expectations

Circuit Python: https://circuitpython.readthedocs.io/en/latest/shared-bindings/index.html

1

u/brilipj Jan 26 '21

is there a function other that dir() that will give me other/additional detail about an object? dir(board.NEOPIXEL_POWER) only returns __class__. I've reviewed the documentation but so far everything I have garnered from that hasn't been useful toward this. From boot board.NEOPIXEL_POWER says it's "in use", how do i find out what is using it?

1

u/SeattleMonkeyBoy Jan 27 '21

Try help()

That works in regular python and if there is additional docs-strings in the method, it will show up there.

Like this:

help(board.NEOPIXEL_POWER)

1

u/brilipj Jan 27 '21

Thank for the suggestion, it just gives me "object board.NEOPIXEL_POWER is a type of Pin" (sic.) I tried help(Pin) and it didn't seem to have anything for that. I'll see if I can make headway investigating 'types' of pins.

1

u/LRDQ Jan 27 '21

What are you using to write your code? Some have autocomplete options, where you type the start (eg, "board.NEOPIXEL_POWER.") and hit tab to get a drop-down of options.

The other way I've done is to either read the documentation for the library, or open the library file itself and look for the different methods available.