def build_message_32_bits(self): """ Builds a 32 bit message to send to Bpod box :rtype: list(float) """ # TODO find how many global timers are used """ thirty_two_bit_message = [i * self.hardware.cycle_frequency for i in self.state_timers] + \ [i * self.hardware.cycle_frequency for i in self.global_timers.timers] + \ [i * self.hardware.cycle_frequency for i in self.global_timers.on_set_delays] + \ [i * self.hardware.cycle_frequency for i in self.global_timers.loop_intervals] + \ self.global_counters.thresholds""" used_timers = range(self.highest_used_global_timer) used_counters = range(self.highest_used_global_counter) thirty_two_bit_message = ( [t * self.hardware.cycle_frequency for t in self.state_timers] + [ self.global_timers.timers[i] * self.hardware.cycle_frequency for i in used_timers ] + [ self.global_timers.on_set_delays[i] * self.hardware.cycle_frequency for i in used_timers ] + [ self.global_timers.loop_intervals[i] * self.hardware.cycle_frequency for i in used_timers ] + [self.global_counters.thresholds[i] for i in used_counters]) return ArduinoTypes.get_uint32_array(thirty_two_bit_message)
def build_message_global_timer(self): message = [] for i in range(self.total_states_added): message += (self.global_timers.triggers_matrix[i], ) for i in range(self.total_states_added): message += (self.global_timers.cancels_matrix[i], ) for i in range(self.highest_used_global_timer): message += (self.global_timers.onset_matrix[i], ) if self.hardware.n_global_timers > 16: return ArduinoTypes.get_uint32_array(message) elif self.hardware.n_global_timers > 8: return ArduinoTypes.get_uint16_array(message) else: return ArduinoTypes.get_uint8_array(message)