Write points to compare common display functions.
First, a still picture is displayed with the string displayed (no Chinese characters are currently displayed)
Only need to write the main function, the others thread lcd.c,lcd.h and other related header files to the project can be
#include "led.h" #include "delay.h" #include "sys.h" #include "usart.h" #include "lcd.h" void init () {delay_init (); The delay function initializes the Uart_init (9600);//serial port is initialized to 9600led_init ();//Initialize the hardware interface with the LED connection lcd_init (); Point_color=black; Defines the brush color lcd_clear (RED);} int main (void) {U8 x=0,i;u16 ty;init (); Lcd_showstring (30,40,200,24,24, "My first TFT ^_^"), Ty=70;for (i=1;i<=10;i++,ty+=20) {lcd_showstring (20,ty, 200,12,12, "The Deep your love,the more you get");} while (1) {;}}
Notice the initialization, because the LCD initialization is useful to printf, so be sure to initialize the serial port, or it will crash tat
For Point_color, as the name implies, but also can be found in the library definition, that is, to define the brush color (equivalent to the color of the font)
U16 point_color=0x0000;//Brush Color U16 back_color=0xffff; Background color
We define black, or we can change it to another color (corresponding to the uppercase English)
Lcd_clear (color); This function is clear screen + fill color (color above)
Lcd_showstring () function:
Display string//x,y: Start coordinate//width,height: Area size //size: Font size//*P: string start address void Lcd_showstring (U16 x,u16 Y,u16 Width,u16 Height,u8 size,u8 *p)
Font size There are 3 options, 12, 16, 24 the first two parameters to fill, x, y is the starting coordinates, and the area is filled (200, font size (3 choices)) The last parameter should be very good to understand, not much to say
Finally we make while (1), and stuck the program to show the still picture
Color Library
Brush Color # define white 0xffff#define BLACK 0x0000 #define BLUE 0x001f #define BRED 0xf81f# Define gred 0xffe0#define gblue 0x07ff#define RED 0xf800#define MAGENTA 0xf81f#define GREEN 0x07e0# Define CYAN 0x7fff#define YELLOW 0xffe0#define Brown 0xbc40//Brown # define Brred 0xfc07//Brownish red # Define gray 0x8430//Grey
Here are some drawing functions
Quick Draw Point
Quick Draw Point//x,y: coordinate//color: color void Lcd_fast_drawpoint (U16 x,u16 y,u16 color)
Draw Line
Draw line//x1,y1: Start coordinate//x2,y2: End coordinate void Lcd_drawline (U16 x1, U16 Y1, U16 x2, U16 Y2)
Draw a rectangle and give the two endpoint coordinates on the diagonal of the rectangle.
Draw rectangle void Lcd_drawrectangle (U16 x1, U16 Y1, U16 x2, U16 Y2)
Draw a Circle
Draws a specified size circle at the specified position//(x, y): Center point//r : Radius void lcd_draw_circle (U16 x0,u16 y0,u8 R)
Fills a single color in the specified area (only the specified rectangular area) and gives only the coordinates Sx<=ex && Sy<=ey
Fills the specified range with the specified color//area size: (xend-xsta+1) * (yend-ysta+1)//xsta//color: color to fill void Lcd_fill (U16 sx,u16 sy,u16 ex,u16 ey,u16 Color
Fills the color block in the specified area, as above, except that the color is put into the array to pass through.
Fills the specified color block//(SX,SY) in the specified range, (Ex,ey): fills the rectangular diagonal coordinates, the area size is: (ex-sx+1) * (ey-sy+1) //color: the color to fill void Lcd_color_fill (U16 SX , U16 sy,u16 ex,u16 ey,u16 *color)
There are some fun functions.
Horizontal screen Display
Set LCD display direction//dir:0, vertical screen, 1, horizontal screen void Lcd_display_dir (U8 dir)
Toggle on/OFF display
LCD on display void Lcd_displayon (void)//lcd off show void Lcd_displayoff (void)
Cortex_m3_stm32 Embedded Learning Note (12): TFTLCD display (deep library function)