humble_rpi-plugin-knocksensor 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.tar.gz.sig +1 -0
- data/lib/humble_rpi-plugin-knocksensor.rb +48 -0
- metadata +87 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c606d9b6f85625a29557f8c5e26e06fd9cbb14e
|
4
|
+
data.tar.gz: 6c578072e68beaf1b33e585f3409b3b3ecfa8ac1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bf9d322985c92902cb1e02d0e12911aec9624442aa5b9011afcf1f6c6212d25eb7dc0a713b6c1ea63399aab64b5d954014a91398fe75bf09a8e31b11ded6aec
|
7
|
+
data.tar.gz: 38a0684cf3dbb62e3270cbf7c47a310b0bb407e72be75a12f1a1e1077546d5f923d725fc3be39f48c06dcb05b3e0feffe17814bedcd999d9679857833a6ae0b8
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
dsZe}]pt�1�4��ڜ���W���+���Y������t�`��d:r����]ʰ��֡%��#^�ݽM3�@�f!9.F~W$�^*4s��f��lR�f�����%�lsķ"iS{Y�-�H��-H5��'��`8�~=��H����'4=�nꂲ)���xP�de#��~�P�E;�Y� ��s*���Q��}z���=�K���n(cfM��J��.?=�T�蓣�+%3M�Ɇ$ 4UXU�牣X�Uު�$�
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: humble_rpi-plugin-knocksensor.rb
|
4
|
+
|
5
|
+
require 'mcp3008pi'
|
6
|
+
|
7
|
+
|
8
|
+
class HumbleRPiPluginKnockSensor < Mcp3008Pi
|
9
|
+
|
10
|
+
def initialize(settings: {}, variables: {})
|
11
|
+
|
12
|
+
@threshold = variables[:threshold] || 10
|
13
|
+
@notifier = variables[:notifier]
|
14
|
+
@device_id = variables[:device_id] || 'pi'
|
15
|
+
super pin: settings[:pin], clock: 18, dout: 23, din: 24, cs: 25
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def start()
|
20
|
+
|
21
|
+
|
22
|
+
t0 = Time.now + 1
|
23
|
+
|
24
|
+
puts 'ready to detect knocks'
|
25
|
+
|
26
|
+
loop do
|
27
|
+
|
28
|
+
value = self.read()
|
29
|
+
|
30
|
+
next if value <= @threshold
|
31
|
+
|
32
|
+
# ignore any movements that happened less than 100
|
33
|
+
# milliseconds ago since the last movement
|
34
|
+
if t0 + 0.1 < Time.now then
|
35
|
+
|
36
|
+
@notifier.notice "%s/knock: detected" % [@device_id]
|
37
|
+
t0 = Time.now
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
alias on_start start
|
47
|
+
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: humble_rpi-plugin-knocksensor
|
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
|
+
8ixkARkWAmV1MB4XDTE2MDMwNjIyNTcyMFoXDTE3MDMwNjIyNTcyMFowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVy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IR0u7ZbpYXgz6g
|
31
|
+
/Qq3HTzrj7TNgYySNigY/IxDeGqiY1206cu+EODa1G2iKoGlLWqPv5WjcdY7uMy9
|
32
|
+
26D4l7Vp7Du7vg==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2016-03-06 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mcp3008pi
|
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.1
|
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.1
|
56
|
+
description:
|
57
|
+
email: james@r0bertson.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/humble_rpi-plugin-knocksensor.rb
|
63
|
+
homepage: https://github.com/jrobertson/humble_rpi-plugin-knocksensor
|
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: A Humble RPi plug to detect knocks using a knock sensor (piezo element).
|
87
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|