当前位置:首页 > 单片机 > 单片机
[导读] /*本例程未使用6963的文本模式,使用程序填入字模也足够快。程序以Youth所提供的51例程移植过来,同时对有些地方做了简化处理,增加了画线画圆的例程,好在6963的画点有专用指令,所以不用读屏就可以直

/*本例程未使用6963的文本模式,使用程序填入字模也足够快。程序以Youth所提供
的51例程移植过来,同时对有些地方做了简化处理,增加了画线画圆的例程,好在
6963的画点有专用指令,所以不用读屏就可以直接画点。

;************************************************************************
;连线图:液晶屏分为8行*15列汉字,使用总线接口方式。*
;*LCM----S8515**LCM----S8515**LCM-----S8515**LCM-----S8515**
;*DB0-----PA0**DB4-----PA4**Rd------/Rd**Cd------PC0**
;*DB1-----PA1**DB5-----PA5**Wr------/Wr**CE------PC1**
;*DB2-----PA2**DB6-----PA6**RST------VCC**FS------Vcc**
;*DB3-----PA3**DB7-----PA7**
;注:S8515的晶振频率为8MHz,尝试使用11.0592MHz超频,发现偶尔有数据丢失*
;************************************************************************/
#include

#defineWDR()asm("wdr")//汇编指令调用的定义
#defineBIT(x)(1<<(x))

#defineSRE7
#defineSRW6
#defineSE5

#defineulongunsignedlong
#defineuintunsignedint
#defineucharunsignedchar

//ASCII字符控制代码解释定义
#defineSTX0x02
#defineETX0x03
#defineEOT0x04
#defineENQ0x05
#defineBS0x08
#defineCR0x0D
#defineLF0x0A
#defineDLE0x10
#defineETB0x17
#defineSPACE0x20
#defineCOMMA0x2C

#defineTRUE1
#defineFALSE0

#defineHIGH1
#defineLOW0

//T6963C端口定义由汇编语言程序定义外部端口
__no_initstatICucharLCMCW@0xF100;//命令口
__no_initstaticucharLCMDW@0xF000;//数据口

//T6963C命令定义
#defineLC_CUR_POS0x21//光标位置设置
#defineLC_CGR_POS0x22//CGRAM偏置地址设置
#defineLC_ADD_POS0x24//地址指针位置
#defineLC_TXT_STP0x40//文本区首址
#defineLC_TXT_WID0x41//文本区宽度
#defineLC_GRH_STP0x42//图形区首址
#defineLC_GRH_WID0x43//图形区宽度
#defineLC_MOD_OR0x80//显示方式:逻辑“或”
#defineLC_MOD_XOR0x81//显示方式:逻辑“异或”
#defineLC_MOD_AND0x82//显示方式:逻辑“与”
#defineLC_MOD_TCH0x83//显示方式:文本特征
#defineLC_DIS_SW0x90//显示开关:D0=1/0:光标闪烁启用/禁用;
//D1=1/0:光标显示启用/禁用;
//D2=1/0:文本显示启用/禁用;
//D3=1/0:图形显示启用/禁用;
#defineLC_CUR_SHP0xA0//光标形状选择:0xA0-0xA7表示光标占的行数
#defineLC_AUT_WR0xB0//自动写设置
#defineLC_AUT_RD0xB1//自动读设置
#defineLC_AUT_OVR0xB2//自动读/写结束
#defineLC_INC_WR0xC0//数据一次写,地址加1
#defineLC_INC_RD0xC1//数据一次读,地址加1
#defineLC_DEC_WR0xC2//数据一次写,地址减1
#defineLC_DEC_RD0xC3//数据一次读,地址减1
#defineLC_NOC_WR0xC4//数据一次写,地址不变
#defineLC_NOC_RD0xC5//数据一次读,地址不变
#defineLC_SCN_RD0xE0//屏读
#defineLC_SCN_CP0xE8//屏拷贝
#defineLC_BIT_OP0xF0//位操作:
//D0-D2:定义D0-D7位;D3:1置位;0:清除

