2024-01-26 19:04:38 +01:00
|
|
|
from machine import Pin
|
|
|
|
|
from neopixel import NeoPixel
|
|
|
|
|
import uasyncio
|
|
|
|
|
|
2022-11-05 03:18:48 +01:00
|
|
|
from lightbar.app import Lightbar
|
2021-12-28 22:10:27 +01:00
|
|
|
|
2024-01-26 19:04:38 +01:00
|
|
|
# TODO: Move this to config file
|
|
|
|
|
NEOPIXEL_COUNT = 28
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Move this into a LightbarController class
|
|
|
|
|
async def run_neopixels():
|
|
|
|
|
print('[main/run_neopixels] Turning on Neopixels')
|
|
|
|
|
np = NeoPixel(Pin(26), NEOPIXEL_COUNT)
|
|
|
|
|
np.fill((0, 0, 0))
|
|
|
|
|
np.write()
|
|
|
|
|
|
|
|
|
|
color_set = [
|
|
|
|
|
(255, 0, 0),
|
|
|
|
|
(255, 255, 0),
|
|
|
|
|
(0, 255, 0),
|
|
|
|
|
(0, 255, 255),
|
|
|
|
|
(0, 0, 255),
|
|
|
|
|
(255, 0, 255),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
for i in range(NEOPIXEL_COUNT):
|
|
|
|
|
np[i] = color_set[i % len(color_set)]
|
|
|
|
|
np.write()
|
|
|
|
|
|
|
|
|
|
await uasyncio.sleep(0.5)
|
|
|
|
|
|
|
|
|
|
uasyncio.create_task(run_neopixels())
|
|
|
|
|
|
2022-11-05 03:18:48 +01:00
|
|
|
print('[main] Starting lightbar HTTP server...')
|
|
|
|
|
api_server = Lightbar()
|
|
|
|
|
api_server.run(port=80, debug=True)
|