mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 14:42:05 +00:00
further testing
This commit is contained in:
parent
cb14fc3b9d
commit
0f1e528b20
@ -39,6 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "graphics/ScreenFonts.h"
|
#include "graphics/ScreenFonts.h"
|
||||||
#include "graphics/images.h"
|
#include "graphics/images.h"
|
||||||
#include "input/ScanAndSelect.h"
|
#include "input/ScanAndSelect.h"
|
||||||
|
#include "input/TouchScreenCST226SE.h"
|
||||||
#include "input/TouchScreenImpl1.h"
|
#include "input/TouchScreenImpl1.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
@ -1823,10 +1824,13 @@ void Screen::setup()
|
|||||||
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast<TFTDisplay *>(dispdev)->getTouch);
|
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast<TFTDisplay *>(dispdev)->getTouch);
|
||||||
touchScreenImpl1->init();
|
touchScreenImpl1->init();
|
||||||
}
|
}
|
||||||
#elif HAS_TOUCHSCREEN
|
#elif HAS_TOUCHSCREEN && !HAS_CST226SE
|
||||||
touchScreenImpl1 =
|
touchScreenImpl1 =
|
||||||
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast<TFTDisplay *>(dispdev)->getTouch);
|
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast<TFTDisplay *>(dispdev)->getTouch);
|
||||||
touchScreenImpl1->init();
|
touchScreenImpl1->init();
|
||||||
|
#elif HAS_TOUCHSCREEN && HAS_CST226SE
|
||||||
|
touchScreenCST226SE = new TouchScreenCST226SE(TFT_HEIGHT, TFT_WIDTH, TouchScreenCST226SE::forwardGetTouch);
|
||||||
|
touchScreenCST226SE->init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Subscribe to status updates
|
// Subscribe to status updates
|
||||||
|
@ -10,11 +10,13 @@
|
|||||||
|
|
||||||
volatile bool CST_IRQ = false;
|
volatile bool CST_IRQ = false;
|
||||||
|
|
||||||
|
TouchScreenCST226SE *TouchScreenCST226SE::instance = nullptr;
|
||||||
TouchScreenCST226SE *touchScreenCST226SE;
|
TouchScreenCST226SE *touchScreenCST226SE;
|
||||||
|
|
||||||
TouchScreenCST226SE::TouchScreenCST226SE(uint16_t width, uint16_t height, bool (*getTouch)(int16_t *, int16_t *))
|
TouchScreenCST226SE::TouchScreenCST226SE(uint16_t width, uint16_t height, bool (*getTouch)(int16_t *, int16_t *))
|
||||||
: TouchScreenBase("touchscreen1", width, height), _getTouch(getTouch)
|
: TouchScreenBase("touchscreen1", width, height), _getTouch(getTouch)
|
||||||
{
|
{
|
||||||
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchScreenCST226SE::init()
|
void TouchScreenCST226SE::init()
|
||||||
@ -23,11 +25,11 @@ void TouchScreenCST226SE::init()
|
|||||||
if (touch.begin(Wire, addr, I2C_SDA, I2C_SCL)) {
|
if (touch.begin(Wire, addr, I2C_SDA, I2C_SCL)) {
|
||||||
i2cAddress = addr;
|
i2cAddress = addr;
|
||||||
|
|
||||||
#ifdef TOUCHSCREEN_INT
|
// #ifdef TOUCHSCREEN_INT
|
||||||
pinMode(TOUCHSCREEN_INT, INPUT);
|
// pinMode(TOUCHSCREEN_INT, INPUT);
|
||||||
attachInterrupt(
|
// attachInterrupt(
|
||||||
TOUCHSCREEN_INT, [] { CST_IRQ = true; }, RISING);
|
// TOUCHSCREEN_INT, [] { CST_IRQ = true; }, RISING);
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
LOG_DEBUG("CST226SE init OK at address 0x%02X", addr);
|
LOG_DEBUG("CST226SE init OK at address 0x%02X", addr);
|
||||||
return;
|
return;
|
||||||
@ -53,6 +55,16 @@ bool TouchScreenCST226SE::getTouch(int16_t &x, int16_t &y)
|
|||||||
return false;
|
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)
|
void TouchScreenCST226SE::onEvent(const TouchEvent &event)
|
||||||
{
|
{
|
||||||
InputEvent e;
|
InputEvent e;
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#ifdef HAS_CST226SE
|
#ifdef HAS_CST226SE
|
||||||
|
|
||||||
|
#include "modules/CannedMessageModule.h"
|
||||||
|
|
||||||
#include "TouchScreenBase.h"
|
#include "TouchScreenBase.h"
|
||||||
#include "touch/TouchClassCST226.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 *));
|
TouchScreenCST226SE(uint16_t width, uint16_t height, bool (*getTouch)(int16_t *, int16_t *));
|
||||||
void init(void);
|
void init(void);
|
||||||
|
|
||||||
|
static bool forwardGetTouch(int16_t *x, int16_t *y);
|
||||||
|
bool (*_getTouch)(int16_t *, int16_t *);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool getTouch(int16_t &x, int16_t &y);
|
virtual bool getTouch(int16_t &x, int16_t &y);
|
||||||
virtual void onEvent(const TouchEvent &event);
|
virtual void onEvent(const TouchEvent &event);
|
||||||
|
|
||||||
bool (*_getTouch)(int16_t *, int16_t *);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static TouchScreenCST226SE *instance;
|
||||||
TouchClassCST226 touch;
|
TouchClassCST226 touch;
|
||||||
uint8_t i2cAddress = 0;
|
uint8_t i2cAddress = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user