- #define uint unsigned int
- #define uchar unsigned char
- #define xchar unsigned char code
- sbit A0 = P2^0;
- sbit WRR = P3^6;
- sbit RDD = P3^7;
- sbit CS = P2^7;
- sbit RES = P2^4;
- sbit BF = ACC^7;
- uchar code num_8x16[11][16];
- uchar code num_24x48[11][144];
- uchar code hui_32x32[];
- uchar code jing_32x32[];
- uchar code ke_32x32[];
- uchar code ji_32x32[];
- uchar code num_16x24_2[];
- uchar code num_16x24_4[];
- uchar code num_16x24_0[];
- uchar code num_16x24_x[];
- uchar code num_16x24_1[];
- uchar code num_16x24_3[];
- uchar code hui2_24x24[];
- uchar code jiu_24x24[];
- uchar code jiao_24x24[];
- uchar code dian_24x24[];
- uchar code jing2_24x24[];
- uchar code ping_24x24[];
- uchar code zi_24x24[];
- uchar code sang_24x24[];
- uint i,data1,temp,data2,j,k;
- uchar m1,num,ii,z,z1,d,d1,s,s1,s10,s100;
- bit k1;
- void delayms(uint v)
- { while(v!=0)v--;}
- void time_nms(unsigned int x)//0.5ms
- {
- unsigned char j;
- while(x--)
- {for(j=0;j<50;j++)
- {;}
- }
- }
- void delay(uint nn)
- {
- uint mm;
- while(nn-->0)
- for(mm=0;mm<1000;mm++) { };
- }
- void busy()
- {
- CS=0;A0=0;
- do
- { P0=0xff;RDD=0;delayms(1);ACC=P0;RDD=1;}
- while(BF==1);
- }
- void wcomd(uint cdat)
- {
- busy();
- A0=1;RDD=1;P0=cdat;WRR=0;WRR=1;CS=1;
- }
- void wdata(uint ddat)
- {
- busy();
- A0=0;RDD=1;P0=ddat;WRR=0;WRR=1;CS=1;
- }
- void wcode(uint csrl,uint csrh)
- {
- uint temdat1=0,temdat2=0;
- temdat1=csrl+40*csrh;
- temdat2=temdat1/256;
- temdat1=temdat1%256;
- wcomd(0x46);
- wdata(temdat1);
- wdata(temdat2);
- wcomd(0x42);
- }
- void initial()
- {
- //uint i=0
- wcomd(0x40); //初始化设置指令( 8)
- wdata(0x30);
- wdata(0x87);
- wdata(0x07);
- wdata(39);
- wdata(66);
- wdata(240);
- wdata(40); //---P7--APL
- wdata(0);
- delayms(0x9);
- wcomd(0x44); //显示区域设置SCROLL
- wdata(0x00);//P1 SAD1L
- wdata(0x00);
- wdata(240);
- wdata(0x80);//P4 SAD2L
- wdata(0x25);
- wdata(240);
- wdata(0x00);//P7 SAD3L
- wdata(0x4b);
- wdata(0x00);//P9 SAD4L
- wdata(0x00);
- delayms(0x9);
- wcomd(0x5a); //点位移设置
- wdata(0x00);
- delayms(0x9);
- wcomd(0x5b); //显示合成方式设置OYLAY
- wdata(0x1c);
- delayms(0x9);
- wcomd(0x59); //显示开 58H显示关
- wdata(0x04);
- delayms(0x9);
- wcomd(0x4c);//4C右, 4D左, 4E上, 4F下( 28页)
- delayms(0x9);
- wcomd(0x46); //光标地址
- wdata(0);//低8位
- wdata(0);//高8位
- delayms(0x9);
- }
- void disp_bmp(xchar *str)
- {
- uint i=0;
- wcode(0,0);
- for(i=0;i<9600;i++)
- { wdata(str[i]);}
- }
- void disp_all(uchar zf1,uchar zf2)
- {
- uint i=0,j=0;
- wcode(0x00,0x00);
- for(i=0;i<120;i++)
- {
- for(j=0;j<40;j++)
- { wdata(zf1);}
- for(j=0;j<40;j++)
- { wdata(zf2);}
- } }
- //
- //
- void ds_32x32(bit fb,uint X,uint Y,uchar *dp)//X为列坐标,以字节为单位;Y为行坐标,
- {
- uint addL;
- uint addH;
- uchar j;
- for(i=0;i<32;i++)
- {
- temp=0x0000+Y*40+X+40*i;
- addL=temp&0x00ff; //取TEMP的低八位,
- addH=((temp&0xff00)>>8); //取TEMP的高八位.
- data1=addL;
- data2=addH;
- wcomd(0x46); //显示地址
- wdata(data1);
- wdata(data2);
- wcomd(0x42);
- for(j=0;j<4;j++)
- {
- if(fb==1) wdata(*dp);
- else wdata(~(*dp));
- dp++;
- }
- }
- }
- uchar code hui_32x32[]=/*-- 宋体24; 此字体下对应的点阵为: 宽x高=32x33 --*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x38,0x00,0x03,0xC0,0x3E,0x00,
- 0x03,0xC0,0x3C,0x00,0x07,0x80,0x7C,0x00,0x07,0x00,0x7E,0x00,0x07,0x00,0x77,0x00,
- 0x0E,0x38,0xE3,0x80,0x0C,0x3D,0xE3,0x80,0x1C,0x79,0xC1,0xE0,0x38,0x73,0x80,0xF0,
- 0x70,0xE7,0x00,0x7C,0x7F,0xEE,0x03,0xFE,0x31,0xDF,0xFF,0xF8,0x03,0xB8,0x00,0x60,
- 0x07,0x30,0x00,0x00,0x07,0x00,0x00,0x00,0x0E,0x00,0x00,0x30,0x1C,0x78,0x00,0x78,
- 0x3F,0xCF,0xFF,0xEC,0x3E,0x00,0x7C,0x00,0x10,0x00,0x78,0x00,0x00,0x00,0xF3,0x00,
- 0x00,0x38,0xE3,0x80,0x03,0xF1,0xC1,0xC0,0x3F,0x03,0x80,0xE0,0x7C,0x07,0x80,0xF0,
- 0x30,0x0F,0xFF,0xF0,0x00,0x07,0xC0,0x70,0x00,0x06,0x00,0x20,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,
- };
复制代码 |