rpi_pinin_msgout 0.1.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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/rpi_pinin_msgout.rb +107 -0
- data.tar.gz.sig +1 -0
- metadata +88 -0
- metadata.gz.sig +1 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8b4fdc2b754129d212acd18f67a26fb72d3c78bf
|
4
|
+
data.tar.gz: 0d0f15d97a7dfc2157ee544bf9198e548488809e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b0ad3e22ff963dca7a745ce285cdae820fcb0503971945c79267d4fa3da9b4665769b17c512d462f93bea6973f735995545a660271b87bbb84a63da05aec520
|
7
|
+
data.tar.gz: f33c4c3851da1ead1d636bc6085755c0f7339cffa6624a133de801b8a5eb4569021b365830eb03e0999605fac0483b8747cd29fe18d59629783e35d00b82a652
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: rpi_pinin_msgout.rb
|
4
|
+
|
5
|
+
require 'rpi_pinin'
|
6
|
+
require 'chronic_duration'
|
7
|
+
|
8
|
+
|
9
|
+
class Echo
|
10
|
+
|
11
|
+
def notice(s)
|
12
|
+
puts "%s: %s" % [Time.now, s]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class RPiPinInMsgOut < RPiPinIn
|
17
|
+
|
18
|
+
|
19
|
+
def initialize(id, pull: nil, mode: :default, verbose: true,
|
20
|
+
subtopic: 'sensor', device_id: 'pi', notifier: Echo.new,
|
21
|
+
duration: '5 seconds', index: 0, capture_rate: 0.5)
|
22
|
+
|
23
|
+
super(id, pull: pull)
|
24
|
+
|
25
|
+
@mode, @verbose, @notifier, @duration = mode, verbose, notifier, duration
|
26
|
+
@capture_rate = capture_rate
|
27
|
+
@topic = [device_id, subtopic, index].join('/')
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def capture_high()
|
32
|
+
|
33
|
+
case @mode
|
34
|
+
when :interval
|
35
|
+
|
36
|
+
count = 0
|
37
|
+
|
38
|
+
duration = ChronicDuration.parse(@duration)
|
39
|
+
|
40
|
+
t1 = Time.now - duration + 1
|
41
|
+
|
42
|
+
setup do
|
43
|
+
count, t1 = interval_mode(t1, count, duration)
|
44
|
+
end
|
45
|
+
|
46
|
+
when :default
|
47
|
+
setup { default_mode() }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def setup()
|
55
|
+
|
56
|
+
t0 = Time.now + 1
|
57
|
+
|
58
|
+
self.watch_high do
|
59
|
+
|
60
|
+
# ignore any movements that happened a short time ago e.g. 250
|
61
|
+
# milliseconds ago since the last movement
|
62
|
+
if t0 + @capture_rate < Time.now then
|
63
|
+
|
64
|
+
puts Time.now.to_s if @verbose
|
65
|
+
|
66
|
+
yield()
|
67
|
+
|
68
|
+
t0 = Time.now
|
69
|
+
|
70
|
+
else
|
71
|
+
#puts 'ignoring ...'
|
72
|
+
end
|
73
|
+
|
74
|
+
end # /watch_high
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def interval_mode(t1, count, duration)
|
79
|
+
|
80
|
+
count += 1
|
81
|
+
|
82
|
+
elapsed = Time.now - (t1 + duration)
|
83
|
+
|
84
|
+
if elapsed > 0 then
|
85
|
+
|
86
|
+
# identify if the movement is consecutive
|
87
|
+
msg = if elapsed < duration then
|
88
|
+
s = ChronicDuration.output(duration, :format => :long)
|
89
|
+
"%s: detected %s times within the past %s" % [@topic, count, s ]
|
90
|
+
else
|
91
|
+
"%s: detected" % [@topic, @index]
|
92
|
+
end
|
93
|
+
|
94
|
+
@notifier.notice msg
|
95
|
+
count, t1 = 0, Time.now
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
[count, t1]
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
def default_mode()
|
104
|
+
@notifier.notice "%s: detected" % [@topic, @index]
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�H1�e�&2�8�o��D]��U=*��� fv������F����>��)�k�݈�>[_Chl~uUR�#_�r<S*P<��~2\���{ŧE�A���F�|����i/�v� ����x�qnR���-.�`BƋ쇨lLIoT�i0�ٴzR���Ȝus��5�'��;�_���ܚ���U=��w��@0���džW����.5�GU��g�v�~�5�l��� �[�A-P8�l�rw-LU
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rpi_pinin_msgout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE2MDQxODIwMjIwM1oXDTE3MDQxODIwMjIwM1owSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
+
ggEBAKzo2LbAB4YZY4rzmlMLUORqIGisj1k26aZM09nS1wQ9qTGNLUoDE/fieoNx
|
19
|
+
ZUx95sp+KbpiUxtD1b8VOB/hNEsES6laO5V4DVg9Eb4UCH0QQygQs+iHId5SC16K
|
20
|
+
yjr9dC1GR+XxwL+C+pBt+B3xSDREscXvgqXp+pBM3dwZJe+FPwRUGQMpRqYQd4RN
|
21
|
+
TaDcIt8NXr5Izx3ao6CMrQRaU3Ce8jv5Bcfv41LkQNeR6JI0UAuPGw9G8tyIPZ2q
|
22
|
+
1aingrSPcBylj+yt3S39C0BH79EldTIZpE62L554KIz57c6gyslZ2D0sCs+Qtfpl
|
23
|
+
axSOBQn1oIDTvAicPZ0hCC7k4gMCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUXnWuMYD22van1xgPL0YzuL8pnegwJgYDVR0RBB8w
|
25
|
+
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEALCsoxGmo
|
27
|
+
8/JLpY6qvCV4Qy+HzeTiqe5rDyp+4xuL81ztou58v1IvyqyDbS4GM0k34Hs15vl0
|
28
|
+
AueKDtbWYM1YfzPx0SG5/+pYyV2foyG3EMHfhnT3gewu1IzaS7JDAVJ9sSEIs+UN
|
29
|
+
RZM01eH8ZM+IwKAAIxPCXayS4R8sUIL6c69W20OWz5L7j4O60sZVgLxFM8mYZ3nE
|
30
|
+
C74GHdHcR0qqBlE/Y0K00YKCqsL/sw0E8vB0/10p5MHqR/3j8H82yinNbrRkpAYq
|
31
|
+
55qRY75k9VJA2GfpeY0Nw/6IyHSZ2JFdwtTDZPKQpT69gVGu7XJlquG9lUMQaNc+
|
32
|
+
2CuqDKVQmWkNHg==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rpi_pinin
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.1'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.1.2
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.1'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.1.2
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/rpi_pinin_msgout.rb
|
63
|
+
homepage: https://github.com/jrobertson/rpi_pinin_msgout
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Returns meaningful messages for humans from the capture of a Raspberry PI
|
87
|
+
GPIO input pin.
|
88
|
+
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
`c-�?�+��s�u�d�ڎ|y%
|