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,39 @@
1
+ /*
2
+ * lcd128x64.h:
3
+ *
4
+ * Copyright (c) 2013 Gordon Henderson.
5
+ ***********************************************************************
6
+ * This file is part of wiringPi:
7
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
8
+ *
9
+ * wiringPi is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * wiringPi is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public License
20
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
21
+ ***********************************************************************
22
+ */
23
+
24
+ extern void lcd128x64setOrigin (int x, int y) ;
25
+ extern void lcd128x64setOrientation (int orientation) ;
26
+ extern void lcd128x64orientCoordinates (int *x, int *y) ;
27
+ extern void lcd128x64getScreenSize (int *x, int *y) ;
28
+ extern void lcd128x64point (int x, int y, int colour) ;
29
+ extern void lcd128x64line (int x0, int y0, int x1, int y1, int colour) ;
30
+ extern void lcd128x64lineTo (int x, int y, int colour) ;
31
+ extern void lcd128x64rectangle (int x1, int y1, int x2, int y2, int colour, int filled) ;
32
+ extern void lcd128x64circle (int x, int y, int r, int colour, int filled) ;
33
+ extern void lcd128x64ellipse (int cx, int cy, int xRadius, int yRadius, int colour, int filled) ;
34
+ extern void lcd128x64putchar (int x, int y, int c, int bgCol, int fgCol) ;
35
+ extern void lcd128x64puts (int x, int y, const char *str, int bgCol, int fgCol) ;
36
+ extern void lcd128x64update (void) ;
37
+ extern void lcd128x64clear (int colour) ;
38
+
39
+ extern int lcd128x64setup (void) ;
@@ -0,0 +1,238 @@
1
+ /*
2
+ * maxdetect.c:
3
+ * Driver for the MaxDetect series sensors
4
+ *
5
+ * Copyright (c) 2013 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 <sys/time.h>
26
+ #include <stdio.h>
27
+ //#include <stdlib.h>
28
+ //#include <unistd.h>
29
+
30
+ #include <wiringPi.h>
31
+
32
+ #include "maxdetect.h"
33
+
34
+ #ifndef TRUE
35
+ # define TRUE (1==1)
36
+ # define FALSE (1==2)
37
+ #endif
38
+
39
+
40
+ /*
41
+ * maxDetectLowHighWait:
42
+ * Wait for a transition from low to high on the bus
43
+ *********************************************************************************
44
+ */
45
+
46
+ static int maxDetectLowHighWait (const int pin)
47
+ {
48
+ struct timeval now, timeOut, timeUp ;
49
+
50
+ // If already high then wait for pin to go low
51
+
52
+ gettimeofday (&now, NULL) ;
53
+ timerclear (&timeOut) ;
54
+ timeOut.tv_usec = 1000 ;
55
+ timeradd (&now, &timeOut, &timeUp) ;
56
+
57
+ while (digitalRead (pin) == HIGH)
58
+ {
59
+ gettimeofday (&now, NULL) ;
60
+ if (timercmp (&now, &timeUp, >))
61
+ return FALSE ;
62
+ }
63
+
64
+ // Wait for it to go HIGH
65
+
66
+ gettimeofday (&now, NULL) ;
67
+ timerclear (&timeOut) ;
68
+ timeOut.tv_usec = 1000 ;
69
+ timeradd (&now, &timeOut, &timeUp) ;
70
+
71
+ while (digitalRead (pin) == LOW)
72
+ {
73
+ gettimeofday (&now, NULL) ;
74
+ if (timercmp (&now, &timeUp, >))
75
+ return FALSE ;
76
+ }
77
+
78
+ return TRUE ;
79
+ }
80
+
81
+
82
+ /*
83
+ * maxDetectClockByte:
84
+ * Read in a single byte from the MaxDetect bus
85
+ *********************************************************************************
86
+ */
87
+
88
+ static unsigned int maxDetectClockByte (const int pin)
89
+ {
90
+ unsigned int byte = 0 ;
91
+ int bit ;
92
+
93
+ for (bit = 0 ; bit < 8 ; ++bit)
94
+ {
95
+ if (!maxDetectLowHighWait (pin))
96
+ return 0 ;
97
+
98
+ // bit starting now - we need to time it.
99
+
100
+ delayMicroseconds (30) ;
101
+ byte <<= 1 ;
102
+ if (digitalRead (pin) == HIGH) // It's a 1
103
+ byte |= 1 ;
104
+ }
105
+
106
+ return byte ;
107
+ }
108
+
109
+
110
+ /*
111
+ * maxDetectRead:
112
+ * Read in and return the 4 data bytes from the MaxDetect sensor.
113
+ * Return TRUE/FALSE depending on the checksum validity
114
+ *********************************************************************************
115
+ */
116
+
117
+ int maxDetectRead (const int pin, unsigned char buffer [4])
118
+ {
119
+ int i ;
120
+ unsigned int checksum ;
121
+ unsigned char localBuf [5] ;
122
+ struct timeval now, then, took ;
123
+
124
+ // See how long we took
125
+
126
+ gettimeofday (&then, NULL) ;
127
+
128
+ // Wake up the RHT03 by pulling the data line low, then high
129
+ // Low for 10mS, high for 40uS.
130
+
131
+ pinMode (pin, OUTPUT) ;
132
+ digitalWrite (pin, 0) ; delay (10) ;
133
+ digitalWrite (pin, 1) ; delayMicroseconds (40) ;
134
+ pinMode (pin, INPUT) ;
135
+
136
+ // Now wait for sensor to pull pin low
137
+
138
+ if (!maxDetectLowHighWait (pin))
139
+ return FALSE ;
140
+
141
+ // and read in 5 bytes (40 bits)
142
+
143
+ for (i = 0 ; i < 5 ; ++i)
144
+ localBuf [i] = maxDetectClockByte (pin) ;
145
+
146
+ checksum = 0 ;
147
+ for (i = 0 ; i < 4 ; ++i)
148
+ {
149
+ buffer [i] = localBuf [i] ;
150
+ checksum += localBuf [i] ;
151
+ }
152
+ checksum &= 0xFF ;
153
+
154
+ // See how long we took
155
+
156
+ gettimeofday (&now, NULL) ;
157
+ timersub (&now, &then, &took) ;
158
+
159
+ // Total time to do this should be:
160
+ // 10mS + 40µS - reset
161
+ // + 80µS + 80µS - sensor doing its low -> high thing
162
+ // + 40 * (50µS + 27µS (0) or 70µS (1) )
163
+ // = 15010µS
164
+ // so if we take more than that, we've had a scheduling interruption and the
165
+ // reading is probably bogus.
166
+
167
+ if ((took.tv_sec != 0) || (took.tv_usec > 16000))
168
+ return FALSE ;
169
+
170
+ return checksum == localBuf [4] ;
171
+ }
172
+
173
+
174
+ /*
175
+ * readRHT03:
176
+ * Read the Temperature & Humidity from an RHT03 sensor
177
+ * Values returned are *10, so 123 is 12.3.
178
+ *********************************************************************************
179
+ */
180
+
181
+ int readRHT03 (const int pin, int *temp, int *rh)
182
+ {
183
+ static struct timeval then ; // will initialise to zero
184
+ static int lastTemp = 0 ;
185
+ static int lastRh = 0 ;
186
+
187
+ int result ;
188
+ struct timeval now, timeOut ;
189
+ unsigned char buffer [4] ;
190
+
191
+ // The data sheets say to not read more than once every 2 seconds, so you
192
+ // get the last good reading
193
+
194
+ gettimeofday (&now, NULL) ;
195
+ if (timercmp (&now, &then, <))
196
+ {
197
+ *rh = lastRh ;
198
+ *temp = lastTemp ;
199
+ return TRUE ;
200
+ }
201
+
202
+ // Set timeout for next read
203
+
204
+ gettimeofday (&now, NULL) ;
205
+ timerclear (&timeOut) ;
206
+ timeOut.tv_sec = 2 ;
207
+ timeradd (&now, &timeOut, &then) ;
208
+
209
+ // Read ...
210
+
211
+ result = maxDetectRead (pin, buffer) ;
212
+
213
+ if (!result) // Try again, but just once
214
+ result = maxDetectRead (pin, buffer) ;
215
+
216
+ if (!result)
217
+ return FALSE ;
218
+
219
+ *rh = (buffer [0] * 256 + buffer [1]) ;
220
+ *temp = (buffer [2] * 256 + buffer [3]) ;
221
+
222
+ if ((*temp & 0x8000) != 0) // Negative
223
+ {
224
+ *temp &= 0x7FFF ;
225
+ *temp = -*temp ;
226
+ }
227
+
228
+ // Discard obviously bogus readings - the checksum can't detect a 2-bit error
229
+ // (which does seem to happen - no realtime here)
230
+
231
+ if ((*rh > 999) || (*temp > 800) || (*temp < -400))
232
+ return FALSE ;
233
+
234
+ lastRh = *rh ;
235
+ lastTemp = *temp ;
236
+
237
+ return TRUE ;
238
+ }
@@ -0,0 +1,40 @@
1
+ /*
2
+ * maxdetect.h:
3
+ * Driver for the MaxDetect series sensors
4
+ *
5
+ * Copyright (c) 2013 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
+
26
+ #ifdef __cplusplus
27
+ extern "C" {
28
+ #endif
29
+
30
+ // Main generic function
31
+
32
+ int maxDetectRead (const int pin, unsigned char buffer [4]) ;
33
+
34
+ // Individual sensors
35
+
36
+ int readRHT03 (const int pin, int *temp, int *rh) ;
37
+
38
+ #ifdef __cplusplus
39
+ }
40
+ #endif
@@ -0,0 +1,112 @@
1
+ /*
2
+ * piFace.:
3
+ * This file to interface with the PiFace peripheral device which
4
+ * has an MCP23S17 GPIO device connected via the SPI bus.
5
+ *
6
+ * Copyright (c) 2012-2013 Gordon Henderson
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
13
+ * published by the Free Software Foundation, either version 3 of the
14
+ * License, or (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
22
+ * License along with wiringPi.
23
+ * If not, see <http://www.gnu.org/licenses/>.
24
+ ***********************************************************************
25
+ */
26
+
27
+
28
+ #include <stdio.h>
29
+ #include <stdint.h>
30
+
31
+ #include <wiringPi.h>
32
+ #include <mcp23s17.h>
33
+
34
+ #include "piFace.h"
35
+
36
+
37
+ /*
38
+ * myDigitalWrite:
39
+ * Perform the digitalWrite function on the PiFace board
40
+ *********************************************************************************
41
+ */
42
+
43
+ void myDigitalWrite (struct wiringPiNodeStruct *node, int pin, int value)
44
+ {
45
+ digitalWrite (pin + 16, value) ;
46
+ }
47
+
48
+
49
+ /*
50
+ * myDigitalRead:
51
+ * Perform the digitalRead function on the PiFace board
52
+ * With a slight twist - if we read from base + 8, then we
53
+ * read from the output latch...
54
+ *********************************************************************************
55
+ */
56
+
57
+ int myDigitalRead (struct wiringPiNodeStruct *node, int pin)
58
+ {
59
+ if ((pin - node->pinBase) >= 8)
60
+ return digitalRead (pin + 8) ;
61
+ else
62
+ return digitalRead (pin + 16 + 8) ;
63
+ }
64
+
65
+
66
+ /*
67
+ * myPullUpDnControl:
68
+ * Perform the pullUpDnControl function on the PiFace board
69
+ *********************************************************************************
70
+ */
71
+
72
+ void myPullUpDnControl (struct wiringPiNodeStruct *node, int pin, int pud)
73
+ {
74
+ pullUpDnControl (pin + 16 + 8, pud) ;
75
+ }
76
+
77
+
78
+ /*
79
+ * piFaceSetup
80
+ * We're going to create an instance of the mcp23s17 here, then
81
+ * provide our own read/write routines on-top of it...
82
+ * The supplied PiFace code (in Pithon) treats it as an 8-bit device
83
+ * where you write the output ports and read the input port using the
84
+ * same pin numbers, however I have had a request to be able to read
85
+ * the output port, so reading 8..15 will read the output latch.
86
+ *********************************************************************************
87
+ */
88
+
89
+ int piFaceSetup (const int pinBase)
90
+ {
91
+ int i ;
92
+ struct wiringPiNodeStruct *node ;
93
+
94
+ // Create an mcp23s17 instance:
95
+
96
+ mcp23s17Setup (pinBase + 16, 0, 0) ;
97
+
98
+ // Set the direction bits
99
+
100
+ for (i = 0 ; i < 8 ; ++i)
101
+ {
102
+ pinMode (pinBase + 16 + i, OUTPUT) ; // Port A is the outputs
103
+ pinMode (pinBase + 16 + 8 + i, INPUT) ; // Port B inputs.
104
+ }
105
+
106
+ node = wiringPiNewNode (pinBase, 16) ;
107
+ node->digitalRead = myDigitalRead ;
108
+ node->digitalWrite = myDigitalWrite ;
109
+ node->pullUpDnControl = myPullUpDnControl ;
110
+
111
+ return 0 ;
112
+ }
@@ -0,0 +1,32 @@
1
+ /*
2
+ * piFace.h:
3
+ * Control the PiFace Interface board for the Raspberry Pi
4
+ * Copyright (c) 2012-2013 Gordon Henderson
5
+ ***********************************************************************
6
+ * This file is part of wiringPi:
7
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
8
+ *
9
+ * wiringPi is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * wiringPi is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public License
20
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
21
+ ***********************************************************************
22
+ */
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ extern int piFaceSetup (const int pinBase) ;
29
+
30
+ #ifdef __cplusplus
31
+ }
32
+ #endif