mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-26 22:33:24 +00:00
rak10701: support touchscreen (#4104)
* Add the touch screen driver RAK10701 platform, lib_deps https://github.com/RAKWireless/RAK14014-FT6336U * Added RAK10701 touch screen virtual keyboard, supporting cannedMessageModule free text
This commit is contained in:
parent
8b8e056b7b
commit
e55604b8e5
@ -118,7 +118,15 @@ static LGFX *tft = nullptr;
|
||||
|
||||
#elif defined(RAK14014)
|
||||
#include <TFT_eSPI.h>
|
||||
#include <RAK14014_FT6336U.h>
|
||||
TFT_eSPI *tft = nullptr;
|
||||
FT6336U ft6336u;
|
||||
|
||||
static uint8_t _rak14014_touch_int = false; // TP interrupt generation flag.
|
||||
static void rak14014_tpIntHandle(void)
|
||||
{
|
||||
_rak14014_touch_int = true;
|
||||
}
|
||||
|
||||
#elif defined(ST7789_CS)
|
||||
#include <LovyanGFX.hpp> // Graphics and font library for ST7735 driver chip
|
||||
@ -642,8 +650,12 @@ void TFTDisplay::sendCommand(uint8_t com)
|
||||
|
||||
void TFTDisplay::setDisplayBrightness(uint8_t _brightness)
|
||||
{
|
||||
#ifdef RAK14014
|
||||
//todo
|
||||
#else
|
||||
tft->setBrightness(_brightness);
|
||||
LOG_DEBUG("Brightness is set to value: %i \n", _brightness);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TFTDisplay::flipScreenVertically()
|
||||
@ -657,6 +669,7 @@ void TFTDisplay::flipScreenVertically()
|
||||
bool TFTDisplay::hasTouch(void)
|
||||
{
|
||||
#ifdef RAK14014
|
||||
return true;
|
||||
#elif !defined(M5STACK)
|
||||
return tft->touch() != nullptr;
|
||||
#else
|
||||
@ -667,6 +680,15 @@ bool TFTDisplay::hasTouch(void)
|
||||
bool TFTDisplay::getTouch(int16_t *x, int16_t *y)
|
||||
{
|
||||
#ifdef RAK14014
|
||||
if(_rak14014_touch_int) {
|
||||
_rak14014_touch_int = false;
|
||||
/* The X and Y axes have to be switched */
|
||||
*y = ft6336u.read_touch1_x();
|
||||
*x = TFT_HEIGHT - ft6336u.read_touch1_y();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#elif !defined(M5STACK)
|
||||
return tft->getTouch(x, y);
|
||||
#else
|
||||
@ -717,6 +739,9 @@ bool TFTDisplay::connect()
|
||||
tft->setRotation(1);
|
||||
tft->setSwapBytes(true);
|
||||
// tft->fillScreen(TFT_BLACK);
|
||||
ft6336u.begin();
|
||||
pinMode(SCREEN_TOUCH_INT, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(SCREEN_TOUCH_INT), rak14014_tpIntHandle, FALLING);
|
||||
#elif defined(T_DECK) || defined(PICOMPUTER_S3) || defined(CHATTER_2)
|
||||
tft->setRotation(1); // T-Deck has the TFT in landscape
|
||||
#elif defined(T_WATCH_S3)
|
||||
|
@ -49,7 +49,7 @@ CannedMessageModule::CannedMessageModule()
|
||||
LOG_INFO("CannedMessageModule is enabled\n");
|
||||
|
||||
// T-Watch interface currently has no way to select destination type, so default to 'node'
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE;
|
||||
#endif
|
||||
|
||||
@ -75,7 +75,7 @@ int CannedMessageModule::splitConfiguredMessages()
|
||||
|
||||
String messages = cannedMessageModuleConfig.messages;
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
String separator = messages.length() ? "|" : "";
|
||||
|
||||
messages = "[---- Free Text ----]" + separator + messages;
|
||||
@ -144,7 +144,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
}
|
||||
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT)) {
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
if (this->currentMessageIndex == 0) {
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
||||
|
||||
@ -170,7 +170,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
e.frameChanged = true;
|
||||
this->currentMessageIndex = -1;
|
||||
|
||||
#ifndef T_WATCH_S3
|
||||
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
||||
this->freetext = ""; // clear freetext
|
||||
this->cursor = 0;
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||
@ -183,7 +183,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
(event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) ||
|
||||
(event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT))) {
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) {
|
||||
this->payload = 0xb4;
|
||||
} else if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT)) {
|
||||
@ -283,7 +283,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
|
||||
String keyTapped = keyForCoordinates(event->touchX, event->touchY);
|
||||
|
||||
@ -404,7 +404,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
this->freetext = ""; // clear freetext
|
||||
this->cursor = 0;
|
||||
|
||||
#ifndef T_WATCH_S3
|
||||
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||
#endif
|
||||
|
||||
@ -417,7 +417,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
this->freetext = ""; // clear freetext
|
||||
this->cursor = 0;
|
||||
|
||||
#ifndef T_WATCH_S3
|
||||
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||
#endif
|
||||
|
||||
@ -437,7 +437,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
return INT32_MAX;
|
||||
} else {
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
sendText(this->dest, indexChannels[this->channel], this->messages[this->currentMessageIndex], true);
|
||||
#else
|
||||
sendText(NODENUM_BROADCAST, channels.getPrimaryIndex(), this->messages[this->currentMessageIndex], true);
|
||||
@ -454,7 +454,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
this->freetext = ""; // clear freetext
|
||||
this->cursor = 0;
|
||||
|
||||
#ifndef T_WATCH_S3
|
||||
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||
#endif
|
||||
|
||||
@ -471,7 +471,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
this->freetext = ""; // clear freetext
|
||||
this->cursor = 0;
|
||||
|
||||
#ifndef T_WATCH_S3
|
||||
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||
#endif
|
||||
|
||||
@ -484,7 +484,7 @@ int32_t CannedMessageModule::runOnce()
|
||||
this->freetext = ""; // clear freetext
|
||||
this->cursor = 0;
|
||||
|
||||
#ifndef T_WATCH_S3
|
||||
#if !defined(T_WATCH_S3) && !defined(RAK14014)
|
||||
this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE;
|
||||
#endif
|
||||
|
||||
@ -714,7 +714,7 @@ void CannedMessageModule::showTemporaryMessage(const String &message)
|
||||
setIntervalFromNow(2000);
|
||||
}
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
|
||||
String CannedMessageModule::keyForCoordinates(uint x, uint y)
|
||||
{
|
||||
@ -949,7 +949,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
||||
display->drawString(10 + x, 0 + y + FONT_HEIGHT_SMALL, "Canned Message\nModule disabled.");
|
||||
} else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
drawKeyboard(display, state, 0, 0);
|
||||
#else
|
||||
|
||||
|
@ -98,7 +98,7 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
|
||||
int getNextIndex();
|
||||
int getPrevIndex();
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
void drawKeyboard(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||
String keyForCoordinates(uint x, uint y);
|
||||
bool shift = false;
|
||||
@ -150,7 +150,7 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
|
||||
unsigned long lastTouchMillis = 0;
|
||||
String temporaryMessage;
|
||||
|
||||
#ifdef T_WATCH_S3
|
||||
#if defined(T_WATCH_S3) || defined(RAK14014)
|
||||
Letter keyboard[2][4][10] = {{{{"Q", 20, 0, 0, 0, 0},
|
||||
{"W", 22, 0, 0, 0, 0},
|
||||
{"E", 17, 0, 0, 0, 0},
|
||||
|
@ -17,6 +17,8 @@ lib_deps =
|
||||
https://github.com/RAKWireless/RAK13800-W5100S.git#1.0.2
|
||||
rakwireless/RAKwireless NCP5623 RGB LED library@^1.0.2
|
||||
bodmer/TFT_eSPI
|
||||
beegee-tokyo/RAKwireless RAK12034@^1.0.0
|
||||
beegee-tokyo/RAK14014-FT6336U @ 1.0.1
|
||||
debug_tool = jlink
|
||||
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
|
||||
;upload_protocol = jlink
|
@ -307,10 +307,10 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
|
||||
#define SCREEN_ROTATE
|
||||
#define SCREEN_TRANSITION_FRAMERATE 5
|
||||
|
||||
#define HAS_TOUCHSCREEN 0
|
||||
#define SCREEN_TOUCH_INT 10 // From tp.h on the tracker open source code.
|
||||
#define TOUCH_I2C_PORT 0
|
||||
#define TOUCH_SLAVE_ADDRESS 0x5D // GT911
|
||||
#define HAS_TOUCHSCREEN 1
|
||||
#define SCREEN_TOUCH_INT WB_IO6
|
||||
|
||||
#define CANNED_MESSAGE_MODULE_ENABLE 1
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Arduino objects - C++ only
|
||||
|
Loading…
Reference in New Issue
Block a user