rad 0.2.2 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/History.txt +34 -0
  2. data/Manifest.txt +113 -7
  3. data/{README.txt → README.rdoc} +17 -5
  4. data/Rakefile +3 -0
  5. data/bin/rad +106 -1
  6. data/lib/examples/add_hysteresis.rb +13 -0
  7. data/lib/examples/basic_blink.rb +10 -0
  8. data/lib/examples/blink_m_address_assignment.rb +104 -0
  9. data/lib/examples/blink_m_hello.rb +14 -0
  10. data/lib/examples/blink_m_multi.rb +61 -0
  11. data/lib/examples/blink_with_serial.rb +16 -0
  12. data/lib/examples/configure_pa_lcd_boot.rb +91 -0
  13. data/lib/examples/debounce_methods.rb +49 -0
  14. data/lib/examples/external_variable_fu.rb +26 -0
  15. data/lib/examples/external_variables.rb +32 -0
  16. data/lib/examples/first_sound.rb +23 -0
  17. data/lib/examples/frequency_generator.rb +30 -0
  18. data/lib/examples/hello_array.rb +48 -0
  19. data/lib/examples/hello_array2.rb +79 -0
  20. data/lib/examples/hello_array_eeprom.rb +59 -0
  21. data/lib/examples/hello_clock.rb +84 -0
  22. data/lib/examples/hello_eeprom.rb +51 -0
  23. data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
  24. data/lib/examples/hello_format_print.rb +94 -0
  25. data/lib/examples/hello_lcd_charset.rb +75 -0
  26. data/lib/examples/hello_pa_lcd.rb +59 -0
  27. data/lib/examples/hello_servos.rb +88 -0
  28. data/lib/examples/hello_spectra_sound.rb +38 -0
  29. data/lib/examples/hello_world.rb +11 -0
  30. data/lib/examples/hello_xbee.rb +12 -0
  31. data/lib/examples/hysteresis_duel.rb +39 -0
  32. data/lib/examples/i2c_with_clock_chip.rb +124 -0
  33. data/lib/examples/midi_beat_box.rb +86 -0
  34. data/lib/examples/midi_scales.rb +94 -0
  35. data/lib/examples/motor_knob.rb +30 -0
  36. data/lib/examples/servo_buttons.rb +23 -0
  37. data/lib/examples/servo_calibrate_continuous.rb +92 -0
  38. data/lib/examples/servo_throttle.rb +40 -0
  39. data/lib/examples/sparkfun_lcd.rb +48 -0
  40. data/lib/examples/spectra_soft_pot.rb +34 -0
  41. data/lib/examples/times_method.rb +8 -0
  42. data/lib/examples/toggle.rb +10 -0
  43. data/lib/examples/twitter.rb +57 -0
  44. data/lib/examples/two_wire.rb +14 -0
  45. data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
  46. data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
  47. data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
  48. data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
  49. data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
  50. data/lib/libraries/DS1307/DS1307.cpp +162 -0
  51. data/lib/libraries/DS1307/DS1307.h +66 -0
  52. data/lib/libraries/{SWSerLCDpa → DS1307}/keywords.txt +1 -1
  53. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
  54. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
  55. data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
  56. data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
  57. data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
  58. data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
  59. data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
  60. data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
  61. data/lib/libraries/LoopTimer/keywords.txt +27 -0
  62. data/lib/libraries/OneWire/OneWire.cpp +194 -0
  63. data/lib/libraries/OneWire/OneWire.h +63 -0
  64. data/lib/libraries/OneWire/keywords.txt +35 -0
  65. data/lib/libraries/OneWire/readme.txt +13 -0
  66. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +93 -47
  67. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +16 -9
  68. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
  69. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
  70. data/lib/libraries/Servo/Servo.cpp +192 -0
  71. data/lib/libraries/Servo/Servo.h +61 -0
  72. data/lib/libraries/Stepper/Stepper.cpp +220 -0
  73. data/lib/libraries/Stepper/Stepper.h +86 -0
  74. data/lib/libraries/Stepper/keywords.txt +28 -0
  75. data/lib/libraries/Wire/Wire.cpp +262 -0
  76. data/lib/libraries/Wire/Wire.h +67 -0
  77. data/lib/libraries/Wire/keywords.txt +31 -0
  78. data/lib/libraries/Wire/twi.h +57 -0
  79. data/lib/libraries/Wire/utility/twi.c +449 -0
  80. data/lib/libraries/Wire/utility/twi.h +57 -0
  81. data/lib/plugins/bitwise_ops.rb +54 -0
  82. data/lib/plugins/blink.rb +25 -0
  83. data/lib/plugins/blink_m.rb +356 -0
  84. data/lib/plugins/debounce.rb +138 -0
  85. data/lib/plugins/debug_output_to_lcd.rb +71 -0
  86. data/lib/plugins/hysteresis.rb +52 -0
  87. data/lib/plugins/input_output_state.rb +84 -0
  88. data/lib/plugins/lcd_padding.rb +58 -0
  89. data/lib/plugins/mem_test.rb +37 -0
  90. data/lib/plugins/midi.rb +60 -0
  91. data/lib/plugins/parallax_ping.rb +50 -0
  92. data/lib/plugins/servo_pulse.rb +31 -0
  93. data/lib/plugins/servo_setup.rb +86 -0
  94. data/lib/plugins/smoother.rb +54 -0
  95. data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
  96. data/lib/plugins/spectra_symbol.rb +79 -0
  97. data/lib/plugins/twitter_connect.rb +145 -0
  98. data/lib/rad/README.rdoc +5 -0
  99. data/lib/rad/arduino_plugin.rb +246 -0
  100. data/lib/rad/arduino_sketch.rb +351 -257
  101. data/lib/rad/generators/makefile/makefile.erb +1 -1
  102. data/lib/rad/generators/makefile/makefile.rb +9 -10
  103. data/lib/rad/hardware_library.rb +813 -0
  104. data/lib/rad/init.rb +3 -1
  105. data/lib/rad/rad_processor.rb +128 -0
  106. data/lib/rad/rad_rewriter.rb +94 -0
  107. data/lib/rad/rad_type_checker.rb +26 -0
  108. data/lib/rad/sim/arduino_sketch.rb +57 -0
  109. data/lib/rad/sketch_compiler.rb +47 -0
  110. data/lib/rad/tasks/build_and_make.rake +146 -24
  111. data/lib/rad/variable_processing.rb +153 -0
  112. data/lib/rad/version.rb +1 -1
  113. data/spec/examples/hello_world.rb +11 -0
  114. data/spec/examples/serial_motor.rb +12 -0
  115. data/spec/models/sketch_compiler_spec.rb +96 -0
  116. data/spec/sim/hello_world_spec.rb +42 -0
  117. data/test/test_array_processing.rb +179 -0
  118. data/test/test_plugin_loading.rb +151 -0
  119. data/test/test_translation_post_processing.rb +185 -0
  120. data/test/test_variable_processing.rb +238 -0
  121. data/website/index.html +22 -7
  122. data/website/stylesheets/screen.css +32 -1
  123. metadata +130 -13
