STM32 TFT touch screen (ILI9320): Process analysis displayed by LCD_ShowChar

Publisher:tau29Latest update time:2017-11-17 Source: eefocusKeywords:stm32 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;

and++;

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): Process analysis displayed by LCD_ShowChar
    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 Reference address:STM32 TFT touch screen (ILI9320): Process analysis displayed by LCD_ShowChar

Previous article:ARM筆記:Linux内核移植到JZ2440
Next article:stm32 uses fsmc bus to drive color screen (based on Shenzhou III)

Recommended ReadingLatest update time:2024-11-23 07:54

STM32 AD dual channel DMA mode
// Collect AD through pins PA1 and PA2. Collect AD 10 times for each channel.       view plain copy print ? #include "ad_driver.h"       //Global variable    //AD sampling storage space    __IO uint16_t ADCConvertedValue ;      //Function    //Initialize AD    void init_ad(void)   {       A
[Microcontroller]
Specific explanation of STM32 external interrupt
  1. Basic Concepts  The ARM Coetex-M3 core supports a total of 256 interrupts, including 16 internal interrupts, 240 external interrupts and programmable 256-level interrupt priority settings. STM32 currently supports a total of 84 interrupts (16 internal + 68 external), and 16-level programmable interrupt priority s
[Microcontroller]
A topic about clearing the CCR of the STM32 timer
Today I would like to share with you a small case encountered in operating the CCR register during STM32 application development. It is about the problem of clearing the capture register in the STM32 timer.   Someone used STM32 to do input capture. In the callback function of the capture, the captured CCR value was fi
[Microcontroller]
A topic about clearing the CCR of the STM32 timer
STM32 startup file (Reset_Handler function)
The main purpose of this file is: Setting the Initial SP Set initial PC=Reset_Handler Set the vector table entry address and initialize the vector table Call SystemInit to set the system clock to 72M. SystemInit is defined in the library file system_stm32f10.c and transferred to the label _main, and finally c
[Microcontroller]
Some common basic library functions and serial port configuration steps in stm32
Commonly used basic library functions: void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState) //Enable port clock   void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) //Initialize port, select port number, set parameters typedef struct {   uint16_t GPIO_Pin; //pin number  
[Microcontroller]
Using while loop in stm32 causes program to freeze
Today, I found such a problem while using stm32. The program was stuck inexplicably. First, let's look at the code that causes the crash.     while ( ReadRawRC ( CommandReg ) & 0x10 );1 This is a writing method we often use in programs. It is easy to understand. The function of the program is to read a piece of data
[Microcontroller]
Using while loop in stm32 causes program to freeze
stm32 i2c eeprom 24C02
Circuit Diagram  Example #define i2c_scl PBout(10) #define i2c_sda PBout(11) #define i2c_ack PBin(11) void I2C_init() {     GPIO_InitTypeDef gpio10 =      {         GPIO_Pin_10,         GPIO_Speed_50MHz,         GPIO_Mode_Out_PP     };     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //Clock enab
[Microcontroller]
stm32 i2c eeprom 24C02
NOR Flash memory expansion technology based on STM32-FSMC mechanism
introduction STM32 is a 32-bit microcontroller series based on the ARM core Cortex-M3 launched by ST (STMicroelectronics). The Cortex-M3 core is specially designed for low-power and price-sensitive applications, with outstanding energy efficiency and processing speed. By adopting the Thumb-2 high-density instru
[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号