added FT6206 flip

This commit is contained in:
2021-08-30 13:49:46 +02:00
parent ddc6f271e8
commit eddaa9003a
4 changed files with 25 additions and 7 deletions

View File

@@ -17,9 +17,13 @@ FT6206::FT6206() { touches = 0; }
@returns True if an FT6206 is found, false on any failure @returns True if an FT6206 is found, false on any failure
*/ */
/**************************************************************************/ /**************************************************************************/
bool FT6206::begin(uint8_t thresh) { // bool begin(uint8_t thresh = FT62XX_DEFAULT_THRESHOLD, uint16_t width, uint16_t height, bool flip );
Wire.begin();
bool FT6206::begin(uint16_t width, uint16_t height, bool flip, uint8_t thresh) {
Wire.begin();
_width = width;
_height = height;
_flip = flip;
#ifdef FT6206_DEBUG #ifdef FT6206_DEBUG
Serial.print("Vend ID: 0x"); Serial.print("Vend ID: 0x");
Serial.println(readRegister8(FT62XX_REG_VENDID), HEX); Serial.println(readRegister8(FT62XX_REG_VENDID), HEX);
@@ -86,7 +90,14 @@ TS_Point FT6206::getPoint(uint8_t n) {
if ((touches == 0) || (n > 1)) { if ((touches == 0) || (n > 1)) {
return TS_Point(0, 0, 0); return TS_Point(0, 0, 0);
} else { } else {
return TS_Point(touchX[n], touchY[n], 1); if(_flip)
{
return TS_Point(_width - touchX[n], _height - touchY[n], 1);
}
else
{
return TS_Point(touchX[n], touchY[n], 1);
}
} }
} }

View File

@@ -56,13 +56,15 @@ public:
class FT6206 { class FT6206 {
public: public:
FT6206(void); FT6206(void);
bool begin(uint8_t thresh = FT62XX_DEFAULT_THRESHOLD); bool begin(uint16_t width, uint16_t height, bool flip = false, uint8_t thresh = FT62XX_DEFAULT_THRESHOLD);
uint8_t touched(void); uint8_t touched(void);
TS_Point getPoint(uint8_t n = 0); TS_Point getPoint(uint8_t n = 0);
// void autoCalibrate(void); // void autoCalibrate(void);
private: private:
uint16_t _width, _height;
bool _flip;
void writeRegister8(uint8_t reg, uint8_t val); void writeRegister8(uint8_t reg, uint8_t val);
uint8_t readRegister8(uint8_t reg); uint8_t readRegister8(uint8_t reg);

View File

@@ -268,6 +268,7 @@ void prepButtons(void)
} }
} }
#if defined(TOUCH_CS)
void touch_calibrate() void touch_calibrate()
{ {
uint16_t calData[5]; uint16_t calData[5];
@@ -300,6 +301,7 @@ void touch_calibrate()
while (1) while (1)
; ;
} }
#endif
void updateGUIButtons(void) void updateGUIButtons(void)
{ {
@@ -355,8 +357,8 @@ void updateGUIButtons(void)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void initTouchScreen(void) void initTouchScreen(void)
{ {
ts.begin(); //ts.begin();
if (!ts.begin(40)) if (!ts.begin(tft.width(), tft.height(), true, 40))
{ {
Serial.println("Unable to start touchscreen."); Serial.println("Unable to start touchscreen.");
} }
@@ -370,12 +372,14 @@ void initLCD(void)
{ {
tft.init(); tft.init();
tft.setRotation(2); tft.setRotation(TFT_ROTATION);
tft.setTextFont(2); tft.setTextFont(2);
tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
tft.invertDisplay(false); tft.invertDisplay(false);
#if defined(TOUCH_CS)
//touch_calibrate(); //touch_calibrate();
tft.setTouch(calData); tft.setTouch(calData);
#endif
initTouchScreen(); initTouchScreen();

View File

@@ -6,6 +6,7 @@
#define TFT_WIDTH 240 #define TFT_WIDTH 240
#define TFT_HEIGT 320 #define TFT_HEIGT 320
#define TFT_DEFAULT_R 4 #define TFT_DEFAULT_R 4
#define TFT_ROTATION 0 //2 = upsidedown
#define LCD_INTERVAL 100 #define LCD_INTERVAL 100