wiringpi 1.1.0 → 2.0.0

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 (138) hide show
  1. checksums.yaml +7 -0
  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 +165 -0
  12. data/ext/wiringpi/{serial.h → WiringPi/devLib/maxdetect.h} +14 -15
  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 +178 -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/examples/Gertboard/7segments.c +221 -0
  21. data/ext/wiringpi/WiringPi/examples/Gertboard/buttons.c +83 -0
  22. data/ext/wiringpi/WiringPi/examples/Gertboard/gertboard.c +96 -0
  23. data/ext/wiringpi/WiringPi/examples/Gertboard/record.c +60 -0
  24. data/ext/wiringpi/WiringPi/examples/Gertboard/temperature.c +78 -0
  25. data/ext/wiringpi/WiringPi/examples/Gertboard/voltmeter.c +73 -0
  26. data/ext/wiringpi/WiringPi/examples/Gertboard/vumeter.c +152 -0
  27. data/ext/wiringpi/WiringPi/examples/PiFace/blink.c +59 -0
  28. data/ext/wiringpi/WiringPi/examples/PiFace/buttons.c +103 -0
  29. data/ext/wiringpi/WiringPi/examples/PiFace/ladder.c +337 -0
  30. data/ext/wiringpi/WiringPi/examples/PiFace/metro.c +111 -0
  31. data/ext/wiringpi/WiringPi/examples/PiFace/motor.c +120 -0
  32. data/ext/wiringpi/WiringPi/examples/PiFace/reaction.c +194 -0
  33. data/ext/wiringpi/WiringPi/examples/PiGlow/piGlow0.c +51 -0
  34. data/ext/wiringpi/WiringPi/examples/PiGlow/piGlow1.c +258 -0
  35. data/ext/wiringpi/WiringPi/examples/PiGlow/piglow.c +176 -0
  36. data/ext/wiringpi/WiringPi/examples/blink.c +48 -0
  37. data/ext/wiringpi/WiringPi/examples/blink12.c +111 -0
  38. data/ext/wiringpi/WiringPi/examples/blink12drcs.c +125 -0
  39. data/ext/wiringpi/WiringPi/examples/blink6drcs.c +115 -0
  40. data/ext/wiringpi/WiringPi/examples/blink8.c +57 -0
  41. data/ext/wiringpi/WiringPi/examples/clock.c +201 -0
  42. data/ext/wiringpi/WiringPi/examples/delayTest.c +107 -0
  43. data/ext/wiringpi/WiringPi/examples/ds1302.c +238 -0
  44. data/ext/wiringpi/WiringPi/examples/header.h +23 -0
  45. data/ext/wiringpi/WiringPi/examples/isr-osc.c +118 -0
  46. data/ext/wiringpi/WiringPi/examples/isr.c +110 -0
  47. data/ext/wiringpi/WiringPi/examples/lcd-adafruit.c +347 -0
  48. data/ext/wiringpi/WiringPi/examples/lcd.c +286 -0
  49. data/ext/wiringpi/WiringPi/examples/lowPower.c +68 -0
  50. data/ext/wiringpi/WiringPi/examples/nes.c +67 -0
  51. data/ext/wiringpi/WiringPi/examples/okLed.c +82 -0
  52. data/ext/wiringpi/WiringPi/examples/pwm.c +58 -0
  53. data/ext/wiringpi/WiringPi/examples/q2w/binary.c +79 -0
  54. data/ext/wiringpi/WiringPi/examples/q2w/blink-io.c +61 -0
  55. data/ext/wiringpi/WiringPi/examples/q2w/blink.c +50 -0
  56. data/ext/wiringpi/WiringPi/examples/q2w/bright.c +59 -0
  57. data/ext/wiringpi/WiringPi/examples/q2w/button.c +63 -0
  58. data/ext/wiringpi/WiringPi/examples/q2w/volts.c +62 -0
  59. data/ext/wiringpi/WiringPi/examples/rht03.c +69 -0
  60. data/ext/wiringpi/WiringPi/examples/serialRead.c +48 -0
  61. data/ext/wiringpi/WiringPi/examples/serialTest.c +75 -0
  62. data/ext/wiringpi/WiringPi/examples/servo.c +57 -0
  63. data/ext/wiringpi/WiringPi/examples/softPwm.c +89 -0
  64. data/ext/wiringpi/WiringPi/examples/softTone.c +54 -0
  65. data/ext/wiringpi/WiringPi/examples/speed.c +95 -0
  66. data/ext/wiringpi/WiringPi/examples/spiSpeed.c +118 -0
  67. data/ext/wiringpi/WiringPi/examples/wfi.c +161 -0
  68. data/ext/wiringpi/WiringPi/gpio/gpio.c +1351 -0
  69. data/ext/wiringpi/WiringPi/gpio/pins.c +33 -0
  70. data/ext/wiringpi/WiringPi/gpio/readall.c +334 -0
  71. data/ext/wiringpi/WiringPi/gpio/version.h +1 -0
  72. data/ext/wiringpi/WiringPi/wiringPi/drcSerial.c +201 -0
  73. data/ext/wiringpi/WiringPi/wiringPi/drcSerial.h +33 -0
  74. data/ext/wiringpi/WiringPi/wiringPi/max31855.c +81 -0
  75. data/ext/wiringpi/WiringPi/wiringPi/max31855.h +33 -0
  76. data/ext/wiringpi/WiringPi/wiringPi/max5322.c +84 -0
  77. data/ext/wiringpi/WiringPi/wiringPi/max5322.h +33 -0
  78. data/ext/wiringpi/WiringPi/wiringPi/mcp23008.c +149 -0
  79. data/ext/wiringpi/WiringPi/wiringPi/mcp23008.h +33 -0
  80. data/ext/wiringpi/WiringPi/wiringPi/mcp23016.c +164 -0
  81. data/ext/wiringpi/WiringPi/wiringPi/mcp23016.h +33 -0
  82. data/ext/wiringpi/WiringPi/wiringPi/mcp23016reg.h +48 -0
  83. data/ext/wiringpi/WiringPi/wiringPi/mcp23017.c +195 -0
  84. data/ext/wiringpi/WiringPi/wiringPi/mcp23017.h +33 -0
  85. data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.c +189 -0
  86. data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.h +33 -0
  87. data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.c +236 -0
  88. data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.h +33 -0
  89. data/ext/wiringpi/WiringPi/wiringPi/mcp23x08.h +73 -0
  90. data/ext/wiringpi/WiringPi/wiringPi/mcp23x0817.h +87 -0
  91. data/ext/wiringpi/WiringPi/wiringPi/mcp3002.c +76 -0
  92. data/ext/wiringpi/WiringPi/wiringPi/mcp3002.h +33 -0
  93. data/ext/wiringpi/WiringPi/wiringPi/mcp3004.c +76 -0
  94. data/ext/wiringpi/WiringPi/wiringPi/mcp3004.h +33 -0
  95. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.c +110 -0
  96. data/ext/wiringpi/WiringPi/wiringPi/mcp3422.h +43 -0
  97. data/ext/wiringpi/WiringPi/wiringPi/mcp4802.c +76 -0
  98. data/ext/wiringpi/WiringPi/wiringPi/mcp4802.h +33 -0
  99. data/ext/wiringpi/WiringPi/wiringPi/pcf8574.c +126 -0
  100. data/ext/wiringpi/WiringPi/wiringPi/pcf8574.h +33 -0
  101. data/ext/wiringpi/WiringPi/wiringPi/pcf8591.c +90 -0
  102. data/ext/wiringpi/WiringPi/wiringPi/pcf8591.h +33 -0
  103. data/ext/wiringpi/WiringPi/wiringPi/piHiPri.c +51 -0
  104. data/ext/wiringpi/WiringPi/wiringPi/piThread.c +63 -0
  105. data/ext/wiringpi/WiringPi/wiringPi/sn3218.c +75 -0
  106. data/ext/wiringpi/WiringPi/wiringPi/sn3218.h +33 -0
  107. data/ext/wiringpi/WiringPi/wiringPi/softPwm.c +166 -0
  108. data/ext/wiringpi/WiringPi/wiringPi/softPwm.h +35 -0
  109. data/ext/wiringpi/WiringPi/wiringPi/softServo.c +211 -0
  110. data/ext/wiringpi/WiringPi/wiringPi/softServo.h +35 -0
  111. data/ext/wiringpi/WiringPi/wiringPi/softTone.c +150 -0
  112. data/ext/wiringpi/WiringPi/wiringPi/softTone.h +39 -0
  113. data/ext/wiringpi/WiringPi/wiringPi/sr595.c +109 -0
  114. data/ext/wiringpi/WiringPi/wiringPi/sr595.h +34 -0
  115. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.c +2007 -0
  116. data/ext/wiringpi/WiringPi/wiringPi/wiringPi.h +224 -0
  117. data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.c +232 -0
  118. data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.h +42 -0
  119. data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.c +136 -0
  120. data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.h +36 -0
  121. data/ext/wiringpi/{serial.c → WiringPi/wiringPi/wiringSerial.c} +38 -29
  122. data/ext/wiringpi/WiringPi/wiringPi/wiringSerial.h +38 -0
  123. data/ext/wiringpi/{wiringShift.c → WiringPi/wiringPi/wiringShift.c} +3 -4
  124. data/ext/wiringpi/{wiringShift.h → WiringPi/wiringPi/wiringShift.h} +5 -5
  125. data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.c +731 -0
  126. data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.h +26 -0
  127. data/ext/wiringpi/extconf.rb +7 -1
  128. data/ext/wiringpi/wiringpi_wrap.c +1741 -218
  129. data/lib/wiringpi.rb +24 -222
  130. data/lib/wiringpi/event.rb +21 -0
  131. data/lib/wiringpi/gpio.rb +139 -0
  132. data/lib/wiringpi/i2c.rb +26 -0
  133. data/lib/wiringpi/mcp23x17.rb +31 -0
  134. data/lib/wiringpi/serial.rb +49 -0
  135. data/lib/wiringpi/spi.rb +15 -0
  136. metadata +146 -22
  137. data/ext/wiringpi/wiringPi.c +0 -729
  138. data/ext/wiringpi/wiringPi.h +0 -69
