Class: Ev3dev::Screen
- Inherits:
-
Object
- Object
- Ev3dev::Screen
- Defined in:
- lib/ev3dev/screen.rb
Constant Summary collapse
- PATH =
"/dev/fb0"- FRAME_BUFFER_SIZE =
24 line length * 128 rows
3072- BLANK_IMAGE =
Array.new(FRAME_BUFFER_SIZE){ 0 }.pack("C*")
Instance Attribute Summary collapse
-
#imgs ⇒ Object
Returns the value of attribute imgs.
Instance Method Summary collapse
-
#initialize ⇒ Screen
constructor
A new instance of Screen.
- #load(image_file) ⇒ Object
- #load_blank ⇒ Object
- #show ⇒ Object
- #show_blank ⇒ Object
Constructor Details
#initialize ⇒ Screen
Returns a new instance of Screen.
25 26 27 28 |
# File 'lib/ev3dev/screen.rb', line 25 def initialize raise "couldn't find screen attributes" unless File.exist?(PATH) @imgs = [] end |
Instance Attribute Details
#imgs ⇒ Object
Returns the value of attribute imgs.
23 24 25 |
# File 'lib/ev3dev/screen.rb', line 23 def imgs @imgs end |
Instance Method Details
#load(image_file) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/ev3dev/screen.rb', line 30 def load(image_file) raise "couldn't load a image file except .mono format" unless image_file.end_with?('.mono') file_size = File.size(image_file) raise "file size:#{file_size} is not correct:(#{FRAME_BUFFER_SIZE})" unless file_size == FRAME_BUFFER_SIZE @imgs << File.binread(image_file) end |
#load_blank ⇒ Object
39 40 41 |
# File 'lib/ev3dev/screen.rb', line 39 def load_blank @imgs << BLANK_IMAGE end |
#show ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ev3dev/screen.rb', line 43 def show if @imgs.size >= 2 File.binwrite(PATH, @imgs.shift) else File.binwrite(PATH, @imgs.first) end end |
#show_blank ⇒ Object
51 52 53 |
# File 'lib/ev3dev/screen.rb', line 51 def show_blank File.binwrite(PATH, BLANK_IMAGE) end |