This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Display image from SD card



Hello, 

I am working TM4C123GH6PMI (equivalent to LM4f230) on a custom board. 

My problem definition is, to display image on LCD by reading the image stored on SD card. 

Please find the project attached with this post. 

I have tried the following things,
1. I have converted the JPeg Image into PNM format using GIMP tool. SO that i can pass the array pointer to GrImageDraw.
2. The array created in .h file has been put onto SD card. (SD card path :  /Image/g_run.txt . Find the attachment as g_run.txt)
3. I have defined a huge array so that i can read all the contents of the array from sd card. (char LineBuf[5000])
4. I read the contents of array in a local buffer. (in LineBuf[])
5. Then i pass the local buffer with this to GrImageDraw(). It reads as follows. 
            GrImageDraw(&sContextMAIN,(const unsigned char*)LineBuf, 10,30);
6. I see nothing displayed on the screen. 
            (Expected : white screen with content Flexi and a image of RUN)
 One more thing i have observed is, this method wont work for large images due to memory problems. 
 For some reason GrImageDraw() does not read and display the image from this buffer.
The main file is called Flexi_main.c. The screen display where i do GrImageDraw() is in EntryScreen( ) ,i.e., Screen.c file. 
 Here what i am able to achieve was, to get the complete image stored in SD card in a local buffer.

I am new to do something like this. I did go through a post in LM3s , where same thing is tried to do. But i dint understand the solution clearly. An elaborate answer would be highly appreciated. 

{
IMAGE_FMT_8BPP_COMP,
25, 0,
25, 0,
97,

0x04, 0x8c, 0x0f,
0x2b, 0xb4, 0x32,
0x38, 0xba, 0x22,
0x40, 0xae, 0x3c,
0x36, 0xb7, 0x31,
0x3f, 0xb8, 0x2e,
0x4b, 0xb3, 0x3e,
0x2f, 0xc3, 0x29,
0x35, 0xbf, 0x31,
0x4c, 0xb4, 0x3f,
0x3e, 0xc0, 0x2e,
0x2b, 0xca, 0x22,
0x43, 0xbc, 0x35,
0x39, 0xb8, 0x42,
0x46, 0xb5, 0x44,
0x4b, 0xb2, 0x49,
0x31, 0xb9, 0x46,
0x3d, 0xbd, 0x3a,
0x2e, 0xc1, 0x38,
0x4e, 0xb6, 0x42,
0x34, 0xbd, 0x3e,
0x47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x70, 0x59, 0x3f, 0x3f, 0x39, 0x21, 0x1b, 0x17, 0x55,
0xe1, 0x3f, 0x3f, 0x39, 0x26, 0x12, 0x17, 0x54, 0x3f, 0xc3, 0x3f, 0x39,
0x1d, 0x21, 0x15, 0x53, 0x3f, 0x3f, 0x87, 0x39, 0x22, 0x22, 0x18, 0x58,
0x3f, 0x3f, 0x39, 0x0e, 0x25, 0x1e, 0x17, 0x57, 0x3f, 0x3f, 0x39, 0x1d,
0x1c, 0x08, 0x0e, 0x52, 0x3f, 0x3f, 0x3a, 0x22, 0x15, 0xe1, 0x3f, 0x3f,
0x3a, 0x0a, 0x22, 0x15, 0x58, 0x3f, 0xc3, 0x3f, 0x39, 0x24, 0x25, 0x18,
0x52, 0x3f, 0x3f, 0x87, 0x39, 0x1c, 0x16, 0x1a, 0x50, 0x3f, 0x3f, 0x3a,
0x1d, 0x07, 0x1a, 0x52, 0x3f, 0x3f, 0x39, 0x28, 0x3f, 0xc3, 0x3f, 0x3c,
0x22, 0x22, 0x15, 0x54, 0x3f, 0x3f, 0x84, 0x39, 0x20, 0x1e, 0x13, 0x51,
0x39, 0x32, 0x36, 0x04, 0x60, 0x34, 0x28, 0x05, 0x46, 0x3a, 0x40, 0x3b,
0x42, 0x10, 0x3a, 0x1e, 0x07, 0x09, 0x4e, 0x39, 0x41, 0x02, 0x32, 0x5d,
0x2c, 0x0a, 0x0c, 0x49, 0x3a, 0x2f, 0x20, 0x3f, 0x04, 0x39,
};

