Fixed XPT2046 syntax and using unPhone library to clean up support (#3631)

* Fixed XPT2046 syntax and using unPhone library to clean up main and TFTDisplay.

* strange extra edits removed wtf
This commit is contained in:
Gareth Coleman
2024-04-16 13:29:08 +01:00
committed by GitHub
parent 7d3175dc83
commit 3413b9da41
5 changed files with 57 additions and 41 deletions

View File

@@ -411,8 +411,7 @@ class LGFX : public lgfx::LGFX_Device
lgfx::Panel_HX8357D _panel_instance;
lgfx::Bus_SPI _bus_instance;
#if defined(USE_XPT2046)
lgfx::ITouch *_touch_instance;
// lgfx::Touch_XPT2046 _touch_instance;
lgfx::Touch_XPT2046 _touch_instance;
#endif
public:
@@ -466,8 +465,7 @@ class LGFX : public lgfx::LGFX_Device
#if defined(USE_XPT2046)
{
// Configure settings for touch control.
_touch_instance = new lgfx::Touch_XPT2046;
auto touch_cfg = _touch_instance->config();
auto touch_cfg = _touch_instance.config();
touch_cfg.pin_cs = TOUCH_CS;
touch_cfg.x_min = 0;
@@ -478,8 +476,8 @@ class LGFX : public lgfx::LGFX_Device
touch_cfg.bus_shared = true;
touch_cfg.offset_rotation = 1;
_touch_instance->config(touch_cfg);
//_panel_instance->setTouch(_touch_instance);
_touch_instance.config(touch_cfg);
_panel_instance.setTouch(&_touch_instance);
}
#endif
setPanel(&_panel_instance);
@@ -496,6 +494,11 @@ static LGFX *tft = nullptr;
#include "TFTDisplay.h"
#include <SPI.h>
#ifdef UNPHONE
#include "unPhone.h"
extern unPhone unphone;
#endif
TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus)
{
LOG_DEBUG("TFTDisplay!\n");
@@ -576,11 +579,7 @@ void TFTDisplay::sendCommand(uint8_t com)
digitalWrite(VTFT_CTRL, LOW);
#endif
#ifdef UNPHONE
Wire.beginTransmission(0x26);
Wire.write(0x02);
Wire.write(0x04); // Backlight on
Wire.write(0x22); // G&B LEDs off
Wire.endTransmission();
unphone.backlight(true); // using unPhone library
#endif
#ifdef RAK14014
#elif !defined(M5STACK)
@@ -612,11 +611,7 @@ void TFTDisplay::sendCommand(uint8_t com)
digitalWrite(VTFT_CTRL, HIGH);
#endif
#ifdef UNPHONE
Wire.beginTransmission(0x26);
Wire.write(0x02);
Wire.write(0x00); // Backlight off
Wire.write(0x22); // G&B LEDs off
Wire.endTransmission();
unphone.backlight(false); // using unPhone library
#endif
#ifdef RAK14014
#elif !defined(M5STACK)
@@ -690,11 +685,7 @@ bool TFTDisplay::connect()
digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON);
#endif
#ifdef UNPHONE
Wire.beginTransmission(0x26);
Wire.write(0x02);
Wire.write(0x04); // Backlight on
Wire.write(0x22); // G&B LEDs off
Wire.endTransmission();
unphone.backlight(true); // using unPhone library
LOG_INFO("Power to TFT Backlight\n");
#endif