Hardware configuration of blue bridge foundation -- LCD function usage

Hardware configuration of blue bridge foundation (3) -- LCD function usage

~QQ: 3020889729

Xiao Cai

LCD main function introduction

Part I common functions of LCD:

void STM3210B_LCD_Init(void);//LCD initialization function
//The initialization function is in the title during the game
void LCD_SetTextColor(vu16 Color);//Set character display color
void LCD_SetBackColor(vu16 Color);//Set LCD screen background color

void LCD_DisplayChar(u8 Line, u16 Column, u8 Ascii);//Display function to display a single character
void LCD_DisplayStringLine(u8 Line, u8 *ptr);//Display function of display string

void LCD_ClearLine(u8 Line);//Line clearing
void LCD_Clear(u16 Color);//Whole page refresh

Step 2. Use of LCD function

See code
u8 string[20];//display string
//1
LCD_SetTextColor(Red);//Set red font
LCD_DisplayStringLine(Line2, string);//Display string content on the third line
LCD_ClearLine(Line2);//Clear third line
LCD_Clear(Blue);//Refresh LCD page in blue
//2
LCD_SetBackColor(Black);//Set the background color of LCD screen to black
//3
LCD_DisplayChar(Line2,319-16*2,'A');//The character A is displayed in the second line from left to right at column 2 * 16

Step 3. Understanding of LCD function parameters

//Definition of line parameters in the function - 10 lines in total - 0 to 9, each line is displayed, occupying the display position of 24 'lines'
#define Line0          0
#define Line1          24
#define Line2          48
#define Line3          72
#define Line4          96
#define Line5          120
#define Line6          144
#define Line7          168
#define Line8          192
#define Line9          216

//Color parameters that can be set
#define White          0xFFFF
#define Black          0x0000
#define Grey           0xF7DE
#define Blue           0x001F
#define Blue2          0x051F
#define Red            0xF800
#define Magenta        0xF81F
#define Green          0x07E0
#define Cyan           0x7FFF
#define Yellow         0xFFE0

Some problems of LCD display

① How to realize that the displayed string contains the parameter information we need:
This requires us to add a header file, including "stdio. H", so that we can use a function called sprintf to specify the combination of a string.
#include "stdio.h"
u8 A=5;
u8 string[20];//display string

sprintf((char*)string," A is %d ",A);//So we get a string: A is 5 
LCD_DisplayStringLine(Line2, string);//Display string content on the third line
//The specified string is displayed.

② Single character display problem:
Single character display requires character display function, and the parameters of this function are mainly in the display of specified characters and positions, which may not be so clear to you.
u8 B=3;
LCD display char (line2319-16 * 2, B + '0'); / / displays a 5 starting from the number 2 * 16 on the left

//Because the function display is based on the class code, if the parameter is not a character (but a current number), you need to add a 0x30 or
 Simply add the character '0', so that a single number can be displayed in a certain position.
③ Display color problem:
Each time we refresh the display string or a single character, we can set the corresponding character font color. (there is no requirement in normal times or no need to be high in the questions
 When it's on, you don't need to worry about it. Just set the font color once. For example, use LCD [SetTextColor (red); / / set the red font. There's no other setting behind it
 If it is set, all the red characters will be displayed.)
u8 string[20];//display string

LCD_SetTextColor(Red);//Set red font
LCD_DisplayStringLine(Line2, string);//Display string content in the third line -- red

LCD_SetTextColor(Green);//Set green font
LCD_DisplayStringLine(Line2, string);//In the third line, the content of the display string changes to green

LCD_SetTextColor(Red);//Set red font
LCD_DisplayChar(Line2,319-16*2,'A');//The character A is displayed in the second line from left to right at column 2 * 16
LCD_SetTextColor(Green);//Set green font
LCD_DisplayChar(Line3,319-16*2,'B');//The character B is displayed in the third line from left to right, column 2*16
LCD_SetTextColor(Yellow);//Set yellow font
LCD_DisplayChar(Line4,319-16*2,'C');//The character C is displayed at the second * 16 column from left to right in the fourth row
//In this way, three different characters of three colors - A (red) - B (green) - C (yellow) are obtained

End

This is a simple LCD function used, I hope to help you.
There are other problems, you can also discuss with each other, contact and exchange.
Published 4 original articles, won praise 4, visited 18
Private letter follow

Tags: ascii

Posted on Thu, 16 Jan 2020 02:50:14 -0800 by Muppet9010