diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 0000000..c504481 --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,8 @@ +v1.0.0 -- Branched from original WiringPi to deliver new WiringPi 2 functionality +v1.0.1 -- Fixed build problems involving missing header files +v1.0.2 -- Fixed build issue with piNes.c +v1.0.3 -- Fixed bug in physical pin assignment mode +v1.0.4 -- Added class wrapper, plus analogRead/Write functions +v1.0.5 -- Second attempt at pretty Pypi page +v1.0.6 -- Fixed spelling error in softToneCreate - Thanks oevsegneev +v1.0.7 -- Added LCD functionality diff --git a/MANIFEST.in b/MANIFEST.in index eb7317d..4d941f2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ graft WiringPi/wiringPi +include *.txt diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..fc19791 --- /dev/null +++ b/README.rst @@ -0,0 +1,75 @@ +====== +WiringPi 2 for Python +====== + +WARNING: This is an in-development library, it will not be bug free and fully featured. +====== + +Please tweet @gadgetoid, find Gadgetoid in IRC, email Phil at Gadgetoid dot com, +or visit http://pi.gadgetoid.com/post/039-wiringpi-version-2-with-extra-python and +comment if you have any problems, suggestions, questions or words of support. + +WiringPi: An implementation of most of the Arduino Wiring + functions for the Raspberry Pi + +WiringPi2: WiringPi version 2 implements new functions for managing IO expanders. + +Testing: +======== +Build with gcc version 4.6.3 (Debian 4.6.3-14+rpi1) +Built against Python 2.7.2, Python 3.2.3 + +Prerequisites: +============== +You must have python-dev and python-setuptools installed +If you manually rebuild the bindings with swig -python wiringpi.i + +Get/setup repo: +=============== +git clone https://github.com/Gadgetoid/WiringPi2-Python.git +cd WiringPi2-Python + +Build & install with: +===================== +sudo python setup.py install + +Or Python 3 +sudo python3 setup.py install + +Class-based Usage: +================== +Description incoming! + +Usage: +====== +import wiringpi2 +wiringpi2.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions +OR +wiringpi2.wiringPiSetupSys // For /sys/class/gpio with GPIO pin numbering +OR +wiringpi2.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): +wiringpi2.mcp23017Setup(65,0x20) +wiringpi2.pinMode(65,1) +wiringpi2.digitalWrite(65,1) + +General IO: +----------- +wiringpi2.pinMode(1,1) // Set pin 1 to output +wiringpi2.digitalWrite(1,1) // Write 1 HIGH to pin 1 +wiringpi2.digitalRead(1) // Read pin 1 + +Bit shifting: +------------- +wiringpi2.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2 + +Serial: +------- +serial = wiringpi2.serialOpen('/dev/ttyAMA0',9600) // Requires device/baud and returns an ID +wiringpi2.serialPuts(serial,"hello") +wiringpi2.serialClose(serial) // Pass in ID + +Full details at: +---------------- +http://www.wiringpi.com diff --git a/WiringPi/wiringPi/wiringPi.c b/WiringPi/wiringPi/wiringPi.c index 59a3392..6bb8883 100644 --- a/WiringPi/wiringPi/wiringPi.c +++ b/WiringPi/wiringPi/wiringPi.c @@ -1083,7 +1083,7 @@ void digitalWrite (int pin, int value) } else if (wiringPiMode == WPI_MODE_PINS) pin = pinToGpio [pin] ; - else if (wiringPiMode == WPI_MODE_GPIO) + else if (wiringPiMode == WPI_MODE_PHYS) pin = physToGpio [pin] ; else if (wiringPiMode != WPI_MODE_GPIO) return ; diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..8d072ea --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +swig2.0 -python wiringpi.i +sudo python setup.py build install +sudo python test.py diff --git a/examples/ladder-board.py b/examples/ladder-board.py new file mode 100644 index 0000000..de4542f --- /dev/null +++ b/examples/ladder-board.py @@ -0,0 +1,27 @@ +import wiringpi2 as wiringpi +INPUT = 0 +OUTPUT = 1 +LOW = 0 +HIGH = 1 +BUTTONS = [13,12,10,11] +LEDS = [0,1,2,3,4,5,6,7,8,9] +PUD_UP = 2 + +wiringpi.wiringPiSetup() + +for button in BUTTONS: + wiringpi.pinMode(button,INPUT) + wiringpi.pullUpDnControl(button,PUD_UP) + +for led in LEDS: + wiringpi.pinMode(led,OUTPUT) + +while 1: + for index,button in enumerate(BUTTONS): + button_state = wiringpi.digitalRead(button) + first_led = LEDS[index*2] + second_led = LEDS[(index*2)+1] + #print str(button) + ' ' + str(button_state) + wiringpi.digitalWrite(first_led,1-button_state) + wiringpi.digitalWrite(second_led,1-button_state) + wiringpi.delay(20) diff --git a/examples/n5510-mcp23017.py b/examples/n5510-mcp23017.py new file mode 100644 index 0000000..fb12f77 --- /dev/null +++ b/examples/n5510-mcp23017.py @@ -0,0 +1,95 @@ +# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander ) +import wiringpi2 as wiringpi + +PIN_BACKLIGHT = 67 # LED +PIN_SCLK = 68 # Clock SCLK +PIN_SDIN = 69 # DN(MOSI) +PIN_DC = 70 # D/C +PIN_RESET = 71 # RST Reset +PIN_SCE = 72 # SCE + +#PIN_BACKLIGHT = 5 +#PIN_SCLK = 4 +#PIN_SDIN = 3 +#PIN_DC = 2 +#PIN_RESET = 1 +#PIN_SCE = 0 + +OUTPUT = 1 +INPUT = 0 +HIGH = 1 +LOW = 0 + +LCD_C = 0 +LCD_D = 1 + +LCD_X = 84 +LCD_Y = 48 +LCD_SEGS = 504 + +MSBFIRST = 1 +LSBFIRST = 0 + +SLOW_DOWN = 400 + +pin_base = 65 +i2c_addr = 0x21 + +wiringpi.wiringPiSetup() +wiringpi.mcp23017Setup(pin_base,i2c_addr) + +def slow_shift_out(data_pin, clock_pin, data): + for bit in bin(data).replace('0b','').rjust(8,'0'): + wiringpi.digitalWrite(clock_pin,LOW) + wiringpi.delay(SLOW_DOWN) + wiringpi.digitalWrite(data_pin,int(bit)) + wiringpi.delay(SLOW_DOWN) + wiringpi.digitalWrite(clock_pin,HIGH) + wiringpi.delay(SLOW_DOWN) + +def lcd_write(dc, data): + wiringpi.digitalWrite(PIN_DC, dc) + wiringpi.digitalWrite(PIN_SCE, LOW) + wiringpi.delay(SLOW_DOWN) + #wiringpi.shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data) + slow_shift_out(PIN_SDIN, PIN_SCLK, data) + wiringpi.digitalWrite(PIN_SCE, HIGH) + wiringpi.delay(SLOW_DOWN) + #wiringpi.delay(2) + +def lcd_initialise(): + wiringpi.pinMode(PIN_BACKLIGHT,OUTPUT) + wiringpi.digitalWrite(PIN_BACKLIGHT, HIGH) + wiringpi.pinMode(PIN_SCE, OUTPUT) + wiringpi.pinMode(PIN_RESET, OUTPUT) + wiringpi.pinMode(PIN_DC, OUTPUT) + wiringpi.pinMode(PIN_SDIN, OUTPUT) + wiringpi.pinMode(PIN_SCLK, OUTPUT) + wiringpi.digitalWrite(PIN_RESET, LOW) + wiringpi.delay(SLOW_DOWN) + wiringpi.digitalWrite(PIN_RESET, HIGH) + wiringpi.delay(SLOW_DOWN) + lcd_write(LCD_C, 0x21 ) # LCD Extended Commands. + lcd_write(LCD_C, 0xCC ) # Set LCD Vop (Contrast). + lcd_write(LCD_C, 0x04 ) # Set Temp coefficent. //0x04 + lcd_write(LCD_C, 0x14 ) # LCD bias mode 1:48. //0x13 + lcd_write(LCD_C, 0x0C ) # LCD in normal mode. + lcd_write(LCD_C, 0x20 ) + lcd_write(LCD_C, 0x0C ) + +def lcd_clear(): + for time in range(0, LCD_SEGS): + lcd_write(LCD_D, 0x00) + +def lcd_fill(): + for time in range(0, LCD_SEGS): + lcd_write(LCD_D, 0xFF) + + +lcd_initialise() + +for time in range(0,4): + lcd_clear() + wiringpi.delay(1000) + lcd_fill() + wiringpi.delay(1000) \ No newline at end of file diff --git a/examples/two-mcp23017.py b/examples/two-mcp23017.py new file mode 100644 index 0000000..a6a38a0 --- /dev/null +++ b/examples/two-mcp23017.py @@ -0,0 +1,18 @@ +# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander ) +import wiringpi2 + +pin_base = 65 +i2c_addr = 0x20 +i2c_addr_2 = 0x21 +#pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80] + +wiringpi2.wiringPiSetup() +wiringpi2.mcp23017Setup(pin_base,i2c_addr) +wiringpi2.mcp23017Setup(pin_base+16,i2c_addr_2) + +#for pin in pins: +for pin in range(65,96): + wiringpi2.pinMode(pin,1) + wiringpi2.digitalWrite(pin,1) +# wiringpi2.delay(1000) +# wiringpi2.digitalWrite(pin,0) diff --git a/setup.py b/setup.py index bb6706d..ff987a4 100644 --- a/setup.py +++ b/setup.py @@ -31,14 +31,14 @@ _wiringpi2 = Extension( setup( name = 'wiringpi2', - version = '1.0.1', + version = '1.0.7', author = "Philip Howard", author_email = "phil@gadgetoid.com", url = 'https://github.com/Gadgetoid/WiringPi2-Python/', description = """A python interface to WiringPi 2.0 library which allows for easily interfacing with the GPIO pins of the Raspberry Pi. Also supports i2c and SPI""", - long_description=open('README').read(), + long_description=open('README.rst','rt').read(), ext_modules = [ _wiringpi2 ], py_modules = ["wiringpi2"], install_requires=[], diff --git a/test.py b/test.py new file mode 100644 index 0000000..95f497e --- /dev/null +++ b/test.py @@ -0,0 +1,4 @@ +import wiringpi2 as wiringpi +io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS) +print io.digitalRead(1) +print io.analogRead(1) diff --git a/wiringpi.i b/wiringpi.i index 40c1644..1538c38 100644 --- a/wiringpi.i +++ b/wiringpi.i @@ -25,27 +25,34 @@ %apply unsigned char { uint8_t }; +// Core wiringPi functions + extern int wiringPiSetup (void) ; extern int wiringPiSetupSys (void) ; extern int wiringPiSetupGpio (void) ; +extern int wiringPiSetupPhys (void) ; extern int piFaceSetup (int pinbase) ; +extern void pinMode (int pin, int mode) ; +extern void pullUpDnControl (int pin, int pud) ; +extern int digitalRead (int pin) ; +extern void digitalWrite (int pin, int value) ; +extern void pwmWrite (int pin, int value) ; +extern int analogRead (int pin) ; +extern void analogWrite (int pin, int value) ; + +// On-Board Raspberry Pi hardware specific stuff + extern int piBoardRev (void) ; extern int wpiPinToGpio (int wpiPin) ; - -extern void pinMode (int pin, int mode) ; -extern int getAlt (int pin) ; -extern void pullUpDnControl (int pin, int pud) ; -extern void digitalWrite (int pin, int value) ; -extern void digitalWriteByte (int value) ; -extern void gpioClockSet (int pin, int freq) ; -extern void pwmWrite (int pin, int value) ; -extern void setPadDrive (int group, int value) ; -extern int digitalRead (int pin) ; -extern void pwmSetMode (int mode) ; -extern void pwmSetRange (unsigned int range) ; -extern void pwmSetClock (int divisor) ; +extern void setPadDrive (int group, int value) ; +extern int getAlt (int pin) ; +extern void digitalWriteByte (int value) ; +extern void pwmSetMode (int mode) ; +extern void pwmSetRange (unsigned int range) ; +extern void pwmSetClock (int divisor) ; +extern void gpioClockSet (int pin, int freq) ; // Interrupts @@ -58,6 +65,10 @@ extern int piThreadCreate (void *(*fn)(void *)) ; extern void piLock (int key) ; extern void piUnlock (int key) ; +// Schedulling priority + +extern int piHiPri (int pri) ; + // Extras from arduino land extern void delay (unsigned int howLong) ; @@ -125,3 +136,16 @@ extern int mcp23s08Setup (int pinBase, int spiPort, int devId) ; extern int mcp23008Setup (int pinBase, int i2cAddress) ; extern int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin) ; + +extern void lcdHome (int fd) ; +extern void lcdClear (int fd) ; +extern void lcdSendCommand (int fd, uint8_t command) ; +extern void lcdPosition (int fd, int x, int y) ; +extern void lcdPutchar (int fd, uint8_t data) ; +extern void lcdPuts (int fd, char *string) ; +extern void lcdPrintf (int fd, char *message, ...) ; + +extern int lcdInit (int rows, int cols, int bits, int rs, int strb, + int d0, int d1, int d2, int d3, int d4, int d5, int d6, int d7) ; + +%include "wiringpi2-class.py" diff --git a/wiringpi2-class.py b/wiringpi2-class.py new file mode 100644 index 0000000..822c18c --- /dev/null +++ b/wiringpi2-class.py @@ -0,0 +1,162 @@ +%pythoncode %{ +class nes(object): + def setupNesJoystick(self,*args): + return setupNesJoystick(*args) + def readNesJoystick(self,*args): + return readNesJoystick(*args) + +class Serial(object): + device = '/dev/ttyAMA0' + baud = 9600 + serial_id = 0 + def printf(self,*args): + return serialPrintf(self.serial_id,*args) + def dataAvail(self,*args): + return serialDataAvail(self.serial_id,*args) + def getchar(self,*args): + return serialGetchar(self.serial_id,*args) + def putchar(self,*args): + return serialPutchar(self.serial_id,*args) + def puts(self,*args): + return serialPuts(self.serial_id,*args) + def __init__(self,device,baud): + self.device = device + self.baud = baud + self.serial_id = serialOpen(self.device,self.baud) + def __del__(self): + serialClose(self.serial_id) + +class GPIO(object): + WPI_MODE_PINS = 0 + WPI_MODE_GPIO = 1 + WPI_MODE_GPIO_SYS = 2 + WPI_MODE_PHYS = 3 + WPI_MODE_PIFACE = 4 + WPI_MODE_UNINITIALISED = -1 + + INPUT = 0 + OUTPUT = 1 + PWM_OUTPUT = 2 + GPIO_CLOCK = 3 + + LOW = 0 + HIGH = 1 + + PUD_OFF = 0 + PUD_DOWN = 1 + PUD_UP = 2 + + PWM_MODE_MS = 0 + PWM_MODE_BAL = 1 + + INT_EDGE_SETUP = 0 + INT_EDGE_FALLING = 1 + INT_EDGE_RISING = 2 + INT_EDGE_BOTH = 3 + + LSBFIRST = 0 + MSBFIRST = 1 + + MODE = 0 + def __init__(self,pinmode=0): + self.MODE=pinmode + if pinmode==self.WPI_MODE_PINS: + wiringPiSetup() + if pinmode==self.WPI_MODE_GPIO: + wiringPiSetupGpio() + if pinmode==self.WPI_MODE_GPIO_SYS: + wiringPiSetupSys() + if pinmode==self.WPI_MODE_PHYS: + wiringPiSetupPhys() + if pinmode==self.WPI_MODE_PIFACE: + wiringPiSetupPiFace() + + def delay(self,*args): + delay(*args) + def delayMicroseconds(self,*args): + delayMicroseconds(*args) + def millis(self): + return millis() + def micros(self): + return micros() + + def piHiPri(self,*args): + return piHiPri(*args) + + def piBoardRev(self): + return piBoardRev() + def wpiPinToGpio(self,*args): + return wpiPinToGpio(*args) + def setPadDrive(self,*args): + return setPadDrive(*args) + def getAlt(self,*args): + return getAlt(*args) + def digitalWriteByte(self,*args): + return digitalWriteByte(*args) + + def pwmSetMode(self,*args): + pwmSetMode(*args) + def pwmSetRange(self,*args): + pwmSetRange(*args) + def pwmSetClock(self,*args): + pwmSetClock(*args) + def gpioClockSet(self,*args): + gpioClockSet(*args) + def pwmWrite(self,*args): + pwmWrite(*args) + + def pinMode(self,*args): + pinMode(*args) + + def digitalWrite(self,*args): + digitalWrite(*args) + def digitalRead(self,*args): + return digitalRead(*args) + def digitalWriteByte(self,*args): + digitalWriteByte(*args) + + def analogWrite(self,*args): + analogWrite(*args) + def analogRead(self,*args): + return analogRead(*args) + + def shiftOut(self,*args): + shiftOut(*args) + def shiftIn(self,*args): + return shiftIn(*args) + + def pullUpDnControl(self,*args): + return pullUpDnControl(*args) + + def waitForInterrupt(self,*args): + return waitForInterrupt(*args) + def wiringPiISR(self,*args): + return wiringPiISR(*args) + + def softPwmCreate(self,*args): + return softPwmCreate(*args) + def softPwmWrite(self,*args): + return sofPwmWrite(*args) + + def softToneCreate(self,*args): + return softToneCreate(*args) + def softToneWrite(self,*args): + return softToneWrite(*args) + + def lcdHome(self,*args): + return lcdHome(self,*args) + def lcdCLear(self,*args): + return lcdClear(self,*args) + def lcdSendCommand(self,*args): + return lcdSendCommand(self,*args) + def lcdPosition(self,*args): + return lcdPosition(self,*args) + def lcdPutchar(self,*args): + return lcdPutchar(self,*args) + def lcdPuts(self,*args): + return lcdPuts(self,*args) + def lcdPrintf(self,*args): + return lcdPrintf(self,*args) + def lcdInit(self,*args): + return lcdInit(self,*args) +%} diff --git a/wiringpi2.py b/wiringpi2.py index 5a9752d..2dad3e1 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -80,53 +80,61 @@ def wiringPiSetupGpio(): return _wiringpi2.wiringPiSetupGpio() wiringPiSetupGpio = _wiringpi2.wiringPiSetupGpio +def wiringPiSetupPhys(): + return _wiringpi2.wiringPiSetupPhys() +wiringPiSetupPhys = _wiringpi2.wiringPiSetupPhys + def piFaceSetup(*args): return _wiringpi2.piFaceSetup(*args) piFaceSetup = _wiringpi2.piFaceSetup -def piBoardRev(): - return _wiringpi2.piBoardRev() -piBoardRev = _wiringpi2.piBoardRev - -def wpiPinToGpio(*args): - return _wiringpi2.wpiPinToGpio(*args) -wpiPinToGpio = _wiringpi2.wpiPinToGpio - def pinMode(*args): return _wiringpi2.pinMode(*args) pinMode = _wiringpi2.pinMode -def getAlt(*args): - return _wiringpi2.getAlt(*args) -getAlt = _wiringpi2.getAlt - def pullUpDnControl(*args): return _wiringpi2.pullUpDnControl(*args) pullUpDnControl = _wiringpi2.pullUpDnControl +def digitalRead(*args): + return _wiringpi2.digitalRead(*args) +digitalRead = _wiringpi2.digitalRead + def digitalWrite(*args): return _wiringpi2.digitalWrite(*args) digitalWrite = _wiringpi2.digitalWrite -def digitalWriteByte(*args): - return _wiringpi2.digitalWriteByte(*args) -digitalWriteByte = _wiringpi2.digitalWriteByte - -def gpioClockSet(*args): - return _wiringpi2.gpioClockSet(*args) -gpioClockSet = _wiringpi2.gpioClockSet - def pwmWrite(*args): return _wiringpi2.pwmWrite(*args) pwmWrite = _wiringpi2.pwmWrite +def analogRead(*args): + return _wiringpi2.analogRead(*args) +analogRead = _wiringpi2.analogRead + +def analogWrite(*args): + return _wiringpi2.analogWrite(*args) +analogWrite = _wiringpi2.analogWrite + +def piBoardRev(): + return _wiringpi2.piBoardRev() +piBoardRev = _wiringpi2.piBoardRev + +def wpiPinToGpio(*args): + return _wiringpi2.wpiPinToGpio(*args) +wpiPinToGpio = _wiringpi2.wpiPinToGpio + def setPadDrive(*args): return _wiringpi2.setPadDrive(*args) setPadDrive = _wiringpi2.setPadDrive -def digitalRead(*args): - return _wiringpi2.digitalRead(*args) -digitalRead = _wiringpi2.digitalRead +def getAlt(*args): + return _wiringpi2.getAlt(*args) +getAlt = _wiringpi2.getAlt + +def digitalWriteByte(*args): + return _wiringpi2.digitalWriteByte(*args) +digitalWriteByte = _wiringpi2.digitalWriteByte def pwmSetMode(*args): return _wiringpi2.pwmSetMode(*args) @@ -140,6 +148,10 @@ def pwmSetClock(*args): return _wiringpi2.pwmSetClock(*args) pwmSetClock = _wiringpi2.pwmSetClock +def gpioClockSet(*args): + return _wiringpi2.gpioClockSet(*args) +gpioClockSet = _wiringpi2.gpioClockSet + def wiringPiISR(*args): return _wiringpi2.wiringPiISR(*args) wiringPiISR = _wiringpi2.wiringPiISR @@ -156,6 +168,10 @@ def piUnlock(*args): return _wiringpi2.piUnlock(*args) piUnlock = _wiringpi2.piUnlock +def piHiPri(*args): + return _wiringpi2.piHiPri(*args) +piHiPri = _wiringpi2.piHiPri + def delay(*args): return _wiringpi2.delay(*args) delay = _wiringpi2.delay @@ -291,6 +307,199 @@ mcp23008Setup = _wiringpi2.mcp23008Setup def sr595Setup(*args): return _wiringpi2.sr595Setup(*args) sr595Setup = _wiringpi2.sr595Setup + +def lcdHome(*args): + return _wiringpi2.lcdHome(*args) +lcdHome = _wiringpi2.lcdHome + +def lcdClear(*args): + return _wiringpi2.lcdClear(*args) +lcdClear = _wiringpi2.lcdClear + +def lcdSendCommand(*args): + return _wiringpi2.lcdSendCommand(*args) +lcdSendCommand = _wiringpi2.lcdSendCommand + +def lcdPosition(*args): + return _wiringpi2.lcdPosition(*args) +lcdPosition = _wiringpi2.lcdPosition + +def lcdPutchar(*args): + return _wiringpi2.lcdPutchar(*args) +lcdPutchar = _wiringpi2.lcdPutchar + +def lcdPuts(*args): + return _wiringpi2.lcdPuts(*args) +lcdPuts = _wiringpi2.lcdPuts + +def lcdPrintf(*args): + return _wiringpi2.lcdPrintf(*args) +lcdPrintf = _wiringpi2.lcdPrintf + +def lcdInit(*args): + return _wiringpi2.lcdInit(*args) +lcdInit = _wiringpi2.lcdInit +class nes(object): + def setupNesJoystick(self,*args): + return setupNesJoystick(*args) + def readNesJoystick(self,*args): + return readNesJoystick(*args) + +class Serial(object): + device = '/dev/ttyAMA0' + baud = 9600 + serial_id = 0 + def printf(self,*args): + return serialPrintf(self.serial_id,*args) + def dataAvail(self,*args): + return serialDataAvail(self.serial_id,*args) + def getchar(self,*args): + return serialGetchar(self.serial_id,*args) + def putchar(self,*args): + return serialPutchar(self.serial_id,*args) + def puts(self,*args): + return serialPuts(self.serial_id,*args) + def __init__(self,device,baud): + self.device = device + self.baud = baud + self.serial_id = serialOpen(self.device,self.baud) + def __del__(self): + serialClose(self.serial_id) + +class GPIO(object): + WPI_MODE_PINS = 0 + WPI_MODE_GPIO = 1 + WPI_MODE_GPIO_SYS = 2 + WPI_MODE_PHYS = 3 + WPI_MODE_PIFACE = 4 + WPI_MODE_UNINITIALISED = -1 + + INPUT = 0 + OUTPUT = 1 + PWM_OUTPUT = 2 + GPIO_CLOCK = 3 + + LOW = 0 + HIGH = 1 + + PUD_OFF = 0 + PUD_DOWN = 1 + PUD_UP = 2 + + PWM_MODE_MS = 0 + PWM_MODE_BAL = 1 + + INT_EDGE_SETUP = 0 + INT_EDGE_FALLING = 1 + INT_EDGE_RISING = 2 + INT_EDGE_BOTH = 3 + + LSBFIRST = 0 + MSBFIRST = 1 + + MODE = 0 + def __init__(self,pinmode=0): + self.MODE=pinmode + if pinmode==self.WPI_MODE_PINS: + wiringPiSetup() + if pinmode==self.WPI_MODE_GPIO: + wiringPiSetupGpio() + if pinmode==self.WPI_MODE_GPIO_SYS: + wiringPiSetupSys() + if pinmode==self.WPI_MODE_PHYS: + wiringPiSetupPhys() + if pinmode==self.WPI_MODE_PIFACE: + wiringPiSetupPiFace() + + def delay(self,*args): + delay(*args) + def delayMicroseconds(self,*args): + delayMicroseconds(*args) + def millis(self): + return millis() + def micros(self): + return micros() + + def piHiPri(self,*args): + return piHiPri(*args) + + def piBoardRev(self): + return piBoardRev() + def wpiPinToGpio(self,*args): + return wpiPinToGpio(*args) + def setPadDrive(self,*args): + return setPadDrive(*args) + def getAlt(self,*args): + return getAlt(*args) + def digitalWriteByte(self,*args): + return digitalWriteByte(*args) + + def pwmSetMode(self,*args): + pwmSetMode(*args) + def pwmSetRange(self,*args): + pwmSetRange(*args) + def pwmSetClock(self,*args): + pwmSetClock(*args) + def gpioClockSet(self,*args): + gpioClockSet(*args) + def pwmWrite(self,*args): + pwmWrite(*args) + + def pinMode(self,*args): + pinMode(*args) + + def digitalWrite(self,*args): + digitalWrite(*args) + def digitalRead(self,*args): + return digitalRead(*args) + def digitalWriteByte(self,*args): + digitalWriteByte(*args) + + def analogWrite(self,*args): + analogWrite(*args) + def analogRead(self,*args): + return analogRead(*args) + + def shiftOut(self,*args): + shiftOut(*args) + def shiftIn(self,*args): + return shiftIn(*args) + + def pullUpDnControl(self,*args): + return pullUpDnControl(*args) + + def waitForInterrupt(self,*args): + return waitForInterrupt(*args) + def wiringPiISR(self,*args): + return wiringPiISR(*args) + + def softPwmCreate(self,*args): + return softPwmCreate(*args) + def softPwmWrite(self,*args): + return sofPwmWrite(*args) + + def softToneCreate(self,*args): + return softToneCreate(*args) + def softToneWrite(self,*args): + return softToneWrite(*args) + + def lcdHome(self,*args): + return lcdHome(self,*args) + def lcdCLear(self,*args): + return lcdClear(self,*args) + def lcdSendCommand(self,*args): + return lcdSendCommand(self,*args) + def lcdPosition(self,*args): + return lcdPosition(self,*args) + def lcdPutchar(self,*args): + return lcdPutchar(self,*args) + def lcdPuts(self,*args): + return lcdPuts(self,*args) + def lcdPrintf(self,*args): + return lcdPrintf(self,*args) + def lcdInit(self,*args): + return lcdInit(self,*args) + # This file is compatible with both classic and new-style classes. cvar = _wiringpi2.cvar diff --git a/wiringpi2.pyc b/wiringpi2.pyc new file mode 100644 index 0000000..6f3ae5c Binary files /dev/null and b/wiringpi2.pyc differ diff --git a/wiringpi_wrap.c b/wiringpi_wrap.c index bce9851..063f987 100644 --- a/wiringpi_wrap.c +++ b/wiringpi_wrap.c @@ -3374,6 +3374,19 @@ fail: } +SWIGINTERN PyObject *_wrap_wiringPiSetupPhys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":wiringPiSetupPhys")) SWIG_fail; + result = (int)wiringPiSetupPhys(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_piFaceSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -3396,42 +3409,37 @@ fail: } -SWIGINTERN PyObject *_wrap_piBoardRev(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int result; - - if (!PyArg_ParseTuple(args,(char *)":piBoardRev")) SWIG_fail; - result = (int)piBoardRev(); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wpiPinToGpio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_pinMode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; + int arg2 ; int val1 ; int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; PyObject * obj0 = 0 ; - int result; + PyObject * obj1 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:wpiPinToGpio",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:pinMode",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wpiPinToGpio" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pinMode" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); - result = (int)wpiPinToGpio(arg1); - resultobj = SWIG_From_int((int)(result)); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pinMode" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + pinMode(arg1,arg2); + resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_pinMode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_pullUpDnControl(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; @@ -3442,18 +3450,18 @@ SWIGINTERN PyObject *_wrap_pinMode(PyObject *SWIGUNUSEDPARM(self), PyObject *arg PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:pinMode",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:pullUpDnControl",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pinMode" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pullUpDnControl" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pinMode" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pullUpDnControl" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); - pinMode(arg1,arg2); + pullUpDnControl(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3461,7 +3469,7 @@ fail: } -SWIGINTERN PyObject *_wrap_getAlt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_digitalRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int val1 ; @@ -3469,13 +3477,13 @@ SWIGINTERN PyObject *_wrap_getAlt(PyObject *SWIGUNUSEDPARM(self), PyObject *args PyObject * obj0 = 0 ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:getAlt",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"O:digitalRead",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "getAlt" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalRead" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); - result = (int)getAlt(arg1); + result = (int)digitalRead(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3483,7 +3491,7 @@ fail: } -SWIGINTERN PyObject *_wrap_pullUpDnControl(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_digitalWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; @@ -3494,18 +3502,18 @@ SWIGINTERN PyObject *_wrap_pullUpDnControl(PyObject *SWIGUNUSEDPARM(self), PyObj PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:pullUpDnControl",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:digitalWrite",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pullUpDnControl" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalWrite" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pullUpDnControl" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "digitalWrite" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); - pullUpDnControl(arg1,arg2); + digitalWrite(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3513,7 +3521,7 @@ fail: } -SWIGINTERN PyObject *_wrap_digitalWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_pwmWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; @@ -3524,18 +3532,18 @@ SWIGINTERN PyObject *_wrap_digitalWrite(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:digitalWrite",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:pwmWrite",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalWrite" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pwmWrite" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "digitalWrite" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pwmWrite" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); - digitalWrite(arg1,arg2); + pwmWrite(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3543,28 +3551,29 @@ fail: } -SWIGINTERN PyObject *_wrap_digitalWriteByte(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_analogRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; + int result; - if (!PyArg_ParseTuple(args,(char *)"O:digitalWriteByte",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"O:analogRead",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalWriteByte" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "analogRead" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); - digitalWriteByte(arg1); - resultobj = SWIG_Py_Void(); + result = (int)analogRead(arg1); + resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_gpioClockSet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_analogWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; @@ -3575,18 +3584,18 @@ SWIGINTERN PyObject *_wrap_gpioClockSet(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:gpioClockSet",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:analogWrite",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gpioClockSet" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "analogWrite" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gpioClockSet" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "analogWrite" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); - gpioClockSet(arg1,arg2); + analogWrite(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3594,30 +3603,35 @@ fail: } -SWIGINTERN PyObject *_wrap_pwmWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_piBoardRev(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":piBoardRev")) SWIG_fail; + result = (int)piBoardRev(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wpiPinToGpio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; - int arg2 ; int val1 ; int ecode1 = 0 ; - int val2 ; - int ecode2 = 0 ; PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + int result; - if (!PyArg_ParseTuple(args,(char *)"OO:pwmWrite",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"O:wpiPinToGpio",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pwmWrite" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wpiPinToGpio" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pwmWrite" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - pwmWrite(arg1,arg2); - resultobj = SWIG_Py_Void(); + result = (int)wpiPinToGpio(arg1); + resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; @@ -3654,7 +3668,7 @@ fail: } -SWIGINTERN PyObject *_wrap_digitalRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_getAlt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int val1 ; @@ -3662,13 +3676,13 @@ SWIGINTERN PyObject *_wrap_digitalRead(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject * obj0 = 0 ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:digitalRead",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"O:getAlt",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalRead" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "getAlt" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); - result = (int)digitalRead(arg1); + result = (int)getAlt(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -3676,6 +3690,27 @@ fail: } +SWIGINTERN PyObject *_wrap_digitalWriteByte(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:digitalWriteByte",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "digitalWriteByte" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + digitalWriteByte(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_pwmSetMode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -3739,6 +3774,36 @@ fail: } +SWIGINTERN PyObject *_wrap_gpioClockSet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:gpioClockSet",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gpioClockSet" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gpioClockSet" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + gpioClockSet(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN int Swig_var_waitForInterrupt_set(PyObject *_val) { { int res = SWIG_ConvertFunctionPtr(_val, (void**)(&waitForInterrupt), SWIGTYPE_p_f_int_int__int); @@ -3862,6 +3927,28 @@ fail: } +SWIGINTERN PyObject *_wrap_piHiPri(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"O:piHiPri",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "piHiPri" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)piHiPri(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_delay(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; unsigned int arg1 ; @@ -4963,30 +5050,386 @@ fail: } +SWIGINTERN PyObject *_wrap_lcdHome(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:lcdHome",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdHome" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + lcdHome(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdClear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:lcdClear",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdClear" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + lcdClear(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdSendCommand(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + uint8_t arg2 ; + int val1 ; + int ecode1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:lcdSendCommand",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdSendCommand" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "lcdSendCommand" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = (uint8_t)(val2); + lcdSendCommand(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdPosition(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:lcdPosition",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdPosition" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "lcdPosition" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "lcdPosition" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + lcdPosition(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdPutchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + uint8_t arg2 ; + int val1 ; + int ecode1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:lcdPutchar",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdPutchar" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "lcdPutchar" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = (uint8_t)(val2); + lcdPutchar(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdPuts(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + char *arg2 = (char *) 0 ; + int val1 ; + int ecode1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:lcdPuts",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdPuts" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "lcdPuts" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + lcdPuts(arg1,arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdPrintf__varargs__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *varargs) { + PyObject *resultobj = 0; + int arg1 ; + char *arg2 = (char *) 0 ; + void *arg3 = 0 ; + int val1 ; + int ecode1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:lcdPrintf",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdPrintf" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "lcdPrintf" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + lcdPrintf(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdPrintf(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj; + PyObject *varargs; + PyObject *newargs; + + newargs = PyTuple_GetSlice(args,0,2); + varargs = PyTuple_GetSlice(args,2,PyTuple_Size(args)+1); + resultobj = _wrap_lcdPrintf__varargs__(NULL,newargs,varargs); + Py_XDECREF(newargs); + Py_XDECREF(varargs); + return resultobj; +} + + +SWIGINTERN PyObject *_wrap_lcdInit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + int arg8 ; + int arg9 ; + int arg10 ; + int arg11 ; + int arg12 ; + int arg13 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + int val8 ; + int ecode8 = 0 ; + int val9 ; + int ecode9 = 0 ; + int val10 ; + int ecode10 = 0 ; + int val11 ; + int ecode11 = 0 ; + int val12 ; + int ecode12 = 0 ; + int val13 ; + int ecode13 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + PyObject * obj10 = 0 ; + PyObject * obj11 = 0 ; + PyObject * obj12 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOOOOO:lcdInit",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9,&obj10,&obj11,&obj12)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdInit" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "lcdInit" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "lcdInit" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "lcdInit" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "lcdInit" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj5, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "lcdInit" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj6, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "lcdInit" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_int(obj7, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "lcdInit" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + ecode9 = SWIG_AsVal_int(obj8, &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "lcdInit" "', argument " "9"" of type '" "int""'"); + } + arg9 = (int)(val9); + ecode10 = SWIG_AsVal_int(obj9, &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "lcdInit" "', argument " "10"" of type '" "int""'"); + } + arg10 = (int)(val10); + ecode11 = SWIG_AsVal_int(obj10, &val11); + if (!SWIG_IsOK(ecode11)) { + SWIG_exception_fail(SWIG_ArgError(ecode11), "in method '" "lcdInit" "', argument " "11"" of type '" "int""'"); + } + arg11 = (int)(val11); + ecode12 = SWIG_AsVal_int(obj11, &val12); + if (!SWIG_IsOK(ecode12)) { + SWIG_exception_fail(SWIG_ArgError(ecode12), "in method '" "lcdInit" "', argument " "12"" of type '" "int""'"); + } + arg12 = (int)(val12); + ecode13 = SWIG_AsVal_int(obj12, &val13); + if (!SWIG_IsOK(ecode13)) { + SWIG_exception_fail(SWIG_ArgError(ecode13), "in method '" "lcdInit" "', argument " "13"" of type '" "int""'"); + } + arg13 = (int)(val13); + result = (int)lcdInit(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + static PyMethodDef SwigMethods[] = { { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, { (char *)"wiringPiSetup", _wrap_wiringPiSetup, METH_VARARGS, NULL}, { (char *)"wiringPiSetupSys", _wrap_wiringPiSetupSys, METH_VARARGS, NULL}, { (char *)"wiringPiSetupGpio", _wrap_wiringPiSetupGpio, METH_VARARGS, NULL}, + { (char *)"wiringPiSetupPhys", _wrap_wiringPiSetupPhys, METH_VARARGS, NULL}, { (char *)"piFaceSetup", _wrap_piFaceSetup, METH_VARARGS, NULL}, - { (char *)"piBoardRev", _wrap_piBoardRev, METH_VARARGS, NULL}, - { (char *)"wpiPinToGpio", _wrap_wpiPinToGpio, METH_VARARGS, NULL}, { (char *)"pinMode", _wrap_pinMode, METH_VARARGS, NULL}, - { (char *)"getAlt", _wrap_getAlt, METH_VARARGS, NULL}, { (char *)"pullUpDnControl", _wrap_pullUpDnControl, METH_VARARGS, NULL}, + { (char *)"digitalRead", _wrap_digitalRead, METH_VARARGS, NULL}, { (char *)"digitalWrite", _wrap_digitalWrite, METH_VARARGS, NULL}, - { (char *)"digitalWriteByte", _wrap_digitalWriteByte, METH_VARARGS, NULL}, - { (char *)"gpioClockSet", _wrap_gpioClockSet, METH_VARARGS, NULL}, { (char *)"pwmWrite", _wrap_pwmWrite, METH_VARARGS, NULL}, + { (char *)"analogRead", _wrap_analogRead, METH_VARARGS, NULL}, + { (char *)"analogWrite", _wrap_analogWrite, METH_VARARGS, NULL}, + { (char *)"piBoardRev", _wrap_piBoardRev, METH_VARARGS, NULL}, + { (char *)"wpiPinToGpio", _wrap_wpiPinToGpio, METH_VARARGS, NULL}, { (char *)"setPadDrive", _wrap_setPadDrive, METH_VARARGS, NULL}, - { (char *)"digitalRead", _wrap_digitalRead, METH_VARARGS, NULL}, + { (char *)"getAlt", _wrap_getAlt, METH_VARARGS, NULL}, + { (char *)"digitalWriteByte", _wrap_digitalWriteByte, METH_VARARGS, NULL}, { (char *)"pwmSetMode", _wrap_pwmSetMode, METH_VARARGS, NULL}, { (char *)"pwmSetRange", _wrap_pwmSetRange, METH_VARARGS, NULL}, { (char *)"pwmSetClock", _wrap_pwmSetClock, METH_VARARGS, NULL}, + { (char *)"gpioClockSet", _wrap_gpioClockSet, METH_VARARGS, NULL}, { (char *)"wiringPiISR", _wrap_wiringPiISR, METH_VARARGS, NULL}, { (char *)"piThreadCreate", _wrap_piThreadCreate, METH_VARARGS, NULL}, { (char *)"piLock", _wrap_piLock, METH_VARARGS, NULL}, { (char *)"piUnlock", _wrap_piUnlock, METH_VARARGS, NULL}, + { (char *)"piHiPri", _wrap_piHiPri, METH_VARARGS, NULL}, { (char *)"delay", _wrap_delay, METH_VARARGS, NULL}, { (char *)"delayMicroseconds", _wrap_delayMicroseconds, METH_VARARGS, NULL}, { (char *)"millis", _wrap_millis, METH_VARARGS, NULL}, @@ -5021,6 +5464,14 @@ static PyMethodDef SwigMethods[] = { { (char *)"mcp23s08Setup", _wrap_mcp23s08Setup, METH_VARARGS, NULL}, { (char *)"mcp23008Setup", _wrap_mcp23008Setup, METH_VARARGS, NULL}, { (char *)"sr595Setup", _wrap_sr595Setup, METH_VARARGS, NULL}, + { (char *)"lcdHome", _wrap_lcdHome, METH_VARARGS, NULL}, + { (char *)"lcdClear", _wrap_lcdClear, METH_VARARGS, NULL}, + { (char *)"lcdSendCommand", _wrap_lcdSendCommand, METH_VARARGS, NULL}, + { (char *)"lcdPosition", _wrap_lcdPosition, METH_VARARGS, NULL}, + { (char *)"lcdPutchar", _wrap_lcdPutchar, METH_VARARGS, NULL}, + { (char *)"lcdPuts", _wrap_lcdPuts, METH_VARARGS, NULL}, + { (char *)"lcdPrintf", _wrap_lcdPrintf, METH_VARARGS, NULL}, + { (char *)"lcdInit", _wrap_lcdInit, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } };