Example #1
0
    def __init__(self):
        super(GhostBoard, self).__init__()

        pins = set([
            pingo.GroundPin(self, 1),
            pingo.VddPin(self, 2, 5.0),
            pingo.DigitalPin(self, 3),
            pingo.DigitalPin(self, 4),
            pingo.DigitalPin(self, 5),
            pingo.DigitalPin(self, 6),
            pingo.DigitalPin(self, 7),
            pingo.DigitalPin(self, 8),
            pingo.DigitalPin(self, 9),
            pingo.DigitalPin(self, 10),
            pingo.DigitalPin(self, 11),
            pingo.DigitalPin(self, 12),
            pingo.DigitalPin(self, 13),
            pingo.DigitalPin(self, 14),
            pingo.GroundPin(self, 15),
            pingo.VddPin(self, 16, 3.3),
        ])

        self.add_pins(pins)

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

        # Pin 8 starts on HIGH
        pin_states[8] = 1

        with open(PIN_STATES_FILEPATH, 'w') as fp:
            json.dump(pin_states, fp, indent=4)
Example #2
0
    def __init__(self, filepath=None):
        super(GhostBoard, self).__init__()

        pins = set([
            pingo.GroundPin(self, 1),
            pingo.VccPin(self, 2, 5.0),
            pingo.DigitalPin(self, 3),
            pingo.DigitalPin(self, 4),
            pingo.DigitalPin(self, 5),
            pingo.DigitalPin(self, 6),
            pingo.DigitalPin(self, 7),
            pingo.DigitalPin(self, 8),
            pingo.DigitalPin(self, 9),
            pingo.DigitalPin(self, 10),
            pingo.DigitalPin(self, 11),
            pingo.DigitalPin(self, 12),
            pingo.DigitalPin(self, 13),
            pingo.DigitalPin(self, 14),
            pingo.GroundPin(self, 15),
            pingo.VccPin(self, 16, 3.3),
        ])

        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
Example #3
0
File: rpi.py Project: iedame/pingo
    def __init__(self):
        global GPIO
        try:
            import RPi.GPIO as GPIO
        except ImportError:
            raise SystemExit('pingo.rpi requires RPi.GPIO installed')

        super(RaspberryPi, self).__init__()
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(True)

        pins = [
            pingo.VddPin(self, 1, 3.3),
            pingo.VddPin(self, 2, 5.0),
            pingo.VddPin(self, 4, 5.0),
            pingo.VddPin(self, 17, 3.3)
        ]

        pins += [pingo.GroundPin(self, n) for n in [6, 9, 14, 20, 25]]

        pins += [
            pingo.DigitalPin(self, location, gpio_id)
            for location, gpio_id in DIGITAL_PIN_MAP.items()
        ]

        self.add_pins(pins)
Example #4
0
 def __init__(self, server):
     self.server = server
     response = urlopen(server)
     if response.code != 200:
         raise Exception(u'HTTPBoard not found on server {}'.format(server))
     response = json.load(response)
     pins = json.loads(response['pins'])
     gpio_pins = []
     ground_pins = []
     vcc_pins = []
     pwm_pins = []
     for pin, value in pins.items():
         # TODO: serialize the pin (and/or the board) to do this in a better way
         if 'GroundPin' in value:
             ground_pins.append(pingo.GroundPin(self, pin))
         elif 'VccPin' in value:
             voltage = float(value[:-2].split(' ')[1])
             vcc_pins.append(pingo.VccPin(self, pin, voltage))
         elif 'PwmPin' in value:
             gpio_id = value.split(' ')[1].split('@')[0]
             pwm_pins.append(pingo.PwmPin(self, pin, gpio_id))
         elif 'DigitalPin' in value:
             gpio_id = value.split(' ')[1].split('@')[0]
             gpio_pins.append(pingo.DigitalPin(self, pin, gpio_id))
     self._add_pins(ground_pins + vcc_pins + gpio_pins + pwm_pins)
Example #5
0
    def __init__(self):
        global GPIO
        try:
            import RPi.GPIO as GPIO
        except ImportError:
            raise ImportError(
                'pingo.rpi.RaspberryPi requires RPi.GPIO installed')

        super(RaspberryPi, self).__init__()
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(True)

        pins = [
            pingo.VccPin(self, 1, 3.3),
            pingo.VccPin(self, 2, 5.0),
            pingo.VccPin(self, 4, 5.0),
            pingo.VccPin(self, 17, 3.3)
        ]

        pins += [pingo.GroundPin(self, n) for n in self.GROUNDS_LIST]

        pins += [
            pingo.PwmPin(self, location, gpio_id)
            for location, gpio_id in self.PWM_PIN_MAP.items()
        ]

        self._add_pins(pins)
        self._rpi_pwm = {}
Example #6
0
    def __init__(self):
        global GPIO
        try:
            import Adafruit_BBIO.GPIO as GPIO
        except ImportError:
            raise ImportError(self._import_error_msg)

        super(BeagleBoneBlack, self).__init__()

        self.PIN_MODES = {
            pingo.IN: GPIO.IN,
            pingo.OUT: GPIO.OUT,
        }

        self.PIN_STATES = {
            pingo.HIGH: GPIO.HIGH,
            pingo.LOW: GPIO.LOW,
        }

        gpio_pins = [
            pingo.DigitalPin(self, location, gpio_id)
            for location, gpio_id in self.PINS.items()
        ]
        ground_pins = [
            pingo.GroundPin(self, location) for location in self.GND_PINS
        ]
        vcc_pins = [
            pingo.VccPin(self, location, voltage)
            for location, voltage in self.VCC_PINS.items()
        ]

        self._add_pins(gpio_pins + ground_pins + vcc_pins)
Example #7
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
Example #8
0
    def __init__(self):
        super(GhostBoard, self).__init__()

        pins = {
            pingo.GroundPin(self, 1),
            pingo.VddPin(self, 2, 5.0),
            pingo.DigitalPin(self, 7),
            pingo.DigitalPin(self, 8),
            pingo.DigitalPin(self, 13),
        }

        self.add_pins(pins)

        pin_states = {
            # All pins start on LOW FIXME: use "LOW" instead of 0
            location: 0 if hasattr(pin, 'state') else None
            for location, pin in self.pins.iteritems()
        }

        # Pin 8 starts on HIGH
        pin_states[8] = 1

        with open(PIN_STATES_FILEPATH, 'w') as fp:
            json.dump(pin_states, fp, indent=4)