mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 17:13:38 +00:00
it works.... is pressed was not working properly
This commit is contained in:
parent
71bc0098e9
commit
ffa5476be3
@ -35,6 +35,7 @@ void TouchScreenCST226SE::init()
|
||||
attachInterrupt(
|
||||
TOUCH_IRQ, []() { isPressed = true; }, FALLING);
|
||||
}
|
||||
touch.setMirrorXY(false, true);
|
||||
LOG_DEBUG("CST226SE init OK at address 0x%02X", addr);
|
||||
return;
|
||||
}
|
||||
@ -45,102 +46,83 @@ void TouchScreenCST226SE::init()
|
||||
|
||||
bool TouchScreenCST226SE::getTouch(int16_t &x, int16_t &y)
|
||||
{
|
||||
if (!touch.isPressed()) {
|
||||
return false;
|
||||
}
|
||||
int16_t x_array[1], y_array[1];
|
||||
uint8_t touched = touch.getPoint(x_array, y_array, 1);
|
||||
if (touched > 0) {
|
||||
x = x_array[0];
|
||||
y = y_array[0];
|
||||
LOG_DEBUG("TouchScreen filtered %dx %dy", x, y);
|
||||
return true;
|
||||
}
|
||||
// bool pressed = false;
|
||||
LOG_DEBUG("TouchScreen touch %dx %dy", x, y);
|
||||
|
||||
// if (TOUCH_IRQ == -1) {
|
||||
// pressed = touch.isPressed();
|
||||
// } else {
|
||||
// if (!isPressed)
|
||||
// return false;
|
||||
// isPressed = false;
|
||||
// pressed = touch.isPressed();
|
||||
// }
|
||||
// if (pressed) {
|
||||
// int16_t x_array[1], y_array[1];
|
||||
// uint8_t touched = touch.getPoint(x_array, y_array, 1);
|
||||
// if (touched > 0) {
|
||||
// int16_t tx = x_array[0];
|
||||
// int16_t ty = y_array[0];
|
||||
// LOG_DEBUG("TouchScreen touched %dx %dy", tx, ty);
|
||||
// if (tx > (TFT_WIDTH) || tx < 0 || ty > (TFT_HEIGHT) || ty < 0) {
|
||||
// LOG_DEBUG("touch ignored");
|
||||
// return false;
|
||||
// }
|
||||
// x = tx;
|
||||
// y = ty;
|
||||
// LOG_DEBUG("TouchScreen filtered %dx %dy", x, y);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
return false;
|
||||
// Check bounds
|
||||
if (x < 0 || x >= TFT_WIDTH || y < 0 || y >= TFT_HEIGHT) {
|
||||
LOG_DEBUG("Touch ignored - Out of bounds");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // Valid touch detected
|
||||
}
|
||||
|
||||
return false; // No valid touch data
|
||||
}
|
||||
|
||||
bool TouchScreenCST226SE::forwardGetTouch(int16_t *x, int16_t *y)
|
||||
{
|
||||
if (instance) {
|
||||
return instance->getTouch(*x, *y);
|
||||
LOG_DEBUG("TouchScreen parsed %dx %dy", x, y);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// if (instance) {
|
||||
// bool result = instance->getTouch(*x, *y);
|
||||
// if (result) {
|
||||
// LOG_DEBUG("TouchScreen parsed %dx %dy", *x, *y);
|
||||
// }
|
||||
// return result;
|
||||
// } else {
|
||||
return false; // Instance not initialized
|
||||
// }
|
||||
}
|
||||
|
||||
void TouchScreenCST226SE::onEvent(const TouchEvent &event)
|
||||
{
|
||||
InputEvent e;
|
||||
e.source = event.source;
|
||||
// InputEvent e;
|
||||
// e.source = event.source;
|
||||
|
||||
e.touchX = event.x;
|
||||
e.touchY = event.y;
|
||||
// e.touchX = event.x;
|
||||
// e.touchY = event.y;
|
||||
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user