Compare commits
18 Commits
Author | SHA1 | Date |
---|---|---|
interfisch | 83ca29d94e | |
interfisch | 606207d27c | |
interfisch | 9c607bf901 | |
interfisch | b85e9eeb88 | |
interfisch | ceb0f3dc46 | |
interfisch | 9dcedb1c45 | |
interfisch | f9e69a8bb6 | |
interfisch | e0fc46af48 | |
interfisch | ee3915b62e | |
Stefan Kinzel | e2ccafac89 | |
Stefan Kinzel | 0686597fb2 | |
Stefan Kinzel | c9d48ca25a | |
Stefan Kinzel | 961538b940 | |
Stefan Kinzel | 3e1405856d | |
Stefan Kinzel | 419aa5e3f5 | |
Stefan Kinzel | 21ab8e990b | |
Stefan Kinzel | 2794b5c762 | |
Stefan Kinzel | b32c78d4dc |
|
@ -134,17 +134,6 @@ class FlipdotSender(object):
|
||||||
|
|
||||||
self._sock.sendto(bytes(packet), (self._udphost, self._udpport))
|
self._sock.sendto(bytes(packet), (self._udphost, self._udpport))
|
||||||
|
|
||||||
def send_binimage(self, data,fadespeed=0): #works like send_bytes, but enables fadeanimation
|
|
||||||
image = Image.new("RGBA", self._img_size, FlipdotSender.C_BLACK)
|
|
||||||
draw = ImageDraw.Draw(image)
|
|
||||||
draw.fontmode = "1"
|
|
||||||
|
|
||||||
for i,d in enumerate(data):
|
|
||||||
if d=="1":
|
|
||||||
draw.point((i%self._img_size[0],int(i/self._img_size[0])), fill=FlipdotSender.C_WHITE)
|
|
||||||
|
|
||||||
self._send(image,fadespeed)
|
|
||||||
|
|
||||||
|
|
||||||
def send_text(self, text,fadespeed=0):
|
def send_text(self, text,fadespeed=0):
|
||||||
image = Image.new("RGBA", self._img_size, FlipdotSender.C_BLACK)
|
image = Image.new("RGBA", self._img_size, FlipdotSender.C_BLACK)
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Hangman(object):
|
||||||
self._fo_word2= (15, 7) #(15,7)
|
self._fo_word2= (15, 7) #(15,7)
|
||||||
#self._wordlist="/home/pi/mqtt-to-flipdot/hangman/wordlists/nomenliste_de.txt"
|
#self._wordlist="/home/pi/mqtt-to-flipdot/hangman/wordlists/nomenliste_de.txt"
|
||||||
#self._wordlist="/home/pi/mqtt-to-flipdot/hangman/wordlists/wordsonly.txt"
|
#self._wordlist="/home/pi/mqtt-to-flipdot/hangman/wordlists/wordsonly.txt"
|
||||||
self._wordlist="/root/mqtt-to-flipdot/hangman/wordlists/wordsonly.txt" #<- on flipdot pi
|
self._wordlist="/root/mqtt-to-flipdot/hangman/wordlists/wordsonly.txt"
|
||||||
|
|
||||||
#self._wordlist="/home/pi/mqtt-to-flipdot/hangman/wordlists/nerdwords.txt"
|
#self._wordlist="/home/pi/mqtt-to-flipdot/hangman/wordlists/nerdwords.txt"
|
||||||
#self._wordlist="./hangman/wordlists/nerdwords.txt" #<- use for local testing
|
#self._wordlist="./hangman/wordlists/nerdwords.txt" #<- use for local testing
|
||||||
|
@ -58,7 +58,7 @@ class Hangman(object):
|
||||||
self._g_chars="" #used characters
|
self._g_chars="" #used characters
|
||||||
|
|
||||||
# self._hmdir="/home/pi/mqtt-to-flipdot/hangman/stdhm/"
|
# self._hmdir="/home/pi/mqtt-to-flipdot/hangman/stdhm/"
|
||||||
self._hmdir="/root/mqtt-to-flipdot/hangman/stdhm/" #<- on flipdot pi
|
self._hmdir="/root/mqtt-to-flipdot/hangman/stdhm/"
|
||||||
#self._hmdir="./hangman/stdhm/" #<- use for local testing
|
#self._hmdir="./hangman/stdhm/" #<- use for local testing
|
||||||
|
|
||||||
self._hmimg=[]
|
self._hmimg=[]
|
||||||
|
|
|
@ -72,55 +72,21 @@ def on_message(client, userdata, msg):
|
||||||
flipthread.start()
|
flipthread.start()
|
||||||
|
|
||||||
|
|
||||||
if mode!="inuse" and msg.topic == "raum2/flipdot/textFull/set": #scale/break text automatically
|
if msg.topic == "raum2/flipdot/textFull/set": #scale/break text automatically
|
||||||
#mode="inuse"
|
mode="inuse"
|
||||||
#updateTimeout()
|
updateTimeout()
|
||||||
payload = msg.payload.decode("utf-8")
|
payload = msg.payload.decode("utf-8")
|
||||||
|
|
||||||
if flipthread is not None and flipthread.isAlive():
|
|
||||||
flipdot.stopAnimation()
|
|
||||||
while flipthread.isAlive():
|
|
||||||
flipdot.stopAnimation() #try to stop animation
|
|
||||||
time.sleep(0.1)
|
|
||||||
flipthread.join()
|
|
||||||
|
|
||||||
if len(payload)>0 and payload[0]=='~':
|
if len(payload)>0 and payload[0]=='~':
|
||||||
payload=payload[1:]
|
payload=payload[1:]
|
||||||
#flipdot.send_textFull(payload,50)
|
flipdot.send_textFull(payload,50)
|
||||||
flipthread=Thread(target=flipdot.send_textFull, args=(payload,64))
|
flipdot.send_textFull(payload)
|
||||||
else:
|
|
||||||
#flipdot.send_textFull(payload)
|
|
||||||
flipthread=Thread(target=flipdot.send_textFull, args=(payload,))
|
|
||||||
|
|
||||||
flipthread.start()
|
|
||||||
|
|
||||||
if msg.topic == "raum2/flipdot/image/set":
|
if msg.topic == "raum2/flipdot/image/set":
|
||||||
'''
|
|
||||||
mode="inuse"
|
mode="inuse"
|
||||||
updateTimeout()
|
updateTimeout()
|
||||||
payload = msg.payload.decode("utf-8")
|
payload = msg.payload.decode("utf-8")
|
||||||
print(payload)
|
print(payload)
|
||||||
flipdot.send_bytes(payload)
|
flipdot.send_bytes(payload)
|
||||||
'''
|
|
||||||
payload = msg.payload.decode("utf-8")
|
|
||||||
|
|
||||||
if flipthread is not None and flipthread.isAlive():
|
|
||||||
flipdot.stopAnimation()
|
|
||||||
while flipthread.isAlive():
|
|
||||||
flipdot.stopAnimation() #try to stop animation
|
|
||||||
time.sleep(0.1)
|
|
||||||
flipthread.join()
|
|
||||||
|
|
||||||
if len(payload)>0 and payload[0]=='~':
|
|
||||||
payload=payload[1:]
|
|
||||||
#flipdot.send_textFull(payload,50)
|
|
||||||
flipthread=Thread(target=flipdot.send_binimage, args=(payload,64))
|
|
||||||
else:
|
|
||||||
#flipdot.send_textFull(payload)
|
|
||||||
flipthread=Thread(target=flipdot.send_binimage, args=(payload,))
|
|
||||||
|
|
||||||
flipthread.start()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +133,7 @@ hangman= Hangman("localhost", 2323,flipdot)
|
||||||
client = mqtt.Client()
|
client = mqtt.Client()
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_message = on_message
|
client.on_message = on_message
|
||||||
client.connect("mqtt.ctdo.de", 1883, 60)
|
client.connect("raum.ctdo.de", 1883, 60)
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,3 +150,5 @@ while True:
|
||||||
timeout=0
|
timeout=0
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue