LCD is the abbreviation of liquid crystal display. Liquid crystal displays are divided into 1. static drive, 2. simple matrix drive and 3. active matrix drive according to the driving mode.
Among them, the simple matrix can be divided into two types: twisted nematic (TN) and super twisted nematic (STN), while the active matrix drive is mainly based on TFT.
Both TN and STN use field voltage drive. If the display size increases, the reaction time of the center part to the motor change will become longer, and the display speed cannot keep up. To solve this problem, active matrix drive TFT was proposed. It uses transistor display signals to turn on and off the voltage of liquid crystal molecules, thus avoiding the display's reliance on electric field effects.
LCD screen displays images not only need LCD driver, but also LCD controller. Many main chip CPUs integrate LCD controllers.
According to the display principle: as the frame synchronization signal, vsync, each pulse means that a new image data starts to be transmitted. As the line synchronization signal, hsync, each pulse indicates that a new line of image data starts to be sent.
LCD Timing Diagram
All LCDs display images from top to bottom and from left to right. An image can be considered a rectangle, consisting of many neatly arranged pixels in rows, which are called pixels.
VCLK: pixel clock signal
A pulse signal is sent, indicating that a new point of image data begins to be transmitted.
LEND: line end signal
Frame Buffer
FrameBuffer is essentially a hardware abstraction of a graphics device. For developers, FrameBuffer is a display buffer. Writing data in a specific format to the display buffer means outputting content to the screen. By continuously writing data to the framebuffer, the display controller automatically retrieves data from the frame buffer and displays it.
In embedded systems, a portion of the main memory is used as video memory; therefore, the essence of the frame buffer is video memory.
Frame buffer device
The frame buffer device is a very typical character device. The device file corresponding to the frame buffer device is /dev/fb*. If the system has multiple display cards, Linux can also support multiple frame buffer devices, up to 32, namely /dev/fb0 to /dev/fb31, and /dev/fb0 is the current default frame buffer device, usually pointing to /dev/fb0. The frame buffer device is a standard character device, with a major device number of 29 and a minor device number from 0 to 31.
Experimental content:
1. Clear LCD
Use command: dd if=/dev/zero of=/dev/fb0 bs=240 count=320
(dd is used to copy files if (in file) of (out file) bs: block size count:)
Bs=240 means one block is 240 bytes; count=320 means 320 blocks
2. Run the application and draw
./LCD
3. Clear LCD
Use command: dd if=/dev/zero of=/dev/fb0 bs=240 count=320
1. Displaying images
2. cat xx.bmp > /dev/fb0
Summary: Through the frame buffer, we can operate the LCD display image, that is, the LCD display image comes from the frame buffer, and /dev/fb0 is the device file of the frame buffer, so operating /dev/fb0 is operating the frame buffer.
The platform device classification method is: bus;
Character device classification method: function
#include
#include
#include
#include
#include
int main () {
int fp=0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long screensize=0;
char *fbp = 0;
int x = 0, y = 0;
long location = 0;
fp = open ("/dev/fb0", O_RDWR); //Open the frame buffer device file
if (fp < 0){
printf("Error : Can not open framebuffer device\n");
exit(1);
}
if (ioctl(fp,FBIOGET_FSCREENINFO,&finfo)){ //Get some configuration parameters of LCD
printf("Error reading fixed information\n");
exit(2);
}
if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo)){
printf("Error reading variable information\n");
exit(3);
}
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; // single frame screen space
/*This is to map out the contents from the beginning to the screensize size in the file pointed to by fp, and get a pointer to this space*/
fbp =(char *) mmap (0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fp,0); //Map video memory to process space, fbp is the mapping address
if ((int) fbp == -1)
{
printf ("Error: failed to map framebuffer device to memory.\n");
exit (4);
}
/*This is the position coordinate of the point you want to draw, (0,0) is in the upper left corner of the screen*/
//Draw a rectangle
for(x=100;x<150;x++)
{
for(y=100;y<150;y++)
{
location = x * (vinfo.bits_per_pixel / 8) + y * finfo.line_length;
*(fbp + location) = 255; /* Blue color depth */ /* Directly assign a value to change the color of a certain point on the screen */
*(fbp + location + 1) = 0; /* Green color depth*/ /*Note: These values are set for four bytes per pixel. If it is set for 2 bytes per pixel, */
*(fbp + location + 2) = 0; /* Red color depth*/ /* For example, RGB565 needs to be converted*/
*(fbp + location + 3) = 0; /* Is it transparent? */
}
}
munmap (fbp, screensize); /*Remove mapping*/
close (fp); /*close the file*/
return 0;
}
Previous article:Compile the driver into the kernel
Next article:Mmap device method---We played with embedded drivers in those years
Recommended ReadingLatest update time:2024-11-15 17:46
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Fix the problem that the MSP430 emulator cannot be used (caused by firmware upgrade)
- Design of screen self-checking program based on FPGA
- Live FAQ|Fujitsu FRAM non-encryption algorithm (spectrum) authenticity verification solution
- Based on STM32F303 dual motor FOC driver: sensorless schematic/BOM/code and other open source sharing
- (C- Wireless Charging Electric Car) 2018TI Cup Wireless Charging Car
- Do popular chargers also need double pulse testing? Download the information to learn more and get gifts!
- Computer System Architecture Q&A
- Please recommend a stackup of single-layer FPC with electromagnetic shielding film
- Radio Frequency Identification Technology and Its Application Development Trend
- MSP430F5529 ADC Reference