//*******************************
// 取反一个 英文字符
//*******************************
void cpl_asc()
{
unsigned char i,j;
unsigned char x_x,y_y;
unsigned char temp_data,y;
unsigned char temp;
unsigned char y1,y2;
x_x=xx;
y=y_y=yy; //保存 y轴
i=8;//显示 字模 8*16
while(i--)
{
yy=y;
//------------写一个字节---------------------------
for(j=8;j>0;j--)
{
y1=yy%8; // 0-7 bie
y2=yy>>3; //0-7 行
temp=lcd_bit_buffer[y2][xx];//写一个点 不调用函数减少调用浪费的系统时间
temp^=(1<<y1);
lcd_bit_buffer[y2][xx]=temp;
//yy=(yy+64-1)%64;//修正y地址
yy=(yy+63)%64;//修正y地址
}
//-------------------------------------------------
xx=(xx+1)%128;
}
y=yy;//显示下半个字
xx=x_x; //写x_x到 xx
i=8;//显示 字模 8*16
while(i--)
{
yy=y;
//------------写一个字节---------------------------
for(j=8;j>0;j--)
{
y1=yy%8; // 0-7 bie
y2=yy>>3; //0-7 行
temp=lcd_bit_buffer[y2][xx];
temp^=(1<<y1);
lcd_bit_buffer[y2][xx]=temp;
// yy=(yy+64-1)%64;//修正y地址
yy=(yy+63)%64;//修正y地址
}
//-------------------------------------------------
xx=(xx+1)%128;
}
yy=y_y; // 恢复原y轴
}
//********************************
// 显示一个 英文字符
//********************************
void dis_char_buffer(const unsigned char *sp)
{
unsigned char i,j;
unsigned char x_x,y_y;
unsigned char temp_data,y;
unsigned char temp;
unsigned char y1,y2;
x_x=xx;
y=y_y=yy; //保存 y轴
i=8;//显示 字模 8*16
while(i--)
{
temp_data=*sp++;
yy=y;
//------------写一个字节---------------------------
for(j=8;j>0;j--)
{
y1=yy%8; // 0-7 bie
y2=yy>>3; //0-7 行
temp=lcd_bit_buffer[y2][xx];
if(temp_data&0x80)//写点
temp|=(1<<y1);
else
temp&=~(1<<y1);
lcd_bit_buffer[y2][xx]=temp;
temp_data<<=1;
yy=(yy+64-1)%64;//修正y地址
}
//-------------------------------------------------
xx=(xx+1)%128;
}
y=yy;//显示下半个字
xx=x_x; //写x_x到 xx
i=8;//显示 字模 8*16
while(i--)
{
temp_data=*sp++;
yy=y;
//------------写一个字节---------------------------
for(j=8;j>0;j--)
{
y1=yy%8; // 0-7 bie
y2=yy>>3; //0-7 行
temp=lcd_bit_buffer[y2][xx];
if(temp_data&0x80)//写点
temp|=(1<<y1);
else
temp&=~(1<<y1);
lcd_bit_buffer[y2][xx]=temp;
temp_data<<=1;
yy=(yy+64-1)%64;//修正y地址
}
//-------------------------------------------------
xx=(xx+1)%128;
}
yy=y_y; // 恢复原y轴
}
//********************************
// 显示一个 汉字
//********************************
void dis_hz_buffer(const unsigned char *sp)
{
unsigned char i,j;
unsigned char x_x,y_y;
unsigned char temp_data,y;
unsigned char temp;
unsigned char y1,y2;
x_x=xx;
y=y_y=yy; //保存 y轴
i=16;//显示 字模 8*16
while(i--)
{
temp_data=*sp++;
yy=y;
//------------写一个字节---------------------------
for(j=8;j>0;j--)
{
y1=yy%8; // 0-7 bie
y2=yy>>3; //0-7 行
temp=lcd_bit_buffer[y2][xx];
if(temp_data&0x80)
temp|=(1<<y1); //写点
else
temp&=~(1<<y1); //擦点
lcd_bit_buffer[y2][xx]=temp;
temp_data<<=1;
yy=(yy+64-1)%64;//修正y地址
}
//-------------------------------------------------
xx=(xx+1)%128;
}
y=yy;//显示下半个字
xx=x_x; //写x_x到 xx
i=16;//显示 字模 16*16
while(i--)
{
temp_data=*sp++;
yy=y;
//------------写一个字节---------------------------
for(j=8;j>0;j--)
{
y1=yy%8; // 0-7 bie
y2=yy>>3; //0-7 行
temp=lcd_bit_buffer[y2][xx];
if(temp_data&0x80)//写点
temp|=(1<<y1);
else
temp&=~(1<<y1);
lcd_bit_buffer[y2][xx]=temp;
temp_data<<=1;
yy=(yy+64-1)%64;//修正y地址
}
//-------------------------------------------------
xx=(xx+1)%128;
}
yy=y_y; // 恢复原y轴
}
//*********************************
// 显示一个汉字 字符
// 包含自动查字库
//*********************************
void dis_buffer(unsigned int data)
{
unsigned char temp,data_temp;
unsigned char temp_h,temp_l;
unsigned char a_temp;
unsigned char i;
if((data>>8)>128)
{
//汉字
i=0;
temp_h=( unsigned char)(data>>8);
temp_l=( unsigned char)(data&0x00ff);
while(1)
{
WDR();
if((Chinese_characters_tab[i][0]==0xff)&&(Chinese_characters_tab[i][1]==0xff))//查找失败 失败显示黑色方块
break;
if((Chinese_characters_tab[i][0]==temp_h)&&(Chinese_characters_tab[i][1]==temp_l))//查找成功
break;
i++;
}
dis_hz_buffer(&Chinese_characters_tab[i][2]);
}
else //英文
{
i=0;
data_temp=(unsigned char)data;
while(1) //查字库
{
WDR();
if(character_tab[i][0]==0xff)//查找失败 失败显示黑色方块
break;
if(character_tab[i][0]==data_temp)//查找成功
break;
i++;
}
dis_char_buffer(&character_tab[i][1]);
}
}
//****************************
// 显示字符串 ram中
//****************************
void dis_lcd_buffer(unsigned char *aa)
{
while(*aa)
{
if(*aa>128)
{
dis_buffer( ((*aa<<8)|*(aa+1)) );
aa+=2;
}
else
{
dis_buffer(*aa);
aa++;
}
}
}
//****************************
// 显示字符串 Rom中
//****************************
void dis_lcd_buffer_rom(const unsigned char *aa)
{
while(*aa)
{
if(*aa>128)
{
dis_buffer( ((*aa<<8)|*(aa+1)) );
aa+=2;
}
else
{
dis_buffer(*aa);
aa++;
}
}
}
//*********************************************************
-----------------------------------------------------------------------------------------------------------
//字库结构
// 汉字
typedef const struct{
const unsigned char cha[2];
const unsigned char data[32];
} character_struct;
character_struct Chinese_characters_tab[]={
{
{"温"},
{0x08,0x84,0x61,0x0E,0x00,0x7E,0x52,0x52,0x52,0x52,0x52,0x7E,0x00,0x00,0x00,0x00,
0x40,0x7F,0x80,0x02,0xFE,0x82,0x82,0xFE,0x82,0x82,0xFE,0x82,0x82,0xFE,0x02,0x00},
},
{
{"度"},
{0x00,0x00,0x3F,0x20,0x24,0x24,0x3F,0xA5,0x65,0x25,0x3F,0x24,0x24,0x24,0x20,0x00,
0x01,0x06,0xF8,0x01,0x01,0x42,0x62,0x54,0x48,0x48,0x54,0x64,0x42,0x03,0x02,0x00,},
},
//.......................
//结束标志
{
{0xff,0xff},
{ 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, }
},
};
//英文
const unsigned char character_tab[][17]={
/*-- 文字: ! --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'!',0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0x0C,0x00,0x00,0x00,
//'!',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: # --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'#',0x02,0x03,0x1E,0x02,0x03,0x1E,0x02,0x00,0x20,0xFC,0x20,0x20,0xFC,0x20,0x20,0x00,
//'#',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
/*-- 文字: % --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'%',0x0F,0x10,0x0F,0x00,0x07,0x18,0x00,0x00,0x00,0x84,0x38,0xC0,0x78,0x84,0x78,0x00,
/*-- 文字: * --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'*',0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
/*-- 文字: - --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'-',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
/*-- 文字: + --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'+',0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xF8,0x80,0x80,0x80,0x00,
/*-- 文字: = --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'=',0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
/*-- 文字: [ --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'[',0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,
/*-- 文字: ] --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
']',0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
/*-- 文字: ? --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'?',0x00,0x0E,0x12,0x10,0x10,0x10,0x0F,0x00,0x00,0x00,0x00,0x0C,0x6C,0x80,0x00,0x00,
/*-- 文字: / --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
'/',0x00,0x00,0x00,0x00,0x01,0x06,0x18,0x20,0x00,0x06,0x18,0x60,0x80,0x00,0x00,0x00,
/*-- 文字: \ --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x5c,0x00,0x30,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x1C,0x03,0x00,
/*-- 文字: 空格 --*/
/*-- New Century Schoolbook12; 此字体下对应的点阵为:宽x高=8x16 --*/
' ',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//摄氏度符号
0xfe, 0x18,0x18,0x03,0x04,0x08,0x08,0x08,0x04,0x00,0x00,0xF0,0x08,0x04,0x04,0x04,0x08,
//结束标志
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
}; |