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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 532009d8c68796ad9c91cce747fc7340cd1029452605cce38a0dbca4c9d1b455
4
- data.tar.gz: 05e10691eaac4c802ae004c1c437da6826a61d8dbca71809c0052afc62226b95
3
+ metadata.gz: 1f3b340b21118185404ab8bd51e178eb393f6892f4e7de1c57b75c370bd8dada
4
+ data.tar.gz: b227867fa95cdbfb87f79c06e98f6bf2630a6e0766a43631491bc100af310b66
5
5
  SHA512:
6
- metadata.gz: 5902e597181f1fd66b92a96de9af55512742f74537c17b754663a6b939fff824244d10f1040126b294e662b40a6bb471019b6c21cc697f71b4f00aeeb986df4f
7
- data.tar.gz: a80c341298b7d361513f93e988ba4ca86178346e97c56ead2a02e09e914695bf08b262efb4cced201903b21b00e6acd2b3dea97b3c7d3e9871575d6b8b77e24b
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
- [Neotrelliis](datasheets/neotrellis.jpg)
5
+ ![Neotrellis](datasheets/neotrellis.jpg)
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 interruption is done by the [YaGPIO](https://github.com/nagius/ya_gpio) gem based on Sysfs interface. It has been designed for Raspberry Pi but should work with any GPIO systems supported by the Sysfs kernel driver.
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`. Te I2C port need to be enabled in the linux kenel to operate. Refer to Raspberry Pi documentation to do so.
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
@@ -3,7 +3,7 @@ require "rspec/core/rake_task"
3
3
  require 'yard'
4
4
 
5
5
  YARD::Rake::YardocTask.new do |t|
6
- t.files = ['lib/neotrellis/*.rb']
6
+ t.files = ['lib/**/*.rb']
7
7
  t.stats_options = ['--list-undoc']
8
8
  end
9
9
 
@@ -1,3 +1,11 @@
1
1
  require 'neotrellis/seesaw'
2
2
  require 'neotrellis/neopixel'
3
3
  require 'neotrellis/keypad'
4
+
5
+ module Neotrellis
6
+ # Raised in case of read error from the underlying I2C device
7
+ class ReadError < StandardError
8
+ end
9
+ end
10
+
11
+ # vim: ts=4:sw=4:ai
@@ -91,7 +91,11 @@ module Neotrellis
91
91
  #
92
92
  # @return [Integer] Number of events
93
93
  def count_events
94
- @seesaw.read_byte(KEYPAD_BASE, KEYPAD_COUNT)
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.
@@ -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).ord
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
@@ -1,6 +1,6 @@
1
1
  module Neotrellis
2
2
  # Version number
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
 
6
6
  # vim: ts=4:sw=4:ai
@@ -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", "~> 10.0"
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.0
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: 2019-10-05 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
68
+ version: 12.3.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement