Update main.py, tests, and add presets, circle test, and tool directory

This commit is contained in:
2025-11-30 18:35:31 +13:00
parent 6ae6189519
commit d45846ec74
8 changed files with 489 additions and 2 deletions

View File

@@ -15,8 +15,11 @@ async def main():
settings = Settings()
patterns = Patterns(settings["led_pin"], settings["num_leds"], selected=settings["pattern"])
if settings["color_order"] == "rbg": color_order = (1, 5, 3)
if settings["color_order"] == "grb": color_order = (3, 1, 5)
if settings["color_order"] == "rbg":
color_order = (1, 5, 3)
print("RBG")
if settings["color_order"] == "grb":
color_order = (3, 1, 5)
else: color_order = (1, 3, 5)
patterns.colors = [(8,0,0)]

31
src/presets.py Normal file
View File

@@ -0,0 +1,31 @@
import json
import wifi
import ubinascii
import machine
class Presets(dict):
FILE = "/presets.json"
def __init__(self):
super().__init__()
self.load() # Load settings from file during initialization
def save(self):
try:
j = json.dumps(self)
with open(self.FILE, 'w') as file:
file.write(j)
print("Presets saved successfully.")
except Exception as e:
print(f"Error saving settings: {e}")
def load(self):
try:
with open(self.FILE, 'r') as file:
self.update(json.load(file))
print("Presets loaded successfully.")
except Exception as e:
print(f"Error loading presets")
self.save()