打印
[应用相关]

使用STM32的HAL库硬件IIC驱动0.96寸OLED,提高FPS至40以上

[复制链接]
1073|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
tpgf|  楼主 | 2024-6-28 14:16 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
一、环境
1、STM32CubeMX 6.11.1
2、keil 5.38a
3、IIC接口的OLED,主控芯片是SSD1315

二、配置
1、硬件IIC,选择频率400K



2、了解一下SSD1306(SSD1315)的寻址方式。一共有3种:页寻址模式、水平寻址模式,垂直寻址模式。



2.1页寻址模式如下:

从图片可以看出,如果需要刷新整个屏幕,他寻址完一页后,需要重新设置地址。

2.2水平寻址模式如下:



从图片可以看出,如果需要刷新整个屏幕,只要设置开始地址,寻址完成一页以后,他会自动移动到下一页。

2.3垂直寻址模式:



与水平寻址类似,只是扫描方向不一样。

三、方案确定及实施
从上面三种寻址方式,我们可以选择水平寻址方式,只要设定一次起始地址后,就只管往屏幕里面发送数据就行。
3.1 设置一个CGRAM的映像缓存

uint8_t g_ucaOledRam[8][128];/*显存*/
1
3.2 设置起点

/*
**********************************************************
* 说明:设置CGRAM起点为0,0
* 输入:
* 输出:
**********************************************************
*/
void OLED_SetStart(void)
{
    //寻址方式
    OLED_WriteByte(0X20,OLED_CMD);                // 设置GDDRAM模式
    OLED_WriteByte(0X00,OLED_CMD);                // 水平寻址模式

    OLED_WriteByte(0X21,OLED_CMD);        // 设置列起始和结束地址
    OLED_WriteByte(0X00,OLED_CMD);        // 列起始地址 0
    OLED_WriteByte(0X7F,OLED_CMD);        // 列终止地址 127

    OLED_WriteByte(0X22,OLED_CMD);        // 设置页起始和结束地址
    OLED_WriteByte(0X00,OLED_CMD);        // 页起始地址 0
    OLED_WriteByte(0X07,OLED_CMD);        // 页终止地址 7
}


3.3 发送数据到OLED

HAL_I2C_Mem_Write( &OLED_COM_PORT,OLED_ADDR,0x40,I2C_MEMADD_SIZE_8BIT,  &g_ucaOledRam[0][0], 1024,200);  //


3个关键的操作,打完收工。
/***********************************************************************************/

四、源文件
4.1 头文件

#ifndef __OLED_H
#define __OLED_H

#include "main.h"

#define SSD1315
//#define SSD1306

#define OLED_COM_PORT        hi2c1
#define OLED_ADDR                0X78

#define OLED_CMD  0        //写命令
#define OLED_DATA 1        //写数据


void OLED_Init(void);
void OLED_ColorTurn(uint8_t i);
void OLED_DisplayTurn(uint8_t i);
void OLED_DisPlay_On(void);
void OLED_DisPlay_Off(void);

void OLED_SetStart(void);

void OLED_ClearPoint(uint8_t x,uint8_t y);
void OLED_DrawPoint(uint8_t x,uint8_t y);
void OLED_Fill(uint8_t ucData);
void OLED_DrawLine(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2);
void OLED_DrawCircle(uint8_t x,uint8_t y,uint8_t r);
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t size1);
void OLED_ShowString(uint8_t x,uint8_t y,char *chr,uint8_t size1);
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size1);
void OLED_ShowPicture(uint8_t x0,uint8_t y0,uint8_t x1,uint8_t y1,uint8_t *ucP);
void OLED_ShowBigNum(uint8_t x,uint8_t y,uint8_t num);//32*16大数字
void OLED_DrawRec(uint8_t xs,uint8_t ys,uint8_t xe,uint8_t ye);/*绘制矩形*/
void OLED_DrawProgress(uint8_t _ucX0,uint8_t _ucY0,uint8_t _ucX1,uint8_t _ucY1,uint8_t _ucPercet);/*进度条绘制*/
void OLED_ShowChinesStr(uint8_t _ucX0,uint8_t _ucY0,char *pstr);/*显示中文字符串*/

void OLED_Refresh(void);
#endif
//



4.2 C文件

#include "oled.h"
#include "stdlib.h"
#include "oledfont.h"
#include "i2c.h"
//#include "spiFlash.h"

uint8_t g_ucaOledRam[8][128];/*显存*/

void OLED_WriteByte(uint8_t dat,uint8_t cmd);

/*
**********************************************************
* 说明:设置正反显
* 输入:
* 输出:
**********************************************************
*/
void OLED_ColorTurn(uint8_t i)
{
    if(i==0)
    {
        OLED_WriteByte(0xA6,OLED_CMD);//正常显示
    }
    if(i==1)
    {
        OLED_WriteByte(0xA7,OLED_CMD);//反色显示
    }
}

/*
**********************************************************
* 说明:旋转屏幕180
* 输入:
* 输出:
**********************************************************
*/
void OLED_DisplayTurn(uint8_t i)
{
    if(i==0)
    {
        OLED_WriteByte(0xC8,OLED_CMD);//正常显示
        OLED_WriteByte(0xA1,OLED_CMD);
    }
    if(i==1)
    {
        OLED_WriteByte(0xC0,OLED_CMD);//反转显示
        OLED_WriteByte(0xA0,OLED_CMD);
    }
}

