Bodmer / TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
Other
3.83k stars 1.1k forks source link

drawLine not working if x < y #149

Closed wawibu closed 6 years ago

wawibu commented 6 years ago

try to draw a graph line and need therefore draw multiple small lines. As soon as the width of the line is smaller than the height, the function draws nothing.

eg. drawLine(5,156,15,156,TFT_White); << works fine drawLine(5,156,15,170,TFT_White); << draws nothing

tried this also with wider ranges, but the issue is the same. So if x width would be 20 and y height would be 21 it will not draw a line.

Bodmer commented 6 years ago

ESP32 or ESP8266? SPI or parallel? Which TFT driver?

wawibu commented 6 years ago

sorry - missed that ESP8266 4 wire SPI (40Mhz - tried 20Mhz as well without any differences) HX8357D tried on a second ESP and second display but is the same. 2018-05-28 at 21 45 28

Bodmer commented 6 years ago

Interesting, it appears that the drawLine is failing on the HX8357D display even though it works fine on other displays I have. It looks like the lines that would be classed as "steep" are not being drawn which is strange. I will think on this further as it seems peculiar to the display you have, unfortunately I do not have one of that type to try. Are you sure this is not a bug in your sketch? Can you provide a simple sketch that demonstrates the problem.

wawibu commented 6 years ago

good catch, created a simple sketch (code below) and uploaded that once to the ESP8266 for HX8357D and on a second ESP8266 with ILI9341 line is fully drawn on the ILI9341 but missing parts on the HX8357D

include

include

// TFT Backlight Pin

define TFT_LED D8

TFT_eSPI TFT = TFT_eSPI();

void setup() { TFT.init(); TFT.setRotation(3); TFT.fillScreen(TFT_BLACK); pinMode(TFT_LED, OUTPUT); // Display Backlight LED Pin digitalWrite(TFT_LED, HIGH); // HIGH to turn Display Backlight on TFT.drawLine( 5, 56, 15, 56,TFT_WHITE); TFT.drawLine( 15, 56, 25, 56,TFT_WHITE); TFT.drawLine( 25, 56, 35, 70,TFT_WHITE); TFT.drawLine( 35, 70, 45, 70,TFT_WHITE); TFT.drawLine( 45, 70, 55, 98,TFT_WHITE); TFT.drawLine( 55, 98, 65,112,TFT_WHITE); TFT.drawLine( 65,112, 75,126,TFT_WHITE); TFT.drawLine( 75,126, 85,154,TFT_WHITE); TFT.drawLine( 85,154, 95,168,TFT_WHITE); TFT.drawLine( 95,168,105,168,TFT_WHITE); TFT.drawLine(105,168,115,182,TFT_WHITE); TFT.drawLine(115,182,125,196,TFT_WHITE); TFT.drawLine(125,196,135,210,TFT_WHITE); TFT.drawLine(135,210,145,210,TFT_WHITE); TFT.drawLine(145,210,155,210,TFT_WHITE); TFT.drawLine(155,210,165,196,TFT_WHITE); TFT.drawLine(165,196,175,168,TFT_WHITE); TFT.drawLine(175,168,185,140,TFT_WHITE); TFT.drawLine(185,140,195,126,TFT_WHITE); TFT.drawLine(195,126,205, 98,TFT_WHITE); TFT.drawLine(205, 98,215, 84,TFT_WHITE); TFT.drawLine(215, 84,225, 70,TFT_WHITE); TFT.drawLine(225, 70,235, 70,TFT_WHITE); }

void loop() { while (1) { yield(); } }

20180529_221758

Bodmer commented 6 years ago

OK, I have made a change to the TFT_eSPI.cpp file, try downloading that file fro GitHub and replacing the one in your library, try the test sketch again. Let me know if this does or does not fix it.

wawibu commented 6 years ago

works! perfect - thanks a lot - closing it right now

Bodmer commented 6 years ago

Thanks for reporting this and helping to solve this issue. Hope your project proceeds without further problems!

Hamed-Elahi commented 3 years ago

Hello,

can you tell me what the problem was?

I have the same problem with this LCD "HY32D". The driver is for ILI9325.

When the code reads the ID of the LCD, then it prints ILI9326.