mkduino 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mkduino +50 -10
- data/lib/makefile_am.rb +28 -17
- data/lib/mkduino/version.rb +1 -1
- data/lib/mkduino.rb +1 -1
- data/lib/probe.rb +90 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5b152daf399b2dd6353a039f14877097a22e6dd
|
4
|
+
data.tar.gz: c21b7d3d1a43177e7b9e8caaa9f69418183e262c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4deedcc41a23c012c4310c38ee55b1589dc130ea9aa24fa2e815dc1b865ceaab4647d7b1ebcc5376e20c3ec4de3e8390687a89bfa641b626af076ac220be5e2e
|
7
|
+
data.tar.gz: 12ab946a5607b571214ce95f0b4f4e9350a9d709559bddbeee31f023c99191c71c7170972bd0aaa827fe6d2c10561f9ae0885914682acf64a1daa98015415406
|
data/bin/mkduino
CHANGED
@@ -34,15 +34,29 @@ require "mkduino"
|
|
34
34
|
require 'optparse'
|
35
35
|
|
36
36
|
options = {}
|
37
|
+
default_options = {}
|
38
|
+
probed_options = {}
|
39
|
+
probe = Mkduino::Probe.new
|
40
|
+
|
37
41
|
OptionParser.new do |opts|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
default_options[:verbose] = false
|
43
|
+
default_options[:git] = false
|
44
|
+
default_options[:update] = false
|
45
|
+
default_options[:overwrite] = false
|
46
|
+
default_options[:mcu] = "atmega328p"
|
47
|
+
default_options[:num_args] = ARGV.length
|
48
|
+
default_options[:autoconfigure] = false
|
49
|
+
default_options[:device] = "/dev/ttyUSB0"
|
50
|
+
default_options[:variant] = "standard"
|
51
|
+
default_options[:clock_speed] = "16000000"
|
52
|
+
default_options[:baud_rate] = "57600"
|
53
|
+
default_options[:programmer] = "arduino"
|
45
54
|
opts.banner = "Usage: #{opts.program_name} [options]"
|
55
|
+
opts.on("-p","--[no-]probe","Probe for stuff") do |v|
|
56
|
+
probe.probe
|
57
|
+
probed_options.merge! probe.options
|
58
|
+
end
|
59
|
+
|
46
60
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
47
61
|
options[:verbose] = v
|
48
62
|
end
|
@@ -55,21 +69,47 @@ OptionParser.new do |opts|
|
|
55
69
|
opts.on('-a',"--[no-]autoconfigure","automatically run autogen.sh and configure") do |v|
|
56
70
|
options[:autoconfigure] = v
|
57
71
|
end
|
72
|
+
|
73
|
+
opts.on("-b","--board BOARD",Mkduino::Probe::BOARDS.keys,"Arduino Board Type", "#{Mkduino::Probe::BOARDS.keys.join(',')}") do |v|
|
74
|
+
options.merge! Mkduino::Probe::BOARDS[v]
|
75
|
+
end
|
76
|
+
|
77
|
+
opts.on("--programmer PROGRAMMER",["arduino","stk500"],"AVRDUDE Programmer type", "arduino, stk500") do |v|
|
78
|
+
options[:programmer] = v
|
79
|
+
end
|
80
|
+
|
81
|
+
|
58
82
|
opts.on("-o","--[no-]overwrite","Overwrite current project files") do |v|
|
59
83
|
options[:overwrite] = v
|
60
84
|
end
|
85
|
+
|
86
|
+
opts.on("-c","--clock SPEED",Integer,"Clock speed") do |v|
|
87
|
+
options[:clock_speed] = v
|
88
|
+
end
|
89
|
+
|
90
|
+
opts.on("-t","--type TYPE",["mega","standard"],"Arduino library type (aka variant)") do |v|
|
91
|
+
options[:variant] = v
|
92
|
+
end
|
93
|
+
|
94
|
+
opts.on("-d","--device DEVICE","Arduino programming device.","Example: /dev/ttyUSB0.") do |v|
|
95
|
+
options[:device] = v
|
96
|
+
end
|
97
|
+
|
61
98
|
opts.on_tail("-h", "--help", "Show this message") do
|
62
99
|
puts opts
|
63
100
|
exit
|
64
101
|
end
|
65
102
|
|
66
|
-
if
|
103
|
+
if( default_options[:num_args] < 1)
|
67
104
|
puts opts
|
68
105
|
exit
|
69
106
|
end
|
70
|
-
|
71
107
|
end.parse!
|
72
108
|
|
109
|
+
|
110
|
+
default_options.merge!( probed_options.merge!( options ) )
|
111
|
+
|
112
|
+
|
73
113
|
if !options[:overwrite] && Mkduino::GENERATED_FILES.collect do |gf|
|
74
114
|
Pathname.new("Makefile.am").exist? ? true : nil
|
75
115
|
end.compact.any?
|
@@ -79,7 +119,7 @@ end
|
|
79
119
|
|
80
120
|
|
81
121
|
|
82
|
-
ma = Mkduino::MakefileAm.new
|
122
|
+
ma = Mkduino::MakefileAm.new "Makefile.am", options
|
83
123
|
ma.find_arduino_libraries '/usr/share/arduino/libraries'
|
84
124
|
ma.find_arduino_libraries '/usr/share/arduino/hardware/arduino/cores'
|
85
125
|
ma.find_source_files
|
data/lib/makefile_am.rb
CHANGED
@@ -24,15 +24,19 @@
|
|
24
24
|
#
|
25
25
|
|
26
26
|
module Mkduino
|
27
|
-
class MakefileAm
|
27
|
+
class MakefileAm < Mkduino::GeneratedFile
|
28
28
|
attr_accessor :source_files, :header_files, :arduino_sources
|
29
29
|
attr_accessor :project_name, :project_author, :project_dir
|
30
30
|
attr_accessor :project_includes
|
31
|
+
|
32
|
+
attr_accessor :mcu, :clock_speed, :variant, :device, :baud_rate, :programmer
|
33
|
+
|
31
34
|
# future stuff
|
32
35
|
attr_accessor :git_project
|
33
|
-
attr_accessor :
|
36
|
+
attr_accessor :common_includes
|
34
37
|
|
35
|
-
def initialize
|
38
|
+
def initialize output_filename, options
|
39
|
+
super output_filename, options
|
36
40
|
@project_dir = Dir.pwd
|
37
41
|
@project_name = File.basename @project_dir
|
38
42
|
@project_name.tr!('.-','__')
|
@@ -44,11 +48,20 @@ module Mkduino
|
|
44
48
|
@arduino_libraries = []
|
45
49
|
@project_author = {}
|
46
50
|
@git_project = nil
|
51
|
+
|
52
|
+
@options = options
|
53
|
+
@mcu = @options[:mcu] || "atmega328p"
|
54
|
+
@clock_speed = @options[:clock_speed] || "16000000"
|
55
|
+
@variant = @options[:variant] || "standard"
|
56
|
+
@device = @options[:device] || "/dev/USB0"
|
57
|
+
@baud_rate = @options[:baud_rate] || "57600"
|
58
|
+
@programmer = @options[:programmer] || "arduino"
|
59
|
+
|
47
60
|
@common_libraries = ['arduino', 'spi','wire']
|
48
61
|
@libraries_to_skip = {
|
49
|
-
'standard' => ['Esplora','GSM','Robot_Control','Robot_Motor','TFT','robot']
|
62
|
+
'standard' => ['Esplora','GSM','Robot_Control','Robot_Motor','TFT','robot'],
|
63
|
+
'mega' => ['Esplora','GSM','Robot_Control','Robot_Motor','TFT','robot']
|
50
64
|
}
|
51
|
-
@board='standard'
|
52
65
|
@project_author[:username] = ENV['USERNAME']
|
53
66
|
git_exists = `which git`.chomp
|
54
67
|
if git_exists && git_exists.length > 0
|
@@ -163,7 +176,7 @@ module Mkduino
|
|
163
176
|
Find.find(libraries_dir) do |path|
|
164
177
|
if FileTest.directory?(path)
|
165
178
|
if File.basename(path)[0] == ?. || File.basename(path) == 'examples' ||
|
166
|
-
(@libraries_to_skip[@
|
179
|
+
(@libraries_to_skip[@variant] && @libraries_to_skip[@variant].include?(File.basename(path)) )
|
167
180
|
Find.prune # Don't look any further into this directory.
|
168
181
|
else
|
169
182
|
if File.dirname(path) == libraries_dir
|
@@ -246,18 +259,18 @@ MAIN_CPP
|
|
246
259
|
|
247
260
|
|
248
261
|
def write_makefile_am
|
249
|
-
puts "Writing
|
250
|
-
|
262
|
+
puts "Writing #{@output_file}"
|
263
|
+
write_file do |f|
|
251
264
|
f.puts <<-MAKEFILE_AM
|
252
265
|
## Process this file with automake to produce Makefile.in
|
253
266
|
bin_PROGRAMS=#{self.project_name}
|
254
|
-
|
255
|
-
MCU
|
256
|
-
F_CPU=-DF_CPU
|
267
|
+
|
268
|
+
MCU=#{self.mcu}
|
269
|
+
F_CPU=-DF_CPU=#{self.clock_speed}
|
257
270
|
ARDUINO_VERSION=-DARDUINO=105
|
258
271
|
ARDUINO_INSTALL=/usr/share/arduino/hardware/arduino
|
259
272
|
ARDUINO_CORES=$(ARDUINO_INSTALL)/cores/arduino
|
260
|
-
ARDUINO_VARIANTS=$(ARDUINO_INSTALL)/variants/#{self.
|
273
|
+
ARDUINO_VARIANTS=$(ARDUINO_INSTALL)/variants/#{self.variant}
|
261
274
|
ARDUINO_COMMON_INCLUDES=#{self.common_includes}
|
262
275
|
ARDUINO_INCLUDE_PATH=-I$(ARDUINO_VARIANTS) $(LIBRARY_INCLUDES)
|
263
276
|
nodist_#{self.project_name}_SOURCES=#{self.source_files.join(' ')}
|
@@ -277,11 +290,9 @@ AM_CXXFLAGS=-g0 -Os
|
|
277
290
|
AM_CFLAGS=-g0 -Os
|
278
291
|
VPATH=/usr/share/arduino/hardware/arduino/cores/arduino
|
279
292
|
|
280
|
-
#
|
281
|
-
|
282
|
-
|
283
|
-
# UPLOAD_RATE = 115200
|
284
|
-
UPLOAD_RATE = 57600
|
293
|
+
AVRDUDE_PORT = #{self.device}
|
294
|
+
AVRDUDE_PROGRAMMER = #{self.programmer}
|
295
|
+
UPLOAD_RATE = #{self.baud_rate}
|
285
296
|
FORMAT=ihex
|
286
297
|
|
287
298
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(bin_PROGRAMS).hex
|
data/lib/mkduino/version.rb
CHANGED
data/lib/mkduino.rb
CHANGED
data/lib/probe.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
module Mkduino
|
2
|
+
class Probe
|
3
|
+
attr_accessor :options
|
4
|
+
attr_accessor :probe_options
|
5
|
+
|
6
|
+
DEVICES = ["/dev/ttyUSB0",
|
7
|
+
"/dev/ttyUSB1",
|
8
|
+
"/dev/ttyUSB2",
|
9
|
+
"/dev/ttyACM0",
|
10
|
+
"/dev/ttyACM1",
|
11
|
+
"/dev/ttyACM2",
|
12
|
+
"/dev/rfcomm0",
|
13
|
+
"/dev/rfcomm1",
|
14
|
+
"/dev/rfcomm2"]
|
15
|
+
|
16
|
+
BOARDS = {
|
17
|
+
"mega" => {
|
18
|
+
variant: "mega",
|
19
|
+
clock_speed: 16000000,
|
20
|
+
device: "/dev/ACM0",
|
21
|
+
baud_rate: "115200",
|
22
|
+
programmer: "stk500",
|
23
|
+
mcu: "atmega2560"
|
24
|
+
},
|
25
|
+
"mega1280" => {
|
26
|
+
variant: "mega",
|
27
|
+
clock_speed: 16000000,
|
28
|
+
device: "/dev/ACM0",
|
29
|
+
baud_rate: "115200",
|
30
|
+
programmer: "stk500",
|
31
|
+
mcu: "atmega1280"
|
32
|
+
},
|
33
|
+
|
34
|
+
"uno" => {
|
35
|
+
variant: "standard",
|
36
|
+
clock_speed: 16000000,
|
37
|
+
device: "/dev/USB0",
|
38
|
+
baud_rate: "57600",
|
39
|
+
programmer: "arduino",
|
40
|
+
mcu: "atmega328p"
|
41
|
+
|
42
|
+
},
|
43
|
+
"mini" => {
|
44
|
+
variant: "standard",
|
45
|
+
clock_speed: 16000000,
|
46
|
+
device: "/dev/USB0",
|
47
|
+
baud_rate: "57600",
|
48
|
+
programmer: "arduino",
|
49
|
+
mcu: "atmega328p"
|
50
|
+
},
|
51
|
+
"mini3v" => {
|
52
|
+
variant: "standard",
|
53
|
+
clock_speed: 8000000,
|
54
|
+
device: "/dev/USB0",
|
55
|
+
baud_rate: "57600",
|
56
|
+
programmer: "arduino",
|
57
|
+
mcu: "atmega328p"
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
def initialize probe_options = {}
|
63
|
+
@probe_options = probe_options
|
64
|
+
@options = {}
|
65
|
+
end
|
66
|
+
|
67
|
+
def probe
|
68
|
+
probe_device
|
69
|
+
probe_variant
|
70
|
+
end
|
71
|
+
|
72
|
+
def probe_variant
|
73
|
+
if @options[:device] && @options[:device] =~ /ACM[0-9]/
|
74
|
+
@options[:variant] = "mega"
|
75
|
+
else
|
76
|
+
@options[:variant] = "standard"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def probe_device
|
81
|
+
@options[:device] = DEVICES[0]
|
82
|
+
DEVICES.each do |d|
|
83
|
+
if File.exist?(d)
|
84
|
+
@options[:device] = d
|
85
|
+
break
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkduino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David H. Wilkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/makefile_am.rb
|
59
59
|
- lib/mkduino.rb
|
60
60
|
- lib/mkduino/version.rb
|
61
|
+
- lib/probe.rb
|
61
62
|
- mkduino.gemspec
|
62
63
|
homepage: https://rubygems.org/gems/mkduino
|
63
64
|
licenses:
|