lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.03k stars 189 forks source link

Add ILI9806G panel support #478

Closed Dimision closed 5 months ago

Dimision commented 5 months ago

Add ILI9806G panel support Tested with ESP32-S3-N16R8 module with 16bit Parallel Bus.

Module model: TK050F5590 v1.3 Panel Driver IC is ILI9806G With capacitive touch screen, Driver IC is FT5436DQQ (Compatible with built-in FT5X06 driver)

Code of Configurations:

#define LGFX_USE_V1
#include <LovyanGFX.hpp>

class LGFX : public lgfx::LGFX_Device
{
    lgfx::Panel_ILI9806     _panel_instance;
    lgfx::Bus_Parallel16  _bus_instance;
    lgfx::Light_PWM     _light_instance;
    lgfx::Touch_FT5x06           _touch_instance; // FT5206, FT5306, FT5406, FT6206, FT6236, FT6336, FT6436
  public:
    LGFX(void)
    {
      {
        auto cfg = _bus_instance.config();    // バス設定用の構造体を取得します。
        cfg.port = 0;
        cfg.freq_write = 20000000;
        cfg.pin_wr = 14;
        cfg.pin_rd = 42;
        cfg.pin_rs = 38;
        cfg.pin_d0 = 12;
        cfg.pin_d1 = 11;
        cfg.pin_d2 = 10;
        cfg.pin_d3 = 9;
        cfg.pin_d4 = 20;
        cfg.pin_d5 = 19;
        cfg.pin_d6 = 8;
        cfg.pin_d7 = 18;
        cfg.pin_d8 = 17;
        cfg.pin_d9 = 16;
        cfg.pin_d10 = 15;
        cfg.pin_d11 = 7;
        cfg.pin_d12 = 6;
        cfg.pin_d13 = 5;
        cfg.pin_d14 = 4;
        cfg.pin_d15 = 1;
        _bus_instance.config(cfg);
        _panel_instance.setBus(&_bus_instance);
      }
      {
        auto cfg = _panel_instance.config();
        cfg.pin_cs           =    39;
        cfg.pin_rst          =    13;
        cfg.pin_busy         =    -1;
        cfg.panel_width      =   480;  // 実際に表示可能な幅
        cfg.panel_height     =   854;  // 実際に表示可能な高さ
        cfg.offset_x         =     0;  // パネルのX方向オフセット量
        cfg.offset_y         =     0;  // パネルのY方向オフセット量
        cfg.offset_rotation  =     1;  // 回転方向の値のオフセット 0~7 (4~7は上下反転)
        cfg.dummy_read_pixel =     8;  // ピクセル読出し前のダミーリードのビット数
        cfg.dummy_read_bits  =     1;  // ピクセル以外のデータ読出し前のダミーリードのビット数
        cfg.readable         =  false;  // データ読出しが可能な場合 trueに設定
        cfg.invert           = false;  // パネルの明暗が反転してしまう場合 trueに設定
        cfg.rgb_order        = true;  // パネルの赤と青が入れ替わってしまう場合 trueに設定
        cfg.dlen_16bit       = true;  // 16bitパラレルやSPIでデータ長を16bit単位で送信するパネルの場合 trueに設定
        cfg.bus_shared       =  true;  // SDカードとバスを共有している場合 trueに設定(drawJpgFile等でバス制御を行います)
        _panel_instance.config(cfg);
      }
      {
        auto cfg = _light_instance.config();    // バックライト設定用の構造体を取得します。
        cfg.pin_bl = 2;              // バックライトが接続されているピン番号
        cfg.invert = false;           // バックライトの輝度を反転させる場合 true
        cfg.freq   = 44100;           // バックライトのPWM周波数
        cfg.pwm_channel = 7;          // 使用するPWMのチャンネル番号
        _light_instance.config(cfg);
        _panel_instance.setLight(&_light_instance);  // バックライトをパネルにセットします。
      }
      {
        auto cfg = _touch_instance.config();
        cfg.x_min      = 0;    // タッチスクリーンから得られる最小のX値(生の値)
        cfg.x_max      = 854;  // タッチスクリーンから得られる最大のX値(生の値)
        cfg.y_min      = 0;    // タッチスクリーンから得られる最小のY値(生の値)
        cfg.y_max      = 480;  // タッチスクリーンから得られる最大のY値(生の値)
        cfg.pin_int    = 21;   // INTが接続されているピン番号
        cfg.bus_shared = true; // 画面と共通のバスを使用している場合 trueを設定
        cfg.offset_rotation = 3;// 表示とタッチの向きのが一致しない場合の調整 0~7の値で設定
        cfg.i2c_port = 0;      // 使用するI2Cを選択 (0 or 1)
        cfg.i2c_addr = 0x38;   // I2Cデバイスアドレス番号
        cfg.pin_sda  = 41;     // SDAが接続されているピン番号
        cfg.pin_scl  = 40;     // SCLが接続されているピン番号
        cfg.freq = 400000;     // I2Cクロックを設定
        _touch_instance.config(cfg);
        _panel_instance.setTouch(&_touch_instance);  // タッチスクリーンをパネルにセットします。
      }
      setPanel(&_panel_instance); // 使用するパネルをセットします。
    }
};

// 準備したクラスのインスタンスを作成します。
LGFX display;

be00528bf08731bd8a974d4fb37d7c9

tobozo commented 5 months ago

h and thanks for your contribution :+1:

can you please edit this PR and target the develop branch instead of master

Dimision commented 5 months ago

h and thanks for your contribution 👍

can you please edit this PR and target the develop branch instead of master

h and thanks for your contribution 👍

can you please edit this PR and target the develop branch instead of master

Sure, I'm sorry for submitting PR to incorrect branch

lovyan03 commented 5 months ago

Thanks for your PR !