__flashucharuPowArr[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

//ASCII字模宽度及高度定义
#defineASC_CHR_WIDTH8
#defineASC_CHR_HEIGHT16

//ASCII字模,显示为8*16
__flashcharASC_MSK[96*16]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*----*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,/*--!--*/
0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x66,0x00,0x00,/*--"--*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x36,0x36,0x7F,0x36,0x36,/*--#--*/
0x36,0x7F,0x36,0x36,0x00,0x00,0x00,0x00,
0x00,0x18,0x18,0x3C,0x66,0x60,0x30,0x18,/*--$--*/
0x0C,0x06,0x66,0x3C,0x18,0x18,0x00,0x00,
0x00,0x00,0x70,0xD8,0xDA,0x76,0x0C,0x18,/*--%--*/
0x30,0x6E,0x5B,0x1B,0x0E,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x6C,0x6C,0x38,0x60,/*--&--*/
0x6F,0x66,0x66,0x3B,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x00,/*--’--*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0C,0x18,0x18,0x30,0x30,/*--(--*/
0x30,0x30,0x30,0x18,0x18,0x0C,0x00,0x00,
0x00,0x00,0x00,0x30,0x18,0x18,0x0C,0x0C,/*--)--*/
0x0C,0x0C,0x0C,0x18,0x18,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x36,0x1C,0x7F,/*--*--*/
0x1C,0x36,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,/*--+--*/
0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*--,--*/
0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,/*-----*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*--.--*/
0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x06,0x0C,0x0C,0x18,/*--/--*/
0x18,0x30,0x30,0x60,0x60,0x00,0x00,0x00,
0x00,0x00,0x00,0x1E,0x33,0x37,0x37,0x33,/*--0--*/
0x3B,0x3B,0x33,0x1E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0C,0x1C,0x7C,0x0C,0x0C,/*--1--*/
0x0C,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x06,0x0C,/*--2--*/
0x18,0x30,0x60,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x06,0x1C,/*--3--*/
0x06,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x30,0x30,0x36,0x36,0x36,/*--4--*/
0x66,0x7F,0x06,0x06,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C,/*--5--*/
0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x18,0x30,0x7C,0x66,/*--6--*/
0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0x06,0x0C,0x0C,0x18,/*--7--*/
0x18,0x30,0x30,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x76,0x3C,/*--8--*/
0x6E,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,/*--9--*/
0x3E,0x0C,0x18,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,/*--:--*/
0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,/*--;--*/
0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00,
0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,/*--<--*/
0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,/*--=--*/
0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06,/*-->--*/
0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x0C,0x18,/*--?--*/
0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0xC3,0xC3,0xCF,0xDB,/*--@--*/
0xDB,0xCF,0xC0,0x7F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x3C,0x66,0x66,0x66,/*--A--*/
0x7E,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,/*--B--*/
0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x60,0x60,/*--C--*/
0x60,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x78,0x6C,0x66,0x66,0x66,/*--D--*/
0x66,0x66,0x6C,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C,/*--E--*/
0x60,0x60,0x60,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C,/*--F--*/
0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x60,0x60,/*--G--*/
0x6E,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x7E,/*--H--*/
0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x18,0x18,0x18,0x18,/*--I--*/
0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,/*--J--*/
0x06,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x6C,0x6C,0x78,/*--K--*/
0x6C,0x6C,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,/*--L--*/
0x60,0x60,0x60,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x63,0x63,0x77,0x6B,0x6B,/*--M--*/
0x6B,0x63,0x63,0x63,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x63,0x63,0x73,0x7B,0x6F,/*--N--*/
0x67,0x63,0x63,0x63,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,/*--O--*/
0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,/*--P--*/
0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,/*--Q--*/
0x66,0x66,0x66,0x3C,0x0C,0x06,0x00,0x00,
0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,/*--R--*/
0x6C,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x66,0x60,0x30,0x18,/*--S--*/
0x0C,0x06,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0x18,0x18,0x18,0x18,/*--T--*/
0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,/*--U--*/
0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,/*--V--*/
0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x63,0x63,0x63,0x6B,0x6B,/*--W--*/
0x6B,0x36,0x36,0x36,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x34,0x18,0x18,/*--X--*/
0x2C,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3C,/*--Y--*/
0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0x06,0x06,0x0C,0x18,/*--Z--*/
0x30,0x60,0x60,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x30,0x30,0x30,0x30,/*--[--*/
0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x3C,
0x00,0x00,0x00,0x60,0x60,0x30,0x30,0x18,/*----*/
0x18,0x0C,0x0C,0x06,0x06,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,/*--]--*/
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x3C,
0x00,0x18,0x3C,0x66,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,0xFF,0xFF,
0x00,0x38,0x18,0x0C,0x00,0x00,0x00,0x00,/*--`--*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3C,0x06,0x06,/*--a--*/
0x3E,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x60,0x7C,0x66,0x66,/*--b--*/
0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x60,/*--c--*/
0x60,0x60,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x06,0x3E,0x66,0x66,/*--d--*/
0x66,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,/*--e--*/
0x7E,0x60,0x60,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1E,0x30,0x30,0x30,0x7E,/*--f--*/
0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,/*--g--*/
0x66,0x66,0x66,0x3E,0x06,0x06,0x7C,0x7C,
0x00,0x00,0x00,0x60,0x60,0x7C,0x66,0x66,/*--h--*/
0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x00,0x78,0x18,0x18,/*--i--*/
0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x0C,0x00,0x3C,0x0C,0x0C,/*--j--*/
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x78,0x78,
0x00,0x00,0x00,0x60,0x60,0x66,0x66,0x6C,/*--k--*/
0x78,0x6C,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x78,0x18,0x18,0x18,0x18,/*--l--*/
0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7E,0x6B,0x6B,/*--m--*/
0x6B,0x6B,0x6B,0x63,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,/*--n--*/
0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,/*--o--*/
0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,/*--p--*/
0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x60,
0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,/*--q--*/
0x66,0x66,0x66,0x3E,0x06,0x06,0x06,0x06,
0x00,0x00,0x00,0x00,0x00,0x66,0x6E,0x70,/*--r--*/
0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3E,0x60,0x60,/*--s--*/
0x3C,0x06,0x06,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x30,0x30,0x7E,0x30,0x30,/*--t--*/
0x30,0x30,0x30,0x1E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,/*--u--*/
0x66,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,/*--v--*/
0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x63,0x6B,0x6B,/*--w--*/
0x6B,0x6B,0x36,0x36,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x3C,/*--x--*/
0x18,0x3C,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,/*--y--*/
0x66,0x66,0x66,0x3C,0x0C,0x18,0xF0,0xF0,
0x00,0x00,0x00,0x00,0x00,0x7E,0x06,0x0C,/*--z--*/
0x18,0x30,0x60,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0C,0x18,0x18,0x18,0x30,/*--{--*/
0x60,0x30,0x18,0x18,0x18,0x0C,0x00,0x00,
0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,/*--|--*/
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x00,0x00,0x00,0x30,0x18,0x18,0x18,0x0C,/*--}--*/
0x06,0x0C,0x18,0x18,0x18,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x71,0xDB,/*--~--*/
0x8E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*--.--*/
0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00
};

