Class: PaPiRus::Display

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

Overview

The Display can be use to send image data to the epd fuse driver

Instance Attribute Summary collapse

Instance Method Summary collapse

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_commandsObject (readonly)

Returns the value of attribute allowed_commands.



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

def allowed_commands
  @allowed_commands
end

#autoObject (readonly)

Returns the value of attribute auto.



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

def auto
  @auto
end

#cogObject (readonly)

Returns the value of attribute cog.



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

def cog
  @cog
end

#display_pathObject (readonly)

Returns the value of attribute display_path.



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

def display_path
  @display_path
end

#epd_pathObject (readonly)

Returns the value of attribute epd_path.



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

def epd_path
  @epd_path
end

#filmObject (readonly)

Returns the value of attribute film.



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

def film
  @film
end

#heightObject (readonly)

Returns the value of attribute height.



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

def height
  @height
end

#imageObject

Returns the value of attribute image.



6
7
8
# File 'lib/papirus.rb', line 6

def image
  @image
end

#inverseObject

Returns the value of attribute inverse.



6
7
8
# File 'lib/papirus.rb', line 6

def inverse
  @inverse
end

#panelObject (readonly)

Returns the value of attribute panel.



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

def panel
  @panel
end

#rotationObject

Returns the value of attribute rotation.



6
7
8
# File 'lib/papirus.rb', line 6

def rotation
  @rotation
end

#widthObject (readonly)

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#clearObject



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_updateObject



29
30
31
# File 'lib/papirus.rb', line 29

def fast_update()
    command('F')
end

#partial_updateObject



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

#updateObject



37
38
39
# File 'lib/papirus.rb', line 37

def update()
    command('U')
end