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

Help me , ST7735S cannot drive 80*160 screen normally #564

Open
dingxiao88 opened this issue May 5, 2024 · 0 comments
Open

Help me , ST7735S cannot drive 80*160 screen normally #564

dingxiao88 opened this issue May 5, 2024 · 0 comments
Labels
device support request Add new device driver pinned exempt from stale bot

Comments

@dingxiao88
Copy link

Carefully written requests are more likely to be given priority.
丁寧に記述された要望は優先して対応される可能性が高くなります。

Problem Description ( 問題の内容 )

TFT_eSPI can be used to drive normally. The driver tested is ST7735, and the ST7735_REDTAB160x80 macro definition is enabled.
pkA5c2d.jpg
View driver code ST7735_Init.c(https://github.com/Bodmer/TFT_eSPI/blob/master/TFT_Drivers/ST7735_Init.h):

Rcmd1[] = {                 // Init for 7735R, part 1 (red or green tab)
    15,                       // 15 commands in list:
    ST7735_SWRESET,   TFT_INIT_DELAY,  //  1: Software reset, 0 args, w/delay
      150,                    //     150 ms delay
    ST7735_SLPOUT ,   TFT_INIT_DELAY,  //  2: Out of sleep mode, 0 args, w/delay
      255,                    //     500 ms delay
    ST7735_FRMCTR1, 3      ,  //  3: Frame rate ctrl - normal mode, 3 args:
      0x01, 0x2C, 0x2D,       //     Rate = fosc/(1x2+40) * (LINE+2C+2D)
    ST7735_FRMCTR2, 3      ,  //  4: Frame rate control - idle mode, 3 args:
      0x01, 0x2C, 0x2D,       //     Rate = fosc/(1x2+40) * (LINE+2C+2D)
    ST7735_FRMCTR3, 6      ,  //  5: Frame rate ctrl - partial mode, 6 args:
      0x01, 0x2C, 0x2D,       //     Dot inversion mode
      0x01, 0x2C, 0x2D,       //     Line inversion mode
    ST7735_INVCTR , 1      ,  //  6: Display inversion ctrl, 1 arg, no delay:
      0x07,                   //     No inversion
    ST7735_PWCTR1 , 3      ,  //  7: Power control, 3 args, no delay:
      0xA2,
      0x02,                   //     -4.6V
      0x84,                   //     AUTO mode
    ST7735_PWCTR2 , 1      ,  //  8: Power control, 1 arg, no delay:
      0xC5,                   //     VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD
    ST7735_PWCTR3 , 2      ,  //  9: Power control, 2 args, no delay:
      0x0A,                   //     Opamp current small
      0x00,                   //     Boost frequency
    ST7735_PWCTR4 , 2      ,  // 10: Power control, 2 args, no delay:
      0x8A,                   //     BCLK/2, Opamp current small & Medium low
      0x2A,  
    ST7735_PWCTR5 , 2      ,  // 11: Power control, 2 args, no delay:
      0x8A, 0xEE,
    ST7735_VMCTR1 , 1      ,  // 12: Power control, 1 arg, no delay:
      0x0E,
    ST7735_INVOFF , 0      ,  // 13: Don't invert display, no args, no delay
    ST7735_MADCTL , 1      ,  // 14: Memory access control (directions), 1 arg:
      0xC0 | TFT_MAD_COLOR_ORDER, //     row addr/col addr, bottom to top refresh
    ST7735_COLMOD , 1      ,  // 15: set color mode, 1 arg, no delay:
      0x05 },   
                    //     16-bit color
  Rcmd2green[] = {            // Init for 7735R, part 2 (green tab only)
    2,                        //  2 commands in list:
    ST7735_CASET  , 4      ,  //  1: Column addr set, 4 args, no delay:
      0x00, 0x02,             //     XSTART = 0
      0x00, 0x7F+0x02,        //     XEND = 127
    ST7735_RASET  , 4      ,  //  2: Row addr set, 4 args, no delay:
      0x00, 0x01,             //     XSTART = 0
      0x00, 0x9F+0x01 },      //     XEND = 159

  Rcmd3[] = {                 // Init for 7735R, part 3 (red or green tab)
    4,                        //  4 commands in list:
    ST7735_GMCTRP1, 16      , //  1: 16 args, no delay:
      0x02, 0x1c, 0x07, 0x12,
      0x37, 0x32, 0x29, 0x2d,
      0x29, 0x25, 0x2B, 0x39,
      0x00, 0x01, 0x03, 0x10,
    ST7735_GMCTRN1, 16      , //  2: 16 args, no delay:
      0x03, 0x1d, 0x07, 0x06,
      0x2E, 0x2C, 0x29, 0x2D,
      0x2E, 0x2E, 0x37, 0x3F,
      0x00, 0x00, 0x02, 0x10,
    ST7735_NORON  ,    TFT_INIT_DELAY, //  3: Normal display on, no args, w/delay
      10,                     //     10 ms delay
    ST7735_DISPON ,    TFT_INIT_DELAY, //  4: Main screen turn on, no args w/delay
      100 };                  //     100 ms delay


	if (tabcolor == INITB)
     {
       commandList(Bcmd);
     }
     else
     {
       commandList(Rcmd1);
       if (tabcolor == INITR_GREENTAB)
       else if (tabcolor == INITR_GREENTAB2)
	   ...

       else if (tabcolor == INITR_REDTAB160x80)  ---> this 
       {

         commandList(Rcmd2green);   ---> use Rcmd2green

         colstart = 24;             ---> set offset
         rowstart = 0;
       }
       
       commandList(Rcmd3);
     }

Configuration using Lonyan:

class LGFX : public lgfx::LGFX_Device
{
// 接続するパネルの型にあったインスタンスを用意します。
lgfx::Panel_ST7735S     _panel_instance;


// パネルを接続するバスの種類にあったインスタンスを用意します。
  lgfx::Bus_SPI        _bus_instance;   // SPIバスのインスタンス
//lgfx::Bus_I2C        _bus_instance;   // I2Cバスのインスタンス
//lgfx::Bus_Parallel8  _bus_instance;   // 8ビットパラレルバスのインスタンス

// バックライト制御が可能な場合はインスタンスを用意します。(必要なければ削除)
  lgfx::Light_PWM     _light_instance;
  
public:

  // コンストラクタを作成し、ここで各種設定を行います。
  // クラス名を変更した場合はコンストラクタも同じ名前を指定してください。
  LGFX(void)
  {
    { // バス制御の設定を行います。
      auto cfg = _bus_instance.config();    // バス設定用の構造体を取得します。
// SPIバスの設定
      cfg.spi_host = SPI2_HOST;     // 使用するSPIを選択  ESP32-S2,C3 : SPI2_HOST or SPI3_HOST / ESP32 : VSPI_HOST or HSPI_HOST
      // ※ ESP-IDFバージョンアップに伴い、VSPI_HOST , HSPI_HOSTの記述は非推奨になるため、エラーが出る場合は代わりにSPI2_HOST , SPI3_HOSTを使用してください。
      cfg.spi_mode = 0;             // SPI通信モードを設定 (0 ~ 3)
      cfg.freq_write = 80000000;    // 送信時のSPIクロック (最大80MHz, 80MHzを整数で割った値に丸められます)
      cfg.freq_read  = 16000000;    // 受信時のSPIクロック
      cfg.spi_3wire  = true;        // 受信をMOSIピンで行う場合はtrueを設定
      cfg.use_lock   = true;        // トランザクションロックを使用する場合はtrueを設定
      cfg.dma_channel = 0;          //@-20230830-ESP32平台测试过程中必须关闭DMA 1或2都会造成图像有条纹
      //SPI_DMA_CH_AUTO; // 使用するDMAチャンネルを設定 (0=DMA不使用 / 1=1ch / 2=ch / SPI_DMA_CH_AUTO=自動設定)
      // ※ ESP-IDFバージョンアップに伴い、DMAチャンネルはSPI_DMA_CH_AUTO(自動設定)が推奨になりました。1ch,2chの指定は非推奨になります。
      cfg.pin_sclk = TFT_SCLK;            // SPIのSCLKピン番号を設定
      cfg.pin_mosi = TFT_MOSI;            // SPIのMOSIピン番号を設定
      cfg.pin_miso = TFT_MISO;            // SPIのMISOピン番号を設定 (-1 = disable)
      cfg.pin_dc   = TFT_DC;            // SPIのD/Cピン番号を設定  (-1 = disable)
     // SDカードと共通のSPIバスを使う場合、MISOは省略せず必ず設定してください。
//*/

      _bus_instance.config(cfg);    // 設定値をバスに反映します。
      _panel_instance.setBus(&_bus_instance);      // バスをパネルにセットします。
    }

    { // 表示パネル制御の設定を行います。
      auto cfg = _panel_instance.config();    // 表示パネル設定用の構造体を取得します。
      cfg.pin_cs           =    TFT_CS;  // CSが接続されているピン番号   (-1 = disable)
      cfg.pin_rst          =    TFT_RESET;  // RSTが接続されているピン番号  (-1 = disable)
      cfg.pin_busy         =    -1;  // BUSYが接続されているピン番号 (-1 = disable)

      // ※ 以下の設定値はパネル毎に一般的な初期値が設定されていますので、不明な項目はコメントアウトして試してみてください。
      cfg.panel_width      =   80;  // 実際に表示可能な幅
      cfg.panel_height     =   160;  // 実際に表示可能な高さ
      cfg.offset_x         =    0;// 24;  // パネルのX方向オフセット量
      cfg.offset_y         =     0;  // パネルのY方向オフセット量
      cfg.offset_rotation  =     0;  // 回転方向の値のオフセット 0~7 (4~7は上下反転)
      cfg.dummy_read_pixel =     8;  // ピクセル読出し前のダミーリードのビット数
      cfg.dummy_read_bits  =     1;  // ピクセル以外のデータ読出し前のダミーリードのビット数
      cfg.readable         = true;  // データ読出しが可能な場合 trueに設定
      cfg.invert           = false; //  // パネルの明暗が反転してしまう場合 trueに設定
      cfg.rgb_order        = false;  // パネルの赤と青が入れ替わってしまう場合 trueに設定
      cfg.dlen_16bit       = false;  // 16bitパラレルやSPIでデータ長を16bit単位で送信するパネルの場合 trueに設定
      cfg.bus_shared       = true;  // SDカードとバスを共有している場合 trueに設定(drawJpgFile等でバス制御を行います)

// 以下はST7735やILI9163のようにピクセル数が可変のドライバで表示がずれる場合にのみ設定してください。
    cfg.memory_width     =   240;  // ドライバICがサポートしている最大の幅
    cfg.memory_height    =   320;  // ドライバICがサポートしている最大の高さ
      _panel_instance.config(cfg);

    }

// //*
    { // バックライト制御の設定を行います。(必要なければ削除)
      auto cfg = _light_instance.config();    // バックライト設定用の構造体を取得します。
      cfg.pin_bl = TFT_BL;              // バックライトが接続されているピン番号
      cfg.invert = false;           // バックライトの輝度を反転させる場合 true
      cfg.freq   = 44100;           // バックライトのPWM周波数
      cfg.pwm_channel = 7;          // 使用するPWMのチャンネル番号
      _light_instance.config(cfg);
      _panel_instance.setLight(&_light_instance);  // バックライトをパネルにセットします。
    }

    setPanel(&_panel_instance); // 使用するパネルをセットします。

  }

};

check

https://github.com/lovyan03/LovyanGFX/blob/master/src/lgfx/v1/panel/Panel_ST7735.hpp

struct Panel_ST7735S : public Panel_ST7735
  {
  protected:
    const uint8_t* getInitCommands(uint8_t listno) const override {
      static constexpr uint8_t Rcmd1[] = {                 // Init for 7735R, part 1 (red or green tab)
        CMD_SWRESET,   CMD_INIT_DELAY,  //  1: Software reset, 0 args, w/delay
          150,                    //     150 ms delay
        CMD_SLPOUT ,   CMD_INIT_DELAY,  //  2: Out of sleep mode, 0 args, w/delay
          255,                    //     500 ms delay
        CMD_FRMCTR1, 3      ,  //  3: Frame rate ctrl - normal mode, 3 args:
          0x01, 0x2C, 0x2D,       //     Rate = fosc/(1x2+40) * (LINE+2C+2D)
        CMD_FRMCTR2, 3      ,  //  4: Frame rate control - idle mode, 3 args:
          0x01, 0x2C, 0x2D,       //     Rate = fosc/(1x2+40) * (LINE+2C+2D)
        CMD_FRMCTR3, 6      ,  //  5: Frame rate ctrl - partial mode, 6 args:
          0x01, 0x2C, 0x2D,       //     Dot inversion mode
          0x01, 0x2C, 0x2D,       //     Line inversion mode
        CMD_INVCTR , 1      ,  //  6: Display inversion ctrl, 1 arg, no delay:
          0x07,                   //     No inversion
        CMD_PWCTR1 , 3      ,  //  7: Power control, 3 args, no delay:
          0xA2,
          0x02,                   //     -4.6V
          0x84,                   //     AUTO mode
        CMD_PWCTR2 , 1      ,  //  8: Power control, 1 arg, no delay:
          0xC5,                   //     VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD
        CMD_PWCTR3 , 2      ,  //  9: Power control, 2 args, no delay:
          0x0A,                   //     Opamp current small
          0x00,                   //     Boost frequency
        CMD_PWCTR4 , 2      ,  // 10: Power control, 2 args, no delay:
          0x8A,                   //     BCLK/2, Opamp current small & Medium low
          0x2A,
        CMD_PWCTR5 , 2      ,  // 11: Power control, 2 args, no delay:
          0x8A, 0xEE,
        CMD_VMCTR1 , 1      ,  // 12: Power control, 1 arg, no delay:
          0x0E,
        0xFF,0xFF
      };
      static constexpr uint8_t Rcmd2[] = {  // Init for 7735R, part 2 (red or green tab)
        CMD_GMCTRP1, 16      , //  1: 16 args, no delay:
          0x02, 0x1c, 0x07, 0x12,
          0x37, 0x32, 0x29, 0x2d,
          0x29, 0x25, 0x2B, 0x39,
          0x00, 0x01, 0x03, 0x10,
        CMD_GMCTRN1, 16      , //  2: 16 args, no delay:
          0x03, 0x1d, 0x07, 0x06,
          0x2E, 0x2C, 0x29, 0x2D,
          0x2E, 0x2E, 0x37, 0x3F,
          0x00, 0x00, 0x02, 0x10,
        CMD_NORON  ,    CMD_INIT_DELAY, //  3: Normal display on, no args, w/delay
          10,                     //     10 ms delay
        CMD_DISPON ,    CMD_INIT_DELAY, //  4: Main screen turn on, no args w/delay
          100,                    //     100 ms delay
        0xFF,0xFF
      };

      switch (listno) {
      case 0: return Rcmd1;
      case 1: return Rcmd2;
      default: return nullptr;
      }
    }
  };

Comparing TFT_eSPI and Lovyan findings

TFT_eSP --> ST7735_Init.h            Lovyan --> Panel_ST7735.hpp
Rcmd1[]     <--   almost same  -->   Rcmd1[]
Rcmd2green[]      miss
Rcmd3[]     <--   same  -->          Rcmd2[]

Add the missing instructions in Rcmd2green[] to Rcmd1[] or Rcmd2[] in Lovyan --> Panel_ST7735.hpp, similar to:

static constexpr uint8_t Rcmd1[] = {                 // Init for 7735R, part 1 (red or green tab)
        CMD_SWRESET,   CMD_INIT_DELAY,  //  1: Software reset, 0 args, w/delay
          150,                    //     150 ms delay
        CMD_SLPOUT ,   CMD_INIT_DELAY,  //  2: Out of sleep mode, 0 args, w/delay
          255,                    //     500 ms delay
        CMD_FRMCTR1, 3      ,  //  3: Frame rate ctrl - normal mode, 3 args:
          0x01, 0x2C, 0x2D,       //     Rate = fosc/(1x2+40) * (LINE+2C+2D)
        CMD_FRMCTR2, 3      ,  //  4: Frame rate control - idle mode, 3 args:
          0x01, 0x2C, 0x2D,       //     Rate = fosc/(1x2+40) * (LINE+2C+2D)
        CMD_FRMCTR3, 6      ,  //  5: Frame rate ctrl - partial mode, 6 args:
          0x01, 0x2C, 0x2D,       //     Dot inversion mode
          0x01, 0x2C, 0x2D,       //     Line inversion mode
        CMD_INVCTR , 1      ,  //  6: Display inversion ctrl, 1 arg, no delay:
          0x07,                   //     No inversion
        CMD_PWCTR1 , 3      ,  //  7: Power control, 3 args, no delay:
          0xA2,
          0x02,                   //     -4.6V
          0x84,                   //     AUTO mode
        CMD_PWCTR2 , 1      ,  //  8: Power control, 1 arg, no delay:
          0xC5,                   //     VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD
        CMD_PWCTR3 , 2      ,  //  9: Power control, 2 args, no delay:
          0x0A,                   //     Opamp current small
          0x00,                   //     Boost frequency
        CMD_PWCTR4 , 2      ,  // 10: Power control, 2 args, no delay:
          0x8A,                   //     BCLK/2, Opamp current small & Medium low
          0x2A,
        CMD_PWCTR5 , 2      ,  // 11: Power control, 2 args, no delay:
          0x8A, 0xEE,
        CMD_VMCTR1 , 1      ,  // 12: Power control, 1 arg, no delay:
          0x0E,
        // 0xFF,0xFF,

		//@- add form TFT_eSP --> ST7735_Init.h  Rcmd2green[] 
        CMD_INVOFF , 0      ,  // 13: Don't invert display, no args, no delay
        CMD_MADCTL , 1      ,  // 14: Memory access control (directions), 1 arg:
        0xC0 | 0x08, //     row addr/col addr, bottom to top refresh
        CMD_COLMOD , 1      ,  // 15: set color mode, 1 arg, no delay:
        0x05,

        CMD_CASET  , 4      ,  //  1: Column addr set, 4 args, no delay:
        0x00, 0x02,             //     XSTART = 0
        0x00, 0x7F+0x02,        //     XEND = 127
        CMD_RASET  , 4      ,  //  2: Row addr set, 4 args, no delay:
        0x00, 0x01,             //     XSTART = 0
        0x00, 0x9F+0x01,
        0xFF,0xFF,
      };

But there are still problems running

pkA568H.jpg

Environment ( 実行環境 )

  • MCU or Board name: esp32-s3
  • Panel Driver IC: ST7735S
  • Bus type: spi
  • LovyanGFX version: latest
  • Build Environment: [ArduinoIDE]

Device Name (デバイスの名称・型番等)

MCU: ESP32-S3 Arduino
TFT Model: 0.96inch, w:80p h:160p, display chip ST7735S
Pa

URL of Device Specifications document (仕様書等のURL)

https://www.panelook.com/TST09602A-0-96inch-IPS-TFT-LCD-screen-80-160-350cd-m-sup2-13PINS-SPI-ST7735S-Wearable-LCD-detail_134063.html?ac=contacts#

URL of the store where we can purchase (商品を購入できるURL)

https://www.panelook.com/TST09602A-0-96inch-IPS-TFT-LCD-screen-80-160-350cd-m-sup2-13PINS-SPI-ST7735S-Wearable-LCD-detail_134063.html
Pins:


please can you help me, thank you very much

@dingxiao88 dingxiao88 added the device support request Add new device driver label May 5, 2024
@github-actions github-actions bot added the stale Inactive issues label Jun 4, 2024
@tobozo tobozo removed the stale Inactive issues label Jun 4, 2024
@github-actions github-actions bot added the stale Inactive issues label Jul 4, 2024
@tobozo tobozo added pinned exempt from stale bot and removed stale Inactive issues labels Jul 4, 2024
Repository owner deleted a comment from github-actions bot Jul 4, 2024
Repository owner deleted a comment from github-actions bot Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
device support request Add new device driver pinned exempt from stale bot
Projects
None yet
Development

No branches or pull requests

2 participants