wiringpi-ruby 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wiringpi/WiringPi/devLib/ds1302.c +240 -0
  3. data/ext/wiringpi/WiringPi/devLib/ds1302.h +44 -0
  4. data/ext/wiringpi/WiringPi/devLib/font.h +2577 -0
  5. data/ext/wiringpi/WiringPi/devLib/gertboard.c +164 -0
  6. data/ext/wiringpi/WiringPi/devLib/gertboard.h +45 -0
  7. data/ext/wiringpi/WiringPi/devLib/lcd.c +495 -0
  8. data/ext/wiringpi/WiringPi/devLib/lcd.h +52 -0
  9. data/ext/wiringpi/WiringPi/devLib/lcd128x64.c +673 -0
  10. data/ext/wiringpi/WiringPi/devLib/lcd128x64.h +39 -0
  11. data/ext/wiringpi/WiringPi/devLib/maxdetect.c +238 -0
  12. data/ext/wiringpi/WiringPi/devLib/maxdetect.h +40 -0
  13. data/ext/wiringpi/WiringPi/devLib/piFace.c +112 -0
  14. data/ext/wiringpi/WiringPi/devLib/piFace.h +32 -0
  15. data/ext/wiringpi/WiringPi/devLib/piFaceOld.c +177 -0
  16. data/ext/wiringpi/WiringPi/devLib/piGlow.c +118 -0
  17. data/ext/wiringpi/WiringPi/devLib/piGlow.h +45 -0
  18. data/ext/wiringpi/WiringPi/devLib/piNes.c +113 -0
  19. data/ext/wiringpi/WiringPi/devLib/piNes.h +45 -0
  20. data/ext/wiringpi/WiringPi/devLib/scrollPhat.c +430 -0
  21. data/ext/wiringpi/WiringPi/devLib/scrollPhat.h +39 -0
  22. data/ext/wiringpi/WiringPi/devLib/scrollPhatFont.h +544 -0
  23. data/ext/wiringpi/WiringPi/examples/Gertboard/7segments.c +221 -0
  24. data/ext/wiringpi/WiringPi/examples/Gertboard/buttons.c +83 -0
  25. data/ext/wiringpi/WiringPi/examples/Gertboard/gertboard.c +96 -0
  26. data/ext/wiringpi/WiringPi/examples/Gertboard/record.c +60 -0
  27. data/ext/wiringpi/WiringPi/examples/Gertboard/temperature.c +78 -0
  28. data/ext/wiringpi/WiringPi/examples/Gertboard/voltmeter.c +73 -0
  29. data/ext/wiringpi/WiringPi/examples/Gertboard/vumeter.c +152 -0
  30. data/ext/wiringpi/WiringPi/examples/PiFace/blink.c +59 -0
  31. data/ext/wiringpi/WiringPi/examples/PiFace/buttons.c +103 -0
  32. data/ext/wiringpi/WiringPi/examples/PiFace/ladder.c +337 -0
  33. data/ext/wiringpi/WiringPi/examples/PiFace/metro.c +111 -0
  34. data/ext/wiringpi/WiringPi/examples/PiFace/motor.c +120 -0
  35. data/ext/wiringpi/WiringPi/examples/PiFace/reaction.c +194 -0
  36. data/ext/wiringpi/WiringPi/examples/PiGlow/piGlow0.c +51 -0
  37. data/ext/wiringpi/WiringPi/examples/PiGlow/piGlow1.c +258 -0
  38. data/ext/wiringpi/WiringPi/examples/PiGlow/piglow.c +176 -0
  39. data/ext/wiringpi/WiringPi/examples/blink-thread.c +61 -0
  40. data/ext/wiringpi/WiringPi/examples/blink.c +48 -0
  41. data/ext/wiringpi/WiringPi/examples/blink12.c +111 -0
  42. data/ext/wiringpi/WiringPi/examples/blink12drcs.c +125 -0
  43. data/ext/wiringpi/WiringPi/examples/blink6drcs.c +115 -0
  44. data/ext/wiringpi/WiringPi/examples/blink8-drcn.c +61 -0
  45. data/ext/wiringpi/WiringPi/examples/blink8.c +57 -0
  46. data/ext/wiringpi/WiringPi/examples/clock.c +201 -0
  47. data/ext/wiringpi/WiringPi/examples/delayTest.c +102 -0
  48. data/ext/wiringpi/WiringPi/examples/ds1302.c +238 -0
  49. data/ext/wiringpi/WiringPi/examples/header.h +23 -0
  50. data/ext/wiringpi/WiringPi/examples/isr-osc.c +118 -0
  51. data/ext/wiringpi/WiringPi/examples/isr.c +110 -0
  52. data/ext/wiringpi/WiringPi/examples/lcd-adafruit.c +347 -0
  53. data/ext/wiringpi/WiringPi/examples/lcd.c +286 -0
  54. data/ext/wiringpi/WiringPi/examples/lowPower.c +68 -0
  55. data/ext/wiringpi/WiringPi/examples/max31855.c +60 -0
  56. data/ext/wiringpi/WiringPi/examples/nes.c +67 -0
  57. data/ext/wiringpi/WiringPi/examples/okLed.c +82 -0
  58. data/ext/wiringpi/WiringPi/examples/pwm.c +58 -0
  59. data/ext/wiringpi/WiringPi/examples/q2w/binary.c +79 -0
  60. data/ext/wiringpi/WiringPi/examples/q2w/blink-io.c +61 -0
  61. data/ext/wiringpi/WiringPi/examples/q2w/blink.c +50 -0
  62. data/ext/wiringpi/WiringPi/examples/q2w/bright.c +59 -0
  63. data/ext/wiringpi/WiringPi/examples/q2w/button.c +63 -0
  64. data/ext/wiringpi/WiringPi/examples/q2w/volts.c +62 -0
  65. data/ext/wiringpi/WiringPi/examples/rht03.c +86 -0
  66. data/ext/wiringpi/WiringPi/examples/scrollPhat/scphat.c +230 -0
  67. data/ext/wiringpi/WiringPi/examples/scrollPhat/test.c +115 -0
  68. data/ext/wiringpi/WiringPi/examples/serialRead.c +48 -0
  69. data/ext/wiringpi/WiringPi/examples/serialTest.c +75 -0
  70. data/ext/wiringpi/WiringPi/examples/servo.c +57 -0
  71. data/ext/wiringpi/WiringPi/examples/softPwm.c +89 -0
  72. data/ext/wiringpi/WiringPi/examples/softTone.c +54 -0
  73. data/ext/wiringpi/WiringPi/examples/speed.c +95 -0
  74. data/ext/wiringpi/WiringPi/examples/spiSpeed.c +118 -0
  75. data/ext/wiringpi/WiringPi/examples/wfi.c +161 -0
  76. data/ext/wiringpi/WiringPi/gpio/gpio.c +1538 -0
  77. data/ext/wiringpi/WiringPi/gpio/readall.c +403 -0
  78. data/ext/wiringpi/WiringPi/version.h +3 -0
  79. data/ext/wiringpi/WiringPi/wiringPi/ads1115.c +293 -0
  80. data/ext/wiringpi/WiringPi/wiringPi/ads1115.h +55 -0
  81. data/ext/wiringpi/WiringPi/wiringPi/bmp180.c +237 -0
  82. data/ext/wiringpi/WiringPi/wiringPi/bmp180.h +34 -0
  83. data/ext/wiringpi/WiringPi/wiringPi/drcNet.c +405 -0
  84. data/ext/wiringpi/WiringPi/wiringPi/drcNet.h +42 -0
  85. data/ext/wiringpi/WiringPi/wiringPi/drcSerial.c +196 -0
  86. data/ext/wiringpi/WiringPi/wiringPi/drcSerial.h +33 -0
  87. data/ext/wiringpi/WiringPi/wiringPi/ds18b20.c +146 -0
  88. data/ext/wiringpi/WiringPi/wiringPi/ds18b20.h +34 -0
  89. data/ext/wiringpi/WiringPi/wiringPi/htu21d.c +150 -0
  90. data/ext/wiringpi/WiringPi/wiringPi/htu21d.h +34 -0
  91. data/ext/wiringpi/WiringPi/wiringPi/max31855.c +99 -0
  92. data/ext/wiringpi/WiringPi/wiringPi/max31855.h +33 -0
  93. data/ext/wiringpi/WiringPi/wiringPi/max5322.c +84 -0
  94. data/ext/wiringpi/WiringPi/wiringPi/max5322.h +33 -0
  95. data/ext/wiringpi/WiringPi/wiringPi/mcp23008.c +149 -0
  96. data/ext/wiringpi/WiringPi/wiringPi/mcp23008.h +33 -0
  97. data/ext/wiringpi/WiringPi/wiringPi/mcp23016.c +164 -0
  98. data/ext/wiringpi/WiringPi/wiringPi/mcp23016.h +33 -0
  99. data/ext/wiringpi/WiringPi/wiringPi/mcp23016reg.h +48 -0
  100. data/ext/wiringpi/WiringPi/wiringPi/mcp23017.c +195 -0
  101. data/ext/wiringpi/WiringPi/wiringPi/mcp23017.h +33 -0
  102. data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.c +188 -0
  103. data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.h +33 -0
  104. data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.c +235 -0
  105. data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.h +33 -0
  106. data/ext/wiringpi/WiringPi/wiringPi/mcp23x08.h +73 -0
  107. data/ext/wiringpi/WiringPi/wiringPi/mcp23x0817.h +87 -0
  108. data/ext/wiringpi/WiringPi/wiringPi/mcp3002.c +76 -0
  109. data/ext/wiringpi/WiringPi/wiringPi/mcp3002.h +33 -0
  110. data/ext/wiringpi/WiringPi/wiringPi/mcp3004.c +76 -0
  111. data/ext/wiringpi/WiringPi/wiringPi/mcp3004.h +33 -0
  112. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.c +125 -0
  113. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.h +43 -0
  114. data/ext/wiringpi/WiringPi/wiringPi/mcp4802.c +76 -0
  115. data/ext/wiringpi/WiringPi/wiringPi/mcp4802.h +33 -0
  116. data/ext/wiringpi/WiringPi/wiringPi/pcf8574.c +126 -0
  117. data/ext/wiringpi/WiringPi/wiringPi/pcf8574.h +33 -0
  118. data/ext/wiringpi/WiringPi/wiringPi/pcf8591.c +90 -0
  119. data/ext/wiringpi/WiringPi/wiringPi/pcf8591.h +33 -0
  120. data/ext/wiringpi/WiringPi/wiringPi/piHiPri.c +51 -0
  121. data/ext/wiringpi/WiringPi/wiringPi/piThread.c +63 -0
  122. data/ext/wiringpi/WiringPi/wiringPi/pseudoPins.c +95 -0
  123. data/ext/wiringpi/WiringPi/wiringPi/pseudoPins.h +26 -0
  124. data/ext/wiringpi/WiringPi/wiringPi/rht03.c +252 -0
  125. data/ext/wiringpi/WiringPi/wiringPi/rht03.h +25 -0
  126. data/ext/wiringpi/WiringPi/wiringPi/sn3218.c +75 -0
  127. data/ext/wiringpi/WiringPi/wiringPi/sn3218.h +33 -0
  128. data/ext/wiringpi/WiringPi/wiringPi/softPwm.c +186 -0
  129. data/ext/wiringpi/WiringPi/wiringPi/softPwm.h +35 -0
  130. data/ext/wiringpi/WiringPi/wiringPi/softServo.c +211 -0
  131. data/ext/wiringpi/WiringPi/wiringPi/softServo.h +35 -0
  132. data/ext/wiringpi/WiringPi/wiringPi/softTone.c +150 -0
  133. data/ext/wiringpi/WiringPi/wiringPi/softTone.h +39 -0
  134. data/ext/wiringpi/WiringPi/wiringPi/sr595.c +109 -0
  135. data/ext/wiringpi/WiringPi/wiringPi/sr595.h +34 -0
  136. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.c +2507 -0
  137. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.h +269 -0
  138. data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.c +233 -0
  139. data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.h +42 -0
  140. data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.c +144 -0
  141. data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.h +36 -0
  142. data/ext/wiringpi/WiringPi/wiringPi/wiringSerial.c +225 -0
  143. data/ext/wiringpi/WiringPi/wiringPi/wiringSerial.h +38 -0
  144. data/ext/wiringpi/WiringPi/wiringPi/wiringShift.c +83 -0
  145. data/ext/wiringpi/WiringPi/wiringPi/wiringShift.h +41 -0
  146. data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.c +928 -0
  147. data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.h +26 -0
  148. data/ext/wiringpi/WiringPi/wiringPiD/daemonise.c +82 -0
  149. data/ext/wiringpi/WiringPi/wiringPiD/daemonise.h +9 -0
  150. data/ext/wiringpi/WiringPi/wiringPiD/drcNetCmd.h +43 -0
  151. data/ext/wiringpi/WiringPi/wiringPiD/network.c +330 -0
  152. data/ext/wiringpi/WiringPi/wiringPiD/network.h +31 -0
  153. data/ext/wiringpi/WiringPi/wiringPiD/runRemote.c +126 -0
  154. data/ext/wiringpi/WiringPi/wiringPiD/runRemote.h +29 -0
  155. data/ext/wiringpi/WiringPi/wiringPiD/wiringpid.c +382 -0
  156. metadata +155 -1
