papirus 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -18
  3. data/lib/papirus.rb +12 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 351e781013b7ce41795cefea94547ff985ac1299
4
- data.tar.gz: 649bbf301e45d6f35e84538f359bd8b0868d51b9
3
+ metadata.gz: e058ef8f10445a56a69a14ae4d8044ac941548a3
4
+ data.tar.gz: 756b5c818963af406a77fbcf4140d93f67d2d620
5
5
  SHA512:
6
- metadata.gz: 3514f623188b3de3dca23ac413de273b625e400114978bade812bdeb4358324bf84d8428e4bf73df3af3313764a2fc3f6f2e0d2b4ea8ae3c0e14d774fa644da9
7
- data.tar.gz: 222e02a5d40b2d9bbdfd81aab137f95d8d9e9268f15de27c343db0714da4faa75cc2bfb2f20780637732875d0aa882edde7143280cbbc8285bf0d9e26f721bd9
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
- ## from here WIP
51
+ # there are multiple screen commands ['F', 'P', 'U', 'C']
56
52
 
57
- #img loading does not work yet
58
- image = ChunkyPNG::Image.from_file(pngfile)
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
- # more control
62
- display = PaPiRus::Display.new()
63
- display.load(imagefile)
64
-
65
- display.update #or
66
- display.fast_update #or
67
- display.partial_update
68
-
69
- #or when testing to a temp file (run createtestepd.sh to create paths in /tmp)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papirus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mischa Molhoek