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.
- checksums.yaml +4 -4
- data/ext/wiringpi/WiringPi/devLib/ds1302.c +240 -0
- data/ext/wiringpi/WiringPi/devLib/ds1302.h +44 -0
- data/ext/wiringpi/WiringPi/devLib/font.h +2577 -0
- data/ext/wiringpi/WiringPi/devLib/gertboard.c +164 -0
- data/ext/wiringpi/WiringPi/devLib/gertboard.h +45 -0
- data/ext/wiringpi/WiringPi/devLib/lcd.c +495 -0
- data/ext/wiringpi/WiringPi/devLib/lcd.h +52 -0
- data/ext/wiringpi/WiringPi/devLib/lcd128x64.c +673 -0
- data/ext/wiringpi/WiringPi/devLib/lcd128x64.h +39 -0
- data/ext/wiringpi/WiringPi/devLib/maxdetect.c +238 -0
- data/ext/wiringpi/WiringPi/devLib/maxdetect.h +40 -0
- data/ext/wiringpi/WiringPi/devLib/piFace.c +112 -0
- data/ext/wiringpi/WiringPi/devLib/piFace.h +32 -0
- data/ext/wiringpi/WiringPi/devLib/piFaceOld.c +177 -0
- data/ext/wiringpi/WiringPi/devLib/piGlow.c +118 -0
- data/ext/wiringpi/WiringPi/devLib/piGlow.h +45 -0
- data/ext/wiringpi/WiringPi/devLib/piNes.c +113 -0
- data/ext/wiringpi/WiringPi/devLib/piNes.h +45 -0
- data/ext/wiringpi/WiringPi/devLib/scrollPhat.c +430 -0
- data/ext/wiringpi/WiringPi/devLib/scrollPhat.h +39 -0
- data/ext/wiringpi/WiringPi/devLib/scrollPhatFont.h +544 -0
- data/ext/wiringpi/WiringPi/examples/Gertboard/7segments.c +221 -0
- data/ext/wiringpi/WiringPi/examples/Gertboard/buttons.c +83 -0
- data/ext/wiringpi/WiringPi/examples/Gertboard/gertboard.c +96 -0
- data/ext/wiringpi/WiringPi/examples/Gertboard/record.c +60 -0
- data/ext/wiringpi/WiringPi/examples/Gertboard/temperature.c +78 -0
- data/ext/wiringpi/WiringPi/examples/Gertboard/voltmeter.c +73 -0
- data/ext/wiringpi/WiringPi/examples/Gertboard/vumeter.c +152 -0
- data/ext/wiringpi/WiringPi/examples/PiFace/blink.c +59 -0
- data/ext/wiringpi/WiringPi/examples/PiFace/buttons.c +103 -0
- data/ext/wiringpi/WiringPi/examples/PiFace/ladder.c +337 -0
- data/ext/wiringpi/WiringPi/examples/PiFace/metro.c +111 -0
- data/ext/wiringpi/WiringPi/examples/PiFace/motor.c +120 -0
- data/ext/wiringpi/WiringPi/examples/PiFace/reaction.c +194 -0
- data/ext/wiringpi/WiringPi/examples/PiGlow/piGlow0.c +51 -0
- data/ext/wiringpi/WiringPi/examples/PiGlow/piGlow1.c +258 -0
- data/ext/wiringpi/WiringPi/examples/PiGlow/piglow.c +176 -0
- data/ext/wiringpi/WiringPi/examples/blink-thread.c +61 -0
- data/ext/wiringpi/WiringPi/examples/blink.c +48 -0
- data/ext/wiringpi/WiringPi/examples/blink12.c +111 -0
- data/ext/wiringpi/WiringPi/examples/blink12drcs.c +125 -0
- data/ext/wiringpi/WiringPi/examples/blink6drcs.c +115 -0
- data/ext/wiringpi/WiringPi/examples/blink8-drcn.c +61 -0
- data/ext/wiringpi/WiringPi/examples/blink8.c +57 -0
- data/ext/wiringpi/WiringPi/examples/clock.c +201 -0
- data/ext/wiringpi/WiringPi/examples/delayTest.c +102 -0
- data/ext/wiringpi/WiringPi/examples/ds1302.c +238 -0
- data/ext/wiringpi/WiringPi/examples/header.h +23 -0
- data/ext/wiringpi/WiringPi/examples/isr-osc.c +118 -0
- data/ext/wiringpi/WiringPi/examples/isr.c +110 -0
- data/ext/wiringpi/WiringPi/examples/lcd-adafruit.c +347 -0
- data/ext/wiringpi/WiringPi/examples/lcd.c +286 -0
- data/ext/wiringpi/WiringPi/examples/lowPower.c +68 -0
- data/ext/wiringpi/WiringPi/examples/max31855.c +60 -0
- data/ext/wiringpi/WiringPi/examples/nes.c +67 -0
- data/ext/wiringpi/WiringPi/examples/okLed.c +82 -0
- data/ext/wiringpi/WiringPi/examples/pwm.c +58 -0
- data/ext/wiringpi/WiringPi/examples/q2w/binary.c +79 -0
- data/ext/wiringpi/WiringPi/examples/q2w/blink-io.c +61 -0
- data/ext/wiringpi/WiringPi/examples/q2w/blink.c +50 -0
- data/ext/wiringpi/WiringPi/examples/q2w/bright.c +59 -0
- data/ext/wiringpi/WiringPi/examples/q2w/button.c +63 -0
- data/ext/wiringpi/WiringPi/examples/q2w/volts.c +62 -0
- data/ext/wiringpi/WiringPi/examples/rht03.c +86 -0
- data/ext/wiringpi/WiringPi/examples/scrollPhat/scphat.c +230 -0
- data/ext/wiringpi/WiringPi/examples/scrollPhat/test.c +115 -0
- data/ext/wiringpi/WiringPi/examples/serialRead.c +48 -0
- data/ext/wiringpi/WiringPi/examples/serialTest.c +75 -0
- data/ext/wiringpi/WiringPi/examples/servo.c +57 -0
- data/ext/wiringpi/WiringPi/examples/softPwm.c +89 -0
- data/ext/wiringpi/WiringPi/examples/softTone.c +54 -0
- data/ext/wiringpi/WiringPi/examples/speed.c +95 -0
- data/ext/wiringpi/WiringPi/examples/spiSpeed.c +118 -0
- data/ext/wiringpi/WiringPi/examples/wfi.c +161 -0
- data/ext/wiringpi/WiringPi/gpio/gpio.c +1538 -0
- data/ext/wiringpi/WiringPi/gpio/readall.c +403 -0
- data/ext/wiringpi/WiringPi/version.h +3 -0
- data/ext/wiringpi/WiringPi/wiringPi/ads1115.c +293 -0
- data/ext/wiringpi/WiringPi/wiringPi/ads1115.h +55 -0
- data/ext/wiringpi/WiringPi/wiringPi/bmp180.c +237 -0
- data/ext/wiringpi/WiringPi/wiringPi/bmp180.h +34 -0
- data/ext/wiringpi/WiringPi/wiringPi/drcNet.c +405 -0
- data/ext/wiringpi/WiringPi/wiringPi/drcNet.h +42 -0
- data/ext/wiringpi/WiringPi/wiringPi/drcSerial.c +196 -0
- data/ext/wiringpi/WiringPi/wiringPi/drcSerial.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/ds18b20.c +146 -0
- data/ext/wiringpi/WiringPi/wiringPi/ds18b20.h +34 -0
- data/ext/wiringpi/WiringPi/wiringPi/htu21d.c +150 -0
- data/ext/wiringpi/WiringPi/wiringPi/htu21d.h +34 -0
- data/ext/wiringpi/WiringPi/wiringPi/max31855.c +99 -0
- data/ext/wiringpi/WiringPi/wiringPi/max31855.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/max5322.c +84 -0
- data/ext/wiringpi/WiringPi/wiringPi/max5322.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23008.c +149 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23008.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23016.c +164 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23016.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23016reg.h +48 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23017.c +195 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23017.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.c +188 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23s08.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.c +235 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23s17.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23x08.h +73 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp23x0817.h +87 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp3002.c +76 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp3002.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp3004.c +76 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp3004.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp3422.c +125 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp3422.h +43 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp4802.c +76 -0
- data/ext/wiringpi/WiringPi/wiringPi/mcp4802.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/pcf8574.c +126 -0
- data/ext/wiringpi/WiringPi/wiringPi/pcf8574.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/pcf8591.c +90 -0
- data/ext/wiringpi/WiringPi/wiringPi/pcf8591.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/piHiPri.c +51 -0
- data/ext/wiringpi/WiringPi/wiringPi/piThread.c +63 -0
- data/ext/wiringpi/WiringPi/wiringPi/pseudoPins.c +95 -0
- data/ext/wiringpi/WiringPi/wiringPi/pseudoPins.h +26 -0
- data/ext/wiringpi/WiringPi/wiringPi/rht03.c +252 -0
- data/ext/wiringpi/WiringPi/wiringPi/rht03.h +25 -0
- data/ext/wiringpi/WiringPi/wiringPi/sn3218.c +75 -0
- data/ext/wiringpi/WiringPi/wiringPi/sn3218.h +33 -0
- data/ext/wiringpi/WiringPi/wiringPi/softPwm.c +186 -0
- data/ext/wiringpi/WiringPi/wiringPi/softPwm.h +35 -0
- data/ext/wiringpi/WiringPi/wiringPi/softServo.c +211 -0
- data/ext/wiringpi/WiringPi/wiringPi/softServo.h +35 -0
- data/ext/wiringpi/WiringPi/wiringPi/softTone.c +150 -0
- data/ext/wiringpi/WiringPi/wiringPi/softTone.h +39 -0
- data/ext/wiringpi/WiringPi/wiringPi/sr595.c +109 -0
- data/ext/wiringpi/WiringPi/wiringPi/sr595.h +34 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringPi.c +2507 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringPi.h +269 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.c +233 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringPiI2C.h +42 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.c +144 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringPiSPI.h +36 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringSerial.c +225 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringSerial.h +38 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringShift.c +83 -0
- data/ext/wiringpi/WiringPi/wiringPi/wiringShift.h +41 -0
- data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.c +928 -0
- data/ext/wiringpi/WiringPi/wiringPi/wpiExtensions.h +26 -0
- data/ext/wiringpi/WiringPi/wiringPiD/daemonise.c +82 -0
- data/ext/wiringpi/WiringPi/wiringPiD/daemonise.h +9 -0
- data/ext/wiringpi/WiringPi/wiringPiD/drcNetCmd.h +43 -0
- data/ext/wiringpi/WiringPi/wiringPiD/network.c +330 -0
- data/ext/wiringpi/WiringPi/wiringPiD/network.h +31 -0
- data/ext/wiringpi/WiringPi/wiringPiD/runRemote.c +126 -0
- data/ext/wiringpi/WiringPi/wiringPiD/runRemote.h +29 -0
- data/ext/wiringpi/WiringPi/wiringPiD/wiringpid.c +382 -0
- data/ext/wiringpi/wiringpi_wrap.c +636 -219
- data/lib/wiringpi.rb +25 -12
- data/lib/wiringpi/gpio.rb +90 -83
- data/lib/wiringpi/i2c.rb +29 -22
- data/lib/wiringpi/modules/mcp23017.rb +15 -0
- data/lib/wiringpi/modules/mcp23s17.rb +16 -0
- data/lib/wiringpi/scrollphat.rb +14 -14
- data/lib/wiringpi/serial.rb +8 -18
- data/lib/wiringpi/spi.rb +14 -11
- data/lib/wiringpi/watch.rb +24 -0
- metadata +160 -4
- data/lib/wiringpi/event.rb +0 -21
- data/lib/wiringpi/mcp23x17.rb +0 -31
@@ -0,0 +1,176 @@
|
|
1
|
+
/*
|
2
|
+
* piglow.c:
|
3
|
+
* Very simple demonstration of the PiGlow board.
|
4
|
+
* This uses the piGlow devLib.
|
5
|
+
*
|
6
|
+
* Copyright (c) 2013 Gordon Henderson.
|
7
|
+
***********************************************************************
|
8
|
+
* This file is part of wiringPi:
|
9
|
+
* https://projects.drogon.net/raspberry-pi/wiringpi/
|
10
|
+
*
|
11
|
+
* wiringPi is free software: you can redistribute it and/or modify
|
12
|
+
* it under the terms of the GNU Lesser General Public License as 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 <stdlib.h>
|
29
|
+
|
30
|
+
#ifndef TRUE
|
31
|
+
# define TRUE (1==1)
|
32
|
+
# define FALSE (!TRUE)
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#include <wiringPi.h>
|
36
|
+
#include <piGlow.h>
|
37
|
+
|
38
|
+
static void failUsage (void)
|
39
|
+
{
|
40
|
+
fprintf (stderr, "Usage examples:\n") ;
|
41
|
+
fprintf (stderr, " piglow off # All off\n") ;
|
42
|
+
fprintf (stderr, " piglow red 50 # Light the 3 red LEDs to 50%%\n") ;
|
43
|
+
fprintf (stderr, " colours are: red, yellow, orange, green, blue and white\n") ;
|
44
|
+
fprintf (stderr, " piglow all 75 # Light all to 75%%\n") ;
|
45
|
+
fprintf (stderr, " piglow leg 0 25 # Light leg 0 to 25%%\n") ;
|
46
|
+
fprintf (stderr, " piglow ring 3 100 # Light ring 3 to 100%%\n") ;
|
47
|
+
fprintf (stderr, " piglow led 2 5 100 # Light the single LED on Leg 2, ring 5 to 100%%\n") ;
|
48
|
+
|
49
|
+
exit (EXIT_FAILURE) ;
|
50
|
+
}
|
51
|
+
|
52
|
+
static int getPercent (char *typed)
|
53
|
+
{
|
54
|
+
int percent ;
|
55
|
+
|
56
|
+
percent = atoi (typed) ;
|
57
|
+
if ((percent < 0) || (percent > 100))
|
58
|
+
{
|
59
|
+
fprintf (stderr, "piglow: percent value out of range\n") ;
|
60
|
+
exit (EXIT_FAILURE) ;
|
61
|
+
}
|
62
|
+
return (percent * 255) / 100 ;
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
/*
|
67
|
+
* main:
|
68
|
+
* Our little demo prgoram
|
69
|
+
*********************************************************************************
|
70
|
+
*/
|
71
|
+
|
72
|
+
int main (int argc, char *argv [])
|
73
|
+
{
|
74
|
+
int percent ;
|
75
|
+
int ring, leg ;
|
76
|
+
|
77
|
+
// Always initialise wiringPi:
|
78
|
+
// Use the Sys method if you don't need to run as root
|
79
|
+
|
80
|
+
wiringPiSetupSys () ;
|
81
|
+
|
82
|
+
// Initialise the piGlow devLib
|
83
|
+
|
84
|
+
piGlowSetup (FALSE) ;
|
85
|
+
|
86
|
+
if (argc == 1)
|
87
|
+
failUsage () ;
|
88
|
+
|
89
|
+
if ((argc == 2) && (strcasecmp (argv [1], "off") == 0))
|
90
|
+
{
|
91
|
+
for (leg = 0 ; leg < 3 ; ++leg)
|
92
|
+
piGlowLeg (leg, 0) ;
|
93
|
+
return 0 ;
|
94
|
+
}
|
95
|
+
|
96
|
+
if (argc == 3)
|
97
|
+
{
|
98
|
+
percent = getPercent (argv [2]) ;
|
99
|
+
|
100
|
+
/**/ if (strcasecmp (argv [1], "red") == 0)
|
101
|
+
piGlowRing (PIGLOW_RED, percent) ;
|
102
|
+
else if (strcasecmp (argv [1], "yellow") == 0)
|
103
|
+
piGlowRing (PIGLOW_YELLOW, percent) ;
|
104
|
+
else if (strcasecmp (argv [1], "orange") == 0)
|
105
|
+
piGlowRing (PIGLOW_ORANGE, percent) ;
|
106
|
+
else if (strcasecmp (argv [1], "green") == 0)
|
107
|
+
piGlowRing (PIGLOW_GREEN, percent) ;
|
108
|
+
else if (strcasecmp (argv [1], "blue") == 0)
|
109
|
+
piGlowRing (PIGLOW_BLUE, percent) ;
|
110
|
+
else if (strcasecmp (argv [1], "white") == 0)
|
111
|
+
piGlowRing (PIGLOW_WHITE, percent) ;
|
112
|
+
else if (strcasecmp (argv [1], "all") == 0)
|
113
|
+
for (ring = 0 ; ring < 6 ; ++ring)
|
114
|
+
piGlowRing (ring, percent) ;
|
115
|
+
else
|
116
|
+
{
|
117
|
+
fprintf (stderr, "piglow: invalid colour\n") ;
|
118
|
+
exit (EXIT_FAILURE) ;
|
119
|
+
}
|
120
|
+
return 0 ;
|
121
|
+
}
|
122
|
+
|
123
|
+
if (argc == 4)
|
124
|
+
{
|
125
|
+
/**/ if (strcasecmp (argv [1], "leg") == 0)
|
126
|
+
{
|
127
|
+
leg = atoi (argv [2]) ;
|
128
|
+
if ((leg < 0) || (leg > 2))
|
129
|
+
{
|
130
|
+
fprintf (stderr, "piglow: leg value out of range\n") ;
|
131
|
+
exit (EXIT_FAILURE) ;
|
132
|
+
}
|
133
|
+
percent = getPercent (argv [3]) ;
|
134
|
+
piGlowLeg (leg, percent) ;
|
135
|
+
}
|
136
|
+
else if (strcasecmp (argv [1], "ring") == 0)
|
137
|
+
{
|
138
|
+
ring = atoi (argv [2]) ;
|
139
|
+
if ((ring < 0) || (ring > 5))
|
140
|
+
{
|
141
|
+
fprintf (stderr, "piglow: ring value out of range\n") ;
|
142
|
+
exit (EXIT_FAILURE) ;
|
143
|
+
}
|
144
|
+
percent = getPercent (argv [3]) ;
|
145
|
+
piGlowRing (ring, percent) ;
|
146
|
+
}
|
147
|
+
return 0 ;
|
148
|
+
}
|
149
|
+
|
150
|
+
if (argc == 5)
|
151
|
+
{
|
152
|
+
if (strcasecmp (argv [1], "led") != 0)
|
153
|
+
failUsage () ;
|
154
|
+
|
155
|
+
leg = atoi (argv [2]) ;
|
156
|
+
if ((leg < 0) || (leg > 2))
|
157
|
+
{
|
158
|
+
fprintf (stderr, "piglow: leg value out of range\n") ;
|
159
|
+
exit (EXIT_FAILURE) ;
|
160
|
+
}
|
161
|
+
ring = atoi (argv [3]) ;
|
162
|
+
if ((ring < 0) || (ring > 5))
|
163
|
+
{
|
164
|
+
fprintf (stderr, "piglow: ring value out of range\n") ;
|
165
|
+
exit (EXIT_FAILURE) ;
|
166
|
+
}
|
167
|
+
percent = getPercent (argv [4]) ;
|
168
|
+
piGlow1 (leg, ring, percent) ;
|
169
|
+
return 0 ;
|
170
|
+
}
|
171
|
+
|
172
|
+
failUsage () ;
|
173
|
+
return 0 ;
|
174
|
+
}
|
175
|
+
|
176
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*
|
2
|
+
* blink-thread.c:
|
3
|
+
* Standard "blink" program in wiringPi. Blinks an LED connected
|
4
|
+
* to the first GPIO pin.
|
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
|
+
// LED Pin - wiringPi pin 0 is BCM_GPIO 17.
|
30
|
+
|
31
|
+
#define LED 0
|
32
|
+
|
33
|
+
PI_THREAD (blinky)
|
34
|
+
{
|
35
|
+
for (;;)
|
36
|
+
{
|
37
|
+
digitalWrite (LED, HIGH) ; // On
|
38
|
+
delay (500) ; // mS
|
39
|
+
digitalWrite (LED, LOW) ; // Off
|
40
|
+
delay (500) ;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
int main (void)
|
46
|
+
{
|
47
|
+
printf ("Raspberry Pi blink\n") ;
|
48
|
+
|
49
|
+
wiringPiSetup () ;
|
50
|
+
pinMode (LED, OUTPUT) ;
|
51
|
+
|
52
|
+
piThreadCreate (blinky) ;
|
53
|
+
|
54
|
+
for (;;)
|
55
|
+
{
|
56
|
+
printf ("Hello, world\n") ;
|
57
|
+
delay (600) ;
|
58
|
+
}
|
59
|
+
|
60
|
+
return 0 ;
|
61
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/*
|
2
|
+
* blink.c:
|
3
|
+
* Standard "blink" program in wiringPi. Blinks an LED connected
|
4
|
+
* to the first GPIO pin.
|
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
|
+
// LED Pin - wiringPi pin 0 is BCM_GPIO 17.
|
30
|
+
|
31
|
+
#define LED 0
|
32
|
+
|
33
|
+
int main (void)
|
34
|
+
{
|
35
|
+
printf ("Raspberry Pi blink\n") ;
|
36
|
+
|
37
|
+
wiringPiSetup () ;
|
38
|
+
pinMode (LED, OUTPUT) ;
|
39
|
+
|
40
|
+
for (;;)
|
41
|
+
{
|
42
|
+
digitalWrite (LED, HIGH) ; // On
|
43
|
+
delay (500) ; // mS
|
44
|
+
digitalWrite (LED, LOW) ; // Off
|
45
|
+
delay (500) ;
|
46
|
+
}
|
47
|
+
return 0 ;
|
48
|
+
}
|
@@ -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
|
+
}
|