LovyanGFX Settings for 3.5" Parallel RGB Display

edited August 2023 in Elecrow HMI Display

I've recently bought a few Elecrow ESP32 Displays. I've been getting them to work with various Arduino graphics libraries and have found several working configurations.

This configuration works for me with the 3.5" Parallel RGB display using the latest LovyanGFX library:

class LGFX : public lgfx::LGFX_Device
{
public:
  lgfx::Bus_Parallel16 _bus_instance;
  lgfx::Panel_ILI9488 _panel_instance;
  lgfx::Light_PWM     _light_instance;
  lgfx::Touch_FT5x06  _touch_instance;


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


      cfg.freq_write = 40000000;
      cfg.pin_wr = 18;
      cfg.pin_rd = 48;
      cfg.pin_rs = 45;


      cfg.pin_d0 = 47;
      cfg.pin_d1 = 21;
      cfg.pin_d2 = 14;
      cfg.pin_d3 = 13;
      cfg.pin_d4 = 12;
      cfg.pin_d5 = 11;
      cfg.pin_d6 = 10;
      cfg.pin_d7 = 9;
      cfg.pin_d8 = 3;
      cfg.pin_d9 = 8;
      cfg.pin_d10 = 16;
      cfg.pin_d11 = 15;
      cfg.pin_d12 = 7;
      cfg.pin_d13 = 6;
      cfg.pin_d14 = 5;
      cfg.pin_d15 = 4;
      _bus_instance.config(cfg);
      _panel_instance.bus(&_bus_instance);
    }


    {
      auto cfg = _panel_instance.config();
      cfg.panel_width     =   480;
      cfg.panel_width     =   320;
      cfg.offset_x        =     0;
      cfg.offset_y        =     0;
      cfg.pin_cs          =    -1;
      cfg.pin_rst         =    -1;
      cfg.pin_busy        =    -1;
      cfg.offset_rotation =     3;
      cfg.readable        =  true;
      cfg.invert          = false;
      cfg.rgb_order       = false;
      cfg.dlen_16bit      =  true;
      cfg.bus_shared      = false;


      _panel_instance.config(cfg);
    }


    {
      auto cfg = _light_instance.config();


      cfg.pin_bl = GPIO_NUM_46;


      _light_instance.config(cfg);
      _panel_instance.light(&_light_instance);
    }


    {
      auto cfg = _touch_instance.config();
      cfg.i2c_port = 0;
      cfg.i2c_addr = 0x38;
      cfg.pin_sda  = 38;
      cfg.pin_scl  = 39;
      cfg.pin_int  = -1;
      cfg.freq = 400000;
      
      cfg.x_min = 0;
      cfg.x_max = 479;
      cfg.y_min = 0;
      cfg.y_max = 319;


      _touch_instance.config(cfg);
      _panel_instance.setTouch(&_touch_instance);
    }


    setPanel(&_panel_instance);
  }


};

Comments

  • edited August 24

    Please note that there is a 3.5" version with a 16 bit parallel bus, the "RGB" version, a.k.a. DLC35010R, and a version with SPI, which is slightly slower.

    The parallel 3.5" board is supported by default in LovianGFX v1.1.6.
    This worked for me:

    #include <Arduino.h>
    #include <LovyanGFX.hpp>
    #include <lgfx_user\LGFX_Elecrow_ESP32_Display_DLC35010R.h>
    #include <lvgl.h>
    
    // Global constants
    LGFX lcd;
    
    static const uint16_t screenWidth  = 480;
    static const uint16_t screenHeight = 320;
    
    static lv_display_t * disp;
    static lv_color_t buf[ screenWidth * screenHeight / 8];
    static lv_draw_buf_t draw_buf;
    

    The file LGFX_Elecrow_ESP32_Display_DLC35010R.h contains the code in the original comment by benlye above (I did not check if it is exactly the same, but it works).

    The display flush callback function is:

      void disp_flush_callback( lv_display_t *disp, const lv_area_t *area, uint8_t * px_map ) {
        uint32_t w = ( area->x2 - area->x1 + 1 );
        uint32_t h = ( area->y2 - area->y1 + 1 );
    
        lcd.startWrite();
        lcd.setAddrWindow( area->x1, area->y1, w, h );
        lcd.pushPixelsDMA( ( uint16_t * ) px_map, w * h, true);
        lcd.endWrite();
    
        lv_disp_flush_ready( disp );
      }
    

    The code to initialize lvgl is:

      lv_init();
      disp = lv_display_create(screenWidth, screenHeight);
      lv_display_set_color_format(disp, LV_COLOR_FORMAT_NATIVE);
      lv_display_set_buffers(disp, buf, NULL, sizeof(buf), LV_DISPLAY_RENDER_MODE_PARTIAL);
      lv_display_set_flush_cb(disp, disp_flush_callback);
    

    I can't recall exactly what I modified in lv_conf.h, but this was pretty straightforward. At least change:

    #define LV_COLOR_DEPTH 16 
    #define LV_DPI_DEF 160     /*[px/inch]*/
    

    I noticed that many important function names were changed in v9 of LVGL, but were not yet updated in the documentation. This was quite a challenge for a beginner like me, but I am really pleased that it works now. It is of course also possible to use an earlier version of LVGL, but the callback function and init procedures must then be a little different.
    I have not tested the capacitive touch yet, which will be my next step.
    Enjoy!

Sign In or Register to comment.