|
发表于 2014-12-7 16:52:36
|
显示全部楼层
楼主程序存在俩个问题,使用过程序中会擦除下面的字,对于高度小于8的图片或字模也会出问题修改如下
/*********************************************
函数名 : BufferPixelStuff
功能 : 把图片、文字点阵写入全屏缓存(精确定位,右上角坐标可以为LCD上任意位置。
字符大小不限,自行修改数组点阵数据,单个字符的宽高参数不要传错了,16号
字模不要传成12,12了,12号字模不要传成16,16了)
参数 : type type = 1-->图片点阵 / type = 2-->ascii字符 / type = 3-->中文字符
index 数据在数组中的位置(当type=2时,直接传ascii字符,如:'A')
x 横坐标:0~83
y 纵坐标:0~47
width 点阵数据的宽度(位数) 如果是字符就为一个字符的宽度、如果是图片就为整个图片的宽度
height 点阵数据的高度(位数) 如果是字符就为一个字符的高度、如果是图片就为整个图片的高度
返回 : 无
编辑器 : Notepad 2
*********************************************/
void Buffer_Pixel_Stuff(unsigned char type,unsigned char *index,unsigned char x, unsigned char y, unsigned char width, unsigned char height)
{
unsigned char i, j,tmpRow;
unsigned char row;
unsigned char offset;
unsigned char level;
unsigned char bytes[2];
unsigned char byteTmp;
unsigned char gb_buf[72];
row = y / 8;
offset = y & 0x07;
level = height >> 3;
level = (height & 0x07) == 0 ? level : level + 1;
if(type == 3)
{
bytes[0] = index[0];
bytes[1] = index[1];
switch(width)
{
case 12:
SPI_Read_Flash((unsigned long)(((bytes[0]-0xa1)*94)+(bytes[1]-0xa1))*24,gb_buf,24);
break;
case 16:
SPI_Read_Flash((unsigned long)(((bytes[0]-0xa1)*94)+(bytes[1]-0xa1))*32 + (unsigned long)0x2FEB0,gb_buf,32);
break;
default:
SPI_Read_Flash((unsigned long)(((bytes[0]-0xa1)*94)+(bytes[1]-0xa1))*72 + +(unsigned long)0x6FCF0,gb_buf,72);
break;
}
}
for(j = 0; j < width;j++ )
{
tmpRow = row;
y = height;
if(x + j < 84)
{
if(offset + height < 8)
byteTmp = Mid_Clear(Display_Buf[tmpRow][x + j],8 - offset,8 - (offset + height));
else
byteTmp = UnClear(Display_Buf[tmpRow][x + j],8 - offset);
}
for(i = 0;i < level;i++ )
{
if(type == 1)
Split_Byte(index[i * width + j],offset,bytes);
else if(type == 2)
Split_Byte(font6x8[*index - 32][i * width + j],offset,bytes);
else if(type == 3)
Split_Byte(gb_buf[i * width + j],offset,bytes);
else if(type == 4)
Split_Byte(font8x16[*index][i * width + j],offset,bytes);
else
Split_Byte(0x00,offset,bytes);
if(i > 0)
{
if(y > 7)
{
if(x + j < 84)
Display_Buf[tmpRow++][x + j] = byteTmp | bytes[0];
byteTmp = bytes[1];
y -= 8;
}
else
{
byteTmp |= bytes[0];
break;
}
}
else
{
if(x + j < 84)
Display_Buf[tmpRow++][x + j] = byteTmp | bytes[0];
byteTmp = bytes[1];
if(offset + height < 8)
y = 0;
else
{
y += offset;
y -= 8;
}
}
if(tmpRow > 6)
tmpRow = 0;
}
Display_Buf[tmpRow][x + j] = byteTmp | LnClear(Display_Buf[tmpRow][x + j],y);
}
} |
|