STM32F103系列_OLED屏幕(SSD1306、SSD1315驱动)SPI驱动【DMA】(高刷)

写在前面

感谢这段时间大家的支持,咱特来优化一下代码。

  • 新增不同尺寸字符显示功能(自动换行、水平居中、垂直居中、完全居中
  • 新增汉字功能(自动换行、水平居中、垂直居中、完全居中)
  • 新增画点功能
  • 新增画线功能
  • 新增画圆功能
  • 新增图片显示功能

一、SSD1306和SSD1315

分辨率都是128*64,电压都在3.3V最佳,这两者可互相替代,但价格上SSD1315会比SSD1306便宜,毕竟用的人少。

二、电路原理图(SPI接法)

为了提高屏幕的刷新速度(帧率),SPI接法远远优于IIC接法。
电路图如下:
OLED_SPI
其中:

  1. 电源为3.3V显示效果最佳。
  2. 电阻电容封装建议大于等于0402
  3. CS接地是为了提高刷新率。

这里OLED的四条SPI信号线,直接对接在STM32对应的SPI接口上。

咱使用的芯片是最廉价的STM32F103C6T6A,接到了其SPI1接口上。
STM32_SPI1
其中:

  1. 这四条SPI信号线建议越短越好,并尽量避免过多的绕线,即从OLED屏幕引脚到STM32芯片的距离尽量要短,以减小周围信号对SPI信号线的干扰,避免屏幕显示异常。
  2. SPI的四条信号线建议间距为7~10mil,并排一起走。
  3. SPI的四条信号线与其他信号的距离建议≥20mil。

三、STM32_SPI

作者@Swiler的文章《STM32之SPI详细解析》讲的很好,可以参考一下。

四、STM32_DMA

作者@Z小旋的文章《【STM32】 DMA原理,步骤超细详解,一文看懂DMA》讲的很好,可以参考一下。

五、代码

OLED.c

/**
 * @file OLED.c
 * @author 星宸 (xingdala@qq.com)
 * @brief OLED SPI驱动库函数
 * @version 0.1
 * @date 2023-09-28
 *
 * @copyright Copyright (c) 2023
 *
 */
#include "STM32F10x.h"
#include "stdio.h"
#include "Delay.h"
#include "OLED.h"
#include "OLED_Library.h"
#include "chinese_characters.h"
#include "bmp.h"

/**
 * @brief 引脚连接提示,SPI
 *
 */
#define OLED_NSS GPIO_Pin_4
#define OLED_RST GPIO_Pin_8
#define OLED_SCL GPIO_Pin_5
#define OLED_DC GPIO_Pin_6
#define OLED_SDA GPIO_Pin_7

/**
 * @brief OLED屏幕ISP接口初始化
 *
 */
void OLED_IO_Init(void)
{
    // 初始化结构体
    GPIO_InitTypeDef GPIO_InitStructure; // 初始化GPIO结构体
    SPI_InitTypeDef SPI_InitStructure;   // 初始化SPI结构体

    // 使能时钟
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA | RCC_APB2Periph_SPI1, ENABLE); // 使用复用时钟复用GPIOA指示引脚SPI1功能

    // GPIO结构体
    GPIO_InitStructure.GPIO_Pin = OLED_SCL | OLED_SDA; // 选择引脚
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;    // 复用输出
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;  // 速度50MHz
    GPIO_Init(GPIOA, &GPIO_InitStructure);             // 初始化PA5(SCL),PA7(SDA)

    GPIO_InitStructure.GPIO_Pin = OLED_RST | OLED_DC | OLED_NSS; // 选择引脚
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;             // 推挽输出
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;            // 速度50MHz
    GPIO_Init(GPIOA, &GPIO_InitStructure);                       // 初始化PA8(RST),PA6(DC)

    GPIO_SetBits(GPIOA, OLED_SCL | OLED_SDA); // PA5 and PA7上拉
    GPIO_ResetBits(GPIOA, OLED_NSS);

    // SPI结构体
    SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;           // 设置SPI单线只发送
    SPI_InitStructure.SPI_Mode = SPI_Mode_Master;                       // 主SPI
    SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;                   // SPI 发送接收8位帧结构
    SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;                          // 串行同步时钟的空闲状态为低电平
    SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;                        // 第1个跳变沿数据被采样
    SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;                           // NSS主机片选信号(CS)由软件控制
    SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; // 预分频 16

    // SPI 速度设置函数(调整传输速度快慢 只有4个分频可选)
    // SPI_BaudRatePrescaler_2 2 分频 (SPI 36M@sys 72M)
    // SPI_BaudRatePrescaler_8 8 分频 (SPI 9M@sys 72M)
    // SPI_BaudRatePrescaler_16 16 分频 (SPI 4.5M@sys 72M)
    // SPI_BaudRatePrescaler_256 256 分频 (SPI 281.25K@sys 72M)

    SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; // 数据传输从 MSB 高位开始 低位为LSB
    SPI_InitStructure.SPI_CRCPolynomial = 7;           // CRC 值计算的多项式
    SPI_Init(SPI1, &SPI_InitStructure);                // 根据指定的参数初始化外设 SPIx 寄存器
    SPI1->CR2 = 1 << 1;                                // 允许DMA往缓冲区内发送

    SPI_Cmd(SPI1, ENABLE); // 使能 SPI 外设
};

uint8_t OLED_SRAM[8][128]; // 图像储存在SRAM里

/**
 * @brief DMA初始化
 *
 */
void OLED_DMA_Init(void)
{
    DMA_InitTypeDef DMA_InitStructure;

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); // 使能 DMA 时钟
    DMA_DeInit(DMA1_Channel3);                         // 选择DMA通道

    DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&SPI1->DR;              // DMA 外设 ADC 基地址
    DMA_InitStructure.DMA_MemoryBaseAddr = (u32)OLED_SRAM;                  // DMA 内存基地址
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;                      // 从储存器读取发送到外设
    DMA_InitStructure.DMA_BufferSize = 1024;                                // DMA 通道的 DMA 缓存的大小
    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;        // 外设地址不变
    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;                 // 内存地址递增
    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; // 8 位
    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;         // 8 位
    DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;                         // 工作在循环传输模式
    DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;                   // DMA 通道 x 拥有中优先级
    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;                            // 非内存到内存传输
    DMA_Init(DMA1_Channel3, &DMA_InitStructure);                            // 根据指定的参数初始化

    DMA_Cmd(DMA1_Channel3, ENABLE); // 使能DMA1 CH3所指示的通道
}

/**
 * @brief 发送命令
 *
 * @param TxData 命令
 */
