touchberrypi 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: c00e3a348218bcab6d0b9bed5d587dbbb70e70d7
4
- data.tar.gz: 237fe41f26b36bb68d0a81f6968260d165c75148
3
+ metadata.gz: 6ff0fb28b3daa491fdf316ea129c34115ea8baf2
4
+ data.tar.gz: c3adea02d27c87a0cc3b6c8636618e9a6372e9d9
5
5
  SHA512:
6
- metadata.gz: f229eeef22a8bb02d7c51163abf34bf992c880ca91ec03b5e7d691aacde1a5e0adc7de09aeacb30733dded68c0521d87834714014177a3ed8b66d9f5a77d6f7a
7
- data.tar.gz: 31102d2f721eeb952e137f137645fe3c825aadfebf380f2537cc6e1424a9aa83c36558ccb9fffc04aa035ca49ce7047d3a347dda8679c95ebce0e862b5cbb3c2
6
+ metadata.gz: 55872b5be9113f6b55e6aebb3b3e99bb9cb4b63d7ea2d849bfb6ef07e94488349ccbe6f0d87b01ed1e2d97ad88f66c465ad7517ad4e14b1546783e27edc170c3
7
+ data.tar.gz: b2e241629f985fe821c875e32fec5bb285e7cddc0dcc7194097a4469a918e29b2b3405a27c61c36b43ce86ca57340b83359476b38f57331ce3990a5c0ff448b7
data/.gitignore CHANGED
@@ -1,10 +1,10 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.swp
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
@@ -1,5 +1,5 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.0
5
- before_install: gem install bundler -v 1.12.4
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.4
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in touchberrypi.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in touchberrypi.gemspec
4
+ gemspec
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Sille Van Landschoot
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sille Van Landschoot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,41 +1,41 @@
1
- # Touchberrypi
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/touchberrypi`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'touchberrypi'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install touchberrypi
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/touchberrypi.
36
-
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
1
+ # Touchberrypi
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/touchberrypi`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'touchberrypi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install touchberrypi
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/touchberrypi.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- task :default => :test
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "touchberrypi"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "touchberrypi"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,3 +1,3 @@
1
- require "touchberrypi/version"
2
- require "touchberrypi/Keyboard"
3
- require "touchberrypi/Leds"
1
+ require "touchberrypi/version"
2
+ require "touchberrypi/Keyboard"
3
+ require "touchberrypi/Leds"
@@ -1,55 +1,55 @@
1
- require 'pi_piper'
2
- require 'qt1070'
3
-
4
-
5
- module Touchberrypi
6
- class Keyboard
7
-
8
- include PiPiper
9
- include Qt1070
10
-
11
- KEY_MAP = ["LEFT","RIGHT","UP","DOWN","B","A","X"]
12
-
13
- def initialize
14
- sensor = Qt1070.new "/dev/i2c-1"
15
-
16
- # read sensor status to reset 'change' pin
17
- sensor.detection_status
18
- @previous_status = sensor.key_status
19
-
20
- this = self
21
-
22
- watch :pin => 4, :pull => :up, :trigger => :falling do
23
- detection = sensor.detection_status
24
- status = sensor.key_status
25
-
26
- this.call_block status
27
- end
28
- end
29
-
30
- def on_key_change &block
31
- @on_key_change_block = block
32
- end
33
-
34
- def on_key_up &block
35
- @on_key_up_block = block
36
- end
37
-
38
- def on_key_down &block
39
- @on_key_down_block = block
40
- end
41
-
42
- def call_block status
43
- status.length.times do |i|
44
- if status[i] != @previous_status[i]
45
- key = KEY_MAP[i]
46
- @on_key_up_block.call key if status[i] == "released" unless @on_key_up_block.nil?
47
- @on_key_down_block.call key if status[i] == "pressed" unless @on_key_down_block.nil?
48
- @on_key_change_block.call key, status[i] unless @on_key_change_block.nil?
49
- end
50
- end
51
- @previous_status = status
52
- end
53
-
54
- end
55
- end
1
+ require 'pi_piper'
2
+ require 'qt1070'
3
+
4
+
5
+ module Touchberrypi
6
+ class Keyboard
7
+
8
+ include PiPiper
9
+ include Qt1070
10
+
11
+ KEY_MAP = ["LEFT","RIGHT","UP","DOWN","B","A","X"]
12
+
13
+ def initialize i2c
14
+ sensor = Qt1070.new i2c
15
+
16
+ # read sensor status to reset 'change' pin
17
+ sensor.detection_status
18
+ @previous_status = sensor.key_status
19
+
20
+ this = self
21
+
22
+ watch :pin => 4, :pull => :up, :trigger => :falling do
23
+ detection = sensor.detection_status
24
+ status = sensor.key_status
25
+
26
+ this.call_block status
27
+ end
28
+ end
29
+
30
+ def on_key_change &block
31
+ @on_key_change_block = block
32
+ end
33
+
34
+ def on_key_up &block
35
+ @on_key_up_block = block
36
+ end
37
+
38
+ def on_key_down &block
39
+ @on_key_down_block = block
40
+ end
41
+
42
+ def call_block status
43
+ status.length.times do |i|
44
+ if status[i] != @previous_status[i]
45
+ key = KEY_MAP[i]
46
+ @on_key_up_block.call key if status[i] == "released" unless @on_key_up_block.nil?
47
+ @on_key_down_block.call key if status[i] == "pressed" unless @on_key_down_block.nil?
48
+ @on_key_change_block.call key, status[i] unless @on_key_change_block.nil?
49
+ end
50
+ end
51
+ @previous_status = status
52
+ end
53
+
54
+ end
55
+ end
@@ -1,9 +1,35 @@
1
-
2
- module Touchberrypi
3
-
4
- class Leds
5
-
6
-
7
- end
8
-
9
- end
1
+ require 'tlc59116'
2
+ require 'color'
3
+
4
+ module Touchberrypi
5
+
6
+ include Tlc59116
7
+ #include Color
8
+
9
+ class Leds
10
+ def initialize i2c
11
+ @driver = Tlc59116::Tlc59116.new i2c
12
+ @driver.enable
13
+
14
+ #enable individual control and group dimming
15
+ @driver.pwm_control 0xFF, 0xFF, 0xFF, 0xFF
16
+
17
+ @driver.group_brightness 0x10
18
+
19
+ clear_all
20
+ end
21
+
22
+ def set_led ledindex, color
23
+ @driver.pwm color.green.to_i, color.red.to_i, color.blue.to_i, offset: ledindex * 3
24
+ end
25
+
26
+ def clear_all
27
+ 5.times do |i|
28
+ set_led i, Color::RGB::Black
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
@@ -1,3 +1,3 @@
1
- module Touchberrypi
2
- VERSION = "0.1.1"
3
- end
1
+ module Touchberrypi
2
+ VERSION = "0.1.2"
3
+ end
@@ -1,29 +1,30 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'touchberrypi/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "touchberrypi"
8
- spec.version = Touchberrypi::VERSION
9
- spec.authors = ["Sille Van Landschoot"]
10
- spec.email = ["info@sillevl.be"]
11
-
12
- spec.summary = %q{Ruby library for using the Touchberry Pi shield}
13
- spec.description = %q{Ruby library for using and controlling the Touchberry Pi shield}
14
- spec.homepage = "https://github.com/99-bugs/touchberrypi"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
-
22
- spec.add_development_dependency "bundler", "~> 1.12"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "minitest", "~> 5.0"
25
-
26
- spec.add_dependency "pi_piper"
27
- spec.add_dependency "qt1070"
28
- spec.add_dependency "tlc59116"
29
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'touchberrypi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "touchberrypi"
8
+ spec.version = Touchberrypi::VERSION
9
+ spec.authors = ["Sille Van Landschoot"]
10
+ spec.email = ["info@sillevl.be"]
11
+
12
+ spec.summary = %q{Ruby library for using the Touchberry Pi shield}
13
+ spec.description = %q{Ruby library for using and controlling the Touchberry Pi shield}
14
+ spec.homepage = "https://github.com/99-bugs/touchberrypi"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "minitest", "~> 5.0"
25
+
26
+ spec.add_dependency "pi_piper"
27
+ spec.add_dependency "qt1070", "0.1.2"
28
+ spec.add_dependency "tlc59116", "0.1.3"
29
+ spec.add_dependency "color"
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: touchberrypi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sille Van Landschoot
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-21 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,18 +70,32 @@ dependencies:
70
70
  name: qt1070
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.1.2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 0.1.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: tlc59116
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.1.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: color
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="