wiringpi-ruby 2.0.0 → 2.1.3

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 (168) 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. data/ext/wiringpi/wiringpi_wrap.c +636 -219
  157. data/lib/wiringpi.rb +25 -12
  158. data/lib/wiringpi/gpio.rb +90 -83
  159. data/lib/wiringpi/i2c.rb +29 -22
  160. data/lib/wiringpi/modules/mcp23017.rb +15 -0
  161. data/lib/wiringpi/modules/mcp23s17.rb +16 -0
  162. data/lib/wiringpi/scrollphat.rb +14 -14
  163. data/lib/wiringpi/serial.rb +8 -18
  164. data/lib/wiringpi/spi.rb +14 -11
  165. data/lib/wiringpi/watch.rb +24 -0
  166. metadata +160 -4
  167. data/lib/wiringpi/event.rb +0 -21
  168. data/lib/wiringpi/mcp23x17.rb +0 -31
@@ -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
+ }
@@ -0,0 +1,48 @@
1
+ /*
2
+ * serial.c:
3
+ * Example program to read bytes from the Serial line
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 <string.h>
27
+ #include <errno.h>
28
+
29
+ #include <wiringSerial.h>
30
+
31
+ int main ()
32
+ {
33
+ int fd ;
34
+
35
+ if ((fd = serialOpen ("/dev/ttyAMA0", 115200)) < 0)
36
+ {
37
+ fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
38
+ return 1 ;
39
+ }
40
+
41
+ // Loop, getting and printing characters
42
+
43
+ for (;;)
44
+ {
45
+ putchar (serialGetchar (fd)) ;
46
+ fflush (stdout) ;
47
+ }
48
+ }
@@ -0,0 +1,75 @@
1
+ /*
2
+ * serialTest.c:
3
+ * Very simple program to test the serial port. Expects
4
+ * the port to be looped back to itself
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 <string.h>
28
+ #include <errno.h>
29
+
30
+ #include <wiringPi.h>
31
+ #include <wiringSerial.h>
32
+
33
+ int main ()
34
+ {
35
+ int fd ;
36
+ int count ;
37
+ unsigned int nextTime ;
38
+
39
+ if ((fd = serialOpen ("/dev/ttyAMA0", 115200)) < 0)
40
+ {
41
+ fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
42
+ return 1 ;
43
+ }
44
+
45
+ if (wiringPiSetup () == -1)
46
+ {
47
+ fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
48
+ return 1 ;
49
+ }
50
+
51
+ nextTime = millis () + 300 ;
52
+
53
+ for (count = 0 ; count < 256 ; )
54
+ {
55
+ if (millis () > nextTime)
56
+ {
57
+ printf ("\nOut: %3d: ", count) ;
58
+ fflush (stdout) ;
59
+ serialPutchar (fd, count) ;
60
+ nextTime += 300 ;
61
+ ++count ;
62
+ }
63
+
64
+ delay (3) ;
65
+
66
+ while (serialDataAvail (fd))
67
+ {
68
+ printf (" -> %3d", serialGetchar (fd)) ;
69
+ fflush (stdout) ;
70
+ }
71
+ }
72
+
73
+ printf ("\n") ;
74
+ return 0 ;
75
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ * servo.c:
3
+ * Test of the softServo code.
4
+ * Do not use this code - use the servoBlaster kernel module instead
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 <errno.h>
28
+ #include <string.h>
29
+
30
+ #include <wiringPi.h>
31
+ #include <softServo.h>
32
+
33
+ int main ()
34
+ {
35
+ if (wiringPiSetup () == -1)
36
+ {
37
+ fprintf (stdout, "oops: %s\n", strerror (errno)) ;
38
+ return 1 ;
39
+ }
40
+
41
+ softServoSetup (0, 1, 2, 3, 4, 5, 6, 7) ;
42
+
43
+ softServoWrite (0, 0) ;
44
+ /*
45
+ softServoWrite (1, 1000) ;
46
+ softServoWrite (2, 1100) ;
47
+ softServoWrite (3, 1200) ;
48
+ softServoWrite (4, 1300) ;
49
+ softServoWrite (5, 1400) ;
50
+ softServoWrite (6, 1500) ;
51
+ softServoWrite (7, 2200) ;
52
+ */
53
+
54
+ for (;;)
55
+ delay (10) ;
56
+
57
+ }
@@ -0,0 +1,89 @@
1
+ /*
2
+ * softPwm.c:
3
+ * Test of the software PWM driver. Needs 8 LEDs connected
4
+ * to the Pi - e.g. Ladder board.
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 <errno.h>
28
+ #include <string.h>
29
+
30
+ #include <wiringPi.h>
31
+ #include <softPwm.h>
32
+
33
+ #define RANGE 100
34
+ #define NUM_LEDS 8
35
+
36
+ int ledMap [NUM_LEDS] = { 0, 1, 2, 3, 4, 5, 6, 7 } ;
37
+
38
+ int values [NUM_LEDS] = { 0, 25, 50, 75, 100, 75, 50, 25 } ;
39
+
40
+ int main ()
41
+ {
42
+ int i, j ;
43
+ char buf [80] ;
44
+
45
+ wiringPiSetup () ;
46
+
47
+ for (i = 0 ; i < NUM_LEDS ; ++i)
48
+ {
49
+ softPwmCreate (ledMap [i], 0, RANGE) ;
50
+ printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ;
51
+ }
52
+
53
+ fgets (buf, 80, stdin) ;
54
+
55
+ // Bring all up one by one:
56
+
57
+ for (i = 0 ; i < NUM_LEDS ; ++i)
58
+ for (j = 0 ; j <= 100 ; ++j)
59
+ {
60
+ softPwmWrite (ledMap [i], j) ;
61
+ delay (10) ;
62
+ }
63
+
64
+ fgets (buf, 80, stdin) ;
65
+
66
+ // All Down
67
+
68
+ for (i = 100 ; i > 0 ; --i)
69
+ {
70
+ for (j = 0 ; j < NUM_LEDS ; ++j)
71
+ softPwmWrite (ledMap [j], i) ;
72
+ delay (10) ;
73
+ }
74
+
75
+ fgets (buf, 80, stdin) ;
76
+
77
+ for (;;)
78
+ {
79
+ for (i = 0 ; i < NUM_LEDS ; ++i)
80
+ softPwmWrite (ledMap [i], values [i]) ;
81
+
82
+ delay (50) ;
83
+
84
+ i = values [0] ;
85
+ for (j = 0 ; j < NUM_LEDS - 1 ; ++j)
86
+ values [j] = values [j + 1] ;
87
+ values [NUM_LEDS - 1] = i ;
88
+ }
89
+ }
@@ -0,0 +1,54 @@
1
+ /*
2
+ * softTone.c:
3
+ * Test of the softTone module in wiringPi
4
+ * Plays a scale out on pin 3 - connect pizeo disc to pin 3 & 0v
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 <errno.h>
28
+ #include <string.h>
29
+
30
+ #include <wiringPi.h>
31
+ #include <softTone.h>
32
+
33
+ #define PIN 3
34
+
35
+ int scale [8] = { 262, 294, 330, 349, 392, 440, 494, 525 } ;
36
+
37
+ int main ()
38
+ {
39
+ int i ;
40
+
41
+ wiringPiSetup () ;
42
+
43
+ softToneCreate (PIN) ;
44
+
45
+ for (;;)
46
+ {
47
+ for (i = 0 ; i < 8 ; ++i)
48
+ {
49
+ printf ("%3d\n", i) ;
50
+ softToneWrite (PIN, scale [i]) ;
51
+ delay (500) ;
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,95 @@
1
+ /*
2
+ * speed.c:
3
+ * Simple program to measure the speed of the various GPIO
4
+ * access mechanisms.
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 <wiringPi.h>
27
+
28
+ #include <stdio.h>
29
+ #include <stdlib.h>
30
+ #include <stdint.h>
31
+
32
+ #define FAST_COUNT 10000000
33
+ #define SLOW_COUNT 1000000
34
+ #define PASSES 5
35
+
36
+ void speedTest (int pin, int maxCount)
37
+ {
38
+ int count, sum, perSec, i ;
39
+ unsigned int start, end ;
40
+
41
+ sum = 0 ;
42
+
43
+ for (i = 0 ; i < PASSES ; ++i)
44
+ {
45
+ start = millis () ;
46
+ for (count = 0 ; count < maxCount ; ++count)
47
+ digitalWrite (pin, 1) ;
48
+ end = millis () ;
49
+ printf (" %6d", end - start) ;
50
+ fflush (stdout) ;
51
+ sum += (end - start) ;
52
+ }
53
+
54
+ digitalWrite (pin, 0) ;
55
+ printf (". Av: %6dmS", sum / PASSES) ;
56
+ perSec = (int)(double)maxCount / (double)((double)sum / (double)PASSES) * 1000.0 ;
57
+ printf (": %7d/sec\n", perSec) ;
58
+ }
59
+
60
+
61
+ int main (void)
62
+ {
63
+ printf ("Raspberry Pi wiringPi GPIO speed test program\n") ;
64
+ printf ("=============================================\n") ;
65
+
66
+ // Start the standard way
67
+
68
+ printf ("\nNative wiringPi method: (%8d iterations)\n", FAST_COUNT) ;
69
+ wiringPiSetup () ;
70
+ pinMode (0, OUTPUT) ;
71
+ speedTest (0, FAST_COUNT) ;
72
+
73
+ // GPIO
74
+
75
+ printf ("\nNative GPIO method: (%8d iterations)\n", FAST_COUNT) ;
76
+ wiringPiSetupGpio () ;
77
+ pinMode (17, OUTPUT) ;
78
+ speedTest (17, FAST_COUNT) ;
79
+
80
+ // Phys
81
+
82
+ printf ("\nPhysical pin GPIO method: (%8d iterations)\n", FAST_COUNT) ;
83
+ wiringPiSetupPhys () ;
84
+ pinMode (11, OUTPUT) ;
85
+ speedTest (11, FAST_COUNT) ;
86
+
87
+ // Switch to SYS mode:
88
+
89
+ system ("/usr/local/bin/gpio export 17 out") ;
90
+ printf ("\n/sys/class/gpio method: (%8d iterations)\n", SLOW_COUNT) ;
91
+ wiringPiSetupSys () ;
92
+ speedTest (17, SLOW_COUNT) ;
93
+
94
+ return 0 ;
95
+ }