void OLED_SendCmd(u8 TxData)
{
    OLED_DC_CMD(); // 命令模式

    while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET) // 检查指定的SPI标志位设置与否:发送缓存空标志位
    {
        for (u8 retry = 0; retry < 200; retry++) // 等待回复
            ;
        return; // 返回
    }

    Delay_ms(100); // 延时100毫秒

    SPI_I2S_SendData(SPI1, TxData); // 通过外设 SPIx 发送一个数据

    OLED_DC_DAT(); // 数据模式
}

/**
 * @brief OLED初始化函数
 *
 */
void OLED_Init(void)
{
    OLED_IO_Init(); // 端口初始化

    // Delay_s(1); // 延时1秒稳定端口状态

    OLED_RST_OFF(); // OLED复位
    Delay_ms(10);   // 复位延时
    OLED_RST_ON();  // 结束复位

    OLED_SendCmd(0xae); // 关闭显示

    OLED_SendCmd(0xd5); // 设置时钟分频因子,震荡频率
    OLED_SendCmd(0x80); //[3:0],分频因子;[7:4],震荡频率

    OLED_SendCmd(0x81); // 设置对比度
    OLED_SendCmd(0x7f); // 128

    OLED_SendCmd(0x8d); // 设置电荷泵开关
    OLED_SendCmd(0x14); // 开

    OLED_SendCmd(0x20); // 设置模式
    OLED_SendCmd(0x00); // 设置为水平地址模式

    OLED_SendCmd(0x21); // 设置列地址的起始和结束的位置
    OLED_SendCmd(0x00); // 0
    OLED_SendCmd(0x7f); // 127

    OLED_SendCmd(0x22); // 设置页地址的起始和结束的位置
    OLED_SendCmd(0x00); // 0
    OLED_SendCmd(0x07); // 7

    OLED_SendCmd(0xc8); // 0xc9上下反置 0xc8正常
    OLED_SendCmd(0xa1); // 0xa0左右反置 0xa1正常

    // OLED_SendCmd(0xC0);
    // OLED_SendCmd(0xA0); // 旋转180度显示

    OLED_SendCmd(0xa4); // 全局显示开启;0xa4正常,0xa5无视命令点亮全屏
    OLED_SendCmd(0xa6); // 设置显示方式;bit0:1,反相显示;0,正常显示

    OLED_SendCmd(0xaf); // 开启显示
    OLED_SendCmd(0x56);

    OLED_DMA_Init(); // DMA初始化
}

/**
 * @brief OLED反色显示
 *
 * @param i 0-正常,1-反色
 */
void OLED_ColorTurn(uint8_t i)
{
    if (i)
        OLED_SendCmd(0xA7); // 反色显示
    else
        OLED_SendCmd(0xA6); // 正常显示
}

/**
 * @brief OLED屏幕旋转180
 *
 * @param i 0-正常显示,1-旋转180度显示
 */
void OLED_DisplayTurn(uint8_t i)
{
    if (i)
    {
        OLED_SendCmd(0xC0);
        OLED_SendCmd(0xA0); // 旋转180度显示
    }
    else
    {
        OLED_SendCmd(0xC8);
        OLED_SendCmd(0xA1); // 正常显示
    }
}

/**
 * @brief 开启OLED显示,功耗 30 mW
 *
 */
void OLED_DisPlay_On(void)
{
    OLED_SendCmd(0x8D); // 电荷泵使能
    OLED_SendCmd(0x14); // 开启电荷泵
    OLED_SendCmd(0xAF); // 点亮屏幕
}

/**
 * @brief 关闭OLED显示,功耗 29 mW
 *
 */
void OLED_DisPlay_Off(void)
{
    OLED_SendCmd(0x8D); // 电荷泵使能
    OLED_SendCmd(0x10); // 关闭电荷泵
    OLED_SendCmd(0xAF); // 关闭屏幕
}

/**
 * @brief 清屏--全灭
 *
 */
void OLED_Clear(uint8_t led)
{
    for (uint8_t i = 0; i < 8; i++)
        for (uint8_t n = 0; n < 128; n++)
            if (led)
                OLED_SRAM[i][n] = 0xFF; // 全屏点亮
            else
                OLED_SRAM[i][n] = 0; // 清除所有数据
}

/**
 * @brief 画点
 *
 * @param x x坐标(0-128)
 * @param y y坐标(0-63)
 */
void OLED_DrawPoint(uint8_t x, uint8_t y)
{
    OLED_SRAM[y / 8][x] |= (1 << (y % 8));
}

/**
 * @brief 清除点
 *
 * @param x x坐标(0-128)
 * @param y y坐标(0-63)
 */
void OLED_ClearPoint(uint8_t x, uint8_t y)
{
    OLED_SRAM[y / 8][x] = ~OLED_SRAM[y / 8][x];
    OLED_SRAM[y / 8][x] |= (1 << (y % 8));
    OLED_SRAM[y / 8][x] = ~OLED_SRAM[y / 8][x];
}

/**
 * @brief 画线
 *
 * @param x1 起点x坐标(0-128)
 * @param y1 起点y坐标(0-63)
 * @param x2 终点x坐标(0-128)
 * @param y2 终点y坐标(0-63)
 */
void OLED_DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
{
    if (x1 == x2) // 画竖线
        for (uint8_t i = 0; i < y2 - y1; i++)
            OLED_DrawPoint(x1, y1 + i);
    else if (y1 == y2) // 画横线
        for (uint8_t i = 0; i < x2 - x1; i++)
            OLED_DrawPoint(x1 + i, y1);
    else // 画斜线
        for (uint8_t i = 0; i < x2 - x1; i++)
            OLED_DrawPoint(x1 + i, y1 + i * ((y2 - y1) * 10 / (x2 - x1)) / 10);
}

/**
 * @brief 清除线
 *
 * @param x1 起点x坐标(0-128)
 * @param y1 起点y坐标(0-63)
 * @param x2 终点x坐标(0-128)
 * @param y2 终点y坐标(0-63)
 */
void OLED_ClearLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
{
    if (x1 == x2) // 清除竖线
        for (uint8_t i = 0; i < y2 - y1; i++)
            OLED_ClearPoint(x1, y1 + i);
    else if (y1 == y2) // 清除横线
        for (uint8_t i = 0; i < x2 - x1; i++)
            OLED_ClearPoint(x1 + i, y1);
    else // 清除斜线
        for (uint8_t i = 0; i < x2 - x1; i++)
            OLED_ClearPoint(x1 + i, y1 + i * ((y2 - y1) * 10 / (x2 - x1)) / 10);
}

/**
 * @brief 画圆
 *
 * @param x 圆心x坐标(0-128)
 * @param y 圆心y坐标(0-63)
 * @param 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--;
    }
}

/**
 * @brief 清除圆
 *
 * @param x 圆心x坐标(0-128)
 * @param y 圆心y坐标(0-63)
 * @param r 圆的半径
 */
