avburn 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/bin/avburn +51 -58
  3. data/lib/avburn.rb +27 -4
  4. metadata +3 -5
  5. data/LICENSE.txt +0 -20
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bin/avburn CHANGED
@@ -4,17 +4,13 @@ require 'avburn'
4
4
  include Avburn
5
5
 
6
6
 
7
-
8
-
9
-
10
-
11
7
  Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
12
8
  background gradient(rgb(245, 245, 245), rgb(190,190,190))
13
9
  # background "#e0e0e0"
14
10
 
15
11
  flow do
16
12
  background "#881010"
17
- # background_gradient(rgb(138, 10, 10), rgb(190,30,30))
13
+ # background_gradient(rgb(138, 10, 10), rgb(190,30,30))
18
14
  # image "gamefaqs-logo.gif"
19
15
  # title "AVRb", :margin_top => 30, :color => "#ffffff"
20
16
  stack :width => '90%' do
@@ -52,7 +48,6 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
52
48
  @prog_list = list_box :items => Prog.all, :width => 120, :choose => Conf[:prog] do |list|
53
49
  @prog = list.text
54
50
  changed(list)
55
- check_enabled()
56
51
  end
57
52
  para " Platform: ", :weight => "bold"
58
53
  @platform_list = list_box :items => Part.all, :text => "Select..", :width => 120, :choose => @platform ||= Conf[:platform] do |list|
@@ -60,13 +55,11 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
60
55
  @platform = list.text
61
56
  changed(list)
62
57
  print_fuses()
63
- check_enabled()
64
58
  end
65
59
  para " Memory: ", :weight => "bold"
66
60
  @memory_list = list_box :items => Memory, :width => 120, :choose => Conf[:memory] do |list|
67
61
  @memory = list.text
68
62
  changed(list)
69
- check_enabled()
70
63
  end
71
64
  para " "
72
65
  button "Read" do
@@ -74,60 +67,60 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
74
67
  end
75
68
  para " "
76
69
  button "Config" do
77
- dialog "foo" do
70
+ @config_dlg = dialog "Config", :width => 300, :height => 280 do
78
71
  flow do
79
- background "#252499"
72
+ background "#881010"
80
73
  # image "gamefaqs-logo.gif"
81
74
  # title "AVRb", :margin_top => 30, :color => "#ffffff"
82
75
  stack :width => '100%' do
83
76
  banner "Config", :margin_left => 15, :margin_top => 20, :variant => 'smallcaps', :size => 'large', :stroke => "#fff", :weight => "bold"
84
77
  end
85
78
  end
86
- stack do
87
- flow { check; para "Disable auto erase for flash" }
79
+ stack :margin => 15 do
80
+ flow do
81
+ ch = check :checked => @erase_flash
82
+ ch.click do |c|
83
+ @erase_flash = c.checked?
84
+ end
85
+ para "Disable auto erase for flash"
86
+ end
88
87
  flow { check; para "Override invalid signature check" }
89
88
  flow { check; para "Perform chip erase" }
90
89
  flow { check; para "Do not verify" }
91
90
  end
92
- flow do
93
- button "Cancel"
94
- button "Save"
91
+ stack :margin_left => 110 do
92
+ button "Close" do
93
+ close
94
+ end
95
95
  end
96
-
97
96
  end
98
97
 
99
98
  end
100
99
  end
101
100
 
102
- # end
103
-
104
- # stack :width => '-50%' do
105
101
 
106
102
  flow do
107
103
  para " Port: ", :weight => "bold"
108
- @game_field = edit_line do
109
- check_enabled()
104
+ edit_line do |l|
105
+ @port = l.text
110
106
  end
111
107
 
112
108
  para " CMD Opts: ", :weight => "bold"
113
- @game_field = edit_line do
114
- check_enabled()
109
+ edit_line do |l|
110
+ @cmd_opts = l.text
115
111
  end
116
112
 
117
113
  para " Format: ", :weight => "bold"
118
114
  @format_list = list_box :items => Format.values, :width => 120, :choose => Conf[:format] do |list|
119
115
  @format = Format.keys[Format.values.index_of(list.text)]
120
116
  changed(list)
121
- check_enabled()
122
117
  end
123
118
 
124
-
125
119
  end
126
120
 
127
121
  end
128
- end
129
-
130
122
 
123
+ end
131
124
 
132
125
  @fuses = stack :margin_top => 15 do
133
126
  caption "Fuses"
@@ -148,18 +141,33 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
148
141
  flow do
149
142
  para " Hexfile: ", :weight => "bold"
150
143
  @hex_list = list_box :items => Hex.all, :width => 420, :choose => Conf[:hex] do |list|
151
- @hex = list.text
152
- changed(list)
153
- check_enabled()
144
+ @hexfile = list.text
145
+ check_hex_enabled
154
146
  end
155
147
  para " "
156
- button "Dump"
148
+ @verify_btn = button("Verify", :state => "disabled") { run_hex_comm :v }
157
149
  para " "
158
- button "Verify"
150
+ @burn_btn = button("Burn!", :state => "disabled") { run_hex_comm :w }
151
+ end
152
+
153
+ flow do
154
+ para " Name: ", :weight => "bold"
155
+ edit_line :width => 220 do |le|
156
+ @proj_name = le.text
157
+ end
159
158
  para " "
