Updated to reflect wiringpi2 to wiringpi rename

pull/39/head
Phil Howard 10 years ago
parent 77ce6cd9eb
commit 6577b7e592

@ -3,5 +3,5 @@ graft WiringPi/devLib
include README.md include README.md
include LICENSE.txt include LICENSE.txt
include setup.cfg include setup.cfg
include wiringpi2.py include wiringpi.py
include wiringpi_wrap.c include wiringpi_wrap.c

@ -44,50 +44,50 @@ Description incoming!
##Usage ##Usage
import wiringpi2 import wiringpi
wiringpi2.wiringPiSetup() # For sequential pin numbering, one of these MUST be called before using IO functions wiringpi.wiringPiSetup() # For sequential pin numbering, one of these MUST be called before using IO functions
# OR # OR
wiringpi2.wiringPiSetupSys() # For /sys/class/gpio with GPIO pin numbering wiringpi.wiringPiSetupSys() # For /sys/class/gpio with GPIO pin numbering
# OR # OR
wiringpi2.wiringPiSetupGpio() # For GPIO pin numbering wiringpi.wiringPiSetupGpio() # For GPIO pin numbering
Setting up IO expanders (This example was tested on a quick2wire board with one digital IO expansion board connected via I2C): Setting up IO expanders (This example was tested on a quick2wire board with one digital IO expansion board connected via I2C):
wiringpi2.mcp23017Setup(65,0x20) wiringpi.mcp23017Setup(65,0x20)
wiringpi2.pinMode(65,1) wiringpi.pinMode(65,1)
wiringpi2.digitalWrite(65,1) wiringpi.digitalWrite(65,1)
**General IO:** **General IO:**
wiringpi2.pinMode(6,1) # Set pin 6 to 1 ( OUTPUT ) wiringpi.pinMode(6,1) # Set pin 6 to 1 ( OUTPUT )
wiringpi2.digitalWrite(6,1) # Write 1 ( HIGH ) to pin 6 wiringpi.digitalWrite(6,1) # Write 1 ( HIGH ) to pin 6
wiringpi2.digitalRead(6) # Read pin 6 wiringpi.digitalRead(6) # Read pin 6
**Setting up a peripheral:** **Setting up a peripheral:**
WiringPi2 supports expanding your range of available "pins" by setting up a port expander. The implementation details of WiringPi2 supports expanding your range of available "pins" by setting up a port expander. The implementation details of
your port expander will be handled transparently, and you can write to the additional pins ( starting from PIN_OFFSET >= 64 ) your port expander will be handled transparently, and you can write to the additional pins ( starting from PIN_OFFSET >= 64 )
as if they were normal pins on the Pi. as if they were normal pins on the Pi.
wiringpi2.mcp23017Setup(PIN_OFFSET,I2C_ADDR) wiringpi.mcp23017Setup(PIN_OFFSET,I2C_ADDR)
**Soft Tone** **Soft Tone**
Hook a speaker up to your Pi and generate music with softTone. Also useful for generating frequencies for other uses such as modulating A/C. Hook a speaker up to your Pi and generate music with softTone. Also useful for generating frequencies for other uses such as modulating A/C.
wiringpi2.softToneCreate(PIN) wiringpi.softToneCreate(PIN)
wiringpi2.softToneWrite(PIN,FREQUENCY) wiringpi.softToneWrite(PIN,FREQUENCY)
**Bit shifting:** **Bit shifting:**
wiringpi2.shiftOut(1,2,0,123) # Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2 wiringpi.shiftOut(1,2,0,123) # Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2
**Serial:** **Serial:**
serial = wiringpi2.serialOpen('/dev/ttyAMA0',9600) # Requires device/baud and returns an ID serial = wiringpi.serialOpen('/dev/ttyAMA0',9600) # Requires device/baud and returns an ID
wiringpi2.serialPuts(serial,"hello") wiringpi.serialPuts(serial,"hello")
wiringpi2.serialClose(serial) # Pass in ID wiringpi.serialClose(serial) # Pass in ID
**Full details at:** **Full details at:**
http://www.wiringpi.com http://www.wiringpi.com

@ -1,14 +1,14 @@
import wiringpi2 import wiringpi
PIN_TO_SENSE = 23 PIN_TO_SENSE = 23
def gpio_callback(): def gpio_callback():
print "GPIO_CALLBACK!" print "GPIO_CALLBACK!"
wiringpi2.wiringPiSetupGpio() wiringpi.wiringPiSetupGpio()
wiringpi2.pinMode(PIN_TO_SENSE, wiringpi2.GPIO.INPUT) wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
wiringpi2.pullUpDnControl(PIN_TO_SENSE, wiringpi2.GPIO.PUD_UP) wiringpi.pullUpDnControl(PIN_TO_SENSE, wiringpi.GPIO.PUD_UP)
wiringpi2.wiringPiISR(PIN_TO_SENSE, wiringpi2.GPIO.INT_EDGE_BOTH, gpio_callback) wiringpi.wiringPiISR(PIN_TO_SENSE, wiringpi.GPIO.INT_EDGE_BOTH, gpio_callback)
while True: while True:
wiringpi2.delay(2000) wiringpi.delay(2000)

