From 9afd71763b89053cdab2729d6687e2bca5b25cdb Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Sun, 6 Aug 2023 09:47:31 +0900 Subject: [PATCH 1/7] Fixed compile errors in older ESP32 frameworks --- src/lgfx/v1/platforms/esp32/common.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index 1ed66a3f..f4a1a705 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -479,8 +479,10 @@ namespace lgfx buscfg.max_transfer_sz = 1; buscfg.flags = SPICOMMON_BUSFLAG_MASTER; buscfg.intr_flags = 0; -#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)) +#if defined (ESP_IDF_VERSION_VAL) + #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)) buscfg.isr_cpu_id = INTR_CPU_ID_AUTO; + #endif #endif if (ESP_OK != spi_bus_initialize(static_cast(spi_host), &buscfg, dma_channel)) { From 460fe47fce83cb14b415631a81e0ef690461b764 Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:40:04 +0900 Subject: [PATCH 2/7] Fixed a crash problem when not enough memory is available. (for ESP32) --- src/lgfx/v1/platforms/esp32/Bus_SPI.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp b/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp index 3667b39a..784e2032 100644 --- a/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp +++ b/src/lgfx/v1/platforms/esp32/Bus_SPI.cpp @@ -425,10 +425,13 @@ namespace lgfx len = (limit << 1) <= length ? limit : length; if (limit <= 256) limit <<= 1; auto dmabuf = _flip_buffer.getBuffer(len * bytes); + if (dmabuf == nullptr) { + break; + } param->fp_copy(dmabuf, 0, len, param); writeBytes(dmabuf, len * bytes, true, true); } while (length -= len); - return; + if (length == 0) return; } /// ESP32-C3 で HIGHPART を使用すると異常動作するため分岐する; @@ -532,10 +535,12 @@ namespace lgfx { if (false == use_dma && length < 1024) { - use_dma = true; auto buf = _flip_buffer.getBuffer(length); - memcpy(buf, data, length); - data = buf; + if (buf) { + memcpy(buf, data, length); + data = buf; + use_dma = true; + } } if (use_dma) { From b6234105613c965b84d19145151903d63638d223 Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Mon, 14 Aug 2023 15:02:45 +0900 Subject: [PATCH 3/7] bugfix I2C error with ESP32S3 --- src/lgfx/v1/platforms/esp32/common.cpp | 40 ++++++++++++-------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index f4a1a705..5e59311a 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -1345,7 +1345,7 @@ namespace lgfx break; } - len = length < 64 ? length : 64; + len = length < 33 ? length : 33; if (length == len && last_nack && len > 1) { --len; } length -= len; @@ -1355,31 +1355,27 @@ namespace lgfx dev->ctr.trans_start = 1; dev->int_clr.val = intmask; - uint32_t us = lgfx::micros(); - taskYIELD(); - -#if defined ( CONFIG_IDF_TARGET_ESP32S3 ) - delayMicroseconds(us_limit >> 2); /// このウェイトを外すと受信失敗するケースがある; -#endif - auto delayus = (us_limit + 7) >> 3; - us = lgfx::micros() - us; - if (us < delayus) { - delayMicroseconds(delayus - us); - } do { + uint32_t us = lgfx::micros(); + taskYIELD(); + us = lgfx::micros() - us; + int delayus = ((us_limit + 7) >> 3) - us; + if (delayus > 0) { + delayMicroseconds(delayus); + } + while (0 == getRxFifoCount(dev) && !(dev->int_raw.val & intmask) && ((lgfx::micros() - us) <= us_limit + 1024)) + { + taskYIELD(); + } + if (0 == getRxFifoCount(dev)) { - uint32_t us = lgfx::micros(); - do { taskYIELD(); } while (0 == getRxFifoCount(dev) && !(dev->int_raw.val & intmask) && ((lgfx::micros() - us) <= us_limit + 1024)); - if (0 == getRxFifoCount(dev)) - { - i2c_stop(i2c_port); - ESP_LOGW("LGFX", "i2c read error : read timeout"); - res = cpp::fail(error_t::connection_lost); - i2c_context[i2c_port].state = cpp::fail(error_t::connection_lost); - return res; - } + i2c_stop(i2c_port); + ESP_LOGW("LGFX", "i2c read error : read timeout"); + res = cpp::fail(error_t::connection_lost); + i2c_context[i2c_port].state = cpp::fail(error_t::connection_lost); + return res; } *readdata++ = *fifo_addr; //dev->fifo_data.data; } while (--len); From 78c41450896b36245d8949bed1bd93c3fb063175 Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Tue, 15 Aug 2023 19:03:08 +0900 Subject: [PATCH 4/7] bugfix I2C error with ESP32S3 --- src/lgfx/v1/platforms/esp32/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index 5e59311a..c0b513c7 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -1360,7 +1360,7 @@ namespace lgfx uint32_t us = lgfx::micros(); taskYIELD(); us = lgfx::micros() - us; - int delayus = ((us_limit + 7) >> 3) - us; + int delayus = ((us_limit + 2) >> 2) - us; if (delayus > 0) { delayMicroseconds(delayus); } From 144a2cf10fa201f7f95564b41b00b228c396ebed Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Wed, 16 Aug 2023 17:09:06 +0900 Subject: [PATCH 5/7] Change panel reset sequence. ( #371 ) --- src/lgfx/v1/panel/Panel_Device.cpp | 24 ++++++++------ src/lgfx/v1/panel/Panel_Device.hpp | 6 ++-- .../LGFX_AutoDetect_ESP32_all.hpp | 33 +++++++++++-------- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/lgfx/v1/panel/Panel_Device.cpp b/src/lgfx/v1/panel/Panel_Device.cpp index 6bf0c7d1..4dbf2ef2 100644 --- a/src/lgfx/v1/panel/Panel_Device.cpp +++ b/src/lgfx/v1/panel/Panel_Device.cpp @@ -56,17 +56,19 @@ namespace lgfx bool Panel_Device::init(bool use_reset) { - init_cs(); - _bus->init(); init_rst(); + init_cs(); if (_light) { _light->init(0); } if (use_reset) { - reset(); + rst_control(false); + delay(8); } + _bus->init(); + rst_control(true); return true; } @@ -308,16 +310,18 @@ namespace lgfx } } - void Panel_Device::reset(void) + void Panel_Device::rst_control(bool level) { auto pin = _cfg.pin_rst; if (pin < 0) return; - gpio_hi(pin); - delay(64); - gpio_lo(pin); - delay(4); - gpio_hi(pin); - delay(64); + if (level) + { + gpio_hi(pin); + } + else + { + gpio_lo(pin); + } } //---------------------------------------------------------------------------- diff --git a/src/lgfx/v1/panel/Panel_Device.hpp b/src/lgfx/v1/panel/Panel_Device.hpp index 5d7a30eb..6f35cfe8 100644 --- a/src/lgfx/v1/panel/Panel_Device.hpp +++ b/src/lgfx/v1/panel/Panel_Device.hpp @@ -183,10 +183,10 @@ namespace lgfx /// If you want to control the RST pin on your own, override this function and implement it. virtual void init_rst(void); - /// RSTピンを一度LOWにし、HIGHに戻す。RSTピンを自前で制御する場合、この関数をoverrideして実装すること。; - /// Bring the RST pin low once and bring it back high. + /// 引数に応じてRSTピンを制御する。false=LOW / true=HIGH。RSTピンを自前で制御する場合、この関数をoverrideして実装すること。; + /// Controls the RST pin to go HIGH when the argument is true. /// If you want to control the RST pin on your own, override this function and implement it. - virtual void reset(void); + virtual void rst_control(bool level); /// パネルの初期化コマンド列を得る。無い場合はnullptrを返す。; /// Get the panel initialization command sequence. diff --git a/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp b/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp index d02d7d21..e92cc5b2 100644 --- a/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp +++ b/src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp @@ -80,13 +80,13 @@ namespace lgfx _rotation = 1; // default rotation } - void reset(void) override + void rst_control(bool level) override { using namespace m5stack; - // AXP192 reg 0x96 = GPIO3&4 control - lgfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x03, 0, ~(1<<5), i2c_freq); // LCD_RST - lgfx::delay(4); - lgfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x03, (1<<5), ~0, i2c_freq); // LCD_RST + uint8_t bits = level ? (1<<5) : 0; + uint8_t mask = level ? ~0 : ~(1<<5); + // LCD_RST + lgfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x03, bits, mask, i2c_freq); } void cs_control(bool flg) override @@ -287,11 +287,16 @@ namespace lgfx bool init(bool use_reset) override { - lgfx::gpio_hi(_cfg.pin_rst); - lgfx::pinMode(_cfg.pin_rst, lgfx::pin_mode_t::input_pulldown); - _cfg.invert = lgfx::gpio_in(_cfg.pin_rst); // get panel type (IPS or TN) - lgfx::pinMode(_cfg.pin_rst, lgfx::pin_mode_t::output); - + _cfg.invert = lgfx::gpio::command( + (const uint8_t[]) { + lgfx::gpio::command_mode_output , GPIO_NUM_33, + lgfx::gpio::command_write_low , GPIO_NUM_33, + lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_33, + lgfx::gpio::command_write_high , GPIO_NUM_33, + lgfx::gpio::command_read , GPIO_NUM_33, + lgfx::gpio::command_mode_output , GPIO_NUM_33, + lgfx::gpio::command_end + }); return lgfx::Panel_ILI9342::init(use_reset); } }; @@ -307,13 +312,13 @@ namespace lgfx _rotation = 1; // default rotation } - void reset(void) override + void rst_control(bool level) override { using namespace m5stack; + uint8_t bits = level ? 2 : 0; + uint8_t mask = level ? ~0 : ~2; // AXP192 reg 0x96 = GPIO3&4 control - lgfx::i2c::writeRegister8(axp_i2c_port, axp_i2c_addr, 0x96, 0, ~0x02, axp_i2c_freq); // GPIO4 LOW (LCD RST) - lgfx::delay(4); - lgfx::i2c::writeRegister8(axp_i2c_port, axp_i2c_addr, 0x96, 2, ~0x00, axp_i2c_freq); // GPIO4 HIGH (LCD RST) + lgfx::i2c::writeRegister8(axp_i2c_port, axp_i2c_addr, 0x96, bits, mask, axp_i2c_freq); } }; From c0045194d32cded03775f30d5aac3a3d1817eade Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Wed, 16 Aug 2023 17:54:46 +0900 Subject: [PATCH 6/7] Change panel reset sequence. ( #371 ) --- src/lgfx/v1/panel/Panel_Device.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lgfx/v1/panel/Panel_Device.cpp b/src/lgfx/v1/panel/Panel_Device.cpp index 4dbf2ef2..4ae1988e 100644 --- a/src/lgfx/v1/panel/Panel_Device.cpp +++ b/src/lgfx/v1/panel/Panel_Device.cpp @@ -69,6 +69,10 @@ namespace lgfx } _bus->init(); rst_control(true); + if (use_reset) + { + delay(64); + } return true; } From 1d403e35a18faa350024993662aab94e15e1b3f2 Mon Sep 17 00:00:00 2001 From: lovyan03 <42724151+lovyan03@users.noreply.github.com> Date: Wed, 6 Sep 2023 13:54:24 +0900 Subject: [PATCH 7/7] raising version 1.1.9 --- examples_for_PC/PlatformIO_SDL/README.md | 4 ++-- library.json | 2 +- library.properties | 2 +- src/lgfx/v1/gitTagVersion.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples_for_PC/PlatformIO_SDL/README.md b/examples_for_PC/PlatformIO_SDL/README.md index 69c4dc73..0d8e6c4b 100644 --- a/examples_for_PC/PlatformIO_SDL/README.md +++ b/examples_for_PC/PlatformIO_SDL/README.md @@ -28,7 +28,7 @@ xcode-select --install `MSYS2` をここ https://www.msys2.org/ から入手してインストールする。 そのあと、Windowsの`システムのプロパティ`->`環境変数` を開き、 `PATH` に以下の3つのパスを追加する。 ``` -C:\msys64\mingw64\bin +C:\msys64\mingw32\bin C:\msys64\ucrt64\bin C:\msys64\usr\bin ``` @@ -70,7 +70,7 @@ https://github.com/libsdl-org/SDL/releases - include - lib -C:\msys64\mingw64\ を開き、上記の4つのフォルダと同名のフォルダが存在することを確認したら、C:\msys64\mingw64\ 内に上記フォルダの内容を追加する。(上書きコピー) +C:\msys64\mingw32\ を開き、上記の4つのフォルダと同名のフォルダが存在することを確認したら、C:\msys64\mingw32\ 内に上記フォルダの内容を追加する。(上書きコピー) --- diff --git a/library.json b/library.json index 476ffbeb..55ca19a7 100644 --- a/library.json +++ b/library.json @@ -11,7 +11,7 @@ "type": "git", "url": "https://github.com/lovyan03/LovyanGFX.git" }, - "version": "1.1.8", + "version": "1.1.9", "frameworks": ["arduino", "espidf", "*"], "platforms": ["espressif32", "espressif8266", "atmelsam", "native"], "headers": "LovyanGFX.hpp", diff --git a/library.properties b/library.properties index c56b1689..7c3bdea0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=LovyanGFX -version=1.1.8 +version=1.1.9 author=lovyan03 maintainer=lovyan03 sentence=TFT LCD Graphics driver with touch for ESP32, ESP8266, SAMD21, SAMD51, RP2040 diff --git a/src/lgfx/v1/gitTagVersion.h b/src/lgfx/v1/gitTagVersion.h index f7172599..25adeaca 100644 --- a/src/lgfx/v1/gitTagVersion.h +++ b/src/lgfx/v1/gitTagVersion.h @@ -1,4 +1,4 @@ #define LGFX_VERSION_MAJOR 1 #define LGFX_VERSION_MINOR 1 -#define LGFX_VERSION_PATCH 8 +#define LGFX_VERSION_PATCH 9 #define LOVYANGFX_VERSION F( LGFX_VERSION_MAJOR "." LGFX_VERSION_MINOR "." LGFX_VERSION_PATCH )