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

main.py does not run on Gemma M0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

main.py does not run on Gemma M0

by bodger on Wed Sep 13, 2017 10:14 pm

I have a simple program I want to run on the Gemma M0 to just light the DotStar at low brightness:

import dotstar
from board import *
dot = dotstar.DotStar(APA102_MOSI, APA102_SCK, 1, brightness=0.1)
dot[0] = [1,1,1]

When I run it from the serial port (REPL), it works as expected and lights the DotStar. When I save it as main.py, I get a pulsing green LED. I've tried unmounting and unplugging it, but when I plug it back in, I get a couple of colored flashes then the pulsating green. Opening main.py shows that the code is still there.

bodger
 
Posts: 12
Joined: Fri Oct 01, 2010 8:21 am

Re: main.py does not run on Gemma M0

by jerryn on Wed Sep 13, 2017 10:32 pm

Just a hunch. If you are not using latest 2.00 release, try set in brightness to 1.0 or just remove brightness setting. There was a bug that affected setting less than 1.0 which is the default.

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

Re: main.py does not run on Gemma M0

by danhalbert on Wed Sep 13, 2017 10:37 pm

The latest release of the library is here: https://github.com/adafruit/Adafruit_Ci ... on_DotStar. You can just download the .py file and try it. Note that the library name has changed. You now need to say:
Code: Select all | TOGGLE FULL SIZE
import adafruit_dotstar

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

Re: main.py does not run on Gemma M0

by tannewt on Thu Sep 14, 2017 2:21 am

FYI, the pin order in the constructor was swapped to match the rest of the CircuitPython APIs which have the clock pin first.

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

Re: main.py does not run on Gemma M0

by bodger on Thu Sep 14, 2017 9:01 am

If it were weirdness with the "brightness" parameter, I would expect it to not work with REPL either. I've also noticed that as soon as I start REPL, the stored program appears to run properly.

bodger
 
Posts: 12
Joined: Fri Oct 01, 2010 8:21 am

Re: main.py does not run on Gemma M0

by bodger on Thu Sep 14, 2017 9:14 am

I also tried installing the latest release of the adafruit_dotstar.py library, but I'm still getting the same behavior: it runs fine under REPL, but putting it in main.py gives green pulsing. Starting REPL seems to run an old version of the code somehow.

bodger
 
Posts: 12
Joined: Fri Oct 01, 2010 8:21 am

Re: main.py does not run on Gemma M0

by danhalbert on Thu Sep 14, 2017 10:07 am

We'll try reproducing this. A couple of questions to narrow things down:
1. What operating system are you running? It's possible your changes to main.py are not being reflected.
2. Are you running CircuitPython 1.0.0 on the Gemma, or did you upgrade it?

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

Re: main.py does not run on Gemma M0

by bodger on Thu Sep 14, 2017 10:20 am

I'm running MacOS Sierra 10.12.5. I did notice that it's putting extra files on the drive (causing it to run out of space at one point), and possibly confusing the loader.

I did the testing with the original version, and I saved off the .uf2 file just in case, but then I upgraded to 2.0.0 and tried again, with the same results.

bodger
 
Posts: 12
Joined: Fri Oct 01, 2010 8:21 am

Re: main.py does not run on Gemma M0

by tannewt on Thu Sep 14, 2017 12:28 pm

I use MacOS myself. Are you using screen to connect to CircuitPython serial? Could you post a screenshot of what it shows when it doesn't work? There may be an error in the main.py.

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

Re: main.py does not run on Gemma M0

by bodger on Thu Sep 14, 2017 1:55 pm

Yes, I'm using screen. Unfortunately, no error is displayed that I can see (it seems to do a screen clear when I plug it in, so it's possible something is lost then).

Sequence of events is, I plug it in to a USB port, and get a flicker then the fading green light. Then I start screen, and get the screen clear and "Press any key to enter the REPL." message. LED is still fading green. I press a key, and the LED lights at medium intensity, as if it's running my old main.py. Then I copy/paste the code, and the LED lights at low intensity.
Attachments
screenshot_1044.png
screenshot_1044.png (44.69 KiB) Viewed 1310 times

bodger
 
Posts: 12
Joined: Fri Oct 01, 2010 8:21 am

Re: main.py does not run on Gemma M0

by danhalbert on Thu Sep 14, 2017 3:20 pm

Scott (tannewt) and I consulted on this. The problem with your main.py is that when it's done, it just falls off the end and exits. Then the board soft-resets and the DotStar will start pulsing again. If you want it to remain glowing as you set it, you need to add while True: pass as the last statement so it loops infinitely. You can ctrl-C out of that in the REPL.

In addition, I found some bugs with brightness handling in the library. I'll have a fixed version available to test later.

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

Re: main.py does not run on Gemma M0

by danhalbert on Thu Sep 14, 2017 3:50 pm

Here's a new version of the library to try. It fixes a couple of problems, including brightness setting and getting the pixel value back. If you have time to test it, very much appreciated.
Download and remove the ".txt" extension (I can't post a .py file).
adafruit_dotstar.py.txt
(7.75 KiB) Downloaded 43 times

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

Re: main.py does not run on Gemma M0

by bodger on Fri Sep 15, 2017 8:52 am

The same notion (that my program exits) occurred to me this morning, and yes, that fixes it!

I tried installing the updated library, and it seems to work well.

I did finally realize that I can't set the brightness lower than 1,1,1 using the "brightness" parameter (I had hoped the DotStars could somehow do this).

However, I can achieve a similar effect by basically unrolling a PWM loop:

while True:
dot[0] = [1,1,1]
dot[0] = [0,0,0]
dot[0] = [0,0,0]
dot[0] = [0,0,0]
dot[0] = [0,0,0]
dot[0] = [0,0,0]

Thanks to all of you for your help!

bodger
 
Posts: 12
Joined: Fri Oct 01, 2010 8:21 am

Re: main.py does not run on Gemma M0

by danhalbert on Fri Sep 15, 2017 9:25 am

Great! Thanks for testing the library. The updated version is now in the official place: https://github.com/adafruit/Adafruit_Ci ... on_DotStar

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

Please be positive and constructive with your questions and comments.