📄 main.c
字号:
#include <reg52.h>
#include <stdio.h>
#include <absacc.h>
#include <intrins.h>
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef long unsigned int uint32;
#define LCM_DISPON 0x3f /* 打开LCM显示 */
#define LCM_STARTROW 0xc0 /* 显示起始行0,可以用LCM_STARTROW+x设置起始行。(x<64) */
#define LCM_ADDRSTRX 0xb8 /* 页起始地址,可以用LCM_ADDRSTRX+x设置当前页(即X)。(x<8) */
#define LCM_ADDRSTRY 0x40 /* 列起始地址,可以用LCM_ADDRSTRY+x设置当前列(即Y)。(x<64) */
#define LcdComA XBYTE[0x6020] /* 左半屏控制端口 */
#define LcdComB XBYTE[0x6040] /* 右半屏控制端口 */
#define LcdComAll XBYTE[0x6060] /* 全屏控制端口 */
#define LcdWDataA XBYTE[0x6120] /* 左半屏数据端口 */
#define LcdWDataB XBYTE[0x6140] /* 右半屏数据端口 */
#define LcdDataAll XBYTE[0x6160] /* 全屏数据端口 */
unsigned char code XI[]=
{
/*------------------------------------------------------------------------------
源文件 / 文字 : 西
宽×高(像素): 16×16
字模格式/大小 : 单色点阵液晶字模,横向取模,字节正序/32字节
------------------------------------------------------------------------------*/
0x00,0x00,0x04,0x00,0x04,0x00,0xE4,0x7F,0x24,0x28,0x24,0x24,0xFC,0x23,0x24,0x20,
0x24,0x20,0xFC,0x23,0x24,0x24,0x24,0x24,0x24,0x24,0xE6,0x7F,0x04,0x00,0x00,0x00
};
unsigned char code AN[]=
{
/*------------------------------------------------------------------------------
源文件 / 文字 : 安
宽×高(像素): 16×16
字模格式/大小 : 单色点阵液晶字模,横向取模,字节正序/32字节
------------------------------------------------------------------------------*/
0x00,0x00,0x80,0x00,0xA0,0x40,0x98,0x40,0x88,0x40,0x88,0x26,0x88,0x25,0xEA,0x18,
0x8C,0x08,0x88,0x0C,0x88,0x13,0x88,0x10,0xA8,0x20,0x98,0x60,0x80,0x00,0x00,0x00
};
unsigned char code JIAO[]=
{
/*------------------------------------------------------------------------------
源文件 / 文字 : 交
宽×高(像素): 16×16
字模格式/大小 : 单色点阵液晶字模,横向取模,字节正序/32字节
------------------------------------------------------------------------------*/
0x00,0x00,0x08,0x00,0x08,0x41,0x88,0x40,0x48,0x40,0xA8,0x21,0x08,0x22,0x0A,0x14,
0x0C,0x08,0x08,0x16,0x88,0x21,0x28,0x20,0x48,0x40,0x8C,0x40,0x08,0x40,0x00,0x00
};
unsigned char code TONG[]=
{
/*------------------------------------------------------------------------------
源文件 / 文字 : 通
宽×高(像素): 16×16
字模格式/大小 : 单色点阵液晶字模,横向取模,字节正序/32字节
------------------------------------------------------------------------------*/
0x00,0x00,0x40,0x20,0x42,0x10,0xCC,0x0F,0x00,0x10,0x00,0x20,0xF4,0x5F,0x54,0x42,
0x5C,0x42,0xF4,0x5F,0x5C,0x42,0x56,0x52,0xF4,0x5F,0x00,0x40,0x00,0x40,0x00,0x00
};
unsigned char code DA[]=
{
/*------------------------------------------------------------------------------
源文件 / 文字 : 大
宽×高(像素): 16×16
字模格式/大小 : 单色点阵液晶字模,横向取模,字节正序/32字节
------------------------------------------------------------------------------*/
0x00,0x00,0x20,0x40,0x20,0x40,0x20,0x20,0x20,0x10,0x20,0x08,0x20,0x06,0xFE,0x01,
0x20,0x02,0x20,0x04,0x20,0x08,0x20,0x10,0x20,0x20,0x30,0x60,0x20,0x20,0x00,0x00
};
unsigned char code XUE[]=
{
/*------------------------------------------------------------------------------
源文件 / 文字 : 学
宽×高(像素): 16×16
字模格式/大小 : 单色点阵液晶字模,横向取模,字节正序/32字节
------------------------------------------------------------------------------*/
0x00,0x00,0x40,0x04,0x30,0x04,0x10,0x04,0x52,0x04,0x5C,0x04,0x50,0x24,0x52,0x44,
0x5C,0x3F,0x50,0x05,0xD8,0x04,0x56,0x04,0x10,0x04,0x50,0x06,0x30,0x04,0x00,0x00
};
/*************************************************
延时子程序
*************************************************/
void delay(uint16 time)
{
while(time--);
}
/*************************************************
液晶初始化
*************************************************/
void LCM_DispIni(void)
{
LcdComAll = LCM_DISPON;
delay(50);
LcdComAll = LCM_STARTROW;
delay(50);
LcdComAll = LCM_ADDRSTRX;
delay(50);
LcdComAll = LCM_ADDRSTRY;
delay(50);
}
/*************************************************
全屏填充
*************************************************/
void LCM_DispFill(uint8 filldata)
{
uint8 x,y;
LcdComAll = LCM_STARTROW;
delay(50);
for(x=0;x<8;x++)
{
LcdComAll = LCM_ADDRSTRX + x;
delay(50);
LcdComAll = LCM_ADDRSTRY;
delay(50);
for(y=0;y<64;y++)
{
LcdDataAll = filldata;
delay(50);
}
}
}
void LCD_init(void)
{
LCM_DispIni();
LCM_DispFill(0x00);
}
/*************************************************
向x,y坐标写入数据wrdata
*************************************************/
void LCM_WriteByte(uint8 x,uint8 y,uint8 wrdata)
{
x = x & 0x7f;
y = y & 0x3f;
y = y >> 3;
if(x<64)
{
LcdComA = LCM_ADDRSTRY + x;
delay(50);
LcdComA = LCM_ADDRSTRX + y;
delay(50);
LcdWDataA = wrdata;
delay(50);
}
else
{
x = x -64;
LcdComB = LCM_ADDRSTRY + x;
delay(50);
LcdComB = LCM_ADDRSTRX + y;
delay(50);
LcdWDataB = wrdata;
delay(50);
}
}
/*************************************************
在x,y坐标处显示汉字(16X16)
*************************************************/
void PutChinese(uint8 x,uint8 y,uint8 *dat)
{
uint8 i;
for(i=0;i<16;i++)
{
LCM_WriteByte(x+i,y,*(dat++));
LCM_WriteByte(x+i,y+8,*(dat++));
}
}
main()
{
//Init_RS232();
SCON=0x52;
TMOD=0x20;
TH1=0xFD; // 波特率为9600,晶振=11.0592M
TR1=1;
LCD_init();
PutChinese(16,0,XI);
PutChinese(32,0,AN);
PutChinese(48,0,JIAO);
PutChinese(64,0,TONG);
PutChinese(80,0,DA);
PutChinese(96,0,XUE);
PutChinese(16,16,XI);
PutChinese(32,16,AN);
PutChinese(48,16,JIAO);
PutChinese(64,16,TONG);
PutChinese(80,16,DA);
PutChinese(96,16,XUE);
PutChinese(16,32,XI);
PutChinese(32,32,AN);
PutChinese(48,32,JIAO);
PutChinese(64,32,TONG);
PutChinese(80,32,DA);
PutChinese(96,32,XUE);
PutChinese(16,48,XI);
PutChinese(32,48,AN);
PutChinese(48,48,JIAO);
PutChinese(64,48,TONG);
PutChinese(80,48,DA);
PutChinese(96,48,XUE);
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -