#define _LCD12864_H_
void led12864_clear(); //Clear screenextern
void lcd12864_init(); //Initialization functionextern
void lcd12864_pxy(unsigned char p,unsigned char x,unsigned char y); //Data display position, p=0 left half screen, p=1 right half screen, p=2 both half screens selected, xy are the displayed coordinates, the fourth quadrant, represented by positive values.
extern void lcd12864_zifu(unsigned char p,unsigned char x,unsigned char,unsigned char m); //The display position of the mth character, the same as the definition of Chinese characters, except that the value of the xy coordinates should be less than or equal to 7.
extern void lcd12864_hanzi(unsigned char p,unsigned char x,unsigned char y,unsigned char m); //The display position of the mth Chinese character, p=0 left half screen, p=1 right half screen, p=2 both half screens are selected, xy is the display coordinates, the fourth quadrant, expressed as positive values, the value of x or y should be less than or equal to 3. m is the mth Chinese character displayed.
#endif
#include
#define uint unsigned int
#define uchar unsigned char
sbit cs2=P2^0;
sbit cs1=P2^1;
sbit e=P2^2;
sbit rw=P2^3;
sbit rs=P2^4;
uchar code zifu[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//,0
0x00,0x00,0x58,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//。1
0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//!2
0x00,0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uchar code ziku[]=
{
//0x80,0x40,0xF0,0x2C,0x43,0x20,0x98,0x0F,0x0A,0xE8,0x08,0x88,0x28,0x1C,0x08,0x00,//"你",
//0x00,0x00,0x7F,0x00,0x10,0x0C,0x03,0x21,0x40,0x3F,0x00,0x00,0x03,0x1C,0x08,0x00,
0x80,0x84,0x44,0x44,0x24,0x14,0x04,0xFF,0x04,0x14,0x24,0x24,0x46,0xC4,0x40,0x00,//"李",0 The numbers after the Chinese characters represent the codes of the Chinese characters for easy use
0x00,0x08,0x08,0x08,0x09,0x49,0x89,0x7D,0x0D,0x0B,0x09,0x08,0x0C,0x08,0x00,0x00,
0x10,0x10,0x10,0xFF,0x90,0x50,0xFE,0x92,0x92,0x92,0x92,0x92,0x9A,0xD3,0x82,0x00,//"振",1
0x02,0x42,0x81,0x7F,0x40,0x30,0x0F,0x00,0xFF,0x40,0x07,0x18,0x28,0x64,0x22,0x00,
0x80,0x40,0x20,0xF8,0x07,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x68,0x4C,0x08,0x00,//"伟",2
0x00,0x00,0x00,0xFF,0x02,0x02,0x02,0x02,0x02,0xFF,0x02,0x12,0x22,0x1F,0x02,0x00,
0x00,0x00,0x00,0xC0,0x70,0x20,0x00,0xFF,0x00,0x10,0x20,0xC0,0x80,0x00,0x00,0x00,//小3
0x04,0x02,0x01,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00,
0x00,0x04,0x84,0x44,0x3C,0x44,0x85,0x06,0x04,0xC4,0x3C,0x44,0x84,0x04,0x00,0x00,//卒4
0x04,0x05,0x04,0x04,0x04,0x04,0x05,0xFE,0x05,0x04,0x04,0x04,0x05,0x04,0x04,0x00,
0x40,0x41,0xCE,0x04,0x00,0x80,0x40,0xBE,0x82,0x82,0x82,0xBE,0xC0,0x40,0x40,0x00,//Set 5
0x00,0x00,0x7F,0x20,0x90,0x80,0x40,0x43,0x2C,0x10,0x10,0x2C,0x43,0xC0,0x40,0x00,
0x20,0x21,0x2E,0xE4,0x00,0x00,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x00,//Count 6
0x00,0x00,0x00,0x7F,0x20,0x10,0x08,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//,7
0x00,0x00,0x58,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//。8
0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//!9
0x00,0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/*void delay(uchar i) //1ms delay function
{
uchar a,b;
for(b=i;b>0;b--)
for(a=110;a>0;a--);
}*/
void lcd12864_busy() //Busy flag function
{
uchar i;
rw=1;
rs=0;
while(1)
{
P0=0xff;
e=1;
//i=P0;
e=0;
i=P0;
i=i&0x80;
if(i!=0x80)
break;
}
}
lcd12864_writedat(uchar dat) //Write data function
{
//lcd12864_busy();
rw=0;
rs=1;
e=1;
P0=dat;
e=0;
}
lcd12864_writecom(uchar com) //Write command function
{
//lcd12864_busy();
rw=0;
rs=0;
e=1;
P0=com;
e=0;
}
void lcd12864_init() //initialization function
{
lcd12864_writecom(0x3f); //turn on display, turn off display to 0x3e
lcd12864_writecom(0xb8); //set page address to 0. The first page.
lcd12864_writecom(0xc0); //set the display start row address, the first row is displayed on the LCD screen
lcd12864_writecom(0x40); //set the column address
}
lcd12864_pxy(uchar p,uchar x,uchar y) //data position, p=0 left half screen, p=1 right half screen, p=2 both half screens are selected, xy is the display coordinates, the fourth quadrant, represented by positive values.
{
switch(p)
{
case 0:cs1=0;cs2=1;break;
case 1:cs1=1;cs2=0;break;
case 2:cs1=0;cs2=0;break;
}
lcd12864_writecom(0xb8+y);
lcd12864_writecom(0x40+x);
}
lcd12864_zifu(uchar p,uchar x,uchar y,uchar m) //The display position of the mth character is the same as the definition of the test character, except that the value of the xy coordinate should be less than or equal to 7.
{
uchar i;
lcd12864_pxy(p,x*8,y);
for(i=0;i<8;i++)
{
lcd12864_writedat(zifu[i+m*8]);
}
}
lcd12864_hanzi(uchar p,uchar x,uchar y,uchar m) //The display position of the mth Chinese character, p=0 left half screen, p=1 right half screen, p=2 both half screens are selected, xy is the display coordinates, the fourth quadrant, expressed as positive values, the value of x or y should be less than or equal to 3. m is the mth Chinese character displayed.
{
uchar i;
lcd12864_pxy(p,x*16,2*y);
for(i=0;i<16;i++)
lcd12864_writedat(ziku[i+m*32]);
lcd12864_pxy(p,x*16,2*y+1);
for(i=0;i<16;i++)
lcd12864_writedat(ziku[i+m*32+16]);
}
void lcd12864_clear() //screen clearing function
{
uint i;
lcd12864_pxy(2,0,0); //clear the first, second, third and fourth pages of the left and right screens
for(i=0;i<256;i++)
{
lcd12864_writedat(0x00);
}
lcd12864_pxy(2,0,4); // Clear the fifth, sixth, seventh and eighth pages of the left and right screens
for(i=0;i<256;i++)
{
lcd12864_writedat(0x00);
}
}
#include
#include"lcd12864.h"
void main()
{
lcd12864_init();
lcd12864_clear();
lcd12864_hanzi(0,0,0,0);//Li
lcd12864_hanzi(0,1,0,1 );//Zhen
lcd12864_hanzi(0,2,0,2);//Wei
lcd12864_hanzi(0,3,0,8);// .
lcd12864_hanzi(0,0,2,3);//small
lcd12864_hanzi(0,1,2,4);//pawn
lcd12864_hanzi(0,2,2,5);//set
lcd12864_hanzi(0,3,2, 6);// count
lcd12864_hanzi(1,0,2,9);//!
lcd12864_zifu(1,6,6,8); //! The upper left part is separated and displayed in the form of characters
lcd12864_zifu(1,7,6 ,9); //! The upper right part
lcd12864_zifu(1,6,7,10); //! The lower left part
lcd12864_zifu(1,7,7,11); //! The lower right part
while(1);
}
Previous article:DS18B20 temperature test program (51 single chip digital tube display) + circuit diagram
Next article:STC12C5A60S2 (ADC query method 10-bit mode) + 1602 display
Recommended ReadingLatest update time:2024-11-16 14:30
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD University ---- Fundamentals of Electronic Design Huang Genchun
- EEWORLD University Hall - Sharing of finger oximeter control and OTA upgrade application solutions based on Lingdong MM32W0 series MCU
- Basic knowledge of RF circuits
- 【Sunbathe】Participate
- About the calibration or calibration of electronic products
- MSP430 MCU Development Record (9)
- Qorvo announced the acquisition of Active-Semi. Will Qorvo take off in areas such as 5G?
- Sun goods + 2 sets of Wei Dongshan suits
- Analog electronics elective test + DC and AC parameters
- Can anyone confirm what device this is? Thanks!