/*
**********************************************************
* 说明:OLED写入一个字节
* 输入:
* 输出:
**********************************************************
*/
void OLED_WriteByte(uint8_t dat,uint8_t cmd)
{
    if(cmd == OLED_CMD)
    {
        HAL_I2C_Mem_Write( &OLED_COM_PORT,OLED_ADDR,0x00,I2C_MEMADD_SIZE_8BIT,  &dat, 1,100);  //
    }
    else
    {
        HAL_I2C_Mem_Write( &OLED_COM_PORT,OLED_ADDR,0x40,I2C_MEMADD_SIZE_8BIT,  &dat, 1,100);  //
    }

}


/*
**********************************************************
* 说明:OLED开启显示
* 输入:
* 输出:
**********************************************************
*/
void OLED_DisPlay_On(void)
{
    OLED_WriteByte(0x8D,OLED_CMD);//电荷泵使能
    OLED_WriteByte(0x14,OLED_CMD);//开启电荷泵
    OLED_WriteByte(0xAF,OLED_CMD);//点亮屏幕
}

/*
**********************************************************
* 说明:OLED关闭显示
* 输入:
* 输出:
**********************************************************
*/
void OLED_DisPlay_Off(void)
{
    OLED_WriteByte(0x8D,OLED_CMD);//电荷泵使能
    OLED_WriteByte(0x10,OLED_CMD);//关闭电荷泵
    OLED_WriteByte(0xAE,OLED_CMD);//关闭屏幕
}

/*
**********************************************************
* 说明:刷新一帧数据
* 输入:
* 输出:
**********************************************************
*/
void OLED_Refresh(void)
{
    HAL_I2C_Mem_Write( &OLED_COM_PORT,OLED_ADDR,0x40,I2C_MEMADD_SIZE_8BIT,  &g_ucaOledRam[0][0], 1024,200);  //
}

/*
**********************************************************
* 说明:填充屏幕
* 输入:
* 输出:
**********************************************************
*/
void OLED_Fill(uint8_t ucData)
{
    uint8_t *puc;
    uint16_t i;
    puc = &g_ucaOledRam[0][0];

    for(i=0; i<1024; i++)
    {
        *puc++ = ucData;
    }
}
/*
**********************************************************
* 说明:设置CGRAM起点为0,0
* 输入:
* 输出:
**********************************************************
*/
void OLED_SetStart(void)
{
    //寻址方式
    OLED_WriteByte(0X20,OLED_CMD);                // 设置GDDRAM模式
    OLED_WriteByte(0X00,OLED_CMD);                // 水平寻址模式

    OLED_WriteByte(0X21,OLED_CMD);        // 设置列起始和结束地址
    OLED_WriteByte(0X00,OLED_CMD);        // 列起始地址 0
    OLED_WriteByte(0X7F,OLED_CMD);        // 列终止地址 127

    OLED_WriteByte(0X22,OLED_CMD);        // 设置页起始和结束地址
    OLED_WriteByte(0X00,OLED_CMD);        // 页起始地址 0
    OLED_WriteByte(0X07,OLED_CMD);        // 页终止地址 7
}
/*
**********************************************************
* 说明:清除一个区域
* 输入:
* 输出:
**********************************************************
*/
void OLED_ClearArea(uint8_t xs,uint8_t ys,uint8_t xe,uint8_t ye)
{
    uint8_t i,n, w,h;
    h = ye - ys;
    w = xe - xs;
    for(i = 0; i<h; i++)
    {
        for(n=0; n<w; n++)
        {
            OLED_ClearPoint(xs+n,ys+i);
        }
    }
}
/*
**********************************************************
* 说明:填充一个区域
* 输入:
* 输出:
**********************************************************
*/
void OLED_FillArea(uint8_t xs,uint8_t ys,uint8_t xe,uint8_t ye)
{
    uint8_t i,n, w,h;
    h = ye - ys;
    w = xe - xs;
    for(i = 0; i<h; i++)
    {
        for(n=0; n<w; n++)
        {
            OLED_DrawPoint(xs+n,ys+i);
        }
    }
}
/*
**********************************************************
* 说明:写点
* 输入:
* 输出:
**********************************************************
*/
void OLED_DrawPoint(uint8_t x,uint8_t y)
{
    uint8_t ucTmp;
    uint8_t ucY,ucZ;
    if(x>127 || y>63)
    {
        return;
    }
    else
    {
        ucY = y / 8;
        ucZ = y % 8;
        ucTmp = g_ucaOledRam[ucY][x];
        ucTmp |= (0x01 << ucZ);
        g_ucaOledRam[ucY][x] = ucTmp;
    }
}
/*
**********************************************************
* 说明:清除点
* 输入:
* 输出:
**********************************************************
*/
void OLED_ClearPoint(uint8_t x,uint8_t y)
{
    uint8_t ucTmp;
    uint8_t ucY,ucZ;
    if(x>127 || y>63)
    {
        return;
    }
    else
    {
        ucY = y / 8;
        ucZ = y % 8;
        ucTmp = g_ucaOledRam[ucY][x];
        ucTmp &= ~(0x01 << ucZ);
        g_ucaOledRam[ucY][x] = ucTmp;
    }
}

