Skip to content

Commit 33cdcc1

Browse files
MatrixPortal Moon Clock: reduce RAM needs by using network.fetch_data() instead of json.loads()
1 parent 1a5030c commit 33cdcc1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Matrix_Portal_Moon_Clock/code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import gc
1616
import time
1717
import math
18-
import json
1918
import board
2019
import busio
2120
import displayio
@@ -146,8 +145,9 @@ def __init__(self, datetime, hours_ahead, utc_offset):
146145
# pylint: disable=bare-except
147146
for _ in range(5): # Retries
148147
try:
149-
full_data = json.loads(NETWORK.fetch_data(url))
150-
moon_data = full_data['location']['time'][0]
148+
location_data = NETWORK.fetch_data(url,
149+
json_path=[['location']])
150+
moon_data = location_data['time'][0]
151151
#print(moon_data)
152152
# Reconstitute JSON data into the elements we need
153153
self.age = float(moon_data['moonphase']['value']) / 100

0 commit comments

Comments
 (0)