<commit_before>import time

from pingo.board import Board, DigitalPin, GroundPin, VddPin
from pingo.board import INPUT, OUTPUT


DIGITAL_PIN_MAP = {
    # pin_number: gpio_id
    3: 2,
    5: 3,
    7: 4,
    8: 14,
    10: 15,
    11: 17,
    12: 18,
    13: 27,
    15: 22,
    16: 23,
    18: 24,
    19: 10,
    21: 9,
    22: 25,
    23: 11,
    24: 8,
    26: 7,
}

GROUND_PINS = (6, 9, 14, 20, 25)
#VCC_PINS = (1, 2, 4, 17)

DIGITAL_PINS_PATH = '/sys/class/gpio/'
DIGITAL_PIN_TEMPLATE = DIGITAL_PINS_PATH + 'gpio{pin}/{operation}'
DIGITAL_PIN_MODES = {INPUT: 'in', OUTPUT: 'out'}
DIGITAL_PIN_OPERATIONS = ('direction', 'value')


class RaspberryPi(Board):
    """
    Reference:
    http://falsinsoft.blogspot.com.br/2012/11/access-gpio-from-linux-user-space.html
    """

    def __init__(self):
        Board.__init__(self)

        digital_pins = [
            DigitalPin(self, number, gpio_id)
                for number, gpio_id in DIGITAL_PIN_MAP.items()
        ]

        gnd_pins = [
            GroundPin(self, n) for n in GROUND_PINS
        ]

        vcc_pins = [
           VddPin(self, 1, "3.3V"),
           VddPin(self, 2, "5V"),
           VddPin(self, 3, "5V"),
           VddPin(self, 17, "3.3V"),
        ]

        pins = digital_pins + gnd_pins + vcc_pins
        self.add_pins(pins)

        # Exports all pins
        for n in DIGITAL_PIN_MAP.values():
            # 3rd arg: buffer_size=0 (a.k.a AutoFlush)
            with open(DIGITAL_PINS_PATH+'export', "wb", 0) as fp:
                fp.write(str(n))
            # Magic Sleep. Less then 0.13 it doesn't works.
            time.sleep(0.21)

    def cleanup(self):
        for gpio_id in (pin.gpio_id for pin in self.pins()):
            with open(DIGITAL_PINS_PATH+'unexport', "wb", 0) as fp:
                fp.write(str(n))<commit_msg>removed call to set_pin_mode from DigitalPin.__init__<commit_after>import time

from pingo.board import Board, DigitalPin, GroundPin, VddPin
from pingo.board import INPUT, OUTPUT


DIGITAL_PIN_MAP = {
    # pin_number: gpio_id
    3: 2,
    5: 3,
    7: 4,
    8: 14,
    10: 15,
    11: 17,
    12: 18,
    13: 27,
    15: 22,
    16: 23,
    18: 24,
    19: 10,
    21: 9,
    22: 25,
    23: 11,
    24: 8,
    26: 7,
}

GROUND_PINS = (6, 9, 14, 20, 25)
#VCC_PINS = (1, 2, 4, 17)

DIGITAL_PINS_PATH = '/sys/class/gpio/'
DIGITAL_PIN_TEMPLATE = DIGITAL_PINS_PATH + 'gpio{pin}/{operation}'
DIGITAL_PIN_MODES = {INPUT: 'in', OUTPUT: 'out'}
DIGITAL_PIN_OPERATIONS = ('direction', 'value')


class RaspberryPi(Board):
    """
    Reference:
    http://falsinsoft.blogspot.com.br/2012/11/access-gpio-from-linux-user-space.html
    """

    def __init__(self):
        Board.__init__(self)

        digital_pins = [
            DigitalPin(self, number, gpio_id)
                for number, gpio_id in DIGITAL_PIN_MAP.items()
        ]

        gnd_pins = [
            GroundPin(self, n) for n in GROUND_PINS
        ]

        vcc_pins = [
           VddPin(self, 1, "3.3V"),
           VddPin(self, 2, "5V"),
           VddPin(self, 3, "5V"),
           VddPin(self, 17, "3.3V"),
        ]

        pins = digital_pins + gnd_pins + vcc_pins
        self.add_pins(pins)

        # Exports all pins
        for n in DIGITAL_PIN_MAP.values():
            # 3rd arg: buffer_size=0 (a.k.a AutoFlush)
            with open(DIGITAL_PINS_PATH+'export', "wb", 0) as fp:
                fp.write(str(n))
            # Magic Sleep. Less then 0.13 it doesn't works.
            time.sleep(0.21)

    def cleanup(self):
        for gpio_id in (pin.gpio_id for pin in self.pins.values()):
            with open(DIGITAL_PINS_PATH+'unexport', "wb", 0) as fp:
                fp.write(str(n))
{'fraction_non_alphanumeric': 0.13253989721395726, 'fraction_numerical': 0.05301595888558291, 'mean_word_length': 2.0212418300653594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3575955', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1390, 'n_words': 326}