Class: Device::Display
- Inherits:
-
Object
- Object
- Device::Display
- Defined in:
- lib/device/display.rb
Constant Summary collapse
- MAIN_BMP =
"main.bmp"
Class Method Summary collapse
- .adapter ⇒ Object
-
.clear(line = nil) ⇒ Object
Clean display.
- .main_image ⇒ Object
-
.print(buf, row = nil, column = nil) ⇒ NilClass
Display buffer.
-
.print_bitmap(path, row = 0, column = 0) ⇒ NilClass
Display bitmap.
- .print_line(buf, row = 0, column = 0) ⇒ Object
- .print_main_image ⇒ Object
-
.print_status_bar(slot, image_path) ⇒ NilClass, TrueClass
Print image in slot of status bar.
Class Method Details
.adapter ⇒ Object
5 6 7 |
# File 'lib/device/display.rb', line 5 def self.adapter Device.adapter::Display end |
.clear(line = nil) ⇒ Object
Clean display
41 42 43 44 45 46 47 48 |
# File 'lib/device/display.rb', line 41 def self.clear(line = nil) if line.nil? STDOUT.fresh adapter.clear else adapter.clear_line line end end |
.main_image ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/device/display.rb', line 70 def self.main_image if adapter.respond_to?(:main_image) && File.exists?("./shared/#{adapter.main_image}") adapter.main_image else MAIN_BMP end end |
.print(buf, row = nil, column = nil) ⇒ NilClass
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 |
.print_bitmap(path, row = 0, column = 0) ⇒ NilClass
Display bitmap
33 34 35 36 |
# File 'lib/device/display.rb', line 33 def self.print_bitmap(path, row = 0, column = 0) raise(File::FileError, path) unless File.exists?(path) adapter.display_bitmap(path, row, column) end |
.print_line(buf, row = 0, column = 0) ⇒ Object
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 |
.print_main_image ⇒ Object
65 66 67 68 |
# File 'lib/device/display.rb', line 65 def self.print_main_image bmp = "./shared/#{self.main_image}" self.print_bitmap(bmp,0,0) if File.exists?(bmp) end |
.print_status_bar(slot, image_path) ⇒ NilClass, TrueClass
Print image in slot of status bar
56 57 58 59 60 61 62 63 |
# File 'lib/device/display.rb', line 56 def self.(slot, image_path) slots = self.adapter. - 1 if (0..slots).include?(slot) if image_path.nil? || File.exists?(image_path) self.adapter.(slot, image_path) end end end |