morsecode_keypad 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e5af2e7192ae9a9c01c840034904e20af59cd64
4
- data.tar.gz: 0670c1065c5e50cfb344abe7c9fffedafa49ab6c
3
+ metadata.gz: 2f18952926f3c47889848d53ce774a9771e6866f
4
+ data.tar.gz: f40b152ec12272f29206709a5f293f60a454e939
5
5
  SHA512:
6
- metadata.gz: 00aca7862f3000950c6469f1f906aaaa07ae177344136f4d34a8ee3558ff01dd0b1d34f4b9d1847b797cea77bb9e69b25ee2bc23e94314c7905f3fea5ce7f01e
7
- data.tar.gz: cda7de7a18bf8533fbd6b609961967e1f4014eea1acd8f97a13b3db94f277f13b7a5b04ee413b0062477da219d2d93b23a45a182a1b77b9a51f96bebe3c85afd
6
+ metadata.gz: f499aea23f123893f8733a6ee1744b7edb12d01aad9128b8833bae7bd313839d173ced4334ccc2739d840af0a2c7439c910cade0ceca917a4793508f740ec5c0
7
+ data.tar.gz: '08e48801eb038f10ef77c20035fa853a882d4dabde867b996cb0af7fba5e17269d79b15a613b88be0afec582fa980f723c46ba03e1ec36efe14dbeca98e47d57'
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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.0
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-17 00:00:00.000000000 Z
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