Example #1
0
    def __init__(self):
        global mraa
        try:
            import mraa as mraa
        except ImportError:
            raise ImportError('pingo.galileo.Galileo2 requires mraa installed')

        super(Galileo2, self).__init__()

        self.PIN_MODES = {
            pingo.IN: mraa.DIR_IN,
            pingo.OUT: mraa.DIR_OUT,
        }

        self.PIN_STATES = {
            pingo.HIGH: 1,
            pingo.LOW: 0,
        }

        pwm_pin_numbers = [3, 5, 6, 9, 10, 11, 13]
        digital_pin_numbers = [1, 2, 4, 7, 8, 12]

        self._add_pins(
            [pingo.PwmPin(self, location) for location in pwm_pin_numbers] + [
                pingo.DigitalPin(self, location)
                for location in digital_pin_numbers
            ] + [
                pingo.AnalogPin(self, 'A' + location, 12)
                for location in '012345'
            ])

        self.mraa_pins, self.mraa_analogs, self.mraa_pwms = {}, {}, {}
Example #2
0
    def __init__(self):
        global grovepi
        try:
            import grovepi as grovepi  # noqa
        except ImportError:
            raise ImportError('pingo.rpi.GrovePi requires grovepi installed')

        super(GrovePi, self).__init__()

        # location: gpio_id
        self.ANALOG_PINS = {'A0': 14, 'A1': 15, 'A2': 16, 'A3': 17}

        self.PIN_MODES = {pingo.IN: 'INPUT', pingo.OUT: 'OUTPUT'}

        self.PIN_STATES = {pingo.HIGH: 1, pingo.LOW: 0}

        pwm_pins = [3, 5, 6]
        digital_pins = [0, 1, 2, 4, 7, 8, 9]

        self._add_pins(
            [pingo.PwmPin(self, location) for location in pwm_pins] +
            [pingo.DigitalPin(self, location) for location in digital_pins] + [
                pingo.AnalogPin(self, location, 10, gpio_id)
                for location, gpio_id in self.ANALOG_PINS.items()
            ])
Example #3
0
    def __init__(self, host, verbose=False):

        super(ArduinoYun, self).__init__()

        self.yun = YunBridge(host, verbose)

        self.PIN_MODES = {
            pingo.IN: 'input',
            pingo.OUT: 'output',
        }

        self.PIN_STATES = {
            pingo.HIGH: 1,
            pingo.LOW: 0,
        }

        pwm_pin_numbers = [3, 5, 6, 9, 10, 11, 13]
        digital_pin_numbers = [0, 1, 2, 4, 7, 8, 12]

        self._add_pins(
            [pingo.PwmPin(self, location) for location in pwm_pin_numbers] + [
                pingo.DigitalPin(self, location)
                for location in digital_pin_numbers
            ] + [
                pingo.AnalogPin(self, 'A' + location, 10)
                for location in '012345'
            ])
Example #4
0
    def __init__(self):
        global mraa
        try:
            import mraa as mraa
        except ImportError:
            raise ImportError('pingo.galileo.Galileo2 requires mraa installed')

        super(Galileo2, self).__init__()

        self.PIN_MODES = {
            pingo.IN: mraa.DIR_IN,
            pingo.OUT: mraa.DIR_OUT,
        }

        self.PIN_STATES = {
            pingo.HIGH: 1,
            pingo.LOW: 0,
        }

        self._add_pins([
            pingo.PwmPin(self, location)
            for location in [3, 5, 6, 9, 10, 11, 13]
        ] + [
            pingo.DigitalPin(self, location)
            for location in [1, 2, 4, 7, 8, 12]
        ] + [
            pingo.AnalogPin(self, 'A' + location, 12) for location in '012345'
        ])

        self.mraa_pins = {
            location: mraa.Gpio(location)
            for location in range(1, 14)
        }

        self.mraa_analogs = {
            'A' + location: mraa.Aio(int(location))
            for location in '012345'
        }

        self.mraa_pwms = {
            location: mraa.Pwm(location)
            for location in [3, 5, 6, 9, 10, 11, 13]
        }
Example #5
0
    def __init__(self, filepath=None):
        super(GhostBoard, self).__init__()

        # Arduino ATmega168/328 pin mapping
        pins = set([
            pingo.DigitalPin(self, 0),
            pingo.DigitalPin(self, 1),
            pingo.DigitalPin(self, 2),
            pingo.PwmPin(self, 3),
            pingo.DigitalPin(self, 4),
            pingo.VccPin(self, 'VCC', 5.0),
            pingo.GroundPin(self, 'GND'),
            pingo.PwmPin(self, 5),
            pingo.PwmPin(self, 6),
            pingo.DigitalPin(self, 7),
            pingo.DigitalPin(self, 8),
            pingo.AnalogPin(self, 'A5', 10),
            pingo.AnalogPin(self, 'A4', 10),
            pingo.AnalogPin(self, 'A3', 10),
            pingo.AnalogPin(self, 'A2', 10),
            pingo.AnalogPin(self, 'A1', 10),
            pingo.AnalogPin(self, 'A0', 10),
            pingo.GroundPin(self, 'GND'),
            pingo.VccPin(self, 'AREF', 5.0),
            pingo.VccPin(self, 'AVCC', 5.0),
            pingo.DigitalPin(self, 12),
            pingo.DigitalPin(self, 13),
            pingo.PwmPin(self, 11),
            pingo.PwmPin(self, 10),
            pingo.PwmPin(self, 9),
        ])

        self._add_pins(pins)

        self._pin_states = pingo.util.StrKeyDict()
        # All pins start on LOW
        # FIXME: use "LOW" instead of 0
        for location, pin in self.pins.iteritems():
            self._pin_states[location] = 0 if hasattr(pin, 'state') else None

        # Pin 8 starts on HIGH
        self._pin_states[8] = 1