typedefstruct//汉字字模数据结构
{
charIndex[2];
charMsk[32];
}typFNT_GB16;

__flashtypFNT_GB16GB_16[]=
{//显示为16*16
"中",0x01,0x00,0x01,0x00,0x21,0x08,0x3F,0xFC,
0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,
0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
"文",0x02,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,
0x08,0x20,0x08,0x20,0x08,0x20,0x04,0x40,
0x04,0x40,0x02,0x80,0x01,0x00,0x02,0x80,
0x04,0x60,0x18,0x1E,0xE0,0x08,0x00,0x00,
"测",0x40,0x02,0x27,0xC2,0x24,0x42,0x84,0x52,
0x45,0x52,0x55,0x52,0x15,0x52,0x25,0x52,
0x25,0x52,0x25,0x52,0xC5,0x52,0x41,0x02,
0x42,0x82,0x42,0x42,0x44,0x4A,0x48,0x04,
"试",0x00,0x20,0x40,0x28,0x20,0x24,0x30,0x24,
0x27,0xFE,0x00,0x20,0xE0,0x20,0x27,0xE0,
0x21,0x20,0x21,0x10,0x21,0x10,0x21,0x0A,
0x29,0xCA,0x36,0x06,0x20,0x02,0x00,0x00
};
ucharconstturnf[8]={7,6,5,4,3,2,1,0};
uchargCurRow,gCurCol;//当前行、列存储,行高16点,列宽8点

/*取当前行数据*/
ucharfnGetRow(void)
{
returngCurRow;
}

/*取当前列数据*/
ucharfnGetCol(void)
{
returngCurCol;
}

/************************************************/
/*状态位STA1,STA0判断(读写指令和读写数据)*/
/*在读写数据或者写入命令前必须保证均为1*/
/************************************************/
ucharfnSTA01(void)
{
uchari;

for(i=10;i>0;i--)
{
if((LCMCW&0x03)==0x03)//读取状态
break;
}
returni;//若返回零,说明错误
}