void OLED_ClearCircle(uint8_t x, uint8_t y, uint8_t r)
{
    int a = 0, b = r, num;

    while (2 * b * b >= r * r)
    {
        OLED_ClearPoint(x + a, y - b);
        OLED_ClearPoint(x - a, y - b);
        OLED_ClearPoint(x - a, y + b);
        OLED_ClearPoint(x + a, y + b);

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

        a++;

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

        if (num > 0)
            b--, a--;
    }
}

char OLED_zfc[] = {0}; // 字符转化为字符串储存于此数组

/**
 * @brief 指定位置显示单字符
 *
 * @param x 横坐标
 * @param y 纵坐标
 * @param ascii 单字符
 * @param Font_Size 字符大小:Font_Size_F6X8 或 Font_Size_F8x16
 */
void OLED_ZF(uint8_t x, uint8_t y, uint8_t *ascii, uint8_t Font_Size)
{
    if (Font_Size)
        for (uint8_t i = 0; i < 6; i++)
            OLED_SRAM[y][x + i] = YIN_F6X8[(*ascii - 32) * 6 + 1 + i];
    else
        for (uint8_t i1 = 0; i1 < 2; i1++)
            for (uint8_t i2 = 0; i2 < 8; i2++)
                OLED_SRAM[y + i1][x + i2] = YIN_F8X16[(*ascii - 32) * 16 + 8 * i1 + i2];
}
/**
 * @brief OLED显示多个字符
 *
 * @param x 横坐标
 * @param y 纵坐标
 * @param chr 字符串
 * @param Font_Size 字符大小:Font_Size_F6X8 或 Font_Size_F8x16
 */
void OLED_ZFC(uint8_t x, uint8_t y, uint8_t *chr, uint8_t Font_Size)
{
    uint8_t j = 0;

    while (chr[j] != '\0')
    {
        if (Font_Size)
        {
            for (uint8_t i = 0; i < 6; i++)
                OLED_SRAM[y][x + i] = YIN_F6X8[(chr[j] - 32) * 6 + 1 + i];

            x += 6;

            if (x > 120) // 自动换行
                x = 0, y++;
        }
        else
        {
            for (uint8_t i1 = 0; i1 < 2; i1++)
                for (uint8_t i2 = 0; i2 < 8; i2++)
                    OLED_SRAM[y + i1][x + i2] = YIN_F8X16[(chr[j] - 32) * 16 + 8 * i1 + i2];

            x += 8;

            if (x > 120) // 自动换行
                x = 0, y += 2;
        }

        j++;
    }
}

/**
 * @brief OLED显示字符串水平居中
 *
 * @param y 纵坐标
 * @param chr 字符串
 * @param Font_Size 字符大小:Font_Size_F6X8 或 Font_Size_F8x16
 */
void OLED_ZFC_Horizontal_center(uint8_t y, uint8_t *chr, uint8_t Font_Size)
{
    uint8_t num = 0, j = 0;

    // 读取字符个数
    while (chr[num] != '\0')
        num++;

    if (num < 22)
    {
        if (Font_Size)
            num = ((21 - num) * 6) / 2;
        else
            num = ((16 - num) * 8) / 2;

        while (chr[j] != '\0')
        {
            if (Font_Size)
            {
                for (uint8_t i = 0; i < 6; i++)
                    OLED_SRAM[y][num + i] = YIN_F6X8[(chr[j] - 32) * 6 + 1 + i];

                num += 6;

                if (num > 120) // 自动换行
                    num = 0, y++;
            }
            else
            {
                for (uint8_t i1 = 0; i1 < 2; i1++)
                    for (uint8_t i2 = 0; i2 < 8; i2++)
                        OLED_SRAM[y + i1][num + i2] = YIN_F8X16[(chr[j] - 32) * 16 + 8 * i1 + i2];

                num += 8;

                if (num > 120) // 自动换行
                    num = 0, y += 2;
            }

            j++; // 显示下一个字符;
        }
    }
    else
        OLED_ZFC_Horizontal_center(y, "ERROR", Font_Size);
}

/**
 * @brief OLED显示字符串垂直居中
 *
 * @param x 横坐标
 * @param chr 字符串
 * @param Font_Size 字符大小:Font_Size_F6X8 或 Font_Size_F8x16
 */
void OLED_ZFC_Vorizontal_center(uint8_t x, uint8_t *chr, uint8_t Font_Size)
{
    uint8_t num = 0, j = 0, y;

    while (chr[num] != '\0') // 读取字符个数
        num++;

    if (Font_Size)
    {
        if (num < 43)
            y = 3;
        else if (num < 85)
            y = 2;
        else if (num < 148)
            y = 1;
        else
            y = 0;
    }
    else
    {
        if (num < 33)
            y = 2;
        else if (num < 49)
            y = 1;
        else
            y = 0;
    }

    while (chr[j] != '\0')
    {
        if (Font_Size)
        {
            for (uint8_t i = 0; i < 6; i++)
                OLED_SRAM[y][x + i] = YIN_F6X8[(chr[j] - 32) * 6 + 1 + i];

            x += 6;

            if (x > 120) // 自动换行
                x = 0, y++;
        }
        else
        {
            for (uint8_t i1 = 0; i1 < 2; i1++)
                for (uint8_t i2 = 0; i2 < 8; i2++)
                    OLED_SRAM[y + i1][x + i2] = YIN_F8X16[(chr[j] - 32) * 16 + 8 * i1 + i2];

            x += 8;

            if (x > 120) // 自动换行
                x = 0, y += 2;
        }

        j++;
    }
}

/**
 * @brief OLED显示一个文字
 *
 * @param x 横坐标
 * @param y 纵坐标
 * @param page 文字所在页码
 * @param num 文字序号
 */
void OLED_ONE_HZ(uint8_t x, uint8_t y, uint8_t page, uint8_t num)
{
    switch (page)
    {
    case 1:
        for (uint8_t i1 = 0; i1 < 2; i1++)
            for (uint8_t i2 = 0; i2 < 16; i2++)
                OLED_SRAM[y + i1][x + i2] = (HZ1[num * 2 + i1][i2]);
        break;
    case 2:
        for (uint8_t i1 = 0; i1 < 2; i1++)
            for (uint8_t i2 = 0; i2 < 16; i2++)
                OLED_SRAM[y + i1][x + i2] = (HZ2[num * 2 + i1][i2]);
        break;
    default:
        break;
    }
}

/**
 * @brief OLED显示一句话
 *
 * @param x 横坐标
 * @param y 纵坐标
 * @param page 文字所在页码
 * @param num1 文字开始序号
 * @param num2 文字结束序号
 */
