conflict solved, maybe
This commit is contained in:
commit
b85e9eeb88
|
@ -842,3 +842,5 @@ Borg
|
|||
Adrino
|
||||
Arduino
|
||||
Nodalpunktadapter
|
||||
Informationslebenszyklusmanagement
|
||||
desoxyribonukleinsaeure
|
||||
|
|
|
@ -8,8 +8,8 @@ from threading import Thread
|
|||
|
||||
global mode
|
||||
mode="standby"
|
||||
global gametimeout
|
||||
gametimeout=0
|
||||
global timeout
|
||||
timeout=0
|
||||
global flipthread
|
||||
flipthread=None
|
||||
|
||||
|
@ -24,13 +24,14 @@ def on_connect(client, userdata, flags, rc):
|
|||
def on_message(client, userdata, msg):
|
||||
print(msg.topic + " " + str(msg.payload.decode("utf-8")))
|
||||
global mode
|
||||
global gametimeout
|
||||
global timeout
|
||||
global flipthread
|
||||
|
||||
if mode=="standby":
|
||||
gametimeout=0
|
||||
if mode=="standby" or mode=="inuse":
|
||||
|
||||
if msg.topic == "raum2/flipdot/scroll/set":
|
||||
mode="inuse"
|
||||
updateTimeout()
|
||||
payload = msg.payload.decode("utf-8")
|
||||
|
||||
if len(payload)>0 and (payload[0]).isdigit():
|
||||
|
@ -51,7 +52,7 @@ def on_message(client, userdata, msg):
|
|||
flipthread=Thread(target=flipdot.send_marquee, args=(text,speed))
|
||||
flipthread.start()
|
||||
|
||||
if msg.topic == "raum2/flipdot/text/set":
|
||||
if mode!="inuse" and msg.topic == "raum2/flipdot/text/set": #used to display information regulary (time etc). only available if flipdot not in use
|
||||
payload = msg.payload.decode("utf-8")
|
||||
|
||||
if flipthread is not None and flipthread.isAlive():
|
||||
|
@ -71,7 +72,9 @@ def on_message(client, userdata, msg):
|
|||
flipthread.start()
|
||||
|
||||
|
||||
if msg.topic == "raum2/flipdot/textFull/set":
|
||||
if msg.topic == "raum2/flipdot/textFull/set": #scale/break text automatically
|
||||
mode="inuse"
|
||||
updateTimeout()
|
||||
payload = msg.payload.decode("utf-8")
|
||||
if len(payload)>0 and payload[0]=='~':
|
||||
payload=payload[1:]
|
||||
|
@ -79,6 +82,8 @@ def on_message(client, userdata, msg):
|
|||
flipdot.send_textFull(payload)
|
||||
|
||||
if msg.topic == "raum2/flipdot/image/set":
|
||||
mode="inuse"
|
||||
updateTimeout()
|
||||
payload = msg.payload.decode("utf-8")
|
||||
print(payload)
|
||||
flipdot.send_bytes(payload)
|
||||
|
@ -90,12 +95,12 @@ def on_message(client, userdata, msg):
|
|||
|
||||
if payload=="#start":
|
||||
hangman.setup()
|
||||
gametimeout=int(round(time.time() * 1000))
|
||||
updateTimeout()
|
||||
client.publish("raum2/flipdot/hangman","started")
|
||||
mode="hangman"
|
||||
|
||||
elif (mode=="hangman") and (len(payload)>0): #try entered character
|
||||
gametimeout=int(round(time.time() * 1000))
|
||||
updateTimeout()
|
||||
trychar=payload[-1]
|
||||
gamestatus=hangman.step(trychar)
|
||||
client.publish("raum2/flipdot/hangman","char="+trychar.upper())
|
||||
|
@ -113,7 +118,10 @@ def on_message(client, userdata, msg):
|
|||
mode="standby"
|
||||
client.publish("raum2/flipdot/hangman","ended")
|
||||
|
||||
|
||||
def updateTimeout():
|
||||
global timeout
|
||||
timeout=int(round(time.time() * 1000))
|
||||
|
||||
|
||||
#flipdot = FlipdotSender("2001:67c:275c:a9::c", 2323)
|
||||
flipdot = FlipdotSender("localhost", 2323)
|
||||
|
@ -131,11 +139,15 @@ client.loop_start()
|
|||
|
||||
while True:
|
||||
millis = int(round(time.time() * 1000))
|
||||
if gametimeout!=0:
|
||||
if millis-120000 > gametimeout: #timeout
|
||||
if (timeout!=0) and (mode=="hangman"):
|
||||
if millis-120000 > timeout: #timeout
|
||||
print("Game Timeout")
|
||||
mode="standby"
|
||||
gametimeout=0
|
||||
timeout=0
|
||||
if (timeout!=0) and (mode=="inuse"): #inuse: flipdot was manually controlled, do not update time,pwr etc for a while
|
||||
if millis-10000 > timeout: #timeout
|
||||
mode="standby"
|
||||
timeout=0
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
|
|
Loading…
Reference in New Issue