rad 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,24 @@
1
- == 0.0.1 2007-07-22
1
+ == 0.0.4 2007-07-24
2
2
 
3
3
  * 1 major enhancement:
4
- * Initial release
5
- * most features of the Arduino software library functional
6
- * experimental implementation of the serial interface
7
- * complete rake-based build, compile, and upload cycle
4
+ * serial_begin class method
5
+
6
+ == 0.0.3 2007-07-23
8
7
 
8
+ * 1 major enhancement:
9
+ * bug fix in blink helper method
10
+
9
11
  == 0.0.2 2007-07-23
10
12
 
11
13
  * 1 major enhancement:
12
14
  * blink helper method
13
15
 
14
- == 0.0.3 2007-07-23
16
+ == 0.0.1 2007-07-22
15
17
 
16
18
  * 1 major enhancement:
17
- * bug fix in blink helper method
19
+ * Initial release
20
+ * most features of the Arduino software library functional
21
+ * experimental implementation of the serial interface
22
+ * complete rake-based build, compile, and upload cycle
23
+
24
+
@@ -6,6 +6,7 @@ class ArduinoSketch
6
6
  def initialize
7
7
  @declarations = []
8
8
  @pin_modes = {:output => [], :input => []}
9
+ @other_setup = [] # specifically, Serial.begin
9
10
  @accessors = []
10
11
  @signatures = ["void blink();"]
11
12
  @helper_methods = <<-CODE
@@ -52,6 +53,12 @@ class ArduinoSketch
52
53
  @helper_methods << "\n#{st}\n"
53
54
  end
54
55
 
56
+ def serial_begin(opts={})
57
+ rate = opts[:rate] ? opts[:rate] : 9600
58
+ @other_setup << "Serial.begin(#{rate});"
59
+ end
60
+
61
+
55
62
  def compose_setup # also composes headers and signatures
56
63
  result = "#include <WProgram.h>\nvoid loop();\nvoid setup();"
57
64
  @signatures.each do |dec|
@@ -70,33 +77,32 @@ class ArduinoSketch
70
77
  result << "pinMode(#{value}, #{k.to_s.upcase});\n"
71
78
  end
72
79
  end
73
- result<<"}\n#{@helper_methods}"
80
+ result << @other_setup.join("\n")
81
+ result << "}\n#{@helper_methods}"
82
+ result << "\n#{serial_boilerplate}\n"
83
+
74
84
  end
75
85
 
76
86
  private
77
87
 
78
88
  def serial_boilerplate
79
89
  # TODO:
80
- # take away serial_begin and write a real class method
81
90
  # serial_print and serial_println need signatures for every combination of argument options
82
91
  <<-CODE
83
- void serial_begin(int speed){
84
- Serial.begin(speed)
85
- }
86
92
  int serial_available(){
87
- Serial.available() > 0
93
+ return (Serial.available() > 0);
88
94
  }
89
95
  int serial_read(){
90
- Serial.read()
96
+ return Serial.read();
91
97
  }
92
98
  void serial_flush(){
93
- Serial.flush()
99
+ return Serial.flush();
94
100
  }
95
- void serial_print()
96
- void serial_println()
97
- Serial.print(data)
98
- Serial.println(data)
99
101
  CODE
102
+ # void serial_print()
103
+ # void serial_println()
104
+ # Serial.print(data)
105
+ # Serial.println(data)
100
106
  end
101
107
 
102
108
  end
@@ -33,7 +33,7 @@ namespace :build do
33
33
  klass = @file_names.first.split(".").first.split("_").collect{|c| c.capitalize}.join("")
34
34
  eval File.read(@file_names.first)
35
35
  @loop = RubyToAnsiC.translate(constantize(klass), "loop")
36
- result = "#{@setup}\n#{@loop}"
36
+ result = "#{@setup}\n#{@loop}\n"
37
37
  name = @file_names.first.split(".").first
38
38
  File.open("#{name}/#{name}.cpp", "w"){|f| f << result}
39
39
  end
@@ -2,7 +2,7 @@ module Rad #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,6 +1,25 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
  require File.expand_path(File.dirname(__FILE__) + "/../../lib/rad/arduino_sketch.rb")
3
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
+
4
23
 
5
24
  context "Arduino Base" do
6
25
  setup do
@@ -33,7 +33,7 @@
33
33
  <h1>RAD</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rad"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/rad" class="numbers">0.0.3</a>
36
+ <a href="http://rubyforge.org/projects/rad" class="numbers">0.0.4</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;Ruby Arduino Development&#8217;</h1>
39
39
 
@@ -55,6 +55,11 @@
55
55
 
56
56
  <pre syntax="ruby">$ sudo gem install rad</pre>
57
57
 
58
+ <p><span class="caps">RAD</span> depends on <a href="http://rubyforge.org/projects/ruby2c/">Ruby2C</a>, which seems immune to the normal gem requirement techniques, so, if you don&#8217;t already have it, you&#8217;ll need to install that as well:</p>
59
+
60
+
61
+ <pre syntax="ruby">$ sudo gem install Ruby2C</pre>
62
+
58
63
  <h2>The basics</h2>
59
64
 
60
65
 
@@ -15,6 +15,10 @@ h2. Installing
15
15
 
16
16
  <pre syntax="ruby">$ sudo gem install rad</pre>
17
17
 
18
+ RAD depends on <a href="http://rubyforge.org/projects/ruby2c/">Ruby2C</a>, which seems immune to the normal gem requirement techniques, so, if you don't already have it, you'll need to install that as well:
19
+
20
+ <pre syntax="ruby">$ sudo gem install Ruby2C</pre>
21
+
18
22
  h2. The basics
19
23
 
20
24
  <code>$ rad my_sketch</code>
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: rad
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.3
7
- date: 2007-07-23 00:00:00 -07:00
6
+ version: 0.0.4
7
+ date: 2007-07-24 00:00:00 -07:00
8
8
  summary: 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.
9
9
  require_paths:
10
10
  - lib