diff --git a/integration/Window.py b/integration/Window.py index fc8645fa5e6f3379bab329ea86f85c7903e4cfff..d6c1bc666d81eb22233dc6b274087a5da230e26c 100644 --- a/integration/Window.py +++ b/integration/Window.py @@ -924,6 +924,7 @@ class gameScreen: self.frame2.grid(row=1, column=0, padx=10, pady=10, sticky="nsew") if 'COM5' in self.ports : + self.last_printEMG_time = time() self.arduino_EMG = serial.Serial('COM5', 9600, timeout=1) self.outer_EMG_label = tk.Label(self.frame2, text=f"EMG for Extensor Carpi Ulnaris is :") self.outer_EMG_label.config(font=("Arial", 12)) @@ -954,11 +955,11 @@ class gameScreen: self.last_averageRoll = 0 self.last_averageyaw = 0 self.last_averagePitch = 0 - self.averageroll = 0 self.averageyaw = 0 self.averagepitch = 0 self.last_print_time = time() + self.last_EMG_Command=None self.arduino = serial.Serial('COM6', 115200) self.roll_label = tk.Label(self.frame1, text="roll is : ") self.roll_label.config(font=("Arial", 12)) @@ -1016,8 +1017,18 @@ class gameScreen: ges_predictions = "Hand Close" if predictions == 0: ges_predictions = "Unknown" - self.gesture_predict.config(text=f"{ges_predictions}") - self.send_command_to_unity(f"Hand :{ges_predictions}") + self.gesture_predict.config(text=f"{ges_predictions}") + self.send_command_to_unity(f"Hand :{ges_predictions}") + #current_time_EMG = time() + #if ges_predictions=="Hand Open": + #if current_time_EMG - self.last_print_time >= 0.01: + #if ges_predictions!=self.last_EMG_Command: + #self.send_command_to_unity(f"Hand :{ges_predictions}") + #self.last_print_time = current_time_EMG + #self.last_EMG_Command=ges_predictions + + + except Exception as e: