madrona-rad 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/README.rdoc +4 -3
- data/bin/rad +28 -3
- data/lib/examples/blink_m_address_assignment.rb +91 -83
- data/lib/examples/blink_m_multi.rb +60 -51
- data/lib/examples/first_sound.rb +23 -16
- data/lib/examples/frequency_generator.rb +31 -24
- data/lib/examples/hello_spectra_sound.rb +35 -26
- data/lib/rad/darwin_installer.rb +6 -6
- data/lib/rad/generators/makefile/makefile.erb +7 -4
- data/lib/rad/generators/makefile/makefile.rb +14 -0
- data/lib/rad/linux_installer.rb +16 -16
- data/lib/rad/version.rb +1 -1
- metadata +16 -3
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -12,8 +12,7 @@ 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
|
-
http://github.com/atduskgreg/rad/tree/master/lib/examples
|
15
|
+
See the examples directory for lots of examples of RAD in action
|
17
16
|
|
18
17
|
The atduskgreg/rad wiki also contains a growing library of examples and hardware tutorials:
|
19
18
|
http://github.com/atduskgreg/rad/wikis
|
@@ -46,7 +45,7 @@ Write a sketch that will blink a single LED every 500ms:
|
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
Attach your Arduino and use rake to
|
48
|
+
Attach your Arduino and use rake to compile and upload your sketch:
|
50
49
|
|
51
50
|
$ rake make:upload
|
52
51
|
|
@@ -58,6 +57,8 @@ Installing RAD and the Arduino software on Linux can be a little more difficult
|
|
58
57
|
|
59
58
|
And RAD will do its best to get the Arduino software installed on your system.
|
60
59
|
|
60
|
+
For OS X, Arduino should be installed in your applications directory -- install the intel or power pc drivers in /drivers
|
61
|
+
|
61
62
|
==Get Involved
|
62
63
|
|
63
64
|
Cheers? Jeers? Wanna help out? Contact Greg Borenstein: greg [dot] borenstein [at] gmail [dot] com
|
data/bin/rad
CHANGED
@@ -28,7 +28,7 @@ class OptionParser #:nodoc:
|
|
28
28
|
"physical_reset" => false
|
29
29
|
},
|
30
30
|
"software" => {
|
31
|
-
"arduino_root" => "/Applications/arduino-
|
31
|
+
"arduino_root" => "/Applications/arduino-0015"
|
32
32
|
}
|
33
33
|
}
|
34
34
|
|
@@ -261,9 +261,13 @@ else
|
|
261
261
|
# example sketches can be uploaded to your arduino with
|
262
262
|
# rake make:upload sketch=examples/hello_world
|
263
263
|
# just replace hello_world with other examples
|
264
|
+
#
|
265
|
+
# hello world (replace with your code):
|
264
266
|
|
267
|
+
output_pin 13, :as => :led
|
268
|
+
|
265
269
|
def loop
|
266
|
-
|
270
|
+
blink led, 100
|
267
271
|
end
|
268
272
|
|
269
273
|
end
|
@@ -282,6 +286,20 @@ else
|
|
282
286
|
puts "Added #{sketch_name}/config"
|
283
287
|
|
284
288
|
File.open("#{sketch_name}/config/hardware.yml", 'w') do |file|
|
289
|
+
file << "##############################################################
|
290
|
+
# Today's MCU Choices (replace the mcu with your arduino board)
|
291
|
+
# atmega8 => Arduino NG or older w/ ATmega8
|
292
|
+
# atmega168 => Arduino NG or older w/ ATmega168
|
293
|
+
# mini => Arduino Mini
|
294
|
+
# bt => Arduino BT
|
295
|
+
# diecimila => Arduino Diecimila or Duemilanove w/ ATmega168
|
296
|
+
# nano => Arduino Nano
|
297
|
+
# lilypad => LilyPad Arduino
|
298
|
+
# pro => Arduino Pro or Pro Mini (8 MHz)
|
299
|
+
# atmega328 => Arduino Duemilanove w/ ATmega328
|
300
|
+
# mega => Arduino Mega
|
301
|
+
|
302
|
+
"
|
285
303
|
file << options["hardware"].to_yaml
|
286
304
|
end
|
287
305
|
puts "Added #{sketch_name}/config/hardware.yml"
|
@@ -296,7 +314,14 @@ else
|
|
296
314
|
|
297
315
|
puts "***************************************************"
|
298
316
|
puts "*** Please note: This version supports ***"
|
299
|
-
puts "*** Arduino
|
317
|
+
puts "*** Arduino 15 only! ***"
|
318
|
+
puts "*** ***"
|
319
|
+
puts "*** default configuration: diecimila ***"
|
320
|
+
puts "*** to change goto config/hardware ***"
|
321
|
+
puts "*** ***"
|
322
|
+
puts "*** using usb? ***"
|
323
|
+
puts "*** don't forget to install the drivers ***"
|
324
|
+
puts "*** ***"
|
300
325
|
puts "*** run rad install arduino to upgrade ***"
|
301
326
|
puts "***************************************************"
|
302
327
|
end
|
@@ -1,5 +1,13 @@
|
|
1
1
|
class BlinkMAddressAssignment < ArduinoSketch
|
2
2
|
|
3
|
+
# IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
|
4
|
+
# the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
|
5
|
+
output_pin 13, :as => :led
|
6
|
+
|
7
|
+
def loop
|
8
|
+
blink led, 100
|
9
|
+
x = 4
|
10
|
+
end
|
3
11
|
# want to use more than one blink m?
|
4
12
|
# since each blink m arrives with the same address,
|
5
13
|
# we can't address each one individually
|
@@ -16,89 +24,89 @@ class BlinkMAddressAssignment < ArduinoSketch
|
|
16
24
|
# if you need to, program an led to help with the timing
|
17
25
|
|
18
26
|
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def loop
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def staging
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
def assign_address
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
def control_it
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
def test_address
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
|
27
|
+
# @blink_m_start_address = 10
|
28
|
+
# @flag = false
|
29
|
+
# @addr1 = "10, byte"
|
30
|
+
# @addr2 = "11, byte"
|
31
|
+
# @addr3 = "12, byte"
|
32
|
+
#
|
33
|
+
# output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
|
34
|
+
# input_pin 7, :as => :button_one, :device => :button
|
35
|
+
# input_pin 8, :as => :button_two, :device => :button
|
36
|
+
# input_pin 9, :as => :button_three, :device => :button
|
37
|
+
#
|
38
|
+
# output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
39
|
+
#
|
40
|
+
# def setup
|
41
|
+
# delay 1000
|
42
|
+
# my_lcd.setxy 0,0, "bienvenue"
|
43
|
+
# delay 5000
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# def loop
|
47
|
+
#
|
48
|
+
# if @flag == false
|
49
|
+
# staging
|
50
|
+
# else
|
51
|
+
# test_address
|
52
|
+
# end
|
53
|
+
# delay 100
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# def staging
|
57
|
+
# my_lcd.setxy 0,0, "press button one to"
|
58
|
+
# my_lcd.setxy 0,1, "set address to "
|
59
|
+
# my_lcd.print @blink_m_start_address
|
60
|
+
# my_lcd.setxy 0,2, "or two for status"
|
61
|
+
# delay 60
|
62
|
+
# my_lcd.setxy 0,3, " "
|
63
|
+
# my_lcd.setxy 0,3
|
64
|
+
# 800.times do |i|
|
65
|
+
# return 0 if @flag == true
|
66
|
+
# my_lcd.print "." if i % 50 == 0
|
67
|
+
# delay 5
|
68
|
+
# if button_one.read_input
|
69
|
+
# assign_address
|
70
|
+
# elsif button_two.read_input
|
71
|
+
# test_address
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
# @blink_m_start_address += 1
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# def assign_address
|
78
|
+
# @flag = true
|
79
|
+
# my_lcd.clearscr "setting to "
|
80
|
+
# my_lcd.print @blink_m_start_address
|
81
|
+
# delay 100
|
82
|
+
# BlinkM_setAddress @blink_m_start_address
|
83
|
+
# my_lcd.clearscr "done"
|
84
|
+
# control_it
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# def control_it
|
88
|
+
# delay 500
|
89
|
+
# my_lcd.clearscr "stopping script"
|
90
|
+
# BlinkM_stopScript @blink_m_start_address
|
91
|
+
# my_lcd.clearscr "stopping script.."
|
92
|
+
# delay 500
|
93
|
+
# my_lcd.clearscr "fade to purple.."
|
94
|
+
# BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
|
95
|
+
# my_lcd.clearscr "fade to purple"
|
96
|
+
# delay 500
|
97
|
+
# BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
#
|
101
|
+
# def test_address
|
102
|
+
# my_lcd.clearscr
|
103
|
+
# my_lcd.setxy 0,0, "testing address"
|
104
|
+
# my_lcd.setxy 0,1
|
105
|
+
# my_lcd.print blink_m_check_address_message @blink_m_start_address
|
106
|
+
# delay 5000
|
107
|
+
# end
|
108
|
+
#
|
109
|
+
#
|
102
110
|
|
103
111
|
|
104
112
|
end
|
@@ -1,61 +1,70 @@
|
|
1
1
|
class BlinkMMulti < ArduinoSketch
|
2
|
+
|
3
|
+
# IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
|
4
|
+
# the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
|
5
|
+
output_pin 13, :as => :led
|
6
|
+
|
7
|
+
def loop
|
8
|
+
blink led, 100
|
9
|
+
x = 4
|
10
|
+
end
|
2
11
|
|
3
12
|
# demonstrate control of individual blinkms
|
4
13
|
# this assumes the leds have been assigned addresses 10, 11, 12
|
5
14
|
# which can be done with blink m address assignment
|
6
15
|
|
7
16
|
# two ways to address the blinkms, array and individual variables
|
8
|
-
@blink_addresses = [10,11,12]
|
9
|
-
@addr_all = "0, byte"
|
10
|
-
@addr1 = "10, byte"
|
11
|
-
@addr2 = "11, byte"
|
12
|
-
@addr3 = "12, byte"
|
13
|
-
|
14
|
-
output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
|
15
|
-
input_pin 7, :as => :button_one, :device => :button
|
16
|
-
input_pin 8, :as => :button_two, :device => :button
|
17
|
-
input_pin 9, :as => :button_three, :device => :button
|
18
|
-
input_pin 10, :as => :button_four, :device => :button
|
19
|
-
|
20
|
-
# display the action on a 4x20 pa_lcd, yours may be 9200 instead of 19,200
|
21
|
-
|
22
|
-
output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
23
|
-
|
24
|
-
|
25
|
-
def loop
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def stop_and_fade(addr)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def dance
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
17
|
+
# @blink_addresses = [10,11,12]
|
18
|
+
# @addr_all = "0, byte"
|
19
|
+
# @addr1 = "10, byte"
|
20
|
+
# @addr2 = "11, byte"
|
21
|
+
# @addr3 = "12, byte"
|
22
|
+
#
|
23
|
+
# output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
|
24
|
+
# input_pin 7, :as => :button_one, :device => :button
|
25
|
+
# input_pin 8, :as => :button_two, :device => :button
|
26
|
+
# input_pin 9, :as => :button_three, :device => :button
|
27
|
+
# input_pin 10, :as => :button_four, :device => :button
|
28
|
+
#
|
29
|
+
# # display the action on a 4x20 pa_lcd, yours may be 9200 instead of 19,200
|
30
|
+
#
|
31
|
+
# output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# def loop
|
35
|
+
# stop_and_fade(@addr1) if button_one.read_input
|
36
|
+
# stop_and_fade(@addr2) if button_two.read_input
|
37
|
+
# stop_and_fade(@addr3) if button_three.read_input
|
38
|
+
# dance if button_four.read_input
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# def stop_and_fade(addr)
|
42
|
+
# f = 1 + addr # hack to coerce addr to int
|
43
|
+
# my_lcd.clearscr
|
44
|
+
# my_lcd.setxy 0,0, "blinkm # "
|
45
|
+
# my_lcd.print addr
|
46
|
+
# delay 700
|
47
|
+
# BlinkM_stopScript addr
|
48
|
+
# my_lcd.setxy 0,1, "stopping script.."
|
49
|
+
# delay 700
|
50
|
+
# my_lcd.setxy 0,2, "fade to purple.."
|
51
|
+
# BlinkM_fadeToRGB(addr, 0xff,0x00,0xff)
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# def dance
|
55
|
+
# BlinkM_setFadeSpeed(@addr_all, 20) # 1-255, with 1 producing the slowest fade
|
56
|
+
# my_lcd.clearscr
|
57
|
+
# my_lcd.setxy 0,0, "Do the shimmy.."
|
58
|
+
# my_lcd.setxy 0,1
|
59
|
+
# @blink_addresses.each do |a|
|
60
|
+
# BlinkM_fadeToRGB(a, 1,166,138)
|
61
|
+
# delay 100
|
62
|
+
# end
|
63
|
+
# @blink_addresses.each do |a|
|
64
|
+
# BlinkM_fadeToRGB(a, 35,0,112)
|
65
|
+
# delay 100
|
66
|
+
# end
|
67
|
+
# end
|
59
68
|
|
60
69
|
|
61
70
|
end
|
data/lib/examples/first_sound.rb
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
class FirstSound < ArduinoSketch
|
2
2
|
|
3
|
+
# IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
|
4
|
+
# the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
|
5
|
+
output_pin 13, :as => :led
|
3
6
|
|
7
|
+
def loop
|
8
|
+
blink led, 100
|
9
|
+
x = 4
|
10
|
+
end
|
4
11
|
|
5
|
-
output_pin 11, :as => :myTone, :device => :freq_out, :frequency => 100 # frequency required
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
# output_pin 11, :as => :myTone, :device => :freq_out, :frequency => 100 # frequency required
|
13
|
+
#
|
14
|
+
# def loop
|
15
|
+
# myTone.disable
|
16
|
+
# 1.upto(400) { |x| tone_out x } # run up the scale to 4000 Hz in 10 Hz steps
|
17
|
+
# 399.downto(1) { |x| tone_out x } # come back down in 10 Hz steps
|
18
|
+
# delay 2000
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# def tone_out(n)
|
22
|
+
# myTone.set_frequency 10*n
|
23
|
+
# myTone.enable
|
24
|
+
# delay 80
|
25
|
+
# myTone.disable
|
26
|
+
# delay 10
|
27
|
+
# end
|
21
28
|
|
22
29
|
|
23
30
|
end
|
@@ -1,30 +1,37 @@
|
|
1
1
|
class FrequencyGenerator < ArduinoSketch
|
2
|
-
|
2
|
+
# IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
|
3
|
+
# the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
|
4
|
+
output_pin 13, :as => :led
|
5
|
+
|
6
|
+
def loop
|
7
|
+
blink led, 100
|
8
|
+
x = 4
|
9
|
+
end
|
3
10
|
# need explaination
|
4
11
|
|
5
|
-
output_pin 11, :as => :myTone, :device => :freq_out, :frequency => 100
|
6
|
-
|
7
|
-
def loop
|
8
|
-
uh_oh 4
|
9
|
-
end
|
10
|
-
|
11
|
-
def uh_oh(n)
|
12
|
-
|
13
|
-
|
14
|
-
n.times do
|
15
|
-
myTone.enable
|
16
|
-
myTone.set_frequency 1800
|
17
|
-
delay 500
|
18
|
-
myTone.disable
|
19
|
-
delay 100
|
20
|
-
myTone.enable
|
21
|
-
myTone.set_frequency 1800
|
22
|
-
delay 800
|
23
|
-
myTone.enable
|
24
|
-
end
|
25
|
-
# hack to help translator guess that n is an int
|
26
|
-
f = n + 0
|
27
|
-
end
|
12
|
+
# output_pin 11, :as => :myTone, :device => :freq_out, :frequency => 100
|
13
|
+
#
|
14
|
+
# def loop
|
15
|
+
# uh_oh 4
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def uh_oh(n)
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# n.times do
|
22
|
+
# myTone.enable
|
23
|
+
# myTone.set_frequency 1800
|
24
|
+
# delay 500
|
25
|
+
# myTone.disable
|
26
|
+
# delay 100
|
27
|
+
# myTone.enable
|
28
|
+
# myTone.set_frequency 1800
|
29
|
+
# delay 800
|
30
|
+
# myTone.enable
|
31
|
+
# end
|
32
|
+
# # hack to help translator guess that n is an int
|
33
|
+
# f = n + 0
|
34
|
+
# end
|
28
35
|
|
29
36
|
|
30
37
|
end
|
@@ -1,5 +1,14 @@
|
|
1
1
|
class HelloSpectraSound < ArduinoSketch
|
2
2
|
|
3
|
+
# IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
|
4
|
+
# the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
|
5
|
+
output_pin 13, :as => :led
|
6
|
+
|
7
|
+
def loop
|
8
|
+
blink led, 100
|
9
|
+
x = 4
|
10
|
+
end
|
11
|
+
|
3
12
|
# demonstrate capability to use soft pot as traditional pot
|
4
13
|
# the last pot reading remains "locked" to the last touch point
|
5
14
|
# similar same behavior as ipod
|
@@ -7,32 +16,32 @@ class HelloSpectraSound < ArduinoSketch
|
|
7
16
|
# this sketch assumes a pa_lcd operating at 19200 and one
|
8
17
|
# spectra symbol softpot connected to analog pin 3
|
9
18
|
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# my_lcd.print pad_int_to_str analogRead(sensor_one), 5
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
19
|
+
# @reading = int
|
20
|
+
# output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 9600, :clear_screen => :true
|
21
|
+
# output_pin 11, :as => :sound, :device => :freq_out, :frequency => 100, :enable => :true
|
22
|
+
# input_pin 3, :as => :sensor_one, :device => :spectra
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# def setup
|
26
|
+
# delay 1000
|
27
|
+
# my_lcd.setxy 0,0, "spectra symbol"
|
28
|
+
# my_lcd.setxy 0,1, "soft pot sound"
|
29
|
+
# delay 3000
|
30
|
+
# my_lcd.clearscr
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# def loop
|
34
|
+
# my_lcd.setxy 0,1
|
35
|
+
# # since lcd's have issues clearing tens and hundreds digits when reading ones,
|
36
|
+
# # we use pad_int_to_str, which is a hack to display these cleanly
|
37
|
+
# # pad_int_to_str takes two arguments: an integer and the final string length
|
38
|
+
# #
|
39
|
+
# # my_lcd.print pad_int_to_str analogRead(sensor_one), 5
|
40
|
+
# @reading = sensor_one.soft_lock
|
41
|
+
# sound.set_frequency @reading * 10
|
42
|
+
# my_lcd.print pad_int_to_str @reading, 3
|
43
|
+
# delay 30
|
44
|
+
# end
|
36
45
|
|
37
46
|
|
38
47
|
end
|
data/lib/rad/darwin_installer.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class DarwinInstaller
|
2
2
|
def self.install!
|
3
|
-
puts "Downloading arduino-
|
4
|
-
File.open("/Applications/arduino-
|
3
|
+
puts "Downloading arduino-0015 for Mac from Arduino.cc"
|
4
|
+
File.open("/Applications/arduino-0015.zip", "w") do |file|
|
5
5
|
pbar = nil
|
6
|
-
file << open("http://
|
6
|
+
file << open("http://arduino.googlecode.com/files/arduino-0015-mac.zip",
|
7
7
|
:content_length_proc => lambda {|t|
|
8
8
|
if t && 0 < t
|
9
9
|
pbar = ProgressBar.new(" Progress", t)
|
@@ -16,8 +16,8 @@ class DarwinInstaller
|
|
16
16
|
pbar.finish
|
17
17
|
end
|
18
18
|
puts "Unzipping..."
|
19
|
-
`cd /Applications; unzip arduino-
|
20
|
-
`rm /Applications/arduino-
|
21
|
-
puts "installed Arduino here: /Applications/arduino-
|
19
|
+
`cd /Applications; unzip arduino-0015.zip`
|
20
|
+
`rm /Applications/arduino-0015.zip`
|
21
|
+
puts "installed Arduino here: /Applications/arduino-0015"
|
22
22
|
end
|
23
23
|
end
|
@@ -59,6 +59,9 @@
|
|
59
59
|
# upload your program to the Arduino board.
|
60
60
|
#
|
61
61
|
# $Id$
|
62
|
+
#
|
63
|
+
#
|
64
|
+
#
|
62
65
|
|
63
66
|
PORT = <%= params['serial_port'] %>
|
64
67
|
TARGET = <%= params['target'] %>
|
@@ -70,11 +73,11 @@ $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
|
70
73
|
$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
|
71
74
|
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c <%= params['twi_c'] %>
|
72
75
|
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(SOFTWARE_SERIAL)/SoftwareSerial.cpp $(ARDUINO)/Print.cpp<%= params['libraries'].collect{|l| " $(LIBRARY_ROOT)/#{ l }/#{l }.cpp"}.join('') %>
|
73
|
-
MCU = <%= params['mcu'] %>
|
76
|
+
MCU = <%= params['build.mcu'] %>
|
74
77
|
<% if params['asm_files'] %>ASRC = <%= params['asm_files'].join(' ') %><% end %>
|
75
|
-
F_CPU =
|
78
|
+
F_CPU = <%= params['build.f_cpu'].chomp("L") %>
|
76
79
|
FORMAT = ihex
|
77
|
-
UPLOAD_RATE =
|
80
|
+
UPLOAD_RATE = <%= params['upload.speed']%>
|
78
81
|
BIN_DIR = <%= params['arduino_root'] %>/hardware/tools/avr/bin
|
79
82
|
|
80
83
|
# Name of this Makefile (used for "make depend").
|
@@ -113,7 +116,7 @@ LDFLAGS = -lm
|
|
113
116
|
|
114
117
|
|
115
118
|
# Programming support using avrdude. Settings and variables.
|
116
|
-
AVRDUDE_PROGRAMMER =
|
119
|
+
AVRDUDE_PROGRAMMER = <%= params['upload.protocol'] %>
|
117
120
|
AVRDUDE_PORT = $(PORT)
|
118
121
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
119
122
|
AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
@@ -7,6 +7,8 @@ class Makefile
|
|
7
7
|
# build the sketch Makefile for the given template based on the values in its software and hardware config files
|
8
8
|
def compose_for_sketch(build_dir)
|
9
9
|
params = hardware_params.merge software_params
|
10
|
+
board_config = board_configuration(@software_params['arduino_root'], @hardware_params['mcu'])
|
11
|
+
params = params.merge board_config
|
10
12
|
params['target'] = build_dir.split("/").last
|
11
13
|
|
12
14
|
params['libraries_root'] = "#{File.expand_path(RAD_ROOT)}/vendor/libraries"
|
@@ -33,6 +35,18 @@ class Makefile
|
|
33
35
|
return @software_params if @software_params
|
34
36
|
return @software_params = YAML.load_file( "#{RAD_ROOT}/config/software.yml" )
|
35
37
|
end
|
38
|
+
|
39
|
+
## match the mcu with the proper board configuration from the arduino board.txt file
|
40
|
+
def board_configuration(arduino_root, board_name)
|
41
|
+
board_configuration = {}
|
42
|
+
File.open("#{arduino_root}/hardware/boards.txt", "r") do |infile|
|
43
|
+
infile.each_line do |line|
|
44
|
+
next unless line.chomp =~ /^#{board_name}\.([^=]*)=(.*)$/
|
45
|
+
board_configuration[$1] = $2
|
46
|
+
end
|
47
|
+
end
|
48
|
+
board_configuration
|
49
|
+
end
|
36
50
|
|
37
51
|
end
|
38
52
|
end
|
data/lib/rad/linux_installer.rb
CHANGED
@@ -91,34 +91,34 @@ class LinuxInstaller
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def self.check_or_install_arduino
|
94
|
-
if File.exist?("/usr/local/arduino-
|
95
|
-
puts "arduino software previously installed at /usr/local/arduino-
|
94
|
+
if File.exist?("/usr/local/arduino-0015")
|
95
|
+
puts "arduino software previously installed at /usr/local/arduino-0015 !"
|
96
96
|
else
|
97
97
|
puts "installing arduino software..."
|
98
|
-
%x{cd /usr/local/; wget http://arduino.
|
99
|
-
%x{tar -C /usr/local -xzf /usr/local/arduino-
|
98
|
+
%x{cd /usr/local/; wget http://arduino.googlecode.com/files/arduino-0015-linux.tgz}
|
99
|
+
%x{tar -C /usr/local -xzf /usr/local/arduino-0015-linux.tgz}
|
100
100
|
|
101
|
-
%x{ln -s /usr/local/arduino-
|
101
|
+
%x{ln -s /usr/local/arduino-0015/arduino ~/Desktop/arduino}
|
102
102
|
|
103
103
|
# gotta patch it so it can run from command line or anywhere
|
104
|
-
arduino_file = File.open("/usr/local/arduino-
|
104
|
+
arduino_file = File.open("/usr/local/arduino-0015/arduino") {|f| f.read}
|
105
105
|
new_doc = arduino_file.split("\n")
|
106
|
-
new_doc[1] = "cd /usr/local/arduino-
|
107
|
-
File.open("/usr/local/arduino-
|
106
|
+
new_doc[1] = "cd /usr/local/arduino-0015"
|
107
|
+
File.open("/usr/local/arduino-0015/arduino", "w") {|f| f.puts new_doc }
|
108
108
|
|
109
|
-
%x{mkdir -p /usr/local/arduino-
|
109
|
+
%x{mkdir -p /usr/local/arduino-0015/hardware/tools/avr/bin}
|
110
110
|
# there is a difference from what the makefile expects to where it is
|
111
|
-
%x{ln -s /usr/bin/avr-gcc /usr/local/arduino-
|
112
|
-
%x{ln -s /usr/bin/avr-g++ /usr/local/arduino-
|
113
|
-
%x{ln -s /usr/bin/avr-ar /usr/local/arduino-
|
114
|
-
%x{ln -s /usr/bin/avr-objcopy /usr/local/arduino-
|
115
|
-
%x{ln -s /usr/local/arduino-
|
116
|
-
%x{ln -s /usr/local/arduino-
|
111
|
+
%x{ln -s /usr/bin/avr-gcc /usr/local/arduino-0015/hardware/tools/avr/bin/avr-gcc}
|
112
|
+
%x{ln -s /usr/bin/avr-g++ /usr/local/arduino-0015/hardware/tools/avr/bin/avr-g++}
|
113
|
+
%x{ln -s /usr/bin/avr-ar /usr/local/arduino-0015/hardware/tools/avr/bin/avr-ar}
|
114
|
+
%x{ln -s /usr/bin/avr-objcopy /usr/local/arduino-0015/hardware/tools/avr/bin/avr-objcopy}
|
115
|
+
%x{ln -s /usr/local/arduino-0015/hardware/tools/avrdude /usr/local/arduino-0015/hardware/tools/avr/bin/avrdude}
|
116
|
+
%x{ln -s /usr/local/arduino-0015/hardware/tools/avrdude.conf /usr/local/arduino-0015/hardware/tools/avr/etc/avrdude.conf}
|
117
117
|
|
118
118
|
|
119
119
|
puts
|
120
120
|
puts "************************************************************************"
|
121
|
-
puts "** please add /usr/local/arduino-
|
121
|
+
puts "** please add /usr/local/arduino-0015 to your path! **"
|
122
122
|
puts "** you will also need to run sudo update-alternatives --config java **"
|
123
123
|
puts "** to choose java-1.50-sun as the default java **"
|
124
124
|
puts "************************************************************************"
|
data/lib/rad/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madrona-rad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Borenstein
|
8
|
-
-
|
8
|
+
- JD Barnhart
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
@@ -46,6 +46,19 @@ dependencies:
|
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.2
|
48
48
|
version:
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: ParseTree
|
51
|
+
type: :runtime
|
52
|
+
version_requirement:
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "3.0"
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.0.4
|
61
|
+
version:
|
49
62
|
description: "Ruby Arduino Development: a framework for programming the Arduino physcial computing platform using Ruby"
|
50
63
|
email: jd@jdbarnhart.com
|
51
64
|
executables:
|
@@ -228,6 +241,6 @@ rubyforge_project: rad
|
|
228
241
|
rubygems_version: 1.3.5
|
229
242
|
signing_key:
|
230
243
|
specification_version: 2
|
231
|
-
summary: "RAD: Ruby Arduino Development - 0.3.
|
244
|
+
summary: "RAD: Ruby Arduino Development - 0.3.6 -- 1.9 Ready"
|
232
245
|
test_files: []
|
233
246
|
|