ruby_it8951 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +16 -24
- data/lib/ruby_it8951.rb +35 -3
- data/lib/ruby_it8951/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91743fb55a8856ef261d171f5afd28b1139586c409ffc3479d983e4f4719f2c6
|
4
|
+
data.tar.gz: 15e1f7722cf925172ec4c53ec4b62a64668580d633e3cffd57948d85a5ecf80c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 493f84f6d5e89fd8f5e7f632ca02e9e09ca778afec00432ac72541015643447699210fc9b4be13b80eb6996e076404f6889959753a33cbf9861cea4b8ce2368d
|
7
|
+
data.tar.gz: d064a08cad049bf4c460e9f1ed0a3ffe1f0a78563e0873e4fa2105bd7a6e89fe5537fdda9421dcd4a27e92e3d7d47d500ce2827c55fb6034e2cdf19ff8135094
|
data/README.md
CHANGED
@@ -1,35 +1,27 @@
|
|
1
1
|
# RubyIt8951
|
2
2
|
|
3
|
-
|
3
|
+
## About
|
4
4
|
|
5
|
-
|
5
|
+
This gem is for [Waveshare Electronics](https://www.waveshare.com "Waveshare website")' IT-8951 controller based EPD (e-paper device) with Raspberry Pi.
|
6
6
|
|
7
|
-
|
7
|
+
You can easily control EPD with simple code.
|
8
8
|
|
9
|
-
|
9
|
+
## Requirement
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
11
|
+
- Native Library for Raspberry Pi [epd_it8950](https://github.com/yagshi/epd_it8951)
|
12
|
+
|
13
|
+
- [FFI](https://github.com/ffi/ffi)
|
20
14
|
|
21
|
-
$ gem install ruby_it8951
|
22
15
|
|
23
|
-
##
|
16
|
+
## Example
|
24
17
|
|
25
|
-
|
18
|
+
```Ruby
|
19
|
+
require 'ruby_it8951'
|
26
20
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
## Contributing
|
21
|
+
IT8951.init
|
22
|
+
info = IT8951.get_device_info # => [width, height, addr, "fw ver", "lut ver"]
|
23
|
+
img = (0..15).inject([]){|a, i| a + [i * 16] * 100}
|
24
|
+
IT8951.transfer_image(20, 10, 100, 16, img)
|
25
|
+
IT8951.display_area(0, 0, info[0], info[1], 2)
|
26
|
+
```
|
34
27
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_it8951.
|
data/lib/ruby_it8951.rb
CHANGED
@@ -3,10 +3,42 @@
|
|
3
3
|
require_relative "ruby_it8951/version"
|
4
4
|
require 'ffi'
|
5
5
|
|
6
|
-
module
|
6
|
+
module IT8951
|
7
7
|
class Error < StandardError; end
|
8
|
+
|
9
|
+
class DeviceInfo < FFI::Struct
|
10
|
+
layout(:panelW, :uint16, :panelH, :uint16,
|
11
|
+
:imgBufAddrL, :uint16, :imgBufAddrH, :uint16,
|
12
|
+
:fwVersion, [:uint8, 16],
|
13
|
+
:lutVersion, [:uint8, 16]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
# private module
|
17
|
+
module IT8951_P
|
18
|
+
extend FFI::Library
|
19
|
+
ffi_lib :it8951
|
20
|
+
attach_function :get_device_info, :it8951_get_device_info, [], DeviceInfo.by_value
|
21
|
+
attach_function :transfer_image, :it8951_transfer_image, [:int, :int, :int, :int, :pointer], :void
|
22
|
+
end
|
23
|
+
|
24
|
+
|
8
25
|
extend FFI::Library
|
9
26
|
ffi_lib :it8951
|
10
|
-
attach_function :it8951_init, [], :
|
11
|
-
attach_function :it8951_display_area, [:int, :int, :int, :int, :int], :void
|
27
|
+
attach_function :init, :it8951_init, [], :int
|
28
|
+
attach_function :display_area, :it8951_display_area, [:int, :int, :int, :int, :int], :void
|
29
|
+
|
30
|
+
def get_device_info
|
31
|
+
d = IT8951_P.get_device_info
|
32
|
+
[d[:panelW], d[:panelH], d[:imgBufAddrL] + d[:imgBufAddrH] * 256, d[:fwVersion].to_s, d[:lutVersion].to_s]
|
33
|
+
end
|
34
|
+
|
35
|
+
def transfer_image(x, y, w, h, data)
|
36
|
+
FFI::MemoryPointer.new(:uint8, data.length) do |p|
|
37
|
+
p.write_array_of_uint8(data)
|
38
|
+
IT8951_P.transfer_image(x, y, w, h, p)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module_function :get_device_info
|
43
|
+
module_function :transfer_image
|
12
44
|
end
|
data/lib/ruby_it8951/version.rb
CHANGED