Example #1
0
 def _try_to_establish_serial(self):
     try:
         print(Serial.list())
         self._serial = Serial(this, "/dev/tty.usbmodem1412", 9600)  # max rate?
         print("*** established serial connection")
     except Exception as exc:
         print("*** error attempting to connect to Pyboard : %s" %exc)
         self._serial = None
 def __init__(self):
     """Initialise the micro:bit, would be good to find it automatically."""
     portName = Serial.list()[len(Serial.list()) - 1]
     port = Serial(this, portName, 115200)
     port.bufferUntil(10)
     self.port = port
     self.state = {'a': False, 'b': False}
     self.data = {
         'name': u'None',
         'accelerometer': PVector(0, 0, -64),
         'button_a': {
             'pressed': False,
             'down': False,
             'up': False
         },
         'button_b': {
             'pressed': False,
             'down': False,
             'up': False
         }
     }