@@ -1,3 +1,37 @@
1
+ == 0.2.5 2008-07-21
2
+ * 1ish large post Bastille Day update:
3
+ - added i2c capability
4
+ - added actual Wire library until workaround for os_x file caching is found
5
+ - added DS1307 and OneWire libraries
6
+ - added cool instance variable style global variables
7
+ - added array and define methods
8
+ - added def setup method, which added to setup 
9
+ - added numerous examples
10
+
11
+ == 0.2.4 2008-07-12
12
+ * 1ish large update:
13
+ - added incredibly primitive tests
14
+ - added 11 sketch examples which are compiled or compiled/uploaded
15
+ - use rake test:compile or rake test:upload
16
+ - can also use the following to run an example (make:compile also works)
17
+ - make:upload sketch=examples/hello_servos
18
+
19
+ == 0.2.3 2008-07-10
20
+ * Manyish updates:
21
+ - updated servo library to support position parameter
22
+ - plus:
23
+ - addition of plugins
24
+ - latest and greatest lcd libraries for pa and sf
25
+ - multiple methods
26
+ - addition of rad_process and rad_rewrite methods methods
27
+ - options for :device => servo, button, lcd,
28
+ - and many more
29
+
30
+ == 0.2.2 2008-04-27
31
+ * 2ish updates:
32
+ - updated makefile template and cli to expect arduino-0011
33
+ - applied David Michael's patch for longs
34
+
1
35
  == 0.2.1 2008-04-02
