Update lovyan driver #220 #390

This commit is contained in:
fvanroie 2022-10-22 01:05:06 +02:00
parent 8454b137ac
commit a664e5379e
2 changed files with 287 additions and 158 deletions

View File

@ -11,7 +11,7 @@ void tftPinInfo(const __FlashStringHelper* pinfunction, int8_t pin)
{ {
if(pin != -1) { if(pin != -1) {
char buffer[64]; char buffer[64];
snprintf_P(buffer, sizeof(buffer), PSTR("%-11s: %s (GPIO %02d)"), String(pinfunction).c_str(), snprintf_P(buffer, sizeof(buffer), PSTR("%-12s: %s (GPIO %02d)"), String(pinfunction).c_str(),
haspDevice.gpio_name(pin).c_str(), pin); haspDevice.gpio_name(pin).c_str(), pin);
LOG_VERBOSE(TAG_TFT, buffer); LOG_VERBOSE(TAG_TFT, buffer);
} }
@ -54,7 +54,8 @@ static lgfx::Bus_Parallel16* init_parallel_16_bus(Preferences* prefs, int8_t dat
cfg.pin_wr = prefs->getInt("wr", TFT_WR); cfg.pin_wr = prefs->getInt("wr", TFT_WR);
cfg.pin_rs = prefs->getInt("rs", TFT_DC); cfg.pin_rs = prefs->getInt("rs", TFT_DC);
cfg.freq_write = prefs->getUInt("write_freq", SPI_FREQUENCY); cfg.freq_write = prefs->getUInt("write_freq", SPI_FREQUENCY);
uint8_t port = prefs->getUInt("i2s_port", 0); #if !defined(CONFIG_IDF_TARGET_ESP32S3)
uint8_t port = prefs->getUInt("i2s_port", 0);
switch(port) { switch(port) {
#if SOC_I2S_NUM > 1 #if SOC_I2S_NUM > 1
case 1: case 1:
@ -64,6 +65,7 @@ static lgfx::Bus_Parallel16* init_parallel_16_bus(Preferences* prefs, int8_t dat
default: default:
cfg.i2s_port = I2S_NUM_0; cfg.i2s_port = I2S_NUM_0;
} }
#endif
for(uint8_t i = 0; i < num; i++) { for(uint8_t i = 0; i < num; i++) {
cfg.pin_data[i] = data_pins[i]; cfg.pin_data[i] = data_pins[i];
} }
@ -81,7 +83,8 @@ static lgfx::Bus_Parallel8* init_parallel_8_bus(Preferences* prefs, int8_t data_
cfg.pin_wr = prefs->getInt("wr", TFT_WR); cfg.pin_wr = prefs->getInt("wr", TFT_WR);
cfg.pin_rs = prefs->getInt("rs", TFT_DC); cfg.pin_rs = prefs->getInt("rs", TFT_DC);
cfg.freq_write = prefs->getUInt("write_freq", SPI_FREQUENCY); cfg.freq_write = prefs->getUInt("write_freq", SPI_FREQUENCY);
uint8_t port = prefs->getUInt("i2s_port", 0); #if !defined(CONFIG_IDF_TARGET_ESP32S3)
uint8_t port = prefs->getUInt("i2s_port", 0);
switch(port) { switch(port) {
#if SOC_I2S_NUM > 1 #if SOC_I2S_NUM > 1
case 1: case 1:
@ -91,6 +94,7 @@ static lgfx::Bus_Parallel8* init_parallel_8_bus(Preferences* prefs, int8_t data_
default: default:
cfg.i2s_port = I2S_NUM_0; cfg.i2s_port = I2S_NUM_0;
} }
#endif
for(uint8_t i = 0; i < num; i++) { for(uint8_t i = 0; i < num; i++) {
cfg.pin_data[i] = data_pins[i]; cfg.pin_data[i] = data_pins[i];
} }
@ -195,12 +199,12 @@ static void configure_panel(lgfx::Panel_Device* panel, Preferences* prefs)
prefs->getUInt("dummy_read_bits", 1); // bits of dummy read before reading data other than pixels prefs->getUInt("dummy_read_bits", 1); // bits of dummy read before reading data other than pixels
cfg.readable = prefs->getBool("readable", false); // true if data can be read cfg.readable = prefs->getBool("readable", false); // true if data can be read
// #ifdef INVERT_COLORS // This is configurable un Web UI #ifdef INVERT_COLORS // This is configurable un Web UI
// cfg.invert = cfg.invert =
// prefs->getBool("invert", INVERT_COLORS != 0); // true if the light and darkness of the panel is reversed prefs->getBool("invert", INVERT_COLORS != 0); // true if the light and darkness of the panel is reversed
// #else #else
cfg.invert = prefs->getBool("invert", false); // true if the light and darkness of the panel is reversed cfg.invert = prefs->getBool("invert", false); // true if the light and darkness of the panel is reversed
// #endif #endif
#ifdef TFT_RGB_ORDER #ifdef TFT_RGB_ORDER
cfg.rgb_order = cfg.rgb_order =
prefs->getBool("rgb_order", TFT_RGB_ORDER != 0); // true if the red and blue of the panel are swapped prefs->getBool("rgb_order", TFT_RGB_ORDER != 0); // true if the red and blue of the panel are swapped
@ -309,7 +313,42 @@ lgfx::ITouch* _init_touch(Preferences* preferences)
// break; // break;
// } // }
#if 0 && TOUCH_DRIVER == 0x6336 #if defined(HASP_USE_LGFX_TOUCH)
#if TOUCH_DRIVER == 0x0911
{ // タッチスクリーン制御の設定を行います。(必要なければ削除)
auto touch = new lgfx::Touch_GT911();
auto cfg = touch->config();
cfg.x_min = 0; // タッチスクリーンから得られる最小のX値(生の値)
cfg.x_max = TFT_WIDTH - 1; // タッチスクリーンから得られる最大のX値(生の値)
cfg.y_min = 0; // タッチスクリーンから得られる最小のY値(生の値)
cfg.y_max = TFT_HEIGHT - 1; // タッチスクリーンから得られる最大のY値(生の値)
cfg.bus_shared = false; // 画面と共通のバスを使用している場合 trueを設定
cfg.offset_rotation = TOUCH_OFFSET_ROTATION; // 表示とタッチの向きのが一致しない場合の調整 0~7の値で設定
// SPI接続の場合
// cfg.spi_host = VSPI_HOST; // 使用するSPIを選択 (HSPI_HOST or VSPI_HOST)
// cfg.freq = 1000000; // SPIクロックを設定
// cfg.pin_sclk = 18; // SCLKが接続されているピン番号
// cfg.pin_mosi = 23; // MOSIが接続されているピン番号
// cfg.pin_miso = 19; // MISOが接続されているピン番号
// cfg.pin_cs = 5; // CSが接続されているピン番号
// I2C接続の場合
cfg.i2c_port = I2C_TOUCH_PORT; // 使用するI2Cを選択 (0 or 1)
cfg.i2c_addr = I2C_TOUCH_ADDRESS; // I2Cデバイスアドレス番号
cfg.pin_sda = TOUCH_SDA; // SDAが接続されているピン番号
cfg.pin_scl = TOUCH_SCL; // SCLが接続されているピン番号
cfg.pin_int = -1; // INTが接続されているピン番号
cfg.freq = I2C_TOUCH_FREQUENCY; // I2Cクロックを設定
touch->config(cfg);
return touch;
}
#endif
#if TOUCH_DRIVER == 0x6336
{ // タッチスクリーン制御の設定を行います。(必要なければ削除) { // タッチスクリーン制御の設定を行います。(必要なければ削除)
auto touch = new lgfx::Touch_FT5x06(); auto touch = new lgfx::Touch_FT5x06();
auto cfg = touch->config(); auto cfg = touch->config();
@ -342,6 +381,31 @@ lgfx::ITouch* _init_touch(Preferences* preferences)
} }
#endif #endif
#if TOUCH_DRIVER == 0x2046
{ // タッチスクリーン制御の設定を行います。(必要なければ削除)
auto touch = new lgfx::Touch_XPT2046();
auto cfg = touch->config();
LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
cfg.bus_shared = true; // 画面と共通のバスを使用している場合 trueを設定
cfg.offset_rotation = 0; // 表示とタッチの向きのが一致しない場合の調整 0~7の値で設定
// SPI接続の場合
cfg.spi_host = VSPI_HOST; // 使用するSPIを選択 (HSPI_HOST or VSPI_HOST)
cfg.pin_sclk = 18; // SCLKが接続されているピン番号
cfg.pin_mosi = 23; // MOSIが接続されているピン番号
cfg.pin_miso = 19; // MISOが接続されているピン番号
cfg.pin_cs = 21; // CSが接続されているピン番号
cfg.pin_int = GPIO_NUM_NC; // INTが接続されているピン番号
touch->config(cfg);
return touch;
}
#endif
#endif // HASP_USE_LGFX_TOUCH
return nullptr; return nullptr;
} }
@ -349,23 +413,105 @@ void LovyanGfx::init(int w, int h)
{ {
LOG_TRACE(TAG_TFT, F(D_SERVICE_STARTING)); LOG_TRACE(TAG_TFT, F(D_SERVICE_STARTING));
#ifdef WTSC01PLUS
auto _panel_instance = new lgfx::Panel_ST7796();
auto _bus_instance = new lgfx::v1::Bus_Parallel8();
auto _touch_instance = new lgfx::Touch_FT5x06(); // FT5206, FT5306, FT5406, FT6206, FT6236, FT6336, FT6436
{ // バス制御の設定を行います。
auto cfg = _bus_instance->config(); // バス設定用の構造体を取得します。
// 8ビットパラレルバスの設定
// cfg.i2s_port = I2S_NUM_0; // 使用するI2Sポートを選択 (I2S_NUM_0 or I2S_NUM_1) (ESP32のI2S
// LCDモードを使用します)
cfg.freq_write = 20000000; // 送信クロック (最大20MHz, 80MHzを整数で割った値に丸められます)
cfg.pin_wr = 47; // WR を接続しているピン番号
cfg.pin_rd = -1; // RD を接続しているピン番号
cfg.pin_rs = 0; // RS(D/C)を接続しているピン番号
cfg.pin_d0 = 9; // D0を接続しているピン番号
cfg.pin_d1 = 46; // D1を接続しているピン番号
cfg.pin_d2 = 3; // D2を接続しているピン番号
cfg.pin_d3 = 8; // D3を接続しているピン番号
cfg.pin_d4 = 18; // D4を接続しているピン番号
cfg.pin_d5 = 17; // D5を接続しているピン番号
cfg.pin_d6 = 16; // D6を接続しているピン番号
cfg.pin_d7 = 15; // D7を接続しているピン番号
_bus_instance->config(cfg); // 設定値をバスに反映します。
_panel_instance->setBus(_bus_instance); // バスをパネルにセットします。
}
{ // 表示パネル制御の設定を行います。
auto cfg = _panel_instance->config(); // 表示パネル設定用の構造体を取得します。
cfg.pin_cs = -1; // CSが接続されているピン番号 (-1 = disable)
cfg.pin_rst = 4; // RSTが接続されているピン番号 (-1 = disable)
cfg.pin_busy = -1; // BUSYが接続されているピン番号 (-1 = disable)
// ※
// 以下の設定値はパネル毎に一般的な初期値が設定されていますので、不明な項目はコメントアウトして試してみてください。
cfg.panel_width = 320; // 実際に表示可能な幅
cfg.panel_height = 480; // 実際に表示可能な高さ
cfg.offset_x = 0; // パネルのX方向オフセット量
cfg.offset_y = 0; // パネルのY方向オフセット量
cfg.offset_rotation = 0; // 回転方向の値のオフセット 0~7 (4~7は上下反転)
cfg.dummy_read_pixel = 8; // ピクセル読出し前のダミーリードのビット数
cfg.dummy_read_bits = 1; // ピクセル以外のデータ読出し前のダミーリードのビット数
cfg.readable = true; // データ読出しが可能な場合 trueに設定
cfg.invert = true; // パネルの明暗が反転してしまう場合 trueに設定
cfg.rgb_order = false; // パネルの赤と青が入れ替わってしまう場合 trueに設定
cfg.dlen_16bit = false; // 16bitパラレルやSPIでデータ長を16bit単位で送信するパネルの場合 trueに設定
cfg.bus_shared = true; // SDカードとバスを共有している場合 trueに設定(drawJpgFile等でバス制御を行います)
// 以下はST7735やILI9163のようにピクセル数が可変のドライバで表示がずれる場合にのみ設定してください。
// cfg.memory_width = 240; // ドライバICがサポートしている最大の幅
// cfg.memory_height = 320; // ドライバICがサポートしている最大の高さ
_panel_instance->config(cfg);
}
{ // タッチスクリーン制御の設定を行います。(必要なければ削除)
auto cfg = _touch_instance->config();
cfg.x_min = 0; // タッチスクリーンから得られる最小のX値(生の値)
cfg.x_max = 319; // タッチスクリーンから得られる最大のX値(生の値)
cfg.y_min = 0; // タッチスクリーンから得られる最小のY値(生の値)
cfg.y_max = 479; // タッチスクリーンから得られる最大のY値(生の値)
cfg.pin_int = 7; // INTが接続されているピン番号
cfg.bus_shared = true; // 画面と共通のバスを使用している場合 trueを設定
cfg.offset_rotation = 0; // 表示とタッチの向きのが一致しない場合の調整 0~7の値で設定
// I2C接続の場合
cfg.i2c_port = 1; // 使用するI2Cを選択 (0 or 1)
cfg.i2c_addr = 0x38; // I2Cデバイスアドレス番号
cfg.pin_sda = 6; // SDAが接続されているピン番号
cfg.pin_scl = 5; // SCLが接続されているピン番号
cfg.freq = 400000; // I2Cクロックを設定
_touch_instance->config(cfg);
_panel_instance->setTouch(_touch_instance); // タッチスクリーンをパネルにセットします。
}
#else
Preferences preferences; Preferences preferences;
preferences.begin("tft", false); preferences.begin("tft", false);
lgfx::IBus* bus = _init_bus(&preferences); lgfx::IBus* _bus_instance = _init_bus(&preferences);
this->tft_driver = preferences.getUInt("DRIVER", get_tft_driver()); this->tft_driver = preferences.getUInt("DRIVER", get_tft_driver());
lgfx::Panel_Device* panel = _init_panel(bus); lgfx::Panel_Device* _panel_instance = _init_panel(_bus_instance);
if(panel != nullptr) { if(_panel_instance != nullptr) {
panel->setBus(bus); _panel_instance->setBus(_bus_instance);
configure_panel(panel, &preferences); configure_panel(_panel_instance, &preferences);
} }
lgfx::ITouch* touch = _init_touch(&preferences); lgfx::ITouch* touch = _init_touch(&preferences);
if(touch != nullptr) { #endif
panel->setTouch(touch);
}
tft.setPanel(panel); tft.setPanel(_panel_instance);
lgfx::v1::ITouch* touch = _panel_instance->getTouch();
if(touch) {
LOG_INFO(TAG_TFT, F("Touch " D_SERVICE_STARTED));
} else {
LOG_WARNING(TAG_TFT, F("Touch " D_SERVICE_START_FAILED));
}
/* TFT init */ /* TFT init */
LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
@ -379,71 +525,99 @@ void LovyanGfx::show_info()
{ {
splashscreen(); splashscreen();
LOG_VERBOSE(TAG_TFT, F("LovyanGFX : v%d.%d.%d"), LGFX_VERSION_MAJOR, LGFX_VERSION_MINOR, LGFX_VERSION_PATCH); LOG_VERBOSE(TAG_TFT, F("LovyanGFX : v%d.%d.%d"), LGFX_VERSION_MAJOR, LGFX_VERSION_MINOR, LGFX_VERSION_PATCH);
auto panel = tft.getPanel();
if(!panel) return;
#ifdef ESP32_PARALLEL if(!panel->getBus()) return;
{ lgfx::v1::bus_type_t bus_type = panel->getBus()->busType();
// LOG_VERBOSE(TAG_TFT, F("Interface : Parallel"));
// auto bus = _bus_instance;
// auto cfg = bus->config(); // Get the structure for bus configuration.
// tftPinInfo(F("TFT_WR"), cfg.pin_wr);
// tftPinInfo(F("TFT_RD"), cfg.pin_rd);
// tftPinInfo(F("TFT_RS"), cfg.pin_rs);
// tftPinInfo(F("TFT_D0"), cfg.pin_d0); if(bus_type == lgfx::v1::bus_parallel8) {
// tftPinInfo(F("TFT_D1"), cfg.pin_d1); LOG_VERBOSE(TAG_TFT, F("Interface : Parallel 8bit"));
// tftPinInfo(F("TFT_D2"), cfg.pin_d2); auto bus = (lgfx::Bus_Parallel8*)panel->getBus();
// tftPinInfo(F("TFT_D3"), cfg.pin_d3); auto cfg = bus->config(); // Get the structure for bus configuration.
// tftPinInfo(F("TFT_D4"), cfg.pin_d4); tftPinInfo(F("TFT_WR"), cfg.pin_wr);
// tftPinInfo(F("TFT_D5"), cfg.pin_d5); tftPinInfo(F("TFT_RD"), cfg.pin_rd);
// tftPinInfo(F("TFT_D6"), cfg.pin_d6); tftPinInfo(F("TFT_RS"), cfg.pin_rs);
// tftPinInfo(F("TFT_D7"), cfg.pin_d7);
tftPinInfo(F("TFT_D0"), cfg.pin_d0);
tftPinInfo(F("TFT_D1"), cfg.pin_d1);
tftPinInfo(F("TFT_D2"), cfg.pin_d2);
tftPinInfo(F("TFT_D3"), cfg.pin_d3);
tftPinInfo(F("TFT_D4"), cfg.pin_d4);
tftPinInfo(F("TFT_D5"), cfg.pin_d5);
tftPinInfo(F("TFT_D6"), cfg.pin_d6);
tftPinInfo(F("TFT_D7"), cfg.pin_d7);
} }
#else
{ if(bus_type == lgfx::v1::bus_parallel16) {
LOG_VERBOSE(TAG_TFT, F("Interface : Serial")); LOG_VERBOSE(TAG_TFT, F("Interface : Parallel 16bit"));
auto panel = tft.getPanel(); auto bus = (lgfx::v1::Bus_Parallel16*)panel->getBus();
auto cfg = bus->config(); // Get the structure for bus configuration.
tftPinInfo(F("TFT_WR"), cfg.pin_wr);
tftPinInfo(F("TFT_RD"), cfg.pin_rd);
tftPinInfo(F("TFT_RS"), cfg.pin_rs);
tftPinInfo(F("TFT_D0"), cfg.pin_d0);
tftPinInfo(F("TFT_D1"), cfg.pin_d1);
tftPinInfo(F("TFT_D2"), cfg.pin_d2);
tftPinInfo(F("TFT_D3"), cfg.pin_d3);
tftPinInfo(F("TFT_D4"), cfg.pin_d4);
tftPinInfo(F("TFT_D5"), cfg.pin_d5);
tftPinInfo(F("TFT_D6"), cfg.pin_d6);
tftPinInfo(F("TFT_D7"), cfg.pin_d7);
tftPinInfo(F("TFT_D1"), cfg.pin_d8);
tftPinInfo(F("TFT_D1"), cfg.pin_d9);
tftPinInfo(F("TFT_D1"), cfg.pin_d10);
tftPinInfo(F("TFT_D1"), cfg.pin_d11);
tftPinInfo(F("TFT_D1"), cfg.pin_d12);
tftPinInfo(F("TFT_D1"), cfg.pin_d13);
tftPinInfo(F("TFT_D1"), cfg.pin_d14);
tftPinInfo(F("TFT_D1"), cfg.pin_d15);
}
if(bus_type == lgfx::v1::bus_spi) {
LOG_VERBOSE(TAG_TFT, F("Interface : Serial"));
auto bus = (lgfx::Bus_SPI*)panel->getBus(); auto bus = (lgfx::Bus_SPI*)panel->getBus();
auto cfg = bus->config(); // Get the structure for bus configuration. auto cfg = bus->config(); // Get the structure for bus configuration.
tftPinInfo(F("MOSI"), cfg.pin_mosi); tftPinInfo(F("TFT_MOSI"), cfg.pin_mosi);
tftPinInfo(F("MISO"), cfg.pin_miso); tftPinInfo(F("TFT_MISO"), cfg.pin_miso);
tftPinInfo(F("SCLK"), cfg.pin_sclk); tftPinInfo(F("TFT_SCLK"), cfg.pin_sclk);
tftPinInfo(F("TFT_DC"), cfg.pin_dc); tftPinInfo(F("TFT_DC"), cfg.pin_dc);
} }
#endif
{ {
auto panel = tft.getPanel(); auto cfg = panel->config(); // Get the structure for panel configuration.
auto cfg = panel->config(); // Get the structure for panel configuration.
tftPinInfo(F("TFT_CS"), cfg.pin_cs); tftPinInfo(F("TFT_CS"), cfg.pin_cs);
tftPinInfo(F("TFT_RST"), cfg.pin_rst); tftPinInfo(F("TFT_RST"), cfg.pin_rst);
tftPinInfo(F("TFT_BUSY"), cfg.pin_busy);
} }
#ifndef ESP32_PARALLEL if(bus_type == lgfx::v1::bus_spi) {
{
auto panel = tft.getPanel();
auto bus = (lgfx::Bus_SPI*)panel->getBus(); auto bus = (lgfx::Bus_SPI*)panel->getBus();
auto cfg = bus->config(); // Get the structure for bus configuration. auto cfg = bus->config(); // Get the structure for bus configuration.
uint32_t freq = cfg.freq_write / 100000; uint32_t freq = cfg.freq_write / 100000;
LOG_VERBOSE(TAG_TFT, F("Display SPI freq. : %d.%d MHz"), freq / 10, freq % 10); LOG_VERBOSE(TAG_TFT, F("TFT SPI freq: %d.%d MHz"), freq / 10, freq % 10);
} }
#endif
{ lgfx::v1::ITouch* touch = panel->getTouch();
// auto cfg = tft._touch_instance->config(); // Get the structure for bus configuration. if(touch) {
// if(cfg.pin_cs != -1) { auto cfg = touch->config(); // Get the structure for bus configuration.
// tftPinInfo(F("TOUCH_CS"), cfg.pin_cs); uint32_t freq = cfg.freq / 100000;
// uint32_t freq = cfg.freq / 100000; tftPinInfo(F("TOUCH_INT"), cfg.pin_int);
// LOG_VERBOSE(TAG_TFT, F("Touch SPI freq. : %d.%d MHz"), freq / 10, freq % 10); tftPinInfo(F("TOUCH_RST"), cfg.pin_rst);
// } if(touch->isSPI()) {
// if(cfg.pin_sda != -1) { tftPinInfo(F("TOUCH_MISO"), cfg.pin_miso);
// tftPinInfo(F("TOUCH_SDA"), cfg.pin_sda); tftPinInfo(F("TOUCH_MOSI"), cfg.pin_mosi);
// } tftPinInfo(F("TOUCH_SCLK"), cfg.pin_sclk);
// if(cfg.pin_scl != -1) { tftPinInfo(F("TOUCH_CS"), cfg.pin_cs);
// tftPinInfo(F("TOUCH_SCL"), cfg.pin_scl); LOG_VERBOSE(TAG_TFT, F("Touch SPI freq. : %d.%d MHz"), freq / 10, freq % 10);
// uint32_t freq = cfg.freq / 100000; } else {
// LOG_VERBOSE(TAG_TFT, F("Touch I2C freq. : %d.%d MHz"), freq / 10, freq % 10); tftPinInfo(F("TOUCH_SDA"), cfg.pin_sda);
// } tftPinInfo(F("TOUCH_SCL"), cfg.pin_scl);
tftPinInfo(F("TOUCH_ADDR"), cfg.i2c_addr);
LOG_VERBOSE(TAG_TFT, F("Touch I2C freq. : %d.%d MHz"), freq / 10, freq % 10);
}
} }
} }
@ -458,11 +632,12 @@ void LovyanGfx::splashscreen()
int x = (tft.width() - logoWidth) / 2; int x = (tft.width() - logoWidth) / 2;
int y = (tft.height() - logoHeight) / 2; int y = (tft.height() - logoHeight) / 2;
tft.drawXBitmap(x, y, logoImage, logoWidth, logoHeight, fgColor.full); tft.drawXBitmap(x, y, logoImage, logoWidth, logoHeight, fgColor.full);
// tft.fillSmoothRoundRect(x, y, logoWidth, logoWidth, 15, fgColor.full);
} }
void LovyanGfx::set_rotation(uint8_t rotation) void LovyanGfx::set_rotation(uint8_t rotation)
{ {
LOG_VERBOSE(TAG_TFT, F("Rotation : %d"), rotation); LOG_VERBOSE(TAG_TFT, F("Rotation : %d"), rotation);
tft.setRotation(rotation); tft.setRotation(rotation);
} }
@ -471,7 +646,7 @@ void LovyanGfx::set_invert(bool invert)
char buffer[4]; char buffer[4];
memcpy_P(buffer, invert ? PSTR(D_YES) : PSTR(D_NO), sizeof(buffer)); memcpy_P(buffer, invert ? PSTR(D_YES) : PSTR(D_NO), sizeof(buffer));
LOG_VERBOSE(TAG_TFT, F("Invert Disp: %s"), buffer); LOG_VERBOSE(TAG_TFT, F("Invert Color: %s"), buffer);
tft.invertDisplay(invert); tft.invertDisplay(invert);
} }
@ -493,97 +668,51 @@ void IRAM_ATTR LovyanGfx::flush_pixels(lv_disp_drv_t* disp, const lv_area_t* are
bool LovyanGfx::is_driver_pin(uint8_t pin) bool LovyanGfx::is_driver_pin(uint8_t pin)
{ {
if(false // start condition is always needed auto panel = tft.getPanel();
if(panel && panel->getBus()) {
lgfx::v1::bus_type_t bus_type = panel->getBus()->busType();
// Use individual checks instead of switch statement, as some case labels could be duplicated if(bus_type == lgfx::v1::bus_parallel8) {
#ifdef TOUCH_CS auto bus = (lgfx::Bus_Parallel8*)panel->getBus();
|| (pin == TOUCH_CS) auto cfg = bus->config(); // Get the structure for bus configuration.
#endif if(pin == cfg.pin_wr || pin == cfg.pin_rd || pin == cfg.pin_rs || pin == cfg.pin_d0 || pin == cfg.pin_d1 ||
#ifdef TFT_MOSI pin == cfg.pin_d2 || pin == cfg.pin_d3 || pin == cfg.pin_d4 || pin == cfg.pin_d5 || pin == cfg.pin_d6 ||
|| (pin == TFT_MOSI) pin == cfg.pin_d7)
#endif return true;
#ifdef TFT_MISO
|| (pin == TFT_MISO) } else if(bus_type == lgfx::v1::bus_parallel16) {
#endif auto bus = (lgfx::v1::Bus_Parallel16*)panel->getBus();
#ifdef TFT_SCLK auto cfg = bus->config(); // Get the structure for bus configuration.
|| (pin == TFT_SCLK) if(cfg.pin_wr || pin == cfg.pin_rd || pin == cfg.pin_rs || pin == cfg.pin_d0 || pin == cfg.pin_d1 ||
#endif pin == cfg.pin_d2 || pin == cfg.pin_d3 || pin == cfg.pin_d4 || pin == cfg.pin_d5 || pin == cfg.pin_d6 ||
#ifdef TFT_CS pin == cfg.pin_d7 || pin == cfg.pin_d8 || pin == cfg.pin_d9 || pin == cfg.pin_d10 ||
|| (pin == TFT_CS) pin == cfg.pin_d11 || pin == cfg.pin_d12 || pin == cfg.pin_d13 || pin == cfg.pin_d14 ||
#endif pin == cfg.pin_d15)
#ifdef TFT_DC return true;
|| (pin == TFT_DC)
#endif } else if(bus_type == lgfx::v1::bus_spi) {
#ifdef TFT_BL auto bus = (lgfx::Bus_SPI*)panel->getBus();
|| (pin == TFT_BL) auto cfg = bus->config(); // Get the structure for bus configuration.
#endif if(pin == cfg.pin_mosi || pin == cfg.pin_miso || pin == cfg.pin_sclk || pin == cfg.pin_dc) return true;
#ifdef TFT_RST }
|| (pin == TFT_RST)
#endif {
#ifdef TFT_WR auto cfg = panel->config(); // Get the structure for panel configuration.
|| (pin == TFT_WR) if(pin == cfg.pin_cs || pin == cfg.pin_rst || pin == cfg.pin_busy) return true;
#endif }
#ifdef TFT_RD
|| (pin == TFT_RD) lgfx::v1::ITouch* touch = panel->getTouch();
#endif if(touch) {
#ifdef TFT_D0 auto cfg = touch->config(); // Get the structure for bus configuration.
|| (pin == TFT_D0) if(pin == cfg.pin_int || pin == cfg.pin_rst) return true;
#endif if(touch->isSPI()) {
#ifdef TFT_D1 if(pin == cfg.pin_miso || pin == cfg.pin_mosi || pin == cfg.pin_sclk || pin == cfg.pin_cs) return true;
|| (pin == TFT_D1) } else {
#endif if(pin == cfg.pin_sda || pin == cfg.pin_scl) return true;
#ifdef TFT_D2 }
|| (pin == TFT_D2) }
#endif
#ifdef TFT_D3
|| (pin == TFT_D3)
#endif
#ifdef TFT_D4
|| (pin == TFT_D4)
#endif
#ifdef TFT_D5
|| (pin == TFT_D5)
#endif
#ifdef TFT_D6
|| (pin == TFT_D6)
#endif
#ifdef TFT_D7
|| (pin == TFT_D7)
#endif
#ifdef TFT_D8
|| (pin == TFT_D8)
#endif
#ifdef TFT_D9
|| (pin == TFT_D9)
#endif
#ifdef TFT_D10
|| (pin == TFT_D10)
#endif
#ifdef TFT_D11
|| (pin == TFT_D11)
#endif
#ifdef TFT_D12
|| (pin == TFT_D12)
#endif
#ifdef TFT_D13
|| (pin == TFT_D13)
#endif
#ifdef TFT_D14
|| (pin == TFT_D14)
#endif
#ifdef TFT_D15
|| (pin == TFT_D15)
#endif
) {
return true;
} }
#ifdef ARDUINO_ARCH_ESP8266
#ifndef TFT_SPI_OVERLAP
if((pin >= 12) && (pin <= 14)) return true; // HSPI
#endif
#endif
return false; return false;
} }

View File

@ -4,7 +4,7 @@
#ifndef HASP_FT6336T_TOUCH_DRIVER_H #ifndef HASP_FT6336T_TOUCH_DRIVER_H
#define HASP_FT6336T_TOUCH_DRIVER_H #define HASP_FT6336T_TOUCH_DRIVER_H
#ifdef ARDUINO #if defined(ARDUINO) && !defined(HASP_USE_LGFX_TOUCH)
#include <Arduino.h> #include <Arduino.h>
#include "ArduinoLog.h" #include "ArduinoLog.h"
#include "hasp_conf.h" #include "hasp_conf.h"