def __init__(self, port=None, baud_rate=MAX_BAUD_RATE): try: import pyfirmata except ImportError: msg = 'pingo.arduino.Arduino requires pyfirmata installed' raise SystemExit(msg) super(ArduinoFirmata, self).__init__() self.port = port self.baud_rate = baud_rate try: self.firmata = pyfirmata.Arduino(self.port, baudrate=self.baud_rate) except OSError: raise OSError('Could find %r' % self.port) self.serial_iterator = pyfirmata.util.Iterator(self.firmata) self.serial_iterator.daemon = True self.add_pins([ DigitalPin(self, location) for location in range(LEN_DIGITAL_PINS) ] + [ AnalogPin(self, 'A%s' % location, resolution=10) for location in range(LEN_ANALOG_PINS) ])
def __init__(self): self._add_pins([ DigitalPin(self, location) for location in range(self.LEN_DIGITAL_PINS) ] + [ AnalogPin(self, 'A%s' % location, resolution=bits) for location, bits in enumerate(self.ANALOG_PIN_RESOLUTIONS) ])
def __init__(self, port=None): try: from PyMata.pymata import PyMata except ImportError: msg = 'pingo.arduino.Arduino requires PyMata installed' raise ImportError(msg) super(ArduinoFirmata, self).__init__() self.port = port self.PyMata = PyMata(self.port) detected_digital_pins = len( self.PyMata._command_handler.digital_response_table) detected_analog_pins = len( self.PyMata._command_handler.analog_response_table) self._add_pins([ DigitalPin(self, location) for location in range(detected_digital_pins) ] + [ AnalogPin(self, 'A%s' % location, resolution=10) for location in range(detected_analog_pins) ])
def __init__(self, port=None): try: from PyMata.pymata import PyMata as PyMata # noqa except ImportError: msg = 'pingo.arduino.Arduino requires PyMata installed' raise ImportError(msg) super(ArduinoFirmata, self).__init__() self.port = port self.firmata_client = PyMata(self.port, verbose=VERBOSE) self.firmata_client.capability_query() time.sleep(10) # TODO: Find a small and safe value capability_query_results = self.firmata_client.get_capability_query_results( ) capability_dict = pin_list_to_board_dict(capability_query_results) self._add_pins([ DigitalPin(self, location) for location in capability_dict['digital'] ] + [PwmPin(self, location) for location in capability_dict['pwm']] + [ AnalogPin(self, 'A%s' % location, resolution=10) for location in capability_dict['analog'] ])