From 8130aa931ba49af3c1119c25e332617a9cd67f1d Mon Sep 17 00:00:00 2001
From: Qubot <1445788683@qq.com>
Date: Tue, 17 Oct 2023 15:21:22 +0800
Subject: [PATCH] New build
---
.gitignore | 11 +
COPYING.LESSER | 165 +
INSTALL | 29 +
People | 37 +
README.md | 390 +++
VERSION | 1 +
build | 194 ++
debian/.gitignore | 9 +
debian/changelog | 6 +
debian/compat | 1 +
debian/control | 29 +
debian/copyright | 15 +
debian/libwiringpi-dev.dirs | 2 +
debian/libwiringpi-dev.install | 3 +
debian/libwiringpi2.install | 1 +
debian/libwiringpi2.shlibs | 2 +
debian/rules | 49 +
debian/wiringpi.dirs | 1 +
debian/wiringpi.install | 4 +
devLib/Makefile | 140 +
devLib/ds1302.c | 240 ++
devLib/ds1302.h | 44 +
devLib/font.h | 2577 ++++++++++++++
devLib/gertboard.c | 164 +
devLib/gertboard.h | 45 +
devLib/lcd.c | 495 +++
devLib/lcd.h | 52 +
devLib/lcd128x64.c | 673 ++++
devLib/lcd128x64.h | 39 +
devLib/maxdetect.c | 238 ++
devLib/maxdetect.h | 40 +
devLib/piFace.c | 112 +
devLib/piFace.h | 32 +
devLib/piFaceOld.c | 177 +
devLib/piGlow.c | 118 +
devLib/piGlow.h | 45 +
devLib/piNes.c | 113 +
devLib/piNes.h | 45 +
devLib/scrollPhat.c | 430 +++
devLib/scrollPhat.h | 39 +
devLib/scrollPhatFont.h | 544 +++
examples/COPYING.LESSER | 165 +
examples/Gertboard/7segments.c | 221 ++
examples/Gertboard/Makefile | 78 +
examples/Gertboard/buttons.c | 83 +
examples/Gertboard/gertboard.c | 96 +
examples/Gertboard/record.c | 60 +
examples/Gertboard/temperature.c | 78 +
examples/Gertboard/voltmeter.c | 73 +
examples/Gertboard/vumeter.c | 152 +
examples/Makefile | 197 ++
examples/PiFace/Makefile | 88 +
examples/PiFace/blink.c | 59 +
examples/PiFace/buttons.c | 103 +
examples/PiFace/ladder.c | 337 ++
examples/PiFace/metro.c | 111 +
examples/PiFace/motor.c | 120 +
examples/PiFace/reaction.c | 194 ++
examples/PiGlow/Makefile | 82 +
examples/PiGlow/piGlow0.c | 51 +
examples/PiGlow/piGlow1.c | 258 ++
examples/PiGlow/piglow.c | 176 +
examples/README.TXT | 18 +
examples/blink-thread.c | 61 +
examples/blink.c | 77 +
examples/blink.rtb | 30 +
examples/blink.sh | 37 +
examples/blink12.c | 111 +
examples/blink12drcs.c | 125 +
examples/blink6drcs.c | 115 +
examples/blink8-drcn.c | 61 +
examples/blink8.c | 57 +
examples/clock.c | 201 ++
examples/delayTest.c | 102 +
examples/ds1302.c | 238 ++
examples/header.h | 23 +
examples/isr-osc.c | 118 +
examples/isr.c | 110 +
examples/lcd-adafruit.c | 347 ++
examples/lcd.c | 286 ++
examples/lowPower.c | 68 +
examples/max31855.c | 60 +
examples/nes.c | 67 +
examples/okLed.c | 82 +
examples/oled_demo.c | 100 +
examples/pwm.c | 128 +
examples/q2w/Makefile | 84 +
examples/q2w/binary.c | 79 +
examples/q2w/blink-io.c | 61 +
examples/q2w/blink.c | 50 +
examples/q2w/blink.sh | 37 +
examples/q2w/bright.c | 59 +
examples/q2w/button.c | 63 +
examples/q2w/volts.c | 62 +
examples/rht03.c | 86 +
examples/scrollPhat/Makefile | 79 +
examples/scrollPhat/scphat.c | 230 ++
examples/scrollPhat/test.c | 115 +
examples/serialRead.c | 48 +
examples/serialTest.c | 75 +
examples/servo.c | 57 +
examples/softPwm.c | 89 +
examples/softTone.c | 54 +
examples/speed.c | 95 +
examples/spiSpeed.c | 118 +
examples/spidev_test.c | 480 +++
examples/spidev_test_linux3_4.c | 210 ++
examples/w25q64_test.c | 139 +
examples/watchdog.c | 115 +
examples/wfi.c | 161 +
gpio/COPYING.LESSER | 165 +
gpio/Makefile | 103 +
gpio/gpio.1 | 351 ++
gpio/gpio.c | 1650 +++++++++
gpio/pintest | 187 +
gpio/readall.c | 1655 +++++++++
gpio/test.sh | 44 +
newVersion | 47 +
pins/Makefile | 22 +
pins/pins.pdf | Bin 0 -> 9833 bytes
pins/pins.tex | 116 +
update | 5 +
version.h | 3 +
wiringPi/COPYING.LESSER | 165 +
wiringPi/Makefile | 170 +
wiringPi/ads1115.c | 293 ++
wiringPi/ads1115.h | 55 +
wiringPi/bmp180.c | 237 ++
wiringPi/bmp180.h | 34 +
wiringPi/drcNet.c | 405 +++
wiringPi/drcNet.h | 42 +
wiringPi/drcSerial.c | 196 ++
wiringPi/drcSerial.h | 33 +
wiringPi/ds18b20.c | 146 +
wiringPi/ds18b20.h | 34 +
wiringPi/font.h | 1808 ++++++++++
wiringPi/htu21d.c | 150 +
wiringPi/htu21d.h | 34 +
wiringPi/max31855.c | 99 +
wiringPi/max31855.h | 33 +
wiringPi/max5322.c | 84 +
wiringPi/max5322.h | 33 +
wiringPi/mcp23008.c | 149 +
wiringPi/mcp23008.h | 33 +
wiringPi/mcp23016.c | 164 +
wiringPi/mcp23016.h | 33 +
wiringPi/mcp23016reg.h | 48 +
wiringPi/mcp23017.c | 195 ++
wiringPi/mcp23017.h | 33 +
wiringPi/mcp23s08.c | 188 +
wiringPi/mcp23s08.h | 33 +
wiringPi/mcp23s17.c | 235 ++
wiringPi/mcp23s17.h | 33 +
wiringPi/mcp23x08.h | 73 +
wiringPi/mcp23x0817.h | 87 +
wiringPi/mcp3002.c | 76 +
wiringPi/mcp3002.h | 33 +
wiringPi/mcp3004.c | 76 +
wiringPi/mcp3004.h | 33 +
wiringPi/mcp3422.c | 125 +
wiringPi/mcp3422.h | 43 +
wiringPi/mcp4802.c | 76 +
wiringPi/mcp4802.h | 33 +
wiringPi/noMoreStatic | 20 +
wiringPi/oled.c | 163 +
wiringPi/oled.h | 127 +
wiringPi/pcf8574.c | 126 +
wiringPi/pcf8574.h | 33 +
wiringPi/pcf8591.c | 90 +
wiringPi/pcf8591.h | 33 +
wiringPi/piHiPri.c | 51 +
wiringPi/piThread.c | 63 +
wiringPi/pseudoPins.c | 95 +
wiringPi/pseudoPins.h | 26 +
wiringPi/rht03.c | 252 ++
wiringPi/rht03.h | 25 +
wiringPi/sn3218.c | 75 +
wiringPi/sn3218.h | 33 +
wiringPi/softPwm.c | 183 +
wiringPi/softPwm.h | 35 +
wiringPi/softServo.c | 211 ++
wiringPi/softServo.h | 35 +
wiringPi/softTone.c | 150 +
wiringPi/softTone.h | 39 +
wiringPi/sr595.c | 109 +
wiringPi/sr595.h | 34 +
wiringPi/w25q64.c | 362 ++
wiringPi/w25q64.h | 36 +
wiringPi/wiringPi.c | 5491 ++++++++++++++++++++++++++++++
wiringPi/wiringPi.h | 628 ++++
wiringPi/wiringPiI2C.c | 231 ++
wiringPi/wiringPiI2C.h | 42 +
wiringPi/wiringPiSPI.c | 145 +
wiringPi/wiringPiSPI.h | 36 +
wiringPi/wiringSerial.c | 231 ++
wiringPi/wiringSerial.h | 38 +
wiringPi/wiringShift.c | 83 +
wiringPi/wiringShift.h | 41 +
wiringPi/wpiExtensions.c | 928 +++++
wiringPi/wpiExtensions.h | 26 +
wiringPiD/Makefile | 100 +
wiringPiD/daemonise.c | 82 +
wiringPiD/daemonise.h | 9 +
wiringPiD/drcNetCmd.h | 44 +
wiringPiD/network.c | 330 ++
wiringPiD/network.h | 31 +
wiringPiD/runRemote.c | 126 +
wiringPiD/runRemote.h | 29 +
wiringPiD/wiringpid.c | 382 +++
209 files changed, 37058 insertions(+)
create mode 100644 .gitignore
create mode 100644 COPYING.LESSER
create mode 100644 INSTALL
create mode 100644 People
create mode 100644 README.md
create mode 100644 VERSION
create mode 100755 build
create mode 100644 debian/.gitignore
create mode 100644 debian/changelog
create mode 100644 debian/compat
create mode 100644 debian/control
create mode 100644 debian/copyright
create mode 100644 debian/libwiringpi-dev.dirs
create mode 100644 debian/libwiringpi-dev.install
create mode 100644 debian/libwiringpi2.install
create mode 100644 debian/libwiringpi2.shlibs
create mode 100755 debian/rules
create mode 100644 debian/wiringpi.dirs
create mode 100644 debian/wiringpi.install
create mode 100644 devLib/Makefile
create mode 100644 devLib/ds1302.c
create mode 100644 devLib/ds1302.h
create mode 100644 devLib/font.h
create mode 100644 devLib/gertboard.c
create mode 100644 devLib/gertboard.h
create mode 100644 devLib/lcd.c
create mode 100644 devLib/lcd.h
create mode 100644 devLib/lcd128x64.c
create mode 100644 devLib/lcd128x64.h
create mode 100755 devLib/maxdetect.c
create mode 100755 devLib/maxdetect.h
create mode 100644 devLib/piFace.c
create mode 100644 devLib/piFace.h
create mode 100644 devLib/piFaceOld.c
create mode 100644 devLib/piGlow.c
create mode 100644 devLib/piGlow.h
create mode 100644 devLib/piNes.c
create mode 100644 devLib/piNes.h
create mode 100644 devLib/scrollPhat.c
create mode 100644 devLib/scrollPhat.h
create mode 100644 devLib/scrollPhatFont.h
create mode 100644 examples/COPYING.LESSER
create mode 100644 examples/Gertboard/7segments.c
create mode 100644 examples/Gertboard/Makefile
create mode 100644 examples/Gertboard/buttons.c
create mode 100644 examples/Gertboard/gertboard.c
create mode 100644 examples/Gertboard/record.c
create mode 100644 examples/Gertboard/temperature.c
create mode 100644 examples/Gertboard/voltmeter.c
create mode 100644 examples/Gertboard/vumeter.c
create mode 100644 examples/Makefile
create mode 100644 examples/PiFace/Makefile
create mode 100644 examples/PiFace/blink.c
create mode 100644 examples/PiFace/buttons.c
create mode 100755 examples/PiFace/ladder.c
create mode 100644 examples/PiFace/metro.c
create mode 100644 examples/PiFace/motor.c
create mode 100644 examples/PiFace/reaction.c
create mode 100644 examples/PiGlow/Makefile
create mode 100644 examples/PiGlow/piGlow0.c
create mode 100644 examples/PiGlow/piGlow1.c
create mode 100644 examples/PiGlow/piglow.c
create mode 100644 examples/README.TXT
create mode 100644 examples/blink-thread.c
create mode 100644 examples/blink.c
create mode 100644 examples/blink.rtb
create mode 100755 examples/blink.sh
create mode 100644 examples/blink12.c
create mode 100644 examples/blink12drcs.c
create mode 100644 examples/blink6drcs.c
create mode 100644 examples/blink8-drcn.c
create mode 100644 examples/blink8.c
create mode 100644 examples/clock.c
create mode 100644 examples/delayTest.c
create mode 100644 examples/ds1302.c
create mode 100644 examples/header.h
create mode 100644 examples/isr-osc.c
create mode 100644 examples/isr.c
create mode 100644 examples/lcd-adafruit.c
create mode 100644 examples/lcd.c
create mode 100644 examples/lowPower.c
create mode 100644 examples/max31855.c
create mode 100644 examples/nes.c
create mode 100644 examples/okLed.c
create mode 100644 examples/oled_demo.c
create mode 100644 examples/pwm.c
create mode 100644 examples/q2w/Makefile
create mode 100644 examples/q2w/binary.c
create mode 100644 examples/q2w/blink-io.c
create mode 100644 examples/q2w/blink.c
create mode 100755 examples/q2w/blink.sh
create mode 100644 examples/q2w/bright.c
create mode 100644 examples/q2w/button.c
create mode 100644 examples/q2w/volts.c
create mode 100644 examples/rht03.c
create mode 100644 examples/scrollPhat/Makefile
create mode 100644 examples/scrollPhat/scphat.c
create mode 100644 examples/scrollPhat/test.c
create mode 100644 examples/serialRead.c
create mode 100644 examples/serialTest.c
create mode 100644 examples/servo.c
create mode 100644 examples/softPwm.c
create mode 100644 examples/softTone.c
create mode 100644 examples/speed.c
create mode 100644 examples/spiSpeed.c
create mode 100644 examples/spidev_test.c
create mode 100644 examples/spidev_test_linux3_4.c
create mode 100644 examples/w25q64_test.c
create mode 100755 examples/watchdog.c
create mode 100644 examples/wfi.c
create mode 100644 gpio/COPYING.LESSER
create mode 100755 gpio/Makefile
create mode 100644 gpio/gpio.1
create mode 100644 gpio/gpio.c
create mode 100755 gpio/pintest
create mode 100644 gpio/readall.c
create mode 100755 gpio/test.sh
create mode 100755 newVersion
create mode 100644 pins/Makefile
create mode 100644 pins/pins.pdf
create mode 100644 pins/pins.tex
create mode 100755 update
create mode 100644 version.h
create mode 100644 wiringPi/COPYING.LESSER
create mode 100755 wiringPi/Makefile
create mode 100644 wiringPi/ads1115.c
create mode 100644 wiringPi/ads1115.h
create mode 100644 wiringPi/bmp180.c
create mode 100644 wiringPi/bmp180.h
create mode 100644 wiringPi/drcNet.c
create mode 100644 wiringPi/drcNet.h
create mode 100644 wiringPi/drcSerial.c
create mode 100644 wiringPi/drcSerial.h
create mode 100644 wiringPi/ds18b20.c
create mode 100644 wiringPi/ds18b20.h
create mode 100644 wiringPi/font.h
create mode 100644 wiringPi/htu21d.c
create mode 100644 wiringPi/htu21d.h
create mode 100644 wiringPi/max31855.c
create mode 100644 wiringPi/max31855.h
create mode 100644 wiringPi/max5322.c
create mode 100644 wiringPi/max5322.h
create mode 100644 wiringPi/mcp23008.c
create mode 100644 wiringPi/mcp23008.h
create mode 100644 wiringPi/mcp23016.c
create mode 100644 wiringPi/mcp23016.h
create mode 100644 wiringPi/mcp23016reg.h
create mode 100644 wiringPi/mcp23017.c
create mode 100644 wiringPi/mcp23017.h
create mode 100644 wiringPi/mcp23s08.c
create mode 100644 wiringPi/mcp23s08.h
create mode 100644 wiringPi/mcp23s17.c
create mode 100644 wiringPi/mcp23s17.h
create mode 100644 wiringPi/mcp23x08.h
create mode 100644 wiringPi/mcp23x0817.h
create mode 100644 wiringPi/mcp3002.c
create mode 100644 wiringPi/mcp3002.h
create mode 100644 wiringPi/mcp3004.c
create mode 100644 wiringPi/mcp3004.h
create mode 100644 wiringPi/mcp3422.c
create mode 100644 wiringPi/mcp3422.h
create mode 100644 wiringPi/mcp4802.c
create mode 100644 wiringPi/mcp4802.h
create mode 100644 wiringPi/noMoreStatic
create mode 100644 wiringPi/oled.c
create mode 100644 wiringPi/oled.h
create mode 100644 wiringPi/pcf8574.c
create mode 100644 wiringPi/pcf8574.h
create mode 100644 wiringPi/pcf8591.c
create mode 100644 wiringPi/pcf8591.h
create mode 100644 wiringPi/piHiPri.c
create mode 100644 wiringPi/piThread.c
create mode 100644 wiringPi/pseudoPins.c
create mode 100644 wiringPi/pseudoPins.h
create mode 100644 wiringPi/rht03.c
create mode 100644 wiringPi/rht03.h
create mode 100644 wiringPi/sn3218.c
create mode 100644 wiringPi/sn3218.h
create mode 100644 wiringPi/softPwm.c
create mode 100644 wiringPi/softPwm.h
create mode 100644 wiringPi/softServo.c
create mode 100644 wiringPi/softServo.h
create mode 100644 wiringPi/softTone.c
create mode 100644 wiringPi/softTone.h
create mode 100644 wiringPi/sr595.c
create mode 100644 wiringPi/sr595.h
create mode 100644 wiringPi/w25q64.c
create mode 100644 wiringPi/w25q64.h
create mode 100644 wiringPi/wiringPi.c
create mode 100644 wiringPi/wiringPi.h
create mode 100644 wiringPi/wiringPiI2C.c
create mode 100644 wiringPi/wiringPiI2C.h
create mode 100644 wiringPi/wiringPiSPI.c
create mode 100644 wiringPi/wiringPiSPI.h
create mode 100644 wiringPi/wiringSerial.c
create mode 100644 wiringPi/wiringSerial.h
create mode 100644 wiringPi/wiringShift.c
create mode 100644 wiringPi/wiringShift.h
create mode 100644 wiringPi/wpiExtensions.c
create mode 100644 wiringPi/wpiExtensions.h
create mode 100644 wiringPiD/Makefile
create mode 100644 wiringPiD/daemonise.c
create mode 100644 wiringPiD/daemonise.h
create mode 100644 wiringPiD/drcNetCmd.h
create mode 100644 wiringPiD/network.c
create mode 100644 wiringPiD/network.h
create mode 100644 wiringPiD/runRemote.c
create mode 100644 wiringPiD/runRemote.h
create mode 100644 wiringPiD/wiringpid.c
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..328286d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+*.o
+*.so
+lib*.so.*
+*~
+*.patch
+debian-template/wiringPi
+debian-template/wiringpi-*.deb
+gpio/gpio
+examples/speed
+examples/blink
+examples/pwm
diff --git a/COPYING.LESSER b/COPYING.LESSER
new file mode 100644
index 0000000..65c5ca8
--- /dev/null
+++ b/COPYING.LESSER
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ 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/INSTALL b/INSTALL
new file mode 100644
index 0000000..4e1df2e
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,29 @@
+
+How to install wiringPi
+=======================
+
+The easiest way is to use the supplied 'build' script:
+
+ ./build
+
+that should do a complete install or upgrade of wiringPi for you.
+
+That will install a dynamic library.
+
+Some distributions do not have /usr/local/lib in the default LD_LIBRARY_PATH. To
+fix this, you need to edit /etc/ld.so.conf and add in a single line:
+
+ /usr/local/lib
+
+then run the ldconfig command.
+
+ sudo ldconfig
+
+To un-install wiringPi:
+
+ ./build uninstall
+
+Gordon Henderson
+
+projects@drogon.net
+https://projects.drogon.net/
diff --git a/People b/People
new file mode 100644
index 0000000..1123f9d
--- /dev/null
+++ b/People
@@ -0,0 +1,37 @@
+
+Just a quick note to some people who've provided help, suggestions,
+bug-fixes, etc. along the way...
+
+Nick Lott: (And others)
+ Hints about making it work with C++
+
+Philipp Stefan Neininger:
+ Minor bug in the Makefile to do with cross compiling
+
+Chris McSweeny
+ Hints and tips about the use of arithmetic in gettimeofday()
+ inside the dealyMicrosecondsHard() function.
+ And spotting a couple of schoolboy errors in the (experimental)
+ softServo code, prompting me to completely re-write it.
+
+Armin (Via projects website)
+ Some pointers about the i2c-dev.h files.
+
+Arno Wagner
+ Suggestions for the mmap calls in wiringPiSetup()
+
+CHARLES Thibaut:
+ A small issue in softTone
+
+Xian Stannard
+ Fixing some typos in the man page!
+
+Andre Crone
+ Suggested the __WIRING_PI.H__ round wiringPi.h
+
+Rik Teerling
+ Pointing out some silly mistooks in the I2C code...
+
+Dolf Andringa
+ Support for multiple SpiDev devices/ports
+ Debian build support
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..925a7fb
--- /dev/null
+++ b/README.md
@@ -0,0 +1,390 @@
+## How to download wiringOP
+
+```
+# apt-get update
+# apt-get install -y git
+# git clone https://github.com/orangepi-xunlong/wiringOP.git
+```
+
+## How to build wiringOP
+
+```
+# cd wiringOP
+# ./build clean
+# ./build
+```
+
+---
+## The output of the gpio readall command
+
+## Allwinner H2+
+
+### Orange Pi Zero/R1
+
+```
+ +------+-----+----------+------+---+ OPi H2 +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 12 | 0 | SDA.0 | ALT2 | 0 | 3 || 4 | | | 5V | | |
+ | 11 | 1 | SCL.0 | ALT2 | 0 | 5 || 6 | | | GND | | |
+ | 6 | 2 | PWM.1 | OFF | 0 | 7 || 8 | 0 | ALT2 | TXD.1 | 3 | 198 |
+ | | | GND | | | 9 || 10 | 0 | ALT2 | RXD.1 | 4 | 199 |
+ | 1 | 5 | RXD.2 | ALT2 | 0 | 11 || 12 | 0 | OFF | PA07 | 6 | 7 |
+ | 0 | 7 | TXD.2 | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 3 | 8 | CTS.2 | OFF | 0 | 15 || 16 | 0 | ALT3 | SDA.1 | 9 | 19 |
+ | | | 3.3V | | | 17 || 18 | 0 | ALT3 | SCK.1 | 10 | 18 |
+ | 15 | 11 | MOSI.1 | ALT2 | 1 | 19 || 20 | | | GND | | |
+ | 16 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | OFF | RTS.2 | 13 | 2 |
+ | 14 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 13 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PA10 | 16 | 10 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ OPi H2 +---+------+----------+-----+------+
+```
+
+## Allwinner H3
+
+### Orange Pi Zero Plus 2
+
+```
+ +------+-----+----------+------+---+ZEROPLUS 2+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 12 | 0 | SDA.0 | ALT2 | 0 | 3 || 4 | | | 5V | | |
+ | 11 | 1 | SCL.0 | ALT2 | 0 | 5 || 6 | | | GND | | |
+ | 6 | 2 | PA6 | OFF | 0 | 7 || 8 | 0 | ALT2 | TXD.2 | 3 | 0 |
+ | | | GND | | | 9 || 10 | 0 | ALT2 | RXD.2 | 4 | 1 |
+ | 352 | 5 | S-SCL | ALT2 | 0 | 11 || 12 | 0 | OFF | PD11 | 6 | 107 |
+ | 353 | 7 | S-SDA | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 3 | 8 | CTS.2 | OFF | 0 | 15 || 16 | 0 | ALT3 | SDA.1 | 9 | 19 |
+ | | | 3.3V | | | 17 || 18 | 0 | ALT3 | SCL.1 | 10 | 18 |
+ | 15 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | GND | | |
+ | 16 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | OFF | RTS.2 | 13 | 2 |
+ | 14 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 13 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PD14 | 16 | 110 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ZEROPLUS 2+---+------+----------+-----+------+
+```
+
+### OrangePi One/Lite/Pc/Plus/PcPlus/Plus2e
+
+```
+ +------+-----+----------+------+---+OrangePiH3+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 12 | 0 | SDA.0 | OUT | 0 | 3 || 4 | | | 5V | | |
+ | 11 | 1 | SCL.0 | OUT | 0 | 5 || 6 | | | GND | | |
+ | 6 | 2 | PA6 | OUT | 0 | 7 || 8 | 0 | OUT | TXD.3 | 3 | 13 |
+ | | | GND | | | 9 || 10 | 0 | OUT | RXD.3 | 4 | 14 |
+ | 1 | 5 | RXD.2 | OUT | 0 | 11 || 12 | 0 | OUT | PD14 | 6 | 110 |
+ | 0 | 7 | TXD.2 | OUT | 0 | 13 || 14 | | | GND | | |
+ | 3 | 8 | CTS.2 | OUT | 0 | 15 || 16 | 0 | OUT | PC04 | 9 | 68 |
+ | | | 3.3V | | | 17 || 18 | 0 | OUT | PC07 | 10 | 71 |
+ | 64 | 11 | MOSI.0 | OUT | 0 | 19 || 20 | | | GND | | |
+ | 65 | 12 | MISO.0 | OUT | 0 | 21 || 22 | 0 | OUT | RTS.2 | 13 | 2 |
+ | 66 | 14 | SCLK.0 | OUT | 0 | 23 || 24 | 0 | OUT | CE.0 | 15 | 67 |
+ | | | GND | | | 25 || 26 | 0 | OUT | PA21 | 16 | 21 |
+ | 19 | 17 | SDA.1 | OUT | 0 | 27 || 28 | 0 | OUT | SCL.1 | 18 | 18 |
+ | 7 | 19 | PA07 | OUT | 0 | 29 || 30 | | | GND | | |
+ | 8 | 20 | PA08 | OUT | 0 | 31 || 32 | 0 | OUT | RTS.1 | 21 | 200 |
+ | 9 | 22 | PA09 | OUT | 0 | 33 || 34 | | | GND | | |
+ | 10 | 23 | PA10 | OUT | 0 | 35 || 36 | 0 | OUT | CTS.1 | 24 | 201 |
+ | 20 | 25 | PA20 | OUT | 0 | 37 || 38 | 0 | OUT | TXD.1 | 26 | 198 |
+ | | | GND | | | 39 || 40 | 0 | OUT | RXD.1 | 27 | 199 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+OrangePiH3+---+------+----------+-----+------+
+```
+
+## Allwinner H5
+
+### Orange Pi Zero Plus
+
+```
+ +------+-----+----------+------+---+ ZEROPLUS +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 12 | 0 | SDA.0 | ALT2 | 0 | 3 || 4 | | | 5V | | |
+ | 11 | 1 | SCL.0 | ALT2 | 0 | 5 || 6 | | | GND | | |
+ | 6 | 2 | PA6 | OFF | 0 | 7 || 8 | 0 | ALT2 | TXD.1 | 3 | 198 |
+ | | | GND | | | 9 || 10 | 0 | ALT2 | RXD.1 | 4 | 199 |
+ | 1 | 5 | RXD.2 | ALT2 | 0 | 11 || 12 | 0 | OFF | PA07 | 6 | 7 |
+ | 0 | 7 | TXD.2 | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 3 | 8 | CTS.2 | OFF | 0 | 15 || 16 | 0 | ALT3 | SDA.1 | 9 | 19 |
+ | | | 3.3V | | | 17 || 18 | 0 | ALT3 | SCL.1 | 10 | 18 |
+ | 15 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | GND | | |
+ | 16 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | OFF | RTS.2 | 13 | 2 |
+ | 14 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 13 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PA10 | 16 | 10 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ ZEROPLUS +---+------+----------+-----+------+
+```
+
+### Orange Pi Zero Plus 2
+
+```
+ +------+-----+----------+------+---+ZEROPLUS 2+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 12 | 0 | SDA.0 | ALT2 | 0 | 3 || 4 | | | 5V | | |
+ | 11 | 1 | SCL.0 | ALT2 | 0 | 5 || 6 | | | GND | | |
+ | 6 | 2 | PA6 | OFF | 0 | 7 || 8 | 0 | ALT2 | TXD.2 | 3 | 0 |
+ | | | GND | | | 9 || 10 | 0 | ALT2 | RXD.2 | 4 | 1 |
+ | 352 | 5 | S-SCL | ALT2 | 0 | 11 || 12 | 0 | OFF | PD11 | 6 | 107 |
+ | 353 | 7 | S-SDA | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 3 | 8 | CTS.2 | OFF | 0 | 15 || 16 | 0 | ALT3 | SDA.1 | 9 | 19 |
+ | | | 3.3V | | | 17 || 18 | 0 | ALT3 | SCL.1 | 10 | 18 |
+ | 15 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | GND | | |
+ | 16 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | OFF | RTS.2 | 13 | 2 |
+ | 14 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 13 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PD14 | 16 | 110 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ZEROPLUS 2+---+------+----------+-----+------+
+```
+
+### Orange Pi Pc 2
+
+```
+ +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 12 | 0 | SDA.0 | ALT2 | 0 | 3 || 4 | | | 5V | | |
+ | 11 | 1 | SCL.0 | ALT2 | 0 | 5 || 6 | | | GND | | |
+ | 6 | 2 | PWM.1 | OFF | 0 | 7 || 8 | 0 | OFF | PC05 | 3 | 69 |
+ | | | GND | | | 9 || 10 | 0 | OFF | PC06 | 4 | 70 |
+ | 1 | 5 | RXD.2 | ALT2 | 0 | 11 || 12 | 0 | OFF | PD14 | 6 | 110 |
+ | 0 | 7 | TXD.2 | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 3 | 8 | CTS.2 | ALT2 | 0 | 15 || 16 | 0 | OFF | PC04 | 9 | 68 |
+ | | | 3.3V | | | 17 || 18 | 0 | OFF | PC07 | 10 | 71 |
+ | 15 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | GND | | |
+ | 16 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | ALT2 | RTS.2 | 13 | 2 |
+ | 14 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 13 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PA21 | 16 | 21 |
+ | 19 | 17 | SDA.1 | ALT3 | 0 | 27 || 28 | 0 | ALT3 | SCL.1 | 18 | 18 |
+ | 7 | 19 | PA07 | OFF | 0 | 29 || 30 | | | GND | | |
+ | 8 | 20 | PA08 | OFF | 0 | 31 || 32 | 0 | ALT2 | RTS.1 | 21 | 200 |
+ | 9 | 22 | PA09 | OFF | 0 | 33 || 34 | | | GND | | |
+ | 10 | 23 | PA10 | OFF | 0 | 35 || 36 | 0 | ALT2 | CTS.1 | 24 | 201 |
+ | 107 | 25 | PD11 | OFF | 0 | 37 || 38 | 0 | ALT2 | TXD.1 | 26 | 198 |
+ | | | GND | | | 39 || 40 | 0 | ALT2 | RXD.1 | 27 | 199 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+
+```
+
+### Orange Pi Prime
+
+```
+ +------+-----+----------+------+---+ PRIME +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 12 | 0 | SDA.0 | ALT2 | 0 | 3 || 4 | | | 5V | | |
+ | 11 | 1 | SCL.0 | ALT2 | 0 | 5 || 6 | | | GND | | |
+ | 6 | 2 | PWM.1 | OFF | 0 | 7 || 8 | 0 | OFF | PC05 | 3 | 69 |
+ | | | GND | | | 9 || 10 | 0 | OFF | PC06 | 4 | 70 |
+ | 1 | 5 | RXD.2 | ALT2 | 0 | 11 || 12 | 0 | OFF | PD14 | 6 | 110 |
+ | 0 | 7 | TXD.2 | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 3 | 8 | CTS.2 | ALT2 | 0 | 15 || 16 | 0 | OFF | PC04 | 9 | 68 |
+ | | | 3.3V | | | 17 || 18 | 0 | OFF | PC07 | 10 | 71 |
+ | 15 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | GND | | |
+ | 16 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | ALT2 | RTS.2 | 13 | 2 |
+ | 14 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 13 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PC08 | 16 | 72 |
+ | 19 | 17 | SDA.1 | ALT3 | 0 | 27 || 28 | 0 | ALT3 | SCL.1 | 18 | 18 |
+ | 7 | 19 | PA07 | OFF | 0 | 29 || 30 | | | GND | | |
+ | 8 | 20 | PA08 | OFF | 0 | 31 || 32 | 0 | OFF | PC09 | 21 | 73 |
+ | 9 | 22 | PA09 | OFF | 0 | 33 || 34 | | | GND | | |
+ | 10 | 23 | PA10 | OFF | 0 | 35 || 36 | 0 | OFF | PC10 | 24 | 74 |
+ | 107 | 25 | PD11 | OFF | 0 | 37 || 38 | 0 | OFF | PC11 | 26 | 75 |
+ | | | GND | | | 39 || 40 | 0 | OFF | PC12 | 27 | 76 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ PRIME +---+------+----------+-----+------+
+```
+
+## Allwinner A64
+
+### Orange Pi Win/Winplus
+
+```
+ +------+-----+----------+------+---+ OPi Win +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 227 | 0 | SDA.1 | ALT2 | 0 | 3 || 4 | | | 5V | | |
+ | 226 | 1 | SCL.1 | ALT2 | 0 | 5 || 6 | | | GND | | |
+ | 362 | 2 | PL10 | OFF | 0 | 7 || 8 | 0 | ALT2 | PL02 | 3 | 354 |
+ | | | GND | | | 9 || 10 | 0 | ALT2 | PL03 | 4 | 355 |
+ | 229 | 5 | RXD.3 | ALT2 | 0 | 11 || 12 | 0 | OFF | PD04 | 6 | 100 |
+ | 228 | 7 | TXD.3 | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 231 | 8 | CTS.3 | OUT | 0 | 15 || 16 | 0 | OFF | PL09 | 9 | 361 |
+ | | | 3.3V | | | 17 || 18 | 0 | OFF | PC04 | 10 | 68 |
+ | 98 | 11 | MOSI.1 | ALT4 | 0 | 19 || 20 | | | GND | | |
+ | 99 | 12 | MISO.1 | ALT4 | 0 | 21 || 22 | 0 | OFF | RTS.3 | 13 | 230 |
+ | 97 | 14 | SCLK.1 | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE.1 | 15 | 96 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PD06 | 16 | 102 |
+ | 143 | 17 | SDA.2 | ALT3 | 0 | 27 || 28 | 0 | ALT3 | SCL.2 | 18 | 142 |
+ | 36 | 19 | PB04 | OFF | 0 | 29 || 30 | | | GND | | |
+ | 37 | 20 | PB05 | OFF | 0 | 31 || 32 | 0 | ALT2 | RTS.2 | 21 | 34 |
+ | 38 | 22 | PB06 | OFF | 0 | 33 || 34 | | | GND | | |
+ | 39 | 23 | PB07 | OFF | 0 | 35 || 36 | 0 | ALT2 | CTS.2 | 24 | 35 |
+ | 101 | 25 | PD05 | OFF | 0 | 37 || 38 | 0 | ALT2 | TXD.2 | 26 | 32 |
+ | | | GND | | | 39 || 40 | 0 | ALT2 | RXD.2 | 27 | 33 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ OPi Win +---+------+----------+-----+------+
+```
+
+## Allwinner H6
+
+### Orange Pi 3/3 LTS
+
+```
+ +------+-----+----------+------+---+ OPi 3 +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 122 | 0 | SDA.0 | OFF | 0 | 3 || 4 | | | 5V | | |
+ | 121 | 1 | SCL.0 | OFF | 0 | 5 || 6 | | | GND | | |
+ | 118 | 2 | PWM.0 | OFF | 0 | 7 || 8 | 0 | OFF | PL02 | 3 | 354 |
+ | | | GND | | | 9 || 10 | 0 | OFF | PL03 | 4 | 355 |
+ | 120 | 5 | RXD.3 | ALT4 | 0 | 11 || 12 | 0 | OFF | PD18 | 6 | 114 |
+ | 119 | 7 | TXD.3 | ALT4 | 0 | 13 || 14 | | | GND | | |
+ | 362 | 8 | PL10 | OFF | 0 | 15 || 16 | 0 | OFF | PD15 | 9 | 111 |
+ | | | 3.3V | | | 17 || 18 | 0 | OFF | PD16 | 10 | 112 |
+ | 229 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | GND | | |
+ | 230 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | OFF | PD21 | 13 | 117 |
+ | 228 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 227 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PL08 | 16 | 360 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ OPi 3 +---+------+----------+-----+------+
+```
+
+### Orange Pi Lite2/OnePlus
+
+```
+ +------+-----+----------+------+---+ OPi H6 +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 230 | 0 | SDA.1 | OFF | 0 | 3 || 4 | | | 5V | | |
+ | 229 | 1 | SCL.1 | OFF | 0 | 5 || 6 | | | GND | | |
+ | 228 | 2 | PWM1 | OFF | 0 | 7 || 8 | 0 | OFF | PD21 | 3 | 117 |
+ | | | GND | | | 9 || 10 | 0 | OFF | PD22 | 4 | 118 |
+ | 120 | 5 | RXD.3 | ALT4 | 0 | 11 || 12 | 0 | OFF | PC09 | 6 | 73 |
+ | 119 | 7 | TXD.3 | ALT4 | 0 | 13 || 14 | | | GND | | |
+ | 122 | 8 | CTS.3 | OFF | 0 | 15 || 16 | 0 | OFF | PC08 | 9 | 72 |
+ | | | 3.3V | | | 17 || 18 | 0 | OFF | PC07 | 10 | 71 |
+ | 66 | 11 | MOSI.0 | ALT4 | 0 | 19 || 20 | | | GND | | |
+ | 67 | 12 | MISO.0 | ALT4 | 0 | 21 || 22 | 0 | OFF | RTS.3 | 13 | 121 |
+ | 64 | 14 | SCLK.0 | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE.0 | 15 | 69 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PH03 | 16 | 227 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ OPi H6 +---+------+----------+-----+------+
+```
+
+## Allwinner H616
+
+### Orange Pi Zero2/Zero2 LTS/Zero2 B
+
+```
+ +------+-----+----------+------+---+ Zero 2 +---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 229 | 0 | SDA.3 | OFF | 0 | 3 || 4 | | | 5V | | |
+ | 228 | 1 | SCL.3 | OFF | 0 | 5 || 6 | | | GND | | |
+ | 73 | 2 | PC9 | OFF | 0 | 7 || 8 | 0 | ALT2 | TXD.5 | 3 | 226 |
+ | | | GND | | | 9 || 10 | 0 | ALT2 | RXD.5 | 4 | 227 |
+ | 70 | 5 | PC6 | ALT5 | 0 | 11 || 12 | 0 | OFF | PC11 | 6 | 75 |
+ | 69 | 7 | PC5 | ALT5 | 0 | 13 || 14 | | | GND | | |
+ | 72 | 8 | PC8 | OFF | 0 | 15 || 16 | 0 | OFF | PC15 | 9 | 79 |
+ | | | 3.3V | | | 17 || 18 | 0 | OFF | PC14 | 10 | 78 |
+ | 231 | 11 | MOSI.1 | ALT4 | 0 | 19 || 20 | | | GND | | |
+ | 232 | 12 | MISO.1 | ALT4 | 0 | 21 || 22 | 0 | OFF | PC7 | 13 | 71 |
+ | 230 | 14 | SCLK.1 | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE.1 | 15 | 233 |
+ | | | GND | | | 25 || 26 | 0 | OFF | PC10 | 16 | 74 |
+ | 65 | 17 | PC1 | OFF | 0 | 27 || 28 | | | | | |
+ | 272 | 18 | PI16 | OFF | 0 | 29 || 30 | | | | | |
+ | 262 | 19 | PI6 | OFF | 0 | 31 || 32 | | | | | |
+ | 234 | 20 | PH10 | ALT3 | 0 | 33 || 34 | | | | | |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+ Zero 2 +---+------+----------+-----+------+
+```
+
+## RockChip RK3399
+
+### Orange Pi RK3399
+
+```
+ +------+-----+----------+------+---+OPi RK3399+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 43 | 0 | SDA.0 | ALT2 | 1 | 3 || 4 | | | 5V | | |
+ | 44 | 1 | SCL.0 | ALT2 | 1 | 5 || 6 | | | GND | | |
+ | 64 | 2 | GPIO4 | ALT3 | 0 | 7 || 8 | 0 | ALT2 | Tx | 3 | 148 |
+ | | | GND | | | 9 || 10 | 1 | ALT2 | Rx | 4 | 147 |
+ | 80 | 5 | GPIO17 | ALT2 | 0 | 11 || 12 | 0 | ALT3 | GPIO18 | 6 | 65 |
+ | 81 | 7 | GPIO27 | ALT2 | 0 | 13 || 14 | | | GND | | |
+ | 82 | 8 | GPIO22 | ALT2 | 0 | 15 || 16 | 0 | IN | GPIO23 | 9 | 66 |
+ | | | 3.3V | | | 17 || 18 | 0 | IN | GPIO24 | 10 | 67 |
+ | 39 | 11 | MOSI | ALT2 | 1 | 19 || 20 | | | GND | | |
+ | 40 | 12 | MISO | ALT2 | 1 | 21 || 22 | 0 | ALT2 | GPIO25 | 13 | 83 |
+ | 41 | 14 | SCLK | ALT3 | 1 | 23 || 24 | 1 | ALT3 | CS0 | 15 | 42 |
+ | | | GND | | | 25 || 26 | 0 | ALT2 | CS1 | 16 | 133 |
+ | 154 | 17 | DNP1 | IN | 0 | 27 || 28 | 1 | IN | DNP2 | 18 | 50 |
+ | 68 | 19 | GPIO5 | OUT | 1 | 29 || 30 | | | GND | | |
+ | 69 | 20 | GPIO6 | OUT | 1 | 31 || 32 | 1 | OUT | GPIO12 | 21 | 76 |
+ | 70 | 22 | GPIO13 | OUT | 1 | 33 || 34 | | | GND | | |
+ | 71 | 23 | GPIO19 | OUT | 1 | 35 || 36 | 1 | OUT | GPIO16 | 24 | 73 |
+ | 72 | 25 | GPIO26 | OUT | 1 | 37 || 38 | 0 | IN | GPIO20 | 26 | 74 |
+ | | | GND | | | 39 || 40 | 0 | ALT4 | GPIO21 | 27 | 75 |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+OPi RK3399+---+------+----------+-----+------+
+ ```
+
+ ### Orange Pi 4/4B/4 LTS
+
+ ```
+ +------+-----+----------+------+---+OrangePi 4+---+---+--+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | | | 3.3V | | | 1 || 2 | | | 5V | | |
+ | 64 | 0 | I2C2_SDA | ALT3 | 0 | 3 || 4 | | | 5V | | |
+ | 65 | 1 | I2C2_SCL | ALT3 | 0 | 5 || 6 | | | GND | | |
+ | 150 | 2 | PWM1 | IN | 0 | 7 || 8 | 1 | ALT2 | I2C3_SCL | 3 | 145 |
+ | | | GND | | | 9 || 10 | 1 | ALT2 | I2C3_SDA | 4 | 144 |
+ | 33 | 5 | GPIO1_A1 | IN | 0 | 11 || 12 | 1 | IN | GPIO1_C2 | 6 | 50 |
+ | 35 | 7 | GPIO1_A3 | OUT | 0 | 13 || 14 | | | GND | | |
+ | 92 | 8 | GPIO2_D4 | OUT | 1 | 15 || 16 | 0 | IN | GPIO1_C6 | 9 | 54 |
+ | | | 3.3V | | | 17 || 18 | 0 | IN | GPIO1_C7 | 10 | 55 |
+ | 40 | 11 | SPI1_TXD | ALT2 | 1 | 19 || 20 | | | GND | | |
+ | 39 | 12 | SPI1_RXD | ALT2 | 1 | 21 || 22 | 0 | IN | GPIO1_D0 | 13 | 56 |
+ | 41 | 14 | SPI1_CLK | ALT3 | 1 | 23 || 24 | 1 | ALT3 | SPI1_CS | 15 | 42 |
+ | | | GND | | | 25 || 26 | 0 | IN | GPIO4_C5 | 16 | 149 |
+ | 64 | 17 | I2C2_SDA | ALT3 | 0 | 27 || 28 | 0 | ALT3 | I2C2_SCL | 18 | 65 |
+ | | | I2S0_RX | | | 29 || 30 | | | GND | | |
+ | | | I2S0_TX | | | 31 || 32 | | | I2S_CLK | | |
+ | | | I2S0_SCK | | | 33 || 34 | | | GND | | |
+ | | | I2S0_SI0 | | | 35 || 36 | | | I2S0_SO0 | | |
+ | | | I2S0_SI1 | | | 37 || 38 | | | I2S0_SI2 | | |
+ | | | GND | | | 39 || 40 | | | I2S0_SI3 | | |
+ +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
+ | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+ +------+-----+----------+------+---+OrangePi 4+---+---+--+----------+-----+------+
+```
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..e409f4b
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+2.52
diff --git a/build b/build
new file mode 100755
index 0000000..d738b59
--- /dev/null
+++ b/build
@@ -0,0 +1,194 @@
+#!/bin/bash -e
+
+# build
+# Simple wiringPi build and install script
+#
+# Copyright (c) 2012-2015 Gordon Henderson
+#################################################################################
+# This file is part of wiringPi:
+# A "wiring" 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 .
+#################################################################################
+#
+# wiringPi is designed to run on a Raspberry Pi only.
+# However if you're clever enough to actually look at this script to
+# see why it's not building for you, then good luck.
+#
+# To everyone else: Stop using cheap alternatives. Support the
+# Raspberry Pi Foundation as they're the only ones putting money
+# back into education!
+#################################################################################
+
+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
+}
+
+sudo=${WIRINGPI_SUDO-sudo}
+
+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
+ cd ../PiGlow
+ echo -n "PiGlow: " ; make clean
+ cd ../scrollPhat
+ echo -n "scrollPhat: " ; make clean
+ cd ../..
+ echo -n "Deb: " ; rm -f debian-template/wiringpi*.deb
+ echo
+ 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
+
+# Only if you know what you're doing!
+
+if [ x$1 = "xdebian" ]; then
+ here=`pwd`
+ echo "removing old libs"
+ cd debian-template/wiringPi
+ rm -rf usr
+ echo "building wiringPi"
+ cd $here/wiringPi
+ make install-deb
+ echo "building devLib"
+ cd $here/devLib
+ make install-deb INCLUDE='-I. -I../wiringPi'
+ echo "building gpio"
+ cd $here/gpio
+ make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
+ echo "Building deb package"
+ cd $here/debian-template
+ fakeroot dpkg-deb --build wiringPi
+ mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
+ exit
+fi
+
+if [ x$1 != "x" ]; then
+ echo "Usage: $0 [clean | uninstall]"
+ exit 1
+fi
+
+ echo "wiringPi Build script"
+ echo "====================="
+ echo
+
+ hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
+
+# if [ x$hardware != "xBCM2708" ]; then
+# echo ""
+# echo " +------------------------------------------------------------+"
+# echo " | wiringPi is designed to run on the Raspberry Pi only. |"
+# echo " | This processor does not appear to be a Raspberry Pi. |"
+# echo " +------------------------------------------------------------+"
+# echo " | In the unlikely event that you think it is a Raspberry Pi, |"
+# echo " | then please accept my apologies and email the contents of |"
+# echo " | /proc/cpuinfo to projects@drogon.net. |"
+# echo " | - Thanks, Gordon |"
+# echo " +------------------------------------------------------------+"
+# echo ""
+# exit 1
+# fi
+
+
+ echo
+ echo "WiringPi Library"
+ cd wiringPi
+ $sudo make uninstall
+ if [ x$1 = "xstatic" ]; then
+ make -j5 static
+ check_make_ok
+ $sudo make install-static
+ else
+ make -j5
+ check_make_ok
+ $sudo make install
+ fi
+ check_make_ok
+
+ echo
+ echo "WiringPi Devices Library"
+ cd ../devLib
+ $sudo make uninstall
+ if [ x$1 = "xstatic" ]; then
+ make -j5 static
+ check_make_ok
+ $sudo make install-static
+ else
+ make -j5
+ check_make_ok
+ $sudo make install
+ fi
+ check_make_ok
+
+ echo
+ echo "GPIO Utility"
+ cd ../gpio
+ make -j5
+ check_make_ok
+ $sudo make install
+ check_make_ok
+
+# echo
+# echo "wiringPi Daemon"
+# cd ../wiringPiD
+# make -j5
+# check_make_ok
+# $sudo make install
+# check_make_ok
+
+# echo
+# echo "Examples"
+# cd ../examples
+# make
+# cd ..
+
+echo
+echo All Done.
+echo ""
+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/debian/.gitignore b/debian/.gitignore
new file mode 100644
index 0000000..6296064
--- /dev/null
+++ b/debian/.gitignore
@@ -0,0 +1,9 @@
+*.debhelper.log
+*.substvars
+tmp
+wiringpi
+libwiringpi2
+libwiringpi-dev
+files
+*.postinst.debhelper
+*.postrm.debhelper
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..7f04ad5
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+wiringpi (2.26~iwj) rpi-unstable; urgency=low
+
+ * Initial version with real Debian source package build.
+
+ -- Ian Jackson Sat, 12 Sep 2015 18:31:35 +0100
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+8
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..5f33b7b
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,29 @@
+Source: wiringpi
+Section: electronics
+Priority: optional
+Maintainer: Ian Jackson
+Standards-Version: 3.8.0
+Homepage: http://wiringpi.com/
+Build-Depends: debhelper (>= 8)
+
+Package: libwiringpi2
+Section: libs
+Architecture: arm64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: GPIO librariees for Raspberry Pi (runtime).
+ Runtime for the popular wiringPi library.
+
+Package: wiringpi
+Architecture: arm64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: gpio utility for Raspberry Pi
+ The wiringPi gpio command line utility, for GPIO access on a
+ Raspberry Pi from the command line.
+
+Package: libwiringpi-dev
+Architecture: arm64
+Depends: libwiringpi2 (= ${binary:Version}), libc6-dev, ${misc:Depends}
+Suggests: wiringpi
+Description: GPIO development library for Raspberry Pi
+ Development libraries to allow GPIO access on a Raspberry Pi from C
+ and C++ programs.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..de82701
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,15 @@
+wiringPi is Copyright (C) 2012-2015 Gordon Henderson.
+
+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.
+
+On all Debian and Raspbian systems, a copy of the GNU Lesser General
+Public License version 3 can be found in
+`/usr/share/common-licenses/LGPL-3'.
diff --git a/debian/libwiringpi-dev.dirs b/debian/libwiringpi-dev.dirs
new file mode 100644
index 0000000..4418816
--- /dev/null
+++ b/debian/libwiringpi-dev.dirs
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
diff --git a/debian/libwiringpi-dev.install b/debian/libwiringpi-dev.install
new file mode 100644
index 0000000..d7ea901
--- /dev/null
+++ b/debian/libwiringpi-dev.install
@@ -0,0 +1,3 @@
+debian/tmp/usr/include
+debian/tmp/usr/lib/*.so
+examples usr/share/doc/libwiringpi-dev
diff --git a/debian/libwiringpi2.install b/debian/libwiringpi2.install
new file mode 100644
index 0000000..c45ebcf
--- /dev/null
+++ b/debian/libwiringpi2.install
@@ -0,0 +1 @@
+debian/tmp/usr/lib/lib*.so.*
diff --git a/debian/libwiringpi2.shlibs b/debian/libwiringpi2.shlibs
new file mode 100644
index 0000000..0be8db1
--- /dev/null
+++ b/debian/libwiringpi2.shlibs
@@ -0,0 +1,2 @@
+libwiringPi 2 libwiringpi2
+libwiringPiDev 2 libwiringpi2
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..423a473
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,49 @@
+#!/usr/bin/make -f
+
+.PHONY: build
+
+VERSION:=$(shell cat VERSION)
+export VERSION
+
+soname:=$(shell echo $${VERSION%%.*})
+WIRINGPI_SONAME_SUFFIX:=.$(soname)
+export soname
+export WIRINGPI_SONAME_SUFFIX
+
+build:
+ dh $@
+
+override_dh_auto_configure:
+
+override_dh_prep:
+ dh_prep -Xdebian/tmp
+
+dirs:
+ dh_installdirs -A
+ mkdir debian/tmp
+ set -e; for p in `dh_listpackages`; do \
+ (cd debian/$$p; find -type d) | \
+ (cd debian/tmp; xargs mkdir -p) \
+ done
+
+override_dh_clean:
+ dh_clean
+ WIRINGPI_SUDO= bash -xe ./build clean
+
+override_dh_auto_build: dirs
+ V=1 LDCONFIG=: WIRINGPI_SUDO= WIRINGPI_SUID=0 \
+ DESTDIR=`pwd`/debian/tmp/usr \
+ PREFIX= WIRINGPI_SUDO= \
+ bash -xe ./build
+
+override_dh_auto_install:
+ dh_install
+ set -ex; for l in libwiringPi libwiringPiDev; do \
+ ln -sf $$l.so.$${VERSION} \
+ debian/libwiringpi$$soname/usr/lib/$$l.so.$$soname; \
+ ln -sf $$l.so.$${VERSION} \
+ debian/libwiringpi-dev/usr/lib/$$l.so; \
+ done
+
+%:
+ dh $@
diff --git a/debian/wiringpi.dirs b/debian/wiringpi.dirs
new file mode 100644
index 0000000..e772481
--- /dev/null
+++ b/debian/wiringpi.dirs
@@ -0,0 +1 @@
+usr/bin
diff --git a/debian/wiringpi.install b/debian/wiringpi.install
new file mode 100644
index 0000000..41ae22d
--- /dev/null
+++ b/debian/wiringpi.install
@@ -0,0 +1,4 @@
+debian/tmp/usr/bin
+debian/tmp/usr/man usr/share
+README.TXT usr/share/doc/wiringpi
+People usr/share/doc/wiringpi
diff --git a/devLib/Makefile b/devLib/Makefile
new file mode 100644
index 0000000..7f313dc
--- /dev/null
+++ b/devLib/Makefile
@@ -0,0 +1,140 @@
+#
+# Makefile:
+# wiringPi device - A "wiring" library for the Raspberry Pi
+#
+# Copyright (c) 2012-2016 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 .
+#################################################################################
+
+VERSION=$(shell cat ../VERSION)
+DESTDIR?=/usr
+PREFIX?=/local
+
+LDCONFIG?=ldconfig
+
+ifneq ($V,1)
+Q ?= @
+endif
+
+STATIC=libwiringPiDev.a
+DYNAMIC=libwiringPiDev.so.$(VERSION)
+
+#DEBUG = -g -O0
+DEBUG = -O2
+CC = gcc
+INCLUDE = -I.
+DEFS = -D_GNU_SOURCE
+CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC
+
+LIBS =
+
+###############################################################################
+
+SRC = ds1302.c maxdetect.c piNes.c \
+ gertboard.c piFace.c \
+ lcd128x64.c lcd.c \
+ scrollPhat.c \
+ piGlow.c
+
+OBJ = $(SRC:.c=.o)
+
+HEADERS = ds1302.h gertboard.h lcd128x64.h lcd.h maxdetect.h piFace.h piGlow.h piNes.h\
+ scrollPhat.h
+
+all: $(DYNAMIC)
+
+static: $(STATIC)
+
+$(STATIC): $(OBJ)
+ $Q echo "[Link (Static)]"
+ $Q ar rcs $(STATIC) $(OBJ)
+ $Q ranlib $(STATIC)
+# @size $(STATIC)
+
+$(DYNAMIC): $(OBJ)
+ $Q echo "[Link (Dynamic)]"
+ $Q $(CC) -shared -Wl,-soname,libwiringPiDev.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ)
+
+.c.o:
+ $Q echo [Compile] $<
+ $Q $(CC) -c $(CFLAGS) $< -o $@
+
+.PHONY: clean
+clean:
+ $Q echo "[Clean]"
+ $Q rm -f $(OBJ) $(OBJ_I2C) *~ core tags Makefile.bak libwiringPiDev.*
+
+.PHONY: tags
+tags: $(SRC)
+ $Q echo [ctags]
+ $Q ctags $(SRC)
+
+
+.PHONY: install
+install: $(DYNAMIC)
+ $Q echo "[Install Headers]"
+ $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
+ $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
+ $Q echo "[Install Dynamic Lib]"
+ $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
+ $Q install -m 0755 libwiringPiDev.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION)
+ $Q ln -sf $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.so.$(VERSION) $(DESTDIR)/lib/libwiringPiDev.so
+ $Q $(LDCONFIG)
+
+.PHONY: install-static
+install-static: $(STATIC)
+ $Q echo "[Install Headers]"
+ $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/include
+ $Q install -m 0644 $(HEADERS) $(DESTDIR)$(PREFIX)/include
+ $Q echo "[Install Static Lib]"
+ $Q install -m 0755 -d $(DESTDIR)$(PREFIX)/lib
+ $Q install -m 0755 libwiringPiDev.a $(DESTDIR)$(PREFIX)/lib
+
+.PHONY: install-deb
+install-deb: $(DYNAMIC)
+ $Q echo "[Install Headers: deb]"
+ $Q install -m 0755 -d $(CURDIR)/../debian-template/wiringPi/usr/include
+ $Q install -m 0644 $(HEADERS) $(CURDIR)/../debian-template/wiringPi/usr/include
+ $Q echo "[Install Dynamic Lib: deb]"
+ install -m 0755 -d $(CURDIR)/../debian-template/wiringPi/usr/lib
+ install -m 0755 libwiringPiDev.so.$(VERSION) $(CURDIR)/../debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION)
+ ln -sf $(CURDIR)/../debian-template/wiringPi/usr/lib/libwiringPiDev.so.$(VERSION) $(CURDIR)/../debian-template/wiringPi/usr/lib/libwiringPiDev.so
+
+.PHONY: uninstall
+uninstall:
+ $Q echo "[UnInstall]"
+ $Q cd $(DESTDIR)$(PREFIX)/include/ && rm -f $(HEADERS)
+ $Q cd $(DESTDIR)$(PREFIX)/lib/ && rm -f libwiringPiDev.*
+ $Q $(LDCONFIG)
+
+
+.PHONY: 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
+scrollPhat.o: scrollPhatFont.h scrollPhat.h
+piGlow.o: piGlow.h
diff --git a/devLib/ds1302.c b/devLib/ds1302.c
new file mode 100644
index 0000000..cf64de7
--- /dev/null
+++ b/devLib/ds1302.c
@@ -0,0 +1,240 @@
+/*
+ * 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 "ds1302.h"
+
+// 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
+
+
+// Locals
+
+static int dPin, cPin, sPin ;
+
+/*
+ * dsShiftIn:
+ * Shift a number in from the chip, LSB first. Note that the data is
+ * sampled on the trailing edge of the last clock, so it's valid immediately.
+ *********************************************************************************
+ */
+
+static unsigned int dsShiftIn (void)
+{
+ uint8_t value = 0 ;
+ int i ;
+
+ pinMode (dPin, INPUT) ; delayMicroseconds (1) ;
+
+ for (i = 0 ; i < 8 ; ++i)
+ {
+ value |= (digitalRead (dPin) << i) ;
+ digitalWrite (cPin, HIGH) ; delayMicroseconds (1) ;
+ digitalWrite (cPin, LOW) ; delayMicroseconds (1) ;
+ }
+
+ return value;
+}
+
+
+/*
+ * dsShiftOut:
+ * A normal LSB-first shift-out, just slowed down a bit - the Pi is
+ * a bit faster than the chip can handle.
+ *********************************************************************************
+ */
+
+static void dsShiftOut (unsigned int data)
+{
+ int i ;
+
+ pinMode (dPin, OUTPUT) ;
+
+ for (i = 0 ; i < 8 ; ++i)
+ {
+ digitalWrite (dPin, data & (1 << i)) ; delayMicroseconds (1) ;
+ digitalWrite (cPin, HIGH) ; delayMicroseconds (1) ;
+ digitalWrite (cPin, LOW) ; delayMicroseconds (1) ;
+ }
+}
+
+
+/*
+ * ds1302regRead: ds1302regWrite:
+ * Read/Write a value to an RTC Register or RAM location on the chip
+ *********************************************************************************
+ */
+
+static unsigned int ds1302regRead (const int reg)
+{
+ unsigned int data ;
+
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+ dsShiftOut (reg) ;
+ data = dsShiftIn () ;
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+
+ return data ;
+}
+
+static void ds1302regWrite (const int reg, const unsigned int data)
+{
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+ dsShiftOut (reg) ;
+ dsShiftOut (data) ;
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+}
+
+
+/*
+ * ds1302rtcWrite: ds1302rtcRead:
+ * Writes/Reads the data to/from the RTC register
+ *********************************************************************************
+ */
+
+unsigned int ds1302rtcRead (const int reg)
+{
+ return ds1302regRead (0x81 | ((reg & 0x1F) << 1)) ;
+}
+
+void ds1302rtcWrite (int reg, unsigned int data)
+{
+ ds1302regWrite (0x80 | ((reg & 0x1F) << 1), data) ;
+}
+
+
+/*
+ * ds1302ramWrite: ds1302ramRead:
+ * Writes/Reads the data to/from the RTC register
+ *********************************************************************************
+ */
+
+unsigned int ds1302ramRead (const int addr)
+{
+ return ds1302regRead (0xC1 | ((addr & 0x1F) << 1)) ;
+}
+
+void ds1302ramWrite (const int addr, const unsigned int data)
+{
+ ds1302regWrite ( 0xC0 | ((addr & 0x1F) << 1), data) ;
+}
+
+/*
+ * ds1302clockRead:
+ * Read all 8 bytes of the clock in a single operation
+ *********************************************************************************
+ */
+
+void ds1302clockRead (int clockData [8])
+{
+ int i ;
+ unsigned int regVal = 0x81 | ((RTC_BM & 0x1F) << 1) ;
+
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+
+ dsShiftOut (regVal) ;
+ for (i = 0 ; i < 8 ; ++i)
+ clockData [i] = dsShiftIn () ;
+
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+}
+
+
+/*
+ * ds1302clockWrite:
+ * Write all 8 bytes of the clock in a single operation
+ *********************************************************************************
+ */
+
+void ds1302clockWrite (const int clockData [8])
+{
+ int i ;
+ unsigned int regVal = 0x80 | ((RTC_BM & 0x1F) << 1) ;
+
+ digitalWrite (sPin, HIGH) ; delayMicroseconds (1) ;
+
+ dsShiftOut (regVal) ;
+ for (i = 0 ; i < 8 ; ++i)
+ dsShiftOut (clockData [i]) ;
+
+ digitalWrite (sPin, LOW) ; delayMicroseconds (1) ;
+}
+
+
+/*
+ * ds1302trickleCharge:
+ * Set the bits on the trickle charger.
+ * Probably best left alone...
+ *********************************************************************************
+ */
+
+void ds1302trickleCharge (const int diodes, const int resistors)
+{
+ if (diodes + resistors == 0)
+ ds1302rtcWrite (RTC_TC, 0x5C) ; // Disabled
+ else
+ ds1302rtcWrite (RTC_TC, 0xA0 | ((diodes & 3) << 2) | (resistors & 3)) ;
+}
+
+
+
+
+/*
+ * ds1302setup:
+ * Initialise the chip & remember the pins we're using
+ *********************************************************************************
+ */
+
+void ds1302setup (const int clockPin, const int dataPin, const int csPin)
+{
+ dPin = dataPin ;
+ cPin = clockPin ;
+ sPin = csPin ;
+
+ digitalWrite (dPin, LOW) ;
+ digitalWrite (cPin, LOW) ;
+ digitalWrite (sPin, LOW) ;
+
+ pinMode (dPin, OUTPUT) ;
+ pinMode (cPin, OUTPUT) ;
+ pinMode (sPin, OUTPUT) ;
+
+ ds1302rtcWrite (RTC_WP, 0) ; // Remove write-protect
+}
diff --git a/devLib/ds1302.h b/devLib/ds1302.h
new file mode 100644
index 0000000..e82b3ed
--- /dev/null
+++ b/devLib/ds1302.h
@@ -0,0 +1,44 @@
+/*
+ * ds1302.h:
+ * 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/devLib/font.h b/devLib/font.h
new file mode 100644
index 0000000..ce99e16
--- /dev/null
+++ b/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/devLib/gertboard.c b/devLib/gertboard.c
new file mode 100644
index 0000000..6a84415
--- /dev/null
+++ b/devLib/gertboard.c
@@ -0,0 +1,164 @@
+/*
+ * gertboard.c:
+ * Access routines for the SPI devices on the Gertboard
+ * Copyright (c) 2012 Gordon Henderson
+ *
+ * The Gertboard has:
+ *
+ * An MCP3002 dual-channel A to D convertor connected
+ * to the SPI bus, selected by chip-select A, and:
+ *
+ * An MCP4802 dual-channel D to A convertor connected
+ * to the SPI bus, selected via chip-select B.
+ *
+ ***********************************************************************
+ * 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 "gertboard.h"
+
+// The A-D convertor won't run at more than 1MHz @ 3.3v
+
+#define SPI_ADC_SPEED 1000000
+#define SPI_DAC_SPEED 1000000
+#define SPI_A2D 0
+#define SPI_D2A 1
+
+
+/*
+ * gertboardAnalogWrite:
+ * Write an 8-bit data value to the MCP4802 Analog to digital
+ * convertor on the Gertboard.
+ *********************************************************************************
+ */
+
+void gertboardAnalogWrite (const int chan, const int value)
+{
+ uint8_t spiData [2] ;
+ uint8_t chanBits, dataBits ;
+
+ if (chan == 0)
+ chanBits = 0x30 ;
+ else
+ chanBits = 0xB0 ;
+
+ chanBits |= ((value >> 4) & 0x0F) ;
+ dataBits = ((value << 4) & 0xF0) ;
+
+ spiData [0] = chanBits ;
+ spiData [1] = dataBits ;
+
+ wiringPiSPIDataRW (SPI_D2A, spiData, 2) ;
+}
+
+
+/*
+ * gertboardAnalogRead:
+ * Return the analog value of the given channel (0/1).
+ * The A/D is a 10-bit device
+ *********************************************************************************
+ */
+
+int gertboardAnalogRead (const int chan)
+{
+ uint8_t spiData [2] ;
+
+ uint8_t chanBits ;
+
+ if (chan == 0)
+ chanBits = 0b11010000 ;
+ else
+ chanBits = 0b11110000 ;
+
+ spiData [0] = chanBits ;
+ spiData [1] = 0 ;
+
+ wiringPiSPIDataRW (SPI_A2D, spiData, 2) ;
+
+ return ((spiData [0] << 8) | (spiData [1] >> 1)) & 0x3FF ;
+}
+
+
+/*
+ * gertboardSPISetup:
+ * Initialise the SPI bus, etc.
+ *********************************************************************************
+ */
+
+int gertboardSPISetup (void)
+{
+ if (wiringPiSPISetup (SPI_A2D, SPI_ADC_SPEED) < 0)
+ return -1 ;
+
+ if (wiringPiSPISetup (SPI_D2A, SPI_DAC_SPEED) < 0)
+ return -1 ;
+
+ return 0 ;
+}
+
+
+/*
+ * New wiringPi node extension methods.
+ *********************************************************************************
+ */
+
+static int myAnalogRead (struct wiringPiNodeStruct *node, const int chan)
+{
+ return gertboardAnalogRead (chan - node->pinBase) ;
+}
+
+static void myAnalogWrite (struct wiringPiNodeStruct *node, const int chan, const int value)
+{
+ gertboardAnalogWrite (chan - node->pinBase, value) ;
+}
+
+
+/*
+ * gertboardAnalogSetup:
+ * Create a new wiringPi device node for the analog devices on the
+ * Gertboard. We create one node with 2 pins - each pin being read
+ * and write - although the operations actually go to different
+ * hardware devices.
+ *********************************************************************************
+ */
+
+int gertboardAnalogSetup (const int pinBase)
+{
+ struct wiringPiNodeStruct *node ;
+ int x ;
+
+ if (( x = gertboardSPISetup ()) != 0)
+ return x;
+
+ node = wiringPiNewNode (pinBase, 2) ;
+ node->analogRead = myAnalogRead ;
+ node->analogWrite = myAnalogWrite ;
+
+ return 0 ;
+}
diff --git a/devLib/gertboard.h b/devLib/gertboard.h
new file mode 100644
index 0000000..3fa1919
--- /dev/null
+++ b/devLib/gertboard.h
@@ -0,0 +1,45 @@
+/*
+ * gertboard.h:
+ * Access routines for the SPI devices on the Gertboard
+ * Copyright (c) 2012 Gordon Henderson
+ *
+ * The Gertboard has an MCP4802 dual-channel D to A convertor
+ * connected to the SPI bus, selected via chip-select B.
+ *
+ ***********************************************************************
+ * 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
+
+// Old routines
+
+extern void gertboardAnalogWrite (const int chan, const int value) ;
+extern int gertboardAnalogRead (const int chan) ;
+extern int gertboardSPISetup (void) ;
+
+// New
+
+extern int gertboardAnalogSetup (const int pinBase) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/devLib/lcd.c b/devLib/lcd.c
new file mode 100644
index 0000000..6c0e474
--- /dev/null
+++ b/devLib/lcd.c
@@ -0,0 +1,495 @@
+/*
+ * lcd.c:
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+#include
+#include
+
+#include
+
+#include "lcd.h"
+
+#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_CTRL 0x08
+#define LCD_CDSHIFT 0x10
+#define LCD_FUNC 0x20
+#define LCD_CGRAM 0x40
+#define LCD_DGRAM 0x80
+
+// Bits in the entry register
+
+#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
+#define LCD_FUNC_DL 0x10
+
+#define LCD_CDSHIFT_RL 0x04
+
+struct lcdDataStruct
+{
+ 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:
+ * Toggle the strobe (Really the "E") pin to the device.
+ * According to the docs, data is latched on the falling edge.
+ *********************************************************************************
+ */
+
+static void strobe (const struct lcdDataStruct *lcd)
+{
+
+// Note timing changes for new version of delayMicroseconds ()
+
+ digitalWrite (lcd->strbPin, 1) ; delayMicroseconds (50) ;
+ digitalWrite (lcd->strbPin, 0) ; delayMicroseconds (50) ;
+}
+
+
+/*
+ * sentDataCmd:
+ * Send an data or command byte to the display.
+ *********************************************************************************
+ */
+
+static void sendDataCmd (const struct lcdDataStruct *lcd, unsigned char data)
+{
+ register unsigned char myData = data ;
+ unsigned char i, d4 ;
+
+ if (lcd->bits == 4)
+ {
+ d4 = (myData >> 4) & 0x0F;
+ for (i = 0 ; i < 4 ; ++i)
+ {
+ digitalWrite (lcd->dataPins [i], (d4 & 1)) ;
+ d4 >>= 1 ;
+ }
+ strobe (lcd) ;
+
+ d4 = myData & 0x0F ;
+ for (i = 0 ; i < 4 ; ++i)
+ {
+ digitalWrite (lcd->dataPins [i], (d4 & 1)) ;
+ d4 >>= 1 ;
+ }
+ }
+ else
+ {
+ for (i = 0 ; i < 8 ; ++i)
+ {
+ digitalWrite (lcd->dataPins [i], (myData & 1)) ;
+ myData >>= 1 ;
+ }
+ }
+ strobe (lcd) ;
+}
+
+
+/*
+ * putCommand:
+ * Send a command byte to the display
+ *********************************************************************************
+ */
+
+static void putCommand (const struct lcdDataStruct *lcd, unsigned char command)
+{
+ digitalWrite (lcd->rsPin, 0) ;
+ sendDataCmd (lcd, command) ;
+ delay (2) ;
+}
+
+static void put4Command (const struct lcdDataStruct *lcd, unsigned char command)
+{
+ register unsigned char myCommand = command ;
+ register unsigned char i ;
+
+ digitalWrite (lcd->rsPin, 0) ;
+
+ for (i = 0 ; i < 4 ; ++i)
+ {
+ digitalWrite (lcd->dataPins [i], (myCommand & 1)) ;
+ myCommand >>= 1 ;
+ }
+ strobe (lcd) ;
+}
+
+
+/*
+ *********************************************************************************
+ * User Callable code below here
+ *********************************************************************************
+ */
+
+/*
+ * lcdHome: lcdClear:
+ * Home the cursor or clear the screen.
+ *********************************************************************************
+ */
+
+void lcdHome (const int fd)
+{
+ struct lcdDataStruct *lcd = lcds [fd] ;
+
+ putCommand (lcd, LCD_HOME) ;
+ lcd->cx = lcd->cy = 0 ;
+ delay (5) ;
+}
+
+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) ;
+}
+
+
+/*
+ * lcdSendCommand:
+ * Send any arbitary command to the display
+ *********************************************************************************
+ */
+
+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.
+ * Ignore invalid locations.
+ *********************************************************************************
+ */
+
+void lcdPosition (const int fd, int x, int y)
+{
+ 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. We implement a very
+ * simple terminal here - with line wrapping, but no scrolling. Yet.
+ *********************************************************************************
+ */
+
+void lcdPutchar (const int fd, unsigned char data)
+{
+ struct lcdDataStruct *lcd = lcds [fd] ;
+
+ digitalWrite (lcd->rsPin, 1) ;
+ 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])) ;
+ }
+}
+
+
+/*
+ * lcdPuts:
+ * Send a string to be displayed on the display
+ *********************************************************************************
+ */
+
+void lcdPuts (const int fd, const char *string)
+{
+ while (*string)
+ lcdPutchar (fd, *string++) ;
+}
+
+
+/*
+ * lcdPrintf:
+ * Printf to an LCD display
+ *********************************************************************************
+ */
+
+void lcdPrintf (const int fd, const char *message, ...)
+{
+ va_list argp ;
+ char buffer [1024] ;
+
+ va_start (argp, message) ;
+ vsnprintf (buffer, 1023, message, argp) ;
+ va_end (argp) ;
+
+ lcdPuts (fd, buffer) ;
+}
+
+
+/*
+ * lcdInit:
+ * Take a lot of parameters and initialise the LCD, and return a handle to
+ * that LCD, or -1 if any error.
+ *********************************************************************************
+ */
+
+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 ;
+
+ unsigned char func ;
+ int i ;
+ int lcdFd = -1 ;
+ struct lcdDataStruct *lcd ;
+
+ if (initialised == 0)
+ {
+ initialised = 1 ;
+ for (i = 0 ; i < MAX_LCDS ; ++i)
+ lcds [i] = NULL ;
+ }
+
+// Simple sanity checks
+
+ if (! ((bits == 4) || (bits == 8)))
+ return -1 ;
+
+ if ((rows < 0) || (rows > 20))
+ return -1 ;
+
+ if ((cols < 0) || (cols > 20))
+ return -1 ;
+
+// Create a new LCD:
+
+ for (i = 0 ; i < MAX_LCDS ; ++i)
+ {
+ if (lcds [i] == NULL)
+ {
+ lcdFd = i ;
+ break ;
+ }
+ }
+
+ if (lcdFd == -1)
+ return -1 ;
+
+ lcd = (struct lcdDataStruct *)malloc (sizeof (struct lcdDataStruct)) ;
+ if (lcd == NULL)
+ return -1 ;
+
+ lcd->rsPin = rs ;
+ lcd->strbPin = 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 ;
+ lcd->dataPins [2] = d2 ;
+ lcd->dataPins [3] = d3 ;
+ lcd->dataPins [4] = d4 ;
+ lcd->dataPins [5] = d5 ;
+ lcd->dataPins [6] = d6 ;
+ lcd->dataPins [7] = d7 ;
+
+ lcds [lcdFd] = lcd ;
+
+ digitalWrite (lcd->rsPin, 0) ; pinMode (lcd->rsPin, OUTPUT) ;
+ digitalWrite (lcd->strbPin, 0) ; pinMode (lcd->strbPin, OUTPUT) ;
+
+ for (i = 0 ; i < bits ; ++i)
+ {
+ digitalWrite (lcd->dataPins [i], 0) ;
+ pinMode (lcd->dataPins [i], OUTPUT) ;
+ }
+ delay (35) ; // mS
+
+
+// 4-bit mode?
+// OK. This is a PIG and it's not at all obvious from the documentation I had,
+// so I guess some others have worked through either with better documentation
+// or more trial and error... Anyway here goes:
+//
+// It seems that the controller needs to see the FUNC command at least 3 times
+// consecutively - in 8-bit mode. If you're only using 8-bit mode, then it appears
+// that you can get away with one func-set, however I'd not rely on it...
+//
+// So to set 4-bit mode, you need to send the commands one nibble at a time,
+// the same three times, but send the command to set it into 8-bit mode those
+// three times, then send a final 4th command to set it into 4-bit mode, and only
+// then can you flip the switch for the rest of the library to work in 4-bit
+// mode which sends the commands as 2 x 4-bit values.
+
+ if (bits == 4)
+ {
+ func = LCD_FUNC | LCD_FUNC_DL ; // Set 8-bit mode 3 times
+ put4Command (lcd, func >> 4) ; delay (35) ;
+ put4Command (lcd, func >> 4) ; delay (35) ;
+ put4Command (lcd, func >> 4) ; delay (35) ;
+ func = LCD_FUNC ; // 4th set: 4-bit mode
+ put4Command (lcd, func >> 4) ; delay (35) ;
+ lcd->bits = 4 ;
+ }
+ else
+ {
+ func = LCD_FUNC | LCD_FUNC_DL ;
+ putCommand (lcd, func ) ; delay (35) ;
+ putCommand (lcd, func ) ; delay (35) ;
+ putCommand (lcd, func ) ; delay (35) ;
+ }
+
+ if (lcd->rows > 1)
+ {
+ func |= LCD_FUNC_N ;
+ putCommand (lcd, func) ; delay (35) ;
+ }
+
+// Rest of the initialisation sequence
+
+ 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/devLib/lcd.h b/devLib/lcd.h
new file mode 100644
index 0000000..0a0e598
--- /dev/null
+++ b/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/devLib/lcd128x64.c b/devLib/lcd128x64.c
new file mode 100644
index 0000000..accd5c3
--- /dev/null
+++ b/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/devLib/lcd128x64.h b/devLib/lcd128x64.h
new file mode 100644
index 0000000..b448bbc
--- /dev/null
+++ b/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/devLib/maxdetect.c b/devLib/maxdetect.c
new file mode 100755
index 0000000..74ff70e
--- /dev/null
+++ b/devLib/maxdetect.c
@@ -0,0 +1,238 @@
+/*
+ * 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
+
+#include "maxdetect.h"
+
+#ifndef TRUE
+# define TRUE (1==1)
+# define FALSE (1==2)
+#endif
+
+
+/*
+ * maxDetectLowHighWait:
+ * Wait for a transition from low to high on the bus
+ *********************************************************************************
+ */
+
+static int maxDetectLowHighWait (const int pin)
+{
+ struct timeval now, timeOut, timeUp ;
+
+// If already high then wait for pin to go low
+
+ gettimeofday (&now, NULL) ;
+ timerclear (&timeOut) ;
+ timeOut.tv_usec = 1000 ;
+ timeradd (&now, &timeOut, &timeUp) ;
+
+ while (digitalRead (pin) == HIGH)
+ {
+ gettimeofday (&now, NULL) ;
+ if (timercmp (&now, &timeUp, >))
+ return FALSE ;
+ }
+
+// Wait for it to go HIGH
+
+ gettimeofday (&now, NULL) ;
+ timerclear (&timeOut) ;
+ timeOut.tv_usec = 1000 ;
+ timeradd (&now, &timeOut, &timeUp) ;
+
+ while (digitalRead (pin) == LOW)
+ {
+ gettimeofday (&now, NULL) ;
+ if (timercmp (&now, &timeUp, >))
+ return FALSE ;
+ }
+
+ return TRUE ;
+}
+
+
+/*
+ * 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)
+ {
+ if (!maxDetectLowHighWait (pin))
+ return 0 ;
+
+// 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] ;
+ struct timeval now, then, took ;
+
+// See how long we took
+
+ gettimeofday (&then, NULL) ;
+
+// 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
+
+ if (!maxDetectLowHighWait (pin))
+ return FALSE ;
+
+// 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 ;
+
+// See how long we took
+
+ gettimeofday (&now, NULL) ;
+ timersub (&now, &then, &took) ;
+
+// Total time to do this should be:
+// 10mS + 40µS - reset
+// + 80µS + 80µS - sensor doing its low -> high thing
+// + 40 * (50µS + 27µS (0) or 70µS (1) )
+// = 15010µS
+// so if we take more than that, we've had a scheduling interruption and the
+// reading is probably bogus.
+
+ if ((took.tv_sec != 0) || (took.tv_usec > 16000))
+ return FALSE ;
+
+ return checksum == localBuf [4] ;
+}
+
+
+/*
+ * readRHT03:
+ * Read the Temperature & Humidity from an RHT03 sensor
+ * Values returned are *10, so 123 is 12.3.
+ *********************************************************************************
+ */
+
+int readRHT03 (const int pin, int *temp, int *rh)
+{
+ static struct timeval then ; // will initialise to zero
+ static int lastTemp = 0 ;
+ static int lastRh = 0 ;
+
+ int result ;
+ struct timeval now, timeOut ;
+ unsigned char buffer [4] ;
+
+// The data sheets say to not read more than once every 2 seconds, so you
+// get the last good reading
+
+ gettimeofday (&now, NULL) ;
+ if (timercmp (&now, &then, <))
+ {
+ *rh = lastRh ;
+ *temp = lastTemp ;
+ return TRUE ;
+ }
+
+// Set timeout for next read
+
+ gettimeofday (&now, NULL) ;
+ timerclear (&timeOut) ;
+ timeOut.tv_sec = 2 ;
+ timeradd (&now, &timeOut, &then) ;
+
+// Read ...
+
+ result = maxDetectRead (pin, buffer) ;
+
+ if (!result) // Try again, but just once
+ result = maxDetectRead (pin, buffer) ;
+
+ if (!result)
+ return FALSE ;
+
+ *rh = (buffer [0] * 256 + buffer [1]) ;
+ *temp = (buffer [2] * 256 + buffer [3]) ;
+
+ if ((*temp & 0x8000) != 0) // Negative
+ {
+ *temp &= 0x7FFF ;
+ *temp = -*temp ;
+ }
+
+// Discard obviously bogus readings - the checksum can't detect a 2-bit error
+// (which does seem to happen - no realtime here)
+
+ if ((*rh > 999) || (*temp > 800) || (*temp < -400))
+ return FALSE ;
+
+ lastRh = *rh ;
+ lastTemp = *temp ;
+
+ return TRUE ;
+}
diff --git a/devLib/maxdetect.h b/devLib/maxdetect.h
new file mode 100755
index 0000000..a1fd742
--- /dev/null
+++ b/devLib/maxdetect.h
@@ -0,0 +1,40 @@
+/*
+ * maxdetect.h:
+ * 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 .
+ ***********************************************************************
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Main generic function
+
+int maxDetectRead (const int pin, unsigned char buffer [4]) ;
+
+// Individual sensors
+
+int readRHT03 (const int pin, int *temp, int *rh) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/devLib/piFace.c b/devLib/piFace.c
new file mode 100644
index 0000000..4475c7f
--- /dev/null
+++ b/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/devLib/piFace.h b/devLib/piFace.h
new file mode 100644
index 0000000..4965314
--- /dev/null
+++ b/devLib/piFace.h
@@ -0,0 +1,32 @@
+/*
+ * piFace.h:
+ * Control the PiFace Interface board 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 .
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int piFaceSetup (const int pinBase) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/devLib/piFaceOld.c b/devLib/piFaceOld.c
new file mode 100644
index 0000000..cadbfe8
--- /dev/null
+++ b/devLib/piFaceOld.c
@@ -0,0 +1,177 @@
+/*
+ * piFace.:
+ * Copyright (c) 2012-2016 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/devLib/piGlow.c b/devLib/piGlow.c
new file mode 100644
index 0000000..44e3db8
--- /dev/null
+++ b/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/devLib/piGlow.h b/devLib/piGlow.h
new file mode 100644
index 0000000..a4d89d0
--- /dev/null
+++ b/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_ORANGE 1
+#define PIGLOW_YELLOW 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/devLib/piNes.c b/devLib/piNes.c
new file mode 100644
index 0000000..a115050
--- /dev/null
+++ b/devLib/piNes.c
@@ -0,0 +1,113 @@
+/*
+ * piNes.c:
+ * Driver for the NES Joystick controller on the Raspberry Pi
+ * 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 .
+ ***********************************************************************
+ */
+
+#include
+
+#include "piNes.h"
+
+#define MAX_NES_JOYSTICKS 8
+
+#define NES_RIGHT 0x01
+#define NES_LEFT 0x02
+#define NES_DOWN 0x04
+#define NES_UP 0x08
+#define NES_START 0x10
+#define NES_SELECT 0x20
+#define NES_B 0x40
+#define NES_A 0x80
+
+
+#define PULSE_TIME 25
+
+// Data to store the pins for each controller
+
+struct nesPinsStruct
+{
+ unsigned int cPin, dPin, lPin ;
+} ;
+
+static struct nesPinsStruct nesPins [MAX_NES_JOYSTICKS] ;
+
+static int joysticks = 0 ;
+
+
+/*
+ * setupNesJoystick:
+ * Create a new NES joystick interface, program the pins, etc.
+ *********************************************************************************
+ */
+
+int setupNesJoystick (int dPin, int cPin, int lPin)
+{
+ if (joysticks == MAX_NES_JOYSTICKS)
+ return -1 ;
+
+ nesPins [joysticks].dPin = dPin ;
+ nesPins [joysticks].cPin = cPin ;
+ nesPins [joysticks].lPin = lPin ;
+
+ digitalWrite (lPin, LOW) ;
+ digitalWrite (cPin, LOW) ;
+
+ pinMode (lPin, OUTPUT) ;
+ pinMode (cPin, OUTPUT) ;
+ pinMode (dPin, INPUT) ;
+
+ return joysticks++ ;
+}
+
+
+/*
+ * readNesJoystick:
+ * Do a single scan of the NES Joystick.
+ *********************************************************************************
+ */
+
+unsigned int readNesJoystick (int joystick)
+{
+ unsigned int value = 0 ;
+ int i ;
+
+ struct nesPinsStruct *pins = &nesPins [joystick] ;
+
+// Toggle Latch - which presents the first bit
+
+ digitalWrite (pins->lPin, HIGH) ; delayMicroseconds (PULSE_TIME) ;
+ digitalWrite (pins->lPin, LOW) ; delayMicroseconds (PULSE_TIME) ;
+
+// Read first bit
+
+ value = digitalRead (pins->dPin) ;
+
+// Now get the next 7 bits with the clock
+
+ for (i = 0 ; i < 7 ; ++i)
+ {
+ digitalWrite (pins->cPin, HIGH) ; delayMicroseconds (PULSE_TIME) ;
+ digitalWrite (pins->cPin, LOW) ; delayMicroseconds (PULSE_TIME) ;
+ value = (value << 1) | digitalRead (pins->dPin) ;
+ }
+
+ return value ^ 0xFF ;
+}
diff --git a/devLib/piNes.h b/devLib/piNes.h
new file mode 100644
index 0000000..897f181
--- /dev/null
+++ b/devLib/piNes.h
@@ -0,0 +1,45 @@
+/*
+ * piNes.h:
+ * Driver for the NES Joystick controller on the Raspberry Pi
+ * 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_NES_JOYSTICKS 8
+
+#define NES_RIGHT 0x01
+#define NES_LEFT 0x02
+#define NES_DOWN 0x04
+#define NES_UP 0x08
+#define NES_START 0x10
+#define NES_SELECT 0x20
+#define NES_B 0x40
+#define NES_A 0x80
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int setupNesJoystick (int dPin, int cPin, int lPin) ;
+extern unsigned int readNesJoystick (int joystick) ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/devLib/scrollPhat.c b/devLib/scrollPhat.c
new file mode 100644
index 0000000..c1a6f11
--- /dev/null
+++ b/devLib/scrollPhat.c
@@ -0,0 +1,430 @@
+/*
+ * scrollPhat.c:
+ * Simple driver for the Pimoroni Scroll Phat device
+ *
+ * Copyright (c) 2015 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 "scrollPhatFont.h"
+#include "scrollPhat.h"
+
+// Size
+
+#define SP_WIDTH 11
+#define SP_HEIGHT 5
+
+// I2C
+
+#define PHAT_I2C_ADDR 0x60
+
+// Software copy of the framebuffer
+// it's 8-bit deep although the display itself is only 1-bit deep.
+
+static unsigned char frameBuffer [SP_WIDTH * SP_HEIGHT] ;
+
+static int lastX, lastY ;
+static int printDelayFactor ;
+static int scrollPhatFd ;
+
+static int putcharX ;
+
+#undef DEBUG
+
+
+/*
+ * delay:
+ * Wait for some number of milliseconds.
+ * This taken from wiringPi as there is no-need to include the whole of
+ * wiringPi just for the delay function.
+ *********************************************************************************
+ */
+
+static void delay (unsigned int howLong)
+{
+ struct timespec sleeper, dummy ;
+
+ sleeper.tv_sec = (time_t)(howLong / 1000) ;
+ sleeper.tv_nsec = (long)(howLong % 1000) * 1000000 ;
+
+ nanosleep (&sleeper, &dummy) ;
+}
+
+
+
+/*
+ * scrollPhatUpdate:
+ * Copy our software version to the real display
+ *********************************************************************************
+ */
+
+void scrollPhatUpdate (void)
+{
+ register int x, y ;
+ register unsigned char data, pixel ;
+ unsigned char pixels [SP_WIDTH] ;
+
+#ifdef DEBUG
+ printf ("+-----------+\n") ;
+ for (y = 0 ; y < SP_HEIGHT ; ++y)
+ {
+ putchar ('|') ;
+ for (x = 0 ; x < SP_WIDTH ; ++x)
+ {
+ pixel = frameBuffer [x + y * SP_WIDTH] ;
+ putchar (pixel == 0 ? ' ' : '*') ;
+ }
+ printf ("|\n") ;
+ }
+ printf ("+-----------+\n") ;
+#endif
+
+ for (x = 0 ; x < SP_WIDTH ; ++x)
+ {
+ data = 0 ;
+ for (y = 0 ; y < SP_HEIGHT ; ++y)
+ {
+ pixel = frameBuffer [x + y * SP_WIDTH] ;
+ data = (data << 1) | ((pixel == 0) ? 0 : 1) ;
+ }
+ pixels [x] = data ;
+ }
+
+ for (x = 0 ; x < SP_WIDTH ; ++x)
+ wiringPiI2CWriteReg8 (scrollPhatFd, 1 + x, pixels [x]) ;
+
+ wiringPiI2CWriteReg8 (scrollPhatFd, 0x0C, 0) ;
+}
+
+
+/*
+ *********************************************************************************
+ * Standard Graphical Functions
+ *********************************************************************************
+ */
+
+
+/*
+ * scrollPhatPoint:
+ * Plot a pixel. Crude clipping - speed is not the essence here.
+ *********************************************************************************
+ */
+
+void scrollPhatPoint (int x, int y, int colour)
+{
+ lastX = x ;
+ lastY = y ;
+
+ if ((x < 0) || (x >= SP_WIDTH) || (y < 0) || (y >= SP_HEIGHT))
+ return ;
+
+ frameBuffer [x + y * SP_WIDTH] = colour ;
+}
+
+
+/*
+ * scrollPhatLine: scrollPhatLineTo:
+ * Classic Bressenham Line code - rely on the point function to do the
+ * clipping for us here.
+ *********************************************************************************
+ */
+
+void scrollPhatLine (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 (;;)
+ {
+ scrollPhatPoint (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 scrollPhatLineTo (int x, int y, int colour)
+{
+ scrollPhatLine (lastX, lastY, x, y, colour) ;
+}
+
+
+/*
+ * scrollPhatRectangle:
+ * A rectangle is a spoilt days fishing
+ *********************************************************************************
+ */
+
+void scrollPhatRectangle (int x1, int y1, int x2, int y2, int colour, int filled)
+{
+ register int x ;
+
+ if (filled)
+ {
+ /**/ if (x1 == x2)
+ scrollPhatLine (x1, y1, x2, y2, colour) ;
+ else if (x1 < x2)
+ for (x = x1 ; x <= x2 ; ++x)
+ scrollPhatLine (x, y1, x, y2, colour) ;
+ else
+ for (x = x2 ; x <= x1 ; ++x)
+ scrollPhatLine (x, y1, x, y2, colour) ;
+ }
+ else
+ {
+ scrollPhatLine (x1, y1, x2, y1, colour) ;
+ scrollPhatLineTo (x2, y2, colour) ;
+ scrollPhatLineTo (x1, y2, colour) ;
+ scrollPhatLineTo (x1, y1, colour) ;
+ }
+}
+
+
+/*
+ * scrollPhatPutchar:
+ * Print a single character to the screen then advance the pointer by an
+ * appropriate ammount (variable width font).
+ * We rely on the clipping done by the pixel plot function to keep us
+ * out of trouble.
+ * Return the width + space
+ *********************************************************************************
+ */
+
+int scrollPhatPutchar (int c)
+{
+ register int x, y ;
+
+ unsigned char line ;
+ unsigned char *fontPtr ;
+ unsigned char *p2 ;
+ int lineWidth, width, mask ;
+
+// The font is printable characters, uppercase only...
+// and somewhat varaible width...
+
+ c &= 0x7F ;
+ if (c > 0x60)
+ c -= 64 ;
+ else
+ c -= 32 ;
+
+ fontPtr = scrollPhatFont + c * fontHeight ;
+
+// Work out width of this character
+// There probably is a more efficient way to do this, but...
+
+ p2 = fontPtr ;
+ width = 0 ;
+ for (y = 0 ; y < fontHeight ; ++y)
+ {
+ mask = 0x80 ;
+ for (lineWidth = 8 ; lineWidth > 0 ; --lineWidth)
+ {
+ if ((*p2 & mask) != 0)
+ break ;
+ mask >>= 1 ;
+ }
+ if (lineWidth > width)
+ width = lineWidth ;
+
+ ++p2 ;
+ }
+
+ if (width == 0) // Likely to be a blank or space character
+ width = 3 ;
+
+ for (y = fontHeight - 1 ; y >= 0 ; --y)
+ {
+ x = 0 ;
+ line = *fontPtr++ ;
+ for (mask = 1 << (width - 1) ; mask != 0 ; mask >>= 1)
+ {
+ scrollPhatPoint (putcharX + x, y, (line & mask)) ;
+ ++x ;
+ }
+ }
+
+// make a line of space
+
+ for (y = fontHeight - 1 ; y >= 0 ; --y)
+ scrollPhatPoint (putcharX + width, y, 0) ;
+
+ putcharX = putcharX + width + 1 ;
+
+ return width + 1 ;
+}
+
+
+/*
+ * scrollPhatPuts:
+ * Send a string to the display - and scroll it across.
+ * This is somewhat of a hack in that we print the entire string to the
+ * display and let the point clipping take care of what's off-screen...
+ *********************************************************************************
+ */
+
+void scrollPhatPuts (const char *str)
+{
+ int i ;
+ int movingX = 0 ;
+ const char *s ;
+ int pixelLen ;
+
+// Print it once, then we know the width in pixels...
+
+ putcharX = 0 ;
+ s = str ;
+ while (*s)
+ scrollPhatPutchar (*s++) ;
+
+ pixelLen = putcharX ;
+
+// Now scroll it by printing it and moving left one pixel
+
+ movingX = 0 ;
+ for (i = 0 ; i < pixelLen ; ++i)
+ {
+ putcharX = movingX ;
+ s = str ;
+ while (*s)
+ scrollPhatPutchar (*s++) ;
+ --movingX ;
+ scrollPhatUpdate () ;
+ delay (printDelayFactor) ;
+ }
+}
+
+
+/*
+ * scrollPhatPrintf:
+ * Does what it says
+ *********************************************************************************
+ */
+
+void scrollPhatPrintf (const char *message, ...)
+{
+ va_list argp ;
+ char buffer [1024] ;
+
+ va_start (argp, message) ;
+ vsnprintf (buffer, 1023, message, argp) ;
+ va_end (argp) ;
+
+ scrollPhatPuts (buffer) ;
+}
+
+
+/*
+ * scrollPhatPrintSpeed:
+ * Change the print speed - mS per shift by 1 pixel
+ *********************************************************************************
+ */
+
+void scrollPhatPrintSpeed (const int pps)
+{
+ if (pps < 0)
+ printDelayFactor = 0 ;
+ else
+ printDelayFactor = pps ;
+}
+
+
+/*
+ * scrollPhatClear:
+ * Clear the display
+ *********************************************************************************
+ */
+
+void scrollPhatClear (void)
+{
+ register int i ;
+ register unsigned char *ptr = frameBuffer ;
+
+ for (i = 0 ; i < (SP_WIDTH * SP_HEIGHT) ; ++i)
+ *ptr++ = 0 ;
+
+ scrollPhatUpdate () ;
+}
+
+
+/*
+ * scrollPhatIntensity:
+ * Set the display brightness - percentage
+ *********************************************************************************
+ */
+
+void scrollPhatIntensity (const int percent)
+{
+ wiringPiI2CWriteReg8 (scrollPhatFd, 0x19, (127 * percent) / 100) ;
+}
+
+
+/*
+ * scrollPhatSetup:
+ * Initialise the Scroll Phat display
+ *********************************************************************************
+ */
+
+int scrollPhatSetup (void)
+{
+ if ((scrollPhatFd = wiringPiI2CSetup (PHAT_I2C_ADDR)) < 0)
+ return scrollPhatFd ;
+
+ wiringPiI2CWriteReg8 (scrollPhatFd, 0x00, 0x03) ; // Enable display, set to 5x11 mode
+ scrollPhatIntensity (10) ;
+ scrollPhatClear () ;
+ scrollPhatPrintSpeed (100) ;
+
+ return 0 ;
+}
diff --git a/devLib/scrollPhat.h b/devLib/scrollPhat.h
new file mode 100644
index 0000000..0e762b1
--- /dev/null
+++ b/devLib/scrollPhat.h
@@ -0,0 +1,39 @@
+/*
+ * scrollPhat.h:
+ * Simple driver for the Pimoroni Scroll Phat device
+ *
+ * Copyright (c) 2015 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 scrollPhatPoint (int x, int y, int colour) ;
+extern void scrollPhatLine (int x0, int y0, int x1, int y1, int colour) ;
+extern void scrollPhatLineTo (int x, int y, int colour) ;
+extern void scrollPhatRectangle (int x1, int y1, int x2, int y2, int colour, int filled) ;
+extern void scrollPhatUpdate (void) ;
+extern void scrollPhatClear (void) ;
+
+extern int scrollPhatPutchar (int c) ;
+//extern void scrollPhatPutchar (int c) ;
+extern void scrollPhatPuts (const char *str) ;
+extern void scrollPhatPrintf (const char *message, ...) ;
+extern void scrollPhatPrintSpeed (const int cps10) ;
+
+extern void scrollPhatIntensity (const int percent) ;
+extern int scrollPhatSetup (void) ;
diff --git a/devLib/scrollPhatFont.h b/devLib/scrollPhatFont.h
new file mode 100644
index 0000000..92f623a
--- /dev/null
+++ b/devLib/scrollPhatFont.h
@@ -0,0 +1,544 @@
+/*
+ * scrollPhatFont.h:
+ * Simple font for the Pimoroni Scroll Phat.
+ * Note: this is a very much reduced font - 5 pixels high and
+ * mostly 4 pixels wide - sometimes 5. Also only
+ * printable characters from space to _ uppercase only.
+ *
+ * Copyright (c) 2015-2016 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 .
+ ***********************************************************************
+ */
+
+static const int fontHeight = 5 ;
+
+static unsigned char scrollPhatFont [] =
+{
+
+// 0x20, Space. Handeled as a special case in the code.
+
+ 0x0, // ....
+ 0x0, // ....
+ 0x0, // ....
+ 0x0, // ....
+ 0x0, // ....
+
+// 0x21, !
+
+ 0x1, // *
+ 0x1, // *
+ 0x1, // *
+ 0x0, // .
+ 0x1, // *
+
+// 0x22, "
+
+ 0x5, // *..*
+ 0x5, // *..*
+ 0x0, // ....
+ 0x0, // ....
+ 0x0, // ....
+
+// 0x23, #
+
+ 0x9, // *..*
+ 0xF, // ****
+ 0x9, // *..*
+ 0xF, // ****
+ 0x9, // *..*
+
+// 0x24, $
+
+ 0x1, // ..*.
+ 0x7, // .***
+ 0x2, // ..*.
+ 0xE, // ***.
+ 0x8, // ..*.
+
+// 0x25, %
+
+ 0x9, // *..*
+ 0x1, // ...*
+ 0x6, // .**.
+ 0x8, // *...
+ 0x9, // *..*
+
+// 0x26, &
+
+ 0x6, // .**.
+ 0x8, // *...
+ 0x4, // .*..
+ 0xA, // *.*.
+ 0x5, // .*.*
+
+// 0x27, '
+
+ 0x1, // .*
+ 0x2, // *.
+ 0x0, // ..
+ 0x0, // ..
+ 0x0, // ..
+
+// 0x28, (
+
+ 0x3, // ..**
+ 0x4, // .*..
+ 0x8, // *...
+ 0x4, // .*..
+ 0x3, // ..**
+
+// 0x29, )
+
+ 0xC, // **..
+ 0x2, // ..*.
+ 0x1, // ...*
+ 0x2, // ..*.
+ 0xC, // **..
+
+// 0x2A, *
+
+ 0x9, // *..*
+ 0x6, // .**.
+ 0xF, // ****
+ 0x6, // .**.
+ 0x9, // *..*
+
+// 0x2B, +
+
+ 0x6, // .**.
+ 0x6, // .**.
+ 0xF, // ****
+ 0x6, // .**.
+ 0x6, // .**.
+
+// 0x2C, ,
+
+ 0x0, // ..
+ 0x0, // ..
+ 0x0, // ..
+ 0x1, // .*
+ 0x2, // *.
+
+// 0x2D, -
+
+ 0x0, // ....
+ 0x0, // ....
+ 0xF, // ****
+ 0x0, // ....
+ 0x0, // ....
+
+// 0x2E, .
+
+ 0x0, // .
+ 0x0, // .
+ 0x0, // .
+ 0x0, // .
+ 0x1, // *
+
+// 0x2F, /
+
+ 0x1, // ...*
+ 0x3, // ..**
+ 0x4, // ..*.
+ 0xC, // **..
+ 0x8, // *...
+
+// 0x30, 0
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x6, // .**.
+
+// 0x31, 1
+
+ 0x2, // ..*.
+ 0x6, // .**.
+ 0x2, // ..*.
+ 0x2, // ..*.
+ 0x7, // .***
+
+// 0x32, 2
+
+ 0x6, // .**.
+ 0x1, // ...*
+ 0x6, // .**.
+ 0x8, // *...
+ 0xF, // ****
+
+// 0x33, 3
+
+ 0xE, // ***.
+ 0x1, // ...*
+ 0xE, // ***.
+ 0x1, // ...*
+ 0xE, // ***.
+
+// 0x34, 4
+
+ 0x6, // .**.
+ 0xA, // *.*.
+ 0xF, // ****
+ 0x2, // ..*.
+ 0x2, // ..*.
+
+// 0x35, 5
+
+ 0xF, // ****
+ 0x8, // *...
+ 0xF, // ****
+ 0x1, // ...*
+ 0xE, // ***.
+
+// 0x36, 6
+
+ 0x2, // ..*.
+ 0x4, // .*..
+ 0xA, // *.*.
+ 0x9, // *..*
+ 0x6, // .**.
+
+// 0x37, 7
+
+ 0xF, // ****
+ 0x1, // ...*
+ 0x2, // ..*.
+ 0x4, // .*..
+ 0x8, // *...
+
+// 0x38, 8
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x6, // .**.
+
+// 0x39, 9
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x7, // .*.*
+ 0x1, // ..*.
+ 0x2, // .*..
+
+// 0x3A, :
+
+ 0x0, // .
+ 0x1, // *
+ 0x0, // .
+ 0x1, // *
+ 0x0, // .
+
+// 0x3B, ;
+
+ 0x0, // ..
+ 0x1, // .*
+ 0x0, // ..
+ 0x1, // .*
+ 0x2, // *.
+
+// 0x3C, <
+
+ 0x2, // ..*.
+ 0x4, // .*..
+ 0x8, // *...
+ 0x4, // .*..
+ 0x2, // ..*.
+
+// 0x3D, =
+
+ 0x0, // ....
+ 0xF, // ****
+ 0x0, // ....
+ 0xF, // ****
+ 0x0, // ....
+
+// 0x3E, >
+
+ 0x0, // .*..
+ 0x0, // ..*.
+ 0x0, // ...*
+ 0x0, // ..*.
+ 0x0, // .*..
+
+// 0x3F, ?
+
+ 0x6, // .**.
+ 0x1, // ...*
+ 0x2, // ..*.
+ 0x0, // ....
+ 0x2, // ..*.
+
+// 0x40, @
+
+ 0x6, // .**.
+ 0xD, // **.*
+ 0x8, // *...
+ 0x4, // .*..
+ 0x3, // ..**
+
+// 0x41, A
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0xF, // ****
+ 0x9, // *..*
+ 0x9, // *..*
+
+// 0x42, B
+
+ 0xE, // ***.
+ 0x9, // *..*
+ 0xE, // ***.
+ 0x9, // *..*
+ 0xE, // ***.
+
+// 0x43, C
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x8, // *...
+ 0x9, // *..*
+ 0x6, // .**.
+
+// 0x44, D
+
+ 0xE, // ***.
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x9, // *..*
+ 0xE, // ***.
+
+// 0x45, E
+
+ 0xF, // ****
+ 0x8, // *...
+ 0xE, // ***.
+ 0x8, // *...
+ 0xF, // ****
+
+// 0x46, F
+
+ 0xF, // ****
+ 0x8, // *...
+ 0xE, // ***.
+ 0x8, // *...
+ 0x8, // *...
+
+// 0x47, G
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x8, // *...
+ 0xB, // *.**
+ 0x6, // .**.
+
+// 0x48, H
+
+ 0x9, // *..*
+ 0x9, // *..*
+ 0xF, // ****
+ 0x9, // *..*
+ 0x9, // *..*
+
+// 0x49, I
+
+ 0x7, // ***
+ 0x2, // .*.
+ 0x2, // .*.
+ 0x2, // .*.
+ 0x7, // ***
+
+// 0x4A, J
+
+ 0x7, // .***
+ 0x2, // ..*.
+ 0x2, // ..*.
+ 0xA, // *.*.
+ 0x4, // .*..
+
+// 0x4B, K
+
+ 0x9, // *..*
+ 0xA, // *.*.
+ 0xC, // **..
+ 0xA, // *.*.
+ 0x9, // *..*
+
+// 0x4C, L
+
+ 0x4, // *..
+ 0x4, // *..
+ 0x4, // *..
+ 0x4, // *..
+ 0x7, // ***
+
+// 0x4D, M
+
+ 0x11, // *...*
+ 0x1B, // **.**
+ 0x15, // *.*.*
+ 0x11, // *...*
+ 0x11, // *...*
+
+// 0x4E, N
+
+ 0x9, // *..*
+ 0xD, // **.*
+ 0xB, // *.**
+ 0x9, // *..*
+ 0x9, // *..*
+
+// 0x4F, O
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x6, // .**.
+
+// 0x50, P
+
+ 0xE, // ***.
+ 0x9, // *..*
+ 0xE, // ***.
+ 0x8, // *...
+ 0x8, // *...
+
+// 0x51, Q
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x9, // *..*
+ 0xA, // *.*.
+ 0x5, // .*.*
+
+// 0x52, R
+
+ 0xE, // ***.
+ 0x9, // *..*
+ 0xF, // ***.
+ 0xA, // *.*.
+ 0x9, // *..*
+
+// 0x53, S
+
+ 0x6, // .**.
+ 0x8, // *...
+ 0x6, // .**.
+ 0x1, // ...*
+ 0x6, // .**.
+
+// 0x54, T
+
+ 0x7, // .***
+ 0x2, // ..*.
+ 0x2, // ..*.
+ 0x2, // ..*.
+ 0x2, // ..*.
+
+// 0x55, U
+
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x6, // .**.
+
+// 0x56, V
+
+ 0x11, // *...*
+ 0x11, // *...*
+ 0x11, // *...*
+ 0x0A, // .*.*.
+ 0x04, // ..*..
+
+// 0x57, W
+
+ 0x11, // *...*
+ 0x11, // *...*
+ 0x11, // *...*
+ 0x15, // *.*.*
+ 0x1B, // **.**
+
+// 0x58, X
+
+ 0x9, // *..*
+ 0x9, // *..*
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x9, // *..*
+
+// 0x59, Y
+
+ 0x11, // *...*
+ 0x0A, // .*.*.
+ 0x04, // ..*..
+ 0x04, // ..*..
+ 0x04, // ..*..
+
+// 0x5A, Z
+
+ 0xF, // ****
+ 0x1, // ...*
+ 0x6, // .**.
+ 0x8, // *...
+ 0xF, // ****
+
+// 0x5B, [
+
+ 0xE, // ***.
+ 0x8, // *...
+ 0x8, // *...
+ 0x8, // *...
+ 0xE, // ***.
+
+// 0x5C, Backslash
+
+ 0x8, // *...
+ 0xC, // **..
+ 0x6, // .**.
+ 0x3, // ..**
+ 0x1, // ...*
+
+// 0x5D, ]
+
+ 0x7, // .***
+ 0x1, // ...*
+ 0x1, // ...*
+ 0x1, // ...*
+ 0x7, // .***
+
+// 0x5E, ^
+
+ 0x6, // .**.
+ 0x9, // *..*
+ 0x0, // ....
+ 0x0, // ....
+ 0x0, // ....
+
+// 0x5F, _
+
+ 0x0, // ....
+ 0x0, // ....
+ 0x0, // ....
+ 0x0, // ....
+ 0xF, // ****
+} ;
diff --git a/examples/COPYING.LESSER b/examples/COPYING.LESSER
new file mode 100644
index 0000000..65c5ca8
--- /dev/null
+++ b/examples/COPYING.LESSER
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ 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/examples/Gertboard/7segments.c b/examples/Gertboard/7segments.c
new file mode 100644
index 0000000..8797e49
--- /dev/null
+++ b/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/examples/Gertboard/Makefile b/examples/Gertboard/Makefile
new file mode 100644
index 0000000..1939ad6
--- /dev/null
+++ b/examples/Gertboard/Makefile
@@ -0,0 +1,78 @@
+#
+# Makefile:
+# Gertboard - Examples using wiringPi
+#
+# Copyright (c) 2013 Gordon Henderson
+#################################################################################
+
+ifneq ($V,1)
+Q ?= @
+endif
+
+#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
+ $Q echo [link]
+ $Q $(CC) -o $@ gertboard.o $(LDFLAGS) $(LDLIBS)
+
+buttons: buttons.o
+ $Q echo [link]
+ $Q $(CC) -o $@ buttons.o $(LDFLAGS) $(LDLIBS)
+
+7segments: 7segments.o
+ $Q echo [link]
+ $Q $(CC) -o $@ 7segments.o $(LDFLAGS) $(LDLIBS)
+
+voltmeter: voltmeter.o
+ $Q echo [link]
+ $Q $(CC) -o $@ voltmeter.o $(LDFLAGS) $(LDLIBS)
+
+temperature: temperature.o
+ $Q echo [link]
+ $Q $(CC) -o $@ temperature.o $(LDFLAGS) $(LDLIBS)
+
+vumeter: vumeter.o
+ $Q echo [link]
+ $Q $(CC) -o $@ vumeter.o $(LDFLAGS) $(LDLIBS)
+
+record: record.o
+ $Q echo [link]
+ $Q $(CC) -o $@ record.o $(LDFLAGS) $(LDLIBS)
+
+.c.o:
+ $Q echo [CC] $<
+ $Q $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+ $Q echo [Clean]
+ $Q rm -f $(OBJ) *~ core tags $(BINS)
+
+tags: $(SRC)
+ $Q echo [ctags]
+ $Q ctags $(SRC)
+
+depend:
+ makedepend -Y $(SRC)
+
+# DO NOT DELETE
diff --git a/examples/Gertboard/buttons.c b/examples/Gertboard/buttons.c
new file mode 100644
index 0000000..5f76764
--- /dev/null
+++ b/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/examples/Gertboard/gertboard.c b/examples/Gertboard/gertboard.c
new file mode 100644
index 0000000..aefcb12
--- /dev/null
+++ b/examples/Gertboard/gertboard.c
@@ -0,0 +1,96 @@
+/*
+ * gertboard.c:
+ * Simple test for the SPI bus on the Gertboard
+ *
+ * Hardware setup:
+ * 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
+ * plot the input value on the terminal as a sort of vertical scrolling
+ * oscilloscipe.
+ *
+ * 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
+
+// Gertboard D to A is an 8-bit unit.
+
+#define B_SIZE 256
+
+#include
+#include
+
+int main (void)
+{
+ double angle ;
+ int i, inputValue ;
+ int buffer [B_SIZE] ;
+ int cols ;
+ struct winsize w ;
+
+
+ printf ("Raspberry Pi Gertboard SPI test program\n") ;
+ printf ("=======================================\n") ;
+
+ ioctl (fileno (stdin), TIOCGWINSZ, &w);
+ cols = w.ws_col - 2 ;
+
+// 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) ;
+
+// Generate a Sine Wave and store in our buffer
+
+ for (i = 0 ; i < B_SIZE ; ++i)
+ {
+ angle = ((double)i / (double)B_SIZE) * M_PI * 2.0 ;
+ 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 (;;)
+ {
+ for (i = 0 ; i < B_SIZE ; ++i)
+ {
+ analogWrite (100, buffer [i]) ;
+
+ 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) ;
+ }
+ }
+
+ return 0 ;
+}
diff --git a/examples/Gertboard/record.c b/examples/Gertboard/record.c
new file mode 100644
index 0000000..71d8718
--- /dev/null
+++ b/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/examples/Gertboard/temperature.c b/examples/Gertboard/temperature.c
new file mode 100644
index 0000000..5985a12
--- /dev/null
+++ b/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/examples/Gertboard/voltmeter.c b/examples/Gertboard/voltmeter.c
new file mode 100644
index 0000000..c4d2113
--- /dev/null
+++ b/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/examples/Gertboard/vumeter.c b/examples/Gertboard/vumeter.c
new file mode 100644
index 0000000..9643ace
--- /dev/null
+++ b/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/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..2dbdd72
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,197 @@
+#
+# Makefile:
+# wiringPi - A "wiring" library for the Raspberry Pi
+# https://projects.drogon.net/wiring-pi
+#
+# Copyright (c) 2012-2015 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 .
+#################################################################################
+
+ifneq ($V,1)
+Q ?= @
+endif
+
+#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 -lcrypt -lrt
+
+# Should not alter anything below this line
+###############################################################################
+
+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 \
+ lowPower.c \
+ max31855.c \
+ rht03.c \
+ w25q64_test.c oled_demo.c spiSpeed.c \
+ watchdog.c spidev_test.c spidev_test_linux3_4.c
+
+OBJ = $(SRC:.c=.o)
+
+BINS = $(SRC:.c=)
+
+all:
+ $Q cat README.TXT
+ $Q echo " $(BINS)" | fmt
+ $Q echo ""
+
+really-all: $(BINS)
+
+blink: blink.o
+ $Q echo [link]
+ $Q $(CC) -o $@ blink.o $(LDFLAGS) $(LDLIBS)
+
+blink8: blink8.o
+ $Q echo [link]
+ $Q $(CC) -o $@ blink8.o $(LDFLAGS) $(LDLIBS)
+
+blink12drcs: blink12drcs.o
+ $Q echo [link]
+ $Q $(CC) -o $@ blink12drcs.o $(LDFLAGS) $(LDLIBS)
+
+blink12: blink12.o
+ $Q echo [link]
+ $Q $(CC) -o $@ blink12.o $(LDFLAGS) $(LDLIBS)
+
+speed: speed.o
+ $Q echo [link]
+ $Q $(CC) -o $@ speed.o $(LDFLAGS) $(LDLIBS)
+
+lcd: lcd.o
+ $Q echo [link]
+ $Q $(CC) -o $@ lcd.o $(LDFLAGS) $(LDLIBS)
+
+lcd-adafruit: lcd-adafruit.o
+ $Q echo [link]
+ $Q $(CC) -o $@ lcd-adafruit.o $(LDFLAGS) $(LDLIBS)
+
+clock: clock.o
+ $Q echo [link]
+ $Q $(CC) -o $@ clock.o $(LDFLAGS) $(LDLIBS)
+
+wfi: wfi.o
+ $Q echo [link]
+ $Q $(CC) -o $@ wfi.o $(LDFLAGS) $(LDLIBS)
+
+isr: isr.o
+ $Q echo [link]
+ $Q $(CC) -o $@ isr.o $(LDFLAGS) $(LDLIBS)
+
+isr-osc: isr-osc.o
+ $Q echo [link]
+ $Q $(CC) -o $@ isr-osc.o $(LDFLAGS) $(LDLIBS)
+
+nes: nes.o
+ $Q echo [link]
+ $Q $(CC) -o $@ nes.o $(LDFLAGS) $(LDLIBS)
+
+rht03: rht03.o
+ $Q echo [link]
+ $Q $(CC) -o $@ rht03.o $(LDFLAGS) $(LDLIBS)
+
+pwm: pwm.o
+ $Q echo [link]
+ $Q $(CC) -o $@ pwm.o $(LDFLAGS) $(LDLIBS)
+
+softPwm: softPwm.o
+ $Q echo [link]
+ $Q $(CC) -o $@ softPwm.o $(LDFLAGS) $(LDLIBS)
+
+softTone: softTone.o
+ $Q echo [link]
+ $Q $(CC) -o $@ softTone.o $(LDFLAGS) $(LDLIBS)
+
+delayTest: delayTest.o
+ $Q echo [link]
+ $Q $(CC) -o $@ delayTest.o $(LDFLAGS) $(LDLIBS)
+
+serialRead: serialRead.o
+ $Q echo [link]
+ $Q $(CC) -o $@ serialRead.o $(LDFLAGS) $(LDLIBS)
+
+serialTest: serialTest.o
+ $Q echo [link]
+ $Q $(CC) -o $@ serialTest.o $(LDFLAGS) $(LDLIBS)
+
+okLed: okLed.o
+ $Q echo [link]
+ $Q $(CC) -o $@ okLed.o $(LDFLAGS) $(LDLIBS)
+
+tone: tone.o
+ $Q echo [link]
+ $Q $(CC) -o $@ tone.o $(LDFLAGS) $(LDLIBS)
+
+ds1302: ds1302.o
+ $Q echo [link]
+ $Q $(CC) -o $@ ds1302.o $(LDFLAGS) $(LDLIBS)
+
+max31855: max31855.o
+ $Q echo [link]
+ $Q $(CC) -o $@ max31855.o $(LDFLAGS) $(LDLIBS)
+
+w25q64_test: w25q64_test.o
+ $Q echo [link]
+ $Q $(CC) -o $@ w25q64_test.o $(LDFLAGS) $(LDLIBS)
+
+watchdog: watchdog.o
+ $Q echo [link]
+ $Q $(CC) -o $@ watchdog.o $(LDFLAGS) $(LDLIBS)
+
+spidev_test: spidev_test.o
+ $Q echo [link]
+ $Q $(CC) -o $@ spidev_test.o $(LDFLAGS) $(LDLIBS)
+
+spidev_test_linux3_4: spidev_test_linux3_4.o
+ $Q echo [link]
+ $Q $(CC) -o $@ spidev_test_linux3_4.o $(LDFLAGS) $(LDLIBS)
+
+oled_demo: oled_demo.o
+ $Q echo [link]
+ $Q $(CC) -o $@ oled_demo.o $(LDFLAGS) $(LDLIBS)
+
+spiSpeed: spiSpeed.o
+ $Q echo [link]
+ $Q $(CC) -o $@ spiSpeed.o $(LDFLAGS) $(LDLIBS)
+
+.c.o:
+ $Q echo [CC] $<
+ $Q $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+ $Q echo "[Clean]"
+ $Q rm -f $(OBJ) *~ core tags $(BINS)
+
+tags: $(SRC)
+ $Q echo [ctags]
+ $Q ctags $(SRC)
+
+depend:
+ makedepend -Y $(SRC)
+
+# DO NOT DELETE
diff --git a/examples/PiFace/Makefile b/examples/PiFace/Makefile
new file mode 100644
index 0000000..f937c14
--- /dev/null
+++ b/examples/PiFace/Makefile
@@ -0,0 +1,88 @@
+#
+# Makefile:
+# wiringPi - A "wiring" library for the Raspberry Pi
+# https://projects.drogon.net/wiring-pi
+#
+# Copyright (c) 2012 Gordon Henderson
+#################################################################################
+# This file is part of wiringPi:
+# A "wiring" 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 .
+#################################################################################
+
+ifneq ($V,1)
+Q ?= @
+endif
+
+#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
+ $Q echo [link]
+ $Q $(CC) -o $@ blink.o $(LDFLAGS) $(LDLIBS)
+
+buttons: buttons.o
+ $Q echo [link]
+ $Q $(CC) -o $@ buttons.o $(LDFLAGS) $(LDLIBS)
+
+reaction: reaction.o
+ $Q echo [link]
+ $Q $(CC) -o $@ reaction.o $(LDFLAGS) $(LDLIBS)
+
+ladder: ladder.o
+ $Q echo [link]
+ $Q $(CC) -o $@ ladder.o $(LDFLAGS) $(LDLIBS)
+
+metro: metro.o
+ $Q echo [link]
+ $Q $(CC) -o $@ metro.o $(LDFLAGS) $(LDLIBS)
+
+motor: motor.o
+ $Q echo [link]
+ $Q $(CC) -o $@ motor.o $(LDFLAGS) $(LDLIBS)
+
+.c.o:
+ $Q echo [CC] $<
+ $Q $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+ $Q echo "[Clean]"
+ $Q rm -f $(OBJ) *~ core tags $(BINS)
+
+tags: $(SRC)
+ $Q echo [ctags]
+ $Q ctags $(SRC)
+
+depend:
+ makedepend -Y $(SRC)
+
+# DO NOT DELETE
diff --git a/examples/PiFace/blink.c b/examples/PiFace/blink.c
new file mode 100644
index 0000000..ffb8a2e
--- /dev/null
+++ b/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/examples/PiFace/buttons.c b/examples/PiFace/buttons.c
new file mode 100644
index 0000000..147a4bd
--- /dev/null
+++ b/examples/PiFace/buttons.c
@@ -0,0 +1,103 @@
+/*
+ * buttons.c:
+ * Simple test for the PiFace interface board.
+ *
+ * Read the buttons and output the same to the 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
+#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)
+ delay (1) ;
+}
+
+
+/*
+ * start here
+ *********************************************************************************
+ */
+
+int main (void)
+{
+ int pin, button ;
+
+ 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") ;
+
+// Always initialise wiringPi. Use wiringPiSys() if you don't need
+// (or want) to run as root
+
+ wiringPiSetupSys () ;
+
+ 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 (5) ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/PiFace/ladder.c b/examples/PiFace/ladder.c
new file mode 100755
index 0000000..4f08a6f
--- /dev/null
+++ b/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/examples/PiFace/metro.c b/examples/PiFace/metro.c
new file mode 100644
index 0000000..a4a8c1d
--- /dev/null
+++ b/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/examples/PiFace/motor.c b/examples/PiFace/motor.c
new file mode 100644
index 0000000..14f5539
--- /dev/null
+++ b/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/examples/PiFace/reaction.c b/examples/PiFace/reaction.c
new file mode 100644
index 0000000..5084508
--- /dev/null
+++ b/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/examples/PiGlow/Makefile b/examples/PiGlow/Makefile
new file mode 100644
index 0000000..f182db7
--- /dev/null
+++ b/examples/PiGlow/Makefile
@@ -0,0 +1,82 @@
+#
+# Makefile:
+# wiringPi - A "wiring" library for the Raspberry Pi
+# https://projects.drogon.net/wiring-pi
+#
+# Copyright (c) 2012-2015 Gordon Henderson
+#################################################################################
+# This file is part of wiringPi:
+# A "wiring" 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 .
+#################################################################################
+
+ifneq ($V,1)
+Q ?= @
+endif
+
+#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
+ $Q echo [link]
+ $Q $(CC) -o $@ piGlow0.o $(LDFLAGS) $(LDLIBS)
+
+piGlow1: piGlow1.o
+ $Q echo [link]
+ $Q $(CC) -o $@ piGlow1.o $(LDFLAGS) $(LDLIBS)
+
+piglow: piglow.o
+ $Q echo [link]
+ $Q $(CC) -o $@ piglow.o $(LDFLAGS) $(LDLIBS)
+
+.c.o:
+ $Q echo [CC] $<
+ $Q $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+ $Q echo "[Clean]"
+ $Q rm -f $(OBJ) *~ core tags $(BINS)
+
+tags: $(SRC)
+ $Q echo [ctags]
+ $Q ctags $(SRC)
+
+install: piglow
+ $Q echo Installing piglow into /usr/local/bin
+ $Q cp -a piglow /usr/local/bin/piglow
+ $Q chmod 755 /usr/local/bin/piglow
+ $Q echo Done. Remember to load the I2C drivers!
+
+depend:
+ makedepend -Y $(SRC)
+
+# DO NOT DELETE
diff --git a/examples/PiGlow/piGlow0.c b/examples/PiGlow/piGlow0.c
new file mode 100644
index 0000000..d3fe4b9
--- /dev/null
+++ b/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/examples/PiGlow/piGlow1.c b/examples/PiGlow/piGlow1.c
new file mode 100644
index 0000000..a00b31e
--- /dev/null
+++ b/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/examples/PiGlow/piglow.c b/examples/PiGlow/piglow.c
new file mode 100644
index 0000000..e6a2db3
--- /dev/null
+++ b/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/examples/README.TXT b/examples/README.TXT
new file mode 100644
index 0000000..33263b1
--- /dev/null
+++ b/examples/README.TXT
@@ -0,0 +1,18 @@
+
+wiringPi Examples
+=================
+
+There are now too many examples to compile them all in a sensible time,
+and you probably don't want to compile or run them all anyway, so they
+have been separated out.
+
+To compile an individual example, just type
+
+ make exampleName
+
+To really compile everything:
+
+ make really-all
+
+The individual tests are:
+
diff --git a/examples/blink-thread.c b/examples/blink-thread.c
new file mode 100644
index 0000000..a53fbf3
--- /dev/null
+++ b/examples/blink-thread.c
@@ -0,0 +1,61 @@
+/*
+ * blink-thread.c:
+ * Standard "blink" program in wiringPi. Blinks an LED connected
+ * to the first GPIO pin.
+ *
+ * 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
+
+// LED Pin - wiringPi pin 0 is BCM_GPIO 17.
+
+#define LED 0
+
+PI_THREAD (blinky)
+{
+ for (;;)
+ {
+ digitalWrite (LED, HIGH) ; // On
+ delay (500) ; // mS
+ digitalWrite (LED, LOW) ; // Off
+ delay (500) ;
+ }
+}
+
+
+int main (void)
+{
+ printf ("Raspberry Pi blink\n") ;
+
+ wiringPiSetup () ;
+ pinMode (LED, OUTPUT) ;
+
+ piThreadCreate (blinky) ;
+
+ for (;;)
+ {
+ printf ("Hello, world\n") ;
+ delay (600) ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/blink.c b/examples/blink.c
new file mode 100644
index 0000000..f69cef3
--- /dev/null
+++ b/examples/blink.c
@@ -0,0 +1,77 @@
+#include
+#include
+
+unsigned char getGpioNum(void)
+{
+ int model = -1;
+
+ piBoardId (&model);
+
+ switch (model)
+ {
+ case PI_MODEL_5B:
+ return 16;
+ break;
+ case PI_MODEL_3:
+ case PI_MODEL_LTIE_2:
+ case PI_MODEL_ZERO:
+ case PI_MODEL_ZERO_PLUS_2:
+ case PI_MODEL_ZERO_PLUS:
+ case PI_MODEL_4_LTS:
+ case PI_MODEL_800:
+ case PI_MODEL_5:
+ return 17;
+ break;
+ case PI_MODEL_ZERO_2:
+ return 21;
+ break;
+ case PI_MODEL_WIN:
+ case PI_MODEL_PRIME:
+ case PI_MODEL_PC_2:
+ case PI_MODEL_H3:
+ case PI_MODEL_RK3399:
+ case PI_MODEL_4:
+ case PI_MODEL_5_PLUS:
+ case PI_MODEL_900:
+ case PI_MODEL_CM4:
+ case PI_MODEL_3B:
+ case PI_MODEL_ZERO_2_W:
+ return 28;
+ break;
+ case PI_MODEL_R1_PLUS:
+ return 8;
+ break;
+ default:
+ printf ("Oops - unable to determine board type... model: %d\n", model);
+ return -1;
+ break;
+ }
+}
+
+int main (void)
+{
+ int i = 0;
+ unsigned char gpio_num = 0;
+
+ wiringPiSetup();
+
+ gpio_num = getGpioNum();
+ if (-1 == gpio_num)
+ printf("Failed to get the number of GPIO!\n");
+
+ for (i = 0; i < gpio_num; i++)
+ pinMode (i, OUTPUT) ;
+
+ for ( ;; )
+ {
+ for (i = 0; i < gpio_num; i++)
+ digitalWrite (i, HIGH); // On
+ delay (2000);
+
+ for (i = 0; i < gpio_num; i++)
+ digitalWrite (i, LOW); // Off
+ delay (2000);
+ }
+
+ return 0;
+}
diff --git a/examples/blink.rtb b/examples/blink.rtb
new file mode 100644
index 0000000..eb7d26c
--- /dev/null
+++ b/examples/blink.rtb
@@ -0,0 +1,30 @@
+// blink.rtb:
+// Blink program in Return to Basic
+//
+// 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 .
+ ***********************************************************************
+//
+PinMode (0, 1) // Output
+CYCLE
+ DigitalWrite (0, 1) // Pin 0 ON
+ WAIT (0.5) // 0.5 seconds
+ DigitalWrite (0, 0)
+ WAIT (0.5)
+REPEAT
+END
diff --git a/examples/blink.sh b/examples/blink.sh
new file mode 100755
index 0000000..3975bb7
--- /dev/null
+++ b/examples/blink.sh
@@ -0,0 +1,37 @@
+#!/bin/sh -e
+#
+# blink.sh:
+# Standard "blink" program in wiringPi. Blinks an LED connected
+# to the first GPIO pin.
+#
+# 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 0 is BCM_GPIO 17.
+
+PIN=0
+
+gpio mode $PIN out
+
+while true; do
+ gpio write $PIN 1
+ sleep 0.5
+ gpio write $PIN 0
+ sleep 0.5
+done
diff --git a/examples/blink12.c b/examples/blink12.c
new file mode 100644
index 0000000..c9b3d50
--- /dev/null
+++ b/examples/blink12.c
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ ***********************************************************************
+ * 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
+
+// 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, 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
+
+ 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,
+ 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 8 GPIO pins, then pins 11, 10, 13, 12 in\n") ;
+ printf (" that order, then sit back and watch the show!\n") ;
+
+ wiringPiSetup () ;
+
+ for (pin = 0 ; pin < 14 ; ++pin)
+ pinMode (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 (l, s) ;
+ delay (d * 100) ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/blink12drcs.c b/examples/blink12drcs.c
new file mode 100644
index 0000000..6ee11fd
--- /dev/null
+++ b/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/examples/blink6drcs.c b/examples/blink6drcs.c
new file mode 100644
index 0000000..32f4921
--- /dev/null
+++ b/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/examples/blink8-drcn.c b/examples/blink8-drcn.c
new file mode 100644
index 0000000..96c775b
--- /dev/null
+++ b/examples/blink8-drcn.c
@@ -0,0 +1,61 @@
+/*
+ * blink8-drcn.c:
+ * Simple sequence over the first 8 GPIO pins - LEDs
+ * Aimed at the Ladder board, 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
+#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") ;
+
+ int pinBase = 100 ;
+
+// wiringPiSetup () ;
+ drcSetupNet (pinBase, 100, "192.168.254.21", "6124", "123456") ;
+
+ for (i = 0 ; i < 8 ; ++i)
+ pinMode (i + pinBase, OUTPUT) ;
+
+ for (;;)
+ {
+ for (led = 0 ; led < 8 ; ++led)
+ {
+ digitalWrite (led + pinBase, 1) ;
+ delay (10) ;
+ }
+
+ for (led = 0 ; led < 8 ; ++led)
+ {
+ digitalWrite (led + pinBase, 0) ;
+ delay (10) ;
+ }
+ }
+}
diff --git a/examples/blink8.c b/examples/blink8.c
new file mode 100644
index 0000000..602d3c0
--- /dev/null
+++ b/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/examples/clock.c b/examples/clock.c
new file mode 100644
index 0000000..9a53210
--- /dev/null
+++ b/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/examples/delayTest.c b/examples/delayTest.c
new file mode 100644
index 0000000..d772cf9
--- /dev/null
+++ b/examples/delayTest.c
@@ -0,0 +1,102 @@
+/*
+ * delayTest.c:
+ * Just a little test program I'm using to experiment with
+ * various timings and latency, etc.
+ *
+ * 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 CYCLES 1000
+
+int main()
+{
+ int x ;
+ struct timeval t1, t2, t3 ;
+ int t ;
+ int max, min ;
+ int del ;
+ int underRuns, overRuns, exactRuns, bogusRuns, total ;
+ int descheds ;
+
+
+// Baseline test
+
+ gettimeofday (&t1, NULL) ;
+ gettimeofday (&t2, NULL) ;
+
+ t = t2.tv_usec - t1.tv_usec ;
+ printf ("Baseline test: %d\n", t);
+
+ for (del = 1 ; del < 200 ; ++del)
+ {
+ underRuns = overRuns = exactRuns = total = 0 ;
+ descheds = 0 ;
+ max = 0 ;
+ min = 999 ;
+
+ for (x = 0 ; x < CYCLES ; ++x)
+ {
+ for (;;) // Repeat this if we get a delay over 999uS
+ { // -> High probability Linux has deschedulled us
+ gettimeofday (&t1, NULL) ;
+ usleep (del) ;
+// delayMicroseconds (del) ;
+ gettimeofday (&t2, NULL) ;
+
+ timersub (&t2, &t1, &t3) ;
+
+ t = t3.tv_usec ;
+
+ if (t > 999)
+ {
+ ++descheds ;
+ continue ;
+ }
+ else
+ break ;
+ }
+
+ if (t == del)
+ ++exactRuns ;
+ else if (t < del)
+ ++underRuns ;
+ else if (t > del)
+ ++overRuns ;
+
+ if (t > max)
+ max = t ;
+ else if (t < min)
+ min = t ;
+
+ total += t ;
+ }
+ printf ("Delay: %3d. Min: %3d, Max: %3d, Unders: %3d, Overs: %3d, Exacts: %3d, Average: %3d, Descheds: %2d\n",
+ del, min, max, underRuns, overRuns, exactRuns, total / CYCLES, descheds) ;
+ fflush (stdout) ;
+ usleep (1000) ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/ds1302.c b/examples/ds1302.c
new file mode 100644
index 0000000..f1e9e20
--- /dev/null
+++ b/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/examples/header.h b/examples/header.h
new file mode 100644
index 0000000..82f723d
--- /dev/null
+++ b/examples/header.h
@@ -0,0 +1,23 @@
+/*
+ * file.c:
+ *
+ * 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 .
+ ***********************************************************************
+ */
+
diff --git a/examples/isr-osc.c b/examples/isr-osc.c
new file mode 100644
index 0000000..a872ee3
--- /dev/null
+++ b/examples/isr-osc.c
@@ -0,0 +1,118 @@
+/*
+ * isr-osc.c:
+ * Wait for Interrupt test program - ISR method - interrupt oscillator
+ *
+ * How to test:
+ *
+ * IMPORTANT: To run this test we connect 2 GPIO pins together, but
+ * before we do that YOU must make sure that they are both setup
+ * the right way. If they are set to outputs and one is high and one low,
+ * then you connect the wire, you'll create a short and that won't be good.
+ *
+ * Before making the connection, type:
+ * gpio mode 0 output
+ * gpio write 0 0
+ * gpio mode 1 input
+ * then you can connect them together.
+ *
+ * Run the program, then:
+ * gpio write 0 1
+ * gpio write 0 0
+ *
+ * at which point it will trigger an interrupt and the program will
+ * then do the up/down toggling for itself and run at full speed, and
+ * it will report the number of interrupts recieved every second.
+ *
+ * Copyright (c) 2013 Gordon Henderson. projects@drogon.net
+ ***********************************************************************
+ * 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
+
+
+// What GPIO input are we using?
+// This is a wiringPi pin number
+
+#define OUT_PIN 0
+#define IN_PIN 1
+
+// globalCounter:
+// Global variable to count interrupts
+// Should be declared volatile to make sure the compiler doesn't cache it.
+
+static volatile int globalCounter = 0 ;
+
+/*
+ * myInterrupt:
+ *********************************************************************************
+ */
+
+void myInterrupt (void)
+{
+ digitalWrite (OUT_PIN, 1) ;
+ ++globalCounter ;
+ digitalWrite (OUT_PIN, 0) ;
+}
+
+
+/*
+ *********************************************************************************
+ * main
+ *********************************************************************************
+ */
+
+int main (void)
+{
+ int myCounter = 0 ;
+ int lastCounter = 0 ;
+
+ if (wiringPiSetup () < 0)
+ {
+ fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno)) ;
+ return 1 ;
+ }
+
+ pinMode (OUT_PIN, OUTPUT) ;
+ pinMode (IN_PIN, INPUT) ;
+
+ if (wiringPiISR (IN_PIN, INT_EDGE_FALLING, &myInterrupt) < 0)
+ {
+ fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno)) ;
+ return 1 ;
+ }
+
+ for (;;)
+ {
+ printf ("Waiting ... ") ; fflush (stdout) ;
+
+ while (myCounter == globalCounter)
+ delay (1000) ;
+
+ printf (" Done. counter: %6d: %6d\n",
+ globalCounter, myCounter - lastCounter) ;
+ lastCounter = myCounter ;
+ myCounter = globalCounter ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/isr.c b/examples/isr.c
new file mode 100644
index 0000000..abc6aec
--- /dev/null
+++ b/examples/isr.c
@@ -0,0 +1,110 @@
+/*
+ * isr.c:
+ * Wait for Interrupt test program - ISR method
+ *
+ * How to test:
+ * Use the SoC's pull-up and pull down resistors that are avalable
+ * on input pins. So compile & run this program (via sudo), then
+ * in another terminal:
+ * gpio mode 0 up
+ * gpio mode 0 down
+ * at which point it should trigger an interrupt. Toggle the pin
+ * up/down to generate more interrupts to test.
+ *
+ * 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
+
+
+// globalCounter:
+// Global variable to count interrupts
+// Should be declared volatile to make sure the compiler doesn't cache it.
+
+static volatile int globalCounter [8] ;
+
+
+/*
+ * myInterrupt:
+ *********************************************************************************
+ */
+
+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] ; }
+
+
+/*
+ *********************************************************************************
+ * main
+ *********************************************************************************
+ */
+
+int main (void)
+{
+ int gotOne, pin ;
+ int myCounter [8] ;
+
+ for (pin = 0 ; pin < 8 ; ++pin)
+ globalCounter [pin] = myCounter [pin] = 0 ;
+
+ 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) ;
+
+ 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/examples/lcd-adafruit.c b/examples/lcd-adafruit.c
new file mode 100644
index 0000000..47c9b9b
--- /dev/null
+++ b/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/examples/lcd.c b/examples/lcd.c
new file mode 100644
index 0000000..510f562
--- /dev/null
+++ b/examples/lcd.c
@@ -0,0 +1,286 @@
+/*
+ * lcd.c:
+ * Text-based LCD driver.
+ * This is designed to drive the parallel interface LCD drivers
+ * based in the Hitachi HD44780U controller and compatables.
+ *
+ * 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/
+ *
+ * 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
+
+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 ;
+
+ char buf [32] ;
+
+ if (argc != 4)
+ return usage (argv [0]) ;
+
+ printf ("Raspberry Pi LCD test\n") ;
+ printf ("=====================\n") ;
+
+ bits = atoi (argv [1]) ;
+ cols = atoi (argv [2]) ;
+ rows = atoi (argv [3]) ;
+
+ if (!((rows == 1) || (rows == 2) || (rows == 4)))
+ {
+ fprintf (stderr, "%s: rows must be 1, 2 or 4\n", argv [0]) ;
+ return EXIT_FAILURE ;
+ }
+
+ if (!((cols == 16) || (cols == 20)))
+ {
+ fprintf (stderr, "%s: cols must be 16 or 20\n", argv [0]) ;
+ return EXIT_FAILURE ;
+ }
+
+ wiringPiSetup () ;
+
+ 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) ;
+
+ if (lcdHandle < 0)
+ {
+ fprintf (stderr, "%s: lcdInit failed\n", argv [0]) ;
+ return -1 ;
+ }
+
+ lcdPosition (lcdHandle, 0, 0) ; lcdPuts (lcdHandle, "Gordon Henderson") ;
+ lcdPosition (lcdHandle, 0, 1) ; lcdPuts (lcdHandle, " wiringpi.com ") ;
+
+ 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 (;;)
+ {
+ scrollMessage (0, cols) ;
+
+ if (rows == 1)
+ continue ;
+
+ 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) ;
+
+ if (rows == 2)
+ continue ;
+
+ 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/examples/lowPower.c b/examples/lowPower.c
new file mode 100644
index 0000000..e901e7f
--- /dev/null
+++ b/examples/lowPower.c
@@ -0,0 +1,68 @@
+/*
+ * lowPower.c:
+ * Check the Pi's LOW-Power signal.
+ *
+ * This is a demonstration program that could be turned into some sort
+ * of logger via e.g. syslog - however it's also probably something
+ * that might be better handled by a future kernel - who knows.
+ *
+ * Copyright (c) 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 LOW_POWER 35
+
+/*
+ * lowPower:
+ * This is an ISR that waits for the low-power signal going low and
+ * prints the result.
+ *********************************************************************************
+ */
+
+void lowPower (void)
+{
+ time_t t ;
+
+ time (&t) ;
+ printf ("%s: LOW POWER DETECTED\n", ctime (&t)) ;
+}
+
+
+/*
+ *********************************************************************************
+ * main
+ *********************************************************************************
+ */
+
+int main (void)
+{
+ wiringPiSetupGpio () ; // GPIO mode as it's an internal pin
+
+ wiringPiISR (LOW_POWER, INT_EDGE_FALLING, &lowPower) ;
+
+ for (;;)
+ delay (1000) ;
+
+ return 0 ;
+}
diff --git a/examples/max31855.c b/examples/max31855.c
new file mode 100644
index 0000000..36b3cf6
--- /dev/null
+++ b/examples/max31855.c
@@ -0,0 +1,60 @@
+/*
+ * max31855.c:
+ * SPI Thermocouple interface chip
+ *
+ * Copyright (c) 2015 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
+
+int main (int argc, char *argv [])
+{
+ int i = 0 ;
+
+ wiringPiSetup () ;
+ max31855Setup (200, 0) ;
+ max31855Setup (400, 1) ;
+
+ for (;;)
+ {
+ if (i == 0)
+ {
+ printf ("+------+------+------+------++------+------+------+------+\n") ;
+ printf ("| Raw | Err | C | F || Raw | Err | C | F |\n") ;
+ printf ("+------+------+------+------++------+------+------+------+\n") ;
+ }
+
+ printf ("| %4d | %4d | %4d | %4d |", analogRead (200), analogRead (201), analogRead (202), analogRead (203)) ;
+ printf ("| %4d | %4d | %4d | %4d |\n", analogRead (400), analogRead (401), analogRead (402), analogRead (403)) ;
+ delay (500) ;
+
+ if (++i == 10)
+ i = 0 ;
+
+ }
+
+}
diff --git a/examples/nes.c b/examples/nes.c
new file mode 100644
index 0000000..31908e8
--- /dev/null
+++ b/examples/nes.c
@@ -0,0 +1,67 @@
+/*
+ * nes.c:
+ * Test program for an old NES controller connected to the 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
+
+#define BLANK "| "
+
+int main ()
+{
+ int joystick ;
+ unsigned int buttons ;
+
+ if (wiringPiSetup () == -1)
+ {
+ fprintf (stdout, "oops: %s\n", strerror (errno)) ;
+ return 1 ;
+ }
+
+ if ((joystick = setupNesJoystick (2, 1, 0)) == -1)
+ {
+ fprintf (stdout, "Unable to setup joystick\n") ;
+ return 1 ;
+ }
+
+ for (;;)
+ {
+ buttons = readNesJoystick (joystick) ;
+
+ if ((buttons & NES_UP) != 0) printf ("| UP " ) ; else printf (BLANK) ;
+ if ((buttons & NES_DOWN) != 0) printf ("| DOWN " ) ; else printf (BLANK) ;
+ if ((buttons & NES_LEFT) != 0) printf ("| LEFT " ) ; else printf (BLANK) ;
+ if ((buttons & NES_RIGHT) != 0) printf ("|RIGHT " ) ; else printf (BLANK) ;
+ if ((buttons & NES_SELECT) != 0) printf ("|SELECT" ) ; else printf (BLANK) ;
+ if ((buttons & NES_START) != 0) printf ("|START " ) ; else printf (BLANK) ;
+ if ((buttons & NES_A) != 0) printf ("| A " ) ; else printf (BLANK) ;
+ if ((buttons & NES_B) != 0) printf ("| B " ) ; else printf (BLANK) ;
+ printf ("|\n") ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/okLed.c b/examples/okLed.c
new file mode 100644
index 0000000..930f266
--- /dev/null
+++ b/examples/okLed.c
@@ -0,0 +1,82 @@
+/*
+ * okLed.c:
+ * Make the OK LED on the Pi Pulsate...
+ *
+ * Originally posted to the Raspberry Pi forums:
+ * http://www.raspberrypi.org/phpBB3/viewtopic.php?p=162581#p162581
+ *
+ * Compile this and store it somewhere, then kick it off at boot time
+ * e.g. by putting it in /etc/rc.local and running it in the
+ * background &
+ *
+ * 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
+
+// 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) ;
+
+ softPwmCreate (OK_LED, 0, 100) ;
+
+ for (;;)
+ {
+ for (i = 0 ; i <= 100 ; ++i)
+ {
+ softPwmWrite (OK_LED, i) ;
+ delay (10) ;
+ }
+ delay (50) ;
+
+ for (i = 100 ; i >= 0 ; --i)
+ {
+ softPwmWrite (OK_LED, i) ;
+ delay (10) ;
+ }
+ delay (10) ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/oled_demo.c b/examples/oled_demo.c
new file mode 100644
index 0000000..93c1e30
--- /dev/null
+++ b/examples/oled_demo.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2015, Vladimir Komendantskiy
+ * MIT License
+ *
+ * SSD1306 demo of block and font drawing.
+ */
+
+//
+// fixed for OrangePiZero by HypHop
+//
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "oled.h"
+#include "font.h"
+
+int oled_demo(struct display_info *disp) {
+ int i;
+ char buf[100];
+
+ //putstrto(disp, 0, 0, "Spnd spd 2468 rpm");
+ // oled_putstrto(disp, 0, 9+1, "Spnd cur 0.46 A");
+ oled_putstrto(disp, 0, 9+1, "Welcome to");
+ disp->font = font1;
+ // oled_putstrto(disp, 0, 18+2, "Spnd tmp 53 C");
+ oled_putstrto(disp, 0, 18+2, "----OrangePi----");
+ disp->font = font2;
+ // oled_putstrto(disp, 0, 27+3, "DrvX tmp 64 C");
+ oled_putstrto(disp, 0, 27+3, "This is 0.96OLED");
+ oled_putstrto(disp, 0, 36+4, "");
+ oled_putstrto(disp, 0, 45+5, "");
+ disp->font = font1;
+ // oled_putstrto(disp, 0, 54, "Total cur 2.36 A");
+ oled_putstrto(disp, 0, 54, "*****************");
+ oled_send_buffer(disp);
+
+ disp->font = font3;
+ for (i=0; i<100; i++) {
+ sprintf(buf, "Spnd spd %d rpm", i);
+ oled_putstrto(disp, 0, 0, buf);
+ oled_putstrto(disp, 135-i, 36+4, "===");
+ oled_putstrto(disp, 100, 0+i/2, ".");
+ oled_send_buffer(disp);
+ }
+ //oled_putpixel(disp, 60, 45);
+ //oled_putstr(disp, 1, "hello");
+
+return 0;
+}
+
+void show_error(int err, int add) {
+ //const gchar* errmsg;
+ //errmsg = g_strerror(errno);
+ printf("\nERROR: %i, %i\n\n", err, add);
+ //printf("\nERROR\n");
+}
+
+void show_usage(char *progname) {
+ printf("\nUsage:\n%s \n", progname);
+}
+
+int main(int argc, char **argv) {
+ int e;
+ char filename[32];
+ struct display_info disp;
+
+ if (argc < 2) {
+ show_usage(argv[0]);
+
+ return -1;
+ }
+
+ memset(&disp, 0, sizeof(disp));
+ sprintf(filename, "%s", argv[1]);
+ disp.address = OLED_I2C_ADDR;
+ disp.font = font2;
+
+ e = oled_open(&disp, filename);
+
+ if (e < 0) {
+ show_error(1, e);
+ } else {
+ e = oled_init(&disp);
+ if (e < 0) {
+ show_error(2, e);
+ } else {
+ printf("---------start--------\n");
+ if (oled_demo(&disp) < 0)
+ show_error(3, 777);
+ printf("----------end---------\n");
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/pwm.c b/examples/pwm.c
new file mode 100644
index 0000000..bbee89d
--- /dev/null
+++ b/examples/pwm.c
@@ -0,0 +1,128 @@
+#include
+#include
+#include
+#include
+
+int main(int argc, char *argv [])
+{
+ int i = 0;
+ int val = 0;
+ int pin= 0;
+
+ if (argc != 2) {
+ fprintf (stderr, "Usage: %s \n", argv [0]) ;
+ exit (1) ;
+ }
+
+ pin = (unsigned int)strtoul (argv [1], NULL, 10) ;
+
+ if (pin != 3 && pin != 4 && pin != 21 && pin != 22 && pin != 2 && pin != 9 ) {
+ fprintf (stderr, "the pin you choose doesn't support hardware PWM\n") ;
+ exit (1) ;
+ }
+
+ // åˆå§‹åŒ–
+ printf("wiringPiSetup start\n");
+
+ wiringPiSetup();
+ pinMode(pin,PWM_OUTPUT);
+
+ printf("wiringPiSetup end\n");
+
+ // 开始测试
+ while(1)
+ {
+ pwmSetRange(pin,1024);
+ pwmSetClock(pin,1);
+ pwmWrite(pin,512);
+
+ //1. 调节PWMå 空比
+ //1.1 通过设置ARR调节PWMå 空比
+ printf("Modified ARR test start\n");
+
+ for (i = 0 ; i <= 8 ; i++) {
+ pwmSetRange(pin,1024+i*128);
+ delay(500);
+ }
+
+ delay(5000);
+
+ for (i = 7 ; i >= 0 ; i-- ) {
+ pwmSetRange(pin,1024+i*128);
+ delay(500);
+ }
+
+ delay(5000);
+
+ printf("Modified ARR test end\n");
+
+ pwmSetMode(pin,PWM_MODE_BAL);
+ delay(5000);
+ pwmSetMode(pin,PWM_MODE_MS);
+
+ //1.2 通过设置CRR调节PWMå 空比
+ printf("Modified CRR test start\n");
+
+ for (i = 0 ; i <= 8 ; i++) {
+ pwmWrite(pin,512 + i*64);
+ delay(500);
+ }
+
+ delay(5000);
+
+ for (i = 7 ; i >= 0 ; i-- ) {
+ pwmWrite(pin,512 + i*64);
+ delay(500);
+ }
+
+ delay(5000);
+
+ printf("Modified active range test end\n");
+
+ pwmSetMode(pin,PWM_MODE_BAL);
+ delay(5000);
+ pwmSetMode(pin,PWM_MODE_MS);
+
+ //2.调节PWM频率
+ //2.1通过设置分频系数调节PWM频率
+
+ printf("Modified frequency division test start\n");
+
+ for (i = 1 ; i <= 10; i++) {
+ pwmSetClock(pin,i);
+ delay(500);
+ }
+
+ delay(5000);
+
+ for (i = 9 ; i >= 1 ; i--) {
+ pwmSetClock(pin,i);
+ delay(500);
+ }
+
+ delay(5000);
+
+ printf("Modified frequency division test end\n");
+
+ pwmSetMode(pin,PWM_MODE_BAL);
+ delay(5000);
+ pwmSetMode(pin,PWM_MODE_MS);
+
+ //2.2 直接设置PWM频率
+ printf("Modified PWM frequency test start\n");
+
+ for (i = 1 ; i <= 10; i++) {
+ pwmToneWrite(pin,2000*i);
+ delay(2000);
+ }
+
+ delay(5000);
+
+ printf("Modified PWM frequency test end\n");
+
+ pwmSetMode(pin,PWM_MODE_BAL);
+ delay(5000);
+ pwmSetMode(pin,PWM_MODE_MS);
+ }
+ return 0;
+}
diff --git a/examples/q2w/Makefile b/examples/q2w/Makefile
new file mode 100644
index 0000000..8f773bf
--- /dev/null
+++ b/examples/q2w/Makefile
@@ -0,0 +1,84 @@
+#
+# Makefile:
+# wiringPi - A "wiring" library for the Raspberry Pi
+# https://projects.drogon.net/wiring-pi
+#
+# Copyright (c) 2012-2013 Gordon Henderson
+#################################################################################
+# This file is part of wiringPi:
+# A "wiring" 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 .
+#################################################################################
+
+ifneq ($V,1)
+Q ?= @
+endif
+
+#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
+ $Q echo [link]
+ $Q $(CC) -o $@ blink.o $(LDFLAGS) $(LDLIBS)
+
+blink-io: blink-io.o
+ $Q echo [link]
+ $Q $(CC) -o $@ blink-io.o $(LDFLAGS) $(LDLIBS)
+
+button: button.o
+ $Q echo [link]
+ $Q $(CC) -o $@ button.o $(LDFLAGS) $(LDLIBS)
+
+volts: volts.o
+ $Q echo [link]
+ $Q $(CC) -o $@ volts.o $(LDFLAGS) $(LDLIBS)
+
+bright: bright.o
+ $Q echo [link]
+ $Q $(CC) -o $@ bright.o $(LDFLAGS) $(LDLIBS)
+
+
+.c.o:
+ $Q echo [CC] $<
+ $Q $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+ $Q echo "[Clean]"
+ $Q rm -f $(OBJ) *~ core tags $(BINS)
+
+tags: $(SRC)
+ $Q echo [ctags]
+ $Q ctags $(SRC)
+
+depend:
+ makedepend -Y $(SRC)
+
+# DO NOT DELETE
diff --git a/examples/q2w/binary.c b/examples/q2w/binary.c
new file mode 100644
index 0000000..3c987c6
--- /dev/null
+++ b/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/examples/q2w/blink-io.c b/examples/q2w/blink-io.c
new file mode 100644
index 0000000..4dd4276
--- /dev/null
+++ b/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/examples/q2w/blink.c b/examples/q2w/blink.c
new file mode 100644
index 0000000..62b694a
--- /dev/null
+++ b/examples/q2w/blink.c
@@ -0,0 +1,50 @@
+/*
+ * blink.c:
+ * Simple "blink" 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 LED 1
+
+int main (void)
+{
+
+// Enable the on-goard GPIO
+
+ wiringPiSetup () ;
+
+ printf ("Raspberry Pi - Quick2Wire Mainboard LED Blink Test\n") ;
+
+ pinMode (LED, OUTPUT) ;
+
+ for (;;)
+ {
+ digitalWrite (LED, HIGH) ;
+ delay (500) ;
+ digitalWrite (LED, LOW) ;
+ delay (500) ;
+ }
+
+ return 0 ;
+}
diff --git a/examples/q2w/blink.sh b/examples/q2w/blink.sh
new file mode 100755
index 0000000..bb6107a
--- /dev/null
+++ b/examples/q2w/blink.sh
@@ -0,0 +1,37 @@
+#!/bin/sh -e
+#
+# 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/examples/q2w/bright.c b/examples/q2w/bright.c
new file mode 100644
index 0000000..2318834
--- /dev/null
+++ b/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/examples/q2w/button.c b/examples/q2w/button.c
new file mode 100644
index 0000000..1781f02
--- /dev/null
+++ b/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/examples/q2w/volts.c b/examples/q2w/volts.c
new file mode 100644
index 0000000..e091093
--- /dev/null
+++ b/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/examples/rht03.c b/examples/rht03.c
new file mode 100644
index 0000000..854f837
--- /dev/null
+++ b/examples/rht03.c
@@ -0,0 +1,86 @@
+/*
+ * rht03.c:
+ * Driver for the MaxDetect series sensors
+ *
+ * Copyright (c) 2012-2013 Gordon Henderson.