Skip to content

Commit

Permalink
Add debounce_time methods (for PiBoard)
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Aug 7, 2024
1 parent 642449d commit 13220df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/denko/behaviors/input_pin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def _stop_listener
board.stop_listener(pin)
end

def debounce_time=(value)
board.set_pin_debounce(pin, value)
end

protected

def initialize_pins(options={})
Expand Down
3 changes: 3 additions & 0 deletions lib/denko/board/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def set_pin_mode(pin, mode=:input)
value: PIN_MODES[mode]
end

def set_pin_debounce(pin, debounce_time)
end

# CMD = 1
def digital_write(pin,value)
unless (value == 1) || (value == 0)
Expand Down
4 changes: 4 additions & 0 deletions test/behaviors/input_pin_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def test_mode_and_pullup
assert_equal :input, part.mode
end

def test_debounce_time=
part.debounce_time = 1
end

def test_stop_listener
mock = Minitest::Mock.new
mock.expect :call, nil, [1]
Expand Down
4 changes: 4 additions & 0 deletions test/board/core_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def test_set_pin_mode
assert_raises { board.set_pin_mode 1, "wrong" }
end

def test_set_pin_debounce
board.set_pin_debounce(1, 1)
end

def test_digital_write
mock = Minitest::Mock.new
mock.expect(:call, nil, [Denko::Message.encode(command: 1, pin: 1, value: board.low)])
Expand Down

0 comments on commit 13220df

Please sign in to comment.