Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Gemma MO: CircuitPython or MicroPython
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Gemma MO: CircuitPython or MicroPython

by danhalbert on Tue Aug 22, 2017 9:49 am

Knowing it was suspended in between is helpful. Did you reinstall the drivers from the folder on the Gemma or from the downloaded driver package (what's the file name?)?

I see you have the Teensy driver installed. Try uninstalling that.

I'll be offline for a while but will try some things later and be back.

danhalbert
 
Posts: 2134
Joined: Tue Aug 08, 2017 12:37 pm

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Tue Aug 22, 2017 9:54 am

I think that was the case. After I got it all working correctly. I told windows to restart. My theory is that it saves all settings as it shuts down. I think when I shut my laptop, it just cuts off, not saving settings. It seems that way.

For now, When I open PUTTY, the numbers scroll by as it's changing colors AND CIRCUITPY (E:) shows up when I go to "Computer".

Is there a small example text file for the gemmaMO and neopixel ring? Correct me if I'm wrong... I just change the name to main.py so it runs when plugged in?

I am excited to learn circuitpython, but seeing the syntax, defining pins, etc. helps

Thanks
Last edited by marine_hm on Tue Aug 22, 2017 10:45 am, edited 1 time in total.

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Tue Aug 22, 2017 10:00 am

danhalbert wrote:Knowing it was suspended in between is helpful. Did you reinstall the drivers from the folder on the Gemma or from the downloaded driver package (what's the file name?)?

I see you have the Teensy driver installed. Try uninstalling that.

I'll be offline for a while but will try some things later and be back.


I used the adafruit driver zip file. and pointed it directly to the Gemma MO instead of the driver installer that installed all the drivers for the boards.
zip file.JPG
zip file.JPG (28.44 KiB) Viewed 588 times


To point out again what I think is wrong: the install drivers.exe file by Adafruit might have issues.
installer.JPG
installer.JPG (18.82 KiB) Viewed 576 times

Thanks for the help.
Last edited by marine_hm on Tue Aug 22, 2017 10:29 am, edited 2 times in total.

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Tue Aug 22, 2017 10:16 am

Are modules and APIs the same thing?

Oh, hey... help()
Those are all the "functions"?

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by tannewt on Tue Aug 22, 2017 1:39 pm

Hi marine_hm,
The line you got the syntax error on should be:

Code: Select all | TOGGLE FULL SIZE
np = neopixel.NeoPixel(board.NEOPIXEL, 10)


The API docs are here and there are a few examples in there as well: https://circuitpython.readthedocs.io/en/stable/

Glad you got it going!
~Scott

tannewt
 
Posts: 1830
Joined: Thu Oct 06, 2016 8:48 pm

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Wed Aug 23, 2017 1:02 am

Double clicking the button does not bring up GEMMABOOT.

Are there any examples files for the GemmaMO lighting up a 12Neopixel ring via circuitpython?

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Wed Aug 23, 2017 8:32 am

tannewt2 wrote:Hi marine_hm,
The line you got the syntax error on should be:

Code: Select all | TOGGLE FULL SIZE
np = neopixel.NeoPixel(board.NEOPIXEL, 10)



Scott:
Looking at the syntax... NEOPIXEL is not associated to "board"
dir.JPG
dir.JPG (22.92 KiB) Viewed 533 times

neopixel.JPG
neopixel.JPG (25.1 KiB) Viewed 533 times

board.JPG
board.JPG (27.35 KiB) Viewed 533 times


I'm sure I have this all wrong... (learning by experimentation) for the GemmaMO shouldn't this be:
Code: Select all | TOGGLE FULL SIZE
np = neopixel.NeoPixel(board.D0, 12)
?
it doesn't work. Could you break down the entire line? I see it as saying we're naming np as a NeoPixel on pin D0 and there are 12 Neopixels on the board.

Another thought... when I type dir() at first all I see is ['__name__']
When I type import board, import neopixel. Where is "board" and "neopixel" being imported from? What else can I import and how can I see what is available?
I found this... https://circuitpython.readthedocs.io/en/stable/ but it doesn't list the math API which works when I type import math.

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by tannewt on Wed Aug 23, 2017 1:16 pm

Yup, sorry. I was thinking it was a CircuitPlayground Express.

You'll want the board part to match the data pin you have the NeoPixels hooked up to. After that you'll need to set the colors to something and possible call show() on the np object.

I believe help("modules") will list all built in modules. math is one like board. math isn't listed because its docs haven't been updated to our new format. Its on our radar but hasn't been done yet.

The neopixel module is being imported from the bundle and browsing it can show the other available libraries.

If it still doesn't work please post your current code and describe how it doesn't work. Thanks!

~Scott

tannewt
 
Posts: 1830
Joined: Thu Oct 06, 2016 8:48 pm

Re: Gemma MO: CircuitPython or MicroPython

by jerryn on Wed Aug 23, 2017 1:38 pm

Take a look at the examples in:
https://learn.adafruit.com/gemma-m0-sheikah-pendant#upload-the-code
The basic example should work fine with a change of the number of pixels.
Note that for the rainbow_cycle example, I had to make some changes as noted here:
https://forums.adafruit.com/viewtopic.php?f=47&t=121933#p609773

jerryn
 
Posts: 1312
Joined: Sat Sep 14, 2013 9:05 am

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Thu Aug 24, 2017 8:53 am

Jerry; Thanks. I had struggled a bit, then instinct kicked in.
"strip" didn't work so I changed it to "pixels"
"show" didn't work either. Changed it to "write" and the LEDs lit up

Code: Select all | TOGGLE FULL SIZE
import board
import neopixel
import time
 
pixpin = board.D0
numpix = 12
 
#led = DigitalInOut(D13)
#led.direction = Direction.OUTPUT
 
pixels = neopixel.NeoPixel(pixpin, numpix, brightness=.5, auto_write=False)
 
 
def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if (pos < 0):
        return (0, 0, 0)
    if (pos > 255):
        return (0, 0, 0)
    if (pos < 85):
        return (int(pos * 3), int(255 - (pos*3)), 0)
    elif (pos < 170):
        pos -= 85
        return (int(255 - pos*3), 0, int(pos*3))
    else:
        pos -= 170
        return (0, int(pos*3), int(255 - pos*3))
 
def rainbow_cycle(wait):
    for j in range(255):
        for i in range(len(pixels)):
            idx = int ((i * 256 / len(pixels)) + j)
            pixels[i] = wheel(idx & 255)
        pixels.write()
        time.sleep(wait)
 
try:
    while True:       
        rainbow_cycle(0.001) #speed of color transition?
except:
    pass
finally:
    for i in range(len(pixels)):
        pixels[i] = (0,0,0)
    pixels.write()

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by jerryn on Thu Aug 24, 2017 9:09 am

Glad you got it working!
I'm puzzled by why using "strip" or .show did not work for you ...
as long as it is used consistently naming the instance strip or pixels or foobar should not make any difference, should it?

As to .show vs .write, it thought hey were equivalent and .show was recommended:
https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/blob/master/neopixel.py

anyway - it works, don't "fix it"

jerryn
 
Posts: 1312
Joined: Sat Sep 14, 2013 9:05 am

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Thu Aug 24, 2017 9:18 am

tannewt2 wrote:I believe help("modules") will list all built in modules. math is one like board. math isn't listed because its docs haven't been updated to our new format. Its on our radar but hasn't been done yet.

The neopixel module is being imported from the bundle and browsing it can show the other available libraries.


Scott;
help()
worked
modules.JPG
modules.JPG (53.06 KiB) Viewed 499 times

So if these modules are built in.... Do I have to "import" them? Such as: import board, import neopixel
and what does this mean: from digitalio import *
from and * ?
No
Thanks all for your help. This is great! I now have 2 mini sketches or circuspython "programs"? for my 12neopixel ring.

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by tannewt on Thu Aug 24, 2017 1:22 pm

You do still need to import them because it takes a bit of memory to have them loaded. The `from <module> import *` imports all names within the module rather than the module itself. For example, doing `import board` means you'd refer to a pin as `board.D13`. If you do `from board import *` you can refer to the same thing as `D13`.

You are likely using an older version of the `neopixel` module because `show` was recently added. It was added to match Arduino and Micro:Bit.

Glad you got it going!

tannewt
 
Posts: 1830
Joined: Thu Oct 06, 2016 8:48 pm

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Thu Aug 24, 2017 11:06 pm

FYI: "show" works

I now have 3 sketches. A Gradient Wheel that rotates slowly (From Gemma Tutorial), Flashy lights, color wheel. This is supposed to be an RGB Neopixel ring but, I found it does white very well.

I'd like some help to show me how to make it do several actions in the same program: fade from one solid color to the next, Circle one way, pause and then circle back the other direction then flashing random colors like I have here:
Code: Select all | TOGGLE FULL SIZE
import board
import neopixel
import time
 
pixpin = board.D0
numpix = 12
 
#led = DigitalInOut(D13)
#led.direction = Direction.OUTPUT
 
pixels = neopixel.NeoPixel(pixpin, numpix, brightness=1, auto_write=False)
 
 
def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if (pos < 0):
        return (0, 0, 0)
    if (pos > 255):
        return (0, 0, 0)
    if (pos < 85):
        return (int(pos*17), int(255 - (pos*17)), 0)
    elif (pos < 170):
        pos -= 85
        return (int(255 - pos*17), 0, int(pos*17))
    else:
        pos -= 170
        return (0, int(pos*17), int(255 - pos*17))
 
def rainbow_cycle(wait):
    for j in range(255):
        for i in range(len(pixels)):
            idx = int ((i * 256 / len(pixels)) + j)
            pixels[i] = wheel(idx & 255)
        pixels.show()
        time.sleep(wait)
 
try:
    while True:       
        rainbow_cycle(.0001) #transition speed?
except:
    pass
finally:
    for i in range(len(pixels)):
        pixels[i] = (0,0,0)
    pixels.show()

Not really random. I just manipulated the way the transition occurs.
Thinking of getting the circuitplayground next, I'm pretty sure It can turn on the leds by the motion sensor and control the colors by the sound sensor.

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Re: Gemma MO: CircuitPython or MicroPython

by marine_hm on Thu Aug 24, 2017 11:31 pm

Simple color wheel:
Code: Select all | TOGGLE FULL SIZE
import board
import neopixel

pixpin = board.D0
numpix = 12

pixels = neopixel.NeoPixel(pixpin, numpix, brightness=.3)

pixels[0] = (255, 255, 0) #Yellow
pixels[1] = (0, 0, 0)
pixels[2] = (255, 255, 255) #white
pixels[3] = (0, 0, 0)
pixels[4] = (255, 100, 0) #Orange
pixels[5] = (0, 0, 0)
pixels[6] = (0, 0, 255) #Blue
pixels[7] = (0, 0, 0)
pixels[8] = (0, 155, 0) #Green
pixels[9] = (0, 0, 0)
pixels[10] = (255, 0, 0) #Red
pixels[11] = (0, 0, 0)

pixels.write()

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Please be positive and constructive with your questions and comments.