2
36
  * 6ish updates:
3
37
  - applied Brian Riley's SWSerLCDpa patch
@@ -1,26 +1,132 @@
1
1
  History.txt
2
2
  License.txt
3
3
  Manifest.txt
4
- README.txt
4
+ README.rdoc
5
5
  Rakefile
6
6
  bin/rad
7
- lib/libraries/SWSerLCDpa/keywords.txt
7
+ lib/examples/add_hysteresis.rb
8
+ lib/examples/basic_blink.rb
9
+ lib/examples/blink_m_address_assignment.rb
10
+ lib/examples/blink_m_hello.rb
11
+ lib/examples/blink_m_multi.rb
12
+ lib/examples/blink_with_serial.rb
13
+ lib/examples/configure_pa_lcd_boot.rb
14
+ lib/examples/debounce_methods.rb
15
+ lib/examples/external_variable_fu.rb
16
+ lib/examples/external_variables.rb
17
+ lib/examples/first_sound.rb
18
+ lib/examples/frequency_generator.rb
19
+ lib/examples/hello_array.rb
20
+ lib/examples/hello_array2.rb
21
+ lib/examples/hello_array_eeprom.rb
22
+ lib/examples/hello_clock.rb
23
+ lib/examples/hello_eeprom.rb
24
+ lib/examples/hello_eeprom_lcdpa.rb
25
+ lib/examples/hello_format_print.rb
26
+ lib/examples/hello_lcd_charset.rb
27
+ lib/examples/hello_pa_lcd.rb
28
+ lib/examples/hello_servos.rb
29
+ lib/examples/hello_spectra_sound.rb
30
+ lib/examples/hello_world.rb
31
+ lib/examples/hello_xbee.rb
32
+ lib/examples/hysteresis_duel.rb
33
+ lib/examples/i2c_with_clock_chip.rb
34
+ lib/examples/midi_beat_box.rb
35
+ lib/examples/midi_scales.rb
36
+ lib/examples/motor_knob.rb
37
+ lib/examples/servo_buttons.rb
38
+ lib/examples/servo_calibrate_continuous.rb
39
+ lib/examples/servo_throttle.rb
40
+ lib/examples/sparkfun_lcd.rb
41
+ lib/examples/spectra_soft_pot.rb
42
+ lib/examples/times_method.rb
43
+ lib/examples/toggle.rb
44
+ lib/examples/twitter.rb
45
+ lib/examples/two_wire.rb
46
+ lib/libraries/AFSoftSerial/AFSoftSerial.cpp
47
+ lib/libraries/AFSoftSerial/AFSoftSerial.h
48
+ lib/libraries/AFSoftSerial/keywords.txt
49
+ lib/libraries/AF_XPort/AF_XPort.cpp
50
+ lib/libraries/AF_XPort/AF_XPort.h
51
+ lib/libraries/DS1307/DS1307.cpp
52
+ lib/libraries/DS1307/DS1307.h
53
+ lib/libraries/DS1307/keywords.txt
54
+ lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp
55
+ lib/libraries/FrequencyTimer2/FrequencyTimer2.h
56
+ lib/libraries/FrequencyTimer2/keywords.txt
57
+ lib/libraries/I2CEEPROM/I2CEEPROM.cpp
58
+ lib/libraries/I2CEEPROM/I2CEEPROM.h
59
+ lib/libraries/I2CEEPROM/keywords.txt
60
+ lib/libraries/LoopTimer/LoopTimer.cpp
61
+ lib/libraries/LoopTimer/LoopTimer.h
62
+ lib/libraries/LoopTimer/keywords.txt
63
+ lib/libraries/OneWire/OneWire.cpp
64
+ lib/libraries/OneWire/OneWire.h
65
+ lib/libraries/OneWire/keywords.txt
66
+ lib/libraries/OneWire/readme.txt
8
67
  lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp
