#include <reg52.h> #include <absacc.h> #include <stdio.h> #include <stdarg.h>
#define ulong unsigned long #define uint unsigned int #define uchar unsigned char #define STX 0x02 #define ETX 0x03 #define EOT 0x04 #define ENQ 0x05 #define BS 0x08 #define CR 0x0D #define LF 0x0A #define DLE 0X10 #define ETB 0x17 #define SPACE 0x20 #define COMMA 0x2C #define TRUE 1 #define FALSE 0 #define HIGH 1 #define LOW 0
/*T6963C 端口定义*/ #define LCMDW XBYTE[0X0000] #define LCMCW XBYTE[0X8100]
/*T6963C 命令定义*/ #define LC_CUR_POS 0x21 /*光标位置设置*/ #define LC_CGR_POS 0x22 /*CGRAM偏置地址设置*/ #define LC_ADD_POS 0x24 /*地址指针位置*/ #define LC_TXT_STP 0x40 /*文本区首地址*/ #define LC_TXT_WID 0x41 /*文本区宽度*/ #define LC_GRH_STP 0x42 /*图形区首地址*/ #define LC_GRH_WID 0x43 /*图形区宽度*/ #define LC_MOD_OR 0x80 /*显示方式:逻辑或*/ #define LC_MOD_XOR 0x81 /*显示方式:逻辑异或*/ #define LC_MOD_AND 0x83 /*显示方式:逻辑与*/ #define LC_MOD_TCH 0X84 /*显示方式:文本特征*/ #define LC_DIS_SW 0x90 /*显示开关*/ /*D0=1/0:光标闪烁启用/禁用*/ /*D1=1/0:光标显示启用/禁用*/ /*D2=1/0:文本显示启用/禁用*/ /*D3=1/0:图形显示启用/禁用*/ #define LC_CUR_SHP 0xA0 /*光标形状选择*/ #define LC_AUT_WR 0xB0 /*自动写设置*/ #define LC_AUT_RD 0xB1 /*自动读设置*/ #define LC_AUT_OVR 0xB2 /*自动读/写结束*/ #define LC_INC_WR 0xC0 /*数据一次写,地址加1*/ #define LC_INC_RD 0xC1 /*数据一次读,地址加1*/ #define LC_DEC_WR 0xC2 /*数据一次写,地址减1*/ #define LC_DEC_RD 0xC3 /*数据一次读,地址减1*/ #define LC_NOC_WR 0xC4 /*数据一次写,地址不变*/ #define LC_NOC_RD 0xC5 /*数据一次读,地址不变*/ #define LC_SCN_RD 0xE0 /*屏读*/ #define LC_SCN_CP 0xE8 /*屏拷贝*/ #define LC_BIT_OP 0xF0 /*位操作*/
uchar code cctab16[][32]= { /*二*/ 0x00,0x00,0x00,0x10,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00, /*十*/ 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00, 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00, /*四*/ 0x00,0x00,0x7F,0xFC,0x44,0x84,0x44,0x84,0x44,0x84,0x44,0x84,0x44,0x84,0x44,0x84, 0x48,0x84,0x48,0x7C,0x50,0x04,0x60,0x04,0x40,0x04,0x7F,0xFC,0x40,0x04,0x00,0x00, /*点*/ 0x01,0x00,0x01,0x00,0x01,0xF8,0x01,0x00,0x01,0x10,0x1F,0xF8,0x10,0x10,0x10,0x10, 0x10,0x10,0x1F,0xF0,0x10,0x10,0x01,0x10,0x28,0x88,0x24,0x44,0x44,0x44,0x00,0x00, /*游*/ 0x44,0x20,0x22,0x20,0x22,0x20,0x0F,0xBE,0x84,0x40,0x54,0xBC,0x57,0x08,0x25,0x10, 0x25,0x10,0x25,0x7E,0xC5,0x10,0x49,0x10,0x49,0x10,0x49,0x10,0x55,0x50,0x42,0x20, /*戏*/ 0x00,0x40,0x00,0x50,0x7E,0x48,0x02,0x48,0x44,0x40,0x25,0xFE,0x18,0x40,0x08,0x44, 0x0C,0x28,0x14,0x30,0x12,0x20,0x22,0x50,0x41,0x92,0x06,0x0A,0x00,0x06,0x00,0x02, /*程*/ 0x0D,0xF8,0x71,0x08,0x11,0x08,0x11,0x08,0xFD,0x08,0x11,0xF8,0x30,0x00,0x3B,0xFC, 0x54,0x40,0x50,0x40,0x93,0xFC,0x10,0x40,0x10,0x40,0x10,0x40,0x17,0xFE,0x10,0x00, /*序*/ 0x01,0x00,0x00,0x80,0x3F,0xFE,0x20,0x00,0x27,0xF8,0x21,0x10,0x20,0xA0,0x20,0x40, 0x2F,0xFE,0x20,0x44,0x20,0x40,0x20,0x40,0x20,0x40,0x40,0x40,0x41,0x40,0x80,0x80, /*指*/ 0x11,0x00,0x11,0x38,0x11,0xC0,0x11,0x04,0xFD,0x04,0x11,0xFC,0x14,0x00,0x19,0xFC, 0x31,0x04,0xD1,0x04,0x11,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x51,0xFC,0x20,0x00, /*导*/ 0x00,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x04,0x10,0x04,0x0F,0xFC,0x00,0x20, 0x00,0x20,0xFF,0xFE,0x08,0x20,0x04,0x20,0x06,0x20,0x04,0x20,0x00,0xA0,0x00,0x40 }; int n=9; int i,j; uchar b; uchar gCurRow,gCurCol;
uchar fngetRoW(void) { return gCurRow; }
uchar fngetCol(void) { return gCurCol; }
uchar fnST01(void) {
while (!((LCMCW & 0x03)==0x03)) {
}
}
uchar fnST2(void) {
while(!((LCMCW & 0x04)==0x04)) { }
}
uchar fnST3(void) {
while(!((LCMCW & 0x08)==0x08)) { } }
uchar fnPR1(uchar uCmd,uchar uPar1,uchar uPar2) { fnST01();
LCMDW = uPar1; fnST01();
LCMDW = uPar2; fnST01();
LCMCW = uCmd;
}
uchar fnPR11(uchar uCmd,uchar uPar1) { fnST01();
LCMDW = uPar1; fnST01();
LCMCW = uCmd;
}
uchar fnPR12(uchar uCmd) { fnST01();
LCMCW = uCmd;
}
uchar fnPR13(uchar uData) { fnST01(); LCMDW = uData;
}
uchar fnPR2(void) { fnST01();
return LCMDW; }
void fnSetpos(uchar urow,uchar ucol) { uint ipos; ipos=urow*32+ucol; fnPR1(LC_ADD_POS,ipos & 0xFF,ipos/256); gCurRow = urow; gCurCol = ucol; }
void cursor(uchar uRow,uchar uCol) { fnSetpos(uRow*16,uCol); }
void cls(void) { uint i; fnPR1(LC_ADD_POS,0x00,0x00); fnPR12(LC_AUT_WR); for(i=0;i<8192;i++) { fnST3(); fnPR13(0x00); } fnPR12(LC_AUT_OVR); fnPR1(LC_ADD_POS,0x00,0x00); gCurRow =0; gCurCol =0; }
char fnLCMInit (void) { uchar b;
fnPR1(LC_GRH_STP,0x00,b); fnPR1(LC_GRH_WID,0x20,0x00); fnPR1(LC_TXT_STP,0x00,0x00); fnPR1(LC_TXT_WID,0x20,0x00); fnPR12(LC_CUR_SHP | 0x01); fnPR12(LC_MOD_OR); fnPR12(0x98); return 0; }
void dprintf_16(uchar uRow,uchar uCol,uchar ucod) file://图形方式下显示16*16汉字 { unsigned short Adr; uchar j; uchar i; Adr=uRow+(uCol*32); j=0; for(i=0;i<16;i++) { uCol=Adr/256; file://计算得到X,Y代表的实际存储地址 uRow=Adr%256; fnPR13(uRow); file://写入地址 fnPR13(uCol); fnPR12(0x24); fnPR13(cctab16[ucod][j]); file://写入同行横字模1 fnPR12(0xc0); j=j+1; fnPR13(cctab16[ucod][j]); file://写入同行横字模2 fnPR12(0xc0); j=j+1; Adr=Adr+32; file://计算新地址 } }
void main(void) {
cls(); cursor(0,0); for(i=0;i<n;i++) { fnLCMInit(); dprintf_16(0,j+i*16,i); }
do { } while(1); }
请各位高手帮帮忙,如何修该fnLCMInit 子函数里的b值能实现滚屏
----------------解决方案--------------------------------------------------------