Skip to content

Commit

Permalink
Merge pull request #446 from lovyan03/develop
Browse files Browse the repository at this point in the history
1.1.9
  • Loading branch information
lovyan03 authored Sep 8, 2023
2 parents 19a2e71 + 1d403e3 commit 302169a
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 59 deletions.
4 changes: 2 additions & 2 deletions examples_for_PC/PlatformIO_SDL/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -70,7 +70,7 @@ https:/libsdl-org/SDL/releases
- include
- lib

C:\msys64\mingw64\ を開き、上記の4つのフォルダと同名のフォルダが存在することを確認したら、C:\msys64\mingw64\ 内に上記フォルダの内容を追加する。(上書きコピー)
C:\msys64\mingw32\ を開き、上記の4つのフォルダと同名のフォルダが存在することを確認したら、C:\msys64\mingw32\ 内に上記フォルダの内容を追加する。(上書きコピー)

---

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https:/lovyan03/LovyanGFX.git"
},
"version": "1.1.8",
"version": "1.1.9",
"frameworks": ["arduino", "espidf", "*"],
"platforms": ["espressif32", "espressif8266", "atmelsam", "native"],
"headers": "LovyanGFX.hpp",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lgfx/v1/gitTagVersion.h
Original file line number Diff line number Diff line change
@@ -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 )
28 changes: 18 additions & 10 deletions src/lgfx/v1/panel/Panel_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,22 @@ 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);
if (use_reset)
{
delay(64);
}
return true;
}
Expand Down Expand Up @@ -308,16 +314,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);
}
}

//----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions src/lgfx/v1/panel/Panel_Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 9 additions & 4 deletions src/lgfx/v1/platforms/esp32/Bus_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 を使用すると異常動作するため分岐する;
Expand Down Expand Up @@ -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)
{
Expand Down
44 changes: 21 additions & 23 deletions src/lgfx/v1/platforms/esp32/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_device_t>(spi_host), &buscfg, dma_channel))
{
Expand Down Expand Up @@ -1343,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;
Expand All @@ -1353,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 + 2) >> 2) - 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);
Expand Down
33 changes: 19 additions & 14 deletions src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
};
Expand All @@ -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);
}
};

Expand Down

0 comments on commit 302169a

Please sign in to comment.