Class: PaPiRus::Display
- Inherits:
-
Object
- Object
- PaPiRus::Display
- Defined in:
- lib/papirus.rb
Overview
The Display can be use to send image data to the epd fuse driver
Instance Attribute Summary collapse
-
#allowed_commands ⇒ Object
readonly
The possible commands to send to the display with command can be eitheri ‘U’ for update ‘F’ for fast update ‘P’ for partial update or ‘C’ for clearing the screen.
-
#auto ⇒ Object
readonly
Returns the value of attribute auto.
-
#cog ⇒ Object
readonly
Returns the value of attribute cog.
-
#display_path ⇒ Object
readonly
Returns the value of attribute display_path.
-
#epd_path ⇒ Object
readonly
Returns the value of attribute epd_path.
-
#film ⇒ Object
readonly
Returns the value of attribute film.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#image ⇒ Object
Returns the value of attribute image.
-
#inverse ⇒ Object
Returns the value of attribute inverse.
-
#panel ⇒ Object
readonly
Returns the value of attribute panel.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #clear ⇒ Object
-
#command(c) ⇒ Object
send’s the display command to the driver.
- #fast_update ⇒ Object
-
#initialize(epd_path: '/dev/epd', width: 200, height: 96, panel: 'EPD 2.0', cog: 0, film: 0, auto: false, inverse: false, rotation: 0) ⇒ Display
constructor
A new instance of Display.
- #partial_update ⇒ Object
- #show(*args) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(epd_path: '/dev/epd', width: 200, height: 96, panel: 'EPD 2.0', cog: 0, film: 0, auto: false, inverse: false, rotation: 0) ⇒ Display
Returns a new instance of Display.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/papirus.rb', line 15 def initialize(epd_path: '/dev/epd', width: 200, height: 96, panel: 'EPD 2.0', cog: 0, film: 0, auto: false, inverse: false, rotation: 0) #transver all vars to attr's method(__method__).parameters.each do |type, k| next unless type == :key v = eval(k.to_s) instance_variable_set("@#{k}", v) unless v.nil? end @allowed_commands = ['F', 'P', 'U', 'C'] get_display_info_from_edp end |
Instance Attribute Details
#allowed_commands ⇒ Object (readonly)
The possible commands to send to the display with command can be eitheri ‘U’ for update ‘F’ for fast update ‘P’ for partial update or ‘C’ for clearing the screen
13 14 15 |
# File 'lib/papirus.rb', line 13 def allowed_commands @allowed_commands end |
#auto ⇒ Object (readonly)
Returns the value of attribute auto.
5 6 7 |
# File 'lib/papirus.rb', line 5 def auto @auto end |
#cog ⇒ Object (readonly)
Returns the value of attribute cog.
5 6 7 |
# File 'lib/papirus.rb', line 5 def cog @cog end |
#display_path ⇒ Object (readonly)
Returns the value of attribute display_path.
5 6 7 |
# File 'lib/papirus.rb', line 5 def display_path @display_path end |
#epd_path ⇒ Object (readonly)
Returns the value of attribute epd_path.
5 6 7 |
# File 'lib/papirus.rb', line 5 def epd_path @epd_path end |
#film ⇒ Object (readonly)
Returns the value of attribute film.
5 6 7 |
# File 'lib/papirus.rb', line 5 def film @film end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/papirus.rb', line 5 def height @height end |
#image ⇒ Object
Returns the value of attribute image.
6 7 8 |
# File 'lib/papirus.rb', line 6 def image @image end |
#inverse ⇒ Object
Returns the value of attribute inverse.
6 7 8 |
# File 'lib/papirus.rb', line 6 def inverse @inverse end |
#panel ⇒ Object (readonly)
Returns the value of attribute panel.
5 6 7 |
# File 'lib/papirus.rb', line 5 def panel @panel end |
#rotation ⇒ Object
Returns the value of attribute rotation.
6 7 8 |
# File 'lib/papirus.rb', line 6 def rotation @rotation end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/papirus.rb', line 5 def width @width end |
Instance Method Details
#clear ⇒ Object
48 49 50 |
# File 'lib/papirus.rb', line 48 def clear() command('C') end |
#command(c) ⇒ Object
send’s the display command to the driver
54 55 56 57 58 59 |
# File 'lib/papirus.rb', line 54 def command(c) raise "command #{c} does not exist" unless @allowed_commands.include?(c) File.open(File.join(@epd_path, "command"), "wb") do |io| io.write(c) end end |
#fast_update ⇒ Object
36 37 38 |
# File 'lib/papirus.rb', line 36 def fast_update() command('F') end |
#partial_update ⇒ Object
40 41 42 |
# File 'lib/papirus.rb', line 40 def partial_update() command('P') end |
#show(*args) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/papirus.rb', line 26 def show(*args) raise 'you need to al least provide raw imagedata' if args.length == 0 data = args[0] updatemethod = args[1] || 'U' File.open(File.join(@epd_path, "LE", "display#{@inverse ? '_inverse': ''}"), 'wb') do |io| io.write data end command(@allowed_commands.include?(updatemethod) ? updatemethod : 'U') end |
#update ⇒ Object
44 45 46 |
# File 'lib/papirus.rb', line 44 def update() command('U') end |