rpi_pinin_msgout 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rpi_pinin_msgout.rb +65 -4
- data.tar.gz.sig +0 -0
- metadata +41 -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: 49944f9d1bdf045a0c29cb82042fd0f1d78ac208
|
4
|
+
data.tar.gz: 25c5297b71b127635107095dd416cf387cba174a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4385eb8f5c8adb748e7e1fbfdd51c7f6a5bc2900738337d11fc96a7456b611ed6789ebbac3da0b5f650fcb22b2cf2832dee35be5b343bd257259b3ea0d582b98
|
7
|
+
data.tar.gz: 5083923876f177bb07525aeb7e57e9ed3ee139ad17721f44da31d9a0bafc38e0d3106ae88c19377769c26c9db27ef443d6ecaef2a81b0d61fb26a4b5008b300b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rpi_pinin_msgout.rb
CHANGED
@@ -3,8 +3,10 @@
|
|
3
3
|
# file: rpi_pinin_msgout.rb
|
4
4
|
|
5
5
|
require 'rpi_pinin'
|
6
|
+
require 'morsecode'
|
6
7
|
require 'secret_knock'
|
7
8
|
require 'chronic_duration'
|
9
|
+
require 'morsecode_listener'
|
8
10
|
|
9
11
|
|
10
12
|
class Echo
|
@@ -31,6 +33,24 @@ class SecretKnockNotifier
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
36
|
+
class MorseCodeTranslator < MorseCode
|
37
|
+
|
38
|
+
def initialize(notifier, topic: 'morsecode')
|
39
|
+
|
40
|
+
super()
|
41
|
+
@notifier, @topic = notifier, topic
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def message(s)
|
46
|
+
|
47
|
+
@input_string = s
|
48
|
+
@notifier.notice "%s: %s" % [@topic, self.to_s]
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
34
54
|
class RPiPinInMsgOut < RPiPinIn
|
35
55
|
|
36
56
|
# duration: Used by sample mode
|
@@ -45,6 +65,35 @@ class RPiPinInMsgOut < RPiPinIn
|
|
45
65
|
@mode, @verbose, @notifier, @duration = mode, verbose, notifier, duration
|
46
66
|
@capture_rate, @descriptor = capture_rate, descriptor
|
47
67
|
@topic = [device_id, subtopic, index].join('/')
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
def capture(external: nil)
|
72
|
+
|
73
|
+
if @mode == :default then
|
74
|
+
|
75
|
+
button_setup do |state|
|
76
|
+
default_mode() if state == HIGH
|
77
|
+
end
|
78
|
+
|
79
|
+
elsif @mode == :secretknock
|
80
|
+
|
81
|
+
notifier = SecretKnockNotifier.new(@notifier, topic: @topic)
|
82
|
+
|
83
|
+
sk = SecretKnock.new \
|
84
|
+
short_delay: 0.55, long_delay: 1.1, external: notifier
|
85
|
+
sk.detect
|
86
|
+
|
87
|
+
setup { sk.knock }
|
88
|
+
|
89
|
+
elsif @mode == :morsecode
|
90
|
+
|
91
|
+
mct = MorseCodeTranslator.new @notifier, topic: @topic
|
92
|
+
mcl = MorseCodeListener.new notifier: mct
|
93
|
+
|
94
|
+
button_setup(external: mcl)
|
95
|
+
|
96
|
+
end
|
48
97
|
|
49
98
|
end
|
50
99
|
|
@@ -74,17 +123,29 @@ class RPiPinInMsgOut < RPiPinIn
|
|
74
123
|
short_delay: 0.55, long_delay: 1.1, external: notifier
|
75
124
|
sk.detect
|
76
125
|
|
77
|
-
setup { sk.knock }
|
78
|
-
|
126
|
+
setup { sk.knock }
|
79
127
|
|
80
128
|
end
|
81
129
|
|
82
130
|
end
|
83
131
|
|
84
|
-
alias capture capture_high
|
85
132
|
|
86
133
|
private
|
87
|
-
|
134
|
+
|
135
|
+
def button_setup(external: nil)
|
136
|
+
|
137
|
+
self.watch do |state|
|
138
|
+
|
139
|
+
name = state.to_i == 1 ? :on_keydown : :on_keyup
|
140
|
+
external.method(name).call
|
141
|
+
|
142
|
+
puts Time.now.to_s + ': ' + state.to_s if @verbose
|
143
|
+
|
144
|
+
yield state if block_given?
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
88
149
|
|
89
150
|
def setup()
|
90
151
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -93,6 +93,46 @@ dependencies:
|
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: 0.10.6
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: morsecode
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0.2'
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 0.2.0
|
106
|
+
type: :runtime
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0.2'
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 0.2.0
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: morsecode_listener
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0.1'
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.1.2
|
126
|
+
type: :runtime
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0.1'
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 0.1.2
|
96
136
|
description:
|
97
137
|
email: james@r0bertson.co.uk
|
98
138
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|