STM32 TFT touch screen: process analysis displayed by LCD_ShowChar

Publisher:omicron25Latest update time:2018-10-16 Source: eefocusKeywords:stm32  LCD_ShowChar Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    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.

STM32 TFT touch screen (ILI9320) (1): Process analysis through LCD_ShowChar display
    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.


Keywords:stm32  LCD_ShowChar Reference address:STM32 TFT touch screen: process analysis displayed by LCD_ShowChar

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

STM32 Driver DP83848 Notes
Check whether the STM32 MAC clock is turned on. Check whether the Ethernet 50M clock is configured correctly. Check whether the Ethernet multiplexed IO of STM32 is connected to the remapped port. Check whether the Ethernet RMII port of the STM32 has been initialized correctly and whether the clock of the IO port
[Microcontroller]
STM32 serial port routine
[Microcontroller]
STM32 serial port routine
Storing constants in FLASH in STM32 (CONST keyword)
Today, when I was writing a program, I wanted to store a string constant in the FLASH of STM32. After looking at other people's example programs for a while, I knew that the keyword const was used, but I didn't succeed the first time. Premise: I am using STM32F103ZE microcontroller, The storage range of FLASH is
[Microcontroller]
STM32 MCU Learning (2) External Interrupt
Li Xiang stm32 video tutorial 49 episodes http://pan.baidu.com/s/1kTyt03P STM32 interrupts (upper, middle and lower) external interrupts (registers, library functions) STM32 Function Description (Chinese).pdf http://download.csdn.net/detail/leytton/7630851 Interrupt Management Function.pdf http://wenku.baidu.com/view
[Microcontroller]
STM32 and HC-SR04 ultrasonic distance measurement
First, let’s take a look at the basic functions and principles of this module. HC-SR04 ultrasonic distance measurement module can provide non-contact distance sensing function of 2cm-400cm, and the distance measurement accuracy can reach up to 3mm; the module includes ultrasonic transmitter, receiver and control circu
[Microcontroller]
STM32 and HC-SR04 ultrasonic distance measurement
Detailed explanation of the priority setting method of stm32 tick clock SYStick
Taking ST's V3.50 firmware as the target, 1. The definition and address allocation of the tick register in the kernel .H file are as follows typedef struct {   __IO uint32_t CTRL;                         /*! Offset: 0x00  SysTick Control and Status Register */   __IO uint32_t LOAD;                         /*! Offset
[Microcontroller]
STM32 study notes DS18B20
The STM32 development board I bought has very few peripherals, not even a digital tube, and the display must be done on the hyperterminal through the serial port. I am very lazy, so I picked a more convenient device DS18B20 to play with. DS18B20 is an entry-level device for learning embedded development, and it is als
[Microcontroller]
STM32-Key Input Experiment Study Notes
Key scanning function key.c fragment:   view plain copy   //Button initialization function   //Special note: After this function, JTAG will not be available (SWD will not be available either)   //If you want JTAG simulation, you can block this function.   //PA0.13.15 is set as input   void KEY_In
[Microcontroller]
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号