@@ -0,0 +1,68 @@
1
+ /*
2
+ * lowPower.c:
3
+ * Check the Pi's LOW-Power signal.
4
+ *
5
+ * This is a demonstration program that could be turned into some sort
6
+ * of logger via e.g. syslog - however it's also probably something
7
+ * that might be better handled by a future kernel - who knows.
8
+ *
9
+ * Copyright (c) 2014 Gordon Henderson.
10
+ ***********************************************************************
11
+ * This file is part of wiringPi:
12
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
13
+ *
14
+ * wiringPi is free software: you can redistribute it and/or modify
15
+ * it under the terms of the GNU Lesser General Public License as published by
16
+ * the Free Software Foundation, either version 3 of the License, or
17
+ * (at your option) any later version.
18
+ *
19
+ * wiringPi is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU Lesser General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU Lesser General Public License
25
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
26
+ ***********************************************************************
27
+ */
28
+
29
+ #include <stdio.h>
30
+ #include <time.h>
31
+ #include <wiringPi.h>
32
+
33
+
34
+ #define LOW_POWER 35
35
+
36
+ /*
37
+ * lowPower:
38
+ * This is an ISR that waits for the low-power signal going low and
39
+ * prints the result.
40
+ *********************************************************************************
41
+ */
42
+
43
+ void lowPower (void)
44
+ {
45
+ time_t t ;
46
+
47
+ time (&t) ;
48
+ printf ("%s: LOW POWER DETECTED\n", ctime (&t)) ;
49
+ }
50
+
51
+
52
+ /*
53
+ *********************************************************************************
54
+ * main
55
+ *********************************************************************************
56
+ */
57
+
58
+ int main (void)
59
+ {
60
+ wiringPiSetupGpio () ; // GPIO mode as it's an internal pin
61
+
62
+ wiringPiISR (LOW_POWER, INT_EDGE_FALLING, &lowPower) ;
63
+
64
+ for (;;)
65
+ delay (1000) ;
66
+
67
+ return 0 ;
68
+ }
@@ -0,0 +1,60 @@
1
+ /*
2
+ * max31855.c:
3
+ * SPI Thermocouple interface chip
4
+ *
5
+ * Copyright (c) 2015 Gordon Henderson.
6
+ ***********************************************************************
7
+ * This file is part of wiringPi:
8
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
9
+ *
10
+ * wiringPi is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU Lesser General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * wiringPi is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU Lesser General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU Lesser General Public License
21
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #include <stdio.h>
26
+ #include <stdlib.h>
27
+ #include <stdint.h>
28
+ #include <string.h>
29
+ #include <time.h>
30
+
31
+ #include <wiringPi.h>
32
+ #include <max31855.h>
33
+
34
+ int main (int argc, char *argv [])
35
+ {
36
+ int i = 0 ;
37
+
38
+ wiringPiSetup () ;
39
+ max31855Setup (200, 0) ;
40
+ max31855Setup (400, 1) ;
41
+
42
+ for (;;)
43
+ {
44
+ if (i == 0)
45
+ {
46
+ printf ("+------+------+------+------++------+------+------+------+\n") ;
47
+ printf ("| Raw | Err | C | F || Raw | Err | C | F |\n") ;
48
+ printf ("+------+------+------+------++------+------+------+------+\n") ;
49
+ }
50
+
51
+ printf ("| %4d | %4d | %4d | %4d |", analogRead (200), analogRead (201), analogRead (202), analogRead (203)) ;
52
+ printf ("| %4d | %4d | %4d | %4d |\n", analogRead (400), analogRead (401), analogRead (402), analogRead (403)) ;
53
+ delay (500) ;
54
+
55
+ if (++i == 10)
56
+ i = 0 ;
57
+
58
+ }
59
+
60
+ }
@@ -0,0 +1,67 @@
1
+ /*
2
+ * nes.c:
3
+ * Test program for an old NES controller connected to the Pi.
4
+ *
5
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
6
+ ***********************************************************************
7
+ * This file is part of wiringPi:
8
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
9
+ *
10
+ * wiringPi is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU Lesser General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * wiringPi is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU Lesser General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU Lesser General Public License
21
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #include <stdio.h>
26
+ #include <errno.h>
27
+ #include <string.h>
28
+
29
+ #include <wiringPi.h>
30
+ #include <piNes.h>
31
+
32
+ #define BLANK "| "
33
+
34
+ int main ()
35
+ {
36
+ int joystick ;
37
+ unsigned int buttons ;
38
+
39
+ if (wiringPiSetup () == -1)
40
+ {
41
+ fprintf (stdout, "oops: %s\n", strerror (errno)) ;
42
+ return 1 ;
43
+ }
44
+
45
+ if ((joystick = setupNesJoystick (2, 1, 0)) == -1)
46
+ {
47
+ fprintf (stdout, "Unable to setup joystick\n") ;
48
+ return 1 ;
49
+ }
50
+
51
+ for (;;)
52
+ {
53
+ buttons = readNesJoystick (joystick) ;
54
+
55
+ if ((buttons & NES_UP) != 0) printf ("| UP " ) ; else printf (BLANK) ;
56
+ if ((buttons & NES_DOWN) != 0) printf ("| DOWN " ) ; else printf (BLANK) ;
57
+ if ((buttons & NES_LEFT) != 0) printf ("| LEFT " ) ; else printf (BLANK) ;
58
+ if ((buttons & NES_RIGHT) != 0) printf ("|RIGHT " ) ; else printf (BLANK) ;
59
+ if ((buttons & NES_SELECT) != 0) printf ("|SELECT" ) ; else printf (BLANK) ;
60
+ if ((buttons & NES_START) != 0) printf ("|START " ) ; else printf (BLANK) ;
61
+ if ((buttons & NES_A) != 0) printf ("| A " ) ; else printf (BLANK) ;
62
+ if ((buttons & NES_B) != 0) printf ("| B " ) ; else printf (BLANK) ;
63
+ printf ("|\n") ;
64
+ }
65
+
66
+ return 0 ;
67
+ }
@@ -0,0 +1,82 @@
1
+ /*
2
+ * okLed.c:
3
+ * Make the OK LED on the Pi Pulsate...
4
+ *
5
+ * Originally posted to the Raspberry Pi forums:
6
+ * http://www.raspberrypi.org/phpBB3/viewtopic.php?p=162581#p162581
7
+ *
8
+ * Compile this and store it somewhere, then kick it off at boot time
9
+ * e.g. by putting it in /etc/rc.local and running it in the
10
+ * background &
11
+ *
12
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
13
+ ***********************************************************************
14
+ * This file is part of wiringPi:
15
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
16
+ *
17
+ * wiringPi is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * wiringPi is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU Lesser General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU Lesser General Public License
28
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
29
+ ***********************************************************************
30
+ */
31
+
32
+ #include <stdio.h>
33
+ #include <errno.h>
34
+ #include <string.h>
35
+ #include <fcntl.h>
36
+ #include <unistd.h>
37
+ #include <math.h>
38
+
39
+ #include <wiringPi.h>
40
+ #include <softPwm.h>
41
+
42
+ // The OK/Act LED is connected to BCM_GPIO pin 16
43
+
44
+ #define OK_LED 16
45
+
46
+ int main ()
47
+ {
48
+ int fd, i ;
49
+
50
+ wiringPiSetupGpio () ;
51
+
52
+ // Change the trigger on the OK/Act LED to "none"
53
+
54
+ if ((fd = open ("/sys/class/leds/led0/trigger", O_RDWR)) < 0)
55
+ {
56
+ fprintf (stderr, "Unable to change LED trigger: %s\n", strerror (errno)) ;
57
+ return 1 ;
58
+ }
59
+ write (fd, "none\n", 5) ;
60
+ close (fd) ;
61
+
62
+ softPwmCreate (OK_LED, 0, 100) ;
63
+
64
+ for (;;)
65
+ {
66
+ for (i = 0 ; i <= 100 ; ++i)
67
+ {
68
+ softPwmWrite (OK_LED, i) ;
69
+ delay (10) ;
70
+ }
71
+ delay (50) ;
72
+
73
+ for (i = 100 ; i >= 0 ; --i)
74
+ {
75
+ softPwmWrite (OK_LED, i) ;
76
+ delay (10) ;
77
+ }
78
+ delay (10) ;
79
+ }
80
+
81
+ return 0 ;
82
+ }
@@ -0,0 +1,58 @@
1
+ /*
2
+ * pwm.c:
3
+ * This tests the hardware PWM channel.
4
+ *
5
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
6
+ ***********************************************************************
7
+ * This file is part of wiringPi:
8
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
9
+ *
10
+ * wiringPi is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU Lesser General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * wiringPi is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU Lesser General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU Lesser General Public License
21
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #include <wiringPi.h>
26
+
27
+ #include <stdio.h>
28
+ #include <stdlib.h>
29
+ #include <stdint.h>
30
+
31
+ int main (void)
32
+ {
33
+ int bright ;
34
+
35
+ printf ("Raspberry Pi wiringPi PWM test program\n") ;
36
+
37
+ if (wiringPiSetup () == -1)
38
+ exit (1) ;
39
+
40
+ pinMode (1, PWM_OUTPUT) ;
41
+
42
+ for (;;)
43
+ {
44
+ for (bright = 0 ; bright < 1024 ; ++bright)
45
+ {
46
+ pwmWrite (1, bright) ;
47
+ delay (1) ;
48
+ }
49
+
50
+ for (bright = 1023 ; bright >= 0 ; --bright)
51
+ {
52
+ pwmWrite (1, bright) ;
53
+ delay (1) ;
54
+ }
55
+ }
56
+
57
+ return 0 ;
58
+ }
@@ -0,0 +1,79 @@
1
+ /*
2
+ * binary.c:
3
+ * Using the Quick 2 wire 16-bit GPIO expansion board to output
4
+ * a binary counter.
5
+ *
6
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
7
+ ***********************************************************************
8
+ * This file is part of wiringPi:
9
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
10
+ *
11
+ * wiringPi is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU Lesser General Public License as published by
13
+ * the Free Software Foundation, either version 3 of the License, or
14
+ * (at your option) any later version.
15
+ *
16
+ * wiringPi is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU Lesser General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Lesser General Public License
22
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
23
+ ***********************************************************************
24
+ */
25
+
26
+ #include <stdio.h>
27
+ #include <wiringPi.h>
28
+ #include <mcp23017.h>
29
+
30
+ #define Q2W_BASE 100
31
+
32
+ int main (void)
33
+ {
34
+ int i, bit ;
35
+
36
+ // Enable the on-goard GPIO
37
+
38
+ wiringPiSetup () ;
39
+
40
+ // Add in the mcp23017 on the q2w board
41
+
42
+ mcp23017Setup (Q2W_BASE, 0x20) ;
43
+
44
+ printf ("Raspberry Pi - quite2Wire MCP23017 Test\n") ;
45
+
46
+ // On-board button Input:
47
+
48
+ pinMode (0, INPUT) ;
49
+
50
+ // First 10 pins on q2w board as outputs:
51
+
52
+ for (i = 0 ; i < 10 ; ++i)
53
+ pinMode (Q2W_BASE + i, OUTPUT) ;
54
+
55
+ // Last pin as an input with the internal pull-up enabled
56
+
57
+ pinMode (Q2W_BASE + 15, INPUT) ;
58
+ pullUpDnControl (Q2W_BASE + 15, PUD_UP) ;
59
+
60
+ // Loop, outputting a binary number,
61
+ // Go faster with the button, or stop if the
62
+ // on-board button is pushed
63
+
64
+ for (;;)
65
+ {
66
+ for (i = 0 ; i < 1024 ; ++i)
67
+ {
68
+ for (bit = 0 ; bit < 10 ; ++bit)
69
+ digitalWrite (Q2W_BASE + bit, i & (1 << bit)) ;
70
+
71
+ while (digitalRead (0) == HIGH) // While pushed
72
+ delay (1) ;
73
+
74
+ if (digitalRead (Q2W_BASE + 15) == HIGH) // Not Pushed
75
+ delay (100) ;
76
+ }
77
+ }
78
+ return 0 ;
79
+ }
@@ -0,0 +1,61 @@
1
+ /*
2
+ * blink-io.c:
3
+ * Simple "blink" test for the Quick2Wire 16-pin IO board.
4
+ *
5
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
6
+ ***********************************************************************
7
+ * This file is part of wiringPi:
8
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
9
+ *
10
+ * wiringPi is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU Lesser General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * wiringPi is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU Lesser General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU Lesser General Public License
21
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #include <stdio.h>
26
+ #include <wiringPi.h>
27
+ #include <mcp23017.h>
28
+
29
+ #define LED 1
30
+ #define Q2W_BASE 100
31
+
32
+ int main (void)
33
+ {
34
+
35
+ // Enable the on-goard GPIO
36
+
37
+ wiringPiSetup () ;
38
+
39
+ // Add in the mcp23017 on the q2w board
40
+
41
+ mcp23017Setup (Q2W_BASE, 0x20) ;
42
+
43
+ printf ("Raspberry Pi - Quick2Wire MCP23017 Blink Test\n") ;
44
+
45
+ // Blink the on-board LED as well as one on the mcp23017
46
+
47
+ pinMode (LED, OUTPUT) ;
48
+ pinMode (Q2W_BASE + 0, OUTPUT) ;
49
+
50
+ for (;;)
51
+ {
52
+ digitalWrite (LED, HIGH) ;
53
+ digitalWrite (Q2W_BASE + 0, HIGH) ;
54
+ delay (500) ;
55
+ digitalWrite (LED, LOW) ;
56
+ digitalWrite (Q2W_BASE + 0, LOW) ;
57
+ delay (500) ;
58
+ }
59
+
60
+ return 0 ;
61
+ }