git subrepo clone --branch=20.41.6 git@github.com:ETLCPP/etl.git components/etl

subrepo:
  subdir:   "components/etl"
  merged:   "be5537ec"
upstream:
  origin:   "git@github.com:ETLCPP/etl.git"
  branch:   "20.41.6"
  commit:   "be5537ec"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
This commit is contained in:
Attila Body 2025-06-11 11:25:49 +02:00
parent 931c4def56
commit 11c24647ea
Signed by: abody
GPG key ID: BD0C6214E68FB5CF
1296 changed files with 801882 additions and 0 deletions

View file

@ -0,0 +1,39 @@
//***********************************************************************************
// A debounce demo that reads a key and toggles the LED.
// Set the pin to the correct one for your key.
//***********************************************************************************
#include <debounce.h>
const int SAMPLE_TIME = 1; // The sample time in ms.
const int DEBOUNCE_COUNT = 50; // The number of samples that must agree before a key state change is recognised. 50 = 50ms for 1ms sample time.
const int HOLD_COUNT = 1000; // The number of samples that must agree before a key held state is recognised. 1000 = 1s for 1ms sample time.
const int REPEAT_COUNT = 200; // The number of samples that must agree before a key repeat state is recognised. 200 = 200ms for 1ms sample time.
const int KEY = XX; // The pin that the key is attached to.
void setup()
{
// Initialize LED pin as an output and set off.
pinMode(LED_BUILTIN , OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
// Initialize KEY pin as an input.
pinMode(KEY, INPUT);
}
void loop()
{
static int led_state = LOW;
static etl::debounce<DEBOUNCE_COUNT, HOLD_COUNT, REPEAT_COUNT> key_state;
if (key_state.add(digitalRead(KEY) == HIGH)) // Assumes 'HIGH' is 'pressed' and 'LOW' is 'released'.
{
if (key_state.is_set())
{
led_state = (led_state == LOW ? HIGH : LOW); // Toggle the LED state on every validated press or repeat.
digitalWrite(LED_BUILTIN, led_state);
}
}
delay(SAMPLE_TIME); // Wait 1ms
}