neotrellis 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.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/Rakefile +1 -1
- data/lib/neotrellis.rb +8 -0
- data/lib/neotrellis/keypad.rb +5 -1
- data/lib/neotrellis/seesaw.rb +5 -1
- data/lib/neotrellis/version.rb +1 -1
- data/neotrellis.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f3b340b21118185404ab8bd51e178eb393f6892f4e7de1c57b75c370bd8dada
|
4
|
+
data.tar.gz: b227867fa95cdbfb87f79c06e98f6bf2630a6e0766a43631491bc100af310b66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4663bbbce9df3f96aaf57191bce3635f1ee78c296e107ec8d1e2ec988f4d24429311b0c02243addc1c6616bbf36c92f2e6de77294954982baf65e363ab017d9b
|
7
|
+
data.tar.gz: 95ebf3e037646148659ddb3b1b759ef32f0fca145a8d12cd407a8b19a13da249073c978ec4d8d27673caf19d37934928eaa03ef12cd8077f6ff416b43b087b72
|
data/README.md
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Neotrellis is a ruby driver for Adafruit's NeoTrellis keypad. This device uses an I2C bus to control both the keypad and the RGB led array.
|
4
4
|
|
5
|
-
[
|
5
|
+

|
6
6
|
|
7
7
|
See https://www.adafruit.com/product/3954 for more details on this device.
|
8
8
|
|
9
9
|
This ruby gem is mainly compose of two classes :
|
10
|
-
- Neotrellis::Neopixels to control the leds behind each keys.
|
11
|
-
- Neotrellis::Keypad to execute code when a key is pressed or released on the keypad
|
10
|
+
- `Neotrellis::Neopixels` to control the leds behind each keys.
|
11
|
+
- `Neotrellis::Keypad` to execute code when a key is pressed or released on the keypad.
|
12
12
|
|
13
13
|
The Keypad class provide two modes to react to key events: using pooling with a loop or using interruption handler. The pooling mode require only the I2C communication to be set up. For the interruption mode to work, the pin INT on the keypad need to be connected to a GPIO input supporting hardware interruption on your computer. A common use case are the pins 15 or 16 of the Raspberry Pi GPIO header. See Raspberry Pi documentation for more details.
|
14
14
|
|
15
|
-
The support of hardware
|
15
|
+
The support of hardware interruptions is done by the [YaGPIO](https://github.com/nagius/ya_gpio) gem based on the Sysfs interface. It has been designed for Raspberry Pi but should work with any GPIO systems supported by the Sysfs kernel driver.
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
@@ -34,7 +34,7 @@ Or install it yourself as:
|
|
34
34
|
|
35
35
|
We will suppose here that you are using a Rasberry Pi B+ to control the Neotrellis device. Adapt the I2C device name and pin numbers for other boards.
|
36
36
|
|
37
|
-
First, connect the pins SDA and SLC of the keypad to GPIO pins 3 and 5. The device will appear on the second I2C bus of the Raspberry Pi `/dev/i2c-1`.
|
37
|
+
First, connect the pins SDA and SLC of the keypad to GPIO pins 3 and 5. The device will appear on the second I2C bus of the Raspberry Pi `/dev/i2c-1`. The I2C port need to be enabled in the linux kernel to operate. Refer to Raspberry Pi documentation to do so.
|
38
38
|
|
39
39
|
If you want to use the interruption mode also connect the INT pin to the GPIO pin 15 (GPIO22).
|
40
40
|
|
data/Rakefile
CHANGED
data/lib/neotrellis.rb
CHANGED
data/lib/neotrellis/keypad.rb
CHANGED
@@ -91,7 +91,11 @@ module Neotrellis
|
|
91
91
|
#
|
92
92
|
# @return [Integer] Number of events
|
93
93
|
def count_events
|
94
|
-
|
94
|
+
begin
|
95
|
+
@seesaw.read_byte(KEYPAD_BASE, KEYPAD_COUNT)
|
96
|
+
rescue ReadError
|
97
|
+
0
|
98
|
+
end
|
95
99
|
end
|
96
100
|
|
97
101
|
# Register a callback to execute when a key's event is processed.
|
data/lib/neotrellis/seesaw.rb
CHANGED
@@ -96,8 +96,12 @@ module Neotrellis
|
|
96
96
|
# @param function_reg [Byte] Function register address
|
97
97
|
#
|
98
98
|
# @return [Byte] Value read in the given register
|
99
|
+
# @raise [ReadError] If no data is returned form the underlying I2C device
|
99
100
|
def read_byte(base_reg, function_reg)
|
100
|
-
read_raw(1, base_reg, function_reg)
|
101
|
+
data = read_raw(1, base_reg, function_reg)
|
102
|
+
raise ReadError, "No data" if data.nil?
|
103
|
+
|
104
|
+
data.ord
|
101
105
|
end
|
102
106
|
|
103
107
|
# Read bytes from a Seesaw register
|
data/lib/neotrellis/version.rb
CHANGED
data/neotrellis.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency "i2c", "~>0.4"
|
25
25
|
spec.add_runtime_dependency "ya_gpio", "~>0.1"
|
26
26
|
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
-
spec.add_development_dependency "rake", "
|
27
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
spec.add_development_dependency 'yard', '~> 0.9'
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neotrellis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas AGIUS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i2c
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.3.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 12.3.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|