9
68
  lib/libraries/SWSerLCDpa/SWSerLCDpa.h
69
+ lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp
70
+ lib/libraries/SWSerLCDsf/SWSerLCDsf.h
71
+ lib/libraries/Servo/Servo.cpp
72
+ lib/libraries/Servo/Servo.h
73
+ lib/libraries/Stepper/Stepper.cpp
74
+ lib/libraries/Stepper/Stepper.h
75
+ lib/libraries/Stepper/keywords.txt
76
+ lib/libraries/Wire/Wire.cpp
77
+ lib/libraries/Wire/Wire.h
78
+ lib/libraries/Wire/keywords.txt
79
+ lib/libraries/Wire/twi.h
80
+ lib/libraries/Wire/utility/twi.c
81
+ lib/libraries/Wire/utility/twi.h
82
+ lib/plugins/bitwise_ops.rb
83
+ lib/plugins/blink.rb
84
+ lib/plugins/blink_m.rb
85
+ lib/plugins/debounce.rb
86
+ lib/plugins/debug_output_to_lcd.rb
87
+ lib/plugins/hysteresis.rb
88
+ lib/plugins/input_output_state.rb
89
+ lib/plugins/lcd_padding.rb
90
+ lib/plugins/mem_test.rb
91
+ lib/plugins/midi.rb
92
+ lib/plugins/parallax_ping.rb
93
+ lib/plugins/servo_pulse.rb
94
+ lib/plugins/servo_setup.rb
95
+ lib/plugins/smoother.rb
96
+ lib/plugins/spark_fun_serial_lcd.rb
97
+ lib/plugins/spectra_symbol.rb
98
+ lib/plugins/twitter_connect.rb
10
99
  lib/rad.rb
100
+ lib/rad/README.rdoc
101
+ lib/rad/arduino_plugin.rb
11
102
  lib/rad/arduino_sketch.rb
103
+ lib/rad/generators/makefile/makefile.erb
104
+ lib/rad/generators/makefile/makefile.rb
105
+ lib/rad/hardware_library.rb
12
106
  lib/rad/init.rb
13
- lib/rad/todo.txt
107
+ lib/rad/rad_processor.rb
108
+ lib/rad/rad_rewriter.rb
109
+ lib/rad/rad_type_checker.rb
110
+ lib/rad/sim/arduino_sketch.rb
111
+ lib/rad/sketch_compiler.rb
14
112
  lib/rad/tasks/build_and_make.rake
15
113
  lib/rad/tasks/rad.rb
114
+ lib/rad/todo.txt
115
+ lib/rad/variable_processing.rb
16
116
  lib/rad/version.rb
17
- lib/rad/generators/makefile/makefile.erb
18
- lib/rad/generators/makefile/makefile.rb
19
117
  scripts/txt2html
20
118
  setup.rb
21
- spec/models/spec_helper.rb
119
+ spec/examples/hello_world.rb
120
+ spec/examples/serial_motor.rb
22
121
  spec/models/arduino_sketch_spec.rb
122
+ spec/models/sketch_compiler_spec.rb
123
+ spec/models/spec_helper.rb
124
+ spec/sim/hello_world_spec.rb
23
125
  spec/spec.opts
126
+ test/test_array_processing.rb
127
+ test/test_plugin_loading.rb
128
+ test/test_translation_post_processing.rb
129
+ test/test_variable_processing.rb
24
130
  website/index.html
25
131
  website/index.txt
26
132
  website/javascripts/rounded_corners_lite.inc.js
@@ -29,4 +135,4 @@ website/template.rhtml
29
135
  website/examples/assembler_test.rb.html
30
136
  website/examples/gps_reader.rb.html
31
137
  website/examples/hello_world.rb.html
