From f5288ef30e6229e7cc855cd8e3f4f6d3bc32dbe9 Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Wed, 6 Nov 2019 00:02:42 +0100 Subject: [PATCH] homecontrol-neopixel: minor updates --- main.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 1609247..2055657 100644 --- a/main.py +++ b/main.py @@ -8,8 +8,9 @@ import math import wifi CONFIG = "config.json" -ADDRESS = "http://192.168.11.21:5000" -TIMEOUT_UPDATE = 1 +NUM_PIXEL = 24 +ADDRESS = "http://192.168.11.11:5000" +TIMEOUT_UPDATE = 5 class ActorNP: @@ -28,24 +29,24 @@ class ActorNP: if not self.config.get("type"): update_config = True self.config["type"] = "neopixel" - if not self.config.get("levels"): + if not self.config.get("maxLevel"): update_config = True - self.config["levels"] = 0xffffff + self.config["maxLevel"] = 0xffffff if update_config: with open(CONFIG, "w") as config_file: ujson.dump(self.config, config_file) self.id_a = self.config["id"] self.type_a = self.config["type"] - self.levels = self.config["levels"] + self.maxLevel = self.config["maxLevel"] self.color = (0, 0, 0) - self.np = neopixel.NeoPixel(machine.Pin(2), 16) + self.np = neopixel.NeoPixel(machine.Pin(2), NUM_PIXEL) def update(self): - url = "%s/actors/update" % ADDRESS + url = "%s/actor/update" % ADDRESS level = ((self.color[0] << 16) + (self.color[1] << 8) + self.color[2]) & 0xffffff - data = {"id": self.id_a, "type": self.type_a, "levels": self.levels, "level": level} + data = {"id": self.id_a, "type": self.type_a, "maxLevel": self.maxLevel, "level": level} try: res = requests.post(url, json=data) content = res.json()