Displaying a bitmap on a gLCD

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Displaying a bitmap on a gLCD

Post by Benj »

Hello,

I am probably going to write this up as an official article but in the mean time I thought I would release the software to see if anyone could put it to good use or find any other uses for this.

Basically we have wanted to be able to display images onto a graphical LCD for a long time now but been unable to control the data source effectively.

Now using the FAT component I have written a routine that will directly parse through a standard 24-bit bitmap file and print it to a graphical display.

To do this project you will first need a target microcontroller that can run the FAT component. eg a PIC18, AVR, ARM, PIC24 or dsPIC. I don't think there are any PIC16 devices that can support the FAT buffer required to drive the FAT component. Secondly you need the graphical display, note that the EB057/58 display requires hardware SPI so you will have to use software SPI for the FAT component to allow this display to work.

You will also need a copy of Fowcode v5 for your target microcontroller to allow you to import or open the example file. The programs are written in v5 as this allows the macros to be fairly standalone to allow you to export and import the bitmap handler macros into existing programs.

Program 1 demonstrates how to display known images by using a pre determined file name. The program then reads the image from the card and displays a list of the image properties such as height, width, compression etc, before outputting the image to the display.

Program 2 demonstrates how to dynamically browse through a folder looking for a specific file type (in this case .bmp). The end result of this program is a replication of a standard electronic photo frame where you pop your pictures on to a card (in the right dimensions and bitmap format) and the program automatically displays each picture in a loop with a few seconds delay between each image.

With a bit of work it should be possible to change the print function so it will scale and display any size bitmap to the appropriate width or height for the display whilst maintaining the aspect ratio. The downside to this is that larger bitmap files would be much slower to process and display.

The function should work as is to allow small sprites or background images to be loaded directly onto the display in any x,y location. On a larger and faster device like a dsPIC or PIC24 you could probably read the sprite image data directly into RAM and then have it readily available to print to the display on command without having to re-parse the bitmap file.
Attachments
Bitmap on gLCD.zip
(161.39 KiB) Downloaded 839 times

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Displaying a bitmap on a gLCD

Post by JohnCrow »

Hi Benj

Sounds interesting
Will try and give it a try tonight.
1 in 10 people understand binary, the other one doesn't !

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: Displaying a bitmap on a gLCD

Post by hyperion007 »

Is there any way we could get similar example for using any displays that uses the SSD1322 chip? many OLED displays with resolutions of 256x64 (and 128x64, 256x32, 128x32 also uses SSD1322) Is the SD card fast enough or are there other memory options I should consider since a 256x64 grayscale bitmap is so large I fear that using a PIC18F isn't going to be fast enough. I don't want to end up with a display that is so slow to redraw a 256x64 bitmap that it is visible to the human eye (like I have seen many examples of on youtube)

Thanks in advance.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Displaying a bitmap on a gLCD

Post by Benj »

Hello,

I will add SSD1322 to the list for v6. Hopefully shouldn't bee too hard to pull off.

SD card should be fast enough but I might suggest a chip such as the EP range of dsPIC33 or PIC24 devices as these run at a fast enough speed to pull off a quick refresh on a larger display while streaming from a card.

For example 128 x 64 pixels x 2 bytes of color per pixel = 16384 bytes, x8 bits per byte means that 131072 clock pulses are required just to be able to redraw the screen.

Post Reply