5807.DisplayImgFrmSD.rar

Thank and regards,

Savita 

  • I've not tried building and debugging your project but here's what I would do.

    1. Make completely sure that my custom board's graphics driver is debugged and known to work correctly. Start by porting the "hello" and "grlib_demo" applications to your board and make sure they run correctly.
    2. Build a testcase that links your test image directly into the application (i.e. don't try to read it from the SDCard) and make sure the image displays correclty.
    3. Update your testcase to add the SDCard access and get that working.

    Once you complete all these steps, then start working on integrating everything into the main application. Step-by-step is normally a lot easier than trying to get everything working at once!

  • Second Dave's advice w/these slight additions:

    a) insure that the display you're using is compatible (both HW & SW) with the display that was targeted by "hello" & grlib_demo."  You may have to make hardware and/or software changes should there be any differences.  Your use of a custom board and unspecified Lcd may confound your "easy hook" to any, "past application."

    b) prove the concept using a small, simple image for testing.  (bigger is not better - at this early stage)

    Dave's guidance to: "test by placing your (small, simple) image solely w/in your application code," and only after that succeeds, "then move that exact (small, simple) image to the SD card - and re-test" - is extremely well advised.

  • I think I failed to mention one of my main assumptions. When "custom board" is mentioned, I assume that the display on that board is likely to be something different from the display on our EK or DK. This, therefore, assumes that the poster has written a brand new display driver.

    In many previous problems of this sort, the bug has been in the display driver and, specifically, incorrect handling of the PixelDrawMultiple function. This function, which is used when displaying images and text, is the most complex in the driver and contains lots of cases, each of which need to be tested before the driver as a whole can be considered to be working correctly. Often, some cases work but some do not so, for example, text displays correctly (because the 1bpp path through the function is OK) but some images don't (because they may be 4bpp or 8bpp and that path has a bug).

    I'm working on a test application to include in the release that will exercise all the display driver functions and make it obvious to the user if something is broken. I expect this will help resolve many of these issues and make integrating a new display somewhat simpler.

  • Dave Wilson said:
    ... exercise all the display driver functions...make it obvious to the user if something is broken.

    Believe this to be most sound & welcome - look forward to its arrival.

    May I suggest an added tack - with a similar (save time/effort - even damage) objective?  Quite often there may be a HW (i.e. improper connection, or bad contrast adjustment) issue - which will "evade" your display driver function diagnosis. 

    Suspect that the first order of, "display diagnosis" may be to get some few pixels to properly appear - thus verifying that the basic MCU -> Display connections, contrast settings & display voltages/backlighting is, "properly present - and accounted for!"  Believe that a simplifed, "PixelDrawSingle()" function (usually 1bpp) is best suited in this role - and propose here for your consideration...  (has the added benefit of more quickly recognizing, "trouble" - thus minimizing potential damage to the MCU, Display, board etc...)

    As always - we appreciate, value and applaud your efforts...

  • Fear not - the example will be command line based and allow you to exercise specific functions and draw specific things at specific positions (to help with debug) as well as showing helpful test patterns.

  • Dave Wilson said:
    Fear not

    Indeed - hauntingly similar to, "If you like your display - you can keep your display..."

    My (perhaps valid) fear is that even "command-line" based methods must properly emphasize & insure that all needed display connections, and other "vitals" - have been correctly & fully implemented (& well tested) prior to roll-out. 

  • Hi Dave, Good Morning! Thank you for your response. In the first post you mentioned 3 steps. I have done the same sequence to arrive at this stage. i.e., 1. I am using Epson controller as a driver to LCD. And use Epson driver itself. 2. I have got the graphics calls of graphics library working. 3. I have got the SD card and the display working in a same project. 4. I got the image display on screen by putting the hex file generated by Gimp in the project. Passing the pointer to this array in GRImageDraw(). So when image is held in flash it works completely fine. 5. Next i tried to display image from SD card. I will read your next posts. this is reply to your first post.