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