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
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Active crystal oscillator waveform problem
- Multi-cell lithium battery charging management solution-TPS54201 application in sweeping robot
- RT-Thread uses printf or rt_kprintf function for serial port printing
- IoT Basics: Important Information for Today and Tomorrow
- [Erha Image Recognition Artificial Intelligence Vision Sensor] 3. General Settings and Face Recognition
- Prize-winning quiz: Find the "know-it-all" expert on Intel Vision Accelerated Design online
- Disassembly of GM520 differential pressure gauge
- I've seen wire winding, but I've never seen one so creative!
- Please recommend a domestically produced isolated 485 chip with a single power supply
- 【ufun learning】Part 4: Serial port printing output