mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 06:02:05 +00:00
Merge 7e1052f82a
into 46c7d74760
This commit is contained in:
commit
39d40ea1d2
@ -4,35 +4,40 @@
|
||||
TrackballInterruptBase::TrackballInterruptBase(const char *name) : concurrency::OSThread(name), _originName(name) {}
|
||||
|
||||
void TrackballInterruptBase::init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLeft, uint8_t pinRight, uint8_t pinPress,
|
||||
char eventDown, char eventUp, char eventLeft, char eventRight, char eventPressed,
|
||||
void (*onIntDown)(), void (*onIntUp)(), void (*onIntLeft)(), void (*onIntRight)(),
|
||||
void (*onIntPress)())
|
||||
uint8_t pinMenuParam, char eventDown, char eventUp, char eventLeft, char eventRight,
|
||||
char eventPressed, char eventmenu, void (*onIntDown)(), void (*onIntUp)(), void (*onIntLeft)(),
|
||||
void (*onIntRight)(), void (*onIntPress)(), void (*onMenuPress)())
|
||||
{
|
||||
this->_pinDown = pinDown;
|
||||
this->_pinUp = pinUp;
|
||||
this->_pinLeft = pinLeft;
|
||||
this->_pinRight = pinRight;
|
||||
this->_pinPress = pinPress;
|
||||
this->_pinMenu = pinMenuParam;
|
||||
|
||||
this->_eventDown = eventDown;
|
||||
this->_eventUp = eventUp;
|
||||
this->_eventLeft = eventLeft;
|
||||
this->_eventRight = eventRight;
|
||||
this->_eventPressed = eventPressed;
|
||||
this->_eventMenu = eventmenu;
|
||||
|
||||
pinMode(pinPress, INPUT_PULLUP);
|
||||
pinMode(this->_pinPress, INPUT_PULLUP);
|
||||
pinMode(this->_pinDown, INPUT_PULLUP);
|
||||
pinMode(this->_pinUp, INPUT_PULLUP);
|
||||
pinMode(this->_pinLeft, INPUT_PULLUP);
|
||||
pinMode(this->_pinRight, INPUT_PULLUP);
|
||||
pinMode(this->_pinMenu, INPUT_PULLUP);
|
||||
|
||||
attachInterrupt(pinPress, onIntPress, RISING);
|
||||
attachInterrupt(this->_pinPress, onIntPress, RISING);
|
||||
attachInterrupt(this->_pinDown, onIntDown, RISING);
|
||||
attachInterrupt(this->_pinUp, onIntUp, RISING);
|
||||
attachInterrupt(this->_pinLeft, onIntLeft, RISING);
|
||||
attachInterrupt(this->_pinRight, onIntRight, RISING);
|
||||
attachInterrupt(this->_pinMenu, onMenuPress, RISING);
|
||||
|
||||
LOG_DEBUG("Trackball GPIO initialized (%d, %d, %d, %d, %d)", this->_pinUp, this->_pinDown, this->_pinLeft, this->_pinRight,
|
||||
pinPress);
|
||||
|
||||
LOG_DEBUG("Trackball GPIO initialized (Up:%d, Down:%d, Left:%d, Right:%d, Press:%d, Menu:%d)", this->_pinUp, this->_pinDown,
|
||||
this->_pinLeft, this->_pinRight, this->_pinPress, this->_pinMenu);
|
||||
this->setInterval(100);
|
||||
}
|
||||
|
||||
@ -42,20 +47,23 @@ int32_t TrackballInterruptBase::runOnce()
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
|
||||
if (this->action == TB_ACTION_PRESSED) {
|
||||
// LOG_DEBUG("Trackball event Press");
|
||||
LOG_DEBUG("Trackball event Press");
|
||||
e.inputEvent = this->_eventPressed;
|
||||
} else if (this->action == TB_ACTION_UP) {
|
||||
// LOG_DEBUG("Trackball event UP");
|
||||
LOG_DEBUG("Trackball event UP");
|
||||
e.inputEvent = this->_eventUp;
|
||||
} else if (this->action == TB_ACTION_DOWN) {
|
||||
// LOG_DEBUG("Trackball event DOWN");
|
||||
LOG_DEBUG("Trackball event DOWN");
|
||||
e.inputEvent = this->_eventDown;
|
||||
} else if (this->action == TB_ACTION_LEFT) {
|
||||
// LOG_DEBUG("Trackball event LEFT");
|
||||
LOG_DEBUG("Trackball event LEFT");
|
||||
e.inputEvent = this->_eventLeft;
|
||||
} else if (this->action == TB_ACTION_RIGHT) {
|
||||
// LOG_DEBUG("Trackball event RIGHT");
|
||||
LOG_DEBUG("Trackball event RIGHT");
|
||||
e.inputEvent = this->_eventRight;
|
||||
} else if (this->action == TB_ACTION_MENU) {
|
||||
LOG_DEBUG("Trackball event Menu");
|
||||
e.inputEvent = this->_eventMenu;
|
||||
}
|
||||
|
||||
if (e.inputEvent != meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
|
||||
@ -93,3 +101,8 @@ void TrackballInterruptBase::intRightHandler()
|
||||
{
|
||||
this->action = TB_ACTION_RIGHT;
|
||||
}
|
||||
|
||||
void TrackballInterruptBase::intMenuHandler()
|
||||
{
|
||||
this->action = TB_ACTION_MENU;
|
||||
}
|
||||
|
@ -7,15 +7,16 @@ class TrackballInterruptBase : public Observable<const InputEvent *>, public con
|
||||
{
|
||||
public:
|
||||
explicit TrackballInterruptBase(const char *name);
|
||||
void init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLeft, uint8_t pinRight, uint8_t pinPress, char eventDown, char eventUp,
|
||||
char eventLeft, char eventRight, char eventPressed, void (*onIntDown)(), void (*onIntUp)(), void (*onIntLeft)(),
|
||||
void (*onIntRight)(), void (*onIntPress)());
|
||||
void init(uint8_t pinDown, uint8_t pinUp, uint8_t pinLeft, uint8_t pinRight, uint8_t pinPress, uint8_t pinMenu,
|
||||
char eventDown, char eventUp, char eventLeft, char eventRight, char eventPressed, char eventmenu,
|
||||
void (*onIntDown)(), void (*onIntUp)(), void (*onIntLeft)(), void (*onIntRight)(), void (*onIntPress)(),
|
||||
void (*onMenuPress)());
|
||||
void intPressHandler();
|
||||
void intDownHandler();
|
||||
void intUpHandler();
|
||||
void intLeftHandler();
|
||||
void intRightHandler();
|
||||
|
||||
void intMenuHandler();
|
||||
virtual int32_t runOnce() override;
|
||||
|
||||
protected:
|
||||
@ -25,7 +26,8 @@ class TrackballInterruptBase : public Observable<const InputEvent *>, public con
|
||||
TB_ACTION_UP,
|
||||
TB_ACTION_DOWN,
|
||||
TB_ACTION_LEFT,
|
||||
TB_ACTION_RIGHT
|
||||
TB_ACTION_RIGHT,
|
||||
TB_ACTION_MENU
|
||||
};
|
||||
|
||||
volatile TrackballInterruptBaseActionType action = TB_ACTION_NONE;
|
||||
@ -35,10 +37,13 @@ class TrackballInterruptBase : public Observable<const InputEvent *>, public con
|
||||
uint8_t _pinUp = 0;
|
||||
uint8_t _pinLeft = 0;
|
||||
uint8_t _pinRight = 0;
|
||||
uint8_t _pinPress = 0;
|
||||
uint8_t _pinMenu = 0;
|
||||
char _eventDown = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
char _eventUp = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
char _eventLeft = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
char _eventRight = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
char _eventPressed = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
char _eventMenu = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
const char *_originName;
|
||||
};
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "InputBroker.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "modules/CannedMessageModule.h"
|
||||
TrackballInterruptImpl1 *trackballInterruptImpl1;
|
||||
|
||||
TrackballInterruptImpl1::TrackballInterruptImpl1() : TrackballInterruptBase("trackball1") {}
|
||||
@ -17,17 +19,20 @@ void TrackballInterruptImpl1::init()
|
||||
uint8_t pinLeft = TB_LEFT;
|
||||
uint8_t pinRight = TB_RIGHT;
|
||||
uint8_t pinPress = TB_PRESS;
|
||||
uint8_t pinmenu = BUTTON_PIN;
|
||||
|
||||
char eventDown = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN);
|
||||
char eventUp = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP);
|
||||
char eventLeft = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT);
|
||||
char eventRight = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT);
|
||||
char eventPressed = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT);
|
||||
char eventcancel = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL);
|
||||
|
||||
TrackballInterruptBase::init(pinDown, pinUp, pinLeft, pinRight, pinPress, eventDown, eventUp, eventLeft, eventRight,
|
||||
eventPressed, TrackballInterruptImpl1::handleIntDown, TrackballInterruptImpl1::handleIntUp,
|
||||
TrackballInterruptImpl1::handleIntLeft, TrackballInterruptImpl1::handleIntRight,
|
||||
TrackballInterruptImpl1::handleIntPressed);
|
||||
TrackballInterruptBase::init(pinDown, pinUp, pinLeft, pinRight, pinPress, pinmenu, eventDown, eventUp, eventLeft, eventRight,
|
||||
eventPressed, eventcancel, TrackballInterruptImpl1::handleIntDown,
|
||||
TrackballInterruptImpl1::handleIntUp, TrackballInterruptImpl1::handleIntLeft,
|
||||
TrackballInterruptImpl1::handleIntRight, TrackballInterruptImpl1::handleIntPressed,
|
||||
TrackballInterruptImpl1::handleMenuPressed);
|
||||
inputBroker->registerSource(this);
|
||||
#endif
|
||||
}
|
||||
@ -52,3 +57,22 @@ void TrackballInterruptImpl1::handleIntPressed()
|
||||
{
|
||||
trackballInterruptImpl1->intPressHandler();
|
||||
}
|
||||
|
||||
void TrackballInterruptImpl1::handleMenuPressed()
|
||||
{
|
||||
bool activateMenuAction = false;
|
||||
|
||||
if (cannedMessageModule && cannedMessageModule->isUIVisibleAndInterceptingInput()) {
|
||||
activateMenuAction = true;
|
||||
}
|
||||
|
||||
if (activateMenuAction) {
|
||||
|
||||
if (trackballInterruptImpl1) {
|
||||
LOG_DEBUG("Menu pressed; Canned Message UI is active and intercepting input. Activating CANCEL.");
|
||||
trackballInterruptImpl1->intMenuHandler();
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG("Menu pressed, but Canned Message module is not intercepting input. No action from trackball.");
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ class TrackballInterruptImpl1 : public TrackballInterruptBase
|
||||
static void handleIntLeft();
|
||||
static void handleIntRight();
|
||||
static void handleIntPressed();
|
||||
static void handleMenuPressed();
|
||||
};
|
||||
|
||||
extern TrackballInterruptImpl1 *trackballInterruptImpl1;
|
||||
|
@ -92,6 +92,7 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool isUIVisibleAndInterceptingInput() { return this->interceptingKeyboardInput(); }
|
||||
|
||||
protected:
|
||||
virtual int32_t runOnce() override;
|
||||
|
Loading…
Reference in New Issue
Block a user