@@ -0,0 +1,111 @@
1
+ /*
2
+ * blink12.c:
3
+ * Simple sequence over the first 12 GPIO pins - LEDs
4
+ * Aimed at the Gertboard, but it's fairly generic.
5
+ *
6
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
7
+ ***********************************************************************
8
+ * This file is part of wiringPi:
9
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
10
+ *
11
+ * wiringPi is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU Lesser General Public License as published by
13
+ * the Free Software Foundation, either version 3 of the License, or
14
+ * (at your option) any later version.
15
+ *
16
+ * wiringPi is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU Lesser General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Lesser General Public License
22
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
23
+ ***********************************************************************
24
+ */
25
+
26
+ #include <stdio.h>
27
+ #include <wiringPi.h>
28
+
29
+ // Simple sequencer data
30
+ // Triplets of LED, On/Off and delay
31
+
32
+ int data [] =
33
+ {
34
+ 0, 1, 1,
35
+ 1, 1, 1,
36
+ 0, 0, 0, 2, 1, 1,
37
+ 1, 0, 0, 3, 1, 1,
38
+ 2, 0, 0, 4, 1, 1,
39
+ 3, 0, 0, 5, 1, 1,
40
+ 4, 0, 0, 6, 1, 1,
41
+ 5, 0, 0, 7, 1, 1,
42
+ 6, 0, 0, 11, 1, 1,
43
+ 7, 0, 0, 10, 1, 1,
44
+ 11, 0, 0, 13, 1, 1,
45
+ 10, 0, 0, 12, 1, 1,
46
+ 13, 0, 1,
47
+ 12, 0, 1,
48
+
49
+ 0, 0, 1, // Extra delay
50
+
51
+ // Back again
52
+
53
+ 12, 1, 1,
54
+ 13, 1, 1,
55
+ 12, 0, 0, 10, 1, 1,
56
+ 13, 0, 0, 11, 1, 1,
57
+ 10, 0, 0, 7, 1, 1,
58
+ 11, 0, 0, 6, 1, 1,
59
+ 7, 0, 0, 5, 1, 1,
60
+ 6, 0, 0, 4, 1, 1,
61
+ 5, 0, 0, 3, 1, 1,
62
+ 4, 0, 0, 2, 1, 1,
63
+ 3, 0, 0, 1, 1, 1,
64
+ 2, 0, 0, 0, 1, 1,
65
+ 1, 0, 1,
66
+ 0, 0, 1,
67
+
68
+ 0, 0, 1, // Extra delay
69
+
70
+ 0, 9, 0, // End marker
71
+
72
+ } ;
73
+
74
+
75
+ int main (void)
76
+ {
77
+ int pin ;
78
+ int dataPtr ;
79
+ int l, s, d ;
80
+
81
+ printf ("Raspberry Pi - 12-LED Sequence\n") ;
82
+ printf ("==============================\n") ;
83
+ printf ("\n") ;
84
+ printf ("Connect LEDs up to the first 8 GPIO pins, then pins 11, 10, 13, 12 in\n") ;
85
+ printf (" that order, then sit back and watch the show!\n") ;
86
+
87
+ wiringPiSetup () ;
88
+
89
+ for (pin = 0 ; pin < 14 ; ++pin)
90
+ pinMode (pin, OUTPUT) ;
91
+
92
+ dataPtr = 0 ;
93
+
94
+ for (;;)
95
+ {
96
+ l = data [dataPtr++] ; // LED
97
+ s = data [dataPtr++] ; // State
98
+ d = data [dataPtr++] ; // Duration (10ths)
99
+
100
+ if (s == 9) // 9 -> End Marker
101
+ {
102
+ dataPtr = 0 ;
103
+ continue ;
104
+ }
105
+
106
+ digitalWrite (l, s) ;
107
+ delay (d * 100) ;
108
+ }
109
+
110
+ return 0 ;
111
+ }
@@ -0,0 +1,125 @@
1
+ /*
2
+ * blink12drcs.c:
3
+ * Simple sequence over the first 12 GPIO pins - LEDs
4
+ * Aimed at the Gertboard, but it's fairly generic.
5
+ * This version uses DRC totalk to the ATmega on the Gertboard
6
+ *
7
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
8
+ ***********************************************************************
9
+ * This file is part of wiringPi:
10
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
11
+ *
12
+ * wiringPi is free software: you can redistribute it and/or modify
13
+ * it under the terms of the GNU Lesser General Public License as published by
14
+ * the Free Software Foundation, either version 3 of the License, or
15
+ * (at your option) any later version.
16
+ *
17
+ * wiringPi is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ * GNU Lesser General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU Lesser General Public License
23
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
24
+ ***********************************************************************
25
+ */
26
+
27
+ #include <stdio.h>
28
+ #include <wiringPi.h>
29
+ #include <drcSerial.h>
30
+
31
+ #define GERT_BASE 100
32
+
33
+ static int pinMap [] =
34
+ {
35
+ 0, 1, 2, 3, // Pi Native
36
+ GERT_BASE + 2, GERT_BASE + 3, GERT_BASE + 4, GERT_BASE + 5,
37
+ GERT_BASE + 6, GERT_BASE + 7, GERT_BASE + 8, GERT_BASE + 9,
38
+ } ;
39
+
40
+ // Simple sequencer data
41
+ // Triplets of LED, On/Off and delay
42
+
43
+
44
+ int data [] =
45
+ {
46
+ 0, 1, 1,
47
+ 1, 1, 1,
48
+ 0, 0, 0, 2, 1, 1,
49
+ 1, 0, 0, 3, 1, 1,
50
+ 2, 0, 0, 4, 1, 1,
51
+ 3, 0, 0, 5, 1, 1,
52
+ 4, 0, 0, 6, 1, 1,
53
+ 5, 0, 0, 7, 1, 1,
54
+ 6, 0, 0, 8, 1, 1,
55
+ 7, 0, 0, 9, 1, 1,
56
+ 8, 0, 0, 10, 1, 1,
57
+ 9, 0, 0, 11, 1, 1,
58
+ 10, 0, 1,
59
+ 11, 0, 1,
60
+
61
+ 0, 0, 1, // Extra delay
62
+
63
+ // Back again
64
+
65
+ 11, 1, 1,
66
+ 10, 1, 1,
67
+ 11, 0, 0, 9, 1, 1,
68
+ 10, 0, 0, 8, 1, 1,
69
+ 9, 0, 0, 7, 1, 1,
70
+ 8, 0, 0, 6, 1, 1,
71
+ 7, 0, 0, 5, 1, 1,
72
+ 6, 0, 0, 4, 1, 1,
73
+ 5, 0, 0, 3, 1, 1,
74
+ 4, 0, 0, 2, 1, 1,
75
+ 3, 0, 0, 1, 1, 1,
76
+ 2, 0, 0, 0, 1, 1,
77
+ 1, 0, 1,
78
+ 0, 0, 1,
79
+
80
+ 0, 0, 1, // Extra delay
81
+
82
+ 0, 9, 0, // End marker
83
+
84
+ } ;
85
+
86
+
87
+ int main (void)
88
+ {
89
+ int pin ;
90
+ int dataPtr ;
91
+ int l, s, d ;
92
+
93
+ printf ("Raspberry Pi - 12-LED Sequence\n") ;
94
+ printf ("==============================\n") ;
95
+ printf ("\n") ;
96
+ printf ("Connect LEDs up to the first 4 Pi pins and 8 pins on the ATmega\n") ;
97
+ printf (" from PD2 through PB1 in that order,\n") ;
98
+ printf (" then sit back and watch the show!\n") ;
99
+
100
+ wiringPiSetup () ;
101
+ drcSetupSerial (GERT_BASE, 20, "/dev/ttyAMA0", 115200) ;
102
+
103
+ for (pin = 0 ; pin < 12 ; ++pin)
104
+ pinMode (pinMap [pin], OUTPUT) ;
105
+
106
+ dataPtr = 0 ;
107
+
108
+ for (;;)
109
+ {
110
+ l = data [dataPtr++] ; // LED
111
+ s = data [dataPtr++] ; // State
112
+ d = data [dataPtr++] ; // Duration (10ths)
113
+
114
+ if (s == 9) // 9 -> End Marker
115
+ {
116
+ dataPtr = 0 ;
117
+ continue ;
118
+ }
119
+
120
+ digitalWrite (pinMap [l], s) ;
121
+ delay (d * analogRead (GERT_BASE) / 4) ;
122
+ }
123
+
124
+ return 0 ;
125
+ }
@@ -0,0 +1,115 @@
1
+ /*
2
+ * blink6drcs.c:
3
+ * Simple sequence over 6 pins on a remote DRC board.
4
+ * Aimed at the Gertduino, but it's fairly generic.
5
+ * This version uses DRC to talk to the ATmega on the Gertduino
6
+ *
7
+ * Copyright (c) 2012-2014 Gordon Henderson. <projects@drogon.net>
8
+ ***********************************************************************
9
+ * This file is part of wiringPi:
10
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
11
+ *
12
+ * wiringPi is free software: you can redistribute it and/or modify
13
+ * it under the terms of the GNU Lesser General Public License as published by
14
+ * the Free Software Foundation, either version 3 of the License, or
15
+ * (at your option) any later version.
16
+ *
17
+ * wiringPi is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ * GNU Lesser General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU Lesser General Public License
23
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
24
+ ***********************************************************************
25
+ */
26
+
27
+ #include <stdio.h>
28
+ #include <wiringPi.h>
29
+ #include <drcSerial.h>
30
+
31
+ #define GERT_BASE 100
32
+
33
+ static int pinMap [] =
34
+ {
35
+ GERT_BASE + 6, GERT_BASE + 5, GERT_BASE + 3, GERT_BASE + 10, GERT_BASE + 9, GERT_BASE + 13,
36
+ } ;
37
+
38
+ // Simple sequencer data
39
+ // Triplets of LED, On/Off and delay
40
+
41
+
42
+ int data [] =
43
+ {
44
+ 0, 1, 1,
45
+ 1, 1, 1,
46
+ 0, 0, 0, 2, 1, 1,
47
+ 1, 0, 0, 3, 1, 1,
48
+ 2, 0, 0, 4, 1, 1,
49
+ 3, 0, 0, 5, 1, 1,
50
+ 4, 0, 1,
51
+ 5, 0, 1,
52
+
53
+ 0, 0, 1, // Extra delay
54
+
55
+ // Back again
56
+
57
+ 5, 1, 1,
58
+ 4, 1, 1,
59
+ 5, 0, 0, 3, 1, 1,
60
+ 4, 0, 0, 2, 1, 1,
61
+ 3, 0, 0, 1, 1, 1,
62
+ 2, 0, 0, 0, 1, 1,
63
+ 1, 0, 1,
64
+ 0, 0, 1,
65
+
66
+ 0, 0, 1, // Extra delay
67
+
68
+ 0, 9, 0, // End marker
69
+
70
+ } ;
71
+
72
+
73
+ int main (void)
74
+ {
75
+ int pin ;
76
+ int dataPtr ;
77
+ int l, s, d ;
78
+
79
+ printf ("Raspberry Pi - 6-LED Sequence\n") ;
80
+ printf ("=============================\n") ;
81
+ printf ("\n") ;
82
+ printf (" Use the 2 buttons to temporarily speed up the sequence\n") ;
83
+
84
+ wiringPiSetupSys () ; // Not using the Pi's GPIO here
85
+ drcSetupSerial (GERT_BASE, 20, "/dev/ttyAMA0", 115200) ;
86
+
87
+ for (pin = 0 ; pin < 6 ; ++pin)
88
+ pinMode (pinMap [pin], OUTPUT) ;
89
+
90
+ pinMode (GERT_BASE + 16, INPUT) ; // Buttons
91
+ pinMode (GERT_BASE + 17, INPUT) ;
92
+
93
+ pullUpDnControl (GERT_BASE + 16, PUD_UP) ;
94
+ pullUpDnControl (GERT_BASE + 17, PUD_UP) ;
95
+
96
+ dataPtr = 0 ;
97
+
98
+ for (;;)
99
+ {
100
+ l = data [dataPtr++] ; // LED
101
+ s = data [dataPtr++] ; // State
102
+ d = data [dataPtr++] ; // Duration (10ths)
103
+
104
+ if (s == 9) // 9 -> End Marker
105
+ {
106
+ dataPtr = 0 ;
107
+ continue ;
108
+ }
109
+
110
+ digitalWrite (pinMap [l], s) ;
111
+ delay (d * digitalRead (GERT_BASE + 16) * 15 + digitalRead (GERT_BASE + 17) * 20) ;
112
+ }
113
+
114
+ return 0 ;
115
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ * blink8.c:
3
+ * Simple sequence over the first 8 GPIO pins - LEDs
4
+ * Aimed at the Gertboard, but it's fairly generic.
5
+ *
6
+ * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
7
+ ***********************************************************************
8
+ * This file is part of wiringPi:
9
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
10
+ *
11
+ * wiringPi is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU Lesser General Public License as published by
13
+ * the Free Software Foundation, either version 3 of the License, or
14
+ * (at your option) any later version.
15
+ *
16
+ * wiringPi is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU Lesser General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Lesser General Public License
22
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
23
+ ***********************************************************************
24
+ */
25
+
26
+ #include <stdio.h>
27
+ #include <wiringPi.h>
28
+
29
+ int main (void)
30
+ {
31
+ int i, led ;
32
+
33
+ printf ("Raspberry Pi - 8-LED Sequencer\n") ;
34
+ printf ("==============================\n") ;
35
+ printf ("\n") ;
36
+ printf ("Connect LEDs to the first 8 GPIO pins and watch ...\n") ;
37
+
38
+ wiringPiSetup () ;
39
+
40
+ for (i = 0 ; i < 8 ; ++i)
41
+ pinMode (i, OUTPUT) ;
42
+
43
+ for (;;)
44
+ {
45
+ for (led = 0 ; led < 8 ; ++led)
46
+ {
47
+ digitalWrite (led, 1) ;
48
+ delay (100) ;
49
+ }
50
+
51
+ for (led = 0 ; led < 8 ; ++led)
52
+ {
53
+ digitalWrite (led, 0) ;
54
+ delay (100) ;
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,201 @@
1
+ /*
2
+ * clock.c:
3
+ * Demo of the 128x64 graphics based LCD driver.
4
+ * This is designed to drive the parallel interface LCD drivers
5
+ * based on the popular 12864H controller chip.
6
+ *
7
+ * This test program assumes the following:
8
+ * (Which is currently hard-wired into the driver)
9
+ *
10
+ * GPIO 0-7 is connected to display data pins 0-7.
11
+ * GPIO 10 is CS1
12
+ * GPIO 11 is CS2
13
+ * GPIO 12 is STROBE
14
+ * GPIO 10 is RS
15
+ *
16
+ * Copyright (c) 2012-2013 Gordon Henderson.
17
+ ***********************************************************************
18
+ * This file is part of wiringPi:
19
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
20
+ *
21
+ * wiringPi is free software: you can redistribute it and/or modify
22
+ * it under the terms of the GNU Lesser General Public License as published by
23
+ * the Free Software Foundation, either version 3 of the License, or
24
+ * (at your option) any later version.
25
+ *
26
+ * wiringPi is distributed in the hope that it will be useful,
27
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
+ * GNU Lesser General Public License for more details.
30
+ *
31
+ * You should have received a copy of the GNU Lesser General Public License
32
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
33
+ ***********************************************************************
34
+ */
35
+
36
+ #include <stdio.h>
37
+ #include <stdlib.h>
38
+ #include <stdint.h>
39
+ #include <unistd.h>
40
+ #include <string.h>
41
+ #include <errno.h>
42
+ #include <time.h>
43
+ #include <math.h>
44
+
45
+ #include <wiringPi.h>
46
+ #include <lcd128x64.h>
47
+
48
+ #ifndef TRUE
49
+ # define TRUE (1==1)
50
+ # define FALSE (1==2)
51
+ #endif
52
+
53
+ double clockRadius ;
54
+ double thickness, barLen ;
55
+ int maxX, maxY ;
56
+
57
+ double rads (double degs)
58
+ {
59
+ return degs * M_PI / 180.0 ;
60
+ }
61
+
62
+ void drawClockHands (void)
63
+ {
64
+ time_t t ;
65
+ struct tm *now ;
66
+ double angle, p, x0, y0, x1, y1 ;
67
+ int h24, h, m, s ;
68
+ char text [20] ;
69
+
70
+ time (&t) ;
71
+ now = localtime (&t) ;
72
+
73
+ h24 = now->tm_hour ;
74
+ m = now->tm_min ;
75
+ s = now->tm_sec ;
76
+
77
+ h = h24 ;
78
+ if (h > 12)
79
+ h -= 12 ;
80
+
81
+ // Hour hand
82
+
83
+ angle = h * 30 + m * 0.5 ;
84
+ x0 = sin (rads (angle)) * (clockRadius * 0.75) ;
85
+ y0 = cos (rads (angle)) * (clockRadius * 0.75) ;
86
+ for (p = -3.0 ; p <= 3.0 ; p += 0.2)
87
+ {
88
+ x1 = sin (rads (angle + p)) * (clockRadius * 0.7) ;
89
+ y1 = cos (rads (angle + p)) * (clockRadius * 0.7) ;
90
+ lcd128x64line (0, 0, x1, y1, 1) ;
91
+ lcd128x64lineTo (x0, y0, 1) ;
92
+ }
93
+
94
+ // Minute hand
95
+
96
+ angle = m * 6 ;
97
+ x0 = sin (rads (angle)) * (clockRadius * 0.9) ;
98
+ y0 = cos (rads (angle)) * (clockRadius * 0.9) ;
99
+ for (p = -1.0 ; p <= 1.0 ; p += 0.2)
100
+ {
101
+ x1 = sin (rads (angle + p)) * (clockRadius * 0.85) ;
102
+ y1 = cos (rads (angle + p)) * (clockRadius * 0.85) ;
103
+ lcd128x64line (0, 0, x1, y1, 1) ;
104
+ lcd128x64lineTo (x0, y0, 1) ;
105
+ }
106
+
107
+ // Second hand
108
+
109
+ angle = s * 6 ;
110
+ x0 = sin (rads (angle)) * (clockRadius * 0.2) ;
111
+ y0 = cos (rads (angle)) * (clockRadius * 0.2) ;
112
+ x1 = sin (rads (angle)) * (clockRadius * 0.95) ;
113
+ y1 = cos (rads (angle)) * (clockRadius * 0.95) ;
114
+ lcd128x64line (0 - x0, 0 - y0, x1, y1, 1) ;
115
+ lcd128x64circle (0, 0, clockRadius * 0.1, 0, 1) ;
116
+ lcd128x64circle (0, 0, clockRadius * 0.05, 1, 1) ;
117
+
118
+ // Text:
119
+
120
+ sprintf (text, "%02d:%02d:%02d", h24, m, s) ;
121
+ lcd128x64puts (32, 24, text, 0, 1) ;
122
+
123
+ sprintf (text, "%2d/%2d/%2d", now->tm_mday, now->tm_mon + 1, now->tm_year - 100) ;
124
+ lcd128x64puts (32, -23, text, 0, 1) ;
125
+ }
126
+
127
+ void drawClockFace (void)
128
+ {
129
+ int m ;
130
+ double d, px1, py1, px2, py2 ;
131
+
132
+ lcd128x64clear (0) ;
133
+ lcd128x64circle (0,0, clockRadius, 1, TRUE) ;
134
+ lcd128x64circle (0,0, clockRadius - thickness, 0, TRUE) ;
135
+
136
+ // The four big indicators for 12,15,30 and 45
137
+
138
+ lcd128x64rectangle (- 3, clockRadius - barLen, 3, clockRadius, 1, TRUE) ; // 12
139
+ lcd128x64rectangle (clockRadius - barLen, 3, clockRadius, -3, 1, TRUE) ; // 3
140
+ lcd128x64rectangle (- 3, -clockRadius + barLen, 3, -clockRadius, 1, TRUE) ; // 6
141
+ lcd128x64rectangle (-clockRadius + barLen, 3, -clockRadius, -3, 1, TRUE) ; // 9
142
+
143
+
144
+ // Smaller 5 and 1 minute ticks
145
+
146
+ for (m = 0 ; m < 60 ; ++m)
147
+ {
148
+ px1 = sin (rads (m * 6)) * clockRadius ;
149
+ py1 = cos (rads (m * 6)) * clockRadius ;
150
+ if ((m % 5) == 0)
151
+ d = barLen ;
152
+ else
153
+ d = barLen / 2.0 ;
154
+
155
+ px2 = sin (rads (m * 6)) * (clockRadius - d) ;
156
+ py2 = cos (rads (m * 6)) * (clockRadius - d) ;
157
+ lcd128x64line (px1, py1, px2, py2, 1) ;
158
+ }
159
+ }
160
+
161
+ void setup (void)
162
+ {
163
+ lcd128x64getScreenSize (&maxX, &maxY) ;
164
+ clockRadius = maxY / 2 - 1 ;
165
+ thickness = maxX / 48 ;
166
+ barLen = thickness * 4 ;
167
+ lcd128x64setOrigin (32, 32) ;
168
+ }
169
+
170
+
171
+
172
+
173
+ /*
174
+ ***********************************************************************
175
+ * The main program
176
+ ***********************************************************************
177
+ */
178
+
179
+ int main (int argc, char *argv [])
180
+ {
181
+ time_t now ;
182
+
183
+ wiringPiSetup () ;
184
+
185
+ lcd128x64setup () ;
186
+
187
+ setup () ;
188
+ for (;;)
189
+ {
190
+ drawClockFace () ;
191
+ drawClockHands () ;
192
+ lcd128x64update () ;
193
+
194
+ now = time (NULL) ;
195
+ while (time (NULL) == now)
196
+ delay (10) ;
197
+ }
198
+
199
+
200
+ return 0 ;
201
+ }