From 17c28c2a4843e18872ec8992e1eebeb5c1cd4148 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Tue, 21 May 2013 22:25:01 +0100 Subject: [PATCH 01/15] Updated to new WiringPi --- .gitignore | 1 + WiringPi/INSTALL | 12 - WiringPi/People | 3 + WiringPi/README | 9 - WiringPi/README.TXT | 2 +- WiringPi/build | 87 + WiringPi/devLib/Makefile | 130 + WiringPi/{wiringPi => devLib}/ds1302.c | 23 +- WiringPi/{wiringPi => devLib}/ds1302.h | 14 +- WiringPi/devLib/font.h | 2577 +++++++++++++++++ WiringPi/{wiringPi => devLib}/gertboard.c | 24 +- WiringPi/{wiringPi => devLib}/gertboard.h | 11 +- WiringPi/{wiringPi => devLib}/lcd.c | 205 +- WiringPi/devLib/lcd.h | 52 + WiringPi/devLib/lcd128x64.c | 673 +++++ WiringPi/devLib/lcd128x64.h | 39 + WiringPi/devLib/maxdetect.c | 165 ++ .../{wiringPi/lcd.h => devLib/maxdetect.h} | 24 +- WiringPi/devLib/piFace.c | 112 + WiringPi/{wiringPi => devLib}/piFace.h | 2 +- WiringPi/{wiringPi => devLib}/piNes.c | 2 +- WiringPi/{wiringPi => devLib}/piNes.h | 0 WiringPi/examples/Gertboard/7segments.c | 221 ++ WiringPi/examples/Gertboard/Makefile | 74 + WiringPi/examples/Gertboard/buttons.c | 83 + WiringPi/examples/{ => Gertboard}/gertboard.c | 62 +- WiringPi/examples/Gertboard/record.c | 60 + WiringPi/examples/Gertboard/temperature.c | 78 + WiringPi/examples/Gertboard/voltmeter.c | 73 + WiringPi/examples/Gertboard/vumeter.c | 152 + WiringPi/examples/Makefile | 59 +- WiringPi/examples/PiFace/Makefile | 85 + WiringPi/examples/PiFace/blink.c | 59 + .../examples/{piface.c => PiFace/buttons.c} | 55 +- WiringPi/examples/PiFace/ladder.c | 337 +++ WiringPi/examples/PiFace/metro.c | 111 + WiringPi/examples/PiFace/motor.c | 120 + WiringPi/examples/PiFace/reaction.c | 194 ++ WiringPi/examples/blink.c | 8 +- WiringPi/examples/{test1.c => blink12.c} | 54 +- WiringPi/examples/blink8.c | 57 + WiringPi/examples/clock.c | 201 ++ WiringPi/examples/ds1302.c | 238 -- WiringPi/examples/gertboard.png | Bin 4834 -> 0 bytes WiringPi/examples/isr.c | 63 +- WiringPi/examples/lcd-adafruit.c | 347 +++ WiringPi/examples/lcd.c | 281 +- WiringPi/examples/okLed.c | 13 +- WiringPi/examples/pwm.c | 79 +- WiringPi/examples/q2w/Makefile | 81 + WiringPi/examples/q2w/binary.c | 79 + WiringPi/examples/q2w/blink-io.c | 61 + WiringPi/examples/{test2.c => q2w/blink.c} | 34 +- WiringPi/examples/q2w/blink.sh | 37 + WiringPi/examples/q2w/bright.c | 59 + WiringPi/examples/q2w/button.c | 63 + WiringPi/examples/q2w/volts.c | 62 + WiringPi/examples/rht03.c | 64 + WiringPi/examples/softPwm.c | 89 + WiringPi/examples/{tone.c => softTone.c} | 9 +- WiringPi/examples/speed.c | 114 +- WiringPi/gpio/Makefile | 14 +- WiringPi/gpio/extensions.c | 414 +++ WiringPi/gpio/extensions.h | 26 + WiringPi/gpio/gpio.1 | 69 +- WiringPi/gpio/gpio.c | 442 +-- WiringPi/gpio/pintest | 193 ++ WiringPi/wiringPi/COPYING.LESSER | 165 ++ WiringPi/wiringPi/Makefile | 73 +- WiringPi/wiringPi/drc.c | 203 ++ WiringPi/wiringPi/drc.h | 34 + WiringPi/wiringPi/mcp23008.c | 40 +- WiringPi/wiringPi/mcp23008.h | 2 +- WiringPi/wiringPi/mcp23016.c | 164 ++ WiringPi/wiringPi/mcp23016.h | 33 + WiringPi/wiringPi/mcp23016reg.h | 48 + WiringPi/wiringPi/mcp23017.c | 26 +- WiringPi/wiringPi/mcp23017.h | 2 +- WiringPi/wiringPi/mcp23s08.c | 40 +- WiringPi/wiringPi/mcp23s08.h | 2 +- WiringPi/wiringPi/mcp23s17.c | 26 +- WiringPi/wiringPi/mcp3002.c | 76 + WiringPi/wiringPi/mcp3002.h | 33 + WiringPi/wiringPi/mcp3422.c | 116 + WiringPi/wiringPi/mcp3422.h | 43 + WiringPi/wiringPi/mcp4802.c | 76 + WiringPi/wiringPi/mcp4802.h | 33 + WiringPi/wiringPi/pcf8574.c | 126 + WiringPi/wiringPi/pcf8574.h | 33 + WiringPi/wiringPi/pcf8591.c | 90 + WiringPi/wiringPi/pcf8591.h | 33 + WiringPi/wiringPi/piFace.c | 179 -- WiringPi/wiringPi/piHiPri.c | 7 +- WiringPi/wiringPi/softPwm.c | 4 +- WiringPi/wiringPi/sr595.c | 3 +- WiringPi/wiringPi/sr595.h | 3 +- WiringPi/wiringPi/wiringPi.c | 107 +- WiringPi/wiringPi/wiringPi.h | 17 +- WiringPi/wiringPi/wiringPiI2C.c | 31 +- WiringPi/wiringPi/wiringPiI2C.h | 4 +- WiringPi/wiringPi/wiringPiSPI.c | 28 +- WiringPi/wiringPi/wiringSerial.c | 16 +- WiringPi/wiringPi/wiringSerial.h | 16 +- setup.py | 86 +- wiringpi.i | 13 +- wiringpi2.pyc | Bin 28020 -> 28020 bytes wiringpi_wrap.c | 13 +- 107 files changed, 9837 insertions(+), 1448 deletions(-) delete mode 100644 WiringPi/README create mode 100755 WiringPi/build create mode 100644 WiringPi/devLib/Makefile rename WiringPi/{wiringPi => devLib}/ds1302.c (90%) rename WiringPi/{wiringPi => devLib}/ds1302.h (68%) create mode 100644 WiringPi/devLib/font.h rename WiringPi/{wiringPi => devLib}/gertboard.c (86%) rename WiringPi/{wiringPi => devLib}/gertboard.h (86%) rename WiringPi/{wiringPi => devLib}/lcd.c (64%) create mode 100644 WiringPi/devLib/lcd.h create mode 100644 WiringPi/devLib/lcd128x64.c create mode 100644 WiringPi/devLib/lcd128x64.h create mode 100755 WiringPi/devLib/maxdetect.c rename WiringPi/{wiringPi/lcd.h => devLib/maxdetect.h} (58%) mode change 100644 => 100755 create mode 100644 WiringPi/devLib/piFace.c rename WiringPi/{wiringPi => devLib}/piFace.h (96%) rename WiringPi/{wiringPi => devLib}/piNes.c (99%) rename WiringPi/{wiringPi => devLib}/piNes.h (100%) create mode 100644 WiringPi/examples/Gertboard/7segments.c create mode 100644 WiringPi/examples/Gertboard/Makefile create mode 100644 WiringPi/examples/Gertboard/buttons.c rename WiringPi/examples/{ => Gertboard}/gertboard.c (61%) create mode 100644 WiringPi/examples/Gertboard/record.c create mode 100644 WiringPi/examples/Gertboard/temperature.c create mode 100644 WiringPi/examples/Gertboard/voltmeter.c create mode 100644 WiringPi/examples/Gertboard/vumeter.c create mode 100644 WiringPi/examples/PiFace/Makefile create mode 100644 WiringPi/examples/PiFace/blink.c rename WiringPi/examples/{piface.c => PiFace/buttons.c} (57%) create mode 100755 WiringPi/examples/PiFace/ladder.c create mode 100644 WiringPi/examples/PiFace/metro.c create mode 100644 WiringPi/examples/PiFace/motor.c create mode 100644 WiringPi/examples/PiFace/reaction.c rename WiringPi/examples/{test1.c => blink12.c} (70%) create mode 100644 WiringPi/examples/blink8.c create mode 100644 WiringPi/examples/clock.c delete mode 100644 WiringPi/examples/ds1302.c delete mode 100644 WiringPi/examples/gertboard.png create mode 100644 WiringPi/examples/lcd-adafruit.c create mode 100644 WiringPi/examples/q2w/Makefile create mode 100644 WiringPi/examples/q2w/binary.c create mode 100644 WiringPi/examples/q2w/blink-io.c rename WiringPi/examples/{test2.c => q2w/blink.c} (70%) create mode 100755 WiringPi/examples/q2w/blink.sh create mode 100644 WiringPi/examples/q2w/bright.c create mode 100644 WiringPi/examples/q2w/button.c create mode 100644 WiringPi/examples/q2w/volts.c create mode 100644 WiringPi/examples/rht03.c create mode 100644 WiringPi/examples/softPwm.c rename WiringPi/examples/{tone.c => softTone.c} (92%) create mode 100644 WiringPi/gpio/extensions.c create mode 100644 WiringPi/gpio/extensions.h create mode 100755 WiringPi/gpio/pintest create mode 100644 WiringPi/wiringPi/COPYING.LESSER create mode 100644 WiringPi/wiringPi/drc.c create mode 100644 WiringPi/wiringPi/drc.h create mode 100644 WiringPi/wiringPi/mcp23016.c create mode 100644 WiringPi/wiringPi/mcp23016.h create mode 100644 WiringPi/wiringPi/mcp23016reg.h create mode 100644 WiringPi/wiringPi/mcp3002.c create mode 100644 WiringPi/wiringPi/mcp3002.h create mode 100644 WiringPi/wiringPi/mcp3422.c create mode 100644 WiringPi/wiringPi/mcp3422.h create mode 100644 WiringPi/wiringPi/mcp4802.c create mode 100644 WiringPi/wiringPi/mcp4802.h create mode 100644 WiringPi/wiringPi/pcf8574.c create mode 100644 WiringPi/wiringPi/pcf8574.h create mode 100644 WiringPi/wiringPi/pcf8591.c create mode 100644 WiringPi/wiringPi/pcf8591.h delete mode 100644 WiringPi/wiringPi/piFace.c diff --git a/.gitignore b/.gitignore index 5c4a878..a53473d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ wiringpi2.egg-info/ dist/ __pycache__ +.pyc diff --git a/WiringPi/INSTALL b/WiringPi/INSTALL index 8a6d38e..8e0c43c 100644 --- a/WiringPi/INSTALL +++ b/WiringPi/INSTALL @@ -30,18 +30,6 @@ To un-install wiringPi: ./build uninstall - -I2C: - -If your system has the correct i2c-dev libraries and headers installed, -then the I2C helpers will be compiled into wiringPi. If you want to -use the I2C helpers and don't have them installed, then under Raspbian, -issue the command: - - sudo apt-get install libi2c-dev - -Consult the documentation for your system if you are not running Raspbian. - Gordon Henderson projects@drogon.net diff --git a/WiringPi/People b/WiringPi/People index 8be8b6d..92d1ea4 100644 --- a/WiringPi/People +++ b/WiringPi/People @@ -25,3 +25,6 @@ CHARLES Thibaut: Xian Stannard Fixing some typos in the man page! + +Andre Crone + Suggested the __WIRING_PI.H__ round wiringPi.h diff --git a/WiringPi/README b/WiringPi/README deleted file mode 100644 index c79754e..0000000 --- a/WiringPi/README +++ /dev/null @@ -1,9 +0,0 @@ - -WiringPi: An implementation of most of the Arduino Wiring - functions for the Raspberry Pi, - along with many more features and libraries to support - hardware, etc. on the Raspberry Pi - -Full details at: - https://projects.drogon.net/raspberry-pi/wiringpi/ - diff --git a/WiringPi/README.TXT b/WiringPi/README.TXT index 0fce86a..7789b2e 100644 --- a/WiringPi/README.TXT +++ b/WiringPi/README.TXT @@ -16,7 +16,7 @@ accepted to Github.... Please see - https://projects.drogon.net/raspberry-pi/wiringpi/ + http://wiringpi.com/ for the official documentation, etc. and the best way to submit bug reports, etc. is by sending an email to projects@drogon.net diff --git a/WiringPi/build b/WiringPi/build new file mode 100755 index 0000000..776c756 --- /dev/null +++ b/WiringPi/build @@ -0,0 +1,87 @@ +#!/bin/bash + +check-make-ok() +{ + if [ $? != 0 ]; then + echo "" + echo "Make Failed..." + echo "Please check the messages and fix any problems. If you're still stuck," + echo "then please email all the output and as many details as you can to" + echo " projects@drogon.net" + echo "" + exit 1 + fi +} + +if [ x$1 = "xclean" ]; then + cd wiringPi + echo -n "wiringPi: " ; make clean + cd ../devLib + echo -n "DevLib: " ; make clean + cd ../gpio + echo -n "gpio: " ; make clean + cd ../examples + echo -n "Examples: " ; make clean + cd Gertboard + echo -n "Gertboard: " ; make clean + cd ../PiFace + echo -n "PiFace: " ; make clean + cd ../q2w + echo -n "Quick2Wire: " ; make clean + exit +fi + +if [ x$1 = "xuninstall" ]; then + cd wiringPi + echo -n "wiringPi: " ; sudo make uninstall + cd ../devLib + echo -n "DevLib: " ; sudo make uninstall + cd ../gpio + echo -n "gpio: " ; sudo make uninstall + exit +fi + + + echo "wiringPi Build script" + echo "=====================" + echo + + echo + echo "WiringPi Library" + cd wiringPi + sudo make uninstall + make + check-make-ok + sudo make install + check-make-ok + + echo + echo "WiringPi Devices Library" + cd ../devLib + sudo make uninstall + make + check-make-ok + sudo make install + check-make-ok + + echo + echo "GPIO Utility" + cd ../gpio + make + check-make-ok + sudo make install + check-make-ok + +# echo +# echo "Examples" +# cd ../examples +# make +# cd .. + +echo +echo All Done. +echo "" +echo "NOTE: This is wiringPi v2, and if you need to use the lcd, Piface," +echo " Gertboard, MaxDetext, etc. routines then you must change your" +echo " compile scripts to add -lwiringPiDev" +echo "" diff --git a/WiringPi/devLib/Makefile b/WiringPi/devLib/Makefile new file mode 100644 index 0000000..a106d93 --- /dev/null +++ b/WiringPi/devLib/Makefile @@ -0,0 +1,130 @@ +# Makefile: +# wiringPi device - Wiring Compatable library for the Raspberry Pi +# +# Copyright (c) 2012-2013 Gordon Henderson +################################################################################# +# This file is part of wiringPi: +# https://projects.drogon.net/raspberry-pi/wiringpi/ +# +# wiringPi is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# wiringPi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with wiringPi. If not, see . +################################################################################# + +DYN_VERS_MAJ=2 +DYN_VERS_MIN=0 + +VERSION=$(DYN_VERS_MAJ).$(DYN_VERS_MIN) +DESTDIR=/usr +PREFIX=/local + +STATIC=libwiringPiDev.a +DYNAMIC=libwiringPiDev.so.$(VERSION) + +#DEBUG = -g -O0 +DEBUG = -O2 +CC = gcc +INCLUDE = -I. +CFLAGS = $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC + +LIBS = + +############################################################################### + +SRC = ds1302.c maxdetect.c piNes.c \ + gertboard.c piFace.c \ + lcd128x64.c lcd.c + +OBJ = $(SRC:.c=.o) + +all: $(DYNAMIC) + +static: $(STATIC) + +$(STATIC): $(OBJ) + @echo "[Link (Static)]" + @ar rcs $(STATIC) $(OBJ) + @ranlib $(STATIC) +# @size $(STATIC) + +$(DYNAMIC): $(OBJ) + @echo "[Link (Dynamic)]" + @$(CC) -shared -Wl,-soname,libwiringPiDev.so -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ) + +.c.o: + @echo [Compile] $< + @$(CC) -c $(CFLAGS) $< -o $@ + +.PHONEY: clean +clean: + @echo "[Clean]" + @rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.* + +.PHONEY: tags +tags: $(SRC) + @echo [ctags] + @ctags $(SRC) + + +.PHONEY: install-headers +install-headers: + @echo "[Install Headers]" + @install -m 0755 -d $(DESTDIR)$(PREFIX)/include + @install -m 0644 ds1302.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 maxdetect.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 piNes.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 gertboard.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 piFace.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 lcd128x64.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 lcd.h $(DESTDIR)$(PREFIX)/include + +.PHONEY: install +install: $(DYNAMIC) install-headers + @echo "[Install Dynamic Lib]" + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib + @install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) + @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so + @ldconfig + +.PHONEY: install-static +install-static: $(STATIC) install-headers + @echo "[Install Static Lib]" + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib + @install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib + +.PHONEY: uninstall +uninstall: + @echo "[UnInstall]" + @rm -f $(DESTDIR)$(PREFIX)/include/ds1302.h + @rm -f $(DESTDIR)$(PREFIX)/include/maxdetect.h + @rm -f $(DESTDIR)$(PREFIX)/include/piNes.h + @rm -f $(DESTDIR)$(PREFIX)/include/gertboard.h + @rm -f $(DESTDIR)$(PREFIX)/include/piFace.h + @rm -f $(DESTDIR)$(PREFIX)/include/lcd128x64.h + @rm -f $(DESTDIR)$(PREFIX)/include/lcd.h + @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.* + @ldconfig + + +.PHONEY: depend +depend: + makedepend -Y $(SRC) + +# DO NOT DELETE + +ds1302.o: ds1302.h +maxdetect.o: maxdetect.h +piNes.o: piNes.h +gertboard.o: gertboard.h +piFace.o: piFace.h +lcd128x64.o: font.h lcd128x64.h +lcd.o: lcd.h diff --git a/WiringPi/wiringPi/ds1302.c b/WiringPi/devLib/ds1302.c similarity index 90% rename from WiringPi/wiringPi/ds1302.c rename to WiringPi/devLib/ds1302.c index ce5da29..cf64de7 100644 --- a/WiringPi/wiringPi/ds1302.c +++ b/WiringPi/devLib/ds1302.c @@ -27,7 +27,8 @@ #include #include -#include "wiringPi.h" +#include + #include "ds1302.h" // Register defines @@ -55,7 +56,7 @@ static int dPin, cPin, sPin ; ********************************************************************************* */ -unsigned int dsShiftIn (void) +static unsigned int dsShiftIn (void) { uint8_t value = 0 ; int i ; @@ -80,7 +81,7 @@ unsigned int dsShiftIn (void) ********************************************************************************* */ -void dsShiftOut (unsigned int data) +static void dsShiftOut (unsigned int data) { int i ; @@ -101,7 +102,7 @@ void dsShiftOut (unsigned int data) ********************************************************************************* */ -static unsigned int ds1302regRead (int reg) +static unsigned int ds1302regRead (const int reg) { unsigned int data ; @@ -113,7 +114,7 @@ static unsigned int ds1302regRead (int reg) return data ; } -static void ds1302regWrite (int reg, unsigned int data) +static void ds1302regWrite (const int reg, const unsigned int data) { digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ; dsShiftOut (reg) ; @@ -128,7 +129,7 @@ static void ds1302regWrite (int reg, unsigned int data) ********************************************************************************* */ -unsigned int ds1302rtcRead (int reg) +unsigned int ds1302rtcRead (const int reg) { return ds1302regRead (0x81 | ((reg & 0x1F) << 1)) ; } @@ -145,12 +146,12 @@ void ds1302rtcWrite (int reg, unsigned int data) ********************************************************************************* */ -unsigned int ds1302ramRead (int addr) +unsigned int ds1302ramRead (const int addr) { return ds1302regRead (0xC1 | ((addr & 0x1F) << 1)) ; } -void ds1302ramWrite (int addr, unsigned int data) +void ds1302ramWrite (const int addr, const unsigned int data) { ds1302regWrite ( 0xC0 | ((addr & 0x1F) << 1), data) ; } @@ -182,7 +183,7 @@ void ds1302clockRead (int clockData [8]) ********************************************************************************* */ -void ds1302clockWrite (int clockData [8]) +void ds1302clockWrite (const int clockData [8]) { int i ; unsigned int regVal = 0x80 | ((RTC_BM & 0x1F) << 1) ; @@ -204,7 +205,7 @@ void ds1302clockWrite (int clockData [8]) ********************************************************************************* */ -void ds1302trickleCharge (int diodes, int resistors) +void ds1302trickleCharge (const int diodes, const int resistors) { if (diodes + resistors == 0) ds1302rtcWrite (RTC_TC, 0x5C) ; // Disabled @@ -221,7 +222,7 @@ void ds1302trickleCharge (int diodes, int resistors) ********************************************************************************* */ -void ds1302setup (int clockPin, int dataPin, int csPin) +void ds1302setup (const int clockPin, const int dataPin, const int csPin) { dPin = dataPin ; cPin = clockPin ; diff --git a/WiringPi/wiringPi/ds1302.h b/WiringPi/devLib/ds1302.h similarity index 68% rename from WiringPi/wiringPi/ds1302.h rename to WiringPi/devLib/ds1302.h index 8449a9b..e82b3ed 100644 --- a/WiringPi/wiringPi/ds1302.h +++ b/WiringPi/devLib/ds1302.h @@ -26,18 +26,18 @@ extern "C" { #endif -extern unsigned int ds1302rtcRead (int reg) ; -extern void ds1302rtcWrite (int reg, unsigned int data) ; +extern unsigned int ds1302rtcRead (const int reg) ; +extern void ds1302rtcWrite (const int reg, const unsigned int data) ; -extern unsigned int ds1302ramRead (int addr) ; -extern void ds1302ramWrite (int addr, unsigned int data) ; +extern unsigned int ds1302ramRead (const int addr) ; +extern void ds1302ramWrite (const int addr, const unsigned int data) ; extern void ds1302clockRead (int clockData [8]) ; -extern void ds1302clockWrite (int clockData [8]) ; +extern void ds1302clockWrite (const int clockData [8]) ; -extern void ds1302trickleCharge (int diodes, int resistors) ; +extern void ds1302trickleCharge (const int diodes, const int resistors) ; -extern void ds1302setup (int clockPin, int dataPin, int csPin) ; +extern void ds1302setup (const int clockPin, const int dataPin, const int csPin) ; #ifdef __cplusplus } diff --git a/WiringPi/devLib/font.h b/WiringPi/devLib/font.h new file mode 100644 index 0000000..ce99e16 --- /dev/null +++ b/WiringPi/devLib/font.h @@ -0,0 +1,2577 @@ +/**********************************************/ +/* */ +/* Font file generated by cpi2fnt */ +/* ------------------------------ */ +/* Combined with the alpha-numeric */ +/* portion of Greg Harp's old PEARL */ +/* font (from earlier versions of */ +/* linux-m86k) by John Shifflett */ +/* */ +/**********************************************/ + +static const int fontHeight = 8 ; +static const int fontWidth = 8 ; + +static unsigned char font [] = +{ + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 1 0x01 '^A' */ + 0x7e, /* 01111110 */ + 0x81, /* 10000001 */ + 0xa5, /* 10100101 */ + 0x81, /* 10000001 */ + 0xbd, /* 10111101 */ + 0x99, /* 10011001 */ + 0x81, /* 10000001 */ + 0x7e, /* 01111110 */ + + /* 2 0x02 '^B' */ + 0x7e, /* 01111110 */ + 0xff, /* 11111111 */ + 0xdb, /* 11011011 */ + 0xff, /* 11111111 */ + 0xc3, /* 11000011 */ + 0xe7, /* 11100111 */ + 0xff, /* 11111111 */ + 0x7e, /* 01111110 */ + + /* 3 0x03 '^C' */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0x10, /* 00010000 */ + 0x00, /* 00000000 */ + + /* 4 0x04 '^D' */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0x10, /* 00010000 */ + 0x00, /* 00000000 */ + + /* 5 0x05 '^E' */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + + /* 6 0x06 '^F' */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + + /* 7 0x07 '^G' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 8 0x08 '^H' */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xe7, /* 11100111 */ + 0xc3, /* 11000011 */ + 0xc3, /* 11000011 */ + 0xe7, /* 11100111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* 9 0x09 '^I' */ + 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x42, /* 01000010 */ + 0x42, /* 01000010 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 10 0x0a '^J' */ + 0xff, /* 11111111 */ + 0xc3, /* 11000011 */ + 0x99, /* 10011001 */ + 0xbd, /* 10111101 */ + 0xbd, /* 10111101 */ + 0x99, /* 10011001 */ + 0xc3, /* 11000011 */ + 0xff, /* 11111111 */ + + /* 11 0x0b '^K' */ + 0x0f, /* 00001111 */ + 0x07, /* 00000111 */ + 0x0f, /* 00001111 */ + 0x7d, /* 01111101 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x78, /* 01111000 */ + + /* 12 0x0c '^L' */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + + /* 13 0x0d '^M' */ + 0x3f, /* 00111111 */ + 0x33, /* 00110011 */ + 0x3f, /* 00111111 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x70, /* 01110000 */ + 0xf0, /* 11110000 */ + 0xe0, /* 11100000 */ + + /* 14 0x0e '^N' */ + 0x7f, /* 01111111 */ + 0x63, /* 01100011 */ + 0x7f, /* 01111111 */ + 0x63, /* 01100011 */ + 0x63, /* 01100011 */ + 0x67, /* 01100111 */ + 0xe6, /* 11100110 */ + 0xc0, /* 11000000 */ + + /* 15 0x0f '^O' */ + 0x18, /* 00011000 */ + 0xdb, /* 11011011 */ + 0x3c, /* 00111100 */ + 0xe7, /* 11100111 */ + 0xe7, /* 11100111 */ + 0x3c, /* 00111100 */ + 0xdb, /* 11011011 */ + 0x18, /* 00011000 */ + + /* 16 0x10 '^P' */ + 0x80, /* 10000000 */ + 0xe0, /* 11100000 */ + 0xf8, /* 11111000 */ + 0xfe, /* 11111110 */ + 0xf8, /* 11111000 */ + 0xe0, /* 11100000 */ + 0x80, /* 10000000 */ + 0x00, /* 00000000 */ + + /* 17 0x11 '^Q' */ + 0x02, /* 00000010 */ + 0x0e, /* 00001110 */ + 0x3e, /* 00111110 */ + 0xfe, /* 11111110 */ + 0x3e, /* 00111110 */ + 0x0e, /* 00001110 */ + 0x02, /* 00000010 */ + 0x00, /* 00000000 */ + + /* 18 0x12 '^R' */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + + /* 19 0x13 '^S' */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* 20 0x14 '^T' */ + 0x7f, /* 01111111 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7b, /* 01111011 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x00, /* 00000000 */ + + /* 21 0x15 '^U' */ + 0x3e, /* 00111110 */ + 0x61, /* 01100001 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x86, /* 10000110 */ + 0x7c, /* 01111100 */ + + /* 22 0x16 '^V' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 23 0x17 '^W' */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + + /* 24 0x18 '^X' */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 25 0x19 '^Y' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 26 0x1a '^Z' */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0xfe, /* 11111110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 27 0x1b '^[' */ + 0x00, /* 00000000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xfe, /* 11111110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 28 0x1c '^\' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 29 0x1d '^]' */ + 0x00, /* 00000000 */ + 0x24, /* 00100100 */ + 0x66, /* 01100110 */ + 0xff, /* 11111111 */ + 0x66, /* 01100110 */ + 0x24, /* 00100100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 30 0x1e '^^' */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 31 0x1f '^_' */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 32 0x20 ' ' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 33 0x21 '!' */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 34 0x22 '"' */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 35 0x23 '#' */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* 36 0x24 '$' */ + 0x18, /* 00011000 */ + 0x3e, /* 00111110 */ + 0x60, /* 01100000 */ + 0x3c, /* 00111100 */ + 0x06, /* 00000110 */ + 0x7c, /* 01111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 37 0x25 '%' */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xcc, /* 11001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x66, /* 01100110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 38 0x26 '&' */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x68, /* 01101000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 39 0x27 ''' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 40 0x28 '(' */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + + /* 41 0x29 ')' */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + + /* 42 0x2a '*' */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0xff, /* 11111111 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 43 0x2b '+' */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 44 0x2c ',' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + + /* 45 0x2d '-' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 46 0x2e '.' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 47 0x2f '/' */ + 0x03, /* 00000011 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + + /* 48 0x30 '0' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xde, /* 11011110 */ + 0xfe, /* 11111110 */ + 0xf6, /* 11110110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 49 0x31 '1' */ + 0x18, /* 00011000 */ + 0x78, /* 01111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 50 0x32 '2' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 51 0x33 '3' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x06, /* 00000110 */ + 0x1c, /* 00011100 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 52 0x34 '4' */ + 0x1c, /* 00011100 */ + 0x3c, /* 00111100 */ + 0x6c, /* 01101100 */ + 0xcc, /* 11001100 */ + 0xfe, /* 11111110 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + + /* 53 0x35 '5' */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 54 0x36 '6' */ + 0x38, /* 00111000 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 55 0x37 '7' */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0x00, /* 00000000 */ + + /* 56 0x38 '8' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 57 0x39 '9' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* 58 0x3a ':' */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 59 0x3b ';' */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + + /* 60 0x3c '<' */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + + /* 61 0x3d '=' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 62 0x3e '>' */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + + /* 63 0x3f '?' */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 64 0x40 '@' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xde, /* 11011110 */ + 0xde, /* 11011110 */ + 0xde, /* 11011110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 65 0x41 'A' */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 66 0x42 'B' */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* 67 0x43 'C' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 68 0x44 'D' */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* 69 0x45 'E' */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xf8, /* 11111000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 70 0x46 'F' */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xf8, /* 11111000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + + /* 71 0x47 'G' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xce, /* 11001110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 72 0x48 'H' */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 73 0x49 'I' */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 74 0x4a 'J' */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 75 0x4b 'K' */ + 0xc6, /* 11000110 */ + 0xcc, /* 11001100 */ + 0xd8, /* 11011000 */ + 0xf0, /* 11110000 */ + 0xd8, /* 11011000 */ + 0xcc, /* 11001100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 76 0x4c 'L' */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 77 0x4d 'M' */ + 0x82, /* 10000010 */ + 0xc6, /* 11000110 */ + 0xee, /* 11101110 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 78 0x4e 'N' */ + 0xc6, /* 11000110 */ + 0xe6, /* 11100110 */ + 0xf6, /* 11110110 */ + 0xde, /* 11011110 */ + 0xce, /* 11001110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 79 0x4f 'O' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 80 0x50 'P' */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfc, /* 11111100 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + + /* 81 0x51 'Q' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xf6, /* 11110110 */ + 0xde, /* 11011110 */ + 0x7c, /* 01111100 */ + 0x06, /* 00000110 */ + + /* 82 0x52 'R' */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfc, /* 11111100 */ + 0xd8, /* 11011000 */ + 0xcc, /* 11001100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 83 0x53 'S' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x60, /* 01100000 */ + 0x38, /* 00111000 */ + 0x0c, /* 00001100 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 84 0x54 'T' */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 85 0x55 'U' */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 86 0x56 'V' */ + 0xc3, /* 11000011 */ + 0xc3, /* 11000011 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 87 0x57 'W' */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xfe, /* 11111110 */ + 0xee, /* 11101110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 88 0x58 'X' */ + 0xc3, /* 11000011 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0xc3, /* 11000011 */ + 0x00, /* 00000000 */ + + /* 89 0x59 'Y' */ + 0xc3, /* 11000011 */ + 0xc3, /* 11000011 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 90 0x5a 'Z' */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 91 0x5b '[' */ + 0x3c, /* 00111100 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 92 0x5c '\' */ + 0xc0, /* 11000000 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x06, /* 00000110 */ + 0x03, /* 00000011 */ + 0x00, /* 00000000 */ + + /* 93 0x5d ']' */ + 0x3c, /* 00111100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 94 0x5e '^' */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 95 0x5f '_' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + + /* 96 0x60 '`' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 97 0x61 'a' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0x06, /* 00000110 */ + 0x7e, /* 01111110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 98 0x62 'b' */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* 99 0x63 'c' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 100 0x64 'd' */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x7e, /* 01111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 101 0x65 'e' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 102 0x66 'f' */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0x00, /* 00000000 */ + + /* 103 0x67 'g' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0x7c, /* 01111100 */ + + /* 104 0x68 'h' */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 105 0x69 'i' */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 106 0x6a 'j' */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + + /* 107 0x6b 'k' */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xcc, /* 11001100 */ + 0xd8, /* 11011000 */ + 0xf0, /* 11110000 */ + 0xd8, /* 11011000 */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + + /* 108 0x6c 'l' */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 109 0x6d 'm' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xec, /* 11101100 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 110 0x6e 'n' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 111 0x6f 'o' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 112 0x70 'p' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfc, /* 11111100 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + + /* 113 0x71 'q' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + + /* 114 0x72 'r' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0xe6, /* 11100110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + + /* 115 0x73 's' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* 116 0x74 't' */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x7c, /* 01111100 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x36, /* 00110110 */ + 0x1c, /* 00011100 */ + 0x00, /* 00000000 */ + + /* 117 0x75 'u' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 118 0x76 'v' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* 119 0x77 'w' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* 120 0x78 'x' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 121 0x79 'y' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc3, /* 11000011 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + + /* 122 0x7a 'z' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x0c, /* 00001100 */ + 0x38, /* 00111000 */ + 0x60, /* 01100000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 123 0x7b '{' */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x70, /* 01110000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0e, /* 00001110 */ + 0x00, /* 00000000 */ + + /* 124 0x7c '|' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 125 0x7d '}' */ + 0x70, /* 01110000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* 126 0x7e '~' */ + 0x72, /* 01110010 */ + 0x9c, /* 10011100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 127 0x7f '' */ + 0x00, /* 00000000 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 128 0x80 '' */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x0c, /* 00001100 */ + 0x78, /* 01111000 */ + + /* 129 0x81 '' */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 130 0x82 '' */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 131 0x83 '' */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 132 0x84 '' */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 133 0x85 '' */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 134 0x86 '' */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 135 0x87 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x7e, /* 01111110 */ + 0x0c, /* 00001100 */ + 0x38, /* 00111000 */ + + /* 136 0x88 '' */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 137 0x89 '' */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 138 0x8a '' */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 139 0x8b '' */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 140 0x8c '' */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 141 0x8d '' */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 142 0x8e '' */ + 0xc6, /* 11000110 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 143 0x8f '' */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 144 0x90 '' */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xf8, /* 11111000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 145 0x91 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0xd8, /* 11011000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 146 0x92 '' */ + 0x3e, /* 00111110 */ + 0x6c, /* 01101100 */ + 0xcc, /* 11001100 */ + 0xfe, /* 11111110 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xce, /* 11001110 */ + 0x00, /* 00000000 */ + + /* 147 0x93 '' */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 148 0x94 '' */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 149 0x95 '' */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 150 0x96 '' */ + 0x78, /* 01111000 */ + 0x84, /* 10000100 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 151 0x97 '' */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 152 0x98 '' */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + + /* 153 0x99 '' */ + 0xc6, /* 11000110 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* 154 0x9a '' */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 155 0x9b '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 156 0x9c '' */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x64, /* 01100100 */ + 0xf0, /* 11110000 */ + 0x60, /* 01100000 */ + 0x66, /* 01100110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* 157 0x9d '' */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 158 0x9e '' */ + 0xf8, /* 11111000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xfa, /* 11111010 */ + 0xc6, /* 11000110 */ + 0xcf, /* 11001111 */ + 0xc6, /* 11000110 */ + 0xc7, /* 11000111 */ + + /* 159 0x9f '' */ + 0x0e, /* 00001110 */ + 0x1b, /* 00011011 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* 160 0xa0 '' */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 161 0xa1 '' */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 162 0xa2 '' */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* 163 0xa3 '' */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 164 0xa4 '' */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* 165 0xa5 '' */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0xe6, /* 11100110 */ + 0xf6, /* 11110110 */ + 0xde, /* 11011110 */ + 0xce, /* 11001110 */ + 0x00, /* 00000000 */ + + /* 166 0xa6 '' */ + 0x3c, /* 00111100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x3e, /* 00111110 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 167 0xa7 '' */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 168 0xa8 '' */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x63, /* 01100011 */ + 0x3e, /* 00111110 */ + 0x00, /* 00000000 */ + + /* 169 0xa9 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 170 0xaa '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 171 0xab '' */ + 0x63, /* 01100011 */ + 0xe6, /* 11100110 */ + 0x6c, /* 01101100 */ + 0x7e, /* 01111110 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x0f, /* 00001111 */ + + /* 172 0xac '' */ + 0x63, /* 01100011 */ + 0xe6, /* 11100110 */ + 0x6c, /* 01101100 */ + 0x7a, /* 01111010 */ + 0x36, /* 00110110 */ + 0x6a, /* 01101010 */ + 0xdf, /* 11011111 */ + 0x06, /* 00000110 */ + + /* 173 0xad '' */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 174 0xae '' */ + 0x00, /* 00000000 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x66, /* 01100110 */ + 0x33, /* 00110011 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 175 0xaf '' */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0x66, /* 01100110 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 176 0xb0 '' */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + + /* 177 0xb1 '' */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + + /* 178 0xb2 '' */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + + /* 179 0xb3 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 180 0xb4 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 181 0xb5 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 182 0xb6 '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 183 0xb7 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 184 0xb8 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 185 0xb9 '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x06, /* 00000110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 186 0xba '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 187 0xbb '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 188 0xbc '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x06, /* 00000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 189 0xbd '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 190 0xbe '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 191 0xbf '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 192 0xc0 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 193 0xc1 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 194 0xc2 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 195 0xc3 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 196 0xc4 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 197 0xc5 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 198 0xc6 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 199 0xc7 '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 200 0xc8 '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x30, /* 00110000 */ + 0x3f, /* 00111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 201 0xc9 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 00111111 */ + 0x30, /* 00110000 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 202 0xca '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf7, /* 11110111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 203 0xcb '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xf7, /* 11110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 204 0xcc '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x30, /* 00110000 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 205 0xcd '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 206 0xce '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf7, /* 11110111 */ + 0x00, /* 00000000 */ + 0xf7, /* 11110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 207 0xcf '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 208 0xd0 '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 209 0xd1 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 210 0xd2 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 211 0xd3 '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x3f, /* 00111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 212 0xd4 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 213 0xd5 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 214 0xd6 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 00111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 215 0xd7 '' */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xff, /* 11111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* 216 0xd8 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 217 0xd9 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 218 0xda '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 219 0xdb '' */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* 220 0xdc '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* 221 0xdd '' */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + + /* 222 0xde '' */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + + /* 223 0xdf '' */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 224 0xe0 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0xc8, /* 11001000 */ + 0xdc, /* 11011100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* 225 0xe1 '' */ + 0x78, /* 01111000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xd8, /* 11011000 */ + 0xcc, /* 11001100 */ + 0xc6, /* 11000110 */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + + /* 226 0xe2 '' */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + + /* 227 0xe3 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* 228 0xe4 '' */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* 229 0xe5 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* 230 0xe6 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0xc0, /* 11000000 */ + + /* 231 0xe7 '' */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* 232 0xe8 '' */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + + /* 233 0xe9 '' */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* 234 0xea '' */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0xee, /* 11101110 */ + 0x00, /* 00000000 */ + + /* 235 0xeb '' */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x3e, /* 00111110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* 236 0xec '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 237 0xed '' */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x7e, /* 01111110 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7e, /* 01111110 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + + /* 238 0xee '' */ + 0x1e, /* 00011110 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0x7e, /* 01111110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x1e, /* 00011110 */ + 0x00, /* 00000000 */ + + /* 239 0xef '' */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* 240 0xf0 '' */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 241 0xf1 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 242 0xf2 '' */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 243 0xf3 '' */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* 244 0xf4 '' */ + 0x0e, /* 00001110 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* 245 0xf5 '' */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + + /* 246 0xf6 '' */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 247 0xf7 '' */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 248 0xf8 '' */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 249 0xf9 '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 250 0xfa '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 251 0xfb '' */ + 0x0f, /* 00001111 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0xec, /* 11101100 */ + 0x6c, /* 01101100 */ + 0x3c, /* 00111100 */ + 0x1c, /* 00011100 */ + + /* 252 0xfc '' */ + 0x6c, /* 01101100 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 253 0xfd '' */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 254 0xfe '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* 255 0xff '' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + +}; diff --git a/WiringPi/wiringPi/gertboard.c b/WiringPi/devLib/gertboard.c similarity index 86% rename from WiringPi/wiringPi/gertboard.c rename to WiringPi/devLib/gertboard.c index 87dbe41..5aeaef7 100644 --- a/WiringPi/wiringPi/gertboard.c +++ b/WiringPi/devLib/gertboard.c @@ -38,8 +38,8 @@ #include #include -#include "wiringPi.h" -#include "wiringPiSPI.h" +#include +#include #include "gertboard.h" @@ -58,7 +58,7 @@ ********************************************************************************* */ -void gertboardAnalogWrite (int chan, int value) +void gertboardAnalogWrite (const int chan, const int value) { uint8_t spiData [2] ; uint8_t chanBits, dataBits ; @@ -85,7 +85,7 @@ void gertboardAnalogWrite (int chan, int value) ********************************************************************************* */ -int gertboardAnalogRead (int chan) +int gertboardAnalogRead (const int chan) { uint8_t spiData [2] ; @@ -128,16 +128,14 @@ int gertboardSPISetup (void) ********************************************************************************* */ -int gbWiringPiAnalogRead (struct wiringPiNodeStruct *node, int chan) +static int myAnalogRead (struct wiringPiNodeStruct *node, const int chan) { - chan -= node->pinBase ; - return gertboardAnalogRead (chan) ; + return gertboardAnalogRead (chan - node->pinBase) ; } -void gbWiringPiAnalogWrite (struct wiringPiNodeStruct *node, int chan, int value) +static void myAnalogWrite (struct wiringPiNodeStruct *node, const int chan, const int value) { - chan -= node->pinBase ; - gertboardAnalogWrite (chan, value) ; + gertboardAnalogWrite (chan - node->pinBase, value) ; } @@ -150,7 +148,7 @@ void gbWiringPiAnalogWrite (struct wiringPiNodeStruct *node, int chan, int value ********************************************************************************* */ -int gertboardAnalogSetup (int pinBase) +int gertboardAnalogSetup (const int pinBase) { struct wiringPiNodeStruct *node ; int x ; @@ -159,8 +157,8 @@ int gertboardAnalogSetup (int pinBase) return x; node = wiringPiNewNode (pinBase, 2) ; - node->analogRead = gbWiringPiAnalogRead ; - node->analogWrite = gbWiringPiAnalogWrite ; + node->analogRead = myAnalogRead ; + node->analogWrite = myAnalogWrite ; return 0 ; } diff --git a/WiringPi/wiringPi/gertboard.h b/WiringPi/devLib/gertboard.h similarity index 86% rename from WiringPi/wiringPi/gertboard.h rename to WiringPi/devLib/gertboard.h index e96300f..3fa1919 100644 --- a/WiringPi/wiringPi/gertboard.h +++ b/WiringPi/devLib/gertboard.h @@ -30,10 +30,15 @@ extern "C" { #endif -extern void gertboardAnalogWrite (int chan, int value) ; -extern int gertboardAnalogRead (int chan) ; +// Old routines + +extern void gertboardAnalogWrite (const int chan, const int value) ; +extern int gertboardAnalogRead (const int chan) ; extern int gertboardSPISetup (void) ; -extern int gertboardAnalogSetup (int pinBase) ; + +// New + +extern int gertboardAnalogSetup (const int pinBase) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/lcd.c b/WiringPi/devLib/lcd.c similarity index 64% rename from WiringPi/wiringPi/lcd.c rename to WiringPi/devLib/lcd.c index f123db2..6c0e474 100644 --- a/WiringPi/wiringPi/lcd.c +++ b/WiringPi/devLib/lcd.c @@ -26,29 +26,40 @@ #include #include -#include #include -#include "wiringPi.h" +#include + #include "lcd.h" -// Commands +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + +// HD44780U Commands #define LCD_CLEAR 0x01 #define LCD_HOME 0x02 #define LCD_ENTRY 0x04 -#define LCD_ON_OFF 0x08 +#define LCD_CTRL 0x08 #define LCD_CDSHIFT 0x10 #define LCD_FUNC 0x20 #define LCD_CGRAM 0x40 #define LCD_DGRAM 0x80 -#define LCD_ENTRY_SH 0x01 -#define LCD_ENTRY_ID 0x02 +// Bits in the entry register -#define LCD_ON_OFF_B 0x01 -#define LCD_ON_OFF_C 0x02 -#define LCD_ON_OFF_D 0x04 +#define LCD_ENTRY_SH 0x01 +#define LCD_ENTRY_ID 0x02 + +// Bits in the control register + +#define LCD_BLINK_CTRL 0x01 +#define LCD_CURSOR_CTRL 0x02 +#define LCD_DISPLAY_CTRL 0x04 + +// Bits in the function register #define LCD_FUNC_F 0x04 #define LCD_FUNC_N 0x08 @@ -58,13 +69,20 @@ struct lcdDataStruct { - uint8_t bits, rows, cols ; - uint8_t rsPin, strbPin ; - uint8_t dataPins [8] ; + int bits, rows, cols ; + int rsPin, strbPin ; + int dataPins [8] ; + int cx, cy ; } ; struct lcdDataStruct *lcds [MAX_LCDS] ; +static int lcdControl ; + +// Row offsets + +static const int rowOff [4] = { 0x00, 0x40, 0x14, 0x54 } ; + /* * strobe: @@ -73,7 +91,7 @@ struct lcdDataStruct *lcds [MAX_LCDS] ; ********************************************************************************* */ -static void strobe (struct lcdDataStruct *lcd) +static void strobe (const struct lcdDataStruct *lcd) { // Note timing changes for new version of delayMicroseconds () @@ -89,13 +107,14 @@ static void strobe (struct lcdDataStruct *lcd) ********************************************************************************* */ -static void sendDataCmd (struct lcdDataStruct *lcd, uint8_t data) +static void sendDataCmd (const struct lcdDataStruct *lcd, unsigned char data) { - uint8_t i, d4 ; + register unsigned char myData = data ; + unsigned char i, d4 ; if (lcd->bits == 4) { - d4 = (data >> 4) & 0x0F; + d4 = (myData >> 4) & 0x0F; for (i = 0 ; i < 4 ; ++i) { digitalWrite (lcd->dataPins [i], (d4 & 1)) ; @@ -103,7 +122,7 @@ static void sendDataCmd (struct lcdDataStruct *lcd, uint8_t data) } strobe (lcd) ; - d4 = data & 0x0F ; + d4 = myData & 0x0F ; for (i = 0 ; i < 4 ; ++i) { digitalWrite (lcd->dataPins [i], (d4 & 1)) ; @@ -114,8 +133,8 @@ static void sendDataCmd (struct lcdDataStruct *lcd, uint8_t data) { for (i = 0 ; i < 8 ; ++i) { - digitalWrite (lcd->dataPins [i], (data & 1)) ; - data >>= 1 ; + digitalWrite (lcd->dataPins [i], (myData & 1)) ; + myData >>= 1 ; } } strobe (lcd) ; @@ -128,22 +147,24 @@ static void sendDataCmd (struct lcdDataStruct *lcd, uint8_t data) ********************************************************************************* */ -static void putCommand (struct lcdDataStruct *lcd, uint8_t command) +static void putCommand (const struct lcdDataStruct *lcd, unsigned char command) { digitalWrite (lcd->rsPin, 0) ; sendDataCmd (lcd, command) ; + delay (2) ; } -static void put4Command (struct lcdDataStruct *lcd, uint8_t command) +static void put4Command (const struct lcdDataStruct *lcd, unsigned char command) { - uint8_t i ; + register unsigned char myCommand = command ; + register unsigned char i ; digitalWrite (lcd->rsPin, 0) ; for (i = 0 ; i < 4 ; ++i) { - digitalWrite (lcd->dataPins [i], (command & 1)) ; - command >>= 1 ; + digitalWrite (lcd->dataPins [i], (myCommand & 1)) ; + myCommand >>= 1 ; } strobe (lcd) ; } @@ -151,7 +172,7 @@ static void put4Command (struct lcdDataStruct *lcd, uint8_t command) /* ********************************************************************************* - * User Code below here + * User Callable code below here ********************************************************************************* */ @@ -161,16 +182,66 @@ static void put4Command (struct lcdDataStruct *lcd, uint8_t command) ********************************************************************************* */ -void lcdHome (int fd) +void lcdHome (const int fd) { struct lcdDataStruct *lcd = lcds [fd] ; + putCommand (lcd, LCD_HOME) ; + lcd->cx = lcd->cy = 0 ; + delay (5) ; } -void lcdClear (int fd) +void lcdClear (const int fd) { struct lcdDataStruct *lcd = lcds [fd] ; + putCommand (lcd, LCD_CLEAR) ; + putCommand (lcd, LCD_HOME) ; + lcd->cx = lcd->cy = 0 ; + delay (5) ; +} + + +/* + * lcdDisplay: lcdCursor: lcdCursorBlink: + * Turn the display, cursor, cursor blinking on/off + ********************************************************************************* + */ + +void lcdDisplay (const int fd, int state) +{ + struct lcdDataStruct *lcd = lcds [fd] ; + + if (state) + lcdControl |= LCD_DISPLAY_CTRL ; + else + lcdControl &= ~LCD_DISPLAY_CTRL ; + + putCommand (lcd, LCD_CTRL | lcdControl) ; +} + +void lcdCursor (const int fd, int state) +{ + struct lcdDataStruct *lcd = lcds [fd] ; + + if (state) + lcdControl |= LCD_CURSOR_CTRL ; + else + lcdControl &= ~LCD_CURSOR_CTRL ; + + putCommand (lcd, LCD_CTRL | lcdControl) ; +} + +void lcdCursorBlink (const int fd, int state) +{ + struct lcdDataStruct *lcd = lcds [fd] ; + + if (state) + lcdControl |= LCD_BLINK_CTRL ; + else + lcdControl &= ~LCD_BLINK_CTRL ; + + putCommand (lcd, LCD_CTRL | lcdControl) ; } @@ -180,40 +251,77 @@ void lcdClear (int fd) ********************************************************************************* */ -void lcdSendCommand (int fd, uint8_t command) +void lcdSendCommand (const int fd, unsigned char command) { struct lcdDataStruct *lcd = lcds [fd] ; putCommand (lcd, command) ; } + /* * lcdPosition: - * Update the position of the cursor on the display + * Update the position of the cursor on the display. + * Ignore invalid locations. ********************************************************************************* */ - -void lcdPosition (int fd, int x, int y) +void lcdPosition (const int fd, int x, int y) { - static uint8_t rowOff [4] = { 0x00, 0x40, 0x14, 0x54 } ; struct lcdDataStruct *lcd = lcds [fd] ; + if ((x > lcd->cols) || (x < 0)) + return ; + if ((y > lcd->rows) || (y < 0)) + return ; + putCommand (lcd, x + (LCD_DGRAM | rowOff [y])) ; + + lcd->cx = x ; + lcd->cy = y ; +} + + +/* + * lcdCharDef: + * Defines a new character in the CGRAM + ********************************************************************************* + */ + +void lcdCharDef (const int fd, int index, unsigned char data [8]) +{ + struct lcdDataStruct *lcd = lcds [fd] ; + int i ; + + putCommand (lcd, LCD_CGRAM | ((index & 7) << 3)) ; + + digitalWrite (lcd->rsPin, 1) ; + for (i = 0 ; i < 8 ; ++i) + sendDataCmd (lcd, data [i]) ; } /* * lcdPutchar: - * Send a data byte to be displayed on the display + * Send a data byte to be displayed on the display. We implement a very + * simple terminal here - with line wrapping, but no scrolling. Yet. ********************************************************************************* */ -void lcdPutchar (int fd, uint8_t data) +void lcdPutchar (const int fd, unsigned char data) { struct lcdDataStruct *lcd = lcds [fd] ; digitalWrite (lcd->rsPin, 1) ; - sendDataCmd (lcd, data) ; + sendDataCmd (lcd, data) ; + + if (++lcd->cx == lcd->cols) + { + lcd->cx = 0 ; + if (++lcd->cy == lcd->rows) + lcd->cy = 0 ; + + putCommand (lcd, lcd->cx + (LCD_DGRAM | rowOff [lcd->cy])) ; + } } @@ -223,7 +331,7 @@ void lcdPutchar (int fd, uint8_t data) ********************************************************************************* */ -void lcdPuts (int fd, char *string) +void lcdPuts (const int fd, const char *string) { while (*string) lcdPutchar (fd, *string++) ; @@ -236,7 +344,7 @@ void lcdPuts (int fd, char *string) ********************************************************************************* */ -void lcdPrintf (int fd, char *message, ...) +void lcdPrintf (const int fd, const char *message, ...) { va_list argp ; char buffer [1024] ; @@ -256,12 +364,14 @@ void lcdPrintf (int fd, char *message, ...) ********************************************************************************* */ -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) +int lcdInit (const int rows, const int cols, const int bits, + const int rs, const int strb, + const int d0, const int d1, const int d2, const int d3, const int d4, + const int d5, const int d6, const int d7) { static int initialised = 0 ; - uint8_t func ; + unsigned char func ; int i ; int lcdFd = -1 ; struct lcdDataStruct *lcd ; @@ -298,7 +408,7 @@ int lcdInit (int rows, int cols, int bits, int rs, int strb, if (lcdFd == -1) return -1 ; - lcd = malloc (sizeof (struct lcdDataStruct)) ; + lcd = (struct lcdDataStruct *)malloc (sizeof (struct lcdDataStruct)) ; if (lcd == NULL) return -1 ; @@ -307,6 +417,8 @@ int lcdInit (int rows, int cols, int bits, int rs, int strb, lcd->bits = 8 ; // For now - we'll set it properly later. lcd->rows = rows ; lcd->cols = cols ; + lcd->cx = 0 ; + lcd->cy = 0 ; lcd->dataPins [0] = d0 ; lcd->dataPins [1] = d1 ; @@ -371,10 +483,13 @@ int lcdInit (int rows, int cols, int bits, int rs, int strb, // Rest of the initialisation sequence - putCommand (lcd, LCD_ON_OFF | LCD_ON_OFF_D) ; delay (2) ; - putCommand (lcd, LCD_ENTRY | LCD_ENTRY_ID) ; delay (2) ; - putCommand (lcd, LCD_CDSHIFT | LCD_CDSHIFT_RL) ; delay (2) ; - putCommand (lcd, LCD_CLEAR) ; delay (5) ; + lcdDisplay (lcdFd, TRUE) ; + lcdCursor (lcdFd, FALSE) ; + lcdCursorBlink (lcdFd, FALSE) ; + lcdClear (lcdFd) ; + + putCommand (lcd, LCD_ENTRY | LCD_ENTRY_ID) ; + putCommand (lcd, LCD_CDSHIFT | LCD_CDSHIFT_RL) ; return lcdFd ; } diff --git a/WiringPi/devLib/lcd.h b/WiringPi/devLib/lcd.h new file mode 100644 index 0000000..0a0e598 --- /dev/null +++ b/WiringPi/devLib/lcd.h @@ -0,0 +1,52 @@ +/* + * lcd.h: + * Text-based LCD driver. + * This is designed to drive the parallel interface LCD drivers + * based in the Hitachi HD44780U controller and compatables. + * + * Copyright (c) 2012 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#define MAX_LCDS 8 + +#ifdef __cplusplus +extern "C" { +#endif + +extern void lcdHome (const int fd) ; +extern void lcdClear (const int fd) ; +extern void lcdDisplay (const int fd, int state) ; +extern void lcdCursor (const int fd, int state) ; +extern void lcdCursorBlink (const int fd, int state) ; +extern void lcdSendCommand (const int fd, unsigned char command) ; +extern void lcdPosition (const int fd, int x, int y) ; +extern void lcdCharDef (const int fd, int index, unsigned char data [8]) ; +extern void lcdPutchar (const int fd, unsigned char data) ; +extern void lcdPuts (const int fd, const char *string) ; +extern void lcdPrintf (const int fd, const char *message, ...) ; + +extern int lcdInit (const int rows, const int cols, const int bits, + const int rs, const int strb, + const int d0, const int d1, const int d2, const int d3, const int d4, + const int d5, const int d6, const int d7) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/devLib/lcd128x64.c b/WiringPi/devLib/lcd128x64.c new file mode 100644 index 0000000..accd5c3 --- /dev/null +++ b/WiringPi/devLib/lcd128x64.c @@ -0,0 +1,673 @@ +/* + * lcd128x64.c: + * Graphics-based LCD driver. + * This is designed to drive the parallel interface LCD drivers + * based on the generic 12864H chips + * + * There are many variations on these chips, however they all mostly + * seem to be similar. + * This implementation has the Pins from the Pi hard-wired into it, + * in particular wiringPi pins 0-7 so that we can use + * digitalWriteByete() to speed things up somewhat. + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include + +#include + +#include "font.h" +#include "lcd128x64.h" + +// Size + +#define LCD_WIDTH 128 +#define LCD_HEIGHT 64 + +// Hardware Pins +// Note pins 0-7 are the 8-bit data port + +#define CS1 10 +#define CS2 11 +#define STROBE 12 +#define RS 13 + +// Software copy of the framebuffer +// it's 8-bit deep although the display itself is only 1-bit deep. + +static unsigned char frameBuffer [LCD_WIDTH * LCD_HEIGHT] ; + +static int maxX, maxY ; +static int lastX, lastY ; +static int xOrigin, yOrigin ; +static int lcdOrientation = 0 ; + +/* + * strobe: + * Toggle the strobe (Really the "E") pin to the device. + * According to the docs, data is latched on the falling edge. + ********************************************************************************* + */ + +static void strobe (void) +{ + digitalWrite (STROBE, 1) ; delayMicroseconds (1) ; + digitalWrite (STROBE, 0) ; delayMicroseconds (5) ; +} + + +/* + * sentData: + * Send an data or command byte to the display. + ********************************************************************************* + */ + +static void sendData (const int data, const int chip) +{ + digitalWrite (chip, 0) ; + digitalWriteByte (data) ; + strobe () ; + digitalWrite (chip, 1) ; +} + + +/* + * sendCommand: + * Send a command byte to the display + ********************************************************************************* + */ + +static void sendCommand (const int command, const int chip) +{ + digitalWrite (RS, 0) ; + sendData (command, chip) ; + digitalWrite (RS, 1) ; +} + + +/* + * setCol: SetLine: + * Set the column and line addresses + ********************************************************************************* + */ + +static void setCol (int col, const int chip) + { sendCommand (0x40 | (col & 0x3F), chip) ; } + +static void setLine (int line, const int chip) + { sendCommand (0xB8 | (line & 0x07), chip) ; } + + +/* + * lcd128x64update: + * Copy our software version to the real display + ********************************************************************************* + */ + +void lcd128x64update (void) +{ + int line, x, y, fbLoc ; + unsigned char byte ; + +// Left side + + for (line = 0 ; line < 8 ; ++line) + { + setCol (0, CS1) ; + setLine (line, CS1) ; + + for (x = 63 ; x >= 0 ; --x) + { + byte = 0 ; + for (y = 0 ; y < 8 ; ++y) + { + fbLoc = x + (((7 - line) * 8) + (7 - y)) * LCD_WIDTH ; + if (frameBuffer [fbLoc] != 0) + byte |= (1 << y) ; + } + sendData (byte, CS1) ; + } + } + +// Right side + + for (line = 0 ; line < 8 ; ++line) + { + setCol (0, CS2) ; + setLine (line, CS2) ; + + for (x = 127 ; x >= 64 ; --x) + { + byte = 0 ; + for (y = 0 ; y < 8 ; ++y) + { + fbLoc = x + (((7 - line) * 8) + (7 - y)) * LCD_WIDTH ; + if (frameBuffer [fbLoc] != 0) + byte |= (1 << y) ; + } + sendData (byte, CS2) ; + } + } +} + + +/* + * lcd128x64setOrigin: + * Set the display offset origin + ********************************************************************************* + */ + +void lcd128x64setOrigin (int x, int y) +{ + xOrigin = x ; + yOrigin = y ; +} + + +/* + * lcd128x64setOrientation: + * Set the display orientation: + * 0: Normal, the display is portrait mode, 0,0 is top left + * 1: Landscape + * 2: Portrait, flipped + * 3: Landscape, flipped + ********************************************************************************* + */ + +void lcd128x64setOrientation (int orientation) +{ + lcdOrientation = orientation & 3 ; + + lcd128x64setOrigin (0,0) ; + + switch (lcdOrientation) + { + case 0: + maxX = LCD_WIDTH ; + maxY = LCD_HEIGHT ; + break ; + + case 1: + maxX = LCD_HEIGHT ; + maxY = LCD_WIDTH ; + break ; + + case 2: + maxX = LCD_WIDTH ; + maxY = LCD_HEIGHT ; + break ; + + case 3: + maxX = LCD_HEIGHT ; + maxY = LCD_WIDTH ; + break ; + } +} + + +/* + * lcd128x64orientCoordinates: + * Adjust the coordinates given to the display orientation + ********************************************************************************* + */ + +void lcd128x64orientCoordinates (int *x, int *y) +{ + register int tmp ; + + *x += xOrigin ; + *y += yOrigin ; + *y = maxY - *y - 1 ; + + switch (lcdOrientation) + { + case 0: + break; + + case 1: + tmp = maxY - *y - 1 ; + *y = *x ; + *x = tmp ; + break; + + case 2: + *x = maxX - *x - 1 ; + *y = maxY - *y - 1 ; + break; + + case 3: + *x = maxX - *x - 1 ; + tmp = *y ; + *y = *x ; + *x = tmp ; + break ; + } +} + + +/* + * lcd128x64getScreenSize: + * Return the max X & Y screen sizes. Needs to be called again, if you + * change screen orientation. + ********************************************************************************* + */ + +void lcd128x64getScreenSize (int *x, int *y) +{ + *x = maxX ; + *y = maxY ; +} + + +/* + ********************************************************************************* + * Standard Graphical Functions + ********************************************************************************* + */ + + +/* + * lcd128x64point: + * Plot a pixel. + ********************************************************************************* + */ + +void lcd128x64point (int x, int y, int colour) +{ + lastX = x ; + lastY = y ; + + lcd128x64orientCoordinates (&x, &y) ; + + if ((x < 0) || (x >= LCD_WIDTH) || (y < 0) || (y >= LCD_HEIGHT)) + return ; + + frameBuffer [x + y * LCD_WIDTH] = colour ; +} + + +/* + * lcd128x64line: lcd128x64lineTo: + * Classic Bressenham Line code + ********************************************************************************* + */ + +void lcd128x64line (int x0, int y0, int x1, int y1, int colour) +{ + int dx, dy ; + int sx, sy ; + int err, e2 ; + + lastX = x1 ; + lastY = y1 ; + + dx = abs (x1 - x0) ; + dy = abs (y1 - y0) ; + + sx = (x0 < x1) ? 1 : -1 ; + sy = (y0 < y1) ? 1 : -1 ; + + err = dx - dy ; + + for (;;) + { + lcd128x64point (x0, y0, colour) ; + + if ((x0 == x1) && (y0 == y1)) + break ; + + e2 = 2 * err ; + + if (e2 > -dy) + { + err -= dy ; + x0 += sx ; + } + + if (e2 < dx) + { + err += dx ; + y0 += sy ; + } + } + +} + +void lcd128x64lineTo (int x, int y, int colour) +{ + lcd128x64line (lastX, lastY, x, y, colour) ; +} + + +/* + * lcd128x64rectangle: + * A rectangle is a spoilt days fishing + ********************************************************************************* + */ + +void lcd128x64rectangle (int x1, int y1, int x2, int y2, int colour, int filled) +{ + register int x ; + + if (filled) + { + /**/ if (x1 == x2) + lcd128x64line (x1, y1, x2, y2, colour) ; + else if (x1 < x2) + for (x = x1 ; x <= x2 ; ++x) + lcd128x64line (x, y1, x, y2, colour) ; + else + for (x = x2 ; x <= x1 ; ++x) + lcd128x64line (x, y1, x, y2, colour) ; + } + else + { + lcd128x64line (x1, y1, x2, y1, colour) ; + lcd128x64lineTo (x2, y2, colour) ; + lcd128x64lineTo (x1, y2, colour) ; + lcd128x64lineTo (x1, y1, colour) ; + } +} + + +/* + * lcd128x64circle: + * This is the midpoint circle algorithm. + ********************************************************************************* + */ + +void lcd128x64circle (int x, int y, int r, int colour, int filled) +{ + int ddF_x = 1 ; + int ddF_y = -2 * r ; + + int f = 1 - r ; + int x1 = 0 ; + int y1 = r ; + + if (filled) + { + lcd128x64line (x, y + r, x, y - r, colour) ; + lcd128x64line (x + r, y, x - r, y, colour) ; + } + else + { + lcd128x64point (x, y + r, colour) ; + lcd128x64point (x, y - r, colour) ; + lcd128x64point (x + r, y, colour) ; + lcd128x64point (x - r, y, colour) ; + } + + while (x1 < y1) + { + if (f >= 0) + { + y1-- ; + ddF_y += 2 ; + f += ddF_y ; + } + x1++ ; + ddF_x += 2 ; + f += ddF_x ; + if (filled) + { + lcd128x64line (x + x1, y + y1, x - x1, y + y1, colour) ; + lcd128x64line (x + x1, y - y1, x - x1, y - y1, colour) ; + lcd128x64line (x + y1, y + x1, x - y1, y + x1, colour) ; + lcd128x64line (x + y1, y - x1, x - y1, y - x1, colour) ; + } + else + { + lcd128x64point (x + x1, y + y1, colour) ; lcd128x64point (x - x1, y + y1, colour) ; + lcd128x64point (x + x1, y - y1, colour) ; lcd128x64point (x - x1, y - y1, colour) ; + lcd128x64point (x + y1, y + x1, colour) ; lcd128x64point (x - y1, y + x1, colour) ; + lcd128x64point (x + y1, y - x1, colour) ; lcd128x64point (x - y1, y - x1, colour) ; + } + } +} + + +/* + * lcd128x64ellipse: + * Fast ellipse drawing algorithm by + * John Kennedy + * Mathematics Department + * Santa Monica College + * 1900 Pico Blvd. + * Santa Monica, CA 90405 + * jrkennedy6@gmail.com + * -Confirned in email this algorithm is in the public domain -GH- + ********************************************************************************* + */ + +static void plot4ellipsePoints (int cx, int cy, int x, int y, int colour, int filled) +{ + if (filled) + { + lcd128x64line (cx + x, cy + y, cx - x, cy + y, colour) ; + lcd128x64line (cx - x, cy - y, cx + x, cy - y, colour) ; + } + else + { + lcd128x64point (cx + x, cy + y, colour) ; + lcd128x64point (cx - x, cy + y, colour) ; + lcd128x64point (cx - x, cy - y, colour) ; + lcd128x64point (cx + x, cy - y, colour) ; + } +} + +void lcd128x64ellipse (int cx, int cy, int xRadius, int yRadius, int colour, int filled) +{ + int x, y ; + int xChange, yChange, ellipseError ; + int twoAsquare, twoBsquare ; + int stoppingX, stoppingY ; + + twoAsquare = 2 * xRadius * xRadius ; + twoBsquare = 2 * yRadius * yRadius ; + + x = xRadius ; + y = 0 ; + + xChange = yRadius * yRadius * (1 - 2 * xRadius) ; + yChange = xRadius * xRadius ; + + ellipseError = 0 ; + stoppingX = twoBsquare * xRadius ; + stoppingY = 0 ; + + while (stoppingX >= stoppingY) // 1st set of points + { + plot4ellipsePoints (cx, cy, x, y, colour, filled) ; + ++y ; + stoppingY += twoAsquare ; + ellipseError += yChange ; + yChange += twoAsquare ; + + if ((2 * ellipseError + xChange) > 0 ) + { + --x ; + stoppingX -= twoBsquare ; + ellipseError += xChange ; + xChange += twoBsquare ; + } + } + + x = 0 ; + y = yRadius ; + + xChange = yRadius * yRadius ; + yChange = xRadius * xRadius * (1 - 2 * yRadius) ; + + ellipseError = 0 ; + stoppingX = 0 ; + stoppingY = twoAsquare * yRadius ; + + while (stoppingX <= stoppingY) //2nd set of points + { + plot4ellipsePoints (cx, cy, x, y, colour, filled) ; + ++x ; + stoppingX += twoBsquare ; + ellipseError += xChange ; + xChange += twoBsquare ; + + if ((2 * ellipseError + yChange) > 0 ) + { + --y ; + stoppingY -= twoAsquare ; + ellipseError += yChange ; + yChange += twoAsquare ; + } + } +} + + +/* + * lcd128x64putchar: + * Print a single character to the screen + ********************************************************************************* + */ + +void lcd128x64putchar (int x, int y, int c, int bgCol, int fgCol) +{ + int y1, y2 ; + + unsigned char line ; + unsigned char *fontPtr ; + +// Can't print if we're offscreen + +//if ((x < 0) || (x >= (maxX - fontWidth)) || (y < 0) || (y >= (maxY - fontHeight))) +// return ; + + fontPtr = font + c * fontHeight ; + + for (y1 = fontHeight - 1 ; y1 >= 0 ; --y1) + { + y2 = y + y1 ; + line = *fontPtr++ ; + lcd128x64point (x + 0, y2, (line & 0x80) == 0 ? bgCol : fgCol) ; + lcd128x64point (x + 1, y2, (line & 0x40) == 0 ? bgCol : fgCol) ; + lcd128x64point (x + 2, y2, (line & 0x20) == 0 ? bgCol : fgCol) ; + lcd128x64point (x + 3, y2, (line & 0x10) == 0 ? bgCol : fgCol) ; + lcd128x64point (x + 4, y2, (line & 0x08) == 0 ? bgCol : fgCol) ; + lcd128x64point (x + 5, y2, (line & 0x04) == 0 ? bgCol : fgCol) ; + lcd128x64point (x + 6, y2, (line & 0x02) == 0 ? bgCol : fgCol) ; + lcd128x64point (x + 7, y2, (line & 0x01) == 0 ? bgCol : fgCol) ; + } +} + + +/* + * lcd128x64puts: + * Send a string to the display. Obeys \n and \r formatting + ********************************************************************************* + */ + +void lcd128x64puts (int x, int y, const char *str, int bgCol, int fgCol) +{ + int c, mx, my ; + + mx = x ; my = y ; + + while (*str) + { + c = *str++ ; + + if (c == '\r') + { + mx = x ; + continue ; + } + + if (c == '\n') + { + mx = x ; + my -= fontHeight ; + continue ; + } + + lcd128x64putchar (mx, my, c, bgCol, fgCol) ; + + mx += fontWidth ; + if (mx >= (maxX - fontWidth)) + { + mx = 0 ; + my -= fontHeight ; + } + } +} + + +/* + * lcd128x64clear: + * Clear the display to the given colour. + ********************************************************************************* + */ + +void lcd128x64clear (int colour) +{ + register int i ; + register unsigned char *ptr = frameBuffer ; + + for (i = 0 ; i < (maxX * maxY) ; ++i) + *ptr++ = colour ; +} + + + + +/* + * lcd128x64setup: + * Initialise the display and GPIO. + ********************************************************************************* + */ + +int lcd128x64setup (void) +{ + int i ; + + for (i = 0 ; i < 8 ; ++i) + pinMode (i, OUTPUT) ; + + digitalWrite (CS1, 1) ; + digitalWrite (CS2, 1) ; + digitalWrite (STROBE, 0) ; + digitalWrite (RS, 1) ; + + pinMode (CS1, OUTPUT) ; + pinMode (CS2, OUTPUT) ; + pinMode (STROBE, OUTPUT) ; + pinMode (RS, OUTPUT) ; + + sendCommand (0x3F, CS1) ; // Display ON + sendCommand (0xC0, CS1) ; // Set display start line to 0 + + sendCommand (0x3F, CS2) ; // Display ON + sendCommand (0xC0, CS2) ; // Set display start line to 0 + + lcd128x64clear (0) ; + lcd128x64setOrientation (0) ; + lcd128x64update () ; + + return 0 ; +} diff --git a/WiringPi/devLib/lcd128x64.h b/WiringPi/devLib/lcd128x64.h new file mode 100644 index 0000000..b448bbc --- /dev/null +++ b/WiringPi/devLib/lcd128x64.h @@ -0,0 +1,39 @@ +/* + * lcd128x64.h: + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +extern void lcd128x64setOrigin (int x, int y) ; +extern void lcd128x64setOrientation (int orientation) ; +extern void lcd128x64orientCoordinates (int *x, int *y) ; +extern void lcd128x64getScreenSize (int *x, int *y) ; +extern void lcd128x64point (int x, int y, int colour) ; +extern void lcd128x64line (int x0, int y0, int x1, int y1, int colour) ; +extern void lcd128x64lineTo (int x, int y, int colour) ; +extern void lcd128x64rectangle (int x1, int y1, int x2, int y2, int colour, int filled) ; +extern void lcd128x64circle (int x, int y, int r, int colour, int filled) ; +extern void lcd128x64ellipse (int cx, int cy, int xRadius, int yRadius, int colour, int filled) ; +extern void lcd128x64putchar (int x, int y, int c, int bgCol, int fgCol) ; +extern void lcd128x64puts (int x, int y, const char *str, int bgCol, int fgCol) ; +extern void lcd128x64update (void) ; +extern void lcd128x64clear (int colour) ; + +extern int lcd128x64setup (void) ; diff --git a/WiringPi/devLib/maxdetect.c b/WiringPi/devLib/maxdetect.c new file mode 100755 index 0000000..23eabf8 --- /dev/null +++ b/WiringPi/devLib/maxdetect.c @@ -0,0 +1,165 @@ +/* + * maxdetect.c: + * Driver for the MaxDetect series sensors + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +//#include +//#include +//#include + +#include + +#include "maxdetect.h" + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + + +/* + * maxDetectLowHighWait: + * Wait for a transition from high to low on the bus + ********************************************************************************* + */ + +static void maxDetectLowHighWait (const int pin) +{ + unsigned int timeOut = millis () + 2000 ; + + while (digitalRead (pin) == HIGH) + if (millis () > timeOut) + return ; + + while (digitalRead (pin) == LOW) + if (millis () > timeOut) + return ; +} + + +/* + * maxDetectClockByte: + * Read in a single byte from the MaxDetect bus + ********************************************************************************* + */ + +static unsigned int maxDetectClockByte (const int pin) +{ + unsigned int byte = 0 ; + int bit ; + + for (bit = 0 ; bit < 8 ; ++bit) + { + maxDetectLowHighWait (pin) ; + +// bit starting now - we need to time it. + + delayMicroseconds (30) ; + byte <<= 1 ; + if (digitalRead (pin) == HIGH) // It's a 1 + byte |= 1 ; + } + + return byte ; +} + + +/* + * maxDetectRead: + * Read in and return the 4 data bytes from the MaxDetect sensor. + * Return TRUE/FALSE depending on the checksum validity + ********************************************************************************* + */ + +int maxDetectRead (const int pin, unsigned char buffer [4]) +{ + int i ; + unsigned int checksum ; + unsigned char localBuf [5] ; + +// Wake up the RHT03 by pulling the data line low, then high +// Low for 10mS, high for 40uS. + + pinMode (pin, OUTPUT) ; + digitalWrite (pin, 0) ; delay (10) ; + digitalWrite (pin, 1) ; delayMicroseconds (40) ; + pinMode (pin, INPUT) ; + +// Now wait for sensor to pull pin low + + maxDetectLowHighWait (pin) ; + +// and read in 5 bytes (40 bits) + + for (i = 0 ; i < 5 ; ++i) + localBuf [i] = maxDetectClockByte (pin) ; + + checksum = 0 ; + for (i = 0 ; i < 4 ; ++i) + { + buffer [i] = localBuf [i] ; + checksum += localBuf [i] ; + } + checksum &= 0xFF ; + + return checksum == localBuf [4] ; +} + + +/* + * readRHT03: + * Read the Temperature & Humidity from an RHT03 sensor + ********************************************************************************* + */ + +int readRHT03 (const int pin, int *temp, int *rh) +{ + static unsigned int nextTime = 0 ; + static int lastTemp = 0 ; + static int lastRh = 0 ; + static int lastResult = TRUE ; + + unsigned char buffer [4] ; + +// Don't read more than once a second + + if (millis () < nextTime) + { + *temp = lastTemp ; + *rh = lastRh ; + return lastResult ; + } + + lastResult = maxDetectRead (pin, buffer) ; + + if (lastResult) + { + *temp = lastTemp = (buffer [2] * 256 + buffer [3]) ; + *rh = lastRh = (buffer [0] * 256 + buffer [1]) ; + nextTime = millis () + 2000 ; + return TRUE ; + } + else + { + return FALSE ; + } +} diff --git a/WiringPi/wiringPi/lcd.h b/WiringPi/devLib/maxdetect.h old mode 100644 new mode 100755 similarity index 58% rename from WiringPi/wiringPi/lcd.h rename to WiringPi/devLib/maxdetect.h index beebb75..a1fd742 --- a/WiringPi/wiringPi/lcd.h +++ b/WiringPi/devLib/maxdetect.h @@ -1,10 +1,8 @@ /* - * lcd.h: - * Text-based LCD driver. - * This is designed to drive the parallel interface LCD drivers - * based in the Hitachi HD44780U controller and compatables. + * maxdetect.h: + * Driver for the MaxDetect series sensors * - * Copyright (c) 2012 Gordon Henderson. + * Copyright (c) 2013 Gordon Henderson. *********************************************************************** * This file is part of wiringPi: * https://projects.drogon.net/raspberry-pi/wiringpi/ @@ -24,22 +22,18 @@ *********************************************************************** */ -#define MAX_LCDS 8 #ifdef __cplusplus extern "C" { #endif -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, ...) ; +// Main generic function -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) ; +int maxDetectRead (const int pin, unsigned char buffer [4]) ; + +// Individual sensors + +int readRHT03 (const int pin, int *temp, int *rh) ; #ifdef __cplusplus } diff --git a/WiringPi/devLib/piFace.c b/WiringPi/devLib/piFace.c new file mode 100644 index 0000000..4475c7f --- /dev/null +++ b/WiringPi/devLib/piFace.c @@ -0,0 +1,112 @@ +/* + * piFace.: + * This file to interface with the PiFace peripheral device which + * has an MCP23S17 GPIO device connected via the SPI bus. + * + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + + +#include +#include + +#include +#include + +#include "piFace.h" + + +/* + * myDigitalWrite: + * Perform the digitalWrite function on the PiFace board + ********************************************************************************* + */ + +void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + digitalWrite (pin + 16, value) ; +} + + +/* + * myDigitalRead: + * Perform the digitalRead function on the PiFace board + * With a slight twist - if we read from base + 8, then we + * read from the output latch... + ********************************************************************************* + */ + +int myDigitalRead (struct wiringPiNodeStruct *node, int pin) +{ + if ((pin - node->pinBase) >= 8) + return digitalRead (pin + 8) ; + else + return digitalRead (pin + 16 + 8) ; +} + + +/* + * myPullUpDnControl: + * Perform the pullUpDnControl function on the PiFace board + ********************************************************************************* + */ + +void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int pud) +{ + pullUpDnControl (pin + 16 + 8, pud) ; +} + + +/* + * piFaceSetup + * We're going to create an instance of the mcp23s17 here, then + * provide our own read/write routines on-top of it... + * The supplied PiFace code (in Pithon) treats it as an 8-bit device + * where you write the output ports and read the input port using the + * same pin numbers, however I have had a request to be able to read + * the output port, so reading 8..15 will read the output latch. + ********************************************************************************* + */ + +int piFaceSetup (const int pinBase) +{ + int i ; + struct wiringPiNodeStruct *node ; + +// Create an mcp23s17 instance: + + mcp23s17Setup (pinBase + 16, 0, 0) ; + +// Set the direction bits + + for (i = 0 ; i < 8 ; ++i) + { + pinMode (pinBase + 16 + i, OUTPUT) ; // Port A is the outputs + pinMode (pinBase + 16 + 8 + i, INPUT) ; // Port B inputs. + } + + node = wiringPiNewNode (pinBase, 16) ; + node->digitalRead = myDigitalRead ; + node->digitalWrite = myDigitalWrite ; + node->pullUpDnControl = myPullUpDnControl ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/piFace.h b/WiringPi/devLib/piFace.h similarity index 96% rename from WiringPi/wiringPi/piFace.h rename to WiringPi/devLib/piFace.h index d012f5c..4965314 100644 --- a/WiringPi/wiringPi/piFace.h +++ b/WiringPi/devLib/piFace.h @@ -25,7 +25,7 @@ extern "C" { #endif -extern int piFaceSetup (int pinBase) ; +extern int piFaceSetup (const int pinBase) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/piNes.c b/WiringPi/devLib/piNes.c similarity index 99% rename from WiringPi/wiringPi/piNes.c rename to WiringPi/devLib/piNes.c index 3b54d76..a115050 100644 --- a/WiringPi/wiringPi/piNes.c +++ b/WiringPi/devLib/piNes.c @@ -22,7 +22,7 @@ *********************************************************************** */ -#include "wiringPi.h" +#include #include "piNes.h" diff --git a/WiringPi/wiringPi/piNes.h b/WiringPi/devLib/piNes.h similarity index 100% rename from WiringPi/wiringPi/piNes.h rename to WiringPi/devLib/piNes.h diff --git a/WiringPi/examples/Gertboard/7segments.c b/WiringPi/examples/Gertboard/7segments.c new file mode 100644 index 0000000..8797e49 --- /dev/null +++ b/WiringPi/examples/Gertboard/7segments.c @@ -0,0 +1,221 @@ +/* + * 7segments.c: + * Simple test program to see if we can drive a 7-segment LED + * display using the GPIO and little else on the Raspberry Pi + * + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + */ + +#undef PHOTO_HACK + +#include + +#include +#include +#include +#include + +/* + * Segment mapping + * + * --a-- + * | | + * f b + * | | + * --g-- + * | | + * e c + * | | + * --d-- p + */ + +// GPIO Pin Mapping + +static int digits [6] = { 7, 11, 10, 13, 12, 14 } ; +static int segments [7] = { 6, 5, 4, 3, 2, 1, 0 } ; + + +static const int segmentDigits [] = +{ +// a b c d e f g Segments +// 6 5 4 3 2 1 0, // wiringPi pin No. + + 1, 1, 1, 1, 1, 1, 0, // 0 + 0, 1, 1, 0, 0, 0, 0, // 1 + 1, 1, 0, 1, 1, 0, 1, // 2 + 1, 1, 1, 1, 0, 0, 1, // 3 + 0, 1, 1, 0, 0, 1, 1, // 4 + 1, 0, 1, 1, 0, 1, 1, // 5 + 1, 0, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 0, 0, 0, 0, // 7 + 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 0, 1, 1, // 9 + 1, 1, 1, 0, 1, 1, 1, // A + 0, 0, 1, 1, 1, 1, 1, // b + 1, 0, 0, 1, 1, 1, 0, // C + 0, 1, 1, 1, 1, 0, 1, // d + 1, 0, 0, 1, 1, 1, 1, // E + 1, 0, 0, 0, 1, 1, 1, // F + 0, 0, 0, 0, 0, 0, 0, // blank +} ; + + +// display: +// A global variable which is written to by the main program and +// read from by the thread that updates the display. Only the first +// 6 characters are used. + +char display [8] ; + + +/* + * displayDigits: + * This is our thread that's run concurrently with the main program. + * Essentially sit in a loop, parsing and displaying the data held in + * the "display" global. + ********************************************************************************* + */ + +PI_THREAD (displayDigits) +{ + int digit, segment ; + int index, d, segVal ; + + piHiPri (50) ; + + for (;;) + { + for (digit = 0 ; digit < 6 ; ++digit) + { + for (segment = 0 ; segment < 7 ; ++segment) + { + d = toupper (display [digit]) ; + /**/ if ((d >= '0') && (d <= '9')) // Digit + index = d - '0' ; + else if ((d >= 'A') && (d <= 'F')) // Hex + index = d - 'A' + 10 ; + else + index = 16 ; // Blank + + segVal = segmentDigits [index * 7 + segment] ; + + digitalWrite (segments [segment], segVal) ; + } + digitalWrite (digits [digit], 1) ; + delay (2) ; + digitalWrite (digits [digit], 0) ; + } + } +} + + +/* + * setup: + * Initialise the hardware and start the thread + ********************************************************************************* + */ + +void setup (void) +{ + int i, c ; + + wiringPiSetup () ; + +// 7 segments + + for (i = 0 ; i < 7 ; ++i) + { digitalWrite (segments [i], 0) ; pinMode (segments [i], OUTPUT) ; } + +// 6 digits + + for (i = 0 ; i < 6 ; ++i) + { digitalWrite (digits [i], 0) ; pinMode (digits [i], OUTPUT) ; } + + strcpy (display, " ") ; + piThreadCreate (displayDigits) ; + delay (10) ; // Just to make sure it's started + +// Quick countdown LED test sort of thing + + c = 999999 ; + for (i = 0 ; i < 10 ; ++i) + { + sprintf (display, "%06d", c) ; + delay (400) ; + c -= 111111 ; + } + + strcpy (display, " ") ; + delay (400) ; + +#ifdef PHOTO_HACK + sprintf (display, "%s", "123456") ; + for (;;) + delay (1000) ; +#endif + +} + + +/* + * teenager: + * No explanation needed. (Nor one given!) + ********************************************************************************* + */ + +void teenager (void) +{ + char *message = " feedbeef babe cafe b00b " ; + int i ; + + for (i = 0 ; i < strlen (message) - 4 ; ++i) + { + strncpy (display, &message [i], 6) ; + delay (200) ; + } + delay (1000) ; + for (i = 0 ; i < 3 ; ++i) + { + strcpy (display, " ") ; + delay (150) ; + strcpy (display, " b00b ") ; + delay (250) ; + } + delay (1000) ; + strcpy (display, " ") ; + delay (1000) ; +} + + +/* + ********************************************************************************* + * main: + * Let the fun begin + ********************************************************************************* + */ + +int main (void) +{ + struct tm *t ; + time_t tim ; + + setup () ; + teenager () ; + + tim = time (NULL) ; + for (;;) + { + while (time (NULL) == tim) + delay (5) ; + + tim = time (NULL) ; + t = localtime (&tim) ; + + sprintf (display, "%02d%02d%02d", t->tm_hour, t->tm_min, t->tm_sec) ; + + delay (500) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/Gertboard/Makefile b/WiringPi/examples/Gertboard/Makefile new file mode 100644 index 0000000..7569261 --- /dev/null +++ b/WiringPi/examples/Gertboard/Makefile @@ -0,0 +1,74 @@ +# +# Makefile: +# Gertboard - Examples using wiringPi +# +# Copyright (c) 2013 Gordon Henderson +################################################################################# + +#DEBUG = -g -O0 +DEBUG = -O3 +CC = gcc +INCLUDE = -I/usr/local/include +CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe + +LDFLAGS = -L/usr/local/lib +LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm + +# Should not alter anything below this line +############################################################################### + +SRC = gertboard.c \ + buttons.c 7segments.c \ + voltmeter.c temperature.c vumeter.c \ + record.c + +OBJ = $(SRC:.c=.o) + +BINS = $(SRC:.c=) + +all: $(BINS) + +gertboard: gertboard.o + @echo [link] + @$(CC) -o $@ gertboard.o $(LDFLAGS) $(LDLIBS) + +buttons: buttons.o + @echo [link] + @$(CC) -o $@ buttons.o $(LDFLAGS) $(LDLIBS) + +7segments: 7segments.o + @echo [link] + @$(CC) -o $@ 7segments.o $(LDFLAGS) $(LDLIBS) + +voltmeter: voltmeter.o + @echo [link] + @$(CC) -o $@ voltmeter.o $(LDFLAGS) $(LDLIBS) + +temperature: temperature.o + @echo [link] + @$(CC) -o $@ temperature.o $(LDFLAGS) $(LDLIBS) + +vumeter: vumeter.o + @echo [link] + @$(CC) -o $@ vumeter.o $(LDFLAGS) $(LDLIBS) + +record: record.o + @echo [link] + @$(CC) -o $@ record.o $(LDFLAGS) $(LDLIBS) + +.c.o: + @echo [CC] $< + @$(CC) -c $(CFLAGS) $< -o $@ + +clean: + @echo [Clean] + @rm -f $(OBJ) *~ core tags $(BINS) + +tags: $(SRC) + @echo [ctags] + @ctags $(SRC) + +depend: + makedepend -Y $(SRC) + +# DO NOT DELETE diff --git a/WiringPi/examples/Gertboard/buttons.c b/WiringPi/examples/Gertboard/buttons.c new file mode 100644 index 0000000..5f76764 --- /dev/null +++ b/WiringPi/examples/Gertboard/buttons.c @@ -0,0 +1,83 @@ +/* + * buttons.c: + * Read the Gertboard buttons. Each one will act as an on/off + * tiggle switch for 3 different LEDs + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include + +// Array to keep track of our LEDs + +int leds [] = { 0, 0, 0 } ; + +// scanButton: +// See if a button is pushed, if so, then flip that LED and +// wait for the button to be let-go + +void scanButton (int button) +{ + if (digitalRead (button) == HIGH) // Low is pushed + return ; + + leds [button] ^= 1 ; // Invert state + digitalWrite (4 + button, leds [button]) ; + + while (digitalRead (button) == LOW) // Wait for release + delay (10) ; +} + +int main (void) +{ + int i ; + + printf ("Raspberry Pi Gertboard Button Test\n") ; + + wiringPiSetup () ; + +// Setup the outputs: +// Pins 3, 4, 5, 6 and 7 output: +// We're not using 3 or 4, but make sure they're off anyway +// (Using same hardware config as blink12.c) + + for (i = 3 ; i < 8 ; ++i) + { + pinMode (i, OUTPUT) ; + digitalWrite (i, 0) ; + } + +// Setup the inputs + + for (i = 0 ; i < 3 ; ++i) + { + pinMode (i, INPUT) ; + pullUpDnControl (i, PUD_UP) ; + leds [i] = 0 ; + } + + for (;;) + { + for (i = 0 ; i < 3 ; ++i) + scanButton (i) ; + delay (1) ; + } +} diff --git a/WiringPi/examples/gertboard.c b/WiringPi/examples/Gertboard/gertboard.c similarity index 61% rename from WiringPi/examples/gertboard.c rename to WiringPi/examples/Gertboard/gertboard.c index f02e27d..aefcb12 100644 --- a/WiringPi/examples/gertboard.c +++ b/WiringPi/examples/Gertboard/gertboard.c @@ -6,8 +6,8 @@ * D/A port 0 jumpered to A/D port 0. * * We output a sine wave on D/A port 0 and sample A/D port 0. We then - * copy this value to D/A port 1 and use a 'scope on both D/A ports - * to check all's well. + * plot the input value on the terminal as a sort of vertical scrolling + * oscilloscipe. * * Copyright (c) 2012-2013 Gordon Henderson. *********************************************************************** @@ -30,11 +30,13 @@ */ #include -#include +#include +#include #include -#define B_SIZE 200 -#undef DO_TIMING +// Gertboard D to A is an 8-bit unit. + +#define B_SIZE 256 #include #include @@ -42,23 +44,28 @@ int main (void) { double angle ; - int i ; - uint32_t x1 ; + int i, inputValue ; int buffer [B_SIZE] ; + int cols ; + struct winsize w ; -#ifdef DO_TIMING - unsigned int now, then ; -#endif printf ("Raspberry Pi Gertboard SPI test program\n") ; + printf ("=======================================\n") ; - if (wiringPiSetupSys () < 0) - return -1 ; + ioctl (fileno (stdin), TIOCGWINSZ, &w); + cols = w.ws_col - 2 ; - if (gertboardSPISetup () < 0) - return 1 ; +// Always initialise wiringPi. Use wiringPiSys() if you don't need +// (or want) to run as root -// Generate a Sine Wave + wiringPiSetupSys () ; + +// Initialise the Gertboard analog hardware at pin 100 + + gertboardAnalogSetup (100) ; + +// Generate a Sine Wave and store in our buffer for (i = 0 ; i < B_SIZE ; ++i) { @@ -66,28 +73,23 @@ int main (void) buffer [i] = (int)rint ((sin (angle)) * 127.0 + 128.0) ; } +// Loop, output the sine wave on analog out port 0, read it into A-D port 0 +// and display it on the screen for (;;) { -#ifdef DO_TIMING - then = millis () ; -#endif - for (i = 0 ; i < B_SIZE ; ++i) { - gertboardAnalogWrite (0, buffer [i]) ; + analogWrite (100, buffer [i]) ; -#ifndef DO_TIMING - x1 = gertboardAnalogRead (0) ; - gertboardAnalogWrite (1, x1 >> 2) ; // 10-bit A/D, 8-bit D/A -#endif + inputValue = analogRead (100) ; + +// We don't need to wory about the scale or sign - the analog hardware is +// a 10-bit value, so 0-1023. Just scale this to our terminal + + printf ("%*s\n", (inputValue * cols) / 1023, "*") ; + delay (2) ; } - -#ifdef DO_TIMING - now = millis () ; - printf ("%4d mS, %9.7f S/sample", now - then, ((double)(now - then) / 1000.0) / (double)B_SIZE) ; - printf (" -> %9.4f samples/sec \n", 1 / (((double)(now - then) / 1000.0) / (double)B_SIZE)) ; -#endif } return 0 ; diff --git a/WiringPi/examples/Gertboard/record.c b/WiringPi/examples/Gertboard/record.c new file mode 100644 index 0000000..71d8718 --- /dev/null +++ b/WiringPi/examples/Gertboard/record.c @@ -0,0 +1,60 @@ +/* + * record.c: + * Record some audio via the Gertboard + * + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + */ + +#include +#include + +#include +#include + +#define B_SIZE 40000 + +int main () +{ + int i ; + struct timeval tStart, tEnd, tTaken ; + unsigned char buffer [B_SIZE] ; + + printf ("\n") ; + printf ("Gertboard demo: Recorder\n") ; + printf ("========================\n") ; + +// Always initialise wiringPi. Use wiringPiSys() if you don't need +// (or want) to run as root + + wiringPiSetupSys () ; + +// Initialise the Gertboard analog hardware at pin 100 + + gertboardAnalogSetup (100) ; + + gettimeofday (&tStart, NULL) ; + + for (i = 0 ; i < B_SIZE ; ++i) + buffer [i] = analogRead (100) >> 2 ; + + gettimeofday (&tEnd, NULL) ; + + timersub (&tEnd, &tStart, &tTaken) ; + + printf ("Time taken for %d reads: %ld.%ld\n", B_SIZE, tTaken.tv_sec, tTaken.tv_usec) ; + + gettimeofday (&tStart, NULL) ; + + for (i = 0 ; i < B_SIZE ; ++i) + analogWrite (100, buffer [i]) ; + + gettimeofday (&tEnd, NULL) ; + + timersub (&tEnd, &tStart, &tTaken) ; + + printf ("Time taken for %d writes: %ld.%ld\n", B_SIZE, tTaken.tv_sec, tTaken.tv_usec) ; + + return 0 ; +} + diff --git a/WiringPi/examples/Gertboard/temperature.c b/WiringPi/examples/Gertboard/temperature.c new file mode 100644 index 0000000..5985a12 --- /dev/null +++ b/WiringPi/examples/Gertboard/temperature.c @@ -0,0 +1,78 @@ +/* + * temperature.c: + * Demonstrate use of the Gertboard A to D converter to make + * a simple thermometer using the LM35. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include + +#include +#include + +int main () +{ + int x1, x2 ; + double v1, v2 ; + + printf ("\n") ; + printf ("Gertboard demo: Simple Thermemeter\n") ; + printf ("==================================\n") ; + +// Always initialise wiringPi. Use wiringPiSys() if you don't need +// (or want) to run as root + + wiringPiSetupSys () ; + +// Initialise the Gertboard analog hardware at pin 100 + + gertboardAnalogSetup (100) ; + + printf ("\n") ; + printf ("| Channel 0 | Channel 1 | Temperature 1 | Temperature 2 |\n") ; + + for (;;) + { + +// Read the 2 channels: + + x1 = analogRead (100) ; + x2 = analogRead (101) ; + +// Convert to a voltage: + + v1 = (double)x1 / 1023.0 * 3.3 ; + v2 = (double)x2 / 1023.0 * 3.3 ; + +// Print + + printf ("| %6.3f | %6.3f |", v1, v2) ; + +// Print Temperature of both channels by converting the LM35 reading +// to a temperature. Fortunately these are easy: 0.01 volts per C. + + printf (" %4.1f | %4.1f |\r", v1 * 100.0, v2 * 100.0) ; + fflush (stdout) ; + } + + return 0 ; +} + diff --git a/WiringPi/examples/Gertboard/voltmeter.c b/WiringPi/examples/Gertboard/voltmeter.c new file mode 100644 index 0000000..c4d2113 --- /dev/null +++ b/WiringPi/examples/Gertboard/voltmeter.c @@ -0,0 +1,73 @@ +/* + * voltmeter.c: + * Demonstrate use of the Gertboard A to D converter to make + * a simple voltmeter. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include + +#include +#include + +int main () +{ + int x1, x2 ; + double v1, v2 ; + + printf ("\n") ; + printf ("Gertboard demo: Simple Voltmeters\n") ; + printf ("=================================\n") ; + +// Always initialise wiringPi. Use wiringPiSys() if you don't need +// (or want) to run as root + + wiringPiSetupSys () ; + +// Initialise the Gertboard analog hardware at pin 100 + + gertboardAnalogSetup (100) ; + + printf ("\n") ; + printf ("| Channel 0 | Channel 1 |\n") ; + + for (;;) + { + +// Read the 2 channels: + + x1 = analogRead (100) ; + x2 = analogRead (101) ; + +// Convert to a voltage: + + v1 = (double)x1 / 1023.0 * 3.3 ; + v2 = (double)x2 / 1023.0 * 3.3 ; + +// Print + + printf ("| %6.3f | %6.3f |\r", v1, v2) ; + fflush (stdout) ; + } + + return 0 ; +} + diff --git a/WiringPi/examples/Gertboard/vumeter.c b/WiringPi/examples/Gertboard/vumeter.c new file mode 100644 index 0000000..9643ace --- /dev/null +++ b/WiringPi/examples/Gertboard/vumeter.c @@ -0,0 +1,152 @@ +/* + * vumeter.c: + * Simple VU meter + * + * Heres the theory: + * We will sample at 4000 samples/sec and put the data into a + * low-pass filter with a depth of 1000 samples. This will give + * us 1/4 a second of lag on the signal, but I think it might + * produce a more pleasing output. + * + * The input of the microphone should be at mid-pont with no + * sound input, but we might have to sample that too, to get + * our reference zero... + * + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + +#ifndef TRUE +#define TRUE (1==1) +#define FALSE (!TRUE) +#endif + +#define B_SIZE 1000 +#define S_SIZE 128 + +static int buffer [B_SIZE] ; +static int bPtr = 0 ; + +/* + * ledPercent: + * Output the given value as a percentage on the LEDs + ********************************************************************************* + */ + +static void ledPercent (int percent) +{ + unsigned int output = 0 ; + + if (percent > 11) output |= 0x01 ; + if (percent > 22) output |= 0x02 ; + if (percent > 33) output |= 0x04 ; + if (percent > 44) output |= 0x08 ; + if (percent > 55) output |= 0x10 ; + if (percent > 66) output |= 0x20 ; + if (percent > 77) output |= 0x40 ; + if (percent > 88) output |= 0x80 ; + + digitalWriteByte (output) ; +} + +static unsigned int tPeriod, tNextSampleTime ; + +/* + * sample: + * Get a sample from the Gertboard. If not enough time has elapsed + * since the last sample, then wait... + ********************************************************************************* + */ + +static void sample (void) +{ + unsigned int tFuture ; + +// Calculate the future sample time + + tFuture = tPeriod + tNextSampleTime ; + +// Wait until the next sample time + + while (micros () < tNextSampleTime) + ; + + buffer [bPtr] = gertboardAnalogRead (0) ; + + tNextSampleTime = tFuture ; +} + + +int main () +{ + int quietLevel, min, max ; + int i, sum ; + unsigned int tStart, tEnd ; + + printf ("\n") ; + printf ("Gertboard demo: VU Meter\n") ; + printf ("========================\n") ; + + wiringPiSetup () ; + gertboardSPISetup () ; + + ledPercent (0) ; + for (i = 0 ; i < 8 ; ++i) + pinMode (i, OUTPUT) ; + + for (bPtr = 0 ; bPtr < B_SIZE ; ++bPtr) + buffer [bPtr] = 99 ; + + tPeriod = 1000000 / 1000 ; + + printf ("Shhhh.... ") ; fflush (stdout) ; + delay (1000) ; + printf ("Sampling quiet... ") ; fflush (stdout) ; + + tStart = micros () ; + + tNextSampleTime = micros () ; + for (bPtr = 0 ; bPtr < B_SIZE ; ++bPtr) + sample () ; + + tEnd = micros () ; + + quietLevel = 0 ; + max = 0 ; + min = 1024 ; + for (i = 0 ; i < B_SIZE ; ++i) + { + quietLevel += buffer [i] ; + if (buffer [i] > max) max = buffer [i] ; + if (buffer [i] < min) min = buffer [i] ; + } + quietLevel /= B_SIZE ; + + printf ("Done. Quiet level is: %d [%d:%d] [%d:%d]\n", quietLevel, min, max, quietLevel - min, max - quietLevel) ; + + printf ("Time taken for %d reads: %duS\n", B_SIZE, tEnd - tStart) ; + + for (bPtr = 0 ;;) + { + sample () ; + sum = 0 ; + for (i = 0 ; i < S_SIZE ; ++i) + sum += buffer [i] ; + sum /= S_SIZE ; + sum = abs (quietLevel - sum) ; + sum = (sum * 1000) / quietLevel ; + ledPercent (sum) ; + if (++bPtr > S_SIZE) + bPtr = 0 ; + } + + + return 0 ; +} diff --git a/WiringPi/examples/Makefile b/WiringPi/examples/Makefile index b1ab319..8cc256f 100644 --- a/WiringPi/examples/Makefile +++ b/WiringPi/examples/Makefile @@ -30,15 +30,19 @@ INCLUDE = -I/usr/local/include CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe LDFLAGS = -L/usr/local/lib -LDLIBS = -lwiringPi -lpthread -lm +LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm # Should not alter anything below this line ############################################################################### -SRC = blink.c test1.c test2.c speed.c lcd.c wfi.c isr.c isr-osc.c \ - piface.c gertboard.c nes.c \ - pwm.c tone.c servo.c \ - delayTest.c serialRead.c serialTest.c okLed.c ds1302.c +SRC = blink.c blink8.c blink12.c \ + pwm.c \ + speed.c wfi.c isr.c isr-osc.c \ + lcd.c lcd-adafruit.c clock.c \ + nes.c \ + softPwm.c softTone.c \ + delayTest.c serialRead.c serialTest.c okLed.c ds1302.c \ + rht03.c OBJ = $(SRC:.c=.o) @@ -55,13 +59,13 @@ blink: blink.o @echo [link] @$(CC) -o $@ blink.o $(LDFLAGS) $(LDLIBS) -test1: test1.o +blink8: blink8.o @echo [link] - @$(CC) -o $@ test1.o $(LDFLAGS) $(LDLIBS) - -test2: test2.o + @$(CC) -o $@ blink8.o $(LDFLAGS) $(LDLIBS) + +blink12: blink12.o @echo [link] - @$(CC) -o $@ test2.o $(LDFLAGS) $(LDLIBS) + @$(CC) -o $@ blink12.o $(LDFLAGS) $(LDLIBS) speed: speed.o @echo [link] @@ -71,6 +75,14 @@ lcd: lcd.o @echo [link] @$(CC) -o $@ lcd.o $(LDFLAGS) $(LDLIBS) +lcd-adafruit: lcd-adafruit.o + @echo [link] + @$(CC) -o $@ lcd-adafruit.o $(LDFLAGS) $(LDLIBS) + +clock: clock.o + @echo [link] + @$(CC) -o $@ clock.o $(LDFLAGS) $(LDLIBS) + wfi: wfi.o @echo [link] @$(CC) -o $@ wfi.o $(LDFLAGS) $(LDLIBS) @@ -83,22 +95,26 @@ isr-osc: isr-osc.o @echo [link] @$(CC) -o $@ isr-osc.o $(LDFLAGS) $(LDLIBS) -piface: piface.o - @echo [link] - @$(CC) -o $@ piface.o $(LDFLAGS) $(LDLIBS) - -gertboard: gertboard.o - @echo [link] - @$(CC) -o $@ gertboard.o $(LDFLAGS) $(LDLIBS) - nes: nes.o @echo [link] @$(CC) -o $@ nes.o $(LDFLAGS) $(LDLIBS) +rht03: rht03.o + @echo [link] + @$(CC) -o $@ rht03.o $(LDFLAGS) $(LDLIBS) + pwm: pwm.o @echo [link] @$(CC) -o $@ pwm.o $(LDFLAGS) $(LDLIBS) +softPwm: softPwm.o + @echo [link] + @$(CC) -o $@ softPwm.o $(LDFLAGS) $(LDLIBS) + +softTone: softTone.o + @echo [link] + @$(CC) -o $@ softTone.o $(LDFLAGS) $(LDLIBS) + delayTest: delayTest.o @echo [link] @$(CC) -o $@ delayTest.o $(LDFLAGS) $(LDLIBS) @@ -119,10 +135,6 @@ tone: tone.o @echo [link] @$(CC) -o $@ tone.o $(LDFLAGS) $(LDLIBS) -servo: servo.o - @echo [link] - @$(CC) -o $@ servo.o $(LDFLAGS) $(LDLIBS) - ds1302: ds1302.o @echo [link] @$(CC) -o $@ ds1302.o $(LDFLAGS) $(LDLIBS) @@ -133,7 +145,8 @@ ds1302: ds1302.o @$(CC) -c $(CFLAGS) $< -o $@ clean: - rm -f $(OBJ) *~ core tags $(BINS) + @echo "[Clean]" + @rm -f $(OBJ) *~ core tags $(BINS) tags: $(SRC) @echo [ctags] diff --git a/WiringPi/examples/PiFace/Makefile b/WiringPi/examples/PiFace/Makefile new file mode 100644 index 0000000..0bde334 --- /dev/null +++ b/WiringPi/examples/PiFace/Makefile @@ -0,0 +1,85 @@ +# +# Makefile: +# wiringPi - Wiring Compatable library for the Raspberry Pi +# https://projects.drogon.net/wiring-pi +# +# Copyright (c) 2012 Gordon Henderson +################################################################################# +# This file is part of wiringPi: +# Wiring Compatable library for the Raspberry Pi +# +# wiringPi is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# wiringPi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with wiringPi. If not, see . +################################################################################# + + +#DEBUG = -g -O0 +DEBUG = -O3 +CC = gcc +INCLUDE = -I/usr/local/include +CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe + +LDFLAGS = -L/usr/local/lib +LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm + +# Should not alter anything below this line +############################################################################### + +SRC = blink.c buttons.c reaction.c ladder.c metro.c motor.c + +OBJ = $(SRC:.c=.o) + +BINS = $(SRC:.c=) + +all: $(BINS) + +blink: blink.o + @echo [link] + @$(CC) -o $@ blink.o $(LDFLAGS) $(LDLIBS) + +buttons: buttons.o + @echo [link] + @$(CC) -o $@ buttons.o $(LDFLAGS) $(LDLIBS) + +reaction: reaction.o + @echo [link] + @$(CC) -o $@ reaction.o $(LDFLAGS) $(LDLIBS) + +ladder: ladder.o + @echo [link] + @$(CC) -o $@ ladder.o $(LDFLAGS) $(LDLIBS) + +metro: metro.o + @echo [link] + @$(CC) -o $@ metro.o $(LDFLAGS) $(LDLIBS) + +motor: motor.o + @echo [link] + @$(CC) -o $@ motor.o $(LDFLAGS) $(LDLIBS) + +.c.o: + @echo [CC] $< + @$(CC) -c $(CFLAGS) $< -o $@ + +clean: + @echo "[Clean]" + @rm -f $(OBJ) *~ core tags $(BINS) + +tags: $(SRC) + @echo [ctags] + @ctags $(SRC) + +depend: + makedepend -Y $(SRC) + +# DO NOT DELETE diff --git a/WiringPi/examples/PiFace/blink.c b/WiringPi/examples/PiFace/blink.c new file mode 100644 index 0000000..ffb8a2e --- /dev/null +++ b/WiringPi/examples/PiFace/blink.c @@ -0,0 +1,59 @@ +/* + * blink.c: + * Simple "blink" test for the PiFace interface board. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include + +#include +#include + +// Use 200 as the pin-base for the PiFace board, and pick a pin +// for the LED that's not connected to a relay + +#define PIFACE 200 +#define LED (PIFACE+2) + +int main (int argc, char *argv []) +{ + printf ("Raspberry Pi PiFace Blink\n") ; + printf ("=========================\n") ; + +// Always initialise wiringPi. Use wiringPiSys() if you don't need +// (or want) to run as root + + wiringPiSetupSys () ; + +// Setup the PiFace board + + piFaceSetup (PIFACE) ; + + for (;;) + { + digitalWrite (LED, HIGH) ; // On + delay (500) ; // mS + digitalWrite (LED, LOW) ; // Off + delay (500) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/piface.c b/WiringPi/examples/PiFace/buttons.c similarity index 57% rename from WiringPi/examples/piface.c rename to WiringPi/examples/PiFace/buttons.c index c17cfb9..147a4bd 100644 --- a/WiringPi/examples/piface.c +++ b/WiringPi/examples/PiFace/buttons.c @@ -1,5 +1,5 @@ /* - * piFace.c: + * buttons.c: * Simple test for the PiFace interface board. * * Read the buttons and output the same to the LEDs @@ -24,23 +24,33 @@ *********************************************************************** */ +#include + #include #include -#include -#include -#include - int outputs [4] = { 0,0,0,0 } ; +// Use 200 as the pin-base for the PiFace board + #define PIFACE_BASE 200 + +/* + * scanButton: + * Read the guiven button - if it's pressed, then flip the state + * of the correspoinding output pin + ********************************************************************************* + */ + void scanButton (int button) { if (digitalRead (PIFACE_BASE + button) == LOW) { outputs [button] ^= 1 ; digitalWrite (PIFACE_BASE + button, outputs [button]) ; + printf ("Button %d pushed - output now: %s\n", + button, (outputs [button] == 0) ? "Off" : "On") ; } while (digitalRead (PIFACE_BASE + button) == LOW) @@ -48,26 +58,45 @@ void scanButton (int button) } +/* + * start here + ********************************************************************************* + */ + int main (void) { int pin, button ; - printf ("Raspberry Pi wiringPiFace test program\n") ; - printf ("======================================\n") ; + printf ("Raspberry Pi wiringPi + PiFace test program\n") ; + printf ("===========================================\n") ; + printf ("\n") ; + printf ( +"This program reads the buttons and uses them to toggle the first 4\n" +"outputs. Push a button once to turn an output on, and push it again to\n" +"turn it off again.\n\n") ; - if (piFaceSetup (200) == -1) - exit (1) ; +// Always initialise wiringPi. Use wiringPiSys() if you don't need +// (or want) to run as root -// Enable internal pull-ups + wiringPiSetupSys () ; - for (pin = PIFACE_BASE ; pin < (PIFACE_BASE + 8) ; ++pin) - pullUpDnControl (pin, PUD_UP) ; + piFaceSetup (PIFACE_BASE) ; + +// Enable internal pull-ups & start with all off + + for (pin = 0 ; pin < 8 ; ++pin) + { + pullUpDnControl (PIFACE_BASE + pin, PUD_UP) ; + digitalWrite (PIFACE_BASE + pin, 0) ; + } + +// Loop, scanning the buttons for (;;) { for (button = 0 ; button < 4 ; ++button) scanButton (button) ; - delay (1) ; + delay (5) ; } return 0 ; diff --git a/WiringPi/examples/PiFace/ladder.c b/WiringPi/examples/PiFace/ladder.c new file mode 100755 index 0000000..4f08a6f --- /dev/null +++ b/WiringPi/examples/PiFace/ladder.c @@ -0,0 +1,337 @@ +/* + * ladder.c: + * + * Gordon Henderson, June 2012 + *********************************************************************** + */ + +#include +#include +#include +#include + +#include +#include + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + +#undef DEBUG + +#define NUM_LEDS 8 + + +// Map the LEDs to the hardware pins +// using PiFace pin numbers here + +#define PIFACE 200 + +const int ledMap [NUM_LEDS] = +{ +// 0, 1, 2, 3, 4, 5, 6, 7, 8 + 200, 201, 202, 203, 204, 205, 206, 207 +} ; + + +// Some constants for our circuit simulation + +const double vBatt = 9.0 ; // Volts (ie. a PP3) +const double capacitor = 0.001 ; // 1000uF +const double rCharge = 2200.0 ; // ohms +const double rDischarge = 68000.0 ; // ohms +const double timeInc = 0.01 ; // Seconds + +double vCharge, vCap, vCapLast ; + + + +/* + * setup: + * Program the GPIO correctly and initialise the lamps + *********************************************************************** + */ + +void setup (void) +{ + int i ; + + wiringPiSetupSys () ; + + if (piFaceSetup (200) == -1) + exit (1) ; + +// Enable internal pull-ups + + for (i = 0 ; i < 8 ; ++i) + pullUpDnControl (PIFACE + i, PUD_UP) ; + +// Calculate the actual charging voltage - standard calculation of +// vCharge = r2 / (r1 + r2) * vBatt +// +// +// -----+--- vBatt +// | +// R1 +// | +// +---+---- vCharge +// | | +// R2 C +// | | +// -----+---+----- + + vCharge = rDischarge / (rCharge + rDischarge) * vBatt ; + +// Start with no charge + + vCap = vCapLast = 0.0 ; +} + + +/* + * introLeds + * Put a little pattern on the LEDs to start with + ********************************************************************************* + */ + +void introLeds (void) +{ + int i, j ; + + + printf ("Pi Ladder\n") ; + printf ("=========\n\n") ; + printf (" vBatt: %6.2f volts\n", vBatt) ; + printf (" rCharge: %6.0f ohms\n", rCharge) ; + printf (" rDischarge: %6.0f ohms\n", rDischarge) ; + printf (" vCharge: %6.2f volts\n", vCharge) ; + printf (" capacitor: %6.0f uF\n", capacitor * 1000.0) ; + +// Flash 3 times: + + for (j = 0 ; j < 3 ; ++j) + { + for (i = 0 ; i < NUM_LEDS ; ++i) + digitalWrite (ledMap [i], 1) ; + delay (500) ; + for (i = 0 ; i < NUM_LEDS ; ++i) + digitalWrite (ledMap [i], 0) ; + delay (100) ; + } + +// All On + + for (i = 0 ; i < NUM_LEDS ; ++i) + digitalWrite (ledMap [i], 1) ; + delay (500) ; + +// Countdown... + + for (i = NUM_LEDS - 1 ; i >= 0 ; --i) + { + digitalWrite (ledMap [i], 0) ; + delay (100) ; + } + delay (500) ; +} + + +/* + * winningLeds + * Put a little pattern on the LEDs to start with + ********************************************************************************* + */ + +void winningLeds (void) +{ + int i, j ; + +// Flash 3 times: + + for (j = 0 ; j < 3 ; ++j) + { + for (i = 0 ; i < NUM_LEDS ; ++i) + digitalWrite (ledMap [i], 1) ; + delay (500) ; + for (i = 0 ; i < NUM_LEDS ; ++i) + digitalWrite (ledMap [i], 0) ; + delay (100) ; + } + +// All On + + for (i = 0 ; i < NUM_LEDS ; ++i) + digitalWrite (ledMap [i], 1) ; + delay (500) ; + +// Countup... + + for (i = 0 ; i < NUM_LEDS ; ++i) + { + digitalWrite (ledMap [i], 0) ; + delay (100) ; + } + delay (500) ; +} + + +/* + * chargeCapacitor: dischargeCapacitor: + * Add or remove charge to the capacitor. + * Standard capacitor formulae. + ********************************************************************************* + */ + +void chargeCapacitor (void) +{ + vCap = (vCapLast - vCharge) * + exp (- timeInc / (rCharge * capacitor)) + vCharge ; + +#ifdef DEBUG + printf ("+vCap: %7.4f\n", vCap) ; +#endif + + vCapLast = vCap ; +} + +void dischargeCapacitor (void) +{ + vCap = vCapLast * + exp (- timeInc / (rDischarge * capacitor)) ; + +#ifdef DEBUG + printf ("-vCap: %7.4f\n", vCap) ; +#endif + + vCapLast = vCap ; +} + + +/* + * ledBargraph: + * Output the supplied number as a bargraph on the LEDs + ********************************************************************************* + */ + +void ledBargraph (double value, int topLedOn) +{ + int topLed = (int)floor (value / vCharge * (double)NUM_LEDS) + 1 ; + int i ; + + if (topLed > NUM_LEDS) + topLed = NUM_LEDS ; + + if (!topLedOn) + --topLed ; + + for (i = 0 ; i < topLed ; ++i) + digitalWrite (ledMap [i], 1) ; + + for (i = topLed ; i < NUM_LEDS ; ++i) + digitalWrite (ledMap [i], 0) ; +} + + +/* + * ledOnAction: + * Make sure the leading LED is on and check the button + ********************************************************************************* + */ + +void ledOnAction (void) +{ + if (digitalRead (PIFACE) == LOW) + { + chargeCapacitor () ; + ledBargraph (vCap, TRUE) ; + } +} + + +/* + * ledOffAction: + * Make sure the leading LED is off and check the button + ********************************************************************************* + */ + +void ledOffAction (void) +{ + dischargeCapacitor () ; + +// Are we still pushing the button? + + if (digitalRead (PIFACE) == LOW) + { + vCap = vCapLast = 0.0 ; + ledBargraph (vCap, FALSE) ; + +// Wait until we release the button + + while (digitalRead (PIFACE) == LOW) + delay (10) ; + } +} + + +/* + *********************************************************************** + * The main program + *********************************************************************** + */ + +int main (void) +{ + unsigned int then, ledOnTime, ledOffTime ; + unsigned int ourDelay = (int)(1000.0 * timeInc) ; + + setup () ; + introLeds () ; + +// Setup the LED times - TODO reduce the ON time as the game progresses + + ledOnTime = 1000 ; + ledOffTime = 1000 ; + +// This is our Gate/Squarewave loop + + for (;;) + { + +// LED ON: + + (void)ledBargraph (vCap, TRUE) ; + then = millis () + ledOnTime ; + while (millis () < then) + { + ledOnAction () ; + delay (ourDelay) ; + } + +// Have we won yet? +// We need vCap to be in the top NUM_LEDS of the vCharge + + if (vCap > ((double)(NUM_LEDS - 1) / (double)NUM_LEDS * vCharge)) // Woo hoo! + { + winningLeds () ; + while (digitalRead (PIFACE) == HIGH) + delay (10) ; + while (digitalRead (PIFACE) == LOW) + delay (10) ; + vCap = vCapLast = 0.0 ; + } + +// LED OFF: + + (void)ledBargraph (vCap, FALSE) ; + then = millis () + ledOffTime ; + while (millis () < then) + { + ledOffAction () ; + delay (ourDelay) ; + } + + } + + return 0 ; +} diff --git a/WiringPi/examples/PiFace/metro.c b/WiringPi/examples/PiFace/metro.c new file mode 100644 index 0000000..a4a8c1d --- /dev/null +++ b/WiringPi/examples/PiFace/metro.c @@ -0,0 +1,111 @@ +/* + * metronome.c: + * Simple test for the PiFace interface board. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + +#define PIFACE 200 + +/* + * middleA: + * Play middle A (on the relays - yea!) + ********************************************************************************* + */ + +static void middleA (void) +{ + unsigned int next ; + + for (;;) + { + next = micros () + 1136 ; + digitalWrite (PIFACE + 0, 0) ; + digitalWrite (PIFACE + 1, 0) ; + while (micros () < next) + delayMicroseconds (1) ; + + next = micros () + 1137 ; + digitalWrite (PIFACE + 0, 1) ; + digitalWrite (PIFACE + 1, 1) ; + while (micros () < next) + delayMicroseconds (1) ; + + } +} + + +int main (int argc, char *argv []) +{ + int bpm, msPerBeat, state = 0 ; + unsigned int end ; + + printf ("Raspberry Pi PiFace Metronome\n") ; + printf ("=============================\n") ; + + piHiPri (50) ; + + wiringPiSetupSys () ; // Needed for timing functions + piFaceSetup (PIFACE) ; + + if (argc != 2) + { + printf ("Usage: %s \n", argv [0]) ; + exit (1) ; + } + + if (strcmp (argv [1], "a") == 0) + middleA () ; + + bpm = atoi (argv [1]) ; + + if ((bpm < 40) || (bpm > 208)) + { + printf ("%s range is 40 through 208 beats per minute\n", argv [0]) ; + exit (1) ; + } + + msPerBeat = 60000 / bpm ; + +// Main loop: +// Put some random LED pairs up for a few seconds, then blank ... + + for (;;) + { + end = millis () + msPerBeat ; + + digitalWrite (PIFACE + 0, state) ; + digitalWrite (PIFACE + 1, state) ; + + while (millis () < end) + delayMicroseconds (500) ; + + state ^= 1 ; + } + + return 0 ; +} diff --git a/WiringPi/examples/PiFace/motor.c b/WiringPi/examples/PiFace/motor.c new file mode 100644 index 0000000..14f5539 --- /dev/null +++ b/WiringPi/examples/PiFace/motor.c @@ -0,0 +1,120 @@ +/* + * motor.c: + * Use the PiFace board to demonstrate an H bridge + * circuit via the 2 relays. + * Then add on an external transsitor to help with PWM. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include +#include + +int outputs [2] = { 0,0 } ; + +#define PIFACE_BASE 200 +#define PWM_OUT_PIN 204 +#define PWM_UP 202 +#define PWM_DOWN 203 + +void scanButton (int button) +{ + if (digitalRead (PIFACE_BASE + button) == LOW) + { + outputs [button] ^= 1 ; + digitalWrite (PIFACE_BASE + button, outputs [button]) ; + printf ("Button %d pushed - output now: %s\n", + button, (outputs [button] == 0) ? "Off" : "On") ; + } + + while (digitalRead (PIFACE_BASE + button) == LOW) + delay (1) ; +} + + +int main (void) +{ + int pin, button ; + int pwmValue = 0 ; + + printf ("Raspberry Pi PiFace - Motor control\n") ; + printf ("==================================\n") ; + printf ("\n") ; + printf ( +"This program is designed to be used with a motor connected to the relays\n" +"in an H-Bridge type configuration with optional speeed control via PWM.\n" +"\n" +"Use the leftmost buttons to turn each relay on and off, and the rigthmost\n" +"buttons to increase ot decrease the PWM output on the control pin (pin\n" +"4)\n\n") ; + + wiringPiSetup () ; + piFaceSetup (PIFACE_BASE) ; + softPwmCreate (PWM_OUT_PIN, 100, 100) ; + +// Enable internal pull-ups & start with all off + + for (pin = 0 ; pin < 8 ; ++pin) + { + pullUpDnControl (PIFACE_BASE + pin, PUD_UP) ; + digitalWrite (PIFACE_BASE + pin, 0) ; + } + + for (;;) + { + for (button = 0 ; button < 2 ; ++button) + scanButton (button) ; + + if (digitalRead (PWM_UP) == LOW) + { + pwmValue += 10 ; + if (pwmValue > 100) + pwmValue = 100 ; + + softPwmWrite (PWM_OUT_PIN, pwmValue) ; + printf ("PWM -> %3d\n", pwmValue) ; + + while (digitalRead (PWM_UP) == LOW) + delay (5) ; + } + + if (digitalRead (PWM_DOWN) == LOW) + { + pwmValue -= 10 ; + if (pwmValue < 0) + pwmValue = 0 ; + + softPwmWrite (PWM_OUT_PIN, pwmValue) ; + printf ("PWM -> %3d\n", pwmValue) ; + + while (digitalRead (PWM_DOWN) == LOW) + delay (5) ; + } + + delay (5) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/PiFace/reaction.c b/WiringPi/examples/PiFace/reaction.c new file mode 100644 index 0000000..5084508 --- /dev/null +++ b/WiringPi/examples/PiFace/reaction.c @@ -0,0 +1,194 @@ +/* + * reaction.c: + * Simple test for the PiFace interface board. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + + +int outputs [4] = { 0,0,0,0 } ; + +#define PIFACE 200 + +/* + * light: + * Light up the given LED - actually lights up a pair + ********************************************************************************* + */ + +void light (int led, int value) +{ + led *= 2 ; + digitalWrite (PIFACE + led + 0, value) ; + digitalWrite (PIFACE + led + 1, value) ; +} + +/* + * lightAll: + * All On or Off + ********************************************************************************* + */ + +void lightAll (int onoff) +{ + light (0, onoff) ; + light (1, onoff) ; + light (2, onoff) ; + light (3, onoff) ; +} + + +/* + * waitForNoButtons: + * Wait for all buttons to be released + ********************************************************************************* + */ + +void waitForNoButtons (void) +{ + int i, button ; + + for (;;) + { + button = 0 ; + for (i = 0 ; i < 4 ; ++i) + button += digitalRead (PIFACE + i) ; + + if (button == 4) + break ; + } +} + + +void scanButton (int button) +{ + if (digitalRead (PIFACE + button) == LOW) + { + outputs [button] ^= 1 ; + digitalWrite (PIFACE + button, outputs [button]) ; + } + + while (digitalRead (PIFACE + button) == LOW) + delay (1) ; +} + + +int main (void) +{ + int i, j ; + int led, button ; + unsigned int start, stop ; + + printf ("Raspberry Pi PiFace Reaction Timer\n") ; + printf ("==================================\n") ; + + if (piFaceSetup (PIFACE) == -1) + exit (1) ; + +// Enable internal pull-ups + + for (i = 0 ; i < 8 ; ++i) + pullUpDnControl (PIFACE + i, PUD_UP) ; + + +// Main game loop: +// Put some random LED pairs up for a few seconds, then blank ... + + for (;;) + { + printf ("Press any button to start ... \n") ; fflush (stdout) ; + + for (;;) + { + led = rand () % 4 ; + light (led, 1) ; + delay (10) ; + light (led, 0) ; + + button = 0 ; + for (j = 0 ; j < 4 ; ++j) + button += digitalRead (PIFACE + j) ; + + if (button != 4) + break ; + } + + waitForNoButtons () ; + + printf ("Wait for it ... ") ; fflush (stdout) ; + + led = rand () % 4 ; + delay (rand () % 500 + 1000) ; + light (led, 1) ; + + start = millis () ; + for (button = -1 ; button == -1 ; ) + { + for (j = 0 ; j < 4 ; ++j) + if (digitalRead (PIFACE + j) == 0) // Pushed + { + button = j ; + break ; + } + } + stop = millis () ; + button = 3 - button ; // Correct for the buttons/LEDs reversed + + light (led, 0) ; + + waitForNoButtons () ; + + light (led, 1) ; + + if (button == led) + { + printf ("You got it in %3d mS\n", stop - start) ; + } + else + { + printf ("Missed: You pushed %d - LED was %d\n", button, led) ; + for (;;) + { + light (button, 1) ; + delay (100) ; + light (button, 0) ; + delay (100) ; + i = 0 ; + for (j = 0 ; j < 4 ; ++j) + i += digitalRead (PIFACE + j) ; + if (i != 4) + break ; + } + + waitForNoButtons () ; + } + light (led, 0) ; + delay (4000) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/blink.c b/WiringPi/examples/blink.c index bb9f856..c27a20e 100644 --- a/WiringPi/examples/blink.c +++ b/WiringPi/examples/blink.c @@ -34,16 +34,14 @@ int main (void) { printf ("Raspberry Pi blink\n") ; - if (wiringPiSetup () == -1) - return 1 ; - + wiringPiSetup () ; pinMode (LED, OUTPUT) ; for (;;) { - digitalWrite (LED, 1) ; // On + digitalWrite (LED, HIGH) ; // On delay (500) ; // mS - digitalWrite (LED, 0) ; // Off + digitalWrite (LED, LOW) ; // Off delay (500) ; } return 0 ; diff --git a/WiringPi/examples/test1.c b/WiringPi/examples/blink12.c similarity index 70% rename from WiringPi/examples/test1.c rename to WiringPi/examples/blink12.c index 4c75711..c9b3d50 100644 --- a/WiringPi/examples/test1.c +++ b/WiringPi/examples/blink12.c @@ -1,8 +1,7 @@ /* - * test1.c: - * Simple test program to test the wiringPi functions - * This is a sequencer to make a patter appear on 8 LEDs - * connected to the GPIO pins. + * blink12.c: + * Simple sequence over the first 12 GPIO pins - LEDs + * Aimed at the Gertboard, but it's fairly generic. * * Copyright (c) 2012-2013 Gordon Henderson. *********************************************************************** @@ -24,17 +23,13 @@ *********************************************************************** */ -#include - #include -#include -#include - +#include // Simple sequencer data // Triplets of LED, On/Off and delay -uint8_t data [] = +int data [] = { 0, 1, 1, 1, 1, 1, @@ -44,15 +39,23 @@ uint8_t data [] = 3, 0, 0, 5, 1, 1, 4, 0, 0, 6, 1, 1, 5, 0, 0, 7, 1, 1, - 6, 0, 1, - 7, 0, 1, + 6, 0, 0, 11, 1, 1, + 7, 0, 0, 10, 1, 1, + 11, 0, 0, 13, 1, 1, + 10, 0, 0, 12, 1, 1, + 13, 0, 1, + 12, 0, 1, 0, 0, 1, // Extra delay // Back again - 7, 1, 1, - 6, 1, 1, + 12, 1, 1, + 13, 1, 1, + 12, 0, 0, 10, 1, 1, + 13, 0, 0, 11, 1, 1, + 10, 0, 0, 7, 1, 1, + 11, 0, 0, 6, 1, 1, 7, 0, 0, 5, 1, 1, 6, 0, 0, 4, 1, 1, 5, 0, 0, 3, 1, 1, @@ -64,7 +67,7 @@ uint8_t data [] = 0, 0, 1, // Extra delay - 9, 9, 9, // End marker + 0, 9, 0, // End marker } ; @@ -75,16 +78,17 @@ int main (void) int dataPtr ; int l, s, d ; - printf ("Raspberry Pi wiringPi test program\n") ; + printf ("Raspberry Pi - 12-LED Sequence\n") ; + printf ("==============================\n") ; + printf ("\n") ; + printf ("Connect LEDs up to the first 8 GPIO pins, then pins 11, 10, 13, 12 in\n") ; + printf (" that order, then sit back and watch the show!\n") ; - if (wiringPiSetup () == -1) - exit (1) ; + wiringPiSetup () ; - for (pin = 0 ; pin < 8 ; ++pin) + for (pin = 0 ; pin < 14 ; ++pin) pinMode (pin, OUTPUT) ; - pinMode (8, INPUT) ; // Pin 8 SDA0 - Has on-board 2k2 pull-up resistor - dataPtr = 0 ; for (;;) @@ -93,18 +97,14 @@ int main (void) s = data [dataPtr++] ; // State d = data [dataPtr++] ; // Duration (10ths) - if ((l + s + d) == 27) + if (s == 9) // 9 -> End Marker { dataPtr = 0 ; continue ; } digitalWrite (l, s) ; - - if (digitalRead (8) == 0) // Pressed as our switch shorts to ground - delay (d * 10) ; // Faster! - else - delay (d * 100) ; + delay (d * 100) ; } return 0 ; diff --git a/WiringPi/examples/blink8.c b/WiringPi/examples/blink8.c new file mode 100644 index 0000000..602d3c0 --- /dev/null +++ b/WiringPi/examples/blink8.c @@ -0,0 +1,57 @@ +/* + * blink8.c: + * Simple sequence over the first 8 GPIO pins - LEDs + * Aimed at the Gertboard, but it's fairly generic. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include + +int main (void) +{ + int i, led ; + + printf ("Raspberry Pi - 8-LED Sequencer\n") ; + printf ("==============================\n") ; + printf ("\n") ; + printf ("Connect LEDs to the first 8 GPIO pins and watch ...\n") ; + + wiringPiSetup () ; + + for (i = 0 ; i < 8 ; ++i) + pinMode (i, OUTPUT) ; + + for (;;) + { + for (led = 0 ; led < 8 ; ++led) + { + digitalWrite (led, 1) ; + delay (100) ; + } + + for (led = 0 ; led < 8 ; ++led) + { + digitalWrite (led, 0) ; + delay (100) ; + } + } +} diff --git a/WiringPi/examples/clock.c b/WiringPi/examples/clock.c new file mode 100644 index 0000000..9a53210 --- /dev/null +++ b/WiringPi/examples/clock.c @@ -0,0 +1,201 @@ +/* + * clock.c: + * Demo of the 128x64 graphics based LCD driver. + * This is designed to drive the parallel interface LCD drivers + * based on the popular 12864H controller chip. + * + * This test program assumes the following: + * (Which is currently hard-wired into the driver) + * + * GPIO 0-7 is connected to display data pins 0-7. + * GPIO 10 is CS1 + * GPIO 11 is CS2 + * GPIO 12 is STROBE + * GPIO 10 is RS + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + +double clockRadius ; +double thickness, barLen ; +int maxX, maxY ; + +double rads (double degs) +{ + return degs * M_PI / 180.0 ; +} + +void drawClockHands (void) +{ + time_t t ; + struct tm *now ; + double angle, p, x0, y0, x1, y1 ; + int h24, h, m, s ; + char text [20] ; + + time (&t) ; + now = localtime (&t) ; + + h24 = now->tm_hour ; + m = now->tm_min ; + s = now->tm_sec ; + + h = h24 ; + if (h > 12) + h -= 12 ; + +// Hour hand + + angle = h * 30 + m * 0.5 ; + x0 = sin (rads (angle)) * (clockRadius * 0.75) ; + y0 = cos (rads (angle)) * (clockRadius * 0.75) ; + for (p = -3.0 ; p <= 3.0 ; p += 0.2) + { + x1 = sin (rads (angle + p)) * (clockRadius * 0.7) ; + y1 = cos (rads (angle + p)) * (clockRadius * 0.7) ; + lcd128x64line (0, 0, x1, y1, 1) ; + lcd128x64lineTo (x0, y0, 1) ; + } + +// Minute hand + + angle = m * 6 ; + x0 = sin (rads (angle)) * (clockRadius * 0.9) ; + y0 = cos (rads (angle)) * (clockRadius * 0.9) ; + for (p = -1.0 ; p <= 1.0 ; p += 0.2) + { + x1 = sin (rads (angle + p)) * (clockRadius * 0.85) ; + y1 = cos (rads (angle + p)) * (clockRadius * 0.85) ; + lcd128x64line (0, 0, x1, y1, 1) ; + lcd128x64lineTo (x0, y0, 1) ; + } + +// Second hand + + angle = s * 6 ; + x0 = sin (rads (angle)) * (clockRadius * 0.2) ; + y0 = cos (rads (angle)) * (clockRadius * 0.2) ; + x1 = sin (rads (angle)) * (clockRadius * 0.95) ; + y1 = cos (rads (angle)) * (clockRadius * 0.95) ; + lcd128x64line (0 - x0, 0 - y0, x1, y1, 1) ; + lcd128x64circle (0, 0, clockRadius * 0.1, 0, 1) ; + lcd128x64circle (0, 0, clockRadius * 0.05, 1, 1) ; + +// Text: + + sprintf (text, "%02d:%02d:%02d", h24, m, s) ; + lcd128x64puts (32, 24, text, 0, 1) ; + + sprintf (text, "%2d/%2d/%2d", now->tm_mday, now->tm_mon + 1, now->tm_year - 100) ; + lcd128x64puts (32, -23, text, 0, 1) ; +} + +void drawClockFace (void) +{ + int m ; + double d, px1, py1, px2, py2 ; + + lcd128x64clear (0) ; + lcd128x64circle (0,0, clockRadius, 1, TRUE) ; + lcd128x64circle (0,0, clockRadius - thickness, 0, TRUE) ; + +// The four big indicators for 12,15,30 and 45 + + lcd128x64rectangle (- 3, clockRadius - barLen, 3, clockRadius, 1, TRUE) ; // 12 + lcd128x64rectangle (clockRadius - barLen, 3, clockRadius, -3, 1, TRUE) ; // 3 + lcd128x64rectangle (- 3, -clockRadius + barLen, 3, -clockRadius, 1, TRUE) ; // 6 + lcd128x64rectangle (-clockRadius + barLen, 3, -clockRadius, -3, 1, TRUE) ; // 9 + + +// Smaller 5 and 1 minute ticks + + for (m = 0 ; m < 60 ; ++m) + { + px1 = sin (rads (m * 6)) * clockRadius ; + py1 = cos (rads (m * 6)) * clockRadius ; + if ((m % 5) == 0) + d = barLen ; + else + d = barLen / 2.0 ; + + px2 = sin (rads (m * 6)) * (clockRadius - d) ; + py2 = cos (rads (m * 6)) * (clockRadius - d) ; + lcd128x64line (px1, py1, px2, py2, 1) ; + } +} + +void setup (void) +{ + lcd128x64getScreenSize (&maxX, &maxY) ; + clockRadius = maxY / 2 - 1 ; + thickness = maxX / 48 ; + barLen = thickness * 4 ; + lcd128x64setOrigin (32, 32) ; +} + + + + +/* + *********************************************************************** + * The main program + *********************************************************************** + */ + +int main (int argc, char *argv []) +{ + time_t now ; + + wiringPiSetup () ; + + lcd128x64setup () ; + + setup () ; + for (;;) + { + drawClockFace () ; + drawClockHands () ; + lcd128x64update () ; + + now = time (NULL) ; + while (time (NULL) == now) + delay (10) ; + } + + + return 0 ; +} diff --git a/WiringPi/examples/ds1302.c b/WiringPi/examples/ds1302.c deleted file mode 100644 index f1e9e20..0000000 --- a/WiringPi/examples/ds1302.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * ds1302.c: - * Real Time clock - * - * Copyright (c) 2013 Gordon Henderson. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with wiringPi. If not, see . - *********************************************************************** - */ - -#include -#include -#include -#include -#include - -#include -#include - -// Register defines - -#define RTC_SECS 0 -#define RTC_MINS 1 -#define RTC_HOURS 2 -#define RTC_DATE 3 -#define RTC_MONTH 4 -#define RTC_DAY 5 -#define RTC_YEAR 6 -#define RTC_WP 7 -#define RTC_TC 8 -#define RTC_BM 31 - - -static unsigned int masks [] = { 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x07, 0xFF } ; - - -/* - * bcdToD: dToBCD: - * BCD decode/encode - ********************************************************************************* - */ - -static int bcdToD (unsigned int byte, unsigned int mask) -{ - unsigned int b1, b2 ; - byte &= mask ; - b1 = byte & 0x0F ; - b2 = ((byte >> 4) & 0x0F) * 10 ; - return b1 + b2 ; -} - -static unsigned int dToBcd (unsigned int byte) -{ - return ((byte / 10) << 4) + (byte % 10) ; -} - - -/* - * ramTest: - * Simple test of the 31 bytes of RAM inside the DS1302 chip - ********************************************************************************* - */ - -static int ramTestValues [] = - { 0x00, 0xFF, 0xAA, 0x55, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0xF0, 0x0F, -1 } ; - -static int ramTest (void) -{ - int addr ; - int got ; - int i = 0 ; - int errors = 0 ; - int testVal ; - - printf ("DS1302 RAM TEST\n") ; - - testVal = ramTestValues [i] ; - - while (testVal != -1) - { - for (addr = 0 ; addr < 31 ; ++addr) - ds1302ramWrite (addr, testVal) ; - - for (addr = 0 ; addr < 31 ; ++addr) - if ((got = ds1302ramRead (addr)) != testVal) - { - printf ("DS1302 RAM Failure: Address: %2d, Expected: 0x%02X, Got: 0x%02X\n", - addr, testVal, got) ; - ++errors ; - } - testVal = ramTestValues [++i] ; - } - - for (addr = 0 ; addr < 31 ; ++addr) - ds1302ramWrite (addr, addr) ; - - for (addr = 0 ; addr < 31 ; ++addr) - if ((got = ds1302ramRead (addr)) != addr) - { - printf ("DS1302 RAM Failure: Address: %2d, Expected: 0x%02X, Got: 0x%02X\n", - addr, addr, got) ; - ++errors ; - } - - if (errors == 0) - printf ("-- DS1302 RAM TEST: OK\n") ; - else - printf ("-- DS1302 RAM TEST FAILURE. %d errors.\n", errors) ; - - return 0 ; -} - -/* - * setLinuxClock: - * Set the Linux clock from the hardware - ********************************************************************************* - */ - -static int setLinuxClock (void) -{ - char dateTime [20] ; - char command [64] ; - int clock [8] ; - - - printf ("Setting the Linux Clock from the DS1302... ") ; fflush (stdout) ; - - ds1302clockRead (clock) ; - -// [MMDDhhmm[[CC]YY][.ss]] - - sprintf (dateTime, "%02d%02d%02d%02d%02d%02d.%02d", - bcdToD (clock [RTC_MONTH], masks [RTC_MONTH]), - bcdToD (clock [RTC_DATE], masks [RTC_DATE]), - bcdToD (clock [RTC_HOURS], masks [RTC_HOURS]), - bcdToD (clock [RTC_MINS], masks [RTC_MINS]), - 20, - bcdToD (clock [RTC_YEAR], masks [RTC_YEAR]), - bcdToD (clock [RTC_SECS], masks [RTC_SECS])) ; - - sprintf (command, "/bin/date %s", dateTime) ; - system (command) ; - - return 0 ; -} - - -/* - * setDSclock: - * Set the DS1302 block from Linux time - ********************************************************************************* - */ - -static int setDSclock (void) -{ - struct tm t ; - time_t now ; - int clock [8] ; - - printf ("Setting the clock in the DS1302 from Linux time... ") ; - - now = time (NULL) ; - gmtime_r (&now, &t) ; - - clock [ 0] = dToBcd (t.tm_sec) ; // seconds - clock [ 1] = dToBcd (t.tm_min) ; // mins - clock [ 2] = dToBcd (t.tm_hour) ; // hours - clock [ 3] = dToBcd (t.tm_mday) ; // date - clock [ 4] = dToBcd (t.tm_mon + 1) ; // months 0-11 --> 1-12 - clock [ 5] = dToBcd (t.tm_wday + 1) ; // weekdays (sun 0) - clock [ 6] = dToBcd (t.tm_year - 100) ; // years - clock [ 7] = 0 ; // W-Protect off - - ds1302clockWrite (clock) ; - - printf ("OK\n") ; - - return 0 ; -} - - - - -int main (int argc, char *argv []) -{ - int i ; - int clock [8] ; - - wiringPiSetup () ; - ds1302setup (0, 1, 2) ; - - if (argc == 2) - { - /**/ if (strcmp (argv [1], "-slc") == 0) - return setLinuxClock () ; - else if (strcmp (argv [1], "-sdsc") == 0) - return setDSclock () ; - else if (strcmp (argv [1], "-rtest") == 0) - return ramTest () ; - else - { - printf ("Usage: ds1302 [-slc | -sdsc | -rtest]\n") ; - return EXIT_FAILURE ; - } - } - - for (i = 0 ;; ++i) - { - printf ("%5d: ", i) ; - - ds1302clockRead (clock) ; - printf (" %2d:%02d:%02d", - bcdToD (clock [2], masks [2]), bcdToD (clock [1], masks [1]), bcdToD (clock [0], masks [0])) ; - - printf (" %2d/%02d/%04d", - bcdToD (clock [3], masks [3]), bcdToD (clock [4], masks [4]), bcdToD (clock [6], masks [6]) + 2000) ; - - printf ("\n") ; - - delay (200) ; - } - - return 0 ; -} diff --git a/WiringPi/examples/gertboard.png b/WiringPi/examples/gertboard.png deleted file mode 100644 index 03c5cdd63dbb163330d19400cb9d896211e86ae7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4834 zcmV<85*_V{P)Px#Fi=cXMfm*q0Q~p>ytw%M0JyvW_yG900Js4B006uIczk&Hpa1{>`1k+-00000 z0000003YmlivR!s32;bRa{vGf5&!@T5&_cPe*6Fc00(qQO+^RX2n!P-G8A#+egFUx zI7vi7RCwC$olTD9s1krZnpKbF1$wJ`5_jm9SN$X(qnC4zTIC&PJG-}?l=1|vx&z2+ zl`>0lmj^_E0RzTARqgDT&df?@772Vr1cbvFH}H#W&2zM!B+G2jWw!pux6B65neB8t zCpP$=*oe#VfdDXIT0#)HPVMzW4=|`V2Lj*z{P7Jy zJ@p&>a3Ch%lPUxB8-N43sH&eYw+q1S3^xM;@RkPQ08;(dRL#9CghUWkjDa|T1>urQ z17cXr7X$(wAc%S5yANWXdhgE~R32%_sxAeS5HFJ9ihLmos|3u}cB;=sxUAg=_X zU=c(ML;{J#$f4^Eh?WGPWTqenBL!j}Ckvu0Z$K`$n|`+-N-8gJdJn$8yrF~?2$v27 ztH-dNlOQmHFbm>TjM-{ef&BQE0XaDv0fV9dE+`qJTB_1-_|SXb;SIr@B&b%X><^@&Y4>wioqL?-2+X4Pn5Qy>KAa(z3E3 zCjvR8Bm(eW5>d7hgM3GT5k`HZ(piZR2qP2D*@)}4d>e@+vY(BlB=X%?E&_Qo-EW{; zUSCuM@q4ZD7kl?wK1k4OO+X+7alKXqazfpGO^+j1GW(As)b(l|I|t*4>aL8DzrhQB z)W)u>q$_X65M>qmg_;FUBEQDS{>%7UzYfT2D0I_TqavEV*9nG6I(E|=9`g5mD zrCV9_4K2g%Xb8j9FpjH3*=gsd3O$ z+g0A!`+5+CanUckZ@$!(HvkzB`(SZ3n^)aojRJWE`Y)tF48*V#2oQ+!f=3W769m!y zulkE4qUxi#2LcWRzcV0^0Wm!2&JxNimx^NROTAaK4ZiQM$gC=gZk7XJW>^Q>Ei#G?% z!8oD?VaAhwHOLuVUJc^LkvHoATM+8CfO;IQ@6&OF@rR3YP>{AddDD6hMqv}p4o%c9 z25J7T-2NIE`KZu~o` zR^x5$J*$?ke`BIh7DT8${R)Cp`u*?{fe54>gA#(OZ{Cj%(zcC&R`aw*e|!-Ag=j<@ zf>b^~x&2!?rMNE1HuE$f4GM-p)K_9O7*w<74vbw8h^af;##n8kpcJWkKRig=_#jx@ z5kyNwgE(tBZm;D)pa^n&V;3QaX`e=r)oVFukbJLon2$yZtr}q`s+RI3=}_^Gf)8ns(c8T%iReRHJ;@{hS!C?2 z)8*|Mt13yUUcK-Q(St^jpy`n)(wylfEa%(1XOd4&u4lqo~fV6gYZhxY44X%CN@&*#!IMeXkOdU3@VjSdTxAc z7$DheRT(?;vn_e%(m4{;klDoCePm^0_dyzAV?kn_8_yxr(6MSs$TYO5&N3^yJ=}N> zl^V^UQe$K_2;Vbg%4_S#q0*Wp{0tD81&LLQ=jtc&qALqo?g(;~K@CdA?j6U;qOtp3 z0WTT5gdHWqpi&Y1#w|BAhe~brK{n5zp^e2!qP{g`z8UTf7#8O+jdp z8JJ8dH!vj-o(BngEt&tFC=i!~%tPOmP?8|-;)_}kUT4CkhL%t(NY&W$&Jcz!^X1^o_Hi|1`i z6eYrItZwtjE{i=*L6>A@r&Ulw39z59C84%{d}YD|fD~0rW>xFwfUx5D=nv&Q{H^4< z!|-@0XStD`?Fqu6(ljMhHnfCVZRG(-u!`4q5dVunwOGNX#U3EK^1WG62Hf&19k|t` z{KaLORD`Ftp?PinszGEV5qjvwiU?%rz*~f=3^Ln!E(T#xsjU)XkUj$GLXg4gToR;k z2p_odJpQfBxbeJr2=CQ=0@8O82t*)O=Mo?cDjRy*tht8fP^qmG5HPFbgdqNkYhbmj zNd-n~L7=vN>p`?c`XMh7*9p{t@MN!51QBIHu?k}{HbSa3xPk>5=svH`C1Yx>z8WObVKuM5ZDof6$|iGOBU-aemV%BA8->f zw`4TW{+B1}#!|-4b_S`_7+Gr$^}ps3$dXfU@m#eTE%#K56_rEGSy&AS&1Li_I*gNQ zL@>FgF{}Pw=lY$MTD}#8rVE&}?a_2uh)z*AJesSvwFBL;&odxx2mq+xiwZbfie4CA5n218Z9pp+uBRamEoc<1)?}|sF z?qlp`jK7QyS!MPR0L$*SfQ+RMVf`keVo}0A*U+QFbYYhHSUx5Ey204xSUp<(Ix59w z$E|8%sv)kQm}F@Zc4L+kYvO*{T|azXHN@<~C-g>*ojAY&2eyYKRSG`vl;#IFE=ae{r0ivGd>G;3zFCIF@}Sp}=Ja$(Ouu76uO%UoCH^i2;wN0@ z#wS8m@ogXaL_@QL=%^AhA-XgOpNh^edzl-b0*QvyF4X8T=4ML0hO&#Jc`Q)DYuGl^ z({{r?ZakYRzH24vtCniM+cY75flVs{h3QiXQ}ge-ecX6H)fd-(iRqP-gs4G0*8J(M zJ&L$^RV}g60SFPmb4IS4suj2nFr}fW5lR1T@?s~eedFEd=%ly+&f5r9bL+j zPZ(WBlgqLXgv_Q{URS&EJfj9!Ms#seCZW!NhYFKXhCaSRD=vGr8*gr~mkH46e{ko< ztLE$elkQuT!J5`Z)sokEjLWr+F8i8^{VsLmCFJi)HFVLHgxT}nLv$5mHp|YJoomDh zWR)Awpm4i0C3pYY&iwtvRDJyGN{2jg7haAzDSNdWU#gxiN7`P?l$u?sMjZ=st6Cfi zGZs{7-j%-7vRAwDym-5_p>qu_OV!gda0$yF_Qgezbp1q4mQHpum2mCI-p)AqlQU*_((H}q60pUKk6j-{+~rLQG^pW#p<`Q5xVbHvcmdc3n)cAqI>s%h4N44-GK zr|Q?W8po7+E7nh6r(Hw*S+|WUdpii8dh5Ebfr99@{aT2o%SO*a4f zT$$yNEBi{$VgTZ=74JKaP2ct1muu|`UJF;q+LonTg~Kd*KMsiFd*gw03Z#3gtzLQ= zv@}U|!dyxZgqCk}Yhoja2tf3`;=gj3wO@+H%a2@e(t-pImA87ouUdNMY)0T;#9=5ApjG@m5bcs5cfmlu;PqOj z?sOy~nnZx^a8J|i3ggH7;UHWy9`H|_iv1o=wI1un|NnqI){Wo(@t#%d*I74yfg68l zi7avB?*pX5jbCVVAG>b+5;y)1BvR+b--BvZx$(#LwHCPX#~w#kxbcS^*&lBF!;OEq z@eeot;l@AQ_=g+6(v3glU0fe-{KJiZxbY7+{^7j~vk@f4wA5FDZuN!}uUTf>R@y8iQR;(L;$dP^Hy7326 zt@j(*5AOYbIwnZF7^FF*YKavfpDMRzOnLt2(>rg?a**m@jEBy*^SRiXO|xAj?*?+a ze58q-mw`M-+e!GLi!hFn0cm#F+7w8TAgtFp+AhsAJi`g#_4x$P&+7ezw@ejuO%`5p zX5z0JM5M~a|4u7L_lKvV@zP;eBd?Zi0mNowenzou{q^N`hKpA43uqm`AqYNBucue_ z*Mfitg7>%8ASvw~?|vJ|l4=09K`9+Udo3(xKw2M!Zal9+@Nu~rsAj~V7lE`s2<;(= z?sxy7ck?2dHTI;8y`!(Moere6(gR;0x{fypUj{^gxnnDVw1Pxx0M7Jx3Zfp*Y1P7f zZkPWmabDD`rFZkP7oj%LjB2JYPPHvS=g9CJfE9&($Mmh2AHC2+fAG9V_e+gaSeJX(4;4-7SfuorBTO}JX1Gz7hzPJs{d2i&4Z4g~AvY(s;n zeFdV$pe6B&f72kCjaDseuhwrnb4jp3iL|yC^CW`n1T^%ry<8-bSRR*41_Zw)S)A?P z7zAyk72u1}wz2_14Q_pH#x$*!h}YguB7T<<*+@%WJH%F!2Em_4AjU=r#P78l*G&T5 zQhc`8G9WF8QMH;#wIUEl+?L0Y7$oeq&R(yjY($%hKaS|kTXZwVQ^R=>v=0H+u(4v} z9dX?lLY~WXsLg}WnH+biaYOD8jw8xX8pn}EBYS#4Ji^HSKVc*y-#-4=i~s-t07*qo IM6N<$f;V*&MF0Q* diff --git a/WiringPi/examples/isr.c b/WiringPi/examples/isr.c index 2bef54a..abc6aec 100644 --- a/WiringPi/examples/isr.c +++ b/WiringPi/examples/isr.c @@ -38,16 +38,11 @@ #include -// What GPIO input are we using? -// This is a wiringPi pin number - -#define BUTTON_PIN 0 - // globalCounter: // Global variable to count interrupts // Should be declared volatile to make sure the compiler doesn't cache it. -static volatile int globalCounter = 0 ; +static volatile int globalCounter [8] ; /* @@ -55,10 +50,14 @@ static volatile int globalCounter = 0 ; ********************************************************************************* */ -void myInterrupt (void) -{ - ++globalCounter ; -} +void myInterrupt0 (void) { ++globalCounter [0] ; } +void myInterrupt1 (void) { ++globalCounter [1] ; } +void myInterrupt2 (void) { ++globalCounter [2] ; } +void myInterrupt3 (void) { ++globalCounter [3] ; } +void myInterrupt4 (void) { ++globalCounter [4] ; } +void myInterrupt5 (void) { ++globalCounter [5] ; } +void myInterrupt6 (void) { ++globalCounter [6] ; } +void myInterrupt7 (void) { ++globalCounter [7] ; } /* @@ -69,30 +68,42 @@ void myInterrupt (void) int main (void) { - int myCounter = 0 ; + int gotOne, pin ; + int myCounter [8] ; - if (wiringPiSetup () < 0) - { - fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno)) ; - return 1 ; - } + for (pin = 0 ; pin < 8 ; ++pin) + globalCounter [pin] = myCounter [pin] = 0 ; - if (wiringPiISR (BUTTON_PIN, INT_EDGE_FALLING, &myInterrupt) < 0) - { - fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno)) ; - return 1 ; - } + wiringPiSetup () ; + wiringPiISR (0, INT_EDGE_FALLING, &myInterrupt0) ; + wiringPiISR (1, INT_EDGE_FALLING, &myInterrupt1) ; + wiringPiISR (2, INT_EDGE_FALLING, &myInterrupt2) ; + wiringPiISR (3, INT_EDGE_FALLING, &myInterrupt3) ; + wiringPiISR (4, INT_EDGE_FALLING, &myInterrupt4) ; + wiringPiISR (5, INT_EDGE_FALLING, &myInterrupt5) ; + wiringPiISR (6, INT_EDGE_FALLING, &myInterrupt6) ; + wiringPiISR (7, INT_EDGE_FALLING, &myInterrupt7) ; for (;;) { + gotOne = 0 ; printf ("Waiting ... ") ; fflush (stdout) ; - while (myCounter == globalCounter) - delay (100) ; - - printf (" Done. counter: %5d\n", globalCounter) ; - myCounter = globalCounter ; + for (;;) + { + for (pin = 0 ; pin < 8 ; ++pin) + { + if (globalCounter [pin] != myCounter [pin]) + { + printf (" Int on pin %d: Counter: %5d\n", pin, globalCounter [pin]) ; + myCounter [pin] = globalCounter [pin] ; + ++gotOne ; + } + } + if (gotOne != 0) + break ; + } } return 0 ; diff --git a/WiringPi/examples/lcd-adafruit.c b/WiringPi/examples/lcd-adafruit.c new file mode 100644 index 0000000..47c9b9b --- /dev/null +++ b/WiringPi/examples/lcd-adafruit.c @@ -0,0 +1,347 @@ +/* + * lcd-adafruit.c: + * Text-based LCD driver test code + * This is designed to drive the Adafruit RGB LCD Plate + * with the additional 5 buttons for the Raspberry Pi + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + + +// Defines for the Adafruit Pi LCD interface board + +#define AF_BASE 100 +#define AF_RED (AF_BASE + 6) +#define AF_GREEN (AF_BASE + 7) +#define AF_BLUE (AF_BASE + 8) + +#define AF_E (AF_BASE + 13) +#define AF_RW (AF_BASE + 14) +#define AF_RS (AF_BASE + 15) + +#define AF_DB4 (AF_BASE + 12) +#define AF_DB5 (AF_BASE + 11) +#define AF_DB6 (AF_BASE + 10) +#define AF_DB7 (AF_BASE + 9) + +#define AF_SELECT (AF_BASE + 0) +#define AF_RIGHT (AF_BASE + 1) +#define AF_DOWN (AF_BASE + 2) +#define AF_UP (AF_BASE + 3) +#define AF_LEFT (AF_BASE + 4) + + +// User-Defined character test + +static unsigned char newChar [8] = +{ + 0b00100, + 0b00100, + 0b00000, + 0b00100, + 0b01110, + 0b11011, + 0b11011, + 0b10001, +} ; + +// Global lcd handle: + +static int lcdHandle ; + +/* + * usage: + ********************************************************************************* + */ + +int usage (const char *progName) +{ + fprintf (stderr, "Usage: %s colour\n", progName) ; + return EXIT_FAILURE ; +} + + +/* + * scrollMessage: + ********************************************************************************* + */ + +static const char *message = + " " + "Wiring Pi by Gordon Henderson. HTTP://WIRINGPI.COM/" + " " ; + +void scrollMessage (int line, int width) +{ + char buf [32] ; + static int position = 0 ; + static int timer = 0 ; + + if (millis () < timer) + return ; + + timer = millis () + 200 ; + + strncpy (buf, &message [position], width) ; + buf [width] = 0 ; + lcdPosition (lcdHandle, 0, line) ; + lcdPuts (lcdHandle, buf) ; + + if (++position == (strlen (message) - width)) + position = 0 ; +} + + +/* + * setBacklightColour: + * The colour outputs are inverted. + ********************************************************************************* + */ + +static void setBacklightColour (int colour) +{ + colour &= 7 ; + + digitalWrite (AF_RED, !(colour & 1)) ; + digitalWrite (AF_GREEN, !(colour & 2)) ; + digitalWrite (AF_BLUE, !(colour & 4)) ; +} + + +/* + * adafruitLCDSetup: + * Setup the Adafruit board by making sure the additional pins are + * set to the correct modes, etc. + ********************************************************************************* + */ + +static void adafruitLCDSetup (int colour) +{ + int i ; + +// Backlight LEDs + + pinMode (AF_RED, OUTPUT) ; + pinMode (AF_GREEN, OUTPUT) ; + pinMode (AF_BLUE, OUTPUT) ; + setBacklightColour (colour) ; + +// Input buttons + + for (i = 0 ; i <= 4 ; ++i) + { + pinMode (AF_BASE + i, INPUT) ; + pullUpDnControl (AF_BASE + i, PUD_UP) ; // Enable pull-ups, switches close to 0v + } + +// Control signals + + pinMode (AF_RW, OUTPUT) ; digitalWrite (AF_RW, LOW) ; // Not used with wiringPi - always in write mode + +// The other control pins are initialised with lcdInit () + + lcdHandle = lcdInit (2, 16, 4, AF_RS, AF_E, AF_DB4,AF_DB5,AF_DB6,AF_DB7, 0,0,0,0) ; + + if (lcdHandle < 0) + { + fprintf (stderr, "lcdInit failed\n") ; + exit (EXIT_FAILURE) ; + } +} + + +/* + * waitForEnter: + * On the Adafruit display, wait for the select button + ********************************************************************************* + */ + +static void waitForEnter (void) +{ + printf ("Press SELECT to continue: ") ; fflush (stdout) ; + + while (digitalRead (AF_SELECT) == HIGH) // Wait for push + delay (1) ; + + while (digitalRead (AF_SELECT) == LOW) // Wait for release + delay (1) ; + + printf ("OK\n") ; +} + + +/* + * speedTest: + * Test the update speed of the display + ********************************************************************************* + */ + +static void speedTest (void) +{ + unsigned int start, end, taken ; + int times ; + + lcdClear (lcdHandle) ; + start = millis () ; + for (times = 0 ; times < 10 ; ++times) + { + lcdPuts (lcdHandle, "0123456789ABCDEF") ; + lcdPuts (lcdHandle, "0123456789ABCDEF") ; + } + end = millis () ; + taken = (end - start) / 10; + + lcdClear (lcdHandle) ; + lcdPosition (lcdHandle, 0, 0) ; lcdPrintf (lcdHandle, "Speed: %dmS", taken) ; + lcdPosition (lcdHandle, 0, 1) ; lcdPrintf (lcdHandle, "For full update") ; + + waitForEnter () ; + + lcdClear (lcdHandle) ; + lcdPosition (lcdHandle, 0, 0) ; lcdPrintf (lcdHandle, "Time: %dmS", taken / 32) ; + lcdPosition (lcdHandle, 0, 1) ; lcdPrintf (lcdHandle, "Per character") ; + + waitForEnter () ; + + lcdClear (lcdHandle) ; + lcdPosition (lcdHandle, 0, 0) ; lcdPrintf (lcdHandle, "%d cps...", 32000 / taken) ; + + waitForEnter () ; +} + + +/* + * The works + ********************************************************************************* + */ + +int main (int argc, char *argv[]) +{ + int colour ; + int cols = 16 ; + int waitForRelease = FALSE ; + + struct tm *t ; + time_t tim ; + + char buf [32] ; + + if (argc != 2) + return usage (argv [0]) ; + + printf ("Raspberry Pi Adafruit LCD test\n") ; + printf ("==============================\n") ; + + colour = atoi (argv [1]) ; + + wiringPiSetupSys () ; + mcp23017Setup (AF_BASE, 0x20) ; + + adafruitLCDSetup (colour) ; + + lcdPosition (lcdHandle, 0, 0) ; lcdPuts (lcdHandle, "Gordon Henderson") ; + lcdPosition (lcdHandle, 0, 1) ; lcdPuts (lcdHandle, " wiringpi.com ") ; + + waitForEnter () ; + + lcdPosition (lcdHandle, 0, 1) ; lcdPuts (lcdHandle, "Adafruit RGB LCD") ; + + waitForEnter () ; + + lcdCharDef (lcdHandle, 2, newChar) ; + + lcdClear (lcdHandle) ; + lcdPosition (lcdHandle, 0, 0) ; + lcdPuts (lcdHandle, "User Char: ") ; + lcdPutchar (lcdHandle, 2) ; + + lcdCursor (lcdHandle, TRUE) ; + lcdCursorBlink (lcdHandle, TRUE) ; + + waitForEnter () ; + + lcdCursor (lcdHandle, FALSE) ; + lcdCursorBlink (lcdHandle, FALSE) ; + + speedTest () ; + + lcdClear (lcdHandle) ; + + for (;;) + { + scrollMessage (0, cols) ; + + tim = time (NULL) ; + t = localtime (&tim) ; + + sprintf (buf, "%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec) ; + + lcdPosition (lcdHandle, (cols - 8) / 2, 1) ; + lcdPuts (lcdHandle, buf) ; + +// Check buttons to cycle colour + +// If Up or Down are still pushed, then skip + + if (waitForRelease) + { + if ((digitalRead (AF_UP) == LOW) || (digitalRead (AF_DOWN) == LOW)) + continue ; + else + waitForRelease = FALSE ; + } + + if (digitalRead (AF_UP) == LOW) // Pushed + { + colour = colour + 1 ; + if (colour == 8) + colour = 0 ; + setBacklightColour (colour) ; + waitForRelease = TRUE ; + } + + if (digitalRead (AF_DOWN) == LOW) // Pushed + { + colour = colour - 1 ; + if (colour == -1) + colour = 7 ; + setBacklightColour (colour) ; + waitForRelease = TRUE ; + } + + } + + return 0 ; +} diff --git a/WiringPi/examples/lcd.c b/WiringPi/examples/lcd.c index 6024917..510f562 100644 --- a/WiringPi/examples/lcd.c +++ b/WiringPi/examples/lcd.c @@ -4,7 +4,19 @@ * This is designed to drive the parallel interface LCD drivers * based in the Hitachi HD44780U controller and compatables. * - * Copyright (c) 2012 Gordon Henderson. + * This test program assumes the following: + * + * 8-bit displays: + * GPIO 0-7 is connected to display data pins 0-7. + * GPIO 11 is the RS pin. + * GPIO 10 is the Strobe/E pin. + * + * For 4-bit interface: + * GPIO 4-7 is connected to display data pins 4-7. + * GPIO 11 is the RS pin. + * GPIO 10 is the Strobe/E pin. + * + * Copyright (c) 2012-2013 Gordon Henderson. *********************************************************************** * This file is part of wiringPi: * https://projects.drogon.net/raspberry-pi/wiringpi/ @@ -35,94 +47,239 @@ #include #include -int main (void) -{ - int i, j ; - int fd1, fd2 ; +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif - char message1 [256] ; - char message2 [256] ; - char buf1 [30] ; - char buf2 [30] ; +static unsigned char newChar [8] = +{ + 0b11111, + 0b10001, + 0b10001, + 0b10101, + 0b11111, + 0b10001, + 0b10001, + 0b11111, +} ; + + +// Global lcd handle: + +static int lcdHandle ; + +/* + * usage: + ********************************************************************************* + */ + +int usage (const char *progName) +{ + fprintf (stderr, "Usage: %s bits cols rows\n", progName) ; + return EXIT_FAILURE ; +} + + +/* + * scrollMessage: + ********************************************************************************* + */ + +static const char *message = + " " + "Wiring Pi by Gordon Henderson. HTTP://WIRINGPI.COM/" + " " ; + +void scrollMessage (int line, int width) +{ + char buf [32] ; + static int position = 0 ; + static int timer = 0 ; + + if (millis () < timer) + return ; + + timer = millis () + 200 ; + + strncpy (buf, &message [position], width) ; + buf [width] = 0 ; + lcdPosition (lcdHandle, 0, line) ; + lcdPuts (lcdHandle, buf) ; + + if (++position == (strlen (message) - width)) + position = 0 ; +} + + +/* + * pingPong: + * Bounce a character - only on 4-line displays + ********************************************************************************* + */ + +static void pingPong (int lcd, int cols) +{ + static int position = 0 ; + static int dir = 0 ; + + if (dir == 0) // Setup + { + dir = 1 ; + lcdPosition (lcdHandle, 0, 3) ; + lcdPutchar (lcdHandle, '*') ; + return ; + } + + lcdPosition (lcdHandle, position, 3) ; + lcdPutchar (lcdHandle, ' ') ; + position += dir ; + + if (position == cols) + { + dir = -1 ; + --position ; + } + + if (position < 0) + { + dir = 1 ; + ++position ; + } + + lcdPosition (lcdHandle, position, 3) ; + lcdPutchar (lcdHandle, '#') ; +} + + +/* + * waitForEnter: + ********************************************************************************* + */ + +static void waitForEnter (void) +{ + printf ("Press ENTER to continue: ") ; + (void)fgetc (stdin) ; +} + + +/* + * The works + ********************************************************************************* + */ + +int main (int argc, char *argv[]) +{ + int i ; + int lcd ; + int bits, rows, cols ; struct tm *t ; time_t tim ; - printf ("Raspberry Pi LCD test program\n") ; + char buf [32] ; - if (wiringPiSetup () == -1) - exit (1) ; + if (argc != 4) + return usage (argv [0]) ; - fd1 = lcdInit (4, 20, 4, 8, 9, 4,5,6,7,0,0,0,0) ; - fd2 = lcdInit (2, 16, 4, 8, 10, 4,5,6,7,0,0,0,0) ; + printf ("Raspberry Pi LCD test\n") ; + printf ("=====================\n") ; -//fd1 = lcdInit (4, 20, 8, 8, 9, 0,1,2,3,4,5,6,7) ; -//fd2 = lcdInit (2, 16, 8, 8, 10, 0,1,2,3,4,5,6,7) ; + bits = atoi (argv [1]) ; + cols = atoi (argv [2]) ; + rows = atoi (argv [3]) ; - if (fd1 == -1) + if (!((rows == 1) || (rows == 2) || (rows == 4))) { - printf ("lcdInit 1 failed\n") ; - return 1 ; + fprintf (stderr, "%s: rows must be 1, 2 or 4\n", argv [0]) ; + return EXIT_FAILURE ; } - if (fd2 == -1) + if (!((cols == 16) || (cols == 20))) { - printf ("lcdInit 2 failed\n") ; - return 1 ; + fprintf (stderr, "%s: cols must be 16 or 20\n", argv [0]) ; + return EXIT_FAILURE ; } - sleep (1) ; + wiringPiSetup () ; - lcdPosition (fd1, 0, 0) ; lcdPuts (fd1, " Gordon Henderson") ; - lcdPosition (fd1, 0, 1) ; lcdPuts (fd1, " --------------") ; -/* - lcdPosition (fd1, 0, 2) ; lcdPuts (fd1, " 00:00:00") ; - lcdPosition (fd1, 0, 3) ; lcdPuts (fd1, " DD:MM:YY") ; -*/ + if (bits == 4) + lcdHandle = lcdInit (rows, cols, 4, 11,10, 4,5,6,7,0,0,0,0) ; + else + lcdHandle = lcdInit (rows, cols, 8, 11,10, 0,1,2,3,4,5,6,7) ; - lcdPosition (fd2, 0, 0) ; lcdPuts (fd2, "Gordon Henderson") ; - lcdPosition (fd2, 0, 1) ; lcdPuts (fd2, "----------------") ; + if (lcdHandle < 0) + { + fprintf (stderr, "%s: lcdInit failed\n", argv [0]) ; + return -1 ; + } - sleep (2) ; + lcdPosition (lcdHandle, 0, 0) ; lcdPuts (lcdHandle, "Gordon Henderson") ; + lcdPosition (lcdHandle, 0, 1) ; lcdPuts (lcdHandle, " wiringpi.com ") ; - sprintf (message1, "%s", " http://projects.drogon.net/ ") ; - sprintf (message2, "%s", " This is a long message to go into the smaller display just for a demonstration of what we can do. ") ; + waitForEnter () ; + + if (rows > 1) + { + lcdPosition (lcdHandle, 0, 1) ; lcdPuts (lcdHandle, " wiringpi.com ") ; + + if (rows == 4) + { + lcdPosition (lcdHandle, 0, 2) ; + for (i = 0 ; i < ((cols - 1) / 2) ; ++i) + lcdPuts (lcdHandle, "=-") ; + lcdPuts (lcdHandle, "=3") ; + + lcdPosition (lcdHandle, 0, 3) ; + for (i = 0 ; i < ((cols - 1) / 2) ; ++i) + lcdPuts (lcdHandle, "-=") ; + lcdPuts (lcdHandle, "-4") ; + } + } + + waitForEnter () ; + + lcdCharDef (lcdHandle, 2, newChar) ; + + lcdClear (lcdHandle) ; + lcdPosition (lcdHandle, 0, 0) ; + lcdPuts (lcdHandle, "User Char: ") ; + lcdPutchar (lcdHandle, 2) ; + + lcdCursor (lcdHandle, TRUE) ; + lcdCursorBlink (lcdHandle, TRUE) ; + + waitForEnter () ; + + lcdCursor (lcdHandle, FALSE) ; + lcdCursorBlink (lcdHandle, FALSE) ; + lcdClear (lcdHandle) ; for (;;) { - i = 0 ; - j = 0 ; - for (;;) - { - strncpy (buf1, &message1 [i], 20) ; - buf1 [20] = 0 ; - lcdPosition (fd1, 0, 1) ; - lcdPuts (fd1, buf1) ; - ++i ; - if (i == strlen (message1) - 20) - i = 0 ; + scrollMessage (0, cols) ; + + if (rows == 1) + continue ; - strncpy (buf2, &message2 [j], 16) ; - buf2 [16] = 0 ; - lcdPosition (fd2, 0, 1) ; - lcdPuts (fd2, buf2) ; - ++j ; - if (j == strlen (message2) - 16) - j = 0 ; + tim = time (NULL) ; + t = localtime (&tim) ; - tim = time (NULL) ; - t = localtime (&tim) ; + sprintf (buf, "%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec) ; - sprintf (buf1, "%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec) ; - lcdPosition (fd1, 5, 2) ; - lcdPuts (fd1, buf1) ; + lcdPosition (lcdHandle, (cols - 8) / 2, 1) ; + lcdPuts (lcdHandle, buf) ; - sprintf (buf1, "%02d/%02d/%02d", t->tm_mday, t->tm_mon + 1, t->tm_year+1900) ; - lcdPosition (fd1, 4, 3) ; - lcdPuts (fd1, buf1) ; + if (rows == 2) + continue ; - delay (250) ; - } + sprintf (buf, "%02d/%02d/%04d", t->tm_mday, t->tm_mon + 1, t->tm_year+1900) ; + + lcdPosition (lcdHandle, (cols - 10) / 2, 2) ; + lcdPuts (lcdHandle, buf) ; + + pingPong (lcd, cols) ; } return 0 ; diff --git a/WiringPi/examples/okLed.c b/WiringPi/examples/okLed.c index 9b3a170..930f266 100644 --- a/WiringPi/examples/okLed.c +++ b/WiringPi/examples/okLed.c @@ -39,27 +39,26 @@ #include #include +// The OK/Act LED is connected to BCM_GPIO pin 16 + #define OK_LED 16 int main () { int fd, i ; + wiringPiSetupGpio () ; + +// Change the trigger on the OK/Act LED to "none" + if ((fd = open ("/sys/class/leds/led0/trigger", O_RDWR)) < 0) { fprintf (stderr, "Unable to change LED trigger: %s\n", strerror (errno)) ; return 1 ; } - write (fd, "none\n", 5) ; close (fd) ; - if (wiringPiSetupGpio () < 0) - { - fprintf (stderr, "Unable to setup GPIO: %s\n", strerror (errno)) ; - return 1 ; - } - softPwmCreate (OK_LED, 0, 100) ; for (;;) diff --git a/WiringPi/examples/pwm.c b/WiringPi/examples/pwm.c index c1fc331..816c832 100644 --- a/WiringPi/examples/pwm.c +++ b/WiringPi/examples/pwm.c @@ -1,7 +1,6 @@ /* * pwm.c: - * Test of the software PWM driver. Needs 12 LEDs connected - * to the Pi. + * This tests the hardware PWM channel. * * Copyright (c) 2012-2013 Gordon Henderson. *********************************************************************** @@ -23,71 +22,37 @@ *********************************************************************** */ -#include -#include -#include - #include -#include -#define RANGE 100 -#define NUM_LEDS 12 +#include +#include +#include -int ledMap [NUM_LEDS] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13 } ; - -int values [NUM_LEDS] = { 0, 17, 32, 50, 67, 85, 100, 85, 67, 50, 32, 17 } ; - -int main () +int main (void) { - int i, j ; - char buf [80] ; + int bright ; + + printf ("Raspberry Pi wiringPi PWM test program\n") ; if (wiringPiSetup () == -1) - { - fprintf (stdout, "oops: %s\n", strerror (errno)) ; - return 1 ; - } + exit (1) ; - for (i = 0 ; i < NUM_LEDS ; ++i) - { - softPwmCreate (ledMap [i], 0, RANGE) ; - printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ; - } - - fgets (buf, 80, stdin) ; - -// Bring all up one by one: - - for (i = 0 ; i < NUM_LEDS ; ++i) - for (j = 0 ; j <= 100 ; ++j) - { - softPwmWrite (ledMap [i], j) ; - delay (10) ; - } - - fgets (buf, 80, stdin) ; - -// Down fast - - for (i = 100 ; i > 0 ; --i) - { - for (j = 0 ; j < NUM_LEDS ; ++j) - softPwmWrite (ledMap [j], i) ; - delay (10) ; - } - - fgets (buf, 80, stdin) ; + pinMode (1, PWM_OUTPUT) ; for (;;) { - for (i = 0 ; i < NUM_LEDS ; ++i) - softPwmWrite (ledMap [i], values [i]) ; + for (bright = 0 ; bright < 1024 ; ++bright) + { + pwmWrite (1, bright) ; + delay (1) ; + } - delay (50) ; - - i = values [0] ; - for (j = 0 ; j < NUM_LEDS - 1 ; ++j) - values [j] = values [j + 1] ; - values [NUM_LEDS - 1] = i ; + for (bright = 1023 ; bright >= 0 ; --bright) + { + pwmWrite (1, bright) ; + delay (1) ; + } } + + return 0 ; } diff --git a/WiringPi/examples/q2w/Makefile b/WiringPi/examples/q2w/Makefile new file mode 100644 index 0000000..150c825 --- /dev/null +++ b/WiringPi/examples/q2w/Makefile @@ -0,0 +1,81 @@ +# +# Makefile: +# wiringPi - Wiring Compatable library for the Raspberry Pi +# https://projects.drogon.net/wiring-pi +# +# Copyright (c) 2012-2013 Gordon Henderson +################################################################################# +# This file is part of wiringPi: +# Wiring Compatable library for the Raspberry Pi +# +# wiringPi is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# wiringPi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with wiringPi. If not, see . +################################################################################# + + +#DEBUG = -g -O0 +DEBUG = -O3 +CC = gcc +INCLUDE = -I/usr/local/include +CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe + +LDFLAGS = -L/usr/local/lib +LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm + +############################################################################### + +SRC = blink.c button.c blink-io.c volts.c bright.c + +OBJ = $(SRC:.c=.o) + +BINS = $(SRC:.c=) + +all: $(BINS) + +blink: blink.o + @echo [link] + @$(CC) -o $@ blink.o $(LDFLAGS) $(LDLIBS) + +blink-io: blink-io.o + @echo [link] + @$(CC) -o $@ blink-io.o $(LDFLAGS) $(LDLIBS) + +button: button.o + @echo [link] + @$(CC) -o $@ button.o $(LDFLAGS) $(LDLIBS) + +volts: volts.o + @echo [link] + @$(CC) -o $@ volts.o $(LDFLAGS) $(LDLIBS) + +bright: bright.o + @echo [link] + @$(CC) -o $@ bright.o $(LDFLAGS) $(LDLIBS) + + +.c.o: + @echo [CC] $< + @$(CC) -c $(CFLAGS) $< -o $@ + +clean: + @echo "[Clean]" + @rm -f $(OBJ) *~ core tags $(BINS) + +tags: $(SRC) + @echo [ctags] + @ctags $(SRC) + +depend: + makedepend -Y $(SRC) + +# DO NOT DELETE diff --git a/WiringPi/examples/q2w/binary.c b/WiringPi/examples/q2w/binary.c new file mode 100644 index 0000000..3c987c6 --- /dev/null +++ b/WiringPi/examples/q2w/binary.c @@ -0,0 +1,79 @@ +/* + * binary.c: + * Using the Quick 2 wire 16-bit GPIO expansion board to output + * a binary counter. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#define Q2W_BASE 100 + +int main (void) +{ + int i, bit ; + +// Enable the on-goard GPIO + + wiringPiSetup () ; + +// Add in the mcp23017 on the q2w board + + mcp23017Setup (Q2W_BASE, 0x20) ; + + printf ("Raspberry Pi - quite2Wire MCP23017 Test\n") ; + +// On-board button Input: + + pinMode (0, INPUT) ; + +// First 10 pins on q2w board as outputs: + + for (i = 0 ; i < 10 ; ++i) + pinMode (Q2W_BASE + i, OUTPUT) ; + +// Last pin as an input with the internal pull-up enabled + + pinMode (Q2W_BASE + 15, INPUT) ; + pullUpDnControl (Q2W_BASE + 15, PUD_UP) ; + +// Loop, outputting a binary number, +// Go faster with the button, or stop if the +// on-board button is pushed + + for (;;) + { + for (i = 0 ; i < 1024 ; ++i) + { + for (bit = 0 ; bit < 10 ; ++bit) + digitalWrite (Q2W_BASE + bit, i & (1 << bit)) ; + + while (digitalRead (0) == HIGH) // While pushed + delay (1) ; + + if (digitalRead (Q2W_BASE + 15) == HIGH) // Not Pushed + delay (100) ; + } + } + return 0 ; +} diff --git a/WiringPi/examples/q2w/blink-io.c b/WiringPi/examples/q2w/blink-io.c new file mode 100644 index 0000000..4dd4276 --- /dev/null +++ b/WiringPi/examples/q2w/blink-io.c @@ -0,0 +1,61 @@ +/* + * blink-io.c: + * Simple "blink" test for the Quick2Wire 16-pin IO board. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#define LED 1 +#define Q2W_BASE 100 + +int main (void) +{ + +// Enable the on-goard GPIO + + wiringPiSetup () ; + +// Add in the mcp23017 on the q2w board + + mcp23017Setup (Q2W_BASE, 0x20) ; + + printf ("Raspberry Pi - Quick2Wire MCP23017 Blink Test\n") ; + +// Blink the on-board LED as well as one on the mcp23017 + + pinMode (LED, OUTPUT) ; + pinMode (Q2W_BASE + 0, OUTPUT) ; + + for (;;) + { + digitalWrite (LED, HIGH) ; + digitalWrite (Q2W_BASE + 0, HIGH) ; + delay (500) ; + digitalWrite (LED, LOW) ; + digitalWrite (Q2W_BASE + 0, LOW) ; + delay (500) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/test2.c b/WiringPi/examples/q2w/blink.c similarity index 70% rename from WiringPi/examples/test2.c rename to WiringPi/examples/q2w/blink.c index 580591e..62b694a 100644 --- a/WiringPi/examples/test2.c +++ b/WiringPi/examples/q2w/blink.c @@ -1,6 +1,6 @@ /* - * test2.c: - * This tests the hardware PWM channel. + * blink.c: + * Simple "blink" test for the Quick2Wire interface board. * * Copyright (c) 2012-2013 Gordon Henderson. *********************************************************************** @@ -22,36 +22,28 @@ *********************************************************************** */ +#include #include -#include -#include -#include +#define LED 1 int main (void) { - int bright ; - printf ("Raspberry Pi wiringPi PWM test program\n") ; +// Enable the on-goard GPIO - if (wiringPiSetup () == -1) - exit (1) ; + wiringPiSetup () ; - pinMode (1, PWM_OUTPUT) ; + printf ("Raspberry Pi - Quick2Wire Mainboard LED Blink Test\n") ; + + pinMode (LED, OUTPUT) ; for (;;) { - for (bright = 0 ; bright < 1024 ; ++bright) - { - pwmWrite (1, bright) ; - delay (1) ; - } - - for (bright = 1023 ; bright >= 0 ; --bright) - { - pwmWrite (1, bright) ; - delay (1) ; - } + digitalWrite (LED, HIGH) ; + delay (500) ; + digitalWrite (LED, LOW) ; + delay (500) ; } return 0 ; diff --git a/WiringPi/examples/q2w/blink.sh b/WiringPi/examples/q2w/blink.sh new file mode 100755 index 0000000..2dee6c7 --- /dev/null +++ b/WiringPi/examples/q2w/blink.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# blink.sh: +# Standard "blink" program in wiringPi. Blinks an LED connected +# to the LED on the Quick2Wire board +# +# Copyright (c) 2012-2013 Gordon Henderson. +####################################################################### +# This file is part of wiringPi: +# https://projects.drogon.net/raspberry-pi/wiringpi/ +# +# wiringPi is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# wiringPi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with wiringPi. If not, see . +####################################################################### + +# LED Pin - wiringPi pin 1 is BCM_GPIO 18. + +LED=1 + +gpio mode $LED out + +while true; do + gpio write $LED 1 + sleep 0.5 + gpio write $LED 0 + sleep 0.5 +done diff --git a/WiringPi/examples/q2w/bright.c b/WiringPi/examples/q2w/bright.c new file mode 100644 index 0000000..2318834 --- /dev/null +++ b/WiringPi/examples/q2w/bright.c @@ -0,0 +1,59 @@ +/* + * bright.c: + * Vary the Q2W LED brightness with the analog card + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#define LED 1 +#define Q2W_ABASE 120 + +int main (void) +{ + int value ; + +// Enable the on-goard GPIO + + wiringPiSetup () ; + +// Add in the pcf8591 on the q2w board + + pcf8591Setup (Q2W_ABASE, 0x48) ; + + printf ("Raspberry Pi - Quick2Wire Analog Test\n") ; + +// Setup the LED + + pinMode (LED, PWM_OUTPUT) ; + pwmWrite (LED, 0) ; + + for (;;) + { + value = analogRead (Q2W_ABASE + 0) ; + pwmWrite (LED, value * 4) ; + delay (10) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/q2w/button.c b/WiringPi/examples/q2w/button.c new file mode 100644 index 0000000..1781f02 --- /dev/null +++ b/WiringPi/examples/q2w/button.c @@ -0,0 +1,63 @@ +/* + * button.c: + * Simple button test for the Quick2Wire interface board. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include + +#define BUTTON 0 +#define LED1 1 +#define LED2 7 + +int main (void) +{ + +// Enable the on-goard GPIO + + wiringPiSetup () ; + + printf ("Raspberry Pi - Quick2Wire Mainboard Button & LED Test\n") ; + + pinMode (BUTTON, INPUT) ; + pinMode (LED1, OUTPUT) ; + pinMode (LED2, OUTPUT) ; + + digitalWrite (LED1, HIGH) ; // On-board LED on + digitalWrite (LED2, LOW) ; // 2nd LED off + + for (;;) + { + if (digitalRead (BUTTON) == HIGH) // Swap LED states + { + digitalWrite (LED1, LOW) ; + digitalWrite (LED2, HIGH) ; + while (digitalRead (BUTTON) == HIGH) + delay (1) ; + digitalWrite (LED1, HIGH) ; + digitalWrite (LED2, LOW) ; + } + delay (1) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/q2w/volts.c b/WiringPi/examples/q2w/volts.c new file mode 100644 index 0000000..e091093 --- /dev/null +++ b/WiringPi/examples/q2w/volts.c @@ -0,0 +1,62 @@ +/* + * volts.c: + * Read in all 4 analogs on the Q2W analog board. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#define LED 1 +#define Q2W_ABASE 120 + +int main (void) +{ + int value, pin ; + +// Enable the on-goard GPIO + + wiringPiSetup () ; + + pinMode (LED, OUTPUT) ; // On-board LED + +// Add in the pcf8591 on the q2w board + + pcf8591Setup (Q2W_ABASE, 0x48) ; + + printf ("Raspberry Pi - Quick2Wire Voltmeter\n") ; + + for (;;) + { + for (pin = 0 ; pin < 4 ; ++pin) + { + value = analogRead (Q2W_ABASE + pin) ; + printf (" %5.2f", (double)value * 3.3 / 255.0) ; + } + printf ("\r") ; fflush (stdout) ; + + delay (100) ; + digitalWrite (LED, !digitalRead (LED)) ; // Flicker the LED + } + + return 0 ; +} diff --git a/WiringPi/examples/rht03.c b/WiringPi/examples/rht03.c new file mode 100644 index 0000000..e0cc116 --- /dev/null +++ b/WiringPi/examples/rht03.c @@ -0,0 +1,64 @@ +/* + * rht03.c: + * Driver for the MaxDetect series sensors + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include + +#include +#include + +#define RHT03_PIN 0 + +/* + *********************************************************************** + * The main program + *********************************************************************** + */ + +int main (void) +{ + int temp, rh ; + int newTemp, newRh ; + + temp = rh = newTemp = newRh = 0 ; + + wiringPiSetup () ; + piHiPri (55) ; + + for (;;) + { + delay (100) ; + + if (!readRHT03 (RHT03_PIN, &newTemp, &newRh)) + continue ; + + if ((temp != newTemp) || (rh != newRh)) + { + temp = newTemp ; + rh = newRh ; + printf ("Temp: %5.1f, RH: %5.1f%%\n", temp / 10.0, rh / 10.0) ; + } + } + + return 0 ; +} diff --git a/WiringPi/examples/softPwm.c b/WiringPi/examples/softPwm.c new file mode 100644 index 0000000..11f7ad0 --- /dev/null +++ b/WiringPi/examples/softPwm.c @@ -0,0 +1,89 @@ +/* + * softPwm.c: + * Test of the software PWM driver. Needs 8 LEDs connected + * to the Pi - e.g. Ladder board. + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + +#define RANGE 100 +#define NUM_LEDS 8 + +int ledMap [NUM_LEDS] = { 0, 1, 2, 3, 4, 5, 6, 7 } ; + +int values [NUM_LEDS] = { 0, 25, 50, 75, 100, 75, 50, 25 } ; + +int main () +{ + int i, j ; + char buf [80] ; + + wiringPiSetup () ; + + for (i = 0 ; i < NUM_LEDS ; ++i) + { + softPwmCreate (ledMap [i], 0, RANGE) ; + printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ; + } + + fgets (buf, 80, stdin) ; + +// Bring all up one by one: + + for (i = 0 ; i < NUM_LEDS ; ++i) + for (j = 0 ; j <= 100 ; ++j) + { + softPwmWrite (ledMap [i], j) ; + delay (10) ; + } + + fgets (buf, 80, stdin) ; + +// All Down + + for (i = 100 ; i > 0 ; --i) + { + for (j = 0 ; j < NUM_LEDS ; ++j) + softPwmWrite (ledMap [j], i) ; + delay (10) ; + } + + fgets (buf, 80, stdin) ; + + for (;;) + { + for (i = 0 ; i < NUM_LEDS ; ++i) + softPwmWrite (ledMap [i], values [i]) ; + + delay (50) ; + + i = values [0] ; + for (j = 0 ; j < NUM_LEDS - 1 ; ++j) + values [j] = values [j + 1] ; + values [NUM_LEDS - 1] = i ; + } +} diff --git a/WiringPi/examples/tone.c b/WiringPi/examples/softTone.c similarity index 92% rename from WiringPi/examples/tone.c rename to WiringPi/examples/softTone.c index 0e8a47d..2f46783 100644 --- a/WiringPi/examples/tone.c +++ b/WiringPi/examples/softTone.c @@ -1,5 +1,5 @@ /* - * tone.c: + * softTone.c: * Test of the softTone module in wiringPi * Plays a scale out on pin 3 - connect pizeo disc to pin 3 & 0v * @@ -38,11 +38,7 @@ int main () { int i ; - if (wiringPiSetup () == -1) - { - fprintf (stdout, "oops: %s\n", strerror (errno)) ; - return 1 ; - } + wiringPiSetup () ; softToneCreate (PIN) ; @@ -55,5 +51,4 @@ int main () delay (500) ; } } - } diff --git a/WiringPi/examples/speed.c b/WiringPi/examples/speed.c index 863317e..0a42b36 100644 --- a/WiringPi/examples/speed.c +++ b/WiringPi/examples/speed.c @@ -31,93 +31,65 @@ #define FAST_COUNT 10000000 #define SLOW_COUNT 1000000 +#define PASSES 5 + +void speedTest (int pin, int maxCount) +{ + int count, sum, perSec, i ; + unsigned int start, end ; + + sum = 0 ; + + for (i = 0 ; i < PASSES ; ++i) + { + start = millis () ; + for (count = 0 ; count < maxCount ; ++count) + digitalWrite (pin, 1) ; + end = millis () ; + printf (" %6d", end - start) ; + fflush (stdout) ; + sum += (end - start) ; + } + + digitalWrite (pin, 0) ; + printf (". Av: %6dmS", sum / PASSES) ; + perSec = (int)(double)maxCount / (double)((double)sum / (double)PASSES) * 1000.0 ; + printf (": %7d/sec\n", perSec) ; +} int main (void) { - int i ; - uint32_t start, end, count, sum, perSec ; - - printf ("Raspberry Pi wiringPi speed test program\n") ; + printf ("Raspberry Pi wiringPi GPIO speed test program\n") ; + printf ("=============================================\n") ; // Start the standard way - if (wiringPiSetup () == -1) - exit (1) ; - - printf ("Native wiringPi method: (%8d iterations)\n", FAST_COUNT) ; - + printf ("\nNative wiringPi method: (%8d iterations)\n", FAST_COUNT) ; + wiringPiSetup () ; pinMode (0, OUTPUT) ; + speedTest (0, FAST_COUNT) ; - sum = 0 ; - for (i = 0 ; i < 3 ; ++i) - { - printf (" Pass: %d: ", i) ; - fflush (stdout) ; - - start = millis () ; - for (count = 0 ; count < FAST_COUNT ; ++count) - digitalWrite (0, 1) ; - end = millis () ; - printf (" %8dmS\n", end - start) ; - sum += (end - start) ; - } - digitalWrite (0, 0) ; - printf (" Average: %8dmS", sum / 3) ; - perSec = (int)(double)FAST_COUNT / (double)((double)sum / 3.0) * 1000.0 ; - printf (": %6d/sec\n", perSec) ; - - - printf ("Native GPIO method: (%8d iterations)\n", FAST_COUNT) ; - - if (wiringPiSetupGpio () == -1) - exit (1) ; +// GPIO + printf ("\nNative GPIO method: (%8d iterations)\n", FAST_COUNT) ; + wiringPiSetupGpio () ; pinMode (17, OUTPUT) ; + speedTest (17, FAST_COUNT) ; - sum = 0 ; - for (i = 0 ; i < 3 ; ++i) - { - printf (" Pass: %d: ", i) ; - fflush (stdout) ; - - start = millis () ; - for (count = 0 ; count < 10000000 ; ++count) - digitalWrite (17, 1) ; - end = millis () ; - printf (" %8dmS\n", end - start) ; - sum += (end - start) ; - } - digitalWrite (17, 0) ; - printf (" Average: %8dmS", sum / 3) ; - perSec = (int)(double)FAST_COUNT / (double)((double)sum / 3.0) * 1000.0 ; - printf (": %6d/sec\n", perSec) ; +// Phys + printf ("\nPhysical pin GPIO method: (%8d iterations)\n", FAST_COUNT) ; + wiringPiSetupPhys () ; + pinMode (11, OUTPUT) ; + speedTest (11, FAST_COUNT) ; // Switch to SYS mode: - if (wiringPiSetupSys () == -1) - exit (1) ; - - printf ("/sys/class/gpio method: (%8d iterations)\n", SLOW_COUNT) ; - - sum = 0 ; - for (i = 0 ; i < 3 ; ++i) - { - printf (" Pass: %d: ", i) ; - fflush (stdout) ; - - start = millis () ; - for (count = 0 ; count < SLOW_COUNT ; ++count) - digitalWrite (17, 1) ; - end = millis () ; - printf (" %8dmS\n", end - start) ; - sum += (end - start) ; - } - digitalWrite (17, 0) ; - printf (" Average: %8dmS", sum / 3) ; - perSec = (int)(double)SLOW_COUNT / (double)((double)sum / 3.0) * 1000.0 ; - printf (": %6d/sec\n", perSec) ; + system ("/usr/local/bin/gpio export 17 out") ; + printf ("\n/sys/class/gpio method: (%8d iterations)\n", SLOW_COUNT) ; + wiringPiSetupSys () ; + speedTest (17, SLOW_COUNT) ; return 0 ; } diff --git a/WiringPi/gpio/Makefile b/WiringPi/gpio/Makefile index a043962..52b0150 100644 --- a/WiringPi/gpio/Makefile +++ b/WiringPi/gpio/Makefile @@ -30,20 +30,20 @@ INCLUDE = -I/usr/local/include CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe LDFLAGS = -L/usr/local/lib -LIBS = -lwiringPi -lpthread -lm +LIBS = -lwiringPi -lwiringPiDev -lpthread -lm # May not need to alter anything below this line ############################################################################### -SRC = gpio.c +SRC = gpio.c extensions.c OBJ = $(SRC:.c=.o) all: gpio -gpio: gpio.o +gpio: $(OBJ) @echo [Link] - @$(CC) -o $@ gpio.o $(LDFLAGS) $(LIBS) + @$(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBS) .c.o: @echo [Compile] $< @@ -51,7 +51,8 @@ gpio: gpio.o .PHONEY: clean clean: - rm -f $(OBJ) gpio *~ core tags *.bak + @echo "[Clean]" + @rm -f $(OBJ) gpio *~ core tags *.bak .PHONEY: tags tags: $(SRC) @@ -78,3 +79,6 @@ depend: makedepend -Y $(SRC) # DO NOT DELETE + +gpio.o: extensions.h +extensions.o: extensions.h diff --git a/WiringPi/gpio/extensions.c b/WiringPi/gpio/extensions.c new file mode 100644 index 0000000..dae1eac --- /dev/null +++ b/WiringPi/gpio/extensions.c @@ -0,0 +1,414 @@ +/* + * extensions.c: + * Part of the GPIO program to test, peek, poke and otherwise + * noodle with the GPIO hardware on the Raspberry Pi. + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "extensions.h" + +extern int wiringPiDebug ; + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + +// Local structure to hold details + +struct extensionFunctionStruct +{ + const char *name ; + int (*function)(char *progName, int pinBase, char *params) ; +} ; + + +/* + * extractInt: + * Check & return an integer at the given location (prefixed by a :) + ********************************************************************************* + */ + +static char *extractInt (char *progName, char *p, int *num) +{ + if (*p != ':') + { + fprintf (stderr, "%s: colon expected\n", progName) ; + return NULL ; + } + + ++p ; + + if (!isdigit (*p)) + { + fprintf (stderr, "%s: digit expected\n", progName) ; + return NULL ; + } + + *num = strtol (p, NULL, 0) ; + while (isdigit (*p)) + ++p ; + + return p ; +} + + + +/* + * doExtensionMcp23008: + * MCP23008 - 8-bit I2C GPIO expansion chip + * mcp23002:base:i2cAddr + ********************************************************************************* + */ + +static int doExtensionMcp23008 (char *progName, int pinBase, char *params) +{ + int i2c ; + + if ((params = extractInt (progName, params, &i2c)) == NULL) + return FALSE ; + + if ((i2c < 0x03) || (i2c > 0x77)) + { + fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; + return FALSE ; + } + + mcp23008Setup (pinBase, i2c) ; + + return TRUE ; +} + + +/* + * doExtensionMcp23016: + * MCP230016- 16-bit I2C GPIO expansion chip + * mcp23016:base:i2cAddr + ********************************************************************************* + */ + +static int doExtensionMcp23016 (char *progName, int pinBase, char *params) +{ + int i2c ; + + if ((params = extractInt (progName, params, &i2c)) == NULL) + return FALSE ; + + if ((i2c < 0x03) || (i2c > 0x77)) + { + fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; + return FALSE ; + } + + mcp23016Setup (pinBase, i2c) ; + + return TRUE ; +} + + +/* + * doExtensionMcp23017: + * MCP230017- 16-bit I2C GPIO expansion chip + * mcp23017:base:i2cAddr + ********************************************************************************* + */ + +static int doExtensionMcp23017 (char *progName, int pinBase, char *params) +{ + int i2c ; + + if ((params = extractInt (progName, params, &i2c)) == NULL) + return FALSE ; + + if ((i2c < 0x03) || (i2c > 0x77)) + { + fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; + return FALSE ; + } + + mcp23017Setup (pinBase, i2c) ; + + return TRUE ; +} + + +/* + * doExtensionMcp23s08: + * MCP23s08 - 8-bit SPI GPIO expansion chip + * mcp23s08:base:spi:port + ********************************************************************************* + */ + +static int doExtensionMcp23s08 (char *progName, int pinBase, char *params) +{ + int spi, port ; + + if ((params = extractInt (progName, params, &spi)) == NULL) + return FALSE ; + + if ((spi < 0) || (spi > 1)) + { + fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ; + return FALSE ; + } + + if ((params = extractInt (progName, params, &port)) == NULL) + return FALSE ; + + if ((port < 0) || (port > 7)) + { + fprintf (stderr, "%s: port address (%d) out of range\n", progName, port) ; + return FALSE ; + } + + mcp23s08Setup (pinBase, spi, port) ; + + return TRUE ; +} + + +/* + * doExtensionMcp23s17: + * MCP23s17 - 16-bit SPI GPIO expansion chip + * mcp23s17:base:spi:port + ********************************************************************************* + */ + +static int doExtensionMcp23s17 (char *progName, int pinBase, char *params) +{ + int spi, port ; + + if ((params = extractInt (progName, params, &spi)) == NULL) + return FALSE ; + + if ((spi < 0) || (spi > 1)) + { + fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ; + return FALSE ; + } + + if ((params = extractInt (progName, params, &port)) == NULL) + return FALSE ; + + if ((port < 0) || (port > 7)) + { + fprintf (stderr, "%s: port address (%d) out of range\n", progName, port) ; + return FALSE ; + } + + mcp23s17Setup (pinBase, spi, port) ; + + return TRUE ; +} + + +/* + * doExtensionSr595: + * Shift Register 74x595 + * sr595:base:pins:data:clock:latch + ********************************************************************************* + */ + +static int doExtensionSr595 (char *progName, int pinBase, char *params) +{ + int pins, data, clock, latch ; + +// Extract pins + + if ((params = extractInt (progName, params, &pins)) == NULL) + return FALSE ; + + if ((pins < 8) || (pins > 32)) + { + fprintf (stderr, "%s: pin count (%d) out of range - 8-32 expected.\n", progName, pins) ; + return FALSE ; + } + + if ((params = extractInt (progName, params, &data)) == NULL) + return FALSE ; + + if ((params = extractInt (progName, params, &clock)) == NULL) + return FALSE ; + + if ((params = extractInt (progName, params, &latch)) == NULL) + return FALSE ; + + sr595Setup (pinBase, pins, data, clock, latch) ; + + return TRUE ; +} + + +/* + * doExtensionPcf8574: + * Digital IO (Crude!) + * pcf8574:base:i2cAddr + ********************************************************************************* + */ + +static int doExtensionPcf8574 (char *progName, int pinBase, char *params) +{ + int i2c ; + + if ((params = extractInt (progName, params, &i2c)) == NULL) + return FALSE ; + + if ((i2c < 0x03) || (i2c > 0x77)) + { + fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; + return FALSE ; + } + + pcf8574Setup (pinBase, i2c) ; + + return TRUE ; +} + + +/* + * doExtensionPcf8591: + * Analog IO + * pcf8591:base:i2cAddr + ********************************************************************************* + */ + +static int doExtensionPcf8591 (char *progName, int pinBase, char *params) +{ + int i2c ; + + if ((params = extractInt (progName, params, &i2c)) == NULL) + return FALSE ; + + if ((i2c < 0x03) || (i2c > 0x77)) + { + fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; + return FALSE ; + } + + pcf8591Setup (pinBase, i2c) ; + + return TRUE ; +} + + +/* + * Function list + ********************************************************************************* + */ + +struct extensionFunctionStruct extensionFunctions [] = +{ + { "mcp23008", &doExtensionMcp23008 }, + { "mcp23016", &doExtensionMcp23016 }, + { "mcp23017", &doExtensionMcp23017 }, + { "mcp23s08", &doExtensionMcp23s08 }, + { "mcp23s17", &doExtensionMcp23s17 }, + { "sr595", &doExtensionSr595 }, + { "pcf8574", &doExtensionPcf8574 }, + { "pcf8591", &doExtensionPcf8591 }, + { NULL, NULL }, +} ; + + +/* + * doExtension: + * Load in a wiringPi extension + ********************************************************************************* + */ + +int doExtension (char *progName, char *extensionData) +{ + char *p ; + char *extension = extensionData ; + struct extensionFunctionStruct *extensionFn ; + int pinBase = 0 ; + +// Get the extension extension name by finding the first colon + + p = extension ; + while (*p != ':') + { + if (!*p) // ran out of characters + { + fprintf (stderr, "%s: extension name not terminated by a colon\n", progName) ; + return FALSE ; + } + ++p ; + } + + *p++ = 0 ; + + if (!isdigit (*p)) + { + fprintf (stderr, "%s: pinBase number expected after extension name\n", progName) ; + return FALSE ; + } + + while (isdigit (*p)) + { + if (pinBase > 1000000000) + { + fprintf (stderr, "%s: pinBase too large\n", progName) ; + return FALSE ; + } + + pinBase = pinBase * 10 + (*p - '0') ; + ++p ; + } + + if (pinBase < 64) + { + fprintf (stderr, "%s: pinBase (%d) too small. Minimum is 64.\n", progName, pinBase) ; + return FALSE ; + } + +// Search for extensions: + + for (extensionFn = extensionFunctions ; extensionFn->name != NULL ; ++extensionFn) + { + if (strcmp (extensionFn->name, extension) == 0) + return extensionFn->function (progName, pinBase, p) ; + } + + fprintf (stderr, "%s: extension %s not found\n", progName, extension) ; + return FALSE ; +} diff --git a/WiringPi/gpio/extensions.h b/WiringPi/gpio/extensions.h new file mode 100644 index 0000000..5d27123 --- /dev/null +++ b/WiringPi/gpio/extensions.h @@ -0,0 +1,26 @@ +/* + * extensions.h: + * Part of the GPIO program to test, peek, poke and otherwise + * noodle with the GPIO hardware on the Raspberry Pi. + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + + +extern int doExtension (char *progName, char *extensionData) ; diff --git a/WiringPi/gpio/gpio.1 b/WiringPi/gpio/gpio.1 index 3703dfa..ae4df4e 100644 --- a/WiringPi/gpio/gpio.1 +++ b/WiringPi/gpio/gpio.1 @@ -1,7 +1,7 @@ -.TH "GPIO" "21st October 2012" "Command-Line access to Raspberry Pi and PiFace GPIO" +.TH "GPIO" "March 2013" "Command-Line access to Raspberry Pi's GPIO" .SH NAME -gpio \- Command-line access to Raspberry Pi and PiFace GPIO +gpio \- Command-line access to Raspberry Pi's GPIO .SH SYNOPSIS .B gpio @@ -9,7 +9,11 @@ gpio \- Command-line access to Raspberry Pi and PiFace GPIO .PP .B gpio .B [ \-g | \-1 ] -.B read/write/aread/awrite/wb/pwm/clock/mode ... +.B mode/read/write/aread/awrite/wb/pwm/clock ... +.PP +.B gpio +.B [ \-x extension:params ] +.B mode/read/write/aread/awrite/pwm ... .PP .B gpio .B [ \-p ] @@ -27,6 +31,10 @@ gpio \- Command-line access to Raspberry Pi and PiFace GPIO .B ... .PP .B gpio +.B wfi +.B ... +.PP +.B gpio .B drive group value .PP @@ -83,6 +91,13 @@ Use the physical pin numbers rather than wiringPi pin numbers. use pins on the Revision 2 P5 connector this way, and as with \-g the BCM_GPIO pin numbers are always used with the export and edge commands. +.TP +.B \-x extension +This causes the named extension to be initialised. Extensions +comprise of a name (e.g. mcp23017) followed by a colon, then the +pin-base, then more optional parameters depending on the extension type. +See the web page on http://wiringpi.com/the-gpio-utility/ + .TP .B \-p Use the PiFace interface board and its corresponding pin numbers. The PiFace @@ -171,6 +186,12 @@ requiring root/sudo. .B unexport Un-Export a GPIO pin in the /sys/class/gpio directory. +.TP +.B wfi +This set the given pin to the supplied interrupt mode: rising, falling +or both then waits for the interrupt to happen. It's a non-busy wait, +so does not consume and CPU while it's waiting. + .TP .B drive group value @@ -221,26 +242,26 @@ The board jumpers need to be in-place to do this operation. .PP .TS -r r r l. -WiringPi GPIO-r1 GPIO-r2 Function +c c c c l. +WiringPi GPIO-r1 GPIO-r2 P1-Phys Function _ -0 17 17 -1 18 18 (PWM) -2 21 27 -3 22 22 -4 23 23 -5 24 24 -6 25 25 -7 4 4 -8 0 2 I2C: SDA0 -9 1 3 I2C: SCL0 -10 8 8 SPI: CE0 -11 7 7 SPI: CE1 -12 10 10 SPI: MOSI -13 9 9 SPI: MISO -14 11 11 SPI: SCLK -15 14 14 TxD -16 15 16 RxD + 0 17 17 11 + 1 18 18 12 (PWM) + 2 21 27 13 + 3 22 22 15 + 4 23 23 16 + 5 24 24 18 + 6 25 25 22 + 7 4 4 7 + 8 0 2 3 I2C: SDA0 + 9 1 3 5 I2C: SCL0 +10 8 8 24 SPI: CE0 +11 7 7 26 SPI: CE1 +12 10 10 19 SPI: MOSI +13 9 9 21 SPI: MISO +14 11 11 23 SPI: SCLK +15 14 14 8 TxD +16 15 16 10 RxD 17 - 28 18 - 29 19 - 30 @@ -286,7 +307,7 @@ pin numbers. .LP WiringPi's home page .IP -https://projects.drogon.net/raspberry-pi/wiringpi/ +http://wiringpi.com/ .SH AUTHOR @@ -298,7 +319,7 @@ Please report bugs to .SH COPYRIGHT -Copyright (c) 2012 Gordon Henderson +Copyright (c) 2012-2013 Gordon Henderson This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/WiringPi/gpio/gpio.c b/WiringPi/gpio/gpio.c index 3a74605..871548e 100644 --- a/WiringPi/gpio/gpio.c +++ b/WiringPi/gpio/gpio.c @@ -30,18 +30,16 @@ #include #include #include -#include #include +#include +#include #include #include #include -#include -#include -#include -#include -#include + +#include "extensions.h" extern int wiringPiDebug ; @@ -50,213 +48,29 @@ extern int wiringPiDebug ; # define FALSE (1==2) #endif -#define VERSION "2.00" +#define VERSION "2.05" +#define I2CDETECT "/usr/sbin/i2cdetect" static int wpMode ; char *usage = "Usage: gpio -v\n" " gpio -h\n" - " gpio [-g|-1] [-x module:params] ...\n" + " gpio [-g|-1] [-x extension:params] ...\n" " gpio [-p] ...\n" " gpio ...\n" " gpio readall/reset\n" " gpio unexportall/exports\n" " gpio export/edge/unexport ...\n" + " gpio wfi \n" " gpio drive \n" " gpio pwm-bal/pwm-ms \n" " gpio pwmr \n" " gpio pwmc \n" " gpio load spi/i2c\n" + " gpio i2cd/i2cdetect\n" " gpio gbr \n" " gpio gbw " ; // No trailing newline needed here. -struct moduleFunctionStruct -{ - const char *name ; - int (*function)(char *progName, int pinBase, char *params) ; -} ; - -static int doModuleMcp23008 (char *progName, int pinBase, char *params) -{ - int i2c ; - -// Extract the I2C address: - - if (*params != ':') - { - fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ; - return FALSE ; - } - - ++params ; - if (!isdigit (*params)) - { - fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ; - return FALSE ; - } - - i2c = strtol (params, NULL, 0) ; - if ((i2c < 0x03) || (i2c > 0x77)) - { - fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; - return FALSE ; - } - - mcp23008Setup (pinBase, i2c) ; - - return TRUE ; -} - -static int doModuleMcp23017 (char *progName, int pinBase, char *params) -{ - int i2c ; - -// Extract the I2C address: - - if (*params != ':') - { - fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ; - return FALSE ; - } - - ++params ; - if (!isdigit (*params)) - { - fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ; - return FALSE ; - } - - i2c = strtol (params, NULL, 0) ; - if ((i2c < 0x03) || (i2c > 0x77)) - { - fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; - return FALSE ; - } - - mcp23017Setup (pinBase, i2c) ; - - return TRUE ; -} - -static int doModuleMcp23s08 (char *progName, int pinBase, char *params) -{ - int spi, port ; - -// Extract the SPI address: - - if (*params != ':') - { - fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ; - return FALSE ; - } - - ++params ; - if (!isdigit (*params)) - { - fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ; - return FALSE ; - } - - spi = *params - '0' ; - if ((spi < 0) || (spi > 1)) - { - fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ; - return FALSE ; - } - -// Extract the port: - - if (*++params != ':') - { - fprintf (stderr, "%s: colon expected after SPI address\n", progName) ; - return FALSE ; - } - - ++params ; - if (!isdigit (*params)) - { - fprintf (stderr, "%s: digit expected after SPI address\n", progName) ; - return FALSE ; - } - - port = strtol (params, NULL, 0) ; - if ((port < 0) || (port > 7)) - { - fprintf (stderr, "%s: port address (%d) out of range\n", progName, port) ; - return FALSE ; - } - - mcp23s08Setup (pinBase, spi, port) ; - - return TRUE ; -} - -static int doModuleMcp23s17 (char *progName, int pinBase, char *params) -{ - int spi, port ; - -// Extract the SPI address: - - if (*params != ':') - { - fprintf (stderr, "%s: colon expected after pin-base number\n", progName) ; - return FALSE ; - } - - ++params ; - if (!isdigit (*params)) - { - fprintf (stderr, "%s: digit expected after pin-base number\n", progName) ; - return FALSE ; - } - - spi = *params - '0' ; - if ((spi < 0) || (spi > 1)) - { - fprintf (stderr, "%s: SPI address (%d) out of range\n", progName, spi) ; - return FALSE ; - } - -// Extract the port: - - if (*++params != ':') - { - fprintf (stderr, "%s: colon expected after SPI address\n", progName) ; - return FALSE ; - } - - ++params ; - if (!isdigit (*params)) - { - fprintf (stderr, "%s: digit expected after SPI address\n", progName) ; - return FALSE ; - } - - port = strtol (params, NULL, 0) ; - if ((port < 0) || (port > 7)) - { - fprintf (stderr, "%s: port address (%d) out of range\n", progName, port) ; - return FALSE ; - } - - mcp23s17Setup (pinBase, spi, port) ; - - return TRUE ; -} - - -struct moduleFunctionStruct moduleFunctions [] = -{ - { "mcp23008", &doModuleMcp23008 }, - { "mcp23017", &doModuleMcp23017 }, - { "mcp23s08", &doModuleMcp23s08 }, - { "mcp23s17", &doModuleMcp23s17 }, - { NULL, NULL }, -} ; - - - - /* * changeOwner: @@ -391,6 +205,37 @@ static void doLoad (int argc, char *argv []) } +/* + * doI2Cdetect: + * Run the i2cdetect command with the right runes for this Pi revision + ********************************************************************************* + */ + +static void doI2Cdetect (int argc, char *argv []) +{ + int port = piBoardRev () == 1 ? 0 : 1 ; + char command [128] ; + struct stat statBuf ; + + if (stat (I2CDETECT, &statBuf) < 0) + { + fprintf (stderr, "%s: Unable to find i2cdetect command: %s\n", argv [0], strerror (errno)) ; + return ; + } + + if (!moduleLoaded ("i2c_dev")) + { + fprintf (stderr, "%s: The I2C kernel module(s) are not loaded.\n", argv [0]) ; + return ; + } + + sprintf (command, "%s -y %d", I2CDETECT, port) ; + if (system (command) < 0) + fprintf (stderr, "%s: Unable to run i2cdetect: %s\n", argv [0], strerror (errno)) ; + +} + + /* * doReadall: * Read all the GPIO pins @@ -431,7 +276,7 @@ static void doReadall (void) printf ("| wiringPi | GPIO | Phys | Name | Mode | Value |\n") ; printf ("+----------+------+------+--------+------+-------+\n") ; - for (pin = 0 ; pin < 64 ; ++pin) + for (pin = 0 ; pin < 64 ; ++pin) // Crude, but effective { if (wpiPinToGpio (pin) == -1) continue ; @@ -460,9 +305,7 @@ static void doExports (int argc, char *argv []) char fName [128] ; char buf [16] ; -// Rather crude, but who knows what others are up to... - - for (first = 0, i = 0 ; i < 64 ; ++i) + for (first = 0, i = 0 ; i < 64 ; ++i) // Crude, but effective { // Try to read the direction @@ -594,6 +437,52 @@ void doExport (int argc, char *argv []) } +/* + * doWfi: + * gpio wfi pin mode + * Wait for Interrupt on a given pin. + * Slight cheat here - it's easier to actually use ISR now (which calls + * gpio to set the pin modes!) then we simply sleep, and expect the thread + * to exit the program. Crude but effective. + ********************************************************************************* + */ + +static void wfi (void) + { exit (0) ; } + +void doWfi (int argc, char *argv []) +{ + int pin, mode ; + + if (argc != 4) + { + fprintf (stderr, "Usage: %s wfi pin mode\n", argv [0]) ; + exit (1) ; + } + + pin = atoi (argv [2]) ; + + /**/ if (strcasecmp (argv [3], "rising") == 0) mode = INT_EDGE_RISING ; + else if (strcasecmp (argv [3], "falling") == 0) mode = INT_EDGE_FALLING ; + else if (strcasecmp (argv [3], "both") == 0) mode = INT_EDGE_BOTH ; + else + { + fprintf (stderr, "%s: wfi: Invalid mode: %s. Should be rising, falling or both\n", argv [1], argv [3]) ; + exit (1) ; + } + + if (wiringPiISR (pin, mode, &wfi) < 0) + { + fprintf (stderr, "%s: wfi: Unable to setup ISR: %s\n", argv [1], strerror (errno)) ; + exit (1) ; + } + + for (;;) + delay (9999) ; +} + + + /* * doEdge: * gpio edge pin mode @@ -833,7 +722,7 @@ static void doGbw (int argc, char *argv []) if (argc != 4) { - fprintf (stderr, "Usage: %s gbr \n", argv [0]) ; + fprintf (stderr, "Usage: %s gbw \n", argv [0]) ; exit (1) ; } @@ -842,13 +731,13 @@ static void doGbw (int argc, char *argv []) if ((channel < 0) || (channel > 1)) { - fprintf (stderr, "%s: channel must be 0 or 1\n", argv [0]) ; + fprintf (stderr, "%s: gbw: Channel number must be 0 or 1\n", argv [0]) ; exit (1) ; } if ((value < 0) || (value > 1023)) { - fprintf (stderr, "%s: value must be from 0 to 255\n", argv [0]) ; + fprintf (stderr, "%s: gbw: Value must be from 0 to 255\n", argv [0]) ; exit (1) ; } @@ -883,7 +772,7 @@ static void doGbr (int argc, char *argv []) if ((channel < 0) || (channel > 1)) { - fprintf (stderr, "%s: channel must be 0 or 1\n", argv [0]) ; + fprintf (stderr, "%s: gbr: Channel number must be 0 or 1\n", argv [0]) ; exit (1) ; } @@ -992,7 +881,6 @@ void doRead (int argc, char *argv []) } pin = atoi (argv [2]) ; - val = digitalRead (pin) ; printf ("%s\n", val == 0 ? "0" : "1") ; @@ -1007,22 +895,37 @@ void doRead (int argc, char *argv []) void doAread (int argc, char *argv []) { - int pin, val ; - if (argc != 3) { fprintf (stderr, "Usage: %s aread pin\n", argv [0]) ; exit (1) ; } - pin = atoi (argv [2]) ; - - val = analogRead (pin) ; - - printf ("%s\n", val == 0 ? "0" : "1") ; + printf ("%d\n", analogRead (atoi (argv [2]))) ; } +/* + * doToggle: + * Toggle an IO pin + ********************************************************************************* + */ + +void doToggle (int argc, char *argv []) +{ + int pin ; + + if (argc != 3) + { + fprintf (stderr, "Usage: %s toggle pin\n", argv [0]) ; + exit (1) ; + } + + pin = atoi (argv [2]) ; + + digitalWrite (pin, !digitalRead (pin)) ; +} + /* * doClock: * Output a clock on a pin @@ -1125,72 +1028,6 @@ static void doPwmClock (int argc, char *argv []) } -/* - * doModule: - * Load in a wiringPi extension module - ********************************************************************************* - */ - -static int doModule (char *progName, char *moduleData) -{ - char *p ; - char *module = moduleData ; - struct moduleFunctionStruct *modFn ; - int pinBase = 0 ; - -// Get the module name by finding the first : - - p = module ; - while (*p != ':') - { - if (!*p) // ran out of characters - { - fprintf (stderr, "%s: module name not terminated by a colon\n", progName) ; - return FALSE ; - } - ++p ; - } - - *p++ = 0 ; - - if (!isdigit (*p)) - { - fprintf (stderr, "%s: pinBase number expected after module name\n", progName) ; - return FALSE ; - } - - while (isdigit (*p)) - { - if (pinBase > 1000000000) - { - fprintf (stderr, "%s: pinBase too large\n", progName) ; - return FALSE ; - } - - pinBase = pinBase * 10 + (*p - '0') ; - ++p ; - } - - if (pinBase < 64) - { - fprintf (stderr, "%s: pinBase (%d) too small. Minimum is 64.\n", progName, pinBase) ; - return FALSE ; - } - -// Search for modules: - - for (modFn = moduleFunctions ; modFn->name != NULL ; ++modFn) - { - if (strcmp (modFn->name, module) == 0) - return modFn->function (progName, pinBase, p) ; - } - - fprintf (stderr, "%s: module %s not found\n", progName, module) ; - return FALSE ; -} - - - /* * main: * Start here @@ -1213,13 +1050,31 @@ int main (int argc, char *argv []) return 1 ; } +// Help + if (strcasecmp (argv [1], "-h") == 0) { printf ("%s: %s\n", argv [0], usage) ; return 0 ; } - if (strcasecmp (argv [1], "-v") == 0) +// Sort of a special: + + if (strcmp (argv [1], "-R") == 0) + { + printf ("%d\n", piBoardRev ()) ; + return 0 ; + } + +// Version & Warranty + + if (strcmp (argv [1], "-V") == 0) + { + printf ("%d\n", piBoardRev ()) ; + return 0 ; + } + + if (strcmp (argv [1], "-v") == 0) { printf ("gpio version: %s\n", VERSION) ; printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ; @@ -1318,17 +1173,17 @@ int main (int argc, char *argv []) wpMode = WPI_MODE_PINS ; } -// Check for -x argument to load in a new module +// Check for -x argument to load in a new extension if (strcasecmp (argv [1], "-x") == 0) { if (argc < 3) { - fprintf (stderr, "%s: -x missing module specification.\n", argv [0]) ; + fprintf (stderr, "%s: -x missing extension specification.\n", argv [0]) ; exit (EXIT_FAILURE) ; } - if (!doModule (argv [0], argv [2])) // Prints its own error messages + if (!doExtension (argv [0], argv [2])) // Prints its own error messages exit (EXIT_FAILURE) ; for (i = 3 ; i < argc ; ++i) @@ -1351,17 +1206,24 @@ int main (int argc, char *argv []) else if (strcasecmp (argv [1], "awrite" ) == 0) doAwrite (argc, argv) ; else if (strcasecmp (argv [1], "aread" ) == 0) doAread (argc, argv) ; +// GPIO Nicies + + else if (strcasecmp (argv [1], "toggle" ) == 0) doToggle (argc, argv) ; + // Pi Specifics - else if (strcasecmp (argv [1], "pwm-bal") == 0) doPwmMode (PWM_MODE_BAL) ; - else if (strcasecmp (argv [1], "pwm-ms" ) == 0) doPwmMode (PWM_MODE_MS) ; - else if (strcasecmp (argv [1], "pwmr" ) == 0) doPwmRange (argc, argv) ; - else if (strcasecmp (argv [1], "pwmc" ) == 0) doPwmClock (argc, argv) ; - else if (strcasecmp (argv [1], "drive" ) == 0) doPadDrive (argc, argv) ; - else if (strcasecmp (argv [1], "readall") == 0) doReadall () ; - else if (strcasecmp (argv [1], "reset" ) == 0) doReset (argv [0]) ; - else if (strcasecmp (argv [1], "wb" ) == 0) doWriteByte (argc, argv) ; - else if (strcasecmp (argv [1], "clock" ) == 0) doClock (argc, argv) ; + else if (strcasecmp (argv [1], "pwm-bal" ) == 0) doPwmMode (PWM_MODE_BAL) ; + else if (strcasecmp (argv [1], "pwm-ms" ) == 0) doPwmMode (PWM_MODE_MS) ; + else if (strcasecmp (argv [1], "pwmr" ) == 0) doPwmRange (argc, argv) ; + else if (strcasecmp (argv [1], "pwmc" ) == 0) doPwmClock (argc, argv) ; + else if (strcasecmp (argv [1], "drive" ) == 0) doPadDrive (argc, argv) ; + else if (strcasecmp (argv [1], "readall" ) == 0) doReadall () ; + else if (strcasecmp (argv [1], "i2cdetect") == 0) doI2Cdetect (argc, argv) ; + else if (strcasecmp (argv [1], "i2cd" ) == 0) doI2Cdetect (argc, argv) ; + else if (strcasecmp (argv [1], "reset" ) == 0) doReset (argv [0]) ; + else if (strcasecmp (argv [1], "wb" ) == 0) doWriteByte (argc, argv) ; + else if (strcasecmp (argv [1], "clock" ) == 0) doClock (argc, argv) ; + else if (strcasecmp (argv [1], "wfi" ) == 0) doWfi (argc, argv) ; else { fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ; diff --git a/WiringPi/gpio/pintest b/WiringPi/gpio/pintest new file mode 100755 index 0000000..83ca12a --- /dev/null +++ b/WiringPi/gpio/pintest @@ -0,0 +1,193 @@ +#!/bin/bash +# +# pintest +# Test the Pi's GPIO port +# Copyright (c) 2013 Gordon Henderson +################################################################################# +# This file is part of wiringPi: +# Wiring Compatable library for the Raspberry Pi +# +# wiringPi is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# wiringPi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with wiringPi. If not, see . +################################################################################# + + +# logErr pin, expected got +################################################################################ + +logErr () +{ + if [ $errs = 0 ]; then + echo "" + fi + echo " --> Pin $1 failure. Expected $2, got $3" + let errs+=1 +} + + +# printErrorCount +################################################################################ + +printErrCount() +{ + if [ $errs = 0 ]; then + echo "No faults detected." + elif [ $errs = 1 ]; then + echo "One fault detected." + else + echo "$errs faults detected" + fi +} + + +# testPins start end +################################################################################ + +testPins() +{ + start=$1 + end=$2 + errs=0 + + printf "%30s %2d:%2d: " "$3" $1 $2 + +# Set range to inputs + + for i in `seq $start $end`; do + gpio mode $i in + done + +# Enable internal pull-ups and expect to read high + + for i in `seq $start $end`; do + gpio mode $i up + if [ `gpio read $i` = 0 ]; then + logErr $i 1 0 + fi + done + +# Enable internal pull-downs and expect to read low + + for i in `seq $start $end`; do + gpio mode $i down + if [ `gpio read $i` = 1 ]; then + echo "Pin $i failure - expected 0, got 1" + let errs+=1 + fi + done + +# Remove the internal pull up/downs + + for i in `seq $start $end`; do + gpio mode $i tri + done + + if [ $errs = 0 ]; then + echo " OK" + else + printErrCount + fi + + let totErrs+=errs +} + + +intro() +{ + revision=`gpio -V` + cat < + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/WiringPi/wiringPi/Makefile b/WiringPi/wiringPi/Makefile index eaf250e..f0120bb 100644 --- a/WiringPi/wiringPi/Makefile +++ b/WiringPi/wiringPi/Makefile @@ -35,7 +35,7 @@ DYNAMIC=libwiringPi.so.$(VERSION) DEBUG = -O2 CC = gcc INCLUDE = -I. -CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe -fPIC +CFLAGS = $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC LIBS = @@ -47,10 +47,12 @@ SRC = wiringPi.c \ piHiPri.c piThread.c \ wiringPiSPI.c wiringPiI2C.c \ softPwm.c softTone.c \ - mcp23s08.c mcp23008.c \ - mcp23s17.c mcp23017.c sr595.c \ - piFace.c gertboard.c \ - piNes.c ds1302.c lcd.c + mcp23008.c mcp23016.c mcp23017.c \ + mcp23s08.c mcp23s17.c \ + sr595.c \ + pcf8574.c pcf8591.c \ + mcp3002.c mcp4802.c mcp3422.c \ + drc.c OBJ = $(SRC:.c=.o) @@ -74,42 +76,50 @@ $(DYNAMIC): $(OBJ) .PHONEY: clean clean: - rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.* + @echo "[Clean]" + @rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPi.* .PHONEY: tags tags: $(SRC) @echo [ctags] @ctags $(SRC) -.PHONEY: install -install: $(DYNAMIC) - @echo "[Install]" - @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib + +.PHONEY: install-headers +install-headers: + @echo "[Install Headers]" @install -m 0755 -d $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringPi.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringSerial.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringShift.h $(DESTDIR)$(PREFIX)/include - @install -m 0644 gertboard.h $(DESTDIR)$(PREFIX)/include - @install -m 0644 piFace.h $(DESTDIR)$(PREFIX)/include - @install -m 0644 piNes.h $(DESTDIR)$(PREFIX)/include - @install -m 0644 ds1302.h $(DESTDIR)$(PREFIX)/include @install -m 0644 softPwm.h $(DESTDIR)$(PREFIX)/include @install -m 0644 softTone.h $(DESTDIR)$(PREFIX)/include - @install -m 0644 lcd.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringPiSPI.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringPiI2C.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23008.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 mcp23016.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23017.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23s08.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23s17.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 mcp3002.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 mcp4802.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 mcp3422.h $(DESTDIR)$(PREFIX)/include @install -m 0644 sr595.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 pcf8574.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 pcf8591.h $(DESTDIR)$(PREFIX)/include + +.PHONEY: install +install: $(DYNAMIC) install-headers + @echo "[Install Dynamic Lib]" + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib @install -m 0755 libwiringPi.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) @ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPi.so.$(VERSION) $(DESTDIR)/lib/libwiringPi.so @ldconfig .PHONEY: install-static -install-static: $(STATIC) - @echo "[Install Static]" +install-static: $(STATIC) install-headers + @echo "[Install Static Lib]" + @install -m 0755 -d $(DESTDIR)$(PREFIX)/lib @install -m 0755 libwiringPi.a $(DESTDIR)$(PREFIX)/lib .PHONEY: uninstall @@ -118,20 +128,21 @@ uninstall: @rm -f $(DESTDIR)$(PREFIX)/include/wiringPi.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringSerial.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringShift.h - @rm -f $(DESTDIR)$(PREFIX)/include/gertboard.h - @rm -f $(DESTDIR)$(PREFIX)/include/piFace.h - @rm -f $(DESTDIR)$(PREFIX)/include/piNes.h - @rm -f $(DESTDIR)$(PREFIX)/include/ds1302.h @rm -f $(DESTDIR)$(PREFIX)/include/softPwm.h @rm -f $(DESTDIR)$(PREFIX)/include/softTone.h - @rm -f $(DESTDIR)$(PREFIX)/include/lcd.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiSPI.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiI2C.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23008.h + @rm -f $(DESTDIR)$(PREFIX)/include/mcp23016.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23017.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s08.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s17.h + @rm -f $(DESTDIR)$(PREFIX)/include/mcp3002.h + @rm -f $(DESTDIR)$(PREFIX)/include/mcp4802.h + @rm -f $(DESTDIR)$(PREFIX)/include/mcp3422.h @rm -f $(DESTDIR)$(PREFIX)/include/sr595.h + @rm -f $(DESTDIR)$(PREFIX)/include/pcf8574.h + @rm -f $(DESTDIR)$(PREFIX)/include/pcf8591.h @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.* @ldconfig @@ -147,17 +158,19 @@ wiringSerial.o: wiringSerial.h wiringShift.o: wiringPi.h wiringShift.h piHiPri.o: wiringPi.h piThread.o: wiringPi.h -wiringPiSPI.o: wiringPiSPI.h +wiringPiSPI.o: wiringPi.h wiringPiSPI.h wiringPiI2C.o: wiringPi.h wiringPiI2C.h softPwm.o: wiringPi.h softPwm.h softTone.o: wiringPi.h softTone.h -mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h mcp23008.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23008.h -mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h +mcp23016.o: wiringPi.h wiringPiI2C.h mcp23016.h mcp23016reg.h mcp23017.o: wiringPi.h wiringPiI2C.h mcp23x0817.h mcp23017.h +mcp23s08.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s08.h +mcp23s17.o: wiringPi.h wiringPiSPI.h mcp23x0817.h mcp23s17.h sr595.o: wiringPi.h sr595.h -piFace.o: wiringPi.h wiringPiSPI.h piFace.h mcp23x0817.h -gertboard.o: wiringPi.h wiringPiSPI.h gertboard.h -piNes.o: wiringPi.h piNes.h -ds1302.o: wiringPi.h ds1302.h -lcd.o: wiringPi.h lcd.h +pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h +pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h +mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h +mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h +mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h +drc.o: wiringPi.h wiringSerial.h drc.h diff --git a/WiringPi/wiringPi/drc.c b/WiringPi/wiringPi/drc.c new file mode 100644 index 0000000..07baf17 --- /dev/null +++ b/WiringPi/wiringPi/drc.c @@ -0,0 +1,203 @@ +/* + * drc.c: + * Extend wiringPi with the DRC control protocll to Arduino + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include +#include +#include + +#include "wiringPi.h" +#include "wiringSerial.h" + +#include "drc.h" + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + + +/* + * myPinMode: + * Change the pin mode on the remote DRC device + ********************************************************************************* + */ + +static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) +{ + /**/ if (mode == OUTPUT) + serialPutchar (node->fd, 'o') ; // Input + else if (mode == PWM_OUTPUT) + serialPutchar (node->fd, 'p') ; // PWM + else + serialPutchar (node->fd, 'i') ; // Default to input + + serialPutchar (node->fd, pin - node->pinBase) ; +} + + +/* + * myPullUpDnControl: + * ATmegas only have pull-up's on of off. No pull-downs. + ********************************************************************************* + */ + +static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode) +{ + +// Force pin into input mode + + serialPutchar (node->fd, 'i' ) ; + serialPutchar (node->fd, pin) ; + + /**/ if (mode == PUD_UP) + { + serialPutchar (node->fd, '1') ; + serialPutchar (node->fd, pin - node->pinBase) ; + } + else if (mode == PUD_OFF) + { + serialPutchar (node->fd, '0') ; + serialPutchar (node->fd, pin - node->pinBase) ; + } +} + + +/* + * myDigitalWrite: + ********************************************************************************* + */ + +static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + serialPutchar (node->fd, value == 0 ? '0' : '1') ; + serialPutchar (node->fd, pin - node->pinBase) ; +} + + +/* + * myPwmWrite: + ********************************************************************************* + */ + +static void myPwmWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + serialPutchar (node->fd, 'v') ; + serialPutchar (node->fd, pin - node->pinBase) ; + serialPutchar (node->fd, value & 0xFF) ; +} + + +/* + * myAnalogRead: + ********************************************************************************* + */ + +static int myAnalogRead (struct wiringPiNodeStruct *node, int pin) +{ + int vHi, vLo ; + + serialPutchar (node->fd, 'a') ; + serialPutchar (node->fd, pin - node->pinBase) ; + vHi = serialGetchar (node->fd) ; + vLo = serialGetchar (node->fd) ; + + return (vHi << 8) | vLo ; +} + + +/* + * myDigitalRead: + ********************************************************************************* + */ + +static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) +{ + serialPutchar (node->fd, 'r') ; // Send read command + serialPutchar (node->fd, pin - node->pinBase) ; + return (serialGetchar (node->fd) == '0') ? 0 : 1 ; +} + + +/* + * drcSetup: + * Create a new instance of an DRC GPIO interface. + * Could be a variable nunber of pins here - we might not know in advance + * if it's an ATmega with 14 pins, or something with less or more! + ********************************************************************************* + */ + +int drcSetup (const int pinBase, const int numPins, const char *device) +{ + int fd ; + int ok, tries ; + time_t then ; + struct wiringPiNodeStruct *node ; + + if ((fd = serialOpen (device, 115200)) < 0) + return wiringPiFailure (WPI_ALMOST, "Unable to open DRC device (%s): %s", device, strerror (errno)) ; + + delay (10) ; // May need longer if it's an Uno that reboots on the open... + +// Flush any pending input + + while (serialDataAvail (fd)) + (void)serialGetchar (fd) ; + + ok = FALSE ; + for (tries = 1 ; tries < 5 ; ++tries) + { + serialPutchar (fd, '@') ; + then = time (NULL) + 2 ; + while (time (NULL) < then) + if (serialDataAvail (fd)) + { + if (serialGetchar (fd) == '@') + { + ok = TRUE ; + break ; + } + } + if (ok) + break ; + } + + if (!ok) + { + serialClose (fd) ; + return wiringPiFailure (WPI_FATAL, "Unable to communidate with DRC device") ; + } + + node = wiringPiNewNode (pinBase, numPins) ; + + node->fd = fd ; + node->pinMode = myPinMode ; + node->pullUpDnControl = myPullUpDnControl ; + node->analogRead = myAnalogRead ; + node->digitalRead = myDigitalRead ; + node->digitalWrite = myDigitalWrite ; + node->pwmWrite = myPwmWrite ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/drc.h b/WiringPi/wiringPi/drc.h new file mode 100644 index 0000000..c2c4ff3 --- /dev/null +++ b/WiringPi/wiringPi/drc.h @@ -0,0 +1,34 @@ +/* + * drc.h: + * Extend wiringPi with the DRC control protocll to Arduino + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +int drcSetup (const int pinBase, const int numPins, const char *device) ; + + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/mcp23008.c b/WiringPi/wiringPi/mcp23008.c index c518c14..d21d237 100644 --- a/WiringPi/wiringPi/mcp23008.c +++ b/WiringPi/wiringPi/mcp23008.c @@ -39,19 +39,18 @@ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, ddr ; + int mask, old, reg ; - pin -= node->pinBase ; - ddr = MCP23x08_IODIR ; - mask = 1 << pin ; - old = wiringPiI2CReadReg8 (node->fd, ddr) ; + reg = MCP23x08_IODIR ; + mask = 1 << (pin - node->pinBase) ; + old = wiringPiI2CReadReg8 (node->fd, reg) ; if (mode == OUTPUT) old &= (~mask) ; else old |= mask ; - wiringPiI2CWriteReg8 (node->fd, ddr, old) ; + wiringPiI2CWriteReg8 (node->fd, reg, old) ; } @@ -62,20 +61,19 @@ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, pud ; + int mask, old, reg ; - pin -= node->pinBase ; - pud = MCP23x08_GPPU ; - mask = 1 << pin ; + reg = MCP23x08_GPPU ; + mask = 1 << (pin - node->pinBase) ; - old = wiringPiI2CReadReg8 (node->fd, pud) ; + old = wiringPiI2CReadReg8 (node->fd, reg) ; if (mode == PUD_UP) old |= mask ; else old &= (~mask) ; - wiringPiI2CWriteReg8 (node->fd, pud, old) ; + wiringPiI2CWriteReg8 (node->fd, reg, old) ; } @@ -88,8 +86,7 @@ static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) { int bit, old ; - pin -= node->pinBase ; - bit = 1 << (pin & 7) ; + bit = 1 << ((pin - node->pinBase) & 7) ; old = node->data2 ; if (value == LOW) @@ -109,13 +106,10 @@ static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) { - int mask, value, gpio ; + int mask, value ; - pin -= node->pinBase ; - gpio = MCP23x08_GPIO ; - mask = 1 << pin ; - - value = wiringPiI2CReadReg8 (node->fd, gpio) ; + mask = 1 << ((pin - node->pinBase) & 7) ; + value = wiringPiI2CReadReg8 (node->fd, MCP23x08_GPIO) ; if ((value & mask) == 0) return LOW ; @@ -127,12 +121,12 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) /* * mcp23008Setup: * Create a new instance of an MCP23008 I2C GPIO interface. We know it - * has 16 pins, so all we need to know here is the I2C address and the + * has 8 pins, so all we need to know here is the I2C address and the * user-defined pin base. ********************************************************************************* */ -int mcp23008Setup (int pinBase, int i2cAddress) +int mcp23008Setup (const int pinBase, const int i2cAddress) { int fd ; struct wiringPiNodeStruct *node ; @@ -142,7 +136,7 @@ int mcp23008Setup (int pinBase, int i2cAddress) wiringPiI2CWriteReg8 (fd, MCP23x08_IOCON, IOCON_INIT) ; - node = wiringPiNewNode (pinBase, 16) ; + node = wiringPiNewNode (pinBase, 8) ; node->fd = fd ; node->pinMode = myPinMode ; diff --git a/WiringPi/wiringPi/mcp23008.h b/WiringPi/wiringPi/mcp23008.h index 0aa21dc..e9299a8 100644 --- a/WiringPi/wiringPi/mcp23008.h +++ b/WiringPi/wiringPi/mcp23008.h @@ -26,7 +26,7 @@ extern "C" { #endif -extern int mcp23008Setup (int pinBase, int i2cAddress) ; +extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/mcp23016.c b/WiringPi/wiringPi/mcp23016.c new file mode 100644 index 0000000..e5cc632 --- /dev/null +++ b/WiringPi/wiringPi/mcp23016.c @@ -0,0 +1,164 @@ +/* + * mcp23016.c: + * Extend wiringPi with the MCP 23016 I2C GPIO expander chip + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "wiringPi.h" +#include "wiringPiI2C.h" +#include "mcp23016.h" + +#include "mcp23016reg.h" + + +/* + * myPinMode: + ********************************************************************************* + */ + +static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) +{ + int mask, old, reg ; + + pin -= node->pinBase ; + + if (pin < 8) // Bank A + reg = MCP23016_IODIR0 ; + else + { + reg = MCP23016_IODIR1 ; + pin &= 0x07 ; + } + + mask = 1 << pin ; + old = wiringPiI2CReadReg8 (node->fd, reg) ; + + if (mode == OUTPUT) + old &= (~mask) ; + else + old |= mask ; + + wiringPiI2CWriteReg8 (node->fd, reg, old) ; +} + + +/* + * myDigitalWrite: + ********************************************************************************* + */ + +static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + int bit, old ; + + pin -= node->pinBase ; // Pin now 0-15 + + bit = 1 << (pin & 7) ; + + if (pin < 8) // Bank A + { + old = node->data2 ; + + if (value == LOW) + old &= (~bit) ; + else + old |= bit ; + + wiringPiI2CWriteReg8 (node->fd, MCP23016_GP0, old) ; + node->data2 = old ; + } + else // Bank B + { + old = node->data3 ; + + if (value == LOW) + old &= (~bit) ; + else + old |= bit ; + + wiringPiI2CWriteReg8 (node->fd, MCP23016_GP1, old) ; + node->data3 = old ; + } +} + + +/* + * myDigitalRead: + ********************************************************************************* + */ + +static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) +{ + int mask, value, gpio ; + + pin -= node->pinBase ; + + if (pin < 8) // Bank A + gpio = MCP23016_GP0 ; + else + { + gpio = MCP23016_GP1 ; + pin &= 0x07 ; + } + + mask = 1 << pin ; + value = wiringPiI2CReadReg8 (node->fd, gpio) ; + + if ((value & mask) == 0) + return LOW ; + else + return HIGH ; +} + + +/* + * mcp23016Setup: + * Create a new instance of an MCP23016 I2C GPIO interface. We know it + * has 16 pins, so all we need to know here is the I2C address and the + * user-defined pin base. + ********************************************************************************* + */ + +int mcp23016Setup (const int pinBase, const int i2cAddress) +{ + int fd ; + struct wiringPiNodeStruct *node ; + + if ((fd = wiringPiI2CSetup (i2cAddress)) < 0) + return fd ; + + wiringPiI2CWriteReg8 (fd, MCP23016_IOCON0, IOCON_INIT) ; + wiringPiI2CWriteReg8 (fd, MCP23016_IOCON1, IOCON_INIT) ; + + node = wiringPiNewNode (pinBase, 16) ; + + node->fd = fd ; + node->pinMode = myPinMode ; + node->digitalRead = myDigitalRead ; + node->digitalWrite = myDigitalWrite ; + node->data2 = wiringPiI2CReadReg8 (fd, MCP23016_OLAT0) ; + node->data3 = wiringPiI2CReadReg8 (fd, MCP23016_OLAT1) ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/mcp23016.h b/WiringPi/wiringPi/mcp23016.h new file mode 100644 index 0000000..f9b5cc5 --- /dev/null +++ b/WiringPi/wiringPi/mcp23016.h @@ -0,0 +1,33 @@ +/* + * mcp23016.h: + * Extend wiringPi with the MCP 23016 I2C GPIO expander chip + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/mcp23016reg.h b/WiringPi/wiringPi/mcp23016reg.h new file mode 100644 index 0000000..9aea92d --- /dev/null +++ b/WiringPi/wiringPi/mcp23016reg.h @@ -0,0 +1,48 @@ +/* + * mcp23016: + * Copyright (c) 2012-2013 Gordon Henderson + * + * Header file for code using the MCP23016 GPIO expander + * chip. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +// MCP23016 Registers + +#define MCP23016_GP0 0x00 +#define MCP23016_GP1 0x01 +#define MCP23016_OLAT0 0x02 +#define MCP23016_OLAT1 0x03 +#define MCP23016_IPOL0 0x04 +#define MCP23016_IPOL1 0x05 +#define MCP23016_IODIR0 0x06 +#define MCP23016_IODIR1 0x07 +#define MCP23016_INTCAP0 0x08 +#define MCP23016_INTCAP1 0x09 +#define MCP23016_IOCON0 0x0A +#define MCP23016_IOCON1 0x0B + +// Bits in the IOCON register + +#define IOCON_IARES 0x01 + +// Default initialisation mode + +#define IOCON_INIT 0 diff --git a/WiringPi/wiringPi/mcp23017.c b/WiringPi/wiringPi/mcp23017.c index cf6593e..5174195 100644 --- a/WiringPi/wiringPi/mcp23017.c +++ b/WiringPi/wiringPi/mcp23017.c @@ -39,27 +39,27 @@ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, ddr ; + int mask, old, reg ; pin -= node->pinBase ; if (pin < 8) // Bank A - ddr = MCP23x17_IODIRA ; + reg = MCP23x17_IODIRA ; else { - ddr = MCP23x17_IODIRB ; + reg = MCP23x17_IODIRB ; pin &= 0x07 ; } mask = 1 << pin ; - old = wiringPiI2CReadReg8 (node->fd, ddr) ; + old = wiringPiI2CReadReg8 (node->fd, reg) ; if (mode == OUTPUT) old &= (~mask) ; else old |= mask ; - wiringPiI2CWriteReg8 (node->fd, ddr, old) ; + wiringPiI2CWriteReg8 (node->fd, reg, old) ; } @@ -70,27 +70,27 @@ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, pud ; + int mask, old, reg ; pin -= node->pinBase ; if (pin < 8) // Bank A - pud = MCP23x17_GPPUA ; + reg = MCP23x17_GPPUA ; else { - pud = MCP23x17_GPPUB ; - pin &= 0x07 ; + reg = MCP23x17_GPPUB ; + pin &= 0x07 ; } mask = 1 << pin ; - old = wiringPiI2CReadReg8 (node->fd, pud) ; + old = wiringPiI2CReadReg8 (node->fd, reg) ; if (mode == PUD_UP) old |= mask ; else old &= (~mask) ; - wiringPiI2CWriteReg8 (node->fd, pud, old) ; + wiringPiI2CWriteReg8 (node->fd, reg, old) ; } @@ -146,7 +146,7 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) pin -= node->pinBase ; if (pin < 8) // Bank A - gpio = MCP23x17_GPIOA ; + gpio = MCP23x17_GPIOA ; else { gpio = MCP23x17_GPIOB ; @@ -171,7 +171,7 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) ********************************************************************************* */ -int mcp23017Setup (int pinBase, int i2cAddress) +int mcp23017Setup (const int pinBase, const int i2cAddress) { int fd ; struct wiringPiNodeStruct *node ; diff --git a/WiringPi/wiringPi/mcp23017.h b/WiringPi/wiringPi/mcp23017.h index 3d0e42c..79b4d7b 100644 --- a/WiringPi/wiringPi/mcp23017.h +++ b/WiringPi/wiringPi/mcp23017.h @@ -26,7 +26,7 @@ extern "C" { #endif -extern int mcp23017Setup (int pinBase, int i2cAddress) ; +extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/mcp23s08.c b/WiringPi/wiringPi/mcp23s08.c index 391e9e1..d0acb5e 100644 --- a/WiringPi/wiringPi/mcp23s08.c +++ b/WiringPi/wiringPi/mcp23s08.c @@ -78,19 +78,18 @@ static uint8_t readByte (uint8_t spiPort, uint8_t devId, uint8_t reg) static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, ddr ; + int mask, old, reg ; - pin -= node->pinBase ; - ddr = MCP23x08_IODIR ; - mask = 1 << pin ; - old = readByte (node->data0, node->data1, ddr) ; + reg = MCP23x08_IODIR ; + mask = 1 << (pin - node->pinBase) ; + old = readByte (node->data0, node->data1, reg) ; if (mode == OUTPUT) old &= (~mask) ; else old |= mask ; - writeByte (node->data0, node->data1, ddr, old) ; + writeByte (node->data0, node->data1, reg, old) ; } @@ -101,20 +100,19 @@ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, pud ; + int mask, old, reg ; - pin -= node->pinBase ; - pud = MCP23x08_GPPU ; - mask = 1 << pin ; + reg = MCP23x08_GPPU ; + mask = 1 << (pin - node->pinBase) ; - old = readByte (node->data0, node->data1, pud) ; + old = readByte (node->data0, node->data1, reg) ; if (mode == PUD_UP) old |= mask ; else old &= (~mask) ; - writeByte (node->data0, node->data1, pud, old) ; + writeByte (node->data0, node->data1, reg, old) ; } @@ -127,8 +125,7 @@ static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) { int bit, old ; - pin -= node->pinBase ; - bit = 1 << pin ; + bit = 1 << ((pin - node->pinBase) & 7) ; old = node->data2 ; if (value == LOW) @@ -148,13 +145,10 @@ static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) { - int mask, value, gpio ; + int mask, value ; - pin -= node->pinBase ; - gpio = MCP23x08_GPIO ; - mask = 1 << pin ; - - value = readByte (node->data0, node->data1, gpio) ; + mask = 1 << ((pin - node->pinBase) & 7) ; + value = readByte (node->data0, node->data1, MCP23x08_GPIO) ; if ((value & mask) == 0) return LOW ; @@ -166,12 +160,12 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) /* * mcp23s08Setup: * Create a new instance of an MCP23s08 SPI GPIO interface. We know it - * has 16 pins, so all we need to know here is the SPI address and the + * has 8 pins, so all we need to know here is the SPI address and the * user-defined pin base. ********************************************************************************* */ -int mcp23s08Setup (int pinBase, int spiPort, int devId) +int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) { int x ; struct wiringPiNodeStruct *node ; @@ -181,7 +175,7 @@ int mcp23s08Setup (int pinBase, int spiPort, int devId) writeByte (spiPort, devId, MCP23x08_IOCON, IOCON_INIT) ; - node = wiringPiNewNode (pinBase, 16) ; + node = wiringPiNewNode (pinBase, 8) ; node->data0 = spiPort ; node->data1 = devId ; diff --git a/WiringPi/wiringPi/mcp23s08.h b/WiringPi/wiringPi/mcp23s08.h index 3c2b22f..ebf93d1 100644 --- a/WiringPi/wiringPi/mcp23s08.h +++ b/WiringPi/wiringPi/mcp23s08.h @@ -26,7 +26,7 @@ extern "C" { #endif -extern int mcp23s08Setup (int pinBase, int spiPort, int devId) ; +extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/mcp23s17.c b/WiringPi/wiringPi/mcp23s17.c index b20ea71..c2d1be3 100644 --- a/WiringPi/wiringPi/mcp23s17.c +++ b/WiringPi/wiringPi/mcp23s17.c @@ -78,27 +78,27 @@ static uint8_t readByte (uint8_t spiPort, uint8_t devId, uint8_t reg) static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, ddr ; + int mask, old, reg ; pin -= node->pinBase ; if (pin < 8) // Bank A - ddr = MCP23x17_IODIRA ; + reg = MCP23x17_IODIRA ; else { - ddr = MCP23x17_IODIRB ; + reg = MCP23x17_IODIRB ; pin &= 0x07 ; } mask = 1 << pin ; - old = readByte (node->data0, node->data1, ddr) ; + old = readByte (node->data0, node->data1, reg) ; if (mode == OUTPUT) old &= (~mask) ; else old |= mask ; - writeByte (node->data0, node->data1, ddr, old) ; + writeByte (node->data0, node->data1, reg, old) ; } @@ -109,27 +109,27 @@ static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mode) { - int mask, old, pud ; + int mask, old, reg ; pin -= node->pinBase ; if (pin < 8) // Bank A - pud = MCP23x17_GPPUA ; + reg = MCP23x17_GPPUA ; else { - pud = MCP23x17_GPPUB ; - pin &= 0x07 ; + reg = MCP23x17_GPPUB ; + pin &= 0x07 ; } mask = 1 << pin ; - old = readByte (node->data0, node->data1, pud) ; + old = readByte (node->data0, node->data1, reg) ; if (mode == PUD_UP) old |= mask ; else old &= (~mask) ; - writeByte (node->data0, node->data1, pud, old) ; + writeByte (node->data0, node->data1, reg, old) ; } @@ -185,7 +185,7 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) pin -= node->pinBase ; if (pin < 8) // Bank A - gpio = MCP23x17_GPIOA ; + gpio = MCP23x17_GPIOA ; else { gpio = MCP23x17_GPIOB ; @@ -210,7 +210,7 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) ********************************************************************************* */ -int mcp23s17Setup (int pinBase, int spiPort, int devId) +int mcp23s17Setup (const int pinBase, const int spiPort, const int devId) { int x ; struct wiringPiNodeStruct *node ; diff --git a/WiringPi/wiringPi/mcp3002.c b/WiringPi/wiringPi/mcp3002.c new file mode 100644 index 0000000..2e7d5cf --- /dev/null +++ b/WiringPi/wiringPi/mcp3002.c @@ -0,0 +1,76 @@ +/* + * mcp3002.c: + * Extend wiringPi with the MCP3002 SPI Analog to Digital convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "mcp3002.h" + +/* + * myAnalogRead: + * Return the analog value of the given pin + ********************************************************************************* + */ + +static int myAnalogRead (struct wiringPiNodeStruct *node, int pin) +{ + unsigned char spiData [2] ; + unsigned char chanBits ; + int chan = pin - node->pinBase ; + + if (chan == 0) + chanBits = 0b11010000 ; + else + chanBits = 0b11110000 ; + + spiData [0] = chanBits ; + spiData [1] = 0 ; + + wiringPiSPIDataRW (node->fd, spiData, 2) ; + + return ((spiData [0] << 7) | (spiData [1] >> 1)) & 0x3FF ; +} + + +/* + * mcp3002Setup: + * Create a new wiringPi device node for an mcp2003 on the Pi's + * SPI interface. + ********************************************************************************* + */ + +int mcp3002Setup (const int pinBase, int spiChannel) +{ + struct wiringPiNodeStruct *node ; + + if (wiringPiSPISetup (spiChannel, 1000000) < 0) + return -1 ; + + node = wiringPiNewNode (pinBase, 2) ; + + node->fd = spiChannel ; + node->analogRead = myAnalogRead ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/mcp3002.h b/WiringPi/wiringPi/mcp3002.h new file mode 100644 index 0000000..0cd727f --- /dev/null +++ b/WiringPi/wiringPi/mcp3002.h @@ -0,0 +1,33 @@ +/* + * mcp3002.c: + * Extend wiringPi with the MCP3002 SPI Analog to Digital convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int mcp3002Setup (int pinBase, int spiChannel) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/mcp3422.c b/WiringPi/wiringPi/mcp3422.c new file mode 100644 index 0000000..8e26d76 --- /dev/null +++ b/WiringPi/wiringPi/mcp3422.c @@ -0,0 +1,116 @@ +/* + * mcp3422.c: + * Extend wiringPi with the MCP3422 I2C ADC chip + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + + +#include +#include +#include +#include +#include + +#include +#include + +#include "mcp3422.h" + + +/* + * myAnalogRead: + * Read a channel from the device + ********************************************************************************* + */ + +int myAnalogRead (struct wiringPiNodeStruct *node, int chan) +{ + unsigned char config, b0, b1, b2, b3 ; + int value = 0 ; + +// One-shot mode, trigger plus the other configs. + + config = 0x80 | ((chan - node->pinBase) << 5) | (node->data0 << 2) | (node->data1) ; + + wiringPiI2CWrite (node->fd, config) ; + + switch (node->data0) // Sample rate + { + case MCP3422_SR_3_75: // 18 bits + delay (270) ; + b0 = wiringPiI2CRead (node->fd) ; + b1 = wiringPiI2CRead (node->fd) ; + b2 = wiringPiI2CRead (node->fd) ; + b3 = wiringPiI2CRead (node->fd) ; + value = ((b0 & 3) << 16) | (b1 << 8) | b2 ; + break ; + + case MCP3422_SR_15: // 16 bits + delay ( 70) ; + b0 = wiringPiI2CRead (node->fd) ; + b1 = wiringPiI2CRead (node->fd) ; + b2 = wiringPiI2CRead (node->fd) ; + value = (b0 << 8) | b1 ; + break ; + + case MCP3422_SR_60: // 14 bits + delay ( 17) ; + b0 = wiringPiI2CRead (node->fd) ; + b1 = wiringPiI2CRead (node->fd) ; + b2 = wiringPiI2CRead (node->fd) ; + value = ((b0 & 0x3F) << 8) | b1 ; + break ; + + case MCP3422_SR_240: // 12 bits + delay ( 5) ; + b0 = wiringPiI2CRead (node->fd) ; + b1 = wiringPiI2CRead (node->fd) ; + b2 = wiringPiI2CRead (node->fd) ; + value = ((b0 & 0x0F) << 8) | b1 ; + break ; + } + + return value ; +} + + +/* + * mcp3422Setup: + * Create a new wiringPi device node for the mcp3422 + ********************************************************************************* + */ + +int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int gain) +{ + int fd ; + struct wiringPiNodeStruct *node ; + + if ((fd = wiringPiI2CSetup (i2cAddress)) < 0) + return fd ; + + node = wiringPiNewNode (pinBase, channels) ; + + node->data0 = sampleRate ; + node->data1 = gain ; + node->analogRead = myAnalogRead ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/mcp3422.h b/WiringPi/wiringPi/mcp3422.h new file mode 100644 index 0000000..8b4e350 --- /dev/null +++ b/WiringPi/wiringPi/mcp3422.h @@ -0,0 +1,43 @@ +/* + * mcp3422.c: + * Extend wiringPi with the MCP3422 I2C ADC chip + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#define MCP3422_SR_3_75 0 +#define MCP3422_SR_15 1 +#define MCP3422_SR_60 2 +#define MCP3422_SR_240 3 + +#define MCP3422_GAIN_1 0 +#define MCP3422_GAIN_2 1 +#define MCP3422_GAIN_4 2 +#define MCP3422_GAIN_8 3 + + +#ifdef __cplusplus +extern "C" { +#endif + +extern int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int gain) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/mcp4802.c b/WiringPi/wiringPi/mcp4802.c new file mode 100644 index 0000000..5c5c17a --- /dev/null +++ b/WiringPi/wiringPi/mcp4802.c @@ -0,0 +1,76 @@ +/* + * mcp4802.c: + * Extend wiringPi with the MCP4802 SPI Digital to Analog convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "mcp4802.h" + +/* + * myAnalogWrite: + * Write analog value on the given pin + ********************************************************************************* + */ + +static void myAnalogWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + unsigned char spiData [2] ; + unsigned char chanBits, dataBits ; + int chan = pin - node->pinBase ; + + if (chan == 0) + chanBits = 0x30 ; + else + chanBits = 0xB0 ; + + chanBits |= ((value >> 4) & 0x0F) ; + dataBits = ((value << 4) & 0xF0) ; + + spiData [0] = chanBits ; + spiData [1] = dataBits ; + + wiringPiSPIDataRW (node->fd, spiData, 2) ; +} + +/* + * mcp4802Setup: + * Create a new wiringPi device node for an mcp4802 on the Pi's + * SPI interface. + ********************************************************************************* + */ + +int mcp4802Setup (const int pinBase, int spiChannel) +{ + struct wiringPiNodeStruct *node ; + + if (wiringPiSPISetup (spiChannel, 1000000) < 0) + return -1 ; + + node = wiringPiNewNode (pinBase, 2) ; + + node->fd = spiChannel ; + node->analogWrite = myAnalogWrite ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/mcp4802.h b/WiringPi/wiringPi/mcp4802.h new file mode 100644 index 0000000..effa024 --- /dev/null +++ b/WiringPi/wiringPi/mcp4802.h @@ -0,0 +1,33 @@ +/* + * mcp4802.c: + * Extend wiringPi with the MCP4802 SPI Digital to Analog convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int mcp4802Setup (int pinBase, int spiChannel) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/pcf8574.c b/WiringPi/wiringPi/pcf8574.c new file mode 100644 index 0000000..c172d1c --- /dev/null +++ b/WiringPi/wiringPi/pcf8574.c @@ -0,0 +1,126 @@ +/* + * pcf8574.c: + * Extend wiringPi with the PCF8574 I2C GPIO expander chip + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "wiringPi.h" +#include "wiringPiI2C.h" + +#include "pcf8574.h" + + +/* + * myPinMode: + * The PCF8574 is an odd chip - the pins are effectively bi-directional, + * however the pins should be drven high when used as an input pin... + * So, we're effectively copying digitalWrite... + ********************************************************************************* + */ + +static void myPinMode (struct wiringPiNodeStruct *node, int pin, int mode) +{ + int bit, old ; + + bit = 1 << ((pin - node->pinBase) & 7) ; + + old = node->data2 ; + if (mode == OUTPUT) + old &= (~bit) ; // Write bit to 0 + else + old |= bit ; // Write bit to 1 + + wiringPiI2CWrite (node->fd, old) ; + node->data2 = old ; +} + + + +/* + * myDigitalWrite: + ********************************************************************************* + */ + +static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + int bit, old ; + + bit = 1 << ((pin - node->pinBase) & 7) ; + + old = node->data2 ; + if (value == LOW) + old &= (~bit) ; + else + old |= bit ; + + wiringPiI2CWrite (node->fd, old) ; + node->data2 = old ; +} + + +/* + * myDigitalRead: + ********************************************************************************* + */ + +static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) +{ + int mask, value ; + + mask = 1 << ((pin - node->pinBase) & 7) ; + value = wiringPiI2CRead (node->fd) ; + + if ((value & mask) == 0) + return LOW ; + else + return HIGH ; +} + + +/* + * pcf8574Setup: + * Create a new instance of a PCF8574 I2C GPIO interface. We know it + * has 8 pins, so all we need to know here is the I2C address and the + * user-defined pin base. + ********************************************************************************* + */ + +int pcf8574Setup (const int pinBase, const int i2cAddress) +{ + int fd ; + struct wiringPiNodeStruct *node ; + + if ((fd = wiringPiI2CSetup (i2cAddress)) < 0) + return fd ; + + node = wiringPiNewNode (pinBase, 8) ; + + node->fd = fd ; + node->pinMode = myPinMode ; + node->digitalRead = myDigitalRead ; + node->digitalWrite = myDigitalWrite ; + node->data2 = wiringPiI2CRead (fd) ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/pcf8574.h b/WiringPi/wiringPi/pcf8574.h new file mode 100644 index 0000000..8e2d818 --- /dev/null +++ b/WiringPi/wiringPi/pcf8574.h @@ -0,0 +1,33 @@ +/* + * pcf8574.h: + * Extend wiringPi with the PCF8574 I2C GPIO expander chip + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/pcf8591.c b/WiringPi/wiringPi/pcf8591.c new file mode 100644 index 0000000..0c86056 --- /dev/null +++ b/WiringPi/wiringPi/pcf8591.c @@ -0,0 +1,90 @@ +/* + * pcf8591.c: + * Extend wiringPi with the PCF8591 I2C GPIO Analog expander chip + * The chip has 1 8-bit DAC and 4 x 8-bit ADCs + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include + +#include "wiringPi.h" +#include "wiringPiI2C.h" + +#include "pcf8591.h" + + +/* + * myAnalogWrite: + ********************************************************************************* + */ + +static void myAnalogWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + unsigned char b [2] ; + b [0] = 0x40 ; + b [1] = value & 0xFF ; + write (node->fd, b, 2) ; +} + + +/* + * myAnalogRead: + ********************************************************************************* + */ + +static int myAnalogRead (struct wiringPiNodeStruct *node, int pin) +{ + int x ; + + wiringPiI2CWrite (node->fd, 0x40 | ((pin - node->pinBase) & 3)) ; + + x = wiringPiI2CRead (node->fd) ; // Throw away the first read + x = wiringPiI2CRead (node->fd) ; + + return x ; +} + + +/* + * pcf8591Setup: + * Create a new instance of a PCF8591 I2C GPIO interface. We know it + * has 4 pins, (4 analog inputs and 1 analog output which we'll shadow + * input 0) so all we need to know here is the I2C address and the + * user-defined pin base. + ********************************************************************************* + */ + +int pcf8591Setup (const int pinBase, const int i2cAddress) +{ + int fd ; + struct wiringPiNodeStruct *node ; + + if ((fd = wiringPiI2CSetup (i2cAddress)) < 0) + return fd ; + + node = wiringPiNewNode (pinBase, 4) ; + + node->fd = fd ; + node->analogRead = myAnalogRead ; + node->analogWrite = myAnalogWrite ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/pcf8591.h b/WiringPi/wiringPi/pcf8591.h new file mode 100644 index 0000000..6b44ccf --- /dev/null +++ b/WiringPi/wiringPi/pcf8591.h @@ -0,0 +1,33 @@ +/* + * pcf8591.h: + * Extend wiringPi with the PCF8591 I2C GPIO Analog expander chip + * Copyright (c) 2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int pcf8591Setup (const int pinBase, const int i2cAddress) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/piFace.c b/WiringPi/wiringPi/piFace.c deleted file mode 100644 index c09c41d..0000000 --- a/WiringPi/wiringPi/piFace.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * piFace.: - * Arduino compatable (ish) Wiring library for the Raspberry Pi - * Copyright (c) 2012-2013 Gordon Henderson - * - * This file to interface with the PiFace peripheral device which - * has an MCP23S17 GPIO device connected via the SPI bus. - *********************************************************************** - * This file is part of wiringPi: - * https://projects.drogon.net/raspberry-pi/wiringpi/ - * - * wiringPi is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * wiringPi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with wiringPi. - * If not, see . - *********************************************************************** - */ - - -#include -#include - -#include "wiringPi.h" -#include "wiringPiSPI.h" - -#include "piFace.h" - -#define PIFACE_SPEED 4000000 -#define PIFACE_DEVNO 0 - -#include "mcp23x0817.h" - - -/* - * writeByte: - * Write a byte to a register on the MCP23S17 on the SPI bus. - ********************************************************************************* - */ - -static void writeByte (uint8_t reg, uint8_t data) -{ - uint8_t spiData [4] ; - - spiData [0] = CMD_WRITE ; - spiData [1] = reg ; - spiData [2] = data ; - - wiringPiSPIDataRW (PIFACE_DEVNO, spiData, 3) ; -} - -/* - * readByte: - * Read a byte from a register on the MCP23S17 on the SPI bus. - ********************************************************************************* - */ - -static uint8_t readByte (uint8_t reg) -{ - uint8_t spiData [4] ; - - spiData [0] = CMD_READ ; - spiData [1] = reg ; - - wiringPiSPIDataRW (PIFACE_DEVNO, spiData, 3) ; - - return spiData [2] ; -} - - -/* - * digitalWrite: - * Perform the digitalWrite function on the PiFace board - ********************************************************************************* - */ - -void digitalWritePiFace (struct wiringPiNodeStruct *node, int pin, int value) -{ - uint8_t mask, old ; - - pin -= node->pinBase ; - mask = 1 << pin ; - old = readByte (MCP23x17_GPIOA) ; - - if (value == 0) - old &= (~mask) ; - else - old |= mask ; - - writeByte (MCP23x17_GPIOA, old) ; -} - - -/* - * digitalReadPiFace: - * Perform the digitalRead function on the PiFace board - ********************************************************************************* - */ - -int digitalReadPiFace (struct wiringPiNodeStruct *node, int pin) -{ - uint8_t mask, reg ; - - pin -= node->pinBase ; - mask = 1 << (pin & 7) ; - - if (pin < 8) - reg = MCP23x17_GPIOB ; // Input regsiter - else - reg = MCP23x17_OLATA ; // Output latch regsiter - - if ((readByte (reg) & mask) != 0) - return HIGH ; - else - return LOW ; -} - - -/* - * pullUpDnControlPiFace: - * Perform the pullUpDnControl function on the PiFace board - ********************************************************************************* - */ - -void pullUpDnControlPiFace (struct wiringPiNodeStruct *node, int pin, int pud) -{ - uint8_t mask, old ; - - pin -= node->pinBase ; - mask = 1 << pin ; - old = readByte (MCP23x17_GPPUB) ; - - if (pud == 0) - old &= (~mask) ; - else - old |= mask ; - - writeByte (MCP23x17_GPPUB, old) ; -} - - -/* - * piFaceSetup - * Setup the SPI interface and initialise the MCP23S17 chip - * We create one node with 16 pins - each if the first 8 pins being read - * and write - although the operations actually go to different - * hardware ports. The top 8 let you read the state of the output register. - ********************************************************************************* - */ - -int piFaceSetup (int pinBase) -{ - int x ; - struct wiringPiNodeStruct *node ; - - if ((x = wiringPiSPISetup (PIFACE_DEVNO, PIFACE_SPEED)) < 0) - return x ; - -// Setup the MCP23S17 - - writeByte (MCP23x17_IOCON, IOCON_INIT) ; - writeByte (MCP23x17_IODIRA, 0x00) ; // Port A -> Outputs - writeByte (MCP23x17_IODIRB, 0xFF) ; // Port B -> Inputs - - node = wiringPiNewNode (pinBase, 16) ; - node->digitalRead = digitalReadPiFace ; - node->digitalWrite = digitalWritePiFace ; - node->pullUpDnControl = pullUpDnControlPiFace ; - - return 0 ; -} diff --git a/WiringPi/wiringPi/piHiPri.c b/WiringPi/wiringPi/piHiPri.c index e7e06b4..d2f3b4e 100644 --- a/WiringPi/wiringPi/piHiPri.c +++ b/WiringPi/wiringPi/piHiPri.c @@ -36,15 +36,16 @@ ********************************************************************************* */ -int piHiPri (int pri) +int piHiPri (const int pri) { struct sched_param sched ; memset (&sched, 0, sizeof(sched)) ; if (pri > sched_get_priority_max (SCHED_RR)) - pri = sched_get_priority_max (SCHED_RR) ; + sched.sched_priority = sched_get_priority_max (SCHED_RR) ; + else + sched.sched_priority = pri ; - sched.sched_priority = pri ; return sched_setscheduler (0, SCHED_RR, &sched) ; } diff --git a/WiringPi/wiringPi/softPwm.c b/WiringPi/wiringPi/softPwm.c index b568dfb..a4f0fc4 100644 --- a/WiringPi/wiringPi/softPwm.c +++ b/WiringPi/wiringPi/softPwm.c @@ -28,7 +28,7 @@ #include "wiringPi.h" #include "softPwm.h" -#define MAX_PINS 64 +#define MAX_PINS 1024 // The PWM Frequency is derived from the "pulse time" below. Essentially, // the frequency is a function of the range and this pulse time. @@ -93,7 +93,7 @@ static PI_THREAD (softPwmThread) void softPwmWrite (int pin, int value) { - pin &= 63 ; + pin &= (MAX_PINS - 1) ; /**/ if (value < 0) value = 0 ; diff --git a/WiringPi/wiringPi/sr595.c b/WiringPi/wiringPi/sr595.c index e71ff58..87210c2 100644 --- a/WiringPi/wiringPi/sr595.c +++ b/WiringPi/wiringPi/sr595.c @@ -82,7 +82,8 @@ static void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) ********************************************************************************* */ -int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin) +int sr595Setup (const int pinBase, const int numPins, + const int dataPin, const int clockPin, const int latchPin) { struct wiringPiNodeStruct *node ; diff --git a/WiringPi/wiringPi/sr595.h b/WiringPi/wiringPi/sr595.h index 708671f..4a26dc7 100644 --- a/WiringPi/wiringPi/sr595.h +++ b/WiringPi/wiringPi/sr595.h @@ -26,7 +26,8 @@ extern "C" { #endif -extern int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin) ; +extern int sr595Setup (const int pinBase, const int numPins, + const int dataPin, const int clockPin, const int latchPin) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/wiringPi.c b/WiringPi/wiringPi/wiringPi.c index 6bb8883..b8e381a 100644 --- a/WiringPi/wiringPi/wiringPi.c +++ b/WiringPi/wiringPi/wiringPi.c @@ -202,11 +202,13 @@ static uint64_t epochMilli, epochMicro ; // Misc static int wiringPiMode = WPI_MODE_UNINITIALISED ; +static volatile int pinPass = -1 ; +static pthread_mutex_t pinMutex ; // Debugging & Return codes -int wiringPiDebug = FALSE ; -int wiringPiCodes = FALSE ; +int wiringPiDebug = FALSE ; +int wiringPiReturnCodes = FALSE ; // sysFds: // Map a file descriptor from the /sys/class/gpio/gpioX/value @@ -512,16 +514,19 @@ static uint8_t gpioToClkDiv [] = ********************************************************************************* */ -int wiringPiFailure (char *message, ...) +int wiringPiFailure (int fatal, const char *message, ...) { va_list argp ; char buffer [1024] ; + if (!fatal && wiringPiReturnCodes) + return -1 ; + va_start (argp, message) ; vsnprintf (buffer, 1023, message, argp) ; va_end (argp) ; - fprintf (stderr,"%s", buffer) ; + fprintf (stderr, "%s", buffer) ; exit (EXIT_FAILURE) ; return 0 ; @@ -531,7 +536,7 @@ int wiringPiFailure (char *message, ...) /* * piBoardRev: * Return a number representing the hardware revision of the board. - * Revision is currently 1 or 2. -1 is returned on error. + * Revision is currently 1 or 2. * * Much confusion here )-: * Seems there are some boards with 0000 in them (mistake in manufacture) @@ -554,7 +559,7 @@ int wiringPiFailure (char *message, ...) ********************************************************************************* */ -static void piBoardRevOops (char *why) +static void piBoardRevOops (const char *why) { fprintf (stderr, "piBoardRev: Unable to determine board revision from /proc/cpuinfo\n") ; fprintf (stderr, " -> %s\n", why) ; @@ -658,7 +663,7 @@ void setPadDrive (int group, int value) { uint32_t wrVal ; - if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO)) + if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO)) { if ((group < 0) || (group > 2)) return ; @@ -712,7 +717,7 @@ int getAlt (int pin) void pwmSetMode (int mode) { - if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO) || (wiringPiMode == WPI_MODE_PHYS)) + if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO)) { if (mode == PWM_MODE_MS) *(pwm + PWM_CONTROL) = PWM0_ENABLE | PWM1_ENABLE | PWM0_MS_MODE | PWM1_MS_MODE ; @@ -731,7 +736,7 @@ void pwmSetMode (int mode) void pwmSetRange (unsigned int range) { - if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO) || (wiringPiMode == WPI_MODE_PHYS)) + if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO)) { *(pwm + PWM0_RANGE) = range ; delayMicroseconds (10) ; *(pwm + PWM1_RANGE) = range ; delayMicroseconds (10) ; @@ -752,7 +757,7 @@ void pwmSetClock (int divisor) uint32_t pwm_control ; divisor &= 4095 ; - if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_GPIO) || (wiringPiMode == WPI_MODE_PHYS)) + if ((wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO)) { if (wiringPiDebug) printf ("Setting to: %d. Current: 0x%08X\n", divisor, *(clk + PWMCLK_DIV)) ; @@ -864,17 +869,17 @@ struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) // Minimum pin base is 64 if (pinBase < 64) - (void)wiringPiFailure ("wiringPiNewNode: pinBase of %d is < 64\n", pinBase) ; + (void)wiringPiFailure (WPI_FATAL, "wiringPiNewNode: pinBase of %d is < 64\n", pinBase) ; // Check all pins in-case there is overlap: for (pin = pinBase ; pin < (pinBase + numPins) ; ++pin) if (wiringPiFindNode (pin) != NULL) - (void)wiringPiFailure ("wiringPiNewNode: Pin %d overlaps with existing definition\n", pin) ; + (void)wiringPiFailure (WPI_FATAL, "wiringPiNewNode: Pin %d overlaps with existing definition\n", pin) ; - node = calloc (sizeof (struct wiringPiNodeStruct), 1) ; // calloc zeros + node = (struct wiringPiNodeStruct *)calloc (sizeof (struct wiringPiNodeStruct), 1) ; // calloc zeros if (node == NULL) - (void)wiringPiFailure ("wiringPiNewNode: Unable to allocate memory: %s\n", strerror (errno)) ; + (void)wiringPiFailure (WPI_FATAL, "wiringPiNewNode: Unable to allocate memory: %s\n", strerror (errno)) ; node->pinBase = pinBase ; node->pinMax = pinBase + numPins - 1 ; @@ -999,15 +1004,13 @@ void pullUpDnControl (int pin, int pud) else if (wiringPiMode != WPI_MODE_GPIO) return ; - pud &= 3 ; - - *(gpio + GPPUD) = pud ; delayMicroseconds (5) ; + *(gpio + GPPUD) = pud & 3 ; delayMicroseconds (5) ; *(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ; *(gpio + GPPUD) = 0 ; delayMicroseconds (5) ; *(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ; } - else + else // Extension module { if ((node = wiringPiFindNode (pin)) != NULL) node->pullUpDnControl (node, pin, pud) ; @@ -1034,8 +1037,8 @@ int digitalRead (int pin) if (sysFds [pin] == -1) return LOW ; - lseek (sysFds [pin], 0L, SEEK_SET) ; - read (sysFds [pin], &c, 1) ; + lseek (sysFds [pin], 0L, SEEK_SET) ; + read (sysFds [pin], &c, 1) ; return (c == '0') ? LOW : HIGH ; } else if (wiringPiMode == WPI_MODE_PINS) @@ -1080,6 +1083,7 @@ void digitalWrite (int pin, int value) else write (sysFds [pin], "1\n", 2) ; } + return ; } else if (wiringPiMode == WPI_MODE_PINS) pin = pinToGpio [pin] ; @@ -1194,6 +1198,7 @@ void digitalWriteByte (int value) digitalWrite (pin, value & mask) ; mask <<= 1 ; } + return ; } else { @@ -1234,7 +1239,7 @@ int waitForInterrupt (int pin, int mS) else if (wiringPiMode == WPI_MODE_PHYS) pin = physToGpio [pin] ; - if ((fd = sysFds [pin & 63]) == -1) + if ((fd = sysFds [pin]) == -1) return -2 ; // Setup poll structure @@ -1265,10 +1270,13 @@ int waitForInterrupt (int pin, int mS) static void *interruptHandler (void *arg) { - int myPin = *(int *)arg ; + int myPin ; (void)piHiPri (55) ; // Only effective if we run as root + myPin = pinPass ; + pinPass = -1 ; + for (;;) if (waitForInterrupt (myPin, -1) > 0) isrFunctions [myPin] () ; @@ -1288,21 +1296,24 @@ static void *interruptHandler (void *arg) int wiringPiISR (int pin, int mode, void (*function)(void)) { pthread_t threadId ; + const char *modeS ; char fName [64] ; - char *modeS ; char pinS [8] ; pid_t pid ; int count, i ; - uint8_t c ; + char c ; + int bcmGpioPin ; pin &= 63 ; /**/ if (wiringPiMode == WPI_MODE_UNINITIALISED) - (void)wiringPiFailure ("wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ; + return wiringPiFailure (WPI_FATAL, "wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ; else if (wiringPiMode == WPI_MODE_PINS) - pin = pinToGpio [pin] ; + bcmGpioPin = pinToGpio [pin] ; else if (wiringPiMode == WPI_MODE_PHYS) - pin = physToGpio [pin] ; + bcmGpioPin = physToGpio [pin] ; + else + bcmGpioPin = pin ; // Now export the pin and set the right edge // We're going to use the gpio program to do this, so it assumes @@ -1319,7 +1330,7 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) else modeS = "both" ; - sprintf (pinS, "%d", pin) ; + sprintf (pinS, "%d", bcmGpioPin) ; if ((pid = fork ()) < 0) // Fail return pid ; @@ -1334,23 +1345,29 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) } // Now pre-open the /sys/class node - it may already be open if -// we are in Sys mode, but this will do no harm. +// we are in Sys mode or if we call here twice, if-so, we'll close it. - sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ; - if ((sysFds [pin] = open (fName, O_RDWR)) < 0) + if (sysFds [bcmGpioPin] != -1) + close (sysFds [bcmGpioPin]) ; + + sprintf (fName, "/sys/class/gpio/gpio%d/value", bcmGpioPin) ; + if ((sysFds [bcmGpioPin] = open (fName, O_RDWR)) < 0) return -1 ; // Clear any initial pending interrupt - ioctl (sysFds [pin], FIONREAD, &count) ; + ioctl (sysFds [bcmGpioPin], FIONREAD, &count) ; for (i = 0 ; i < count ; ++i) - read (sysFds [pin], &c, 1) ; + read (sysFds [bcmGpioPin], &c, 1) ; isrFunctions [pin] = function ; - pthread_create (&threadId, NULL, interruptHandler, &pin) ; - - delay (1) ; + pthread_mutex_lock (&pinMutex) ; + pinPass = pin ; + pthread_create (&threadId, NULL, interruptHandler, NULL) ; + while (pinPass != -1) + delay (1) ; + pthread_mutex_unlock (&pinMutex) ; return 0 ; } @@ -1492,10 +1509,10 @@ int wiringPiSetup (void) wiringPiDebug = TRUE ; if (getenv (ENV_CODES) != NULL) - wiringPiCodes = TRUE ; + wiringPiReturnCodes = TRUE ; if (geteuid () != 0) - (void)wiringPiFailure ("wiringPiSetup: Must be root. (Did you forget sudo?)\n") ; + (void)wiringPiFailure (WPI_FATAL, "wiringPiSetup: Must be root. (Did you forget sudo?)\n") ; if (wiringPiDebug) printf ("wiringPi: wiringPiSetup called\n") ; @@ -1516,38 +1533,38 @@ int wiringPiSetup (void) // Open the master /dev/memory device if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0) - (void)wiringPiFailure ("wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ; + return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ; // GPIO: gpio = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_BASE) ; if ((int32_t)gpio == -1) - (void)wiringPiFailure ("wiringPiSetup: mmap (GPIO) failed: %s\n", strerror (errno)) ; + return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (GPIO) failed: %s\n", strerror (errno)) ; // PWM pwm = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PWM) ; if ((int32_t)pwm == -1) - (void)wiringPiFailure ("wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ; + return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ; // Clock control (needed for PWM) clk = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, CLOCK_BASE) ; if ((int32_t)clk == -1) - (void)wiringPiFailure ("wiringPiSetup: mmap (CLOCK) failed: %s\n", strerror (errno)) ; + return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (CLOCK) failed: %s\n", strerror (errno)) ; // The drive pads pads = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PADS) ; if ((int32_t)pads == -1) - (void)wiringPiFailure ("wiringPiSetup: mmap (PADS) failed: %s\n", strerror (errno)) ; + return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PADS) failed: %s\n", strerror (errno)) ; #ifdef USE_TIMER // The system timer timer = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_TIMER) ; if ((int32_t)timer == -1) - (void)wiringPiFailure ("wiringPiSetup: mmap (TIMER) failed: %s\n", strerror (errno)) ; + return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (TIMER) failed: %s\n", strerror (errno)) ; // Set the timer to free-running, 1MHz. // 0xF9 is 249, the timer divide is base clock / (divide+1) @@ -1629,7 +1646,7 @@ int wiringPiSetupSys (void) wiringPiDebug = TRUE ; if (getenv (ENV_CODES) != NULL) - wiringPiCodes = TRUE ; + wiringPiReturnCodes = TRUE ; if (wiringPiDebug) printf ("wiringPi: wiringPiSetupSys called\n") ; diff --git a/WiringPi/wiringPi/wiringPi.h b/WiringPi/wiringPi/wiringPi.h index 2c0a72b..600b318 100644 --- a/WiringPi/wiringPi/wiringPi.h +++ b/WiringPi/wiringPi/wiringPi.h @@ -21,6 +21,9 @@ *********************************************************************** */ +#ifndef __WIRING_PI_H__ +#define __WIRING_PI_H__ + // Handy defines // Deprecated @@ -65,6 +68,12 @@ #define PI_THREAD(X) void *X (void *dummy) +// Failure modes + +#define WPI_FATAL (1==1) +#define WPI_ALMOST (1==2) + + // wiringPiNodeStruct: // This describes additional device nodes in the extended wiringPi // 2.0 scheme of things. @@ -104,6 +113,9 @@ struct wiringPiNodeStruct extern "C" { #endif +// Internal + +extern int wiringPiFailure (int fatal, const char *message, ...) ; // Core wiringPi functions @@ -132,6 +144,7 @@ extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio extern int piBoardRev (void) ; extern int wpiPinToGpio (int wpiPin) ; +extern int physPinToGpio (int physPin) ; extern void setPadDrive (int group, int value) ; extern int getAlt (int pin) ; extern void digitalWriteByte (int value) ; @@ -154,7 +167,7 @@ extern void piUnlock (int key) ; // Schedulling priority -extern int piHiPri (int pri) ; +extern int piHiPri (const int pri) ; // Extras from arduino land @@ -166,3 +179,5 @@ extern unsigned int micros (void) ; #ifdef __cplusplus } #endif + +#endif diff --git a/WiringPi/wiringPi/wiringPiI2C.c b/WiringPi/wiringPi/wiringPiI2C.c index dbc94b9..c787bce 100644 --- a/WiringPi/wiringPi/wiringPiI2C.c +++ b/WiringPi/wiringPi/wiringPiI2C.c @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #include @@ -148,7 +150,7 @@ int wiringPiI2CReadReg16 (int fd, int reg) if (i2c_smbus_access (fd, I2C_SMBUS_READ, reg, I2C_SMBUS_WORD_DATA, &data)) return -1 ; else - return data.byte & 0xFF ; + return data.word & 0xFFFF ; } @@ -188,35 +190,38 @@ int wiringPiI2CWriteReg16 (int fd, int reg, int value) /* - * wiringPiI2CSetup: - * Open the I2C device, and regsiter the target device + * wiringPiI2CSetupInterface: + * Undocumented access to set the interface explicitly - might be used + * for the Pi's 2nd I2C interface... ********************************************************************************* */ -int wiringPiI2CSetupInterface (char *device, int devId) +int wiringPiI2CSetupInterface (const char *device, int devId) { int fd ; if ((fd = open (device, O_RDWR)) < 0) - return -1 ; + return wiringPiFailure (WPI_ALMOST, "Unable to open I2C device: %s\n", strerror (errno)) ; if (ioctl (fd, I2C_SLAVE, devId) < 0) - return -1 ; + return wiringPiFailure (WPI_ALMOST, "Unable to select I2C device: %s\n", strerror (errno)) ; return fd ; } -int wiringPiI2CSetup (int devId) +/* + * wiringPiI2CSetup: + * Open the I2C device, and regsiter the target device + ********************************************************************************* + */ + +int wiringPiI2CSetup (const int devId) { int rev ; - char *device ; + const char *device ; - if ((rev = piBoardRev ()) < 0) - { - fprintf (stderr, "wiringPiI2CSetup: Unable to determine Pi board revision\n") ; - exit (1) ; - } + rev = piBoardRev () ; if (rev == 1) device = "/dev/i2c-0" ; diff --git a/WiringPi/wiringPi/wiringPiI2C.h b/WiringPi/wiringPi/wiringPiI2C.h index d1b5c01..6db8c68 100644 --- a/WiringPi/wiringPi/wiringPiI2C.h +++ b/WiringPi/wiringPi/wiringPiI2C.h @@ -34,8 +34,8 @@ extern int wiringPiI2CWrite (int fd, int data) ; extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; -extern int wiringPiI2CSetupInterface (char *device, int devId) ; -extern int wiringPiI2CSetup (int devId) ; +extern int wiringPiI2CSetupInterface (const char *device, int devId) ; +extern int wiringPiI2CSetup (const int devId) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/wiringPiSPI.c b/WiringPi/wiringPi/wiringPiSPI.c index 4014bb7..215a027 100644 --- a/WiringPi/wiringPi/wiringPiSPI.c +++ b/WiringPi/wiringPi/wiringPiSPI.c @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include @@ -36,11 +38,11 @@ // The SPI bus parameters // Variables as they need to be passed as pointers later on -static char *spiDev0 = "/dev/spidev0.0" ; -static char *spiDev1 = "/dev/spidev0.1" ; -static uint8_t spiMode = 0 ; -static uint8_t spiBPW = 8 ; -static uint16_t spiDelay = 0; +const static char *spiDev0 = "/dev/spidev0.0" ; +const static char *spiDev1 = "/dev/spidev0.1" ; +const static uint8_t spiMode = 0 ; +const static uint8_t spiBPW = 8 ; +const static uint16_t spiDelay = 0 ; static uint32_t spiSpeeds [2] ; static int spiFds [2] ; @@ -97,7 +99,7 @@ int wiringPiSPISetup (int channel, int speed) channel &= 1 ; if ((fd = open (channel == 0 ? spiDev0 : spiDev1, O_RDWR)) < 0) - return -1 ; + return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ; spiSpeeds [channel] = speed ; spiFds [channel] = fd ; @@ -106,14 +108,14 @@ int wiringPiSPISetup (int channel, int speed) // Why are we reading it afterwriting it? I've no idea, but for now I'm blindly // copying example code I've seen online... - if (ioctl (fd, SPI_IOC_WR_MODE, &spiMode) < 0) return -1 ; - if (ioctl (fd, SPI_IOC_RD_MODE, &spiMode) < 0) return -1 ; + if (ioctl (fd, SPI_IOC_WR_MODE, &spiMode) < 0) + return wiringPiFailure (WPI_ALMOST, "SPI Mode Change failure: %s\n", strerror (errno)) ; + + if (ioctl (fd, SPI_IOC_WR_BITS_PER_WORD, &spiBPW) < 0) + return wiringPiFailure (WPI_ALMOST, "SPI BPW Change failure: %s\n", strerror (errno)) ; - if (ioctl (fd, SPI_IOC_WR_BITS_PER_WORD, &spiBPW) < 0) return -1 ; - if (ioctl (fd, SPI_IOC_RD_BITS_PER_WORD, &spiBPW) < 0) return -1 ; - - if (ioctl (fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) < 0) return -1 ; - if (ioctl (fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) return -1 ; + if (ioctl (fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) < 0) + return wiringPiFailure (WPI_ALMOST, "SPI Speed Change failure: %s\n", strerror (errno)) ; return fd ; } diff --git a/WiringPi/wiringPi/wiringSerial.c b/WiringPi/wiringPi/wiringSerial.c index 7035593..ca976a9 100644 --- a/WiringPi/wiringPi/wiringSerial.c +++ b/WiringPi/wiringPi/wiringSerial.c @@ -41,7 +41,7 @@ ********************************************************************************* */ -int serialOpen (char *device, int baud) +int serialOpen (const char *device, const int baud) { struct termios options ; speed_t myBaud ; @@ -117,7 +117,7 @@ int serialOpen (char *device, int baud) ********************************************************************************* */ -void serialFlush (int fd) +void serialFlush (const int fd) { tcflush (fd, TCIOFLUSH) ; } @@ -129,7 +129,7 @@ void serialFlush (int fd) ********************************************************************************* */ -void serialClose (int fd) +void serialClose (const int fd) { close (fd) ; } @@ -141,7 +141,7 @@ void serialClose (int fd) ********************************************************************************* */ -void serialPutchar (int fd, unsigned char c) +void serialPutchar (const int fd, const unsigned char c) { write (fd, &c, 1) ; } @@ -153,7 +153,7 @@ void serialPutchar (int fd, unsigned char c) ********************************************************************************* */ -void serialPuts (int fd, char *s) +void serialPuts (const int fd, const char *s) { write (fd, s, strlen (s)) ; } @@ -164,7 +164,7 @@ void serialPuts (int fd, char *s) ********************************************************************************* */ -void serialPrintf (int fd, char *message, ...) +void serialPrintf (const int fd, const char *message, ...) { va_list argp ; char buffer [1024] ; @@ -183,7 +183,7 @@ void serialPrintf (int fd, char *message, ...) ********************************************************************************* */ -int serialDataAvail (int fd) +int serialDataAvail (const int fd) { int result ; @@ -202,7 +202,7 @@ int serialDataAvail (int fd) ********************************************************************************* */ -int serialGetchar (int fd) +int serialGetchar (const int fd) { uint8_t x ; diff --git a/WiringPi/wiringPi/wiringSerial.h b/WiringPi/wiringPi/wiringSerial.h index 1a4198c..430dc73 100644 --- a/WiringPi/wiringPi/wiringSerial.h +++ b/WiringPi/wiringPi/wiringSerial.h @@ -24,14 +24,14 @@ extern "C" { #endif -extern int serialOpen (char *device, int baud) ; -extern void serialClose (int fd) ; -extern void serialFlush (int fd) ; -extern void serialPutchar (int fd, unsigned char c) ; -extern void serialPuts (int fd, char *s) ; -extern void serialPrintf (int fd, char *message, ...) ; -extern int serialDataAvail (int fd) ; -extern int serialGetchar (int fd) ; +extern int serialOpen (const char *device, const int baud) ; +extern void serialClose (const int fd) ; +extern void serialFlush (const int fd) ; +extern void serialPutchar (const int fd, const unsigned char c) ; +extern void serialPuts (const int fd, const char *s) ; +extern void serialPrintf (const int fd, const char *message, ...) ; +extern int serialDataAvail (const int fd) ; +extern int serialGetchar (const int fd) ; #ifdef __cplusplus } diff --git a/setup.py b/setup.py index 338eb2e..fd20293 100644 --- a/setup.py +++ b/setup.py @@ -5,27 +5,36 @@ from setuptools import setup, find_packages, Extension _wiringpi2 = Extension( '_wiringpi2', sources=[ - 'WiringPi/wiringPi/ds1302.c', - 'WiringPi/wiringPi/gertboard.c', - 'WiringPi/wiringPi/lcd.c', - 'WiringPi/wiringPi/mcp23008.c', - 'WiringPi/wiringPi/mcp23017.c', - 'WiringPi/wiringPi/mcp23s08.c', + 'WiringPi/devLib/ds1302.c', + 'WiringPi/devLib/lcd128x64.c', + 'WiringPi/devLib/maxdetect.c', + 'WiringPi/devLib/gertboard.c', + 'WiringPi/devLib/lcd.c', + 'WiringPi/devLib/piFace.c', + 'WiringPi/devLib/piNes.c', + 'WiringPi/wiringPi/drc.c', 'WiringPi/wiringPi/mcp23s17.c', - 'WiringPi/wiringPi/piFace.c', - 'WiringPi/wiringPi/piHiPri.c', - 'WiringPi/wiringPi/piNes.c', - 'WiringPi/wiringPi/piThread.c', - 'WiringPi/wiringPi/softPwm.c', - 'WiringPi/wiringPi/softServo.c', + 'WiringPi/wiringPi/pcf8591.c', 'WiringPi/wiringPi/softTone.c', - 'WiringPi/wiringPi/sr595.c', - 'WiringPi/wiringPi/wiringPi.c', - 'WiringPi/wiringPi/wiringPiI2C.c', - 'WiringPi/wiringPi/wiringPiSPI.c', 'WiringPi/wiringPi/wiringSerial.c', + 'WiringPi/wiringPi/mcp23008.c', + 'WiringPi/wiringPi/mcp3002.c', + 'WiringPi/wiringPi/piHiPri.c', + 'WiringPi/wiringPi/sr595.c', 'WiringPi/wiringPi/wiringShift.c', - 'wiringpi_wrap.c' + 'WiringPi/wiringPi/mcp23016.c', + 'WiringPi/wiringPi/mcp3422.c', + 'WiringPi/wiringPi/piThread.c', + 'WiringPi/wiringPi/wiringPi.c', + 'WiringPi/wiringPi/mcp23017.c', + 'WiringPi/wiringPi/mcp4802.c', + 'WiringPi/wiringPi/softPwm.c', + 'WiringPi/wiringPi/wiringPiI2C.c', + 'WiringPi/wiringPi/mcp23s08.c', + 'WiringPi/wiringPi/pcf8574.c', + 'WiringPi/wiringPi/softServo.c', + 'WiringPi/wiringPi/wiringPiSPI.c', + 'wiringpi_wrap.c' ], ) @@ -43,25 +52,36 @@ setup( py_modules = ["wiringpi2"], install_requires=[], headers=[ - 'WiringPi/wiringPi/ds1302.h', - 'WiringPi/wiringPi/gertboard.h', - 'WiringPi/wiringPi/lcd.h', - 'WiringPi/wiringPi/mcp23008.h', - 'WiringPi/wiringPi/mcp23017.h', + 'WiringPi/devLib/ds1302.h', + 'WiringPi/devLib/gertboard.h', + 'WiringPi/devLib/lcd.h', + 'WiringPi/devLib/piFace.h', + 'WiringPi/devLib/font.h', + 'WiringPi/devLib/lcd128x64.h', + 'WiringPi/devLib/maxdetect.h', + 'WiringPi/devLib/piNes.h', + 'WiringPi/wiringPi/drc.h', 'WiringPi/wiringPi/mcp23s08.h', - 'WiringPi/wiringPi/mcp23s17.h', - 'WiringPi/wiringPi/mcp23x0817.h', - 'WiringPi/wiringPi/mcp23x08.h', - 'WiringPi/wiringPi/piFace.h', - 'WiringPi/wiringPi/piNes.h', - 'WiringPi/wiringPi/softPwm.h', + 'WiringPi/wiringPi/mcp3422.h', 'WiringPi/wiringPi/softServo.h', - 'WiringPi/wiringPi/softTone.h', - 'WiringPi/wiringPi/sr595.h', - 'WiringPi/wiringPi/wiringPi.h', - 'WiringPi/wiringPi/wiringPiI2C.h', 'WiringPi/wiringPi/wiringPiSPI.h', + 'WiringPi/wiringPi/mcp23008.h', + 'WiringPi/wiringPi/mcp23s17.h', + 'WiringPi/wiringPi/mcp4802.h', + 'WiringPi/wiringPi/softTone.h', 'WiringPi/wiringPi/wiringSerial.h', - 'WiringPi/wiringPi/wiringShift.h' + 'WiringPi/wiringPi/mcp23016.h', + 'WiringPi/wiringPi/mcp23x0817.h', + 'WiringPi/wiringPi/pcf8574.h', + 'WiringPi/wiringPi/sr595.h', + 'WiringPi/wiringPi/wiringShift.h', + 'WiringPi/wiringPi/mcp23016reg.h', + 'WiringPi/wiringPi/mcp23x08.h', + 'WiringPi/wiringPi/pcf8591.h', + 'WiringPi/wiringPi/wiringPi.h', + 'WiringPi/wiringPi/mcp23017.h', + 'WiringPi/wiringPi/mcp3002.h', + 'WiringPi/wiringPi/softPwm.h', + 'WiringPi/wiringPi/wiringPiI2C.h' ] ) diff --git a/wiringpi.i b/wiringpi.i index a38d5a0..7f97312 100644 --- a/wiringpi.i +++ b/wiringpi.i @@ -1,17 +1,20 @@ %module wiringpi2 %{ -#include "WiringPi/wiringPi/ds1302.h" -#include "WiringPi/wiringPi/gertboard.h" -#include "WiringPi/wiringPi/lcd.h" +#include "WiringPi/devLib/font.h" +#include "WiringPi/devLib/maxdetect.h" +#include "WiringPi/devLib/ds1302.h" +#include "WiringPi/devLib/gertboard.h" +#include "WiringPi/devLib/lcd.h" +#include "WiringPi/devLib/lcd128x64.h" #include "WiringPi/wiringPi/mcp23008.h" #include "WiringPi/wiringPi/mcp23017.h" #include "WiringPi/wiringPi/mcp23s08.h" #include "WiringPi/wiringPi/mcp23s17.h" #include "WiringPi/wiringPi/mcp23x0817.h" #include "WiringPi/wiringPi/mcp23x08.h" -#include "WiringPi/wiringPi/piFace.h" -#include "WiringPi/wiringPi/piNes.h" +#include "WiringPi/devLib/piFace.h" +#include "WiringPi/devLib/piNes.h" #include "WiringPi/wiringPi/softPwm.h" #include "WiringPi/wiringPi/softServo.h" #include "WiringPi/wiringPi/softTone.h" diff --git a/wiringpi2.pyc b/wiringpi2.pyc index cbde93d8045408091c64146507b85627ff8b5551..7f5ec4574d0e56b47a0883e0c34e75237d96d22a 100644 GIT binary patch delta 18 acmexzi}A}XMt0`Uyj&me&)&$Mn+pI}xd^ZT delta 18 acmexzi}A}XMt0`Uyj=gY6E?Ev<^ljzJO~c} diff --git a/wiringpi_wrap.c b/wiringpi_wrap.c index 9b23aa6..4ad515b 100644 --- a/wiringpi_wrap.c +++ b/wiringpi_wrap.c @@ -2966,17 +2966,20 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) -#include "WiringPi/wiringPi/ds1302.h" -#include "WiringPi/wiringPi/gertboard.h" -#include "WiringPi/wiringPi/lcd.h" +#include "WiringPi/devLib/font.h" +#include "WiringPi/devLib/maxdetect.h" +#include "WiringPi/devLib/ds1302.h" +#include "WiringPi/devLib/gertboard.h" +#include "WiringPi/devLib/lcd.h" +#include "WiringPi/devLib/lcd128x64.h" #include "WiringPi/wiringPi/mcp23008.h" #include "WiringPi/wiringPi/mcp23017.h" #include "WiringPi/wiringPi/mcp23s08.h" #include "WiringPi/wiringPi/mcp23s17.h" #include "WiringPi/wiringPi/mcp23x0817.h" #include "WiringPi/wiringPi/mcp23x08.h" -#include "WiringPi/wiringPi/piFace.h" -#include "WiringPi/wiringPi/piNes.h" +#include "WiringPi/devLib/piFace.h" +#include "WiringPi/devLib/piNes.h" #include "WiringPi/wiringPi/softPwm.h" #include "WiringPi/wiringPi/softServo.h" #include "WiringPi/wiringPi/softTone.h" From 6ae3e5b52e5a6636ff87e1654dbd3115ac7699b6 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Tue, 21 May 2013 22:48:41 +0100 Subject: [PATCH 02/15] Function bindings for all the things --- .gitignore | 2 +- functions.txt | 113 ++++ wiringpi.i | 133 +++-- wiringpi2.py | 168 +++++- wiringpi2.pyc | Bin 28020 -> 35770 bytes wiringpi_wrap.c | 1466 +++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 1782 insertions(+), 100 deletions(-) create mode 100644 functions.txt diff --git a/.gitignore b/.gitignore index a53473d..718abe0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ build/ wiringpi2.egg-info/ dist/ __pycache__ -.pyc +*.pyc diff --git a/functions.txt b/functions.txt new file mode 100644 index 0000000..106d9db --- /dev/null +++ b/functions.txt @@ -0,0 +1,113 @@ +extern unsigned int ds1302rtcRead (const int reg) ; +extern void ds1302rtcWrite (const int reg, const unsigned int data) ; +extern unsigned int ds1302ramRead (const int addr) ; +extern void ds1302ramWrite (const int addr, const unsigned int data) ; +extern void ds1302clockRead (int clockData [8]) ; +extern void ds1302clockWrite (const int clockData [8]) ; +extern void ds1302trickleCharge (const int diodes, const int resistors) ; +extern void ds1302setup (const int clockPin, const int dataPin, const int csPin) ; +extern void gertboardAnalogWrite (const int chan, const int value) ; +extern int gertboardAnalogRead (const int chan) ; +extern int gertboardSPISetup (void) ; +extern int gertboardAnalogSetup (const int pinBase) ; +extern void lcd128x64setOrigin (int x, int y) ; +extern void lcd128x64setOrientation (int orientation) ; +extern void lcd128x64orientCoordinates (int *x, int *y) ; +extern void lcd128x64getScreenSize (int *x, int *y) ; +extern void lcd128x64point (int x, int y, int colour) ; +extern void lcd128x64line (int x0, int y0, int x1, int y1, int colour) ; +extern void lcd128x64lineTo (int x, int y, int colour) ; +extern void lcd128x64rectangle (int x1, int y1, int x2, int y2, int colour, int filled) ; +extern void lcd128x64circle (int x, int y, int r, int colour, int filled) ; +extern void lcd128x64ellipse (int cx, int cy, int xRadius, int yRadius, int colour, int filled) ; +extern void lcd128x64putchar (int x, int y, int c, int bgCol, int fgCol) ; +extern void lcd128x64puts (int x, int y, const char *str, int bgCol, int fgCol) ; +extern void lcd128x64update (void) ; +extern void lcd128x64clear (int colour) ; +extern int lcd128x64setup (void) ; +extern void lcdHome (const int fd) ; +extern void lcdClear (const int fd) ; +extern void lcdDisplay (const int fd, int state) ; +extern void lcdCursor (const int fd, int state) ; +extern void lcdCursorBlink (const int fd, int state) ; +extern void lcdSendCommand (const int fd, unsigned char command) ; +extern void lcdPosition (const int fd, int x, int y) ; +extern void lcdCharDef (const int fd, int index, unsigned char data [8]) ; +extern void lcdPutchar (const int fd, unsigned char data) ; +extern void lcdPuts (const int fd, const char *string) ; +extern void lcdPrintf (const int fd, const char *message, ...) ; +extern int lcdInit (const int rows, const int cols, const int bits, +extern int piFaceSetup (const int pinBase) ; +extern int setupNesJoystick (int dPin, int cPin, int lPin) ; +extern unsigned int readNesJoystick (int joystick) ; +extern int doExtension (char *progName, char *extensionData) ; +extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; +extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ; +extern int mcp3002Setup (int pinBase, int spiChannel) ; +extern int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int gain) ; +extern int mcp4802Setup (int pinBase, int spiChannel) ; +extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; +extern int pcf8591Setup (const int pinBase, const int i2cAddress) ; +extern int softPwmCreate (int pin, int value, int range) ; +extern void softPwmWrite (int pin, int value) ; +extern void softServoWrite (int pin, int value) ; +extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ; +extern int softToneCreate (int pin) ; +extern void softToneWrite (int pin, int freq) ; +extern int sr595Setup (const int pinBase, const int numPins, +extern int wiringPiFailure (int fatal, const char *message, ...) ; +extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; +extern int wiringPiSetup (void) ; +extern int wiringPiSetupSys (void) ; +extern int wiringPiSetupGpio (void) ; +extern int wiringPiSetupPhys (void) ; +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) ; +extern int wiringPiSetupPiFace (void) ; +extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only +extern int piBoardRev (void) ; +extern int wpiPinToGpio (int wpiPin) ; +extern int physPinToGpio (int physPin) ; +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) ; +extern int waitForInterrupt (int pin, int mS) ; +extern int wiringPiISR (int pin, int mode, void (*function)(void)) ; +extern int piThreadCreate (void *(*fn)(void *)) ; +extern void piLock (int key) ; +extern void piUnlock (int key) ; +extern int piHiPri (const int pri) ; +extern void delay (unsigned int howLong) ; +extern void delayMicroseconds (unsigned int howLong) ; +extern unsigned int millis (void) ; +extern unsigned int micros (void) ; +extern int wiringPiI2CRead (int fd) ; +extern int wiringPiI2CReadReg8 (int fd, int reg) ; +extern int wiringPiI2CReadReg16 (int fd, int reg) ; +extern int wiringPiI2CWrite (int fd, int data) ; +extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; +extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; +extern int wiringPiI2CSetupInterface (const char *device, int devId) ; +extern int wiringPiI2CSetup (const int devId) ; +extern int serialOpen (const char *device, const int baud) ; +extern void serialClose (const int fd) ; +extern void serialFlush (const int fd) ; +extern void serialPutchar (const int fd, const unsigned char c) ; +extern void serialPuts (const int fd, const char *s) ; +extern void serialPrintf (const int fd, const char *message, ...) ; +extern int serialDataAvail (const int fd) ; +extern int serialGetchar (const int fd) ; +extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ; +extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ; diff --git a/wiringpi.i b/wiringpi.i index 7f97312..1cf28e1 100644 --- a/wiringpi.i +++ b/wiringpi.i @@ -1,29 +1,37 @@ %module wiringpi2 %{ -#include "WiringPi/devLib/font.h" -#include "WiringPi/devLib/maxdetect.h" -#include "WiringPi/devLib/ds1302.h" -#include "WiringPi/devLib/gertboard.h" -#include "WiringPi/devLib/lcd.h" -#include "WiringPi/devLib/lcd128x64.h" -#include "WiringPi/wiringPi/mcp23008.h" +#include "WiringPi/wiringPi/wiringPi.h" +#include "WiringPi/wiringPi/wiringPiSPI.h" +#include "WiringPi/wiringPi/wiringPiI2C.h" +#include "WiringPi/wiringPi/wiringSerial.h" +#include "WiringPi/wiringPi/wiringShift.h" #include "WiringPi/wiringPi/mcp23017.h" +#include "WiringPi/wiringPi/mcp4802.h" +#include "WiringPi/wiringPi/mcp3422.h" #include "WiringPi/wiringPi/mcp23s08.h" -#include "WiringPi/wiringPi/mcp23s17.h" -#include "WiringPi/wiringPi/mcp23x0817.h" +#include "WiringPi/wiringPi/mcp23008.h" #include "WiringPi/wiringPi/mcp23x08.h" -#include "WiringPi/devLib/piFace.h" -#include "WiringPi/devLib/piNes.h" +#include "WiringPi/wiringPi/mcp23016.h" +#include "WiringPi/wiringPi/mcp3002.h" +#include "WiringPi/wiringPi/mcp23016reg.h" +#include "WiringPi/wiringPi/mcp23x0817.h" +#include "WiringPi/wiringPi/mcp23s17.h" +#include "WiringPi/wiringPi/pcf8574.h" +#include "WiringPi/wiringPi/pcf8591.h" +#include "WiringPi/wiringPi/drc.h" #include "WiringPi/wiringPi/softPwm.h" #include "WiringPi/wiringPi/softServo.h" #include "WiringPi/wiringPi/softTone.h" #include "WiringPi/wiringPi/sr595.h" -#include "WiringPi/wiringPi/wiringPi.h" -#include "WiringPi/wiringPi/wiringPiI2C.h" -#include "WiringPi/wiringPi/wiringPiSPI.h" -#include "WiringPi/wiringPi/wiringSerial.h" -#include "WiringPi/wiringPi/wiringShift.h" +#include "WiringPi/devLib/gertboard.h" +#include "WiringPi/devLib/lcd128x64.h" +#include "WiringPi/devLib/font.h" +#include "WiringPi/devLib/lcd.h" +#include "WiringPi/devLib/maxdetect.h" +#include "WiringPi/devLib/piFace.h" +#include "WiringPi/devLib/ds1302.h" +#include "WiringPi/devLib/piNes.h" %} %apply unsigned char { uint8_t }; @@ -35,7 +43,7 @@ extern int wiringPiSetupSys (void) ; extern int wiringPiSetupGpio (void) ; extern int wiringPiSetupPhys (void) ; -extern int piFaceSetup (int pinbase) ; +extern int piFaceSetup (const int pinBase) ; extern void pinMode (int pin, int mode) ; extern void pullUpDnControl (int pin, int pud) ; @@ -81,14 +89,14 @@ extern unsigned int micros (void) ; // WiringSerial -extern int serialOpen (char *device, int baud) ; -extern void serialClose (int fd) ; -extern void serialFlush (int fd) ; -extern void serialPutchar (int fd, unsigned char c) ; -extern void serialPuts (int fd, char *s) ; -extern void serialPrintf (int fd, char *message, ...) ; -extern int serialDataAvail (int fd) ; -extern int serialGetchar (int fd) ; +extern int serialOpen (const char *device, const int baud) ; +extern void serialClose (const int fd) ; +extern void serialFlush (const int fd) ; +extern void serialPutchar (const int fd, const unsigned char c) ; +extern void serialPuts (const int fd, const char *s) ; +extern void serialPrintf (const int fd, const char *message, ...) ; +extern int serialDataAvail (const int fd) ; +extern int serialGetchar (const int fd) ; // Shifting @@ -134,24 +142,73 @@ extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int extern int softPwmCreate (int pin, int value, int range) ; extern void softPwmWrite (int pin, int value) ; +// MCP and stuff +extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ; -extern int mcp23017Setup (int pinBase, int i2cAddress) ; - -extern int mcp23s08Setup (int pinBase, int spiPort, int devId) ; -extern int mcp23008Setup (int pinBase, int i2cAddress) ; +extern int mcp3002Setup (int pinBase, int spiChannel) ; +extern int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int gain) ; +extern int mcp4802Setup (int pinBase, int spiChannel) ; +extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; +extern int pcf8591Setup (const int pinBase, const 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, +// LCD +extern void lcdHome (const int fd) ; +extern void lcdClear (const int fd) ; +extern void lcdDisplay (const int fd, int state) ; +extern void lcdCursor (const int fd, int state) ; +extern void lcdCursorBlink (const int fd, int state) ; +extern void lcdSendCommand (const int fd, unsigned char command) ; +extern void lcdPosition (const int fd, int x, int y) ; +extern void lcdCharDef (const int fd, int index, unsigned char data [8]) ; +extern void lcdPutchar (const int fd, unsigned char data) ; +extern void lcdPuts (const int fd, const char *string) ; +extern void lcdPrintf (const int fd, const 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) ; +// ds1302 +extern unsigned int ds1302rtcRead (const int reg) ; +extern void ds1302rtcWrite (const int reg, const unsigned int data) ; +extern unsigned int ds1302ramRead (const int addr) ; +extern void ds1302ramWrite (const int addr, const unsigned int data) ; +extern void ds1302clockRead (int clockData [8]) ; +extern void ds1302clockWrite (const int clockData [8]) ; +extern void ds1302trickleCharge (const int diodes, const int resistors) ; +extern void ds1302setup (const int clockPin, const int dataPin, const int csPin) ; + +// Gertboard +extern void gertboardAnalogWrite (const int chan, const int value) ; +extern int gertboardAnalogRead (const int chan) ; +extern int gertboardSPISetup (void) ; +extern int gertboardAnalogSetup (const int pinBase) ; + +// LCD128x64 +extern void lcd128x64setOrigin (int x, int y) ; +extern void lcd128x64setOrientation (int orientation) ; +extern void lcd128x64orientCoordinates (int *x, int *y) ; +extern void lcd128x64getScreenSize (int *x, int *y) ; +extern void lcd128x64point (int x, int y, int colour) ; +extern void lcd128x64line (int x0, int y0, int x1, int y1, int colour) ; +extern void lcd128x64lineTo (int x, int y, int colour) ; +extern void lcd128x64rectangle (int x1, int y1, int x2, int y2, int colour, int filled) ; +extern void lcd128x64circle (int x, int y, int r, int colour, int filled) ; +extern void lcd128x64ellipse (int cx, int cy, int xRadius, int yRadius, int colour, int filled) ; +extern void lcd128x64putchar (int x, int y, int c, int bgCol, int fgCol) ; +extern void lcd128x64puts (int x, int y, const char *str, int bgCol, int fgCol) ; +extern void lcd128x64update (void) ; +extern void lcd128x64clear (int colour) ; +extern int lcd128x64setup (void) ; + +// NES Joystick +extern int setupNesJoystick (int dPin, int cPin, int lPin) ; +extern unsigned int readNesJoystick (int joystick) ; + + + %include "wiringpi2-class.py" diff --git a/wiringpi2.py b/wiringpi2.py index 2940572..098fec2 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -296,9 +296,13 @@ def softPwmWrite(*args): return _wiringpi2.softPwmWrite(*args) softPwmWrite = _wiringpi2.softPwmWrite -def mcp23s17Setup(*args): - return _wiringpi2.mcp23s17Setup(*args) -mcp23s17Setup = _wiringpi2.mcp23s17Setup +def mcp23008Setup(*args): + return _wiringpi2.mcp23008Setup(*args) +mcp23008Setup = _wiringpi2.mcp23008Setup + +def mcp23016Setup(*args): + return _wiringpi2.mcp23016Setup(*args) +mcp23016Setup = _wiringpi2.mcp23016Setup def mcp23017Setup(*args): return _wiringpi2.mcp23017Setup(*args) @@ -308,9 +312,29 @@ def mcp23s08Setup(*args): return _wiringpi2.mcp23s08Setup(*args) mcp23s08Setup = _wiringpi2.mcp23s08Setup -def mcp23008Setup(*args): - return _wiringpi2.mcp23008Setup(*args) -mcp23008Setup = _wiringpi2.mcp23008Setup +def mcp23s17Setup(*args): + return _wiringpi2.mcp23s17Setup(*args) +mcp23s17Setup = _wiringpi2.mcp23s17Setup + +def mcp3002Setup(*args): + return _wiringpi2.mcp3002Setup(*args) +mcp3002Setup = _wiringpi2.mcp3002Setup + +def mcp3422Setup(*args): + return _wiringpi2.mcp3422Setup(*args) +mcp3422Setup = _wiringpi2.mcp3422Setup + +def mcp4802Setup(*args): + return _wiringpi2.mcp4802Setup(*args) +mcp4802Setup = _wiringpi2.mcp4802Setup + +def pcf8574Setup(*args): + return _wiringpi2.pcf8574Setup(*args) +pcf8574Setup = _wiringpi2.pcf8574Setup + +def pcf8591Setup(*args): + return _wiringpi2.pcf8591Setup(*args) +pcf8591Setup = _wiringpi2.pcf8591Setup def sr595Setup(*args): return _wiringpi2.sr595Setup(*args) @@ -324,6 +348,18 @@ def lcdClear(*args): return _wiringpi2.lcdClear(*args) lcdClear = _wiringpi2.lcdClear +def lcdDisplay(*args): + return _wiringpi2.lcdDisplay(*args) +lcdDisplay = _wiringpi2.lcdDisplay + +def lcdCursor(*args): + return _wiringpi2.lcdCursor(*args) +lcdCursor = _wiringpi2.lcdCursor + +def lcdCursorBlink(*args): + return _wiringpi2.lcdCursorBlink(*args) +lcdCursorBlink = _wiringpi2.lcdCursorBlink + def lcdSendCommand(*args): return _wiringpi2.lcdSendCommand(*args) lcdSendCommand = _wiringpi2.lcdSendCommand @@ -332,6 +368,10 @@ def lcdPosition(*args): return _wiringpi2.lcdPosition(*args) lcdPosition = _wiringpi2.lcdPosition +def lcdCharDef(*args): + return _wiringpi2.lcdCharDef(*args) +lcdCharDef = _wiringpi2.lcdCharDef + def lcdPutchar(*args): return _wiringpi2.lcdPutchar(*args) lcdPutchar = _wiringpi2.lcdPutchar @@ -347,6 +387,122 @@ lcdPrintf = _wiringpi2.lcdPrintf def lcdInit(*args): return _wiringpi2.lcdInit(*args) lcdInit = _wiringpi2.lcdInit + +def ds1302rtcRead(*args): + return _wiringpi2.ds1302rtcRead(*args) +ds1302rtcRead = _wiringpi2.ds1302rtcRead + +def ds1302rtcWrite(*args): + return _wiringpi2.ds1302rtcWrite(*args) +ds1302rtcWrite = _wiringpi2.ds1302rtcWrite + +def ds1302ramRead(*args): + return _wiringpi2.ds1302ramRead(*args) +ds1302ramRead = _wiringpi2.ds1302ramRead + +def ds1302ramWrite(*args): + return _wiringpi2.ds1302ramWrite(*args) +ds1302ramWrite = _wiringpi2.ds1302ramWrite + +def ds1302clockRead(*args): + return _wiringpi2.ds1302clockRead(*args) +ds1302clockRead = _wiringpi2.ds1302clockRead + +def ds1302clockWrite(*args): + return _wiringpi2.ds1302clockWrite(*args) +ds1302clockWrite = _wiringpi2.ds1302clockWrite + +def ds1302trickleCharge(*args): + return _wiringpi2.ds1302trickleCharge(*args) +ds1302trickleCharge = _wiringpi2.ds1302trickleCharge + +def ds1302setup(*args): + return _wiringpi2.ds1302setup(*args) +ds1302setup = _wiringpi2.ds1302setup + +def gertboardAnalogWrite(*args): + return _wiringpi2.gertboardAnalogWrite(*args) +gertboardAnalogWrite = _wiringpi2.gertboardAnalogWrite + +def gertboardAnalogRead(*args): + return _wiringpi2.gertboardAnalogRead(*args) +gertboardAnalogRead = _wiringpi2.gertboardAnalogRead + +def gertboardSPISetup(): + return _wiringpi2.gertboardSPISetup() +gertboardSPISetup = _wiringpi2.gertboardSPISetup + +def gertboardAnalogSetup(*args): + return _wiringpi2.gertboardAnalogSetup(*args) +gertboardAnalogSetup = _wiringpi2.gertboardAnalogSetup + +def lcd128x64setOrigin(*args): + return _wiringpi2.lcd128x64setOrigin(*args) +lcd128x64setOrigin = _wiringpi2.lcd128x64setOrigin + +def lcd128x64setOrientation(*args): + return _wiringpi2.lcd128x64setOrientation(*args) +lcd128x64setOrientation = _wiringpi2.lcd128x64setOrientation + +def lcd128x64orientCoordinates(*args): + return _wiringpi2.lcd128x64orientCoordinates(*args) +lcd128x64orientCoordinates = _wiringpi2.lcd128x64orientCoordinates + +def lcd128x64getScreenSize(*args): + return _wiringpi2.lcd128x64getScreenSize(*args) +lcd128x64getScreenSize = _wiringpi2.lcd128x64getScreenSize + +def lcd128x64point(*args): + return _wiringpi2.lcd128x64point(*args) +lcd128x64point = _wiringpi2.lcd128x64point + +def lcd128x64line(*args): + return _wiringpi2.lcd128x64line(*args) +lcd128x64line = _wiringpi2.lcd128x64line + +def lcd128x64lineTo(*args): + return _wiringpi2.lcd128x64lineTo(*args) +lcd128x64lineTo = _wiringpi2.lcd128x64lineTo + +def lcd128x64rectangle(*args): + return _wiringpi2.lcd128x64rectangle(*args) +lcd128x64rectangle = _wiringpi2.lcd128x64rectangle + +def lcd128x64circle(*args): + return _wiringpi2.lcd128x64circle(*args) +lcd128x64circle = _wiringpi2.lcd128x64circle + +def lcd128x64ellipse(*args): + return _wiringpi2.lcd128x64ellipse(*args) +lcd128x64ellipse = _wiringpi2.lcd128x64ellipse + +def lcd128x64putchar(*args): + return _wiringpi2.lcd128x64putchar(*args) +lcd128x64putchar = _wiringpi2.lcd128x64putchar + +def lcd128x64puts(*args): + return _wiringpi2.lcd128x64puts(*args) +lcd128x64puts = _wiringpi2.lcd128x64puts + +def lcd128x64update(): + return _wiringpi2.lcd128x64update() +lcd128x64update = _wiringpi2.lcd128x64update + +def lcd128x64clear(*args): + return _wiringpi2.lcd128x64clear(*args) +lcd128x64clear = _wiringpi2.lcd128x64clear + +def lcd128x64setup(): + return _wiringpi2.lcd128x64setup() +lcd128x64setup = _wiringpi2.lcd128x64setup + +def setupNesJoystick(*args): + return _wiringpi2.setupNesJoystick(*args) +setupNesJoystick = _wiringpi2.setupNesJoystick + +def readNesJoystick(*args): + return _wiringpi2.readNesJoystick(*args) +readNesJoystick = _wiringpi2.readNesJoystick class nes(object): def setupNesJoystick(self,*args): return setupNesJoystick(*args) diff --git a/wiringpi2.pyc b/wiringpi2.pyc index 7f5ec4574d0e56b47a0883e0c34e75237d96d22a..9735e5b3daceeb1a54af06a522a90f0b27f75f14 100644 GIT binary patch delta 3438 zcmZveX>43q701uJ&P*0N&N>M=G-|7&7=a*hyeFhd#z~VVP3`CXdKo{@eKUTU)o*6J zCb6>-Xi2l&7AJM6)21|~Y1)K|hyV$Y_<&G9fCLh#NFY?iz6gpyg3@x%dGU+`Sn=`y z{LcR_@4ox)&EMWOzCI(imb|-s+0Nh1wuIr{j}QOu#NW)1mH;UHXFwbvVSqHiunkZr zFKnGLPThWMv2W@WfNTf51P-^8Q0+jZgGmPo)xo5bNhiooP@PP=m~?^c0@cN&n@Kmw zZcyD!Bohfzf|5*nnDl_`0o4Pirf{%cM!h6dFPr+9^nvUH)yJftNk7PbQ2k6oOhO<- zph8Rrm<)g%05!nGVq$@`Kv_%%nGAv)1T~0c3S^j3n1l+mNik6%6)45TW@3Z1LD@_q zOd=p7pdw77Orjv8prTBMm<)j&0yV_MVd8*vKsiLFQac{ranTYlK|cF2&kj;^jLu&1%;z|-syQ- zDUX3VK95h#W9iLn8ss!6KeSe!&e!@!KB;fkhIDDoA){8`s_oTZtvRSWYeL$pJ*Wj% z%IbppP|Z^PdUZ(OsSB2t;WwBFr?+n2T*dzG`XZ~Y^4JGOR$YJ3cca1crNfc>n!0Lk z+t#>%HEdz_USsfL#UkBWXXzKW1@)ub7VG!xdi1{SL4Bn@tpB)uh2BtCzbqbBO-?2q zx5o8D>pFcd&I;$edB^glsIVB!xtWy9wG5Il)^?W{`0luqjBzoG#V8f^-Ui#3!z@PK z=sz_?d?T2p^s2huG+J=Ta+~Z3HyXu4h6;MN(ejO9HmZ$nSAFBCCb{`9w<+HQW>d)b z=!@HXe3O`+q}r&UZ{1tPF5TBUB07Od-}iIT8Tp2 zV^}}8u&tFSw8g^+G__r`0+rWyIGzf}3azJ+&#+_V{foWd88Fh32T8Z4JA&oosa`com<<>UYq`o7J0LI^`s@+{x#$_+9E`CGDZY z^l>wD+p`GYqB6hgg=M=f#T`6@j_;G>{^xh?aMnsjvj*fX3* z{9_)5_DjKF$Ky^q!(CiJ{!?<4-{(l{xyC-WEK)dbTl~5EpTpwsx&7*Ll!XECCEwd8UqJk4nt`@I9ngz5cKBwH zyvtvmU|Gx|bjh%NupR;bpvMEOU_@NWap0f7RH%0(E>0EJBys7LdX zUUi_|cNyhB^Y8CyHpC*Kn|JOsX7z=gap9+Ao4^3W!jA9ixghcEoII6?O>TG7y38BJvi=kOLu#AF&0B1WyeFI z)j0e4C!mvk!4r605Tm}$D-^y+;ROnF6s}UZM&V_8QvdTPLFDW9e8Ldxgg)L^qo3dF zh!1(P@v$LMF)s&n!@e@{5idQmFCjL1^1=O%c+ivI-k%T;ds01~eDsk8Q(Z=578m;! zO0QFRmBN=Pyhh;$h1V(ELEq}ysN0&A=n(pe zmMZ;+=8)(jc|k~T8Ua&@KCgJw42c1c23wUF^yJS_Do>8LDG~AHb*aPI9&Tfn5#-lQ|#q+{EpbJ;vkfsR*`j!~1&N|R1Q p^EnE1u-!X(NYTM#(l=?+zBk{{cVj8zSNToxCPSyOpy~hs delta 1327 zcmZ9MZ)jUp7{BShsqb(fq{==i2;vBWR?$uTvrVB6k?BCDOb05cV=^X8^gZWx1-;}x_jjK6 z$$N6ny}8TB_@5VGOU2cibyqIFyeq_34>w)A>CAdG#sqzU#TbhN^8*75m>6E%atuaJ zd|v6Ev#QxRIRoqvV+R=<@((bvhpoDUYwjK$xa_`?-f|z<@EWZH-O7swaEPw4R)Q}G0V=Sc3RmT$?2>e2~FYyQ^W2o z6%72+-&$|i5@sw@{6AuoZ{lR2QIlcaM%Xam&Jd24e+u*ip8)JOI<$US%;N#W!1E(D zJnFc+*4&y(!mwqBCd^FCDL(e!Vk)PK30dq0*(%IafWH`-hCC%(DrCG-%8Zm*Ob3T~ z25=?VTde}}7U+#+_hZtm=6S#wbCb3jex-DWR*-=?xd1IkD4=}X*gXLIXagR?1EC1a zC^{*E_`TtB%iSofIx#3J3R!V@N>Sx_1P&>BZ9ES1iXIIocnR>m@Fx7Wv>9C+bgf7e zO+$J2#I*`F{~Lgh$4>Bf0L_dSJK};b10Ihr^7rNCK^#vQ@PTS}BO&-H$2^)e;A3Up zof7b=qECoUD+;CsoKg8vP8vd|7uG}DGVN(~quFM44TPl-@f zEF^q=mYLzoi>VB~5131h<7ynIv8KieId&yvi^b6#`BN-p4=&uql{r;R)1%Jpqh zh7 diff --git a/wiringpi_wrap.c b/wiringpi_wrap.c index 4ad515b..fefd55e 100644 --- a/wiringpi_wrap.c +++ b/wiringpi_wrap.c @@ -2932,9 +2932,10 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { #define SWIGTYPE_p_f_int_int__int swig_types[1] #define SWIGTYPE_p_f_p_void__p_void swig_types[2] #define SWIGTYPE_p_f_void__void swig_types[3] -#define SWIGTYPE_p_unsigned_char swig_types[4] -static swig_type_info *swig_types[6]; -static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; +#define SWIGTYPE_p_int swig_types[4] +#define SWIGTYPE_p_unsigned_char swig_types[5] +static swig_type_info *swig_types[7]; +static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2966,29 +2967,37 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) -#include "WiringPi/devLib/font.h" -#include "WiringPi/devLib/maxdetect.h" -#include "WiringPi/devLib/ds1302.h" -#include "WiringPi/devLib/gertboard.h" -#include "WiringPi/devLib/lcd.h" -#include "WiringPi/devLib/lcd128x64.h" -#include "WiringPi/wiringPi/mcp23008.h" +#include "WiringPi/wiringPi/wiringPi.h" +#include "WiringPi/wiringPi/wiringPiSPI.h" +#include "WiringPi/wiringPi/wiringPiI2C.h" +#include "WiringPi/wiringPi/wiringSerial.h" +#include "WiringPi/wiringPi/wiringShift.h" #include "WiringPi/wiringPi/mcp23017.h" +#include "WiringPi/wiringPi/mcp4802.h" +#include "WiringPi/wiringPi/mcp3422.h" #include "WiringPi/wiringPi/mcp23s08.h" -#include "WiringPi/wiringPi/mcp23s17.h" -#include "WiringPi/wiringPi/mcp23x0817.h" +#include "WiringPi/wiringPi/mcp23008.h" #include "WiringPi/wiringPi/mcp23x08.h" -#include "WiringPi/devLib/piFace.h" -#include "WiringPi/devLib/piNes.h" +#include "WiringPi/wiringPi/mcp23016.h" +#include "WiringPi/wiringPi/mcp3002.h" +#include "WiringPi/wiringPi/mcp23016reg.h" +#include "WiringPi/wiringPi/mcp23x0817.h" +#include "WiringPi/wiringPi/mcp23s17.h" +#include "WiringPi/wiringPi/pcf8574.h" +#include "WiringPi/wiringPi/pcf8591.h" +#include "WiringPi/wiringPi/drc.h" #include "WiringPi/wiringPi/softPwm.h" #include "WiringPi/wiringPi/softServo.h" #include "WiringPi/wiringPi/softTone.h" #include "WiringPi/wiringPi/sr595.h" -#include "WiringPi/wiringPi/wiringPi.h" -#include "WiringPi/wiringPi/wiringPiI2C.h" -#include "WiringPi/wiringPi/wiringPiSPI.h" -#include "WiringPi/wiringPi/wiringSerial.h" -#include "WiringPi/wiringPi/wiringShift.h" +#include "WiringPi/devLib/gertboard.h" +#include "WiringPi/devLib/lcd128x64.h" +#include "WiringPi/devLib/font.h" +#include "WiringPi/devLib/lcd.h" +#include "WiringPi/devLib/maxdetect.h" +#include "WiringPi/devLib/piFace.h" +#include "WiringPi/devLib/ds1302.h" +#include "WiringPi/devLib/piNes.h" SWIGINTERNINLINE PyObject* @@ -4036,7 +4045,7 @@ SWIGINTERN PyObject *_wrap_serialOpen(PyObject *SWIGUNUSEDPARM(self), PyObject * if (!PyArg_ParseTuple(args,(char *)"OO:serialOpen",&obj0,&obj1)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "serialOpen" "', argument " "1"" of type '" "char *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "serialOpen" "', argument " "1"" of type '" "char const *""'"); } arg1 = (char *)(buf1); ecode2 = SWIG_AsVal_int(obj1, &val2); @@ -4044,7 +4053,7 @@ SWIGINTERN PyObject *_wrap_serialOpen(PyObject *SWIGUNUSEDPARM(self), PyObject * SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "serialOpen" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); - result = (int)serialOpen(arg1,arg2); + result = (int)serialOpen((char const *)arg1,arg2); resultobj = SWIG_From_int((int)(result)); if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); return resultobj; @@ -4146,10 +4155,10 @@ SWIGINTERN PyObject *_wrap_serialPuts(PyObject *SWIGUNUSEDPARM(self), PyObject * arg1 = (int)(val1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "serialPuts" "', argument " "2"" of type '" "char *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "serialPuts" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); - serialPuts(arg1,arg2); + serialPuts(arg1,(char const *)arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; @@ -4180,10 +4189,10 @@ SWIGINTERN PyObject *_wrap_serialPrintf__varargs__(PyObject *SWIGUNUSEDPARM(self arg1 = (int)(val1); res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "serialPrintf" "', argument " "2"" of type '" "char *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "serialPrintf" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); - serialPrintf(arg1,arg2,arg3); + serialPrintf(arg1,(char const *)arg2,arg3); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; @@ -4909,39 +4918,61 @@ fail: } -SWIGINTERN PyObject *_wrap_mcp23s17Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_mcp23008Setup(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 ; int result; - if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s17Setup",&obj0,&obj1,&obj2)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:mcp23008Setup",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s17Setup" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23008Setup" "', 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 '" "mcp23s17Setup" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "mcp23008Setup" "', 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 '" "mcp23s17Setup" "', argument " "3"" of type '" "int""'"); + result = (int)mcp23008Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp23016Setup(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:mcp23016Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23016Setup" "', argument " "1"" of type '" "int""'"); } - arg3 = (int)(val3); - result = (int)mcp23s17Setup(arg1,arg2,arg3); + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "mcp23016Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp23016Setup(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -5020,7 +5051,47 @@ fail: } -SWIGINTERN PyObject *_wrap_mcp23008Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_mcp23s17Setup(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s17Setup",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s17Setup" "', 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 '" "mcp23s17Setup" "', 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 '" "mcp23s17Setup" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)mcp23s17Setup(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp3002Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int arg2 ; @@ -5032,18 +5103,169 @@ SWIGINTERN PyObject *_wrap_mcp23008Setup(PyObject *SWIGUNUSEDPARM(self), PyObjec PyObject * obj1 = 0 ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:mcp23008Setup",&obj0,&obj1)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:mcp3002Setup",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23008Setup" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp3002Setup" "', 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 '" "mcp23008Setup" "', argument " "2"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "mcp3002Setup" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); - result = (int)mcp23008Setup(arg1,arg2); + result = (int)mcp3002Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp3422Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:mcp3422Setup",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + result = (int)mcp3422Setup(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp4802Setup(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:mcp4802Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp4802Setup" "', 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 '" "mcp4802Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp4802Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pcf8574Setup(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:pcf8574Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pcf8574Setup" "', 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 '" "pcf8574Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)pcf8574Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pcf8591Setup(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:pcf8591Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pcf8591Setup" "', 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 '" "pcf8591Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)pcf8591Setup(arg1,arg2); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: @@ -5151,10 +5373,100 @@ fail: } +SWIGINTERN PyObject *_wrap_lcdDisplay(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:lcdDisplay",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdDisplay" "', 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 '" "lcdDisplay" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + lcdDisplay(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdCursor(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:lcdCursor",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCursor" "', 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 '" "lcdCursor" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + lcdCursor(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdCursorBlink(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:lcdCursorBlink",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCursorBlink" "', 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 '" "lcdCursorBlink" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + lcdCursorBlink(arg1,arg2); + 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 ; + unsigned char arg2 ; int val1 ; int ecode1 = 0 ; unsigned char val2 ; @@ -5170,9 +5482,9 @@ SWIGINTERN PyObject *_wrap_lcdSendCommand(PyObject *SWIGUNUSEDPARM(self), PyObje 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""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "lcdSendCommand" "', argument " "2"" of type '" "unsigned char""'"); } - arg2 = (uint8_t)(val2); + arg2 = (unsigned char)(val2); lcdSendCommand(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; @@ -5220,10 +5532,49 @@ fail: } +SWIGINTERN PyObject *_wrap_lcdCharDef(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + unsigned char *arg3 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:lcdCharDef",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCharDef" "', 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 '" "lcdCharDef" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "lcdCharDef" "', argument " "3"" of type '" "unsigned char [8]""'"); + } + arg3 = (unsigned char *)(argp3); + lcdCharDef(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 ; + unsigned char arg2 ; int val1 ; int ecode1 = 0 ; unsigned char val2 ; @@ -5239,9 +5590,9 @@ SWIGINTERN PyObject *_wrap_lcdPutchar(PyObject *SWIGUNUSEDPARM(self), PyObject * 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""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "lcdPutchar" "', argument " "2"" of type '" "unsigned char""'"); } - arg2 = (uint8_t)(val2); + arg2 = (unsigned char)(val2); lcdPutchar(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; @@ -5270,10 +5621,10 @@ SWIGINTERN PyObject *_wrap_lcdPuts(PyObject *SWIGUNUSEDPARM(self), PyObject *arg 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 *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "lcdPuts" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); - lcdPuts(arg1,arg2); + lcdPuts(arg1,(char const *)arg2); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; @@ -5304,10 +5655,10 @@ SWIGINTERN PyObject *_wrap_lcdPrintf__varargs__(PyObject *SWIGUNUSEDPARM(self), 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 *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "lcdPrintf" "', argument " "2"" of type '" "char const *""'"); } arg2 = (char *)(buf2); - lcdPrintf(arg1,arg2,arg3); + lcdPrintf(arg1,(char const *)arg2,arg3); resultobj = SWIG_Py_Void(); if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); return resultobj; @@ -5461,6 +5812,968 @@ fail: } +SWIGINTERN PyObject *_wrap_ds1302rtcRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + unsigned int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ds1302rtcRead",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ds1302rtcRead" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (unsigned int)ds1302rtcRead(arg1); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ds1302rtcWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + unsigned int arg2 ; + int val1 ; + int ecode1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ds1302rtcWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ds1302rtcWrite" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ds1302rtcWrite" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + ds1302rtcWrite(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ds1302ramRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + unsigned int result; + + if (!PyArg_ParseTuple(args,(char *)"O:ds1302ramRead",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ds1302ramRead" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (unsigned int)ds1302ramRead(arg1); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ds1302ramWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + unsigned int arg2 ; + int val1 ; + int ecode1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:ds1302ramWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ds1302ramWrite" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ds1302ramWrite" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + ds1302ramWrite(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ds1302clockRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ds1302clockRead",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ds1302clockRead" "', argument " "1"" of type '" "int [8]""'"); + } + arg1 = (int *)(argp1); + ds1302clockRead(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ds1302clockWrite(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:ds1302clockWrite",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ds1302clockWrite" "', argument " "1"" of type '" "int const [8]""'"); + } + arg1 = (int *)(argp1); + ds1302clockWrite((int const (*))arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ds1302trickleCharge(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:ds1302trickleCharge",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ds1302trickleCharge" "', 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 '" "ds1302trickleCharge" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ds1302trickleCharge(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ds1302setup(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:ds1302setup",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ds1302setup" "', 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 '" "ds1302setup" "', 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 '" "ds1302setup" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ds1302setup(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_gertboardAnalogWrite(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:gertboardAnalogWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gertboardAnalogWrite" "', 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 '" "gertboardAnalogWrite" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + gertboardAnalogWrite(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_gertboardAnalogRead(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:gertboardAnalogRead",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gertboardAnalogRead" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)gertboardAnalogRead(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_gertboardSPISetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":gertboardSPISetup")) SWIG_fail; + result = (int)gertboardSPISetup(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_gertboardAnalogSetup(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:gertboardAnalogSetup",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gertboardAnalogSetup" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)gertboardAnalogSetup(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64setOrigin(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:lcd128x64setOrigin",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64setOrigin" "', 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 '" "lcd128x64setOrigin" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + lcd128x64setOrigin(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64setOrientation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:lcd128x64setOrientation",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64setOrientation" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + lcd128x64setOrientation(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64orientCoordinates(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 = (int *) 0 ; + int *arg2 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:lcd128x64orientCoordinates",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "lcd128x64orientCoordinates" "', argument " "1"" of type '" "int *""'"); + } + arg1 = (int *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "lcd128x64orientCoordinates" "', argument " "2"" of type '" "int *""'"); + } + arg2 = (int *)(argp2); + lcd128x64orientCoordinates(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64getScreenSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 = (int *) 0 ; + int *arg2 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:lcd128x64getScreenSize",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "lcd128x64getScreenSize" "', argument " "1"" of type '" "int *""'"); + } + arg1 = (int *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "lcd128x64getScreenSize" "', argument " "2"" of type '" "int *""'"); + } + arg2 = (int *)(argp2); + lcd128x64getScreenSize(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64point(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:lcd128x64point",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64point" "', 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 '" "lcd128x64point" "', 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 '" "lcd128x64point" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + lcd128x64point(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64line(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:lcd128x64line",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64line" "', 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 '" "lcd128x64line" "', 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 '" "lcd128x64line" "', 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 '" "lcd128x64line" "', 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 '" "lcd128x64line" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + lcd128x64line(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64lineTo(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:lcd128x64lineTo",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64lineTo" "', 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 '" "lcd128x64lineTo" "', 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 '" "lcd128x64lineTo" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + lcd128x64lineTo(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64rectangle(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:lcd128x64rectangle",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64rectangle" "', 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 '" "lcd128x64rectangle" "', 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 '" "lcd128x64rectangle" "', 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 '" "lcd128x64rectangle" "', 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 '" "lcd128x64rectangle" "', 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 '" "lcd128x64rectangle" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + lcd128x64rectangle(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64circle(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:lcd128x64circle",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64circle" "', 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 '" "lcd128x64circle" "', 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 '" "lcd128x64circle" "', 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 '" "lcd128x64circle" "', 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 '" "lcd128x64circle" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + lcd128x64circle(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64ellipse(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:lcd128x64ellipse",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64ellipse" "', 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 '" "lcd128x64ellipse" "', 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 '" "lcd128x64ellipse" "', 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 '" "lcd128x64ellipse" "', 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 '" "lcd128x64ellipse" "', 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 '" "lcd128x64ellipse" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + lcd128x64ellipse(arg1,arg2,arg3,arg4,arg5,arg6); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64putchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:lcd128x64putchar",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64putchar" "', 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 '" "lcd128x64putchar" "', 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 '" "lcd128x64putchar" "', 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 '" "lcd128x64putchar" "', 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 '" "lcd128x64putchar" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + lcd128x64putchar(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64puts(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + char *arg3 = (char *) 0 ; + int arg4 ; + int arg5 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:lcd128x64puts",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64puts" "', 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 '" "lcd128x64puts" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "lcd128x64puts" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "lcd128x64puts" "', 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 '" "lcd128x64puts" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + lcd128x64puts(arg1,arg2,(char const *)arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64update(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + + if (!PyArg_ParseTuple(args,(char *)":lcd128x64update")) SWIG_fail; + lcd128x64update(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:lcd128x64clear",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcd128x64clear" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + lcd128x64clear(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcd128x64setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":lcd128x64setup")) SWIG_fail; + result = (int)lcd128x64setup(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_setupNesJoystick(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:setupNesJoystick",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "setupNesJoystick" "', 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 '" "setupNesJoystick" "', 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 '" "setupNesJoystick" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)setupNesJoystick(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_readNesJoystick(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + unsigned int result; + + if (!PyArg_ParseTuple(args,(char *)"O:readNesJoystick",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "readNesJoystick" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (unsigned int)readNesJoystick(arg1); + resultobj = SWIG_From_unsigned_SS_int((unsigned 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}, @@ -5520,19 +6833,58 @@ static PyMethodDef SwigMethods[] = { { (char *)"softServoSetup", _wrap_softServoSetup, METH_VARARGS, NULL}, { (char *)"softPwmCreate", _wrap_softPwmCreate, METH_VARARGS, NULL}, { (char *)"softPwmWrite", _wrap_softPwmWrite, METH_VARARGS, NULL}, - { (char *)"mcp23s17Setup", _wrap_mcp23s17Setup, METH_VARARGS, NULL}, + { (char *)"mcp23008Setup", _wrap_mcp23008Setup, METH_VARARGS, NULL}, + { (char *)"mcp23016Setup", _wrap_mcp23016Setup, METH_VARARGS, NULL}, { (char *)"mcp23017Setup", _wrap_mcp23017Setup, METH_VARARGS, NULL}, { (char *)"mcp23s08Setup", _wrap_mcp23s08Setup, METH_VARARGS, NULL}, - { (char *)"mcp23008Setup", _wrap_mcp23008Setup, METH_VARARGS, NULL}, + { (char *)"mcp23s17Setup", _wrap_mcp23s17Setup, METH_VARARGS, NULL}, + { (char *)"mcp3002Setup", _wrap_mcp3002Setup, METH_VARARGS, NULL}, + { (char *)"mcp3422Setup", _wrap_mcp3422Setup, METH_VARARGS, NULL}, + { (char *)"mcp4802Setup", _wrap_mcp4802Setup, METH_VARARGS, NULL}, + { (char *)"pcf8574Setup", _wrap_pcf8574Setup, METH_VARARGS, NULL}, + { (char *)"pcf8591Setup", _wrap_pcf8591Setup, 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 *)"lcdDisplay", _wrap_lcdDisplay, METH_VARARGS, NULL}, + { (char *)"lcdCursor", _wrap_lcdCursor, METH_VARARGS, NULL}, + { (char *)"lcdCursorBlink", _wrap_lcdCursorBlink, METH_VARARGS, NULL}, { (char *)"lcdSendCommand", _wrap_lcdSendCommand, METH_VARARGS, NULL}, { (char *)"lcdPosition", _wrap_lcdPosition, METH_VARARGS, NULL}, + { (char *)"lcdCharDef", _wrap_lcdCharDef, 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}, + { (char *)"ds1302rtcRead", _wrap_ds1302rtcRead, METH_VARARGS, NULL}, + { (char *)"ds1302rtcWrite", _wrap_ds1302rtcWrite, METH_VARARGS, NULL}, + { (char *)"ds1302ramRead", _wrap_ds1302ramRead, METH_VARARGS, NULL}, + { (char *)"ds1302ramWrite", _wrap_ds1302ramWrite, METH_VARARGS, NULL}, + { (char *)"ds1302clockRead", _wrap_ds1302clockRead, METH_VARARGS, NULL}, + { (char *)"ds1302clockWrite", _wrap_ds1302clockWrite, METH_VARARGS, NULL}, + { (char *)"ds1302trickleCharge", _wrap_ds1302trickleCharge, METH_VARARGS, NULL}, + { (char *)"ds1302setup", _wrap_ds1302setup, METH_VARARGS, NULL}, + { (char *)"gertboardAnalogWrite", _wrap_gertboardAnalogWrite, METH_VARARGS, NULL}, + { (char *)"gertboardAnalogRead", _wrap_gertboardAnalogRead, METH_VARARGS, NULL}, + { (char *)"gertboardSPISetup", _wrap_gertboardSPISetup, METH_VARARGS, NULL}, + { (char *)"gertboardAnalogSetup", _wrap_gertboardAnalogSetup, METH_VARARGS, NULL}, + { (char *)"lcd128x64setOrigin", _wrap_lcd128x64setOrigin, METH_VARARGS, NULL}, + { (char *)"lcd128x64setOrientation", _wrap_lcd128x64setOrientation, METH_VARARGS, NULL}, + { (char *)"lcd128x64orientCoordinates", _wrap_lcd128x64orientCoordinates, METH_VARARGS, NULL}, + { (char *)"lcd128x64getScreenSize", _wrap_lcd128x64getScreenSize, METH_VARARGS, NULL}, + { (char *)"lcd128x64point", _wrap_lcd128x64point, METH_VARARGS, NULL}, + { (char *)"lcd128x64line", _wrap_lcd128x64line, METH_VARARGS, NULL}, + { (char *)"lcd128x64lineTo", _wrap_lcd128x64lineTo, METH_VARARGS, NULL}, + { (char *)"lcd128x64rectangle", _wrap_lcd128x64rectangle, METH_VARARGS, NULL}, + { (char *)"lcd128x64circle", _wrap_lcd128x64circle, METH_VARARGS, NULL}, + { (char *)"lcd128x64ellipse", _wrap_lcd128x64ellipse, METH_VARARGS, NULL}, + { (char *)"lcd128x64putchar", _wrap_lcd128x64putchar, METH_VARARGS, NULL}, + { (char *)"lcd128x64puts", _wrap_lcd128x64puts, METH_VARARGS, NULL}, + { (char *)"lcd128x64update", _wrap_lcd128x64update, METH_VARARGS, NULL}, + { (char *)"lcd128x64clear", _wrap_lcd128x64clear, METH_VARARGS, NULL}, + { (char *)"lcd128x64setup", _wrap_lcd128x64setup, METH_VARARGS, NULL}, + { (char *)"setupNesJoystick", _wrap_setupNesJoystick, METH_VARARGS, NULL}, + { (char *)"readNesJoystick", _wrap_readNesJoystick, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; @@ -5543,6 +6895,7 @@ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_f_int_int__int = {"_p_f_int_int__int", "int (*)(int,int)", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_f_p_void__p_void = {"_p_f_p_void__p_void", "void *(*)(void *)", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_f_void__void = {"_p_f_void__void", "void (*)(void)", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { @@ -5550,6 +6903,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_f_int_int__int, &_swigt__p_f_p_void__p_void, &_swigt__p_f_void__void, + &_swigt__p_int, &_swigt__p_unsigned_char, }; @@ -5557,6 +6911,7 @@ static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, static swig_cast_info _swigc__p_f_int_int__int[] = { {&_swigt__p_f_int_int__int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_f_p_void__p_void[] = { {&_swigt__p_f_p_void__p_void, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_f_void__void[] = { {&_swigt__p_f_void__void, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { @@ -5564,6 +6919,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_f_int_int__int, _swigc__p_f_p_void__p_void, _swigc__p_f_void__void, + _swigc__p_int, _swigc__p_unsigned_char, }; From 0d8267f16bb15d0daa4c1d3ad0b7048d4e93ffda Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Wed, 22 May 2013 22:09:55 +0100 Subject: [PATCH 03/15] pointless modifications to order of files in setup.py, readme updated --- README.md | 6 ++++++ setup.py | 38 +++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 47630a1..274bd2a 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ Built against Python 2.7.2, Python 3.2.3 You must have python-dev and python-setuptools installed If you manually rebuild the bindings with swig -python wiringpi.i +YOU MUST FIRST INSTALL WIRINGPI2!! + +git clone git://git.drogon.net/wiringPi +cd wiringPi +sudo ./build + **Get/setup repo:** git clone https://github.com/Gadgetoid/WiringPi2-Python.git cd WiringPi2-Python diff --git a/setup.py b/setup.py index fd20293..17db3f1 100644 --- a/setup.py +++ b/setup.py @@ -5,13 +5,8 @@ from setuptools import setup, find_packages, Extension _wiringpi2 = Extension( '_wiringpi2', sources=[ - 'WiringPi/devLib/ds1302.c', - 'WiringPi/devLib/lcd128x64.c', - 'WiringPi/devLib/maxdetect.c', - 'WiringPi/devLib/gertboard.c', - 'WiringPi/devLib/lcd.c', - 'WiringPi/devLib/piFace.c', - 'WiringPi/devLib/piNes.c', + 'WiringPi/wiringPi/wiringPi.c', + 'WiringPi/wiringPi/wiringPiSPI.c', 'WiringPi/wiringPi/drc.c', 'WiringPi/wiringPi/mcp23s17.c', 'WiringPi/wiringPi/pcf8591.c', @@ -25,7 +20,6 @@ _wiringpi2 = Extension( 'WiringPi/wiringPi/mcp23016.c', 'WiringPi/wiringPi/mcp3422.c', 'WiringPi/wiringPi/piThread.c', - 'WiringPi/wiringPi/wiringPi.c', 'WiringPi/wiringPi/mcp23017.c', 'WiringPi/wiringPi/mcp4802.c', 'WiringPi/wiringPi/softPwm.c', @@ -33,7 +27,13 @@ _wiringpi2 = Extension( 'WiringPi/wiringPi/mcp23s08.c', 'WiringPi/wiringPi/pcf8574.c', 'WiringPi/wiringPi/softServo.c', - 'WiringPi/wiringPi/wiringPiSPI.c', + 'WiringPi/devLib/ds1302.c', + 'WiringPi/devLib/lcd128x64.c', + 'WiringPi/devLib/maxdetect.c', + 'WiringPi/devLib/gertboard.c', + 'WiringPi/devLib/lcd.c', + 'WiringPi/devLib/piFace.c', + 'WiringPi/devLib/piNes.c', 'wiringpi_wrap.c' ], ) @@ -52,14 +52,8 @@ setup( py_modules = ["wiringpi2"], install_requires=[], headers=[ - 'WiringPi/devLib/ds1302.h', - 'WiringPi/devLib/gertboard.h', - 'WiringPi/devLib/lcd.h', - 'WiringPi/devLib/piFace.h', - 'WiringPi/devLib/font.h', - 'WiringPi/devLib/lcd128x64.h', - 'WiringPi/devLib/maxdetect.h', - 'WiringPi/devLib/piNes.h', + 'WiringPi/wiringPi/wiringPi.h', + 'WiringPi/wiringPi/wiringPiI2C.h', 'WiringPi/wiringPi/drc.h', 'WiringPi/wiringPi/mcp23s08.h', 'WiringPi/wiringPi/mcp3422.h', @@ -78,10 +72,16 @@ setup( 'WiringPi/wiringPi/mcp23016reg.h', 'WiringPi/wiringPi/mcp23x08.h', 'WiringPi/wiringPi/pcf8591.h', - 'WiringPi/wiringPi/wiringPi.h', 'WiringPi/wiringPi/mcp23017.h', 'WiringPi/wiringPi/mcp3002.h', 'WiringPi/wiringPi/softPwm.h', - 'WiringPi/wiringPi/wiringPiI2C.h' + 'WiringPi/devLib/ds1302.h', + 'WiringPi/devLib/gertboard.h', + 'WiringPi/devLib/lcd.h', + 'WiringPi/devLib/piFace.h', + 'WiringPi/devLib/font.h', + 'WiringPi/devLib/lcd128x64.h', + 'WiringPi/devLib/maxdetect.h', + 'WiringPi/devLib/piNes.h' ] ) From 651295cac0803753b45d4d18856170c883d3429c Mon Sep 17 00:00:00 2001 From: William Pickering Date: Wed, 26 Jun 2013 15:54:50 +1000 Subject: [PATCH 04/15] Correct typo (sofPwmWrite -> softPwmWrite) --- wiringpi2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiringpi2.py b/wiringpi2.py index 098fec2..5fb5c37 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -658,7 +658,7 @@ class GPIO(object): def softPwmCreate(self,*args): return softPwmCreate(*args) def softPwmWrite(self,*args): - return sofPwmWrite(*args) + return softPwmWrite(*args) def softToneCreate(self,*args): return softToneCreate(*args) From d9fc85a610a30dafabbb3a9d092a3bf34c846ee2 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Tue, 13 Aug 2013 16:38:26 +0100 Subject: [PATCH 05/15] Partial update to latest WiringPi --- WiringPi/wiringPi/wiringPi.c | 70 +++++++++++++++++------ WiringPi/wiringPi/wiringPi.h | 6 +- setup.py | 10 ++++ wiringpi.i | 10 +++- wiringpi2.py | 14 ++++- wiringpi2.pyc | Bin 35770 -> 36351 bytes wiringpi_wrap.c | 106 +++++++++++++++++++++++++++++++++++ 7 files changed, 195 insertions(+), 21 deletions(-) diff --git a/WiringPi/wiringPi/wiringPi.c b/WiringPi/wiringPi/wiringPi.c index b8e381a..b54ad29 100644 --- a/WiringPi/wiringPi/wiringPi.c +++ b/WiringPi/wiringPi/wiringPi.c @@ -88,7 +88,7 @@ #define PI_GPIO_MASK (0xFFFFFFC0) -static struct wiringPiNodeStruct *wiringPiNodes = NULL ; +struct wiringPiNodeStruct *wiringPiNodes = NULL ; // BCM Magic @@ -118,7 +118,6 @@ static struct wiringPiNodeStruct *wiringPiNodes = NULL ; #define FSEL_INPT 0b000 #define FSEL_OUTP 0b001 #define FSEL_ALT0 0b100 -#define FSEL_ALT0 0b100 #define FSEL_ALT1 0b101 #define FSEL_ALT2 0b110 #define FSEL_ALT3 0b111 @@ -213,7 +212,13 @@ int wiringPiReturnCodes = FALSE ; // sysFds: // Map a file descriptor from the /sys/class/gpio/gpioX/value -static int sysFds [64] ; +static int sysFds [64] = +{ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +} ; // ISR Data @@ -833,7 +838,7 @@ void gpioClockSet (int pin, int freq) ********************************************************************************* */ -static struct wiringPiNodeStruct *wiringPiFindNode (int pin) +struct wiringPiNodeStruct *wiringPiFindNode (int pin) { struct wiringPiNodeStruct *node = wiringPiNodes ; @@ -919,6 +924,32 @@ void pinEnableED01Pi (int pin) ********************************************************************************* */ +/* + * pinModeAlt: + * This is an un-documented special to let you set any pin to any mode + ********************************************************************************* + */ + +void pinModeAlt (int pin, int mode) +{ + int fSel, shift ; + + if ((pin & PI_GPIO_MASK) == 0) // On-board pin + { + /**/ if (wiringPiMode == WPI_MODE_PINS) + pin = pinToGpio [pin] ; + else if (wiringPiMode == WPI_MODE_PHYS) + pin = physToGpio [pin] ; + else if (wiringPiMode != WPI_MODE_GPIO) + return ; + + fSel = gpioToGPFSEL [pin] ; + shift = gpioToShift [pin] ; + + *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | ((mode & 0x7) << shift) ; + } +} + /* * pinMode: @@ -1304,7 +1335,8 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) char c ; int bcmGpioPin ; - pin &= 63 ; + if ((pin < 0) || (pin > 63)) + return wiringPiFailure (WPI_FATAL, "wiringPiISR: pin must be 0-63 (%d)\n", pin) ; /**/ if (wiringPiMode == WPI_MODE_UNINITIALISED) return wiringPiFailure (WPI_FATAL, "wiringPiISR: wiringPi has not been initialised. Unable to continue.\n") ; @@ -1333,26 +1365,26 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) sprintf (pinS, "%d", bcmGpioPin) ; if ((pid = fork ()) < 0) // Fail - return pid ; + return wiringPiFailure (WPI_FATAL, "wiringPiISR: fork failed: %s\n", strerror (errno)) ; if (pid == 0) // Child, exec { execl ("/usr/local/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; - return -1 ; // Failure ... + return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; } else // Parent, wait wait (NULL) ; } -// Now pre-open the /sys/class node - it may already be open if -// we are in Sys mode or if we call here twice, if-so, we'll close it. +// Now pre-open the /sys/class node - but it may already be open if +// we are in Sys mode... - if (sysFds [bcmGpioPin] != -1) - close (sysFds [bcmGpioPin]) ; - - sprintf (fName, "/sys/class/gpio/gpio%d/value", bcmGpioPin) ; - if ((sysFds [bcmGpioPin] = open (fName, O_RDWR)) < 0) - return -1 ; + if (sysFds [bcmGpioPin] == -1) + { + sprintf (fName, "/sys/class/gpio/gpio%d/value", bcmGpioPin) ; + if ((sysFds [bcmGpioPin] = open (fName, O_RDWR)) < 0) + return wiringPiFailure (WPI_FATAL, "wiringPiISR: unable to open %s: %s\n", fName, strerror (errno)) ; + } // Clear any initial pending interrupt @@ -1441,6 +1473,8 @@ void delayMicrosecondsHard (unsigned int howLong) void delayMicroseconds (unsigned int howLong) { struct timespec sleeper ; + unsigned int uSecs = howLong % 1000000 ; + unsigned int wSecs = howLong / 1000000 ; /**/ if (howLong == 0) return ; @@ -1448,8 +1482,8 @@ void delayMicroseconds (unsigned int howLong) delayMicrosecondsHard (howLong) ; else { - sleeper.tv_sec = 0 ; - sleeper.tv_nsec = (long)(howLong * 1000) ; + sleeper.tv_sec = wSecs ; + sleeper.tv_nsec = (long)(uSecs * 1000L) ; nanosleep (&sleeper, NULL) ; } } @@ -1532,7 +1566,7 @@ int wiringPiSetup (void) // Open the master /dev/memory device - if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0) + if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0) return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ; // GPIO: diff --git a/WiringPi/wiringPi/wiringPi.h b/WiringPi/wiringPi/wiringPi.h index 600b318..ce4680a 100644 --- a/WiringPi/wiringPi/wiringPi.h +++ b/WiringPi/wiringPi/wiringPi.h @@ -104,6 +104,8 @@ struct wiringPiNodeStruct struct wiringPiNodeStruct *next ; } ; +extern struct wiringPiNodeStruct *wiringPiNodes ; + // Function prototypes // c++ wrappers thanks to a comment by Nick Lott @@ -119,13 +121,15 @@ extern int wiringPiFailure (int fatal, const char *message, ...) ; // Core wiringPi functions -extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; +extern struct wiringPiNodeStruct *wiringPiFindNode (int pin) ; +extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; extern int wiringPiSetup (void) ; extern int wiringPiSetupSys (void) ; extern int wiringPiSetupGpio (void) ; extern int wiringPiSetupPhys (void) ; +extern void pinModeAlt (int pin, int mode) ; extern void pinMode (int pin, int mode) ; extern void pullUpDnControl (int pin, int pud) ; extern int digitalRead (int pin) ; diff --git a/setup.py b/setup.py index 17db3f1..ac52a91 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,17 @@ _wiringpi2 = Extension( sources=[ 'WiringPi/wiringPi/wiringPi.c', 'WiringPi/wiringPi/wiringPiSPI.c', + 'WiringPi/wiringPi/max31855.c', + 'WiringPi/wiringPi/max5322.c', 'WiringPi/wiringPi/drc.c', + 'WiringPi/wiringPi/sn3218.c', 'WiringPi/wiringPi/mcp23s17.c', 'WiringPi/wiringPi/pcf8591.c', 'WiringPi/wiringPi/softTone.c', 'WiringPi/wiringPi/wiringSerial.c', 'WiringPi/wiringPi/mcp23008.c', 'WiringPi/wiringPi/mcp3002.c', + 'WiringPi/wiringPi/mcp3004.c', 'WiringPi/wiringPi/piHiPri.c', 'WiringPi/wiringPi/sr595.c', 'WiringPi/wiringPi/wiringShift.c', @@ -34,6 +38,7 @@ _wiringpi2 = Extension( 'WiringPi/devLib/lcd.c', 'WiringPi/devLib/piFace.c', 'WiringPi/devLib/piNes.c', + 'WiringPi/devLib/piGlow.c', 'wiringpi_wrap.c' ], ) @@ -54,7 +59,10 @@ setup( headers=[ 'WiringPi/wiringPi/wiringPi.h', 'WiringPi/wiringPi/wiringPiI2C.h', + 'WiringPi/wiringPi/max31855.h', + 'WiringPi/wiringPi/max5322.h', 'WiringPi/wiringPi/drc.h', + 'WiringPi/wiringPi/sn3218.h', 'WiringPi/wiringPi/mcp23s08.h', 'WiringPi/wiringPi/mcp3422.h', 'WiringPi/wiringPi/softServo.h', @@ -74,6 +82,7 @@ setup( 'WiringPi/wiringPi/pcf8591.h', 'WiringPi/wiringPi/mcp23017.h', 'WiringPi/wiringPi/mcp3002.h', + 'WiringPi/wiringPi/mcp3004.h', 'WiringPi/wiringPi/softPwm.h', 'WiringPi/devLib/ds1302.h', 'WiringPi/devLib/gertboard.h', @@ -83,5 +92,6 @@ setup( 'WiringPi/devLib/lcd128x64.h', 'WiringPi/devLib/maxdetect.h', 'WiringPi/devLib/piNes.h' + 'WiringPi/devLib/piGlow.h', ] ) diff --git a/wiringpi.i b/wiringpi.i index 1cf28e1..1780955 100644 --- a/wiringpi.i +++ b/wiringpi.i @@ -6,6 +6,8 @@ #include "WiringPi/wiringPi/wiringPiI2C.h" #include "WiringPi/wiringPi/wiringSerial.h" #include "WiringPi/wiringPi/wiringShift.h" +#include "WiringPi/wiringPi/max31855.h" +#include "WiringPi/wiringPi/max5322.h" #include "WiringPi/wiringPi/mcp23017.h" #include "WiringPi/wiringPi/mcp4802.h" #include "WiringPi/wiringPi/mcp3422.h" @@ -14,7 +16,9 @@ #include "WiringPi/wiringPi/mcp23x08.h" #include "WiringPi/wiringPi/mcp23016.h" #include "WiringPi/wiringPi/mcp3002.h" +#include "WiringPi/wiringPi/mcp3004.h" #include "WiringPi/wiringPi/mcp23016reg.h" +#include "WiringPi/wiringPi/sn3218.h" #include "WiringPi/wiringPi/mcp23x0817.h" #include "WiringPi/wiringPi/mcp23s17.h" #include "WiringPi/wiringPi/pcf8574.h" @@ -32,6 +36,7 @@ #include "WiringPi/devLib/piFace.h" #include "WiringPi/devLib/ds1302.h" #include "WiringPi/devLib/piNes.h" +#include "WiringPi/devLib/piGlow.h" %} %apply unsigned char { uint8_t }; @@ -209,6 +214,9 @@ extern int lcd128x64setup (void) ; extern int setupNesJoystick (int dPin, int cPin, int lPin) ; extern unsigned int readNesJoystick (int joystick) ; - +// PiGlow +extern void piGlow1 (const int leg, const int ring, const int intensity) ; +extern void piGlowLeg (const int leg, const int intensity) ; +extern void piGlowRing (const int ring, const int intensity) ; %include "wiringpi2-class.py" diff --git a/wiringpi2.py b/wiringpi2.py index 5fb5c37..2a3557d 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -503,6 +503,18 @@ setupNesJoystick = _wiringpi2.setupNesJoystick def readNesJoystick(*args): return _wiringpi2.readNesJoystick(*args) readNesJoystick = _wiringpi2.readNesJoystick + +def piGlow1(*args): + return _wiringpi2.piGlow1(*args) +piGlow1 = _wiringpi2.piGlow1 + +def piGlowLeg(*args): + return _wiringpi2.piGlowLeg(*args) +piGlowLeg = _wiringpi2.piGlowLeg + +def piGlowRing(*args): + return _wiringpi2.piGlowRing(*args) +piGlowRing = _wiringpi2.piGlowRing class nes(object): def setupNesJoystick(self,*args): return setupNesJoystick(*args) @@ -658,7 +670,7 @@ class GPIO(object): def softPwmCreate(self,*args): return softPwmCreate(*args) def softPwmWrite(self,*args): - return softPwmWrite(*args) + return sofPwmWrite(*args) def softToneCreate(self,*args): return softToneCreate(*args) diff --git a/wiringpi2.pyc b/wiringpi2.pyc index 9735e5b3daceeb1a54af06a522a90f0b27f75f14..0ddd717b47dccff1a37ad109d523e0424313a74e 100644 GIT binary patch delta 1201 zcmX|>YiN^a6vvc49-RmpSoLM5Uu%aEkb8gE^eO?HHzN8hg^%k!ur;u1(T3 zO>2h;?tn#WwO!T89JOs)2Sv~i3W6|@!M2YDLD;8(4mMHHbB=97-v9f{@BcjSC3)V= z4Owr8twzVos`BU;<#wA{csY5$kGFVvnK8(3FhOHNU_4;J4+i@$G!DVQ)RRZ0nLcAY z-Nx@Q-*yXNw-J+4lM=v`nzWj<@uUqhSD1D_PDZMnF^4@FgFTBjTeLj}dlzl4XtM_U z7VV0BQS(T?ik$J}47yBH{n^65OFlS6x0|*q9?U- z7pERroEm^y`r8|?xyqv6A+}E9y2K5NwH|>w`mOb|3hhCAwg)NVtAN$i<*VEJeyB7u z#=a&oDlsPUqr|wxO^KffKK$A_!dO{Yb$koJTKx{PZ5^;q=>fLVytl;J>G$D=1rvmN zr8a*EHZfg;%@k`NhplS&2g1-mbAdW~7O1VXC*(ADBqsG-w-`Sz*eCvTIOPhO=s<9q zUPe|?G`X5~hY*gFFVaZAhrEDF?O`uHjP0a1VT2AgKR{5=vnh%YR(iw~RcehPbSj-s zA|wbxpVH+{grw50IKmmFzv4(u$=#GpAidzd`y@g}n^~q_rRGxzc|F!YOatoVsDnyd zP9vPt_A%3Wb%8So7t~qbA&}At(?zE3w6iPboZ~ybr2bhK!mv`h8+m2Oh}u*XM%CR< zA&e_|(g-(rne3wfnQkdv%mm?Qr9C|ezc7u!gnmAqMVM4__aaOy%`nX<**R>uYw@1| zZ^l6VK2EzvVxvSsVn$+C;;zK6h3C0ya7_!}q=|uATAug993}E=;T{d;r-;5^XM?<>o|?Q+++m$}cr18!b}Q~&?~ delta 1136 zcmY+CT}V@57{}jdZgVpg(Kbp%OiCpT3ekveRzY4wmS!JHw#~ijW=^N`+f6q=nrIUG zM531Yl}Uo83#=}ppsu2epsOyjya?(>s*A#qdfvC~q=$3<=l}aZ&w1a6bIzYJ)ze{B zR>Y5(DAU)md>acL8oHb4a=+6t#_0rB#h4RVF)%0t#=8cyhM{}u^{Yr;wu6;Z;$hv4 zbum^{>|xx?LTS5_dKvEsr#>ZZXWSo7JC&3gBUq)675f<1vU3?d!TtK!e9XN3M)e!; zn=2a+mT=W3;H{E+?Fh}e0l~N{X8_bV=t)3Rryf1#eK3ak7IUng>fBmyJ=SP-RB5*~ zq-gW0R3N%4LAR}NI$W^nTn+U$yR|NATRksaH|y18smC3S38iks7*R%qs3r=T6f%WN z=Chd6smAqE9mL|V(vvjWpsNTMEgHOIi`)~hqE}59V~`Oo9x(_>7ZO^*-=AO@7kpR9 zgpg?=Gq@T!uNfuFg1P(vfRX0R!TB-=?2_(Oxg8Qi&LW4%tI$D`Oa>~PkSyIHy8}|B zduw+>s&oyG>a@LE28$B={U2;r;C&%;xZy~`wLpR99-$%Vsr(tC5!2;jbM-P5(rQU) zX->wn8V(n*#Fd4cHD0Kt3-_<>Vy_@Ik=nlX;V7Hu3m*MwsP>v zuJ5fJPc$FJ!8VR-&4)45!y!PGQRpMhMyt10vqEoVKz7HpbGRYh9JwLcalFF?H)Zyv zgTt_N-98Q@ Date: Thu, 15 Aug 2013 22:21:38 +0100 Subject: [PATCH 06/15] Added missing files --- WiringPi/wiringPi/wiringPi.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WiringPi/wiringPi/wiringPi.h b/WiringPi/wiringPi/wiringPi.h index ce4680a..7cfd2e5 100644 --- a/WiringPi/wiringPi/wiringPi.h +++ b/WiringPi/wiringPi/wiringPi.h @@ -24,6 +24,9 @@ #ifndef __WIRING_PI_H__ #define __WIRING_PI_H__ +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif // Handy defines // Deprecated From 1a6514e35660ffb411f8f2ca42165e99c5745674 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Thu, 15 Aug 2013 22:21:51 +0100 Subject: [PATCH 07/15] Added missing files --- WiringPi/devLib/piFaceOld.c | 178 +++++++++++++++++++++++++++++++++++ WiringPi/devLib/piGlow.c | 118 +++++++++++++++++++++++ WiringPi/devLib/piGlow.h | 45 +++++++++ WiringPi/wiringPi/max31855.c | 81 ++++++++++++++++ WiringPi/wiringPi/max31855.h | 33 +++++++ WiringPi/wiringPi/max5322.c | 84 +++++++++++++++++ WiringPi/wiringPi/max5322.h | 33 +++++++ WiringPi/wiringPi/mcp3004.c | 76 +++++++++++++++ WiringPi/wiringPi/mcp3004.h | 33 +++++++ WiringPi/wiringPi/sn3218.c | 75 +++++++++++++++ WiringPi/wiringPi/sn3218.h | 33 +++++++ 11 files changed, 789 insertions(+) create mode 100644 WiringPi/devLib/piFaceOld.c create mode 100644 WiringPi/devLib/piGlow.c create mode 100644 WiringPi/devLib/piGlow.h create mode 100644 WiringPi/wiringPi/max31855.c create mode 100644 WiringPi/wiringPi/max31855.h create mode 100644 WiringPi/wiringPi/max5322.c create mode 100644 WiringPi/wiringPi/max5322.h create mode 100644 WiringPi/wiringPi/mcp3004.c create mode 100644 WiringPi/wiringPi/mcp3004.h create mode 100644 WiringPi/wiringPi/sn3218.c create mode 100644 WiringPi/wiringPi/sn3218.h diff --git a/WiringPi/devLib/piFaceOld.c b/WiringPi/devLib/piFaceOld.c new file mode 100644 index 0000000..1b1c0dd --- /dev/null +++ b/WiringPi/devLib/piFaceOld.c @@ -0,0 +1,178 @@ +/* + * piFace.: + * Arduino compatable (ish) Wiring library for the Raspberry Pi + * Copyright (c) 2012-2013 Gordon Henderson + * + * This file to interface with the PiFace peripheral device which + * has an MCP23S17 GPIO device connected via the SPI bus. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + + +#include +#include + +#include +#include + +#include "../wiringPi/mcp23x0817.h" + +#include "piFace.h" + +#define PIFACE_SPEED 4000000 +#define PIFACE_DEVNO 0 + + + +/* + * writeByte: + * Write a byte to a register on the MCP23S17 on the SPI bus. + ********************************************************************************* + */ + +static void writeByte (uint8_t reg, uint8_t data) +{ + uint8_t spiData [4] ; + + spiData [0] = CMD_WRITE ; + spiData [1] = reg ; + spiData [2] = data ; + + wiringPiSPIDataRW (PIFACE_DEVNO, spiData, 3) ; +} + +/* + * readByte: + * Read a byte from a register on the MCP23S17 on the SPI bus. + ********************************************************************************* + */ + +static uint8_t readByte (uint8_t reg) +{ + uint8_t spiData [4] ; + + spiData [0] = CMD_READ ; + spiData [1] = reg ; + + wiringPiSPIDataRW (PIFACE_DEVNO, spiData, 3) ; + + return spiData [2] ; +} + + +/* + * myDigitalWrite: + * Perform the digitalWrite function on the PiFace board + ********************************************************************************* + */ + +void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + uint8_t mask, old ; + + pin -= node->pinBase ; + mask = 1 << pin ; + old = readByte (MCP23x17_GPIOA) ; + + if (value == 0) + old &= (~mask) ; + else + old |= mask ; + + writeByte (MCP23x17_GPIOA, old) ; +} + + +/* + * myDigitalRead: + * Perform the digitalRead function on the PiFace board + ********************************************************************************* + */ + +int myDigitalRead (struct wiringPiNodeStruct *node, int pin) +{ + uint8_t mask, reg ; + + mask = 1 << ((pin - node->pinBase) & 7) ; + + if (pin < 8) + reg = MCP23x17_GPIOB ; // Input regsiter + else + reg = MCP23x17_OLATA ; // Output latch regsiter + + if ((readByte (reg) & mask) != 0) + return HIGH ; + else + return LOW ; +} + + +/* + * myPullUpDnControl: + * Perform the pullUpDnControl function on the PiFace board + ********************************************************************************* + */ + +void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int pud) +{ + uint8_t mask, old ; + + mask = 1 << (pin - node->pinBase) ; + old = readByte (MCP23x17_GPPUB) ; + + if (pud == 0) + old &= (~mask) ; + else + old |= mask ; + + writeByte (MCP23x17_GPPUB, old) ; +} + + +/* + * piFaceSetup + * Setup the SPI interface and initialise the MCP23S17 chip + * We create one node with 16 pins - each if the first 8 pins being read + * and write - although the operations actually go to different + * hardware ports. The top 8 let you read the state of the output register. + ********************************************************************************* + */ + +int piFaceSetup (const int pinBase) +{ + int x ; + struct wiringPiNodeStruct *node ; + + if ((x = wiringPiSPISetup (PIFACE_DEVNO, PIFACE_SPEED)) < 0) + return x ; + +// Setup the MCP23S17 + + writeByte (MCP23x17_IOCON, IOCON_INIT) ; + writeByte (MCP23x17_IODIRA, 0x00) ; // Port A -> Outputs + writeByte (MCP23x17_IODIRB, 0xFF) ; // Port B -> Inputs + + node = wiringPiNewNode (pinBase, 16) ; + node->digitalRead = myDigitalRead ; + node->digitalWrite = myDigitalWrite ; + node->pullUpDnControl = myPullUpDnControl ; + + return 0 ; +} diff --git a/WiringPi/devLib/piGlow.c b/WiringPi/devLib/piGlow.c new file mode 100644 index 0000000..44e3db8 --- /dev/null +++ b/WiringPi/devLib/piGlow.c @@ -0,0 +1,118 @@ +/* + * piGlow.c: + * Easy access to the Pimoroni PiGlow board. + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include + +#include "piGlow.h" + +#define PIGLOW_BASE 577 + +static int leg0 [6] = { 6, 7, 8, 5, 4, 9 } ; +static int leg1 [6] = { 17, 16, 15, 13, 11, 10 } ; +static int leg2 [6] = { 0, 1, 2, 3, 14, 12 } ; + + +/* + * piGlow1: + * Light up an individual LED + ********************************************************************************* + */ + +void piGlow1 (const int leg, const int ring, const int intensity) +{ + int *legLeds ; + + if ((leg < 0) || (leg > 2)) return ; + if ((ring < 0) || (ring > 5)) return ; + + /**/ if (leg == 0) + legLeds = leg0 ; + else if (leg == 1) + legLeds = leg1 ; + else + legLeds = leg2 ; + + analogWrite (PIGLOW_BASE + legLeds [ring], intensity) ; +} + +/* + * piGlowLeg: + * Light up all 6 LEDs on a leg + ********************************************************************************* + */ + +void piGlowLeg (const int leg, const int intensity) +{ + int i ; + int *legLeds ; + + if ((leg < 0) || (leg > 2)) + return ; + + /**/ if (leg == 0) + legLeds = leg0 ; + else if (leg == 1) + legLeds = leg1 ; + else + legLeds = leg2 ; + + for (i = 0 ; i < 6 ; ++i) + analogWrite (PIGLOW_BASE + legLeds [i], intensity) ; +} + + +/* + * piGlowRing: + * Light up 3 LEDs in a ring. Ring 0 is the outermost, 5 the innermost + ********************************************************************************* + */ + +void piGlowRing (const int ring, const int intensity) +{ + if ((ring < 0) || (ring > 5)) + return ; + + analogWrite (PIGLOW_BASE + leg0 [ring], intensity) ; + analogWrite (PIGLOW_BASE + leg1 [ring], intensity) ; + analogWrite (PIGLOW_BASE + leg2 [ring], intensity) ; +} + +/* + * piGlowSetup: + * Initialise the board & remember the pins we're using + ********************************************************************************* + */ + +void piGlowSetup (int clear) +{ + sn3218Setup (PIGLOW_BASE) ; + + if (clear) + { + piGlowLeg (0, 0) ; + piGlowLeg (1, 0) ; + piGlowLeg (2, 0) ; + } +} diff --git a/WiringPi/devLib/piGlow.h b/WiringPi/devLib/piGlow.h new file mode 100644 index 0000000..d501c2c --- /dev/null +++ b/WiringPi/devLib/piGlow.h @@ -0,0 +1,45 @@ +/* + * piglow.h: + * Easy access to the Pimoroni PiGlow board. + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + + +#define PIGLOW_RED 0 +#define PIGLOW_YELLOW 1 +#define PIGLOW_ORANGE 2 +#define PIGLOW_GREEN 3 +#define PIGLOW_BLUE 4 +#define PIGLOW_WHITE 5 + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void piGlow1 (const int leg, const int ring, const int intensity) ; +extern void piGlowLeg (const int leg, const int intensity) ; +extern void piGlowRing (const int ring, const int intensity) ; +extern void piGlowSetup (int clear) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/max31855.c b/WiringPi/wiringPi/max31855.c new file mode 100644 index 0000000..2185839 --- /dev/null +++ b/WiringPi/wiringPi/max31855.c @@ -0,0 +1,81 @@ +/* + * max31855.c: + * Extend wiringPi with the max31855 SPI Analog to Digital convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "max31855.h" + +/* + * myAnalogRead: + * Return the analog value of the given pin + * Note: The chip really only has one read "channel", but we're faking it + * here so we can read the error registers. Channel 0 will be the data + * channel, and 1 is the error register code. + * Note: Temperature returned is temp in C * 4, so divide result by 4 + ********************************************************************************* + */ + +static int myAnalogRead (struct wiringPiNodeStruct *node, int pin) +{ + unsigned int spiData ; + int temp ; + int chan = pin - node->pinBase ; + + wiringPiSPIDataRW (node->fd, (unsigned char *)&spiData, 4) ; + + if (chan == 0) // Read temp in C + { + spiData >>= 18 ; + temp = spiData & 0x3FFF ; // Bottom 13 bits + if ((spiData & 0x2000) != 0) // Negative + temp = -temp ; + return temp ; + } + else // Return error bits + return spiData & 0x7 ; +} + + +/* + * max31855Setup: + * Create a new wiringPi device node for an max31855 on the Pi's + * SPI interface. + ********************************************************************************* + */ + +int max31855Setup (const int pinBase, int spiChannel) +{ + struct wiringPiNodeStruct *node ; + + if (wiringPiSPISetup (spiChannel, 5000000) < 0) // 5MHz - prob 4 on the Pi + return -1 ; + + node = wiringPiNewNode (pinBase, 2) ; + + node->fd = spiChannel ; + node->analogRead = myAnalogRead ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/max31855.h b/WiringPi/wiringPi/max31855.h new file mode 100644 index 0000000..385c4bd --- /dev/null +++ b/WiringPi/wiringPi/max31855.h @@ -0,0 +1,33 @@ +/* + * max31855.c: + * Extend wiringPi with the MAX31855 SPI Thermocouple driver + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int max31855Setup (int pinBase, int spiChannel) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/max5322.c b/WiringPi/wiringPi/max5322.c new file mode 100644 index 0000000..b7cd6a9 --- /dev/null +++ b/WiringPi/wiringPi/max5322.c @@ -0,0 +1,84 @@ +/* + * max5322.c: + * Extend wiringPi with the MAX5322 SPI Digital to Analog convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "max5322.h" + +/* + * myAnalogWrite: + * Write analog value on the given pin + ********************************************************************************* + */ + +static void myAnalogWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + unsigned char spiData [2] ; + unsigned char chanBits, dataBits ; + int chan = pin - node->pinBase ; + + if (chan == 0) + chanBits = 0b01000000 ; + else + chanBits = 0b01010000 ; + + chanBits |= ((value >> 12) & 0x0F) ; + dataBits = ((value ) & 0xFF) ; + + spiData [0] = chanBits ; + spiData [1] = dataBits ; + + wiringPiSPIDataRW (node->fd, spiData, 2) ; +} + +/* + * max5322Setup: + * Create a new wiringPi device node for an max5322 on the Pi's + * SPI interface. + ********************************************************************************* + */ + +int max5322Setup (const int pinBase, int spiChannel) +{ + struct wiringPiNodeStruct *node ; + unsigned char spiData [2] ; + + if (wiringPiSPISetup (spiChannel, 8000000) < 0) // 10MHz Max + return -1 ; + + node = wiringPiNewNode (pinBase, 2) ; + + node->fd = spiChannel ; + node->analogWrite = myAnalogWrite ; + +// Enable both DACs + + spiData [0] = 0b11100000 ; + spiData [1] = 0 ; + + wiringPiSPIDataRW (node->fd, spiData, 2) ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/max5322.h b/WiringPi/wiringPi/max5322.h new file mode 100644 index 0000000..a217cf8 --- /dev/null +++ b/WiringPi/wiringPi/max5322.h @@ -0,0 +1,33 @@ +/* + * max5322.h: + * Extend wiringPi with the MAX5322 SPI Digital to Analog convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int max5322Setup (int pinBase, int spiChannel) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/mcp3004.c b/WiringPi/wiringPi/mcp3004.c new file mode 100644 index 0000000..82c73dd --- /dev/null +++ b/WiringPi/wiringPi/mcp3004.c @@ -0,0 +1,76 @@ +/* + * mcp3004.c: + * Extend wiringPi with the MCP3004 SPI Analog to Digital convertor + * Copyright (c) 2012-2013 Gordon Henderson + * + * Thanks also to "ShorTie" on IRC for some remote debugging help! + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "mcp3004.h" + +/* + * myAnalogRead: + * Return the analog value of the given pin + ********************************************************************************* + */ + +static int myAnalogRead (struct wiringPiNodeStruct *node, int pin) +{ + unsigned char spiData [3] ; + unsigned char chanBits ; + int chan = pin - node->pinBase ; + + chanBits = 0b10000000 | (chan << 4) ; + + spiData [0] = 1 ; // Start bit + spiData [1] = chanBits ; + spiData [2] = 0 ; + + wiringPiSPIDataRW (node->fd, spiData, 3) ; + + return ((spiData [1] << 8) | spiData [2]) & 0x3FF ; +} + + +/* + * mcp3004Setup: + * Create a new wiringPi device node for an mcp3004 on the Pi's + * SPI interface. + ********************************************************************************* + */ + +int mcp3004Setup (const int pinBase, int spiChannel) +{ + struct wiringPiNodeStruct *node ; + + if (wiringPiSPISetup (spiChannel, 1000000) < 0) + return -1 ; + + node = wiringPiNewNode (pinBase, 8) ; + + node->fd = spiChannel ; + node->analogRead = myAnalogRead ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/mcp3004.h b/WiringPi/wiringPi/mcp3004.h new file mode 100644 index 0000000..a07c0bf --- /dev/null +++ b/WiringPi/wiringPi/mcp3004.h @@ -0,0 +1,33 @@ +/* + * mcp3004.c: + * Extend wiringPi with the MCP3004 SPI Analog to Digital convertor + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int mcp3004Setup (int pinBase, int spiChannel) ; + +#ifdef __cplusplus +} +#endif diff --git a/WiringPi/wiringPi/sn3218.c b/WiringPi/wiringPi/sn3218.c new file mode 100644 index 0000000..7ceb156 --- /dev/null +++ b/WiringPi/wiringPi/sn3218.c @@ -0,0 +1,75 @@ +/* + * sn3218.c: + * Extend wiringPi with the SN3218 I2C LEd Driver + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#include +#include + +#include "sn3218.h" + +/* + * myAnalogWrite: + * Write analog value on the given pin + ********************************************************************************* + */ + +static void myAnalogWrite (struct wiringPiNodeStruct *node, int pin, int value) +{ + int fd = node->fd ; + int chan = 0x01 + (pin - node->pinBase) ; + + wiringPiI2CWriteReg8 (fd, chan, value & 0xFF) ; // Value + wiringPiI2CWriteReg8 (fd, 0x16, 0x00) ; // Update +} + +/* + * sn3218Setup: + * Create a new wiringPi device node for an sn3218 on the Pi's + * SPI interface. + ********************************************************************************* + */ + +int sn3218Setup (const int pinBase) +{ + int fd ; + struct wiringPiNodeStruct *node ; + + if ((fd = wiringPiI2CSetup (0x54)) < 0) + return fd ; + +// Setup the chip - initialise all 18 LEDs to off + +//wiringPiI2CWriteReg8 (fd, 0x17, 0) ; // Reset + wiringPiI2CWriteReg8 (fd, 0x00, 1) ; // Not Shutdown + wiringPiI2CWriteReg8 (fd, 0x13, 0x3F) ; // Enable LEDs 0- 5 + wiringPiI2CWriteReg8 (fd, 0x14, 0x3F) ; // Enable LEDs 6-11 + wiringPiI2CWriteReg8 (fd, 0x15, 0x3F) ; // Enable LEDs 12-17 + wiringPiI2CWriteReg8 (fd, 0x16, 0x00) ; // Update + + node = wiringPiNewNode (pinBase, 18) ; + + node->fd = fd ; + node->analogWrite = myAnalogWrite ; + + return 0 ; +} diff --git a/WiringPi/wiringPi/sn3218.h b/WiringPi/wiringPi/sn3218.h new file mode 100644 index 0000000..580d5f9 --- /dev/null +++ b/WiringPi/wiringPi/sn3218.h @@ -0,0 +1,33 @@ +/* + * sn3218.c: + * Extend wiringPi with the SN3218 I2C LED driver board. + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with wiringPi. + * If not, see . + *********************************************************************** + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int sn3218Setup (int pinBase) ; + +#ifdef __cplusplus +} +#endif From 77a4244474dfe2851d5b16b4f10fc7db8a185d9d Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Thu, 15 Aug 2013 22:32:14 +0100 Subject: [PATCH 08/15] PiGlow fixes --- piglow.py | 4 ++++ wiringpi.i | 1 + wiringpi2-class.py | 8 ++++++++ wiringpi2.pyc | Bin 36351 -> 34416 bytes 4 files changed, 13 insertions(+) create mode 100644 piglow.py diff --git a/piglow.py b/piglow.py new file mode 100644 index 0000000..a35cd35 --- /dev/null +++ b/piglow.py @@ -0,0 +1,4 @@ +import wiringpi2 as wiringpi +io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS) +io.piGlowSetup() +io.piGlowLeg(1,100) diff --git a/wiringpi.i b/wiringpi.i index 1780955..6132a36 100644 --- a/wiringpi.i +++ b/wiringpi.i @@ -218,5 +218,6 @@ extern unsigned int readNesJoystick (int joystick) ; extern void piGlow1 (const int leg, const int ring, const int intensity) ; extern void piGlowLeg (const int leg, const int intensity) ; extern void piGlowRing (const int ring, const int intensity) ; +extern void piGlowSetup (int clear) ; %include "wiringpi2-class.py" diff --git a/wiringpi2-class.py b/wiringpi2-class.py index beeb811..d178599 100644 --- a/wiringpi2-class.py +++ b/wiringpi2-class.py @@ -177,4 +177,12 @@ class GPIO(object): return lcdPrintf(self,*args) def lcdInit(self,*args): return lcdInit(self,*args) + def piGlowSetup(self,*args): + return piGlowSetup(self,*args) + def piGlow1(self,*args): + return piGlow1(self,*args) + def piGlowLeg(self,*args): + return piGlowLeg(self,*args) + def piGlowRing(self,*args): + return piGlowRing(self,*args) %} diff --git a/wiringpi2.pyc b/wiringpi2.pyc index 0ddd717b47dccff1a37ad109d523e0424313a74e..ce0c5ccbf96903e38b86febc2e827825dd2ca4f6 100644 GIT binary patch delta 6676 zcmZA5eN2_t9S895b9pP^1$lqJz~xn5qtaZ!k zS-LK5(`C!Dtj!u%*R9FcWu|Fs(yW_Jnyp=9mZiy-+IDr>lK!#Ho%6f*z|R`5KIilM zo!>dAs5|ZM{&58VMC<=s^ykd_NI>ep4yJ&U4uk_|!hw7Y zlVO-igCoOm1rRPwxNun?gy4V+({3Hmy}~gSLgZjE3KO9aVHlcDKy!sNjynBL_B0XNdo+)Py$2(WCBqlB_%>6LMD=%qGbp$$`j$%pu9u;)gF6A{R23$V*9H2rs0U zB#$HyA`dc;B%dT7A|EoJq=2LVq5!ghq>!W#q7br>q==*lq6o5xq}YhxR}4`MSxmHn zk~TnWfZRY*LQ(=z0$D;*N>U0@3Ry~0Mp6b*23bZ@PErn04p~l8K~e!x0a-y(N#d`B zsD!K}+DNn!Vk6{6k}8rah$_e`l4_D_h-%1ck{Xg4h#JTml3J2lh+4>6l1(I=AT~j6 zBB>*(^F!1@))8$c+6=K7ax=*mk}VKhAh(dzlhi}hL)MctkTgIvKsJzUCD{tG6>=*{ zBS|AfBV;4VHj-`di*1nGh?NLoo+AzC3@N!m!- zAle|?NZLu-A=)9^NjgY6Ap9MW9YouSwnJ=(+)mO-(h1QC*-5g4WCz3!$Q>kIBwY|) zkX4)ftU-lCX5Dh>KKn{@XBiRSB4{{&L zAju%aAmkv)evCrM6`oPsz7d5UD3 zWEx@`avE3sdiWWl8FL_KC~1~t7Gf51mgF?aX^7L1r%C2W<{;)E=Sa?woPjt4d4^=3 zWFBH3a-L*?WC3CUazTs!{y9r@)*Q&Qlyr{d9K<=ub0p_U&O@AsJWsMnvIwyVxkz$> z3 z+)jv->56uGeU6^oc$oetTz^9JXLZVE2nUlc%*4T20(|^Ezx@Pr8ee+=$bwO4gr9C&`IGj1%F+skhz7Sl)C@MQ6WW;@Zm0kalJIwCN%B zO6-HBOvpm3CWF*d&3t%o&(M?2%@yt?!!!k*F&eXyt>wDc(q zjHvF!=D34{Y0;yq==I-XRsXzxCfIs4(W9=$73+<4JwHW_7KN%m#AUHqWqdGpt<0^K z;!{}Y0}9RV&QQNiaI3600Fx>*NT;_R+#_tuSt7G~ouzy}n?9|p;>QO04nXBee z3rUpQ?@_-_%4hCPwlyY_xxc&WF)0Nse<8)@zn)^}vU1L=vQzVEE*>?On$7axOttyp zX}tc)G~?zpwKRpQ>uKq%&$@Kmr!Sq4{fkwPDGXQl(><)ukqq1C2N`_)kj$W8D+^WK znY`T3f+3IkDwB5^$+D%M&*D>ddDc8i^?CS|UtW!U;o)NpX4^i`X7gJATlLnQBDRc| za%}$RIebpNxz?Y~wWr-kkIH?JU2BVWxHq%nUt=;1|{^@?hq|3bCR|4Vg6uugT2J@cxD z@7Dj+m|Sy)+iUq5{&B6X@o6p3AK0|!ZuP@We7*N6W@>fT@mep{**>4w@vFXXvmN`n z%{>49s&{VT{?ZnkfA0YwthfGrz0Ln?y;-lB%Z>(X=5Bkr!OrE220oX;t!w^}`uC$E#dYMWh8CXtY>Uag+0w}NPjjp7U(pt!zR{Y)Vs}}LU+3?(**+h&*}dy+ zw_`rp&d2&EeziroYM0>$Lgi zT0PQf-03P%zwhMvWjpNLW_Iv7|B2k`YGJi6cdg|{tJ__?e&tSz>HG8SPP;}k?#BT) z-x#4PubW@iC%bLA-*xj_ck3?emv-?|pR9UO55Gm9>9P4A_V7A8b{n7F-N=^k1)2HM zEb2*69liFJTj@2Y+4$=NZuMoa-AdJc)>Yp|Rwrza9kXjs4f8jwU)x*B`1D?zZg$PD z_VQhm)o)_v?vnld?z%;OufL7eSs1W&ULPoBUa*h6zep|Y<5&0nfCtWg+MqrAV}rp} znTztyDx2$7vER;SVLzYEhven~WwtU@#STQO!l7g~gG)npW@d%AhWH9ghE2@$HL=sf ze1`8)jDDhos-zJ+Lo=17k-(xn>dg_m59SVeRk<)*-)!+&!MEUh!sOp<@u;K&_WGGR z3kL#I)6aSb_(Me2!DrY4{(W#H*qS@EpLx{bcXZWnA5Bt!J8XBCc`F$_QWf;)kK_gO zjXR^YLEkmH=6izn6*I3odbEOk3+o>>)*7MTSK_{lMqDdi^^dU{ot-ycyPEA) zFN}`|TV|zg^3G~ZKY30ZXRYXChgs|8V~2t*Q@QuJZJ8B(ete8&K7E4stMc*K2foo@ zrXKyqxydP)|2z79LBEaY=^wEN`t{4aj_Fqs{laD5@}~9gxC1%*jm3sSza9!(4TXO_ z6tNn5=xd=Q{UT{AMy;{be3Ib&0ng@=KQail4`J zKFnL6JbaL4t~_E}u9X$$Z?9PQwtLly%frFgT!&YMU$L!~D;HRwrblfbvz0%7G}*Nl zyixnaN=UG2ZkPW&l~Al-*kdD|2-iCOD~S*%%87BpoOSNVkjU`Jun_&L3L^C=)fYIV1}uO!67 z*v7BKPMpL^oWyy}crtlT-jh^KrYeg}RTf!fkwq3+WRXP{S)^*RNY!MK`M&?EyCoSj z(6^6krfPuubMANh{^z^r{O5h|`5XVTbW!2(A}=j7e-_~XeK<;sT0|`V#Uv{-9upIj zSSBX+RT*0##VukN$jc(8K{5?;6@f-M)gZYgdQY=t8x@Jk^diYLiCG{+x!a^E(=20) zqHk=1#G9DzZ|Mm10(kU8%?_MOKMf zC3ck}cPVn0n7hQ@rO4fi+%4vAv3DzSk0SSoxkv0hirlNny<+Yad#@t*DRQ5f`^4U- z$o-1kFXn!+_bc*%A`ggpK{Dc)n0;dRDblG(r&NWWSjGV)rZ3rAU{UF0oyT zbSu&=rdw>cA_o*XAm)JB1Bx6}?Vh<|PqezdK90e#r7*QpvZuj z0kH#$#1)B)iHnUZa!iq9VvdPDriiDAC&m-&DUwhmAtoUjgJK574k~h7k>g^H zi#@K$(~3MT=4r7{D>9_WkeDH{LyDYG0_BF~6CAVur;ID>9($OT0%h`Av4f+80cxhUqM*o%r>Qsk1DOJXl6a#@kfVlIoltjP04|h%aBdz06id0LD-i%ryZbB(?YqtKrSti z#EDA{R6W)r#jnYQ`&219R#4g?mmr(uYLi@UmLdEI(76^STkOOoJSmVwTNBv!&w5-w ziuH@R)OaRXgm7}oFZ#KWg5S}`(}36Wr45BtFzRXgGy?F)3xO)i=Q6=!0K}NB{q+aYDFXW5CfnqUV^q80mX7j1a9Zbq}HebrLF*c3Hqxyiq9xkXx z5>S$i&SpyKqF)G*N1;akn(?>ce^F6-3Zado`SHxgg1@mlGnvWe3*(twurYkVxc_v= z#vy&yxZm+ad^#A-=Vq?q;WrefgWI8@H06&Z@wj+^a$P^iW=^hA)EsrgUHOCrb zZLy^YEx^$jyRTt!tlwu!rTJL28>X0A%6kYf`(iTIAVuVz$T|FrG2>tj30`Z^YsdKP zA$qQnxyu`lX$IqlCTiJjk)1gxgjFq&bIqz5g#?zQmQtLiy&wvzX@K%3DZMpULvFbs zZ7tM^tOS9V)YcMhB;Kz%AB_5?{8Uaen_(>-38YDUdf@E2Ogbn%h~J*fPqd~}xm-SI zOT7!J++EN?F8{*vt5ilt#`lbtIV`0X^SVGIOemcO(3j8#g)buZ9 z0$As0-j;w<#YiUbNHVw;qO%;GT38!XT=|wV*V-3eP-2-z%4VOz@^(xl9T zVk7RA>sD5krYh4)cGh=KG>p zn$-s%h@3RRx)GSha1vETxz0dRtwQTElv}FJgf=xgC`Mx8H(?5f0Tl3<3^&Tknd-m9 z0$C{L&ri4Jhg)GwGaPoWEp1p^+Jz$9x<@O4u+WCZvY06pQT%voG8q=BWY}WNRQ$=L zcPB2Y5o$te4N?kAJkgW+Vy!~N9@{WL| ztK4iQGQmWl{uCcW6g@b~WfnpG!&JKwiY$3^C?=+7WqQ35@^Qp+1V^nb*$B;H*;DZI z^-s(v5Y0e6X~sugq~-=tOw6NMu6ooKXm_DmqDp!5T9(P)P{BW#N@qg5A(MT>M$%$mY|4OS|b%H~HL=KD58l8?rd1{(5onV{QAavo8f-f;WQ)GYY>^QofsGLzLB zNket0mUck@6pn}mXsY1H{oG()8%@@|UfnBDcIGZdW6CVYh%uhB-9>-WRY`vmv0RBp zlp{I}13I&Tqk3}}B0zsKO186GH@n{4KkcmU+>NMSi^f*V(bPD)A`aVlPAt6g5=xLh_Zdhq-9=dB3&IZ-G^x2iN=(9Umk+= zCOk((I}yvf(TH+xt>6!i7SXZmf^b&wIWqoAG_I^l3x1zF6Xg*2y=WY@W9J{wIV?z= zCi;3bmf;xbkRLDlj!g3a2!1;nNzUHdOg1&`h~h!$|6VkToM}*sNBwjWOB-oS`Ia2f z?Lk~WnnxF>H{AVX=^6L4+1b-{_3C;ag6^NHInxPj=#Fk`!yu!LXwg9Y8d{iNinam4i7Xk@FF+LLiYt*~otL;6 zaAHl)O`G~OnEp8$Tdr@HO`*4=OWF43f=qE3>o$&P42yXd ziHKH274PX>hx7UkmyVF$V8_T<*QDp^yVue!G;WGcvA)3AQVY;QmDbq19?WzmY zEj!$%X%ey%BpHn-zd>MX zP83UdSIaIX#KG?{BFq4ATvDOAKkMgQy+0EmB790%2d;@s&UWR;$5T01bHx+jIu?!V z;xJv~`I65s03DV3NyL(mMs%h;bzyO^JL76KYYIF|b>ZoD9rHYRPDSH6Q`I|M#GD4n zi_u8VR8Dw*#@!0$1<t!PwdC2Pv*)Xo)feLEUgt^kE5fREYJV-6Gc z1;q4DG_qWtm_^p5#lDEB-i^kV>s29Jd|I9!%VyZ7I(u>YCB*iXXoT5E2?>`Rt_@#B zEbm1l%7veiOffjik54-FiyoJ@@G_$NdNjtgg?Wq}7PVIp+qdTt26V&kFY?8P3R}E~ z5ss#*p{}noz6yokn@1C;`W1N({x7l4$2ftTO?<$ooY$}fmqY*8KhH+^AW`OvuLEbb3`SP^F<$wyYl&> z^>g?lz}3ryA4Q};kH(wZWK?+LGpj_pn91Z4{smXlL~kI%Uqs_PGh+}MbRmxsgrmXj zo8bD(Xk1yLRMHod8?KV|V~FQh(WtUxHizn9-ch=K95MYm8reCOS`l09;0v*=tHgZ^ ze18*-@0`R<`^B^~vY!Ci-$o+{)sbz%>09QX0^8q5V>_op z09#jW!`qnJqs#y zl}zh3p6FPUkASfzHXTDhGog>rA3g{RMspzZ`dg~h z!u{s>607bx=8?Il91y5)-T6f*Y-Y?&48&R*bfZJOEs3ud-=E`ryS$R)VRj?0u`i|3 zy-S((3%F+_1I;qCSNuY5rAh?bNiNg?_IStk??4unw|`$ugQ02Yes>#fW^!W?Om`mb z+~mKow!FJ)Il~(9JGCX&+O(x`>H-#p&HrXBika#S@H&fj_~BU6w+=H=6Rw~uJIkwC zS+TMkCLJg9FGING%0xluCj2_>_9%3ZeHe7vhG3Y^FDdVcLiXr~MRuk`zA_5g{tts} z6Cz=M{H|F{X{zO;3*piR2vpc8XLxy>yNc>t8r+2zC9homu#YTpR0q|1o!Yfrpg{ZS zaEsNmsR`>H#)Z(x8Bw^k=07p?HHdn44rlg_^|6$hOy0wXamo9BJbljMY6Ty-G?c74Iv&`c;a5 zp!i3M_bC3E;_DDqjvA`N80JgRx`YhxK%g1B(eiIgL*;Lib{p_zRvOp!4-;%ZjuI=l zN+a?zT7g;J1~er^Zn8B&+i?q&R_a>t`ky)*L->iy3YOy@9Z*!hrF)2}MP^dn!}SJ; zo^VWbL7C{owee$@z-2-Tgq|g}^yd{M`sMeKTPqmdjPCZ(7G_}6$ zUkVP8Lbp=zdlY(;g2K>=6#O2AzN6soD0CSGFGr!LC^$C?9Yn#WQRo*6u8cx=Q1D>1 zTFJw4QRw^${)*Np0yjmWtEcT{4^MDP^oU-9FQRoCfD58F4Z!nI=)DOJheD@K@G}(p zYJz*A&_&Z;jtifF9r!pzT_=P-HyU}`L_zNyX_`v;=t8*kQHW}nHQX9Kbgl3Z-6vc{ zE1WC;0^7;cg~BdwPCWO*0=+QEKJ45J3-!V{T_nuC(4rS!73_XKa{(q&9+dLM4>j|n z1KkI7^WIGH$^@E(8P9q~he*wxZeU;Z#Q!Iw|sx<7NZTGHLou@5r*Wz3rSu0w~BebEHVKG$B^|6UebH1BwS z|Bbz<%4E^(&baoz58`T-dHpAhsQ(Np)3UDBYr8%@PEoj|NBw8#(PO&s=)zIrU;?QJ zJ1iTZCfgyv;fxz6@T#?Z9Wt4!QDM$Wu^XY(>y8pt56`2-{N%wDRPO*48=I3*2XNVC z22ww3v)T4_BdN86yfiE8o`F;i&qQ-5-C%0%bevk$pR0}9la8rTf1x&NyBt%a{$g#^ zb~~m<{b-6m*w(IJy*}lb9`#SvPH&H6delE%JH5S*=~4g1+Uf0cOpp5ESFKjt+v=De z^> z^Lq3?IAgatrbhiAzaF*gXRPO#9`%3ndh|Xx&N!w<{a?EVwMO7N@aIGudjUEPIP29B9a$G} z(Peq1{%_RG?m4&YbkQ8ILU;Ay#nNxp%yPmlOON`$Q!~3s$Ly&8yEU^r@0cC+f4^pS z(~j9u{|{?scfm0`>i==g>@GTHNBuvkvTNIi^I403KjP_+DgKq>Clo)02v$N=mJ5#e z_xAS=_ICF5CJuDNpRP!6fBg8MzRNRke2_u*7~?}nle12_T9NGP8|XTsZ-4X+4C!je zq28WDx~>pE-klsccu=bshPwxb`c)-Qj>ol4rAl29Ihs(1(v|c5oqg)kxwn5Xd7!)J zKr(S)5cja7Re=t6_VxAl_vq3`1@w9o#8}-|u>Avrhm=NNV*kNjFEOYmM`upFAL6&+ z+cR7P@Yq~}YNSMBYm=%VPRP{X{I#UAEWeRr*op`#T26ay4-ienU2OC03saf+uY zhA2)@oTM-mrzlQS@a+rlSqkGCn-Kf@ixV$DLzB-S&DZkK1cC+iZ4*SOYudDFHwAh;s+2~ zXQn6dNe@oyT86cf+l{5&iEL&M&As%WF;UO*Ez4R^QkTRU@plot%r~*THnudkENH}g geMDBo7ByAM?X0r+|JeVT6o{>CUU}!r+gHB+-_>x1fB*mh From 8460e7975d472d4ae9f8eefa8e750322e9ade106 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Thu, 15 Aug 2013 22:35:44 +0100 Subject: [PATCH 09/15] Updated wrap --- wiringpi2.py | 12 ++++++++++++ wiringpi_wrap.c | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/wiringpi2.py b/wiringpi2.py index 2a3557d..a9fc944 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -515,6 +515,10 @@ piGlowLeg = _wiringpi2.piGlowLeg def piGlowRing(*args): return _wiringpi2.piGlowRing(*args) piGlowRing = _wiringpi2.piGlowRing + +def piGlowSetup(*args): + return _wiringpi2.piGlowSetup(*args) +piGlowSetup = _wiringpi2.piGlowSetup class nes(object): def setupNesJoystick(self,*args): return setupNesJoystick(*args) @@ -693,6 +697,14 @@ class GPIO(object): return lcdPrintf(self,*args) def lcdInit(self,*args): return lcdInit(self,*args) + def piGlowSetup(self,*args): + return piGlowSetup(self,*args) + def piGlow1(self,*args): + return piGlow1(self,*args) + def piGlowLeg(self,*args): + return piGlowLeg(self,*args) + def piGlowRing(self,*args): + return piGlowRing(self,*args) # This file is compatible with both classic and new-style classes. diff --git a/wiringpi_wrap.c b/wiringpi_wrap.c index d53d4c5..0eb71f3 100644 --- a/wiringpi_wrap.c +++ b/wiringpi_wrap.c @@ -2984,6 +2984,7 @@ static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0}; #include "WiringPi/wiringPi/mcp3002.h" #include "WiringPi/wiringPi/mcp3004.h" #include "WiringPi/wiringPi/mcp23016reg.h" +#include "WiringPi/wiringPi/sn3218.h" #include "WiringPi/wiringPi/mcp23x0817.h" #include "WiringPi/wiringPi/mcp23s17.h" #include "WiringPi/wiringPi/pcf8574.h" @@ -6877,6 +6878,27 @@ fail: } +SWIGINTERN PyObject *_wrap_piGlowSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:piGlowSetup",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "piGlowSetup" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + piGlowSetup(arg1); + resultobj = SWIG_Py_Void(); + 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}, @@ -6991,6 +7013,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"piGlow1", _wrap_piGlow1, METH_VARARGS, NULL}, { (char *)"piGlowLeg", _wrap_piGlowLeg, METH_VARARGS, NULL}, { (char *)"piGlowRing", _wrap_piGlowRing, METH_VARARGS, NULL}, + { (char *)"piGlowSetup", _wrap_piGlowSetup, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; From f90c17ab7c60f50c9d5bedb6a49359a8576b1d33 Mon Sep 17 00:00:00 2001 From: sbma44 Date: Thu, 22 Aug 2013 10:46:02 -0400 Subject: [PATCH 10/15] fixing typo around softPwmWrite binding --- wiringpi2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiringpi2.py b/wiringpi2.py index a9fc944..1d596e5 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -674,7 +674,7 @@ class GPIO(object): def softPwmCreate(self,*args): return softPwmCreate(*args) def softPwmWrite(self,*args): - return sofPwmWrite(*args) + return softPwmWrite(*args) def softToneCreate(self,*args): return softToneCreate(*args) From 07bfabb8d3137a6ccb98b8ecda3cd027d648a98a Mon Sep 17 00:00:00 2001 From: Sebastian Aigner Date: Thu, 5 Sep 2013 17:46:33 +0200 Subject: [PATCH 11/15] Made the README examples work with Python compilers / fixed syntax. --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 274bd2a..f31410b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 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 +You **must** have python-dev and python-setuptools installed If you manually rebuild the bindings with swig -python wiringpi.i YOU MUST FIRST INSTALL WIRINGPI2!! @@ -35,11 +35,11 @@ Description incoming! **Usage:** import wiringpi2 - wiringpi2.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions + 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 + wiringpi2.wiringPiSetupSys() # For /sys/class/gpio with GPIO pin numbering OR - wiringpi2.wiringPiSetupGpio // For GPIO pin numbering + 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): @@ -49,9 +49,9 @@ Setting up IO expanders (This example was tested on a quick2wire board with one **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 + 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 **Setting up a peripheral:** WiringPi2 supports expanding your range of available "pins" by setting up a port expander. The implementation details of @@ -69,13 +69,13 @@ Hook a speaker up to your Pi and generate music with softTone. Also useful for g **Bit shifting:** - wiringpi2.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2 + 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 + serial = wiringpi2.serialOpen('/dev/ttyAMA0',9600) # Requires device/baud and returns an ID wiringpi2.serialPuts(serial,"hello") - wiringpi2.serialClose(serial) // Pass in ID + wiringpi2.serialClose(serial) # Pass in ID **Full details at:** http://www.wiringpi.com From e1a81e18a49970b71cb50663cc79f77cc9b63382 Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Sun, 15 Sep 2013 12:21:15 +0100 Subject: [PATCH 12/15] Fixed erroneous Python syntax, thanks Livio --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index 6d2abd0..5194b61 100644 --- a/README +++ b/README @@ -31,11 +31,11 @@ Class-based Usage: Usage: import wiringpi2 - wiringpi2.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions + 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 + wiringpi2.wiringPiSetupSys() // For /sys/class/gpio with GPIO pin numbering OR - wiringpi2.wiringPiSetupGpio // For GPIO pin numbering + 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) From 4e1f4b7f33d733355617bd618e39d219f69e2cbb Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Wed, 11 Dec 2013 14:36:44 +0000 Subject: [PATCH 13/15] Fixed ReadReg8 to call correct underlying method --- wiringpi2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiringpi2.py b/wiringpi2.py index 1d596e5..b01b882 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -554,7 +554,7 @@ class I2C(object): def read(self,*args): return wiringPiI2CRead(*args) def readReg8(self,*args): - return wiringPiI2CRead(*args) + return wiringPiI2CReadReg8(*args) def readReg16(self,*args): return wiringPiI2CReadReg16(*args) def write(self,*args): From f388d58fbdb5fa308fd69e6b32936e3c76c0481b Mon Sep 17 00:00:00 2001 From: Philip Howard Date: Wed, 11 Dec 2013 14:37:16 +0000 Subject: [PATCH 14/15] Fixed ReadReg8 to use correct underlying method --- wiringpi2-class.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiringpi2-class.py b/wiringpi2-class.py index d178599..74ca602 100644 --- a/wiringpi2-class.py +++ b/wiringpi2-class.py @@ -34,7 +34,7 @@ class I2C(object): def read(self,*args): return wiringPiI2CRead(*args) def readReg8(self,*args): - return wiringPiI2CRead(*args) + return wiringPiI2CReadReg8(*args) def readReg16(self,*args): return wiringPiI2CReadReg16(*args) def write(self,*args): From 22041764087c8be68ba1ec6ad4228f9226e7e2ed Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 18 Jul 2014 11:48:01 +0000 Subject: [PATCH 15/15] Updated to latest WiringPi --- Makefile | 8 + WiringPi/People | 3 + WiringPi/build | 48 +- WiringPi/devLib/Makefile | 6 +- WiringPi/examples/Makefile | 11 +- WiringPi/examples/PiGlow/Makefile | 79 + WiringPi/examples/PiGlow/piGlow0.c | 51 + WiringPi/examples/PiGlow/piGlow1.c | 258 ++ WiringPi/examples/PiGlow/piglow.c | 176 + WiringPi/examples/blink.sh | 2 +- WiringPi/examples/blink12drcs.c | 125 + WiringPi/examples/blink6drcs.c | 115 + WiringPi/examples/ds1302.c | 238 ++ WiringPi/examples/rht03.c | 5 + WiringPi/gpio/Makefile | 37 +- WiringPi/gpio/extensions.c | 286 ++ WiringPi/gpio/gpio.1 | 54 +- WiringPi/gpio/gpio.c | 281 +- WiringPi/gpio/pins.c | 33 + WiringPi/gpio/readall.c | 321 ++ WiringPi/wiringPi/Makefile | 27 +- WiringPi/wiringPi/{drc.c => drcSerial.c} | 20 +- WiringPi/wiringPi/{drc.h => drcSerial.h} | 7 +- WiringPi/wiringPi/mcp3002.c | 2 +- WiringPi/wiringPi/mcp3422.c | 34 +- WiringPi/wiringPi/mcp3422.h | 2 +- WiringPi/wiringPi/softPwm.c | 55 +- WiringPi/wiringPi/softPwm.h | 1 + WiringPi/wiringPi/softTone.c | 33 +- WiringPi/wiringPi/softTone.h | 1 + WiringPi/wiringPi/wiringPi.c | 283 +- WiringPi/wiringPi/wiringPi.h | 40 +- setup.py | 102 +- wiringpi.i | 233 +- wiringpi2.py | 481 +-- wiringpi2.pyc | Bin 34416 -> 30422 bytes wiringpi_wrap.c | 4406 ++++++++++++---------- 37 files changed, 5291 insertions(+), 2573 deletions(-) create mode 100644 Makefile create mode 100644 WiringPi/examples/PiGlow/Makefile create mode 100644 WiringPi/examples/PiGlow/piGlow0.c create mode 100644 WiringPi/examples/PiGlow/piGlow1.c create mode 100644 WiringPi/examples/PiGlow/piglow.c create mode 100644 WiringPi/examples/blink12drcs.c create mode 100644 WiringPi/examples/blink6drcs.c create mode 100644 WiringPi/examples/ds1302.c create mode 100644 WiringPi/gpio/pins.c create mode 100644 WiringPi/gpio/readall.c rename WiringPi/wiringPi/{drc.c => drcSerial.c} (91%) rename WiringPi/wiringPi/{drc.h => drcSerial.h} (84%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..584c8ce --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +all: bindings + python setup.py build + +bindings: + swig2.0 -python wiringpi.i + +install: + sudo python setup.py install diff --git a/WiringPi/People b/WiringPi/People index 92d1ea4..b339494 100644 --- a/WiringPi/People +++ b/WiringPi/People @@ -28,3 +28,6 @@ Xian Stannard Andre Crone Suggested the __WIRING_PI.H__ round wiringPi.h + +Rik Teerling + Pointing out some silly mistooks in the I2C code... diff --git a/WiringPi/build b/WiringPi/build index 776c756..bac483a 100755 --- a/WiringPi/build +++ b/WiringPi/build @@ -1,7 +1,6 @@ -#!/bin/bash +#!/bin/sh -check-make-ok() -{ +check_make_ok() { if [ $? != 0 ]; then echo "" echo "Make Failed..." @@ -28,6 +27,8 @@ if [ x$1 = "xclean" ]; then echo -n "PiFace: " ; make clean cd ../q2w echo -n "Quick2Wire: " ; make clean + cd ../PiGlow + echo -n "PiGlow: " ; make clean exit fi @@ -50,27 +51,39 @@ fi echo "WiringPi Library" cd wiringPi sudo make uninstall - make - check-make-ok - sudo make install - check-make-ok + if [ x$1 = "xstatic" ]; then + make static + check_make_ok + sudo make install-static + else + make + check_make_ok + sudo make install + fi + check_make_ok echo echo "WiringPi Devices Library" cd ../devLib sudo make uninstall - make - check-make-ok - sudo make install - check-make-ok + if [ x$1 = "xstatic" ]; then + make static + check_make_ok + sudo make install-static + else + make + check_make_ok + sudo make install + fi + check_make_ok echo echo "GPIO Utility" cd ../gpio make - check-make-ok + check_make_ok sudo make install - check-make-ok + check_make_ok # echo # echo "Examples" @@ -81,7 +94,10 @@ fi echo echo All Done. echo "" -echo "NOTE: This is wiringPi v2, and if you need to use the lcd, Piface," -echo " Gertboard, MaxDetext, etc. routines then you must change your" -echo " compile scripts to add -lwiringPiDev" +echo "NOTE: To compile programs with wiringPi, you need to add:" +echo " -lwiringPi" +echo " to your compile line(s) To use the Gertboard, MaxDetect, etc." +echo " code (the devLib), you need to also add:" +echo " -lwiringPiDev" +echo " to your compile line(s)." echo "" diff --git a/WiringPi/devLib/Makefile b/WiringPi/devLib/Makefile index a106d93..a3c0d42 100644 --- a/WiringPi/devLib/Makefile +++ b/WiringPi/devLib/Makefile @@ -42,7 +42,8 @@ LIBS = SRC = ds1302.c maxdetect.c piNes.c \ gertboard.c piFace.c \ - lcd128x64.c lcd.c + lcd128x64.c lcd.c \ + piGlow.c OBJ = $(SRC:.c=.o) @@ -86,6 +87,7 @@ install-headers: @install -m 0644 piFace.h $(DESTDIR)$(PREFIX)/include @install -m 0644 lcd128x64.h $(DESTDIR)$(PREFIX)/include @install -m 0644 lcd.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 piGlow.h $(DESTDIR)$(PREFIX)/include .PHONEY: install install: $(DYNAMIC) install-headers @@ -111,6 +113,7 @@ uninstall: @rm -f $(DESTDIR)$(PREFIX)/include/piFace.h @rm -f $(DESTDIR)$(PREFIX)/include/lcd128x64.h @rm -f $(DESTDIR)$(PREFIX)/include/lcd.h + @rm -f $(DESTDIR)$(PREFIX)/include/piGlow.h @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.* @ldconfig @@ -128,3 +131,4 @@ gertboard.o: gertboard.h piFace.o: piFace.h lcd128x64.o: font.h lcd128x64.h lcd.o: lcd.h +piGlow.o: piGlow.h diff --git a/WiringPi/examples/Makefile b/WiringPi/examples/Makefile index 8cc256f..571e341 100644 --- a/WiringPi/examples/Makefile +++ b/WiringPi/examples/Makefile @@ -36,13 +36,14 @@ LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm ############################################################################### SRC = blink.c blink8.c blink12.c \ + blink12drcs.c \ pwm.c \ speed.c wfi.c isr.c isr-osc.c \ lcd.c lcd-adafruit.c clock.c \ nes.c \ softPwm.c softTone.c \ delayTest.c serialRead.c serialTest.c okLed.c ds1302.c \ - rht03.c + rht03.c piglow.c OBJ = $(SRC:.c=.o) @@ -63,6 +64,10 @@ blink8: blink8.o @echo [link] @$(CC) -o $@ blink8.o $(LDFLAGS) $(LDLIBS) +blink12drcs: blink12drcs.o + @echo [link] + @$(CC) -o $@ blink12drcs.o $(LDFLAGS) $(LDLIBS) + blink12: blink12.o @echo [link] @$(CC) -o $@ blink12.o $(LDFLAGS) $(LDLIBS) @@ -139,6 +144,10 @@ ds1302: ds1302.o @echo [link] @$(CC) -o $@ ds1302.o $(LDFLAGS) $(LDLIBS) +piglow: piglow.o + @echo [link] + @$(CC) -o $@ piglow.o $(LDFLAGS) $(LDLIBS) + .c.o: @echo [CC] $< diff --git a/WiringPi/examples/PiGlow/Makefile b/WiringPi/examples/PiGlow/Makefile new file mode 100644 index 0000000..8d31141 --- /dev/null +++ b/WiringPi/examples/PiGlow/Makefile @@ -0,0 +1,79 @@ +# +# Makefile: +# wiringPi - Wiring Compatable library for the Raspberry Pi +# https://projects.drogon.net/wiring-pi +# +# Copyright (c) 2012-2013 Gordon Henderson +################################################################################# +# This file is part of wiringPi: +# Wiring Compatable library for the Raspberry Pi +# +# wiringPi is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# wiringPi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with wiringPi. If not, see . +################################################################################# + + +#DEBUG = -g -O0 +DEBUG = -O3 +CC = gcc +INCLUDE = -I/usr/local/include +CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe + +LDFLAGS = -L/usr/local/lib +LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm + +# Should not alter anything below this line +############################################################################### + +SRC = piGlow0.c piGlow1.c piglow.c + +OBJ = $(SRC:.c=.o) + +BINS = $(SRC:.c=) + +all: $(BINS) + +piGlow0: piGlow0.o + @echo [link] + @$(CC) -o $@ piGlow0.o $(LDFLAGS) $(LDLIBS) + +piGlow1: piGlow1.o + @echo [link] + @$(CC) -o $@ piGlow1.o $(LDFLAGS) $(LDLIBS) + +piglow: piglow.o + @echo [link] + @$(CC) -o $@ piglow.o $(LDFLAGS) $(LDLIBS) + +.c.o: + @echo [CC] $< + @$(CC) -c $(CFLAGS) $< -o $@ + +clean: + @echo "[Clean]" + @rm -f $(OBJ) *~ core tags $(BINS) + +tags: $(SRC) + @echo [ctags] + @ctags $(SRC) + +install: piglow + @echo Installing piglow into /usr/local/bin + @cp -a piglow /usr/local/bin/piglow + @chmod 755 /usr/local/bin/piglow + @echo Done. Remember to load the I2C drivers! + +depend: + makedepend -Y $(SRC) + +# DO NOT DELETE diff --git a/WiringPi/examples/PiGlow/piGlow0.c b/WiringPi/examples/PiGlow/piGlow0.c new file mode 100644 index 0000000..d3fe4b9 --- /dev/null +++ b/WiringPi/examples/PiGlow/piGlow0.c @@ -0,0 +1,51 @@ +/* + * piglow.c: + * Very simple demonstration of the PiGlow board. + * This uses the SN3218 directly - soon there will be a new PiGlow + * devLib device which will handle the PiGlow board on a more easy + * to use manner... + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include + +#define LED_BASE 533 + +int main (void) +{ + int i, j ; + + wiringPiSetupSys () ; + + sn3218Setup (LED_BASE) ; + + for (;;) + { + for (i = 0 ; i < 256 ; ++i) + for (j = 0 ; j < 18 ; ++j) + analogWrite (LED_BASE + j, i) ; + + for (i = 255 ; i >= 0 ; --i) + for (j = 0 ; j < 18 ; ++j) + analogWrite (LED_BASE + j, i) ; + } +} diff --git a/WiringPi/examples/PiGlow/piGlow1.c b/WiringPi/examples/PiGlow/piGlow1.c new file mode 100644 index 0000000..a00b31e --- /dev/null +++ b/WiringPi/examples/PiGlow/piGlow1.c @@ -0,0 +1,258 @@ +/* + * piGlow1.c: + * Very simple demonstration of the PiGlow board. + * This uses the piGlow devLib. + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#include +#include + +#define PIGLOW_BASE 533 + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (!TRUE) +#endif + + +/* + * keypressed: clearKeypressed: + * Simple but effective ways to tell if the enter key has been pressed + ********************************************************************************* + */ + +static int keypressed (void) +{ + struct pollfd polls ; + + polls.fd = fileno (stdin) ; + polls.events = POLLIN ; + + return poll (&polls, 1, 0) != 0 ; +} + +static void clearKeypressed (void) +{ + while (keypressed ()) + (void)getchar () ; +} + + +/* + * pulseLed: + * Pulses the LED at position leg, ring from off to a max. value, + * then off again + ********************************************************************************* + */ + +static void pulseLed (int leg, int ring) +{ + int i ; + + for (i = 0 ; i < 140 ; ++i) + { + piGlow1 (leg, ring, i) ; + delay (1) ; + } + delay (10) ; + for (i = 140 ; i >= 0 ; --i) + { + piGlow1 (leg, ring, i) ; + delay (1) ; + } +} + +/* + * pulseLeg: + * Same as above, but a whole leg at a time + ********************************************************************************* + */ + +static void pulseLeg (int leg) +{ + int i ; + + for (i = 0 ; i < 140 ; ++i) + { + piGlowLeg (leg, i) ; delay (1) ; + } + delay (10) ; + for (i = 140 ; i >= 0 ; --i) + { + piGlowLeg (leg, i) ; delay (1) ; + } +} + + +/* + * pulse Ring: + * Same as above, but a whole ring at a time + ********************************************************************************* + */ + +static void pulseRing (int ring) +{ + int i ; + + for (i = 0 ; i < 140 ; ++i) + { + piGlowRing (ring, i) ; delay (1) ; + } + delay (10) ; + for (i = 140 ; i >= 0 ; --i) + { + piGlowRing (ring, i) ; delay (1) ; + } +} + +#define LEG_STEPS 3 + +static int legSequence [] = +{ + 4, 12, 99, + 99, 4, 12, + 12, 99, 4, +} ; + + +#define RING_STEPS 16 + +static int ringSequence [] = +{ + 0, 0, 0, 0, 0, 64, + 0, 0, 0, 0, 64, 64, + 0, 0, 0, 64, 64, 0, + 0, 0, 64, 64, 0, 0, + 0, 64, 64, 0, 0, 0, + 64, 64, 0, 0, 0, 0, + 64, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 64, 0, 0, 0, 0, 0, + 64, 64, 0, 0, 0, 0, + 0, 64, 64, 0, 0, 0, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 64, 64, 0, + 0, 0, 0, 0, 64, 64, + 0, 0, 0, 0, 0, 64, + 0, 0, 0, 0, 0, 0, +} ; + +/* + * main: + * Our little demo prgoram + ********************************************************************************* + */ + +int main (void) +{ + int i ; + int step, ring, leg ; + +// Always initialise wiringPi: +// Use the Sys method if you don't need to run as root + + wiringPiSetupSys () ; + +// Initialise the piGlow devLib with our chosen pin base + + piGlowSetup (1) ; + +// LEDs, one at a time + + printf ("LEDs, one at a time\n") ; + for (; !keypressed () ;) + for (leg = 0 ; leg < 3 ; ++leg) + { + for (ring = 0 ; ring < 6 ; ++ring) + { + pulseLed (leg, ring) ; + if (keypressed ()) + break ; + } + if (keypressed ()) + break ; + } + clearKeypressed () ; + +// Rings, one at a time + + printf ("Rings, one at a time\n") ; + for (; !keypressed () ;) + for (ring = 0 ; ring < 6 ; ++ring) + { + pulseRing (ring) ; + if (keypressed ()) + break ; + } + clearKeypressed () ; + +// Legs, one at a time + + printf ("Legs, one at a time\n") ; + for (; !keypressed () ;) + for (leg = 0 ; leg < 3 ; ++leg) + { + pulseLeg (leg) ; + if (keypressed ()) + break ; + } + clearKeypressed () ; + + delay (1000) ; + +// Sequence - alternating rings, legs and random + + printf ("Sequence now\n") ; + for (; !keypressed () ;) + { + for (i = 0 ; i < 20 ; ++i) + for (step = 0 ; step < LEG_STEPS ; ++step) + { + for (leg = 0 ; leg < 3 ; ++leg) + piGlowLeg (leg, legSequence [step * 3 + leg]) ; + delay (80) ; + } + + for (i = 0 ; i < 10 ; ++i) + for (step = 0 ; step < RING_STEPS ; ++step) + { + for (ring = 0 ; ring < 6 ; ++ring) + piGlowRing (ring, ringSequence [step * 6 + ring]) ; + delay (80) ; + } + + for (i = 0 ; i < 1000 ; ++i) + { + leg = random () % 3 ; + ring = random () % 6 ; + piGlow1 (leg, ring, random () % 256) ; + delay (5) ; + piGlow1 (leg, ring, 0) ; + } + } + + return 0 ; +} diff --git a/WiringPi/examples/PiGlow/piglow.c b/WiringPi/examples/PiGlow/piglow.c new file mode 100644 index 0000000..e6a2db3 --- /dev/null +++ b/WiringPi/examples/PiGlow/piglow.c @@ -0,0 +1,176 @@ +/* + * piglow.c: + * Very simple demonstration of the PiGlow board. + * This uses the piGlow devLib. + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (!TRUE) +#endif + +#include +#include + +static void failUsage (void) +{ + fprintf (stderr, "Usage examples:\n") ; + fprintf (stderr, " piglow off # All off\n") ; + fprintf (stderr, " piglow red 50 # Light the 3 red LEDs to 50%%\n") ; + fprintf (stderr, " colours are: red, yellow, orange, green, blue and white\n") ; + fprintf (stderr, " piglow all 75 # Light all to 75%%\n") ; + fprintf (stderr, " piglow leg 0 25 # Light leg 0 to 25%%\n") ; + fprintf (stderr, " piglow ring 3 100 # Light ring 3 to 100%%\n") ; + fprintf (stderr, " piglow led 2 5 100 # Light the single LED on Leg 2, ring 5 to 100%%\n") ; + + exit (EXIT_FAILURE) ; +} + +static int getPercent (char *typed) +{ + int percent ; + + percent = atoi (typed) ; + if ((percent < 0) || (percent > 100)) + { + fprintf (stderr, "piglow: percent value out of range\n") ; + exit (EXIT_FAILURE) ; + } + return (percent * 255) / 100 ; +} + + +/* + * main: + * Our little demo prgoram + ********************************************************************************* + */ + +int main (int argc, char *argv []) +{ + int percent ; + int ring, leg ; + +// Always initialise wiringPi: +// Use the Sys method if you don't need to run as root + + wiringPiSetupSys () ; + +// Initialise the piGlow devLib + + piGlowSetup (FALSE) ; + + if (argc == 1) + failUsage () ; + + if ((argc == 2) && (strcasecmp (argv [1], "off") == 0)) + { + for (leg = 0 ; leg < 3 ; ++leg) + piGlowLeg (leg, 0) ; + return 0 ; + } + + if (argc == 3) + { + percent = getPercent (argv [2]) ; + + /**/ if (strcasecmp (argv [1], "red") == 0) + piGlowRing (PIGLOW_RED, percent) ; + else if (strcasecmp (argv [1], "yellow") == 0) + piGlowRing (PIGLOW_YELLOW, percent) ; + else if (strcasecmp (argv [1], "orange") == 0) + piGlowRing (PIGLOW_ORANGE, percent) ; + else if (strcasecmp (argv [1], "green") == 0) + piGlowRing (PIGLOW_GREEN, percent) ; + else if (strcasecmp (argv [1], "blue") == 0) + piGlowRing (PIGLOW_BLUE, percent) ; + else if (strcasecmp (argv [1], "white") == 0) + piGlowRing (PIGLOW_WHITE, percent) ; + else if (strcasecmp (argv [1], "all") == 0) + for (ring = 0 ; ring < 6 ; ++ring) + piGlowRing (ring, percent) ; + else + { + fprintf (stderr, "piglow: invalid colour\n") ; + exit (EXIT_FAILURE) ; + } + return 0 ; + } + + if (argc == 4) + { + /**/ if (strcasecmp (argv [1], "leg") == 0) + { + leg = atoi (argv [2]) ; + if ((leg < 0) || (leg > 2)) + { + fprintf (stderr, "piglow: leg value out of range\n") ; + exit (EXIT_FAILURE) ; + } + percent = getPercent (argv [3]) ; + piGlowLeg (leg, percent) ; + } + else if (strcasecmp (argv [1], "ring") == 0) + { + ring = atoi (argv [2]) ; + if ((ring < 0) || (ring > 5)) + { + fprintf (stderr, "piglow: ring value out of range\n") ; + exit (EXIT_FAILURE) ; + } + percent = getPercent (argv [3]) ; + piGlowRing (ring, percent) ; + } + return 0 ; + } + + if (argc == 5) + { + if (strcasecmp (argv [1], "led") != 0) + failUsage () ; + + leg = atoi (argv [2]) ; + if ((leg < 0) || (leg > 2)) + { + fprintf (stderr, "piglow: leg value out of range\n") ; + exit (EXIT_FAILURE) ; + } + ring = atoi (argv [3]) ; + if ((ring < 0) || (ring > 5)) + { + fprintf (stderr, "piglow: ring value out of range\n") ; + exit (EXIT_FAILURE) ; + } + percent = getPercent (argv [4]) ; + piGlow1 (leg, ring, percent) ; + return 0 ; + } + + failUsage () ; + return 0 ; +} + + diff --git a/WiringPi/examples/blink.sh b/WiringPi/examples/blink.sh index 2aa378a..7755383 100644 --- a/WiringPi/examples/blink.sh +++ b/WiringPi/examples/blink.sh @@ -25,7 +25,7 @@ # LED Pin - wiringPi pin 0 is BCM_GPIO 17. -LED=0 +PIN=0 gpio mode $PIN out diff --git a/WiringPi/examples/blink12drcs.c b/WiringPi/examples/blink12drcs.c new file mode 100644 index 0000000..6ee11fd --- /dev/null +++ b/WiringPi/examples/blink12drcs.c @@ -0,0 +1,125 @@ +/* + * blink12drcs.c: + * Simple sequence over the first 12 GPIO pins - LEDs + * Aimed at the Gertboard, but it's fairly generic. + * This version uses DRC totalk to the ATmega on the Gertboard + * + * Copyright (c) 2012-2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#define GERT_BASE 100 + +static int pinMap [] = +{ + 0, 1, 2, 3, // Pi Native + GERT_BASE + 2, GERT_BASE + 3, GERT_BASE + 4, GERT_BASE + 5, + GERT_BASE + 6, GERT_BASE + 7, GERT_BASE + 8, GERT_BASE + 9, +} ; + +// Simple sequencer data +// Triplets of LED, On/Off and delay + + +int data [] = +{ + 0, 1, 1, + 1, 1, 1, + 0, 0, 0, 2, 1, 1, + 1, 0, 0, 3, 1, 1, + 2, 0, 0, 4, 1, 1, + 3, 0, 0, 5, 1, 1, + 4, 0, 0, 6, 1, 1, + 5, 0, 0, 7, 1, 1, + 6, 0, 0, 8, 1, 1, + 7, 0, 0, 9, 1, 1, + 8, 0, 0, 10, 1, 1, + 9, 0, 0, 11, 1, 1, + 10, 0, 1, + 11, 0, 1, + + 0, 0, 1, // Extra delay + +// Back again + + 11, 1, 1, + 10, 1, 1, + 11, 0, 0, 9, 1, 1, + 10, 0, 0, 8, 1, 1, + 9, 0, 0, 7, 1, 1, + 8, 0, 0, 6, 1, 1, + 7, 0, 0, 5, 1, 1, + 6, 0, 0, 4, 1, 1, + 5, 0, 0, 3, 1, 1, + 4, 0, 0, 2, 1, 1, + 3, 0, 0, 1, 1, 1, + 2, 0, 0, 0, 1, 1, + 1, 0, 1, + 0, 0, 1, + + 0, 0, 1, // Extra delay + + 0, 9, 0, // End marker + +} ; + + +int main (void) +{ + int pin ; + int dataPtr ; + int l, s, d ; + + printf ("Raspberry Pi - 12-LED Sequence\n") ; + printf ("==============================\n") ; + printf ("\n") ; + printf ("Connect LEDs up to the first 4 Pi pins and 8 pins on the ATmega\n") ; + printf (" from PD2 through PB1 in that order,\n") ; + printf (" then sit back and watch the show!\n") ; + + wiringPiSetup () ; + drcSetupSerial (GERT_BASE, 20, "/dev/ttyAMA0", 115200) ; + + for (pin = 0 ; pin < 12 ; ++pin) + pinMode (pinMap [pin], OUTPUT) ; + + dataPtr = 0 ; + + for (;;) + { + l = data [dataPtr++] ; // LED + s = data [dataPtr++] ; // State + d = data [dataPtr++] ; // Duration (10ths) + + if (s == 9) // 9 -> End Marker + { + dataPtr = 0 ; + continue ; + } + + digitalWrite (pinMap [l], s) ; + delay (d * analogRead (GERT_BASE) / 4) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/blink6drcs.c b/WiringPi/examples/blink6drcs.c new file mode 100644 index 0000000..32f4921 --- /dev/null +++ b/WiringPi/examples/blink6drcs.c @@ -0,0 +1,115 @@ +/* + * blink6drcs.c: + * Simple sequence over 6 pins on a remote DRC board. + * Aimed at the Gertduino, but it's fairly generic. + * This version uses DRC to talk to the ATmega on the Gertduino + * + * Copyright (c) 2012-2014 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include + +#define GERT_BASE 100 + +static int pinMap [] = +{ + GERT_BASE + 6, GERT_BASE + 5, GERT_BASE + 3, GERT_BASE + 10, GERT_BASE + 9, GERT_BASE + 13, +} ; + +// Simple sequencer data +// Triplets of LED, On/Off and delay + + +int data [] = +{ + 0, 1, 1, + 1, 1, 1, + 0, 0, 0, 2, 1, 1, + 1, 0, 0, 3, 1, 1, + 2, 0, 0, 4, 1, 1, + 3, 0, 0, 5, 1, 1, + 4, 0, 1, + 5, 0, 1, + + 0, 0, 1, // Extra delay + +// Back again + + 5, 1, 1, + 4, 1, 1, + 5, 0, 0, 3, 1, 1, + 4, 0, 0, 2, 1, 1, + 3, 0, 0, 1, 1, 1, + 2, 0, 0, 0, 1, 1, + 1, 0, 1, + 0, 0, 1, + + 0, 0, 1, // Extra delay + + 0, 9, 0, // End marker + +} ; + + +int main (void) +{ + int pin ; + int dataPtr ; + int l, s, d ; + + printf ("Raspberry Pi - 6-LED Sequence\n") ; + printf ("=============================\n") ; + printf ("\n") ; + printf (" Use the 2 buttons to temporarily speed up the sequence\n") ; + + wiringPiSetupSys () ; // Not using the Pi's GPIO here + drcSetupSerial (GERT_BASE, 20, "/dev/ttyAMA0", 115200) ; + + for (pin = 0 ; pin < 6 ; ++pin) + pinMode (pinMap [pin], OUTPUT) ; + + pinMode (GERT_BASE + 16, INPUT) ; // Buttons + pinMode (GERT_BASE + 17, INPUT) ; + + pullUpDnControl (GERT_BASE + 16, PUD_UP) ; + pullUpDnControl (GERT_BASE + 17, PUD_UP) ; + + dataPtr = 0 ; + + for (;;) + { + l = data [dataPtr++] ; // LED + s = data [dataPtr++] ; // State + d = data [dataPtr++] ; // Duration (10ths) + + if (s == 9) // 9 -> End Marker + { + dataPtr = 0 ; + continue ; + } + + digitalWrite (pinMap [l], s) ; + delay (d * digitalRead (GERT_BASE + 16) * 15 + digitalRead (GERT_BASE + 17) * 20) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/ds1302.c b/WiringPi/examples/ds1302.c new file mode 100644 index 0000000..f1e9e20 --- /dev/null +++ b/WiringPi/examples/ds1302.c @@ -0,0 +1,238 @@ +/* + * ds1302.c: + * Real Time clock + * + * Copyright (c) 2013 Gordon Henderson. + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + +#include +#include +#include +#include +#include + +#include +#include + +// Register defines + +#define RTC_SECS 0 +#define RTC_MINS 1 +#define RTC_HOURS 2 +#define RTC_DATE 3 +#define RTC_MONTH 4 +#define RTC_DAY 5 +#define RTC_YEAR 6 +#define RTC_WP 7 +#define RTC_TC 8 +#define RTC_BM 31 + + +static unsigned int masks [] = { 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x07, 0xFF } ; + + +/* + * bcdToD: dToBCD: + * BCD decode/encode + ********************************************************************************* + */ + +static int bcdToD (unsigned int byte, unsigned int mask) +{ + unsigned int b1, b2 ; + byte &= mask ; + b1 = byte & 0x0F ; + b2 = ((byte >> 4) & 0x0F) * 10 ; + return b1 + b2 ; +} + +static unsigned int dToBcd (unsigned int byte) +{ + return ((byte / 10) << 4) + (byte % 10) ; +} + + +/* + * ramTest: + * Simple test of the 31 bytes of RAM inside the DS1302 chip + ********************************************************************************* + */ + +static int ramTestValues [] = + { 0x00, 0xFF, 0xAA, 0x55, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0xF0, 0x0F, -1 } ; + +static int ramTest (void) +{ + int addr ; + int got ; + int i = 0 ; + int errors = 0 ; + int testVal ; + + printf ("DS1302 RAM TEST\n") ; + + testVal = ramTestValues [i] ; + + while (testVal != -1) + { + for (addr = 0 ; addr < 31 ; ++addr) + ds1302ramWrite (addr, testVal) ; + + for (addr = 0 ; addr < 31 ; ++addr) + if ((got = ds1302ramRead (addr)) != testVal) + { + printf ("DS1302 RAM Failure: Address: %2d, Expected: 0x%02X, Got: 0x%02X\n", + addr, testVal, got) ; + ++errors ; + } + testVal = ramTestValues [++i] ; + } + + for (addr = 0 ; addr < 31 ; ++addr) + ds1302ramWrite (addr, addr) ; + + for (addr = 0 ; addr < 31 ; ++addr) + if ((got = ds1302ramRead (addr)) != addr) + { + printf ("DS1302 RAM Failure: Address: %2d, Expected: 0x%02X, Got: 0x%02X\n", + addr, addr, got) ; + ++errors ; + } + + if (errors == 0) + printf ("-- DS1302 RAM TEST: OK\n") ; + else + printf ("-- DS1302 RAM TEST FAILURE. %d errors.\n", errors) ; + + return 0 ; +} + +/* + * setLinuxClock: + * Set the Linux clock from the hardware + ********************************************************************************* + */ + +static int setLinuxClock (void) +{ + char dateTime [20] ; + char command [64] ; + int clock [8] ; + + + printf ("Setting the Linux Clock from the DS1302... ") ; fflush (stdout) ; + + ds1302clockRead (clock) ; + +// [MMDDhhmm[[CC]YY][.ss]] + + sprintf (dateTime, "%02d%02d%02d%02d%02d%02d.%02d", + bcdToD (clock [RTC_MONTH], masks [RTC_MONTH]), + bcdToD (clock [RTC_DATE], masks [RTC_DATE]), + bcdToD (clock [RTC_HOURS], masks [RTC_HOURS]), + bcdToD (clock [RTC_MINS], masks [RTC_MINS]), + 20, + bcdToD (clock [RTC_YEAR], masks [RTC_YEAR]), + bcdToD (clock [RTC_SECS], masks [RTC_SECS])) ; + + sprintf (command, "/bin/date %s", dateTime) ; + system (command) ; + + return 0 ; +} + + +/* + * setDSclock: + * Set the DS1302 block from Linux time + ********************************************************************************* + */ + +static int setDSclock (void) +{ + struct tm t ; + time_t now ; + int clock [8] ; + + printf ("Setting the clock in the DS1302 from Linux time... ") ; + + now = time (NULL) ; + gmtime_r (&now, &t) ; + + clock [ 0] = dToBcd (t.tm_sec) ; // seconds + clock [ 1] = dToBcd (t.tm_min) ; // mins + clock [ 2] = dToBcd (t.tm_hour) ; // hours + clock [ 3] = dToBcd (t.tm_mday) ; // date + clock [ 4] = dToBcd (t.tm_mon + 1) ; // months 0-11 --> 1-12 + clock [ 5] = dToBcd (t.tm_wday + 1) ; // weekdays (sun 0) + clock [ 6] = dToBcd (t.tm_year - 100) ; // years + clock [ 7] = 0 ; // W-Protect off + + ds1302clockWrite (clock) ; + + printf ("OK\n") ; + + return 0 ; +} + + + + +int main (int argc, char *argv []) +{ + int i ; + int clock [8] ; + + wiringPiSetup () ; + ds1302setup (0, 1, 2) ; + + if (argc == 2) + { + /**/ if (strcmp (argv [1], "-slc") == 0) + return setLinuxClock () ; + else if (strcmp (argv [1], "-sdsc") == 0) + return setDSclock () ; + else if (strcmp (argv [1], "-rtest") == 0) + return ramTest () ; + else + { + printf ("Usage: ds1302 [-slc | -sdsc | -rtest]\n") ; + return EXIT_FAILURE ; + } + } + + for (i = 0 ;; ++i) + { + printf ("%5d: ", i) ; + + ds1302clockRead (clock) ; + printf (" %2d:%02d:%02d", + bcdToD (clock [2], masks [2]), bcdToD (clock [1], masks [1]), bcdToD (clock [0], masks [0])) ; + + printf (" %2d/%02d/%04d", + bcdToD (clock [3], masks [3]), bcdToD (clock [4], masks [4]), bcdToD (clock [6], masks [6]) + 2000) ; + + printf ("\n") ; + + delay (200) ; + } + + return 0 ; +} diff --git a/WiringPi/examples/rht03.c b/WiringPi/examples/rht03.c index e0cc116..566e954 100644 --- a/WiringPi/examples/rht03.c +++ b/WiringPi/examples/rht03.c @@ -56,6 +56,11 @@ int main (void) { temp = newTemp ; rh = newRh ; + if ((temp & 0x8000) != 0) // Negative + { + temp &= 0x7FFF ; + temp = -temp ; + } printf ("Temp: %5.1f, RH: %5.1f%%\n", temp / 10.0, rh / 10.0) ; } } diff --git a/WiringPi/gpio/Makefile b/WiringPi/gpio/Makefile index 52b0150..37b4887 100644 --- a/WiringPi/gpio/Makefile +++ b/WiringPi/gpio/Makefile @@ -1,9 +1,10 @@ # # Makefile: -# wiringPi - Wiring Compatable library for the Raspberry Pi +# The gpio command: +# A swiss-army knige of GPIO shenanigans. # https://projects.drogon.net/wiring-pi # -# Copyright (c) 2012 Gordon Henderson +# Copyright (c) 2012-2013 Gordon Henderson ################################################################################# # This file is part of wiringPi: # Wiring Compatable library for the Raspberry Pi @@ -22,20 +23,22 @@ # along with wiringPi. If not, see . ################################################################################# +DESTDIR=/usr +PREFIX=/local #DEBUG = -g -O0 DEBUG = -O2 CC = gcc -INCLUDE = -I/usr/local/include +INCLUDE = -I$(DESTDIR)$(PREFIX)/include CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe -LDFLAGS = -L/usr/local/lib +LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib LIBS = -lwiringPi -lwiringPiDev -lpthread -lm # May not need to alter anything below this line ############################################################################### -SRC = gpio.c extensions.c +SRC = gpio.c extensions.c readall.c pins.c OBJ = $(SRC:.c=.o) @@ -49,32 +52,32 @@ gpio: $(OBJ) @echo [Compile] $< @$(CC) -c $(CFLAGS) $< -o $@ -.PHONEY: clean +.PHONY: clean clean: @echo "[Clean]" @rm -f $(OBJ) gpio *~ core tags *.bak -.PHONEY: tags +.PHONY: tags tags: $(SRC) @echo [ctags] @ctags $(SRC) -.PHONEY: install +.PHONY: install install: @echo "[Install]" - @cp gpio /usr/local/bin - @chown root.root /usr/local/bin/gpio - @chmod 4755 /usr/local/bin/gpio - @mkdir -p /usr/local/man/man1 - @cp gpio.1 /usr/local/man/man1 + @cp gpio $(DESTDIR)$(PREFIX)/bin + @chown root.root $(DESTDIR)$(PREFIX)/bin/gpio + @chmod 4755 $(DESTDIR)$(PREFIX)/bin/gpio + @mkdir -p $(DESTDIR)$(PREFIX)/man/man1 + @cp gpio.1 $(DESTDIR)$(PREFIX)/man/man1 -.PHONEY: uninstall +.PHONY: uninstall uninstall: @echo "[UnInstall]" - @rm -f /usr/local/bin/gpio - @rm -f /usr/local/man/man1/gpio.1 + @rm -f $(DESTDIR)$(PREFIX)/bin/gpio + @rm -f $(DESTDIR)$(PREFIX)/man/man1/gpio.1 -.PHONEY: depend +.PHONY: depend depend: makedepend -Y $(SRC) diff --git a/WiringPi/gpio/extensions.c b/WiringPi/gpio/extensions.c index dae1eac..96d6255 100644 --- a/WiringPi/gpio/extensions.c +++ b/WiringPi/gpio/extensions.c @@ -43,6 +43,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include "extensions.h" @@ -92,6 +100,43 @@ static char *extractInt (char *progName, char *p, int *num) } +/* + * extractStr: + * Check & return a string at the given location (prefixed by a :) + ********************************************************************************* + */ + +static char *extractStr (char *progName, char *p, char **str) +{ + char *q, *r ; + + if (*p != ':') + { + fprintf (stderr, "%s: colon expected\n", progName) ; + return NULL ; + } + + ++p ; + + if (!isprint (*p)) + { + fprintf (stderr, "%s: character expected\n", progName) ; + return NULL ; + } + + q = p ; + while ((*q != 0) && (*q != ':')) + ++q ; + + *str = r = calloc (q - p + 2, 1) ; // Zeros it + + while (p != q) + *r++ = *p++ ; + + return p ; +} + + /* * doExtensionMcp23008: @@ -330,6 +375,239 @@ static int doExtensionPcf8591 (char *progName, int pinBase, char *params) } +/* + * doExtensionMax31855: + * Analog IO + * max31855:base:spiChan + ********************************************************************************* + */ + +static int doExtensionMax31855 (char *progName, int pinBase, char *params) +{ + int spi ; + + if ((params = extractInt (progName, params, &spi)) == NULL) + return FALSE ; + + if ((spi < 0) || (spi > 1)) + { + fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ; + return FALSE ; + } + + max31855Setup (pinBase, spi) ; + + return TRUE ; +} + + +/* + * doExtensionMcp3002: + * Analog IO + * mcp3002:base:spiChan + ********************************************************************************* + */ + +static int doExtensionMcp3002 (char *progName, int pinBase, char *params) +{ + int spi ; + + if ((params = extractInt (progName, params, &spi)) == NULL) + return FALSE ; + + if ((spi < 0) || (spi > 1)) + { + fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ; + return FALSE ; + } + + mcp3002Setup (pinBase, spi) ; + + return TRUE ; +} + + +/* + * doExtensionMcp3004: + * Analog IO + * mcp3004:base:spiChan + ********************************************************************************* + */ + +static int doExtensionMcp3004 (char *progName, int pinBase, char *params) +{ + int spi ; + + if ((params = extractInt (progName, params, &spi)) == NULL) + return FALSE ; + + if ((spi < 0) || (spi > 1)) + { + fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ; + return FALSE ; + } + + mcp3004Setup (pinBase, spi) ; + + return TRUE ; +} + + +/* + * doExtensionMax5322: + * Analog O + * max5322:base:spiChan + ********************************************************************************* + */ + +static int doExtensionMax5322 (char *progName, int pinBase, char *params) +{ + int spi ; + + if ((params = extractInt (progName, params, &spi)) == NULL) + return FALSE ; + + if ((spi < 0) || (spi > 1)) + { + fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ; + return FALSE ; + } + + max5322Setup (pinBase, spi) ; + + return TRUE ; +} + + +/* + * doExtensionMcp4802: + * Analog IO + * mcp4802:base:spiChan + ********************************************************************************* + */ + +static int doExtensionMcp4802 (char *progName, int pinBase, char *params) +{ + int spi ; + + if ((params = extractInt (progName, params, &spi)) == NULL) + return FALSE ; + + if ((spi < 0) || (spi > 1)) + { + fprintf (stderr, "%s: SPI channel (%d) out of range\n", progName, spi) ; + return FALSE ; + } + + mcp4802Setup (pinBase, spi) ; + + return TRUE ; +} + + +/* + * doExtensionSn3218: + * Analog Output (LED Driver) + * sn3218:base + ********************************************************************************* + */ + +static int doExtensionSn3218 (char *progName, int pinBase, char *params) +{ + sn3218Setup (pinBase) ; + return TRUE ; +} + + +/* + * doExtensionMcp3422: + * Analog IO + * mcp3422:base:i2cAddr + ********************************************************************************* + */ + +static int doExtensionMcp3422 (char *progName, int pinBase, char *params) +{ + int i2c, sampleRate, gain ; + + if ((params = extractInt (progName, params, &i2c)) == NULL) + return FALSE ; + + if ((i2c < 0x03) || (i2c > 0x77)) + { + fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ; + return FALSE ; + } + + if ((params = extractInt (progName, params, &sampleRate)) == NULL) + return FALSE ; + + if ((sampleRate < 0) || (sampleRate > 3)) + { + fprintf (stderr, "%s: sample rate (%d) out of range\n", progName, sampleRate) ; + return FALSE ; + } + + if ((params = extractInt (progName, params, &gain)) == NULL) + return FALSE ; + + if ((gain < 0) || (gain > 3)) + { + fprintf (stderr, "%s: gain (%d) out of range\n", progName, gain) ; + return FALSE ; + } + + mcp3422Setup (pinBase, i2c, sampleRate, gain) ; + + return TRUE ; +} + +/* + * doExtensionDrcS: + * Interface to a DRC Serial system + * drcs:base:pins:serialPort:baud + ********************************************************************************* + */ + +static int doExtensionDrcS (char *progName, int pinBase, char *params) +{ + char *port ; + int pins, baud ; + + if ((params = extractInt (progName, params, &pins)) == NULL) + return FALSE ; + + if ((pins < 1) || (pins > 100)) + { + fprintf (stderr, "%s: pins (%d) out of range (2-100)\n", progName, pins) ; + return FALSE ; + } + + if ((params = extractStr (progName, params, &port)) == NULL) + return FALSE ; + + if (strlen (port) == 0) + { + fprintf (stderr, "%s: serial port device name required\n", progName) ; + return FALSE ; + } + + if ((params = extractInt (progName, params, &baud)) == NULL) + return FALSE ; + + if ((baud < 1) || (baud > 4000000)) + { + fprintf (stderr, "%s: baud rate (%d) out of range\n", progName, baud) ; + return FALSE ; + } + + drcSetupSerial (pinBase, pins, port, baud) ; + + return TRUE ; +} + + + /* * Function list ********************************************************************************* @@ -345,6 +623,14 @@ struct extensionFunctionStruct extensionFunctions [] = { "sr595", &doExtensionSr595 }, { "pcf8574", &doExtensionPcf8574 }, { "pcf8591", &doExtensionPcf8591 }, + { "mcp3002", &doExtensionMcp3002 }, + { "mcp3004", &doExtensionMcp3004 }, + { "mcp4802", &doExtensionMcp4802 }, + { "mcp3422", &doExtensionMcp3422 }, + { "max31855", &doExtensionMax31855 }, + { "max5322", &doExtensionMax5322 }, + { "sn3218", &doExtensionSn3218 }, + { "drcs", &doExtensionDrcS }, { NULL, NULL }, } ; diff --git a/WiringPi/gpio/gpio.1 b/WiringPi/gpio/gpio.1 index ae4df4e..e7131c1 100644 --- a/WiringPi/gpio/gpio.1 +++ b/WiringPi/gpio/gpio.1 @@ -13,11 +13,11 @@ gpio \- Command-line access to Raspberry Pi's GPIO .PP .B gpio .B [ \-x extension:params ] -.B mode/read/write/aread/awrite/pwm ... +.B mode/read/write/aread/awrite/pwm/pwmTone ... .PP .B gpio .B [ \-p ] -.B read/write/wb +.B read/write/toggle/wb .B ... .PP .B gpio @@ -39,6 +39,10 @@ gpio \- Command-line access to Raspberry Pi's GPIO group value .PP .B gpio +.B usbp +high | low +.PP +.B gpio .B pwm-bal/pwm-ms .PP .B gpio @@ -114,6 +118,28 @@ respective logic levels. Write the given value (0 or 1) to the pin. You need to set the pin to output mode first. +.TP +.B aread +Read the analog value of the given pin. This needs to be uses in +conjunction with a -x flag to add in an extension that handles analog +inputs. respective logic levels. + +e.g. gpio -x mcp3002:200:0 aread 200 + +will read the first analog input on an mcp3002 SPI ADC chip. + +.TP +.B awrite +Write the analog value to the given pin. This needs to be used in +conjunction with a -x flag to add in an extension that handles analog +inputs. respective logic levels. + +e.g. gpio -x mcp4802:200:0 awrite 200 128 + +will write the value 128 to the first DAC port on an mcp4802 chip on +the Pi's SPI bus 0. + + .TP .B wb Write the given byte to the 8 main GPIO pins. You can prefix it with 0x @@ -126,10 +152,19 @@ Output a table of all GPIO pins values. The values represent the actual values r if the pin is in input mode, or the last value written if the pin is in output mode. +The readall command is usable with an extension module (via the -x parameter), +but it's unable to determine pin modes or states, so will perform both a +digital and analog read on each pin in-turn. + .TP .B reset -Resets the GPIO - As much as it's possible to do. All pins are set to input -mode and all the internal pull-up/down resistors are disconnected (tristate mode). +Resets the GPIO - As much as it's possible to do. All pins are set to +input mode and all the internal pull-up/down resistors are disconnected +(tristate mode). + +The reset command is usable with an extension module (via the -x parameter), +but it's limited to turning the pin into input mode (if applicable) and +removing any pull up/down resistor. .TP .B pwm @@ -200,6 +235,13 @@ Change the pad driver value for the given pad group to the supplied drive value. Group is 0, 1 or 2 and value is 0-7. Do not use unless you are absolutely sure you know what you're doing. +.TP +.B usbp +high | low + +Change the USB current limiter to high (1.2 amps) or low (the default, 600mA) +This is only applicable to the model B+ + .TP .B pwm-bal/pwm-ms Change the PWM mode to balanced (the default) or mark:space ratio (traditional) @@ -212,8 +254,8 @@ Change the PWM range register. The default is 1024. .B load i2c [baudrate] This loads the i2c or drivers into the kernel and changes the permissions on the associated /dev/ entries so that the current user has access to -them. Optionally it will set the I2C baudrate to that supplied (or as -close as the Pi can manage) The default speed is 100Kb/sec. +them. Optionally it will set the I2C baudrate to that supplied in Kb/sec +(or as close as the Pi can manage) The default speed is 100Kb/sec. .TP .B load spi [buffer size in KB] diff --git a/WiringPi/gpio/gpio.c b/WiringPi/gpio/gpio.c index 871548e..c440874 100644 --- a/WiringPi/gpio/gpio.c +++ b/WiringPi/gpio/gpio.c @@ -43,15 +43,21 @@ extern int wiringPiDebug ; +// External functions I can't be bothered creating a separate .h file for: + +extern void doReadall (void) ; +extern void doPins (void) ; + #ifndef TRUE # define TRUE (1==1) # define FALSE (1==2) #endif -#define VERSION "2.05" -#define I2CDETECT "/usr/sbin/i2cdetect" +#define VERSION "2.20" +#define PI_USB_POWER_CONTROL 38 +#define I2CDETECT "/usr/sbin/i2cdetect" -static int wpMode ; +int wpMode ; char *usage = "Usage: gpio -v\n" " gpio -h\n" @@ -68,10 +74,32 @@ char *usage = "Usage: gpio -v\n" " gpio pwmc \n" " gpio load spi/i2c\n" " gpio i2cd/i2cdetect\n" + " gpio usbp high/low\n" " gpio gbr \n" " gpio gbw " ; // No trailing newline needed here. +#ifdef NOT_FOR_NOW +/* + * decodePin: + * Decode a pin "number" which can actually be a pin name to represent + * one of the Pi's on-board pins. + ********************************************************************************* + */ + +static int decodePin (const char *str) +{ + +// The first case - see if it's a number: + + if (isdigit (str [0])) + return atoi (str) ; + + return 0 ; +} +#endif + + /* * changeOwner: * Change the ownership of the file to the real userId of the calling @@ -236,62 +264,6 @@ static void doI2Cdetect (int argc, char *argv []) } -/* - * doReadall: - * Read all the GPIO pins - ********************************************************************************* - */ - -static char *pinNames [] = -{ - "GPIO 0", "GPIO 1", "GPIO 2", "GPIO 3", "GPIO 4", "GPIO 5", "GPIO 6", "GPIO 7", - "SDA ", "SCL ", - "CE0 ", "CE1 ", "MOSI ", "MISO ", "SCLK ", - "TxD ", "RxD ", - "GPIO 8", "GPIO 9", "GPIO10", "GPIO11", -} ; - -static char *alts [] = -{ - "IN ", "OUT ", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3" -} ; - -static int wpiToPhys [64] = -{ - 11, 12, 13, 15, 16, 18, 22, 7, // 0...7 - 3, 5, // 8...9 - 24, 26, 19, 21, 23, // 10..14 - 8, 10, // 15..16 - 3, 4, 5, 6, // 17..20 - 0,0,0,0,0,0,0,0,0,0,0, // 20..31 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 32..47 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 47..63 -} ; - -static void doReadall (void) -{ - int pin ; - - printf ("+----------+-Rev%d-+------+--------+------+-------+\n", piBoardRev ()) ; - printf ("| wiringPi | GPIO | Phys | Name | Mode | Value |\n") ; - printf ("+----------+------+------+--------+------+-------+\n") ; - - for (pin = 0 ; pin < 64 ; ++pin) // Crude, but effective - { - if (wpiPinToGpio (pin) == -1) - continue ; - - printf ("| %6d | %3d | %3d | %s | %s | %s |\n", - pin, wpiPinToGpio (pin), wpiToPhys [pin], - pinNames [pin], - alts [getAlt (pin)], - digitalRead (pin) == HIGH ? "High" : "Low ") ; - } - - printf ("+----------+------+------+--------+------+-------+\n") ; -} - - /* * doExports: * List all GPIO exports @@ -614,6 +586,24 @@ void doUnexportall (char *progName) } +/* + * doResetExternal: + * Load readallExternal, we try to do this with an external device. + ********************************************************************************* + */ + +static void doResetExternal (void) +{ + int pin ; + + for (pin = wiringPiNodes->pinBase ; pin <= wiringPiNodes->pinMax ; ++pin) + { + pinMode (pin, INPUT) ; + pullUpDnControl (pin, PUD_OFF) ; + } +} + + /* * doReset: * Reset the GPIO pins - as much as we can do @@ -624,16 +614,21 @@ static void doReset (char *progName) { int pin ; - doUnexportall (progName) ; - - for (pin = 0 ; pin < 64 ; ++pin) + if (wiringPiNodes != NULL) // External reset + doResetExternal () ; + else { - if (wpiPinToGpio (pin) == -1) - continue ; + doUnexportall (progName) ; - digitalWrite (pin, LOW) ; - pinMode (pin, INPUT) ; - pullUpDnControl (pin, PUD_OFF) ; + for (pin = 0 ; pin < 64 ; ++pin) + { + if (wpiPinToGpio (pin) == -1) + continue ; + + digitalWrite (pin, LOW) ; + pinMode (pin, INPUT) ; + pullUpDnControl (pin, PUD_OFF) ; + } } } @@ -659,13 +654,26 @@ void doMode (int argc, char *argv []) mode = argv [3] ; - /**/ if (strcasecmp (mode, "in") == 0) pinMode (pin, INPUT) ; - else if (strcasecmp (mode, "out") == 0) pinMode (pin, OUTPUT) ; - else if (strcasecmp (mode, "pwm") == 0) pinMode (pin, PWM_OUTPUT) ; - else if (strcasecmp (mode, "clock") == 0) pinMode (pin, GPIO_CLOCK) ; - else if (strcasecmp (mode, "up") == 0) pullUpDnControl (pin, PUD_UP) ; - else if (strcasecmp (mode, "down") == 0) pullUpDnControl (pin, PUD_DOWN) ; - else if (strcasecmp (mode, "tri") == 0) pullUpDnControl (pin, PUD_OFF) ; + /**/ if (strcasecmp (mode, "in") == 0) pinMode (pin, INPUT) ; + else if (strcasecmp (mode, "input") == 0) pinMode (pin, INPUT) ; + else if (strcasecmp (mode, "out") == 0) pinMode (pin, OUTPUT) ; + else if (strcasecmp (mode, "output") == 0) pinMode (pin, OUTPUT) ; + else if (strcasecmp (mode, "pwm") == 0) pinMode (pin, PWM_OUTPUT) ; + else if (strcasecmp (mode, "pwmTone") == 0) pinMode (pin, PWM_TONE_OUTPUT) ; + else if (strcasecmp (mode, "clock") == 0) pinMode (pin, GPIO_CLOCK) ; + else if (strcasecmp (mode, "up") == 0) pullUpDnControl (pin, PUD_UP) ; + else if (strcasecmp (mode, "down") == 0) pullUpDnControl (pin, PUD_DOWN) ; + else if (strcasecmp (mode, "tri") == 0) pullUpDnControl (pin, PUD_OFF) ; + else if (strcasecmp (mode, "off") == 0) pullUpDnControl (pin, PUD_OFF) ; + +// Undocumented + + else if (strcasecmp (mode, "alt0") == 0) pinModeAlt (pin, 0b100) ; + else if (strcasecmp (mode, "alt1") == 0) pinModeAlt (pin, 0b101) ; + else if (strcasecmp (mode, "alt2") == 0) pinModeAlt (pin, 0b110) ; + else if (strcasecmp (mode, "alt3") == 0) pinModeAlt (pin, 0b111) ; + else if (strcasecmp (mode, "alt4") == 0) pinModeAlt (pin, 0b011) ; + else if (strcasecmp (mode, "alt5") == 0) pinModeAlt (pin, 0b010) ; else { fprintf (stderr, "%s: Invalid mode: %s. Should be in/out/pwm/clock/up/down/tri\n", argv [1], mode) ; @@ -709,6 +717,58 @@ static void doPadDrive (int argc, char *argv []) } +/* + * doUsbP: + * Control USB Power - High (1.2A) or Low (600mA) + * gpio usbp high/low + ********************************************************************************* + */ + +static void doUsbP (int argc, char *argv []) +{ + int model, rev, mem, maker, overVolted ; + + if (argc != 3) + { + fprintf (stderr, "Usage: %s usbp high|low\n", argv [0]) ; + exit (1) ; + } + +// Make sure we're on a B+ + + piBoardId (&model, &rev, &mem, &maker, &overVolted) ; + + if (model != PI_MODEL_BP) + { + fprintf (stderr, "USB power contol is applicable to B+ boards only.\n") ; + exit (1) ; + } + +// Need to force BCM_GPIO mode: + + wiringPiSetupGpio () ; + + if ((strcasecmp (argv [2], "high") == 0) || (strcasecmp (argv [2], "hi") == 0)) + { + digitalWrite (PI_USB_POWER_CONTROL, 1) ; + pinMode (PI_USB_POWER_CONTROL, OUTPUT) ; + printf ("Switched to HIGH current USB (1.2A)\n") ; + return ; + } + + if ((strcasecmp (argv [2], "low") == 0) || (strcasecmp (argv [2], "lo") == 0)) + { + digitalWrite (PI_USB_POWER_CONTROL, 0) ; + pinMode (PI_USB_POWER_CONTROL, OUTPUT) ; + printf ("Switched to LOW current USB (600mA)\n") ; + return ; + } + + fprintf (stderr, "Usage: %s usbp high|low\n", argv [0]) ; + exit (1) ; +} + + /* * doGbw: * gpio gbw channel value @@ -735,7 +795,7 @@ static void doGbw (int argc, char *argv []) exit (1) ; } - if ((value < 0) || (value > 1023)) + if ((value < 0) || (value > 255)) { fprintf (stderr, "%s: gbw: Value must be from 0 to 255\n", argv [0]) ; exit (1) ; @@ -926,6 +986,30 @@ void doToggle (int argc, char *argv []) digitalWrite (pin, !digitalRead (pin)) ; } + +/* + * doPwmTone: + * Output a tone in a PWM pin + ********************************************************************************* + */ + +void doPwmTone (int argc, char *argv []) +{ + int pin, freq ; + + if (argc != 4) + { + fprintf (stderr, "Usage: %s pwmTone \n", argv [0]) ; + exit (1) ; + } + + pin = atoi (argv [2]) ; + freq = atoi (argv [3]) ; + + pwmToneWrite (pin, freq) ; +} + + /* * doClock: * Output a clock on a pin @@ -1037,6 +1121,7 @@ static void doPwmClock (int argc, char *argv []) int main (int argc, char *argv []) { int i ; + int model, rev, mem, maker, overVolted ; if (getenv ("WIRINGPI_DEBUG") != NULL) { @@ -1077,18 +1162,30 @@ int main (int argc, char *argv []) if (strcmp (argv [1], "-v") == 0) { printf ("gpio version: %s\n", VERSION) ; - printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ; + printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ; printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ; printf ("For details type: %s -warranty\n", argv [0]) ; printf ("\n") ; - printf ("This Raspberry Pi is a revision %d board.\n", piBoardRev ()) ; + piBoardId (&model, &rev, &mem, &maker, &overVolted) ; + if (model == PI_MODEL_UNKNOWN) + { + printf ("Your Raspberry Pi has an unknown model type. Please report this to\n") ; + printf (" projects@drogon.net\n") ; + printf ("with a copy of your /proc/cpuinfo if possible\n") ; + } + else + { + printf ("Raspberry Pi Details:\n") ; + printf (" Type: %s, Revision: %s, Memory: %dMB, Maker: %s %s\n", + piModelNames [model], piRevisionNames [rev], mem, piMakerNames [maker], overVolted ? "[OV]" : "") ; + } return 0 ; } if (strcasecmp (argv [1], "-warranty") == 0) { printf ("gpio version: %s\n", VERSION) ; - printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ; + printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ; printf ("\n") ; printf (" This program is free software; you can redistribute it and/or modify\n") ; printf (" it under the terms of the GNU Leser General Public License as published\n") ; @@ -1212,18 +1309,22 @@ int main (int argc, char *argv []) // Pi Specifics - else if (strcasecmp (argv [1], "pwm-bal" ) == 0) doPwmMode (PWM_MODE_BAL) ; - else if (strcasecmp (argv [1], "pwm-ms" ) == 0) doPwmMode (PWM_MODE_MS) ; - else if (strcasecmp (argv [1], "pwmr" ) == 0) doPwmRange (argc, argv) ; - else if (strcasecmp (argv [1], "pwmc" ) == 0) doPwmClock (argc, argv) ; - else if (strcasecmp (argv [1], "drive" ) == 0) doPadDrive (argc, argv) ; - else if (strcasecmp (argv [1], "readall" ) == 0) doReadall () ; - else if (strcasecmp (argv [1], "i2cdetect") == 0) doI2Cdetect (argc, argv) ; - else if (strcasecmp (argv [1], "i2cd" ) == 0) doI2Cdetect (argc, argv) ; - else if (strcasecmp (argv [1], "reset" ) == 0) doReset (argv [0]) ; - else if (strcasecmp (argv [1], "wb" ) == 0) doWriteByte (argc, argv) ; - else if (strcasecmp (argv [1], "clock" ) == 0) doClock (argc, argv) ; - else if (strcasecmp (argv [1], "wfi" ) == 0) doWfi (argc, argv) ; + else if (strcasecmp (argv [1], "pwm-bal" ) == 0) doPwmMode (PWM_MODE_BAL) ; + else if (strcasecmp (argv [1], "pwm-ms" ) == 0) doPwmMode (PWM_MODE_MS) ; + else if (strcasecmp (argv [1], "pwmr" ) == 0) doPwmRange (argc, argv) ; + else if (strcasecmp (argv [1], "pwmc" ) == 0) doPwmClock (argc, argv) ; + else if (strcasecmp (argv [1], "pwmTone" ) == 0) doPwmTone (argc, argv) ; + else if (strcasecmp (argv [1], "drive" ) == 0) doPadDrive (argc, argv) ; + else if (strcasecmp (argv [1], "usbp" ) == 0) doUsbP (argc, argv) ; + else if (strcasecmp (argv [1], "readall" ) == 0) doReadall () ; + else if (strcasecmp (argv [1], "nreadall" ) == 0) doReadall () ; + else if (strcasecmp (argv [1], "pins" ) == 0) doPins () ; + else if (strcasecmp (argv [1], "i2cdetect") == 0) doI2Cdetect (argc, argv) ; + else if (strcasecmp (argv [1], "i2cd" ) == 0) doI2Cdetect (argc, argv) ; + else if (strcasecmp (argv [1], "reset" ) == 0) doReset (argv [0]) ; + else if (strcasecmp (argv [1], "wb" ) == 0) doWriteByte (argc, argv) ; + else if (strcasecmp (argv [1], "clock" ) == 0) doClock (argc, argv) ; + else if (strcasecmp (argv [1], "wfi" ) == 0) doWfi (argc, argv) ; else { fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ; diff --git a/WiringPi/gpio/pins.c b/WiringPi/gpio/pins.c new file mode 100644 index 0000000..19fcc1a --- /dev/null +++ b/WiringPi/gpio/pins.c @@ -0,0 +1,33 @@ +/* + * pins.c: + * Just display a handy Pi pinnout diagram. + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + + +#include + +void doPins (void) +{ + printf ("The pins command has been deprecated - sorry. Please use the\n") ; + printf (" gpio readall\n") ; + printf ("command to get a list of the pinnouts for your Pi.\n") ; +} + diff --git a/WiringPi/gpio/readall.c b/WiringPi/gpio/readall.c new file mode 100644 index 0000000..76b5cfc --- /dev/null +++ b/WiringPi/gpio/readall.c @@ -0,0 +1,321 @@ +/* + * readall.c: + * The readall functions - getting a bit big, so split them out. + * Copyright (c) 2012-2013 Gordon Henderson + *********************************************************************** + * This file is part of wiringPi: + * https://projects.drogon.net/raspberry-pi/wiringpi/ + * + * wiringPi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * wiringPi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with wiringPi. If not, see . + *********************************************************************** + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +extern int wpMode ; + +#ifndef TRUE +# define TRUE (1==1) +# define FALSE (1==2) +#endif + +/* + * doReadallExternal: + * A relatively crude way to read the pins on an external device. + * We don't know the input/output mode of pins, but we can tell + * if it's an analog pin or a digital one... + ********************************************************************************* + */ + +static void doReadallExternal (void) +{ + int pin ; + + printf ("+------+---------+--------+\n") ; + printf ("| Pin | Digital | Analog |\n") ; + printf ("+------+---------+--------+\n") ; + + for (pin = wiringPiNodes->pinBase ; pin <= wiringPiNodes->pinMax ; ++pin) + printf ("| %4d | %4d | %4d |\n", pin, digitalRead (pin), analogRead (pin)) ; + + printf ("+------+---------+--------+\n") ; +} + + +/* + * doReadall: + * Read all the GPIO pins + * We also want to use this to read the state of pins on an externally + * connected device, so we need to do some fiddling with the internal + * wiringPi node structures - since the gpio command can only use + * one external device at a time, we'll use that to our advantage... + ********************************************************************************* + */ + +static char *alts [] = +{ + "IN", "OUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3" +} ; + +static int physToWpi [64] = +{ + -1, // 0 + -1, -1, // 1, 2 + 8, -1, + 9, -1, + 7, 15, + -1, 16, + 0, 1, + 2, -1, + 3, 4, + -1, 5, + 12, -1, + 13, 6, + 14, 10, + -1, 11, // 25, 26 + 30, 31, // Actually I2C, but not used + 21, -1, + 22, 26, + 23, -1, + 24, 27, + 25, 28, + -1, 29, + -1, -1, + -1, -1, + -1, -1, + -1, -1, + -1, -1, + 17, 18, + 19, 20, + -1, -1, -1, -1, -1, -1, -1, -1, -1 +} ; + +static char *physNames [64] = +{ + NULL, + + " 3.3v", "5v ", + " SDA.1", "5V ", + " SCL.1", "0v ", + "GPIO. 7", "TxD ", + " 0v", "RxD ", + "GPIO. 0", "GPIO. 1", + "GPIO. 2", "0v ", + "GPIO. 3", "GPIO. 4", + " 3.3v", "GPIO. 5", + " MOSI", "0v ", + " MISO", "GPIO. 6", + " SCLK", "CE0 ", + " 0v", "CE1 ", + " SDA.0", "SCL.0 ", + "GPIO.21", "0v ", + "GPIO.22", "GPIO.26", + "GPIO.23", "0v ", + "GPIO.24", "GPIO.27", + "GPIO.25", "GPIO.28", + " 0v", "GPIO.29", + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, + "GPIO.17", "GPIO.18", + "GPIO.19", "GPIO.20", + NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +} ; + + +/* + * readallPhys: + * Given a physical pin output the data on it and the next pin: + *| BCM | wPi | Name | Mode | Val| Physical |Val | Mode | Name | wPi | BCM | + ********************************************************************************* + */ + +static void readallPhys (int physPin) +{ + int pin ; + + if (physPinToGpio (physPin) == -1) + printf (" | | ") ; + else + printf (" | %3d | %3d", physPinToGpio (physPin), physToWpi [physPin]) ; + + printf (" | %s", physNames [physPin]) ; + + if (physToWpi [physPin] == -1) + printf (" | | ") ; + else + { + /**/ if (wpMode == WPI_MODE_GPIO) + pin = physPinToGpio (physPin) ; + else if (wpMode == WPI_MODE_PHYS) + pin = physPin ; + else + pin = physToWpi [physPin] ; + + printf (" | %4s", alts [getAlt (pin)]) ; + printf (" | %d", digitalRead (pin)) ; + } + +// Pin numbers: + + printf (" | %2d", physPin) ; + ++physPin ; + printf (" || %-2d", physPin) ; + +// Same, reversed + + if (physToWpi [physPin] == -1) + printf (" | | ") ; + else + { + /**/ if (wpMode == WPI_MODE_GPIO) + pin = physPinToGpio (physPin) ; + else if (wpMode == WPI_MODE_PHYS) + pin = physPin ; + else + pin = physToWpi [physPin] ; + + printf (" | %d", digitalRead (pin)) ; + printf (" | %-4s", alts [getAlt (pin)]) ; + } + + printf (" | %-5s", physNames [physPin]) ; + + if (physToWpi [physPin] == -1) + printf (" | | ") ; + else + printf (" | %-3d | %-3d", physToWpi [physPin], physPinToGpio (physPin)) ; + + printf (" |\n") ; +} + + +void cmReadall (void) +{ + int pin ; + + printf ("+-----+------+-------+ +-----+------+-------+\n") ; + printf ("| Pin | Mode | Value | | Pin | Mode | Value |\n") ; + printf ("+-----+------+-------+ +-----+------+-------+\n") ; + + for (pin = 0 ; pin < 28 ; ++pin) + { + printf ("| %3d ", pin) ; + printf ("| %-4s ", alts [getAlt (pin)]) ; + printf ("| %s ", digitalRead (pin) == HIGH ? "High" : "Low ") ; + printf ("| ") ; + printf ("| %3d ", pin + 28) ; + printf ("| %-4s ", alts [getAlt (pin + 28)]) ; + printf ("| %s ", digitalRead (pin + 28) == HIGH ? "High" : "Low ") ; + printf ("|\n") ; + } + + printf ("+-----+------+-------+ +-----+------+-------+\n") ; +} + + +/* + * abReadall: + * Read all the pins on the model A or B. + ********************************************************************************* + */ + +void abReadall (int model, int rev) +{ + int pin ; + char *type ; + + if (model == PI_MODEL_A) + type = " A" ; + else + if (rev == PI_VERSION_2) + type = "B2" ; + else + type = "B1" ; + + printf (" +-----+-----+---------+------+---+-Model %s-+---+------+---------+-----+-----+\n", type) ; + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; + for (pin = 1 ; pin <= 26 ; pin += 2) + readallPhys (pin) ; + + if (rev == PI_VERSION_2) // B version 2 + { + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; + for (pin = 51 ; pin <= 54 ; pin += 2) + readallPhys (pin) ; + } + + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; + printf (" +-----+-----+---------+------+---+-Model %s-+---+------+---------+-----+-----+\n", type) ; +} + + +/* + * bPlusReadall: + * Read all the pins on the model B+ + ********************************************************************************* + */ + +void bPlusReadall (void) +{ + int pin ; + + printf (" +-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+\n") ; + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; + for (pin = 1 ; pin <= 40 ; pin += 2) + readallPhys (pin) ; + printf (" +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n") ; + printf (" | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |\n") ; + printf (" +-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+\n") ; +} + + +void doReadall (void) +{ + int model, rev, mem, maker, overVolted ; + + if (wiringPiNodes != NULL) // External readall + { + doReadallExternal () ; + return ; + } + + piBoardId (&model, &rev, &mem, &maker, &overVolted) ; + + /**/ if ((model == PI_MODEL_A) || (model == PI_MODEL_B)) + abReadall (model, rev) ; + else if (model == PI_MODEL_BP) + bPlusReadall () ; + else if (model == PI_MODEL_CM) + cmReadall () ; + else + printf ("Oops - unable to determine board type... model: %d\n", model) ; +} diff --git a/WiringPi/wiringPi/Makefile b/WiringPi/wiringPi/Makefile index f0120bb..78d3612 100644 --- a/WiringPi/wiringPi/Makefile +++ b/WiringPi/wiringPi/Makefile @@ -35,7 +35,8 @@ DYNAMIC=libwiringPi.so.$(VERSION) DEBUG = -O2 CC = gcc INCLUDE = -I. -CFLAGS = $(DEBUG) -Wformat=2 -Wall $(INCLUDE) -Winline -pipe -fPIC +DEFS = -D_GNU_SOURCE +CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC LIBS = @@ -51,8 +52,10 @@ SRC = wiringPi.c \ mcp23s08.c mcp23s17.c \ sr595.c \ pcf8574.c pcf8591.c \ - mcp3002.c mcp4802.c mcp3422.c \ - drc.c + mcp3002.c mcp3004.c mcp4802.c mcp3422.c \ + max31855.c max5322.c \ + sn3218.c \ + drcSerial.c OBJ = $(SRC:.c=.o) @@ -96,17 +99,22 @@ install-headers: @install -m 0644 softTone.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringPiSPI.h $(DESTDIR)$(PREFIX)/include @install -m 0644 wiringPiI2C.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 drcSerial.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23008.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23016.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23017.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23s08.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp23s17.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 max31855.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 max5322.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp3002.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 mcp3004.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp4802.h $(DESTDIR)$(PREFIX)/include @install -m 0644 mcp3422.h $(DESTDIR)$(PREFIX)/include @install -m 0644 sr595.h $(DESTDIR)$(PREFIX)/include @install -m 0644 pcf8574.h $(DESTDIR)$(PREFIX)/include @install -m 0644 pcf8591.h $(DESTDIR)$(PREFIX)/include + @install -m 0644 sn3218.h $(DESTDIR)$(PREFIX)/include .PHONEY: install install: $(DYNAMIC) install-headers @@ -132,17 +140,22 @@ uninstall: @rm -f $(DESTDIR)$(PREFIX)/include/softTone.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiSPI.h @rm -f $(DESTDIR)$(PREFIX)/include/wiringPiI2C.h + @rm -f $(DESTDIR)$(PREFIX)/include/drcSerial.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23008.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23016.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23017.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s08.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp23s17.h + @rm -f $(DESTDIR)$(PREFIX)/include/max31855.h + @rm -f $(DESTDIR)$(PREFIX)/include/max5322.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp3002.h + @rm -f $(DESTDIR)$(PREFIX)/include/mcp3004.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp4802.h @rm -f $(DESTDIR)$(PREFIX)/include/mcp3422.h @rm -f $(DESTDIR)$(PREFIX)/include/sr595.h @rm -f $(DESTDIR)$(PREFIX)/include/pcf8574.h @rm -f $(DESTDIR)$(PREFIX)/include/pcf8591.h + @rm -f $(DESTDIR)$(PREFIX)/include/sn3218.h @rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPi.* @ldconfig @@ -153,7 +166,7 @@ depend: # DO NOT DELETE -wiringPi.o: wiringPi.h +wiringPi.o: softPwm.h softTone.h wiringPi.h wiringSerial.o: wiringSerial.h wiringShift.o: wiringPi.h wiringShift.h piHiPri.o: wiringPi.h @@ -171,6 +184,10 @@ sr595.o: wiringPi.h sr595.h pcf8574.o: wiringPi.h wiringPiI2C.h pcf8574.h pcf8591.o: wiringPi.h wiringPiI2C.h pcf8591.h mcp3002.o: wiringPi.h wiringPiSPI.h mcp3002.h +mcp3004.o: wiringPi.h wiringPiSPI.h mcp3004.h mcp4802.o: wiringPi.h wiringPiSPI.h mcp4802.h mcp3422.o: wiringPi.h wiringPiI2C.h mcp3422.h -drc.o: wiringPi.h wiringSerial.h drc.h +max31855.o: wiringPi.h wiringPiSPI.h max31855.h +max5322.o: wiringPi.h wiringPiSPI.h max5322.h +sn3218.o: wiringPi.h wiringPiI2C.h sn3218.h +drcSerial.o: wiringPi.h wiringSerial.h drcSerial.h diff --git a/WiringPi/wiringPi/drc.c b/WiringPi/wiringPi/drcSerial.c similarity index 91% rename from WiringPi/wiringPi/drc.c rename to WiringPi/wiringPi/drcSerial.c index 07baf17..6491a98 100644 --- a/WiringPi/wiringPi/drc.c +++ b/WiringPi/wiringPi/drcSerial.c @@ -1,6 +1,6 @@ /* - * drc.c: - * Extend wiringPi with the DRC control protocll to Arduino + * drcSerial.c: + * Extend wiringPi with the DRC Serial protocol (e.g. to Arduino) * Copyright (c) 2013 Gordon Henderson *********************************************************************** * This file is part of wiringPi: @@ -30,7 +30,7 @@ #include "wiringPi.h" #include "wiringSerial.h" -#include "drc.h" +#include "drcSerial.h" #ifndef TRUE # define TRUE (1==1) @@ -69,7 +69,7 @@ static void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int mod // Force pin into input mode serialPutchar (node->fd, 'i' ) ; - serialPutchar (node->fd, pin) ; + serialPutchar (node->fd, pin - node->pinBase) ; /**/ if (mode == PUD_UP) { @@ -148,14 +148,14 @@ static int myDigitalRead (struct wiringPiNodeStruct *node, int pin) ********************************************************************************* */ -int drcSetup (const int pinBase, const int numPins, const char *device) +int drcSetupSerial (const int pinBase, const int numPins, const char *device, const int baud) { int fd ; int ok, tries ; time_t then ; struct wiringPiNodeStruct *node ; - if ((fd = serialOpen (device, 115200)) < 0) + if ((fd = serialOpen (device, baud)) < 0) return wiringPiFailure (WPI_ALMOST, "Unable to open DRC device (%s): %s", device, strerror (errno)) ; delay (10) ; // May need longer if it's an Uno that reboots on the open... @@ -166,9 +166,9 @@ int drcSetup (const int pinBase, const int numPins, const char *device) (void)serialGetchar (fd) ; ok = FALSE ; - for (tries = 1 ; tries < 5 ; ++tries) + for (tries = 1 ; (tries < 5) && (!ok) ; ++tries) { - serialPutchar (fd, '@') ; + serialPutchar (fd, '@') ; // Ping then = time (NULL) + 2 ; while (time (NULL) < then) if (serialDataAvail (fd)) @@ -179,14 +179,12 @@ int drcSetup (const int pinBase, const int numPins, const char *device) break ; } } - if (ok) - break ; } if (!ok) { serialClose (fd) ; - return wiringPiFailure (WPI_FATAL, "Unable to communidate with DRC device") ; + return wiringPiFailure (WPI_FATAL, "Unable to communicate with DRC serial device") ; } node = wiringPiNewNode (pinBase, numPins) ; diff --git a/WiringPi/wiringPi/drc.h b/WiringPi/wiringPi/drcSerial.h similarity index 84% rename from WiringPi/wiringPi/drc.h rename to WiringPi/wiringPi/drcSerial.h index c2c4ff3..29e988e 100644 --- a/WiringPi/wiringPi/drc.h +++ b/WiringPi/wiringPi/drcSerial.h @@ -1,6 +1,6 @@ /* - * drc.h: - * Extend wiringPi with the DRC control protocll to Arduino + * drcSerial.h: + * Extend wiringPi with the DRC Serial protocol (e.g. to Arduino) * Copyright (c) 2013 Gordon Henderson *********************************************************************** * This file is part of wiringPi: @@ -26,8 +26,7 @@ extern "C" { #endif -int drcSetup (const int pinBase, const int numPins, const char *device) ; - +extern int drcSetupSerial (const int pinBase, const int numPins, const char *device, const int baud) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/mcp3002.c b/WiringPi/wiringPi/mcp3002.c index 2e7d5cf..5d44940 100644 --- a/WiringPi/wiringPi/mcp3002.c +++ b/WiringPi/wiringPi/mcp3002.c @@ -55,7 +55,7 @@ static int myAnalogRead (struct wiringPiNodeStruct *node, int pin) /* * mcp3002Setup: - * Create a new wiringPi device node for an mcp2003 on the Pi's + * Create a new wiringPi device node for an mcp3002 on the Pi's * SPI interface. ********************************************************************************* */ diff --git a/WiringPi/wiringPi/mcp3422.c b/WiringPi/wiringPi/mcp3422.c index 8e26d76..831aece 100644 --- a/WiringPi/wiringPi/mcp3422.c +++ b/WiringPi/wiringPi/mcp3422.c @@ -1,6 +1,7 @@ /* * mcp3422.c: * Extend wiringPi with the MCP3422 I2C ADC chip + * Also works for the MCP3423 and MCP3224 (4 channel) chips * Copyright (c) 2013 Gordon Henderson *********************************************************************** * This file is part of wiringPi: @@ -24,6 +25,7 @@ #include +#include #include #include #include @@ -43,7 +45,8 @@ int myAnalogRead (struct wiringPiNodeStruct *node, int chan) { - unsigned char config, b0, b1, b2, b3 ; + unsigned char config ; + unsigned char buffer [4] ; int value = 0 ; // One-shot mode, trigger plus the other configs. @@ -56,35 +59,26 @@ int myAnalogRead (struct wiringPiNodeStruct *node, int chan) { case MCP3422_SR_3_75: // 18 bits delay (270) ; - b0 = wiringPiI2CRead (node->fd) ; - b1 = wiringPiI2CRead (node->fd) ; - b2 = wiringPiI2CRead (node->fd) ; - b3 = wiringPiI2CRead (node->fd) ; - value = ((b0 & 3) << 16) | (b1 << 8) | b2 ; + read (node->fd, buffer, 4) ; + value = ((buffer [0] & 3) << 16) | (buffer [1] << 8) | buffer [0] ; break ; case MCP3422_SR_15: // 16 bits delay ( 70) ; - b0 = wiringPiI2CRead (node->fd) ; - b1 = wiringPiI2CRead (node->fd) ; - b2 = wiringPiI2CRead (node->fd) ; - value = (b0 << 8) | b1 ; + read (node->fd, buffer, 3) ; + value = (buffer [0] << 8) | buffer [1] ; break ; case MCP3422_SR_60: // 14 bits delay ( 17) ; - b0 = wiringPiI2CRead (node->fd) ; - b1 = wiringPiI2CRead (node->fd) ; - b2 = wiringPiI2CRead (node->fd) ; - value = ((b0 & 0x3F) << 8) | b1 ; + read (node->fd, buffer, 3) ; + value = ((buffer [0] & 0x3F) << 8) | buffer [1] ; break ; case MCP3422_SR_240: // 12 bits delay ( 5) ; - b0 = wiringPiI2CRead (node->fd) ; - b1 = wiringPiI2CRead (node->fd) ; - b2 = wiringPiI2CRead (node->fd) ; - value = ((b0 & 0x0F) << 8) | b1 ; + read (node->fd, buffer, 3) ; + value = ((buffer [0] & 0x0F) << 8) | buffer [0] ; break ; } @@ -98,7 +92,7 @@ int myAnalogRead (struct wiringPiNodeStruct *node, int chan) ********************************************************************************* */ -int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int gain) +int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain) { int fd ; struct wiringPiNodeStruct *node ; @@ -106,7 +100,7 @@ int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int if ((fd = wiringPiI2CSetup (i2cAddress)) < 0) return fd ; - node = wiringPiNewNode (pinBase, channels) ; + node = wiringPiNewNode (pinBase, 4) ; node->data0 = sampleRate ; node->data1 = gain ; diff --git a/WiringPi/wiringPi/mcp3422.h b/WiringPi/wiringPi/mcp3422.h index 8b4e350..bb4692d 100644 --- a/WiringPi/wiringPi/mcp3422.h +++ b/WiringPi/wiringPi/mcp3422.h @@ -36,7 +36,7 @@ extern "C" { #endif -extern int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int gain) ; +extern int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/softPwm.c b/WiringPi/wiringPi/softPwm.c index a4f0fc4..3c79ba7 100644 --- a/WiringPi/wiringPi/softPwm.c +++ b/WiringPi/wiringPi/softPwm.c @@ -1,7 +1,7 @@ /* * softPwm.c: * Provide 2 channels of software driven PWM. - * Copyright (c) 2012 Gordon Henderson + * Copyright (c) 2012-2014 Gordon Henderson *********************************************************************** * This file is part of wiringPi: * https://projects.drogon.net/raspberry-pi/wiringpi/ @@ -28,17 +28,22 @@ #include "wiringPi.h" #include "softPwm.h" +// MAX_PINS: +// This is more than the number of Pi pins because we can actually softPwm +// pins that are on GPIO expanders. It's not that efficient and more than 1 or +// 2 pins on e.g. (SPI) mcp23s17 won't really be that effective, however... + #define MAX_PINS 1024 // The PWM Frequency is derived from the "pulse time" below. Essentially, // the frequency is a function of the range and this pulse time. -// The total period will be range * pulse time in uS, so a pulse time -// of 100 and a range of 100 gives a period of 100 * 100 = 10,000 uS +// The total period will be range * pulse time in µS, so a pulse time +// of 100 and a range of 100 gives a period of 100 * 100 = 10,000 µS // which is a frequency of 100Hz. // // It's possible to get a higher frequency by lowering the pulse time, // however CPU uage will skyrocket as wiringPi uses a hard-loop to time -// periods under 100uS - this is because the Linux timer calls are just +// periods under 100µS - this is because the Linux timer calls are just // accurate at all, and have an overhead. // // Another way to increase the frequency is to reduce the range - however @@ -46,8 +51,9 @@ #define PULSE_TIME 100 -static int marks [MAX_PINS] ; -static int range [MAX_PINS] ; +static int marks [MAX_PINS] ; +static int range [MAX_PINS] ; +static pthread_t threads [MAX_PINS] ; int newPin = -1 ; @@ -61,11 +67,15 @@ int newPin = -1 ; static PI_THREAD (softPwmThread) { int pin, mark, space ; + struct sched_param param ; + + param.sched_priority = sched_get_priority_max (SCHED_RR) ; + pthread_setschedparam (pthread_self (), SCHED_RR, ¶m) ; pin = newPin ; newPin = -1 ; - piHiPri (50) ; + piHiPri (90) ; for (;;) { @@ -106,13 +116,20 @@ void softPwmWrite (int pin, int value) /* * softPwmCreate: - * Create a new PWM thread. + * Create a new softPWM thread. ********************************************************************************* */ int softPwmCreate (int pin, int initialValue, int pwmRange) { int res ; + pthread_t myThread ; + + if (range [pin] != 0) // Already running on this pin + return -1 ; + + if (range <= 0) + return -1 ; pinMode (pin, OUTPUT) ; digitalWrite (pin, LOW) ; @@ -121,10 +138,30 @@ int softPwmCreate (int pin, int initialValue, int pwmRange) range [pin] = pwmRange ; newPin = pin ; - res = piThreadCreate (softPwmThread) ; + res = pthread_create (&myThread, NULL, softPwmThread, NULL) ; while (newPin != -1) delay (1) ; + threads [pin] = myThread ; + return res ; } + + +/* + * softPwmStop: + * Stop an existing softPWM thread + ********************************************************************************* + */ + +void softPwmStop (int pin) +{ + if (range [pin] != 0) + { + pthread_cancel (threads [pin]) ; + pthread_join (threads [pin], NULL) ; + range [pin] = 0 ; + digitalWrite (pin, LOW) ; + } +} diff --git a/WiringPi/wiringPi/softPwm.h b/WiringPi/wiringPi/softPwm.h index 28ad299..0351da5 100644 --- a/WiringPi/wiringPi/softPwm.h +++ b/WiringPi/wiringPi/softPwm.h @@ -28,6 +28,7 @@ extern "C" { extern int softPwmCreate (int pin, int value, int range) ; extern void softPwmWrite (int pin, int value) ; +extern void softPwmStop (int pin) ; #ifdef __cplusplus } diff --git a/WiringPi/wiringPi/softTone.c b/WiringPi/wiringPi/softTone.c index b4a89f8..e2fb737 100644 --- a/WiringPi/wiringPi/softTone.c +++ b/WiringPi/wiringPi/softTone.c @@ -36,7 +36,8 @@ #define PULSE_TIME 100 -static int freqs [MAX_PINS] ; +static int freqs [MAX_PINS] ; +static pthread_t threads [MAX_PINS] ; static int newPin = -1 ; @@ -50,6 +51,10 @@ static int newPin = -1 ; static PI_THREAD (softToneThread) { int pin, freq, halfPeriod ; + struct sched_param param ; + + param.sched_priority = sched_get_priority_max (SCHED_RR) ; + pthread_setschedparam (pthread_self (), SCHED_RR, ¶m) ; pin = newPin ; newPin = -1 ; @@ -105,17 +110,41 @@ void softToneWrite (int pin, int freq) int softToneCreate (int pin) { int res ; + pthread_t myThread ; pinMode (pin, OUTPUT) ; digitalWrite (pin, LOW) ; + if (threads [pin] != 0) + return -1 ; + freqs [pin] = 0 ; newPin = pin ; - res = piThreadCreate (softToneThread) ; + res = pthread_create (&myThread, NULL, softToneThread, NULL) ; while (newPin != -1) delay (1) ; + threads [pin] = myThread ; + return res ; } + + +/* + * softToneStop: + * Stop an existing softTone thread + ********************************************************************************* + */ + +void softToneStop (int pin) +{ + if (threads [pin] != 0) + { + pthread_cancel (threads [pin]) ; + pthread_join (threads [pin], NULL) ; + threads [pin] = 0 ; + digitalWrite (pin, LOW) ; + } +} diff --git a/WiringPi/wiringPi/softTone.h b/WiringPi/wiringPi/softTone.h index d8b4e54..a93c5af 100644 --- a/WiringPi/wiringPi/softTone.h +++ b/WiringPi/wiringPi/softTone.h @@ -31,6 +31,7 @@ extern "C" { #endif extern int softToneCreate (int pin) ; +extern void softToneStop (int pin) ; extern void softToneWrite (int pin, int freq) ; #ifdef __cplusplus diff --git a/WiringPi/wiringPi/wiringPi.c b/WiringPi/wiringPi/wiringPi.c index b54ad29..e7ae386 100644 --- a/WiringPi/wiringPi/wiringPi.c +++ b/WiringPi/wiringPi/wiringPi.c @@ -70,6 +70,9 @@ #include #include +#include "softPwm.h" +#include "softTone.h" + #include "wiringPi.h" #ifndef TRUE @@ -194,6 +197,39 @@ static volatile uint32_t *timer ; static volatile uint32_t *timerIrqRaw ; #endif + +// Data for use with the boardId functions. +// The order of entries here to correspond with the PI_MODEL_X +// and PI_VERSION_X defines in wiringPi.h +// Only intended for the gpio command - use at your own risk! + +const char *piModelNames [5] = +{ + "Unknown", + "Model A", + "Model B", + "Model B+", + "Compute Module", +} ; + +const char *piRevisionNames [5] = +{ + "Unknown", + "1", + "1.1", + "1.2", + "2", +} ; + +const char *piMakerNames [4] = +{ + "Unknown", + "Egoman", + "Sony", + "Qusda", +} ; + + // Time for easy calculations static uint64_t epochMilli, epochMicro ; @@ -231,14 +267,16 @@ static void (*isrFunctions [64])(void) ; // pinToGpio: // Take a Wiring pin (0 through X) and re-map it to the BCM_GPIO pin -// Cope for 2 different board revisions here. +// Cope for 3 different board revisions here. static int *pinToGpio ; +// Revision 1, 1.1: + static int pinToGpioR1 [64] = { 17, 18, 21, 22, 23, 24, 25, 4, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7 - 0, 1, // I2C - SDA0, SCL0 wpi 8 - 9 + 0, 1, // I2C - SDA1, SCL1 wpi 8 - 9 8, 7, // SPI - CE1, CE0 wpi 10 - 11 10, 9, 11, // SPI - MOSI, MISO, SCLK wpi 12 - 14 14, 15, // UART - Tx, Rx wpi 15 - 16 @@ -250,6 +288,8 @@ static int pinToGpioR1 [64] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63 } ; +// Revision 2: + static int pinToGpioR2 [64] = { 17, 18, 27, 22, 23, 24, 25, 4, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7 @@ -257,11 +297,13 @@ static int pinToGpioR2 [64] = 8, 7, // SPI - CE1, CE0 wpi 10 - 11 10, 9, 11, // SPI - MOSI, MISO, SCLK wpi 12 - 14 14, 15, // UART - Tx, Rx wpi 15 - 16 - 28, 29, 30, 31, // New GPIOs 8 though 11 wpi 17 - 20 + 28, 29, 30, 31, // Rev 2: New GPIOs 8 though 11 wpi 17 - 20 + 5, 6, 13, 19, 26, // B+ wpi 21, 22, 23, 24, 25 + 12, 16, 20, 21, // B+ wpi 26, 27, 28, 29 + 0, 1, // B+ wpi 30, 31 // Padding: - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 31 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63 } ; @@ -270,6 +312,7 @@ static int pinToGpioR2 [64] = // physToGpio: // Take a physical pin (1 through 26) and re-map it to the BCM_GPIO pin // Cope for 2 different board revisions here. +// Also add in the P5 connector, so the P5 pins are 3,4,5,6, so 53,54,55,56 static int *physToGpio ; @@ -290,8 +333,6 @@ static int physToGpioR1 [64] = 11, 8, -1, 7, // 25, 26 -// Padding: - -1, -1, -1, -1, -1, // ... 31 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63 @@ -314,14 +355,31 @@ static int physToGpioR2 [64] = 11, 8, -1, 7, // 25, 26 -// Padding: +// B+ - -1, -1, -1, -1, -1, // ... 31 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63 + 0, 1, + 5, -1, + 6, 12, + 13, -1, + 19, 16, + 26, 20, + -1, 21, + +// the P5 connector on the Rev 2 boards: + + -1, -1, + -1, -1, + -1, -1, + -1, -1, + -1, -1, + 28, 29, + 30, 31, + -1, -1, + -1, -1, + -1, -1, + -1, -1, } ; - // gpioToGPFSEL: // Map a BCM_GPIO pin to it's Function Selection // control port. (GPFSEL 0-5) @@ -391,7 +449,7 @@ static uint8_t gpioToEDS [] = } ; // gpioToREN -// (Word) offset to the Rising edgde ENable register +// (Word) offset to the Rising edge ENable register static uint8_t gpioToREN [] = { @@ -541,26 +599,36 @@ int wiringPiFailure (int fatal, const char *message, ...) /* * piBoardRev: * Return a number representing the hardware revision of the board. - * Revision is currently 1 or 2. * - * Much confusion here )-: + * Revision 1 really means the early Model B's. + * Revision 2 is everything else - it covers the B, B+ and CM. + * * Seems there are some boards with 0000 in them (mistake in manufacture) - * and some board with 0005 in them (another mistake in manufacture?) * So the distinction between boards that I can see is: * 0000 - Error - * 0001 - Not used - * 0002 - Rev 1 - * 0003 - Rev 1 - * 0004 - Rev 2 (Early reports? - * 0005 - Rev 2 (but error?) - * 0006 - Rev 2 - * 0008 - Rev 2 - Model A - * 000e - Rev 2 + 512MB - * 000f - Rev 2 + 512MB + * 0001 - Not used + * 0002 - Model B, Rev 1, 256MB, Egoman + * 0003 - Model B, Rev 1.1, 256MB, Egoman, Fuses/D14 removed. + * 0004 - Model B, Rev 2, 256MB, Sony + * 0005 - Model B, Rev 2, 256MB, Qisda + * 0006 - Model B, Rev 2, 256MB, Egoman + * 0007 - Model A, Rev 2, 256MB, Egoman + * 0008 - Model A, Rev 2, 256MB, Sony + * 0009 - Model A, Rev 2, 256MB, Qisda + * 000d - Model B, Rev 2, 512MB, Egoman + * 000e - Model B, Rev 2, 512MB, Sony + * 000f - Model B, Rev 2, 512MB, Qisda + * 0010 - Model B+, Rev 1.2, 512MB, Sony + * 0011 - Pi CM, Rev 1.2, 512MB, Sony * * A small thorn is the olde style overvolting - that will add in * 1000000 * + * The Pi compute module has an revision of 0011 - since we only check the + * last digit, then it's 1, therefore it'll default to not 2 or 3 for a + * Rev 1, so will appear as a Rev 2. This is fine for the most part, but + * we'll properly detect the Compute Module later and adjust accordingly. + * ********************************************************************************* */ @@ -577,7 +645,7 @@ int piBoardRev (void) { FILE *cpuFd ; char line [120] ; - char *c, lastChar ; + char *c ; static int boardRev = -1 ; if (boardRev != -1) // No point checking twice @@ -595,12 +663,16 @@ int piBoardRev (void) if (strncmp (line, "Revision", 8) != 0) piBoardRevOops ("No \"Revision\" line") ; +// Chomp trailing CR/NL + for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) *c = 0 ; if (wiringPiDebug) printf ("piboardRev: Revision string: %s\n", line) ; +// Scan to first digit + for (c = line ; *c ; ++c) if (isdigit (*c)) break ; @@ -608,6 +680,11 @@ int piBoardRev (void) if (!isdigit (*c)) piBoardRevOops ("No numeric revision string") ; +// Make sure its long enough + + if (strlen (c) < 4) + piBoardRevOops ("Bogus \"Revision\" line (too small)") ; + // If you have overvolted the Pi, then it appears that the revision // has 100000 added to it! @@ -615,12 +692,14 @@ int piBoardRev (void) if (strlen (c) != 4) printf ("piboardRev: This Pi has/is overvolted!\n") ; - lastChar = line [strlen (line) - 1] ; +// Isolate last 4 characters: + + c = c + strlen (c) - 4 ; if (wiringPiDebug) - printf ("piboardRev: lastChar is: '%c' (%d, 0x%02X)\n", lastChar, lastChar, lastChar) ; + printf ("piboardRev: last4Chars are: \"%s\"\n", c) ; - /**/ if ((lastChar == '2') || (lastChar == '3')) + if ( (strcmp (c, "0002") == 0) || (strcmp (c, "0003") == 0)) boardRev = 1 ; else boardRev = 2 ; @@ -632,6 +711,82 @@ int piBoardRev (void) } +/* + * piBoardId: + * Do more digging into the board revision string as above, but return + * as much details as we can. + * This is undocumented and really only intended for the GPIO command. + * Use at your own risk! + ********************************************************************************* + */ + +void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) +{ + FILE *cpuFd ; + char line [120] ; + char *c ; + + (void)piBoardRev () ; // Call this first to make sure all's OK. Don't care about the result. + + if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL) + piBoardRevOops ("Unable to open /proc/cpuinfo") ; + + while (fgets (line, 120, cpuFd) != NULL) + if (strncmp (line, "Revision", 8) == 0) + break ; + + fclose (cpuFd) ; + + if (strncmp (line, "Revision", 8) != 0) + piBoardRevOops ("No \"Revision\" line") ; + +// Chomp trailing CR/NL + + for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c) + *c = 0 ; + + if (wiringPiDebug) + printf ("piboardId: Revision string: %s\n", line) ; + +// Scan to first digit + + for (c = line ; *c ; ++c) + if (isdigit (*c)) + break ; + +// Make sure its long enough + + if (strlen (c) < 4) + piBoardRevOops ("Bogus \"Revision\" line") ; + +// If longer than 4, we'll assume it's been overvolted + + *overVolted = strlen (c) > 4 ; + +// Extract last 4 characters: + + c = c + strlen (c) - 4 ; + +// Fill out the replys as appropriate + + /**/ if (strcmp (c, "0002") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0003") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0004") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "0005") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_QISDA ; } + else if (strcmp (c, "0006") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0007") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0008") == 0) { *model = PI_MODEL_A ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_SONY ; ; } + else if (strcmp (c, "0009") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_QISDA ; } + else if (strcmp (c, "000d") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 512 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "000e") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 512 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "000f") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 512 ; *maker = PI_MAKER_EGOMAN ; } + else if (strcmp (c, "0010") == 0) { *model = PI_MODEL_BP ; *rev = PI_VERSION_1_2 ; *mem = 512 ; *maker = PI_MAKER_SONY ; } + else if (strcmp (c, "0011") == 0) { *model = PI_MODEL_CM ; *rev = PI_VERSION_1_2 ; *mem = 512 ; *maker = PI_MAKER_SONY ; } + else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; } +} + + + /* * wpiPinToGpio: * Translate a wiringPi Pin number to native GPIO pin number. @@ -961,6 +1116,7 @@ void pinMode (int pin, int mode) { int fSel, shift, alt ; struct wiringPiNodeStruct *node = wiringPiNodes ; + int origPin = pin ; if ((pin & PI_GPIO_MASK) == 0) // On-board pin { @@ -971,6 +1127,9 @@ void pinMode (int pin, int mode) else if (wiringPiMode != WPI_MODE_GPIO) return ; + softPwmStop (origPin) ; + softToneStop (origPin) ; + fSel = gpioToGPFSEL [pin] ; shift = gpioToShift [pin] ; @@ -978,9 +1137,18 @@ void pinMode (int pin, int mode) *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) ; // Sets bits to zero = input else if (mode == OUTPUT) *(gpio + fSel) = (*(gpio + fSel) & ~(7 << shift)) | (1 << shift) ; + else if (mode == SOFT_PWM_OUTPUT) + softPwmCreate (origPin, 0, 100) ; + else if (mode == SOFT_TONE_OUTPUT) + softToneCreate (origPin) ; + else if (mode == PWM_TONE_OUTPUT) + { + pinMode (origPin, PWM_OUTPUT) ; // Call myself to enable PWM mode + pwmSetMode (PWM_MODE_MS) ; + } else if (mode == PWM_OUTPUT) { - if ((alt = gpioToPwmALT [pin]) == 0) // Not a PWM pin + if ((alt = gpioToPwmALT [pin]) == 0) // Not a hardware capable PWM pin return ; // Set pin to PWM mode @@ -990,7 +1158,7 @@ void pinMode (int pin, int mode) pwmSetMode (PWM_MODE_BAL) ; // Pi default mode pwmSetRange (1024) ; // Default range of 1024 - pwmSetClock (32) ; // 19.2 / 32 = 600KHz - Also starts the PWM + pwmSetClock (32) ; // 19.2 / 32 = 600KHz - Also starts the PWM } else if (mode == GPIO_CLOCK) { @@ -1203,6 +1371,28 @@ void analogWrite (int pin, int value) } +/* + * pwmToneWrite: + * Pi Specific. + * Output the given frequency on the Pi's PWM pin + ********************************************************************************* + */ + +void pwmToneWrite (int pin, int freq) +{ + int range ; + + if (freq == 0) + pwmWrite (pin, 0) ; // Off + else + { + range = 600000 / freq ; + pwmSetRange (range) ; + pwmWrite (pin, freq / 2) ; + } +} + + /* * digitalWriteByte: @@ -1369,8 +1559,18 @@ int wiringPiISR (int pin, int mode, void (*function)(void)) if (pid == 0) // Child, exec { - execl ("/usr/local/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; - return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; + /**/ if (access ("/usr/local/bin/gpio", X_OK) == 0) + { + execl ("/usr/local/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; + return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; + } + else if (access ("/usr/bin/gpio", X_OK) == 0) + { + execl ("/usr/bin/gpio", "gpio", "edge", pinS, modeS, (char *)NULL) ; + return wiringPiFailure (WPI_FATAL, "wiringPiISR: execl failed: %s\n", strerror (errno)) ; + } + else + return wiringPiFailure (WPI_FATAL, "wiringPiISR: Can't find gpio program\n") ; } else // Parent, wait wait (NULL) ; @@ -1531,13 +1731,16 @@ unsigned int micros (void) * * Default setup: Initialises the system into wiringPi Pin mode and uses the * memory mapped hardware directly. + * + * Changed now to revert to "gpio" mode if we're running on a Compute Module. ********************************************************************************* */ int wiringPiSetup (void) { - int fd ; - int boardRev ; + int fd ; + int boardRev ; + int model, rev, mem, maker, overVolted ; if (getenv (ENV_DEBUG) != NULL) wiringPiDebug = TRUE ; @@ -1553,12 +1756,12 @@ int wiringPiSetup (void) boardRev = piBoardRev () ; - if (boardRev == 1) + /**/ if (boardRev == 1) // A, B, Rev 1, 1.1 { pinToGpio = pinToGpioR1 ; physToGpio = physToGpioR1 ; } - else + else // A, B, Rev 2, B+, CM { pinToGpio = pinToGpioR2 ; physToGpio = physToGpioR2 ; @@ -1611,7 +1814,13 @@ int wiringPiSetup (void) initialiseEpoch () ; - wiringPiMode = WPI_MODE_PINS ; +// If we're running on a compute module, then wiringPi pin numbers don't really many anything... + + piBoardId (&model, &rev, &mem, &maker, &overVolted) ; + if (model == PI_MODEL_CM) + wiringPiMode = WPI_MODE_GPIO ; + else + wiringPiMode = WPI_MODE_PINS ; return 0 ; } diff --git a/WiringPi/wiringPi/wiringPi.h b/WiringPi/wiringPi/wiringPi.h index 7cfd2e5..2bc63ba 100644 --- a/WiringPi/wiringPi/wiringPi.h +++ b/WiringPi/wiringPi/wiringPi.h @@ -24,9 +24,6 @@ #ifndef __WIRING_PI_H__ #define __WIRING_PI_H__ -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif // Handy defines // Deprecated @@ -45,6 +42,9 @@ #define OUTPUT 1 #define PWM_OUTPUT 2 #define GPIO_CLOCK 3 +#define SOFT_PWM_OUTPUT 4 +#define SOFT_TONE_OUTPUT 5 +#define PWM_TONE_OUTPUT 6 #define LOW 0 #define HIGH 1 @@ -67,6 +67,33 @@ #define INT_EDGE_RISING 2 #define INT_EDGE_BOTH 3 +// Pi model types and version numbers +// Intended for the GPIO program Use at your own risk. + +#define PI_MODEL_UNKNOWN 0 +#define PI_MODEL_A 1 +#define PI_MODEL_B 2 +#define PI_MODEL_BP 3 +#define PI_MODEL_CM 4 + +#define PI_VERSION_UNKNOWN 0 +#define PI_VERSION_1 1 +#define PI_VERSION_1_1 2 +#define PI_VERSION_1_2 3 +#define PI_VERSION_2 4 + +#define PI_MAKER_UNKNOWN 0 +#define PI_MAKER_EGOMAN 1 +#define PI_MAKER_SONY 2 +#define PI_MAKER_QISDA 3 + +extern const char *piModelNames [5] ; +extern const char *piRevisionNames [5] ; +extern const char *piMakerNames [4] ; + + +// Intended for the GPIO program Use at your own risk. + // Threads #define PI_THREAD(X) void *X (void *dummy) @@ -118,6 +145,11 @@ extern struct wiringPiNodeStruct *wiringPiNodes ; extern "C" { #endif +// Data + +//extern const char *piModelNames [] ; +//extern const char *piRevisionNames[] ; + // Internal extern int wiringPiFailure (int fatal, const char *message, ...) ; @@ -150,10 +182,12 @@ extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio // On-Board Raspberry Pi hardware specific stuff extern int piBoardRev (void) ; +extern void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) ; extern int wpiPinToGpio (int wpiPin) ; extern int physPinToGpio (int physPin) ; extern void setPadDrive (int group, int value) ; extern int getAlt (int pin) ; +extern void pwmToneWrite (int pin, int freq) ; extern void digitalWriteByte (int value) ; extern void pwmSetMode (int mode) ; extern void pwmSetRange (unsigned int range) ; diff --git a/setup.py b/setup.py index ac52a91..22ce8eb 100644 --- a/setup.py +++ b/setup.py @@ -4,41 +4,42 @@ from setuptools import setup, find_packages, Extension _wiringpi2 = Extension( '_wiringpi2', + include_dirs=['WiringPi/wiringPi','WiringPi/devLib'], sources=[ - 'WiringPi/wiringPi/wiringPi.c', - 'WiringPi/wiringPi/wiringPiSPI.c', + 'WiringPi/devLib/ds1302.c', + 'WiringPi/devLib/gertboard.c', + 'WiringPi/devLib/lcd128x64.c', + 'WiringPi/devLib/lcd.c', + 'WiringPi/devLib/maxdetect.c', + 'WiringPi/devLib/piFace.c', + 'WiringPi/devLib/piGlow.c', + 'WiringPi/devLib/piNes.c', + 'WiringPi/wiringPi/drcSerial.c', 'WiringPi/wiringPi/max31855.c', 'WiringPi/wiringPi/max5322.c', - 'WiringPi/wiringPi/drc.c', - 'WiringPi/wiringPi/sn3218.c', - 'WiringPi/wiringPi/mcp23s17.c', - 'WiringPi/wiringPi/pcf8591.c', - 'WiringPi/wiringPi/softTone.c', - 'WiringPi/wiringPi/wiringSerial.c', 'WiringPi/wiringPi/mcp23008.c', + 'WiringPi/wiringPi/mcp23016.c', + 'WiringPi/wiringPi/mcp23017.c', + 'WiringPi/wiringPi/mcp23s08.c', + 'WiringPi/wiringPi/mcp23s17.c', 'WiringPi/wiringPi/mcp3002.c', 'WiringPi/wiringPi/mcp3004.c', - 'WiringPi/wiringPi/piHiPri.c', - 'WiringPi/wiringPi/sr595.c', - 'WiringPi/wiringPi/wiringShift.c', - 'WiringPi/wiringPi/mcp23016.c', 'WiringPi/wiringPi/mcp3422.c', - 'WiringPi/wiringPi/piThread.c', - 'WiringPi/wiringPi/mcp23017.c', 'WiringPi/wiringPi/mcp4802.c', - 'WiringPi/wiringPi/softPwm.c', - 'WiringPi/wiringPi/wiringPiI2C.c', - 'WiringPi/wiringPi/mcp23s08.c', 'WiringPi/wiringPi/pcf8574.c', + 'WiringPi/wiringPi/pcf8591.c', + 'WiringPi/wiringPi/piHiPri.c', + 'WiringPi/wiringPi/piThread.c', + 'WiringPi/wiringPi/sn3218.c', + 'WiringPi/wiringPi/softPwm.c', 'WiringPi/wiringPi/softServo.c', - 'WiringPi/devLib/ds1302.c', - 'WiringPi/devLib/lcd128x64.c', - 'WiringPi/devLib/maxdetect.c', - 'WiringPi/devLib/gertboard.c', - 'WiringPi/devLib/lcd.c', - 'WiringPi/devLib/piFace.c', - 'WiringPi/devLib/piNes.c', - 'WiringPi/devLib/piGlow.c', + 'WiringPi/wiringPi/softTone.c', + 'WiringPi/wiringPi/sr595.c', + 'WiringPi/wiringPi/wiringPi.c', + 'WiringPi/wiringPi/wiringPiI2C.c', + 'WiringPi/wiringPi/wiringPiSPI.c', + 'WiringPi/wiringPi/wiringSerial.c', + 'WiringPi/wiringPi/wiringShift.c', 'wiringpi_wrap.c' ], ) @@ -58,40 +59,41 @@ setup( install_requires=[], headers=[ 'WiringPi/wiringPi/wiringPi.h', + 'WiringPi/wiringPi/wiringPi.h', 'WiringPi/wiringPi/wiringPiI2C.h', + 'WiringPi/wiringPi/wiringPiSPI.h', + 'WiringPi/wiringPi/wiringSerial.h', + 'WiringPi/wiringPi/wiringShift.h', + 'WiringPi/devLib/ds1302.h', + 'WiringPi/devLib/font.h', + 'WiringPi/devLib/gertboard.h', + 'WiringPi/devLib/lcd128x64.h', + 'WiringPi/devLib/lcd.h', + 'WiringPi/devLib/maxdetect.h', + 'WiringPi/devLib/piFace.h', + 'WiringPi/devLib/piGlow.h', + 'WiringPi/devLib/piNes.h', + 'WiringPi/wiringPi/drcSerial.h', 'WiringPi/wiringPi/max31855.h', 'WiringPi/wiringPi/max5322.h', - 'WiringPi/wiringPi/drc.h', - 'WiringPi/wiringPi/sn3218.h', - 'WiringPi/wiringPi/mcp23s08.h', - 'WiringPi/wiringPi/mcp3422.h', - 'WiringPi/wiringPi/softServo.h', - 'WiringPi/wiringPi/wiringPiSPI.h', 'WiringPi/wiringPi/mcp23008.h', - 'WiringPi/wiringPi/mcp23s17.h', - 'WiringPi/wiringPi/mcp4802.h', - 'WiringPi/wiringPi/softTone.h', - 'WiringPi/wiringPi/wiringSerial.h', 'WiringPi/wiringPi/mcp23016.h', - 'WiringPi/wiringPi/mcp23x0817.h', - 'WiringPi/wiringPi/pcf8574.h', - 'WiringPi/wiringPi/sr595.h', - 'WiringPi/wiringPi/wiringShift.h', 'WiringPi/wiringPi/mcp23016reg.h', - 'WiringPi/wiringPi/mcp23x08.h', - 'WiringPi/wiringPi/pcf8591.h', 'WiringPi/wiringPi/mcp23017.h', + 'WiringPi/wiringPi/mcp23s08.h', + 'WiringPi/wiringPi/mcp23s17.h', + 'WiringPi/wiringPi/mcp23x0817.h', + 'WiringPi/wiringPi/mcp23x08.h', 'WiringPi/wiringPi/mcp3002.h', 'WiringPi/wiringPi/mcp3004.h', + 'WiringPi/wiringPi/mcp3422.h', + 'WiringPi/wiringPi/mcp4802.h', + 'WiringPi/wiringPi/pcf8574.h', + 'WiringPi/wiringPi/pcf8591.h', + 'WiringPi/wiringPi/sn3218.h', 'WiringPi/wiringPi/softPwm.h', - 'WiringPi/devLib/ds1302.h', - 'WiringPi/devLib/gertboard.h', - 'WiringPi/devLib/lcd.h', - 'WiringPi/devLib/piFace.h', - 'WiringPi/devLib/font.h', - 'WiringPi/devLib/lcd128x64.h', - 'WiringPi/devLib/maxdetect.h', - 'WiringPi/devLib/piNes.h' - 'WiringPi/devLib/piGlow.h', + 'WiringPi/wiringPi/softServo.h', + 'WiringPi/wiringPi/softTone.h', + 'WiringPi/wiringPi/sr595.h' ] ) diff --git a/wiringpi.i b/wiringpi.i index 6132a36..89832b4 100644 --- a/wiringpi.i +++ b/wiringpi.i @@ -2,54 +2,60 @@ %{ #include "WiringPi/wiringPi/wiringPi.h" -#include "WiringPi/wiringPi/wiringPiSPI.h" #include "WiringPi/wiringPi/wiringPiI2C.h" +#include "WiringPi/wiringPi/wiringPiSPI.h" #include "WiringPi/wiringPi/wiringSerial.h" #include "WiringPi/wiringPi/wiringShift.h" +#include "WiringPi/wiringPi/drcSerial.h" #include "WiringPi/wiringPi/max31855.h" #include "WiringPi/wiringPi/max5322.h" -#include "WiringPi/wiringPi/mcp23017.h" -#include "WiringPi/wiringPi/mcp4802.h" -#include "WiringPi/wiringPi/mcp3422.h" -#include "WiringPi/wiringPi/mcp23s08.h" #include "WiringPi/wiringPi/mcp23008.h" -#include "WiringPi/wiringPi/mcp23x08.h" #include "WiringPi/wiringPi/mcp23016.h" +#include "WiringPi/wiringPi/mcp23016reg.h" +#include "WiringPi/wiringPi/mcp23017.h" +#include "WiringPi/wiringPi/mcp23s08.h" +#include "WiringPi/wiringPi/mcp23s17.h" +#include "WiringPi/wiringPi/mcp23x0817.h" +#include "WiringPi/wiringPi/mcp23x08.h" #include "WiringPi/wiringPi/mcp3002.h" #include "WiringPi/wiringPi/mcp3004.h" -#include "WiringPi/wiringPi/mcp23016reg.h" -#include "WiringPi/wiringPi/sn3218.h" -#include "WiringPi/wiringPi/mcp23x0817.h" -#include "WiringPi/wiringPi/mcp23s17.h" +#include "WiringPi/wiringPi/mcp3422.h" +#include "WiringPi/wiringPi/mcp4802.h" #include "WiringPi/wiringPi/pcf8574.h" #include "WiringPi/wiringPi/pcf8591.h" -#include "WiringPi/wiringPi/drc.h" +#include "WiringPi/wiringPi/sn3218.h" #include "WiringPi/wiringPi/softPwm.h" #include "WiringPi/wiringPi/softServo.h" #include "WiringPi/wiringPi/softTone.h" #include "WiringPi/wiringPi/sr595.h" +#include "WiringPi/devLib/ds1302.h" +#include "WiringPi/devLib/font.h" #include "WiringPi/devLib/gertboard.h" #include "WiringPi/devLib/lcd128x64.h" -#include "WiringPi/devLib/font.h" #include "WiringPi/devLib/lcd.h" #include "WiringPi/devLib/maxdetect.h" #include "WiringPi/devLib/piFace.h" -#include "WiringPi/devLib/ds1302.h" -#include "WiringPi/devLib/piNes.h" #include "WiringPi/devLib/piGlow.h" +#include "WiringPi/devLib/piNes.h" %} %apply unsigned char { uint8_t }; +%typemap(in) (unsigned char *data, int len) { + $1 = (unsigned char *) PyString_AsString($input); + $2 = PyString_Size($input); +}; + +extern int wiringPiFailure (int fatal, const char *message, ...) ; +extern struct wiringPiNodeStruct *wiringPiFindNode (int pin) ; +extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ; // Core wiringPi functions - extern int wiringPiSetup (void) ; extern int wiringPiSetupSys (void) ; extern int wiringPiSetupGpio (void) ; extern int wiringPiSetupPhys (void) ; -extern int piFaceSetup (const int pinBase) ; - +extern void pinModeAlt (int pin, int mode) ; extern void pinMode (int pin, int mode) ; extern void pullUpDnControl (int pin, int pud) ; extern int digitalRead (int pin) ; @@ -59,11 +65,13 @@ extern int analogRead (int pin) ; extern void analogWrite (int pin, int value) ; // On-Board Raspberry Pi hardware specific stuff - extern int piBoardRev (void) ; +extern void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) ; extern int wpiPinToGpio (int wpiPin) ; +extern int physPinToGpio (int physPin) ; extern void setPadDrive (int group, int value) ; extern int getAlt (int pin) ; +extern void pwmToneWrite (int pin, int freq) ; extern void digitalWriteByte (int value) ; extern void pwmSetMode (int mode) ; extern void pwmSetRange (unsigned int range) ; @@ -71,112 +79,24 @@ extern void pwmSetClock (int divisor) ; extern void gpioClockSet (int pin, int freq) ; // Interrupts - -extern int (*waitForInterrupt) (int pin, int mS) ; +extern int waitForInterrupt (int pin, int mS) ; extern int wiringPiISR (int pin, int mode, void (*function)(void)) ; // Threads - -extern int piThreadCreate (void *(*fn)(void *)) ; -extern void piLock (int key) ; -extern void piUnlock (int key) ; +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 int piHiPri (const int pri) ; +// Delays and Timing extern void delay (unsigned int howLong) ; extern void delayMicroseconds (unsigned int howLong) ; extern unsigned int millis (void) ; extern unsigned int micros (void) ; -// WiringSerial - -extern int serialOpen (const char *device, const int baud) ; -extern void serialClose (const int fd) ; -extern void serialFlush (const int fd) ; -extern void serialPutchar (const int fd, const unsigned char c) ; -extern void serialPuts (const int fd, const char *s) ; -extern void serialPrintf (const int fd, const char *message, ...) ; -extern int serialDataAvail (const int fd) ; -extern int serialGetchar (const int fd) ; - -// Shifting - -extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val); -extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order); - -// Spi - -%typemap(in) (unsigned char *data, int len) { - $1 = (unsigned char *) PyString_AsString($input); - $2 = PyString_Size($input); -}; - -int wiringPiSPIGetFd (int channel) ; -int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ; -int wiringPiSPISetup (int channel, int speed) ; - -// i2c - -extern int wiringPiI2CSetupInterface (char *device, int devId) ; -extern int wiringPiI2CSetup (int devId) ; - -extern int wiringPiI2CRead (int fd) ; -extern int wiringPiI2CReadReg8 (int fd, int reg) ; -extern int wiringPiI2CReadReg16 (int fd, int reg) ; - -extern int wiringPiI2CWrite (int fd, int data) ; -extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; -extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; - -// Soft Tone - -extern int softToneCreate (int pin) ; -extern void softToneWrite (int pin, int frewq) ; - -// Soft Servo - -extern void softServoWrite (int pin, int value) ; -extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ; - -// Soft PWM - -extern int softPwmCreate (int pin, int value, int range) ; -extern void softPwmWrite (int pin, int value) ; - -// MCP and stuff - -extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; -extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; -extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; -extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; -extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ; -extern int mcp3002Setup (int pinBase, int spiChannel) ; -extern int mcp3422Setup (int pinBase, int i2cAddress, int channels, int sampleRate, int gain) ; -extern int mcp4802Setup (int pinBase, int spiChannel) ; -extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; -extern int pcf8591Setup (const int pinBase, const int i2cAddress) ; - -extern int sr595Setup (int pinBase, int numPins, int dataPin, int clockPin, int latchPin) ; - -// LCD -extern void lcdHome (const int fd) ; -extern void lcdClear (const int fd) ; -extern void lcdDisplay (const int fd, int state) ; -extern void lcdCursor (const int fd, int state) ; -extern void lcdCursorBlink (const int fd, int state) ; -extern void lcdSendCommand (const int fd, unsigned char command) ; -extern void lcdPosition (const int fd, int x, int y) ; -extern void lcdCharDef (const int fd, int index, unsigned char data [8]) ; -extern void lcdPutchar (const int fd, unsigned char data) ; -extern void lcdPuts (const int fd, const char *string) ; -extern void lcdPrintf (const int fd, const 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) ; - // ds1302 extern unsigned int ds1302rtcRead (const int reg) ; extern void ds1302rtcWrite (const int reg, const unsigned int data) ; @@ -193,7 +113,7 @@ extern int gertboardAnalogRead (const int chan) ; extern int gertboardSPISetup (void) ; extern int gertboardAnalogSetup (const int pinBase) ; -// LCD128x64 +// LCD 128x64 extern void lcd128x64setOrigin (int x, int y) ; extern void lcd128x64setOrientation (int orientation) ; extern void lcd128x64orientCoordinates (int *x, int *y) ; @@ -210,9 +130,25 @@ extern void lcd128x64update (void) ; extern void lcd128x64clear (int colour) ; extern int lcd128x64setup (void) ; -// NES Joystick -extern int setupNesJoystick (int dPin, int cPin, int lPin) ; -extern unsigned int readNesJoystick (int joystick) ; +// LCD +extern void lcdHome (const int fd) ; +extern void lcdClear (const int fd) ; +extern void lcdDisplay (const int fd, int state) ; +extern void lcdCursor (const int fd, int state) ; +extern void lcdCursorBlink (const int fd, int state) ; +extern void lcdSendCommand (const int fd, unsigned char command) ; +extern void lcdPosition (const int fd, int x, int y) ; +extern void lcdCharDef (const int fd, int index, unsigned char data [8]) ; +extern void lcdPutchar (const int fd, unsigned char data) ; +extern void lcdPuts (const int fd, const char *string) ; +extern void lcdPrintf (const int fd, const char *message, ...) ; +extern int lcdInit (const int rows, const int cols, const int bits, + const int rs, const int strb, + const int d0, const int d1, const int d2, const int d3, const int d4, + const int d5, const int d6, const int d7) ; + +// PiFace +extern int piFaceSetup (const int pinBase) ; // PiGlow extern void piGlow1 (const int leg, const int ring, const int intensity) ; @@ -220,4 +156,69 @@ extern void piGlowLeg (const int leg, const int intensity) ; extern void piGlowRing (const int ring, const int intensity) ; extern void piGlowSetup (int clear) ; +// NES +extern int setupNesJoystick (int dPin, int cPin, int lPin) ; +extern unsigned int readNesJoystick (int joystick) ; + +// Various IC setup functions +extern int sr595Setup (const int pinBase, const int numPins, const int dataPin, const int clockPin, const int latchPin) ; +extern int drcSetupSerial (const int pinBase, const int numPins, const char *device, const int baud) ; +extern int max31855Setup (int pinBase, int spiChannel) ; +extern int max5322Setup (int pinBase, int spiChannel) ; +extern int mcp23008Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23016Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23017Setup (const int pinBase, const int i2cAddress) ; +extern int mcp23s08Setup (const int pinBase, const int spiPort, const int devId) ; +extern int mcp23s17Setup (int pinBase, int spiPort, int devId) ; +extern int mcp3002Setup (int pinBase, int spiChannel) ; +extern int mcp3004Setup (int pinBase, int spiChannel) ; +extern int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain) ; +extern int mcp4802Setup (int pinBase, int spiChannel) ; +extern int pcf8574Setup (const int pinBase, const int i2cAddress) ; +extern int pcf8591Setup (const int pinBase, const int i2cAddress) ; +extern int sn3218Setup (int pinBase) ; + +// Soft PWM +extern int softPwmCreate (int pin, int value, int range) ; +extern void softPwmWrite (int pin, int value) ; +extern void softPwmStop (int pin) ; + +// Soft Servo +extern void softServoWrite (int pin, int value) ; +extern int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7) ; + +// Soft Tone +extern int softToneCreate (int pin) ; +extern void softToneStop (int pin) ; +extern void softToneWrite (int pin, int freq) ; + +// SPI +int wiringPiSPIGetFd (int channel) ; +int wiringPiSPIDataRW (int channel, unsigned char *data, int len) ; +int wiringPiSPISetup (int channel, int speed) ; + +// I2C +extern int wiringPiI2CRead (int fd) ; +extern int wiringPiI2CReadReg8 (int fd, int reg) ; +extern int wiringPiI2CReadReg16 (int fd, int reg) ; +extern int wiringPiI2CWrite (int fd, int data) ; +extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ; +extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ; +extern int wiringPiI2CSetupInterface (const char *device, int devId) ; +extern int wiringPiI2CSetup (const int devId) ; + +// WiringSerial +extern int serialOpen (const char *device, const int baud) ; +extern void serialClose (const int fd) ; +extern void serialFlush (const int fd) ; +extern void serialPutchar (const int fd, const unsigned char c) ; +extern void serialPuts (const int fd, const char *s) ; +extern void serialPrintf (const int fd, const char *message, ...) ; +extern int serialDataAvail (const int fd) ; +extern int serialGetchar (const int fd) ; + +// Shift Register +extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ; +extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ; + %include "wiringpi2-class.py" diff --git a/wiringpi2.py b/wiringpi2.py index b01b882..b9002ce 100644 --- a/wiringpi2.py +++ b/wiringpi2.py @@ -68,6 +68,18 @@ except AttributeError: +def wiringPiFailure(*args): + return _wiringpi2.wiringPiFailure(*args) +wiringPiFailure = _wiringpi2.wiringPiFailure + +def wiringPiFindNode(*args): + return _wiringpi2.wiringPiFindNode(*args) +wiringPiFindNode = _wiringpi2.wiringPiFindNode + +def wiringPiNewNode(*args): + return _wiringpi2.wiringPiNewNode(*args) +wiringPiNewNode = _wiringpi2.wiringPiNewNode + def wiringPiSetup(): return _wiringpi2.wiringPiSetup() wiringPiSetup = _wiringpi2.wiringPiSetup @@ -84,9 +96,9 @@ def wiringPiSetupPhys(): return _wiringpi2.wiringPiSetupPhys() wiringPiSetupPhys = _wiringpi2.wiringPiSetupPhys -def piFaceSetup(*args): - return _wiringpi2.piFaceSetup(*args) -piFaceSetup = _wiringpi2.piFaceSetup +def pinModeAlt(*args): + return _wiringpi2.pinModeAlt(*args) +pinModeAlt = _wiringpi2.pinModeAlt def pinMode(*args): return _wiringpi2.pinMode(*args) @@ -120,10 +132,18 @@ def piBoardRev(): return _wiringpi2.piBoardRev() piBoardRev = _wiringpi2.piBoardRev +def piBoardId(*args): + return _wiringpi2.piBoardId(*args) +piBoardId = _wiringpi2.piBoardId + def wpiPinToGpio(*args): return _wiringpi2.wpiPinToGpio(*args) wpiPinToGpio = _wiringpi2.wpiPinToGpio +def physPinToGpio(*args): + return _wiringpi2.physPinToGpio(*args) +physPinToGpio = _wiringpi2.physPinToGpio + def setPadDrive(*args): return _wiringpi2.setPadDrive(*args) setPadDrive = _wiringpi2.setPadDrive @@ -132,6 +152,10 @@ def getAlt(*args): return _wiringpi2.getAlt(*args) getAlt = _wiringpi2.getAlt +def pwmToneWrite(*args): + return _wiringpi2.pwmToneWrite(*args) +pwmToneWrite = _wiringpi2.pwmToneWrite + def digitalWriteByte(*args): return _wiringpi2.digitalWriteByte(*args) digitalWriteByte = _wiringpi2.digitalWriteByte @@ -152,6 +176,10 @@ def gpioClockSet(*args): return _wiringpi2.gpioClockSet(*args) gpioClockSet = _wiringpi2.gpioClockSet +def waitForInterrupt(*args): + return _wiringpi2.waitForInterrupt(*args) +waitForInterrupt = _wiringpi2.waitForInterrupt + def wiringPiISR(*args): return _wiringpi2.wiringPiISR(*args) wiringPiISR = _wiringpi2.wiringPiISR @@ -188,206 +216,6 @@ def micros(): return _wiringpi2.micros() micros = _wiringpi2.micros -def serialOpen(*args): - return _wiringpi2.serialOpen(*args) -serialOpen = _wiringpi2.serialOpen - -def serialClose(*args): - return _wiringpi2.serialClose(*args) -serialClose = _wiringpi2.serialClose - -def serialFlush(*args): - return _wiringpi2.serialFlush(*args) -serialFlush = _wiringpi2.serialFlush - -def serialPutchar(*args): - return _wiringpi2.serialPutchar(*args) -serialPutchar = _wiringpi2.serialPutchar - -def serialPuts(*args): - return _wiringpi2.serialPuts(*args) -serialPuts = _wiringpi2.serialPuts - -def serialPrintf(*args): - return _wiringpi2.serialPrintf(*args) -serialPrintf = _wiringpi2.serialPrintf - -def serialDataAvail(*args): - return _wiringpi2.serialDataAvail(*args) -serialDataAvail = _wiringpi2.serialDataAvail - -def serialGetchar(*args): - return _wiringpi2.serialGetchar(*args) -serialGetchar = _wiringpi2.serialGetchar - -def shiftOut(*args): - return _wiringpi2.shiftOut(*args) -shiftOut = _wiringpi2.shiftOut - -def shiftIn(*args): - return _wiringpi2.shiftIn(*args) -shiftIn = _wiringpi2.shiftIn - -def wiringPiSPIGetFd(*args): - return _wiringpi2.wiringPiSPIGetFd(*args) -wiringPiSPIGetFd = _wiringpi2.wiringPiSPIGetFd - -def wiringPiSPIDataRW(*args): - return _wiringpi2.wiringPiSPIDataRW(*args) -wiringPiSPIDataRW = _wiringpi2.wiringPiSPIDataRW - -def wiringPiSPISetup(*args): - return _wiringpi2.wiringPiSPISetup(*args) -wiringPiSPISetup = _wiringpi2.wiringPiSPISetup - -def wiringPiI2CSetupInterface(*args): - return _wiringpi2.wiringPiI2CSetupInterface(*args) -wiringPiI2CSetupInterface = _wiringpi2.wiringPiI2CSetupInterface - -def wiringPiI2CSetup(*args): - return _wiringpi2.wiringPiI2CSetup(*args) -wiringPiI2CSetup = _wiringpi2.wiringPiI2CSetup - -def wiringPiI2CRead(*args): - return _wiringpi2.wiringPiI2CRead(*args) -wiringPiI2CRead = _wiringpi2.wiringPiI2CRead - -def wiringPiI2CReadReg8(*args): - return _wiringpi2.wiringPiI2CReadReg8(*args) -wiringPiI2CReadReg8 = _wiringpi2.wiringPiI2CReadReg8 - -def wiringPiI2CReadReg16(*args): - return _wiringpi2.wiringPiI2CReadReg16(*args) -wiringPiI2CReadReg16 = _wiringpi2.wiringPiI2CReadReg16 - -def wiringPiI2CWrite(*args): - return _wiringpi2.wiringPiI2CWrite(*args) -wiringPiI2CWrite = _wiringpi2.wiringPiI2CWrite - -def wiringPiI2CWriteReg8(*args): - return _wiringpi2.wiringPiI2CWriteReg8(*args) -wiringPiI2CWriteReg8 = _wiringpi2.wiringPiI2CWriteReg8 - -def wiringPiI2CWriteReg16(*args): - return _wiringpi2.wiringPiI2CWriteReg16(*args) -wiringPiI2CWriteReg16 = _wiringpi2.wiringPiI2CWriteReg16 - -def softToneCreate(*args): - return _wiringpi2.softToneCreate(*args) -softToneCreate = _wiringpi2.softToneCreate - -def softToneWrite(*args): - return _wiringpi2.softToneWrite(*args) -softToneWrite = _wiringpi2.softToneWrite - -def softServoWrite(*args): - return _wiringpi2.softServoWrite(*args) -softServoWrite = _wiringpi2.softServoWrite - -def softServoSetup(*args): - return _wiringpi2.softServoSetup(*args) -softServoSetup = _wiringpi2.softServoSetup - -def softPwmCreate(*args): - return _wiringpi2.softPwmCreate(*args) -softPwmCreate = _wiringpi2.softPwmCreate - -def softPwmWrite(*args): - return _wiringpi2.softPwmWrite(*args) -softPwmWrite = _wiringpi2.softPwmWrite - -def mcp23008Setup(*args): - return _wiringpi2.mcp23008Setup(*args) -mcp23008Setup = _wiringpi2.mcp23008Setup - -def mcp23016Setup(*args): - return _wiringpi2.mcp23016Setup(*args) -mcp23016Setup = _wiringpi2.mcp23016Setup - -def mcp23017Setup(*args): - return _wiringpi2.mcp23017Setup(*args) -mcp23017Setup = _wiringpi2.mcp23017Setup - -def mcp23s08Setup(*args): - return _wiringpi2.mcp23s08Setup(*args) -mcp23s08Setup = _wiringpi2.mcp23s08Setup - -def mcp23s17Setup(*args): - return _wiringpi2.mcp23s17Setup(*args) -mcp23s17Setup = _wiringpi2.mcp23s17Setup - -def mcp3002Setup(*args): - return _wiringpi2.mcp3002Setup(*args) -mcp3002Setup = _wiringpi2.mcp3002Setup - -def mcp3422Setup(*args): - return _wiringpi2.mcp3422Setup(*args) -mcp3422Setup = _wiringpi2.mcp3422Setup - -def mcp4802Setup(*args): - return _wiringpi2.mcp4802Setup(*args) -mcp4802Setup = _wiringpi2.mcp4802Setup - -def pcf8574Setup(*args): - return _wiringpi2.pcf8574Setup(*args) -pcf8574Setup = _wiringpi2.pcf8574Setup - -def pcf8591Setup(*args): - return _wiringpi2.pcf8591Setup(*args) -pcf8591Setup = _wiringpi2.pcf8591Setup - -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 lcdDisplay(*args): - return _wiringpi2.lcdDisplay(*args) -lcdDisplay = _wiringpi2.lcdDisplay - -def lcdCursor(*args): - return _wiringpi2.lcdCursor(*args) -lcdCursor = _wiringpi2.lcdCursor - -def lcdCursorBlink(*args): - return _wiringpi2.lcdCursorBlink(*args) -lcdCursorBlink = _wiringpi2.lcdCursorBlink - -def lcdSendCommand(*args): - return _wiringpi2.lcdSendCommand(*args) -lcdSendCommand = _wiringpi2.lcdSendCommand - -def lcdPosition(*args): - return _wiringpi2.lcdPosition(*args) -lcdPosition = _wiringpi2.lcdPosition - -def lcdCharDef(*args): - return _wiringpi2.lcdCharDef(*args) -lcdCharDef = _wiringpi2.lcdCharDef - -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 - def ds1302rtcRead(*args): return _wiringpi2.ds1302rtcRead(*args) ds1302rtcRead = _wiringpi2.ds1302rtcRead @@ -496,13 +324,57 @@ def lcd128x64setup(): return _wiringpi2.lcd128x64setup() lcd128x64setup = _wiringpi2.lcd128x64setup -def setupNesJoystick(*args): - return _wiringpi2.setupNesJoystick(*args) -setupNesJoystick = _wiringpi2.setupNesJoystick +def lcdHome(*args): + return _wiringpi2.lcdHome(*args) +lcdHome = _wiringpi2.lcdHome -def readNesJoystick(*args): - return _wiringpi2.readNesJoystick(*args) -readNesJoystick = _wiringpi2.readNesJoystick +def lcdClear(*args): + return _wiringpi2.lcdClear(*args) +lcdClear = _wiringpi2.lcdClear + +def lcdDisplay(*args): + return _wiringpi2.lcdDisplay(*args) +lcdDisplay = _wiringpi2.lcdDisplay + +def lcdCursor(*args): + return _wiringpi2.lcdCursor(*args) +lcdCursor = _wiringpi2.lcdCursor + +def lcdCursorBlink(*args): + return _wiringpi2.lcdCursorBlink(*args) +lcdCursorBlink = _wiringpi2.lcdCursorBlink + +def lcdSendCommand(*args): + return _wiringpi2.lcdSendCommand(*args) +lcdSendCommand = _wiringpi2.lcdSendCommand + +def lcdPosition(*args): + return _wiringpi2.lcdPosition(*args) +lcdPosition = _wiringpi2.lcdPosition + +def lcdCharDef(*args): + return _wiringpi2.lcdCharDef(*args) +lcdCharDef = _wiringpi2.lcdCharDef + +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 + +def piFaceSetup(*args): + return _wiringpi2.piFaceSetup(*args) +piFaceSetup = _wiringpi2.piFaceSetup def piGlow1(*args): return _wiringpi2.piGlow1(*args) @@ -519,6 +391,194 @@ piGlowRing = _wiringpi2.piGlowRing def piGlowSetup(*args): return _wiringpi2.piGlowSetup(*args) piGlowSetup = _wiringpi2.piGlowSetup + +def setupNesJoystick(*args): + return _wiringpi2.setupNesJoystick(*args) +setupNesJoystick = _wiringpi2.setupNesJoystick + +def readNesJoystick(*args): + return _wiringpi2.readNesJoystick(*args) +readNesJoystick = _wiringpi2.readNesJoystick + +def sr595Setup(*args): + return _wiringpi2.sr595Setup(*args) +sr595Setup = _wiringpi2.sr595Setup + +def drcSetupSerial(*args): + return _wiringpi2.drcSetupSerial(*args) +drcSetupSerial = _wiringpi2.drcSetupSerial + +def max31855Setup(*args): + return _wiringpi2.max31855Setup(*args) +max31855Setup = _wiringpi2.max31855Setup + +def max5322Setup(*args): + return _wiringpi2.max5322Setup(*args) +max5322Setup = _wiringpi2.max5322Setup + +def mcp23008Setup(*args): + return _wiringpi2.mcp23008Setup(*args) +mcp23008Setup = _wiringpi2.mcp23008Setup + +def mcp23016Setup(*args): + return _wiringpi2.mcp23016Setup(*args) +mcp23016Setup = _wiringpi2.mcp23016Setup + +def mcp23017Setup(*args): + return _wiringpi2.mcp23017Setup(*args) +mcp23017Setup = _wiringpi2.mcp23017Setup + +def mcp23s08Setup(*args): + return _wiringpi2.mcp23s08Setup(*args) +mcp23s08Setup = _wiringpi2.mcp23s08Setup + +def mcp23s17Setup(*args): + return _wiringpi2.mcp23s17Setup(*args) +mcp23s17Setup = _wiringpi2.mcp23s17Setup + +def mcp3002Setup(*args): + return _wiringpi2.mcp3002Setup(*args) +mcp3002Setup = _wiringpi2.mcp3002Setup + +def mcp3004Setup(*args): + return _wiringpi2.mcp3004Setup(*args) +mcp3004Setup = _wiringpi2.mcp3004Setup + +def mcp3422Setup(*args): + return _wiringpi2.mcp3422Setup(*args) +mcp3422Setup = _wiringpi2.mcp3422Setup + +def mcp4802Setup(*args): + return _wiringpi2.mcp4802Setup(*args) +mcp4802Setup = _wiringpi2.mcp4802Setup + +def pcf8574Setup(*args): + return _wiringpi2.pcf8574Setup(*args) +pcf8574Setup = _wiringpi2.pcf8574Setup + +def pcf8591Setup(*args): + return _wiringpi2.pcf8591Setup(*args) +pcf8591Setup = _wiringpi2.pcf8591Setup + +def sn3218Setup(*args): + return _wiringpi2.sn3218Setup(*args) +sn3218Setup = _wiringpi2.sn3218Setup + +def softPwmCreate(*args): + return _wiringpi2.softPwmCreate(*args) +softPwmCreate = _wiringpi2.softPwmCreate + +def softPwmWrite(*args): + return _wiringpi2.softPwmWrite(*args) +softPwmWrite = _wiringpi2.softPwmWrite + +def softPwmStop(*args): + return _wiringpi2.softPwmStop(*args) +softPwmStop = _wiringpi2.softPwmStop + +def softServoWrite(*args): + return _wiringpi2.softServoWrite(*args) +softServoWrite = _wiringpi2.softServoWrite + +def softServoSetup(*args): + return _wiringpi2.softServoSetup(*args) +softServoSetup = _wiringpi2.softServoSetup + +def softToneCreate(*args): + return _wiringpi2.softToneCreate(*args) +softToneCreate = _wiringpi2.softToneCreate + +def softToneStop(*args): + return _wiringpi2.softToneStop(*args) +softToneStop = _wiringpi2.softToneStop + +def softToneWrite(*args): + return _wiringpi2.softToneWrite(*args) +softToneWrite = _wiringpi2.softToneWrite + +def wiringPiSPIGetFd(*args): + return _wiringpi2.wiringPiSPIGetFd(*args) +wiringPiSPIGetFd = _wiringpi2.wiringPiSPIGetFd + +def wiringPiSPIDataRW(*args): + return _wiringpi2.wiringPiSPIDataRW(*args) +wiringPiSPIDataRW = _wiringpi2.wiringPiSPIDataRW + +def wiringPiSPISetup(*args): + return _wiringpi2.wiringPiSPISetup(*args) +wiringPiSPISetup = _wiringpi2.wiringPiSPISetup + +def wiringPiI2CRead(*args): + return _wiringpi2.wiringPiI2CRead(*args) +wiringPiI2CRead = _wiringpi2.wiringPiI2CRead + +def wiringPiI2CReadReg8(*args): + return _wiringpi2.wiringPiI2CReadReg8(*args) +wiringPiI2CReadReg8 = _wiringpi2.wiringPiI2CReadReg8 + +def wiringPiI2CReadReg16(*args): + return _wiringpi2.wiringPiI2CReadReg16(*args) +wiringPiI2CReadReg16 = _wiringpi2.wiringPiI2CReadReg16 + +def wiringPiI2CWrite(*args): + return _wiringpi2.wiringPiI2CWrite(*args) +wiringPiI2CWrite = _wiringpi2.wiringPiI2CWrite + +def wiringPiI2CWriteReg8(*args): + return _wiringpi2.wiringPiI2CWriteReg8(*args) +wiringPiI2CWriteReg8 = _wiringpi2.wiringPiI2CWriteReg8 + +def wiringPiI2CWriteReg16(*args): + return _wiringpi2.wiringPiI2CWriteReg16(*args) +wiringPiI2CWriteReg16 = _wiringpi2.wiringPiI2CWriteReg16 + +def wiringPiI2CSetupInterface(*args): + return _wiringpi2.wiringPiI2CSetupInterface(*args) +wiringPiI2CSetupInterface = _wiringpi2.wiringPiI2CSetupInterface + +def wiringPiI2CSetup(*args): + return _wiringpi2.wiringPiI2CSetup(*args) +wiringPiI2CSetup = _wiringpi2.wiringPiI2CSetup + +def serialOpen(*args): + return _wiringpi2.serialOpen(*args) +serialOpen = _wiringpi2.serialOpen + +def serialClose(*args): + return _wiringpi2.serialClose(*args) +serialClose = _wiringpi2.serialClose + +def serialFlush(*args): + return _wiringpi2.serialFlush(*args) +serialFlush = _wiringpi2.serialFlush + +def serialPutchar(*args): + return _wiringpi2.serialPutchar(*args) +serialPutchar = _wiringpi2.serialPutchar + +def serialPuts(*args): + return _wiringpi2.serialPuts(*args) +serialPuts = _wiringpi2.serialPuts + +def serialPrintf(*args): + return _wiringpi2.serialPrintf(*args) +serialPrintf = _wiringpi2.serialPrintf + +def serialDataAvail(*args): + return _wiringpi2.serialDataAvail(*args) +serialDataAvail = _wiringpi2.serialDataAvail + +def serialGetchar(*args): + return _wiringpi2.serialGetchar(*args) +serialGetchar = _wiringpi2.serialGetchar + +def shiftIn(*args): + return _wiringpi2.shiftIn(*args) +shiftIn = _wiringpi2.shiftIn + +def shiftOut(*args): + return _wiringpi2.shiftOut(*args) +shiftOut = _wiringpi2.shiftOut class nes(object): def setupNesJoystick(self,*args): return setupNesJoystick(*args) @@ -674,7 +734,7 @@ class GPIO(object): def softPwmCreate(self,*args): return softPwmCreate(*args) def softPwmWrite(self,*args): - return softPwmWrite(*args) + return sofPwmWrite(*args) def softToneCreate(self,*args): return softToneCreate(*args) @@ -708,5 +768,4 @@ class GPIO(object): # This file is compatible with both classic and new-style classes. -cvar = _wiringpi2.cvar diff --git a/wiringpi2.pyc b/wiringpi2.pyc index ce0c5ccbf96903e38b86febc2e827825dd2ca4f6..a989bd1180f1d2f31f5026fd6992dbf1928fc53e 100644 GIT binary patch literal 30422 zcmeHQdvH|OdH+@t0)a8u81UP|7$XA)B;E!CdLSVqBym?*aIn2z_N=6Z)$V$Cg%A&8 zTiDpfZzpyVC$VEEaUAE>B(0OWshd|lnRJ@zWTu%;W}41qI_Wf>rqgtqPTOhv`+Zlt ztA{P_-K+mv;C`I@yXTzWd3@)6@3)n|oj=!^{iAS9#{SI0|GRPJmdzEh_!p9-$Y4lJ zNJ831muZ-4NmeQnl99O*uM#s$dQ(?ORlHh` z&z0=`5(W|??}sG`UL5GQI5+smIV^8lw%9TED*au5kv}Pp_qkY7br6P+IStMqW*hPw5rN~uct`d8dB8wGSEM~FT#fmIZWQmw1VwWhgRFS1( zmWo}f$kmEmE#_*mS1WRjBG-tyM(j0;T&u{nVy+c?ts>Vca-Ep##9pV!^@?0C=6bQ$ zD{_M(H;B1G>_#nvjaOp#?`mWf@a$jyq} zEaqmhH!HGSk>z5Ri(RhBEsESC<`%KHD6&G46=GJ1U7^UWirgyZR zsYsn7bz)`o!E7XtXE{cnDt`UD^jmWy_kBj^@=no(jcZmY=a^j z6xkqVgV+sHk=1#G9Dza0N zonm&1-KoefMRtkVC3cr0yA|0jX1CbgiZm+HD5gK^v+oVXdBF$o&#WpL_ zqDYIF7O^dg>``Qom_1_mDAKA(tC&`?t%|fM(k7-&Y?~r`71=9huh_kcv@6msrd@2i zB6lfrmzcZ6-lfPsMfQo=Cw8AA9g1{_=@8qY$bLoki`g%BzapKAbc*Q|+o?#GB3)v- z#C9pttw^_+Zn52p98lzdm;+)DDB>vMh;hU^ii8yjiwTPjE7GG#kC+~@J&GJu? zVh<{Ew<33oxm)briu5YdE2dX$uOf#OIV9$g*h7jOR^+gl!(tCBViYlAj98<{5k-!O zIU@FmBKIhAkC=PJ-lNF9irg#aUa|Koa-SmiiMdbgeTqaBiHM1ajVN-zBKM2AU+n#g zL=}mOiHeOXa#WF{VvdSEsz^+cn3$N@m?BmYE5?eoio_L(i;0VkE7GS(pO`+eeTwue z(l4f8Y`-D{iVTPu5IdkqLXm`+gxG{4#}qjx=9t)HiX2zuxR~Q&k1LW?Bq=5-HmS&< zB7AVur;ID{@kilVVPaJ*miu zA|ql(#EvL(N|94yPKiCG$Z17Ri#aX!v?6B|IV0wb*fWZpRphLgvtrLG@}MFQig{4% zgNmF}c}VO-iae~y!(tv5`>-O9DDsGyN5np&$fzQtVn)S|Dsod0gz{iaepn6Jnka z`-CD-D)OY5C&fOg$VEjiin%EEq9RWz@|2jT#6G3S(~3MT=4r7{EAosY&xmy_)`~xD}Ncp ziFh`bNT(u+R9`w#!ROT!xFkj~8y9Dp&A4)JL12n$E5>G-XGKE17fDvgS#_MPkdZn$ z6Ov<9Vk_kgXlBW1NcuxES|RsT3Ot;JtirtTMyblXQ_N#JFLYy?EoW!RnOPD(bf$t) zAFq+@=j7D&8tEL3v_j4x>M9wnlC#y)3s3NRtcIl(I&=m(1rn~SLTWq5WtUm8iEJu5 z7|&z6ERo?vHj(PjBpT{?o9FX%Zfz!-A8@pMDgh)0GkJ|Dor>q@0q9GlY-BKPhm!I9 z9Nb4DeTif|648h4gPC+TzbBhbXB`%%g2{BW7=lF^OQv)2I1;d~%O)~;)R7w_eUrZq|BH$o>#>-ZwV9Fpl>lk=r%jj~~LP%&~ z=(13Cs4`R+nh)13T$Q2gE9Qkd6U=ywsiYdP0JP%YfP=LWlH(PUMOBC#!@m&g0hJr( zvkHB7fLU?TW0kBd1~{Pgg#cBIWrs!Wq!1yLWR@JO)|jE{PzaZwfS`Iiddw9Nr$6#enM!$jsUhiEL&slwE;#5KLSc(PA5G?t9!a*;ggSnaA5 z41FS+9Ezjqpg!}_JXq;;iKbJFtKqAdF6K3oN~i1yqD{n>GctOR&}BmPSPa#e4OuPo zp(+b2VoU)qay8@1ErH0Rmb4~Ouc$64$S7KF9ksbrI}z<^oLby#dvvIO&UF;mQ{2D@ zxIRpi=i||YB(DdMWAqY=u|Sz3{;w(OgrlUU*Ob(B6dFf$Lob1jL%S8K8{CzW-8rUP zRAh8kcsx#{G$+nNM6C6r%HXhu$5%6IwOGv#3sLLXxrU*bz{$C$>UqmGVrE5cKmcv# zteyEkJx+xcVD$ zd)u*2GZJwY(om2j1))itG4bymTX#>8;d?&w&kfi^%n>MBZ!y`sod9D(?_ z)6FRZ9d&o2HJV5cW#jHh%o>bl`=`slvl@PshfzWMRYLIABR|!+$d7TXGi}`j zIBW2vR02~oe>U9Va#x*{-xYZncVH{u1$`~FQSG6BP%ATz^04ay53E6DRB+{46YCS?7 znMu~}0S|d?0ApkltIxK?O3x%x`=P>($-FzvTuO`Cjk4X0uUDV6vrDwzI5#3de=ttA zoXk)%c`(zGYEGx}*>uty_a+299*molMw{qQy_OA^eKJ&yys;s51el&oEJ z6Ft}#@X>Y}5$cs-#GG4EI-a&5cAgP7BB-1RmXaKiLPFk0#r3LCUe zG}Z5smy4k{XNtEunT{Rzmft<#d^;E~l?(e)X=O#Oy%Dz})K`NM>%=vh$hW4m?Wue` zn;pt{ByR)pH-eF~mJ1Wu_ORnE(|Zxq}!IXD}-Uq_(2P2)0;F-kUM0Ymfty((};Qe5n+$gj0WOT$E<9>Mm zaWF=%z?5-+B9_G-Zw$L@IdAOTx%$Z@cHDZNR8f%z6UpTGEfk$vO*~b{~Alxs4QIE@X zbkKXI!(jboFy?WYj`~>x^?>$Q!KfD?xLe*hAc-CKp6!DO`0HTYI;m1EQ*Ix%eK&}I z6O4Qjg1Z^V=|k*zGTuCZy+Dt%oL&U}Z7_b0yDmTG?${mkv`#sMK)(yddliEB$FupP zTnaYo>eolXA4cf^3YGvC{G`qn(t>KVGn9{EkoQL35AqGc$S0^e$USy317O}Vi5ZaRF>XR-4`nQu)(l?~QIl+C3*w%9a+goCk;>5|LZ zgwe_4?qdejy)!}`j;CyMdT=nB@_1(Q0H}`yqvlcsW!;_5CA`navIrCj#yh53TzIv_ z`@D6_IneSIoB&htG1_iFqd^|Dc$qQ??O2ZiT94zv5IBzq;~Z;6*Z@rBJr?i@u%?5t zj^(sHmGC&N90q4D7$frrdZ?vZoW;7VBTd^!)9~FyN!Q?_PUQSzeHqjZ+-IX56;e}6+ zg8|;pmW#p2IfcvOV8l1~g9!L+FmBd!F1u;lCLiT}4q;vlM$4hsW@Abkj%O25k8j&N zgm5nhqvkw)FnV%B{nkx>GW{@uy%LO>M~-0Lw4tHFM`=HTP_G6f)-1;|4I9?4-|B;T z6wGhT6m$J%AI#^${N{`?Z}GwWD45@#A?BQ~(tZrgU!5uDdOvx-0OoH5V^-CUWuRbw zRQqudzcW+B8-3LB6Ci$fW{5ZXYRpf9_`Mk+-ni9QQC|e{_k$B>VtrdTZShmoPl5RT z86w_R@1u^N2Jw%B5py<@OKoVV_tR@WgFrtC#>@UXm+s4V4-fizS>jm)`)M#{w&O8o zALm5RA=J-;5o=MqSq|sZ9uLT#2k*~=@p2-<3}X^p{VYx<)g{&g_oLZkBeI^j!T{!K7uE-nf$UEvh6EuL@nxZU$I zLjE=wInO}Hk+($iQK#42dhTNg`nzE4ld|qZ%RdhC{|ZLVbyXqj?G4S|&z(PkfWHsM z&2#Tb+)liItG9xG1%WH^*-wCNFP=b8<*(oDEdifI=-I&%Fuvwd_&&PUPl0@1F!D*c zS90&g|7j#(L9hfYo>=^a1b8j~R}p+suoPS~F$LQ4^nKGl?3#Jgg4Ynm(qO5Wqy;|O z|7SpcT`+Rp+tAI0u1wtHiwCcR_NHL8I+amcyj$$`^z#kyE}tph*5pubz*`-E7Q8Ei z@#?^;`SrEQ{y8wO4#r%nVDJ0vp9k%_V6-}gaWm{=tNl$7ZwN-r0WGJ*9L5_@;PX~* zwfqGH+!BntRLhvZct2Qw3(VVtF>}*BH<0Mdw|i{EUqpai!8m#Ns+?Uz9#1viMu_GT zsahgP!LS5i{e$U*`)M=ZOTvp5_(&SBdSIgq2IKHCIUSY!Y#LGMk(VCE^QH}#eua%w zDSSMR^>kP(z0<9F?mw44^uFY`PxRhaN@k47B8vwm?l${iqWAU^llzfA$3^`V++ji- zjS`M&&+os4=dFyW3XbYfO@*3baCeQT7BAmfEEca@wkTLw&M;~$h2=bpRxRkLmNA=s zvuV492n=4#R!5DR;R7q=BX6k zHE}y3T1_d;RehHLdkDYm>=N)U9lN2PAlw{-%Hhtqr^$B*;pRZ(mzymB+_^*Jh*`~r zs~PUxS_pI$P&vH5NSh&gbWf8pYOumpMVRIwj+RmCPZ+!E6m&ZgbM2uVjSgAobv$sB zN+Q?N#y9EuLx?(Du9)(o(U{Ga1dfIy5wu0gRnv2*27gse3(BJD=1R5LR7PQ3b6nC8 zR-88|R8JXBlQA7Rl_V0u$0Cu)eWmiMW9u!Mq;QJ)(3qXC^6A$o{($1^6yKouBZ_w* zN|frFl4^D zXD^06YYrkUb_y&=?U>k;v9za-D6ip(kDfqx(D-6?admODRN8)cKjV*g7QE-ki-MWb z`*_GE7x_N2$;QD$+P?DGxTN>N#yTS#7p(*3F@Dk?BRljl#`?`LRZ~upa^>zLldQpE z8XkaUvvTOTPWM5_94Z|PHB}xZ7v?@F*~ki%^_w##PMt`M>xI4zkIo-cyi4&X6yKrv zQ;PQ}{tV)heb2YxDM}j7J0|ox=zr9}RaWbuUmq3l+ISkt@{=bHVTl6Tyf9W`Pj{OaUX5 z8dsvpU$|lB7xN6v&EOLTe%-kl?E22pz7XboYt#WNzH`+93u^fc@K>)d91&%hdsEx3{QcOTkbu zY}?+d2u#|pR0k~C)~N#qY;RKs?AESQ2h7#3RtK!qu2Bb!)4B$JcNgsXHWtkJHWjS+ zHgoD*4_!&%6189F+A*x;Z50JA9>%Cng{v9v+>;QcsfcSb%e8NJGi}(7VlI#>_<+?g z+OgYC`)m^*%+d!voSRI1Fk2rC(oWsP2Q~WOF@aUAu?JA2!n~XNGujmPceU)vb6wlp z-5%jhq`SQ{?5yMS2{7A?!~EwtM=AOy90?x|JL{)}=-vysfiTzX#Sq=?t&Pol)T~)y zb5^&+XsQakaxA-&y)IbZfepfOZ*xzbYH(8WB0{O1IL@mUgyv4VrjEcIu!|%A_(_(| zs`le)DIu3!PtyBqOaapli&>0=PF_0Cn4YZ@-h8mp`|Fd~$jGZ1SB`T&411F-_k}*|dDr6}`VxK3j`FHhTYd`D}aqvC;dx<+HW=W25))l+U)+9~-^DS3cWD ze{A&rz4F<%_+z8@A5O>i;p^ee{+Q_f{ppydZ);8d*y#O7<+I)4kB#2{Vmh`DFU4*C znCSg4r(>GF6uBGkqsOB6znYHi!}Ik;e@yiL)AE=$`D3E@zb=o7L${C8qxZilk7=(z zCVKyQc}&mxW1{!JEsII*k>iyzyu7E!{yqxwIgtKcS)|TK{AG{ce_0;WOa7SX{qH}3 zsS>zO5xLUJV-e`?MV5|7bOM_6M@H}eP&V11FEZWS=0}Si`1ti7%O-um7pX(<|5P>^ zKjZVEkM#b}Ws{*&{gBc7zm!cj&=@Bdyl8Cs#AI-~dh zD4T4=9~r&>XW3+@{E^Z7f0s>m+8-Ic|4)gmj!T+xo5SDd?GGq^Nb%T_f3r*`XdbOojs8~ zEp2-u;XOSFvryAE2DLVJbhLN2={{M}pVJ;D#-X8zHFfpu)ns&pn_AnQaF5>XAG>kB z2fywi9k-+$?i4xP%yGEi;&3a(;ckV)jRc2ld}lXB69pHnjutwXcMexw4i`htMhY$+ zoXr%R{yLnQI-D>%oXa_!W;q9ySVK3yc zcW~Hh9kwQiTJBK$991GXrrqQDE}nDmE%z84g~LYuzhdl;|GVyz%SCX1+5E9%$;z6_ z;sND&m+PinPS!)KfH2Y@pD3*P7LOR}D~w(8^aeP-WUd&#F;7=_;vJBX2)cw@T{LPJee% z?4wXM{UH54z^5!SCrr^paggF}ie8FC6o)Ac#Sw~oDDI`Wk0L^GKSh+{C`F9IQp73x zDEcV|C|G&UF^c09s>y?Nr6|%A8H$o(=Xm=;+I^A_CTh2<@n`wqL5gz}4^cc!@d(8z z#d(THDX8Yo1&YTho}hS=;v&UU6i-t;Ls4ps&-3;L3hJQSHa|+&OB63te2n7b6rZ4Y zh2oPGpQ89Q#j6yrQGABtb&5AAK1=aAiqBKLN$~}WwoGM8YS51PvqF{F^`9TAVr#Cfsjit-i5CutEDFu7 YDz@rk`}}|8|4<2pmQ*iUyyVLN1(G3;8~^|S literal 34416 zcmeHQTW}QDnf^x-7lFBB@ZG`~Bik4u?idUR2?>Fa#y!G<1NJb?8A%PJnej|ZLR^e( zd`s-aNu0z`ImJ_P-z5^>WvS{}CYeU@mx);>c9|kj3uL*N!^mDp8^tX5>TnAKueD{`kIcZ#`F?463NQDlvnHDcE& zvR09`V%CaXtH@o7+$H8Nv3DtQw<33oxm)brirk~fJ!0+=dygXbDsr!wd&S}EaqXc4=b`kkqu%th~1#bBZ@pC<`J=vD6&zJ zjbb*6-Ka>bBCTRt#kMN)s3MPwc~tD9iae&sV`3f?`?Vh<|Pp-6|A4zV4I98%cB0Y-qi0KjAqsS3Oj)*xT_J|_A ziu8)<72B)GQALi5IV$$3BF7XtCgzyfV~X@C(kG@*Y@Z^>6*(^ExY*;0^efUYreAEo zA_IyHh#3$&ph#SixR|)uxFSz0^0b(z#XhZwr-&!U6YD9GP$VHHAvU4Npdy1}2E`64 zazc?4Vor!Xp~y3eJR{~AvCk+nq{xt%A+bY>oK)nbn3G~pDsoDZQ({huJ*9|I#E3Cs zjUuNNIW6Y2*wc!fQRIx6Gh)vu@~k4yig{M-vx+>Y$a7+z6Z@PZNkx)kl46sJoK@tk zn6qNfDw0wpB_<^{rN}u&&WSlE_M9SVMbcu@V$+IPMXVSr)+&-wBqJsxHlxU}BEw>a z#SSYnqR5Dt5wRnRj4CoJW>oB`BEBNN7+F|lKc?>vT)e4Fe;T&8SbDb_tqV)}U zM*iRM*BV1AxC3G$Q!M%UT++`C=lupApHG2J(i97@Ey31_t@JGjcvQAw+NruKaF?(z za-l)4YT{~xOts3DnD|X%8|4aaGf%F^WF#in8{|x*;DoD?O>lu)q$vpfsnwwi6slSv zSLexQBm58RNH8NEYnu-+qyCnnQXo=mdOQe zL;3^b{?;erQ^9CH*H-z(n+sFHN?cZ&^hc8TjbNP|&14IiB5zu{2SQ@YV|T>n#~Nd; zv89??g7ke2i(~yhvnS2pLW5y8RZN7X7L)T0l3yV)SOBaEXQRAe2ZF~eAm6f~)QW+Jcq9We;O%H8YDBzxB9$G_ zpt_-CgH(XKG8x_|x*6RCT^07skz_8Pvs1XapI*;f@&t)3krlBeu{GG5V|T_D$kNz? z*ouZUd2%BoHKH|01Sn4Y54%wlfk9nIlhDdK(yz^vwqafi_O+IKv{&z5iu)+;=K*Zd z>Ia*?SwCzGfD%baEX~3pZ~m*iJtSzHq4Co!%f^45Moa@nBc-jE4GkFSM#(QO+p1O& zG?-8_!$S2pd&{9*%Ug}hqs7cL8(2xjY&>SS+KhKMuOi90`9o87nLoHc3w|5ame{ed zw3lirFOH?zR`6G_!PA`TLShPoMilRiELw{`WQb$%SPV@Bc2Mn4hP}vi#^Ge-AnI^T zh8tzgbOT>vohuac7pGeC!!59!X%71~ls0cD?M1C@*{}6Hte0WUD`pBs)G%I}Oop{4 z8TJX&O?xuw-HC&0a+-VENR)yi+lJ^_r`?a%crw{T&V(e^C~L7Tis|i=d2M;pJi>#|ypi1vY?ejyQ04e36C8^z}Ht@7@t(5&? zmhp;!6)5a+;(j6%j29g7dK`Ltu$Ai~lKRK|xfNclO|y66Bq%7M6)yJ^aN{xNT zENVRkKkq2po`CKFm)zo`&hl+DcqQg=D>ock)U+j3Zu$};Z{5h+=(rU8?o>Jx+8Qs{ zZZK6GnNhs8R)#jH8^SiTWN(upTfl;!JD#_humfX1fQBk=b}Qd!o>l z>&)kZVm|AVAsy6YG=?l)>yP+BD(huZ)+IZ3TWn(^lq@^FX?85?jQYFj?^9er_Y3jZuhsnTPb*}ff`a@)r3gZ|f}QPc`CIflO9b^rPlh`kw& z9L)|5FvxkS+=x@N+Yi-myJFXw&8IK8w7mmh_D(c*>{~HOmsf7cL6`InLifAT=&@+a z9(!-XbIGm)s^5#oj?+d3e{i%2pQ#hVZMEg#@JrDMvdJs>eU8nJqrms05mTSZKaq1? zBRKo<)o9ehal{cnUi4j>+hMT!Ml@!eY_yqdYRVoN1^$r(a5nM2+5(N!t))6e(y1;{+TOw-P!Tds7rQzVD|H9 z>^Qj-=3RU|NROt9F8LjY@?S*bS2aBFbJ}k7gV-;lk)wY!oq2ei84SD3y8-C_RWy3b zD)hQiL8@aS(J0QE>yP)cdU!)FYwrp0`$II2bFvY` zFFeI@*tIYkxx0xCEdHVQz`c5f=qE3j{;nB9m0+N9F6PD>@0J2N%17;{UsVj zw%0SV)Ag+EDX9NzG={4_$k5A->~@)t2DkWIG?uGx$g+K>OPZ%~k4DtSnNI#~`qXnQ z()m318BkmhjpCe~REn+({8`Xk9E~R57no6T$~4`U_;a|)vS>UxB~;1}2ZMN{&Ha>6 z653ZqBdGq^G(qR~cozKDM&nn`z(l4vk#|lo1%mfFBEiqzOi&+>$WXhb~`U#yjLWTyW-cr(>cFk@N09%ZU=bI(-or=kCVDGPM?ZQf?UZ7xjH=Vx(ITU(a24=!>*roO@Z0v zXw0VD6TJA~_(9htaJv?b+jOq==6t75X)c4=^=QmEUbLn5ZCkb$gS6`jUA&GjuSes@ zmbk*t`G6ZAs>++u2+qjB)R^lGd;$F4j>d0B2BzH4SX=|accKyGLxr$}@$qZ=g6k}N z5$fNK#*p*iGZ;Fz!k3``y=WBq+#{rjuTIk!vKe-5ZeJ#S8MpXSG?sJeg*gVYBZWG>NzxB*O^ywi*L+f3Fwwz5aZM93Pn6& z4+oUg5dB@T*P!J)bGTtwKO^nIza=)v@UU<4HP{Ub+WC<8b+GtBG@2`+0)vqDt-CMo z+>Qz}P{cP*PCe;2aEBj9Bf0j2B(b^xJ|uVR^M44p`AIaU{0_X5o%x~O z`Rw$?tq{x9s=KGQ#nKcL;jP{^7}c=uzNdR&#aaj)x+&<^`}7Q4|50t zy5+2!#V#Bj@bc(6_i1SP;~ZkQnRBeUN~u3nI+~vz|DU5#q~#Uy9ao(g zeg^9Q5{)6JzzTj(Hb2?!vVZ$5)c!RZGfo_a%=$7TF1dXUivJdk8z-tmZXT8+b4l(! zXl}$(EYnX(bVaEg78C=lf8ZT1@It>CFMeP_8N8l?@hg_b#qvB%G;)a9J0e;uo&F5!Laze0Ul=^4L@W_`qp)EX>Jwtxxw;kp;e6NmYK#$ z_lpqD3G(N|n+QLVSs8`n({1|B0-exkKH3d7@dWjO8Cu8G31zitehpqWnXT{Gy> z{K{J=(xuH1T>nnj&EYC|`Y4_&CTblED-zZ_B#wGrZGWjqtT}|O#5SqY*uR3-dPeV! zCZEV{w)$w}7eZ;Jc?7Tjsm~w6DbCwOju_M{uYAz+5VMGMq`I=;EwDRT4|em)>>jR- z6gz3>S=I!l93?#RzlalUiJbJSjoNteQy1rX#V&W6SNqP#Y9n^09>i!_lUzt_Q*EU9 zIZIt~OG&X9H`hjt->*0)Mt8JKtbON}Dl>IdXSD7Af)l;3Q+$Ksn-t%o_%_9ND838f zs73!8RIMW!dcU*UaVIfTi><;W!ntq}$+K}3x(PRYh{c#_s~RFX%_!AKq}#~?wFj4<>FVq=66 zN1!kaG=kU|VSEvU#0bNRAQDCxO#}fj!XP4udlAMCLAZ-BWC)^MtW)v`ZV?6uK}?JF ziXfCl7!G7tISL2@S3IJJ5U*mRCJ?5gRTGF#5k~kxP>L|H2Vzl#@jMWMA`IhkfP0FQZM@FqH>_hW(9c~_)Kljjr%AtjG4>eZ~Evg)Xv6RPnd?!E+{`f%GVODBhdoPBPxx zpYR^%anAZyVAc$eIT6rToCPNnrxM<#4_pyH0+?=dzd~U7I9G$}iN~pwVeDs2s#}?1oKImJ~*`Zgg^C>f3V%mY% z4N;}*XikMn&ypvt=|&#a%{g&w@0=5ro}0soIlxVgoqjy>35Hv?FU_DMfWzr0&Sq8H z@LJ1|`p_KC%9~r^(d(E8^$pMA!Q$e^ywa7UD|Rz0OAh0(^YWomwn{T?=2r4$H_2#8 zxhWs&%g*6(i}|vr9{ED0h}ShMUv81lll9<3rG?t~?5zhMDlOK=XJ0+|P${~`zh7QA zZ~LCA2PZ0>tew;TdT^rBsoFUms0Sx1y<9t|gZ1DVo4(3W#T>~_Ohk?KnWI*csfpz|!E(y!G_ z>G?WP(nqU!skE~Xuk(GqW@_VgpypBOH*2OeQ4dN~`t6!2U91NsD*bNFl&0!IiAuj; zGo?%QphTrVteMi~dQhU$A5|%}9>o5P$4Nin?hh&cmEuPfKZXd_KvZU+PxSZp_YU@U z^z|kVcOkx?NN<1q#Gt;UF>qp#NqS)Mq2tLJyPN<|cJ>W)9@FRkeFH-}fqta7=ZH>K z$4_)62fDkpabUV@V5nbJa_2-`yEdxSN%rFj4QE-|Kh)8u0VR9;2a|`pdJZQOhX-*D z-I)s1-O<(RsX=+=4kozx5R=p}gUkF{s@&N9We-urh7wqqV!4v%%!W9{&0kDi(p5)Pb! z??KBp8q*6%lwa`Be;cOv_-~l5ra}b!cPyEH6{NAbvGP*L%v6}B47X}3M5?cnG_3O=s)o}-|L78+-YsdE%n)6H;qm|}!tl!Arlou{}!k);@;$Wi1e)Xtx0sz_0y z2q>y%Kgr!2*uDqXOT4QTG+XZ)#fua#QM^oXoq~qry-M*K#p@JrP<)8u!xV2)yhZU5 zijPvfP4O{`k5hbt;vI@lQhbWy(-iMge1_t)6rZDbkK*$bU!eFJ#rGhzp-fNU+Xw7K zuejQr?Zb0HM10;)8!!DSCbFD?Y?n317Bt*}sK|}6MTn6+kCn8sd4BV}M!dU4WL0c& bQ>C)bsDS^E{h!H!*qZrk?p(8S%^Uv>w{NX2 diff --git a/wiringpi_wrap.c b/wiringpi_wrap.c index 0eb71f3..a0f47a7 100644 --- a/wiringpi_wrap.c +++ b/wiringpi_wrap.c @@ -2929,11 +2929,11 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_char swig_types[0] -#define SWIGTYPE_p_f_int_int__int swig_types[1] -#define SWIGTYPE_p_f_p_void__p_void swig_types[2] -#define SWIGTYPE_p_f_void__void swig_types[3] -#define SWIGTYPE_p_int swig_types[4] -#define SWIGTYPE_p_unsigned_char swig_types[5] +#define SWIGTYPE_p_f_p_void__p_void swig_types[1] +#define SWIGTYPE_p_f_void__void swig_types[2] +#define SWIGTYPE_p_int swig_types[3] +#define SWIGTYPE_p_unsigned_char swig_types[4] +#define SWIGTYPE_p_wiringPiNodeStruct swig_types[5] static swig_type_info *swig_types[7]; static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) @@ -2968,48 +2968,41 @@ static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0}; #include "WiringPi/wiringPi/wiringPi.h" -#include "WiringPi/wiringPi/wiringPiSPI.h" #include "WiringPi/wiringPi/wiringPiI2C.h" +#include "WiringPi/wiringPi/wiringPiSPI.h" #include "WiringPi/wiringPi/wiringSerial.h" #include "WiringPi/wiringPi/wiringShift.h" +#include "WiringPi/wiringPi/drcSerial.h" #include "WiringPi/wiringPi/max31855.h" #include "WiringPi/wiringPi/max5322.h" -#include "WiringPi/wiringPi/mcp23017.h" -#include "WiringPi/wiringPi/mcp4802.h" -#include "WiringPi/wiringPi/mcp3422.h" -#include "WiringPi/wiringPi/mcp23s08.h" #include "WiringPi/wiringPi/mcp23008.h" -#include "WiringPi/wiringPi/mcp23x08.h" #include "WiringPi/wiringPi/mcp23016.h" +#include "WiringPi/wiringPi/mcp23016reg.h" +#include "WiringPi/wiringPi/mcp23017.h" +#include "WiringPi/wiringPi/mcp23s08.h" +#include "WiringPi/wiringPi/mcp23s17.h" +#include "WiringPi/wiringPi/mcp23x0817.h" +#include "WiringPi/wiringPi/mcp23x08.h" #include "WiringPi/wiringPi/mcp3002.h" #include "WiringPi/wiringPi/mcp3004.h" -#include "WiringPi/wiringPi/mcp23016reg.h" -#include "WiringPi/wiringPi/sn3218.h" -#include "WiringPi/wiringPi/mcp23x0817.h" -#include "WiringPi/wiringPi/mcp23s17.h" +#include "WiringPi/wiringPi/mcp3422.h" +#include "WiringPi/wiringPi/mcp4802.h" #include "WiringPi/wiringPi/pcf8574.h" #include "WiringPi/wiringPi/pcf8591.h" -#include "WiringPi/wiringPi/drc.h" +#include "WiringPi/wiringPi/sn3218.h" #include "WiringPi/wiringPi/softPwm.h" #include "WiringPi/wiringPi/softServo.h" #include "WiringPi/wiringPi/softTone.h" #include "WiringPi/wiringPi/sr595.h" +#include "WiringPi/devLib/ds1302.h" +#include "WiringPi/devLib/font.h" #include "WiringPi/devLib/gertboard.h" #include "WiringPi/devLib/lcd128x64.h" -#include "WiringPi/devLib/font.h" #include "WiringPi/devLib/lcd.h" #include "WiringPi/devLib/maxdetect.h" #include "WiringPi/devLib/piFace.h" -#include "WiringPi/devLib/ds1302.h" -#include "WiringPi/devLib/piNes.h" #include "WiringPi/devLib/piGlow.h" - - -SWIGINTERNINLINE PyObject* - SWIG_From_int (int value) -{ - return PyInt_FromLong((long) value); -} +#include "WiringPi/devLib/piNes.h" #include @@ -3157,73 +3150,6 @@ SWIG_AsVal_int (PyObject * obj, int *val) } -SWIGINTERN int -SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) -{ - if (PyInt_Check(obj)) { - long v = PyInt_AsLong(obj); - if (v >= 0) { - if (val) *val = v; - return SWIG_OK; - } else { - return SWIG_OverflowError; - } - } else if (PyLong_Check(obj)) { - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { - if (val) *val = (unsigned long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) -{ - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v > UINT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = (unsigned int)(v); - } - } - return res; -} - - -SWIGINTERNINLINE PyObject* - SWIG_From_unsigned_SS_int (unsigned int value) -{ - return PyInt_FromSize_t((size_t) value); -} - - SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { @@ -3316,6 +3242,80 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } + return res; +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_unsigned_SS_int (unsigned int value) +{ + return PyInt_FromSize_t((size_t) value); +} + + SWIGINTERN int SWIG_AsVal_unsigned_SS_char (PyObject * obj, unsigned char *val) { @@ -3352,6 +3352,108 @@ SWIG_From_unsigned_SS_char (unsigned char value) #ifdef __cplusplus extern "C" { #endif +SWIGINTERN PyObject *_wrap_wiringPiFailure__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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiFailure",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiFailure" "', 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 '" "wiringPiFailure" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)wiringPiFailure(arg1,(char const *)arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiFailure(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_wiringPiFailure__varargs__(NULL,newargs,varargs); + Py_XDECREF(newargs); + Py_XDECREF(varargs); + return resultobj; +} + + +SWIGINTERN PyObject *_wrap_wiringPiFindNode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + struct wiringPiNodeStruct *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:wiringPiFindNode",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiFindNode" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (struct wiringPiNodeStruct *)wiringPiFindNode(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_wiringPiNodeStruct, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiNewNode(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 ; + struct wiringPiNodeStruct *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiNewNode",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiNewNode" "', 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 '" "wiringPiNewNode" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (struct wiringPiNodeStruct *)wiringPiNewNode(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_wiringPiNodeStruct, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_wiringPiSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int result; @@ -3404,22 +3506,30 @@ fail: } -SWIGINTERN PyObject *_wrap_piFaceSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_pinModeAlt(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:piFaceSetup",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:pinModeAlt",&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "piFaceSetup" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pinModeAlt" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); - result = (int)piFaceSetup(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 '" "pinModeAlt" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + pinModeAlt(arg1,arg2); + resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; @@ -3633,6 +3743,63 @@ fail: } +SWIGINTERN PyObject *_wrap_piBoardId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int *arg1 = (int *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:piBoardId",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "piBoardId" "', argument " "1"" of type '" "int *""'"); + } + arg1 = (int *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "piBoardId" "', argument " "2"" of type '" "int *""'"); + } + arg2 = (int *)(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "piBoardId" "', argument " "3"" of type '" "int *""'"); + } + arg3 = (int *)(argp3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "piBoardId" "', argument " "4"" of type '" "int *""'"); + } + arg4 = (int *)(argp4); + res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "piBoardId" "', argument " "5"" of type '" "int *""'"); + } + arg5 = (int *)(argp5); + piBoardId(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_wpiPinToGpio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -3655,6 +3822,28 @@ fail: } +SWIGINTERN PyObject *_wrap_physPinToGpio(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:physPinToGpio",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "physPinToGpio" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)physPinToGpio(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_setPadDrive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -3707,6 +3896,36 @@ fail: } +SWIGINTERN PyObject *_wrap_pwmToneWrite(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:pwmToneWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pwmToneWrite" "', 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 '" "pwmToneWrite" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + pwmToneWrite(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_digitalWriteByte(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -3821,24 +4040,34 @@ fail: } -SWIGINTERN int Swig_var_waitForInterrupt_set(PyObject *_val) { - { - int res = SWIG_ConvertFunctionPtr(_val, (void**)(&waitForInterrupt), SWIGTYPE_p_f_int_int__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""waitForInterrupt""' of type '""int (*)(int,int)""'"); - } - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var_waitForInterrupt_get(void) { - PyObject *pyobj = 0; +SWIGINTERN PyObject *_wrap_waitForInterrupt(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; - pyobj = SWIG_NewFunctionPtrObj((void *)(waitForInterrupt), SWIGTYPE_p_f_int_int__int); - return pyobj; + if (!PyArg_ParseTuple(args,(char *)"OO:waitForInterrupt",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "waitForInterrupt" "', 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 '" "waitForInterrupt" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)waitForInterrupt(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; } @@ -4034,1789 +4263,6 @@ fail: } -SWIGINTERN PyObject *_wrap_serialOpen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int arg2 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:serialOpen",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "serialOpen" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "serialOpen" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)serialOpen((char const *)arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_serialClose(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:serialClose",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialClose" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - serialClose(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_serialFlush(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"O:serialFlush",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialFlush" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - serialFlush(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_serialPutchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - unsigned char arg2 ; - int val1 ; - int ecode1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OO:serialPutchar",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPutchar" "', 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 '" "serialPutchar" "', argument " "2"" of type '" "unsigned char""'"); - } - arg2 = (unsigned char)(val2); - serialPutchar(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_serialPuts(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:serialPuts",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPuts" "', 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 '" "serialPuts" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - serialPuts(arg1,(char const *)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_serialPrintf__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:serialPrintf",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPrintf" "', 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 '" "serialPrintf" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - serialPrintf(arg1,(char const *)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_serialPrintf(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_serialPrintf__varargs__(NULL,newargs,varargs); - Py_XDECREF(newargs); - Py_XDECREF(varargs); - return resultobj; -} - - -SWIGINTERN PyObject *_wrap_serialDataAvail(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:serialDataAvail",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialDataAvail" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (int)serialDataAvail(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_serialGetchar(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:serialGetchar",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialGetchar" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (int)serialGetchar(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_shiftOut(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - uint8_t arg1 ; - uint8_t arg2 ; - uint8_t arg3 ; - uint8_t arg4 ; - unsigned char val1 ; - int ecode1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - unsigned char val3 ; - int ecode3 = 0 ; - unsigned char val4 ; - int ecode4 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOOO:shiftOut",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "shiftOut" "', argument " "1"" of type '" "uint8_t""'"); - } - arg1 = (uint8_t)(val1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "shiftOut" "', argument " "2"" of type '" "uint8_t""'"); - } - arg2 = (uint8_t)(val2); - ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "shiftOut" "', argument " "3"" of type '" "uint8_t""'"); - } - arg3 = (uint8_t)(val3); - ecode4 = SWIG_AsVal_unsigned_SS_char(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "shiftOut" "', argument " "4"" of type '" "uint8_t""'"); - } - arg4 = (uint8_t)(val4); - shiftOut(arg1,arg2,arg3,arg4); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_shiftIn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - uint8_t arg1 ; - uint8_t arg2 ; - uint8_t arg3 ; - unsigned char val1 ; - int ecode1 = 0 ; - unsigned char val2 ; - int ecode2 = 0 ; - unsigned char val3 ; - int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - uint8_t result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:shiftIn",&obj0,&obj1,&obj2)) SWIG_fail; - ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "shiftIn" "', argument " "1"" of type '" "uint8_t""'"); - } - arg1 = (uint8_t)(val1); - ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "shiftIn" "', argument " "2"" of type '" "uint8_t""'"); - } - arg2 = (uint8_t)(val2); - ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "shiftIn" "', argument " "3"" of type '" "uint8_t""'"); - } - arg3 = (uint8_t)(val3); - result = shiftIn(arg1,arg2,arg3); - resultobj = SWIG_From_unsigned_SS_char((unsigned char)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiSPIGetFd(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:wiringPiSPIGetFd",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPIGetFd" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (int)wiringPiSPIGetFd(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiSPIDataRW(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - unsigned char *arg2 = (unsigned char *) 0 ; - int arg3 ; - int val1 ; - int ecode1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiSPIDataRW",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPIDataRW" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - { - arg2 = (unsigned char *) PyString_AsString(obj1); - arg3 = PyString_Size(obj1); - } - result = (int)wiringPiSPIDataRW(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiSPISetup(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:wiringPiSPISetup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPISetup" "', 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 '" "wiringPiSPISetup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)wiringPiSPISetup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CSetupInterface(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int arg2 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiI2CSetupInterface",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wiringPiI2CSetupInterface" "', argument " "1"" of type '" "char *""'"); - } - arg1 = (char *)(buf1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiI2CSetupInterface" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)wiringPiI2CSetupInterface(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CSetup(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:wiringPiI2CSetup",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CSetup" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (int)wiringPiI2CSetup(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CRead(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:wiringPiI2CRead",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CRead" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (int)wiringPiI2CRead(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CReadReg8(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:wiringPiI2CReadReg8",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CReadReg8" "', 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 '" "wiringPiI2CReadReg8" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)wiringPiI2CReadReg8(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CReadReg16(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:wiringPiI2CReadReg16",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CReadReg16" "', 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 '" "wiringPiI2CReadReg16" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)wiringPiI2CReadReg16(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CWrite(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:wiringPiI2CWrite",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWrite" "', 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 '" "wiringPiI2CWrite" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)wiringPiI2CWrite(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CWriteReg8(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 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:wiringPiI2CWriteReg8",&obj0,&obj1,&obj2)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWriteReg8" "', 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 '" "wiringPiI2CWriteReg8" "', 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 '" "wiringPiI2CWriteReg8" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)wiringPiI2CWriteReg8(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_wiringPiI2CWriteReg16(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 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:wiringPiI2CWriteReg16",&obj0,&obj1,&obj2)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWriteReg16" "', 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 '" "wiringPiI2CWriteReg16" "', 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 '" "wiringPiI2CWriteReg16" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)wiringPiI2CWriteReg16(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_softToneCreate(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:softToneCreate",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softToneCreate" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (int)softToneCreate(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_softToneWrite(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:softToneWrite",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softToneWrite" "', 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 '" "softToneWrite" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - softToneWrite(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_softServoWrite(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:softServoWrite",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softServoWrite" "', 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 '" "softServoWrite" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - softServoWrite(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_softServoSetup(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 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 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - PyObject * obj6 = 0 ; - PyObject * obj7 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:softServoSetup",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', argument " "8"" of type '" "int""'"); - } - arg8 = (int)(val8); - result = (int)softServoSetup(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_softPwmCreate(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 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:softPwmCreate",&obj0,&obj1,&obj2)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softPwmCreate" "', 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 '" "softPwmCreate" "', 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 '" "softPwmCreate" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)softPwmCreate(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_softPwmWrite(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:softPwmWrite",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softPwmWrite" "', 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 '" "softPwmWrite" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - softPwmWrite(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp23008Setup(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:mcp23008Setup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23008Setup" "', 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 '" "mcp23008Setup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)mcp23008Setup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp23016Setup(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:mcp23016Setup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23016Setup" "', 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 '" "mcp23016Setup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)mcp23016Setup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp23017Setup(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:mcp23017Setup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23017Setup" "', 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 '" "mcp23017Setup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)mcp23017Setup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp23s08Setup(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 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s08Setup",&obj0,&obj1,&obj2)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s08Setup" "', 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 '" "mcp23s08Setup" "', 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 '" "mcp23s08Setup" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)mcp23s08Setup(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp23s17Setup(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 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s17Setup",&obj0,&obj1,&obj2)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s17Setup" "', 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 '" "mcp23s17Setup" "', 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 '" "mcp23s17Setup" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)mcp23s17Setup(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp3002Setup(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:mcp3002Setup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp3002Setup" "', 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 '" "mcp3002Setup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)mcp3002Setup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp3422Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int arg2 ; - int arg3 ; - int arg4 ; - int arg5 ; - 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 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:mcp3422Setup",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - result = (int)mcp3422Setup(arg1,arg2,arg3,arg4,arg5); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mcp4802Setup(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:mcp4802Setup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp4802Setup" "', 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 '" "mcp4802Setup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)mcp4802Setup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pcf8574Setup(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:pcf8574Setup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pcf8574Setup" "', 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 '" "pcf8574Setup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)pcf8574Setup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pcf8591Setup(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:pcf8591Setup",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pcf8591Setup" "', 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 '" "pcf8591Setup" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)pcf8591Setup(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sr595Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int arg2 ; - int arg3 ; - int arg4 ; - int arg5 ; - 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 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - int result; - - if (!PyArg_ParseTuple(args,(char *)"OOOOO:sr595Setup",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "sr595Setup" "', 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 '" "sr595Setup" "', 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 '" "sr595Setup" "', 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 '" "sr595Setup" "', 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 '" "sr595Setup" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - result = (int)sr595Setup(arg1,arg2,arg3,arg4,arg5); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -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_lcdDisplay(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:lcdDisplay",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdDisplay" "', 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 '" "lcdDisplay" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - lcdDisplay(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_lcdCursor(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:lcdCursor",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCursor" "', 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 '" "lcdCursor" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - lcdCursor(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_lcdCursorBlink(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:lcdCursorBlink",&obj0,&obj1)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCursorBlink" "', 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 '" "lcdCursorBlink" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - lcdCursorBlink(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_lcdSendCommand(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - unsigned char 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 '" "unsigned char""'"); - } - arg2 = (unsigned char)(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_lcdCharDef(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int arg2 ; - unsigned char *arg3 ; - int val1 ; - int ecode1 = 0 ; - int val2 ; - int ecode2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - - if (!PyArg_ParseTuple(args,(char *)"OOO:lcdCharDef",&obj0,&obj1,&obj2)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCharDef" "', 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 '" "lcdCharDef" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_unsigned_char, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "lcdCharDef" "', argument " "3"" of type '" "unsigned char [8]""'"); - } - arg3 = (unsigned char *)(argp3); - lcdCharDef(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 ; - unsigned char 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 '" "unsigned char""'"); - } - arg2 = (unsigned char)(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 const *""'"); - } - arg2 = (char *)(buf2); - lcdPuts(arg1,(char const *)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 const *""'"); - } - arg2 = (char *)(buf2); - lcdPrintf(arg1,(char const *)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; -} - - SWIGINTERN PyObject *_wrap_ds1302rtcRead(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; @@ -6717,7 +5163,169 @@ fail: } -SWIGINTERN PyObject *_wrap_setupNesJoystick(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +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_lcdDisplay(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:lcdDisplay",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdDisplay" "', 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 '" "lcdDisplay" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + lcdDisplay(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdCursor(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:lcdCursor",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCursor" "', 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 '" "lcdCursor" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + lcdCursor(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdCursorBlink(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:lcdCursorBlink",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCursorBlink" "', 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 '" "lcdCursorBlink" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + lcdCursorBlink(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdSendCommand(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + unsigned char 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 '" "unsigned char""'"); + } + arg2 = (unsigned char)(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 ; @@ -6731,25 +5339,304 @@ SWIGINTERN PyObject *_wrap_setupNesJoystick(PyObject *SWIGUNUSEDPARM(self), PyOb PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; - int result; - if (!PyArg_ParseTuple(args,(char *)"OOO:setupNesJoystick",&obj0,&obj1,&obj2)) SWIG_fail; + 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 '" "setupNesJoystick" "', argument " "1"" of type '" "int""'"); + 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 '" "setupNesJoystick" "', argument " "2"" of type '" "int""'"); + 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 '" "setupNesJoystick" "', argument " "3"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "lcdPosition" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); - result = (int)setupNesJoystick(arg1,arg2,arg3); + lcdPosition(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lcdCharDef(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + unsigned char *arg3 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOO:lcdCharDef",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lcdCharDef" "', 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 '" "lcdCharDef" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "lcdCharDef" "', argument " "3"" of type '" "unsigned char [8]""'"); + } + arg3 = (unsigned char *)(argp3); + lcdCharDef(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 ; + unsigned char 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 '" "unsigned char""'"); + } + arg2 = (unsigned char)(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 const *""'"); + } + arg2 = (char *)(buf2); + lcdPuts(arg1,(char const *)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 const *""'"); + } + arg2 = (char *)(buf2); + lcdPrintf(arg1,(char const *)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: @@ -6757,22 +5644,22 @@ fail: } -SWIGINTERN PyObject *_wrap_readNesJoystick(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_piFaceSetup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; - unsigned int result; + int result; - if (!PyArg_ParseTuple(args,(char *)"O:readNesJoystick",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"O:piFaceSetup",&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "readNesJoystick" "', argument " "1"" of type '" "int""'"); + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "piFaceSetup" "', argument " "1"" of type '" "int""'"); } arg1 = (int)(val1); - result = (unsigned int)readNesJoystick(arg1); - resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + result = (int)piFaceSetup(arg1); + resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; @@ -6899,13 +5786,1580 @@ fail: } +SWIGINTERN PyObject *_wrap_setupNesJoystick(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:setupNesJoystick",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "setupNesJoystick" "', 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 '" "setupNesJoystick" "', 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 '" "setupNesJoystick" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)setupNesJoystick(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_readNesJoystick(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + unsigned int result; + + if (!PyArg_ParseTuple(args,(char *)"O:readNesJoystick",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "readNesJoystick" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (unsigned int)readNesJoystick(arg1); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sr595Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOO:sr595Setup",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "sr595Setup" "', 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 '" "sr595Setup" "', 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 '" "sr595Setup" "', 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 '" "sr595Setup" "', 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 '" "sr595Setup" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + result = (int)sr595Setup(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_drcSetupSerial(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + char *arg3 = (char *) 0 ; + int arg4 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:drcSetupSerial",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "drcSetupSerial" "', 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 '" "drcSetupSerial" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "drcSetupSerial" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "drcSetupSerial" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + result = (int)drcSetupSerial(arg1,arg2,(char const *)arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_max31855Setup(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:max31855Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "max31855Setup" "', 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 '" "max31855Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)max31855Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_max5322Setup(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:max5322Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "max5322Setup" "', 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 '" "max5322Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)max5322Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp23008Setup(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:mcp23008Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23008Setup" "', 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 '" "mcp23008Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp23008Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp23016Setup(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:mcp23016Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23016Setup" "', 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 '" "mcp23016Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp23016Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp23017Setup(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:mcp23017Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23017Setup" "', 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 '" "mcp23017Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp23017Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp23s08Setup(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s08Setup",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s08Setup" "', 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 '" "mcp23s08Setup" "', 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 '" "mcp23s08Setup" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)mcp23s08Setup(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp23s17Setup(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:mcp23s17Setup",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp23s17Setup" "', 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 '" "mcp23s17Setup" "', 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 '" "mcp23s17Setup" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)mcp23s17Setup(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp3002Setup(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:mcp3002Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp3002Setup" "', 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 '" "mcp3002Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp3002Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp3004Setup(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:mcp3004Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp3004Setup" "', 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 '" "mcp3004Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp3004Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp3422Setup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int arg4 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:mcp3422Setup",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', 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 '" "mcp3422Setup" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + result = (int)mcp3422Setup(arg1,arg2,arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mcp4802Setup(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:mcp4802Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "mcp4802Setup" "', 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 '" "mcp4802Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)mcp4802Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pcf8574Setup(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:pcf8574Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pcf8574Setup" "', 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 '" "pcf8574Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)pcf8574Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pcf8591Setup(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:pcf8591Setup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "pcf8591Setup" "', 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 '" "pcf8591Setup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)pcf8591Setup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sn3218Setup(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:sn3218Setup",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "sn3218Setup" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)sn3218Setup(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softPwmCreate(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:softPwmCreate",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softPwmCreate" "', 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 '" "softPwmCreate" "', 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 '" "softPwmCreate" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)softPwmCreate(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softPwmWrite(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:softPwmWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softPwmWrite" "', 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 '" "softPwmWrite" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + softPwmWrite(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softPwmStop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:softPwmStop",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softPwmStop" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + softPwmStop(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softServoWrite(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:softServoWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softServoWrite" "', 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 '" "softServoWrite" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + softServoWrite(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softServoSetup(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 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 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:softServoSetup",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', 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 '" "softServoSetup" "', argument " "8"" of type '" "int""'"); + } + arg8 = (int)(val8); + result = (int)softServoSetup(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softToneCreate(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:softToneCreate",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softToneCreate" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)softToneCreate(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softToneStop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:softToneStop",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softToneStop" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + softToneStop(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_softToneWrite(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:softToneWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "softToneWrite" "', 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 '" "softToneWrite" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + softToneWrite(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiSPIGetFd(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:wiringPiSPIGetFd",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPIGetFd" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)wiringPiSPIGetFd(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiSPIDataRW(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiSPIDataRW",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPIDataRW" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + { + arg2 = (unsigned char *) PyString_AsString(obj1); + arg3 = PyString_Size(obj1); + } + result = (int)wiringPiSPIDataRW(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiSPISetup(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:wiringPiSPISetup",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiSPISetup" "', 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 '" "wiringPiSPISetup" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)wiringPiSPISetup(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CRead(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:wiringPiI2CRead",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CRead" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)wiringPiI2CRead(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CReadReg8(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:wiringPiI2CReadReg8",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CReadReg8" "', 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 '" "wiringPiI2CReadReg8" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)wiringPiI2CReadReg8(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CReadReg16(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:wiringPiI2CReadReg16",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CReadReg16" "', 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 '" "wiringPiI2CReadReg16" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)wiringPiI2CReadReg16(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CWrite(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:wiringPiI2CWrite",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWrite" "', 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 '" "wiringPiI2CWrite" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)wiringPiI2CWrite(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CWriteReg8(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:wiringPiI2CWriteReg8",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWriteReg8" "', 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 '" "wiringPiI2CWriteReg8" "', 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 '" "wiringPiI2CWriteReg8" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)wiringPiI2CWriteReg8(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CWriteReg16(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 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:wiringPiI2CWriteReg16",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CWriteReg16" "', 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 '" "wiringPiI2CWriteReg16" "', 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 '" "wiringPiI2CWriteReg16" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)wiringPiI2CWriteReg16(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CSetupInterface(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:wiringPiI2CSetupInterface",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wiringPiI2CSetupInterface" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "wiringPiI2CSetupInterface" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)wiringPiI2CSetupInterface((char const *)arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wiringPiI2CSetup(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:wiringPiI2CSetup",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "wiringPiI2CSetup" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)wiringPiI2CSetup(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_serialOpen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OO:serialOpen",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "serialOpen" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + ecode2 = SWIG_AsVal_int(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "serialOpen" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)serialOpen((char const *)arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_serialClose(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:serialClose",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialClose" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + serialClose(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_serialFlush(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:serialFlush",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialFlush" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + serialFlush(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_serialPutchar(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + unsigned char arg2 ; + int val1 ; + int ecode1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:serialPutchar",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPutchar" "', 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 '" "serialPutchar" "', argument " "2"" of type '" "unsigned char""'"); + } + arg2 = (unsigned char)(val2); + serialPutchar(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_serialPuts(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:serialPuts",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPuts" "', 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 '" "serialPuts" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + serialPuts(arg1,(char const *)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_serialPrintf__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:serialPrintf",&obj0,&obj1)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialPrintf" "', 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 '" "serialPrintf" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + serialPrintf(arg1,(char const *)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_serialPrintf(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_serialPrintf__varargs__(NULL,newargs,varargs); + Py_XDECREF(newargs); + Py_XDECREF(varargs); + return resultobj; +} + + +SWIGINTERN PyObject *_wrap_serialDataAvail(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:serialDataAvail",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialDataAvail" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)serialDataAvail(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_serialGetchar(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:serialGetchar",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "serialGetchar" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int)serialGetchar(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_shiftIn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t arg1 ; + uint8_t arg2 ; + uint8_t arg3 ; + unsigned char val1 ; + int ecode1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + unsigned char val3 ; + int ecode3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + uint8_t result; + + if (!PyArg_ParseTuple(args,(char *)"OOO:shiftIn",&obj0,&obj1,&obj2)) SWIG_fail; + ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "shiftIn" "', argument " "1"" of type '" "uint8_t""'"); + } + arg1 = (uint8_t)(val1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "shiftIn" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = (uint8_t)(val2); + ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "shiftIn" "', argument " "3"" of type '" "uint8_t""'"); + } + arg3 = (uint8_t)(val3); + result = shiftIn(arg1,arg2,arg3); + resultobj = SWIG_From_unsigned_SS_char((unsigned char)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_shiftOut(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t arg1 ; + uint8_t arg2 ; + uint8_t arg3 ; + uint8_t arg4 ; + unsigned char val1 ; + int ecode1 = 0 ; + unsigned char val2 ; + int ecode2 = 0 ; + unsigned char val3 ; + int ecode3 = 0 ; + unsigned char val4 ; + int ecode4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:shiftOut",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + ecode1 = SWIG_AsVal_unsigned_SS_char(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "shiftOut" "', argument " "1"" of type '" "uint8_t""'"); + } + arg1 = (uint8_t)(val1); + ecode2 = SWIG_AsVal_unsigned_SS_char(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "shiftOut" "', argument " "2"" of type '" "uint8_t""'"); + } + arg2 = (uint8_t)(val2); + ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "shiftOut" "', argument " "3"" of type '" "uint8_t""'"); + } + arg3 = (uint8_t)(val3); + ecode4 = SWIG_AsVal_unsigned_SS_char(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "shiftOut" "', argument " "4"" of type '" "uint8_t""'"); + } + arg4 = (uint8_t)(val4); + shiftOut(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + static PyMethodDef SwigMethods[] = { { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, + { (char *)"wiringPiFailure", _wrap_wiringPiFailure, METH_VARARGS, NULL}, + { (char *)"wiringPiFindNode", _wrap_wiringPiFindNode, METH_VARARGS, NULL}, + { (char *)"wiringPiNewNode", _wrap_wiringPiNewNode, METH_VARARGS, 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 *)"pinModeAlt", _wrap_pinModeAlt, METH_VARARGS, NULL}, { (char *)"pinMode", _wrap_pinMode, METH_VARARGS, NULL}, { (char *)"pullUpDnControl", _wrap_pullUpDnControl, METH_VARARGS, NULL}, { (char *)"digitalRead", _wrap_digitalRead, METH_VARARGS, NULL}, @@ -6914,14 +7368,18 @@ static PyMethodDef SwigMethods[] = { { (char *)"analogRead", _wrap_analogRead, METH_VARARGS, NULL}, { (char *)"analogWrite", _wrap_analogWrite, METH_VARARGS, NULL}, { (char *)"piBoardRev", _wrap_piBoardRev, METH_VARARGS, NULL}, + { (char *)"piBoardId", _wrap_piBoardId, METH_VARARGS, NULL}, { (char *)"wpiPinToGpio", _wrap_wpiPinToGpio, METH_VARARGS, NULL}, + { (char *)"physPinToGpio", _wrap_physPinToGpio, METH_VARARGS, NULL}, { (char *)"setPadDrive", _wrap_setPadDrive, METH_VARARGS, NULL}, { (char *)"getAlt", _wrap_getAlt, METH_VARARGS, NULL}, + { (char *)"pwmToneWrite", _wrap_pwmToneWrite, 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 *)"waitForInterrupt", _wrap_waitForInterrupt, METH_VARARGS, NULL}, { (char *)"wiringPiISR", _wrap_wiringPiISR, METH_VARARGS, NULL}, { (char *)"piThreadCreate", _wrap_piThreadCreate, METH_VARARGS, NULL}, { (char *)"piLock", _wrap_piLock, METH_VARARGS, NULL}, @@ -6931,56 +7389,6 @@ static PyMethodDef SwigMethods[] = { { (char *)"delayMicroseconds", _wrap_delayMicroseconds, METH_VARARGS, NULL}, { (char *)"millis", _wrap_millis, METH_VARARGS, NULL}, { (char *)"micros", _wrap_micros, METH_VARARGS, NULL}, - { (char *)"serialOpen", _wrap_serialOpen, METH_VARARGS, NULL}, - { (char *)"serialClose", _wrap_serialClose, METH_VARARGS, NULL}, - { (char *)"serialFlush", _wrap_serialFlush, METH_VARARGS, NULL}, - { (char *)"serialPutchar", _wrap_serialPutchar, METH_VARARGS, NULL}, - { (char *)"serialPuts", _wrap_serialPuts, METH_VARARGS, NULL}, - { (char *)"serialPrintf", _wrap_serialPrintf, METH_VARARGS, NULL}, - { (char *)"serialDataAvail", _wrap_serialDataAvail, METH_VARARGS, NULL}, - { (char *)"serialGetchar", _wrap_serialGetchar, METH_VARARGS, NULL}, - { (char *)"shiftOut", _wrap_shiftOut, METH_VARARGS, NULL}, - { (char *)"shiftIn", _wrap_shiftIn, METH_VARARGS, NULL}, - { (char *)"wiringPiSPIGetFd", _wrap_wiringPiSPIGetFd, METH_VARARGS, NULL}, - { (char *)"wiringPiSPIDataRW", _wrap_wiringPiSPIDataRW, METH_VARARGS, NULL}, - { (char *)"wiringPiSPISetup", _wrap_wiringPiSPISetup, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CSetupInterface", _wrap_wiringPiI2CSetupInterface, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CSetup", _wrap_wiringPiI2CSetup, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CRead", _wrap_wiringPiI2CRead, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CReadReg8", _wrap_wiringPiI2CReadReg8, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CReadReg16", _wrap_wiringPiI2CReadReg16, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CWrite", _wrap_wiringPiI2CWrite, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CWriteReg8", _wrap_wiringPiI2CWriteReg8, METH_VARARGS, NULL}, - { (char *)"wiringPiI2CWriteReg16", _wrap_wiringPiI2CWriteReg16, METH_VARARGS, NULL}, - { (char *)"softToneCreate", _wrap_softToneCreate, METH_VARARGS, NULL}, - { (char *)"softToneWrite", _wrap_softToneWrite, METH_VARARGS, NULL}, - { (char *)"softServoWrite", _wrap_softServoWrite, METH_VARARGS, NULL}, - { (char *)"softServoSetup", _wrap_softServoSetup, METH_VARARGS, NULL}, - { (char *)"softPwmCreate", _wrap_softPwmCreate, METH_VARARGS, NULL}, - { (char *)"softPwmWrite", _wrap_softPwmWrite, METH_VARARGS, NULL}, - { (char *)"mcp23008Setup", _wrap_mcp23008Setup, METH_VARARGS, NULL}, - { (char *)"mcp23016Setup", _wrap_mcp23016Setup, METH_VARARGS, NULL}, - { (char *)"mcp23017Setup", _wrap_mcp23017Setup, METH_VARARGS, NULL}, - { (char *)"mcp23s08Setup", _wrap_mcp23s08Setup, METH_VARARGS, NULL}, - { (char *)"mcp23s17Setup", _wrap_mcp23s17Setup, METH_VARARGS, NULL}, - { (char *)"mcp3002Setup", _wrap_mcp3002Setup, METH_VARARGS, NULL}, - { (char *)"mcp3422Setup", _wrap_mcp3422Setup, METH_VARARGS, NULL}, - { (char *)"mcp4802Setup", _wrap_mcp4802Setup, METH_VARARGS, NULL}, - { (char *)"pcf8574Setup", _wrap_pcf8574Setup, METH_VARARGS, NULL}, - { (char *)"pcf8591Setup", _wrap_pcf8591Setup, 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 *)"lcdDisplay", _wrap_lcdDisplay, METH_VARARGS, NULL}, - { (char *)"lcdCursor", _wrap_lcdCursor, METH_VARARGS, NULL}, - { (char *)"lcdCursorBlink", _wrap_lcdCursorBlink, METH_VARARGS, NULL}, - { (char *)"lcdSendCommand", _wrap_lcdSendCommand, METH_VARARGS, NULL}, - { (char *)"lcdPosition", _wrap_lcdPosition, METH_VARARGS, NULL}, - { (char *)"lcdCharDef", _wrap_lcdCharDef, 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}, { (char *)"ds1302rtcRead", _wrap_ds1302rtcRead, METH_VARARGS, NULL}, { (char *)"ds1302rtcWrite", _wrap_ds1302rtcWrite, METH_VARARGS, NULL}, { (char *)"ds1302ramRead", _wrap_ds1302ramRead, METH_VARARGS, NULL}, @@ -7008,12 +7416,70 @@ static PyMethodDef SwigMethods[] = { { (char *)"lcd128x64update", _wrap_lcd128x64update, METH_VARARGS, NULL}, { (char *)"lcd128x64clear", _wrap_lcd128x64clear, METH_VARARGS, NULL}, { (char *)"lcd128x64setup", _wrap_lcd128x64setup, METH_VARARGS, NULL}, - { (char *)"setupNesJoystick", _wrap_setupNesJoystick, METH_VARARGS, NULL}, - { (char *)"readNesJoystick", _wrap_readNesJoystick, METH_VARARGS, NULL}, + { (char *)"lcdHome", _wrap_lcdHome, METH_VARARGS, NULL}, + { (char *)"lcdClear", _wrap_lcdClear, METH_VARARGS, NULL}, + { (char *)"lcdDisplay", _wrap_lcdDisplay, METH_VARARGS, NULL}, + { (char *)"lcdCursor", _wrap_lcdCursor, METH_VARARGS, NULL}, + { (char *)"lcdCursorBlink", _wrap_lcdCursorBlink, METH_VARARGS, NULL}, + { (char *)"lcdSendCommand", _wrap_lcdSendCommand, METH_VARARGS, NULL}, + { (char *)"lcdPosition", _wrap_lcdPosition, METH_VARARGS, NULL}, + { (char *)"lcdCharDef", _wrap_lcdCharDef, 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}, + { (char *)"piFaceSetup", _wrap_piFaceSetup, METH_VARARGS, NULL}, { (char *)"piGlow1", _wrap_piGlow1, METH_VARARGS, NULL}, { (char *)"piGlowLeg", _wrap_piGlowLeg, METH_VARARGS, NULL}, { (char *)"piGlowRing", _wrap_piGlowRing, METH_VARARGS, NULL}, { (char *)"piGlowSetup", _wrap_piGlowSetup, METH_VARARGS, NULL}, + { (char *)"setupNesJoystick", _wrap_setupNesJoystick, METH_VARARGS, NULL}, + { (char *)"readNesJoystick", _wrap_readNesJoystick, METH_VARARGS, NULL}, + { (char *)"sr595Setup", _wrap_sr595Setup, METH_VARARGS, NULL}, + { (char *)"drcSetupSerial", _wrap_drcSetupSerial, METH_VARARGS, NULL}, + { (char *)"max31855Setup", _wrap_max31855Setup, METH_VARARGS, NULL}, + { (char *)"max5322Setup", _wrap_max5322Setup, METH_VARARGS, NULL}, + { (char *)"mcp23008Setup", _wrap_mcp23008Setup, METH_VARARGS, NULL}, + { (char *)"mcp23016Setup", _wrap_mcp23016Setup, METH_VARARGS, NULL}, + { (char *)"mcp23017Setup", _wrap_mcp23017Setup, METH_VARARGS, NULL}, + { (char *)"mcp23s08Setup", _wrap_mcp23s08Setup, METH_VARARGS, NULL}, + { (char *)"mcp23s17Setup", _wrap_mcp23s17Setup, METH_VARARGS, NULL}, + { (char *)"mcp3002Setup", _wrap_mcp3002Setup, METH_VARARGS, NULL}, + { (char *)"mcp3004Setup", _wrap_mcp3004Setup, METH_VARARGS, NULL}, + { (char *)"mcp3422Setup", _wrap_mcp3422Setup, METH_VARARGS, NULL}, + { (char *)"mcp4802Setup", _wrap_mcp4802Setup, METH_VARARGS, NULL}, + { (char *)"pcf8574Setup", _wrap_pcf8574Setup, METH_VARARGS, NULL}, + { (char *)"pcf8591Setup", _wrap_pcf8591Setup, METH_VARARGS, NULL}, + { (char *)"sn3218Setup", _wrap_sn3218Setup, METH_VARARGS, NULL}, + { (char *)"softPwmCreate", _wrap_softPwmCreate, METH_VARARGS, NULL}, + { (char *)"softPwmWrite", _wrap_softPwmWrite, METH_VARARGS, NULL}, + { (char *)"softPwmStop", _wrap_softPwmStop, METH_VARARGS, NULL}, + { (char *)"softServoWrite", _wrap_softServoWrite, METH_VARARGS, NULL}, + { (char *)"softServoSetup", _wrap_softServoSetup, METH_VARARGS, NULL}, + { (char *)"softToneCreate", _wrap_softToneCreate, METH_VARARGS, NULL}, + { (char *)"softToneStop", _wrap_softToneStop, METH_VARARGS, NULL}, + { (char *)"softToneWrite", _wrap_softToneWrite, METH_VARARGS, NULL}, + { (char *)"wiringPiSPIGetFd", _wrap_wiringPiSPIGetFd, METH_VARARGS, NULL}, + { (char *)"wiringPiSPIDataRW", _wrap_wiringPiSPIDataRW, METH_VARARGS, NULL}, + { (char *)"wiringPiSPISetup", _wrap_wiringPiSPISetup, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CRead", _wrap_wiringPiI2CRead, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CReadReg8", _wrap_wiringPiI2CReadReg8, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CReadReg16", _wrap_wiringPiI2CReadReg16, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CWrite", _wrap_wiringPiI2CWrite, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CWriteReg8", _wrap_wiringPiI2CWriteReg8, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CWriteReg16", _wrap_wiringPiI2CWriteReg16, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CSetupInterface", _wrap_wiringPiI2CSetupInterface, METH_VARARGS, NULL}, + { (char *)"wiringPiI2CSetup", _wrap_wiringPiI2CSetup, METH_VARARGS, NULL}, + { (char *)"serialOpen", _wrap_serialOpen, METH_VARARGS, NULL}, + { (char *)"serialClose", _wrap_serialClose, METH_VARARGS, NULL}, + { (char *)"serialFlush", _wrap_serialFlush, METH_VARARGS, NULL}, + { (char *)"serialPutchar", _wrap_serialPutchar, METH_VARARGS, NULL}, + { (char *)"serialPuts", _wrap_serialPuts, METH_VARARGS, NULL}, + { (char *)"serialPrintf", _wrap_serialPrintf, METH_VARARGS, NULL}, + { (char *)"serialDataAvail", _wrap_serialDataAvail, METH_VARARGS, NULL}, + { (char *)"serialGetchar", _wrap_serialGetchar, METH_VARARGS, NULL}, + { (char *)"shiftIn", _wrap_shiftIn, METH_VARARGS, NULL}, + { (char *)"shiftOut", _wrap_shiftOut, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; @@ -7021,35 +7487,35 @@ static PyMethodDef SwigMethods[] = { /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_int_int__int = {"_p_f_int_int__int", "int (*)(int,int)", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_f_p_void__p_void = {"_p_f_p_void__p_void", "void *(*)(void *)", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_f_void__void = {"_p_f_void__void", "void (*)(void)", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_wiringPiNodeStruct = {"_p_wiringPiNodeStruct", "struct wiringPiNodeStruct *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_char, - &_swigt__p_f_int_int__int, &_swigt__p_f_p_void__p_void, &_swigt__p_f_void__void, &_swigt__p_int, &_swigt__p_unsigned_char, + &_swigt__p_wiringPiNodeStruct, }; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_int_int__int[] = { {&_swigt__p_f_int_int__int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_f_p_void__p_void[] = { {&_swigt__p_f_p_void__p_void, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_f_void__void[] = { {&_swigt__p_f_void__void, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_wiringPiNodeStruct[] = { {&_swigt__p_wiringPiNodeStruct, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_char, - _swigc__p_f_int_int__int, _swigc__p_f_p_void__p_void, _swigc__p_f_void__void, _swigc__p_int, _swigc__p_unsigned_char, + _swigc__p_wiringPiNodeStruct, }; @@ -7735,8 +8201,6 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - PyDict_SetItemString(md,(char*)"cvar", SWIG_globals()); - SWIG_addvarlink(SWIG_globals(),(char*)"waitForInterrupt",Swig_var_waitForInterrupt_get, Swig_var_waitForInterrupt_set); #if PY_VERSION_HEX >= 0x03000000 return m; #else