Skip to content

Commit

Permalink
Added new firmata commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar O Silva committed Feb 6, 2014
1 parent 6045bb5 commit 3dd54df
Show file tree
Hide file tree
Showing 3 changed files with 760 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
source "http://rubygems.org"

# Specify your gem's dependencies in artoo-arduino.gemspec
gemspec
#gem 'hybridgroup-firmata', path: '/path/to/hybridgroup-firmata'
43 changes: 43 additions & 0 deletions lib/artoo/commands/firmata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'artoo/commands/commands'

module Artoo
module Commands
class Firmata < Commands
package_name "firmata"

desc "upload", "Uploads firmata to the arduino using avrdude"
option :serial_port, aliases: '-p', default: "/dev/ttyACM0", desc: "serial port address e.g. /dev/ttyACM0"
def upload
part = '-patmega328p'
programmer = '-carduino'
baudrate = '-b115200'
hexPath = File.join(File.expand_path(File.dirname(__FILE__)), "hex/StandardFirmata.cpp.hex")
hexFile = "-Uflash:w:#{ hexPath }:i"
case os
when :linux
port = "-P#{ options[:serial_port] }"
run("avrdude #{ part } #{ programmer } #{ port } #{ baudrate } -D #{ hexFile }")
when :macosx
port = "-P#{ options[:serial_port] }"
run("avrdude #{ part } #{ programmer } #{ port } #{ baudrate } -D #{ hexFile }")
else
say "OS not yet supported..."
end
end

desc "install", "Install avrdude in order to be able to upload firmata to the arduino"
def install
case os
when :linux
run('sudo apt-get install avrdude')
when :macosx
Bundler.with_clean_env do
run("brew install avrdude")
end
else
say "OS not yet supported..."
end
end
end
end
end
Loading

0 comments on commit 3dd54df

Please sign in to comment.