Module: Avburn

Defined in:
lib/avburn.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.read_confObject



77
78
79
80
# File 'lib/avburn.rb', line 77

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

.write_confObject



82
83
84
# File 'lib/avburn.rb', line 82

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

Instance Method Details

#avr_bool(bit) ⇒ Object



40
41
42
# File 'lib/avburn.rb', line 40

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

#dump_stamp(n) ⇒ Object



44
45
46
# File 'lib/avburn.rb', line 44

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

#run_comm(c) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/avburn.rb', line 48

def run_comm(c)
  @log.text = ""
  comm = "#{Avrdude} -c #{Conf[:prog]} -p #{Conf[:platform]} "
  comm << "-P #{@port} " if @port
  comm << "#{@cmd_opts} -U #{c}"
  log  "> Running #{comm}"
  if block_given?
    Thread.new do
      Kernel.system "#{comm} &> output"
      log File.read("output")
      yield
    end
  else
    set_footer Kernel.system "#{comm} &> output"
    log File.read("output")
  end
end


66
67
68
69
70
71
72
# File 'lib/avburn.rb', line 66

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

end