(sysname='rp2040', nodename='rp2040', release='8.0.0', version='8.0.0-beta.6 on 2022-12-21', machine='Adafruit Feather RP2040 with rp2040')
My program runs through one loop of the while True loop in main(). Then without warning or action it aborts the program with the Mu message:
Code stopped by auto-reload. Reloading soon.
This too was working code prior to CP8.0.0-beta.6. There are no file writes to the CIRCUITPY device. There are no file writing modules imported by my code. It imports a ton of animations. I will, of course, try to strip this down, but this code had worked consistently for nearly a year.
One thought is my lib folder is out of date but I usually get a more explicit error. I suspect this is it. Here are the imported modules. I'll remind myself to use circup to see if I can sync all libs.
import board
import time
from digitalio import DigitalInOut, Direction, Pull
import analogio
import math
from neopixel import NeoPixel
from adafruit_led_animation.animation.sparkle import Sparkle
from adafruit_led_animation.animation.rainbowchase import RainbowChase
from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
from adafruit_led_animation.animation.rainbowcomet import RainbowComet
from adafruit_led_animation.animation.rainbow import Rainbow
from adafruit_led_animation.animation.customcolorchase import CustomColorChase
from adafruit_led_animation.sequence import AnimationSequence
from adafruit_led_animation.color import RAINBOW
from os import uname
import gc
# the following two are my own imports. many_colors just has lots of colors defined
from many_colors import *
# AnimationConfiguration is a class with all the configuration attributes encapsulated (poor man's YAML, json,
# TOML implemented like a static instance of itself). Been in use a year plus in all my code. Imports just board and # neopixels. No writing to the device
from anim_config import AnimationConfiguration
# used like:
pixel_num = AnimationConfiguration.num_pixels
brightness = AnimationConfiguration.get_brightness() #enforces a max brightness limit
pixel_pin = AnimationConfiguration.neopixel_pin
None of this is really relevant. There's a setup_animations() which gets called on each loop through main while True and deletes and gc() all animations and rebuilds them with some chaos/randomness involved. Originally conceived as a way to test garbage collector and not heap fragmentation. These never proved a problem and app often ran weeks at a time.
Now it makes exactly one pass through the main while true loop. There's a break condition in the while True when the AnimationConfiguration.animation_time_ms has expired and it repeats an outer loop that setups up animation on random values creating a brand new sequence and times, tails, chase speeds, ...
The function run_aminations is called through the outer while True loop in main. Odd details: none of the print statements showing debug or mem information prints. It does complete one sequence for the allotted time and then restarts the program. Here's that method. I know it would help to strip this down and I will try. Old code that had run for over a year I believe:
Code: Select all
def elapsed_time(start, time_to_run_ms):
return False if elapsed_time is None else time.monotonic() >= start + time_to_run_ms
def run_animations(animation_ms):
# setup_animations() correctly runs and prints all detail
animations = setup_animations()
# this print also prints
print(f"animations setup: animation loop running for {animation_ms / 60} minutes, time per animation {advance_interval} seconds")
start = time.monotonic()
pixels.fill(0)
pixels.show()
animations_loop = 0
while True:
# this code runs until the elapsed_time triggers break and the print("elapsed... is rendered
animation_loop += 1
print("animation loop: {}", animation_loop)
animations.animate()
# the elapsed time seems to fire on time but there is no print
if elapsed_time(start, animation_ms):
# does not print but does break while True
print(f"elapsed time of {animation_ms} has gone by. Exiting animate")
break
# doesn't print any of this, nor does it loop on the main while True again
# instead, the program reloads in Mu "Code stopped by auto-reload. Reloading soon."
print("break, before del animations")
del animations
gc.collect()
print("past garbage collector")
def main():
main_loops = 0
while True:
main_loops += 1
print("in main loop: {}", main_loops)
print(f"beginning mem_free: {gc.mem_free()}")
run_animations(animation_ms)
# never displays these prints
print(f"after mem_free: {gc.mem_free()}")
print("end main loop: {}", main_loops)
print("exiting main after {} loops : SHOULD NOT REACH THIS CODE", main_loops)
main()
My next step will be to put latest stable on and see if it works again like it did. Sorry this is long. But it bizarre and unlike any problem I've seen. I will update what I find in hopes it may help someone else.
-RichSad