From b26b74bb2464b497598478669d120c0e82c3d737 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 12 Jun 2025 23:37:10 -0500 Subject: [PATCH] Trackball everywhere, and unPhone buttons --- src/configuration.h | 16 ++++++++++++++++ src/input/TrackballInterruptImpl1.cpp | 6 ------ src/main.cpp | 6 +++++- src/modules/CannedMessageModule.cpp | 3 ++- src/modules/Modules.cpp | 2 +- variants/unphone/variant.h | 6 +++++- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index 32d99295e..114efb0f6 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -302,6 +302,22 @@ along with this program. If not, see . #error HW_VENDOR must be defined #endif +#ifndef TB_DOWN +#define TB_DOWN 255 +#endif +#ifndef TB_UP +#define TB_UP 255 +#endif +#ifndef TB_LEFT +#define TB_LEFT 255 +#endif +#ifndef TB_RIGHT +#define TB_RIGHT 255 +#endif +#ifndef TB_PRESS +#define TB_PRESS 255 +#endif + // Support multiple RGB LED configuration #if defined(HAS_NCP5623) || defined(HAS_LP5562) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) #define HAS_RGB_LED diff --git a/src/input/TrackballInterruptImpl1.cpp b/src/input/TrackballInterruptImpl1.cpp index 2072deea6..c6d21ac2b 100644 --- a/src/input/TrackballInterruptImpl1.cpp +++ b/src/input/TrackballInterruptImpl1.cpp @@ -8,11 +8,6 @@ TrackballInterruptImpl1::TrackballInterruptImpl1() : TrackballInterruptBase("tra void TrackballInterruptImpl1::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLeft, uint8_t pinRight, uint8_t pinPress) { -#if !HAS_TRACKBALL - // Input device is disabled. - return; -#else - input_broker_event eventDown = INPUT_BROKER_DOWN; input_broker_event eventUp = INPUT_BROKER_UP; input_broker_event eventLeft = INPUT_BROKER_LEFT; @@ -24,7 +19,6 @@ void TrackballInterruptImpl1::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLe TrackballInterruptImpl1::handleIntLeft, TrackballInterruptImpl1::handleIntRight, TrackballInterruptImpl1::handleIntPressed); inputBroker->registerSource(this); -#endif } void TrackballInterruptImpl1::handleIntDown() diff --git a/src/main.cpp b/src/main.cpp index 267b05992..42762cf76 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -431,6 +431,10 @@ void setup() gpio_pullup_en((gpio_num_t)(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN)); delay(10); #endif +#ifdef BUTTON_NEED_PULLUP2 + gpio_pullup_en((gpio_num_t)BUTTON_NEED_PULLUP2); + delay(10); +#endif #endif #endif #endif @@ -911,7 +915,7 @@ void setup() pullup_sense = INPUT_PULLUP_SENSE; #endif #endif -#if defined(ARCH_PORTDUINO) // make it work +#if defined(ARCH_PORTDUINO) if (settingsMap.count(userButtonPin) != 0 && settingsMap[userButtonPin] != RADIOLIB_NC) { diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 9efd8bc34..9591e83a5 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -371,7 +371,8 @@ bool CannedMessageModule::isUpEvent(const InputEvent *event) } bool CannedMessageModule::isDownEvent(const InputEvent *event) { - return event->inputEvent == INPUT_BROKER_DOWN; + return event->inputEvent == INPUT_BROKER_DOWN || + (runState == CANNED_MESSAGE_RUN_STATE_ACTIVE && event->inputEvent == INPUT_BROKER_USER_PRESS); } bool CannedMessageModule::isSelectEvent(const InputEvent *event) { diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index f6d5820da..a6380d367 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -203,7 +203,7 @@ void setupModules() aLinuxInputImpl->init(); } #endif -#if HAS_TRACKBALL && !MESHTASTIC_EXCLUDE_INPUTBROKER +#if !MESHTASTIC_EXCLUDE_INPUTBROKER if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) { trackballInterruptImpl1 = new TrackballInterruptImpl1(); trackballInterruptImpl1->init(TB_DOWN, TB_UP, TB_LEFT, TB_RIGHT, TB_PRESS); diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index e21d397e4..6619c87c2 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -57,9 +57,13 @@ #define LED_PIN 13 // the red part of the RGB LED #define LED_STATE_ON 0 // State when LED is lit -#define BUTTON_PIN 21 // Button 3 - square - top button in landscape mode +#define TB_UP 21 // Button 3 - square - top button in landscape mode +#define BUTTON_NEED_PULLUP2 TB_UP +#define BUTTON_PIN 0 // Circle button #define BUTTON_NEED_PULLUP // we do need a helping hand up #define CANCEL_BUTTON_PIN 45 // Button 1 - triangle - bottom button in landscape mode +#define CANCEL_BUTTON_ACTIVE_LOW true +#define CANCEL_BUTTON_ACTIVE_PULLUP true #define I2C_SDA 3 // I2C pins for this board #define I2C_SCL 4