madrona-rad 0.2.7 → 0.3.1
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.
- data/History.txt +6 -15
- data/Manifest.txt +38 -5
- data/README.rdoc +19 -7
- data/Rakefile +4 -3
- data/bin/rad +214 -130
- data/lib/examples/basic_blink.rb +10 -0
- data/lib/examples/blink_with_serial.rb +16 -0
- data/lib/examples/external_variable_fu.rb +21 -19
- data/lib/examples/external_variables.rb +0 -3
- data/lib/examples/hello_array2.rb +34 -1
- data/lib/examples/hello_array_eeprom.rb +4 -6
- data/lib/examples/hello_clock.rb +84 -0
- data/lib/examples/hello_eeprom.rb +3 -3
- data/lib/examples/hello_eeprom_lcdpa.rb +2 -2
- data/lib/examples/hello_format_print.rb +94 -0
- data/lib/examples/hello_spectra_sound.rb +38 -0
- data/lib/examples/hello_world.rb +3 -3
- data/lib/examples/hello_xbee.rb +12 -0
- data/lib/examples/midi_beat_box.rb +86 -0
- data/lib/examples/midi_scales.rb +94 -0
- data/lib/examples/servo_throttle.rb +11 -8
- data/lib/examples/software_serial.rb +10 -0
- data/lib/examples/twitter.rb +57 -0
- data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
- data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
- data/lib/libraries/{Servo → AFSoftSerial}/keywords.txt +18 -25
- data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
- data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
- data/lib/libraries/DS1307/DS1307.cpp +10 -9
- data/lib/libraries/DS1307/DS1307.h +6 -4
- data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
- data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
- data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
- data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
- data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
- data/lib/libraries/LoopTimer/keywords.txt +27 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +42 -48
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +11 -12
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +38 -0
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +9 -2
- data/lib/plugins/blink.rb +25 -0
- data/lib/plugins/blink_m.rb +3 -3
- data/lib/plugins/lcd_padding.rb +19 -0
- data/lib/plugins/midi.rb +60 -0
- data/lib/plugins/parallax_ping.rb +50 -0
- data/lib/plugins/servo_setup.rb +1 -1
- data/lib/plugins/twitter_connect.rb +145 -0
- data/lib/rad/README.rdoc +5 -0
- data/lib/rad/arduino_sketch.rb +91 -904
- data/lib/rad/darwin_installer.rb +23 -0
- data/lib/rad/generators/makefile/makefile.erb +1 -1
- data/lib/rad/generators/makefile/makefile.rb +3 -3
- data/lib/rad/hardware_library.rb +813 -0
- data/lib/rad/init.rb +4 -2
- data/lib/rad/linux_installer.rb +132 -0
- data/lib/rad/progressbar.rb +236 -0
- data/lib/rad/rad_processor.rb +56 -9
- data/lib/rad/rad_rewriter.rb +7 -2
- data/lib/rad/rad_type_checker.rb +1 -1
- data/lib/rad/sketch_compiler.rb +47 -0
- data/lib/rad/tasks/build_and_make.rake +41 -48
- data/lib/rad/version.rb +2 -2
- data/spec/examples/hello_world.rb +11 -0
- data/spec/examples/serial_motor.rb +12 -0
- data/spec/models/sketch_compiler_spec.rb +96 -0
- data/spec/sim/hello_world_spec.rb +0 -0
- data/test/hello_world_test/Makefile +436 -0
- data/test/hello_world_test/hello_world.cpp +23 -0
- data/test/test_array_processing.rb +1 -1
- data/test/test_plugin_loading.rb +1 -1
- data/test/test_translation_post_processing.rb +14 -70
- metadata +52 -39
- data/lib/examples/orig_servo_throttle.rb +0 -39
- data/lib/plugins/i2c_eeprom.rb +0 -70
data/History.txt
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
== 0.
|
|
2
|
-
|
|
1
|
+
== 0.3.5 2009-08-16
|
|
2
|
+
- added support for ruby 1.9 with help of Zen Spider
|
|
3
3
|
|
|
4
|
-
== 0.
|
|
5
|
-
*
|
|
6
|
-
- added
|
|
7
|
-
- added
|
|
8
|
-
- added multi sensor hysteresis -- formerly one sensor only
|
|
9
|
-
- added testing for plugin loading
|
|
10
|
-
- external arrays now have cool instance style plus
|
|
11
|
-
- drop down the metal style declarations
|
|
12
|
-
- iteration on external arrays now works. internal still problematic
|
|
13
|
-
- defines now work handily
|
|
14
|
-
- numerous lcd library changes plus enhancements: setxy 0,1, "print_something"
|
|
15
|
-
- lots of examples
|
|
16
|
-
- and much more
|
|
4
|
+
== 0.3.0 2008-09-22
|
|
5
|
+
* Pushing to rubyforge..
|
|
6
|
+
- added rad install arduino
|
|
7
|
+
- added rad test arduino
|
|
17
8
|
|
|
18
9
|
== 0.2.5 2008-07-21
|
|
19
10
|
* 1ish large post Bastille Day update:
|
data/Manifest.txt
CHANGED
|
@@ -5,9 +5,11 @@ README.rdoc
|
|
|
5
5
|
Rakefile
|
|
6
6
|
bin/rad
|
|
7
7
|
lib/examples/add_hysteresis.rb
|
|
8
|
+
lib/examples/basic_blink.rb
|
|
8
9
|
lib/examples/blink_m_address_assignment.rb
|
|
9
10
|
lib/examples/blink_m_hello.rb
|
|
10
11
|
lib/examples/blink_m_multi.rb
|
|
12
|
+
lib/examples/blink_with_serial.rb
|
|
11
13
|
lib/examples/configure_pa_lcd_boot.rb
|
|
12
14
|
lib/examples/debounce_methods.rb
|
|
13
15
|
lib/examples/external_variable_fu.rb
|
|
@@ -17,30 +19,48 @@ lib/examples/frequency_generator.rb
|
|
|
17
19
|
lib/examples/hello_array.rb
|
|
18
20
|
lib/examples/hello_array2.rb
|
|
19
21
|
lib/examples/hello_array_eeprom.rb
|
|
22
|
+
lib/examples/hello_clock.rb
|
|
20
23
|
lib/examples/hello_eeprom.rb
|
|
21
24
|
lib/examples/hello_eeprom_lcdpa.rb
|
|
25
|
+
lib/examples/hello_format_print.rb
|
|
22
26
|
lib/examples/hello_lcd_charset.rb
|
|
23
27
|
lib/examples/hello_pa_lcd.rb
|
|
24
28
|
lib/examples/hello_servos.rb
|
|
29
|
+
lib/examples/hello_spectra_sound.rb
|
|
25
30
|
lib/examples/hello_world.rb
|
|
31
|
+
lib/examples/hello_xbee.rb
|
|
26
32
|
lib/examples/hysteresis_duel.rb
|
|
27
33
|
lib/examples/i2c_with_clock_chip.rb
|
|
34
|
+
lib/examples/midi_beat_box.rb
|
|
35
|
+
lib/examples/midi_scales.rb
|
|
28
36
|
lib/examples/motor_knob.rb
|
|
29
|
-
lib/examples/orig_servo_throttle.rb
|
|
30
37
|
lib/examples/servo_buttons.rb
|
|
31
38
|
lib/examples/servo_calibrate_continuous.rb
|
|
32
39
|
lib/examples/servo_throttle.rb
|
|
40
|
+
lib/examples/software_serial.rb
|
|
33
41
|
lib/examples/sparkfun_lcd.rb
|
|
34
42
|
lib/examples/spectra_soft_pot.rb
|
|
35
43
|
lib/examples/times_method.rb
|
|
36
44
|
lib/examples/toggle.rb
|
|
45
|
+
lib/examples/twitter.rb
|
|
37
46
|
lib/examples/two_wire.rb
|
|
47
|
+
lib/libraries/AFSoftSerial/AFSoftSerial.cpp
|
|
48
|
+
lib/libraries/AFSoftSerial/AFSoftSerial.h
|
|
49
|
+
lib/libraries/AFSoftSerial/keywords.txt
|
|
50
|
+
lib/libraries/AF_XPort/AF_XPort.cpp
|
|
51
|
+
lib/libraries/AF_XPort/AF_XPort.h
|
|
38
52
|
lib/libraries/DS1307/DS1307.cpp
|
|
39
53
|
lib/libraries/DS1307/DS1307.h
|
|
40
54
|
lib/libraries/DS1307/keywords.txt
|
|
41
55
|
lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp
|
|
42
56
|
lib/libraries/FrequencyTimer2/FrequencyTimer2.h
|
|
43
57
|
lib/libraries/FrequencyTimer2/keywords.txt
|
|
58
|
+
lib/libraries/I2CEEPROM/I2CEEPROM.cpp
|
|
59
|
+
lib/libraries/I2CEEPROM/I2CEEPROM.h
|
|
60
|
+
lib/libraries/I2CEEPROM/keywords.txt
|
|
61
|
+
lib/libraries/LoopTimer/LoopTimer.cpp
|
|
62
|
+
lib/libraries/LoopTimer/LoopTimer.h
|
|
63
|
+
lib/libraries/LoopTimer/keywords.txt
|
|
44
64
|
lib/libraries/OneWire/OneWire.cpp
|
|
45
65
|
lib/libraries/OneWire/OneWire.h
|
|
46
66
|
lib/libraries/OneWire/keywords.txt
|
|
@@ -51,7 +71,6 @@ lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp
|
|
|
51
71
|
lib/libraries/SWSerLCDsf/SWSerLCDsf.h
|
|
52
72
|
lib/libraries/Servo/Servo.cpp
|
|
53
73
|
lib/libraries/Servo/Servo.h
|
|
54
|
-
lib/libraries/Servo/keywords.txt
|
|
55
74
|
lib/libraries/Stepper/Stepper.cpp
|
|
56
75
|
lib/libraries/Stepper/Stepper.h
|
|
57
76
|
lib/libraries/Stepper/keywords.txt
|
|
@@ -62,40 +81,54 @@ lib/libraries/Wire/twi.h
|
|
|
62
81
|
lib/libraries/Wire/utility/twi.c
|
|
63
82
|
lib/libraries/Wire/utility/twi.h
|
|
64
83
|
lib/plugins/bitwise_ops.rb
|
|
84
|
+
lib/plugins/blink.rb
|
|
65
85
|
lib/plugins/blink_m.rb
|
|
66
86
|
lib/plugins/debounce.rb
|
|
67
87
|
lib/plugins/debug_output_to_lcd.rb
|
|
68
88
|
lib/plugins/hysteresis.rb
|
|
69
|
-
lib/plugins/i2c_eeprom.rb
|
|
70
89
|
lib/plugins/input_output_state.rb
|
|
71
90
|
lib/plugins/lcd_padding.rb
|
|
72
91
|
lib/plugins/mem_test.rb
|
|
92
|
+
lib/plugins/midi.rb
|
|
93
|
+
lib/plugins/parallax_ping.rb
|
|
73
94
|
lib/plugins/servo_pulse.rb
|
|
74
95
|
lib/plugins/servo_setup.rb
|
|
75
96
|
lib/plugins/smoother.rb
|
|
76
97
|
lib/plugins/spark_fun_serial_lcd.rb
|
|
77
98
|
lib/plugins/spectra_symbol.rb
|
|
99
|
+
lib/plugins/twitter_connect.rb
|
|
78
100
|
lib/rad.rb
|
|
101
|
+
lib/rad/README.rdoc
|
|
79
102
|
lib/rad/arduino_plugin.rb
|
|
80
103
|
lib/rad/arduino_sketch.rb
|
|
104
|
+
lib/rad/darwin_installer.rb
|
|
81
105
|
lib/rad/generators/makefile/makefile.erb
|
|
82
106
|
lib/rad/generators/makefile/makefile.rb
|
|
107
|
+
lib/rad/hardware_library.rb
|
|
83
108
|
lib/rad/init.rb
|
|
109
|
+
lib/rad/linux_installer.rb
|
|
110
|
+
lib/rad/progressbar.rb
|
|
84
111
|
lib/rad/rad_processor.rb
|
|
85
112
|
lib/rad/rad_rewriter.rb
|
|
86
113
|
lib/rad/rad_type_checker.rb
|
|
87
114
|
lib/rad/sim/arduino_sketch.rb
|
|
115
|
+
lib/rad/sketch_compiler.rb
|
|
88
116
|
lib/rad/tasks/build_and_make.rake
|
|
89
|
-
lib/rad/developer.rake
|
|
90
117
|
lib/rad/tasks/rad.rb
|
|
91
118
|
lib/rad/todo.txt
|
|
92
119
|
lib/rad/variable_processing.rb
|
|
93
120
|
lib/rad/version.rb
|
|
94
121
|
scripts/txt2html
|
|
95
122
|
setup.rb
|
|
96
|
-
spec/
|
|
123
|
+
spec/examples/hello_world.rb
|
|
124
|
+
spec/examples/serial_motor.rb
|
|
97
125
|
spec/models/arduino_sketch_spec.rb
|
|
126
|
+
spec/models/sketch_compiler_spec.rb
|
|
127
|
+
spec/models/spec_helper.rb
|
|
128
|
+
spec/sim/hello_world_spec.rb
|
|
98
129
|
spec/spec.opts
|
|
130
|
+
test/hello_world_test/Makefile
|
|
131
|
+
test/hello_world_test/hello_world.cpp
|
|
99
132
|
test/test_array_processing.rb
|
|
100
133
|
test/test_plugin_loading.rb
|
|
101
134
|
test/test_translation_post_processing.rb
|
data/README.rdoc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
=Welcome to RAD (Ruby Arduino Development)
|
|
2
2
|
|
|
3
|
-
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.
|
|
3
|
+
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.
|
|
4
4
|
|
|
5
5
|
For a full introduction see http://rad.rubyforge.org
|
|
6
6
|
|
|
@@ -12,22 +12,26 @@ 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:
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
18
20
|
|
|
19
21
|
==Getting Started
|
|
20
22
|
|
|
21
|
-
To install the
|
|
23
|
+
To install the edge gem:
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
# Update to RubyGems 1.2.0 before proceeding!
|
|
24
26
|
$ gem sources -a http://gems.github.com (you only have to do this once)
|
|
25
27
|
$ sudo gem install madrona-rad
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
A very old and feature poor (though slightly more 'stable' RAD) is available from RubyGems:
|
|
28
30
|
|
|
29
31
|
$ sudo gem install rad
|
|
30
32
|
|
|
33
|
+
We plan to push tagged releases to RubyGems at key points. The 0.3 release should be coming up soon.
|
|
34
|
+
|
|
31
35
|
Run the rad command to create a new project:
|
|
32
36
|
|
|
33
37
|
$ rad my_project
|
|
@@ -46,6 +50,14 @@ Attach your Arduino and use rake to complile and upload your sketch:
|
|
|
46
50
|
|
|
47
51
|
$ rake make:upload
|
|
48
52
|
|
|
53
|
+
==Installing the Arduino Software
|
|
54
|
+
|
|
55
|
+
Installing RAD and the Arduino software on Linux can be a little more difficult than on OS X. Thankfully, the RAD command line tool can help. Run:
|
|
56
|
+
|
|
57
|
+
$ rad install arduino
|
|
58
|
+
|
|
59
|
+
And RAD will do its best to get the Arduino software installed on your system.
|
|
60
|
+
|
|
49
61
|
==Get Involved
|
|
50
62
|
|
|
51
63
|
Cheers? Jeers? Wanna help out? Contact Greg Borenstein: greg [dot] borenstein [at] gmail [dot] com
|
data/Rakefile
CHANGED
|
@@ -9,9 +9,10 @@ require 'rake/contrib/rubyforgepublisher'
|
|
|
9
9
|
require 'fileutils'
|
|
10
10
|
require 'hoe'
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
$: << "../lib/" # HACK while I work out r2c/rad incompatibilities
|
|
13
|
+
# gem "RubyToC" # HACK to deal with rubygems beta version activation bug
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
RAD_ROOT = File.expand_path(File.dirname(__FILE__))
|
|
15
16
|
|
|
16
17
|
begin
|
|
17
18
|
require 'spec/rake/spectask'
|
|
@@ -84,7 +85,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
|
84
85
|
|
|
85
86
|
# == Optional
|
|
86
87
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
|
87
|
-
p.extra_deps = [ ['
|
|
88
|
+
p.extra_deps = [ ['ruby2c', '>= 1.0.0.6'] ]
|
|
88
89
|
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
|
89
90
|
end
|
|
90
91
|
|
data/bin/rad
CHANGED
|
@@ -9,8 +9,13 @@ end
|
|
|
9
9
|
require 'optparse'
|
|
10
10
|
require 'fileutils'
|
|
11
11
|
require 'yaml'
|
|
12
|
+
require 'open-uri'
|
|
13
|
+
require 'readline'
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/version.rb"
|
|
16
|
+
require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/progressbar.rb"
|
|
17
|
+
require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/linux_installer.rb"
|
|
18
|
+
require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/darwin_installer.rb"
|
|
14
19
|
|
|
15
20
|
class OptionParser #:nodoc:
|
|
16
21
|
|
|
@@ -23,7 +28,7 @@ class OptionParser #:nodoc:
|
|
|
23
28
|
"physical_reset" => false
|
|
24
29
|
},
|
|
25
30
|
"software" => {
|
|
26
|
-
"arduino_root" => "/Applications/arduino-
|
|
31
|
+
"arduino_root" => "/Applications/arduino-0012"
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
|
|
@@ -60,6 +65,13 @@ Usage: #{File.basename($0)} <sketch_dir_name> <options for config>
|
|
|
60
65
|
" (default: #{options['software']['arduino_root']})") do |arduino|
|
|
61
66
|
options["software"]["arduino_root"] = arduino if arduino
|
|
62
67
|
end
|
|
68
|
+
|
|
69
|
+
opts.on("-v", "--version [VERSION]",
|
|
70
|
+
"RAD version number",
|
|
71
|
+
" (#{Rad::VERSION::STRING})") do
|
|
72
|
+
puts Rad::VERSION::STRING
|
|
73
|
+
exit
|
|
74
|
+
end
|
|
63
75
|
|
|
64
76
|
opts.on_tail("-h", "--help", "Show this message") do
|
|
65
77
|
puts opts
|
|
@@ -83,136 +95,208 @@ end
|
|
|
83
95
|
#
|
|
84
96
|
|
|
85
97
|
|
|
86
|
-
|
|
87
|
-
options, parser = OptionParser.parse(ARGV)
|
|
88
|
-
sketch_name = ARGV[0]
|
|
89
|
-
parser.parse!(["-h"]) unless sketch_name
|
|
98
|
+
if ARGV[0] == "install"
|
|
90
99
|
|
|
100
|
+
case RUBY_PLATFORM
|
|
101
|
+
when /linux/
|
|
102
|
+
LinuxInstaller.install!
|
|
103
|
+
when /darwin/
|
|
104
|
+
DarwinInstaller.install!
|
|
105
|
+
else
|
|
106
|
+
raise "Sorry. Can only install Arduino on Mac OS X. See here for Linux instructions: http://www.arduino.cc/playground/Learning/Linux"
|
|
107
|
+
end
|
|
91
108
|
|
|
92
|
-
|
|
109
|
+
elsif ARGV[0] == "test"
|
|
110
|
+
test_dir = File.expand_path(File.dirname(__FILE__)) + "/../test/hello_world_test"
|
|
111
|
+
puts "Compiling hello_world.cpp to test your Arduino."
|
|
112
|
+
puts "cd #{test_dir}; make depend; make;"
|
|
113
|
+
`cd #{test_dir}; make depend; make;`
|
|
114
|
+
puts
|
|
115
|
+
puts "Compilation successful."
|
|
116
|
+
puts
|
|
117
|
+
puts "Make sure your Arduino is connected and then hit return."
|
|
118
|
+
Readline::readline('')
|
|
93
119
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
puts "
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
puts "
|
|
108
|
-
puts
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
puts
|
|
112
|
-
puts
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
puts "
|
|
116
|
-
puts
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
puts "
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDsf/.", "#{sketch_name}/vendor/libraries/SWSerLCDsf"
|
|
131
|
-
puts "Installed SWSerLCDsf into #{sketch_name}/vendor/libraries"
|
|
132
|
-
puts
|
|
133
|
-
|
|
134
|
-
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
|
|
135
|
-
puts "Installed Stepper into #{sketch_name}/vendor/libraries"
|
|
136
|
-
puts
|
|
137
|
-
|
|
138
|
-
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Wire/.", "#{sketch_name}/vendor/libraries/Wire"
|
|
139
|
-
puts "Installed Wire into #{sketch_name}/vendor/libraries"
|
|
140
|
-
puts
|
|
141
|
-
|
|
142
|
-
# Build examples -- used for basic testing
|
|
143
|
-
|
|
144
|
-
FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
|
|
145
|
-
puts "Successfully created your examples directory."
|
|
146
|
-
|
|
147
|
-
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/examples/.", "#{sketch_name}/examples"
|
|
148
|
-
puts "Installed examples into #{sketch_name}/examples"
|
|
149
|
-
puts
|
|
150
|
-
|
|
151
|
-
# Build test -- used testing
|
|
152
|
-
|
|
153
|
-
# FIXME: this should put the tests into the vendor/tests directory instead.
|
|
154
|
-
|
|
155
|
-
# FileUtils.mkdir_p "#{sketch_name}/test"
|
|
156
|
-
# puts "Successfully created your test directory."
|
|
157
|
-
#
|
|
158
|
-
# FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/test/.", "#{sketch_name}/test"
|
|
159
|
-
# puts "Installed tests into #{sketch_name}/test"
|
|
160
|
-
# puts
|
|
161
|
-
|
|
162
|
-
# Build vendor/plugins:
|
|
163
|
-
|
|
164
|
-
FileUtils.mkdir_p "#{sketch_name}/vendor/plugins"
|
|
165
|
-
puts "Successfully created your plugins directory."
|
|
166
|
-
|
|
167
|
-
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/plugins/.", "#{sketch_name}/vendor/plugins"
|
|
168
|
-
puts "Installed Default plugins into #{sketch_name}/vendor/plugins"
|
|
169
|
-
puts
|
|
170
|
-
|
|
171
|
-
# Add an default sketch directory # needed to run test:compile
|
|
172
|
-
|
|
173
|
-
FileUtils.mkdir_p "#{sketch_name}/#{sketch_name}"
|
|
174
|
-
puts "Successfully created your default sketch directory."
|
|
175
|
-
|
|
176
|
-
# Build sketch files, etc.:
|
|
177
|
-
|
|
178
|
-
FileUtils.touch "#{sketch_name}/#{sketch_name}.rb"
|
|
179
|
-
File.open("#{sketch_name}/#{sketch_name}.rb", "w") do |file|
|
|
180
|
-
file << <<-EOS
|
|
181
|
-
class #{sketch_name.split("_").collect{|c| c.capitalize}.join("")} < ArduinoSketch
|
|
182
|
-
|
|
183
|
-
# looking for hints? check out the examples directory
|
|
184
|
-
# example sketches can be uploaded to your arduino with
|
|
185
|
-
# rake make:upload sketch=examples/hello_world
|
|
186
|
-
# just replace hello_world with other examples
|
|
187
|
-
|
|
188
|
-
def loop
|
|
189
|
-
# your code here
|
|
190
|
-
end
|
|
120
|
+
`cd #{test_dir}; make upload`
|
|
121
|
+
|
|
122
|
+
# find the USB port to make sure the Arduino's actually plugged in
|
|
123
|
+
options, parser = OptionParser.parse(ARGV)
|
|
124
|
+
usb_port = options["hardware"]["serial_port"]
|
|
125
|
+
port_name = usb_port.split("/").last
|
|
126
|
+
port_dir = usb_port.split("/")[0..(usb_port.split("/").length-2)].join("/")
|
|
127
|
+
unless `ls #{port_dir}`.split(/\n/).any?{|d| d.match(/#{port_name}/)}
|
|
128
|
+
puts
|
|
129
|
+
puts "******************************************************"
|
|
130
|
+
puts "*** It looks like your Arduino is not plugged in. ***"
|
|
131
|
+
puts "*** Plug it in and try again. ***"
|
|
132
|
+
puts "*** ***"
|
|
133
|
+
puts "*** NOTE: If your usb port is not /dev/tty.usb* ***"
|
|
134
|
+
puts "*** pass it in to this script with the -p option. ***"
|
|
135
|
+
puts "******************************************************"
|
|
136
|
+
else
|
|
137
|
+
puts
|
|
138
|
+
puts "******************************************************"
|
|
139
|
+
puts "*** Success! ***"
|
|
140
|
+
puts "*** If your Arduino's light starts blinking soon, ***"
|
|
141
|
+
puts "*** then your Arduino environment is ***"
|
|
142
|
+
puts "*** correctly configured. ***"
|
|
143
|
+
puts "*** ***"
|
|
144
|
+
puts "*** Otherwise something is not hooked up properly. ***"
|
|
145
|
+
puts "******************************************************"
|
|
146
|
+
end
|
|
147
|
+
puts
|
|
148
|
+
puts "cleaning up..."
|
|
149
|
+
`rm #{test_dir}/hello_world.hex #{test_dir}/core.a #{test_dir}/hello_world.elf`
|
|
150
|
+
else
|
|
151
|
+
# Handle options:
|
|
152
|
+
options, parser = OptionParser.parse(ARGV)
|
|
153
|
+
sketch_name = ARGV[0]
|
|
154
|
+
parser.parse!(["-h"]) unless sketch_name
|
|
191
155
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
FileUtils.mkdir_p "#{sketch_name}/
|
|
205
|
-
puts "
|
|
206
|
-
|
|
207
|
-
File.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
puts "Added #{sketch_name}/config/hardware.yml"
|
|
211
|
-
|
|
212
|
-
File.open("#{sketch_name}/config/software.yml", 'w') do |file|
|
|
213
|
-
file << options["software"].to_yaml
|
|
214
|
-
end
|
|
215
|
-
puts "Added #{sketch_name}/config/software.yml"
|
|
156
|
+
|
|
157
|
+
# Build vendor/rad:
|
|
158
|
+
|
|
159
|
+
FileUtils.mkdir_p "#{sketch_name}/vendor/rad"
|
|
160
|
+
puts "Successfully created your sketch directory."
|
|
161
|
+
|
|
162
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/rad/.", "#{sketch_name}/vendor/rad"
|
|
163
|
+
puts "Installed RAD into #{sketch_name}/vendor/rad"
|
|
164
|
+
puts
|
|
165
|
+
|
|
166
|
+
# Build vendor/libraries:
|
|
167
|
+
|
|
168
|
+
FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
|
|
169
|
+
puts "Successfully created your libraries directory."
|
|
170
|
+
|
|
171
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/AF_XPort/.", "#{sketch_name}/vendor/libraries/AF_XPort"
|
|
172
|
+
puts "Installed AF_XPort into #{sketch_name}/vendor/libraries"
|
|
173
|
+
puts
|
|
216
174
|
|
|
217
|
-
|
|
218
|
-
puts "
|
|
175
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/AFSoftSerial/.", "#{sketch_name}/vendor/libraries/AFSoftSerial"
|
|
176
|
+
puts "Installed AFSoftSerial into #{sketch_name}/vendor/libraries"
|
|
177
|
+
puts
|
|
178
|
+
|
|
179
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/DS1307/.", "#{sketch_name}/vendor/libraries/DS1307"
|
|
180
|
+
puts "Installed DS1307 into #{sketch_name}/vendor/libraries"
|
|
181
|
+
puts
|
|
182
|
+
|
|
183
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/FrequencyTimer2/.", "#{sketch_name}/vendor/libraries/FrequencyTimer2"
|
|
184
|
+
puts "Installed FrequencyTimer2 into #{sketch_name}/vendor/libraries"
|
|
185
|
+
puts
|
|
186
|
+
|
|
187
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/I2CEEPROM/.", "#{sketch_name}/vendor/libraries/I2CEEPROM"
|
|
188
|
+
puts "Installed I2CEEPROM into #{sketch_name}/vendor/libraries"
|
|
189
|
+
puts
|
|
190
|
+
|
|
191
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/LoopTimer/.", "#{sketch_name}/vendor/libraries/LoopTimer"
|
|
192
|
+
puts "Installed LoopTimer into #{sketch_name}/vendor/libraries"
|
|
193
|
+
puts
|
|
194
|
+
|
|
195
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/OneWire/.", "#{sketch_name}/vendor/libraries/OneWire"
|
|
196
|
+
puts "Installed OneWire into #{sketch_name}/vendor/libraries"
|
|
197
|
+
puts
|
|
198
|
+
|
|
199
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Servo/.", "#{sketch_name}/vendor/libraries/Servo"
|
|
200
|
+
puts "Installed Servo into #{sketch_name}/vendor/libraries"
|
|
201
|
+
puts
|
|
202
|
+
|
|
203
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
|
|
204
|
+
puts "Installed Stepper into #{sketch_name}/vendor/libraries"
|
|
205
|
+
puts
|
|
206
|
+
|
|
207
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDpa/.", "#{sketch_name}/vendor/libraries/SWSerLCDpa"
|
|
208
|
+
puts "Installed SWSerLCDpa into #{sketch_name}/vendor/libraries"
|
|
209
|
+
puts
|
|
210
|
+
|
|
211
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDsf/.", "#{sketch_name}/vendor/libraries/SWSerLCDsf"
|
|
212
|
+
puts "Installed SWSerLCDsf into #{sketch_name}/vendor/libraries"
|
|
213
|
+
puts
|
|
214
|
+
|
|
215
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Wire/.", "#{sketch_name}/vendor/libraries/Wire"
|
|
216
|
+
puts "Installed Wire into #{sketch_name}/vendor/libraries"
|
|
217
|
+
puts
|
|
218
|
+
|
|
219
|
+
# Build examples -- used for basic testing
|
|
220
|
+
|
|
221
|
+
FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
|
|
222
|
+
puts "Successfully created your examples directory."
|
|
223
|
+
|
|
224
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/examples/.", "#{sketch_name}/examples"
|
|
225
|
+
puts "Installed examples into #{sketch_name}/examples"
|
|
226
|
+
puts
|
|
227
|
+
|
|
228
|
+
# Build test -- used testing
|
|
229
|
+
|
|
230
|
+
# FIXME: this should put the tests into the vendor/tests directory instead.
|
|
231
|
+
|
|
232
|
+
# FileUtils.mkdir_p "#{sketch_name}/test"
|
|
233
|
+
# puts "Successfully created your test directory."
|
|
234
|
+
#
|
|
235
|
+
# FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/test/.", "#{sketch_name}/test"
|
|
236
|
+
# puts "Installed tests into #{sketch_name}/test"
|
|
237
|
+
# puts
|
|
238
|
+
|
|
239
|
+
# Build vendor/plugins:
|
|
240
|
+
|
|
241
|
+
FileUtils.mkdir_p "#{sketch_name}/vendor/plugins"
|
|
242
|
+
puts "Successfully created your plugins directory."
|
|
243
|
+
|
|
244
|
+
FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/plugins/.", "#{sketch_name}/vendor/plugins"
|
|
245
|
+
puts "Installed Default plugins into #{sketch_name}/vendor/plugins"
|
|
246
|
+
puts
|
|
247
|
+
|
|
248
|
+
# Add an default sketch directory # needed to run test:compile
|
|
249
|
+
|
|
250
|
+
FileUtils.mkdir_p "#{sketch_name}/#{sketch_name}"
|
|
251
|
+
puts "Successfully created your default sketch directory."
|
|
252
|
+
|
|
253
|
+
# Build sketch files, etc.:
|
|
254
|
+
|
|
255
|
+
FileUtils.touch "#{sketch_name}/#{sketch_name}.rb"
|
|
256
|
+
File.open("#{sketch_name}/#{sketch_name}.rb", "w") do |file|
|
|
257
|
+
file << <<-EOS
|
|
258
|
+
class #{sketch_name.split("_").collect{|c| c.capitalize}.join("")} < ArduinoSketch
|
|
259
|
+
|
|
260
|
+
# looking for hints? check out the examples directory
|
|
261
|
+
# example sketches can be uploaded to your arduino with
|
|
262
|
+
# rake make:upload sketch=examples/hello_world
|
|
263
|
+
# just replace hello_world with other examples
|
|
264
|
+
|
|
265
|
+
def loop
|
|
266
|
+
# your code here
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
end
|
|
270
|
+
EOS
|
|
271
|
+
end
|
|
272
|
+
puts "Added #{sketch_name}/#{sketch_name}.rb"
|
|
273
|
+
|
|
274
|
+
File.open("#{sketch_name}/Rakefile", 'w') do |file|
|
|
275
|
+
file << <<-EOS
|
|
276
|
+
require 'vendor/rad/init.rb'
|
|
277
|
+
EOS
|
|
278
|
+
end
|
|
279
|
+
puts "Added #{sketch_name}/Rakefile"
|
|
280
|
+
|
|
281
|
+
FileUtils.mkdir_p "#{sketch_name}/config"
|
|
282
|
+
puts "Added #{sketch_name}/config"
|
|
283
|
+
|
|
284
|
+
File.open("#{sketch_name}/config/hardware.yml", 'w') do |file|
|
|
285
|
+
file << options["hardware"].to_yaml
|
|
286
|
+
end
|
|
287
|
+
puts "Added #{sketch_name}/config/hardware.yml"
|
|
288
|
+
|
|
289
|
+
File.open("#{sketch_name}/config/software.yml", 'w') do |file|
|
|
290
|
+
file << options["software"].to_yaml
|
|
291
|
+
end
|
|
292
|
+
puts "Added #{sketch_name}/config/software.yml"
|
|
293
|
+
|
|
294
|
+
puts
|
|
295
|
+
puts "Run 'rake -T' inside your sketch dir to learn how to compile and upload it."
|
|
296
|
+
|
|
297
|
+
puts "***************************************************"
|
|
298
|
+
puts "*** Please note: This version supports ***"
|
|
299
|
+
puts "*** Arduino 12 only! ***"
|
|
300
|
+
puts "*** run rad install arduino to upgrade ***"
|
|
301
|
+
puts "***************************************************"
|
|
302
|
+
end
|