那位高手帮我详细点分析下面这段程序 小弟感激不尽
16*16点阵程序
#include #define uchar unsigned char #define uint unsigned int ***it SH_CP=P2^1; ***it DS=P2^0; ***it ST_CP=P2^2; ***it s=P2^4; ***it clk=P2^5; uchar code tab[ ]= { 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,0x00,0x00,0x00,0x00,/*" ",0*/ 0x00,0x00,0x20,0x00,0x17,0xFC,0x10,0x40,0x80,0x40,0x40,0x40,0x48,0x40,0x08,0x40, 0x10,0x40,0x10,0x40,0xE0,0x40,0x20,0x40,0x20,0x40,0x2F,0xFE,0x20,0x00,0x00,0x00,/*"江",0*/ 0x00,0x00,0x7D,0xFC,0x45,0x04,0x49,0x04,0x49,0x04,0x51,0xFC,0x49,0x04,0x49,0x04, 0x45,0x04,0x45,0xFC,0x45,0x04,0x69,0x04,0x52,0x04,0x42,0x04,0x44,0x14,0x48,0x08,/*"阴",1*/ 0x22,0x08,0x11,0x08,0x11,0x10,0x00,0x20,0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0, 0x00,0x40,0x01,0x80,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,/*"学",2*/ 0x00,0x40,0x78,0x20,0x4B,0xFE,0x52,0x02,0x54,0x04,0x61,0xF8,0x50,0x00,0x48,0x00, 0x4B,0xFE,0x48,0x90,0x68,0x90,0x50,0x90,0x41,0x12,0x41,0x12,0x42,0x0E,0x44,0x00,/*"院",3*/ }; uchar num,temp,temp1,temp2; //顺向、逐列、阴码 MICROSOFT SANS SERIF 字宽32 字高25 MATRIX-8X8-GREEN 左旋90度 左右翻转 // MATRIX-8X8-RED 右旋90度 上下翻转 void delay_ms(unsigned int ms) { uchar j; while(ms--) for(j=0;j<123;j++); } void WriteByte(uchar dat) { uchar k; for(k=0;k<8;k++) { dat=dat>>1; DS=CY; SH_CP=0; SH_CP=1; } } void disp_up() { uchar i,m,k; for(k=0;k<4;k++)//4个字符(含空格) for(i=0;i<16;i++) { for(m=0;m<4;m++) //重复显示4次 for(num=0;num<16;num++) //每字16字节 { if(i<8) { temp1=tab[2*num+k*32]<前字节左移i位 temp1|=tab[2*num+1+k*32]>>8-i;//或后字节的最高位 temp2=tab[2*num+1+k*32]< temp2|=tab[2*num+32*(k+1)]>>8-i;//或下一字前字节的最高位 } else { temp1=tab[2*num+1+k*32]< temp1|=tab[2*num+32*(k+1)]>>8-i+8; temp2=tab[2*num+32*(k+1)]< temp2+=tab[2*num+1+32*(k+1)]>>8-i+8; } WriteByte(temp2); WriteByte(temp1); P1=temp; clk=0; clk=1; s=1; ST_CP=0; ST_CP=1; delay_ms(1); temp++; if(temp==16) {temp=0; s=0; } } } } void main() { uint t; for(t=0;t>16;t++) { clk=0; clk=1; } s=0; while(1) { temp=0;// 不加此条,流动飞快 disp_up(); } }
|