void OLED_Long_HZ(uint8_t x, uint8_t y, uint8_t page, uint8_t num1, uint8_t num2)
{
    for (uint8_t num = num1; num < num2 + 1; num++)
    {
        if (x % 16)
        {
            if (x + (num - num1 + 1) * 16 < 128)
                OLED_ONE_HZ(x + (num - num1) * 16, y, page, num);
            else if (x + (num - num1 + 1) * 16 < 256)
                OLED_ONE_HZ((num - num1 - 8 + (x / 16) + 1) * 16, y + 2, page, num);
            else if (x + (num - num1 + 1) * 16 < 384)
                OLED_ONE_HZ((num - num1 - 16 + (x / 16) + 1) * 16, y + 4, page, num);
            else if (x + (num - num1 + 1) * 16 < 512)
                OLED_ONE_HZ((num - num1 - 24 + (x / 16) + 1) * 16, y + 6, page, num);
        }
        else
        {
            if (x + (num - num1) * 16 < 128)
                OLED_ONE_HZ(x + (num - num1) * 16, y, page, num);
            else if (x + (num - num1) * 16 < 256)
                OLED_ONE_HZ((num - num1 - 8 + (x / 16)) * 16, y + 2, page, num);
            else if (x + (num - num1) * 16 < 384)
                OLED_ONE_HZ((num - num1 - 16 + (x / 16)) * 16, y + 4, page, num);
            else if (x + (num - num1) * 16 < 512)
                OLED_ONE_HZ((num - num1 - 24 + (x / 16)) * 16, y + 6, page, num);
        }
    }
}

/**
 * @brief OLED显示一句话水平居中
 *
 * @param y 纵坐标
 * @param chr 字符串
 * @param num1 文字开始序号
 * @param num2 文字结束序号
 */
void OLED_Long_HZ_Horizontal_center(uint8_t y, uint8_t page, uint8_t num1, uint8_t num2)
{
    uint8_t x, x1;

    if ((num2 - num1) < 7)
        x = ((7 - (num2 - num1)) * 16) / 2;
    else
        x = 0;

    for (uint8_t num = num1; num < num2 + 1; num++)
    {
        if (x % 16)
        {
            if (x + (num - num1 + 1) * 16 < 128)
                OLED_ONE_HZ(x + (num - num1) * 16, y, page, num);
            else if (x + (num - num1 + 1) * 16 < 256)
                OLED_ONE_HZ((num - num1 - 8 + (x1 / 16) + 1) * 16 + (((15 - (num2 - num1)) * 16) / 2), y + 2, page, num);
            else if (x + (num - num1 + 1) * 16 < 384)
                OLED_ONE_HZ((num - num1 - 16 + (x1 / 16) + 1) * 16 + (((23 - (num2 - num1)) * 16) / 2), y + 4, page, num);
            else if (x + (num - num1 + 1) * 16 < 512)
                OLED_ONE_HZ((num - num1 - 24 + (x1 / 16) + 1) * 16 + (((31 - (num2 - num1)) * 16) / 2), y + 6, page, num);
        }
        else
        {
            if (x + (num - num1) * 16 < 128)
                OLED_ONE_HZ(x + (num - num1) * 16, y, page, num);
            else if (x + (num - num1) * 16 < 256)
                OLED_ONE_HZ((num - num1 - 8 + (x1 / 16)) * 16 + (((15 - (num2 - num1)) * 16) / 2), y + 2, page, num);
            else if (x + (num - num1 + 1) * 16 < 384)
                OLED_ONE_HZ((num - num1 - 16 + (x1 / 16)) * 16 + (((23 - (num2 - num1)) * 16) / 2), y + 4, page, num);
            else if (x + (num - num1 + 1) * 16 < 512)
                OLED_ONE_HZ((num - num1 - 24 + (x1 / 16)) * 16 + (((31 - (num2 - num1)) * 16) / 2), y + 6, page, num);
        }
    }
}

/**
 * @brief OLED显示一句话垂直居中
 *
 * @param x 横坐标
 * @param chr 字符串
 * @param num1 文字开始序号
 * @param num2 文字结束序号
 */
void OLED_Long_HZ_Vorizontal_center(uint8_t x, uint8_t page, uint8_t num1, uint8_t num2)
{
    uint8_t y;

    if ((num2 - num1) < 7)
        y = 3;
    else if ((num2 - num1) < 15)
        y = 2;
    else if ((num2 - num1) < 23)
        y = 1;
    else
        y = 0;

    for (uint8_t num = num1; num < num2 + 1; num++)
    {
        if (x % 16)
        {
            if (x + (num - num1 + 1) * 16 < 128)
                OLED_ONE_HZ(x + (num - num1) * 16, y, page, num);
            else if (x + (num - num1 + 1) * 16 < 256)
                OLED_ONE_HZ((num - num1 - 8 + (x / 16) + 1) * 16, y + 2, page, num);
            else if (x + (num - num1 + 1) * 16 < 384)
                OLED_ONE_HZ((num - num1 - 16 + (x / 16) + 1) * 16, y + 4, page, num);
            else if (x + (num - num1 + 1) * 16 < 512)
                OLED_ONE_HZ((num - num1 - 24 + (x / 16) + 1) * 16, y + 6, page, num);
        }
        else
        {
            if (x + (num - num1) * 16 < 128)
                OLED_ONE_HZ(x + (num - num1) * 16, y, page, num);
            else if (x + (num - num1) * 16 < 256)
                OLED_ONE_HZ((num - num1 - 8 + (x / 16)) * 16, y + 2, page, num);
            else if (x + (num - num1) * 16 < 384)
                OLED_ONE_HZ((num - num1 - 16 + (x / 16)) * 16, y + 4, page, num);
            else if (x + (num - num1) * 16 < 512)
                OLED_ONE_HZ((num - num1 - 24 + (x / 16)) * 16, y + 6, page, num);
        }
    }
}

/**
 * @brief OLED显示图片
 *
 * @param x1 起点x坐标
 * @param y1 起点y坐标
 * @param x2 终点x坐标,最大是128
 * @param y2 终点y坐标,最大是8
 * @param BMP 图片选择
 */
void OLED_ShowPicture(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t BMP)
{
    uint32_t j = 0;

    switch (BMP)
    {
    case 1:
        for (uint8_t i = y1; i < (y2 - y1); i++)
            for (uint8_t n = x1; n < x2 - x1; n++, j++)
                OLED_SRAM[i][n] = BMP1[j];
        break;
    case 2:
        for (uint8_t i = y1; i < (y2 - y1); i++)
            for (uint8_t n = x1; n < x2 - x1; n++, j++)
                OLED_SRAM[i][n] = BMP2[j];
        break;
    case 3:
        for (uint8_t i = y1; i < (y2 - y1); i++)
            for (uint8_t n = x1; n < x2 - x1; n++, j++)
                OLED_SRAM[i][n] = BMP3[j];
        break;

    default:
        break;
    }
}