32
- website/examples/serial_motor.rb.html
138
+ website/examples/serial_motor.rb.html
@@ -12,17 +12,29 @@ See also the Arduino Software reference: http://www.arduino.cc/en/Reference/Home
12
12
 
13
13
  ==Examples
14
14
 
15
- See the examples directory for lots of examples of RAD in action: http://rad.rubyforge.org/examples
15
+ See the examples directory for lots of examples of RAD in action:
16
+ http://github.com/atduskgreg/rad/tree/master/lib/examples
17
+
18
+ The atduskgreg/rad wiki also contains a growing library of examples and hardware tutorials:
19
+ http://github.com/atduskgreg/rad/wikis
16
20
 
17
21
  ==Getting Started
18
22
 
19
- Install the gem:
23
+ To install the edge gem:
24
+
25
+ # Update to RubyGems 1.2.0 before proceeding!
26
+ $ gem sources -a http://gems.github.com (you only have to do this once)
27
+ $ sudo gem install atduskgreg-rad
28
+
29
+ A very old and feature poor (though slightly more 'stable' RAD) is available from RubyGems:
30
+
31
+ $ sudo gem install rad
20
32
 
21
- $ sudo gem install rad
33
+ We plan to push tagged releases to RubyGems at key points. The 0.3 release should be coming up soon.
22
34
 
23
35
  Run the rad command to create a new project:
24
36
 
25
- $ rad my_project
37
+ $ rad my_project
26
38
 
27
39
  Write a sketch that will blink a single LED every 500ms:
28
40
 
@@ -36,7 +48,7 @@ Write a sketch that will blink a single LED every 500ms:
36
48
 
37
49
  Attach your Arduino and use rake to complile and upload your sketch:
38
50
 
39
- $ rake make:upload
51
+ $ rake make:upload
40
52
 
41
53
  ==Get Involved
42
54
 
data/Rakefile CHANGED
@@ -8,6 +8,9 @@ require 'rake/rdoctask'
8
8
  require 'rake/contrib/rubyforgepublisher'
9
9
  require 'fileutils'
10
10
  require 'hoe'
11
+
12
+ RAD_ROOT = File.expand_path(File.dirname(__FILE__))
13
+
11
14
  begin
12
15
  require 'spec/rake/spectask'
13
16
  rescue LoadError
data/bin/rad CHANGED
@@ -10,7 +10,7 @@ require 'optparse'
10
10
  require 'fileutils'
11
11
  require 'yaml'
12
12
 
13
-
13
+ require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/version.rb"
14
14
 
15
15
  class OptionParser #:nodoc:
16
16
 
@@ -60,6 +60,13 @@ Usage: #{File.basename($0)} <sketch_dir_name> <options for config>
60
60
  " (default: #{options['software']['arduino_root']})") do |arduino|
61
61
  options["software"]["arduino_root"] = arduino if arduino
62
62
  end
63
+
64
+ opts.on("-v", "--version [VERSION]",
65
+ "RAD version number",
66
+ " (#{Rad::VERSION::STRING})") do
67
+ puts Rad::VERSION::STRING
68
+ exit
69
+ end
63
70
 
64
71
  opts.on_tail("-h", "--help", "Show this message") do
65
72
  puts opts
@@ -102,17 +109,115 @@ puts
102
109
 
103
110
  FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
104
111
  puts "Successfully created your libraries directory."
