Skip to content

Commit

Permalink
Change panel reset sequence. ( #371 )
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Aug 16, 2023
1 parent 78c4145 commit 144a2cf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
24 changes: 14 additions & 10 deletions src/lgfx/v1/panel/Panel_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}

//----------------------------------------------------------------------------
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
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 144a2cf

Please sign in to comment.