OLED.h

/**
 * @file OLED.h
 * @author 星宸 (xingdala@qq.com)
 * @brief OLED SPI驱动库函数
 * @version 0.1
 * @date 2023-09-28
 *
 * @copyright Copyright (c) 2023
 *
 */
#ifndef __OLED_H__
#define __OLED_H__

#include "STM32F10x.h"

#pragma diag_suppress 167, 940 // 消除格式警告
extern char OLED_zfc[];        // 字符转化为字符串储存于此数组

#define Font_Size_F6X8 1
#define Font_Size_F8x16 0

#define OLED_SCL_CLR() GPIO_ResetBits(GPIOA, GPIO_Pin_5) // 时钟
#define OLED_SCL_SET() GPIO_SetBits(GPIOA, GPIO_Pin_5)

#define OLED_SDA_LOW() GPIO_ResetBits(GPIOA, GPIO_Pin_7) // MOSI主设备输出
#define OLED_SDA_HIGH() GPIO_SetBits(GPIOA, GPIO_Pin_7)

#define OLED_RST_OFF() GPIO_ResetBits(GPIOA, GPIO_Pin_8) // 接低电平复位
#define OLED_RST_ON() GPIO_SetBits(GPIOA, GPIO_Pin_8)

#define OLED_DC_CMD() GPIO_ResetBits(GPIOA, GPIO_Pin_6) // 模式
#define OLED_DC_DAT() GPIO_SetBits(GPIOA, GPIO_Pin_6)

void OLED_IO_Init(void);
void OLED_DMA_Init(void);
void OLED_Init(void);
void OLED_SendCmd(u8 TxData);

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

void OLED_Clear(uint8_t led);

void OLED_DrawPoint(uint8_t x, uint8_t y);
void OLED_ClearPoint(uint8_t x, uint8_t y);

