Esempio n. 1
0
 def makeLightSensor(port):
     try:
         p = ev3dev.LegoPort(port)
         p.set_device = 'lego-nxt-light'
         s = ev3dev.LightSensor(port)
     except (AttributeError, OSError):
         logger.info('no light sensor connected to port [%s]', port)
         s = None
     return s
Esempio n. 2
0
 def makeSoundSensor(port):
     try:
         p = ev3dev.LegoPort(port)
         p.set_device = 'lego-nxt-sound'
         s = ev3dev.SoundSensor(port)
     except (AttributeError, OSError):
         logger.info('no sound sensor connected to port [%s]', port)
         s = None
     return s
Esempio n. 3
0
 def makeOtherConsumer(port, regulated, direction, side=None):
     try:
         lp = ev3dev.LegoPort(port)
         lp.mode = 'dc-motor'
         # https://github.com/ev3dev/ev3dev-lang-python/issues/234
         # some time is needed to set the permissions for the new attributes
         time.sleep(0.5)
         m = ev3dev.DcMotor(address=port)
     except (AttributeError, OSError):
         logger.info('no other consumer connected to port [%s]', port)
         logger.exception("HW Config error")
         m = None
     return m
Esempio n. 4
0
 def resetAllOutputs(self):
     for port in (ev3dev.OUTPUT_A, ev3dev.OUTPUT_B, ev3dev.OUTPUT_C,
                  ev3dev.OUTPUT_D):
         lp = ev3dev.LegoPort(port)
         lp.mode = 'auto'