rDuinoscope and Waveshare 4" LCD

Hi, Before I am called a idiot, I know I am. Being a new be and still learning the programming language I am stuck and do not know how to move forward.

I own a Waveshare 4" LCD and decided to try and use it with rDuinoscope. I found a sketch that uses the ILI9488 library and thought this is the closes to the ILI9486 that my LCD uses. I found the ILI9486_SPI library by ZinggJM and changed the sketch to use this library. the compiler had a problem with two commands "setAddrWindow " and "pushColor". For starters I just commented those two lines out. The sketch then compiled. The LCD displays everything as expected, except the bitmaps(as expected). I tried a lot of things but not getting anywhere.
I tried using the sketch as is with ILI9488 library and it displays but with little bad colors. The bitmaps is displayed but garbled.

What I like to know is if someone has maybe got rDuinoscope to work with this LCD or
Would someone like to take up the challenge to make this work.


@anon77222424, Hi,

I had some problems to understand your post and what you would like to do. But I think I got it.

For this Displays section of the forum, you should always post clickable links to the devices you have. Then it becomes much clearer. And a link to the library the original source used (ok, I found it through the link provided).

ILI9486_SPI should work with your Waveshare ILI9486 display, using the "special" SPI serial to parallel 16bit converter circuit.

But it uses only Adafruit_GFX, without Adafruit_SPITFT, and therefore has slightly different syntax for these methods:

    void setWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
    void pushColors(const uint16_t* data, uint16_t n); // fast one

You should be able to adapt to these. pushColor() would be pushColors() with 1 for n, and a pointer to the value instead of the value itself.

The bare ILI9488 panel would use native SPI with 18bit / 3 bytes color values per pixel, and a different initialization code.

I am busy with e-paper displays currently, so I can't help you further.


Thanks for your reply.
The problem I have is how change the code or how to implement "pushColors"

 if ((bmpDepth == 24) && (read32(bmpFile) == 0)) // 0 = uncompressed
        goodBmp = true; // Supported BMP format -- proceed!
        // BMP rows are padded (if needed) to 4-byte boundary
        rowSize = (bmpWidth * 3 + 3) & ~3;

        // If bmpHeight is negative, image is in top-down order.
        // This is not canon but has been observed in the wild.
        if (bmpHeight < 0)
          bmpHeight = -bmpHeight;
          flip      = false;
        // Crop area to be loaded
        w = bmpWidth;
        h = bmpHeight;
        if ((x + w - 1) >= tft.width())  w = tft.width()  - x;
        if ((y + h - 1) >= tft.height()) h = tft.height() - y;

 // Set TFT address window to clipped image bounds
        tft.setAddrWindow(x, y, x + w - 1, y + h - 1);

        for (row = 0; row < h; row++) { // For each scanline...

          if (flip) // Bitmap is stored bottom-to-top order (normal BMP)
            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
          else     // Bitmap is stored top-to-bottom
            pos = bmpImageoffset + row * rowSize;
          if (bmpFile.position() != pos)
          { // Need seek?
            buffidx = sizeof(sdbuffer); // Force buffer reload

          for (col = 0; col < w; col++) { // For each pixel...
            // Time to read more pixel data?
            if (buffidx >= sizeof(sdbuffer)) { // Indeed
              bmpFile.read(sdbuffer, sizeof(sdbuffer));
              buffidx = 0; // Set index to beginning

            // Convert pixel from BMP to TFT format, push to display
            b = sdbuffer[buffidx++];
            g = sdbuffer[buffidx++];
            r = sdbuffer[buffidx++];
            tft.pushColor(tft.color565(r, g, b));
          } // end pixel
        } // end scanline
      } // end goodBmp


uint16_t color = tft.color565(r, g, b);
tft.pushColors(&color, 1);

untested. I am busy!

Thanks a lot. This work partially. But at least now it is compiling. It seems that the "setWindow" is not creating the right size window and displayed Bmp is bigger than screen.

You gave me something to work with.

I don't want to take up anymore of your time.

setAddrWindow() takes x_end and y_end as parameters.
setWindow() takes w and h.

Hi, I changed the
tft.setAddrWindow(x, y, x + w - 1, y + h - 1);

tft.setWindow(x, y, w ,h);

and every thing seem to be working fine now. Just one qeustion : should I stick with "w - 1" and "h - 1"

Thanks for your help. You made my day.

is correct. The "end address" is one less than the sum of start and width or height.

BTW: welcome to the forum! Are you a second incarnation or a separate poster?

Sorry not sure what you're asking.
I am just a hobbyist trying to build some projects for personal use.

I was surprised by your question, when I noticed you are not the original poster.
So I don't know the context of your question.

Sorry for the confusion. Posted from my home computer. Seems I have not updated my account details there yet.

Can you please explain something about the touch screen. How does it know the size of the screen(physical). Why I am asking is because though the resolution of my LCD and the one used in the original sketch is the same. My LCD is 4" and the sketch LCD is 3.5". Do I need to make changes in the sketch to compensate for that.

I am still not sure if you use a Waveshare board, or a TFT panel connected to a rDuinoscope board. At least now I know you have a TFT panel with touch overlay. But not if it is resistive or capacitive, and if it has its own controller, and which one. Please post a link.

The size of the touch panel doesn't matter. But the resolution does. In general, each touch panel needs to get calibrated. But this depends on the touch driver you use. I have no experience with this.


Sorry about that.



Using this library

1 Like

Thank you for the links! I got the same display recently, but had no time to test it yet.
Good to know there is an XPT2046 touch controller driver from thingpulse.


From Github ThingPulse said:

Update 2021-08-24: this is no longer relevant as the underlying issue was addressed with Release Version 1.4 · PaulStoffregen/XPT2046_Touchscreen · GitHub. Please use XPT2046_Touchscreen >=1.4.

I am going to try that library and will post findings.

Ok i tried this library:


It works the same as the one from TingPulse. I think I will stick with this one because of possible future updates.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.