fix stuff

This commit is contained in:
interfisch 2021-07-01 20:47:21 +01:00
parent 506615f3a3
commit c219d7cf5f
1 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,3 @@
import subprocess
import paho.mqtt.client as mqtt
import time
@ -8,7 +7,7 @@ from adafruit_ht16k33 import segments
__TOPIC_BRIGHTNESS__ = "brightness"
__TOPIC_SCROLL_INTERVAL__ = "scroll_interval"
__TOPIC_TEXT__ = ""
__TOPIC_TEXT__ = "text"
class Controller:
connected = False
@ -19,7 +18,7 @@ class Controller:
self.scroll_interval = 0.25
self.text = ""
self.poscount = 0
# Create the I2C interface.
self.i2c = busio.I2C(board.SCL, board.SDA)
@ -39,7 +38,9 @@ class Controller:
self.mqtt.on_disconnect = self.on_disconnect
self.mqtt.connect(mqtt_host, mqtt_port)
self.topic = base_topic
self.display.print("ABCD")
def on_disconnect(self, client, userdata, rc):
print("MQTT disconnected")
@ -66,14 +67,13 @@ class Controller:
self.mqtt.publish(self.topic + "/" + __TOPIC_SCROLL_INTERVAL__, self.scroll_interval, 1 )
else:
print("error not >0.0: ", val)
if message.topic.endswith(__TOPIC_TEXT__ + "/set"):
self.text = msg
print("changed text to ", self.text)
self.mqtt.publish(self.topic + "/" + __TOPIC_TEXT__, self.text, 1 )
def on_connect(self, client, userdata, flags, rc):
print("Connected to MQTT Broker")
@ -88,9 +88,9 @@ class Controller:
self.mqtt.loop()
if self.display is not None:
self.display.print(self.text[self.poscount])
##display.print(self.text[self.poscount])
display.print(42)
self.poscount += 1
self.poscount %= len(self.text)
time.sleep(self.scroll_interval)