名称:LCD12864_ST7920并行测试程序
试验功能:测试基于ST7920控制芯片的LCD12864的显示
并行方式连接;晶振11.0592M
编写:JiangX.net
*************************************************/
#include <reg52.h>
#include <ziku.h>
#include <intrins.h>
#include <string.h>
#define uchar unsigned char
#define uint unsigned int//宏定义
#define ulong unsigned long
#define Channal_A 1//通道A
#define Channal_B 2//通道B
#define Channal_AB3//通道A&B
//**************************一下为函数声明修**************************************
static void DA_conver(uint Dignum)
extern void Write_A_B(uint Data_A,uint Data_B,uchar Channal,bit Model)
//**************************修改硬件时要修改的部分********************************
sbit DIN = P0^0//数据输入端
sbit SCLK = P0^1//时钟信号
sbit CS= P0^2//片选输入端,低电平有效
/*MAX187接口定义*/
sbit MAX187_CS= P2^6
sbit MAX187_DO= P2^5
sbit MAX187_SK= P2^7
/*****13864LCD接口定义*****/
sbit LCD_RS = P3^7//1:输入数据 ;0:输入命前庆野令
sbit LCD_RW = P2^7//1:读数据 0:写数据
sbit LCD_EN = P2^6//LCM使能端
sbit LCD_PSB = P2^3//串并口选择 1:并口模式0:串口模式
#define LCD_DATA P1 //LCD总线端口
/*****LCD功能初始化指令*****/
#define CLEAR_SCREEN 0x01 //清屏指令:清屏且AC值为00H
#define AC_INIT 0x02 //将AC设置为00H。且游标移到原点位置
#define CURSE_ADD 0x06 //设定游标移到方向及图像整体移动方向(差弊默认游标右移,图像整体不动)
#define FUN_MODE 0x30 //工作模式:8位基本指令集
#define DISPLAY_ON 0x0c //显示开,显示游标,且游标位置反白
#define DISPLAY_OFF 0x08 //显示关
#define CURSE_DIR 0x14 //游标向右移动:AC=AC+1
#define SET_CG_AC 0x40 //设置AC,范围为:00H~3FH
#define SET_DD_AC 0x80
/*****汉字地址表*****/
uchar code addr_tab[]={ //便于根据汉字坐标求出地址
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,//第一行汉字位置
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,//第二行慧喊汉字位置
0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,//第三行汉字位置
0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,//第四行汉字位置
}
//------------全局变量定义-------------
uchar first[]="MAX187 "
uchar show187[]="12345"
//uchar code shw187[]="123456"
uchar error[]="ERROR!"
ulong vv
/*****n(ms)延时子程序*****/
void delayms(uint t) //约延时n(ms)
{
uint i
while(t--)
{
for(i=0i<125i++)
}
}
/*****等待LCD忙*****/
void WaitBusy(void) //延时一小段时间,等待LCD空闲
{
uchar i=5
while(i--)
}
/*****写指令代码*****/
void Lcd_WriteCmd(uchar cmdcode)
{
LCD_RS = 0
LCD_RW = 0
LCD_EN = 1
WaitBusy()
LCD_DATA = cmdcode
LCD_EN = 0
}
/*****写数据*****/
void Lcd_WriteData(uchar dispdata)
{
LCD_RS = 1
LCD_RW = 0
LCD_EN = 1
WaitBusy()
LCD_DATA = dispdata
LCD_EN = 0
}
/*****初始化LCD*****/
void Lcd_Init()
{
LCD_PSB = 1
delayms(50)
Lcd_WriteCmd(0x30) //选择基本指令集
delayms(1)
Lcd_WriteCmd(0x30) //选择8bit数据流
delayms(1)
Lcd_WriteCmd(0x0c) //开显示(无游标、不反白)
delayms(1)
Lcd_WriteCmd(0x01) //清除显示,并且设定地址指针为00H
delayms(20)
}
/*****显示汉字*****/
void hanzi_Disp(uchar x,uchar y,uchar *s)
{ //x、y为汉字坐标
Lcd_WriteCmd(addr_tab[8*x+y]) //写地址
while(*s>0)
{
Lcd_WriteData(*s) //写数据
s++
}
}
/*****显示图片(显示Gdram内容)*****/
/*绘图显示的步骤
1 关闭绘图显示功能
2 先将垂直的坐标(Y)写入绘图RAM地址
3 再将水平的位元组坐标(X)写入绘图RAM地址
4 将D15-D8写入RAM中
5 将D7-D0写入到RAM中
6 打开绘图显示功能*/
//图片取模方式:横向取模,字节正序
void pic_Disp(uchar *pic)//显示Gdram内容(显示图片)
{
uchar x,y,i
for(i=0i<9i=i+8)
for(y=0y<32y++)
{
for(x=0x<8x++)
{
Lcd_WriteCmd(0x36) //扩充指令,开绘图显示
Lcd_WriteCmd(0x80+y) //行地址
Lcd_WriteCmd(0x80+x+i) //列地址
Lcd_WriteData(*pic++) //写数据 D15-D8
Lcd_WriteData(*pic++) //写数据 D7-D0
Lcd_WriteCmd(0x30)
}
}
}
/*max187延时程序*/
void delay_MS(uint ms)//普通延时MS级
{ uint i,j
for(i=0i<msi++)
{for(j=0j<1141j++)}
}
void delay_uS(uint us)//普通延时US级
{ uint i,j
for(i=0i<usi++)
{ for(j=0j<10j++)}
}
//MAX187读程序
unsigned int MAX187read(void)
{
uchar H,L,i
uint count //16位变量
MAX187_CS=0 //低电平有效,开始转换
delay_uS(2) //延时8.5μ等待转换结束
MAX187_SK=1
MAX187_SK=0
H=0//高位变量清零
for(i=0i<4i++) //高4位
{
MAX187_SK=1
if(MAX187_DO) H++ //位标量,如为1则H加1,如为0则跳过
MAX187_SK=0
if(i!=3)
H<<=1
}
L=0
for(i=0i<8i++) //低8位
{
MAX187_SK=1
if(MAX187_DO) L++ //位标量,如为1则L加1,如为0则跳过
MAX187_SK=0
if(i!=7)
L<<=1
}
delay_uS(1)
MAX187_CS=1
count=0
count=L
return count
}
void MAX187_data()
{
vv=MAX187read()
vv=vv*2*4096/4093
show187[0]=vv/1000+'0'
show187[1]='.'
show187[2]=vv/100%10+'0'
show187[3]=vv/10%10+'0'
show187[4]=vv%10+'0'
show187[5]='\0'
}
/*****主函数*****/
void main(void)
{
uchar volt,number
number=2
volt=0x30+number
Lcd_Init()
while(1)
{
Lcd_Init()
hanzi_Disp(0,1,"山东天工机电")
hanzi_Disp(1,2,"智能充电机")
hanzi_Disp(2,0,"www.sdtgjd.com")
hanzi_Disp(3,3,"")
delayms(1000)
Lcd_Init()
hanzi_Disp(1,2,"充电电流:")
//delayms(500)
//Lcd_Init()
MAX187_data()
hanzi_Disp(2,3,show187)
delayms(1500)
Write_A_B(0x0fff,0x0000,Channal_A,0) //测量A通道
//Write_A_B(0x0000,0x0600,Channal_B,1) //测量B通道
// Write_A_B(0x0504,0x0a47,Channal_AB,1) //测量AB通道,测量时需屏蔽上面两句
//while(1)
}
}
//=================================================================
// 函数名称 :void DA_conver(uint Dignum)
// 函数功能 :进行DA转换
// 入口参数 :Dignum:根据说明设置转化数据.头四位为特殊位用于选择转化方式,
//以及用于通道选择.请自行设置.后12位为需要转换的值
// 出口参数 :无
//=================================================================
void DA_conver(uint Dignum)
{
uint Dig=0
uchar i=0
SCLK=1
CS=0 //片选有效
for(i=0i<16i++) //写入16为Bit的控制位和数据
{
Dig=Dignum&0x8000
if(Dig)
{
DIN=1
}
else
{
DIN=0
}
SCLK=0
_nop_()
Dignum<<=1
SCLK=1
_nop_()
}
SCLK=1
CS=1 //片选无效
}
//=================================================================
// 函数名称 :void Write_A_B(uint Data_A,uint Data_B,uchar Channal,bit Model)
// 函数功能 :模式、通道选择并进行DA转换
// 入口参数 :Data_A:A通道转换的电压值
//Data_B:B通道转换的电压值
//Channal:通道选择,其值为Channal_A,Channal_B,或Channal_AB
//Model:速度控制位 0:slow mode 1:fast mode
// 出口参数 :无
// 说明: Data_A,Data_B的范围为:0-0x0fff
//本程序如果只需要一个通道时,另外一个通道的值可任意,但是不能缺省
//=================================================================
void Write_A_B(uint Data_A,uint Data_B,uchar Channal,bit Model)
{
uint Temp
if(Model)
{
Temp=0x4000
}
else
{
Temp=0x0000
}
switch(Channal)
{
case Channal_A: //A通道
DA_conver(Temp|0x8000|(0x0fff&Data_A))
break
case Channal_B: //B通道
DA_conver(Temp|0x0000|(0x0fff&Data_B))
break
case Channal_AB:
DA_conver(Temp|0x1000|(0x0fff&Data_B)) //A&B通道
DA_conver(Temp|0x8000|(0x0fff&Data_A))
break
default:
break
}
}
//LCD12864字库系列(控制器ST7920A),单片机:89S52,晶振:12M,//串口连接 与 并口连接 ( 串口时 屏蔽 并行模块)
//并行连接方式,P2.0-RS,P2.1-RW,P2.2-E
#include<reg52.h>
#include <intrins.h>
sbit RS=P3^2//串口时为CS
sbit RW=P3^1//串李碧敬口为SID
sbit E=P3^0 //串口为时钟SCLK
sbit stop=P2^2
sbit PSB=P3^4
sbit REST=P3^3
//以下是用<at89x51.h>头文件的定义
/*
#define RS P2_0
#define RW P2_1 //定义引脚
#define E P2_2
#define PSB P2_3
#define REST P2_4
#define Data P1
#include<at89x51.h>
*/
#define BF0x80 //用于检测LCM状态字中的Busy标识
typedef unsigned int Uint
typedef unsigned char Uchar
//字符串例子
//"F1--English",也可以往里面写入汉字码,一个汉字由两个码组成
const Uchar F1English[]={0x46,0x31,0x2d,0x2d,0x45,0x6e,0x67,0x6c,0x69,0x73,0x68,0x00}
const Uchar lengthF1=6 //字符串长度
//汉字,直接可以慧坦写入字形
unsigned char code uctech[] = {"有限公司"}
const Uchar lengthCF3=8
Uchar code TAB1[]={
/*-- 调入了一幅图像:D:\公司的文件\程序图片\未命名哪慎11.bmp --*/
/*-- 宽度x高度=128x64 --*/
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x05,0xAE,0x90,0x00,0x00,0x00,0x00,0x00,
0x95,0x55,0x48,0x80,0x00,0x00,0x00,0x00,
0x2B,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xA8,0x00,0x22,0x15,0x20,0x00,0x00,0x00,
0x97,0xFB,0x00,0x00,0x00,0x00,0x00,0x00,
0x45,0x55,0x08,0xA0,0x00,0x00,0x00,0x0A,
0x6F,0xF4,0x00,0x00,0x00,0x00,0x00,0x00,
0xB2,0x80,0x40,0x00,0x04,0x40,0x00,0x00,
0xBA,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x4D,0x55,0x15,0x15,0x20,0x00,0x00,0x95,
0xD5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xE8,0x40,0x40,0x00,0x00,0x00,0x4A,
0xAA,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0x2A,0x00,0x40,0x00,0x00,0x15,
0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFD,0xD0,0xAA,0x01,0x00,0x00,0x25,
0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xB6,0x00,0x10,0x00,0x01,0x4A,
0x49,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFD,0xE8,0x40,0x00,0x00,0x11,
0x00,0x24,0x84,0x00,0x00,0x00,0x00,0x00,
0xAB,0xFF,0xFF,0x55,0x00,0x00,0x00,0x24,
0x02,0x49,0x5E,0xA0,0x00,0x00,0x00,0x00,
0x84,0xBF,0xFF,0xF4,0x88,0x00,0x00,0x00,
0x10,0x05,0xFF,0xF4,0x00,0x00,0x00,0x00,
0x29,0x0B,0xFF,0xFA,0x20,0x00,0x00,0x00,
0x02,0xBF,0xFF,0xFC,0x00,0x00,0x00,0x00,
0x44,0xA0,0x57,0xFD,0x80,0x00,0x00,0x00,
0x08,0x5F,0xFF,0xFF,0x80,0x00,0x00,0x00,
0x91,0x0A,0xAA,0xF6,0x50,0x00,0x00,0x00,
0x41,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
0x44,0xA0,0x01,0x1B,0x84,0x00,0x00,0x00,
0x26,0xFF,0xFF,0xFF,0x90,0x00,0x00,0x00,
0x11,0x0A,0xAA,0x6D,0x68,0x00,0x00,0x00,
0x0B,0xFB,0xFF,0xEF,0xE0,0x00,0x00,0x00,
0xC4,0xA0,0x01,0x02,0x80,0x00,0x00,0x00,
0x43,0xF1,0xFE,0x63,0xF0,0x00,0x00,0x00,
0x15,0x55,0x54,0x55,0x6A,0x00,0x00,0x00,
0x9F,0xE3,0xFC,0x87,0x38,0x00,0x00,0x00,
0xCA,0xAB,0x91,0x00,0x90,0x00,0x00,0x00,
0x07,0xC1,0xFA,0x2A,0x80,0x00,0x00,0x00,
0x25,0xFF,0xFE,0x95,0x2A,0x00,0x00,0x00,
0x2F,0x13,0xFE,0xFC,0x10,0x00,0x00,0x00,
0x95,0xFF,0xFF,0xC0,0x50,0x00,0x00,0x00,
0x0F,0x41,0xFF,0xF3,0x80,0x00,0x00,0x00,
0x4F,0xFF,0xFF,0xF9,0x2A,0x00,0x00,0x00,
0x9F,0x08,0xFF,0xD4,0x00,0x00,0x00,0x00,
0xB3,0xFF,0xFF,0xFE,0x54,0x80,0x00,0x00,
0x1E,0xA0,0x7F,0xA0,0x00,0x00,0x00,0x00,
0x5F,0xFE,0x7F,0xFE,0xAA,0x00,0x00,0x00,
0x5F,0x57,0xFE,0x00,0x00,0x00,0x00,0x00,
0xAF,0xFD,0x7F,0xFF,0x94,0x80,0x00,0x00,
0x1F,0xFE,0xE8,0x00,0x00,0x00,0x00,0x00,
0x7F,0xFA,0x7F,0x5F,0xCA,0x00,0x00,0x00,
0x3F,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xAF,0xF1,0x7F,0xDE,0xF5,0x40,0x00,0x00,
0x1A,0xA0,0x80,0x00,0x00,0x00,0x00,0x00,
0xDF,0xF2,0x3F,0xFC,0xC2,0x00,0x00,0x00,
0x50,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x2F,0xFA,0xBF,0xFF,0xF4,0xA0,0x00,0x00,
0x05,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
0x97,0xFE,0x3F,0xFF,0xE3,0x00,0x00,0x00,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x68,0xFF,0xDF,0xD5,0x78,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x5F,0xFF,0x48,0x02,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD0,0xAA,0xF4,0xA0,0xAA,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0A,0x45,0x09,0x05,0x11,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA1,0x28,0xA0,0x00,0x44,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x42,0x04,0x52,0x12,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA5,0x09,0x51,0x00,0x48,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x50,0x04,0x4A,0x12,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xAA,0x05,0x50,0x21,0x48,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x90,0x02,0x84,0x12,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD4,0x05,0x48,0x10,0x48,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x81,0x20,0x00,0x02,0x02,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA4,0x84,0x92,0x48,0x94,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x48,0x10,0x00,0x00,0x21,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
}
//这个是在串口时指令和数据之间的延时
/*
void delay10US(Uchar x)
{
Uchar k
for(k=0k<xk++)
}
*/
const Uchar delay=250 //延时时间常数
static void Wait1ms(void)//延迟1 ms
{
Uchar cnt=0
while (cnt<delay) cnt++
}
//延迟n ms
void WaitNms(int n)
{
Uchar i
for(i=1i<=ni++)
Wait1ms()
}
void stopint(void)//中断程序
{
if(stop==0)
while(1)
}
//**************************************************************************//
//以下是并口时才开的
//读忙标志,
void RDBF(void)
{
Uchar temp
RS=0// RS=0
RW=1// RW=1
while(1)
{
P1=0xFF //数据线为输入
E=1
temp=P1
E=0// E=0
if ((temp&0x80)==0) break
}
}
//写数据到指令寄存器
void WRCommand(Uchar comm)
{
RDBF()
RW=0
P1=comm
E=1
E=0
}
//写数据到数据寄存器
void WRData(Uchar TEMP)
{
RDBF()
RS=1
RW=0
P1=TEMP
E=1
E=0
stopint()
}
/////////////////////////////////////////////////////////////////////////////////
//以下是串口时开的读写时序
/*void SendByteLCD(Uchar WLCDData)
{
Uchar i
for(i=0i<8i++)
{
if((WLCDData<<i)&0x80)RW=1
else RW=0
E=0
E=1
}
}
SPIWR(Uchar Wdata,Uchar WRS)
{
SendByteLCD(0xf8+(WRS<<1))
SendByteLCD(Wdata&0xf0)
SendByteLCD((Wdata<<4)&0xf0)
}
void WRCommand(Uchar CMD)
{
RS=0
RS=1
SPIWR(CMD,0)
delay10US(90)//89S52来模拟串行通信,所以,加上89S52的延时,
}
void WRData(Uchar Data)
{
RS=0
RS=1
SPIWR(Data,1)
}
*/
/*******************************************************************/
//初始化LCD-8位接口
void LCDInit(void)
{ // PSB=0//串口
PSB=1//并口时选这个,上一行取消
REST=1
REST=0
REST=1
WRCommand(0x30)//基本指令集,8位并行
WRCommand(0x06)//启始点设定:光标右移
WRCommand(0x01)//清除显示DDRAM
WRCommand(0x0C)//显示状态开关:整体显示开,光标显示关,光标显示反白关
WRCommand(0x02)//地址归零
}
//显示数组字符串(显示半宽字型16*8点阵)
void ShowQQChar(Uchar addr,Uchar *english,Uchar count)
{
Uchar i
WRCommand(addr)//设定DDRAM地址
for(i=0i<count)
{
WRData(english[i*2])
WRData(english[i*2+1])
i++
}
}
//显示连续字串(半宽字符)
void ShowNUMChar(Uchar addr,Uchar i,Uchar count)
{
Uchar j
for(j=0j<count)
{
WRCommand(addr)//设定DDRAM地址
WRData(i+j)
j++
WRData(i+j)
addr++
j++
}
}
//自定义字符写入CGRAM
void WRCGRAM(Uchar data1,Uchar data2,Uchar addr)
{
Uchar i
for(i=0i<16)
{
WRCommand(addr+i) //设定CGRAM地址
WRData(data1)
WRData(data1)
i++
WRCommand(addr+i) //设定CGRAM地址
WRData(data2)
WRData(data2)
i++
}
}
//显示自定义的字符,并把这个字符填满全屏16*16
void ShowCGChar(Uchar addr,Uchar i)
{
Uchar j
for(j=0j<0x20)
{
WRCommand(addr+j)//设定DDRAM地址
WRData(0x00)
WRData(i)
j++
}
}
void CLEARGDRAM(void)
{
Uchar j
Uchar i
WRCommand(0x34)
WRCommand(0x36)
for(j=0j<32j++)
{
WRCommand(0x80+j)
WRCommand(0x80)//X坐标
for(i=0i<32i++)//
{
WRData(0x00)
}
}
}
//写入GDRAM 绘图,Y是Y绘图坐标,2个字节一行,CLONG是图形长度,以字节
//为单位HIGHT是图形高度,TAB是图形数据表.12864M的图形显示是相当于256*32点阵.
//由两屏128*32上下两屏组成,同一行的下屏的头地址紧接上屏的未地址。
//绘图在串口输入时,会比在并口下的输入要慢一些
void WRGDRAM(Uchar Y1,Uchar clong,Uchar hight,Uchar *TAB1)
{
Uint k
Uchar j
Uchar i
WRCommand(0x34)
WRCommand(0x36)
for(j=0j<hightj++)//32
{ //先上半屏
WRCommand(Y1+j) //Y总坐标,即第几行
WRCommand(0x80)//X坐标,即横数第几个字节开始写起
for(i=0i<clongi++)//
{
WRData(TAB1[clong*j+i])
}
//后下半屏
for(k=0k<clongk++)//
{
WRData(TAB1[clong*(j+hight)+k])
}
}
}
void menu(void)
{
LCDInit()
ShowNUMChar(0x80,0x01,0x0f)//显示半宽特殊符号
ShowNUMChar(0x90,0x30,0x0f)//显示半宽0~?数字标点
ShowNUMChar(0x88,0x41,0x0f)//显示半宽A~P大写
ShowNUMChar(0x98,0x61,0x0f)//显示半宽a~p小写
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
WRCGRAM(0xff,0x00,0x40)//写入横
WRCGRAM(0x00,0xff,0x50)//写入横2
WRCGRAM(0xaa,0xaa,0x60)//写入竖
WRCGRAM(0x55,0x55,0x70)//写入竖2
ShowCGChar(0x80,0x00)//显示横并填满
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
ShowCGChar(0x80,02)//显示横2并填满
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
ShowCGChar(0x80,04)//显示竖并填满
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
ShowCGChar(0x80,06)//显示竖2并填满
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
WRCGRAM(0x00,0x00,0x40)//清CGRAM1
WRCGRAM(0x00,0x00,0x50)//清CGRAM2
WRCGRAM(0xaa,0x55,0x40)//写入点
WRCGRAM(0x55,0xaa,0x50)//写入点2
ShowCGChar(0x80,00)//显示点并填满
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
ShowCGChar(0x80,02)//显示点2并填满
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
ShowQQChar(0x80,uctech,lengthCF3)//显示'有限公司',以下共四行
ShowQQChar(0x90,uctech,lengthCF3)
ShowQQChar(0x88,uctech,lengthCF3)
ShowQQChar(0x98,uctech,lengthCF3)
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
WRCommand(0x01)//清除显示DDRAM
}
void menu2(void)
{ CLEARGDRAM()
WRGDRAM(0x80,16,32,TAB1)
WaitNms(250) //等待时间
WaitNms(250) //等待时间
stopint()
}
//主函数
void main(void)
{
menu()//初始化及半宽字符和点横竖汉字扫描
menu2()//绘图显示
for()
{}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)