<commit_before>import Adafruit_BBIO.GPIO as gpio
from time import sleep


def setup_pin_list():
    pins = []
    base_name = "P8_"
    for x in range(7,20):
        if x < 10:
            pins.append(base_name + '0' + str(x))
        else:
            pins.append(base_name + str(x))

    print(pins)
    return pins


def setPinsGPIOin(pins):
    pinDict = {}
    for pin in pins:
        gpio.setup(pin, gpio.IN)
        pinDict[str(pin)] = str(gpio.input(pin))
    print pinDict


def setupFallDetect(pin):
    try:
        gpio.add_event_detect(pin, gpio.FALLING)
    except:
        print('error')
    print(pin + " : " + str(gpio.input(pin)))


def isMoving(pin):
    return gpio.event_detected(pin)


def detectKnob(knob):
    running = True
    while running == True:
        if isMoving(knob) == True:
            print('detected')
            userInput = raw_input('keep checking?')
	    if userInput == 'n':
                running = False
            else:
                running = True
        else:
            print('checking...')
        sleep(.1)


def inv_detectknob(knob):
    running = True
    while running == True:
        if isMoving(knob) != True:
            while gpio.input(knob):
                print('detected')
                sleep(.1)
        else:
            print('checking')
            userInput = raw_input('keep checking?')
            if userInput == 'n':
                running = False
            else:
                running = True
        sleep(.1)


def check_all(pins):
    dict = {}
    for pin in pins:
        dict[pin] = gpio.input(pin)
    print dict




def main():
    knob = 'P8_10'

    pins = setup_pin_list()
    setPinsGPIOin(pins)
    check_all(pins)
    setupFallDetect(knob)


    input = raw_input('check?')
    if input == 'y':
        pass
    else:
        exit()

#   detectKnob(knob)
    inv_detectknob(knob)


if __name__ == "__main__":
    main()<commit_msg>removed silly inverted detection, added OrderedDictionary<commit_after>import Adafruit_BBIO.GPIO as gpio
from time import sleep
from collections import OrderedDict as od

def setup_pin_list(start, stop):
    pins = []
    base_name = "P8_"
    for x in range(start, stop):
        if x < 10:
            pins.append(base_name + '0' + str(x))
        else:
            pins.append(base_name + str(x))

    print(pins)
    return pins


def setPinsGPIOin(pins):
    pinDict = od()
    for pin in pins:
        gpio.setup(pin, gpio.IN)
        pinDict[str(pin)] = str(gpio.input(pin))
    print pinDict


def setupFallDetect(knob):
    try:
        gpio.add_event_detect(knob, gpio.FALLING)
    except:
        print('error')
    print(knob + " : " + str(gpio.input(knob)))


def isMoving(knob):
    return gpio.event_detected(knob)


def check_all(pins):
    pinDict = od()
    for pin in pins:
        pinDict[pin] = gpio.input(pin)
    print(pinDict)


def detectKnob(knob):
    running = True
    while running == True:
        if isMoving(knob) == True:
            print('detected')
            userInput = raw_input('keep checking?')
	    if userInput == 'n':
                running = False
            else:
                running = True
        else:
            print('checking...')
        sleep(.1)




def main():
    knob = 'P8_07'

    pins = setup_pin_list(7,20)
    setPinsGPIOin(pins)
    check_all(pins)

    setupFallDetect(knob)


    input = raw_input('check?')
    if input == 'y':
        pass
    else:
        exit()

    detectKnob(knob)


if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.11849547511312217, 'fraction_numerical': 0.006787330316742082, 'mean_word_length': 1.9499582985821518, 'pattern_counts': {'":': 2, '<': 5, '<?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': '1019278', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1152, 'n_words': 268}