Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Added GUITION ST7701 panel instructions. #562

Merged
merged 2 commits into from
May 1, 2024

Conversation

FigueiredoStable
Copy link
Contributor

Just add a new device support for ST7701 manufactured by GUITION, link: GUITION Smart Display

* The board:

971639B2-4FC4-41CF-A686-3E82BFD55B0F

* Before the new instructions, colors were inverted or only rendered a partial size of the screen:

FD656371-C06C-403B-A00E-3FD29255FF97

* After added instructions by manufacture

6B443387-C58F-4529-8518-D653D0CE62EA

@tobozo
Copy link
Collaborator

tobozo commented May 1, 2024

both ::init() methods are identical; since LGFX has a desing pattern for display variants, let's create a Panel_ST7701_Base to handle the redundant ::init() and make both Panel_ST7701 and Panel_ST7701_guition_esp32_4848S040 inherit from it:

lgfx/v1/platforms/esp32s3/Panel_RGB.hpp

  struct Panel_ST7701_Base : public Panel_RGB
  {
    bool init(bool) override; 
  };

  struct Panel_ST7701 : public Panel_ST7701_Base
  {
  protected:
    const uint8_t* getInitCommands(uint8_t listno) const override;
  };

  struct Panel_ST7701_guition_esp32_4848S040: public Panel_ST7701_Base
  {
  protected:
    const uint8_t* getInitCommands(uint8_t listno) const override;
  };

lgfx/v1/platforms/esp32s3/Panel_RGB.cpp

  • create Panel_ST7701_Base::init(bool)
  • remove Panel_ST7701::init(bool)
  • remove Panel_ST7701_guition_esp32_4848S040::init(bool)

@FigueiredoStable
Copy link
Contributor Author

both ::init() methods are identical; since LGFX has a desing pattern for display variants, let's create a Panel_ST7701_Base to handle the redundant ::init() and make both Panel_ST7701 and Panel_ST7701_guition_esp32_4848S040 inherit from it:

lgfx/v1/platforms/esp32s3/Panel_RGB.hpp

  struct Panel_ST7701_Base : public Panel_RGB
  {
    bool init(bool) override; 
  };

  struct Panel_ST7701 : public Panel_ST7701_Base
  {
  protected:
    const uint8_t* getInitCommands(uint8_t listno) const override;
  };

  struct Panel_ST7701_guition_esp32_4848S040: public Panel_ST7701_Base
  {
  protected:
    const uint8_t* getInitCommands(uint8_t listno) const override;
  };

lgfx/v1/platforms/esp32s3/Panel_RGB.cpp

  • create Panel_ST7701_Base::init(bool)
  • remove Panel_ST7701::init(bool)
  • remove Panel_ST7701_guition_esp32_4848S040::init(bool)

Great point, i added Panel ST7701 base initialization. Tks

@tobozo
Copy link
Collaborator

tobozo commented May 1, 2024

looks good, thanks for your contribution 👍

@tobozo tobozo merged commit 27d417b into lovyan03:develop May 1, 2024
88 checks passed
@Christian-Me
Copy link

@FigueiredoStable Thank you for your contribution. Happy to see that lgfx is working with this panel. Nevertheless I struggle to get it running myself. May I ask if it is possible to share your config file (PIN definitions etc.) to give me a kickstart. Here is my my hacked config. I get a picture but with distorted colors. I'm practicing trial and error for hours and can't get it right.

#define LGFX_USE_V1
#include <LovyanGFX.hpp>

#include <lgfx/v1/platforms/esp32s3/Panel_RGB.hpp>
#include <lgfx/v1/platforms/esp32s3/Bus_RGB.hpp>
#include <driver/i2c.h>

class LGFX : public lgfx::LGFX_Device
{
public:

  lgfx::Bus_RGB      _bus_instance;
  lgfx::Panel_ST7701_guition_esp32_4848S040 _panel_instance;
  lgfx::Touch_GT911  _touch_instance;
  lgfx::Light_PWM   _light_instance;

