class Domotics::Core::Button
Public Class Methods
new(args = {})
click to toggle source
Calls superclass method
Domotics::Core::Element::new
# File lib/domotics/core/element/button.rb, line 3 def initialize(args = {}) @type = args[:type] || :button @touch = args[:touch] @last_on = nil args[:driver] = @touch ? "DigitalSensor" : "NOSensor" load_driver args super end
Public Instance Methods
set_state(*_args)
click to toggle source
# File lib/domotics/core/element/button.rb, line 12 def set_state(*_args) nil end
state_changed(value)
click to toggle source
Calls superclass method
Domotics::Core::Element#state_changed
# File lib/domotics/core/element/button.rb, line 16 def state_changed(value) case value when :on @last_on = Time.now when :off case Time.now - (@last_on || Time.now) when 0...0.03 then nil # debounce when 0.03...0.3 then super :tap when 0.3...1 then super :long_tap when 1...2 then super :long_tap_x2 end end end