From e6e52ebe6e6c9a125221905e977867175c034a31 Mon Sep 17 00:00:00 2001 From: Mason Chen Date: Mon, 28 Mar 2022 17:34:39 +0800 Subject: [PATCH] add stop feature for nthu method --- nthu_controller/wire.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/nthu_controller/wire.py b/nthu_controller/wire.py index ba118a5..e2c21b1 100644 --- a/nthu_controller/wire.py +++ b/nthu_controller/wire.py @@ -19,13 +19,19 @@ def __init__(self) -> None: self.socket = ZMQSocket(port=8000) self.play = Play(self.socket) - self.load =Load(self.socket) + self.stop = Stop(self.socket) + self.load = Load(self.socket) self.restartController = RestartController(self.socket) - - self.restartController() - time.sleep(10) # wait for controller to restart - self.load({"path": "./data/"}) + self.darkAll = DarkAll(self.socket) + self.lightAll = LightAll(self.socket) + + log("Start to lightall") + self.lightAll({"color": "16711680", "alpha": "10"}) + + time.sleep(10) + self.darkAll() + self.load({"path": "./data/"}) def signalHandler(self, sig, frame): GPIO.cleanup() @@ -41,10 +47,14 @@ def button_pressed_down_callback(self, channel): # 軟體組從這裡開始加 def button_pressed_up_callback(self, channel): # Trigger only when delta_T is between 0.47 second ~ 0.53 second (the siganal should be at 0.5 second) - if (time.time() - self.recv_time > 0.47 and time.time() - self.recv_time < 0.53): + if (time.time() - self.recv_time > 0.3 and time.time() - self.recv_time < 0.7): log("Sending Play request ...") response = self.play({"start_time": 0, "delay_time": 0}) log("Response: " + response) + elif (time.time() - self.recv_time > 0.8 and time.time() - self.recv_time < 1.2): + log("Sending Stop request ...") + response = self.stop() + log("Response: " + response) # clean event listener and start listenting rising event GPIO.remove_event_detect(BUTTON_GPIO)