1.main.c
#include "oled.h"
#include "sys.h"
int main(void)
{
OLED_Init(); //初始化OLED
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
OLED_ShowChinese(0,0,0,12,1); //温
OLED_ShowChinese(40,0,1,12,1); //度
OLED_Refresh_Gram(); //更新显示到OLED
}
2.oled.c
void OLED_ShowChinese(u8 x,u8 y, u8 num,u8 size,u8 mode)
{
u8 temp,t,t1;
u8 y0=y;
u8 csize=(size/8+((size%8)?1:0))*size; //得到字体一个字符对应点阵集所占的字节数
for(t=0;t<csize;t++)
{
if(size==12)temp=mine12[num][t]; //调用1206字体
else return; //没有的字库
for(t1=0;t1<8;t1++)
{
if(temp&0x80)OLED_DrawPoint(x,y,mode);
else OLED_DrawPoint(x,y,!mode);
temp<<=1;
y++;
if((y-y0)==size)
{
y=y0;
x++;
break;
}
}
}
}
3.oled.h
const unsigned char mine12[11][24]={
{0x44,0x20,0x22,0x40,0x00,0x90,0x03,0xF0,0xFA,0x10,0xAB,0xF0,0xAA,0x10,0xAB,0xF0,0xFA,0x10,0x03,0xF0,0x00,0x10,0x00,0x00},/*"温",0*/
{0x00,0x10,0x7F,0xE0,0x50,0x00,0x51,0x10,0x7D,0x90,0x55,0x50,0xD5,0x20,0x55,0x20,0x7D,0x50,0x51,0x90,0x50,0x10,0x00,0x00},/*"度",1*/