Class: Device::Display

Inherits:
Object
  • Object
show all
Defined in:
lib/device/display.rb

Constant Summary collapse

MAIN_BMP =
"main.bmp"

Class Method Summary collapse

Class Method Details

.adapterObject



5
6
7
# File 'lib/device/display.rb', line 5

def self.adapter
  Device.adapter::Display
end

.clear(line = nil) ⇒ Object

Clean display



44
45
46
47
48
49
50
51
# File 'lib/device/display.rb', line 44

def self.clear(line = nil)
  if line.nil?
    STDOUT.fresh
    adapter.clear
  else
    adapter.clear_line line
  end
end

.main_imageObject



73
74
75
76
77
78
79
80
# File 'lib/device/display.rb', line 73

def self.main_image
  if adapter.respond_to?(:main_image) &&
    File.exists?("./shared/#{adapter.main_image}")
    adapter.main_image
  else
    MAIN_BMP
  end
end

Display buffer



15
16
17
18
19
20
21
# File 'lib/device/display.rb', line 15

def self.print(buf, row = nil, column = nil)
  if row.nil? && column.nil?
    STDOUT.print(buf)
  else
    adapter.print_in_line(buf, row, column)
  end
end

Display bitmap



33
34
35
36
37
38
39
# File 'lib/device/display.rb', line 33

def self.print_bitmap(path, row = 0, column = 0)
  if File.exists?(path)
    adapter.display_bitmap(path, row, column)
  else
    false
  end
end


23
24
25
# File 'lib/device/display.rb', line 23

def self.print_line(buf, row = 0, column = 0)
  self.print(buf, row, column)
end


68
69
70
71
# File 'lib/device/display.rb', line 68

def self.print_main_image
  bmp = "./shared/#{self.main_image}"
  self.print_bitmap(bmp,0,0) if File.exists?(bmp)
end

Print image in slot of status bar



59
60
61
62
63
64
65
66
# File 'lib/device/display.rb', line 59

def self.print_status_bar(slot, image_path)
  slots = self.adapter.status_bar_slots_available - 1
  if (0..slots).include?(slot)
    if image_path.nil? || File.exists?(image_path)
      self.adapter.print_status_bar(slot, image_path)
    end
  end
end