revert temp

This commit is contained in:
NATURESPEAK 2022-04-04 10:48:02 +02:00
parent b2cc817911
commit 35caa1e0ad
2 changed files with 17 additions and 11 deletions

View File

@ -49,16 +49,17 @@ def broadcast_utterance(v, utterance):
global broadcast, exit, debug
if debug:
temp = format(v.temp, '.2f')
text = f"{v.name.upper()}: {temp}\n"
else:
text = f""
# if debug:
# temp = format(v.temp, '.2f')
# text = f"{v.name.upper()}: {temp}\n"
# else:
# text = f""
# Send all text to server to calculate bounds in advance
broadcast.utterance(utterance, v.calculate)
broadcast.utterance(utterance, v.calculate)
text = ""
broadcast.utterance(text, v.channel)
terminal_utterance(text)
time.sleep(2)
@ -164,7 +165,7 @@ def main() -> int:
if v.name == name:
print(f'{name} - {temp}')
v.temp = temp
broadcast.temperature(temp, v.temperature)
# broadcast.temperature(temp, v.temperature) # <-- doesn works because deadlocks in osc_process...
receiver = utterance.osc.OscReceiver(name="osc_receiver", host=conf['host_machinespeak'], port=conf['port_machinespeak'], callback_fn=receiver_cb)

View File

@ -3,6 +3,8 @@ from osc4py3 import oscbuildparse
from threading import Lock
mutex = Lock()
temp_mutex = Lock()
def start_osc():
osc_startup()
@ -38,9 +40,12 @@ class OscBroadcaster:
update()
def temperature(self, temp: float, channel: str):
msg = oscbuildparse.OSCMessage(channel, None, [temp])
osc_send(msg, self.name)
update()
global temp_mutex
with temp_mutex:
msg = oscbuildparse.OSCMessage(channel, None, [temp])
osc_send(msg, self.name)
osc_process()
class OscReceiver: