Advertisement
balatech

gfx_config

Jan 2nd, 2025 (edited)
55
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 2.91 KB | Source Code | 0 0
  1. // SAVE THIS AS gfx_conf.h in the same folder as the .ino file
  2. #define LGFX_USE_V1
  3. #include <LovyanGFX.hpp>
  4. #include <lgfx/v1/platforms/esp32s3/Panel_RGB.hpp>
  5. #include <lgfx/v1/platforms/esp32s3/Bus_RGB.hpp>
  6.  
  7. class LGFX : public lgfx::LGFX_Device {
  8. public:
  9.   // Instances for the RGB bus and panel.
  10.   lgfx::Bus_RGB     _bus_instance;
  11.   lgfx::Panel_RGB   _panel_instance;
  12.   lgfx::Light_PWM   _light_instance;
  13.  
  14.   // Constructor for the LGFX class.
  15.   LGFX(void) {
  16.  
  17.     // Configure the panel.
  18.     {
  19.       auto cfg = _panel_instance.config();
  20.       cfg.memory_width  = 800;
  21.       cfg.memory_height = 480;
  22.       cfg.panel_width   = 800;
  23.       cfg.panel_height  = 480;
  24.       cfg.offset_x      = 0;
  25.       cfg.offset_y      = 0;
  26.  
  27.       // Apply configuration to the panel instance.
  28.       _panel_instance.config(cfg);
  29.     }
  30.  
  31.     {
  32.       auto cfg = _panel_instance.config_detail();
  33.  
  34.       cfg.use_psram = 1;
  35.  
  36.       _panel_instance.config_detail(cfg);
  37.     }
  38.  
  39.  
  40.     // Configure the RGB bus.
  41.     {
  42.       auto cfg = _bus_instance.config();
  43.       cfg.panel = &_panel_instance;
  44.  
  45.       // Configure data pins.
  46.       cfg.pin_d0  = GPIO_NUM_15; // B0
  47.       cfg.pin_d1  = GPIO_NUM_7;  // B1
  48.       cfg.pin_d2  = GPIO_NUM_6;  // B2
  49.       cfg.pin_d3  = GPIO_NUM_5;  // B3
  50.       cfg.pin_d4  = GPIO_NUM_4;  // B4
  51.      
  52.       cfg.pin_d5  = GPIO_NUM_9;  // G0
  53.       cfg.pin_d6  = GPIO_NUM_46; // G1
  54.       cfg.pin_d7  = GPIO_NUM_3;  // G2
  55.       cfg.pin_d8  = GPIO_NUM_8;  // G3
  56.       cfg.pin_d9  = GPIO_NUM_16; // G4
  57.       cfg.pin_d10 = GPIO_NUM_1;  // G5
  58.      
  59.       cfg.pin_d11 = GPIO_NUM_14; // R0
  60.       cfg.pin_d12 = GPIO_NUM_21; // R1
  61.       cfg.pin_d13 = GPIO_NUM_47; // R2
  62.       cfg.pin_d14 = GPIO_NUM_48; // R3
  63.       cfg.pin_d15 = GPIO_NUM_45; // R4
  64.  
  65.       // Configure sync and clock pins.
  66.       cfg.pin_henable = GPIO_NUM_41;
  67.       cfg.pin_vsync   = GPIO_NUM_40;
  68.       cfg.pin_hsync   = GPIO_NUM_39;
  69.       cfg.pin_pclk    = GPIO_NUM_0;
  70.       cfg.freq_write  = 14000000;
  71.  
  72.       // Configure timing parameters for horizontal and vertical sync.
  73.       cfg.hsync_polarity    = 0;
  74.       cfg.hsync_front_porch = 40;
  75.       cfg.hsync_pulse_width = 48;
  76.       cfg.hsync_back_porch  = 40;
  77.      
  78.       cfg.vsync_polarity    = 0;
  79.       cfg.vsync_front_porch = 1;
  80.       cfg.vsync_pulse_width = 31;
  81.       cfg.vsync_back_porch  = 13;
  82.  
  83.       // Configure polarity for clock and data transmission.
  84.       cfg.pclk_active_neg   = 1;
  85.       cfg.de_idle_high      = 0;
  86.       cfg.pclk_idle_high    = 0;
  87.  
  88.       // Apply configuration to the RGB bus instance.
  89.       _bus_instance.config(cfg);
  90.     }
  91.      
  92.  
  93.     {
  94.       auto cfg = _light_instance.config();
  95.       cfg.pin_bl = GPIO_NUM_2;
  96.       _light_instance.config(cfg);
  97.     }
  98.     _panel_instance.light(&_light_instance);
  99.  
  100.     // Set the RGB bus and panel instances.
  101.     _panel_instance.setBus(&_bus_instance);
  102.     setPanel(&_panel_instance);
  103.   }
  104. };
  105.  
  106. static LGFX lcd;
Advertisement
Comments
  • balatech
    18 days
    # text 0.10 KB | 0 0
    1. This is the configuration file for the lcd. It contains the pin assignments to enable the display to work.
Add Comment
Please, Sign In to add comment
Advertisement