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,50 @@
1
+ /*
2
+ * blink.c:
3
+ * Simple "blink" test for the Quick2Wire interface 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
+
28
+ #define LED 1
29
+
30
+ int main (void)
31
+ {
32
+
33
+ // Enable the on-goard GPIO
34
+
35
+ wiringPiSetup () ;
36
+
37
+ printf ("Raspberry Pi - Quick2Wire Mainboard LED Blink Test\n") ;
38
+
39
+ pinMode (LED, OUTPUT) ;
40
+
41
+ for (;;)
42
+ {
43
+ digitalWrite (LED, HIGH) ;
44
+ delay (500) ;
45
+ digitalWrite (LED, LOW) ;
46
+ delay (500) ;
47
+ }
48
+
49
+ return 0 ;
50
+ }
@@ -0,0 +1,59 @@
1
+ /*
2
+ * bright.c:
3
+ * Vary the Q2W LED brightness with the analog card
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 <pcf8591.h>
28
+
29
+ #define LED 1
30
+ #define Q2W_ABASE 120
31
+
32
+ int main (void)
33
+ {
34
+ int value ;
35
+
36
+ // Enable the on-goard GPIO
37
+
38
+ wiringPiSetup () ;
39
+
40
+ // Add in the pcf8591 on the q2w board
41
+
42
+ pcf8591Setup (Q2W_ABASE, 0x48) ;
43
+
44
+ printf ("Raspberry Pi - Quick2Wire Analog Test\n") ;
45
+
46
+ // Setup the LED
47
+
48
+ pinMode (LED, PWM_OUTPUT) ;
49
+ pwmWrite (LED, 0) ;
50
+
51
+ for (;;)
52
+ {
53
+ value = analogRead (Q2W_ABASE + 0) ;
54
+ pwmWrite (LED, value * 4) ;
55
+ delay (10) ;
56
+ }
57
+
58
+ return 0 ;
59
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ * button.c:
3
+ * Simple button test for the Quick2Wire interface 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
+
28
+ #define BUTTON 0
29
+ #define LED1 1
30
+ #define LED2 7
31
+
32
+ int main (void)
33
+ {
34
+
35
+ // Enable the on-goard GPIO
36
+
37
+ wiringPiSetup () ;
38
+
39
+ printf ("Raspberry Pi - Quick2Wire Mainboard Button & LED Test\n") ;
40
+
41
+ pinMode (BUTTON, INPUT) ;
42
+ pinMode (LED1, OUTPUT) ;
43
+ pinMode (LED2, OUTPUT) ;
44
+
45
+ digitalWrite (LED1, HIGH) ; // On-board LED on
46
+ digitalWrite (LED2, LOW) ; // 2nd LED off
47
+
48
+ for (;;)
49
+ {
50
+ if (digitalRead (BUTTON) == HIGH) // Swap LED states
51
+ {
52
+ digitalWrite (LED1, LOW) ;
53
+ digitalWrite (LED2, HIGH) ;
54
+ while (digitalRead (BUTTON) == HIGH)
55
+ delay (1) ;
56
+ digitalWrite (LED1, HIGH) ;
57
+ digitalWrite (LED2, LOW) ;
58
+ }
59
+ delay (1) ;
60
+ }
61
+
62
+ return 0 ;
63
+ }
@@ -0,0 +1,62 @@
1
+ /*
2
+ * volts.c:
3
+ * Read in all 4 analogs on the Q2W analog 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 <pcf8591.h>
28
+
29
+ #define LED 1
30
+ #define Q2W_ABASE 120
31
+
32
+ int main (void)
33
+ {
34
+ int value, pin ;
35
+
36
+ // Enable the on-goard GPIO
37
+
38
+ wiringPiSetup () ;
39
+
40
+ pinMode (LED, OUTPUT) ; // On-board LED
41
+
42
+ // Add in the pcf8591 on the q2w board
43
+
44
+ pcf8591Setup (Q2W_ABASE, 0x48) ;
45
+
46
+ printf ("Raspberry Pi - Quick2Wire Voltmeter\n") ;
47
+
48
+ for (;;)
49
+ {
50
+ for (pin = 0 ; pin < 4 ; ++pin)
51
+ {
52
+ value = analogRead (Q2W_ABASE + pin) ;
53
+ printf (" %5.2f", (double)value * 3.3 / 255.0) ;
54
+ }
55
+ printf ("\r") ; fflush (stdout) ;
56
+
57
+ delay (100) ;
58
+ digitalWrite (LED, !digitalRead (LED)) ; // Flicker the LED
59
+ }
60
+
61
+ return 0 ;
62
+ }
@@ -0,0 +1,86 @@
1
+ /*
2
+ * rht03.c:
3
+ * Driver for the MaxDetect series sensors
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
+
27
+ #include <wiringPi.h>
28
+ #include <maxdetect.h>
29
+
30
+ #define RHT03_PIN 7
31
+
32
+ /*
33
+ ***********************************************************************
34
+ * The main program
35
+ ***********************************************************************
36
+ */
37
+
38
+ int main (void)
39
+ {
40
+ int result, temp, rh ;
41
+ int minT, maxT, minRH, maxRH ;
42
+
43
+ int numGood, numBad ;
44
+
45
+ wiringPiSetup () ;
46
+ piHiPri (55) ;
47
+
48
+ minT = 1000 ;
49
+ maxT = -1000 ;
50
+
51
+ minRH = 1000 ;
52
+ maxRH = -1000 ;
53
+
54
+ numGood = numBad = 0 ;
55
+
56
+ for (;;)
57
+ {
58
+ delay (100) ;
59
+
60
+ result = readRHT03 (RHT03_PIN, &temp, &rh) ;
61
+
62
+ if (!result)
63
+ {
64
+ printf (".") ;
65
+ fflush (stdout) ;
66
+ ++numBad ;
67
+ continue ;
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") ;
83
+ }
84
+
85
+ return 0 ;
86
+ }
@@ -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
+ }