112
+ puts
113
+
114
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/AF_XPort/.", "#{sketch_name}/vendor/libraries/AF_XPort"
115
+ puts "Installed AF_XPort into #{sketch_name}/vendor/libraries"
116
+ puts
117
+
118
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/AFSoftSerial/.", "#{sketch_name}/vendor/libraries/AFSoftSerial"
119
+ puts "Installed AFSoftSerial into #{sketch_name}/vendor/libraries"
120
+ puts
121
+
122
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/DS1307/.", "#{sketch_name}/vendor/libraries/DS1307"
123
+ puts "Installed DS1307 into #{sketch_name}/vendor/libraries"
124
+ puts
125
+
126
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/FrequencyTimer2/.", "#{sketch_name}/vendor/libraries/FrequencyTimer2"
127
+ puts "Installed FrequencyTimer2 into #{sketch_name}/vendor/libraries"
128
+ puts
129
+
130
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/I2CEEPROM/.", "#{sketch_name}/vendor/libraries/I2CEEPROM"
131
+ puts "Installed I2CEEPROM into #{sketch_name}/vendor/libraries"
132
+ puts
133
+
134
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/LoopTimer/.", "#{sketch_name}/vendor/libraries/LoopTimer"
135
+ puts "Installed LoopTimer into #{sketch_name}/vendor/libraries"
136
+ puts
137
+
138
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/OneWire/.", "#{sketch_name}/vendor/libraries/OneWire"
139
+ puts "Installed OneWire into #{sketch_name}/vendor/libraries"
140
+ puts
141
+
142
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Servo/.", "#{sketch_name}/vendor/libraries/Servo"
143
+ puts "Installed Servo into #{sketch_name}/vendor/libraries"
144
+ puts
145
+
146
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
147
+ puts "Installed Stepper into #{sketch_name}/vendor/libraries"
148
+ puts
105
149
 
106
150
  FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDpa/.", "#{sketch_name}/vendor/libraries/SWSerLCDpa"
107
151
  puts "Installed SWSerLCDpa into #{sketch_name}/vendor/libraries"
108
152
  puts
109
153
 
154
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDsf/.", "#{sketch_name}/vendor/libraries/SWSerLCDsf"
155
+ puts "Installed SWSerLCDsf into #{sketch_name}/vendor/libraries"
156
+ puts
157
+
158
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Wire/.", "#{sketch_name}/vendor/libraries/Wire"
159
+ puts "Installed Wire into #{sketch_name}/vendor/libraries"
160
+ puts
161
+
162
+ # Build examples -- used for basic testing
163
+
164
+ FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
165
+ puts "Successfully created your examples directory."
166
+
167
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/examples/.", "#{sketch_name}/examples"
168
+ puts "Installed examples into #{sketch_name}/examples"
169
+ puts
170
+
171
+ # Build test -- used testing
172
+
173
+ # FIXME: this should put the tests into the vendor/tests directory instead.
174
+
175
+ # FileUtils.mkdir_p "#{sketch_name}/test"
176
+ # puts "Successfully created your test directory."
177
+ #
178
+ # FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/test/.", "#{sketch_name}/test"
179
+ # puts "Installed tests into #{sketch_name}/test"
180
+ # puts
181
+
182
+ # Build vendor/plugins:
183
+
184
+ FileUtils.mkdir_p "#{sketch_name}/vendor/plugins"
185
+ puts "Successfully created your plugins directory."
186
+ puts
187
+
188
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/plugins/.", "#{sketch_name}/vendor/plugins"
189
+ puts "Installed Default plugins into #{sketch_name}/vendor/plugins"
190
+ puts
191
+
192
+ # Add an default sketch directory # needed to run test:compile
193
+
194
+ FileUtils.mkdir_p "#{sketch_name}/#{sketch_name}"
195
+ puts "Successfully created your default sketch directory."
196
+ puts
197
+
198
+ # Copy the README how_to to the sketch directory
199
+
200
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/rad/README.rdoc", "#{sketch_name}"
201
+ puts "Copied README how_to into #{sketch_name}"
202
+ puts
203
+
204
+
110
205
  # Build sketch files, etc.:
111
206
 
112
207
  FileUtils.touch "#{sketch_name}/#{sketch_name}.rb"
113
208
  File.open("#{sketch_name}/#{sketch_name}.rb", "w") do |file|
114
209
  file << <<-EOS
115
210
  class #{sketch_name.split("_").collect{|c| c.capitalize}.join("")} < ArduinoSketch
211
+
212
+ # looking for hints? check out the examples directory
213
+ # example sketches can be uploaded to your arduino with
214
+ # rake make:upload sketch=examples/hello_world
215
+ # just replace hello_world with other examples
216
+
217
+ def loop
218
+ # your code here
219
+ end
220
+
116
221
  end
117
222
  EOS
118
223
  end