//画线
//x:0~128
//y:0~64
void OLED_DrawLine(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2)
{
    uint8_t i,k,k1,k2;
//        if((x1<0)||(x2>128)||(y1<0)||(y2>64)||(x1>x2)||(y1>y2))return;
    if(x1==x2)    //画竖线
    {
        for(i=0; i<(y2-y1); i++)
        {
            OLED_DrawPoint(x1,y1+i);
        }
    }
    else if(y1==y2)   //画横线
    {
        for(i=0; i<(x2-x1); i++)
        {
            OLED_DrawPoint(x1+i,y1);
        }
    }
    else      //画斜线
    {
        k1=y2-y1;
        k2=x2-x1;
        k=k1*10/k2;
        for(i=0; i<(x2-x1); i++)
        {
            OLED_DrawPoint(x1+i,y1+i*k/10);
        }
    }
}
//x,y:圆心坐标
//r:圆的半径
void OLED_DrawCircle(uint8_t x,uint8_t y,uint8_t r)
{
    int a, b,num;
    a = 0;
    b = r;
    while(2 * b * b >= r * r)
    {
        OLED_DrawPoint(x + a, y - b);
        OLED_DrawPoint(x - a, y - b);
        OLED_DrawPoint(x - a, y + b);
        OLED_DrawPoint(x + a, y + b);

        OLED_DrawPoint(x + b, y + a);
        OLED_DrawPoint(x + b, y - a);
        OLED_DrawPoint(x - b, y - a);
        OLED_DrawPoint(x - b, y + a);

        a++;
        num = (a * a + b * b) - r*r;//计算画的点离圆心的距离
        if(num > 0)
        {
            b--;
            a--;
        }
    }
}



//在指定位置显示一个字符,包括部分字符
//x:0~127
//y:0~63
//size:选择字体 12/16/24
//取模方式 逐列式
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t size1)
{
    uint8_t i,m,temp,size2,chr1;
    uint8_t y0=y;
    size2=(size1/8+((size1%8)?1:0))*(size1/2);  //得到字体一个字符对应点阵集所占的字节数
    chr1=chr-' ';  //计算偏移后的值
    for(i=0; i<size2; i++)
    {
        temp=asc2_1608[chr1];//调用1608字体
//                if(size1==12)
//        {temp=asc2_1206[chr1];} //调用1206字体
//                else if(size1==16)
//        {temp=asc2_1608[chr1];} //调用1608字体
//                else if(size1==24)
//        {temp=asc2_2412[chr1];} //调用2412字体
//                else return;
        for(m=0; m<8; m++)         //写入数据
        {
            if(temp&0x80)OLED_DrawPoint(x,y);
            else OLED_ClearPoint(x,y);
            temp<<=1;
            y++;
            if((y-y0)==size1)
            {
                y=y0;
                x++;
                break;
            }
        }
    }
}


//显示字符串
//x,y:起点坐标
//size1:字体大小
//*chr:字符串起始地址
void OLED_ShowString(uint8_t x,uint8_t y,char *chr,uint8_t size1)
{
    while((*chr>=' ')&&(*chr<='~'))//判断是不是非法字符!
    {
        OLED_ShowChar(x,y,*chr,size1);
        x+=size1/2;
        if(x>128-size1)  //换行
        {
            x=0;
            y+=2;
        }
        chr++;
    }
}

//m^n
static uint32_t OLED_Pow(uint8_t m,uint8_t n)
{
    uint32_t result=1;
    while(n--)
    {
        result*=m;
    }
    return result;
}

显示2个数字
x,y :起点坐标
len :数字的位数
size:字体大小
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size1)
{
    uint8_t t,temp;
    for(t=0; t<len; t++)
    {
        temp=(num/OLED_Pow(10,len-t-1))%10;
        if(temp==0)
        {
            OLED_ShowChar(x+(size1/2)*t,y,'0',size1);
        }
        else
        {
            OLED_ShowChar(x+(size1/2)*t,y,temp+'0',size1);
        }
    }
}

//
void OLED_ShowBigNum(uint8_t x,uint8_t y,uint8_t num)//32*16大数字
{
    uint8_t i,j,k,tmp;
    uint8_t x0=x;
    for(i=0; i<32; i++)
    {
        for(j=0; j<2; j++)
        {
            tmp=num_3216[num][i*2+j];
            for(k=0; k<8; k++)
            {
                if(tmp&0x80)OLED_DrawPoint(x,y);
                else OLED_ClearPoint(x,y);
                tmp<<=1;
                x++;
            }
        }
        y++;
        x=x0;
    }
}


