struct typFNT_GB16 // 汉字字模数据结构
{
char Index[3]; // 汉字内码索引
char Msk[32]; // 点阵码数据
};
const struct typFNT_GB16 code_GB_16[] = // 数据表
{
"检", 0x08,0x20,0x08,0xC0,0x0B,0x00,0xFF,0xFF,0x09,0x00,0x0A,0x82,0x04,0x22,0x0A,0x1A,
0x32,0x82,0xC2,0x72,0x32,0x06,0x0A,0x1A,0x04,0xE2,0x02,0x02,0x02,0x02,0x00,0x00,
"测", 0x08,0x20,0x06,0x20,0x40,0x7E,0x31,0x80,0x00,0x01,0x7F,0xE2,0x40,0x0C,0x4F,0xF0,
0x40,0x08,0x7F,0xE4,0x00,0x00,0x1F,0xE2,0x00,0x01,0xFF,0xFE,0x00,0x00,0x00,0x00,
"到", 0x42,0x02,0x46,0x23,0x4A,0x22,0x52,0x22,0x63,0xFE,0x42,0x24,0x4A,0x24,0x46,0x24,
0x43,0x04,0x00,0x00,0x1F,0xF0,0x00,0x02,0x00,0x01,0xFF,0xFE,0x00,0x00,0x00,0x00,
"卡", 0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0xFF,0xFF,0x22,0x00,
0x22,0x00,0x22,0x40,0x22,0x20,0x22,0x10,0x22,0x08,0x02,0x00,0x02,0x00,0x00,0x00,
"注", 0x08,0x20,0x06,0x20,0x40,0x7E,0x31,0x80,0x00,0x02,0x10,0x02,0x10,0x82,0x10,0x82,
0x90,0x82,0x5F,0xFE,0x10,0x82,0x10,0x82,0x10,0x82,0x10,0x82,0x00,0x02,0x00,0x00,
};
void OLED_ShowHz(u8 x,u8 y, char c[3],u8 size,u8 mode)
{
int k,i;
u8 t1,m;
u8 y0=y;
//u8 csize=(size/8+((size%8)?1:0))*(size);
for ( k=0;k<200;k++) //k表示汉字的个数。查找200个汉字
{
if ((code_GB_16[k].Index[0]==c[0])&&(code_GB_16[k].Index[1]==c[1]))//找到汉字u8 c[2]表示汉字的两字节
{
for(i=0;i<32;i++)
{
m=code_GB_16[k].Msk[i];//读取这个汉字的32字节点阵数据到//m[32]这个数组中,再根据这个数组中点阵信息显示汉字
for(t1=0;t1<8;t1++)
{
if(m&0x80)OLED_DrawPoint(x,y,mode);
else OLED_DrawPoint(x,y,!mode);
m<<=1;
y++;
if((y-y0)==size)
{
y=y0;
x++;
break;
}
}
}
}
}
这是我自己写的oled汉字显示函数,但是程序不报错但是无法显示。求大神指点
int main(void)
{
//u8 t=0;
Stm32_Clock_Init(336,8,2,7);//设置时钟,168Mhz
delay_init(168); //延时初始化
uart_init(84,115200); //初始化串口波特率为115200
LED_Init(); //初始化LED
OLED_Init(); //初始化OLED
OLED_ShowHz(0,0,"检",16,1);
OLED_Refresh_Gram();//更新显示到OLED
}
这是我写的主函数,调用了refresh函数的
一周热门 更多>