@@ -0,0 +1,13 @@
1
+ class AddHysteresis < ArduinoSketch
2
+
3
+ input_pin 3, :as => :sensor
4
+ output_pin 13, :as => :led
5
+
6
+
7
+ def loop
8
+ reading = add_hysteresis sensor, 8
9
+ blink led, 100 if reading > 100
10
+ blink led, 1000 if reading <= 100
11
+ end
12
+
13
+ end
@@ -0,0 +1,10 @@
1
+ class BasicBlink < ArduinoSketch
2
+ # hello world (uncomment to run)
3
+
4
+ output_pin 13, :as => :led
5
+
6
+ def loop
7
+ blink led, 100
8
+ x = 4
9
+ end
10
+ end
@@ -0,0 +1,104 @@
1
+ class BlinkMAddressAssignment < ArduinoSketch
2
+
3
+ # want to use more than one blink m?
4
+ # since each blink m arrives with the same address,
5
+ # we can't address each one individually
6
+ #
7
+ # so the first thing we need to do is give each one a new address
8
+ # that's the purpose of this sketch
9
+ #
10
+ # install one blinkm at a time
11
+ # a pa_lcd screen makes this easier
12
+ # the screen will start at address ten and increment approximately every
13
+ # four seconds. Pressing during the first four seconds sets the blnikm
14
+ # address to 10, during the next four seconds to 11 and so on
15
+ # difficult without a screen.
16
+ # if you need to, program an led to help with the timing
17
+
18
+
19
+ @blink_m_start_address = 10
20
+ @flag = false
21
+ @addr1 = "10, byte"
22
+ @addr2 = "11, byte"
23
+ @addr3 = "12, byte"
24
+
25
+ output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
26
+ input_pin 7, :as => :button_one, :device => :button
27
+ input_pin 8, :as => :button_two, :device => :button
28
+ input_pin 9, :as => :button_three, :device => :button
29
+
30
+ output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
31
+
32
+ def setup
33
+ delay 1000
34
+ my_lcd.setxy 0,0, "bienvenue"
35
+ delay 5000
36
+ end
37
+
38
+ def loop
39
+
40
+ if @flag == false
41
+ staging
42
+ else
43
+ test_address
44
+ end
45
+ delay 100
46
+ end
47
+
48
+ def staging
49
+ my_lcd.setxy 0,0, "press button one to"
50
+ my_lcd.setxy 0,1, "set address to "
51
+ my_lcd.print @blink_m_start_address
52
+ my_lcd.setxy 0,2, "or two for status"
53
+ delay 60
54
+ my_lcd.setxy 0,3, " "
55
+ my_lcd.setxy 0,3
56
+ 800.times do |i|
57
+ return 0 if @flag == true
58
+ my_lcd.print "." if i % 50 == 0
59
+ delay 5
60
+ if button_one.read_input
61
+ assign_address
62
+ elsif button_two.read_input
63
+ test_address
64
+ end
65
+ end
66
+ @blink_m_start_address += 1
67
+ end
68
+
69
+ def assign_address
70
+ @flag = true
71
+ my_lcd.clearscr "setting to "
72
+ my_lcd.print @blink_m_start_address
73
+ delay 100
74
+ BlinkM_setAddress @blink_m_start_address
75
+ my_lcd.clearscr "done"
76
+ control_it
77
+ end
78
+
79
+ def control_it
80
+ delay 500
81
+ my_lcd.clearscr "stopping script"
82
+ BlinkM_stopScript @blink_m_start_address
83
+ my_lcd.clearscr "stopping script.."
84
+ delay 500
85
+ my_lcd.clearscr "fade to purple.."
86
+ BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
87
+ my_lcd.clearscr "fade to purple"
88
+ delay 500
89
+ BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
90
+ end
91
+
92
+
93
+ def test_address
94
+ my_lcd.clearscr
95
+ my_lcd.setxy 0,0, "testing address"
96
+ my_lcd.setxy 0,1
97
+ my_lcd.print blink_m_check_address_message @blink_m_start_address
98
+ delay 5000
99
+ end
100
+
101
+
102
+
103
+
104
+ end