Class: PaPiRus::Display
- Inherits:
-
Object
- Object
- PaPiRus::Display
- Defined in:
- lib/papirus.rb
Instance Attribute Summary collapse
-
#allowed_commands ⇒ Array<String>
readonly
The possible commands to send to the display with command can be either ‘U’ for update ‘F’ for fast update ‘P’ for partial update or ‘C’ for clearing the display.
-
#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
Send the clear command to the display.
-
#command(c) ⇒ Object
Send’s the display command to the driver available commands are * ‘U’ => update the display * ‘F’ => fast update the display * ‘P’ => Partial update the display * ‘C’ => Clear the display.
-
#fast_update ⇒ Object
Send the fast update command to the display.
-
#initialize(options: {}) ⇒ Display
constructor
By default, no parameters need to be passed to initialize.
-
#partial_update ⇒ Object
Send the partial update command to the display.
-
#show(data:, command: 'U') ⇒ Object
Show can be used to send raw image data to the display.
-
#update ⇒ Object
Send the full update command to the display.
Constructor Details
#initialize(options: {}) ⇒ Display
By default, no parameters need to be passed to initialize. It will read all display settings from the panel info file that is created by the fuse driver. However, if you want to test without the display being available, you can pass a fake epd_path set to a folder in /tmp in that case initialize will use all other params to create a fake fuse structure
PaPiRus display sizes:
1.44" 128 x 96
1.9" 144 x 128
2.0" 200 x 96
2.6" 232 x 128
2.7" 264 x 176
All the examples used in the documentation are also used to unit testing the code with yard:doctest, so we have duomentation and testing in one go, great!
-
the display that is used for the examples is a 8x3 mini display for the sake of simplicity.
-
imagewithline is a test helper that create an image of 8x3 pixels
-
testdisplaylookslike is a test helper that shows the bit content of the display
-
lastcommand is a test helper that will show the last command send to the display
56 57 58 59 60 |
# File 'lib/papirus.rb', line 56 def initialize(options: {}) initializeOptions(options: ) createFakeEpdFileStructure(epd_path: @epd_path) if @epd_path != EPDPATH updateOptionsFromPanel end |
Instance Attribute Details
#allowed_commands ⇒ Array<String> (readonly)
The possible commands to send to the display with command can be either
'U' for update
'F' for fast update
'P' for partial update
or 'C' for clearing the display
24 25 26 |
# File 'lib/papirus.rb', line 24 def allowed_commands @allowed_commands end |
#auto ⇒ Object (readonly)
Returns the value of attribute auto.
15 16 17 |
# File 'lib/papirus.rb', line 15 def auto @auto end |
#cog ⇒ Object (readonly)
Returns the value of attribute cog.
15 16 17 |
# File 'lib/papirus.rb', line 15 def cog @cog end |
#display_path ⇒ Object (readonly)
Returns the value of attribute display_path.
15 16 17 |
# File 'lib/papirus.rb', line 15 def display_path @display_path end |
#epd_path ⇒ Object (readonly)
Returns the value of attribute epd_path.
15 16 17 |
# File 'lib/papirus.rb', line 15 def epd_path @epd_path end |
#film ⇒ Object (readonly)
Returns the value of attribute film.
15 16 17 |
# File 'lib/papirus.rb', line 15 def film @film end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
15 16 17 |
# File 'lib/papirus.rb', line 15 def height @height end |
#image ⇒ Object
Returns the value of attribute image.
16 17 18 |
# File 'lib/papirus.rb', line 16 def image @image end |
#inverse ⇒ Object
Returns the value of attribute inverse.
16 17 18 |
# File 'lib/papirus.rb', line 16 def inverse @inverse end |
#panel ⇒ Object (readonly)
Returns the value of attribute panel.
15 16 17 |
# File 'lib/papirus.rb', line 15 def panel @panel end |
#rotation ⇒ Object
Returns the value of attribute rotation.
16 17 18 |
# File 'lib/papirus.rb', line 16 def rotation @rotation end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
15 16 17 |
# File 'lib/papirus.rb', line 15 def width @width end |
Instance Method Details
#clear ⇒ Object
Send the clear command to the display
105 106 107 |
# File 'lib/papirus.rb', line 105 def clear() command('C') end |
#command(c) ⇒ Object
Send’s the display command to the driver available commands are
* 'U' => update the display
* 'F' => fast update the display
* 'P' => Partial update the display
* 'C' => Clear the display
129 130 131 132 133 134 |
# File 'lib/papirus.rb', line 129 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
Send the fast update command to the display
81 82 83 |
# File 'lib/papirus.rb', line 81 def fast_update() command('F') end |
#partial_update ⇒ Object
Send the partial update command to the display
89 90 91 |
# File 'lib/papirus.rb', line 89 def partial_update() command('P') end |
#show(data:, command: 'U') ⇒ Object
Show can be used to send raw image data to the display.
70 71 72 73 74 75 |
# File 'lib/papirus.rb', line 70 def show(data:, command: 'U') File.open(File.join(@epd_path, "LE", "display#{@inverse ? '_inverse': ''}"), 'wb') do |io| io.write data end command(@allowed_commands.include?(command) ? command : 'U') end |
#update ⇒ Object
Send the full update command to the display
97 98 99 |
# File 'lib/papirus.rb', line 97 def update() command('U') end |