STM32+OLED显示屏制作指针式电子钟

一、硬件环境介绍

单片机:  STM32F103C8T6

RTC时钟来源:  使用STM32内部RTC定时器得到时间。

显示屏:中景园0.96寸 SPI接口的OLED显示屏

编程软件:keil5

二、实现效果图与代码技术部分介绍

2.1 实现的效果图

STM32+OLED显示屏制作指针式电子钟_第1张图片

STM32+OLED显示屏制作指针式电子钟_第2张图片

2.2 代码技术部分介绍

核心代码内容里分为以下几个部分:

1. RTC时钟代码部分:该电子钟使用的是STM32内部RTC实时时钟,需要编写RTC初始化代码。

2. 电子钟界面逻辑代码部分:电子钟的界面仪表盘画面更新是在RTC秒中断里调用,实现时间指针的更新。

3. OLED驱动代码部分:编写OLED驱动代码,编写常用的OLED接口函数,比如:字符串显示,画点,划线等。

OLED在程序的驱动方式采用显存的方式驱动,定义一个显存数组,程序里的所有逻辑代码先绘制在显存数组里,然后再刷新到OLED显示屏上。

 

三、核心代码

 3.1 OLED显示屏驱动代码

(1).  oled.c

#include "oled.h"
/*
函数功能: 初始化OLED显示屏硬件
硬件连接:
D0--PB14--时钟线
D1--PB13--数据线
RES-PB12-复位脚
DC--PB1--命令数据选择脚
CS--PA7--片选
*/
void OLED_Init(void)
{
    /*1. 开时钟*/
    RCC->APB2ENR|=1<<2; //PA
    RCC->APB2ENR|=1<<3; //PB
    /*2. 配置GPIO口模式*/
    GPIOB->CRL&=0xFFFFFF0F;
    GPIOB->CRL|=0x00000030;
    GPIOB->CRH&=0xF000FFFF;
    GPIOB->CRH|=0x03330000;
    GPIOA->CRL&=0x0FFFFFFF;
    GPIOA->CRL|=0x30000000;
    /*配置默认电平*/
    OLED_CS=1;
    OLED_SCK=1;
    
    /*OLED显示屏驱动代码*/
    OLED_RES=1;
    delay_ms(1000);
    OLED_RES=0;
    delay_ms(1000);
    OLED_RES=1;
    delay_ms(1000);
    OLED_SPI_WriteOneByte(0xAE,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0x00,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0x10,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0x40,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xB0,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0x81,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0xCF,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xA1,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xA6,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xA8,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0x3F,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xC8,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xD3,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0x00,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xD5,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0x80,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xD9,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0xF1,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xDA,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0x12,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xDB,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0x30,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0x8D,OLED_WRITE_CMD);
    OLED_SPI_WriteOneByte(0x14,OLED_WRITE_CMD);
    
    OLED_SPI_WriteOneByte(0xAF,OLED_WRITE_CMD);
}

/*
函数功能: SPI底层发送一个字节的函数
函数参数:data 表示发送的数据  flag表示发送命令还是数据(0表示命令 1表示数据)
*/
void OLED_SPI_WriteOneByte(u8 data,u8 flag)
{
    u8 i;
    OLED_DC=flag; //区分发送数据还是命令
    OLED_CS=0;  //选中OLED显示屏
    for(i=0;i<8;i++)
    {
        OLED_SCK=0; //表示发送数据
        if(data&0x80) //先发高位
        {
            OLED_MOSI=1;
        }
        else 
        {
            OLED_MOSI=0;
        }
        data<<=1;
        OLED_SCK=1; //表示发送完毕
    }
    OLED_CS=1;  //取消选中OLED显示屏
}

/*
函数功能: OLED清屏函数
函数参数: data=0xFF 表示全亮   data=0x00 表示全灭
*/
void OLED_Clear(u8 data)
{
    memset(OLED_GRAM,data,sizeof(OLED_GRAM));
}

/*
函数功能: 设置光标的位置
函数参数:
u8 x 横向坐标--列地址(0~127)
u8 y 纵坐标--页地址(0~7)
*/
void OLED_SetPos(u8 x,u8 y)
{
    OLED_SPI_WriteOneByte(0xB0+y,OLED_WRITE_CMD); //设置页地址
    OLED_SPI_WriteOneByte(((x&0xF0)>>4)|0x10,OLED_WRITE_CMD); //设置上列地址
    OLED_SPI_WriteOneByte((x&0x0F)|0x00,OLED_WRITE_CMD); //设置下列地址
}

