Ejemplo n.º 1
0
 def _update_motors(self,
                    left_val,
                    right_val,
                    left_rev,
                    right_rev,
                    pwm_period=20000):
     period = tools.int_to_uint32(pwm_period)
     left_pwm = tools.int_to_uint16(left_val)
     right_pwm = tools.int_to_uint16(right_val)
     self.ubit._io_pin_pwm.value = [
         0, left_pwm[0], left_pwm[1], period[0], period[1], period[2],
         period[3], 1, right_pwm[0], right_pwm[1], period[0], period[1],
         period[2], period[3]
     ]
     self.ubit._pin_states = [0x08, left_rev, 0x0C, right_rev]
Ejemplo n.º 2
0
 def _update_motors(self,
                    left_val,
                    right_val,
                    left_rev,
                    right_rev,
                    pwm_period=20000):
     period = tools.int_to_uint32(pwm_period)
     left_pwm = tools.int_to_uint16(left_val)
     right_pwm = tools.int_to_uint16(right_val)
     self.pin_pwm_iface.WriteValue([
         0, left_pwm[0], left_pwm[1], period[0], period[1], period[2],
         period[3], 1, right_pwm[0], right_pwm[1], period[0], period[1],
         period[2], period[3]
     ], ())
     self._pin_states([0x08, left_rev, 0x0C, right_rev])
Ejemplo n.º 3
0
 def scroll_delay(self, delay=None):
     """
     Specifies a millisecond delay to wait for in between showing each
     character on the display.
     """
     if delay < 0:
         delay = 0
     elif delay > 2**16:
         delay = 2**16
     self._led_scroll.value = tools.int_to_uint16(delay)
Ejemplo n.º 4
0
 def scroll_delay(self, delay=None):
     """
     Specifies a millisecond delay to wait for in between showing each
     character on the display.
     """
     if delay < 0:
         delay = 0
     elif delay > 2**16:
         delay = 2**16
     self._led_scroll.value = tools.int_to_uint16(delay)
Ejemplo n.º 5
0
 def _update_motors(self, left_val, right_val,
                    left_rev, right_rev,
                    pwm_period=20000):
     period = tools.int_to_uint32(pwm_period)
     left_pwm = tools.int_to_uint16(left_val)
     right_pwm = tools.int_to_uint16(right_val)
     self.ubit._io_pin_pwm.value = [0,
                                    left_pwm[0],
                                    left_pwm[1],
                                    period[0],
                                    period[1],
                                    period[2],
                                    period[3],
                                    1,
                                    right_pwm[0],
                                    right_pwm[1],
                                    period[0],
                                    period[1],
                                    period[2],
                                    period[3]
                                    ]
     self.ubit._pin_states = [0x08, left_rev, 0x0C, right_rev]
Ejemplo n.º 6
0
 def _pin_pwm_control(self, pin, value, period):
     """
     Write only method to set the PWM control data
     :param pin: pin number [range 0-19]
     :param value: Value is in the range 0 to 1024, per the current DAL API
         (e.g. setAnalogValue). 0 means OFF.
     :param period: Period is in microseconds and is an unsigned integer
     :return:
     """
     byte_value = tools.int_to_uint16(value)
     byte_period = tools.int_to_uint32(period)
     self.pin_pwm_iface.WriteValue([
         pin, byte_value[0], byte_value[1], byte_period[0], byte_period[1],
         byte_period[2], byte_period[3]
     ], ())
Ejemplo n.º 7
0
    def display_scroll_delay(self, delay=None):
        """
        Specifies a millisecond delay to wait for in between showing each
        character on the display.
        """

        if delay is None:
            return int.from_bytes(self.scroll_iface.ReadValue(()),
                                  byteorder='little',
                                  signed=False)
        else:
            if delay < 0:
                delay = 0
            elif delay > 2**16:
                delay = 2**16
            self.scroll_iface.WriteValue(tools.int_to_uint16(delay), ())
Ejemplo n.º 8
0
    def _pin_pwm_control(self, pin, value, period):
        """
        Write only method to set the PWM control data
        :param pin: pin number [range 0-19]
        :param value: Value is in the range 0 to 1024, per the current DAL API
            (e.g. setAnalogValue). 0 means OFF.
        :param period: Period is in microseconds and is an unsigned integer
        :return:
        """
        pin_pwm_obj = tools.get_dbus_obj(constants.BLUEZ_SERVICE_NAME,
                                         self.io_pin_pwm_path)

        pin_pwm_iface = tools.get_dbus_iface(constants.GATT_CHRC_IFACE,
                                             pin_pwm_obj)
        byte_value = tools.int_to_uint16(value)
        byte_period = tools.int_to_uint32(period)
        pin_pwm_iface.WriteValue([
            pin, byte_value[0], byte_value[1], byte_period[0], byte_period[1],
            byte_period[2], byte_period[3]
        ], ())
Ejemplo n.º 9
0
    def display_scroll_delay(self, delay=None):
        """
        Specifies a millisecond delay to wait for in between showing each
        character on the display.
        """
        scroll_obj = tools.get_dbus_obj(constants.BLUEZ_SERVICE_NAME,
                                        self.led_scroll_path)

        scroll_iface = tools.get_dbus_iface(constants.GATT_CHRC_IFACE,
                                            scroll_obj)
        if delay is None:
            return int.from_bytes(scroll_iface.ReadValue(()),
                                  byteorder='little',
                                  signed=False)
        else:
            if delay < 0:
                delay = 0
            elif delay > 2**16:
                delay = 2**16
            scroll_iface.WriteValue(tools.int_to_uint16(delay), ())
Ejemplo n.º 10
0
 def _pin_pwm_control(self, data):
     """
     Write only method to set the PWM control data
     :param pin: pin number [range 0-19]
     :param value: Value is in the range 0 to 1024, per the current DAL API
         (e.g. setAnalogValue). 0 means OFF.
     :param period: Period is in microseconds and is an unsigned integer
     :return:
     """
     pin = data[0]
     value = data[1]
     period = data[2]
     byte_value = tools.int_to_uint16(value)
     byte_period = tools.int_to_uint32(period)
     self._io_pin_pwm.value = [pin,
                               byte_value[0],
                               byte_value[1],
                               byte_period[0],
                               byte_period[1],
                               byte_period[2],
                               byte_period[3]
                               ]