<commit_before>CHIP_IO
============================
A CHIP GPIO library

Manual::

    sudo ntpdate pool.ntp.org
    sudo apt-get update
    sudo apt-get install git build-essential python-dev python-pip -y
    git clone git://github.com/xtacocorex/CHIP_IO.git
    cd CHIP_IO
    sudo python setup.py install
    cd ..
    sudo rm -rf CHIP_IO

**Usage**

Using the library is very similar to the excellent RPi.GPIO library used on the Raspberry Pi. Below are some examples.

**GPIO Setup**

Import the library, and setup as GPIO.OUT or GPIO.IN::

    import CHIP_IO.GPIO as GPIO
    GPIO.setup("CSID0", GPIO.OUT)

You can also refer to the pin number::

    GPIO.setup("U14_31", GPIO.OUT)

**GPIO Output**

Setup the pin for output, and write GPIO.HIGH or GPIO.LOW. Or you can use 1 or 0.::

    import CHIP_IO.GPIO as GPIO
    GPIO.setup("CSID0", GPIO.OUT)
    GPIO.output("CSID0", GPIO.HIGH)

**GPIO Input**

Inputs work similarly to outputs.::

    import CHIP_IO.GPIO as GPIO
    GPIO.setup("CSID0", GPIO.IN)

Polling inputs::

    if GPIO.input("CSID0"):
      print("HIGH")
    else:
      print("LOW")

