Reset after each loop to prevent freezes

This commit is contained in:
Neale Pickett 2020-03-15 14:20:34 -06:00
parent 7ab0fb426a
commit 0d2f10b410
1 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,3 @@
# Trinket IO demo
# Welcome to CircuitPython 3.1.1 :)
import board import board
from digitalio import DigitalInOut, Direction, Pull from digitalio import DigitalInOut, Direction, Pull
import adafruit_dotstar as dotstar import adafruit_dotstar as dotstar
@ -8,9 +5,11 @@ import adafruit_fancyled.adafruit_fancyled as fancy
import time import time
import neopixel import neopixel
import random import random
import microcontroller
# One pixel connected internally! # One pixel connected internally!
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
dot[0] = 0
# Built in red LED # Built in red LED
led = DigitalInOut(board.D13) led = DigitalInOut(board.D13)
@ -63,6 +62,7 @@ def singleCursor():
pos = 20 pos = 20
for i in range(80): for i in range(80):
grid[pos] = red * (i % 2) grid[pos] = red * (i % 2)
led.value = not (i % 2)
grid.show() grid.show()
time.sleep(0.08) time.sleep(0.08)
@ -96,6 +96,9 @@ def loop():
singleCursor() singleCursor()
sparkle() sparkle()
glitchPulse() glitchPulse()
# For some reason, this program freezes occasionally.
# I don't want to debug CircuitPython.
microcontroller.reset()
while True: while True:
loop() loop()