/*
函数功能: 显示数据---取模
取模方式:横向取模
*/
void OLED_DisplayData(u8 x,u8 y,u8 w,u8 h,u8 *p)
{
    u8 i,j,data;
    u8 x0=x;
    for(i=0;i8页128列

/*
函数功能: 画点函数
函数参数:
u8 x 横坐标 0~127
u8 y 纵坐标 0~63
u8 c 显示值(0灭  1亮)
*/
void OLED_DisplayPoint(u8 x,u8 y,u8 c)
{
    u8 page=y/8;//0~7
    y=y%8;
    if(c)
    {
       OLED_GRAM[page][x]|=1<0)incx=1; //设置单步方向 
	else if(delta_x==0)incx=0;//垂直线 
	else {incx=-1;delta_x=-delta_x;} 
	if(delta_y>0)incy=1; 
	else if(delta_y==0)incy=0;//水平线 
	else{incy=-1;delta_y=-delta_y;} 
	if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 
	else distance=delta_y; 
	for(t=0;t<=distance+1;t++ )//画线输出 
	{  
		OLED_DisplayPoint(uRow,uCol,1);//画点 
		xerr+=delta_x ; 
		yerr+=delta_y ; 
		if(xerr>distance) 
		{ 
			xerr-=distance; 
			uRow+=incx; 
		} 
		if(yerr>distance) 
		{ 
			yerr-=distance; 
			uCol+=incy; 
		} 
	}  
}  

/*
函数功能:任意角度画直线 
参    数:
	x,y:坐标
	du :度数
	len:半径
	w  :线段的长度
	c  :颜色值 0或者1
例如:OLED_DrawAngleLine(60,30,45,20,20,1);//角度画线
*/
#include 
void OLED_DrawAngleLine(u32 x,u32 y,float du,u32 len,u32 w,u8 c)
{
	int i;
	int x0,y0;
	double k=du*(3.1415926535/180);	
	for(i=len-w;i=127) //判断横坐标有没有溢出
			{
					y0+=h;
					y=y0;
					x=x0; //如果填0,就是从新行0开始
			}
	 }
	 OLED_WriteGRAM(); //将显存里的数据刷新到OLED显示屏
}







//取模16*16的中文字体   横向取模、高位在前
const u8 ChineseFont_16_16[][32]=
{ 
{0x00,0x00,0x00,0x00,0xFF,0xFE,0x04,0x00,0x04,0x00,0x04,0x00,0x07,0xF0,0x04,0x10,0x04,0x10,0x08,0x10,0x08,0x10,0x10,0x10,0x10,0x10,0x20,0x10,0x40,0xA0,0x80,0x40},/*"万",0*/

{0x08,0x00,0x08,0x7C,0x08,0x44,0xFF,0x48,0x08,0x48,0x08,0x50,0x7E,0x48,0x08,0x48,0x08,0x44,0xFF,0x44,0x08,0x44,0x10,0x68,0x10,0x50,0x20,0x40,0x40,0x40,0x80,0x40},/*"邦",1*/

{0x0F,0xF0,0x08,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10,0x0F,0xF0,0x04,0x00,0x08,0x00,0x1F,0xFC,0x22,0x44,0x42,0x44,0x04,0x84,0x08,0x84,0x11,0x28,0x02,0x10},/*"易",2*/

{0x01,0x00,0x21,0x08,0x21,0x08,0x3F,0xF8,0x00,0x20,0x22,0x20,0x22,0x3E,0xFF,0x42,0x22,0x94,0x22,0x10,0x3E,0x10,0x22,0x10,0x22,0x28,0x3E,0x28,0x22,0x44,0x00,0x82},/*"嵌",3*/

{0x10,0x00,0x10,0x00,0x1F,0xFC,0x20,0x80,0x20,0x80,0x40,0x80,0x1F,0xF8,0x10,0x80,0x10,0x80,0x10,0x80,0xFF,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80},/*"年",0*/

{0x00,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x01,0x00,0x11,0x00,0x1F,0xF8,0x21,0x00,0x41,0x00,0x1F,0xF0,0x01,0x00,0x01,0x00,0x7F,0xFC,0x00,0x00},/*"星",0*/

{0x22,0x00,0x22,0x7C,0x7F,0x44,0x22,0x44,0x22,0x44,0x3E,0x7C,0x22,0x44,0x22,0x44,0x3E,0x44,0x22,0x7C,0x22,0x44,0xFF,0x44,0x04,0x84,0x22,0x84,0x41,0x14,0x82,0x08},/*"期",1*/

{0x00,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10},/*"日",6*/
		
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"一",0*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00},/*"二",1*/

{0x00,0x00,0x00,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00},/*"三",2*/

{0x00,0x00,0x00,0x00,0x7F,0xFC,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x48,0x44,0x48,0x3C,0x50,0x04,0x60,0x04,0x40,0x04,0x7F,0xFC,0x40,0x04,0x00,0x00},/*"四",3*/

{0x00,0x00,0x7F,0xFC,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x3F,0xF0,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0xFF,0xFE,0x00,0x00},/*"五",4*/

{0x02,0x00,0x01,0x00,0x00,0x80,0x00,0x80,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x04,0x40,0x04,0x20,0x08,0x10,0x08,0x08,0x10,0x08,0x20,0x04,0x40,0x04,0x00,0x00},/*"六",5*/


};


//取模24*24的中文字体   横向取模、高位在前
const u8 ChineseFont_24_24[][24*24/8]=
{
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x3F,0xFF,0xFC,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x7F,0xF0,0x00,0x60,0x30,0x00,0x40,0x30,0x00,0xC0,0x30,0x00,0xC0,0x30,0x00,0x80,0x20,0x01,0x80,0x20,0x01,0x00,0x20,0x03,0x00,0x20,0x02,0x00,0x60,0x04,0x00,0x60,0x08,0x07,0xE0,0x10,0x01,0xC0,0x20,0x01,0x00,0x00,0x00,0x00},/*"万",0*/

{0x00,0x00,0x00,0x01,0x00,0x00,0x01,0x02,0x00,0x01,0x03,0xFC,0x01,0x03,0x0C,0x3F,0xFF,0x08,0x01,0x03,0x08,0x01,0x03,0x10,0x01,0x13,0x10,0x3F,0xFB,0x20,0x01,0x03,0x20,0x01,0x03,0x20,0x01,0x03,0x10,0x01,0x03,0x08,0x7F,0xFF,0x0C,0x03,0x03,0x04,0x03,0x03,0x04,0x02,0x03,0x0C,0x06,0x03,0x3C,0x04,0x03,0x10,0x08,0x03,0x00,0x30,0x03,0x00,0x40,0x02,0x00,0x00,0x00,0x00},/*"邦",1*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xC0,0x03,0x00,0x40,0x03,0x00,0x40,0x03,0x00,0x40,0x03,0xFF,0xC0,0x03,0x00,0x40,0x03,0x00,0x40,0x03,0xFF,0xC0,0x03,0xC0,0x40,0x01,0x80,0x00,0x01,0xFF,0xF8,0x03,0x31,0x18,0x04,0x23,0x10,0x08,0x62,0x10,0x10,0xC6,0x10,0x01,0x84,0x10,0x02,0x0C,0x30,0x0C,0x18,0x20,0x00,0x62,0x20,0x01,0x81,0xE0,0x06,0x00,0x80,0x00,0x00,0x00},/*"易",2*/

{0x00,0x00,0x00,0x00,0x18,0x00,0x0C,0x10,0x30,0x08,0x10,0x30,0x08,0x10,0x30,0x0F,0xFF,0xF0,0x08,0x00,0x30,0x08,0x41,0x00,0x0C,0x61,0x00,0x08,0x43,0x00,0x7F,0xFB,0xFC,0x08,0x42,0x08,0x08,0x44,0x90,0x08,0x49,0x90,0x0F,0xC9,0x80,0x08,0x41,0x40,0x08,0x41,0x40,0x08,0x41,0x40,0x08,0x42,0x20,0x0F,0xC6,0x30,0x08,0x4C,0x18,0x08,0x50,0x0E,0x00,0x20,0x00,0x00,0x00,0x00},/*"嵌",3*/


};

/*
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
*/

