Crowpanel 4.3(v2.1) LovyanGFX(v1.2.19) fillRect doesn't work correctly

It can't draw a 1-pixel-wide rectangle and there are other glitches. Text is drawn using fillRect, and all vertical lines are 1 pixel too small. If the width is only 1 pixel, there's no line at all.
What's the cause?
forum.elecrow.com/uploads/editor/x4/1cc4zr496ofr.png
Part of the code from the image:
for (int i=1; i <= 48; i++){
tft.fillRect(10+i, 10+i, 100-(i2), 100-(i2), tft.color888(255(i%2), 255(i%2), 255(i%2)));
}
for (int i=1; i <= 25; i++){
tft.fillRect(380, 10+(i
4), 100, 1, TFT_WHITE);
}
for (int i=1; i <= 25; i++){
tft.fillRect(380+(i*4), 10, 1, 100, TFT_WHITE);
}

Comments

  • HI aggress,
    Sorry, it seems you're using your own code, right?

    We apologize, but we can only provide technical support for our sample code and hardware. You'll need to investigate the issues with your code yourself. You can search online or consult AI.

    You can also refer to our sample code and tutorials, which are available on the following website:
    https://www.elecrow.com/pub/wiki/
    Thanks!
    Warm regards,

  • Okay, let's take your code CrowPanel_ESP32_Tutorial\Code\V2.X\Lesson 2 Draw GUI with LovyanGFX\4.3inch_5inch_7inch\Draw\Draw.ino, change tft.setTextSize(3); to tft.setTextSize(1); and the vertical stripes in the text are not drawn.
    forum.elecrow.com/uploads/editor/wa/8aegy1117ac8.jpg

  • Or even change nothing at all. Look at how the font is rendered. At its native size, the lines should be one pixel wide, but since you've set the size to 3, the lines should be 3 pixels wide. However, the font's vertical lines are 2 pixels wide.
    forum.elecrow.com/uploads/editor/e0/xh42mcqftjnx.jpg

  • drawLine() uses the same drawing function (writeFillRectPreclipped()) as fillRect(), and vertical lines are simply not drawn.

  • HI aggress,
    I am Sorry, this issue requires some time for our team to analyze. I will get back to you as soon as we finish the analysis. Please wait patiently.

    Sorry for the inconvenience caused.
    Warm regards,

  • HI aggress,

    In LovyanGFX's RGB panel implementation, fillRect() ultimately calls writeFillRectPreclipped(). In some versions, there's a bug in the clipping calculation: When width = 1, the internal calculation becomes: x_end = x + width - 1. Then, in the clip condition, it becomes: if (x >= x_end) return;. The result is: width=1 → x_end=x, which is considered a width of 0, and therefore not drawn. So, the actual drawing is: width=2 1px and width=1 0px. This results in: Vertical lines being 1px shorter, and width=1 being completely invisible. A simple solution is to set the minimum width to 2.

    Alternatively, upgrade LovyanGFX to version 1.2.23.

    Thanks!
    Warm regards,

  • edited March 13

    Thanks, but where can I get version 1.2.23? I can't see it in the Arduino IDE, and it's not listed at github.com/lovyan03/LovyanGFX/releases.

Sign In or Register to comment.