本帖最后由 nan_banqiu 于 2011-3-11 16:47 编辑
已解决 感觉写的挺麻烦只是实现了功能 不知哪位高手有好办法
/******************************************************************
***参数:发白起始横坐标(0 - 15),起始纵坐标(0 - 3),反白字符长度(1 - 16)
***返回值:无
***功能:实现反白显示
******************************************************************/
void Set_Reverse(unsigned char x, y, width)
{
char i,j,flag= 0;
unsigned char real_x,real_width;
Clear_Gdram();
if(y>1)
{
flag=0x08;
y=y-2;
}
Write_Led_Data(0,0x34); //关显示,打开基本指令
if(x % 2 == 0 && width % 2 == 0) //开始地址为偶数,字符长度为偶数
{
real_x = x / 2;
real_width = width / 2;
for(i=0;i<16;i++)
{
Write_Led_Data(0,0x80+(y<<4)+i);
Write_Led_Data(0,0x80+flag+real_x); //写地址
for(j=0;j<real_width;j++)
{
Write_Led_Data(1,0xff);
Write_Led_Data(1,0xff); //写数据
}
}
}
if(x % 2 == 0 && width %2 != 0) //开始地址为偶数,地址长度为奇数
{
real_x = x / 2;
real_width = width / 2;
for(i=0;i<16;i++)
{
Write_Led_Data(0,0x80+(y<<4)+i);
Write_Led_Data(0,0x80+flag+real_x); // 写地址
for(j=0;j<real_width;j++)
{
Write_Led_Data(1,0xff);
Write_Led_Data(1,0xff); //写数据
}
Write_Led_Data(1,0xff);
Write_Led_Data(1,0x00); //写数据
}
}
if(x % 2 != 0 && width % 2 == 0) //开始地址为奇数,字符长度为偶数
{
real_x = x / 2;
real_width = width / 2 - 1;
for(i=0;i<16;i++)
{
Write_Led_Data(0,0x80+(y<<4)+i);
Write_Led_Data(0,0x80+flag+real_x); //写地址
Write_Led_Data(1,0x00);
Write_Led_Data(1,0xff);
for(j=0;j<real_width;j++)
{
Write_Led_Data(1,0xff);
Write_Led_Data(1,0xff); //写数据
}
Write_Led_Data(1,0xff);
Write_Led_Data(1,0x00); //写数据
}
}
if(x % 2 != 0 && width % 2 != 0) //开始地址为奇数,字符长度为奇数
{
real_x = x / 2;
real_width = width / 2;
for(i=0;i<16;i++)
{
Write_Led_Data(0,0x80+(y<<4)+i);
Write_Led_Data(0,0x80+flag+real_x); //写地址
Write_Led_Data(1,0x00);
Write_Led_Data(1,0xff); //写数据
for(j=0;j<real_width;j++)
{
Write_Led_Data(1,0xff);
Write_Led_Data(1,0xff); //写数据
}
}
}
Write_Led_Data(0,0x36); //写完数据,开图形显示
Write_Led_Data(0,0x30); //从扩展指令到基本指令
} |