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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecdf21aaed59fa16a9c157e93770e02100155505b22b33abd1ff99428d9e9e1e
4
- data.tar.gz: c00772e6514cc340174334947a2fd137758db645616af4092589f75cb653ae0f
3
+ metadata.gz: 91743fb55a8856ef261d171f5afd28b1139586c409ffc3479d983e4f4719f2c6
4
+ data.tar.gz: 15e1f7722cf925172ec4c53ec4b62a64668580d633e3cffd57948d85a5ecf80c
5
5
  SHA512:
6
- metadata.gz: a04afc13b1451a89e19fdcf2fddea3d5574f69f812d2f1db988742eec88fd3ca0e2567724792835bcdff3efda85c16c9940497dcab3400ad9c6984480cd470db
7
- data.tar.gz: b2fbe314d19a4c90142f60dbc441e486501aa42801c956a710dd6d6fcb540815d82f3720a6e11baaad69b372ca20c3b1eead922850ec3f9b63aba278e722cfbc
6
+ metadata.gz: 493f84f6d5e89fd8f5e7f632ca02e9e09ca778afec00432ac72541015643447699210fc9b4be13b80eb6996e076404f6889959753a33cbf9861cea4b8ce2368d
7
+ data.tar.gz: d064a08cad049bf4c460e9f1ed0a3ffe1f0a78563e0873e4fa2105bd7a6e89fe5537fdda9421dcd4a27e92e3d7d47d500ce2827c55fb6034e2cdf19ff8135094
data/README.md CHANGED
@@ -1,35 +1,27 @@
1
1
  # RubyIt8951
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby_it8951`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ ## About
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- ## Installation
7
+ You can easily control EPD with simple code.
8
8
 
9
- Add this line to your application's Gemfile:
9
+ ## Requirement
10
10
 
11
- ```ruby
12
- gem 'ruby_it8951'
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
- ## Usage
16
+ ## Example
24
17
 
25
- TODO: Write usage instructions here
18
+ ```Ruby
19
+ require 'ruby_it8951'
26
20
 
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake ` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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 RubyIt8951
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, [], :void
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyIt8951
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_it8951
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yagshi