void OLED_DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
void OLED_ClearLine(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_ClearCircle(uint8_t x, uint8_t y, uint8_t r);

void OLED_ZF(uint8_t x, uint8_t y, uint8_t *ascii, uint8_t Font_Size);
void OLED_ZFC(uint8_t x, uint8_t y, uint8_t *chr, uint8_t Font_Size);
void OLED_ZFC_Horizontal_center(uint8_t y, uint8_t *chr, uint8_t Font_Size);
void OLED_ZFC_Vorizontal_center(uint8_t x, uint8_t *chr, uint8_t Font_Size);

void OLED_ONE_HZ(uint8_t x, uint8_t y, uint8_t page, uint8_t num);
void OLED_Long_HZ(uint8_t x, uint8_t y, uint8_t page, uint8_t num1, uint8_t num2);
void OLED_Long_HZ_Horizontal_center(uint8_t y, uint8_t page, uint8_t num1, uint8_t num2);
void OLED_Long_HZ_Vorizontal_center(uint8_t x, uint8_t page, uint8_t num1, uint8_t num2);
void OLED_ShowPicture(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t BMP);

#endif

OLED_Library.h(字符取模缓存)

/**
 * @file OLED.h
 * @author 星宸 (xingdala@qq.com)
 * @brief OLED SPI驱动库函数
 * @version 0.1
 * @date 2023-09-28
 *
 * @copyright Copyright (c) 2023
 *
 */
#ifndef __OLED_LIBRARY_H__
#define __OLED_LIBRARY_H__

const uint8_t YIN_F6X8[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp
    0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // !
    0x00, 0x00, 0x07, 0x00, 0x07, 0x00, // "
    0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14, // #
    0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12, // $
    0x00, 0x62, 0x64, 0x08, 0x13, 0x23, // %
    0x00, 0x36, 0x49, 0x55, 0x22, 0x50, // &
    0x00, 0x00, 0x05, 0x03, 0x00, 0x00, // '
    0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, // (
    0x00, 0x00, 0x41, 0x22, 0x1c, 0x00, // )
    0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, // *
    0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, // +
    0x00, 0x00, 0x00, 0xA0, 0x60, 0x00, // ,
    0x00, 0x08, 0x08, 0x08, 0x08, 0x08, // -
    0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // .
    0x00, 0x20, 0x10, 0x08, 0x04, 0x02, // /
    0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
    0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, // 1
    0x00, 0x42, 0x61, 0x51, 0x49, 0x46, // 2
    0x00, 0x21, 0x41, 0x45, 0x4B, 0x31, // 3
    0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, // 4
    0x00, 0x27, 0x45, 0x45, 0x45, 0x39, // 5
    0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, // 6
    0x00, 0x01, 0x71, 0x09, 0x05, 0x03, // 7
    0x00, 0x36, 0x49, 0x49, 0x49, 0x36, // 8
    0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, // 9
    0x00, 0x00, 0x36, 0x36, 0x00, 0x00, // :
    0x00, 0x00, 0x56, 0x36, 0x00, 0x00, // ;
    0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // <
    0x00, 0x14, 0x14, 0x14, 0x14, 0x14, // =
    0x00, 0x00, 0x41, 0x22, 0x14, 0x08, // >
    0x00, 0x02, 0x01, 0x51, 0x09, 0x06, // ?
    0x00, 0x32, 0x49, 0x59, 0x51, 0x3E, // @
    0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, // A
    0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, // B
    0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, // C
    0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, // D
    0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, // E
    0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, // F
    0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, // G
    0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, // H
    0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, // I
    0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, // J
    0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, // K
    0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, // L
    0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
    0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, // N
    0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, // O
    0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, // P
    0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, // Q
    0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, // R
    0x00, 0x46, 0x49, 0x49, 0x49, 0x31, // S
    0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, // T
    0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, // U
    0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, // V
    0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, // W
    0x00, 0x63, 0x14, 0x08, 0x14, 0x63, // X
    0x00, 0x07, 0x08, 0x70, 0x08, 0x07, // Y
    0x00, 0x61, 0x51, 0x49, 0x45, 0x43, // Z
    0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // [
    0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55, // 55
    0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, // ]
    0x00, 0x04, 0x02, 0x01, 0x02, 0x04, // ^
    0x00, 0x40, 0x40, 0x40, 0x40, 0x40, // _
    0x00, 0x00, 0x01, 0x02, 0x04, 0x00, // '
    0x00, 0x20, 0x54, 0x54, 0x54, 0x78, // a
    0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, // b
    0x00, 0x38, 0x44, 0x44, 0x44, 0x20, // c
    0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, // d
    0x00, 0x38, 0x54, 0x54, 0x54, 0x18, // e
    0x00, 0x08, 0x7E, 0x09, 0x01, 0x02, // f
    0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, // g
    0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, // h
    0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, // i
    0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, // j
    0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // k
    0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, // l
    0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, // m
    0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, // n
    0x00, 0x38, 0x44, 0x44, 0x44, 0x38, // o
    0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, // p
    0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, // q
    0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, // r
    0x00, 0x48, 0x54, 0x54, 0x54, 0x20, // s
    0x00, 0x04, 0x3F, 0x44, 0x40, 0x20, // t
    0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, // u
    0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, // v
    0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, // w
    0x00, 0x44, 0x28, 0x10, 0x28, 0x44, // x
    0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, // y
    0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, // z
    0x14, 0x14, 0x14, 0x14, 0x14, 0x14  // horiz lines
};

// ASCII表
const uint8_t YIN_F8X16[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0
    0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x30, 0x00, 0x00, 0x00, //! 1
    0x00, 0x10, 0x0C, 0x06, 0x10, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //" 2
    0x40, 0xC0, 0x78, 0x40, 0xC0, 0x78, 0x40, 0x00, 0x04, 0x3F, 0x04, 0x04, 0x3F, 0x04, 0x04, 0x00, //# 3
    0x00, 0x70, 0x88, 0xFC, 0x08, 0x30, 0x00, 0x00, 0x00, 0x18, 0x20, 0xFF, 0x21, 0x1E, 0x00, 0x00, //$ 4
    0xF0, 0x08, 0xF0, 0x00, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x21, 0x1C, 0x03, 0x1E, 0x21, 0x1E, 0x00, //% 5
    0x00, 0xF0, 0x08, 0x88, 0x70, 0x00, 0x00, 0x00, 0x1E, 0x21, 0x23, 0x24, 0x19, 0x27, 0x21, 0x10, //& 6
    0x10, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //' 7
    0x00, 0x00, 0x00, 0xE0, 0x18, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x07, 0x18, 0x20, 0x40, 0x00, //( 8
    0x00, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x18, 0x07, 0x00, 0x00, 0x00, //) 9
    0x40, 0x40, 0x80, 0xF0, 0x80, 0x40, 0x40, 0x00, 0x02, 0x02, 0x01, 0x0F, 0x01, 0x02, 0x02, 0x00, //* 10
    0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x1F, 0x01, 0x01, 0x01, 0x00, //+ 11
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xB0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, //, 12
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, //- 13
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, //. 14
    0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x04, 0x00, 0x60, 0x18, 0x06, 0x01, 0x00, 0x00, 0x00, /// 15
    0x00, 0xE0, 0x10, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x00, 0x0F, 0x10, 0x20, 0x20, 0x10, 0x0F, 0x00, // 0
    0x00, 0x00, 0x10, 0x10, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, // 1
    0x00, 0x70, 0x08, 0x08, 0x08, 0x08, 0xF0, 0x00, 0x00, 0x30, 0x28, 0x24, 0x22, 0x21, 0x30, 0x00, // 2
    0x00, 0x30, 0x08, 0x08, 0x08, 0x88, 0x70, 0x00, 0x00, 0x18, 0x20, 0x21, 0x21, 0x22, 0x1C, 0x00, // 3
    0x00, 0x00, 0x80, 0x40, 0x30, 0xF8, 0x00, 0x00, 0x00, 0x06, 0x05, 0x24, 0x24, 0x3F, 0x24, 0x24, // 4
    0x00, 0xF8, 0x88, 0x88, 0x88, 0x08, 0x08, 0x00, 0x00, 0x19, 0x20, 0x20, 0x20, 0x11, 0x0E, 0x00, // 5
    0x00, 0xE0, 0x10, 0x88, 0x88, 0x90, 0x00, 0x00, 0x00, 0x0F, 0x11, 0x20, 0x20, 0x20, 0x1F, 0x00, // 6
    0x00, 0x18, 0x08, 0x08, 0x88, 0x68, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x01, 0x00, 0x00, 0x00, // 7
    0x00, 0x70, 0x88, 0x08, 0x08, 0x88, 0x70, 0x00, 0x00, 0x1C, 0x22, 0x21, 0x21, 0x22, 0x1C, 0x00, // 8
    0x00, 0xF0, 0x08, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x00, 0x01, 0x12, 0x22, 0x22, 0x11, 0x0F, 0x00, // 9
    0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, //: 26
    0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x00, 0x00, //; 27
    0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, //< 28
    0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, //= 29
    0x00, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, //> 30
    0x00, 0x70, 0x48, 0x08, 0x08, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x36, 0x01, 0x00, 0x00, //? 31
    0xC0, 0x30, 0xC8, 0x28, 0xE8, 0x10, 0xE0, 0x00, 0x07, 0x18, 0x27, 0x24, 0x23, 0x14, 0x0B, 0x00, //@ 32
    0x00, 0x00, 0xC0, 0x38, 0xE0, 0x00, 0x00, 0x00, 0x20, 0x3C, 0x23, 0x02, 0x02, 0x27, 0x38, 0x20, // A 33
    0x08, 0xF8, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x11, 0x0E, 0x00, // B 34
    0xC0, 0x30, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x07, 0x18, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, // C 35
    0x08, 0xF8, 0x08, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x10, 0x0F, 0x00, // D 36
    0x08, 0xF8, 0x88, 0x88, 0xE8, 0x08, 0x10, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x23, 0x20, 0x18, 0x00, // E 37
    0x08, 0xF8, 0x88, 0x88, 0xE8, 0x08, 0x10, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, // F 38
    0xC0, 0x30, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x07, 0x18, 0x20, 0x20, 0x22, 0x1E, 0x02, 0x00, // G 39
    0x08, 0xF8, 0x08, 0x00, 0x00, 0x08, 0xF8, 0x08, 0x20, 0x3F, 0x21, 0x01, 0x01, 0x21, 0x3F, 0x20, // H 40
    0x00, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // I 41
    0x00, 0x00, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x00, 0xC0, 0x80, 0x80, 0x80, 0x7F, 0x00, 0x00, 0x00, // J 42
    0x08, 0xF8, 0x88, 0xC0, 0x28, 0x18, 0x08, 0x00, 0x20, 0x3F, 0x20, 0x01, 0x26, 0x38, 0x20, 0x00, // K 43
    0x08, 0xF8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x20, 0x20, 0x20, 0x30, 0x00, // L 44
    0x08, 0xF8, 0xF8, 0x00, 0xF8, 0xF8, 0x08, 0x00, 0x20, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x20, 0x00, // M 45
    0x08, 0xF8, 0x30, 0xC0, 0x00, 0x08, 0xF8, 0x08, 0x20, 0x3F, 0x20, 0x00, 0x07, 0x18, 0x3F, 0x00, // N 46
    0xE0, 0x10, 0x08, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x0F, 0x10, 0x20, 0x20, 0x20, 0x10, 0x0F, 0x00, // O 47
    0x08, 0xF8, 0x08, 0x08, 0x08, 0x08, 0xF0, 0x00, 0x20, 0x3F, 0x21, 0x01, 0x01, 0x01, 0x00, 0x00, // P 48
    0xE0, 0x10, 0x08, 0x08, 0x08, 0x10, 0xE0, 0x00, 0x0F, 0x18, 0x24, 0x24, 0x38, 0x50, 0x4F, 0x00, // Q 49
    0x08, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x03, 0x0C, 0x30, 0x20, // R 50
    0x00, 0x70, 0x88, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x38, 0x20, 0x21, 0x21, 0x22, 0x1C, 0x00, // S 51
    0x18, 0x08, 0x08, 0xF8, 0x08, 0x08, 0x18, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x00, 0x00, // T 52
    0x08, 0xF8, 0x08, 0x00, 0x00, 0x08, 0xF8, 0x08, 0x00, 0x1F, 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, // U 53
    0x08, 0x78, 0x88, 0x00, 0x00, 0xC8, 0x38, 0x08, 0x00, 0x00, 0x07, 0x38, 0x0E, 0x01, 0x00, 0x00, // V 54
    0xF8, 0x08, 0x00, 0xF8, 0x00, 0x08, 0xF8, 0x00, 0x03, 0x3C, 0x07, 0x00, 0x07, 0x3C, 0x03, 0x00, // W 55
    0x08, 0x18, 0x68, 0x80, 0x80, 0x68, 0x18, 0x08, 0x20, 0x30, 0x2C, 0x03, 0x03, 0x2C, 0x30, 0x20, // X 56
    0x08, 0x38, 0xC8, 0x00, 0xC8, 0x38, 0x08, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x00, 0x00, // Y 57
    0x10, 0x08, 0x08, 0x08, 0xC8, 0x38, 0x08, 0x00, 0x20, 0x38, 0x26, 0x21, 0x20, 0x20, 0x18, 0x00, // Z 58
    0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x00, //[ 59
    0x00, 0x0C, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x38, 0xC0, 0x00, //\ 60
    0x00, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x7F, 0x00, 0x00, 0x00, //] 61
    0x00, 0x00, 0x04, 0x02, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //^ 62
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, //_ 63
    0x00, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //` 64
    0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x19, 0x24, 0x22, 0x22, 0x22, 0x3F, 0x20, // a 65
    0x08, 0xF8, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x11, 0x20, 0x20, 0x11, 0x0E, 0x00, // b 66
    0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x0E, 0x11, 0x20, 0x20, 0x20, 0x11, 0x00, // c 67
    0x00, 0x00, 0x00, 0x80, 0x80, 0x88, 0xF8, 0x00, 0x00, 0x0E, 0x11, 0x20, 0x20, 0x10, 0x3F, 0x20, // d 68
    0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x22, 0x22, 0x22, 0x22, 0x13, 0x00, // e 69
    0x00, 0x80, 0x80, 0xF0, 0x88, 0x88, 0x88, 0x18, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // f 70
    0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x6B, 0x94, 0x94, 0x94, 0x93, 0x60, 0x00, // g 71
    0x08, 0xF8, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x20, 0x3F, 0x21, 0x00, 0x00, 0x20, 0x3F, 0x20, // h 72
    0x00, 0x80, 0x98, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // i 73
    0x00, 0x00, 0x00, 0x80, 0x98, 0x98, 0x00, 0x00, 0x00, 0xC0, 0x80, 0x80, 0x80, 0x7F, 0x00, 0x00, // j 74
    0x08, 0xF8, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x20, 0x3F, 0x24, 0x02, 0x2D, 0x30, 0x20, 0x00, // k 75
    0x00, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x3F, 0x20, 0x20, 0x00, 0x00, // l 76
    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x20, 0x3F, 0x20, 0x00, 0x3F, 0x20, 0x00, 0x3F, // m 77
    0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x20, 0x3F, 0x21, 0x00, 0x00, 0x20, 0x3F, 0x20, // n 78
    0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, // o 79
    0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xA1, 0x20, 0x20, 0x11, 0x0E, 0x00, // p 80
    0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x0E, 0x11, 0x20, 0x20, 0xA0, 0xFF, 0x80, // q 81
    0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x20, 0x20, 0x3F, 0x21, 0x20, 0x00, 0x01, 0x00, // r 82
    0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x33, 0x24, 0x24, 0x24, 0x24, 0x19, 0x00, // s 83
    0x00, 0x80, 0x80, 0xE0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x00, 0x00, // t 84
    0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x20, 0x10, 0x3F, 0x20, // u 85
    0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0E, 0x30, 0x08, 0x06, 0x01, 0x00, // v 86
    0x80, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80, 0x0F, 0x30, 0x0C, 0x03, 0x0C, 0x30, 0x0F, 0x00, // w 87
    0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x20, 0x31, 0x2E, 0x0E, 0x31, 0x20, 0x00, // x 88
    0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x81, 0x8E, 0x70, 0x18, 0x06, 0x01, 0x00, // y 89
    0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x21, 0x30, 0x2C, 0x22, 0x21, 0x30, 0x00, // z 90
    0x00, 0x00, 0x00, 0x00, 0x80, 0x7C, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x40, 0x40, //{ 91
    0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, //| 92
    0x00, 0x02, 0x02, 0x7C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x3F, 0x00, 0x00, 0x00, 0x00, //} 93
    0x00, 0x06, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //~ 94
};

#endif

chinese_characters.h(汉字取模缓存)

/**
 * @file chinese_characters.h
 * @author 星宸
 * @brief 汉字,取模方式“列行式”、取模走向“逆向”、输出数制“十六进制”、自定义格式“C51格式”
 * @version 1.0
 * @date 2023-09-28
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#ifndef __CHINESE_CHARACTERS_H__
#define __CHINESE_CHARACTERS_H__

unsigned char HZ1[][32] =
    {
        {0x00, 0x00, 0x00, 0xBE, 0x2A, 0x2A, 0x2A, 0xEA, 0x2A, 0x2A, 0x2A, 0x3E, 0x00, 0x00, 0x00, 0x00},
        {0x00, 0x44, 0x42, 0x49, 0x49, 0x49, 0x49, 0x7F, 0x49, 0x49, 0x49, 0x49, 0x41, 0x40, 0x00, 0x00}, /*"星",0*/

        {0x10, 0x0C, 0xE4, 0x24, 0xA4, 0xA4, 0xA5, 0xA6, 0xA4, 0xA4, 0xA4, 0xA4, 0x24, 0x14, 0x0C, 0x00},
        {0x40, 0x30, 0x0F, 0x02, 0x02, 0xFE, 0x42, 0x22, 0x06, 0x0A, 0x12, 0x2A, 0x26, 0x42, 0x40, 0x00}, /*"宸",1*/
};

