Skip to content

Commit

Permalink
tweak autodetect order for AtomS3R
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Sep 13, 2024
1 parent 7236318 commit b9ee9f0
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/M5GFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,22 +1255,22 @@ namespace m5gfx
lgfx::i2c::release(i2c_port);
}

if (board == 0 || board == board_t::board_M5AtomS3)
if (board == 0 || board == board_t::board_M5AtomS3R)
{
_pin_reset(GPIO_NUM_34, use_reset); // LCD RST
_pin_reset(GPIO_NUM_48, use_reset); // LCD RST
bus_cfg.pin_mosi = GPIO_NUM_21;
bus_cfg.pin_miso = (gpio_num_t)-1; //GPIO_NUM_NC;
bus_cfg.pin_sclk = GPIO_NUM_17;
bus_cfg.pin_dc = GPIO_NUM_33;
bus_cfg.pin_sclk = GPIO_NUM_15;
bus_cfg.pin_dc = GPIO_NUM_42;
bus_cfg.spi_mode = 0;
bus_cfg.spi_3wire = true;
bus_spi->config(bus_cfg);
bus_spi->init();
id = _read_panel_id(bus_spi, GPIO_NUM_15);
id = _read_panel_id(bus_spi, GPIO_NUM_14);
if ((id & 0xFFFFFF) == 0x079100)
{ // check panel (GC9107)
board = board_t::board_M5AtomS3;
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5AtomS3");
board = board_t::board_M5AtomS3R;
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5AtomS3R");
bus_spi->release();
bus_cfg.spi_host = SPI3_HOST;
bus_cfg.freq_write = 40000000;
Expand All @@ -1281,39 +1281,40 @@ namespace m5gfx
p->bus(bus_spi);
{
auto cfg = p->config();
cfg.pin_cs = GPIO_NUM_15;
cfg.pin_rst = GPIO_NUM_34;
cfg.pin_cs = GPIO_NUM_14;
cfg.pin_rst = GPIO_NUM_48;
cfg.panel_width = 128;
cfg.panel_height = 128;
cfg.offset_y = 32;
cfg.readable = false;
cfg.bus_shared = false;
p->config(cfg);
}
_panel_last.reset(p);
_set_pwm_backlight(GPIO_NUM_16, 7, 256, false, 48);
_set_backlight(new Light_M5StackAtomS3R());

goto init_clear;
}
lgfx::pinMode(GPIO_NUM_48, lgfx::pin_mode_t::input); // LCD RST
bus_spi->release();
}

if (board == 0 || board == board_t::board_M5AtomS3R)
if (board == 0 || board == board_t::board_M5AtomS3)
{
_pin_reset(GPIO_NUM_48, use_reset); // LCD RST
_pin_reset(GPIO_NUM_34, use_reset); // LCD RST
bus_cfg.pin_mosi = GPIO_NUM_21;
bus_cfg.pin_miso = (gpio_num_t)-1; //GPIO_NUM_NC;
bus_cfg.pin_sclk = GPIO_NUM_15;
bus_cfg.pin_dc = GPIO_NUM_42;
bus_cfg.pin_sclk = GPIO_NUM_17;
bus_cfg.pin_dc = GPIO_NUM_33;
bus_cfg.spi_mode = 0;
bus_cfg.spi_3wire = true;
bus_spi->config(bus_cfg);
bus_spi->init();
id = _read_panel_id(bus_spi, GPIO_NUM_14);
id = _read_panel_id(bus_spi, GPIO_NUM_15);
if ((id & 0xFFFFFF) == 0x079100)
{ // check panel (GC9107)
board = board_t::board_M5AtomS3R;
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5AtomS3R");
board = board_t::board_M5AtomS3;
ESP_LOGW(LIBRARY_NAME, "[Autodetect] board_M5AtomS3");
bus_spi->release();
bus_cfg.spi_host = SPI3_HOST;
bus_cfg.freq_write = 40000000;
Expand All @@ -1324,17 +1325,16 @@ namespace m5gfx
p->bus(bus_spi);
{
auto cfg = p->config();
cfg.pin_cs = GPIO_NUM_14;
cfg.pin_rst = GPIO_NUM_48;
cfg.pin_cs = GPIO_NUM_15;
cfg.pin_rst = GPIO_NUM_34;
cfg.panel_width = 128;
cfg.panel_height = 128;
cfg.offset_y = 32;
cfg.readable = false;
cfg.bus_shared = false;
p->config(cfg);
}
_panel_last.reset(p);
_set_backlight(new Light_M5StackAtomS3R());
_set_pwm_backlight(GPIO_NUM_16, 7, 256, false, 48);

goto init_clear;
}
Expand Down

0 comments on commit b9ee9f0

Please sign in to comment.