mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-13 15:11:20 +10:00
* Update Favorite Node Message Options to unify against other screens * Rebuild Horizontal Battery, Resolve overlap concerns * Update positioning on Message frame and fix drawCommonHeader overlay * Beginnings of creating isHighResolution bool * Fixup determineResolution() * Implement isHighResolution in place of SCREEN_WIDTH > 128 checks * Line Spacing bound to isHighResolution * Analog Clock for all * Add AM/PM to Analog Clock if isHighResolution and not TWatch * Simple Menu Queue, and add time menu * Fix prompt string for 12/24 hour picker * More menu banners into functions * Fix Action Menu on Home frame * Correct pop-up calculation size and continue to leverage isHighResolution * Move menu bits to MenuHandler * Plumb in the digital/analog picker * Correct Clock Face Picker title * Clock picker fixes * Migrate the rest of the menus to MenuHandler.* * Add compass menu and needle point option * Minor fix for compass point menu * Correct Home menu into typical format * Fix emoji bounce, overlap, and missing commonHeader * Sanitize long_names and removed unused variables * Slightly better sanitizeString variation * Resolved apostrophe being shown as upside down question mark * Gotta keep height and width in expected order * Remove Second Hand for Analog Clock on EInk displays * Fix Clock menu option decision tree * Improvements to Eink Navigation * Pause Banner for Eink moved to bottom * Updated working for 12-/24-hour menu and Added US/Arizona to timezone picker * Add Adhoc Ping and resolve error with std::string sanitized * Hide quick toggle as option is available within Action Menu, commented out for the moment * Remove old battery icon and option, use drawCommonHeader throughout, re-add battery to Clock frames * fix misc build warnings. NFC * Update Analog Clock on EInk to show more digits * Establish Action Menu on all node list screens, add NodeDB reset (with confirmation) option * Add Toggle Backlight for EInk Displays * Suppress action screen Full refresh for Eink * Adjust drawBluetoothConnectedIcon on TWatch * Maintain clock frame when switching between Clock Faces * Move modules beyond the clock in navigation * addressed the conflicts, and changed target branch to 2.7-MiscFixes-Week1 * cleanup, cheers * Add AM/PM to low resolution clock also * Small adjustments to AM/PM replacement across various devices * Resolve dangling pointer issues with sanitize code * Update comments for Screen.cpp related to module load change * Trunk runs * Update message caching to correct aged timestamp * Menu wording adjustments * Time Format wording * Use all the rows on EInk since with autohide the navigation bar * Finalize Time Format picker word change * Retired drawFunctionOverlay code No longer being used * Actually honor the points-north setting * Trunk * Compressed action list * Update no-op showOverlayBanner function * trunk * Correct T_Watch_S3 specific line * Autosized Action menu per screen * Finalize Autosized Action menu per screen * Unify Message Titles * Reorder Timezones to match expectations * Adjust text location for pop-ups * Revert "Actually honor the points-north setting" This reverts commit 20988aa4fabb0975be644989d556fca7e1176680. * Make NodeDB sort its internal vector when lastheard is updated. Don't sort in NodeListRenderer * Update src/graphics/draw/NodeListRenderer.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/mesh/NodeDB.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Pass by reference -- Thanks Copilot! * Throttle sorting just a touch * Check more carefully for own node * Eliminate some now-unneeded sorting * Move function after include * Putting Modules back to position 0 and some trunk checks found * Add Scrollbar for Action menus * Second attempt to move modules down the navigation bar * Continue effort of moving modules in the navigation * Canned Messages tweak * Replicate Function + Space through the Menu System * Move init button parameters into config struct (#7145) * Remove bundling of web-ui from ESP32 devices (#7143) * Fixed triple click GPS toggle bungle * Move init button parameters into config struct * Reapply "Actually honor the points-north setting" This reverts commit 42c1967e7b3735ec9f5be8acd9582bc9edcbc78a. * Actually do compass pointings correctly * Tweak to node bearings * Menu wording tweaks * Get the compass_north_top logic right * Don't jump frames after setting Compass * Get rid of the extra bearingTo functions * Don't blink Mail on EInk Clock Screens * Actually set lat and long * Calibrate * Convert Radians to Degrees * More degree vs radians fixes * De-duplicate draw arrow function * Don't advertise compass calibration without an accell thread. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz> Co-authored-by: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: csrutil <keming.cao@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
129 lines
3.9 KiB
C++
129 lines
3.9 KiB
C++
#pragma once
|
|
|
|
#include "InputBroker.h"
|
|
#include "OneButton.h"
|
|
#include "concurrency/OSThread.h"
|
|
#include "configuration.h"
|
|
|
|
typedef void (*voidFuncPtr)(void);
|
|
|
|
struct ButtonConfig {
|
|
uint8_t pinNumber;
|
|
bool activeLow = true;
|
|
bool activePullup = true;
|
|
uint32_t pullupSense = 0;
|
|
voidFuncPtr intRoutine = nullptr;
|
|
input_broker_event singlePress = INPUT_BROKER_NONE;
|
|
input_broker_event longPress = INPUT_BROKER_NONE;
|
|
uint16_t longPressTime = 500;
|
|
input_broker_event doublePress = INPUT_BROKER_NONE;
|
|
input_broker_event longLongPress = INPUT_BROKER_NONE;
|
|
uint16_t longLongPressTime = 5000;
|
|
input_broker_event triplePress = INPUT_BROKER_NONE;
|
|
input_broker_event shortLong = INPUT_BROKER_NONE;
|
|
bool touchQuirk = false;
|
|
|
|
// Constructor to set required parameter
|
|
ButtonConfig(uint8_t pin = 0) : pinNumber(pin) {}
|
|
};
|
|
|
|
#ifndef BUTTON_CLICK_MS
|
|
#define BUTTON_CLICK_MS 250
|
|
#endif
|
|
|
|
#ifndef BUTTON_TOUCH_MS
|
|
#define BUTTON_TOUCH_MS 400
|
|
#endif
|
|
|
|
#ifndef BUTTON_COMBO_TIMEOUT_MS
|
|
#define BUTTON_COMBO_TIMEOUT_MS 1000 // 1 second to complete the combination -- tap faster
|
|
#endif
|
|
|
|
#ifndef BUTTON_LEADUP_MS
|
|
#define BUTTON_LEADUP_MS 2200 // Play lead-up sound after 2.5 seconds of holding
|
|
#endif
|
|
|
|
class ButtonThread : public Observable<const InputEvent *>, public concurrency::OSThread
|
|
{
|
|
public:
|
|
const char *_originName;
|
|
static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot
|
|
bool initButton(const ButtonConfig &config);
|
|
|
|
enum ButtonEventType {
|
|
BUTTON_EVENT_NONE,
|
|
BUTTON_EVENT_PRESSED,
|
|
BUTTON_EVENT_PRESSED_SCREEN,
|
|
BUTTON_EVENT_DOUBLE_PRESSED,
|
|
BUTTON_EVENT_MULTI_PRESSED,
|
|
BUTTON_EVENT_LONG_PRESSED,
|
|
BUTTON_EVENT_LONG_RELEASED,
|
|
BUTTON_EVENT_TOUCH_LONG_PRESSED,
|
|
BUTTON_EVENT_COMBO_SHORT_LONG,
|
|
};
|
|
|
|
ButtonThread(const char *name);
|
|
int32_t runOnce() override;
|
|
OneButton userButton;
|
|
void attachButtonInterrupts();
|
|
void detachButtonInterrupts();
|
|
void storeClickCount();
|
|
bool isButtonPressed(int buttonPin)
|
|
{
|
|
if (_activeLow)
|
|
return !digitalRead(buttonPin); // Active low: pressed = LOW
|
|
else
|
|
return digitalRead(buttonPin); // Most buttons are active low by default
|
|
}
|
|
|
|
// Disconnect and reconnect interrupts for light sleep
|
|
#ifdef ARCH_ESP32
|
|
int beforeLightSleep(void *unused);
|
|
int afterLightSleep(esp_sleep_wakeup_cause_t cause);
|
|
#endif
|
|
private:
|
|
input_broker_event _singlePress = INPUT_BROKER_NONE;
|
|
input_broker_event _longPress = INPUT_BROKER_NONE;
|
|
input_broker_event _longLongPress = INPUT_BROKER_NONE;
|
|
|
|
input_broker_event _doublePress = INPUT_BROKER_NONE;
|
|
input_broker_event _triplePress = INPUT_BROKER_NONE;
|
|
input_broker_event _shortLong = INPUT_BROKER_NONE;
|
|
|
|
voidFuncPtr _intRoutine = nullptr;
|
|
uint16_t _longPressTime = 500;
|
|
uint16_t _longLongPressTime = 5000;
|
|
int _pinNum = 0;
|
|
bool _activeLow = true;
|
|
bool _touchQuirk = false;
|
|
|
|
uint32_t buttonPressStartTime = 0;
|
|
bool buttonWasPressed = false;
|
|
|
|
#ifdef ARCH_ESP32
|
|
// Get notified when lightsleep begins and ends
|
|
CallbackObserver<ButtonThread, void *> lsObserver =
|
|
CallbackObserver<ButtonThread, void *>(this, &ButtonThread::beforeLightSleep);
|
|
CallbackObserver<ButtonThread, esp_sleep_wakeup_cause_t> lsEndObserver =
|
|
CallbackObserver<ButtonThread, esp_sleep_wakeup_cause_t>(this, &ButtonThread::afterLightSleep);
|
|
#endif
|
|
|
|
volatile ButtonEventType btnEvent = BUTTON_EVENT_NONE;
|
|
|
|
// Store click count during callback, for later use
|
|
volatile int multipressClickCount = 0;
|
|
|
|
// Combination tracking state
|
|
bool waitingForLongPress = false;
|
|
uint32_t shortPressTime = 0;
|
|
|
|
// Long press lead-up tracking
|
|
bool leadUpPlayed = false;
|
|
uint32_t lastLeadUpNoteTime = 0;
|
|
bool leadUpSequenceActive = false;
|
|
|
|
static void wakeOnIrq(int irq, int mode);
|
|
};
|
|
|
|
extern ButtonThread *buttonThread;
|