When using a TFT touch screen and wanting to display strings, graphics or numbers, you will find that there is a most important function LCD_ShowChar in their library functions. It seems that few people have analyzed this function. Although it is simple, it is still a bit confusing.
Let me post the code of this function first. Since the function display is divided into overlay display and non-overlay display, the principles are similar, so you should understand it just by analyzing the non-overlay part.
void LCD_ShowChar(u16 x,u16 y,u8 num,u8 size,u8 mode)
{
u8 temp,t1,t;
u16 y0=y;
u16 colortemp=POINT_COLOR;
num=num-' '; //Get the offset value
if(!mode) //non-overlapping mode
{
for(t=0;t
{
if(size==12)temp=asc2_1206[num][t]; //Call 1206 font
else temp=asc2_1608[num][t]; //Call 1608 font
for(t1=0;t1<8;t1++)
{
if(temp&0x80)POINT_COLOR=colortemp;
else POINT_COLOR=BACK_COLOR;
LCD_DrawPoint(x,y);
temp<<=1;
y++;
if(x>=lcddev.width){POINT_COLOR=colortemp;return;}//Out of area
if((y-y0)==size)
{
y=y0;
x++;
if(x>=lcddev.width){POINT_COLOR=colortemp;return;}//Out of area
break;
}
}
}
}
1206 font and 1608 font are two different font sizes, one is 6 points horizontally and 12 points vertically, and the other is 8 points horizontally and 16 points vertically. From the judgment statement, we can see that the code tables corresponding to the two are different. This code table is a two-dimensional array in font.h. We use 1608 font here, taking the letter "M" as an example. Check the array corresponding to "M" in the code table, as follows:
{0x10,0x04,0x1F,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x1F,0xFC,0x10,0x04,0x00,0x00},
' ' is the beginning of the code table. The offset is obtained by subtracting ' ' from the letter, which is the row number of the two-dimensional array. At the beginning of the first loop, the temporary variable temp is assigned the first value of the array. Since it is a 1608 font, there are also 16 numbers in an array. The first loop is to let temp traverse these 16 numbers.
Then the second loop starts. Since each number in the array is 8 bits, and temp is shifted left by one bit each loop, the second loop is 8 times. After judging by if(temp&0x80), if the highest bit of the number is 1, the color of the point to be drawn is the font color. If it is not 1, the color of the point to be drawn is the background color. (PS: The point drawing function LCD_DrawPoint is still very simple. In general, it writes the point color we want to write to the GRAM register R20h, R21h. The basic operation is O(∩_∩)O)
Each time it shifts, y will increment by itself. The second loop is 8 times, and the size is 16. That is to say, after reading two numbers in the array, y will be cleared after 16 increments, and then x will be incremented by 1, just like a column scan. After a column of 16 points, it will move on to the next column.
The part beyond the area means that it exceeds the size, and it will return after drawing a point. The following describes the process of drawing points using "M" as an example.
The first 8
0x10 (0,3)
0x04 (0,13)
0x1F (1,3),(1,4),(1,5),(1,6),(1,7)
0xFC (1,8),(1,9),(1,10),(1,11),(1,12),(1,13)
0x1F (2,3),(2,4),(2,5),(2,6),(2,7)
0x00 None
0x00 None
0xFC (3,8),(3,9),(3,10),(3,11),(3,12),(3,13)
8 after the meter
0x1F (4,3),(4,4),(4,5),(4,6),(4,7)
0x00 None
0x1F (5,3),(5,4),(5,5),(5,6),(5,7)
0xFC (5,8),(5,9),(5,10),(5,11),(5,12),(5,13)
0x10 (6,3)
0x04 (6,13)
0x00 None
0x00 None
This is not intuitive. Use Matlab's scatter(x,y) to draw a point, and it is exactly the "M" graphic displayed on the TFT screen.
The above is the whole process of ILI9320 dot plotting function LCD_ShowChar(u16 x,u16 y,u8 num,u8 size,u8 mode). I hope that those who are learning for the first time can understand it.
Previous article:STM32 tick timer (1): The location of the tick timer in the kernel
Next article:STM32 DMA receives data from the serial port
Recommended ReadingLatest update time:2024-11-22 19:57
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Another technical solution for power-type plug-in hybrid: A brief discussion on Volvo T8 plug-in hybrid technology
- Modification of 4-20mA two-wire passive digital display meter Part 12 (Work submission)
- CircuitPython 7.1.0 released
- Trial Notes of Zhongke Bluexun AB32VG1 RISC-V Development Board
- How to view the future development of Linux
- TI Wireless Products RF Hardware FAQ
- Li Qihao and Li Jing: Multifunctional fan
- Purgatory Legend-Battle of Digital Tubes
- Share the reference program of hub motor/scooter motor drive based on ST FOC self-made IHM08 V2 board (motor parameters can be measured)...
- Useful Information | Special components in switching power supplies, do you know their types and uses?
- [RTT & Renesas high-performance CPK-RA6M4] 2. Evaluation of GPIO and UART