Module: Avburn

Defined in:
lib/avburn.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.read_confObject



86
87
88
89
# File 'lib/avburn.rb', line 86

def read_conf
  `touch #{Avb}` unless File.exists?(Avb)
  Conf.merge! YAML.load(File.read(Avb)) || {}
end

.write_confObject



91
92
93
# File 'lib/avburn.rb', line 91

def write_conf
  File.open(Avb, 'w') { |f| f << Conf.to_yaml }
end

Instance Method Details

#avr_bool(bit) ⇒ Object



42
43
44
# File 'lib/avburn.rb', line 42

def avr_bool(bit)
  bit.to_i.zero?
end

#dump_stamp(n) ⇒ Object



46
47
48
# File 'lib/avburn.rb', line 46

def dump_stamp(n)
  "/tmp/#{n}-#{Time.now.to_i}"
end

#run_comm(c) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/avburn.rb', line 50

def run_comm(c)
  @log.text = ""
  comm = "#{Avrdude} -c #{Conf[:prog]} -p #{Conf[:platform]} "
  comm << "-P #{@port} " if @port
  comm << "-V " if Conf[:no_verify]
  comm << "-F " if Conf[:override_sig]
  comm << "-D " if Conf[:dont_erase_flash]
  comm << "-e " if Conf[:chip_erase]
  comm << "#{@cmd_opts} -U #{c}"
  log  "> Running #{comm}"
  @status.clear
  @status.append { image("../lib/avburn/img/clock.png") }

  if block_given?
    Thread.new do
      run_n_log(comm)
      yield
    end
  else
    run_n_log(comm)
  end
end

#run_n_log(comm) ⇒ Object



79
80
81
82
# File 'lib/avburn.rb', line 79

def run_n_log(comm)
  set_footer Kernel.system "#{comm} &> #{LastComm}"
  log File.read(LastComm)
end


73
74
75
76
77
# File 'lib/avburn.rb', line 73

def set_footer bool
  img = bool ? "tick" : "err"
  @status.clear
  @status.append { image("../lib/avburn/img/#{img}.png") }
end