From 18e6004d2eb5606b02f91bfc7e125f65f6b31e31 Mon Sep 17 00:00:00 2001 From: han-lab Date: Wed, 21 Apr 2021 17:06:03 -0400 Subject: [PATCH] Fixed the global_timer CANCEL bug; allowing TRIGGERING and CANCELING more than one timers --- pybpodapi/state_machine/state_machine_base.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pybpodapi/state_machine/state_machine_base.py b/pybpodapi/state_machine/state_machine_base.py index b7f5303..e5d0457 100644 --- a/pybpodapi/state_machine/state_machine_base.py +++ b/pybpodapi/state_machine/state_machine_base.py @@ -238,12 +238,21 @@ def add_state( output_code == self.hardware.channels.events_positions.globalTimerTrigger ): - self.global_timers.triggers_matrix[state_name_idx] = 2 ** ( - output_value - 1 - ) + # self.global_timers.triggers_matrix[state_name_idx] = 2 ** ( + # output_value - 1 ) + + # output_value here could be a decimal integer representing (more than one) bits to TRIGGER + # E.g.: 3 = '11' = trigger timers 1 & 2 + self.global_timers.triggers_matrix[state_name_idx] = output_value if output_code == self.hardware.channels.events_positions.globalTimerCancel: - self.global_timers.cancels_matrix[output_value - 1] = 1 + + # self.global_timers.cancels_matrix[output_value - 1] = 1 # This doesn't work + + # output_value here could be a decimal integer representing (more than one) bits to CANCEL + # E.g.: 3 = '11' = cancel timers 1 & 2 + self.global_timers.cancels_matrix[state_name_idx] = output_value + self.output_matrix[state_name_idx].append((output_code, output_value))