rpi_pinin_msgout 0.1.2 → 0.2.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/rpi_pinin_msgout.rb +37 -38
- metadata +21 -1
- 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: 5c4a876ecbc7789eff94a8ade300b8ef2d7320db
|
4
|
+
data.tar.gz: 31f807e5fd7ad237862c8ff562775785debe9c53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bcfd00cf738c35741a7cf6d0afbf372293f85e5cdd7ed570214ef23ad5c4e3b8921ab114301886ef8c0f4340f7bd67b6a2b9f8295df90c4ff56a4d545a26054
|
7
|
+
data.tar.gz: 21b29a49c3096dce0e35cf75dc7f5c39fc4d3bcda09f31ccff714aec5f1840da47fa73f24f3de216f27ef9a84e1a2612b5dd8c19d700a5ad499ae6d2dfa3b090
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rpi_pinin_msgout.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# file: rpi_pinin_msgout.rb
|
4
4
|
|
5
5
|
require 'rpi_pinin'
|
6
|
+
require 'secret_knock'
|
6
7
|
require 'chronic_duration'
|
7
8
|
|
8
9
|
|
@@ -13,9 +14,26 @@ class Echo
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
class
|
17
|
+
class SecretKnockNotifier
|
18
|
+
|
19
|
+
def initialize(notifier, topic: 'secretknock')
|
20
|
+
|
21
|
+
@notifier, @topic = notifier, topic
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def knock()
|
26
|
+
end
|
27
|
+
|
28
|
+
def message(s)
|
29
|
+
@notifier.notice "%s: %s" % [topice, s]
|
30
|
+
end
|
31
|
+
end
|
17
32
|
|
33
|
+
class RPiPinInMsgOut < RPiPinIn
|
18
34
|
|
35
|
+
# duration: Used by sample mode
|
36
|
+
|
19
37
|
def initialize(id, pull: nil, mode: :default, verbose: true,
|
20
38
|
subtopic: 'sensor', device_id: 'pi', notifier: Echo.new,
|
21
39
|
duration: '5 seconds', index: 0, capture_rate: 0.5,
|
@@ -29,20 +47,9 @@ class RPiPinInMsgOut < RPiPinIn
|
|
29
47
|
|
30
48
|
end
|
31
49
|
|
32
|
-
def capture()
|
33
|
-
|
34
|
-
case @mode
|
35
|
-
|
36
|
-
when :default
|
37
|
-
setup { default_mode() }
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
50
|
def capture_high()
|
43
|
-
|
44
|
-
|
45
|
-
when :interval
|
51
|
+
|
52
|
+
if @mode == :interval or @mode == :sample then
|
46
53
|
|
47
54
|
count = 0
|
48
55
|
|
@@ -54,36 +61,28 @@ class RPiPinInMsgOut < RPiPinIn
|
|
54
61
|
count, t1 = interval_mode(t1, count, duration)
|
55
62
|
end
|
56
63
|
|
57
|
-
|
64
|
+
elsif @mode == :default
|
65
|
+
|
58
66
|
setup { default_mode() }
|
67
|
+
|
68
|
+
elsif @mode == :secretknock
|
69
|
+
|
70
|
+
notifier = SecretKnockNotifier.new(@notifier, topic: @topic)
|
71
|
+
|
72
|
+
sk = SecretKnock.new \
|
73
|
+
short_delay: 0.55, long_delay: 1.1, external: notifier
|
74
|
+
sk.detect
|
75
|
+
setup { sk.knock }
|
76
|
+
|
77
|
+
|
59
78
|
end
|
60
79
|
|
61
80
|
end
|
62
81
|
|
82
|
+
alias capture capture_high
|
83
|
+
|
63
84
|
private
|
64
85
|
|
65
|
-
def button_setup()
|
66
|
-
|
67
|
-
t0 = Time.now + 1
|
68
|
-
|
69
|
-
self.watch do |v|
|
70
|
-
|
71
|
-
# ignore any movements that happened a short time ago e.g. 250
|
72
|
-
# milliseconds ago since the last movement
|
73
|
-
if t0 + @capture_rate < Time.now then
|
74
|
-
|
75
|
-
puts Time.now.to_s if @verbose
|
76
|
-
|
77
|
-
yield(v)
|
78
|
-
|
79
|
-
t0 = Time.now
|
80
|
-
|
81
|
-
else
|
82
|
-
#puts 'ignoring ...'
|
83
|
-
end
|
84
|
-
|
85
|
-
end # /watch
|
86
|
-
end
|
87
86
|
|
88
87
|
def setup()
|
89
88
|
|
@@ -137,5 +136,5 @@ class RPiPinInMsgOut < RPiPinIn
|
|
137
136
|
def default_mode()
|
138
137
|
@notifier.notice "%s: %s" % [@topic, @descriptor]
|
139
138
|
end
|
140
|
-
|
139
|
+
|
141
140
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpi_pinin_msgout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -53,6 +53,26 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.1.2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: secret_knock
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.2'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.2.1
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.2'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.2.1
|
56
76
|
- !ruby/object:Gem::Dependency
|
57
77
|
name: chronic_duration
|
58
78
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|