subduino 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +26 -0
- data/Rakefile +76 -0
- data/Readme.textile +46 -0
- data/VERSION +1 -0
- data/bin/subduino +34 -0
- data/bin/subduino-cli +65 -0
- data/duino/.gitignore +2 -0
- data/duino/Makefile +401 -0
- data/duino/duino.pde +17 -0
- data/duino/duino.rb +16 -0
- data/duino/methods.pde +5 -0
- data/lib/subduino/ard_io.rb +60 -0
- data/lib/subduino/ard_ps.rb +38 -0
- data/lib/subduino/arduino.rb +30 -0
- data/lib/subduino/parse.rb +61 -0
- data/lib/subduino/scaffold/Makefile +401 -0
- data/lib/subduino/scaffold/Makefile2 +247 -0
- data/lib/subduino/scaffold/generator.rb +29 -0
- data/lib/subduino/scaffold/scaffold.pde +17 -0
- data/lib/subduino/scaffold/scaffold.rb +16 -0
- data/lib/subduino/store.rb +65 -0
- data/lib/subduino.rb +48 -0
- data/node/arduinode.js +68 -0
- data/node/server.js +45 -0
- data/node/vendor/faye.js +1925 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/subduino/ard_io_spec.rb +9 -0
- data/spec/subduino/parse_spec.rb +21 -0
- data/spec/subduino/store_spec.rb +17 -0
- data/spec/subduino_spec.rb +20 -0
- data/subduino.gemspec +239 -0
- data/webapp/Gemfile +8 -0
- data/webapp/Gemfile.lock +14 -0
- data/webapp/Rakefile +49 -0
- data/webapp/Readme.textile +45 -0
- data/webapp/VERSION +1 -0
- data/webapp/lib/app.rb +103 -0
- data/webapp/lib/duino.rb +213 -0
- data/webapp/lib/environment.rb +36 -0
- data/webapp/lib/messenger.rb +16 -0
- data/webapp/public/app.css +119 -0
- data/webapp/public/app.js +34 -0
- data/webapp/public/faye.js +1 -0
- data/webapp/public/icons/alarm-clock-blue.png +0 -0
- data/webapp/public/icons/alarm-clock.png +0 -0
- data/webapp/public/icons/balloon-left.png +0 -0
- data/webapp/public/icons/bandaid.png +0 -0
- data/webapp/public/icons/bell-disable.png +0 -0
- data/webapp/public/icons/bell.png +0 -0
- data/webapp/public/icons/big_icon.png +0 -0
- data/webapp/public/icons/bomb.png +0 -0
- data/webapp/public/icons/bookmark.png +0 -0
- data/webapp/public/icons/box-label.png +0 -0
- data/webapp/public/icons/brightness-control-up.png +0 -0
- data/webapp/public/icons/brightness-control.png +0 -0
- data/webapp/public/icons/brightness-small.png +0 -0
- data/webapp/public/icons/broom.png +0 -0
- data/webapp/public/icons/bug.png +0 -0
- data/webapp/public/icons/calculator.png +0 -0
- data/webapp/public/icons/calendar-day.png +0 -0
- data/webapp/public/icons/camera.png +0 -0
- data/webapp/public/icons/cards-address.png +0 -0
- data/webapp/public/icons/chart.png +0 -0
- data/webapp/public/icons/clock-select.png +0 -0
- data/webapp/public/icons/color.png +0 -0
- data/webapp/public/icons/compass.png +0 -0
- data/webapp/public/icons/control-power-small.png +0 -0
- data/webapp/public/icons/control-power.png +0 -0
- data/webapp/public/icons/control-record-small.png +0 -0
- data/webapp/public/icons/cpus.png +0 -0
- data/webapp/public/icons/credit-card.png +0 -0
- data/webapp/public/icons/cross-small.png +0 -0
- data/webapp/public/icons/dashboard.png +0 -0
- data/webapp/public/icons/database.png +0 -0
- data/webapp/public/icons/databases.png +0 -0
- data/webapp/public/icons/door-open-in.png +0 -0
- data/webapp/public/icons/door-open-out.png +0 -0
- data/webapp/public/icons/door-open.png +0 -0
- data/webapp/public/icons/door.png +0 -0
- data/webapp/public/icons/drive-globe.png +0 -0
- data/webapp/public/icons/equalizer.png +0 -0
- data/webapp/public/icons/exclamation-diamond.png +0 -0
- data/webapp/public/icons/exclamation.png +0 -0
- data/webapp/public/icons/eye-disable.png +0 -0
- data/webapp/public/icons/eye.png +0 -0
- data/webapp/public/icons/false.png +0 -0
- data/webapp/public/icons/gear-small.png +0 -0
- data/webapp/public/icons/gear.png +0 -0
- data/webapp/public/icons/groups.png +0 -0
- data/webapp/public/icons/heart.png +0 -0
- data/webapp/public/icons/heart_empty.png +0 -0
- data/webapp/public/icons/info.png +0 -0
- data/webapp/public/icons/key.png +0 -0
- data/webapp/public/icons/lightbulb.png +0 -0
- data/webapp/public/icons/lightbulb_off.png +0 -0
- data/webapp/public/icons/lightning-disable.png +0 -0
- data/webapp/public/icons/lightning-small.png +0 -0
- data/webapp/public/icons/lightning.png +0 -0
- data/webapp/public/icons/lock-unlock.png +0 -0
- data/webapp/public/icons/lock.png +0 -0
- data/webapp/public/icons/marker.png +0 -0
- data/webapp/public/icons/media-player-phone.png +0 -0
- data/webapp/public/icons/megaphone.png +0 -0
- data/webapp/public/icons/mem.png +0 -0
- data/webapp/public/icons/microphone.png +0 -0
- data/webapp/public/icons/monitor.png +0 -0
- data/webapp/public/icons/navigation.png +0 -0
- data/webapp/public/icons/off.png +0 -0
- data/webapp/public/icons/on.png +0 -0
- data/webapp/public/icons/pin.png +0 -0
- data/webapp/public/icons/plug--exclamation.png +0 -0
- data/webapp/public/icons/plug-disable.png +0 -0
- data/webapp/public/icons/plug.png +0 -0
- data/webapp/public/icons/restart.png +0 -0
- data/webapp/public/icons/ruby.png +0 -0
- data/webapp/public/icons/server.png +0 -0
- data/webapp/public/icons/shield-disable.png +0 -0
- data/webapp/public/icons/shield.png +0 -0
- data/webapp/public/icons/socket--exclamation.png +0 -0
- data/webapp/public/icons/socket-disable.png +0 -0
- data/webapp/public/icons/socket.png +0 -0
- data/webapp/public/icons/start.png +0 -0
- data/webapp/public/icons/stop.png +0 -0
- data/webapp/public/icons/switch--exclamation.png +0 -0
- data/webapp/public/icons/switch-disable.png +0 -0
- data/webapp/public/icons/switch-small.png +0 -0
- data/webapp/public/icons/switch.png +0 -0
- data/webapp/public/icons/target.png +0 -0
- data/webapp/public/icons/television-off.png +0 -0
- data/webapp/public/icons/television.png +0 -0
- data/webapp/public/icons/terminal.png +0 -0
- data/webapp/public/icons/tick-small.png +0 -0
- data/webapp/public/icons/traffic-light-off.png +0 -0
- data/webapp/public/icons/traffic-light.png +0 -0
- data/webapp/public/icons/traffic.png +0 -0
- data/webapp/public/icons/true.png +0 -0
- data/webapp/public/icons/umbrella.png +0 -0
- data/webapp/public/icons/unmonitor.png +0 -0
- data/webapp/public/icons/unmonitored.png +0 -0
- data/webapp/public/icons/users.png +0 -0
- data/webapp/public/icons/vcard.png +0 -0
- data/webapp/public/icons/wall.png +0 -0
- data/webapp/public/icons/wall_brick.png +0 -0
- data/webapp/public/icons/wall_disable.png +0 -0
- data/webapp/public/icons/wand-disable.png +0 -0
- data/webapp/public/icons/wand.png +0 -0
- data/webapp/public/icons/warn.png +0 -0
- data/webapp/public/icons/weather_clouds.png +0 -0
- data/webapp/public/icons/weather_cloudy.png +0 -0
- data/webapp/public/icons/weather_lightning.png +0 -0
- data/webapp/public/icons/weather_rain.png +0 -0
- data/webapp/public/icons/weather_snow.png +0 -0
- data/webapp/public/icons/weather_sun.png +0 -0
- data/webapp/public/icons/wrench-screwdriver.png +0 -0
- data/webapp/public/icons/wrench.png +0 -0
- data/webapp/public/iui/backButton.png +0 -0
- data/webapp/public/iui/blueButton.png +0 -0
- data/webapp/public/iui/cancel.png +0 -0
- data/webapp/public/iui/grayButton.png +0 -0
- data/webapp/public/iui/greenButton.png +0 -0
- data/webapp/public/iui/iui-logo-touch-icon.png +0 -0
- data/webapp/public/iui/iui.css +396 -0
- data/webapp/public/iui/iui.js +511 -0
- data/webapp/public/iui/iuix.css +1 -0
- data/webapp/public/iui/iuix.js +1 -0
- data/webapp/public/iui/listArrow.png +0 -0
- data/webapp/public/iui/listArrowSel.png +0 -0
- data/webapp/public/iui/listGroup.png +0 -0
- data/webapp/public/iui/loading.gif +0 -0
- data/webapp/public/iui/pinstripes.png +0 -0
- data/webapp/public/iui/redButton.png +0 -0
- data/webapp/public/iui/selection.png +0 -0
- data/webapp/public/iui/thumb.png +0 -0
- data/webapp/public/iui/toggle.png +0 -0
- data/webapp/public/iui/toggleOn.png +0 -0
- data/webapp/public/iui/toolButton.png +0 -0
- data/webapp/public/iui/toolbar.png +0 -0
- data/webapp/public/iui/whiteButton.png +0 -0
- data/webapp/public/iui/yellowButton.png +0 -0
- data/webapp/public/jquery.js +154 -0
- data/webapp/public/layout.css +33 -0
- data/webapp/public/right.js +9 -0
- data/webapp/public/rt.js +7 -0
- data/webapp/public/sparkline.js +85 -0
- data/webapp/spec/duino_spec.rb +8 -0
- data/webapp/spec/spec_helper.rb +10 -0
- data/webapp/views/command.haml +4 -0
- data/webapp/views/icon.haml +6 -0
- data/webapp/views/index.haml +51 -0
- data/webapp/views/layout.haml +17 -0
- data/webapp/views/mobile.haml +21 -0
- data/webapp/views/switch.haml +56 -0
- data/webapp/views/top.haml +4 -0
- data/webapp/views/watch.haml +26 -0
- metadata +277 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
|
21
|
+
## PROJECT::SPECIFIC
|
22
|
+
*.log
|
23
|
+
*.gem
|
24
|
+
*.rdb
|
25
|
+
*.cache
|
26
|
+
webapp/.bundle/*
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "subduino"
|
8
|
+
gem.summary = "Arduino Ruby Helpers"
|
9
|
+
gem.description = "Interface, compile, upload, play with arduino/ruby"
|
10
|
+
gem.email = "x@nofxx.com"
|
11
|
+
gem.homepage = "http://github.com/nofxx/subduino"
|
12
|
+
gem.authors = ["Marcos Piccinini"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
# require 'spec/rake/spectask'
|
22
|
+
# Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
# spec.libs << 'lib' << 'spec'
|
24
|
+
# spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
# end
|
26
|
+
|
27
|
+
# Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
# spec.libs << 'lib' << 'spec'
|
29
|
+
# spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
# spec.rcov = true
|
31
|
+
# end
|
32
|
+
|
33
|
+
# task :spec => :check_dependencies
|
34
|
+
|
35
|
+
# task :default => :spec
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "subduino #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Download and install arduino libraries"
|
48
|
+
task :clibs do |t|
|
49
|
+
puts "Starting...."
|
50
|
+
get_c_lib("Messenger")
|
51
|
+
puts "Done"
|
52
|
+
#/usr/share/arduino/libraries
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def get_c_lib(name)
|
58
|
+
puts "C LIB #{name}"
|
59
|
+
`mkdir #{name}`
|
60
|
+
[:h, :cpp].each do |ext|
|
61
|
+
next if File.exists?("#{name}/#{name}.#{ext}")
|
62
|
+
`wget http://github.com/nofxx/Messenger/raw/master/arduino/Messenger/#{name}.#{ext} -O #{name}/#{name}.#{ext}`
|
63
|
+
end
|
64
|
+
install_c_lib(name)
|
65
|
+
end
|
66
|
+
|
67
|
+
def install_c_lib(name)
|
68
|
+
try_root("mv ./#{name} /usr/share/arduino/libraries/#{name}")
|
69
|
+
end
|
70
|
+
|
71
|
+
def try_root(comm)
|
72
|
+
unless system(comm)
|
73
|
+
puts "Trying sudo..."
|
74
|
+
`sudo #{comm}`
|
75
|
+
end
|
76
|
+
end
|
data/Readme.textile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
h1. Subduino
|
2
|
+
|
3
|
+
Talks to arduino using cool stuff.
|
4
|
+
|
5
|
+
http://github.com/nofxx/subduino
|
6
|
+
|
7
|
+
h2. Install
|
8
|
+
|
9
|
+
gem install subduino
|
10
|
+
|
11
|
+
|
12
|
+
h3. Requirements
|
13
|
+
|
14
|
+
* "Arduino":http://arduino.cc
|
15
|
+
* "serialport":http://github.com/hparra/ruby-serialport
|
16
|
+
* "redis":http://github.com/ezmobius/redis-rb
|
17
|
+
|
18
|
+
|
19
|
+
h2. Use
|
20
|
+
|
21
|
+
<pre><code>
|
22
|
+
|
23
|
+
Subduino.start do |reading|
|
24
|
+
puts "Received from arduino: #{reading}"
|
25
|
+
# Mail.send("foo@bla.com") if reading && reading.digital?
|
26
|
+
# Postgre.remember(:sensor => reading)
|
27
|
+
end
|
28
|
+
|
29
|
+
Subduino.write(TXT)
|
30
|
+
|
31
|
+
</pre></code>
|
32
|
+
|
33
|
+
|
34
|
+
h2. Contributing
|
35
|
+
|
36
|
+
Fork/work/push.
|
37
|
+
|
38
|
+
|
39
|
+
h3. Author
|
40
|
+
|
41
|
+
nofxx
|
42
|
+
|
43
|
+
|
44
|
+
h3. License
|
45
|
+
|
46
|
+
"WTFPL":http://sam.zoy.org/wtfpl/
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/subduino
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'rubygems'
|
4
|
+
require 'optparse'
|
5
|
+
require 'subduino'
|
6
|
+
require 'faye'
|
7
|
+
|
8
|
+
OptionParser.new { |op|
|
9
|
+
op.on('-e env') { |val| set :environment, val.to_sym }
|
10
|
+
op.on('-s server') { |val| set :server, val }
|
11
|
+
op.on('-p port') { |val| set :port, val.to_i }
|
12
|
+
}.parse!(ARGV.dup)
|
13
|
+
|
14
|
+
# set :run, true
|
15
|
+
if ARGV.empty?
|
16
|
+
|
17
|
+
client = Faye::Client.new('http://localhost:8000/faye')
|
18
|
+
|
19
|
+
EM.run do
|
20
|
+
|
21
|
+
Subduino.start do |read|
|
22
|
+
client.publish('/stats', 'data' => read)
|
23
|
+
puts "[IO] #{read}"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
require "subduino/scaffold/generator"
|
30
|
+
dir = ARGV[0]
|
31
|
+
puts "Subduing dir #{dir}"
|
32
|
+
`mkdir #{dir}` unless File.exists?(dir)
|
33
|
+
|
34
|
+
Subduino::Generator.copy_files(dir)
|
data/bin/subduino-cli
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'eventmachine'
|
5
|
+
require 'stringio'
|
6
|
+
require 'readline'
|
7
|
+
require 'redis'
|
8
|
+
|
9
|
+
|
10
|
+
def halt!
|
11
|
+
puts "Closing server"
|
12
|
+
@redis.quit
|
13
|
+
puts "..."
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
trap(:TERM) { halt! }
|
18
|
+
trap(:INT) { halt! }
|
19
|
+
|
20
|
+
W = ARGV.join.empty? ? "TEST" : ARGV.join
|
21
|
+
|
22
|
+
module MyKeyboardHandler
|
23
|
+
include EM::Protocols::LineText2
|
24
|
+
|
25
|
+
def receive_line l
|
26
|
+
puts "Line > #{l}" if DEBUG
|
27
|
+
|
28
|
+
CONN.send_data(l) unless l.empty?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def readline_with_hist_management
|
33
|
+
line = Readline.readline('> ', true)
|
34
|
+
return nil if line.nil?
|
35
|
+
if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
|
36
|
+
Readline::HISTORY.pop
|
37
|
+
end
|
38
|
+
line
|
39
|
+
end
|
40
|
+
|
41
|
+
EventMachine::run do
|
42
|
+
@redis = Redis.new(:timeout => 0)
|
43
|
+
|
44
|
+
stty_save = `stty -g`.chomp
|
45
|
+
|
46
|
+
trap(:INT) do
|
47
|
+
system('stty', stty_save)
|
48
|
+
halt!
|
49
|
+
end
|
50
|
+
|
51
|
+
# Thread.new do
|
52
|
+
begin
|
53
|
+
while line = readline_with_hist_management
|
54
|
+
p line
|
55
|
+
p @redis.publish('ard', line) unless line.empty?
|
56
|
+
end
|
57
|
+
rescue Interrupt => e
|
58
|
+
system('stty', stty_save) # Restore
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
# end
|
62
|
+
|
63
|
+
# EM.open_keyboard(MyKeyboardHandler)
|
64
|
+
end
|
65
|
+
|
data/duino/.gitignore
ADDED
data/duino/Makefile
ADDED
@@ -0,0 +1,401 @@
|
|
1
|
+
########################################################################
|
2
|
+
#
|
3
|
+
# Arduino command line tools Makefile
|
4
|
+
# System part (i.e. project independent)
|
5
|
+
#
|
6
|
+
# Copyright (C) 2010 Martin Oldfield <m@mjo.tc>, based on work that is
|
7
|
+
# Copyright Nicholas Zambetti, David A. Mellis & Hernando Barragan
|
8
|
+
#
|
9
|
+
# This file is free software; you can redistribute it and/or modify it
|
10
|
+
# under the terms of the GNU Lesser General Public License as
|
11
|
+
# published by the Free Software Foundation; either version 2.1 of the
|
12
|
+
# License, or (at your option) any later version.
|
13
|
+
#
|
14
|
+
# Adapted from Arduino 0011 Makefile by M J Oldfield
|
15
|
+
#
|
16
|
+
# Original Arduino adaptation by mellis, eighthave, oli.keller
|
17
|
+
#
|
18
|
+
# Version 0.1 17.ii.2009 M J Oldfield
|
19
|
+
#
|
20
|
+
# 0.2 22.ii.2009 M J Oldfield
|
21
|
+
# - fixes so that the Makefile actually works!
|
22
|
+
# - support for uploading via ISP
|
23
|
+
# - orthogonal choices of using the Arduino for
|
24
|
+
# tools, libraries and uploading
|
25
|
+
#
|
26
|
+
# 0.3 21.v.2010 M J Oldfield
|
27
|
+
# - added proper license statement
|
28
|
+
# - added code from Philip Hands to reset
|
29
|
+
# Arduino prior to upload
|
30
|
+
#
|
31
|
+
# 0.4 25.v.2010 M J Oldfield
|
32
|
+
# - tweaked reset target on Philip Hands' advice
|
33
|
+
#
|
34
|
+
########################################################################
|
35
|
+
#
|
36
|
+
# STANDARD ARDUINO WORKFLOW
|
37
|
+
#
|
38
|
+
# Given a normal sketch directory, all you need to do is to create
|
39
|
+
# a small Makefile which defines a few things, and then includes this one.
|
40
|
+
#
|
41
|
+
# For example:
|
42
|
+
#
|
43
|
+
ARDUINO_DIR = /usr/share/arduino
|
44
|
+
#
|
45
|
+
TARGET = DUINO
|
46
|
+
ARDUINO_LIBS = Messenger
|
47
|
+
|
48
|
+
MCU = atmega328p
|
49
|
+
F_CPU = 16000000
|
50
|
+
ARDUINO_PORT = /dev/ttyUSB* #cu.usb*
|
51
|
+
|
52
|
+
# Linux
|
53
|
+
AVR_TOOLS_PATH = /usr/bin
|
54
|
+
AVRDUDE_CONF = /usr/share/arduino/hardware/tools/avrdude.conf
|
55
|
+
|
56
|
+
# INC_DIRS = ./vendor/Messenger
|
57
|
+
|
58
|
+
#
|
59
|
+
# include /usr/local/share/Arduino.mk
|
60
|
+
#
|
61
|
+
# Hopefully these will be self-explanatory but in case they're not:
|
62
|
+
#
|
63
|
+
# ARDUINO_DIR - Where the Arduino software has been unpacked
|
64
|
+
# TARGET - The basename used for the final files. Canonically
|
65
|
+
# this would match the .pde file, but it's not needed
|
66
|
+
# here: you could always set it to xx if you wanted!
|
67
|
+
# ARDUINO_LIBS - A list of any libraries used by the sketch (we assume
|
68
|
+
# these are in $(ARDUINO_DIR)/hardware/libraries
|
69
|
+
# MCU,F_CPU - The target processor description
|
70
|
+
# ARDUINO_PORT - The port where the Arduino can be found (only needed
|
71
|
+
# when uploading
|
72
|
+
#
|
73
|
+
# Once this file has been created the typical workflow is just
|
74
|
+
#
|
75
|
+
# $ make upload
|
76
|
+
#
|
77
|
+
# All of the object files are created in the build-cli subdirectory
|
78
|
+
# All sources should be in the current directory and can include:
|
79
|
+
# - at most one .pde file which will be treated as C++ after the standard
|
80
|
+
# Arduino header and footer have been affixed.
|
81
|
+
# - any number of .c, .cpp, .s and .h files
|
82
|
+
#
|
83
|
+
#
|
84
|
+
# Besides make upload you can also
|
85
|
+
# make - no upload
|
86
|
+
# make clean - remove all our dependencies
|
87
|
+
# make depends - update dependencies
|
88
|
+
# make reset - reset the Arduino by tickling DTR on the serial port
|
89
|
+
# make raw_upload - upload without first resetting
|
90
|
+
#
|
91
|
+
########################################################################
|
92
|
+
#
|
93
|
+
# ARDUINO WITH OTHER TOOLS
|
94
|
+
#
|
95
|
+
# If the tools aren't in the Arduino distribution, then you need to
|
96
|
+
# specify their location:
|
97
|
+
#
|
98
|
+
# AVR_TOOLS_PATH = /usr/bin
|
99
|
+
# AVRDUDE_CONF = /etc/avrdude/avrdude.conf
|
100
|
+
#
|
101
|
+
########################################################################
|
102
|
+
#
|
103
|
+
# ARDUINO WITH ISP
|
104
|
+
#
|
105
|
+
# You need to specify some details of your ISP programmer and might
|
106
|
+
# also need to specify the fuse values:
|
107
|
+
#
|
108
|
+
# ISP_PROG = -c stk500v2
|
109
|
+
# ISP_PORT = /dev/ttyACM0
|
110
|
+
#
|
111
|
+
# ISP_LOCK_FUSE_PRE = 0x3f
|
112
|
+
# ISP_LOCK_FUSE_POST = 0xcf
|
113
|
+
# ISP_HIGH_FUSE = 0xdf
|
114
|
+
# ISP_LOW_FUSE = 0xff
|
115
|
+
# ISP_EXT_FUSE = 0x01
|
116
|
+
#
|
117
|
+
# I think the fuses here are fine for uploading to the ATmega168
|
118
|
+
# without bootloader.
|
119
|
+
#
|
120
|
+
# To actually do this upload use the ispload target:
|
121
|
+
#
|
122
|
+
# make ispload
|
123
|
+
#
|
124
|
+
#
|
125
|
+
########################################################################
|
126
|
+
# Some paths
|
127
|
+
#
|
128
|
+
|
129
|
+
ifneq (ARDUINO_DIR,)
|
130
|
+
|
131
|
+
ifndef AVR_TOOLS_PATH
|
132
|
+
AVR_TOOLS_PATH = $(ARDUINO_DIR)/hardware/tools/avr/bin
|
133
|
+
endif
|
134
|
+
|
135
|
+
ifndef ARDUINO_ETC_PATH
|
136
|
+
ARDUINO_ETC_PATH = $(ARDUINO_DIR)/hardware/tools/avr/etc
|
137
|
+
endif
|
138
|
+
|
139
|
+
ifndef AVRDUDE_CONF
|
140
|
+
AVRDUDE_CONF = $(ARDUINO_ETC_PATH)/avrdude.conf
|
141
|
+
endif
|
142
|
+
|
143
|
+
ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries
|
144
|
+
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
|
145
|
+
|
146
|
+
endif
|
147
|
+
|
148
|
+
# Everything gets built in here
|
149
|
+
OBJDIR = build-cli
|
150
|
+
|
151
|
+
########################################################################
|
152
|
+
# Local sources
|
153
|
+
#
|
154
|
+
LOCAL_C_SRCS = $(wildcard *.c)
|
155
|
+
LOCAL_CPP_SRCS = $(wildcard *.cpp)
|
156
|
+
LOCAL_CC_SRCS = $(wildcard *.cc)
|
157
|
+
LOCAL_PDE_SRCS = $(wildcard *.pde)
|
158
|
+
LOCAL_AS_SRCS = $(wildcard *.S)
|
159
|
+
LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
|
160
|
+
$(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \
|
161
|
+
$(LOCAL_AS_SRCS:.S=.o)
|
162
|
+
LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES))
|
163
|
+
|
164
|
+
# Dependency files
|
165
|
+
DEPS = $(LOCAL_OBJS:.o=.d)
|
166
|
+
|
167
|
+
# core sources
|
168
|
+
ifeq ($(strip $(NO_CORE)),)
|
169
|
+
ifdef ARDUINO_CORE_PATH
|
170
|
+
CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c)
|
171
|
+
CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
|
172
|
+
EXTRA_CPP_SRCS = $(wildcard $(ARDUINO_LIB_PATH)/Messenger/*.cpp)
|
173
|
+
CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) $(EXTRA_CPP_SRCS:.cpp=.o)
|
174
|
+
CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, $(OBJDIR)/%,$(CORE_OBJ_FILES))
|
175
|
+
endif
|
176
|
+
endif
|
177
|
+
|
178
|
+
# all the objects!
|
179
|
+
OBJS = $(LOCAL_OBJS) $(CORE_OBJS)
|
180
|
+
|
181
|
+
########################################################################
|
182
|
+
# Rules for making stuff
|
183
|
+
#
|
184
|
+
|
185
|
+
# The name of the main targets
|
186
|
+
TARGET_HEX = $(OBJDIR)/$(TARGET).hex
|
187
|
+
TARGET_ELF = $(OBJDIR)/$(TARGET).elf
|
188
|
+
TARGETS = $(OBJDIR)/$(TARGET).*
|
189
|
+
|
190
|
+
# A list of dependencies
|
191
|
+
DEP_FILE = $(OBJDIR)/depends.mk
|
192
|
+
|
193
|
+
# Names of executables
|
194
|
+
CC = $(AVR_TOOLS_PATH)/avr-gcc
|
195
|
+
CXX = $(AVR_TOOLS_PATH)/avr-g++
|
196
|
+
OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
|
197
|
+
OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
|
198
|
+
AR = $(AVR_TOOLS_PATH)/avr-ar
|
199
|
+
SIZE = $(AVR_TOOLS_PATH)/avr-size
|
200
|
+
NM = $(AVR_TOOLS_PATH)/avr-nm
|
201
|
+
REMOVE = rm -f
|
202
|
+
MV = mv -f
|
203
|
+
CAT = cat
|
204
|
+
ECHO = echo
|
205
|
+
|
206
|
+
# General arguments
|
207
|
+
SYS_LIBS = $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS))
|
208
|
+
SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS))
|
209
|
+
SYS_OBJS = $(wildcard $(patsubst %,%/*.o,$(SYS_LIBS)))
|
210
|
+
|
211
|
+
CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) \
|
212
|
+
-I. -I$(ARDUINO_CORE_PATH) \
|
213
|
+
$(SYS_INCLUDES) -g -Os -w -Wall \
|
214
|
+
-ffunction-sections -fdata-sections
|
215
|
+
CFLAGS = -std=gnu99
|
216
|
+
CXXFLAGS = -fno-exceptions
|
217
|
+
ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp
|
218
|
+
LDFLAGS = -mmcu=$(MCU) -lm -Wl,--gc-sections -Os
|
219
|
+
|
220
|
+
# Rules for making a CPP file from the main sketch (.cpe)
|
221
|
+
PDEHEADER = \\\#include \"WProgram.h\"
|
222
|
+
|
223
|
+
# Expand and pick the first port
|
224
|
+
ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT)))
|
225
|
+
|
226
|
+
# Implicit rules for building everything (needed to get everything in
|
227
|
+
# the right directory)
|
228
|
+
#
|
229
|
+
# Rather than mess around with VPATH there are quasi-duplicate rules
|
230
|
+
# here for building e.g. a system C++ file and a local C++
|
231
|
+
# file. Besides making things simpler now, this would also make it
|
232
|
+
# easy to change the build options in future
|
233
|
+
|
234
|
+
# normal local sources
|
235
|
+
# .o rules are for objects, .d for dependency tracking
|
236
|
+
# there seems to be an awful lot of duplication here!!!
|
237
|
+
$(OBJDIR)/%.o: %.c
|
238
|
+
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
239
|
+
|
240
|
+
$(OBJDIR)/%.o: %.cc
|
241
|
+
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
242
|
+
|
243
|
+
$(OBJDIR)/%.o: %.cpp
|
244
|
+
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
245
|
+
|
246
|
+
$(OBJDIR)/%.o: %.S
|
247
|
+
$(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
248
|
+
|
249
|
+
$(OBJDIR)/%.o: %.s
|
250
|
+
$(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
251
|
+
|
252
|
+
$(OBJDIR)/%.d: %.c
|
253
|
+
$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
254
|
+
|
255
|
+
$(OBJDIR)/%.d: %.cc
|
256
|
+
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
257
|
+
|
258
|
+
$(OBJDIR)/%.d: %.cpp
|
259
|
+
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
260
|
+
|
261
|
+
$(OBJDIR)/%.d: %.S
|
262
|
+
$(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
263
|
+
|
264
|
+
$(OBJDIR)/%.d: %.s
|
265
|
+
$(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
266
|
+
|
267
|
+
# the pde -> cpp -> o file
|
268
|
+
$(OBJDIR)/%.cpp: %.pde
|
269
|
+
$(ECHO) $(PDEHEADER) > $@
|
270
|
+
$(CAT) $< >> $@
|
271
|
+
|
272
|
+
$(OBJDIR)/%.o: $(OBJDIR)/%.cpp
|
273
|
+
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
274
|
+
|
275
|
+
$(OBJDIR)/%.d: $(OBJDIR)/%.cpp
|
276
|
+
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
|
277
|
+
|
278
|
+
# core files
|
279
|
+
$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c
|
280
|
+
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
281
|
+
|
282
|
+
$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp
|
283
|
+
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
284
|
+
|
285
|
+
# various object conversions
|
286
|
+
$(OBJDIR)/%.hex: $(OBJDIR)/%.elf
|
287
|
+
$(OBJCOPY) -O ihex -R .eeprom $< $@
|
288
|
+
|
289
|
+
$(OBJDIR)/%.eep: $(OBJDIR)/%.elf
|
290
|
+
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
291
|
+
--change-section-lma .eeprom=0 -O ihex $< $@
|
292
|
+
|
293
|
+
$(OBJDIR)/%.lss: $(OBJDIR)/%.elf
|
294
|
+
$(OBJDUMP) -h -S $< > $@
|
295
|
+
|
296
|
+
$(OBJDIR)/%.sym: $(OBJDIR)/%.elf
|
297
|
+
$(NM) -n $< > $@
|
298
|
+
|
299
|
+
########################################################################
|
300
|
+
#
|
301
|
+
# Avrdude
|
302
|
+
#
|
303
|
+
ifndef AVRDUDE
|
304
|
+
AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
|
305
|
+
endif
|
306
|
+
|
307
|
+
AVRDUDE_COM_OPTS = -q -V -p $(MCU)
|
308
|
+
ifdef AVRDUDE_CONF
|
309
|
+
AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF)
|
310
|
+
endif
|
311
|
+
|
312
|
+
ifndef AVRDUDE_ARD_PROGRAMMER
|
313
|
+
AVRDUDE_ARD_PROGRAMMER = stk500v1
|
314
|
+
endif
|
315
|
+
|
316
|
+
ifndef AVRDUDE_ARD_BAUDRATE
|
317
|
+
AVRDUDE_ARD_BAUDRATE = 57600 # 19600
|
318
|
+
endif
|
319
|
+
|
320
|
+
AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT)
|
321
|
+
|
322
|
+
ifndef ISP_LOCK_FUSE_PRE
|
323
|
+
ISP_LOCK_FUSE_PRE = 0x3f
|
324
|
+
endif
|
325
|
+
|
326
|
+
ifndef ISP_LOCK_FUSE_POST
|
327
|
+
ISP_LOCK_FUSE_POST = 0xcf
|
328
|
+
endif
|
329
|
+
|
330
|
+
ifndef ISP_HIGH_FUSE
|
331
|
+
ISP_HIGH_FUSE = 0xdf
|
332
|
+
endif
|
333
|
+
|
334
|
+
ifndef ISP_LOW_FUSE
|
335
|
+
ISP_LOW_FUSE = 0xff
|
336
|
+
endif
|
337
|
+
|
338
|
+
ifndef ISP_EXT_FUSE
|
339
|
+
ISP_EXT_FUSE = 0x01
|
340
|
+
endif
|
341
|
+
|
342
|
+
ifndef ISP_PROG
|
343
|
+
ISP_PROG = -c stk500v2
|
344
|
+
endif
|
345
|
+
|
346
|
+
AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG)
|
347
|
+
|
348
|
+
|
349
|
+
########################################################################
|
350
|
+
#
|
351
|
+
# Explicit targets start here
|
352
|
+
#
|
353
|
+
|
354
|
+
all: $(OBJDIR) $(TARGET_HEX)
|
355
|
+
|
356
|
+
$(OBJDIR):
|
357
|
+
mkdir $(OBJDIR)
|
358
|
+
|
359
|
+
$(TARGET_ELF): $(OBJS)
|
360
|
+
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(SYS_OBJS)
|
361
|
+
|
362
|
+
$(DEP_FILE): $(OBJDIR) $(DEPS)
|
363
|
+
cat $(DEPS) > $(DEP_FILE)
|
364
|
+
|
365
|
+
upload: reset raw_upload
|
366
|
+
|
367
|
+
raw_upload: $(TARGET_HEX)
|
368
|
+
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
|
369
|
+
-U flash:w:$(TARGET_HEX):i
|
370
|
+
|
371
|
+
# stty on MacOS likes -F, but on Debian it likes -f redirecting
|
372
|
+
# stdin/out appears to work but generates a spurious error on MacOS at
|
373
|
+
# least. Perhaps it would be better to just do it in perl ?
|
374
|
+
reset:
|
375
|
+
for STTYF in 'stty --file' 'stty -f' 'stty <' ; \
|
376
|
+
do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \
|
377
|
+
done ;\
|
378
|
+
$$STTYF $(ARD_PORT) hupcl ;\
|
379
|
+
(sleep 0.1 || sleep 1) ;\
|
380
|
+
$$STTYF $(ARD_PORT) -hupcl
|
381
|
+
|
382
|
+
ispload: $(TARGET_HEX)
|
383
|
+
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \
|
384
|
+
-U lock:w:$(ISP_LOCK_FUSE_PRE):m \
|
385
|
+
-U hfuse:w:$(ISP_HIGH_FUSE):m \
|
386
|
+
-U lfuse:w:$(ISP_LOW_FUSE):m \
|
387
|
+
-U efuse:w:$(ISP_EXT_FUSE):m
|
388
|
+
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -D \
|
389
|
+
-U flash:w:$(TARGET_HEX):i
|
390
|
+
$(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \
|
391
|
+
-U lock:w:$(ISP_LOCK_FUSE_POST):m
|
392
|
+
|
393
|
+
clean:
|
394
|
+
$(REMOVE) $(OBJS) $(TARGETS) $(DEP_FILE) $(DEPS)
|
395
|
+
|
396
|
+
depends: $(DEPS)
|
397
|
+
cat $(DEPS) > $(DEP_FILE)
|
398
|
+
|
399
|
+
.PHONY: all clean depends upload raw_upload reset
|
400
|
+
|
401
|
+
include $(DEP_FILE)
|
data/duino/duino.pde
ADDED
data/duino/duino.rb
ADDED