This commit is contained in:
Jimmy 2025-08-14 17:01:31 +12:00
parent 2a7b5527a5
commit b0c8a4371b
1 changed files with 33 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import time
import wifi
import json
from p2p import p2p
from machine import ADC, Pin
async def main():
settings = Settings()
@ -22,18 +23,48 @@ async def main():
patterns.set_brightness(int(settings["brightness"]))
patterns.set_delay(int(settings["delay"]))
async def tick():
while True:
patterns.tick()
await asyncio.sleep_ms(0)
async def system():
adc = ADC(Pin(2), atten=ADC.ATTN_11DB)
while True:
gc.collect()
for i in range(60):
wdt.feed()
await asyncio.sleep(1)
async def sw():
sw1 = machine.Pin(8, machine.Pin.IN, machine.Pin.PULL_UP)
sw2 = machine.Pin(9, machine.Pin.IN, machine.Pin.PULL_UP)
p = ["on", "rainbow_cycle", "theater_chase",
"color_transition", "flicker",
"bidirectional_scanner"]
pattern_index = 0
print(p)
pressed1 = 0
pressed2 = 0
while True:
if sw1.value() == 0:
patterns.select(p[pattern_index])
print(p[pattern_index])
pattern_index = pattern_index + 1
if pattern_index > len(p)-1:
pattern_index = 0
print("pressed 1")
if sw2.value() == 0:
patterns.select("off")
await asyncio.sleep_ms(200)
w = web(settings, patterns)
print(settings)
# start the server in a bacakground task
@ -45,8 +76,7 @@ async def main():
asyncio.create_task(tick())
asyncio.create_task(p2p(settings, patterns))
asyncio.create_task(system())
asyncio.create_task(sw())
# cleanup before ending the application
await server