/********************************************************/
/*检查STA2,如果STA2=1为自动读状态*/
/********************************************************/
ucharfnSTA2(void)
{
uchari;

for(i=10;i>0;i--)
{
if((LCMCW&0x04)==0x04)
break;
}
returni;//若返回零,说明错误
}

/********************************************************/
/*状态位STA3判断(STA3=1数据自动写状态)*/
/********************************************************/
ucharfnSTA3(void)
{
uchari;

for(i=10;i>0;i--)
{
if((LCMCW&0x08)==0x08)
break;
}
returni;//若返回零,说明错误
}

/********************************************************/
/*状态位STA6判断(STA6=1屏读/屏拷贝状态)*/
/********************************************************/
ucharfnSTA6(void)
{
uchari;

for(i=10;i>0;i--)
{
if((LCMCW&0x40)==0x40)
break;
}
returni;//若返回零,说明错误
}

/********************************************************/
/*写双参数的指令*/
/********************************************************/
ucharfnPR1(ucharuCmd,ucharuPar1,ucharuPar2)
{
if(fnSTA01()==0)
return1;
LCMDW=uPar1;
if(fnSTA01()==0)
return2;
LCMDW=uPar2;
if(fnSTA01()==0)
return3;
LCMCW=uCmd;
return0;//返回0成功
}

/********************************************************/
/*写单参数的指令*/
/********************************************************/
ucharfnPR11(ucharuCmd,ucharuPar1)
{
if(fnSTA01()==0)
return1;
LCMDW=uPar1;
if(fnSTA01()==0)
return2;
LCMCW=uCmd;
return0;//返回0成功
}

/********************************************************/
/*写无参数的指令*/
/********************************************************/
ucharfnPR12(ucharuCmd)
{
if(fnSTA01()==0)
return1;
LCMCW=uCmd;
return0;//返回0成功
}

/********************************************************/
/*写数据*/
/********************************************************/
ucharfnPR13(ucharuData)
{
if(fnSTA3()==0)
return1;
LCMDW=uData;
return0;//返回0成功
}

/********************************************************/
/*读数据*/
/********************************************************/
ucharfnPR2(void)
{
if(fnSTA01()==0)return1;//获取状态,如果状态错
returnLCMDW;//返回数据
}

/********************************************************/
/*设置当前地址*/
/********************************************************/
voidfnSetPos(ucharurow,ucharucol)
{
uintiPos;

iPos=urow*30+ucol;
fnPR1(LC_ADD_POS,iPos&0xFF,iPos/256);
gCurRow=urow;
gCurCol=ucol;
}

/********************************************************/
/*设置当前显示行、列*/
/********************************************************/
voidcursor(ucharuRow,ucharuCol)
{
fnSetPos(uRow*16,uCol);
}

/********************************************************/
/*清屏*/
/********************************************************/
voidcls(void)
{
uinti;

fnPR1(LC_ADD_POS,0x00,0x00);//置地址指针为从零开始
fnPR12(LC_AUT_WR);//自动写
for(i=0;i<240*128/8;i++)//清一屏
{
fnSTA3();
fnPR13(0x0);//写数据,实际使用时请将0x55改成0x0
}
fnPR12(LC_AUT_OVR);//自动写结束
fnPR1(LC_ADD_POS,0x00,0x00);//重置地址指针
gCurRow=0;//置地址指针存储变量
gCurCol=0;
}

/********************************************************/
/*LCM初始化*/
/********************************************************/
charfnLCMInit(void)
{
if(fnPR1(LC_TXT_STP,0x00,0x00)!=0)//文本显示区首地址
return(0xff);
fnPR1(LC_TXT_WID,0x1E,0x00);//文本显示区宽度
fnPR1(LC_GRH_STP,0x00,0x00);//图形显示区首地址
fnPR1(LC_GRH_WID,0x1E,0x00);//图形显示区宽度
fnPR12(LC_CUR_SHP|0x01);//光标形状
fnPR12(LC_MOD_OR);//显示方式设置
fnPR12(LC_DIS_SW|0x08);//显示开关设置

return0;
}

