pixel[0] lights after "Code done running"

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

pixel[0] lights after "Code done running"

Post by macewmi »

Here's a minimal program to test. After the program completes, pixel[0] will periodically turn on (red) and then off. Sometimes it flashes. Sometimes it stays on for 4+/- seconds. Sometimes I've see it flash green-ish or blue-ish. Is this normal behavior?

Code: Select all

from adafruit_macropad import MacroPad
import time

macropad = MacroPad()

for i in range(10):
    time.sleep(0.25)

p.s. I closed down Mu, unplugged and replugged into my Mac and now it lights green.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: pixel[0] lights after "Code done running"

Post by mikeysklar »

If the goal is not to have the macopad light up at all until you are ready you could add some initializations code such as:

Code: Select all

MACROPAD.display.auto_refresh = False
MACROPAD.pixels.auto_write = False

User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

Re: pixel[0] lights after "Code done running"

Post by macewmi »

My goal is that when code.py on the MacroPad finishes and the "code done running" message is displayed on the OLED, then the MacroPad pixel[0] shouldn't randomly flash. If pixel[0] is off at the time the code finishes, then it should stay off and not blink.

The two statements you gave have no effect on the blinking when those statements are included in code.py. (I wouldn't have expected them to have any effect since "code done running" suggest to me that the MacroPad should be behaving like an electric brick at that point.)

Based on those statements, I thought perhaps that the blinking was being caused by the MacroPad doing some sort of check to see if the laptop was trying to transfer new code, but the blinking still occurs when the MacroPad is plugged into a dump USB charging port on my workbench.

Any other thoughts?

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: pixel[0] lights after "Code done running"

Post by mikeysklar »

Which version of CircuitPython are you running on your macropad? I think it might be worth trying the current 7.0.0-alpha5 if you are not already on it with the current 7.x libraries to see if that changes the idle behavior.

https://circuitpython.org/board/adafrui ... ad_rp2040/

User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

Re: pixel[0] lights after "Code done running"

Post by macewmi »

Contents of boot_out.txt

Adafruit CircuitPython 7.0.0-alpha.5 on 2021-07-21; Adafruit Macropad RP2040 with rp2040

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: pixel[0] lights after "Code done running"

Post by mikeysklar »

Great. Glad to see the CircuitPython is current. If you have not already can you replace any of the contents of /lib with the 20210806 7.x library bundle?

https://circuitpython.org/libraries
https://github.com/adafruit/Adafruit_Ci ... 210806.zip

User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

Re: pixel[0] lights after "Code done running"

Post by macewmi »

The following is a listing of the files in the lib directory after having copied new versions of whatever was there already with a version from /adafruit-circuitpython-bundle-7.x-mpy-20210806.
pixel[0] still flashes, but this time, it's blue. Previously, I've seen red and green.

Code: Select all

Aug  6 05:10 adafruit_debouncer.mpy*
Aug  9 18:47 adafruit_display_shapes/
Aug  9 18:47 adafruit_display_text/
Aug  9 18:47 adafruit_hid/
Aug  6 05:10 adafruit_macropad.mpy*
Aug  9 18:47 adafruit_midi/
Aug  6 05:10 adafruit_pixelbuf.mpy*
Aug  6 05:10 adafruit_simple_text_display.mpy*
Aug  6 05:10 neopixel.mpy*

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: pixel[0] lights after "Code done running"

Post by mikeysklar »

Okay, a change in behavior is notable.

When you look at the serial console in the mu do you see any output from the REPL besides "Code done running" or is that the same?

If you do the reverse and leave the macropad running doing nothing does this stop the random flashing? I am not suggesting this is a solution to sitting idle without blinking, but would like to know if it exhibits the correct behavior.

Code: Select all

 from adafruit_macropad import MacroPad
import time

macropad = MacroPad()
macropad.display.auto_refresh = False
macropad.pixels.auto_write = False

while True:
        pass

User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

Re: pixel[0] lights after "Code done running"

Post by macewmi »

With the code above (while True: pass), pixels[0] does not blink.

If the while loop is removed and the code is allowed to fall through the bottom and end, then I get flashes. (It's back to red right now).

Serial monitor shows the following in response to a SAVE in the Mu IDE.
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:

Code done running.

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

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: pixel[0] lights after "Code done running"

Post by mikeysklar »

Would you like to open an issue on the github report for CircuitPython? This seems like the a settings that others would appreciate that the default state of the macropad be off until code is being executed. It might be declines, but seems reasonable to request.

https://github.com/adafruit/circuitpython/issues

User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

Re: pixel[0] lights after "Code done running"

Post by macewmi »

I will post an issue on GitHub. Can you first confirm that the behavior that I see is what everyone sees and that it’s not a hardware/assembly issue that I’m dealing with?

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: pixel[0] lights after "Code done running"

Post by mikeysklar »

I have a high confidence that the behavior you are seeing is normal, but never having used a macropad I'm not 100%. Opening an issue and letting hearing from the mainters about the design choice to have default on lillumination would be helpful and if that was not the case we will find out quickly.

User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

Re: pixel[0] lights after "Code done running"

Post by macewmi »

Well, apparently the flashing is desired and expected based on the Issue filed on GitHub:
The first NeoPixel is used as a status pixel, like the status NeoPixels on Feather and Metro boards. If your program starts using the NeoPixels, the status information will not be displayed. Normally your user program would run forever, but if it completes, CircuitPython restart and will again display status information.

Yes, the status RGB LED indicates various states and errors. In 6.x and earlier, it flashed more often: https://learn.adafruit.com/welcome-to-c ... 2978455-21. In 7.0.0, we are simplifying it and reducing the frequency of flashing, to save power and annoyance. The new flashing scheme hasn't been written up yet in detail.
Thanks for looking into this.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: pixel[0] lights after "Code done running"

Post by mikeysklar »

Thank you for the summary of that issue. It sounds like it will be less annoying, but still blinking status information in the future if the code completes.

User avatar
macewmi
 
Posts: 69
Joined: Sat Feb 08, 2020 10:26 am

Re: pixel[0] lights after "Code done running"

Post by macewmi »

The issue has been reopened in GitHub. It turns out this pattern of lights is not normal.

Locked
Please be positive and constructive with your questions and comments.

Return to “AdaBox! Show us what you made!”