s3c2440 bare metal - LCD programming - 4 - realize the display function

Publisher:rockstar7Latest update time:2024-07-04 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Make the LCD display full of red

We want to display data on the LCD. The steps required are as follows:


a. Initialize LCD

b. Enable LCD

c. Get LCD parameters: fb_base, xres, yres, bpp

d. Write data to the framebuffer

1. Initialize LCD work We have introduced the framework preparation and LCD initialization in detail in the previous section.


2. Enable LCD


void lcd_enable()

{

lcd_controller_enalbe(); //will indirectly call s3c2440_lcd_controller_enalbe

}

3. Get LCD parameters


void get_lcd_params(unsigned int *fb_base, int *xres, int *yres, int *bpp)

{

*fb_base = g_p_lcd_selected->fb_base;

*xres = g_p_lcd_selected->xres;

*yres = g_p_lcd_selected->yres;

*bpp = g_p_lcd_selected->bpp;

}

4. Write data to the framebuffer


1) Assuming that we initialize the configuration with BPP=16, how can we make the full screen display red?


The pixels of the entire screen starting from the framebuffer base address need to be filled with red values. For 16BPP, RGB=565, if you want to display red, [15:11] is all 1 for red, [10:5] is all 0 for no green, and [4:0] is all 0 for no blue, 0b1111100000000000=0xF800. Starting from the base address, with xres and yres as the boundaries, fill in the colors in sequence.


p = (unsigned short *)fb_base;

for (x = 0; x < xres; x++)

for (y = 0; y < yres; y++)

*p++ = 0xf800;

2) Assuming that we initialize the configuration with BPP=24 or BPP=32, how can we make the full screen display red?


In fact, no matter it is 24bpp or 32bpp, each pixel in the frame buffer occupies 4 bytes. The LCD controller data storage format is introduced. For 24BPP or 32 bpp, that is, RGB:888, each color occupies 8 bits, a total of 24 bits. The code is as follows:


p = (unsigned int *)fb_base;

for (x = 0; x < xres; x++)

for (y = 0; y < yres; y++)

*p++ = 0xff0000;

When the frame buffer is filled with color data, the LCD controller will fill the data onto the LCD display according to our previous configuration. So how can the previous 24BPP and 32BPP be displayed on an LCD that can only receive 16BPP (there are only 16 data lines in the hardware)?


This is because when using 24BPP, of the 8 red, 8 green, and 8 blue data sent, only the upper 5 red, upper 6 green, and upper 5 blue are used to connect to the LCD. (This is discussed in 4.FrameBuffer and BPP in the previous LCD Hardware Principles)


Reference address:s3c2440 bare metal - LCD programming - 4 - realize the display function

Previous article:s3c2440 bare metal - LCD programming - 5 - drawing dots, lines and circles on LCD
Next article:S3C2440 bare metal - LCD programming - 3 - frame preparation and LCD initialization

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号