unsigned char HZ2[][32] =
    {
        0x00};

#endif

bmp.h(图片取模缓存)

/**
 * @file bmp.h
 * @author 星宸
 * @brief 取模方式“列行式”、取模走向“顺向”、输出数制“十六进制”、自定义格式“C51格式”
 * @version 1.0
 * @date 2023-09-28
 * 
 * @copyright 深圳市华视微科技版权所有,侵权必究
 * 
 */

#ifndef __BMP_H
#define __BMP_H

uint8_t BMP1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,
0xF0,0xF8,0xF8,0x7C,0x0E,0x86,0xC0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,
0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xC0,0x86,0x0E,0x7C,0xF8,0xF8,0xF0,
0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0xFF,0xFF,0xFF,
0xFF,0xFF,0xC3,0x00,0x3C,0xFF,0xFF,0xFF,0xFC,0xF0,0xC0,0x80,0x00,0x0E,0x3F,0xFF,
0xFF,0x3F,0x0E,0x00,0x80,0xC0,0xF0,0xFC,0xFF,0xFF,0xFF,0x38,0x00,0xC7,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFC,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFC,0xF8,0xE1,0xC7,0x8F,0x1F,0x3F,0x3F,0x7F,0x7F,0xFE,0xFE,0xFE,
0xFE,0xFE,0xFE,0x7F,0x7F,0x3F,0x3F,0x1F,0x8F,0xC7,0xE1,0xF8,0xFC,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0xF0,0xF0,0xE0,0xE0,0xC0,0xC0,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x0F,0x8F,0x8F,0x6F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xFC,0xFC,0xF8,
0xF8,0xFC,0xFC,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x6F,0x8F,0x8F,0x0F,0x07,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFE,0xFC,0xF8,0xF8,0xF0,0xF0,0xF1,0xF1,0xF3,0xFF,0xFF,
0xFF,0xFF,0xFD,0xF9,0xF3,0xF3,0xF3,0xE7,0xE7,0x07,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0x07,0xE7,0xE7,0xF3,0xF3,0xF3,0xF9,0xFD,0xFF,0xFF,
0xFF,0xFF,0xF3,0xF1,0xF1,0xF0,0xF0,0xF8,0xF8,0xFC,0xFE,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFE,0xFC,0xF8,0xF0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xE1,0xC3,0xC3,0xC3,0xC3,0xD9,0x99,0x99,0xB8,0xB8,0x38,0x78,
0x78,0xF8,0xF9,0xF9,0xFB,0xFB,0xFB,0xFB,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFB,0xFB,0xFB,0xFB,0xF9,0xF9,0xF8,0x78,
0x78,0x38,0xB8,0xB8,0x99,0x99,0xD9,0xC3,0xC3,0xC3,0xC3,0xE1,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xF0,0xF8,0xFC,0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x0F,0x0F,0x07,0x07,
0x07,0x07,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07,
0x0E,0x0E,0x0D,0x1F,0x07,0x0F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x0F,0x07,0x1F,0x0D,0x0E,0x0E,
0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x07,
0x07,0x07,0x0F,0x0F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x3F,0x7F,
0x7F,0x3F,0x1F,0x0F,0x0F,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

