Esempio n. 1
0
def test_pin_range():
    a = ArduinoTree()
    eq_(a.pin.count, 20)
    eq_(a.pin.count_analog, 6)
    eq_(a.pin.count_digital, 14)

#     eq_(a.pin.get.range_all, range(0, 20))
#     eq_(a.pin.get.range_analog, range(14, 20))
#     eq_(a.pin.get.range_digital, range(0, 14))

    a.pin.get('A5')
    exc_(ValueError, lambda: a.pin.get('A6'))
    exc_(ValueError, lambda: a.pin.get('D14'))
Esempio n. 2
0
def test_pin_range():
    a = ArduinoTree()
    eq_(a.pin.count, 20)
    eq_(a.pin.count_analog, 6)
    eq_(a.pin.count_digital, 14)

    #     eq_(a.pin.get.range_all, range(0, 20))
    #     eq_(a.pin.get.range_analog, range(14, 20))
    #     eq_(a.pin.get.range_digital, range(0, 14))

    a.pin.get('A5')
    exc_(ValueError, lambda: a.pin.get('A6'))
    exc_(ValueError, lambda: a.pin.get('D14'))
Esempio n. 3
0
File: test.py Progetto: 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)
Esempio n. 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)
Esempio n. 5
0
def test_registers():
    a = ArduinoTree()
    print(a.register.names)
    ok_(len(a.register.names) > 77)

    eq_(a.register.get('DDRB').read_value(), 0)
    eq_(a.register.get('DDRB').value, 0)
    exc_(ValueError, lambda x: a.register.get('xxx').value, 0)

    a.register.get('DDRB').write_value(5)
    eq_(a.register.get('DDRB').value, 5)
    a.register.get('DDRB').value = 3
    eq_(a.register.get('DDRB').value, 3)
    a.register.get('DDRB').write_value(0)

    eq_(a.register.get('DDRB').address, 0x24)
    eq_(a.register.get('DDRB').name, 'DDRB')
    eq_(a.register.get('DDRB').size, 1)

    # 9 bit
    eq_(a.register.get('EEAR').size, 2)
    a.register.get('EEAR').value = 511
    eq_(a.register.get('EEAR').value, 511)
Esempio n. 6
0
def test_registers():
    a = ArduinoTree()
    print (a.register.names)
    ok_(len(a.register.names) > 77)

    eq_(a.register.get('DDRB').read_value(), 0)
    eq_(a.register.get('DDRB').value, 0)
    exc_(ValueError, lambda x: a.register.get('xxx').value, 0)

    a.register.get('DDRB').write_value(5)
    eq_(a.register.get('DDRB').value, 5)
    a.register.get('DDRB').value = 3
    eq_(a.register.get('DDRB').value, 3)
    a.register.get('DDRB').write_value(0)

    eq_(a.register.get('DDRB').address, 0x24)
    eq_(a.register.get('DDRB').name, 'DDRB')
    eq_(a.register.get('DDRB').size, 1)

    # 9 bit
    eq_(a.register.get('EEAR').size, 2)
    a.register.get('EEAR').value = 511
    eq_(a.register.get('EEAR').value, 511)