  LGFX(void)
  {
    {
      auto cfg = _panel_instance.config();

      cfg.memory_width  = 480;
      cfg.memory_height = 480;
      cfg.panel_width  = 480;
      cfg.panel_height = 480;

      cfg.offset_x = 0;
      cfg.offset_y = 0;

      _panel_instance.config(cfg);
    }

    {
      auto cfg = _panel_instance.config_detail();

      cfg.pin_cs = 39;
      cfg.pin_sclk = 48;
      cfg.pin_mosi = 47; // SDA

      _panel_instance.config_detail(cfg);
    }

    {
      auto cfg = _bus_instance.config();
      cfg.panel = &_panel_instance;
      cfg.pin_d0  = GPIO_NUM_4;  // B0
      cfg.pin_d1  = GPIO_NUM_5;  // B1
      cfg.pin_d2  = GPIO_NUM_6; // B2
      cfg.pin_d3  = GPIO_NUM_7; // B3
      cfg.pin_d4  = GPIO_NUM_15;  // B4
      cfg.pin_d5  = GPIO_NUM_8;  // G0
      cfg.pin_d6  = GPIO_NUM_20;  // G1
      cfg.pin_d7  = GPIO_NUM_3; // G2
      cfg.pin_d8  = GPIO_NUM_46; // G3
      cfg.pin_d9  = GPIO_NUM_9; // G4
      cfg.pin_d10 = GPIO_NUM_10;  // G5
      cfg.pin_d11 = GPIO_NUM_11; // R0
      cfg.pin_d12 = GPIO_NUM_12; // R1
      cfg.pin_d13 = GPIO_NUM_13; // R2
      cfg.pin_d14 = GPIO_NUM_14; // R3
      cfg.pin_d15 = GPIO_NUM_0; // R4

      cfg.pin_henable = GPIO_NUM_18;
      cfg.pin_vsync   = GPIO_NUM_17;
      cfg.pin_hsync   = GPIO_NUM_16;
      cfg.pin_pclk    = GPIO_NUM_21;
      cfg.freq_write  = 14000000;

      cfg.hsync_polarity    = 0;
      cfg.hsync_front_porch = 10;
      cfg.hsync_pulse_width = 8;
      cfg.hsync_back_porch  = 50;
      cfg.vsync_polarity    = 0;
      cfg.vsync_front_porch = 10;
      cfg.vsync_pulse_width = 8;
      cfg.vsync_back_porch  = 20;
      cfg.pclk_idle_high    = 0;
      cfg.de_idle_high      = 1;
      _bus_instance.config(cfg);
    }
    _panel_instance.setBus(&_bus_instance);

    {
      auto cfg = _light_instance.config();
      cfg.pin_bl = GPIO_NUM_38;
      _light_instance.config(cfg);
    }
    _panel_instance.light(&_light_instance);

    {
      auto cfg = _touch_instance.config();
      cfg.x_min      = 0;
      cfg.x_max      = 480;
      cfg.y_min      = 0;
      cfg.y_max      = 480;
      cfg.bus_shared = false;
      cfg.offset_rotation = 0;

      cfg.i2c_port   = I2C_NUM_1;

      cfg.pin_int    = GPIO_NUM_NC;
      cfg.pin_sda    = GPIO_NUM_19;
      cfg.pin_scl    = GPIO_NUM_45;
      cfg.pin_rst    = GPIO_NUM_NC;

      cfg.freq       = 400000;
      _touch_instance.config(cfg);
      _panel_instance.setTouch(&_touch_instance);
    }

    // {
    //   auto cfg = _light_instance.config();
    //   cfg.pin_bl = GPIO_NUM_44;
    //   _light_instance.config(cfg);
    // }
    // _panel_instance.light(&_light_instance);

    setPanel(&_panel_instance);
  }
};

Thank you for your help.

@FigueiredoStable
Copy link
Contributor Author

@FigueiredoStable Thank you for your contribution. Happy to see that lgfx is working with this panel. Nevertheless I struggle to get it running myself. May I ask if it is possible to share your config file (PIN definitions etc.) to give me a kickstart. Here is my my hacked config. I get a picture but with distorted colors. I'm practicing trial and error for hours and can't get it right.

Hy Christian, sure, i can help you i will put here my configuration as soon as a possible ok

@Christian-Me
Copy link

Thank you very much. Any help is appreciated.

@FigueiredoStable
Copy link
Contributor Author

Thank you very much. Any help is appreciated.

Hi i'am back, i used your instruction in my test code and works very well, so if you use with LVGL i publishied on this repository below:

LovyanGFX-GUITION-ESP32-4848S040

  • In lv_conf set #define LV_COLOR_16_SWAP 1 because this work with SPI protocol. (prevent color reversed or distorced).

  • my_disp_flush use DMA to better performance.

5C0FB502-0C22-44EE-A122-424F0AE70001

I hope the repository help you, otherwise i'am here.

@Christian-Me
Copy link

@FigueiredoStable Many, many thanx! That does the trick. You made my day.

@FigueiredoStable
Copy link
Contributor Author

@FigueiredoStable Many, many thanx! That does the trick. You made my day.

Glad that helped you Cristian, made my day too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants