madrona-rad 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +75 -0
- data/License.txt +282 -0
- data/Manifest.txt +47 -0
- data/README.rdoc +51 -0
- data/Rakefile +139 -0
- data/bin/rad +197 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +267 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +64 -0
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +254 -0
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +57 -0
- data/lib/libraries/Servo/Servo.cpp +152 -0
- data/lib/libraries/Servo/Servo.h +33 -0
- data/lib/libraries/Servo/keywords.txt +25 -0
- data/lib/plugins/debounce.rb +116 -0
- data/lib/plugins/debug_output_to_lcd.rb +71 -0
- data/lib/plugins/input_output_state.rb +84 -0
- data/lib/plugins/mem_test.rb +37 -0
- data/lib/plugins/servo_pulse.rb +31 -0
- data/lib/plugins/servo_setup.rb +86 -0
- data/lib/plugins/smoother.rb +54 -0
- data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
- data/lib/rad/arduino_plugin.rb +202 -0
- data/lib/rad/arduino_sketch.rb +952 -0
- data/lib/rad/generators/makefile/makefile.erb +243 -0
- data/lib/rad/generators/makefile/makefile.rb +39 -0
- data/lib/rad/init.rb +12 -0
- data/lib/rad/rad_processor.rb +66 -0
- data/lib/rad/rad_rewriter.rb +94 -0
- data/lib/rad/tasks/build_and_make.rake +159 -0
- data/lib/rad/tasks/rad.rb +2 -0
- data/lib/rad/todo.txt +13 -0
- data/lib/rad/version.rb +9 -0
- data/lib/rad.rb +5 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- data/spec/models/arduino_sketch_spec.rb +82 -0
- data/spec/models/spec_helper.rb +2 -0
- data/spec/spec.opts +1 -0
- data/website/examples/assembler_test.rb.html +73 -0
- data/website/examples/gps_reader.rb.html +39 -0
- data/website/examples/hello_world.rb.html +38 -0
- data/website/examples/serial_motor.rb.html +41 -0
- data/website/index.html +177 -0
- data/website/index.txt +64 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +169 -0
- data/website/template.rhtml +48 -0
- metadata +120 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../lib/rad/arduino_sketch.rb")
|
3
|
+
|
4
|
+
context "Arduino#serial_begin" do
|
5
|
+
setup do
|
6
|
+
@as = ArduinoSketch.new
|
7
|
+
end
|
8
|
+
|
9
|
+
specify "should default baud_rate to 9600" do
|
10
|
+
@as.serial_begin
|
11
|
+
@as.instance_variable_get("@other_setup").should include("Serial.begin(9600);")
|
12
|
+
end
|
13
|
+
specify "should set an alternate baud_rate if told" do
|
14
|
+
@as.serial_begin :rate => 2400
|
15
|
+
@as.instance_variable_get("@other_setup").should include("Serial.begin(2400);")
|
16
|
+
end
|
17
|
+
specify "should add the correct function call to the composed_setup" do
|
18
|
+
@as.serial_begin
|
19
|
+
@as.compose_setup.should match(Regexp.new(Regexp.escape("Serial.begin(9600);")))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
context "Arduino Base" do
|
25
|
+
setup do
|
26
|
+
@as = ArduinoSketch.new
|
27
|
+
end
|
28
|
+
|
29
|
+
specify "output_pin method without :as arg. should add the pin to the pin_mode hash's output list and leave the declarations alone" do
|
30
|
+
@as.output_pin 1
|
31
|
+
@as.instance_variable_get("@declarations").first.should == nil
|
32
|
+
@as.instance_variable_get("@pin_modes")[:output].should include(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "output_pin method with :as arg. should add the pin to the pin_mode hash's output list write the appropriate declaration and accessor" do
|
36
|
+
@as.output_pin 3, :as => :led
|
37
|
+
@as.instance_variable_get("@declarations").first.should == "int _led = 3;"
|
38
|
+
@as.instance_variable_get("@accessors").first.should == "int led(){\nreturn _led;\n}"
|
39
|
+
@as.instance_variable_get("@pin_modes")[:output].should include(3)
|
40
|
+
end
|
41
|
+
|
42
|
+
specify "output_pins method should add the pin to the pin_mode hash's output list and leave the declarations and accessors alone" do
|
43
|
+
@as.output_pins [5,4,3,2]
|
44
|
+
@as.instance_variable_get("@pin_modes")[:output].should include(5)
|
45
|
+
@as.instance_variable_get("@pin_modes")[:output].should include(4)
|
46
|
+
@as.instance_variable_get("@pin_modes")[:output].should include(3)
|
47
|
+
@as.instance_variable_get("@pin_modes")[:output].should include(2)
|
48
|
+
@as.instance_variable_get("@declarations").first.should == nil
|
49
|
+
@as.instance_variable_get("@accessors").first.should == nil
|
50
|
+
end
|
51
|
+
|
52
|
+
specify "input_pin method with :as arg. should add the pin to the pin_mode hash's input list write the appropriate declaration and accessor" do
|
53
|
+
@as.input_pin 1, :as => :knob
|
54
|
+
@as.instance_variable_get("@declarations").first.should == "int _knob = 1;"
|
55
|
+
@as.instance_variable_get("@accessors").first.should == "int knob(){\nreturn _knob;\n}"
|
56
|
+
@as.instance_variable_get("@pin_modes")[:input].should include(1)
|
57
|
+
end
|
58
|
+
|
59
|
+
specify "input_pins method should add the pins to the pin_mode hash's input list and leave the declarations and accessors alone" do
|
60
|
+
@as.input_pins [5,4,3,2]
|
61
|
+
@as.instance_variable_get("@pin_modes")[:input].should include(5)
|
62
|
+
@as.instance_variable_get("@pin_modes")[:input].should include(4)
|
63
|
+
@as.instance_variable_get("@pin_modes")[:input].should include(3)
|
64
|
+
@as.instance_variable_get("@pin_modes")[:input].should include(2)
|
65
|
+
@as.instance_variable_get("@declarations").first.should == nil
|
66
|
+
@as.instance_variable_get("@accessors").first.should == nil
|
67
|
+
end
|
68
|
+
|
69
|
+
specify "compose_setup should append each appropriate pinMode statement and :as accessor to the setup_function string with a newline" do
|
70
|
+
@as.output_pins [1, 2]
|
71
|
+
@as.input_pin 3, :as => :button
|
72
|
+
|
73
|
+
result = @as.send :compose_setup
|
74
|
+
|
75
|
+
result.should match(Regexp.new(Regexp.escape("pinMode(1, OUTPUT);\n")))
|
76
|
+
result.should match(Regexp.new(Regexp.escape("pinMode(2, OUTPUT);\n")))
|
77
|
+
result.should match(Regexp.new(Regexp.escape("pinMode(3, INPUT);\n")))
|
78
|
+
result.should match(Regexp.new(Regexp.escape("int _button = 3;\n")))
|
79
|
+
result.should match(Regexp.new(Regexp.escape("int button(){\nreturn _button;\n}")))
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>assembler_test.rb.html</title
|
4
|
+
<style type="text/css">
|
5
|
+
|
6
|
+
.ruby .normal {}
|
7
|
+
.ruby .comment { color: #888; font-style: italic; }
|
8
|
+
.ruby .keyword { color: #A00; font-weight: bold; }
|
9
|
+
.ruby .method { color: #077; }
|
10
|
+
.ruby .class { color: #074; }
|
11
|
+
.ruby .module { color: #050; }
|
12
|
+
.ruby .punct { color: #447; font-weight: bold; }
|
13
|
+
.ruby .symbol { color: #099; }
|
14
|
+
.ruby .string { color: #944; }
|
15
|
+
.ruby .char { color: #F07; }
|
16
|
+
.ruby .ident { color: #004; }
|
17
|
+
.ruby .constant { color: #07F; }
|
18
|
+
.ruby .regex { color: #B66; }
|
19
|
+
.ruby .number { color: #D55; }
|
20
|
+
.ruby .attribute { color: #377; }
|
21
|
+
.ruby .global { color: #3B7; }
|
22
|
+
.ruby .expr { color: #227; }
|
23
|
+
</style>
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
<pre class="ruby">
|
27
|
+
<pre><span class="comment"># Hardware: Connect to serial output with screen:</span>
|
28
|
+
<span class="comment"># $ screen /dev/tty/path.to.your.usb 9600</span>
|
29
|
+
|
30
|
+
<span class="keyword">class </span><span class="class">AssemblerTest</span> <span class="punct"><</span> <span class="constant">ArduinoSketch</span>
|
31
|
+
<span class="ident">vars</span> <span class="symbol">:a</span> <span class="punct">=></span> <span class="number">10</span><span class="punct">,</span> <span class="symbol">:b</span> <span class="punct">=></span> <span class="number">4</span>
|
32
|
+
<span class="ident">serial_begin</span>
|
33
|
+
|
34
|
+
<span class="keyword">def </span><span class="method">loop</span>
|
35
|
+
<span class="ident">serial_println</span> <span class="ident">product</span><span class="punct">(</span><span class="ident">a</span><span class="punct">,</span><span class="ident">b</span><span class="punct">)</span>
|
36
|
+
<span class="keyword">end</span>
|
37
|
+
|
38
|
+
<span class="ident">assembler</span><span class="punct">(</span> <span class="symbol">:product</span><span class="punct">,</span> <span class="punct">"</span><span class="string">int product(int a, int b);</span><span class="punct">",</span>
|
39
|
+
<span class="punct"><<-</span><span class="constant">CODE</span><span class="string">
|
40
|
+
product:
|
41
|
+
mov r18,r24 ; move a to another register
|
42
|
+
ldi r24,0 ; clear running sum, used to coalesce product
|
43
|
+
ldi r25,0 ; sum = 0
|
44
|
+
|
45
|
+
.loop:
|
46
|
+
tst r18 ; is a = 0? if so, we're done
|
47
|
+
breq .end
|
48
|
+
|
49
|
+
mov r19,r18 ; copy a
|
50
|
+
andi r19,1 ; is a % 2 == 0
|
51
|
+
breq .skip
|
52
|
+
|
53
|
+
add r24,r22 ; add b to sum
|
54
|
+
adc r25,r23
|
55
|
+
|
56
|
+
.skip:
|
57
|
+
lsr r18 ; divide a by 2
|
58
|
+
|
59
|
+
clc
|
60
|
+
rol r22 ; multiply b by 2
|
61
|
+
rol r23
|
62
|
+
rjmp .loop
|
63
|
+
|
64
|
+
.end:
|
65
|
+
ret
|
66
|
+
.size product, .-product
|
67
|
+
</span><span class="constant"> CODE</span>
|
68
|
+
<span class="punct">)</span>
|
69
|
+
<span class="keyword">end</span>
|
70
|
+
</pre>
|
71
|
+
</pre>
|
72
|
+
</body>
|
73
|
+
</html>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>gps_reader.rb.html</title
|
4
|
+
<style type="text/css">
|
5
|
+
|
6
|
+
.ruby .normal {}
|
7
|
+
.ruby .comment { color: #888; font-style: italic; }
|
8
|
+
.ruby .keyword { color: #A00; font-weight: bold; }
|
9
|
+
.ruby .method { color: #077; }
|
10
|
+
.ruby .class { color: #074; }
|
11
|
+
.ruby .module { color: #050; }
|
12
|
+
.ruby .punct { color: #447; font-weight: bold; }
|
13
|
+
.ruby .symbol { color: #099; }
|
14
|
+
.ruby .string { color: #944; }
|
15
|
+
.ruby .char { color: #F07; }
|
16
|
+
.ruby .ident { color: #004; }
|
17
|
+
.ruby .constant { color: #07F; }
|
18
|
+
.ruby .regex { color: #B66; }
|
19
|
+
.ruby .number { color: #D55; }
|
20
|
+
.ruby .attribute { color: #377; }
|
21
|
+
.ruby .global { color: #3B7; }
|
22
|
+
.ruby .expr { color: #227; }
|
23
|
+
</style>
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
<pre class="ruby">
|
27
|
+
<pre><span class="keyword">class </span><span class="class">GpsReader</span> <span class="punct"><</span> <span class="constant">ArduinoSketch</span>
|
28
|
+
<span class="ident">output_pin</span> <span class="number">13</span><span class="punct">,</span> <span class="symbol">:as</span> <span class="punct">=></span> <span class="symbol">:led</span>
|
29
|
+
<span class="ident">software_serial</span> <span class="number">6</span><span class="punct">,</span> <span class="number">7</span><span class="punct">,</span> <span class="symbol">:as</span> <span class="punct">=></span> <span class="symbol">:gps</span>
|
30
|
+
<span class="ident">serial_begin</span>
|
31
|
+
|
32
|
+
<span class="keyword">def </span><span class="method">loop</span>
|
33
|
+
<span class="ident">digitalWrite</span><span class="punct">(</span><span class="ident">led</span><span class="punct">,</span> <span class="constant">true</span><span class="punct">)</span>
|
34
|
+
<span class="ident">serial_print</span><span class="punct">(</span><span class="ident">gps</span><span class="punct">.</span><span class="ident">read</span><span class="punct">)</span>
|
35
|
+
<span class="keyword">end</span>
|
36
|
+
<span class="keyword">end</span></pre>
|
37
|
+
</pre>
|
38
|
+
</body>
|
39
|
+
</html>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>hello_world.rb.html</title
|
4
|
+
<style type="text/css">
|
5
|
+
|
6
|
+
.ruby .normal {}
|
7
|
+
.ruby .comment { color: #888; font-style: italic; }
|
8
|
+
.ruby .keyword { color: #A00; font-weight: bold; }
|
9
|
+
.ruby .method { color: #077; }
|
10
|
+
.ruby .class { color: #074; }
|
11
|
+
.ruby .module { color: #050; }
|
12
|
+
.ruby .punct { color: #447; font-weight: bold; }
|
13
|
+
.ruby .symbol { color: #099; }
|
14
|
+
.ruby .string { color: #944; }
|
15
|
+
.ruby .char { color: #F07; }
|
16
|
+
.ruby .ident { color: #004; }
|
17
|
+
.ruby .constant { color: #07F; }
|
18
|
+
.ruby .regex { color: #B66; }
|
19
|
+
.ruby .number { color: #D55; }
|
20
|
+
.ruby .attribute { color: #377; }
|
21
|
+
.ruby .global { color: #3B7; }
|
22
|
+
.ruby .expr { color: #227; }
|
23
|
+
</style>
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
<pre class="ruby">
|
27
|
+
<pre><span class="comment"># Hardware: LED connected on pin 7</span>
|
28
|
+
|
29
|
+
<span class="keyword">class </span><span class="class">HelloWorld</span> <span class="punct"><</span> <span class="constant">ArduinoSketch</span>
|
30
|
+
<span class="ident">output_pin</span> <span class="number">7</span><span class="punct">,</span> <span class="symbol">:as</span> <span class="punct">=></span> <span class="symbol">:led</span>
|
31
|
+
<span class="keyword">def </span><span class="method">loop</span>
|
32
|
+
<span class="ident">blink</span> <span class="ident">led</span><span class="punct">,</span> <span class="number">500</span>
|
33
|
+
<span class="keyword">end</span>
|
34
|
+
<span class="keyword">end</span>
|
35
|
+
</pre>
|
36
|
+
</pre>
|
37
|
+
</body>
|
38
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>serial_motor.rb.html</title
|
4
|
+
<style type="text/css">
|
5
|
+
|
6
|
+
.ruby .normal {}
|
7
|
+
.ruby .comment { color: #888; font-style: italic; }
|
8
|
+
.ruby .keyword { color: #A00; font-weight: bold; }
|
9
|
+
.ruby .method { color: #077; }
|
10
|
+
.ruby .class { color: #074; }
|
11
|
+
.ruby .module { color: #050; }
|
12
|
+
.ruby .punct { color: #447; font-weight: bold; }
|
13
|
+
.ruby .symbol { color: #099; }
|
14
|
+
.ruby .string { color: #944; }
|
15
|
+
.ruby .char { color: #F07; }
|
16
|
+
.ruby .ident { color: #004; }
|
17
|
+
.ruby .constant { color: #07F; }
|
18
|
+
.ruby .regex { color: #B66; }
|
19
|
+
.ruby .number { color: #D55; }
|
20
|
+
.ruby .attribute { color: #377; }
|
21
|
+
.ruby .global { color: #3B7; }
|
22
|
+
.ruby .expr { color: #227; }
|
23
|
+
</style>
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
<pre class="ruby">
|
27
|
+
<pre><span class="comment"># Hardware: motor control circuit (i.e. TIP-120 control pin)</span>
|
28
|
+
<span class="comment"># connected at pin 7.</span>
|
29
|
+
<span class="comment"># Demo: http://www.youtube.com/watch?v=7OguEBfdTe0</span>
|
30
|
+
|
31
|
+
<span class="keyword">class </span><span class="class">SerialMotor</span> <span class="punct"><</span> <span class="constant">ArduinoSketch</span>
|
32
|
+
<span class="ident">output_pin</span> <span class="number">7</span><span class="punct">,</span> <span class="symbol">:as</span> <span class="punct">=></span> <span class="symbol">:motor</span>
|
33
|
+
<span class="ident">serial_begin</span>
|
34
|
+
|
35
|
+
<span class="keyword">def </span><span class="method">loop</span>
|
36
|
+
<span class="ident">digitalWrite</span><span class="punct">(</span><span class="ident">motor</span><span class="punct">,</span> <span class="ident">serial_read</span><span class="punct">)</span> <span class="keyword">if</span> <span class="ident">serial_available</span>
|
37
|
+
<span class="keyword">end</span>
|
38
|
+
<span class="keyword">end</span></pre>
|
39
|
+
</pre>
|
40
|
+
</body>
|
41
|
+
</html>
|
data/website/index.html
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<title>
|
8
|
+
RAD
|
9
|
+
</title>
|
10
|
+
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
+
<style>
|
12
|
+
.movie {float: left; margin-right: 10px; margin-bottom: 10px;}
|
13
|
+
</style>
|
14
|
+
<script type="text/javascript">
|
15
|
+
window.onload = function() {
|
16
|
+
settings = {
|
17
|
+
tl: { radius: 10 },
|
18
|
+
tr: { radius: 10 },
|
19
|
+
bl: { radius: 10 },
|
20
|
+
br: { radius: 10 },
|
21
|
+
antiAlias: true,
|
22
|
+
autoPad: true,
|
23
|
+
validTags: ["div"]
|
24
|
+
}
|
25
|
+
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
+
versionBox.applyCornersToAll();
|
27
|
+
}
|
28
|
+
</script>
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="main">
|
32
|
+
<div id="metadata">
|
33
|
+
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rad"; return false'>
|
34
|
+
<p>Get Version</p>
|
35
|
+
<a href="http://rubyforge.org/projects/rad" class="numbers">0.2.2</a>
|
36
|
+
</div>
|
37
|
+
<div id="buy-arduino">
|
38
|
+
|
39
|
+
<a href="http://www.sparkfun.com/commerce/product_info.php?products_id=666">
|
40
|
+
|
41
|
+
<img src="http://www.sparkfun.com/commerce/images/ArduinoUSBBoard-01-M.jpg" />
|
42
|
+
</a>
|
43
|
+
<h4><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=666">Buy an Arduino from Sparkfun</a></h4>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
<h1>RAD</h1>
|
48
|
+
<h1>→ ‘Ruby Arduino Development’</h1>
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<h2>What?</h2>
|
54
|
+
|
55
|
+
|
56
|
+
<p><span class="caps">RAD</span> is a framework for programming the Arduino physcial computing platform using Ruby. <span class="caps">RAD</span> converts Ruby scripts written using a set of Rails-like conventions and helpers into C source code which can be compiled and run on the Arduino microcontroller. It also provides a set of Rake tasks for automating the compilation and upload process.</p>
|
57
|
+
|
58
|
+
<br style="clear:both" />
|
59
|
+
|
60
|
+
<h2>Demo: 'Hello World'</h2>
|
61
|
+
|
62
|
+
<p>Here's a basic demo of <span class="caps">RAD</span> in action. In this movie, we'll write, compile, and upload the universal physical computing 'Hello World': a single flashing LED.
|
63
|
+
<div class="movie"><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/AKbHcMaC_cA&hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/AKbHcMaC_cA&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></div>
|
64
|
+
<em>Note: This movie was made using an old version of the Arduino board which required a hardware reset before being able to accept a new sketch. More recent versions of the board don't have this requirement and hence as of version 0.2.0, <span class="caps">RAD</span> no longer prompts for reset when running 'rake make:upload' (thought the option is still available for older boards.)</em>
|
65
|
+
</p>
|
66
|
+
<br style="clear:both" />
|
67
|
+
<h2>Why?</h2>
|
68
|
+
|
69
|
+
|
70
|
+
<p>While duplicating the functionality of the well-designed Arduino software interface in Ruby may seem like an odd or redundant goal, <span class="caps">RAD</span> has further ambitions! Bootstrapping the ability to write microcontroller code in a high level dynamic language like Ruby could greatly ease the creation of all the luxurious development aids the users of such a language have come to expect: developer testing, platform independence, easy metaprogramming, etc.</p>
|
71
|
+
|
72
|
+
|
73
|
+
<h2>Installing</h2>
|
74
|
+
|
75
|
+
|
76
|
+
<p><code>$ sudo gem install rad</code></p>
|
77
|
+
|
78
|
+
|
79
|
+
<p>You’ll also need to have the Arduino environment installed, which you can get from <a href="http://www.arduino.cc/en/Main/Software">the Arduino website</a>. <span class="caps">RAD</span> currently requires Arduino 0010, but we try to keep it up-to-date with new Arduino releases.</p>
|
80
|
+
|
81
|
+
|
82
|
+
<h2>The Basics</h2>
|
83
|
+
|
84
|
+
|
85
|
+
<p><code>$ rad my_sketch</code></p>
|
86
|
+
|
87
|
+
|
88
|
+
<p>This command will create a new <span class="caps">RAD</span> project directory (my_sketch/) inside of the current directory that contains a blank script in which you can write your own <span class="caps">RAD</span> code, as well as a full install of the <span class="caps">RAD</span> support infrastructure (in vendor/). A sample ‘hello world’ script in <span class="caps">RAD</span> will look like this:</p>
|
89
|
+
|
90
|
+
|
91
|
+
<pre syntax="ruby">
|
92
|
+
class MySketch < ArduinoSketch
|
93
|
+
output_pin 7, :as => :led
|
94
|
+
def loop
|
95
|
+
blink led, 500
|
96
|
+
end
|
97
|
+
end
|
98
|
+
</pre>
|
99
|
+
|
100
|
+
<p>Once your code is written, your relevant local configuration properly setup in <code>config/hardware.rb</code> and <code>config/software.rb</code>, and an Arduino with the corresponding circuit (a 220ohm resistor and an <span class="caps">LED</span> wired in series between Arduino pin 7 and ground) is connected to your computer via serial, run:</p>
|
101
|
+
|
102
|
+
|
103
|
+
<p><code>$ rake make:upload</code></p>
|
104
|
+
|
105
|
+
|
106
|
+
<p>This will:</p>
|
107
|
+
|
108
|
+
|
109
|
+
<ul>
|
110
|
+
<li>generate the correct Arduino C++ code from your sketch</li>
|
111
|
+
<li>dynamically prepare a localized version of the default Arduino Makefile</li>
|
112
|
+
<li>compile your sketch</li>
|
113
|
+
<li>prompt you to hit the reset button on your Arduino (if necessary!)</li>
|
114
|
+
<li>upload your compiled binary onto your Arduino</li>
|
115
|
+
</ul>
|
116
|
+
|
117
|
+
|
118
|
+
<h2>Documentation and The Arduino <span class="caps">API</span></h2>
|
119
|
+
|
120
|
+
|
121
|
+
<p>Most of <a href="http://www.arduino.cc/en/Reference/HomePage">the Arduino software <span class="caps">API</span></a> should be working correctly at this point. Documentation for RAD's version of things and details about usage of the wider Arduino API are available in the <a href="http://rad.rubyforge.org/rdoc">RAD rDocs</a>.</p>
|
122
|
+
|
123
|
+
<h2>Demo: Serial Communication</h2>
|
124
|
+
<p>
|
125
|
+
To demonstrate some of the more advanced features of <span class="caps">RAD</span>, here's a movie showing how to program the Arduino to listen to serial communication from a computer.
|
126
|
+
<div class="movie">
|
127
|
+
<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/7OguEBfdTe0&hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/7OguEBfdTe0&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object> </div>
|
128
|
+
|
129
|
+
<em>Note: The same comment from above applies here about the hardware reset. Also, extra points are available if you recognize the logo on the flag in the video.</em>
|
130
|
+
</p>
|
131
|
+
<br style="clear:both" />
|
132
|
+
|
133
|
+
<p>For more examples of <span class="caps">RAD</span> in action, see <a href="http://rad.rubyforge.org/examples">the RAD example directory</a>.</p>
|
134
|
+
<h2><span class="caps">RAD</span> Needs You!</h2>
|
135
|
+
|
136
|
+
|
137
|
+
<p>All the many discipline-crossing skills required for a project like <span class="caps">RAD</span> make for lots of opportunities to help out: Have you written lots of sketches exploring the obscure depths of the Arduino library? Do you run the Arduino development tool chain on an obscure (i.e., non-OS X) platform? Do you develop for other <span class="caps">AVR</span> or <span class="caps">PIC</span> microcontrollers? Are you a C/C++ ninja? Or even C/C++ competent?</p>
|
138
|
+
|
139
|
+
|
140
|
+
<p>There’s lots to do.</p>
|
141
|
+
|
142
|
+
|
143
|
+
<p>If you’re looking for a place to dive in and don’t know quite where, <a href="mailto:ruby-arduino-development@googlegroups.com">email the RAD Google Group</a>; we're friendly! If you want to start by taking a log at the code, the trunk repository is <code>svn://rubyforge.org/var/svn/rad/trunk</code> for anonymous access.</p>
|
144
|
+
|
145
|
+
|
146
|
+
<h2>License</h2>
|
147
|
+
|
148
|
+
|
149
|
+
<p>This code is free to use under the terms of the <span class="caps">GPL</span> 2.0 license, just like the Arduino software library itself.</p>
|
150
|
+
|
151
|
+
|
152
|
+
<h2>Contact</h2>
|
153
|
+
|
154
|
+
|
155
|
+
<p>Comments, questions, heckles, attacks, praises, and, (most especially) patches and contributions are welcome! Send email to <a href="mailto:ruby-arduino-development@googlegroups.com">the RAD mailing list</a>.</p>
|
156
|
+
|
157
|
+
<h2>Who</h2>
|
158
|
+
<p><a href="http://urbanhonking.com/ideasfordozens">Greg Borenstein</a> is RAD's original author and main maintainer with significant contributions from <a href="http://blog.bleything.net/">Ben Bleything</a> and <a href="http://www.wulfden.org/TheShoppe.shtml">Brian Riley</a>, patches from Scott Windsor and David Michael, and the support of the <a href="http://groups.google.com/group/ruby-arduino-development">the Ruby Arduino Development Google Group</a>.</p>
|
159
|
+
|
160
|
+
<p class="coda">
|
161
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 18th November 2007<br>
|
162
|
+
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
163
|
+
</p>
|
164
|
+
</div>
|
165
|
+
|
166
|
+
<!-- insert site tracking codes here, like Google Urchin -->
|
167
|
+
<script type="text/javascript">
|
168
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
169
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
170
|
+
</script>
|
171
|
+
<script type="text/javascript">
|
172
|
+
var pageTracker = _gat._getTracker("UA-3885443-1");
|
173
|
+
pageTracker._initData();
|
174
|
+
pageTracker._trackPageview();
|
175
|
+
</script>
|
176
|
+
</body>
|
177
|
+
</html>
|
data/website/index.txt
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
h1. RAD
|
2
|
+
|
3
|
+
h1. → 'Ruby Arduino Development'
|
4
|
+
|
5
|
+
h2. What?
|
6
|
+
|
7
|
+
RAD is a framework for programming the Arduino physcial computing platform using Ruby. RAD converts Ruby scripts written using a set of Rails-like conventions and helpers into C source code which can be compiled and run on the Arduino microcontroller. It also provides a set of Rake tasks for automating the compilation and upload process.
|
8
|
+
|
9
|
+
h2. Why?
|
10
|
+
|
11
|
+
While duplicating the functionality of the well-designed Arduino software interface in Ruby may seem like an odd or redundant goal, RAD has further ambitions! Bootstrapping the ability to write microcontroller code in a high level dynamic language like Ruby could greatly ease the creation of all the luxurious development aids the users of such a language have come to expect: developer testing, platform independence, easy metaprogramming, etc.
|
12
|
+
|
13
|
+
h2. Installing
|
14
|
+
|
15
|
+
@$ sudo gem install rad@
|
16
|
+
|
17
|
+
You'll also need to have the Arduino environment installed, which you can get from "the Arduino website":http://www.arduino.cc/en/Main/Software. RAD currently requires Arduino 0010, but we try to keep it up-to-date with new Arduino releases.
|
18
|
+
|
19
|
+
h2. The Basics
|
20
|
+
|
21
|
+
@$ rad my_sketch@
|
22
|
+
|
23
|
+
This command will create a new RAD project directory (my_sketch/) inside of the current directory that contains a blank script in which you can write your own RAD code, as well as a full install of the RAD support infrastructure (in vendor/). A sample 'hello world' script in RAD will look like this:
|
24
|
+
|
25
|
+
<pre syntax="ruby">
|
26
|
+
class MySketch < ArduinoSketch
|
27
|
+
output_pin 7, :as => :led
|
28
|
+
def loop
|
29
|
+
blink led, 500
|
30
|
+
end
|
31
|
+
end
|
32
|
+
</pre>
|
33
|
+
|
34
|
+
Once your code is written, your relevant local configuration properly setup in @config/hardware.rb@ and @config/software.rb@, and an Arduino with the corresponding circuit (a 220ohm resistor and an LED wired in series between Arduino pin 7 and ground) is connected to your computer via serial, run:
|
35
|
+
|
36
|
+
@$ rake make:upload@
|
37
|
+
|
38
|
+
This will:
|
39
|
+
|
40
|
+
* generate the correct Arduino C++ code from your sketch
|
41
|
+
* dynamically prepare a localized version of the default Arduino Makefile
|
42
|
+
* compile your sketch
|
43
|
+
* prompt you to hit the reset button on your Arduino (if necessary!)
|
44
|
+
* upload your compiled binary onto your Arduino
|
45
|
+
|
46
|
+
h2. The Arduino API
|
47
|
+
|
48
|
+
With the exception of the still-experimental Serial interface, most of <a href="http://www.arduino.cc/en/Reference/HomePage">the Arduino software API</a> should be working correctly at this point. Documentation for the Ruby versions of the methods is forthcoming, but it is mostly what you'd expect: methods with identical names and arguments to their Arduino counterparts with the exception of using 'true' and 'false' for HIGH and LOW.
|
49
|
+
|
50
|
+
h2. RAD Needs You!
|
51
|
+
|
52
|
+
All the many discipline-crossing skills required for a project like RAD make for lots of opportunities to help out: Have you written lots of sketches exploring the obscure depths of the Arduino library? Do you run the Arduino development tool chain on an obscure (i.e., non-OS X) platform? Do you develop for other AVR or PIC microcontrollers? Are you a C/C++ ninja? Or even C/C++ competent?
|
53
|
+
|
54
|
+
There's lots to do.
|
55
|
+
|
56
|
+
If you're looking for a place to dive in and don't know quite where, "email Greg":mailto:greg@grabb.it. If you want to start by taking a log at the code, the trunk repository is @svn://rubyforge.org/var/svn/rad/trunk@ for anonymous access.
|
57
|
+
|
58
|
+
h2. License
|
59
|
+
|
60
|
+
This code is free to use under the terms of the GPL 2.0 license, just like the Arduino software library itself.
|
61
|
+
|
62
|
+
h2. Contact
|
63
|
+
|
64
|
+
Comments, questions, heckles, attacks, praises, and, (most especially) patches and contributions are welcome! Send email to "Greg Borenstein":mailto:greg@grabb.it.
|