mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* UI revamp for companion radios
This commit is contained in:
parent
a310a5c4d5
commit
4b95c981bb
26 changed files with 840 additions and 323 deletions
25
src/helpers/ui/MomentaryButton.h
Normal file
25
src/helpers/ui/MomentaryButton.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define BUTTON_EVENT_NONE 0
|
||||
#define BUTTON_EVENT_CLICK 1
|
||||
#define BUTTON_EVENT_LONG_PRESS 2
|
||||
|
||||
class MomentaryButton {
|
||||
int8_t _pin;
|
||||
int8_t prev, cancel;
|
||||
bool _reverse;
|
||||
int _long_millis;
|
||||
unsigned long down_at;
|
||||
|
||||
bool isPressed(int level) const;
|
||||
|
||||
public:
|
||||
MomentaryButton(int8_t pin, int long_press_mills=0, bool reverse=false);
|
||||
void begin(bool pulldownup=false);
|
||||
int check(bool repeat_click=false); // returns one of BUTTON_EVENT_*
|
||||
void cancelClick(); // suppress next BUTTON_EVENT_CLICK (if already in DOWN state)
|
||||
uint8_t getPin() { return _pin; }
|
||||
bool isPressed() const;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue