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
Returns the value of attribute allowed_commands.
-
#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
- #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.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/papirus.rb', line 8 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)
Returns the value of attribute allowed_commands.
5 6 7 |
# File 'lib/papirus.rb', line 5 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
41 42 43 |
# File 'lib/papirus.rb', line 41 def clear() command('C') end |
#command(c) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/papirus.rb', line 45 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
29 30 31 |
# File 'lib/papirus.rb', line 29 def fast_update() command('F') end |
#partial_update ⇒ Object
33 34 35 |
# File 'lib/papirus.rb', line 33 def partial_update() command('P') end |
#show(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/papirus.rb', line 19 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
37 38 39 |
# File 'lib/papirus.rb', line 37 def update() command('U') end |