codex init
This commit is contained in:
17
OpticalChannelTester/Buttons.h
Normal file
17
OpticalChannelTester/Buttons.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
enum class ButtonEvent : uint8_t { NONE, SHORT, LONG, REPEAT };
|
||||
|
||||
class Button {
|
||||
public:
|
||||
explicit Button(uint8_t pin) : pin_(pin) {}
|
||||
void begin();
|
||||
ButtonEvent update(uint32_t nowMs);
|
||||
bool pressed() const { return stable_; }
|
||||
private:
|
||||
uint8_t pin_;
|
||||
bool raw_ = false, stable_ = false, longSent_ = false;
|
||||
uint32_t changedAt_ = 0, pressedAt_ = 0, nextRepeat_ = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user