9 years, 3 months ago.

rendering BMP file to screen

hello,

first, i want to say you thanks for the library :-)

every function is working properly but i can't render a BMP file on the screen from the onboard sd card reader. for icons, it's the same, so i'm sure i do it wrong.

i want to make a simple photo frame.

the sd card is formatted in FAT.

how can i make this working?

gaetan

Question relating to:

1 Answer

9 years, 3 months ago.

Hi gaetan,

Thanks, I hope we can make it work for you!

I don't know if you saw some of the performance concerns in the documentation - it won't be a "fast" picture frame. See the "Performance" section on this link.

That said, let's move on to solving your problem.

I developed this on the LPC1768, and I don't have either of the ST parts listed in your profile. So, let's start with the basics and move forward.

On the LPC1768, I have shared a single SPI port between the display and an SD card. In the SW, I take care not to access both in an overlapping manner. Also, if you are sharing the SPI port, that one of the drivers configures the port in a manner not compatible with the other.

When you say every function works properly - other than the bitmap, this suggests that the RA8875 driver library is working fine, but perhaps the SD file system interface is not. This would not be an RA8875 problem, as that circuit is simply carried on the backside of the display module, and is not part of the RA8875 controller.

So, here's how I would try to solve this:

  1. If they are on the same SPI port, can you separate them to different SPI ports?
    If you cannot put them on separate ports, then can you disconnect the display, run a small test program to verify SD works, then disconnect the SD and connect the SPI and run a small program to test the display separately? If together they fail, this might be due to incompatible SPI register settings.
  2. Have you verified that you can read from the SD card?
    From my own work, I have found a near constant challenge getting SD and USB File System interfaces to work (and stay working as the mbed, mbed_rtos, and libraries evolve). I'll assume that this works for you, and proceed forward with next steps. If it does not, then we need to move in a very different direction.
  3. Have you created a simple picture - in BMP format?
    I've used Windows Paint to create a simple BMP file to test with. Something small enough (perhaps just 10 x 10 pixels) to easily debug.
  4. Both the RA8875.cpp and the GraphicsDisplay.cpp files have commented out debug - look for #define DEBUG <label> near the top and remove the comments. This does require that you have the serial port (often via USB) working with a terminal program on your host PC. If you are running Windows, here are the Windows serial configuration instructions.
  5. Do the ST parts you have support "local file system"?
    If so, then program below may be a simple test to perform, once you've remapped the IO pins to your hardware. You can put the BMP files on the local file system. There is nothing special about the BMP files. I took a picture, sized it to the display I have (480 x 272) and Save As... to 24-bit BMP, then Save As... to 8-bit BMP and once more to 16-color BMP.

The following code shows two methods to start the display. If I were a bit better at C++, I could probably explain (or solve) the differences you see below, but for now, I simply documented my observations.

#include "mbed.h"
#include "RA8875.h"

LocalFileSystem local("local");
Serial pc(USBTX, USBRX);

const char * files[] = {
    "/local/Test24.bmp", "/local/Test08.bmp", "/local/Test04.bmp"
};

#if 1
RA8875 * lcd;

int main()
{
    int i;
    RetCode_t r;

    pc.baud(460800);    // I like a snappy terminal, so crank it up!
    pc.printf("\r\nBitmap Test - Build " __DATE__ " " __TIME__ "\r\n");
    // The following run-time constructor brings the display online properly 
    // (all instantiation code runs all initializers properly)
    lcd = new RA8875(p5, p6, p7, p12, NC, "tft");    // MOSI, MISO, SCK, /ChipSelect, /reset, name
    
    // Preset the test
    lcd->puts(0,0, "Graphics Test");
    wait(3);

    for (i=0; i<sizeof(files)/sizeof(files[0]); i++) {
        pc.printf("  TestFile {%s}\r\n", files[i]);
        r = lcd->RenderBitmapFile(0,0, files[i]);
        pc.printf("    RenderBitmapFile returned {%s}.\r\n", lcd->GetErrorMessage(r));
        wait(5);
    }
    pc.printf("Test end.\r\n");
}
#else
RA8875 lcd(p5, p6, p7, p12, NC, "tft");

int main()
{
    int i;
    RetCode_t r;

    pc.baud(460800);    // I like a snappy terminal, so crank it up!
    pc.printf("\r\nBitmap Test - Build " __DATE__ " " __TIME__ "\r\n");
    // The declaration constructor (above) doe not bring the display online properly 
    // (and the following is needed)
    lcd.Reset();
    lcd.frequency(5000000);
    lcd.Power(true);
    lcd.Backlight(1);
    lcd.cls();
    
    // Preset the test
    lcd.puts(0,0, "Graphics Test");
    wait(3);

    for (i=0; i<sizeof(files)/sizeof(files[0]); i++) {
        pc.printf("  TestFile {%s}\r\n", files[i]);
        r = lcd.RenderBitmapFile(0,0, files[i]);
        pc.printf("    RenderBitmapFile returned {%s}.\r\n", lcd.GetErrorMessage(r));
        wait(5);
    }
    pc.printf("Test end.\r\n");
}
#endif

Accepted Answer

Hi David, thanks for the answer.

effectively, i think the problem is related to the file system.

when checking the datasheet, i saw that the sd card has to modes on the display(SPI and SD)... so perhaps the raio is directly connected to the SD card and i need to make a function to access this specific SD slot.(through the raio) no complete schematic of the board, so difficult to say(or, i don't find the schematic,lol)

i've got a spare spi SD card module, so i'll make the complete tests using two separate SPI ports ;-)

well, i make the tests tomorrow and say you the results.

have a nice evening!

gaetan

posted by gaetan krausch-lacroix 28 Dec 2014

Hi David, i've tested with the SD card file system and it's OK. The local file system is not implemented on the nucleo yet. The LCD put the .bmp file on the screen and an icon.

it was my mistake with the onboard sd card , it's not wired to the ra8875 spi bus. everything is working now :-)

thanks!

posted by gaetan krausch-lacroix 29 Dec 2014