wiringpi 2.0.0 → 2.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wiringpi/WiringPi/devLib/maxdetect.c +100 -27
  3. data/ext/wiringpi/WiringPi/devLib/maxdetect.h +0 -0
  4. data/ext/wiringpi/WiringPi/devLib/scrollPhat.c +430 -0
  5. data/ext/wiringpi/WiringPi/devLib/scrollPhat.h +39 -0
  6. data/ext/wiringpi/WiringPi/devLib/scrollPhatFont.h +544 -0
  7. data/ext/wiringpi/WiringPi/examples/PiFace/ladder.c +0 -0
  8. data/ext/wiringpi/WiringPi/examples/max31855.c +60 -0
  9. data/ext/wiringpi/WiringPi/examples/rht03.c +32 -15
  10. data/ext/wiringpi/WiringPi/examples/scrollPhat/scphat.c +230 -0
  11. data/ext/wiringpi/WiringPi/examples/scrollPhat/test.c +115 -0
  12. data/ext/wiringpi/WiringPi/gpio/gpio.c +88 -37
  13. data/ext/wiringpi/WiringPi/gpio/readall.c +41 -9
  14. data/ext/wiringpi/WiringPi/gpio/version.h +1 -1
  15. data/ext/wiringpi/WiringPi/wiringPi/ads1115.c +293 -0
  16. data/ext/wiringpi/WiringPi/wiringPi/ads1115.h +55 -0
  17. data/ext/wiringpi/WiringPi/wiringPi/drcSerial.c +4 -9
  18. data/ext/wiringpi/WiringPi/wiringPi/max31855.c +41 -23
  19. data/ext/wiringpi/WiringPi/wiringPi/max5322.c +2 -2
  20. data/ext/wiringpi/WiringPi/wiringPi/mcp23008.c +2 -2
  21. data/ext/wiringpi/WiringPi/wiringPi/mcp23016.c +2 -2
  22. data/ext/wiringpi/WiringPi/wiringPi/mcp23017.c +2 -2
  23. data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.c +3 -4
  24. data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.c +3 -4
  25. data/ext/wiringpi/WiringPi/wiringPi/mcp3002.c +2 -2
  26. data/ext/wiringpi/WiringPi/wiringPi/mcp3004.c +2 -2
  27. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.c +33 -18
  28. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.h +6 -6
  29. data/ext/wiringpi/WiringPi/wiringPi/mcp4802.c +2 -2
  30. data/ext/wiringpi/WiringPi/wiringPi/pcf8574.c +2 -2
  31. data/ext/wiringpi/WiringPi/wiringPi/pcf8591.c +2 -2
  32. data/ext/wiringpi/WiringPi/wiringPi/sn3218.c +2 -2
  33. data/ext/wiringpi/WiringPi/wiringPi/sr595.c +1 -1
  34. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.c +418 -132
  35. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.h +47 -37
  36. data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.c +38 -9
  37. data/ext/wiringpi/extconf.rb +26 -2
  38. data/ext/wiringpi/wiringpi_wrap.c +3456 -981
  39. metadata +9 -1
@@ -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
+ }
@@ -27,7 +27,7 @@
27
27
  #include <wiringPi.h>
28
28
  #include <maxdetect.h>
29
29
 
30
- #define RHT03_PIN 0
30
+ #define RHT03_PIN 7
31
31
 
