Skip to content

Commit

Permalink
weather.py: Add button debounce.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Jun 17, 2024
1 parent 0132ca8 commit c265958
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pathlib
import select
import time
from datetime import timedelta

import gpiod
import gpiodevice
Expand Down Expand Up @@ -519,7 +520,11 @@ def __init__(self, views):

config = {}
for pin in BUTTONS:
config[pin] = gpiod.LineSettings(edge_detection=Edge.FALLING, bias=Bias.PULL_UP)
config[pin] = gpiod.LineSettings(
edge_detection=Edge.FALLING,
bias=Bias.PULL_UP,
debounce_period=timedelta(milliseconds=20)
)

chip = gpiodevice.find_chip_by_platform()
self._buttons = chip.request_lines(consumer="LTR559", config=config)
Expand Down

0 comments on commit c265958

Please sign in to comment.