[ESK32-360 Review] + TFT screen display function and expansion (1)
[Copy link]
This post was last edited by jinglixixi on 2020-7-29 08:13
1. Initial expansion of display functions
The ESK32-360 development board is equipped with a TFT display, which can display characters, graphics, pictures, etc.
The interface circuit of the display screen is shown in Figure 1. It is connected to the development board via the CN3 connector, and the occupied pins are shown in Figure 2.
Figure 1 Display screen interface circuit
Figure 2 Display pin usage
In terms of software, the routine also provides relatively complete display functions, but there are still some functions that need to be added and supplemented.
First, let's take a look at the display functions it provides. They are:
void LCD_Init(void); // Initialization function
void LCD_Config(void); //Pin configuration function
void LCD_Clear(u16 Color); // Clear screen function with color
void LCD_BackColorSet(u16 Color); //Set background color
void LCD_TextColorSet(u16 Color); //Set foreground color
void LCD_CharDisplay(u32 Line_Num, u32 Column, u32 Ascii); // Character display function
void LCD_StringLineDisplay(u32 Line_Num, char *Sptr); // string display function
void LCD_PicDraw(u8 X_Location, u16 Y_Location, u8 Height, u16 Width, uc8 *Pptr); // Picture display function
void LCD_LineDraw(u32 X_Location, u32 Y_Location, u32 Length, u32 Direction); // Line drawing function
void LCD_CircleDraw(u32 X_Location, u32 Y_Location, u32 Radius); //Circle drawing function
void LCD_RectDraw(u32 X_Location, u32 Y_Location, u32 Height, u32 Width); // Rectangle drawing function
So what other display functions do we need to add?
1) Numerical display function: It is very inconvenient to simply call character display function when displaying data;
2) Draw point function, which is the basis of other graphics drawing functions;
3) Line drawing function. Although the routine provides a line drawing function, it is only used to solve simple horizontal or vertical lines and cannot be used to draw waveform curves;
4) Area filling function to solve the erasure of waveform curves within the window;
5) Chinese character display function, under the condition of configuring the corresponding Chinese character library, realizes the display of special Chinese characters.
Through the study and analysis of the routine, the added numerical display function is:
uint32_t LCD_Pow(char m,char n)
{
uint32_t result=1;
while(n--)result*=m;
return result;
}
void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len)
{
u8 t,temp;
u8 enshow=0;
for(t=0;t<len;t++)
{
temp=(num/LCD_Pow(10,len-t-1))%10;
if(enshow==0&&t<(len-1))
{
if(temp==0)
{
LCD_CharDisplay(x, y+14*t, ' ');
continue;
}else enshow=1;
}
LCD_CharDisplay(x, y+14*t, temp+'0');
}
}
After running the following main program, the effect shown in Figure 3 can be obtained.
int main(void)
{
LCD_Init();
LCD_Config();
LCD_Clear(0x2c5c);
LCD_BackColorSet(0x2c5c);
LCD_TextColorSet(Yellow);
LCD_StringLineDisplay(Line3, " Holtek ");
LCD_StringLineDisplay(Line4, " HT32 Series ");
LCD_StringLineDisplay(Line5, " LCD Example ");
LCD_ShowNum(Line7,100,1234567890,10);
while (1);
}
Figure 3 Numerical display
This way, you can easily implement it when you encounter numerical display. We will continue to supplement and improve the addition of functions in the future, so please stay tuned.
|