Ejemplo n.º 1
0
 def test_straight(self):
     with LED(20) as left, LED(21) as right:
         steering = Steering(left, right)
         left.on()
         right.off()
         self.assertEqual(True, steering.straight())
         self.assertEqual(0, left.value)
Ejemplo n.º 2
0
def main():
    this_folder = os.path.dirname(os.path.abspath(__file__))
    init_file = os.path.join(this_folder, 'config.cfg')
    config = configparser.ConfigParser()
    config.read(init_file)

    # define gpios
    ffw = LED(config.get('GPIOS', 'pin_emotor_ffd'))
    rwd = LED(config.get('GPIOS', 'pin_emotor_rwd'))

    left = LED(config.get('GPIOS', 'pin_steering_left'))
    right = LED(config.get('GPIOS', 'pin_steering_right'))

    e_motor = Emotor(ffw, rwd)
    steering = Steering(left, right)

    engine = Engine(e_motor, steering)
    engine.start()

    print('Ready to go!!!')
    go(engine)
Ejemplo n.º 3
0
 def test_turn_right(self):
     with LED(20) as left, LED(21) as right:
         steering = Steering(left, right)
         left.off()
         right.on()
         self.assertEqual(right.is_active, steering.turn_right().is_active)
Ejemplo n.º 4
0
 def test_get_status(self):
     with LED(20) as left, LED(21) as right:
         steering = Steering(left, right)
         left.on()
         self.assertEqual(1, left.value)
         self.assertEqual(1, steering.status())
Ejemplo n.º 5
0
 def test_left(self):
     with LED(20) as left, LED(21) as right:
         steering = Steering(left, right)
         self.assertEqual(left, steering.left)