// ASCII编码8*16英文字符  纵向取模、高位在前
const u8 ASCII_8_16[][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,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/

{0x00,0x00,0x08,0x00,0x30,0x00,0x40,0x00,0x08,0x00,0x30,0x00,0x40,0x00,0x00,0x00},/*""",2*/

{0x00,0x00,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x00,0x00},/*"#",3*/

{0x00,0x00,0x0E,0x18,0x11,0x04,0x11,0x04,0x3F,0xFF,0x10,0x84,0x0C,0x78,0x00,0x00},/*"$",4*/

{0x0F,0x00,0x10,0x8C,0x0F,0x30,0x01,0xC0,0x06,0x78,0x18,0x84,0x00,0x78,0x00,0x00},/*"%",5*/

{0x00,0x78,0x0F,0x84,0x10,0xC4,0x11,0x34,0x0E,0x98,0x00,0xE4,0x00,0x84,0x00,0x08},/*"&",6*/

{0x00,0x00,0x48,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,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x07,0xF0,0x00,0x80,0x00,0x80,0x00,0x80},/*"+",11*/

{0x00,0x00,0x00,0x09,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,0x00},/*"-",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,0xE0,0x03,0x00,0x1C,0x00,0x20,0x00,0x00,0x00},/*"/",15*/

{0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0",16*/

{0x00,0x00,0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00},/*"1",17*/

{0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x10,0x84,0x0F,0x0C,0x00,0x00},/*"2",18*/

{0x00,0x00,0x0C,0x18,0x10,0x04,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"3",19*/

{0x00,0x00,0x00,0x60,0x01,0xA0,0x02,0x24,0x0C,0x24,0x1F,0xFC,0x00,0x24,0x00,0x24},/*"4",20*/

{0x00,0x00,0x1F,0x98,0x11,0x04,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5",21*/

{0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x09,0x04,0x00,0xF8,0x00,0x00},/*"6",22*/

{0x00,0x00,0x18,0x00,0x10,0x00,0x10,0x7C,0x11,0x80,0x16,0x00,0x18,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,0x0F,0x80,0x10,0x48,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,0x00,0x01,0x07,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*/

{0x00,0x00,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,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,0xEC,0x11,0x00,0x0E,0x00,0x00,0x00},/*"?",31*/

{0x03,0xE0,0x0C,0x18,0x13,0xE4,0x14,0x14,0x17,0xF4,0x08,0x14,0x07,0xE8,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,0x80,0x00,0x7C,0x1F,0x80,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,0x08,0x10,0x14,0x10,0x14,0x10,0x0C,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*/

{0x10,0x00,0x1F,0xC0,0x00,0x7C,0x1F,0x80,0x00,0x7C,0x1F,0xC0,0x10,0x00,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,0x20,0x00,0x1C,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,0x20,0x00,0x00,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,0x24,0x01,0x48,0x00,0xFC,0x00,0x04,0x00,0x00},/*"a",65*/

{0x08,0x00,0x0F,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,0xF8,0x01,0x04,0x01,0x04,0x01,0x04,0x09,0x08,0x0F,0xFC,0x00,0x04},/*"d",68*/

{0x00,0x00,0x00,0xF8,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x00,0xE8,0x00,0x00},/*"e",69*/

{0x00,0x00,0x01,0x04,0x01,0x04,0x07,0xFC,0x09,0x04,0x09,0x04,0x04,0x00,0x00,0x00},/*"f",70*/

{0x00,0x00,0x00,0xD6,0x01,0x29,0x01,0x29,0x01,0x29,0x01,0xC9,0x01,0x06,0x00,0x00},/*"g",71*/

{0x08,0x04,0x0F,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*/

{0x08,0x04,0x0F,0xFC,0x00,0x24,0x00,0x60,0x01,0x94,0x01,0x0C,0x01,0x04,0x00,0x00},/*"k",75*/

{0x00,0x00,0x08,0x04,0x08,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,0x89,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"p",80*/

{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x00,0x89,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,0x08,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,0xC0,0x01,0x30,0x00,0x0C,0x01,0x30,0x01,0xC0,0x01,0x00,0x00,0x00},/*"v",86*/

{0x01,0x80,0x01,0x70,0x00,0x0C,0x01,0x30,0x01,0xE0,0x00,0x1C,0x01,0x60,0x01,0x80},/*"w",87*/

{0x00,0x00,0x01,0x04,0x01,0x8C,0x01,0x70,0x00,0x74,0x01,0x8C,0x01,0x04,0x00,0x00},/*"x",88*/

{0x01,0x00,0x01,0x81,0x01,0x61,0x00,0x1E,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,0x00,0x80,0x3F,0x7C,0x40,0x02,0x40,0x02},/*"{",91*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/

{0x40,0x02,0x40,0x02,0x3F,0x7C,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/

{0x00,0x00,0x40,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x40,0x00,0x00,0x00},/*"~",94*/
};


//跑步图片1
const u8 bmp_foot_18_29_1[]=
{
	// E:\教学&项目开发\教学\Cortex-M3 教学\STM32项目开发资料\05 OLED显示屏资料\软件工具\OLED屏幕_图片素材\取膜图片\OnFoot_2_1.bmp(0)
	0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xE0,0xF2,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x06,0x7F,0xFF,0xFF,0xFF,0xFF,0x06,
	0x00,0x00,0x00,0x00,0xF0,0x70,0x60,0x30,0x30,0x30,0x30,0x30,0x3E,0x3F,0x1F,0x07,0xFF,0xFE,0xF8,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x1B,0x1F,0x1C,0x10,0x10
};


//跑步图片2
const u8 bmp_foot_17_32_2[]=
{
	0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xF0,0xFF,0xFF,0xEF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x0C,0x0C,0x0C,0x0C,
	0x0E,0x0C,0x00,0x00,0x00,0x00,0x80,0xFF,0xFF,0xFF,0xDF,0xDF,0xFE,0x7C,0x78,0x20,0x00,0x00,0x00,0x60,0xF0,0xFC,0x9E,0x87,0x1F,0x1F,0x01,0x01,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00
};


/*
尺寸: 12*24 ,纵向取模、高位在前
*/
const u8 ASCII_12_24[][12*3]=
{
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xEE,0x38,0x0F,0xF0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x06,0x00,0x00,0x0C,0x00,0x00,0x38,0x00,0x00,0x31,0x00,0x00,0x06,0x00,0x00,0x0C,0x00,0x00,0x38,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00},/*""",2*/

{0x00,0x00,0x00,0x00,0xC1,0x80,0x00,0xC1,0xF8,0x00,0xFF,0x80,0x0F,0xC1,0x80,0x00,0xC1,0x80,0x00,0xC1,0x80,0x00,0xC1,0x80,0x00,0xDF,0xF8,0x0F,0xE1,0x80,0x00,0xC1,0x80,0x00,0x00,0x00},/*"#",3*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0xE0,0x03,0xE0,0xF0,0x06,0x30,0x48,0x04,0x18,0x08,0x1F,0xFF,0xFE,0x04,0x8E,0x08,0x07,0x87,0xF0,0x03,0x81,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*"$",4*/

{0x03,0xE0,0x00,0x0C,0x18,0x00,0x08,0x08,0x18,0x0C,0x18,0xE0,0x03,0xF3,0x00,0x00,0x1C,0x00,0x00,0x63,0xE0,0x03,0x8C,0x18,0x0C,0x08,0x08,0x00,0x0C,0x18,0x00,0x03,0xE0,0x00,0x00,0x00},/*"%",5*/

{0x00,0x03,0xE0,0x00,0x07,0xF0,0x07,0xE8,0x18,0x0F,0xFC,0x08,0x08,0x1F,0x08,0x0F,0xE3,0xC8,0x07,0xC0,0xF0,0x00,0x10,0x70,0x00,0x1F,0x98,0x00,0x10,0x08,0x00,0x10,0x08,0x00,0x00,0x30},/*"&",6*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x00,0x32,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x01,0x80,0xC0,0x06,0x00,0x30,0x08,0x00,0x08,0x10,0x00,0x04,0x20,0x00,0x02,0x00,0x00,0x00},/*"(",8*/

{0x00,0x00,0x00,0x20,0x00,0x02,0x10,0x00,0x04,0x08,0x00,0x08,0x06,0x00,0x30,0x01,0x80,0xC0,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*")",9*/

{0x00,0x00,0x00,0x00,0x66,0x00,0x00,0x66,0x00,0x00,0x24,0x00,0x00,0x1C,0x00,0x00,0x08,0x00,0x03,0xFF,0xC0,0x01,0x18,0x00,0x00,0x3C,0x00,0x00,0x24,0x00,0x00,0x66,0x00,0x00,0x66,0x00},/*"*",10*/

{0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x01,0xFF,0xC0,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00},/*"+",11*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x00,0x32,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/

{0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00},/*"-",13*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/

{0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x1C,0x00,0x00,0x70,0x00,0x01,0x80,0x00,0x0E,0x00,0x00,0x38,0x00,0x00,0xC0,0x00,0x07,0x00,0x00,0x1C,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00},/*"/",15*/

{0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x18,0x04,0x00,0x08,0x04,0x00,0x08,0x06,0x00,0x18,0x03,0x80,0x70,0x01,0xFF,0xE0,0x00,0x7F,0x80,0x00,0x00,0x00},/*"0",16*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x08,0x02,0x00,0x08,0x02,0x00,0x08,0x03,0xFF,0xF8,0x07,0xFF,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",17*/

{0x00,0x00,0x00,0x01,0xC0,0x18,0x02,0xC0,0x38,0x04,0x00,0x48,0x04,0x00,0x88,0x04,0x03,0x08,0x04,0x06,0x08,0x06,0x0C,0x08,0x03,0xF8,0x08,0x01,0xE0,0x78,0x00,0x00,0x00,0x00,0x00,0x00},/*"2",18*/

{0x00,0x00,0x00,0x03,0x80,0x70,0x03,0x80,0x70,0x04,0x00,0x08,0x04,0x08,0x08,0x04,0x08,0x08,0x06,0x18,0x08,0x03,0xF4,0x18,0x01,0xE7,0xF0,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*"3",19*/

{0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x05,0x00,0x00,0x19,0x00,0x00,0x21,0x00,0x00,0xC1,0x08,0x01,0x01,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x00,0x01,0x08,0x00,0x01,0x08,0x00,0x01,0x00},/*"4",20*/

{0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xFC,0xD0,0x04,0x08,0x08,0x04,0x10,0x08,0x04,0x10,0x08,0x04,0x10,0x08,0x04,0x18,0x38,0x04,0x0F,0xF0,0x04,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00},/*"5",21*/

{0x00,0x00,0x00,0x00,0x3F,0x80,0x01,0xFF,0xE0,0x03,0x84,0x30,0x02,0x08,0x18,0x04,0x10,0x08,0x04,0x10,0x08,0x04,0x10,0x08,0x07,0x18,0x10,0x03,0x0F,0xF0,0x00,0x07,0xC0,0x00,0x00,0x00},/*"6",22*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0xF8,0x04,0x07,0xF8,0x04,0x18,0x00,0x04,0xE0,0x00,0x07,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00},/*"7",23*/

{0x00,0x00,0x00,0x01,0xC1,0xE0,0x03,0xF3,0xF0,0x06,0x36,0x10,0x04,0x18,0x08,0x04,0x08,0x08,0x04,0x0C,0x08,0x04,0x0C,0x08,0x06,0x16,0x18,0x03,0xF3,0xF0,0x01,0xC1,0xE0,0x00,0x00,0x00},/*"8",24*/

{0x00,0x00,0x00,0x00,0xF8,0x00,0x03,0xFC,0x30,0x03,0x06,0x38,0x04,0x02,0x08,0x04,0x02,0x08,0x04,0x02,0x08,0x04,0x04,0x10,0x03,0x08,0xF0,0x01,0xFF,0xC0,0x00,0x7F,0x00,0x00,0x00,0x00},/*"9",25*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x00,0x38,0x38,0x00,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1B,0x00,0x30,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x14,0x00,0x00,0x22,0x00,0x00,0x41,0x00,0x00,0x80,0x80,0x01,0x00,0x40,0x02,0x00,0x20,0x04,0x00,0x10,0x08,0x00,0x08,0x00,0x00,0x00},/*"<",28*/

{0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x22,0x00,0x00,0x00,0x00},/*"=",29*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x04,0x00,0x10,0x02,0x00,0x20,0x01,0x00,0x40,0x00,0x80,0x80,0x00,0x41,0x00,0x00,0x22,0x00,0x00,0x14,0x00,0x00,0x08,0x00,0x00,0x00,0x00},/*">",30*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x02,0x60,0x00,0x02,0x00,0x00,0x04,0x00,0x38,0x04,0x07,0x38,0x04,0x08,0x38,0x04,0x18,0x00,0x06,0x10,0x00,0x03,0xF0,0x00,0x01,0xE0,0x00},/*"?",31*/

{0x00,0x00,0x00,0x00,0x7F,0x00,0x03,0xFF,0xE0,0x07,0x00,0x70,0x04,0x1F,0x18,0x08,0xFF,0x88,0x09,0xC0,0x88,0x09,0x3F,0x88,0x05,0xE0,0x90,0x06,0x01,0x30,0x01,0xFE,0x40,0x00,0x00,0x00},/*"@",32*/

{0x00,0x00,0x08,0x00,0x00,0x38,0x00,0x01,0xC8,0x00,0x1E,0x08,0x01,0xE2,0x00,0x06,0x02,0x00,0x07,0x82,0x00,0x00,0xFA,0x00,0x00,0x0F,0x88,0x00,0x01,0xF8,0x00,0x00,0x18,0x00,0x00,0x08},/*"A",33*/

{0x00,0x00,0x00,0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x08,0x06,0x18,0x08,0x03,0xF4,0x18,0x03,0xE7,0xF0,0x00,0x01,0xE0,0x00,0x00,0x00},/*"B",34*/

{0x00,0x00,0x00,0x00,0x3F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x02,0x00,0x18,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x06,0x00,0x10,0x07,0x00,0x30,0x01,0xC0,0xC0,0x00,0x00,0x00},/*"C",35*/

{0x04,0x00,0x08,0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x02,0x00,0x10,0x03,0x80,0x70,0x01,0xFF,0xE0,0x00,0x7F,0x80,0x00,0x00,0x00},/*"D",36*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x3F,0x08,0x06,0x00,0x08,0x06,0x00,0x18,0x01,0x80,0x60,0x00,0x00,0x00},/*"E",37*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x08,0x04,0x08,0x00,0x04,0x08,0x00,0x04,0x3F,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00},/*"F",38*/

{0x00,0x00,0x00,0x00,0x3F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x18,0x04,0x00,0x08,0x04,0x02,0x08,0x04,0x02,0x08,0x02,0x03,0xF0,0x01,0xC3,0xF0,0x00,0x02,0x00,0x00,0x02,0x00},/*"G",39*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x04,0x08,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08},/*"H",40*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00},/*"I",41*/

{0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x07,0x04,0x00,0x01,0x04,0x00,0x01,0x04,0x00,0x03,0x07,0xFF,0xFE,0x07,0xFF,0xFC,0x04,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00},/*"J",42*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x0C,0x08,0x00,0x30,0x00,0x00,0x5C,0x00,0x05,0x87,0x00,0x07,0x01,0xC8,0x06,0x00,0x78,0x04,0x00,0x18,0x00,0x00,0x08,0x00,0x00,0x00},/*"K",43*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,0x04,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x18,0x00,0x00,0x60,0x00,0x00,0x00},/*"L",44*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xF0,0x08,0x00,0xFF,0x00,0x00,0x07,0xF0,0x00,0x01,0xE0,0x00,0x3E,0x00,0x03,0xC0,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,0x00,0x00,0x00},/*"M",45*/

{0x00,0x00,0x08,0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0x80,0x08,0x01,0xE0,0x08,0x00,0x78,0x00,0x00,0x1E,0x00,0x04,0x03,0xC0,0x04,0x00,0xF0,0x07,0xFF,0xF8,0x04,0x00,0x00,0x04,0x00,0x00},/*"N",46*/

{0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x18,0x04,0x00,0x08,0x04,0x00,0x08,0x06,0x00,0x18,0x03,0x00,0x30,0x01,0xFF,0xE0,0x00,0x7F,0x80,0x00,0x00,0x00},/*"O",47*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x04,0x08,0x04,0x04,0x08,0x04,0x04,0x00,0x04,0x04,0x00,0x04,0x0C,0x00,0x02,0x08,0x00,0x03,0xF8,0x00,0x01,0xF0,0x00,0x00,0x00,0x00},/*"P",48*/

{0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0xFF,0xE0,0x03,0x80,0x70,0x06,0x00,0x98,0x04,0x00,0x88,0x04,0x00,0xE8,0x06,0x00,0x3C,0x03,0x00,0x36,0x01,0xFF,0xE6,0x00,0x7F,0x84,0x00,0x00,0x00},/*"Q",49*/

{0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x08,0x08,0x04,0x08,0x00,0x04,0x08,0x00,0x04,0x0E,0x00,0x04,0x0B,0x80,0x06,0x10,0xE0,0x03,0xF0,0x78,0x01,0xE0,0x18,0x00,0x00,0x08},/*"R",50*/

{0x00,0x00,0x00,0x01,0xE0,0xE0,0x03,0xF0,0x30,0x06,0x38,0x10,0x04,0x18,0x08,0x04,0x1C,0x08,0x04,0x0C,0x08,0x04,0x0E,0x08,0x02,0x07,0x18,0x07,0x87,0xF0,0x00,0x01,0xE0,0x00,0x00,0x00},/*"S",51*/

{0x01,0x80,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x08,0x04,0x00,0x08,0x07,0xFF,0xF8,0x07,0xFF,0xF8,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x00,0x06,0x00,0x00,0x01,0x80,0x00},/*"T",52*/

{0x00,0x00,0x00,0x04,0x00,0x00,0x07,0xFF,0xE0,0x07,0xFF,0xF0,0x04,0x00,0x18,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x04,0x00,0x10,0x07,0xFF,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"U",53*/

{0x04,0x00,0x00,0x06,0x00,0x00,0x07,0xE0,0x00,0x04,0x7E,0x00,0x00,0x07,0xE0,0x00,0x00,0x78,0x00,0x01,0xC0,0x00,0x1E,0x00,0x05,0xE0,0x00,0x06,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00},/*"V",54*/

{0x04,0x00,0x00,0x07,0xC0,0x00,0x04,0xFF,0x00,0x00,0x03,0xF8,0x04,0x03,0xC0,0x06,0x3C,0x00,0x07,0xFC,0x00,0x04,0x0F,0xF8,0x00,0x01,0xE0,0x04,0x3E,0x00,0x07,0xC0,0x00,0x04,0x00,0x00},/*"W",55*/

{0x00,0x00,0x00,0x04,0x00,0x08,0x06,0x00,0x18,0x07,0x80,0x68,0x04,0xE1,0x80,0x00,0x3E,0x00,0x00,0x17,0x00,0x04,0x61,0xC8,0x07,0x80,0x78,0x04,0x00,0x18,0x04,0x00,0x08,0x00,0x00,0x00},/*"X",56*/

{0x04,0x00,0x00,0x06,0x00,0x00,0x07,0x80,0x00,0x04,0xF0,0x08,0x00,0x3C,0x08,0x00,0x1F,0xF8,0x00,0x07,0xF8,0x00,0x18,0x08,0x04,0x60,0x08,0x05,0x80,0x00,0x06,0x00,0x00,0x04,0x00,0x00},/*"Y",57*/

{0x00,0x00,0x00,0x01,0x80,0x08,0x07,0x00,0x38,0x06,0x00,0xE8,0x04,0x01,0x88,0x04,0x06,0x08,0x04,0x18,0x08,0x04,0x60,0x08,0x05,0xC0,0x08,0x07,0x00,0x18,0x04,0x00,0x60,0x00,0x00,0x00},/*"Z",58*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFE,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00},/*"[",59*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x03,0x00,0x00,0x00,0xE0,0x00,0x00,0x18,0x00,0x00,0x07,0x00,0x00,0x01,0xC0,0x00,0x00,0x30,0x00,0x00,0x0E,0x00,0x00,0x01,0x00,0x00,0x00},/*"\",60*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x20,0x00,0x02,0x3F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"]",61*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x20,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x20,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"^",62*/

{0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01},/*"_",63*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/

{0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x19,0xF8,0x00,0x19,0x98,0x00,0x21,0x08,0x00,0x22,0x08,0x00,0x22,0x08,0x00,0x22,0x10,0x00,0x3F,0xF0,0x00,0x1F,0xF8,0x00,0x00,0x08,0x00,0x00,0x18},/*"a",65*/

{0x00,0x00,0x00,0x04,0x00,0x00,0x07,0xFF,0xF8,0x0F,0xFF,0xF0,0x00,0x18,0x10,0x00,0x10,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x30,0x18,0x00,0x1F,0xF0,0x00,0x0F,0xC0,0x00,0x00,0x00},/*"b",66*/

{0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x18,0x30,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x3C,0x08,0x00,0x1C,0x10,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00},/*"c",67*/

{0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x38,0x18,0x00,0x20,0x08,0x00,0x20,0x08,0x04,0x20,0x08,0x04,0x10,0x10,0x07,0xFF,0xF8,0x0F,0xFF,0xF0,0x00,0x00,0x10,0x00,0x00,0x00},/*"d",68*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x11,0x30,0x00,0x21,0x08,0x00,0x21,0x08,0x00,0x21,0x08,0x00,0x31,0x08,0x00,0x1F,0x10,0x00,0x07,0x20,0x00,0x00,0x00},/*"e",69*/

{0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x08,0x00,0x20,0x08,0x01,0xFF,0xF8,0x03,0xFF,0xF8,0x06,0x20,0x08,0x04,0x20,0x08,0x04,0x20,0x08,0x07,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00},/*"f",70*/

{0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x0E,0x7E,0x00,0x1F,0xF3,0x00,0x31,0xA1,0x00,0x20,0xA1,0x00,0x30,0xB1,0x00,0x3F,0xB3,0x00,0x2F,0x1E,0x00,0x30,0x1E,0x00,0x30,0x00,0x00,0x00,0x00},/*"g",71*/

{0x00,0x00,0x00,0x04,0x00,0x08,0x07,0xFF,0xF8,0x0F,0xFF,0xF8,0x00,0x10,0x08,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x1F,0xF8,0x00,0x00,0x08,0x00,0x00,0x00},/*"h",72*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x06,0x3F,0xF8,0x06,0x7F,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00},/*"i",73*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x20,0x01,0x00,0x20,0x01,0x06,0x20,0x03,0x06,0x3F,0xFE,0x06,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"j",74*/

{0x00,0x00,0x00,0x04,0x00,0x08,0x07,0xFF,0xF8,0x0F,0xFF,0xF8,0x00,0x01,0x08,0x00,0x02,0x00,0x00,0x07,0x00,0x00,0x38,0xC8,0x00,0x20,0x78,0x00,0x20,0x18,0x00,0x00,0x08,0x00,0x00,0x00},/*"k",75*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x08,0x04,0x00,0x08,0x04,0x00,0x08,0x07,0xFF,0xF8,0x0F,0xFF,0xF8,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00},/*"l",76*/

{0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x10,0x08,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x1F,0xF8,0x00,0x10,0x08,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x00,0x08},/*"m",77*/

{0x00,0x00,0x00,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x10,0x08,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x1F,0xF8,0x00,0x00,0x08,0x00,0x00,0x00},/*"n",78*/

{0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x0F,0xF0,0x00,0x18,0x30,0x00,0x30,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x30,0x08,0x00,0x18,0x30,0x00,0x0F,0xF0,0x00,0x07,0xC0,0x00,0x00,0x00},/*"o",79*/

{0x00,0x00,0x00,0x00,0x20,0x01,0x00,0x3F,0xFF,0x00,0x3F,0xFF,0x00,0x10,0x11,0x00,0x20,0x09,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x30,0x38,0x00,0x1F,0xF0,0x00,0x0F,0xC0,0x00,0x00,0x00},/*"p",80*/

{0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x1F,0xF0,0x00,0x38,0x18,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x09,0x00,0x10,0x11,0x00,0x1F,0xFF,0x00,0x3F,0xFF,0x00,0x00,0x01,0x00,0x00,0x00},/*"q",81*/

{0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x3F,0xF8,0x00,0x3F,0xF8,0x00,0x08,0x08,0x00,0x10,0x08,0x00,0x20,0x08,0x00,0x20,0x00,0x00,0x38,0x00,0x00,0x18,0x00,0x00,0x00,0x00},/*"r",82*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x78,0x00,0x1E,0x18,0x00,0x33,0x08,0x00,0x23,0x08,0x00,0x21,0x88,0x00,0x21,0x98,0x00,0x30,0xF8,0x00,0x3C,0xF0,0x00,0x00,0x00,0x00,0x00,0x00},/*"s",83*/

{0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0xFF,0xF0,0x03,0xFF,0xF8,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x20,0x08,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00},/*"t",84*/

{0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x3F,0xF0,0x00,0x7F,0xF8,0x00,0x00,0x18,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x20,0x10,0x00,0x3F,0xF8,0x00,0x7F,0xF0,0x00,0x00,0x10,0x00,0x00,0x00},/*"u",85*/

{0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x30,0x00,0x00,0x3E,0x00,0x00,0x23,0xC0,0x00,0x00,0xF8,0x00,0x00,0x30,0x00,0x01,0xC0,0x00,0x2E,0x00,0x00,0x30,0x00,0x00,0x20,0x00,0x00,0x00,0x00},/*"v",86*/

{0x00,0x20,0x00,0x00,0x38,0x00,0x00,0x2F,0x80,0x00,0x01,0xF8,0x00,0x20,0xF0,0x00,0x37,0x00,0x00,0x3F,0x00,0x00,0x21,0xF0,0x00,0x00,0xF0,0x00,0x27,0x00,0x00,0x38,0x00,0x00,0x20,0x00},/*"w",87*/

{0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x20,0x08,0x00,0x30,0x38,0x00,0x3C,0x48,0x00,0x27,0x80,0x00,0x03,0x80,0x00,0x24,0xC8,0x00,0x38,0x38,0x00,0x20,0x18,0x00,0x20,0x08,0x00,0x00,0x00},/*"x",88*/

{0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x03,0x00,0x3C,0x01,0x00,0x23,0x81,0x00,0x00,0xFE,0x00,0x00,0x70,0x00,0x23,0x80,0x00,0x3C,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x00},/*"y",89*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x18,0x00,0x20,0x78,0x00,0x20,0xC8,0x00,0x23,0x88,0x00,0x2E,0x08,0x00,0x38,0x08,0x00,0x30,0x18,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00},/*"z",90*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x14,0x00,0x1F,0xE3,0xFC,0x20,0x00,0x02,0x20,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00},/*"{",91*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x02,0x20,0x00,0x02,0x1F,0xE3,0xFC,0x00,0x14,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/

{0x00,0x00,0x00,0x30,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x20,0x00,0x00,0x10,0x00,0x00,0x18,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00},/*"~",94*/
};

 (2). oled.h

#ifndef _OLED_H
#define _OLED_H
#include "stm32f10x.h"
#include "delay.h"
#include "sys.h"
#include 

extern const u8 ChineseFont_16_16[][32];
extern const u8 ChineseFont_24_24[][24*24/8];
extern const u8 ASCII_8_16[][16];
extern const u8 bmp_foot_18_29_1[];
extern const u8 bmp_foot_17_32_2[];
extern const u8 ASCII_12_24[][12*3];

/*
初始化OLED显示屏硬件
硬件连接:
D0--PB14--时钟线
D1--PB13--数据线
RES-PB12-复位脚
DC--PB1--命令数据选择脚
CS--PA7--片选
*/
#define OLED_SCK PBout(14)
#define OLED_MOSI PBout(13)
#define OLED_RES PBout(12)
#define OLED_DC PBout(1)
#define OLED_CS PAout(7)

//定义命令
#define OLED_WRITE_CMD 0
#define OLED_WRITE_DAT 1

//函数声明
void OLED_SPI_WriteOneByte(u8 data,u8 flag);
void OLED_Init(void);
void OLED_Clear(u8 data);
void OLED_SetPos(u8 x,u8 y);
void OLED_DisplayPoint(u8 x,u8 y,u8 c);
void OLED_DisplayData(u8 x,u8 y,u8 w,u8 h,u8 *p);
void OLED_WriteGRAM(void);

void OLED_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2); //两点画线
void OLED_DrawAngleLine(u32 x,u32 y,float du,u32 len,u32 w,u8 c);//角度画线
void OLED_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2); //矩形
void OLED_Circle(u16 x0,u16 y0,u8 r); //圆
void OLED_DrawAngleLine2(u32 x,u32 y,int du,u32 len,u8 c);
void OLED_ShowString(u8 x,u8 y,u8 h,char *str);
void OLED_ShowChineseFont(u8 x,u8 y,u8 size,u8 number);

extern u8 OLED_GRAM[8][128]; //8行128列---->8页128列
#endif

3.2 rtc驱动代码

(1) rtc.c

#include "rtc.h"

//定义RTC标准结构体
struct RTC_CLOCK rtc_clock; 

/*
函数功能: RTC初始化函数
*/
void RTC_Init(void)
{
	 if(BKP->DR1!=0xAB) //表示RTC第一次初始化
	 {
			//1. 备份寄存器时钟
			RCC->APB1ENR|=1<<27; //备份时钟接口
			RCC->APB1ENR|=1<<28; //电源时钟接口
			PWR->CR|=1<<8; 			 //允许写入RTC和后备寄存器
		  
		  //2. 配置RTC时钟源
			RCC->BDCR|=1<<0;     //开启外部32.768K时钟
		  while(!(RCC->BDCR&1<<1)){} //等待时钟就绪
			RCC->BDCR&=~(0x3<<8);  //清空时钟配置
			RCC->BDCR|=0x1<<8;     //选择外部32.768K时钟
			
			//3. 配置RTC核心寄存器
			RCC->BDCR|=1<<15;     //开启RTC时钟
      while(!(RTC->CRL&1<<5)){} //判断上一次寄存器是否写完成
			RTC->CRL|=1<<4;  //进入配置模式
			RTC->PRLH=0;      //预分频高位
			RTC->PRLL=0x7FFF; //32767	预分频低位
			RTC->CNTH=0;      //计数器高位
			RTC->CNTL=0;      //计数器低位
			RTC->ALRH=0;      //闹钟寄存器高位
			RTC->ALRL=60;      //闹钟寄存器低位
			RTC->CRL&=~(1<<4);//退出配置模式	
			while(!(RTC->CRL&1<<5)){} //判断上一次寄存器是否写完成
			BKP->DR1=0xAB; 		//表示配置成功了	
		}

		RTC->CRH|=1<<0; //秒中断
		RTC->CRH|=1<<1; //闹钟中断
		STM32_SetPriority(RTC_IRQn,2,2); //优先级
}

extern void Update_FrameShow(void);
/*
函数功能: RTC闹钟中断服务函数
*/
void RTC_IRQHandler(void)
{
	  u32 SecCnt;
		if(RTC->CRL&1<<0)
		{
				SecCnt=RTC->CNTH<<16;//获取高位
				SecCnt|=RTC->CNTL;   //获取低位
				RTC_GetTime(SecCnt); //转换标准时间
				RTC_GetWeek(SecCnt);
			 // printf("%d-%d-%d %d:%d:%d week:%d\n",rtc_clock.year,rtc_clock.mon,rtc_clock.day,rtc_clock.hour,rtc_clock.min,rtc_clock.sec,rtc_clock.week);
				Update_FrameShow(); //更新显示
				RTC->CRL&=~(1<<0); //清除秒中断标志位
		}
		
		if(RTC->CRL&1<<1)
		{
//				printf("闹钟时间到达!....\n");
//			  BEEP=1;
//			  DelayMs(500);
//				BEEP=0;
				RTC->CRL&=~(1<<1); //清除闹钟中断标志位
		}
}



//闰年的月份
static int mon_r[12]={31,29,31,30,31,30,31,31,30,31,30,31};
//平年的月份
static int mon_p[12]={31,28,31,30,31,30,31,31,30,31,30,31};


/*
函数功能: 设置RTC时间
函数形参:
    u32 year;   2018
	  u32 mon;     8
	  u32 day;
		u32 hour;
		u32 min;
	  u32 sec;
*/
void RTC_SetTime(u32 year,u32 mon,u32 day,u32 hour,u32 min,u32 sec)
{
		u32 i;
	  u32 SecCnt=0; //总秒数
		/*1. 累加已经过去的年份*/
		for(i=2017;iAPB1ENR|=1<<27; //备份时钟接口
		RCC->APB1ENR|=1<<28; //电源时钟接口
		PWR->CR|=1<<8; 			 //允许写入RTC和后备寄存器
		while(!(RTC->CRL&1<<5)){} //判断上一次寄存器是否写完成
		RTC->CRL|=1<<4;           //进入配置模式
		RTC->CNTH=SecCnt>>16;     //计数器高位
		RTC->CNTL=SecCnt&0xFFFF;  //计数器低位
		RTC->CRL&=~(1<<4);//退出配置模式	
		while(!(RTC->CRL&1<<5)){} //判断上一次寄存器是否写完成
}


/*
函数功能: 获取RTC时间
函数参数: u32 sec 秒单位时间
*/
void RTC_GetTime(u32 sec)
{
		u32 i;
		rtc_clock.year=2017; //基准年份
		
	  /*1. 计算当前的年份*/
	  while(1)
		{
			  if(RTC_GetYearState(rtc_clock.year))
				{
						if(sec>=366*24*60*60) //够一年
						{
								sec-=366*24*60*60;
								rtc_clock.year++;
						}
						else break;
				}
				else
				{
						if(sec>=365*24*60*60) //够一年
						{
								sec-=365*24*60*60;
								rtc_clock.year++;
						}
						else break;
				}
		}
		
		/*2. 计算当前的月份*/
		rtc_clock.mon=1;
		for(i=0;i<12;i++)
		{
				if(RTC_GetYearState(rtc_clock.year))
				{
					 	if(sec>=mon_r[i]*24*60*60)
						{
							 sec-=mon_r[i]*24*60*60;
							 rtc_clock.mon++;
						}
						else break;		
				}
				else
				{
						if(sec>=mon_p[i]*24*60*60)
						{
							 sec-=mon_p[i]*24*60*60;
							 rtc_clock.mon++;
						}
						else break;	
				}
		}
		
		/*3. 计算当前的天数*/
		rtc_clock.day=1;
		while(1)
		{
				if(sec>=24*60*60)
				{
						sec-=24*60*60;
						rtc_clock.day++;
				}
				else break;
		}
		
		/*4. 计算当前的小时*/
		rtc_clock.hour=0;
		while(1)
		{
				if(sec>=60*60)
				{
						sec-=60*60;
						rtc_clock.hour++;
				}
				else break;
		}
		
		/*5. 计算当前的分钟*/
		rtc_clock.min=0;
		while(1)
		{
				if(sec>=60)
				{
						sec-=60;
						rtc_clock.min++;
				}
				else break;
		}
		
		/*6. 计算当前的秒*/
		rtc_clock.sec=sec;
}


/*
函数功能: 判断年份是否是平年、闰年
返回值  : 0表示平年 1表示闰年
*/
u8 RTC_GetYearState(u32 year)
{
	 if((year%4==0&&year%100!=0)||year%400==0)
	 {
		 return 1;
	 }
	 return 0;
}


/*
函数功能: 获取星期
*/
void RTC_GetWeek(u32 sec)
{
	u32 day1=sec/(60*60*24); //将秒单位时间转为天数
	switch(day1%7)
	{
		case 0:
			rtc_clock.week=0;
			break;
	 	case 1:
			rtc_clock.week=1;
			break;
		case 2:
			rtc_clock.week=2;
			break;
		case 3:
			rtc_clock.week=3;
			break;
		case 4:
			rtc_clock.week=4;
			break;
		case 5:
			rtc_clock.week=5;
			break;
		case 6:
			rtc_clock.week=6;
			break;
	}
}

(2) rtc.h

#ifndef RTC_H
#define RTC_H
#include "stm32f10x.h"
#include "sys.h"
#include "usart.h"
#include "delay.h"

//定时RTC时钟结构体
struct RTC_CLOCK
{
		u32 year;
	  u32 mon;
	  u32 day;
		u32 hour;
		u32 min;
	  u32 sec;
		u32 week;
};
extern struct RTC_CLOCK rtc_clock; 

//函数声明
void RTC_Init(void);
u8 RTC_GetYearState(u32 year);
void RTC_GetTime(u32 sec);
void RTC_GetWeek(u32 sec);
void RTC_SetTime(u32 year,u32 mon,u32 day,u32 hour,u32 min,u32 sec);
#endif

3.3 界面绘制部分代码-主函数

#include "stm32f10x.h"
#include "led.h"
#include "delay.h"
#include "key.h"
#include "usart.h"
#include 
#include "timer.h"
#include "oled.h"
#include "rtc.h"

/*
函数功能: 绘制时钟表盘框架
*/
void DrawTimeFrame(void)
{
	u8 i;
	OLED_Circle(32,32,31);//画外圆
	OLED_Circle(32,32,1); //画中心圆
	//画刻度
	for(i=0;i<60;i++)
	{
		if(i%5==0)OLED_DrawAngleLine(32,32,6*i,31,3,1);
	}
	OLED_WriteGRAM();  //刷新数据到OLED屏幕
}


/*
函数功能: 更新时间框架显示,在RTC中断里调用
*/
char TimeBuff[20];
void Update_FrameShow(void)
{
	/*1. 绘制秒针、分针、时针*/
	OLED_DrawAngleLine2(32,32,rtc_clock.sec*6-6-90,27,0);//清除之前的秒针
	OLED_DrawAngleLine2(32,32,rtc_clock.sec*6-90,27,1); //画秒针
	
	OLED_DrawAngleLine2(32,32,rtc_clock.min*6-6-90,24,0);
	OLED_DrawAngleLine2(32,32,rtc_clock.min*6-90,24,1);
	
	OLED_DrawAngleLine2(32,32,rtc_clock.hour*30-6-90,21,0);
	OLED_DrawAngleLine2(32,32,rtc_clock.hour*30-90,21,1);
	
	//绘制电子钟时间
	sprintf(TimeBuff,"%d",rtc_clock.year);
	OLED_ShowString(65,16*0,16,TimeBuff);  //年份字符串
	OLED_ShowChineseFont(66+32,16*0,16,4); //显示年
	
	sprintf(TimeBuff,"%d/%d",rtc_clock.mon,rtc_clock.day);
	OLED_ShowString(75,16*1,16,TimeBuff); //月
	
	if(rtc_clock.sec==0)OLED_ShowString(65,16*2,16,"        ");	//清除多余的数据
	sprintf(TimeBuff,"%d:%d:%d",rtc_clock.hour,rtc_clock.min,rtc_clock.sec);
	OLED_ShowString(65,16*2,16,TimeBuff); //秒
	
	//显示星期
	OLED_ShowChineseFont(70,16*3,16,5); //星
	OLED_ShowChineseFont(70+16,16*3,16,6); //期
	OLED_ShowChineseFont(70+32,16*3,16,rtc_clock.week+7); //具体的值
}


int main()
{
    LED_Init();
    BEEP_Init();
    KEY_Init();
    USART1_Init(115200);
    TIMER1_Init(72,20000); //超时时间20ms
    USART2_Init(9600);//串口-蓝牙
    TIMER2_Init(72,20000); //超时时间20ms
    USART3_Init(115200);//串口-WIFI
    TIMER3_Init(72,20000); //超时时间20ms
    USART1_Printf("正在初始化WIFI请稍等.\n");
    RTC_Init(); //RTC初始化
    OLED_Init();
    OLED_Clear(0x00); //清屏
    
    RTC_SetTime(2020,7,15,10,52,10);
    DrawTimeFrame();
    while(1)
    { 
        
    }
}

 

下面公众号有全套的单片机、C语言、Linux、QT教程,欢迎关注:

STM32+OLED显示屏制作指针式电子钟_第3张图片

 

你可能感兴趣的:(STM32,stm32)