papirus 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -18
- data/lib/papirus.rb +12 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e058ef8f10445a56a69a14ae4d8044ac941548a3
|
4
|
+
data.tar.gz: 756b5c818963af406a77fbcf4140d93f67d2d620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10d7c085d808892a893d3317d57490bdeed02ef2bffd5352300264ae5b37454725d89677c9c7f5b0568166926022ae049b3b2628989b56cd3cf27072711f23b2
|
7
|
+
data.tar.gz: fb164c0c081400db678970787ba88d7da0444fcd3cbb9875116fc79ed6bacd1411770169fda1dbc7d780597d1fa64a467b566f610b3df0dbe399e67aa53889dd
|
data/README.md
CHANGED
@@ -6,10 +6,7 @@ ruby gem to talk to the PAPiRus display
|
|
6
6
|
```bash
|
7
7
|
sudo apt-get install libfuse-dev -y
|
8
8
|
|
9
|
-
mkdir /tmp/papirus
|
10
|
-
cd /tmp/papirus
|
11
9
|
git clone https://github.com/repaper/gratis.git
|
12
|
-
|
13
10
|
cd gratis
|
14
11
|
make rpi EPD_IO=epd_io.h PANEL_VERSION='V231_G2'
|
15
12
|
make rpi-install EPD_IO=epd_io.h PANEL_VERSION='V231_G2'
|
@@ -50,21 +47,33 @@ display.clear
|
|
50
47
|
image.circle(display.width/2, display.height/2, radius)
|
51
48
|
display.show(image.to_bit_stream, 'F')
|
52
49
|
end
|
53
|
-
```
|
54
50
|
|
55
|
-
|
51
|
+
# there are multiple screen commands ['F', 'P', 'U', 'C']
|
56
52
|
|
57
|
-
|
58
|
-
image
|
59
|
-
display.show(image.to_bit_stream)
|
53
|
+
* you can call `display.show(image.to_bit_stream); display.update` or `display.show(image.to_bit_stream, 'U')`
|
54
|
+
* you can call `display.show(image.to_bit_stream); display.fast_update` or `display.show(image.to_bit_stream, 'F')`
|
55
|
+
* you can call `display.show(image.to_bit_stream); display.partial_update` or `display.show(image.to_bit_stream, 'P')`
|
60
56
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
display = PaPiRus::Display.new(epd_path: '/tmp/epd')
|
57
|
+
```
|
58
|
+
# Testing without a PAPiRus display
|
59
|
+
|
60
|
+
If you want to test the gem, but don't have your PaPiRus available, you can do the following
|
61
|
+
|
62
|
+
* clone this repo
|
63
|
+
* run the createtestepd.sh script that is in the repo which creates the needed files and folders in /tmp/epd
|
64
|
+
* start irb
|
65
|
+
* require 'papirus'
|
66
|
+
* display = PaPiRus::Display.new(epd_path: '/tmp/epd')
|
67
|
+
* play with the examples above
|
68
|
+
* when you run `display.show` the **fake** display /tmp/epd/LE/display is filled with your image
|
69
|
+
* now you can use a bin editor like xxd to have a look at the result: `xxd -b /tmp/epd/LE/display`
|
70
|
+
|
71
|
+
# TODO
|
72
|
+
|
73
|
+
* make the image.to_bit_stream routine faster (as it is now to slow to do animations with partial updates)
|
74
|
+
* add support for reading the temperature of the display
|
75
|
+
* add support for changing the update rate
|
76
|
+
* make the gem not depending on chunky_png
|
77
|
+
* make load png image with chunky_png work (now output is black)
|
78
|
+
* make a display.load(image) that takes multiple formats and figures out how to present them
|
79
|
+
* create an issue to add your own requests :)
|
data/lib/papirus.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative "chunky"
|
|
2
2
|
|
3
3
|
module PaPiRus
|
4
4
|
class Display
|
5
|
-
attr_reader :epd_path, :width, :height, :panel, :cog, :film, :auto
|
5
|
+
attr_reader :epd_path, :width, :height, :panel, :cog, :film, :auto, :allowed_commands
|
6
6
|
attr_accessor :rotation, :inverse, :image
|
7
7
|
|
8
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)
|
@@ -12,6 +12,7 @@ module PaPiRus
|
|
12
12
|
v = eval(k.to_s)
|
13
13
|
instance_variable_set("@#{k}", v) unless v.nil?
|
14
14
|
end
|
15
|
+
@allowed_commands = ['F', 'P', 'U', 'C']
|
15
16
|
get_display_info_from_edp
|
16
17
|
end
|
17
18
|
|
@@ -22,7 +23,7 @@ module PaPiRus
|
|
22
23
|
File.open(File.join(@epd_path, "LE", "display#{@inverse ? '_inverse': ''}"), 'wb') do |io|
|
23
24
|
io.write data
|
24
25
|
end
|
25
|
-
command(updatemethod)
|
26
|
+
command(@allowed_commands.include?(updatemethod) ? updatemethod : 'U')
|
26
27
|
end
|
27
28
|
|
28
29
|
def fast_update()
|
@@ -41,8 +42,17 @@ module PaPiRus
|
|
41
42
|
command('C')
|
42
43
|
end
|
43
44
|
|
45
|
+
def command(c)
|
46
|
+
raise "command #{c} does not exist" unless @allowed_commands.include?(c)
|
47
|
+
File.open(File.join(@epd_path, "command"), "wb") do |io|
|
48
|
+
io.write(c)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
44
52
|
private
|
45
53
|
def get_display_info_from_edp
|
54
|
+
#now we will read the info of the installed display
|
55
|
+
#and update the properties accordingly
|
46
56
|
if File.exists?(File.join(@epd_path, 'panel'))
|
47
57
|
info = File.read(File.join(@epd_path, 'panel'))
|
48
58
|
if match = info.match(/^([A-Za-z]+\s+\d+\.\d+)\s+(\d+)x(\d+)\s+COG\s+(\d+)\s+FILM\s+(\d+)\s*$/)
|
@@ -57,9 +67,5 @@ module PaPiRus
|
|
57
67
|
end
|
58
68
|
end
|
59
69
|
|
60
|
-
def command(c)
|
61
|
-
f = File.new(File.join(@epd_path, "command"), "wb")
|
62
|
-
f.write(c)
|
63
|
-
end
|
64
70
|
end
|
65
71
|
end
|