//x0,y0:起点坐标
//x1,y1:终点坐标
//BMP[]:要写入的图片数组
void OLED_ShowPicture(uint8_t x0,uint8_t y0,uint8_t x1,uint8_t y1,uint8_t *ucP)
{
//    uint32_t j=0;
//    uint8_t x=0,y=0;
//    if(y%8==0)y=0;
//    else y+=1;
//    for(y=y0; y<y1; y++)
//    {
//        OLED_WR_BP(x0,y);
//        for(x=x0; x<x1; x++)
//        {
//            OLED_WriteByte(ucP[j],OLED_DATA);
//            j++;
//        }
//    }
}
//OLED的初始化
void OLED_Init(void)
{
    HAL_Delay(100);

#ifdef  SSD1315
       
        OLED_WriteByte(0xAE,OLED_CMD);//--turn off oled panel
        OLED_WriteByte(0x00,OLED_CMD);//---set low column address
        OLED_WriteByte(0x10,OLED_CMD);//---set high column address
        OLED_WriteByte(0x40,OLED_CMD);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
        OLED_WriteByte(0x81,OLED_CMD);//--set contrast control register
        OLED_WriteByte(0xCF,OLED_CMD);// Set SEG Output Current Brightness
        OLED_WriteByte(0xA1,OLED_CMD);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
        OLED_WriteByte(0xC8,OLED_CMD);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
        OLED_WriteByte(0xA6,OLED_CMD);//--set normal display
        OLED_WriteByte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
        OLED_WriteByte(0x3f,OLED_CMD);//--1/64 duty
        OLED_WriteByte(0xD3,OLED_CMD);//-set display offset        Shift Mapping RAM Counter (0x00~0x3F)
        OLED_WriteByte(0x00,OLED_CMD);//-not offset
        OLED_WriteByte(0xd5,OLED_CMD);//--set display clock divide ratio/oscillator frequency
        OLED_WriteByte(0x80,OLED_CMD);//--set divide ratio, Set Clock as 100 Frames/Sec
        OLED_WriteByte(0xD9,OLED_CMD);//--set pre-charge period
        OLED_WriteByte(0xF1,OLED_CMD);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
        OLED_WriteByte(0xDA,OLED_CMD);//--set com pins hardware configuration
        OLED_WriteByte(0x12,OLED_CMD);
        OLED_WriteByte(0xDB,OLED_CMD);//--set vcomh
        OLED_WriteByte(0x40,OLED_CMD);//Set VCOM Deselect Level
        OLED_WriteByte(0x20,OLED_CMD);//-Set Page Addressing Mode (0x00/0x01/0x02)
        OLED_WriteByte(0x00,OLED_CMD);//
        OLED_WriteByte(0x8D,OLED_CMD);//--set Charge Pump enable/disable
        OLED_WriteByte(0x14,OLED_CMD);//--set(0x10) disable
        OLED_WriteByte(0xA4,OLED_CMD);// Disable Entire Display On (0xa4/0xa5)
        OLED_WriteByte(0xA6,OLED_CMD);// Disable Inverse Display On (0xa6/a7)
        OLED_WriteByte(0xAF,OLED_CMD);
       
#else

    OLED_WriteByte(0xAE,OLED_CMD);//--display off
    OLED_WriteByte(0x00,OLED_CMD);//---set low column address
    OLED_WriteByte(0x10,OLED_CMD);//---set high column address
    OLED_WriteByte(0x40,OLED_CMD);//--set start line address
    OLED_WriteByte(0xB0,OLED_CMD);//--set page address
    OLED_WriteByte(0x81,OLED_CMD); // contract control
    OLED_WriteByte(0xFF,OLED_CMD);//--128
    OLED_WriteByte(0xA1,OLED_CMD);//set segment remap
    OLED_WriteByte(0xA6,OLED_CMD);//--normal / reverse
    OLED_WriteByte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
    OLED_WriteByte(0x3F,OLED_CMD);//--1/32 duty
    OLED_WriteByte(0xC8,OLED_CMD);//Com scan direction
    OLED_WriteByte(0xD3,OLED_CMD);//-set display offset
    OLED_WriteByte(0x00,OLED_CMD);//

    OLED_WriteByte(0xD5,OLED_CMD);//set osc division
    OLED_WriteByte(0x80,OLED_CMD);//

    OLED_WriteByte(0xD8,OLED_CMD);//set area color mode off
    OLED_WriteByte(0x05,OLED_CMD);//

    OLED_WriteByte(0xD9,OLED_CMD);//Set Pre-Charge Period
    OLED_WriteByte(0xF1,OLED_CMD);//

    OLED_WriteByte(0xDA,OLED_CMD);//set com pin configuartion
    OLED_WriteByte(0x12,OLED_CMD);//

    OLED_WriteByte(0xDB,OLED_CMD);//set Vcomh
    OLED_WriteByte(0x30,OLED_CMD);//

    OLED_WriteByte(0x8D,OLED_CMD);//set charge pump enable
    OLED_WriteByte(0x14,OLED_CMD);//

    OLED_WriteByte(0x20,OLED_CMD);    // Set Memory Addressing Mode (20h)
    OLED_WriteByte(0x00,OLED_CMD);    // Set 页地址模式(A[1:0]=10b) 水平地址模式(A[1:0]=00b) 垂直地址模式(A[1:0]=01b)

    OLED_WriteByte(0xAF,OLED_CMD);//--turn on oled panel

#endif



//    OLED_Fill(0);

}//
//
/*
* 功能:绘制进度条
* 说明:_ucX0,_ucY0=原点坐标;_ucWidth
*/
void OLED_DrawProgress(uint8_t _ucX0,uint8_t _ucY0,uint8_t _ucX1,uint8_t _ucY1,uint8_t _ucPercet)
{
    uint8_t xe,ye;
    OLED_ClearArea(_ucX0,_ucY0,_ucX1,_ucY1);
    xe = (_ucX1-_ucX0) * _ucPercet / 100 + _ucX0;
    ye = _ucY1;
    OLED_FillArea(_ucX0,_ucY0,xe,ye);
}
/*
* 功能:绘制矩形框
* 说明:_ucX0,_ucY0=原点坐标;_ucWidth
*/
void OLED_DrawRec(uint8_t xs,uint8_t ys,uint8_t xe,uint8_t ye)
{
    OLED_DrawLine(xs,ys,xe,ys);
    OLED_DrawLine(xs,ye,xe,ye);
    OLED_DrawLine(xs,ys,xs,ye);
    OLED_DrawLine(xe,ys,xe,ye);
}
/*
* 功能:显示中文字符串
* 说明:_ucX0,_ucY0=原点坐标;
*/
void OLED_ShowChinesStr(uint8_t _ucX0,uint8_t _ucY0,char *pstr)
{

    __IO uint8_t i,k,j,cnt = 0,index = 0,num,tmp;
    uint8_t x =_ucX0,y = _ucY0;
    __IO char buff[2];

    num = sizeof(tHZ_FONT16) / sizeof(chType_T);

    while(*pstr != '\0')
    {
        buff[0] = *pstr++;
        buff[1] = *pstr++;
        /*索引汉字所在位置*/
        while(index<num)
        {

            if(buff[0] == tHZ_FONT16[index].str[0] && buff[1] == tHZ_FONT16[index].str[1])
            {
                break;
            }
            index++;
        }
        if(index == num)
        {
            //字库中无此汉字
        }
        else
        {

            for(i=0; i<16; i++)
            {
                for(j=0; j<2; j++)
                {
                    tmp=tHZ_FONT16[index].dot[cnt++];
                    for(k=0; k<8; k++)
                    {
                        if(tmp&0x80)OLED_DrawPoint(x,y);
                        else OLED_ClearPoint(x,y);
                        tmp<<=1;
                        x++;
                    }
                }
                y++;
                x=_ucX0;
            }
            index = 0;
            _ucX0 += 16;
            y = _ucY0;
            x = _ucX0;
            cnt = 0;
        }
    }
}

