示例#1
0
    def __init__(self, data_pin, clock_pin,
                 bit_order=0, connection=None, A0=None):
        """Shifts out a byte of data one bit at a time.

        :param data_pin: the pin on which to output each bit (int or string)
        :param clock_pin: the pin to toggle once the dataPin has been set to the correct value (int or string)
        :param bit_order: which order to shift out the bits; either MSBFIRST or LSBFIRST.

        """
        if connection and hasattr(connection, 'shiftOut'):
            self._shiftOut_func = connection.shiftOut
        else:
            api = ArduinoApi(connection=connection)
            self._shiftOut_func = api.shiftOut
        self.bit_order = bit_order
        self.data_pin_number = to_pin_number(data_pin, A0)
        self.clock_pin_number = to_pin_number(clock_pin, A0)
示例#2
0
    def __init__(self,
                 data_pin,
                 clock_pin,
                 bit_order=0,
                 connection=None,
                 A0=None):
        """Shifts out a byte of data one bit at a time.

        :param data_pin: the pin on which to output each bit (int or string)
        :param clock_pin: the pin to toggle once the dataPin has been set to the correct value (int or string)
        :param bit_order: which order to shift out the bits; either MSBFIRST or LSBFIRST.

        """
        if connection and hasattr(connection, 'shiftOut'):
            self._shiftOut_func = connection.shiftOut
        else:
            api = ArduinoApi(connection=connection)
            self._shiftOut_func = api.shiftOut
        self.bit_order = bit_order
        self.data_pin_number = to_pin_number(data_pin, A0)
        self.clock_pin_number = to_pin_number(clock_pin, A0)
示例#3
0
文件: test.py 项目: bminton3/pi
def test_to_pin_number():
    eq_(to_pin_number(0), 0)
    eq_(to_pin_number(1, A0=None), 1)
    eq_(to_pin_number(20, A0=5), 20)

    eq_(to_pin_number('D0', A0=None), 0)
    eq_(to_pin_number('D7', A0=8), 7)
    exc_(ValueError, lambda: to_pin_number('D7', A0=7))
    eq_(to_pin_number('D20', A0=21), 20)

    eq_(to_pin_number('A0', A0=0), 0)
    eq_(to_pin_number('A0', A0=7), 7)
    eq_(to_pin_number('A15', A0=5), 20)
    exc_(ValueError, lambda: to_pin_number('A7', A0=None))

    class Dummy(object):
        pass
    obj = Dummy()
    obj.pin_number = 23
    eq_(to_pin_number(obj, A0=0), 23)
示例#4
0
def test_to_pin_number():
    eq_(to_pin_number(0), 0)
    eq_(to_pin_number(1, A0=None), 1)
    eq_(to_pin_number(20, A0=5), 20)

    eq_(to_pin_number('D0', A0=None), 0)
    eq_(to_pin_number('D7', A0=8), 7)
    exc_(ValueError, lambda: to_pin_number('D7', A0=7))
    eq_(to_pin_number('D20', A0=21), 20)

    eq_(to_pin_number('A0', A0=0), 0)
    eq_(to_pin_number('A0', A0=7), 7)
    eq_(to_pin_number('A15', A0=5), 20)
    exc_(ValueError, lambda: to_pin_number('A7', A0=None))

    class Dummy(object):
        pass

    obj = Dummy()
    obj.pin_number = 23
    eq_(to_pin_number(obj, A0=0), 23)