Exemplo n.º 1
0
def test_motor_counter_state():
    with ftdu.FtDuino() as ftd:
        #TODO: The tests motor_left and motor_right may change the state of the counters.
        # Usually we should be able to test: assert not ftd.m1_counter_active
        assert ftd.m1_counter_active in (True, False)
        assert ftd.m2_counter_active in (True, False)
        assert ftd.m3_counter_active in (True, False)
        assert ftd.m4_counter_active in (True, False)
Exemplo n.º 2
0
def test_counter_props():
    with ftdu.FtDuino() as ftd:
        ftd.c1_clear()
        ftd.c2_clear()
        ftd.c3_clear()
        ftd.c4_clear()
        assert ftd.c1 == 0
        assert ftd.c2 == 0
        assert ftd.c3 == 0
        assert ftd.c4 == 0
Exemplo n.º 3
0
def test_output_props():
    with ftdu.FtDuino() as ftd:
        ftd.o1 = True
        ftd.o2 = False
        ftd.o3 = ftdu.OFF
        ftd.o4 = ftdu.HIGH
        ftd.o5 = ftdu.LOW
        ftd.o6 = ftdu.HIGH, ftdu.MAX / 2
        ftd.o7 = True
        ftd.o8 = False
Exemplo n.º 4
0
def test_input_props():
    with ftdu.FtDuino() as ftd:
        assert ftd.i1 == 0
        assert ftd.i2 == 0
        assert ftd.i3 == 0
        assert ftd.i4 == 0
        assert ftd.i5 == 0
        assert ftd.i6 == 0
        assert ftd.i7 == 0
        assert ftd.i8 == 0
Exemplo n.º 5
0
def example():
    with ftdu.FtDuino() as ftd:
        setup(ftd)
        while True:
            loop(ftd)
Exemplo n.º 6
0
def test_counter_mode():
    with ftdu.FtDuino() as ftd:
        ftd.c1_mode = ftdu.COUNTER_EDGE_NONE
        ftd.c2_mode = ftdu.COUNTER_EDGE_RISING
        ftd.c3_mode = ftdu.COUNTER_EDGE_FALLING
        ftd.c4_mode = ftdu.COUNTER_EDGE_ANY
Exemplo n.º 7
0
def test_counter_states():
    with ftdu.FtDuino() as ftd:
        assert not ftd.c1_state
        assert not ftd.c2_state
        assert not ftd.c3_state
        assert not ftd.c4_state
Exemplo n.º 8
0
def test_counter_clear():
    with ftdu.FtDuino() as ftd:
        ftd.c1_clear()
        ftd.c2_clear()
        ftd.c3_clear()
        ftd.c4_clear()
Exemplo n.º 9
0
def test_output_props_illegal2():
    with ftdu.FtDuino() as ftd:
        with pytest.raises(ValueError) as ex:
            ftd.o1 = 'true'
Exemplo n.º 10
0
def test_output_props_illegal():
    with ftdu.FtDuino() as ftd:
        with pytest.raises(TypeError) as ex:
            ftd.o1 = 42
Exemplo n.º 11
0
def test_input_mode_error():
    with ftdu.FtDuino() as ftd:
        with pytest.raises(ValueError) as ex:
            ftd.i1_mode = 'illegal'
Exemplo n.º 12
0
def test_input_mode():
    with ftdu.FtDuino() as ftd:
        ftd.i1_mode = ftdu.INPUT_MODE_RESISTANCE
        ftd.i1_mode = ftdu.INPUT_MODE_VOLTAGE
        ftd.i1_mode = ftdu.INPUT_MODE_SWITCH
Exemplo n.º 13
0
def test_motor_right():
    with ftdu.FtDuino() as ftd:
        ftd.m1_right()
        ftd.m2_right(steps=23)
        ftd.m3_right(pwm=ftdu.MAX)
        ftd.m4_right(pwm=ftdu.MAX / 2, steps=47)
Exemplo n.º 14
0
def test_led():
    with ftdu.FtDuino() as ftd:
        ftd.led = True
        ftd.led = False
Exemplo n.º 15
0
def test_ultrasonic():
    with ftdu.FtDuino() as ftd:
        assert -1 == ftd.ultrasonic
Exemplo n.º 16
0
def test_counter_mode_illegal():
    with ftdu.FtDuino() as ftd:
        with pytest.raises(ValueError) as ex:
            ftd.c1_mode = 'illegal'