uint8_t BMP2[] = {0x00};

uint8_t BMP3[] = {0x00};

uint8_t BMP4[] = {0x00};

uint8_t BMP5[] = {0x00};

#endif

Delay.c 与 Delay.h

使用系统时钟SysTick的延时函数

六、调用方法

例:main.c

#include "stm32f10x.h"
#include "Delay.h"
#include "OLED.h"

int main(void)
{
    Delay_Init();// 延时初始化
    OLED_Init();// OLED_SPI初始化

    OLED_ZFC(0, 0, "DRAGON", Font_Size_F6X8); // 在OLED屏幕的X轴为0,Y轴为0,显示6*8大小的字符串“DRAGON”

    OLED_ZFC(21, 3, "Hello 2022,I Love You!!!!!!!!!", Font_Size_F8x16); // 在OLED屏幕的X轴为21,Y轴为3,显示8*16大小的字符串“Hello 2022,I Love You!!!!!!!!!”,不够显示自动换行

    OLED_ZFC(4, 7, "2022", Font_Size_F6X8); // 在OLED屏幕的X轴为4,Y轴为7,显示6*8大小的字符串“2022”

    Delay_s(1); // 延时一秒
    
    OLED_Clear(0); // 清屏
    
    for (uint16_t i = 0; i < 0xFFFF; i++) // OLED屏幕显示6*8大小的高速自增的数
    {
        sprintf(OLED_zfc, "%d", i);
        OLED_ZFC(0, 0, OLED_zfc, Font_Size_F6X8);
    }

    OLED_Clear(0); // 清屏

    for (uint8_t i = 0; i < 5; i++) // OLED显示自动变大变小的空心圆
    {
        for (uint8_t i = 1; i < 30; i++)
        {
            OLED_DrawCircle(64, 32, i);
            Delay_ms(10);
            OLED_ClearCircle(64, 32, i);
        }
        for (uint8_t i = 30; i > 1; i--)
        {
            OLED_DrawCircle(64, 32, i);
            Delay_ms(10);
            OLED_ClearCircle(64, 32, i);
        }
    }

    OLED_Clear(0); // 清屏

    for (uint8_t i = 0; i < 5; i++) // OLED显示上下移动的斜线
    {
        for (uint8_t i = 0; i < 50; i++)
        {
            OLED_DrawLine(15, i, 80, i + 8);
            Delay_ms(10);
            OLED_ClearLine(15, i, 80, i + 8);
        }
        for (uint8_t i = 50; i > 0; i--)
        {
            OLED_DrawLine(15, i + 10, 80, i);
            Delay_ms(10);
            OLED_ClearLine(15, i + 10, 80, i);
        }
    }

    OLED_Clear(0); // 清屏

    OLED_Long_HZ(0, 0, 1, 0, 1); // OLED显示汉字“星宸”
    
    Delay_s(1); // 延时一秒
    
    OLED_Clear(0); // 清屏

    OLED_ShowPicture(0, 0, 128, 8, 1); // OLED显示图片
    
    Delay_s(1); // 延时一秒
    
    OLED_Clear(0); // 清屏
}

运行效果

STM32_OLED_TEXT

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星宸-Darla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值