rpi_pinin_msgout 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15e256d28802699a4baf8496fb7c9b68059a1fec
4
- data.tar.gz: 43f0e93825465c0b8384d5dbd0e09df99a2c359c
3
+ metadata.gz: 5c4a876ecbc7789eff94a8ade300b8ef2d7320db
4
+ data.tar.gz: 31f807e5fd7ad237862c8ff562775785debe9c53
5
5
  SHA512:
6
- metadata.gz: f262efc6ee6aae8e98fabd54d720512e4407d2ece1f80207162d4cbec008008c33d9eca9939ee7b09b85e2ef66a9b9d906674b074efd422305a26a0d42f2ee06
7
- data.tar.gz: d644b5f61bb8c872ad11b9ab335b114a9189cff3af701c243e21159a37fe5f00082abb667943a69cdaad59a4c19af84ae1158fe8b61a4aa7f4a9649926a0b10f
6
+ metadata.gz: 7bcfd00cf738c35741a7cf6d0afbf372293f85e5cdd7ed570214ef23ad5c4e3b8921ab114301886ef8c0f4340f7bd67b6a2b9f8295df90c4ff56a4d545a26054
7
+ data.tar.gz: 21b29a49c3096dce0e35cf75dc7f5c39fc4d3bcda09f31ccff714aec5f1840da47fa73f24f3de216f27ef9a84e1a2612b5dd8c19d700a5ad499ae6d2dfa3b090
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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 RPiPinInMsgOut < RPiPinIn
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
- case @mode
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
- when :default
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.1.2
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