Class: MorsecodeKeypad
- Inherits:
-
Object
- Object
- MorsecodeKeypad
- Defined in:
- lib/morsecode_keypad.rb
Constant Summary collapse
- DASH =
'1'- DOT =
'2'- SEPARATOR =
'4'
Instance Method Summary collapse
-
#initialize(dash: 4, dot: 17, separator: 27, sendx: 22, notifier: nil) ⇒ MorsecodeKeypad
constructor
A new instance of MorsecodeKeypad.
- #start ⇒ Object
Constructor Details
#initialize(dash: 4, dot: 17, separator: 27, sendx: 22, notifier: nil) ⇒ MorsecodeKeypad
14 15 16 17 18 19 20 21 |
# File 'lib/morsecode_keypad.rb', line 14 def initialize(dash: 4, dot: 17, separator: 27, sendx: 22, notifier: nil) @notifier = notifier @dash_pin, @dot_pin, @separator_pin, @send_pin = \ [dash, dot, separator, sendx].map {|pin| RPiPinIn.new(pin, pull: :up)} @mc = '' end |
Instance Method Details
#start ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/morsecode_keypad.rb', line 23 def start() Thread.new do @dash_pin.watch_high do |v| puts "dash: " + Time.now.to_s if @notifier.nil? on_dash() end end Thread.new do @dot_pin.watch_high do |v| puts "dot: " + Time.now.to_s if @notifier.nil? on_dot() end end Thread.new do @separator_pin.watch_high do |v| puts "separator: " + Time.now.to_s if @notifier.nil? on_separator() end end @send_pin.watch_high do |v| puts "send: " + Time.now.to_s if @notifier.nil? on_send() end end |