/*
* 功能:显示中文字符串
* 说明:_ucX0,_ucY0=原点坐标;
*/
//void OLED_ShowChinesStr(uint8_t _ucX0,uint8_t _ucY0,char *pstr)
//{
//
//    __IO uint8_t i,k,j,index = 0,tmp;
//        uint8_t x =_ucX0,y = _ucY0;
//        __IO uint8_t ucGB2312L,ucGB2312H;
//        __IO uint32_t ulHZaddr;
//        uint8_t ucaHZDot[32];/*16*16的汉字点阵信息*/
//
//
//        while(*pstr != '\0')
//        {
//                ucGB2312H = *pstr++;
//                ucGB2312L = *pstr++;
//                /*索引汉字所在位置*/
//                ulHZaddr = 32*((ucGB2312H-0xa0-1)*94+(ucGB2312L-0xa0-1));
//                SF_ReadBuffer(ucaHZDot,ulHZaddr,32);

//                        for(i=0; i<16; i++)
//                        {
//                                for(j=0; j<2; j++)
//                                {
//                                        tmp=ucaHZDot[index];
//                                        for(k=0; k<8; k++)
//                                        {
//                                                if(tmp&0x80)OLED_DrawPoint(x,y);
//                                                else OLED_ClearPoint(x,y);
//                                                tmp<<=1;
//                                                x++;
//                                        }
//                                        index++;
//                                }
//                                y++;
//                                x=_ucX0;
//                        }
//                        index = 0;
//                        _ucX0 += 16;
//                        y = _ucY0;
//                        x = _ucX0;
//
//        }
//
//}




4.3 字库文件

#ifndef __OLEDFONT_H
#define __OLEDFONT_H
#include  "main.h"