Waiting for an edge (GPIO.RISING, GPIO.FALLING, or GPIO.BOTH::

This only works for the AP-EINT1, AP-EINT3, and XPO Pins on the CHIP

    GPIO.wait_for_edge(channel, GPIO.RISING)

Detecting events::

    GPIO.setup("XIO-P0", GPIO.IN)
    GPIO.add_event_detect("XIO-P0", GPIO.FALLING)
    #your amazing code here
    #detect wherever:
    if GPIO.event_detected("XIO-P0"):
      print "event detected!"

**GPIO Cleanup**

To clean up the GPIO when done, do the following::

    GPIO.cleanup()

**PWM**::

    import CHIP_IO.PWM as PWM
    #PWM.start(channel, duty, freq=2000, polarity=0)
    #duty values are valid 0 (off) to 100 (on)
    PWM.start("PWM0", 50)
    PWM.set_duty_cycle("PWM0", 25.5)
    PWM.set_frequency("PWM0", 10)

    PWM.stop("PWM0")
    PWM.cleanup()

    #set polarity to 1 on start:
    PWM.start("PWM0", 50, 2000, 1)

**SOFTPWM**::

    import CHIP_IO.SOFTPWM as PWM
    #PWM.start(channel, duty, freq=2000, polarity=0)
    #duty values are valid 0 (off) to 100 (on)
    #you can choose any pin
    PWM.start("XIO-P7", 50)
    PWM.set_duty_cycle("XIO-P7", 25.5)
    PWM.set_frequency("XIO-P7", 10)

    PWM.stop("XIO-P7")
    PWM.cleanup()

    #set polarity to 1 on start:
    PWM.start("XIO-P7", 50, 2000, 1)

Use SOFTPWM at low speeds (hundreds of Hz) for the best results. Do not use for anything that needs high precision or reliability.

**ADC**::

    Not Implemented yet

**Running tests**

Install py.test to run the tests. You'll also need the python compiler package for py.test.::

    sudo apt-get install python-pytest

Execute the following in the root of the project::

    py.test

**Credits**

The CHIP IO Python library was originally forked from the Adafruit Beaglebone IO Python Library.
The BeagleBone IO Python library was originally forked from the excellent MIT Licensed [RPi.GPIO](https://code.google.com/p/raspberry-gpio-python) library written by <NAME>.

**License**

CHIP IO port by <NAME>, released under the MIT License.
Beaglebone IO Library Written by <NAME>, Adafruit Industries. BeagleBone IO Python library is released under the MIT License.<commit_msg>Updating the README to mention running with super user permissions, adding sudo in front of py.test to help with issues found in issue #8<commit_after>CHIP_IO
============================
A CHIP GPIO library

Manual::

    sudo ntpdate pool.ntp.org
    sudo apt-get update
    sudo apt-get install git build-essential python-dev python-pip -y
    git clone git://github.com/xtacocorex/CHIP_IO.git
    cd CHIP_IO
    sudo python setup.py install
    cd ..
    sudo rm -rf CHIP_IO

**Usage**

Using the library is very similar to the excellent RPi.GPIO library used on the Raspberry Pi. Below are some examples.

All scripts that require GPIO access need to be run with super user permissions!

**GPIO Setup**

Import the library, and setup as GPIO.OUT or GPIO.IN::

    import CHIP_IO.GPIO as GPIO
    GPIO.setup("CSID0", GPIO.OUT)

You can also refer to the pin number::

    GPIO.setup("U14_31", GPIO.OUT)

**GPIO Output**

Setup the pin for output, and write GPIO.HIGH or GPIO.LOW. Or you can use 1 or 0.::

    import CHIP_IO.GPIO as GPIO
    GPIO.setup("CSID0", GPIO.OUT)
    GPIO.output("CSID0", GPIO.HIGH)

**GPIO Input**

Inputs work similarly to outputs.::

    import CHIP_IO.GPIO as GPIO
    GPIO.setup("CSID0", GPIO.IN)

Polling inputs::

    if GPIO.input("CSID0"):
      print("HIGH")
    else:
      print("LOW")

Waiting for an edge (GPIO.RISING, GPIO.FALLING, or GPIO.BOTH::

This only works for the AP-EINT1, AP-EINT3, and XPO Pins on the CHIP

    GPIO.wait_for_edge(channel, GPIO.RISING)

Detecting events::

    GPIO.setup("XIO-P0", GPIO.IN)
    GPIO.add_event_detect("XIO-P0", GPIO.FALLING)
    #your amazing code here
    #detect wherever:
    if GPIO.event_detected("XIO-P0"):
      print "event detected!"

**GPIO Cleanup**

To clean up the GPIO when done, do the following::

    GPIO.cleanup()

**PWM**::

    import CHIP_IO.PWM as PWM
    #PWM.start(channel, duty, freq=2000, polarity=0)
    #duty values are valid 0 (off) to 100 (on)
    PWM.start("PWM0", 50)
    PWM.set_duty_cycle("PWM0", 25.5)
    PWM.set_frequency("PWM0", 10)

    PWM.stop("PWM0")
    PWM.cleanup()

    #set polarity to 1 on start:
    PWM.start("PWM0", 50, 2000, 1)

**SOFTPWM**::

    import CHIP_IO.SOFTPWM as PWM
    #PWM.start(channel, duty, freq=2000, polarity=0)
    #duty values are valid 0 (off) to 100 (on)
    #you can choose any pin
    PWM.start("XIO-P7", 50)
    PWM.set_duty_cycle("XIO-P7", 25.5)
    PWM.set_frequency("XIO-P7", 10)

    PWM.stop("XIO-P7")
    PWM.cleanup()

    #set polarity to 1 on start:
    PWM.start("XIO-P7", 50, 2000, 1)

Use SOFTPWM at low speeds (hundreds of Hz) for the best results. Do not use for anything that needs high precision or reliability.

**ADC**::

    Not Implemented yet

**Running tests**

Install py.test to run the tests. You'll also need the python compiler package for py.test.::

    sudo apt-get install python-pytest

Execute the following in the root of the project::

    sudo py.test

**Credits**

The CHIP IO Python library was originally forked from the Adafruit Beaglebone IO Python Library.
The BeagleBone IO Python library was originally forked from the excellent MIT Licensed [RPi.GPIO](https://code.google.com/p/raspberry-gpio-python) library written by <NAME>.

**License**

CHIP IO port by <NAME>, released under the MIT License.
Beaglebone IO Library Written by <NAME>, Adafruit Industries. BeagleBone IO Python library is released under the MIT License.
{'fraction_non_alphanumeric': 0.11596815382304342, 'fraction_numerical': 0.022382454559110712, 'mean_word_length': 3.354480052321779, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '40097', 'n_tokens_mistral': 2427, 'n_tokens_neox': 2248, 'n_words': 797}