qt1070 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: 33cd55716699c6d5130b03225d9471da3661ed55
4
- data.tar.gz: 52b0cb5f04ee121278a0bd486a35831630674f99
3
+ metadata.gz: 2b41dd353939f2200974d800204a709ccac91448
4
+ data.tar.gz: a4f84ea33abde4ca35ecb860297d7e0d07c565d4
5
5
  SHA512:
6
- metadata.gz: de0a34d49f28274b7631c77fe3577979ec6557596f8cc83b575c6e06179f2083eaf0370133ef25ea6e160eadcde0edc2d393a9dd5d76026bb52ac187688841fd
7
- data.tar.gz: 494629066335cb701d3e86d4aef236a2cb4a6afae6530a1063c6b400d57798208a289b115fe7b5fd9a4a5c1244002eb4327581b134584c38ce07964f67399bd3
6
+ metadata.gz: 071bea69631661d784939bdfb665b2414660441238ed08670a22c25bb9a8b1e5920840149a9de854eb198e1d1cab940068e25178baa054f8e61b0e395ce677a2
7
+ data.tar.gz: 74f0dca980887917e22dbaaf93a2c62ee47bfffd688ef20c41e05d0bc6777a92a6472ec71b78e781ea12329792c4a139bf1616bc7e5fe5f0d01730e508311108
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -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 qt1070.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in qt1070.gemspec
4
+ gemspec
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 TODO: Write your name
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 TODO: Write your name
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
- # Qt1070
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/qt1070`. 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 'qt1070'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install qt1070
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]/qt1070.
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
+ # Qt1070
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/qt1070`. 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 'qt1070'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install qt1070
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]/qt1070.
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 "qt1070"
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 "qt1070"
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,2 +1,2 @@
1
- require "qt1070/version"
2
- require "qt1070/qt1070"
1
+ require "qt1070/version"
2
+ require "qt1070/qt1070"
@@ -1,124 +1,124 @@
1
- require "i2c"
2
-
3
- module Qt1070
4
- class Qt1070
5
-
6
- I2C_ADDRESS = 0x1B
7
-
8
- def initialize port
9
- @i2c = I2C.create port
10
- end
11
-
12
- def chip_id
13
- id = read_byte 0x00
14
- minor = id & 0x0F
15
- major = (id >> 4) & 0x0F
16
- {major: major, minor: minor}
17
- end
18
-
19
- def firmware_version
20
- version = read_byte 0x01
21
- minor = version & 0x0F
22
- major = (version >> 4) & 0x0F
23
- "#{major}.#{minor}"
24
- end
25
-
26
- def detection_status
27
- status = read_byte 0x02
28
- return "Calibrate" if status & (1 << 7) != 0
29
- return "Touch" if status & (1 << 0) != 0
30
- return "Overflow" if status & (1 << 6) != 0
31
- "Undefined"
32
- end
33
-
34
- def key_status key = nil
35
- unless key.nil?
36
- raise "Key index must be between 0 and 6" unless key.between? 0, 6
37
- end
38
- status_value = read_byte 0x03
39
- status = []
40
- 8.times do |i|
41
- status[i] = status_value & (1 << i) != 0 ? "pressed" : "released"
42
- end
43
- key.nil? ? status : status[i]
44
- end
45
-
46
- def key_signal key
47
- raise "Key index must be between 0 and 6" unless key.between? 0, 6
48
- register = 0x04 + (key * 2)
49
- read_short register
50
- end
51
-
52
- def reference_data key
53
- raise "Key index must b between 0 and 6" unless key.between? 0, 6
54
- register = 18 + (key * 2)
55
- read_short register
56
- end
57
-
58
- #TODO write to this register
59
- def negative_threshold_level key
60
- raise "Key index must be between 0 and 6" unless key.between? 0, 6
61
- read_byte 32 + key
62
- end
63
-
64
- #TODO write to this register
65
- def adjacent_key_suppression_level key
66
- #TODO parse/check result
67
- raise "Key index must be between 0 and 6" unless key.between? 0, 6
68
- read_byte 39 + key
69
- end
70
-
71
- #TODO write to this register
72
- def detection_integrator_counter key
73
- #TODO parse/check result
74
- raise "Key index must be between 0 and 6" unless key.between? 0, 6
75
- read_byte 46 + key
76
- end
77
-
78
- #TODO write to this register
79
- def fo_mo_guard_no
80
- #TODO parse/check result
81
- read_byte 53
82
- end
83
-
84
- #TODO write to this register
85
- def low_power_mode
86
- #TODO parse/check result
87
- read_byte 54
88
- end
89
-
90
- #TODO write to this register
91
- def maximum_on_duration
92
- #TODO parse/check result
93
- read_byte 55
94
- end
95
-
96
- #TODO write to this register
97
- def calibrate
98
- #TODO parse/check result
99
- read_byte 56
100
- end
101
-
102
- #TODO write to this register
103
- def reset
104
- #TODO parse/check result
105
- read_byte 57
106
- end
107
-
108
- private
109
- def read register, read_bytes = 1
110
- @i2c.read I2C_ADDRESS, read_bytes , register
111
- end
112
-
113
- def read_byte register
114
- data = read register
115
- data.unpack("C").first
116
- end
117
-
118
- def read_short register
119
- data = read register, 2
120
- data.unpack("S_").first
121
- end
122
- end
123
-
124
- end
1
+ require "i2c"
2
+
3
+ module Qt1070
4
+ class Qt1070
5
+
6
+ I2C_ADDRESS = 0x1B
7
+
8
+ def initialize i2c
9
+ @i2c = i2c
10
+ end
11
+
12
+ def chip_id
13
+ id = read_byte 0x00
14
+ minor = id & 0x0F
15
+ major = (id >> 4) & 0x0F
16
+ {major: major, minor: minor}
17
+ end
18
+
19
+ def firmware_version
20
+ version = read_byte 0x01
21
+ minor = version & 0x0F
22
+ major = (version >> 4) & 0x0F
23
+ "#{major}.#{minor}"
24
+ end
25
+
26
+ def detection_status
27
+ status = read_byte 0x02
28
+ return "Calibrate" if status & (1 << 7) != 0
29
+ return "Touch" if status & (1 << 0) != 0
30
+ return "Overflow" if status & (1 << 6) != 0
31
+ "Undefined"
32
+ end
33
+
34
+ def key_status key = nil
35
+ unless key.nil?
36
+ raise "Key index must be between 0 and 6" unless key.between? 0, 6
37
+ end
38
+ status_value = read_byte 0x03
39
+ status = []
40
+ 8.times do |i|
41
+ status[i] = status_value & (1 << i) != 0 ? "pressed" : "released"
42
+ end
43
+ key.nil? ? status : status[i]
44
+ end
45
+
46
+ def key_signal key
47
+ raise "Key index must be between 0 and 6" unless key.between? 0, 6
48
+ register = 0x04 + (key * 2)
49
+ read_short register
50
+ end
51
+
52
+ def reference_data key
53
+ raise "Key index must b between 0 and 6" unless key.between? 0, 6
54
+ register = 18 + (key * 2)
55
+ read_short register
56
+ end
57
+
58
+ #TODO write to this register
59
+ def negative_threshold_level key
60
+ raise "Key index must be between 0 and 6" unless key.between? 0, 6
61
+ read_byte 32 + key
62
+ end
63
+
64
+ #TODO write to this register
65
+ def adjacent_key_suppression_level key
66
+ #TODO parse/check result
67
+ raise "Key index must be between 0 and 6" unless key.between? 0, 6
68
+ read_byte 39 + key
69
+ end
70
+
71
+ #TODO write to this register
72
+ def detection_integrator_counter key
73
+ #TODO parse/check result
74
+ raise "Key index must be between 0 and 6" unless key.between? 0, 6
75
+ read_byte 46 + key
76
+ end
77
+
78
+ #TODO write to this register
79
+ def fo_mo_guard_no
80
+ #TODO parse/check result
81
+ read_byte 53
82
+ end
83
+
84
+ #TODO write to this register
85
+ def low_power_mode
86
+ #TODO parse/check result
87
+ read_byte 54
88
+ end
89
+
90
+ #TODO write to this register
91
+ def maximum_on_duration
92
+ #TODO parse/check result
93
+ read_byte 55
94
+ end
95
+
96
+ #TODO write to this register
97
+ def calibrate
98
+ #TODO parse/check result
99
+ read_byte 56
100
+ end
101
+
102
+ #TODO write to this register
103
+ def reset
104
+ #TODO parse/check result
105
+ read_byte 57
106
+ end
107
+
108
+ private
109
+ def read register, read_bytes = 1
110
+ @i2c.read I2C_ADDRESS, read_bytes , register
111
+ end
112
+
113
+ def read_byte register
114
+ data = read register
115
+ data.unpack("C").first
116
+ end
117
+
118
+ def read_short register
119
+ data = read register, 2
120
+ data.unpack("S_").first
121
+ end
122
+ end
123
+
124
+ end
@@ -1,3 +1,3 @@
1
- module Qt1070
2
- VERSION = "0.1.1"
3
- end
1
+ module Qt1070
2
+ VERSION = "0.1.2"
3
+ end
@@ -1,27 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'qt1070/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "qt1070"
8
- spec.version = Qt1070::VERSION
9
- spec.authors = ["Sille Van Landschoot"]
10
- spec.email = ["info@sillevl.be"]
11
-
12
- spec.summary = %q{QT1070 capacitive touch sensor library for Ruby}
13
- spec.description = %q{QT1070 capacitive touch sensor library for Ruby}
14
- spec.homepage = "https://github.com/sillevl/ruby-qt1070"
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 "i2c", "~> 0.4"
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qt1070/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "qt1070"
8
+ spec.version = Qt1070::VERSION
9
+ spec.authors = ["Sille Van Landschoot"]
10
+ spec.email = ["info@sillevl.be"]
11
+
12
+ spec.summary = %q{QT1070 capacitive touch sensor library for Ruby}
13
+ spec.description = %q{QT1070 capacitive touch sensor library for Ruby}
14
+ spec.homepage = "https://github.com/sillevl/ruby-qt1070"
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 "i2c", "~> 0.4"
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qt1070
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-20 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler