📄 lcd.c
字号:
}
LCDSetModifyWriteOFF1();
LCDSetModifyWriteOFF2();
if(j>3)break;
}
}
void LCDDrawText10(unsigned char x0,unsigned char y0,unsigned char size,unsigned int *dat,char mode)
{
unsigned char i;
for (i=0;i<size;i++)
{
LCDDrawChar10(x0,y0,CharTable10+(*(dat+i))*13,mode);
x0+=11;
}
}
void LCDDrawImg(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char *pic,char mode)
{
unsigned char i,j,page0,page1,width,temp,ym,dtemp,mask;
if(x0>x1)xchg(&x0,&x1);
if(y0>y1)xchg(&y0,&y1);
page0=y0>>3;
page1=y1>>3;
width=x1-x0+1;
ym=y0%8;
for(j=page0;j<=page1;j++)
{
if(j>3)break;
LCDSetPage1(j);
LCDSetPage2(j);
if(x0<MAXCOL&&x1<MAXCOL)
LCDWriteCom1(x0);
else if(x0<MAXCOL)
{
LCDWriteCom1(x0);
LCDWriteCom2(0);
}
else if(x0>=MAXCOL)
LCDWriteCom2(x0-MAXCOL);
LCDSetModifyWriteON1();
LCDSetModifyWriteON2();
for(i=x0;i<=x1;i++)
{
if(i>MAXCOL*2)break;
if(i<MAXCOL)dtemp=LCDReadDat1();
else dtemp=LCDReadDat2();
if(j==page0)
{
temp=(*(pic+(i-x0)))<<ym;
mask=0xff<<ym;
}
else if(j!=page0)
{
temp=((*(pic+(j-page0-1)*width+(i-x0)))>>(8-ym))
|((*(pic+(j-page0)*width+(i-x0)))<<ym);
mask=0xff;
}
if(j==page1)
{
temp=temp&(0xff>>(7-y1%8));
mask=mask&(0xff>>(7-y1%8));
}
if(mode==DrawType_Normal)temp=(dtemp&(~mask))|(temp&mask);
else if(mode==DrawType_NotNormal)temp=(dtemp&(~mask))|((~temp)&mask);
else if(mode==DrawType_Mask)temp=(dtemp&(~mask))|((dtemp|temp)&mask);
else if(mode==DrawType_NotMask)temp=(dtemp&(~mask))|((dtemp|(~temp))&mask);
else if(mode==DrawType_And)temp=(dtemp&(~mask))|((dtemp&temp)&mask);
else if(mode==DrawType_Or)temp=(dtemp&(~mask))|((temp|dtemp)&mask);
//else if(mode==DrawType_Not)temp=(dtemp&(~mask))&((~temp)&mask);
// else if(mode==DrawType_MaskNot)temp=(dtemp&(~mask))|((~temp)&mask);
if(i<MAXCOL)LCDWriteDat1(temp);
else if(i<2*MAXCOL) LCDWriteDat2(temp);
else break;
}
LCDSetModifyWriteOFF1();
LCDSetModifyWriteOFF2();
if(j>3)break;
}
}
/*
//在x,y点显示一个点
void LCDDrawPoint(unsigned char x,unsigned char y,char color )
{
unsigned char dat,temp;
//设置页
temp=(y>>3);
LCDSetPage1(temp);
LCDSetPage2(temp);
if(x<MAXCOL)
{
LCDSetCol1(x); //设置行
LCDSetModifyWriteON1(); //打开改写模式
dat=LCDReadDat1(); //读数据
if(color==0)dat=dat&(!(1<<(y%8))); //计算要写数据
else dat=dat|(1<<(y%8));
LCDWriteDat1(dat); //写数据
LCDSetModifyWriteOFF1(); //关闭改写模式
}
else
{ LCDSetCol2(x-MAXCOL); //设置行
LCDSetModifyWriteON2(); //打开改写模式
dat=LCDReadDat2(); //读数据
if(color==0) dat=dat&(!(1<<(y%8)));//计算要写数据
else dat=dat|(1<<(y%8));
LCDWriteDat2(dat); //写数据
LCDSetModifyWriteOFF2(); //关闭改写模式
}
}
*/
void LCDDrawText8(char *str,unsigned char x0,unsigned char y0,char mode)
{
unsigned char i,StrSize;
StrSize=strlen(str);
for(i=0;i<StrSize;i++)
{
if(str[i]<128)
LCDDrawImg(x0+i*8,y0,x0+i*8+7,y0+7,CharTable8+8*str[i],mode);
else
LCDDrawImg(x0+i*8,y0,x0+i*8+7,y0+7,CharTable8,mode);
}
}
char code CharTable10[]=
{
0x34,0x4c,0xc7,0x34,0x0c,0x21,0x21,0xf9,0x25,0x23,0x46,0xea,0x00,//好
0x02,0x12,0x12,0x1f,0xf2,0x12,0x92,0x9f,0x92,0x72,0x00,0x03,0x00,//节
0x00,0xff,0x11,0x11,0x11,0x11,0x11,0x11,0xff,0x00,0x5c,0x55,0x03,//日
0x0c,0xff,0x04,0x28,0x22,0xa2,0x7f,0xa2,0x3e,0x20,0xac,0x01,0x09,//快
0x00,0x9e,0x52,0x32,0x12,0xfd,0x31,0x51,0x91,0x10,0x81,0x0e,0x04,//乐
0x00,0x0c,0xbe,0xbe,0x0c,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,//!
0x00,0x01,0x01,0x01,0x01,0xf9,0x09,0x05,0x03,0x01,0x80,0x0e,0x00,//了
0x7f,0x01,0xfd,0x81,0x7f,0x84,0x44,0x24,0xff,0x04,0x06,0x89,0x03,//财
0x04,0x07,0xc4,0x3c,0x17,0x74,0x94,0x55,0x36,0x04,0xa6,0x45,0x09,//发
};
char code CharTable8[128L*8L]=
{
/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 1 */ 0x00, 0x7e, 0x81, 0x95, 0xb1, 0xb1, 0x95, 0x81,
/* 2 */ 0x00, 0x7e, 0xff, 0xeb, 0xcf, 0xcf, 0xeb, 0xff,
/* 3 */ 0x00, 0x0e, 0x1f, 0x3e, 0x7c, 0x3e, 0x1f, 0x0e,
/* 4 */ 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08,
/* 5 */ 0x00, 0x1c, 0x1c, 0x4a, 0x7f, 0x7f, 0x4a, 0x1c,
/* 6 */ 0x00, 0x08, 0x1c, 0x5e, 0x7f, 0x7f, 0x5e, 0x1c,
/* 7 */ 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00,
/* 8 */ 0x00, 0xff, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xff,
/* 9 */ 0x00, 0x00, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e,
/* 10 */ 0x00, 0xff, 0x81, 0xbd, 0xbd, 0xbd, 0xbd, 0x81,
/* 11 */ 0x00, 0x70, 0xf8, 0x88, 0x88, 0xf9, 0x7f, 0x07,
/* 12 */ 0x00, 0x4e, 0x5f, 0xf1, 0xf1, 0x5f, 0x4e, 0x00,
/* 13 */ 0x00, 0xc0, 0xe0, 0xfe, 0x7f, 0x05, 0x05, 0x07,
/* 14 */ 0x00, 0xc0, 0xfe, 0x7f, 0x05, 0x05, 0x65, 0x7f,
/* 15 */ 0x00, 0xdb, 0xdb, 0x3c, 0xe7, 0xe7, 0x3c, 0xdb,
/* 16 */ 0x00, 0x7f, 0x7f, 0x3e, 0x3e, 0x1c, 0x08, 0x08,
/* 17 */ 0x00, 0x08, 0x08, 0x1c, 0x3e, 0x3e, 0x7f, 0x7f,
/* 18 */ 0x00, 0x24, 0x66, 0xff, 0xff, 0x66, 0x24, 0x00,
/* 19 */ 0x00, 0x00, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x00,
/* 20 */ 0x00, 0x0e, 0x1f, 0x11, 0x7f, 0x7f, 0x01, 0x7f,
/* 21 */ 0x00, 0x00, 0x1a, 0xbf, 0xa5, 0xa5, 0xfd, 0x58,
/* 22 */ 0x00, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70,
/* 23 */ 0x00, 0x00, 0x94, 0xb6, 0xff, 0xff, 0xb6, 0x94,
/* 24 */ 0x00, 0x04, 0x06, 0x7f, 0x7f, 0x06, 0x04, 0x00,
/* 25 */ 0x00, 0x10, 0x30, 0x7f, 0x7f, 0x30, 0x10, 0x00,
/* 26 */ 0x00, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x1c, 0x08,
/* 27 */ 0x00, 0x08, 0x1c, 0x3e, 0x08, 0x08, 0x08, 0x08,
/* 28 */ 0x00, 0x1c, 0x1c, 0x10, 0x10, 0x10, 0x10, 0x10,
/* 29 */ 0x00, 0x08, 0x1c, 0x2a, 0x08, 0x08, 0x2a, 0x1c,
/* 30 */ 0x00, 0x30, 0x38, 0x3c, 0x3e, 0x3c, 0x38, 0x30,
/* 31 */ 0x00, 0x06, 0x0e, 0x1e, 0x3e, 0x1e, 0x0e, 0x06,
/* 32 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 33 */ 0x00, 0x00, 0x00, 0x00, 0x5f, 0x5f, 0x00, 0x00,
/* 34 */ 0x00, 0x07, 0x07, 0x00, 0x00, 0x07, 0x07, 0x00,
/* 35 */ 0x00, 0x54, 0x7e, 0x3f, 0x55, 0x7e, 0x3f, 0x15,
/* 36 */ 0x00, 0x24, 0x2e, 0x6a, 0x6b, 0x2b, 0x3a, 0x12,
/* 37 */ 0x00, 0x43, 0x63, 0x30, 0x18, 0x0c, 0x66, 0x63,
/* 38 */ 0x00, 0x30, 0x7a, 0x4f, 0x5d, 0x37, 0x72, 0x50,
/* 39 */ 0x00, 0x00, 0x04, 0x07, 0x03, 0x00, 0x00, 0x00,
/* 40 */ 0x00, 0x00, 0x00, 0x1c, 0x3e, 0x63, 0x41, 0x00,
/* 41 */ 0x00, 0x00, 0x00, 0x41, 0x63, 0x3e, 0x1c, 0x00,
/* 42 */ 0x00, 0x08, 0x2a, 0x3e, 0x1c, 0x3e, 0x2a, 0x08,
/* 43 */ 0x00, 0x00, 0x08, 0x08, 0x3e, 0x3e, 0x08, 0x08,
/* 44 */ 0x00, 0x00, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x00,
/* 45 */ 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
/* 46 */ 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
/* 47 */ 0x00, 0x40, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03,
/* 48 */ 0x00, 0x3e, 0x7f, 0x41, 0x41, 0x41, 0x7f, 0x3e,
/* 49 */ 0x00, 0x00, 0x40, 0x42, 0x7f, 0x7f, 0x40, 0x40,
/* 50 */ 0x00, 0x62, 0x73, 0x51, 0x59, 0x49, 0x6f, 0x66,
/* 51 */ 0x00, 0x22, 0x63, 0x41, 0x49, 0x49, 0x7f, 0x36,
/* 52 */ 0x00, 0x18, 0x1c, 0x16, 0x13, 0x7f, 0x7f, 0x10,
/* 53 */ 0x00, 0x27, 0x67, 0x45, 0x45, 0x45, 0x7d, 0x39,
/* 54 */ 0x00, 0x3c, 0x7e, 0x4b, 0x49, 0x49, 0x79, 0x30,
/* 55 */ 0x00, 0x03, 0x03, 0x71, 0x79, 0x0d, 0x07, 0x03,
/* 56 */ 0x00, 0x36, 0x7f, 0x49, 0x49, 0x49, 0x7f, 0x36,
/* 57 */ 0x00, 0x06, 0x4f, 0x49, 0x49, 0x69, 0x3f, 0x1e,
/* 58 */ 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
/* 59 */ 0x00, 0x00, 0x00, 0x80, 0xe6, 0x66, 0x00, 0x00,
/* 60 */ 0x00, 0x00, 0x08, 0x1c, 0x36, 0x63, 0x41, 0x00,
/* 61 */ 0x00, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
/* 62 */ 0x00, 0x00, 0x00, 0x41, 0x63, 0x36, 0x1c, 0x08,
/* 63 */ 0x00, 0x00, 0x02, 0x03, 0x51, 0x59, 0x0f, 0x06,
/* 64 */ 0x00, 0x3e, 0x7f, 0x41, 0x5d, 0x5d, 0x5f, 0x1e,
/* 65 */ 0x00, 0x7c, 0x7e, 0x13, 0x11, 0x13, 0x7e, 0x7c,
/* 66 */ 0x00, 0x7f, 0x7f, 0x49, 0x49, 0x49, 0x7f, 0x36,
/* 67 */ 0x00, 0x3e, 0x7f, 0x41, 0x41, 0x41, 0x67, 0x26,
/* 68 */ 0x00, 0x7f, 0x7f, 0x41, 0x41, 0x63, 0x3e, 0x1c,
/* 69 */ 0x00, 0x7f, 0x7f, 0x49, 0x49, 0x49, 0x49, 0x41,
/* 70 */ 0x00, 0x7f, 0x7f, 0x09, 0x09, 0x09, 0x09, 0x01,
/* 71 */ 0x00, 0x3e, 0x7f, 0x41, 0x41, 0x49, 0x7b, 0x7a,
/* 72 */ 0x00, 0x7f, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x7f,
/* 73 */ 0x00, 0x00, 0x41, 0x7f, 0x7f, 0x41, 0x00, 0x00,
/* 74 */ 0x00, 0x30, 0x70, 0x40, 0x41, 0x41, 0x7f, 0x3f,
/* 75 */ 0x00, 0x7f, 0x7f, 0x08, 0x1c, 0x36, 0x63, 0x41,
/* 76 */ 0x00, 0x7f, 0x7f, 0x40, 0x40, 0x40, 0x40, 0x40,
/* 77 */ 0x00, 0x7f, 0x7f, 0x06, 0x0c, 0x06, 0x7f, 0x7f,
/* 78 */ 0x00, 0x7f, 0x7f, 0x06, 0x0c, 0x18, 0x7f, 0x7f,
/* 79 */ 0x00, 0x3e, 0x7f, 0x41, 0x41, 0x41, 0x7f, 0x3e,
/* 80 */ 0x00, 0x7f, 0x7f, 0x09, 0x09, 0x09, 0x0f, 0x06,
/* 81 */ 0x00, 0x3e, 0x7f, 0x41, 0x41, 0x41, 0xff, 0xbe,
/* 82 */ 0x00, 0x7f, 0x7f, 0x09, 0x09, 0x09, 0x7f, 0x76,
/* 83 */ 0x00, 0x22, 0x67, 0x4d, 0x59, 0x73, 0x22, 0x00,
/* 84 */ 0x00, 0x01, 0x01, 0x7f, 0x7f, 0x01, 0x01, 0x00,
/* 85 */ 0x00, 0x3f, 0x7f, 0x40, 0x40, 0x40, 0x7f, 0x3f,
/* 86 */ 0x00, 0x1f, 0x3f, 0x60, 0x40, 0x60, 0x3f, 0x1f,
/* 87 */ 0x00, 0x7f, 0x7f, 0x30, 0x18, 0x30, 0x7f, 0x7f,
/* 88 */ 0x00, 0x63, 0x77, 0x1c, 0x08, 0x1c, 0x77, 0x63,
/* 89 */ 0x00, 0x03, 0x07, 0x0c, 0x78, 0x78, 0x0c, 0x07,
/* 90 */ 0x00, 0x61, 0x71, 0x59, 0x4d, 0x47, 0x43, 0x41,
/* 91 */ 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x41, 0x41, 0x00,
/* 92 */ 0x00, 0x01, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60,
/* 93 */ 0x00, 0x00, 0x00, 0x41, 0x41, 0x7f, 0x7f, 0x00,
/* 94 */ 0x00, 0x08, 0x0c, 0x06, 0x02, 0x06, 0x0c, 0x08,
/* 95 */ 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
/* 96 */ 0x00, 0x00, 0x00, 0x03, 0x07, 0x04, 0x00, 0x00,
/* 97 */ 0x00, 0x20, 0x74, 0x54, 0x54, 0x54, 0x7c, 0x78,
/* 98 */ 0x00, 0x7f, 0x7f, 0x24, 0x44, 0x44, 0x7c, 0x38,
/* 99 */ 0x00, 0x38, 0x7c, 0x44, 0x44, 0x44, 0x4c, 0x48,
/* 100 */ 0x00, 0x38, 0x7c, 0x44, 0x44, 0x24, 0x7f, 0x7f,
/* 101 */ 0x00, 0x38, 0x7c, 0x54, 0x54, 0x54, 0x5c, 0x58,
/* 102 */ 0x00, 0x00, 0x04, 0x7e, 0x7f, 0x05, 0x05, 0x01,
/* 103 */ 0x00, 0x18, 0xbc, 0xa4, 0xa4, 0x94, 0xfc, 0x7c,
/* 104 */ 0x00, 0x7f, 0x7f, 0x04, 0x04, 0x04, 0x7c, 0x78,
/* 105 */ 0x00, 0x00, 0x00, 0x44, 0x7d, 0x7d, 0x40, 0x00,
/* 106 */ 0x00, 0x80, 0x80, 0x84, 0xfd, 0x7d, 0x00, 0x00,
/* 107 */ 0x00, 0x7f, 0x7f, 0x10, 0x38, 0x6c, 0x44, 0x00,
/* 108 */ 0x00, 0x00, 0x00, 0x41, 0x7f, 0x7f, 0x40, 0x00,
/* 109 */ 0x00, 0x7c, 0x7c, 0x08, 0x18, 0x0c, 0x7c, 0x78,
/* 110 */ 0x00, 0x7c, 0x7c, 0x04, 0x04, 0x04, 0x7c, 0x78,
/* 111 */ 0x00, 0x38, 0x7c, 0x44, 0x44, 0x44, 0x7c, 0x38,
/* 112 */ 0x00, 0xfc, 0xfc, 0x24, 0x44, 0x44, 0x7c, 0x38,
/* 113 */ 0x00, 0x38, 0x7c, 0x44, 0x44, 0x24, 0xfc, 0xfc,
/* 114 */ 0x00, 0x00, 0x7c, 0x7c, 0x08, 0x04, 0x04, 0x04,
/* 115 */ 0x00, 0x48, 0x5c, 0x54, 0x54, 0x54, 0x74, 0x20,
/* 116 */ 0x00, 0x00, 0x04, 0x3f, 0x7f, 0x44, 0x44, 0x00,
/* 117 */ 0x00, 0x3c, 0x7c, 0x40, 0x40, 0x40, 0x7c, 0x7c,
/* 118 */ 0x00, 0x1c, 0x3c, 0x60, 0x40, 0x60, 0x3c, 0x1c,
/* 119 */ 0x00, 0x3c, 0x7c, 0x60, 0x30, 0x60, 0x7c, 0x3c,
/* 120 */ 0x00, 0x44, 0x6c, 0x38, 0x10, 0x38, 0x6c, 0x44,
/* 121 */ 0x00, 0x1c, 0xbc, 0xa0, 0xa0, 0x90, 0xfc, 0x7c,
/* 122 */ 0x00, 0x44, 0x64, 0x74, 0x5c, 0x4c, 0x44, 0x00,
/* 123 */ 0x00, 0x00, 0x08, 0x08, 0x3e, 0x77, 0x41, 0x41,
/* 124 */ 0x00, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0x00,
/* 125 */ 0x00, 0x00, 0x41, 0x41, 0x77, 0x3e, 0x08, 0x08,
/* 126 */ 0x00, 0x04, 0x06, 0x02, 0x06, 0x04, 0x06, 0x02,
/* 127 */ 0x00, 0x78, 0x7c, 0x46, 0x43, 0x46, 0x7c, 0x78
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -