LCD12864 key menu setting with Chinese character library, single chip microcomputer experimental program

Publisher:chaohuangmeitaoLatest update time:2020-11-10 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The actual picture of the LCD12864 button menu setting reverse white experiment sharing with Chinese character library is as follows:




I am using Puzhong's development board. If you have the same model of Puzhong development board, you can't display it by downloading it directly because my development board has changed the circuit.
You need to change it.

#include "lcd12864.h"


sbit LCD12864_RS=P2^6; //Register selection input
sbit LCD12864_RW=P2^5; //Register selection input
sbit LCD12864_E=P2^7; //LCD enable control
sbit LCD12864_PSB=P3^0; //Serial/parallel control
sbit LCD12864_RES=P3^2; //Data
reset





Part of the program (some programs are in #include"lcd12864.h" )

#include //This file defines some special function registers of the microcontroller
#include"lcd12864.h" //lcd12864 LCD screen driver
#define uchar unsigned char //Macro definition unsigned character data type declaration definition name uchar number of bits occupied 8 bits range 0~255
#define uint unsigned int //Macro definition unsigned integer data type declaration definition name uint number of bits occupied 16 bits range 0~65535

/*Button IO pin definition*/
sbit k1=P3^0; //Menu selection button
uchar cdsz=0; //Menu setting flag
/*Delay function delay_ms(1) is about 1ms*/
void delay_ms(uint ms)
{
uchar t;
while(ms--)
{
for(t=120;t>0;t--);
}
}
/*Key function*/
void an_jian()
{
if(k1==0)
{
  delay_ms(10); //Debounce delay is about 10ms
  if(k1==0)
  {
   if(cdsz<2)cdsz=cdsz+1;else(cdsz=0);
  }
  while(!k1); //Confirm whether the key is released
}
}
/*Menu setting function*/
void caidan_shezhi()
{
if(cdsz==0)Lcd12864_SetAscWhite(2,2,10,0); //If cdsz==0, the 10 characters in the range of the 2nd row and the 2nd column are highlighted
else(Lcd12864_SetAscWhite(2,2,10,1)); //If cdsz!=0 2nd row, 2nd column, 10 characters, 1 is for off highlight
if(cdsz==1)Lcd12864_SetAscWhite(3,2,10,0); //If cdsz==1, 3rd row, 2nd column, 10 characters, 0 is for off highlight
else(Lcd12864_SetAscWhite(3,2,10,1)); //If cdsz!=1, 3rd row, 2nd column, 10 characters, 1 is for off highlight

if(cdsz==2)Lcd12864_SetAscWhite(4,2,10,0); //If cdsz==2, 4th row, 2nd column, 10 characters, 0 is for off highlight
else(Lcd12864_SetAscWhite(4,2,10,1)); //If cdsz!=2, 4th row, 2nd column, 10 characters, 1 is for off highlight
}
void main()
{
lcd12864init(); //lcd12864 initialization
LCD12864_cluck(); //Clear the screen completely or the screen will be distorted
while(1)
{
  an_jian(); //Read the button function
  caidan_shezhi(); //Read the menu setting function*
  LCD_PutString(1,3,"settings"); //Start displaying settings at the 3rd column of the 1st row
  LCD_PutString(2,1,"1.Display settings"); //Start displaying 1.Display settings at the 1st column of the 2nd row
   LCD_PutString(3,1,"2.Application settings"); //Start displaying 2.Application settings at the 1st column of the 3rd row
  LCD_PutString(4,1,"3.System settings"); //Start displaying 3.System settings at the 1st column of the 4th row
}
}


Reference address:LCD12864 key menu setting with Chinese character library, single chip microcomputer experimental program

Previous article:ws2812b color light with indoor automatic system microcontroller source program
Next article:Single chip intelligent lighting system program

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号