Skip to content

Commit 144a2cf

Browse files
committed
Change panel reset sequence. ( #371 )
1 parent 78c4145 commit 144a2cf

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

src/lgfx/v1/panel/Panel_Device.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,19 @@ namespace lgfx
5656

5757
bool Panel_Device::init(bool use_reset)
5858
{
59-
init_cs();
60-
_bus->init();
6159
init_rst();
60+
init_cs();
6261
if (_light)
6362
{
6463
_light->init(0);
6564
}
6665
if (use_reset)
6766
{
68-
reset();
67+
rst_control(false);
68+
delay(8);
6969
}
70+
_bus->init();
71+
rst_control(true);
7072
return true;
7173
}
7274

@@ -308,16 +310,18 @@ namespace lgfx
308310
}
309311
}
310312

311-
void Panel_Device::reset(void)
313+
void Panel_Device::rst_control(bool level)
312314
{
313315
auto pin = _cfg.pin_rst;
314316
if (pin < 0) return;
315-
gpio_hi(pin);
316-
delay(64);
317-
gpio_lo(pin);
318-
delay(4);
319-
gpio_hi(pin);
320-
delay(64);
317+
if (level)
318+
{
319+
gpio_hi(pin);
320+
}
321+
else
322+
{
323+
gpio_lo(pin);
324+
}
321325
}
322326

323327
//----------------------------------------------------------------------------

src/lgfx/v1/panel/Panel_Device.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ namespace lgfx
183183
/// If you want to control the RST pin on your own, override this function and implement it.
184184
virtual void init_rst(void);
185185

186-
/// RSTピンを一度LOWにし、HIGHに戻す。RSTピンを自前で制御する場合、この関数をoverrideして実装すること。;
187-
/// Bring the RST pin low once and bring it back high.
186+
/// 引数に応じてRSTピンを制御する。false=LOW / true=HIGH。RSTピンを自前で制御する場合、この関数をoverrideして実装すること。;
187+
/// Controls the RST pin to go HIGH when the argument is true.
188188
/// If you want to control the RST pin on your own, override this function and implement it.
189-
virtual void reset(void);
189+
virtual void rst_control(bool level);
190190

191191
/// パネルの初期化コマンド列を得る。無い場合はnullptrを返す。;
192192
/// Get the panel initialization command sequence.

src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ namespace lgfx
8080
_rotation = 1; // default rotation
8181
}
8282

83-
void reset(void) override
83+
void rst_control(bool level) override
8484
{
8585
using namespace m5stack;
86-
// AXP192 reg 0x96 = GPIO3&4 control
87-
lgfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x03, 0, ~(1<<5), i2c_freq); // LCD_RST
88-
lgfx::delay(4);
89-
lgfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x03, (1<<5), ~0, i2c_freq); // LCD_RST
86+
uint8_t bits = level ? (1<<5) : 0;
87+
uint8_t mask = level ? ~0 : ~(1<<5);
88+
// LCD_RST
89+
lgfx::i2c::writeRegister8(i2c_port, aw9523_i2c_addr, 0x03, bits, mask, i2c_freq);
9090
}
9191

9292
void cs_control(bool flg) override
@@ -287,11 +287,16 @@ namespace lgfx
287287

288288
bool init(bool use_reset) override
289289
{
290-
lgfx::gpio_hi(_cfg.pin_rst);
291-
lgfx::pinMode(_cfg.pin_rst, lgfx::pin_mode_t::input_pulldown);
292-
_cfg.invert = lgfx::gpio_in(_cfg.pin_rst); // get panel type (IPS or TN)
293-
lgfx::pinMode(_cfg.pin_rst, lgfx::pin_mode_t::output);
294-
290+
_cfg.invert = lgfx::gpio::command(
291+
(const uint8_t[]) {
292+
lgfx::gpio::command_mode_output , GPIO_NUM_33,
293+
lgfx::gpio::command_write_low , GPIO_NUM_33,
294+
lgfx::gpio::command_mode_input_pulldown, GPIO_NUM_33,
295+
lgfx::gpio::command_write_high , GPIO_NUM_33,
296+
lgfx::gpio::command_read , GPIO_NUM_33,
297+
lgfx::gpio::command_mode_output , GPIO_NUM_33,
298+
lgfx::gpio::command_end
299+
});
295300
return lgfx::Panel_ILI9342::init(use_reset);
296301
}
297302
};
@@ -307,13 +312,13 @@ namespace lgfx
307312
_rotation = 1; // default rotation
308313
}
309314

310-
void reset(void) override
315+
void rst_control(bool level) override
311316
{
312317
using namespace m5stack;
318+
uint8_t bits = level ? 2 : 0;
319+
uint8_t mask = level ? ~0 : ~2;
313320
// AXP192 reg 0x96 = GPIO3&4 control
314-
lgfx::i2c::writeRegister8(axp_i2c_port, axp_i2c_addr, 0x96, 0, ~0x02, axp_i2c_freq); // GPIO4 LOW (LCD RST)
315-
lgfx::delay(4);
316-
lgfx::i2c::writeRegister8(axp_i2c_port, axp_i2c_addr, 0x96, 2, ~0x00, axp_i2c_freq); // GPIO4 HIGH (LCD RST)
321+
lgfx::i2c::writeRegister8(axp_i2c_port, axp_i2c_addr, 0x96, bits, mask, axp_i2c_freq);
317322
}
318323
};
319324

0 commit comments

Comments
 (0)