rpi_pinin_msgout 0.1.0 → 0.1.1
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/lib/rpi_pinin_msgout.rb +41 -7
- data.tar.gz.sig +1 -1
- metadata +1 -1
- metadata.gz.sig +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0d353cf5ebadeaf89618ce7a0bbc4ed07cf53d0
|
4
|
+
data.tar.gz: 0847602dac884ec4c2d8cb8783e8bd766f7b670e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1788b4f60a5a1ce11f59e0800fbe5b41f2d57d071dc129c60326a0f8973896fb3ac9bdb125f91479234a5e4da1efbc9ac21742cd193e72886c60af780a2f4b7c
|
7
|
+
data.tar.gz: 118ff1aa58148eb97a20b39e9d6dae80dbf212b485c16f0629340d96212d9de6c8f195737884d3b05ea41556060277c069ad19b3babc006d453505c857d823ae
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rpi_pinin_msgout.rb
CHANGED
@@ -18,15 +18,26 @@ class RPiPinInMsgOut < RPiPinIn
|
|
18
18
|
|
19
19
|
def initialize(id, pull: nil, mode: :default, verbose: true,
|
20
20
|
subtopic: 'sensor', device_id: 'pi', notifier: Echo.new,
|
21
|
-
duration: '5 seconds', index: 0, capture_rate: 0.5
|
21
|
+
duration: '5 seconds', index: 0, capture_rate: 0.5,
|
22
|
+
descriptor: 'detected')
|
22
23
|
|
23
24
|
super(id, pull: pull)
|
24
25
|
|
25
26
|
@mode, @verbose, @notifier, @duration = mode, verbose, notifier, duration
|
26
|
-
@capture_rate = capture_rate
|
27
|
+
@capture_rate, @descriptor = capture_rate, descriptor
|
27
28
|
@topic = [device_id, subtopic, index].join('/')
|
28
29
|
|
29
30
|
end
|
31
|
+
|
32
|
+
def capture()
|
33
|
+
|
34
|
+
case @mode
|
35
|
+
|
36
|
+
when :default
|
37
|
+
setup { default_mode() }
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
30
41
|
|
31
42
|
def capture_high()
|
32
43
|
|
@@ -51,12 +62,35 @@ class RPiPinInMsgOut < RPiPinIn
|
|
51
62
|
|
52
63
|
private
|
53
64
|
|
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
|
+
|
54
88
|
def setup()
|
55
89
|
|
56
90
|
t0 = Time.now + 1
|
57
91
|
|
58
92
|
self.watch_high do
|
59
|
-
|
93
|
+
|
60
94
|
# ignore any movements that happened a short time ago e.g. 250
|
61
95
|
# milliseconds ago since the last movement
|
62
96
|
if t0 + @capture_rate < Time.now then
|
@@ -86,9 +120,9 @@ class RPiPinInMsgOut < RPiPinIn
|
|
86
120
|
# identify if the movement is consecutive
|
87
121
|
msg = if elapsed < duration then
|
88
122
|
s = ChronicDuration.output(duration, :format => :long)
|
89
|
-
"%s:
|
123
|
+
"%s: %s %s times within the past %s" % [@topic, count, @descriptor, s ]
|
90
124
|
else
|
91
|
-
"%s:
|
125
|
+
"%s: %s" % [@topic, @descriptor]
|
92
126
|
end
|
93
127
|
|
94
128
|
@notifier.notice msg
|
@@ -101,7 +135,7 @@ class RPiPinInMsgOut < RPiPinIn
|
|
101
135
|
end
|
102
136
|
|
103
137
|
def default_mode()
|
104
|
-
@notifier.notice "%s:
|
138
|
+
@notifier.notice "%s: %s" % [@topic, @descriptor]
|
105
139
|
end
|
106
140
|
|
107
|
-
end
|
141
|
+
end
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
_���ʼ�+n2�j'������3-��sAT��ϥ�6O+�_���@�A�PGg1���W&��T��y��X�HUM�F�����S��*m�+��w?���O�e�<���(^�3)�%�u����A�&���j>Z�VwAfgH!w;UUI�M��M\����x���k���bU2����Y����C�u͓�sS����Ry�W������1<��ĝ��DX�"�3�$I6��T(ؖ�����WX��ݨ
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
^��h��//qS�<����l�?g��."�0{p]#�Q�a���hz*���=��O��62�K"�Ǽ>O0��0��zs�e�}w����[�-C�v;�V���h��QD�"j+LU�nj�wѪ��Q�N�\��be���X�BD�����_e�!D��gE���Eg�������1�Q0-�p9���M/����+Dt�
|
2
|
+
4e�{$��2��r)K���c(
|