avburn 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.3.0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.2"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.8.7)
11
+ rcov (0.9.9)
12
+ rspec (2.3.0)
13
+ rspec-core (~> 2.3.0)
14
+ rspec-expectations (~> 2.3.0)
15
+ rspec-mocks (~> 2.3.0)
16
+ rspec-core (2.3.1)
17
+ rspec-expectations (2.3.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.3.0)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ bundler (~> 1.0.0)
26
+ jeweler (~> 1.5.2)
27
+ rcov
28
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Marcos Piccinini
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,50 @@
1
+ = avburn
2
+
3
+ Simple Shoes GUI for AVRDUDE. Burn fuses/hexes.
4
+
5
+
6
+ == Install
7
+
8
+ gem install avburn
9
+
10
+
11
+ == Use
12
+
13
+
14
+ avburn
15
+
16
+
17
+ == Requirements
18
+
19
+
20
+ * Shoes
21
+ * Avrdude
22
+
23
+
24
+ == HexFiles
25
+
26
+ Copy yr firmware to ~/.avb.hex/ in this format (optional):
27
+
28
+ name_mcu_freq.hex
29
+
30
+ Example:
31
+
32
+ cp compiled.hex ~/avb.hex/myproj_atmega328p_16mhz.hex
33
+
34
+
35
+
36
+ == Contributing to avburn
37
+
38
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
39
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
40
+ * Fork the project
41
+ * Start a feature/bugfix branch
42
+ * Commit and push until you are happy with your contribution
43
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
44
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
45
+
46
+ == Copyright
47
+
48
+ Copyright (c) 2010 Marcos Piccinini. See LICENSE.txt for
49
+ further details.
50
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "avburn"
16
+ gem.homepage = "http://github.com/nofxx/avburn"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Shoes based GUI for AVRDUDE}
19
+ gem.description = %Q{Shoes based GUI for AVRDUDE, burn fuses, bootloaders}
20
+ gem.email = "x@nofxx.com"
21
+ gem.authors = ["Marcos Piccinini"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "avburn #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/avburn ADDED
@@ -0,0 +1,303 @@
1
+ #!/usr/bin/env shoes
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'avburn'
4
+ include Avburn
5
+
6
+
7
+
8
+
9
+
10
+
11
+ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
12
+ background gradient(rgb(245, 245, 245), rgb(190,190,190))
13
+ # background "#e0e0e0"
14
+
15
+ flow do
16
+ background "#881010"
17
+ # background_gradient(rgb(138, 10, 10), rgb(190,30,30))
18
+ # image "gamefaqs-logo.gif"
19
+ # title "AVRb", :margin_top => 30, :color => "#ffffff"
20
+ stack :width => '90%' do
21
+ banner "AVbuRn", :margin_left => 15, :margin_top => 17, :variant => 'smallcaps', :size => 'large', :stroke => "#fff", :weight => "bold"
22
+ end
23
+ stack :margin_top => 17, :width => '-5%' do
24
+ @fuse_stack = stack do
25
+ @fuse_btn = button("FUSE") do |btn|
26
+ @fuse_stack.hide
27
+ @hex_stack.show
28
+
29
+ @hex.hide
30
+ @fuses.show
31
+ end
32
+ end
33
+ @fuse_stack.hide
34
+ @hex_stack = stack do
35
+ # @fuse_btn.toggle
36
+ @hex_btn = button("HEX") do |btn|
37
+ @fuse_stack.show
38
+ @hex_stack.hide
39
+ @hex.show
40
+ @fuses.hide
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ stack :margin => 10, :margin_top => 2 do
47
+ flow do
48
+ stack do #:width => '50%' do
49
+ border "#fff"
50
+ flow do
51
+ para " Programmer: ", :weight => "bold"
52
+ @prog_list = list_box :items => Prog.all, :width => 120, :choose => Conf[:prog] do |list|
53
+ @prog = list.text
54
+ changed(list)
55
+ check_enabled()
56
+ end
57
+ para " Platform: ", :weight => "bold"
58
+ @platform_list = list_box :items => Part.all, :text => "Select..", :width => 120, :choose => @platform ||= Conf[:platform] do |list|
59
+ # @platform_list = list_box :items => [1,2], :width => 120 do |list|
60
+ @platform = list.text
61
+ changed(list)
62
+ print_fuses()
63
+ check_enabled()
64
+ end
65
+ para " Memory: ", :weight => "bold"
66
+ @memory_list = list_box :items => Memory, :width => 120, :choose => Conf[:memory] do |list|
67
+ @memory = list.text
68
+ changed(list)
69
+ check_enabled()
70
+ end
71
+ para " "
72
+ button "Read" do
73
+ run_comm "#{@memory}:r:#{@memory}:#{@format||'i'}"
74
+ end
75
+ para " "
76
+ button "Config" do
77
+ dialog "foo" do
78
+ flow do
79
+ background "#252499"
80
+ # image "gamefaqs-logo.gif"
81
+ # title "AVRb", :margin_top => 30, :color => "#ffffff"
82
+ stack :width => '100%' do
83
+ banner "Config", :margin_left => 15, :margin_top => 20, :variant => 'smallcaps', :size => 'large', :stroke => "#fff", :weight => "bold"
84
+ end
85
+ end
86
+ stack do
87
+ flow { check; para "Disable auto erase for flash" }
88
+ flow { check; para "Override invalid signature check" }
89
+ flow { check; para "Perform chip erase" }
90
+ flow { check; para "Do not verify" }
91
+ end
92
+ flow do
93
+ button "Cancel"
94
+ button "Save"
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+ end
101
+
102
+ # end
103
+
104
+ # stack :width => '-50%' do
105
+
106
+ flow do
107
+ para " Port: ", :weight => "bold"
108
+ @game_field = edit_line do
109
+ check_enabled()
110
+ end
111
+
112
+ para " CMD Opts: ", :weight => "bold"
113
+ @game_field = edit_line do
114
+ check_enabled()
115
+ end
116
+
117
+ para " Format: ", :weight => "bold"
118
+ @format_list = list_box :items => Format.values, :width => 120, :choose => Conf[:format] do |list|
119
+ @format = Format.keys[Format.values.index_of(list.text)]
120
+ changed(list)
121
+ check_enabled()
122
+ end
123
+
124
+
125
+ end
126
+
127
+ end
128
+ end
129
+
130
+
131
+
132
+ @fuses = stack :margin_top => 15 do
133
+ caption "Fuses"
134
+ flow do
135
+ button("HFUSE") { read_from_chip "hfuse" }
136
+ button("LFUSE") { read_from_chip "lfuse" }
137
+ button("EFUSE") { read_from_chip "efuse" }
138
+ button "LOCK" do
139
+ dialog
140
+ end
141
+ end
142
+
143
+ @fuses_checks = stack(:margin_top => 20) { }
144
+ end
145
+
146
+ @hex = stack :margit_top => 15 do
147
+ caption "HEX"
148
+ flow do
149
+ para " Hexfile: ", :weight => "bold"
150
+ @hex_list = list_box :items => Hex.all, :width => 420, :choose => Conf[:hex] do |list|
151
+ @hex = list.text
152
+ changed(list)
153
+ check_enabled()
154
+ end
155
+ para " "
156
+ button "Dump"
157
+ para " "
158
+ button "Verify"
159
+ para " "
160
+ button "Burn!" do
161
+ run_comm "#{@memory}:w:#{ENV['HOME']}/#{AvbHex}/#{@hex}"
162
+ end
163
+ end
164
+
165
+ end
166
+ @hex.hide
167
+ # print_fuses
168
+
169
+ stack(:margin_top => 20, :width => "100%", :height => 350, :scroll => true) do
170
+ flow do
171
+ caption "Log"
172
+ button("Clear") { @log.text = "" }
173
+ end
174
+ @log = para "", :family => "Inconsolata;monospace;monospaced"
175
+ end
176
+
177
+ flow(:width => "100%") do
178
+ background "#777"
179
+
180
+ @footer = para "AVRburn v0.1"
181
+ end
182
+
183
+ end
184
+
185
+ #
186
+ #
187
+ # Methods
188
+ #
189
+
190
+ def calc_fuses
191
+
192
+ end
193
+
194
+ # stack :margin => 20 do
195
+ # @average_score = para ""
196
+ # @one_line = para ""
197
+ # @full_review = para ""
198
+ # end
199
+
200
+ def print_fuses
201
+ @fuses_checks.clear
202
+ return unless @platform && fuse_ary = FuseLabel[@platform.to_sym]
203
+ @fuses_checks.append do
204
+ [:hfuse, :lfuse, :efuse].each do |fuse|
205
+ next unless all = fuse_ary[fuse]
206
+ flow do
207
+ ftxt = edit_line @fuses_store["#{fuse}hex"], :width => "25px" do |line|
208
+ @fuses_store.set(fuse, line.text)
209
+ print_fuses if line.text.size > 1
210
+ end
211
+ instance_variable_set("@#{fuse}_txt".to_sym, ftxt)
212
+ all.each_with_index do |label, i|
213
+
214
+ lbl = para label
215
+ ch = check :checked => avr_bool(@fuses_store[fuse][i])
216
+ ch.click do |c|
217
+ instance_variable_get("@#{fuse}_txt").text = @fuses_store.set_bit(fuse, i, c.checked?)
218
+ end
219
+ para "|", :stroke => "#aaa"
220
+ # lbl.click { ch.checked = ch.checked? ? false : true } #TODO nice to click on labels... =/
221
+ end
222
+ para " #{@fuses_store[fuse].join.scan(/\d{4}/).join(' ')} "
223
+ button("w") { write_fuse(fuse) }
224
+
225
+ end
226
+ end
227
+ # button("Clear") { @log.text = "" }
228
+ end
229
+ end
230
+
231
+ def toggle_mode
232
+ @toggle_btn.text = @toggle_btn.text == "HEX" ? "FUSES" : "HEX"
233
+ end
234
+
235
+ def log(txt)
236
+ @footer.text = txt
237
+ @log.text += txt + "\n" #+ @log.text
238
+ end
239
+
240
+ def read_fuse(fuse)
241
+ name = (fuse =~ /\// ? fuse.split("/")[1] : fuse)
242
+ p name
243
+ data = File.read(fuse)
244
+ log "Data: #{data}"
245
+ @fuses_store.set(name, Integer(data).to_s(16))
246
+ p @fuses_store
247
+ end
248
+
249
+ def write_fuse(fu)
250
+ hex = @fuses_store["#{fu}hex"].upcase
251
+ run_comm "#{fu}:w:0x#{hex}:m"
252
+ end
253
+
254
+ def changed(obj)
255
+ Conf.merge!({ :platform => @platform, :prog => @prog, :memory => @memory, :format => @format })
256
+ Avburn.write_conf
257
+ end
258
+
259
+ def read_dir
260
+ @fuses_store = FuseStore.new
261
+ Fuses.each { |f| @fuses_store.set(f, "FF") }
262
+
263
+ Dir['./*'].each do |file|
264
+ case file
265
+ when /\wfuse/ then read_fuse(file)
266
+ when /\.hex/ then add_hex(file)
267
+ end
268
+ end
269
+ end
270
+ read_dir
271
+
272
+ # #{Conf[:memory]}
273
+ def read_from_chip(fuse)
274
+ run_comm "#{fuse}:r:#{fuse}:h"
275
+ read_fuse(fuse)
276
+ print_fuses
277
+ end
278
+
279
+
280
+
281
+ def check_enabled
282
+ [@one_line_review_button, @review_button, @average_score_button].each do |btn|
283
+ if @game_field.text.size > 0 and !@platform_list.text.nil?
284
+ btn.state = nil
285
+ else
286
+ btn.state = "disabled"
287
+ end
288
+ end
289
+ end
290
+ end
291
+
292
+ # stack :margin => 10 do
293
+ # button "Start" do
294
+ # @time = Time.now
295
+ # @label.replace "Stop watch started at #@time"
296
+ # end
297
+ # button "Stop" do
298
+ # @label.replace "Stopped, ", strong("#{Time.now - @time}"), " seconds elapsed."
299
+ # end
300
+ # @label = para "Press ", strong("start"), " to begin timing."
301
+ # end
302
+ # end
303
+