further testing

This commit is contained in:
nasimovy 2025-04-19 15:43:55 +00:00
parent cb14fc3b9d
commit 0f1e528b20
3 changed files with 28 additions and 8 deletions

View File

@ -39,6 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "graphics/ScreenFonts.h"
#include "graphics/images.h"
#include "input/ScanAndSelect.h"
#include "input/TouchScreenCST226SE.h"
#include "input/TouchScreenImpl1.h"
#include "main.h"
#include "mesh-pb-constants.h"
@ -1823,10 +1824,13 @@ void Screen::setup()
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast<TFTDisplay *>(dispdev)->getTouch);
touchScreenImpl1->init();
}
#elif HAS_TOUCHSCREEN
#elif HAS_TOUCHSCREEN && !HAS_CST226SE
touchScreenImpl1 =
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast<TFTDisplay *>(dispdev)->getTouch);
touchScreenImpl1->init();
#elif HAS_TOUCHSCREEN && HAS_CST226SE
touchScreenCST226SE = new TouchScreenCST226SE(TFT_HEIGHT, TFT_WIDTH, TouchScreenCST226SE::forwardGetTouch);
touchScreenCST226SE->init();
#endif
// Subscribe to status updates

View File

@ -10,11 +10,13 @@
volatile bool CST_IRQ = false;
TouchScreenCST226SE *TouchScreenCST226SE::instance = nullptr;
TouchScreenCST226SE *touchScreenCST226SE;
TouchScreenCST226SE::TouchScreenCST226SE(uint16_t width, uint16_t height, bool (*getTouch)(int16_t *, int16_t *))
: TouchScreenBase("touchscreen1", width, height), _getTouch(getTouch)
{
instance = this;
}
void TouchScreenCST226SE::init()
@ -23,11 +25,11 @@ void TouchScreenCST226SE::init()
if (touch.begin(Wire, addr, I2C_SDA, I2C_SCL)) {
i2cAddress = addr;
#ifdef TOUCHSCREEN_INT
pinMode(TOUCHSCREEN_INT, INPUT);
attachInterrupt(
TOUCHSCREEN_INT, [] { CST_IRQ = true; }, RISING);
#endif
// #ifdef TOUCHSCREEN_INT
// pinMode(TOUCHSCREEN_INT, INPUT);
// attachInterrupt(
// TOUCHSCREEN_INT, [] { CST_IRQ = true; }, RISING);
// #endif
LOG_DEBUG("CST226SE init OK at address 0x%02X", addr);
return;
@ -53,6 +55,16 @@ bool TouchScreenCST226SE::getTouch(int16_t &x, int16_t &y)
return false;
}
bool TouchScreenCST226SE::forwardGetTouch(int16_t *x, int16_t *y)
{
if (instance) {
return instance->getTouch(*x, *y);
LOG_DEBUG("TouchScreen touched %dx %dy", x, y);
}
return false;
}
void TouchScreenCST226SE::onEvent(const TouchEvent &event)
{
InputEvent e;

View File

@ -4,6 +4,8 @@
#ifdef HAS_CST226SE
#include "modules/CannedMessageModule.h"
#include "TouchScreenBase.h"
#include "touch/TouchClassCST226.h"
@ -13,13 +15,15 @@ class TouchScreenCST226SE : public TouchScreenBase
TouchScreenCST226SE(uint16_t width, uint16_t height, bool (*getTouch)(int16_t *, int16_t *));
void init(void);
static bool forwardGetTouch(int16_t *x, int16_t *y);
bool (*_getTouch)(int16_t *, int16_t *);
protected:
virtual bool getTouch(int16_t &x, int16_t &y);
virtual void onEvent(const TouchEvent &event);
bool (*_getTouch)(int16_t *, int16_t *);
private:
static TouchScreenCST226SE *instance;
TouchClassCST226 touch;
uint8_t i2cAddress = 0;