diff options
author | uvok | 2025-07-17 21:33:50 +0200 |
---|---|---|
committer | uvok | 2025-07-17 21:33:50 +0200 |
commit | a5571a834f1b2b7ec0b8cdc016884442099ceab8 (patch) | |
tree | b6f1a2aa0ca3bc50957bcf7383f59fcca95fc4d4 /src/gpio.cpp | |
parent | 3f9e0e97aa0491d0143642f8302dd38afb42f479 (diff) |
Reorganize, scope, add GPIO
Diffstat (limited to 'src/gpio.cpp')
-rw-r--r-- | src/gpio.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gpio.cpp b/src/gpio.cpp new file mode 100644 index 0000000..d7dcd7b --- /dev/null +++ b/src/gpio.cpp @@ -0,0 +1,35 @@ +#include "badge/gpio.h" + +#include <Arduino.h> + +#define BUTTON_PIN 0 + +static unsigned long pressedTime = 0; +static unsigned long releasedTime = 0; + +void de::uvok::badge::gpio_init(void) +{ +} + +long de::uvok::badge::gpio_poll(void) +{ + static int lastState = HIGH; + int buttonState = digitalRead(BUTTON_PIN); + long pressDuration = 0; + if (lastState == HIGH && buttonState == LOW) + { + Serial.println("``\\__"); + pressedTime = millis(); + lastState = LOW; + } + else if (lastState == LOW && buttonState == HIGH) + { + lastState = HIGH; + Serial.println("__/``"); + releasedTime = millis(); + + pressDuration = releasedTime - pressedTime; + }; + + return pressDuration; +} |