madrona-rad 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Rakefile +38 -129
- data/VERSION +1 -0
- data/bin/{rad → madrona-rad} +0 -0
- data/lib/examples/blink_m_address_assignment.rb +84 -92
- data/lib/examples/blink_m_multi.rb +52 -61
- data/lib/plugins/blink_m.rb +0 -8
- data/lib/rad/antiquated_todo.txt +47 -0
- data/madrona-rad.gemspec +201 -0
- data/project_dev.rake +36 -0
- data/test/fixture.rb +51 -0
- metadata +42 -42
- data/scripts/txt2html +0 -67
- data/website/examples/assembler_test.rb.html +0 -73
- data/website/examples/gps_reader.rb.html +0 -39
- data/website/examples/hello_world.rb.html +0 -38
- data/website/examples/serial_motor.rb.html +0 -41
- data/website/index.html +0 -178
- data/website/index.txt +0 -64
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -169
- data/website/template.rhtml +0 -48
data/.gitignore
ADDED
data/Rakefile
CHANGED
@@ -1,145 +1,54 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require 'rake/packagetask'
|
6
|
-
require 'rake/gempackagetask'
|
7
|
-
require 'rake/rdoctask'
|
8
|
-
require 'rake/contrib/rubyforgepublisher'
|
9
|
-
require 'fileutils'
|
10
|
-
require 'hoe'
|
11
|
-
|
12
|
-
$: << "../lib/" # HACK while I work out r2c/rad incompatibilities
|
13
|
-
# gem "RubyToC" # HACK to deal with rubygems beta version activation bug
|
14
|
-
|
15
|
-
RAD_ROOT = File.expand_path(File.dirname(__FILE__))
|
16
3
|
|
17
4
|
begin
|
18
|
-
require '
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
EMAIL = "greg@mfdz.com"
|
31
|
-
DESCRIPTION = "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."
|
32
|
-
GEM_NAME = 'rad' # what ppl will type to install your gem
|
33
|
-
|
34
|
-
@config_file = "~/.rubyforge/user-config.yml"
|
35
|
-
@config = nil
|
36
|
-
def rubyforge_username
|
37
|
-
unless @config
|
38
|
-
begin
|
39
|
-
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
40
|
-
rescue
|
41
|
-
puts <<-EOS
|
42
|
-
ERROR: No rubyforge config file found: #{@config_file}"
|
43
|
-
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
44
|
-
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
45
|
-
EOS
|
46
|
-
exit
|
47
|
-
end
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "madrona-rad"
|
8
|
+
gem.summary = %Q{RAD: Ruby Arduino Development - 0.4.1 -- 1.9 Ready!}
|
9
|
+
gem.description = %Q{Ruby Arduino Development: a framework for programming the Arduino physcial computing platform using Ruby}
|
10
|
+
gem.email = "jd@jdbarnhart.com"
|
11
|
+
gem.homepage = "http://github.com/madrona/madrona-rad"
|
12
|
+
gem.authors = ["JD Barnhart", "Greg Borenstein"]
|
13
|
+
gem.add_dependency "ruby2c", ">= 1.0.0.7"
|
14
|
+
gem.add_dependency "sexp_processor", ">=3.0.2"
|
15
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
48
17
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
RUBYFORGE_PROJECT = 'rad' # The unix name for your project
|
53
|
-
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
54
|
-
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
55
|
-
|
56
|
-
NAME = "rad"
|
57
|
-
REV = nil
|
58
|
-
# UNCOMMENT IF REQUIRED:
|
59
|
-
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
60
|
-
VERS = Rad::VERSION::STRING + (REV ? ".#{REV}" : "")
|
61
|
-
CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
|
62
|
-
RDOC_OPTS = ['--quiet', '--title', 'rad documentation',
|
63
|
-
"--opname", "index.html",
|
64
|
-
"--line-numbers",
|
65
|
-
"--main", "README",
|
66
|
-
"--inline-source"]
|
67
|
-
|
68
|
-
class Hoe
|
69
|
-
def extra_deps
|
70
|
-
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
71
|
-
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
72
20
|
end
|
73
21
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
p.email = EMAIL
|
80
|
-
p.summary = DESCRIPTION
|
81
|
-
p.url = HOMEPATH
|
82
|
-
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
83
|
-
p.test_globs = ["test/**/test_*.rb"]
|
84
|
-
p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
|
85
|
-
|
86
|
-
# == Optional
|
87
|
-
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
88
|
-
p.extra_deps = [ ['ruby2c', '>= 1.0.0.6'] ]
|
89
|
-
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
90
27
|
end
|
91
28
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
100
39
|
end
|
101
40
|
end
|
102
41
|
|
103
|
-
|
104
|
-
task :website_upload do
|
105
|
-
host = "#{rubyforge_username}@rubyforge.org"
|
106
|
-
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
107
|
-
local_dir = 'website'
|
108
|
-
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
109
|
-
end
|
110
|
-
|
111
|
-
desc 'Generate and upload website files'
|
112
|
-
task :website => [:website_generate, :website_upload, :publish_docs]
|
113
|
-
|
114
|
-
desc 'Release the website and new gem version'
|
115
|
-
task :deploy => [:check_version, :website, :release] do
|
116
|
-
puts "Remember to create SVN tag:"
|
117
|
-
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
118
|
-
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
119
|
-
puts "Suggested comment:"
|
120
|
-
puts "Tagging release #{CHANGES}"
|
121
|
-
end
|
42
|
+
task :test => :check_dependencies
|
122
43
|
|
123
|
-
|
124
|
-
task :local_deploy => [:website_generate, :install_gem]
|
44
|
+
task :default => :test
|
125
45
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
exit
|
130
|
-
end
|
131
|
-
unless ENV['VERSION'] == VERS
|
132
|
-
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
133
|
-
exit
|
134
|
-
end
|
135
|
-
end
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
136
49
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "madrona-rad #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
141
54
|
end
|
142
|
-
|
143
|
-
desc "Default task is to run specs"
|
144
|
-
task :default => :spec
|
145
|
-
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.1
|
data/bin/{rad → madrona-rad}
RENAMED
File without changes
|
@@ -1,13 +1,5 @@
|
|
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
|
11
3
|
# want to use more than one blink m?
|
12
4
|
# since each blink m arrives with the same address,
|
13
5
|
# we can't address each one individually
|
@@ -22,91 +14,91 @@ class BlinkMAddressAssignment < ArduinoSketch
|
|
22
14
|
# address to 10, during the next four seconds to 11 and so on
|
23
15
|
# difficult without a screen.
|
24
16
|
# if you need to, program an led to help with the timing
|
25
|
-
|
17
|
+
|
26
18
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
+
|
110
102
|
|
111
103
|
|
112
104
|
end
|
@@ -1,70 +1,61 @@
|
|
1
1
|
class BlinkMMulti < 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
|
-
|
12
3
|
# demonstrate control of individual blinkms
|
13
4
|
# this assumes the leds have been assigned addresses 10, 11, 12
|
14
5
|
# which can be done with blink m address assignment
|
15
6
|
|
16
7
|
# two ways to address the blinkms, array and individual variables
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
+
stop_and_fade(@addr1) if button_one.read_input
|
27
|
+
stop_and_fade(@addr2) if button_two.read_input
|
28
|
+
stop_and_fade(@addr3) if button_three.read_input
|
29
|
+
dance if button_four.read_input
|
30
|
+
end
|
31
|
+
|
32
|
+
def stop_and_fade(addr)
|
33
|
+
f = 1 + addr # hack to coerce addr to int
|
34
|
+
my_lcd.clearscr
|
35
|
+
my_lcd.setxy 0,0, "blinkm # "
|
36
|
+
my_lcd.print addr
|
37
|
+
delay 700
|
38
|
+
BlinkM_stopScript addr
|
39
|
+
my_lcd.setxy 0,1, "stopping script.."
|
40
|
+
delay 700
|
41
|
+
my_lcd.setxy 0,2, "fade to purple.."
|
42
|
+
BlinkM_fadeToRGB(addr, 0xff,0x00,0xff)
|
43
|
+
end
|
44
|
+
|
45
|
+
def dance
|
46
|
+
BlinkM_setFadeSpeed(@addr_all, 20) # 1-255, with 1 producing the slowest fade
|
47
|
+
my_lcd.clearscr
|
48
|
+
my_lcd.setxy 0,0, "Do the shimmy.."
|
49
|
+
my_lcd.setxy 0,1
|
50
|
+
@blink_addresses.each do |a|
|
51
|
+
BlinkM_fadeToRGB(a, 1,166,138)
|
52
|
+
delay 100
|
53
|
+
end
|
54
|
+
@blink_addresses.each do |a|
|
55
|
+
BlinkM_fadeToRGB(a, 35,0,112)
|
56
|
+
delay 100
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
69
60
|
|
70
61
|
end
|