32
32
  /*
33
33
  ***********************************************************************
@@ -37,32 +37,49 @@
37
37
 
38
38
  int main (void)
39
39
  {
40
- int temp, rh ;
41
- int newTemp, newRh ;
40
+ int result, temp, rh ;
41
+ int minT, maxT, minRH, maxRH ;
42
42
 
43
- temp = rh = newTemp = newRh = 0 ;
43
+ int numGood, numBad ;
44
44
 
45
45
  wiringPiSetup () ;
46
46
  piHiPri (55) ;
47
47
 
48
+ minT = 1000 ;
49
+ maxT = -1000 ;
50
+
51
+ minRH = 1000 ;
52
+ maxRH = -1000 ;
53
+
54
+ numGood = numBad = 0 ;
55
+
48
56
  for (;;)
49
57
  {
50
58
  delay (100) ;
51
59
 
52
- if (!readRHT03 (RHT03_PIN, &newTemp, &newRh))
53
- continue ;
60
+ result = readRHT03 (RHT03_PIN, &temp, &rh) ;
54
61
 
55
- if ((temp != newTemp) || (rh != newRh))
62
+ if (!result)
56
63
  {
57
- temp = newTemp ;
58
- rh = newRh ;
59
- if ((temp & 0x8000) != 0) // Negative
60
- {
61
- temp &= 0x7FFF ;
62
- temp = -temp ;
63
- }
64
- printf ("Temp: %5.1f, RH: %5.1f%%\n", temp / 10.0, rh / 10.0) ;
64
+ printf (".") ;
65
+ fflush (stdout) ;
66
+ ++numBad ;
67
+ continue ;
65
68
  }
69
+
70
+ ++numGood ;
71
+
72
+ if (temp < minT) minT = temp ;
73
+ if (temp > maxT) maxT = temp ;
74
+ if (rh < minRH) minRH = rh ;
75
+ if (rh > maxRH) maxRH = rh ;
76
+
77
+ printf ("\r%6d, %6d: ", numGood, numBad) ;
78
+ printf ("Temp: %5.1f, RH: %5.1f%%", temp / 10.0, rh / 10.0) ;
79
+ printf (" Max/Min Temp: %5.1f:%5.1f", maxT / 10.0, minT / 10.0) ;
80
+ printf (" Max/Min RH: %5.1f:%5.1f", maxRH / 10.0, minRH / 10.0) ;
81
+
82
+ printf ("\n") ;
66
83
  }
67
84
 
68
85
  return 0 ;
@@ -0,0 +1,230 @@
1
+ /*
2
+ * scphat.c:
3
+ * Little program to allow use of the Pimoroni Sctoll Phat
4
+ * from the command-line.
5
+ *
6
+ * Copyright (c) 2015-2016 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 <stdlib.h>
28
+ #include <errno.h>
29
+ #include <string.h>
30
+
31
+ #include <wiringPi.h>
32
+ #include <scrollPhat.h>
33
+
34
+ static char *progName ;
35
+
36
+
37
+ /*
38
+ * checkArgs:
39
+ * Count the arguments for each little function
40
+ *********************************************************************************
41
+ */
42
+
43
+ static void checkArgs (char *command, int num, int arg, int argc)
44
+ {
45
+ if ((arg + num) < argc)
46
+ return ;
47
+
48
+ fprintf (stderr, "%s: Not enough data for %s command.\n", progName, command) ;
49
+ exit (EXIT_FAILURE) ;
50
+ }
51
+
52
+
53
+ /*
54
+ * doClear:
55
+ * Clear the display
56
+ *********************************************************************************
57
+ */
58
+
59
+ static int doClear (void)
60
+ {
61
+ scrollPhatClear () ;
62
+ return 1 ;
63
+ }
64
+
65
+
66
+ /*
67
+ * doBright
68
+ *********************************************************************************
69
+ */
70
+
71
+ static int doBright (int arg, int argc, char *argv [])
72
+ {
73
+ checkArgs ("bright", 1, arg, argc) ;
74
+ scrollPhatIntensity (atoi (argv [arg+1])) ;
75
+ return 2 ;
76
+ }
77
+
78
+
79
+
80
+ /*
81
+ * doPlot
82
+ *********************************************************************************
83
+ */
84
+
85
+ static int doPlot (int arg, int argc, char *argv [])
86
+ {
87
+ checkArgs ("plot", 2, arg, argc) ;
88
+ scrollPhatPoint (atoi (argv [arg+1]), atoi (argv [arg+2]), 1) ;
89
+ scrollPhatUpdate () ;
90
+ return 3 ;
91
+ }
92
+
93
+
94
+ /*
95
+ * doLine
96
+ *********************************************************************************
97
+ */
98
+
99
+ static int doLine (int arg, int argc, char *argv [])
100
+ {
101
+ checkArgs ("line", 4, arg, argc) ;
102
+ scrollPhatLine (atoi (argv [arg+1]), atoi (argv [arg+2]),
103
+ atoi (argv [arg+3]), atoi (argv [arg+4]), 1) ;
104
+ scrollPhatUpdate () ;
105
+ return 5 ;
106
+ }
107
+
108
+
109
+ /*
110
+ * doLineTo
111
+ *********************************************************************************
112
+ */
113
+
114
+ static int doLineTo (int arg, int argc, char *argv [])
115
+ {
116
+ checkArgs ("lineto", 2, arg, argc) ;
117
+ scrollPhatLineTo (atoi (argv [arg+1]), atoi (argv [arg+2]), 1) ;
118
+ scrollPhatUpdate () ;
119
+ return 3 ;
120
+ }
121
+
122
+
123
+ /*
124
+ * doWait
125
+ *********************************************************************************
126
+ */
127
+
128
+ static int doWait (int arg, int argc, char *argv [])
129
+ {
130
+ checkArgs ("wait", 1, arg, argc) ;
131
+ delay (atoi (argv [arg+1]) * 100) ;
132
+ scrollPhatUpdate () ;
133
+ return 2 ;
134
+ }
135
+
136
+
137
+ /*
138
+ * doSpeed
139
+ *********************************************************************************
140
+ */
141
+
142
+ static int doSpeed (int arg, int argc, char *argv [])
143
+ {
144
+ checkArgs ("speed", 1, arg, argc) ;
145
+ scrollPhatPrintSpeed (atoi (argv [arg+1])) ;
146
+ return 2 ;
147
+ }
148
+
149
+
150
+ /*
151
+ * doScroll
152
+ *********************************************************************************
153
+ */
154
+
155
+ static int doScroll (int arg, int argc, char *argv [])
156
+ {
157
+ checkArgs ("scroll", 1, arg, argc) ;
158
+ scrollPhatPuts (argv [arg+1]) ;
159
+ return 2 ;
160
+ }
161
+
162
+
163
+ static void failUsage (void)
164
+ {
165
+ fprintf (stderr, "Usage: %s command [paremters] ...\n", progName) ;
166
+ fprintf (stderr, " commands:\n") ;
167
+ fprintf (stderr, " clear/cls - Clear the display\n") ;
168
+ fprintf (stderr, " bright N - Set display brightness; 1-100\n") ;
169
+ fprintf (stderr, " plot X Y - Set a single pixel at location X Y; 0-10, 0-4\n") ;
170
+ fprintf (stderr, " line X1 Y1 X2 Y2 - Draw a line from the 2 points\n") ;
171
+ fprintf (stderr, " lineto X2 Y2 - Draw a line from the last point to the new one\n") ;
172
+ fprintf (stderr, " wait/delay N - Wait for N 10ths seconds\n") ;
173
+ fprintf (stderr, " speed N - Set scrolling speed (cps)\n") ;
174
+ fprintf (stderr, " scroll S - Scroll the given string\n") ;
175
+ fprintf (stderr, "\n") ;
176
+ fprintf (stderr, " Example: %s plot 0 0 wait 50 scroll \" Hello \"\n", progName) ;
177
+ exit (EXIT_FAILURE) ;
178
+ }
179
+
180
+
181
+ /*
182
+ * the works
183
+ *********************************************************************************
184
+ */
185
+
186
+ int main (int argc, char *argv [])
187
+ {
188
+ int arg = 1 ;
189
+ char *command ;
190
+
191
+ progName = argv [0] ;
192
+
193
+ wiringPiSetupSys () ;
194
+
195
+ if (scrollPhatSetup () != 0)
196
+ {
197
+ fprintf (stderr, "%s: Unable to initialise the scrollPhat: %s\n", progName, strerror (errno)) ;
198
+ exit (EXIT_FAILURE) ;
199
+ }
200
+
201
+ progName = argv [0] ;
202
+
203
+ if (argc < 2)
204
+ {
205
+ fprintf (stderr, "%s: Nothing to do...\n", argv [0]) ;
206
+ failUsage () ;
207
+ }
208
+
209
+ while (arg != argc)
210
+ {
211
+ command = argv [arg] ;
212
+ /**/ if (strcasecmp (command, "clear") == 0) arg += doClear () ;
213
+ else if (strcasecmp (command, "cls") == 0) arg += doClear () ;
214
+ else if (strcasecmp (command, "bright") == 0) arg += doBright (arg, argc, argv) ;
215
+ else if (strcasecmp (command, "plot") == 0) arg += doPlot (arg, argc, argv) ;
216
+ else if (strcasecmp (command, "line") == 0) arg += doLine (arg, argc, argv) ;
217
+ else if (strcasecmp (command, "lineto") == 0) arg += doLineTo (arg, argc, argv) ;
218
+ else if (strcasecmp (command, "wait") == 0) arg += doWait (arg, argc, argv) ;
219
+ else if (strcasecmp (command, "delay") == 0) arg += doWait (arg, argc, argv) ;
220
+ else if (strcasecmp (command, "speed") == 0) arg += doSpeed (arg, argc, argv) ;
221
+ else if (strcasecmp (command, "scroll") == 0) arg += doScroll (arg, argc, argv) ;
222
+ else
223
+ {
224
+ fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [arg]) ;
225
+ failUsage () ;
226
+ }
227
+ }
228
+
229
+ return 0 ;
230
+ }
@@ -0,0 +1,115 @@
1
+ /*
2
+ * test.c:
3
+ * Little test program forthe Pimoroni Scroll Phat.
4
+ *
5
+ * Copyright (c) 2015-2016 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 <stdlib.h>
27
+ #include <errno.h>
28
+ #include <string.h>
29
+
30
+ #include <scrollPhat.h>
31
+
32
+
33
+ /*
34
+ * prompt:
35
+ * Simple prompt & wait
36
+ *********************************************************************************
37
+ */
38
+
39
+ static void prompt (const char *p)
40
+ {
41
+ printf (" %s. Press ENTER: ", p) ;
42
+ (void)getchar () ;
43
+ }
44
+
45
+
46
+ /*
47
+ * the works
48
+ *********************************************************************************
49
+ */
50
+
51
+ int main (void)
52
+ {
53
+ int x, y ;
54
+
55
+ printf ("\n") ;
56
+ printf ("Scroll Phat Test program\n") ;
57
+ printf ("========================\n") ;
58
+
59
+ if (scrollPhatSetup () != 0)
60
+ {
61
+ printf ("Unable to initialise the scrollPhat: %s\n", strerror (errno)) ;
62
+ exit (1) ;
63
+ }
64
+
65
+ printf ("-> Scroll Phat initialised OK\n") ;
66
+ printf ("... Basic display tests.\n\n") ;
67
+
68
+ prompt ("Display ought to be blank") ;
69
+
70
+ // Light all pixels using one point at a time
71
+
72
+ for (y = 0 ; y < 5 ; ++y)
73
+ for (x = 0 ; x < 12 ; ++x)
74
+ scrollPhatPoint (x, y, 1) ;
75
+ scrollPhatUpdate () ;
76
+
77
+ prompt ("Display ought to be all lit-up") ;
78
+
79
+ // Big rectangle
80
+
81
+ scrollPhatClear () ;
82
+ scrollPhatRectangle (0,0, 10, 4, 1, 0) ;
83
+ scrollPhatUpdate () ;
84
+
85
+ prompt ("There should now be a rectangle round the outside") ;
86
+
87
+ scrollPhatLine (0,0, 10,4, 1) ;
88
+ scrollPhatLine (0,4, 10,0, 1) ;
89
+ scrollPhatUpdate () ;
90
+
91
+ prompt ("Diagonal lines") ;
92
+
93
+ scrollPhatIntensity (1) ;
94
+
95
+ prompt ("Minimum brightness") ;
96
+
97
+ scrollPhatIntensity (100) ;
98
+
99
+ prompt ("Maximum brightness") ;
100
+
101
+ scrollPhatIntensity (10) ;
102
+
103
+ prompt ("Default brightness") ;
104
+
105
+ scrollPhatClear () ;
106
+
107
+ printf (" Message Test...Press Ctrl-C to exit: ") ;
108
+ fflush (stdout) ;
109
+
110
+ scrollPhatPrintSpeed (75) ;
111
+ for (;;)
112
+ scrollPhatPuts (" Welcome to the scroll phat from Pimoroni ") ;
113
+
114
+ return 0 ;
115
+ }