Esempio n. 1
0
    def build_header(self, run_asap=None, statemachine_body_size=0):
        message = [ord(SendMessageHeader.NEW_STATE_MATRIX)]
        message += [0 if run_asap is None else 1]
        message += [1 if self.use_255_back_signal else 0]

        return ArduinoTypes.get_uint8_array(
            message) + ArduinoTypes.get_uint16_array([statemachine_body_size])
Esempio n. 2
0
    def set_wrappoint(self, wrap_point):
        """
        Sets wrap point (number of tics in a half-rotation)

        :ivar int wrap_point: number of tics in a half-rotation.
        """
        ticks = self.__degrees_2_pos(wrap_point)
        self.arcom.write_array([self.COM_SETWRAPPOINT] + ArduinoTypes.get_uint16_array([ticks]))
        return self.arcom.read_uint8() == 1
Esempio n. 3
0
    def set_thresholds(self, thresholds):
        """
        Sets the thresholds values to trigger the events.

        :ivar list(int) thresholds: List, in maximum, of 6 thresholds to trigger events.
        """
        data = ArduinoTypes.get_uint8_array([self.COM_SETTHRESHOLDS, len(thresholds)])
        data += ArduinoTypes.get_uint16_array([self.__degrees_2_pos(thresh) for thresh in thresholds])
        self.arcom.write_array(data)
        return self.arcom.read_uint8() == 1
Esempio n. 4
0
    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)