Skip to content

Commit

Permalink
added restart capability
Browse files Browse the repository at this point in the history
added self-healing restart based on stale time checks
  • Loading branch information
TristanAmond committed Mar 27, 2023
1 parent 4cd5f2a commit 30ff3d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import busio
from digitalio import DigitalInOut, Pull
import neopixel
import supervisor

from adafruit_matrixportal.matrix import Matrix
from adafruit_esp32spi import adafruit_esp32spi
Expand Down Expand Up @@ -312,6 +313,14 @@ def send_notification(text):
# print available memory
print("Loop {} available memory: {} bytes".format(loop_counter, gc.mem_free()))

# if any checks haven't run in a long time, restart the Matrix Portal
# weather check: 60 minutes
# train check: 10 minutes
if time.monotonic() > last_weather_check + 60 * 60 or time.monotonic() > last_train_check + 60 * 10:
print("Supervisor reloading\nLast Weather Check: {} | Last Train Check: {}".format(last_weather_check, last_train_check))
time.sleep(5)
supervisor.reload()

# increment loop and sleep
# Day mode: 10 seconds
# Night mode: 5 minutes
Expand Down

0 comments on commit 30ff3d4

Please sign in to comment.