谢谢大哥,我是用画图模式写字模取出来的 18*32的汉字,现在想从中间两行八个点后写入 字模里的汉字。不知道怎样从任意位置写起。还需要大神 多指点。
void write1632GDRAM(unsigned char x,unsigned char y,unsigned char *bmp)
{
unsigned char i,j,basex,basey;
switch(y) //由y纵坐标定是上半屏还是下半屏
{
case 1: basex=0x80; break; //上半屏
case 2: basex=0x80; break; //先上半屏,下面再下半屏。
case 3: basex=0x88; break; //下半屏
default: return; //别的则返回
}
basey=basex+x-1;
LCD_write_command(0x34); //打开扩展指令
LCD_write_command(0x36);
if(y==1||y==3) //如为第一第三行,则直接是在同一半屏,直接绘完32行点陈数据。
{
for(i=0;i<32;i++) //写入32行点阵
{
LCD_write_command(0x80+i); //先写入垂直位址,选上下32行的哪一行,不管上下半屏,首行都为0X80
LCD_write_command(basey); //再写入水平位址(选上下半屏)
for(j=0;j<2;j++) //2个8位元的数据,即16BIT宽度
LCD_write_data(*bmp++);
}
}
if(y==2) //从第二行开始则画图将上下半屏都有,所以先画完上半屏16行,再画下半屏16行。
{
for(i=0;i<16;i++) //写入上半屏16行点阵
{
LCD_write_command(0x90+i); //先写入垂直位址,选上下32行的哪一行,不管上下半屏,首行都为0X80,第二行为0X90。
LCD_write_command(basey); //(选上半屏)再写入水平位址
for(j=0;j<2;j++) //2个8位元的数据,即16BIT宽度
LCD_write_data(*bmp++);
}
for(i=0;i<16;i++) //写入下半屏16行点阵
{
LCD_write_command(0x80+i); //先写入垂直位址,选上下32行的哪一行,不管上下半屏,首行都为0X80
LCD_write_command(basey+8); //(选下半屏)再写入水平位址
for(j=0;j<2;j++) //2个8位元的数据,即16BIT宽度
LCD_write_data(*bmp++);
}
}
LCD_write_command(0x36); //写完数据,开图片显示
LCD_write_command(0x30); //基本指令
}
void clear_gcrom()
{
unsigned char i,j,k;
// LCD_write_command(0x30);
LCD_write_command(0x34);
for(i=0;i<2;i++)
{
for(j=0;j<32;j++)
{
LCD_write_command(0x80+j);
if(i==0)
{
LCD_write_command(0x80);
}
else
{
LCD_write_command(0x88);
}
for(k=0;k<16;k++)
{
LCD_write_data(0x00);
LCD_write_data(0x00);
}
}
}
LCD_write_command(0x36);
LCD_write_command(0x30);
}
这是我写中间两行16*32字体的函数,但汉字位置只能从起始位置,或隔16个点后的地址写起。 |