160
- button "Burn!" do
161
- run_comm "#{@memory}:w:#{ENV['HOME']}/#{AvbHex}/#{@hex}"
159
+ button "Dump" do |btn|
160
+ btn.state = "Disabled"
161
+ Thread.new do
162
+ ds = dump_stamp(@memory)
163
+ run_comm "#{@memory}:r:#{ds}:i"
164
+ data = File.read(ds)
165
+ filename = "/#{@proj_name}_#{@platform}.hex"
166
+ File.open(AvbHex + filename, "w") { |f| f << data }
167
+ @hex_list.items = Hex.all
168
+ end
162
169
  end
170
+
163
171
  end
164
172
 
165
173
  end
@@ -186,17 +194,10 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
186
194
  #
187
195
  # Methods
188
196
  #
189
-
190
- def calc_fuses
191
-
197
+ def run_hex_comm(c)
198
+ run_comm "#{@memory}:#{c}:#{ENV['HOME']}/#{AvbHex}/#{@hexfile}"
192
199
  end
193
200
 
194
- # stack :margin => 20 do
195
- # @average_score = para ""
196
- # @one_line = para ""
197
- # @full_review = para ""
198
- # end
199
-
200
201
  def print_fuses
201
202
  @fuses_checks.clear
202
203
  return unless @platform && fuse_ary = FuseLabel[@platform.to_sym]
@@ -209,7 +210,7 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
209
210
  print_fuses if line.text.size > 1
210
211
  end
211
212
  instance_variable_set("@#{fuse}_txt".to_sym, ftxt)
212
- all.each_with_index do |label, i|
213
+ all.each_with_index do |label, i|
213
214
 
214
215
  lbl = para label
215
216
  ch = check :checked => avr_bool(@fuses_store[fuse][i])
@@ -218,7 +219,7 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
218
219
  end
219
220
  para "|", :stroke => "#aaa"
220
221
  # lbl.click { ch.checked = ch.checked? ? false : true } #TODO nice to click on labels... =/
221
- end
222
+ end
222
223
  para " #{@fuses_store[fuse].join.scan(/\d{4}/).join(' ')} "
223
224
  button("w") { write_fuse(fuse) }
224
225
 
@@ -233,17 +234,15 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
233
234
  end
234
235
 
235
236
  def log(txt)
236
- @footer.text = txt
237
+ @footer.text = txt.split("\n")[-1]
237
238
  @log.text += txt + "\n" #+ @log.text
238
239
  end
239
240
 
240
241
  def read_fuse(fuse)
241
242
  name = (fuse =~ /\// ? fuse.split("/")[1] : fuse)
242
- p name
243
243
  data = File.read(fuse)
244
244
  log "Data: #{data}"
245
245
  @fuses_store.set(name, Integer(data).to_s(16))
246
- p @fuses_store
247
246
  end
248
247
 
249
248
  def write_fuse(fu)
@@ -276,16 +275,10 @@ Shoes.app :title => "AVbuRn", :width => 980, :height => 730 do
276
275
  print_fuses
277
276
  end
278
277
 
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
278
+ def check_hex_enabled
279
+ state = @hexfile ? nil : "disabled"
280
+ @verify_btn.state = state
281
+ @burn_btn.state = state
289
282
  end
290
283
  end
291
284
 
data/lib/avburn.rb CHANGED
@@ -41,16 +41,29 @@ module Avburn
41
41
  bit.to_i.zero?
42
42
  end
43
43
 
44
+ def dump_stamp(n)
45
+ "/tmp/#{n}-#{Time.now.to_i}"
46
+ end
47
+
44
48
  def run_comm(c)
45
49
  @log.text = ""
46
50
  comm = "#{Avrdude} -c #{Conf[:prog]} -p #{Conf[:platform]} "
47
- comm << "-P #{Conf[:port]} " if @port
48
- comm << "-U #{c}"
51
+ comm << "-P #{@port} " if @port
52
+ comm << "#{@cmd_opts} -U #{c}"
49
53
  log "> Running #{comm}"
50
- Kernel.system "#{comm} &> output"
51
- log File.read("output")
54
+ if block_given?
55
+ Thread.new do
56
+ Kernel.system "#{comm} &> output"
57
+ log File.read("output")
58
+ yield
59
+ end
60
+ else
61
+ Kernel.system "#{comm} &> output"
62
+ log File.read("output")
63
+ end
52
64
  end
53
65
 
66
+
54
67
  class << self
55
68
 
56
69
  def read_conf
@@ -117,3 +130,13 @@ end
117
130
 
118
131
 
119
132
  Avburn.read_conf
133
+
134
+
135
+ # class AvrdudeWrapper
136
+ # attr_accessor :percent
137
+
138
+ # def bg_run_comm
139
+ # @percent = 0.0
140
+ # end
141
+
142
+ # end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marcos Piccinini
@@ -83,14 +83,12 @@ executables:
83
83
  extensions: []
84
84
 
85
85
  extra_rdoc_files:
86
- - LICENSE.txt
87
86
  - README.rdoc
88
87
  files:
89
88
  - .document
90
89
  - .rspec
91
90
  - Gemfile
92
91
  - Gemfile.lock
93
- - LICENSE.txt
94
92
  - README.rdoc
95
93
  - Rakefile
96
94
  - VERSION
@@ -114,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
112
  requirements:
115
113
  - - ">="
116
114
  - !ruby/object:Gem::Version
117
- hash: -1524349970638977619
115
+ hash: -2285582613984815413
118
116
  segments:
119
117
  - 0
120
118
  version: "0"
data/LICENSE.txt DELETED
@@ -1,20 +0,0 @@
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.