/********************************************************/
/*ASCII(8*16)及汉字(16*16)显示函数*/
/********************************************************/
uchardprintf(ucharx,uchary,char*ptr)
{

charc1,c2,cData;
uchari,j,uLen,uRow,uCol;
uintk;
uLen=0;
i=0;
uRow=y;
uCol=x;
fnSetPos(uRow*16,uCol);//起点定位
while(ptr[uLen]!=0){uLen++;};//探测字串长度

while(i{
c1=ptr[i];
c2=ptr[i+1];
//ascii字符与汉字内码的区别在于128做分界,大于界线的为汉字码
uRow=fnGetRow();
uCol=fnGetCol();
if(c1<=128)//ASCII
{
for(j=0;j<16;j++)//写16行
{
fnPR12(LC_AUT_WR);//写数据(命令)
if(c1>=0x20)
{
fnPR13(ASC_MSK[(c1-0x20)*ASC_CHR_HEIGHT+j-(16-ASC_CHR_HEIGHT)]);
}
else
fnPR13(cData);
fnPR12(LC_AUT_OVR);//写数据结束
fnSetPos(uRow+j+1,uCol);
}
if(c1!=BS)//非退格
uCol++;//列数加1
}
else//中文
{
for(j=0;j{
if(c1==GB_16[j].Index[0]&&c2==GB_16[j].Index[1])
break;
}
for(k=0;k{
fnSetPos(uRow+k,uCol);
fnPR12(LC_AUT_WR);//写数据
if(j{
fnPR13(GB_16[j].Msk[k*2]);
fnPR13(GB_16[j].Msk[k*2+1]);
}
else//未找到该字
{
if(k{
fnPR13(0x00);
fnPR13(0x00);
}
else
{
fnPR13(0xff);
fnPR13(0xff);
}
}
fnPR12(LC_AUT_OVR);
}
uCol+=2;
i++;
};
if(uCol>=30)//光标后移
{
uRow+=16;
if(uRow<0x80)
uCol-=30;
else
{
uRow=0;
uCol=0;
}
}
fnSetPos(uRow,uCol);
i++;
}
returnuLen;//返回字串长度,汉字按2字节计算
}

/*==============================*/
/*延时*/
/*==============================*/
voidshortdelay(uinttt)
{
uchari;
while(tt)
{
i=100;
while(i)i--;
tt--;
};
}
/****************************************/
/*画点*/
/****************************************/

voidpoint(ucharx,uchary,uchars)
{
ucharx1;
x1=x>>3;//取Y方向分页地址
fnSetPos(y,x1);//起点定位
x1=turnf[x&0x07];
x1=0xF0|x1|s;//字节内位置计算
fnPR12(x1);//画上屏幕,S显示属性8画点0擦除点
}


/************************************************/
/*画线。任意方向的斜线,直线数学方程aX+bY=1*/
/************************************************/
voidLinexy(ucharx0,uchary0,ucharxt,ucharyt,uchars)
{
registeruchart;
intxerr=0,yerr=0,delta_x,delta_y,distance;
intincx,incy,uRow,uCol;

delta_x=xt-x0;//计算坐标增量
delta_y=yt-y0;
uRow=x0;
uCol=y0;
if(delta_x>0)incx=1;//设置单步方向
elseif(delta_x==0)incx=0;//垂直线
else{incx=-1;delta_x=-delta_x;}

if(delta_y>0)incy=1;
elseif(delta_y==0)incy=0;//水平线
else{incy=-1;delta_y=-delta_y;}

if(delta_x>delta_y)distance=delta_x;//选取基本增量坐标轴
elsedistance=delta_y;

for(t=0;t<=distance+1;t++)
{//画线输出
point(uRow,uCol,s);//画点
xerr+=delta_x;
yerr+=delta_y;

if(xerr>distance)
{
xerr-=distance;
uRow+=incx;
}
if(yerr>distance)
{
yerr-=distance;
uCol+=incy;
}
}
}

/************************************************/
/*画圆。数学方程(X-Ox)^2+(Y-Oy)^2=Rx^2*/
/************************************************/
voidcircle(ucharOx,ucharOy,ucharRx,uchars)
{
unsignedintxx,rr,xt,yt,rs,row,col;
yt=Rx;
rr=Rx*Rx+1;//补偿1修正方形
rs=(yt+(yt>>1))>>1;//(*0.75)分开1/8圆弧来画
for(xt=0;xt<=rs;xt++)
{
xx=xt*xt;
while((yt*yt)>(rr-xx))yt--;
row=Ox+xt;//第一象限
col=Oy-yt;
point(row,col,s);
row=Ox-xt;//第二象限
point(row,col,s);
col=Oy+yt;//第三象限
point(row,col,s);
row=Ox+xt;//第四象限
point(row,col,s);

/***************45度镜象画另一半***************/

row=Ox+yt;//第一象限
col=Oy-xt;
point(row,col,s);
row=Ox-yt;//第二象限
point(row,col,s);
col=Oy+xt;//第三象限
point(row,col,s);
row=Ox+yt;//第四象限
point(row,col,s);
}
}


voidmain(void)//测试用
{
uchari;
shortdelay(1200);
MCUCR|=BIT(SRE)|BIT(SRW);
fnLCMInit();
cls();
cursor(0,0);
dprintf(3,3,"Thisisatest:中文测试");

dprintf(0,6,"LCMExsampleuse90S8515&6963");
dprintf(15,7,"~Xiaoqi~");
Linexy(10,20,239,110,8);//画斜线1
Linexy(10,20,217,1,8);//斜线2
Linexy(239,110,217,1,8);//斜线3
circle(185,45,40,8);//画圆
circle(185,45,41,8);//画同心圆加粗
shortdelay(24000);

while(1)
{
//变化圆演示,直径不断的变化,由大到小再由小到大来回缩放
for(i=40;i>5;i--)
{
circle(185,45,i+1,0);//擦除外圆
circle(185,45,i,8);
circle(185,45,i-1,8);
shortdelay(3600);
};

shortdelay(8000);

for(i=5;i<40;i++)
{
circle(185,45,i-1,0);//擦除内圆
circle(185,45,i,8);
circle(185,45,i+1,8);
shortdelay(1800);
};

shortdelay(4000);

};
}

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

9月2日消息,不造车的华为或将催生出更大的独角兽公司,随着阿维塔和赛力斯的入局,华为引望愈发显得引人瞩目。

关键字: 阿维塔 塞力斯 华为

加利福尼亚州圣克拉拉县2024年8月30日 /美通社/ -- 数字化转型技术解决方案公司Trianz今天宣布,该公司与Amazon Web Services (AWS)签订了...

关键字: AWS AN BSP 数字化

伦敦2024年8月29日 /美通社/ -- 英国汽车技术公司SODA.Auto推出其旗舰产品SODA V,这是全球首款涵盖汽车工程师从创意到认证的所有需求的工具,可用于创建软件定义汽车。 SODA V工具的开发耗时1.5...

关键字: 汽车 人工智能 智能驱动 BSP

北京2024年8月28日 /美通社/ -- 越来越多用户希望企业业务能7×24不间断运行,同时企业却面临越来越多业务中断的风险,如企业系统复杂性的增加,频繁的功能更新和发布等。如何确保业务连续性,提升韧性,成...

关键字: 亚马逊 解密 控制平面 BSP

8月30日消息,据媒体报道,腾讯和网易近期正在缩减他们对日本游戏市场的投资。

关键字: 腾讯 编码器 CPU

8月28日消息,今天上午,2024中国国际大数据产业博览会开幕式在贵阳举行,华为董事、质量流程IT总裁陶景文发表了演讲。

关键字: 华为 12nm EDA 半导体

8月28日消息,在2024中国国际大数据产业博览会上,华为常务董事、华为云CEO张平安发表演讲称,数字世界的话语权最终是由生态的繁荣决定的。

关键字: 华为 12nm 手机 卫星通信

要点: 有效应对环境变化,经营业绩稳中有升 落实提质增效举措,毛利润率延续升势 战略布局成效显著,战新业务引领增长 以科技创新为引领,提升企业核心竞争力 坚持高质量发展策略,塑强核心竞争优势...

关键字: 通信 BSP 电信运营商 数字经济

北京2024年8月27日 /美通社/ -- 8月21日,由中央广播电视总台与中国电影电视技术学会联合牵头组建的NVI技术创新联盟在BIRTV2024超高清全产业链发展研讨会上宣布正式成立。 活动现场 NVI技术创新联...

关键字: VI 传输协议 音频 BSP

北京2024年8月27日 /美通社/ -- 在8月23日举办的2024年长三角生态绿色一体化发展示范区联合招商会上,软通动力信息技术(集团)股份有限公司(以下简称"软通动力")与长三角投资(上海)有限...

关键字: BSP 信息技术
关闭
关闭