mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 03:00:56 +00:00
* Add mesh/Default.h include. * Reflacter OnScreenKeyBoard Module, do not interrupt keyboard when new message comes. * feat: Add long press scrolling for Joystick and upDown Encoder on baseUI frames and menus. * refactor: Clean up code formatting and improve readability in Screen and OnScreenKeyboardModule * Fix navigation on UpDownEncoder, default was RotaryEncoder while bringing the T_LORA_PAGER * Update src/graphics/draw/MenuHandler.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/OnScreenKeyboardModule.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/graphics/draw/NotificationRenderer.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Optimize the detection logic for repeated events of the arrow keys. * Fixed parameter names in the OnScreenKeyboardModule::start * Trunk fix * Reflator OnScreenKeyboard Input checking, make it simple * Simplify long press logic in OnScreenKeyboardModule. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "InputBroker.h"
|
|
#include "mesh/NodeDB.h"
|
|
|
|
#ifndef UPDOWN_LONG_PRESS_DURATION
|
|
#define UPDOWN_LONG_PRESS_DURATION 300
|
|
#endif
|
|
|
|
#ifndef UPDOWN_LONG_PRESS_REPEAT_INTERVAL
|
|
#define UPDOWN_LONG_PRESS_REPEAT_INTERVAL 300
|
|
#endif
|
|
|
|
class UpDownInterruptBase : public Observable<const InputEvent *>, public concurrency::OSThread
|
|
{
|
|
public:
|
|
explicit UpDownInterruptBase(const char *name);
|
|
void init(uint8_t pinDown, uint8_t pinUp, uint8_t pinPress, input_broker_event eventDown, input_broker_event eventUp,
|
|
input_broker_event eventPressed, input_broker_event eventPressedLong, input_broker_event eventUpLong,
|
|
input_broker_event eventDownLong, void (*onIntDown)(), void (*onIntUp)(), void (*onIntPress)(),
|
|
unsigned long updownDebounceMs = 50);
|
|
void intPressHandler();
|
|
void intDownHandler();
|
|
void intUpHandler();
|
|
|
|
int32_t runOnce() override;
|
|
|
|
protected:
|
|
enum UpDownInterruptBaseActionType {
|
|
UPDOWN_ACTION_NONE,
|
|
UPDOWN_ACTION_PRESSED,
|
|
UPDOWN_ACTION_PRESSED_LONG,
|
|
UPDOWN_ACTION_UP,
|
|
UPDOWN_ACTION_UP_LONG,
|
|
UPDOWN_ACTION_DOWN,
|
|
UPDOWN_ACTION_DOWN_LONG
|
|
};
|
|
|
|
volatile UpDownInterruptBaseActionType action = UPDOWN_ACTION_NONE;
|
|
|
|
// Long press detection variables
|
|
uint32_t pressStartTime = 0;
|
|
uint32_t upStartTime = 0;
|
|
uint32_t downStartTime = 0;
|
|
bool pressDetected = false;
|
|
bool upDetected = false;
|
|
bool downDetected = false;
|
|
uint32_t lastPressLongEventTime = 0;
|
|
uint32_t lastUpLongEventTime = 0;
|
|
uint32_t lastDownLongEventTime = 0;
|
|
static const uint32_t LONG_PRESS_DURATION = UPDOWN_LONG_PRESS_DURATION;
|
|
static const uint32_t LONG_PRESS_REPEAT_INTERVAL = UPDOWN_LONG_PRESS_REPEAT_INTERVAL;
|
|
|
|
private:
|
|
uint8_t _pinDown = 0;
|
|
uint8_t _pinUp = 0;
|
|
uint8_t _pinPress = 0;
|
|
input_broker_event _eventDown = INPUT_BROKER_NONE;
|
|
input_broker_event _eventUp = INPUT_BROKER_NONE;
|
|
input_broker_event _eventPressed = INPUT_BROKER_NONE;
|
|
input_broker_event _eventPressedLong = INPUT_BROKER_NONE;
|
|
input_broker_event _eventUpLong = INPUT_BROKER_NONE;
|
|
input_broker_event _eventDownLong = INPUT_BROKER_NONE;
|
|
const char *_originName;
|
|
|
|
unsigned long lastUpKeyTime = 0;
|
|
unsigned long lastDownKeyTime = 0;
|
|
unsigned long lastPressKeyTime = 0;
|
|
unsigned long updownDebounceMs = 50;
|
|
const unsigned long pressDebounceMs = 200;
|
|
};
|