Add device ID
This commit is contained in:
parent
55ef5c1580
commit
0b6eb9724f
|
@ -26,14 +26,15 @@ async def main():
|
|||
patterns.tick()
|
||||
await asyncio.sleep_ms(1)
|
||||
|
||||
|
||||
async def espnow():
|
||||
e = aioespnow.AIOESPNow() # Returns AIOESPNow enhanced with async support
|
||||
e.active(True)
|
||||
async for mac, msg in e:
|
||||
print(msg)
|
||||
data = json.loads(msg)
|
||||
|
||||
settings.set_settings(data, patterns)
|
||||
print(data)
|
||||
if settings["id"] in data["ids"]:
|
||||
settings.set_settings(data["settings"], patterns)
|
||||
print("should not print")
|
||||
|
||||
async def wifi_connect():
|
||||
|
|
|
@ -27,6 +27,7 @@ class Settings(dict):
|
|||
self["wifi_password"] = ""
|
||||
self["wifi_ip"] = ""
|
||||
self["wifi_gateway"] = ""
|
||||
self["id"] = 0
|
||||
|
||||
def save(self):
|
||||
try:
|
||||
|
@ -75,6 +76,8 @@ class Settings(dict):
|
|||
elif key == "color_order":
|
||||
if value == "rbg": self.color_order = (1, 5, 3)
|
||||
else: self.color_order = (1, 3, 5)
|
||||
elif key == "id":
|
||||
pass
|
||||
else:
|
||||
return "Invalid key", 400
|
||||
self[key] = value
|
||||
|
|
|
@ -150,6 +150,12 @@ async function updateName(event) {
|
|||
sendWebSocketData({ name: name });
|
||||
}
|
||||
|
||||
async function updateID(event) {
|
||||
event.preventDefault();
|
||||
const id = document.getElementById("id").value;
|
||||
sendWebSocketData({ id: parseInt(id) });
|
||||
}
|
||||
|
||||
function createPatternButtons(patterns) {
|
||||
const container = document.getElementById("pattern_buttons");
|
||||
container.innerHTML = ""; // Clear previous buttons
|
||||
|
@ -184,6 +190,7 @@ document.addEventListener("DOMContentLoaded", async function () {
|
|||
.getElementById("num_leds_form")
|
||||
.addEventListener("submit", updateNumLeds);
|
||||
document.getElementById("name_form").addEventListener("submit", updateName);
|
||||
document.getElementById("id_form").addEventListener("submit", updateID);
|
||||
document.getElementById("delay").addEventListener("touchend", updateDelay);
|
||||
document
|
||||
.getElementById("brightness")
|
||||
|
|
|
@ -79,6 +79,16 @@
|
|||
/>
|
||||
<input type="submit" value="Update Name" />
|
||||
</form>
|
||||
<form id="id_form" method="post" action="/id">
|
||||
<label for="id">ID:</label>
|
||||
<input
|
||||
type="text"
|
||||
id="id"
|
||||
name="id"
|
||||
value="{{settings['id']}}"
|
||||
/>
|
||||
<input type="submit" value="Update ID" />
|
||||
</form>
|
||||
<!-- Separate form for submitting num_leds -->
|
||||
<form id="num_leds_form" method="post" action="/num_leds">
|
||||
<label for="num_leds">Number of LEDs:</label>
|
||||
|
|
Loading…
Reference in New Issue