From c26595839e7f1c65502ed3ed81a3522cea2ea02d Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 17 Jun 2024 14:37:08 +0100 Subject: [PATCH] weather.py: Add button debounce. --- examples/weather.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/weather.py b/examples/weather.py index 65f4775..ea03f18 100644 --- a/examples/weather.py +++ b/examples/weather.py @@ -3,6 +3,7 @@ import pathlib import select import time +from datetime import timedelta import gpiod import gpiodevice @@ -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)