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.



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

#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



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

Parameters:

  • c (string)

    command to execute, have a look at {}



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_updateObject



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

def fast_update()
    command('F')
end

#partial_updateObject



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

#updateObject



44
45
46
# File 'lib/papirus.rb', line 44

def update()
    command('U')
end