Class: EstormButton::Button
- Inherits:
-
Object
- Object
- EstormButton::Button
- Includes:
- PiPiper
- Defined in:
- lib/estorm_button/button.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bootup ⇒ Object
-
#manage_buttons ⇒ Object
ADD MUTEX TO MANAGE TIME.
Class Method Details
.held ⇒ Object
22 23 24 |
# File 'lib/estorm_button/button.rb', line 22 def self.held puts "button HELD: " end |
.led_mgr(cmd) ⇒ Object
17 18 19 20 21 |
# File 'lib/estorm_button/button.rb', line 17 def self.led_mgr(cmd) @@led.on cmd @@led.off end |
.tap ⇒ Object
8 9 10 |
# File 'lib/estorm_button/button.rb', line 8 def self.tap puts "button TAPPED" end |
.test_flag ⇒ Object
11 12 13 |
# File 'lib/estorm_button/button.rb', line 11 def self.test_flag true end |
Instance Method Details
#bootup ⇒ Object
14 15 16 |
# File 'lib/estorm_button/button.rb', line 14 def bootup puts " bootup script" end |
#manage_buttons ⇒ Object
ADD MUTEX TO MANAGE TIME
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/estorm_button/button.rb', line 26 def bootup @@pin=PiPiper::Pin.new(:pin => 23, :pull => :up) @@led=PiPiper::Pin.new(:pin => 18, :direction => :out) @@led.on @@t=Time.now PiPiper.watch :pin => 23,:trigger => :falling , :pull => :up do #puts "Button pressed changed from #{last_value} to #{value}" #puts "." @@t=Time.now end PiPiper.watch :pin => 23,:trigger => :rising , :pull => :up do delta = Time.now.to_f - @@t.to_f @@t = Time.now EstormLottoGem::Button.led_mgr(EstormLottoGem::Button.tap()) if 0.03 <= delta and delta < 0.7 EstormLottoGem::Button.led_mgr(EstormLottoGem::Button.held()) if 2 < delta and delta < 20 #puts "debounce" if 0.1 > delta end sleep 5 @@led.off @@t=Time.now PiPiper.wait end |