@ -1,5 +1,5 @@
# Demonstrates use of Arduino-like delay function # Demonstrates use of Arduino-like delay function
import wiringpi2 import wiringpi
print 'Hello World' print 'Hello World'
wiringpi2.delay(1500) # Delay for 1.5 seconds wiringpi.delay(1500) # Delay for 1.5 seconds
print 'Hi again!' print 'Hi again!'

@ -1,4 +1,4 @@
import wiringpi2 as wiringpi import wiringpi
INPUT = 0 INPUT = 0
OUTPUT = 1 OUTPUT = 1
LOW = 0 LOW = 0

@ -1,5 +1,5 @@
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander ) # Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
import wiringpi2 as wiringpi import wiringpi
PIN_BACKLIGHT = 67 # LED PIN_BACKLIGHT = 67 # LED
PIN_SCLK = 68 # Clock SCLK PIN_SCLK = 68 # Clock SCLK
@ -92,4 +92,4 @@ for time in range(0,4):
lcd_clear() lcd_clear()
wiringpi.delay(1000) wiringpi.delay(1000)
lcd_fill() lcd_fill()
wiringpi.delay(1000) wiringpi.delay(1000)

@ -1,15 +1,15 @@
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander ) # Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
import wiringpi2 import wiringpi
pin_base = 65 pin_base = 65
i2c_addr = 0x20 i2c_addr = 0x20
pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80] pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
wiringpi2.wiringPiSetup() wiringpi.wiringPiSetup()
wiringpi2.mcp23017Setup(pin_base,i2c_addr) wiringpi.mcp23017Setup(pin_base,i2c_addr)
for pin in pins: for pin in pins:
wiringpi2.pinMode(pin,1) wiringpi.pinMode(pin,1)
wiringpi2.digitalWrite(pin,1) wiringpi.digitalWrite(pin,1)
# wiringpi2.delay(1000) # wiringpi.delay(1000)
# wiringpi2.digitalWrite(pin,0) # wiringpi.digitalWrite(pin,0)

@ -1,19 +1,19 @@
# Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm # Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm
# softPwm uses a fixed frequency # softPwm uses a fixed frequency
import wiringpi2 import wiringpi
OUTPUT = 1 OUTPUT = 1
PIN_TO_PWM = 1 PIN_TO_PWM = 1
wiringpi2.wiringPiSetup() wiringpi.wiringPiSetup()
wiringpi2.pinMode(PIN_TO_PWM,OUTPUT) wiringpi.pinMode(PIN_TO_PWM,OUTPUT)
wiringpi2.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters wiringpi.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters
for time in range(0,4): for time in range(0,4):
for brightness in range(0,100): # Going from 0 to 100 will give us full off to full on for brightness in range(0,100): # Going from 0 to 100 will give us full off to full on
wiringpi2.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle wiringpi.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle
wiringpi2.delay(10) # Delay for 0.2 seconds wiringpi.delay(10) # Delay for 0.2 seconds
for brightness in reversed(range(0,100)): for brightness in reversed(range(0,100)):
wiringpi2.softPwmWrite(PIN_TO_PWM,brightness) wiringpi.softPwmWrite(PIN_TO_PWM,brightness)
wiringpi2.delay(10) wiringpi.delay(10)

@ -1,18 +1,18 @@
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander ) # Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
import wiringpi2 import wiringpi
pin_base = 65 pin_base = 65
i2c_addr = 0x20 i2c_addr = 0x20
i2c_addr_2 = 0x21 i2c_addr_2 = 0x21
#pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80] #pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
wiringpi2.wiringPiSetup() wiringpi.wiringPiSetup()
wiringpi2.mcp23017Setup(pin_base,i2c_addr) wiringpi.mcp23017Setup(pin_base,i2c_addr)
wiringpi2.mcp23017Setup(pin_base+16,i2c_addr_2) wiringpi.mcp23017Setup(pin_base+16,i2c_addr_2)
#for pin in pins: #for pin in pins:
for pin in range(65,96): for pin in range(65,96):
wiringpi2.pinMode(pin,1) wiringpi.pinMode(pin,1)
wiringpi2.digitalWrite(pin,1) wiringpi.digitalWrite(pin,1)
# wiringpi2.delay(1000) # wiringpi.delay(1000)
# wiringpi2.digitalWrite(pin,0) # wiringpi.digitalWrite(pin,0)

@ -1,4 +1,4 @@
import wiringpi2 as wiringpi import wiringpi
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS) io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
io.piGlowSetup() io.piGlowSetup()
io.piGlowLeg(1,100) io.piGlowLeg(1,100)

@ -1,4 +1,4 @@
import wiringpi2 as wiringpi import wiringpi
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS) io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
print io.digitalRead(1) print io.digitalRead(1)
print io.analogRead(1) print io.analogRead(1)

Loading…
Cancel
Save