* WIP * ESP8266 SAM fun * I2S audio / ext. notification module * Remove * Protos * Add use_i2s_as_buzzer from protos * Fixes * Stuff * Thing * Ext. Notification working(ish) * Remove SAM commented code * Trunk upgrade * Trunk * Fixes * Slow not fast... :-| * T-Deck and T-Watch don't use normal buttons * Stop ext. notification nagging with touchscreen as well * Add button gpio back for T-Deck, but guard against long-press during ext. notification * Ext. notification wrap up * Better place to guard against long-press false positives * Adjust default gain and guard against non-i2s devices referencing audio-thread * Simplify guard logic with a boolean * Supress uninitMemberVar * Protos merge got out of wack * Trunk resolution * Remove extra crap * Cleanup and thread-interval * Default to alert message buzzer and add nag timeout * Formatting
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
#include "TouchScreenImpl1.h"
|
|
#include "InputBroker.h"
|
|
#include "PowerFSM.h"
|
|
#include "configuration.h"
|
|
#include "modules/ExternalNotificationModule.h"
|
|
|
|
TouchScreenImpl1 *touchScreenImpl1;
|
|
|
|
TouchScreenImpl1::TouchScreenImpl1(uint16_t width, uint16_t height, bool (*getTouch)(int16_t *, int16_t *))
|
|
: TouchScreenBase("touchscreen1", width, height), _getTouch(getTouch)
|
|
{
|
|
}
|
|
|
|
void TouchScreenImpl1::init()
|
|
{
|
|
#if !HAS_TOUCHSCREEN
|
|
TouchScreenBase::init(false);
|
|
return;
|
|
#else
|
|
TouchScreenBase::init(true);
|
|
inputBroker->registerSource(this);
|
|
#endif
|
|
}
|
|
|
|
bool TouchScreenImpl1::getTouch(int16_t &x, int16_t &y)
|
|
{
|
|
return _getTouch(&x, &y);
|
|
}
|
|
|
|
/**
|
|
* @brief forward touchscreen event
|
|
*
|
|
* @param event
|
|
*
|
|
* The touchscreen events are translated to input events and reversed
|
|
*/
|
|
void TouchScreenImpl1::onEvent(const TouchEvent &event)
|
|
{
|
|
InputEvent e;
|
|
e.source = event.source;
|
|
switch (event.touchEvent) {
|
|
case TOUCH_ACTION_LEFT: {
|
|
e.inputEvent = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT);
|
|
break;
|
|
}
|
|
case TOUCH_ACTION_RIGHT: {
|
|
e.inputEvent = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT);
|
|
break;
|
|
}
|
|
case TOUCH_ACTION_UP: {
|
|
e.inputEvent = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP);
|
|
break;
|
|
}
|
|
case TOUCH_ACTION_DOWN: {
|
|
e.inputEvent = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN);
|
|
break;
|
|
}
|
|
case TOUCH_ACTION_DOUBLE_TAP: {
|
|
e.inputEvent = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT);
|
|
break;
|
|
}
|
|
case TOUCH_ACTION_LONG_PRESS: {
|
|
e.inputEvent = static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL);
|
|
break;
|
|
}
|
|
case TOUCH_ACTION_TAP: {
|
|
if (moduleConfig.external_notification.enabled && (externalNotificationModule->nagCycleCutoff != UINT32_MAX)) {
|
|
externalNotificationModule->stopNow();
|
|
} else {
|
|
powerFSM.trigger(EVENT_INPUT);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
return;
|
|
}
|
|
this->notifyObservers(&e);
|
|
} |