mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-13 08:45:04 +00:00

Some checks failed
Generate UsersPrefs JSON manifest / generate-userprefs (push) Has been cancelled
CI / setup (check) (push) Has been cancelled
CI / setup (esp32) (push) Has been cancelled
CI / setup (esp32c3) (push) Has been cancelled
CI / setup (esp32c6) (push) Has been cancelled
CI / setup (esp32s3) (push) Has been cancelled
CI / setup (nrf52840) (push) Has been cancelled
CI / setup (rp2040) (push) Has been cancelled
CI / setup (stm32) (push) Has been cancelled
CI / package-raspbian (push) Has been cancelled
CI / package-raspbian-armv7l (push) Has been cancelled
CI / package-native (push) Has been cancelled
Flawfinder Scan / Flawfinder (push) Has been cancelled
CI / check (push) Has been cancelled
CI / build-esp32 (push) Has been cancelled
CI / build-esp32-s3 (push) Has been cancelled
CI / build-esp32-c3 (push) Has been cancelled
CI / build-esp32-c6 (push) Has been cancelled
CI / build-nrf52 (push) Has been cancelled
CI / build-rpi2040 (push) Has been cancelled
CI / build-stm32 (push) Has been cancelled
CI / after-checks (push) Has been cancelled
CI / gather-artifacts (esp32) (push) Has been cancelled
CI / gather-artifacts (esp32c3) (push) Has been cancelled
CI / gather-artifacts (esp32c6) (push) Has been cancelled
CI / gather-artifacts (esp32s3) (push) Has been cancelled
CI / gather-artifacts (nrf52840) (push) Has been cancelled
CI / gather-artifacts (rp2040) (push) Has been cancelled
CI / gather-artifacts (stm32) (push) Has been cancelled
CI / release-artifacts (push) Has been cancelled
CI / release-firmware (esp32) (push) Has been cancelled
CI / release-firmware (esp32c3) (push) Has been cancelled
CI / release-firmware (esp32c6) (push) Has been cancelled
CI / release-firmware (esp32s3) (push) Has been cancelled
CI / release-firmware (nrf52840) (push) Has been cancelled
CI / release-firmware (rp2040) (push) Has been cancelled
CI / release-firmware (stm32) (push) Has been cancelled
Nightly / Trunk Check Upload (push) Has been cancelled
* userPrefs.h Added FixedGPS Added Fixed Bluetooth PIN * Update NodeDB.cpp Removed some un-used LOG_INFO * Added BUTTON_PIN * Trunk * Variable re-naming. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "OneButton.h"
|
|
#include "concurrency/OSThread.h"
|
|
#include "configuration.h"
|
|
|
|
#ifndef BUTTON_CLICK_MS
|
|
#define BUTTON_CLICK_MS 250
|
|
#endif
|
|
|
|
#ifndef BUTTON_LONGPRESS_MS
|
|
#define BUTTON_LONGPRESS_MS 5000
|
|
#endif
|
|
|
|
#ifndef BUTTON_TOUCH_MS
|
|
#define BUTTON_TOUCH_MS 400
|
|
#endif
|
|
|
|
class ButtonThread : public concurrency::OSThread
|
|
{
|
|
public:
|
|
static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot
|
|
|
|
enum ButtonEventType {
|
|
BUTTON_EVENT_NONE,
|
|
BUTTON_EVENT_PRESSED,
|
|
BUTTON_EVENT_DOUBLE_PRESSED,
|
|
BUTTON_EVENT_MULTI_PRESSED,
|
|
BUTTON_EVENT_LONG_PRESSED,
|
|
BUTTON_EVENT_LONG_RELEASED,
|
|
BUTTON_EVENT_TOUCH_LONG_PRESSED,
|
|
};
|
|
|
|
ButtonThread();
|
|
int32_t runOnce() override;
|
|
void attachButtonInterrupts();
|
|
void detachButtonInterrupts();
|
|
void storeClickCount();
|
|
|
|
private:
|
|
#if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) || defined(USERPREFS_BUTTON_PIN)
|
|
static OneButton userButton; // Static - accessed from an interrupt
|
|
#endif
|
|
#ifdef BUTTON_PIN_ALT
|
|
OneButton userButtonAlt;
|
|
#endif
|
|
#ifdef BUTTON_PIN_TOUCH
|
|
OneButton userButtonTouch;
|
|
#endif
|
|
|
|
// set during IRQ
|
|
static volatile ButtonEventType btnEvent;
|
|
|
|
// Store click count during callback, for later use
|
|
volatile int multipressClickCount = 0;
|
|
|
|
static void wakeOnIrq(int irq, int mode);
|
|
|
|
// IRQ callbacks
|
|
static void userButtonPressed() { btnEvent = BUTTON_EVENT_PRESSED; }
|
|
static void userButtonDoublePressed() { btnEvent = BUTTON_EVENT_DOUBLE_PRESSED; }
|
|
static void userButtonMultiPressed(void *callerThread); // Retrieve click count from non-static Onebutton while still valid
|
|
static void userButtonPressedLongStart();
|
|
static void userButtonPressedLongStop();
|
|
static void touchPressedLongStart() { btnEvent = BUTTON_EVENT_TOUCH_LONG_PRESSED; }
|
|
};
|
|
|
|
extern ButtonThread *buttonThread;
|