本帖最后由 peng1554 于 2019-6-12 19:50 编辑
程序基于各开发板的OLED显示实验例程修改而来,利用PCtoLCD2002生成“开” “发” “板”三个点阵库并存放在片内FLASH,该软件的取模方式与OLED实验例程ASCII字符集的取模方式一致[mw_shl_code=c,true]const u8 OLED_HZK_TBL[3][72]=
{
{0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x02,0x08,0x10,0x04,0x08,0x10,0x08,0x08,0x10,0x18,0x08,0x10,0x30,0x08,0x11,0xC0,
0x0F,0xFF,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x08,0x10,0x00,0x0F,0xFF,0xFE,
0x08,0x10,0x02,0x08,0x10,0x00,0x10,0x10,0x00,0x30,0x10,0x00,0x10,0x30,0x00,0x00,0x30,0x00,0x00,0x10,0x00,0x00,0x00,0x00},/*"开",0*/
{0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x04,0x03,0x80,0x08,0x0F,0x00,0x10,0x19,0x00,0x60,0x11,0x01,0xC2,0x01,0x07,0x02,
0x01,0x7C,0x02,0x1F,0xE8,0x04,0x39,0x0C,0x08,0x01,0x0A,0x08,0x01,0x09,0x90,0x01,0x08,0x70,0x01,0x08,0x60,0x21,0x09,0x90,
0x11,0x0B,0x18,0x1D,0x1E,0x08,0x0D,0x18,0x0C,0x01,0x00,0x04,0x03,0x00,0x06,0x01,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x00},/*"发",1*/
{0x00,0x00,0x00,0x01,0x00,0x40,0x01,0x01,0x80,0x01,0x0E,0x00,0x01,0x78,0x00,0x3F,0xFF,0xFE,0x21,0x20,0x00,0x01,0x10,0x02,
0x03,0x0C,0x05,0x01,0x00,0x1A,0x00,0x07,0xE4,0x0F,0xFE,0x04,0x08,0x40,0x08,0x08,0x78,0x10,0x08,0x47,0x30,0x08,0x41,0xE0,
0x10,0x41,0xE0,0x10,0x47,0x30,0x30,0x7C,0x18,0x30,0xE0,0x0C,0x10,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x00},/*"板",2*/
}; [/mw_shl_code]
整个程序最重要的是OLED_Show_Font()
[mw_shl_code=c,true]//在指定位置,显示一个24*24大小的汉字
//x,y :汉字的坐标
//index:汉字编号(在字库数组里面的编号)
void OLED_Show_Font(u16 x,u16 y,u8 index)
{
u8 temp,t,t1;
u16 y0=y;
u8 *dzk;
u8 csize=72; //一个24*24的汉字72字节
dzk=(u8*)OLED_HZK_TBL[index]; //得到汉字编号对应的点阵库
for(t=0;t<csize;t++)
{
temp=dzk[t]; //得到点阵数据
for(t1=0;t1<8;t1++) //按照从高位到低位的顺序画点
{
if(temp&0x80)OLED_DrawPoint(x,y,1);
else OLED_DrawPoint(x,y,0);
temp<<=1;
y++;
if((y-y0)==24) //对y坐标的处理,当y坐标距起始坐标差24个像素点,x坐标加1
{
y=y0;
x++;
break;
}
}
}
}[/mw_shl_code]
然后main.c函数中调用 OLED_Show_Font()
[mw_shl_code=c,true] OLED_ShowString(16,0,"ALIENTEK",24); //24*24字体
OLED_ShowString(28,24,"MiniSTM32",16); //16*16字体
OLED_Show_Font(28,40,0); //开
OLED_Show_Font(28+24,40,1); //发
OLED_Show_Font(28+48,40,2); //板
OLED_Refresh_Gram();//更新显示到OLED [/mw_shl_code]
OLED显示效果如图
|