Implement shutdown and reboot via API; add Makefile for deployment

This commit is contained in:
Lexi / Zoe 2022-11-05 03:18:48 +01:00
parent 56e7a1d2de
commit f16f506332
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
11 changed files with 124 additions and 14 deletions

22
src/lightbar/app.py Normal file
View file

@ -0,0 +1,22 @@
import machine
import uasyncio
from microdot_asyncio import Microdot
from lightbar.frontend import frontend
from lightbar.rest_api import rest_api
class Lightbar(Microdot):
def __init__(self):
super().__init__()
self.mount(frontend)
self.mount(rest_api, url_prefix='/api')
async def scheduled_shutdown(self):
await uasyncio.sleep(0.1)
self.shutdown()
@staticmethod
async def scheduled_reboot():
await uasyncio.sleep(0.1)
machine.reset()