Hi, I asked this issue to LovyanGFX github too. The issue is that it shows 2 different colors with the same code, just different number of pixel.
Environment
- MCU or Board name: ESP32-S3-N16R8
- Panel Driver IC: ST7796 - 320x480
- Bus type: Parallel8
- LovyanGFX version: 1.2.7
- FrameWork version: framework-arduinoespressif32 @ 3.20017.0 (2.0.17)
- Build Environment: PlatformIO - Core 6.1.18 - Home 3.4.4
- Operating System: Windows
Problem Description
This is the minimal block of code that describes my issue.
I draw 2 lines with different number of pixels (1st line has 131 pixels and 2nd line has 130 pixels), the same color code, and the lcd shows 2 lines with different colors.
Expected Behavior
It should show 2 lines with the same color
Actual Behavior
It shows different colors with the same code.
Steps to reproduce
- I prepare a uint16_t array which is filled with TFT_RED color code.
- I use setAddrWindow w = 131, h = 1 (one line), pushPixels with len = 131, the lcd shows a BLUE line
- I use setAddrWindow w = 130, h = 1 (one line), pushPixels with len = 130, the lcd shows a RED line
- I draw a 50x50 red square to check the color, it shows correct red square
Code to reproduce this issue
#include <Arduino.h>
#include <LovyanGFX.hpp>
// Create a display class
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7796 _panel_instance; // Change this to your LCD driver
lgfx::Bus_Parallel8 _bus_instance; // Parallel 8-bit bus
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.freq_write = 4000000; // 4MHz
cfg.pin_wr = 12; // WR pin
cfg.pin_rd = 11; // No read pin
cfg.pin_rs = 7; // RS (D/C) pin
// Data bus pins (D0 - D7)
cfg.pin_d0 = 14;
cfg.pin_d1 = 13;
cfg.pin_d2 = 10;
cfg.pin_d3 = 9;
cfg.pin_d4 = 3;
cfg.pin_d5 = 4;
cfg.pin_d6 = 2;
cfg.pin_d7 = 1;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{ // Configure display panel
auto cfg = _panel_instance.config();
cfg.pin_cs = 5; // No CS pin required for parallel mode
cfg.pin_rst = 6; // Reset pin
cfg.invert = false; // Set `true` if colors are inverted
cfg.rgb_order = false; // RGB or BGR order
cfg.dlen_16bit = false; // Use 8-bit mode
cfg.bus_shared = false; // Parallel bus is not shared
_panel_instance.config(cfg);
}
setPanel(&_panel_instance);
}
};
LGFX _tft;
uint16_t *pBitmap = nullptr;
void setup()
{
Serial.begin(115200);
/* Enable LCD */
pinMode(48, OUTPUT); digitalWrite(48, HIGH);
/* Init LCD */
_tft.init();
_tft.fillScreen(TFT_BLACK);
/* Prepare data */
int32_t PIXELS_NUM = 150;
pBitmap = (uint16_t *)calloc(PIXELS_NUM, sizeof(uint16_t));
for (int i = 0; i < PIXELS_NUM; i++) {
pBitmap[i] = TFT_RED;
}
/* Draw one line */
_tft.setAddrWindow(0, 0, 131, 1 /* ONE line */);
_tft.pushPixels((const uint16_t *)pBitmap, 131);
// delay(1000); // No difference with or without delay
/* Draw another line */
_tft.setAddrWindow(0, 10, 130, 1 /* ONE line */);
_tft.pushPixels((const uint16_t *)pBitmap, 130);
/* Draw a red square */
_tft.fillRect(0, 20, 50, 50, TFT_RED);
}
void loop()
{}