//常用ASCII表
//16*16 ASCII字符集点阵
const unsigned char asc2_1608[95][16]={          
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00},/*""",2*/
{0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x00,0x00},/*"#",3*/
{0x00,0x00,0x0E,0x18,0x11,0x04,0x3F,0xFF,0x10,0x84,0x0C,0x78,0x00,0x00,0x00,0x00},/*"$",4*/
{0x0F,0x00,0x10,0x84,0x0F,0x38,0x00,0xC0,0x07,0x78,0x18,0x84,0x00,0x78,0x00,0x00},/*"%",5*/
{0x00,0x78,0x0F,0x84,0x10,0xC4,0x11,0x24,0x0E,0x98,0x00,0xE4,0x00,0x84,0x00,0x08},/*"&",6*/
{0x08,0x00,0x68,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x18,0x18,0x20,0x04,0x40,0x02,0x00,0x00},/*"(",8*/
{0x00,0x00,0x40,0x02,0x20,0x04,0x18,0x18,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*")",9*/
{0x02,0x40,0x02,0x40,0x01,0x80,0x0F,0xF0,0x01,0x80,0x02,0x40,0x02,0x40,0x00,0x00},/*"*",10*/
{0x00,0x80,0x00,0x80,0x00,0x80,0x0F,0xF8,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00},/*"+",11*/
{0x00,0x01,0x00,0x0D,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80},/*"-",13*/
{0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00},/*"/",15*/
{0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0",16*/
{0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"1",17*/
{0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00},/*"2",18*/
{0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00},/*"3",19*/
{0x00,0x00,0x00,0xE0,0x03,0x20,0x04,0x24,0x08,0x24,0x1F,0xFC,0x00,0x24,0x00,0x00},/*"4",20*/
{0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5",21*/
{0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00},/*"6",22*/
{0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0xFC,0x13,0x00,0x1C,0x00,0x10,0x00,0x00,0x00},/*"7",23*/
{0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"8",24*/
{0x00,0x00,0x07,0x00,0x08,0x8C,0x10,0x44,0x10,0x44,0x08,0x88,0x07,0xF0,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x00,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08,0x08,0x10,0x04,0x00,0x00},/*"<",28*/
{0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x00,0x00},/*"=",29*/
{0x00,0x00,0x10,0x04,0x08,0x08,0x04,0x10,0x02,0x20,0x01,0x40,0x00,0x80,0x00,0x00},/*">",30*/
{0x00,0x00,0x0E,0x00,0x12,0x00,0x10,0x0C,0x10,0x6C,0x10,0x80,0x0F,0x00,0x00,0x00},/*"?",31*/
{0x03,0xE0,0x0C,0x18,0x13,0xE4,0x14,0x24,0x17,0xC4,0x08,0x28,0x07,0xD0,0x00,0x00},/*"@",32*/
{0x00,0x04,0x00,0x3C,0x03,0xC4,0x1C,0x40,0x07,0x40,0x00,0xE4,0x00,0x1C,0x00,0x04},/*"A",33*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x0E,0x88,0x00,0x70,0x00,0x00},/*"B",34*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x1C,0x10,0x00,0x00},/*"C",35*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"D",36*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x17,0xC4,0x10,0x04,0x08,0x18,0x00,0x00},/*"E",37*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x17,0xC0,0x10,0x00,0x08,0x00,0x00,0x00},/*"F",38*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x44,0x1C,0x78,0x00,0x40,0x00,0x00},/*"G",39*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x00,0x80,0x00,0x80,0x10,0x84,0x1F,0xFC,0x10,0x04},/*"H",40*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x00,0x00,0x00,0x00},/*"I",41*/
{0x00,0x03,0x00,0x01,0x10,0x01,0x10,0x01,0x1F,0xFE,0x10,0x00,0x10,0x00,0x00,0x00},/*"J",42*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x03,0x80,0x14,0x64,0x18,0x1C,0x10,0x04,0x00,0x00},/*"K",43*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x0C,0x00,0x00},/*"L",44*/
{0x10,0x04,0x1F,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x1F,0xFC,0x10,0x04,0x00,0x00},/*"M",45*/
{0x10,0x04,0x1F,0xFC,0x0C,0x04,0x03,0x00,0x00,0xE0,0x10,0x18,0x1F,0xFC,0x10,0x00},/*"N",46*/
{0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"O",47*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x10,0x80,0x10,0x80,0x10,0x80,0x0F,0x00,0x00,0x00},/*"P",48*/
{0x07,0xF0,0x08,0x18,0x10,0x24,0x10,0x24,0x10,0x1C,0x08,0x0A,0x07,0xF2,0x00,0x00},/*"Q",49*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x11,0xC0,0x11,0x30,0x0E,0x0C,0x00,0x04},/*"R",50*/
{0x00,0x00,0x0E,0x1C,0x11,0x04,0x10,0x84,0x10,0x84,0x10,0x44,0x1C,0x38,0x00,0x00},/*"S",51*/
{0x18,0x00,0x10,0x00,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x00,0x18,0x00,0x00,0x00},/*"T",52*/
{0x10,0x00,0x1F,0xF8,0x10,0x04,0x00,0x04,0x00,0x04,0x10,0x04,0x1F,0xF8,0x10,0x00},/*"U",53*/
{0x10,0x00,0x1E,0x00,0x11,0xE0,0x00,0x1C,0x00,0x70,0x13,0x80,0x1C,0x00,0x10,0x00},/*"V",54*/
{0x1F,0xC0,0x10,0x3C,0x00,0xE0,0x1F,0x00,0x00,0xE0,0x10,0x3C,0x1F,0xC0,0x00,0x00},/*"W",55*/
{0x10,0x04,0x18,0x0C,0x16,0x34,0x01,0xC0,0x01,0xC0,0x16,0x34,0x18,0x0C,0x10,0x04},/*"X",56*/
{0x10,0x00,0x1C,0x00,0x13,0x04,0x00,0xFC,0x13,0x04,0x1C,0x00,0x10,0x00,0x00,0x00},/*"Y",57*/
{0x08,0x04,0x10,0x1C,0x10,0x64,0x10,0x84,0x13,0x04,0x1C,0x04,0x10,0x18,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x40,0x02,0x40,0x02,0x40,0x02,0x00,0x00},/*"[",59*/
{0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x1C,0x00,0x03,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00},/*"^",62*/
{0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01},/*"_",63*/
{0x00,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x00,0x98,0x01,0x24,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xFC,0x00,0x04},/*"a",65*/
{0x10,0x00,0x1F,0xFC,0x00,0x88,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"b",66*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x00},/*"c",67*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x11,0x08,0x1F,0xFC,0x00,0x04},/*"d",68*/
{0x00,0x00,0x00,0xF8,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xC8,0x00,0x00},/*"e",69*/
{0x00,0x00,0x01,0x04,0x01,0x04,0x0F,0xFC,0x11,0x04,0x11,0x04,0x11,0x00,0x18,0x00},/*"f",70*/
{0x00,0x00,0x00,0xD6,0x01,0x29,0x01,0x29,0x01,0x29,0x01,0xC9,0x01,0x06,0x00,0x00},/*"g",71*/
{0x10,0x04,0x1F,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"h",72*/
{0x00,0x00,0x01,0x04,0x19,0x04,0x19,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x00,0x00,0x03,0x00,0x01,0x01,0x01,0x19,0x01,0x19,0xFE,0x00,0x00,0x00,0x00},/*"j",74*/
{0x10,0x04,0x1F,0xFC,0x00,0x24,0x00,0x40,0x01,0xB4,0x01,0x0C,0x01,0x04,0x00,0x00},/*"k",75*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"l",76*/
{0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0x00,0x01,0xFC,0x01,0x04,0x01,0x00,0x00,0xFC},/*"m",77*/
{0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"n",78*/
{0x00,0x00,0x00,0xF8,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0xF8,0x00,0x00},/*"o",79*/
{0x01,0x01,0x01,0xFF,0x00,0x85,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"p",80*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x05,0x01,0xFF,0x00,0x01},/*"q",81*/
{0x01,0x04,0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x04,0x01,0x00,0x01,0x80,0x00,0x00},/*"r",82*/
{0x00,0x00,0x00,0xCC,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x98,0x00,0x00},/*"s",83*/
{0x00,0x00,0x01,0x00,0x01,0x00,0x07,0xF8,0x01,0x04,0x01,0x04,0x00,0x00,0x00,0x00},/*"t",84*/
{0x01,0x00,0x01,0xF8,0x00,0x04,0x00,0x04,0x00,0x04,0x01,0x08,0x01,0xFC,0x00,0x04},/*"u",85*/
{0x01,0x00,0x01,0x80,0x01,0x70,0x00,0x0C,0x00,0x10,0x01,0x60,0x01,0x80,0x01,0x00},/*"v",86*/
{0x01,0xF0,0x01,0x0C,0x00,0x30,0x01,0xC0,0x00,0x30,0x01,0x0C,0x01,0xF0,0x01,0x00},/*"w",87*/
{0x00,0x00,0x01,0x04,0x01,0x8C,0x00,0x74,0x01,0x70,0x01,0x8C,0x01,0x04,0x00,0x00},/*"x",88*/
{0x01,0x01,0x01,0x81,0x01,0x71,0x00,0x0E,0x00,0x18,0x01,0x60,0x01,0x80,0x01,0x00},/*"y",89*/
{0x00,0x00,0x01,0x84,0x01,0x0C,0x01,0x34,0x01,0x44,0x01,0x84,0x01,0x0C,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x3E,0xFC,0x40,0x02,0x40,0x02},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x3E,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x00,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x20,0x00},/*"~",94*/
};
//32*32 数字点阵
const unsigned char num_3216[11][64]={          
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x0E,0x70,0x1E,0x70,
0x1C,0x78,0x3C,0x38,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x7C,0x3C,
0x7C,0x3C,0x7C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
0x1C,0x78,0x1E,0x78,0x0E,0x70,0x07,0xE0,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"0",0*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xE0,0x03,0xE0,0x1F,0xE0,
0x07,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,
0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,
0x03,0xE0,0x03,0xE0,0x07,0xF0,0x1F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",1*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x0F,0xF0,0x18,0x78,0x38,0x7C,
0x3C,0x7C,0x3E,0x7C,0x3E,0x7C,0x3E,0x7C,0x3C,0x7C,0x00,0x78,0x00,0xF8,0x00,0xF0,
0x01,0xE0,0x03,0xC0,0x03,0x00,0x06,0x00,0x04,0x02,0x08,0x06,0x18,0x04,0x10,0x1C,
0x3F,0xFC,0x3F,0xFC,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"2",2*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x18,0xF8,0x38,0x78,
0x3C,0x7C,0x3E,0x7C,0x3E,0x7C,0x1E,0x7C,0x0C,0x7C,0x00,0x78,0x00,0xF8,0x0F,0xE0,
0x0F,0xF0,0x00,0xF8,0x00,0x7C,0x00,0x7C,0x18,0x3E,0x3E,0x3E,0x3E,0x3E,0x7E,0x3E,
0x3C,0x7C,0x38,0x7C,0x18,0x78,0x0F,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"3",3*/
},
{       

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x78,0x00,0x78,
0x00,0xF8,0x00,0xF8,0x01,0xF8,0x01,0xF8,0x03,0xF8,0x02,0xF8,0x04,0xF8,0x04,0xF8,
0x08,0xF8,0x08,0xF8,0x10,0xF8,0x10,0xF8,0x20,0xF8,0x3F,0xFE,0x00,0xF8,0x00,0xF8,
0x00,0xF8,0x00,0xF8,0x01,0xF8,0x03,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"4",4*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x1F,0xF8,
0x1F,0xF8,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x17,0xE0,0x1C,0xF8,
0x10,0x78,0x00,0x7C,0x00,0x7C,0x00,0x3C,0x08,0x3E,0x3C,0x3E,0x3E,0x3C,0x3E,0x7C,
0x3C,0x7C,0x38,0x78,0x18,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"5",5*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x0F,0x38,0x0E,0x38,
0x1E,0x7C,0x1E,0x7C,0x3C,0x78,0x3C,0x30,0x3C,0x00,0x3C,0x00,0x7C,0xC0,0x7F,0xF0,
0x7C,0x78,0x7C,0x78,0x7C,0x7C,0x7C,0x7C,0x3C,0x7C,0x3C,0x7C,0x3C,0x7C,0x3C,0x7C,
0x1C,0x7C,0x1C,0x78,0x0E,0x70,0x07,0xE0,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"6",6*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFE,0x3F,0xFE,0x3F,0xFE,
0x3F,0xFC,0x38,0x08,0x30,0x18,0x20,0x30,0x20,0x30,0x00,0x70,0x00,0x60,0x00,0xE0,
0x00,0xE0,0x01,0xE0,0x01,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xE0,
0x07,0xE0,0x07,0xE0,0x03,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x1C,0x38,0x3C,0x1C,
0x38,0x1C,0x38,0x1C,0x3C,0x1C,0x7C,0x1C,0x3E,0x18,0x3F,0x38,0x1F,0xF0,0x0F,0xE0,
0x07,0xF0,0x07,0xF8,0x0D,0xFC,0x18,0xFC,0x38,0x3E,0x70,0x1E,0x70,0x1E,0x70,0x1E,
0x78,0x1E,0x38,0x1C,0x1C,0x3C,0x0F,0xF0,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"8",8*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1E,0x70,0x3E,0x70,
0x3E,0x78,0x3C,0x78,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x7C,0x3C,0x7C,0x3C,0x7C,
0x3E,0x7C,0x1E,0x7C,0x0F,0xFC,0x00,0x7C,0x00,0x7C,0x18,0x7C,0x3C,0x78,0x3E,0x78,
0x3C,0x70,0x38,0xF0,0x18,0xE0,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"9",9*/
},
{       
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x80,0x07,0xE0,0x07,0xE0,0x0F,0xF0,0x07,0xE0,0x07,0xE0,0x03,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x07,0xE0,
0x0F,0xF0,0x07,0xE0,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*":",10*/
},
};
//



/*
* 取模软件:PCtoLCD2002
* 取模字体:宋体
* 字体尺寸:16*16
* 取模方式:阴码,逐行式,顺向(高位在前)
*/
typedef struct
{
        char str[2];
        uint8_t dot[32];
}chType_T;

const chType_T tHZ_FONT16[14]=
{
{"测",
{
0x00,0x04,0x27,0xC4,0x14,0x44,0x14,0x54,0x85,0x54,0x45,0x54,0x45,0x54,0x15,0x54,
0x15,0x54,0x25,0x54,0xE5,0x54,0x21,0x04,0x22,0x84,0x22,0x44,0x24,0x14,0x08,0x08,/*"测",0*/
}
},
{"量",
{
0x00,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0xFF,0xFE,0x00,0x00,0x1F,0xF0,
0x11,0x10,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x00,0x1F,0xF0,0x01,0x00,0x7F,0xFC,/*"量",1*/
}
},
{"启",
{
0x01,0x00,0x00,0x80,0x1F,0xFC,0x10,0x04,0x10,0x04,0x10,0x04,0x1F,0xFC,0x10,0x00,
0x10,0x00,0x10,0x00,0x17,0xFC,0x24,0x04,0x24,0x04,0x44,0x04,0x87,0xFC,0x04,0x04,/*"启",2*/
}
},
{"动",
{
0x00,0x40,0x00,0x40,0x7C,0x40,0x00,0x40,0x01,0xFC,0x00,0x44,0xFE,0x44,0x20,0x44,
0x20,0x44,0x20,0x84,0x48,0x84,0x44,0x84,0xFD,0x04,0x45,0x04,0x02,0x28,0x04,0x10,/*"动",3*/
}
},
{"关",
{
0x10,0x10,0x08,0x10,0x08,0x20,0x00,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,
0xFF,0xFE,0x01,0x00,0x02,0x80,0x02,0x80,0x04,0x40,0x08,0x20,0x30,0x18,0xC0,0x06,/*"关",4*/
}
},
{"闭",
{
0x20,0x00,0x17,0xFC,0x00,0x04,0x40,0x84,0x40,0x84,0x5F,0xF4,0x40,0x84,0x41,0x84,
0x42,0x84,0x44,0x84,0x48,0x84,0x50,0x84,0x42,0x84,0x41,0x04,0x40,0x14,0x40,0x08,/*"闭",5*/
}
},
{"蓝",
{
0x08,0x20,0x08,0x20,0xFF,0xFE,0x08,0x20,0x04,0x80,0x24,0x80,0x24,0xFC,0x24,0xA0,
0x25,0x10,0x00,0x00,0x3F,0xF8,0x24,0x48,0x24,0x48,0x24,0x48,0xFF,0xFE,0x00,0x00,/*"蓝",5*/
}
},
{"牙",
{
0x00,0x00,0x3F,0xFC,0x00,0x40,0x00,0x40,0x10,0x40,0x10,0x40,0x20,0x40,0x3F,0xFE,
0x01,0x40,0x02,0x40,0x04,0x40,0x08,0x40,0x10,0x40,0x60,0x40,0x01,0x40,0x00,0x80,/*"牙",6*/
}
},
{"连",
{
0x00,0x40,0x20,0x40,0x17,0xFE,0x10,0x80,0x00,0xA0,0x01,0x20,0xF3,0xFC,0x10,0x20,
0x10,0x20,0x10,0x20,0x17,0xFE,0x10,0x20,0x10,0x20,0x28,0x20,0x47,0xFE,0x00,0x00,/*"连",7*/
}
},
{"接",
{
0x10,0x80,0x10,0x40,0x13,0xFC,0x10,0x00,0xFD,0x08,0x10,0x90,0x17,0xFE,0x10,0x40,
0x18,0x40,0x37,0xFE,0xD0,0x88,0x11,0x08,0x10,0x90,0x10,0x60,0x51,0x98,0x26,0x04,/*"接",8*/
}
},
{"断",
{
0x04,0x00,0x04,0x04,0x55,0x78,0x4E,0x40,0x44,0x40,0x7F,0x40,0x44,0x7E,0x4E,0x48,
0x55,0x48,0x65,0x48,0x44,0x48,0x44,0x48,0x40,0x48,0x7F,0x88,0x00,0x88,0x01,0x08,/*"断",9*/
}
},
{"开",
{
0x00,0x00,0x7F,0xFC,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xFF,0xFE,
0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x10,0x20,0x10,0x20,0x20,0x20,0x40,0x20,/*"开",10*/
}
},
{"关",
{
0x10,0x10,0x08,0x10,0x08,0x20,0x00,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,
0xFF,0xFE,0x01,0x00,0x02,0x80,0x02,0x80,0x04,0x40,0x08,0x20,0x30,0x18,0xC0,0x06,/*"关",11*/
}
},
{"机",
{
0x10,0x00,0x11,0xF0,0x11,0x10,0x11,0x10,0xFD,0x10,0x11,0x10,0x31,0x10,0x39,0x10,
0x55,0x10,0x55,0x10,0x91,0x10,0x11,0x12,0x11,0x12,0x12,0x12,0x12,0x0E,0x14,0x00,/*"机",12*/
}
},
};

#endif
//




五、使用方法
    OLED_Init();                /*初始化*/
        OLED_SetStart();        /*设置起点*/
        while(1)
        {
        /*待补充图形显示代码*/
        OLED_Refresh();                /*刷新缓存到OLED*/       
        }



最后展示一下:



左上角的43即是屏幕刷新速度43帧/秒。
————————————————

                            版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/qq_39649731/article/details/139956416

使用特权

评论回复
沙发
是你的乱码| | 2024-8-31 13:50 | 只看该作者
调用OLED_SetStart()来设置OLED的起始地址和寻址模式。

使用特权

评论回复
板凳
t60yz| | 2024-8-31 22:15 | 只看该作者
确保你的OLED显示屏正确连接到STM32的I2C接口

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2028

主题

15903

帖子

13

粉丝