This repository has been archived by the owner on Jul 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Join OPi PC and PCPLUS - Update mode BCM - Prepare to pypi
- Loading branch information
Showing
15 changed files
with
213 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global-include *.md *.txt *.py *.c *.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
# OrangePi.GPIO | ||
RPi.GPIO drop-in replacement library for Orange Pi Boards | ||
|
||
This is a modified version of **RPi.GPIO** for Orange Pi Boards. | ||
|
||
It is based on the original [RPi.GPIO](https://pypi.python.org/pypi/RPi.GPIO). | ||
|
||
## Installation | ||
|
||
#### With PIP | ||
|
||
sudo pip install OrangePi.GPIO | ||
|
||
#### Manual | ||
|
||
sudo apt-get update | ||
sudo apt-get install python-dev git | ||
git clone https://github.com/Jeremie-C/OrangePi.GPIO | ||
cd /OrangePi.GPIO | ||
sudo python setup.py install | ||
|
||
## Supported Boards | ||
|
||
* OPi ZERO | ||
* OPi ZERO PLUS | ||
* OPi ZERO PLUS2 H3 | ||
* OPi ZERO PLUS2 H5 | ||
* OPi R1 | ||
* OPi PC & PC PLUS | ||
* OPi ONE | ||
* OPi LITE | ||
* OPi PC2 | ||
* OPi PRIME | ||
|
||
## Usage | ||
|
||
Same as RPi.GPIO but with a new function to choose OrangePi Board. | ||
|
||
import OPi.GPIO as GPIO | ||
GPIO.setboard(GPIO.ZEROPLUS) | ||
GPIO.setmode(GPIO.BOARD) | ||
GPIO.output(5, 1) | ||
|
||
Many demo is on the example folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import OPi.GPIO as GPIO | ||
from time import sleep # this lets us have a time delay | ||
|
||
GPIO.setboard(GPIO.PCPCPLUS) # Orange Pi PC board | ||
GPIO.setmode(GPIO.BOARD) # set up BOARD BCM numbering | ||
GPIO.setup(7, GPIO.OUT) # set BCM7 (pin 26) as an output (LED) | ||
|
||
try: | ||
print ("Press CTRL+C to exit") | ||
while True: | ||
GPIO.output(7, 1) # set port/pin value to 1/HIGH/True | ||
sleep(0.1) | ||
GPIO.output(7, 0) # set port/pin value to 0/LOW/False | ||
sleep(0.1) | ||
|
||
GPIO.output(7, 1) # set port/pin value to 1/HIGH/True | ||
sleep(0.1) | ||
GPIO.output(7, 0) # set port/pin value to 0/LOW/False | ||
sleep(0.1) | ||
|
||
sleep(0.5) | ||
|
||
except KeyboardInterrupt: | ||
GPIO.output(7, 0) # set port/pin value to 0/LOW/False | ||
GPIO.cleanup() # Clean GPIO | ||
print ("Bye.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import OPi.GPIO as GPIO | ||
from time import sleep # this lets us have a time delay | ||
|
||
GPIO.setboard(GPIO.ZERO) # Orange Pi Zero board | ||
GPIO.setmode(GPIO.SOC) # set up SOC numbering | ||
|
||
sled = GPIO.PA+17 # Status led is on PA17 | ||
GPIO.setup(sled, GPIO.OUT) # set PA17 as an output (Status led of board) | ||
|
||
try: | ||
while True: | ||
GPIO.output(sled, 1) # set port/pin value to 1/HIGH/True | ||
sleep(0.1) | ||
GPIO.output(sled, 0) # set port/pin value to 0/LOW/False | ||
sleep(0.1) | ||
GPIO.output(sled, 1) # set port/pin value to 1/HIGH/True | ||
sleep(0.1) | ||
GPIO.output(sled, 0) # set port/pin value to 0/LOW/False | ||
sleep(0.5) | ||
|
||
except KeyboardInterrupt: | ||
GPIO.output(sled, 0) | ||
GPIO.cleanup() # clean up after yourself | ||
print ("Bye.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import OPi.GPIO as GPIO | ||
from time import sleep | ||
|
||
GPIO.setboard(GPIO.ZERO) | ||
GPIO.setmode(GPIO.BOARD) | ||
|
||
print(GPIO.gpio_function(3)) | ||
sleep(0.1) | ||
GPIO.setup(3, GPIO.IN) | ||
sleep(0.1) | ||
print(GPIO.gpio_function(3)) | ||
sleep(0.1) | ||
GPIO.cleanup() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import OPi.GPIO as GPIO | ||
from time import sleep # this lets us have a time delay | ||
|
||
GPIO.setboard(GPIO.ZERO) # Orange Pi Zero board | ||
GPIO.setmode(GPIO.BOARD) # set up BOARD GPIO numbering | ||
GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_OFF) # set pin 15 as input (button) | ||
GPIO.setup(11, GPIO.OUT) # set pin 11 as an output (LED) | ||
|
||
try: | ||
while True: # this will carry on until you hit CTRL+C | ||
if GPIO.input(15): # if pin 15 == 1 | ||
print "Port 15 is 1/HIGH/True - LED ON" | ||
GPIO.output(11, 1) # set port/pin value to 1/HIGH/True | ||
else: | ||
print "Port 15 is 0/LOW/False - LED OFF" | ||
GPIO.output(11, 0) # set port/pin value to 0/LOW/False | ||
sleep(0.1) # wait 0.1 seconds | ||
|
||
finally: # this block will run no matter how the try block exits | ||
print("Finally") | ||
GPIO.output(11, 0) | ||
GPIO.cleanup() # clean up after yourself |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import OPi.GPIO as GPIO | ||
from time import sleep | ||
|
||
GPIO.setboard(GPIO.ZERO) | ||
GPIO.setmode(GPIO.BOARD) # set up BOARD BCM numbering | ||
GPIO.setup(26, GPIO.OUT) # set pin 26 as an output (LED) | ||
|
||
p = GPIO.PWM(26, 10) # new PWM on channel=26 frequency=10Hz | ||
p.start(0) | ||
try: | ||
while 1: | ||
for dc in range(0, 101, 5): | ||
p.ChangeDutyCycle(dc) | ||
sleep(0.1) | ||
for dc in range(100, -1, -5): | ||
p.ChangeDutyCycle(dc) | ||
sleep(0.1) | ||
except KeyboardInterrupt: | ||
pass | ||
p.stop() | ||
GPIO.output(26, 0) | ||
GPIO.cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import OPi.GPIO as GPIO | ||
from time import sleep | ||
|
||
GPIO.setboard(GPIO.ZERO) | ||
GPIO.setmode(GPIO.BOARD) | ||
GPIO.setup(26, GPIO.OUT) | ||
|
||
p = GPIO.PWM(26, 0.5) # channel=26 frequency=0.5Hz | ||
p.start(1) | ||
raw_input('Press return to stop:') # use input for Python 3 | ||
p.stop() | ||
GPIO.cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters