humble_rpi-plugin-button 0.2.0 → 0.3.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/humble_rpi-plugin-button.rb +27 -45
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bfe9d964429a76c0064b749de7f9399d98548c2
|
4
|
+
data.tar.gz: 10b7836831dee0dfa4d6e0120ca40deedb2dbfa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b16758a535f22cb2205f42b8902ab2d663aade73afd9f039be1333cc1f33c6d40561957abcec4ddbe0be1b83a99a2b67302bd99943a9465232c58059141b4d6
|
7
|
+
data.tar.gz: b528ac8dc1019dd365b7eda0bad1d78cc61e3ff92eb4138380d320c65f2d4ad4d3914904b8fd850ee174321cde82ea15d27e234be4fc4f54c6cf3452b91c40d2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -3,66 +3,48 @@
|
|
3
3
|
# file: humble_rpi-plugin-button.rb
|
4
4
|
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'rpi_pinin_msgout'
|
7
7
|
|
8
8
|
|
9
9
|
class HumbleRPiPluginButton
|
10
10
|
|
11
11
|
|
12
|
-
def initialize(settings: {
|
13
|
-
|
14
|
-
@ignore_keyup = settings[:ignore_keyup] || true
|
15
|
-
@pins = settings[:pins].map {|x| RPiPinIn.new x, pull: :up}
|
16
|
-
@notifier = variables[:notifier]
|
17
|
-
@device_id = variables[:device_id] || 'pi'
|
12
|
+
def initialize(settings: {}, variables: {}, verbose: false)
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
def start()
|
14
|
+
pins = settings[:pins]
|
15
|
+
settings.delete :pins
|
22
16
|
|
23
|
-
|
24
|
-
|
17
|
+
h1 = {
|
18
|
+
capture_rate: 0.25, # seconds
|
19
|
+
mode: :default
|
20
|
+
}.merge settings
|
21
|
+
|
22
|
+
h2 = {device_id: 'pi'}.merge variables
|
25
23
|
|
26
|
-
|
24
|
+
h3 = {
|
25
|
+
pull: :up,
|
26
|
+
subtopic: 'button',
|
27
|
+
descriptor: 'pressed',
|
28
|
+
verbose: verbose
|
29
|
+
}
|
27
30
|
|
28
|
-
|
31
|
+
h = h1.merge(h2).merge(h3)
|
29
32
|
|
30
|
-
@pins.
|
33
|
+
@pins = pins.map.with_index do |x,i|
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
n = (i+1).to_s
|
35
|
-
|
36
|
-
Thread.new do
|
37
|
-
|
38
|
-
button.watch do |value|
|
39
|
-
|
40
|
-
# ignore any movements that happened 250
|
41
|
-
# milliseconds ago since the last movement
|
42
|
-
if t0 + 0.25 < Time.now then
|
43
|
-
|
44
|
-
state = case value
|
45
|
-
when 1
|
46
|
-
@ignore_keyup ? :press : :down
|
47
|
-
when 0
|
48
|
-
:up unless @ignore_keyup
|
49
|
-
end
|
50
|
-
|
51
|
-
if state
|
52
|
-
notifier.notice "%s/button/%s: key%s" % [device_id, i, state]
|
53
|
-
end
|
54
|
-
|
55
|
-
t0 = Time.now
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
35
|
+
RPiPinInMsgOut.new x, h.merge(index: i+1)
|
61
36
|
|
62
37
|
end
|
63
|
-
|
64
38
|
|
65
39
|
end
|
40
|
+
|
41
|
+
def start()
|
42
|
+
|
43
|
+
puts 'ready to detect buttons'
|
44
|
+
|
45
|
+
@pins.each {|pin| Thread.new { pin.capture} }
|
46
|
+
|
47
|
+
end
|
66
48
|
|
67
49
|
alias on_start start
|
68
50
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humble_rpi-plugin-button
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,10 +31,10 @@ cert_chain:
|
|
31
31
|
BpuaDRLyhUfMJfBG+PlWbU2XPeE6pbRnGWCbBwZtUcCzSfwfEehXiw0aZOMCG6Gu
|
32
32
|
OTO58NMjMKNbdQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-04-
|
34
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: rpi_pinin_msgout
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '0.1'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.1.
|
45
|
+
version: 0.1.1
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
version: '0.1'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.1.
|
55
|
+
version: 0.1.1
|
56
56
|
description:
|
57
57
|
email: james@r0bertson.co.uk
|
58
58
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|