morsecode_keypad 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.tar.gz.sig +0 -0
- data/lib/morsecode_keypad.rb +68 -2
- metadata +2 -2
- 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: 2f18952926f3c47889848d53ce774a9771e6866f
|
4
|
+
data.tar.gz: f40b152ec12272f29206709a5f293f60a454e939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f499aea23f123893f8733a6ee1744b7edb12d01aad9128b8833bae7bd313839d173ced4334ccc2739d840af0a2c7439c910cade0ceca917a4793508f740ec5c0
|
7
|
+
data.tar.gz: '08e48801eb038f10ef77c20035fa853a882d4dabde867b996cb0af7fba5e17269d79b15a613b88be0afec582fa980f723c46ba03e1ec36efe14dbeca98e47d57'
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/morsecode_keypad.rb
CHANGED
@@ -13,6 +13,8 @@ class MorsecodeKeypad
|
|
13
13
|
|
14
14
|
def initialize(dash: 4, dot: 17, separator: 27, sendx: 22, notifier: nil)
|
15
15
|
|
16
|
+
@pins = {dash: dash, dot: dot, separator: separator, sendx: sendx}
|
17
|
+
|
16
18
|
@notifier = notifier
|
17
19
|
@dash_pin, @dot_pin, @separator_pin, @send_pin = \
|
18
20
|
[dash, dot, separator, sendx].map {|pin| RPiPinIn.new(pin, pull: :up)}
|
@@ -56,8 +58,72 @@ class MorsecodeKeypad
|
|
56
58
|
|
57
59
|
end
|
58
60
|
|
59
|
-
|
60
61
|
end
|
62
|
+
|
63
|
+
# test() returns the user-defined button to GPIO pin mappings given the
|
64
|
+
# user selects the buttons in sequence (dash, dot, separator, sendx)
|
65
|
+
# e.g. => {:dash=>4, :dot=>22, :separator=>27, :sendx=>17}
|
66
|
+
|
67
|
+
|
68
|
+
def test()
|
69
|
+
|
70
|
+
pins = %i(dash dot separator sendx)
|
71
|
+
buttons = {}
|
72
|
+
i = 0
|
73
|
+
|
74
|
+
Thread.new do
|
75
|
+
@dash_pin.watch_high do |v|
|
76
|
+
|
77
|
+
buttons[pins[i]] = @pins[:dash]
|
78
|
+
puts pins[i].to_s + ": GPIO " + buttons[pins[i]].to_s
|
79
|
+
i += 1
|
80
|
+
|
81
|
+
puts buttons.inspect if i > 3
|
82
|
+
Thread.stop
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
Thread.new do
|
88
|
+
@dot_pin.watch_high do |v|
|
89
|
+
|
90
|
+
buttons[pins[i]] = @pins[:dot]
|
91
|
+
puts pins[i].to_s + ": GPIO " + buttons[pins[i]].to_s
|
92
|
+
i += 1
|
93
|
+
|
94
|
+
puts buttons.inspect if i > 3
|
95
|
+
Thread.stop
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
Thread.new do
|
101
|
+
@separator_pin.watch_high do |v|
|
102
|
+
|
103
|
+
buttons[pins[i]] = @pins[:separator]
|
104
|
+
puts pins[i].to_s + ": GPIO " + buttons[pins[i]].to_s
|
105
|
+
i += 1
|
106
|
+
|
107
|
+
puts buttons.inspect if i > 3
|
108
|
+
Thread.stop
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Thread.new do
|
114
|
+
@send_pin.watch_high do |v|
|
115
|
+
|
116
|
+
buttons[pins[i]] = @pins[:sendx]
|
117
|
+
puts pins[i].to_s + ": GPIO " + buttons[pins[i]].to_s
|
118
|
+
i += 1
|
119
|
+
|
120
|
+
puts buttons.inspect if i > 3
|
121
|
+
Thread.stop
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
61
127
|
|
62
128
|
private
|
63
129
|
|
@@ -71,6 +137,7 @@ class MorsecodeKeypad
|
|
71
137
|
|
72
138
|
def on_separator()
|
73
139
|
@mc << SEPARATOR
|
140
|
+
@mc.sub!(/[^4]+444$/,'') if @mc =~ /444$/ # undo command?
|
74
141
|
end
|
75
142
|
|
76
143
|
def on_send()
|
@@ -86,4 +153,3 @@ class MorsecodeKeypad
|
|
86
153
|
end
|
87
154
|
|
88
155
|
end
|
89
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morsecode_keypad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
Qrh60hwQOtZY3gRl2ibYZzXCsSKrI+DSeP3wBNTsDXNo7LT0GwqFf9ibuLK2tI/a
|
32
32
|
CmyBJlnccx5pmw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-10-
|
34
|
+
date: 2016-10-18 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rpi_pinin
|
metadata.gz.sig
CHANGED
Binary file
|