STM32+OLED

OLED.H

#ifndef _OLED_H_
#define _OLED_H_

#include "stm32f10x.h"


#define  OLED_SCLK_Set()    GPIO_SetBits(GPIOB,GPIO_Pin_0)  //PB0(SCL)输出高
#define  OLED_SCLK_CLr()    GPIO_ResetBits(GPIOB,GPIO_Pin_0) //PB0(SCL)输出低
#define  OLED_SDIN_Set()    GPIO_SetBits(GPIOB,GPIO_Pin_1)  //PB1(SDA)输出高
#define  OLED_SDIN_CLr()    GPIO_ResetBits(GPIOB,GPIO_Pin_1) //PB1(SDA)输出低
#define  OLED_READ_SDIN()    GPIO_ReadInputDataBit(GPIOB,  GPIO_Pin_1) //读取PB1(SDA)电平

   
#define IIC_ACK  0  //应答
#define IIC_NO_ACK  1  //不应答
#define  OLED_CMD 0 //写命令
#define  OLED_DATA  1 //写数据
#define SIZE 		16		//显示字符的大小
#define Max_Column	128		//最大列数


			  				   


//static void delay_u(unsigned char num);
//static void delay_ms(unsigned int ms);
static void OLED_IIC_Start(void);
static void OLED_IIC_Stop(void);
static unsigned char IIC_Wait_Ack(void);
static void Write_IIC_Byte(unsigned char IIC_Byte);
static void Write_IIC_Command(unsigned char IIC_Command);
static void Write_IIC_Data(unsigned char IIC_Data);
void OLED_WR_Byte(unsigned char dat,unsigned char cmd);
void OLED_Set_Pos(unsigned char x,unsigned char y);
void OLED_Display_On(void);
void OLED_Display_Off(void);
void OLED_Clear(void);
void OLED_ShouChar(unsigned char x,unsigned char y,unsigned char chr);
void OLED_Init(void);
void OLED_ShowString(unsigned char x,unsigned char y,unsigned char *str);
unsigned int oled_pow(unsigned char m,unsigned char n);
void OLED_ShowNum(unsigned char x,unsigned char y,unsigned int num,unsigned char len,unsigned char size);
void OLED_ShowCHinese(unsigned char x,unsigned char y,unsigned char no);

#endif

1.初始化

static void OLED_GPIO_Init(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;	
	
	RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);	
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;	
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;//开漏输出,控制多机下拉	
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;	
	GPIO_Init(GPIOB,&GPIO_InitStructure);	
	
	OLED_SCLK_Set();	
	OLED_SDIN_Set();	
}

2.模拟IIC开始信号

static void OLED_IIC_Start(void)
{

	OLED_SCLK_Set();//时钟线置高
	OLED_SDIN_Set();//信号线置高	
	delay_us(1);
	OLED_SDIN_CLr();//信号线置低	
	delay_us(1);
	OLED_SCLK_CLr();//时钟线置低	
	delay_us(1);
}

3.模拟IIC停止信号

static void OLED_IIC_Stop(void)
{
	OLED_SDIN_CLr();//信号线置低
	delay_us(1);
	OLED_SCLK_Set();//时钟线置高
	delay_us(1);
	OLED_SDIN_Set();//信号线置高
	delay_us(1);
}

4.模拟IIC等待应答信号

static unsigned char IIC_Wait_Ack(void)
{
	unsigned char ack;

	OLED_SCLK_CLr();//时钟线置低
	 delay_us(1);
	OLED_SDIN_Set();//信号线置高
	delay_us(1);
	OLED_SCLK_Set();//时钟先置高
	 delay_us(1);

	if(OLED_READ_SDIN())//读取SDA电平
		ack = IIC_NO_ACK;//若为1,从机没有应答
	else
		ack = IIC_ACK;	//若为0,从机有应答

	OLED_SCLK_CLr();//时钟线置低
	 delay_us(1);

	return ack;	//返回读取到的应答信息
}

5.模拟IIC写一个BIT

static void Write_IIC_Byte(unsigned char IIC_Byte)
{
	unsigned char i;  
	for(i=0;i<8;i++) //8位一bit
	{
		OLED_SCLK_CLr();	//时钟置低,为传输数据做准备
		 delay_us(1);

		if(IIC_Byte & 0x80)	//读取最高位
		  	OLED_SDIN_Set();//最高位是1
		else
			OLED_SDIN_CLr();	//最高位是0

		IIC_Byte <<= 1;  //数据左移一位
		 delay_us(1);
		OLED_SCLK_Set(); //时钟线置高,产生上升沿,发送数据
		 delay_us(1);
	}
	OLED_SCLK_CLr();	//时钟线置低
		 delay_us(1);

	while(IIC_Wait_Ack());	//从机应答
}

6.模拟IIC写命令和数据函数

static void Write_IIC_Command(unsigned char IIC_Command)
{
   OLED_IIC_Start();
   Write_IIC_Byte(0x78);//写从机地址
   Write_IIC_Byte(0x00);//写入命令指令0x00
   Write_IIC_Byte(IIC_Command);//数据
   OLED_IIC_Stop();  //停止信号
}


static void Write_IIC_Data(unsigned char IIC_Data)
{
   OLED_IIC_Start();
   Write_IIC_Byte(0x78);	//写从机地址
   Write_IIC_Byte(0x40);	//写入数据指令0x40
   Write_IIC_Byte(IIC_Data);//数据
   OLED_IIC_Stop();		//停止信号
}
//写入一个字节
void OLED_WR_Byte(unsigned char dat,unsigned char cmd)//cmd==1就是写数据指令
{
	if(cmd) 
	  {
       Write_IIC_Data(dat); 
	  }
	else {
       Write_IIC_Command(dat); 
	}
}

7.设置起始坐标

void OLED_Set_Pos(unsigned char x, unsigned char y) 
{ 
	OLED_WR_Byte(0xb0+y,OLED_CMD);//写入页地址
	OLED_WR_Byte((x&0x0f),OLED_CMD);  //写入列地址,低4位
	OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD);//高四位,数据手册要求分开写
}   	
//x:列的起始地址
//y:页的起始地址0-7  

8.OLED初始化函数

void OLED_Init(void)
{
	OLED_GPIO_Init();	//GPIO初始化
 
	delay_ms(200);	//单片机上电比OLED快,加延时等OLED复位完成

	OLED_WR_Byte(0xAE,OLED_CMD);	//关闭显示

	OLED_WR_Byte(0x00,OLED_CMD);	//设置低列地址
	OLED_WR_Byte(0x10,OLED_CMD);	//设置高列地址
	OLED_WR_Byte(0x40,OLED_CMD);	//设置起始行地址
	OLED_WR_Byte(0xB0,OLED_CMD);	//起始页地址

	OLED_WR_Byte(0x81,OLED_CMD); 	// 对比度设置
	OLED_WR_Byte(0xFF,OLED_CMD);	//  265  

	OLED_WR_Byte(0xA1,OLED_CMD);	//设置段(SEG)的起始映射地址
	OLED_WR_Byte(0xA6,OLED_CMD);	//正常显示,0xa7逆显示

	OLED_WR_Byte(0xA8,OLED_CMD);	//设置驱动路数
	OLED_WR_Byte(0x3F,OLED_CMD);	//64duty
	
	OLED_WR_Byte(0xC8,OLED_CMD);	//重映射模式,COM[N-1]-COM0

	OLED_WR_Byte(0xD3,OLED_CMD);	//设置显示偏移
	OLED_WR_Byte(0x00,OLED_CMD);	//无偏移
	
	OLED_WR_Byte(0xD5,OLED_CMD);	//设置振荡器分频
	OLED_WR_Byte(0x80,OLED_CMD);	//默认值
	
	OLED_WR_Byte(0xD9,OLED_CMD);	//设置Pre—Charge Period
	OLED_WR_Byte(0xF1,OLED_CMD);	//推荐值
	
	OLED_WR_Byte(0xDA,OLED_CMD);	//设置Vcomh,可调亮度
	OLED_WR_Byte(0x12,OLED_CMD);	//推荐值
	
	OLED_WR_Byte(0xDB,OLED_CMD);	//设置com pin configuration
	OLED_WR_Byte(0x40,OLED_CMD);	推荐
	
	OLED_WR_Byte(0x8D,OLED_CMD);	//设置OLED电荷泵
	OLED_WR_Byte(0x14,OLED_CMD);	//开显示
	
	OLED_WR_Byte(0xAF,OLED_CMD);	//开OLED面板显示
	OLED_Clear();        //清屏幕
	OLED_Set_Pos(0,0); 	 //设置起始行
}  

Segment翻译下来就是,这个段驱动器将OLED的面板切割成128个段,每个段都有一个电流源去驱动OLED面板。电流源的强度可以用一个八位的寄存器在0~100uA的范围内进行调整,也就是说,电流的大小被化分成256个等级,也可以对应着256个亮度等级。

然而一个发光二极管要工作,光有电流是没用的,负载直接与电流源连接是不会工作的。电流、负载有了,差个电压,就是Common驱动器了。

在抽象的地方想,SegmentCommon可以想象成一个直角坐标系,每一个坐标点都会对应一个像素点(或发光二极管),只要是Segment和Common对应的坐标上的负载,就是点亮的二极管(或有颜色的像素点)。页(Page)。每一个页由8个COM组成,即128 x 64 比特的矩阵映射成了 128 x 8 字节(或页)的矩阵。

9.清屏和全屏显示

void OLED_Display_Off(void)
{
	OLED_WR_Byte(0XAE,OLED_CMD);  //关显示
	OLED_WR_Byte(0X8D,OLED_CMD);  //设置OLED电荷泵
	OLED_WR_Byte(0X10,OLED_CMD);  //失能,关
}		   			 

//清屏幕
void OLED_Clear(void)  
{  
	unsigned char i,n;		    //定义变量
	for(i=0;i<8;i++)  
	{  
		OLED_WR_Byte (0xb0+i,OLED_CMD);    //从0~7页依次写入
		OLED_WR_Byte (0x00,OLED_CMD);      //列低地址
		OLED_WR_Byte (0x10,OLED_CMD);      //列高地址  
		for(n=0;n<128;n++)OLED_WR_Byte(0,OLED_DATA); //写入 0 清屏
	}

10.显示字符

void OLED_ShouChar(unsigned char x,unsigned char y,unsigned char chr)
{

    unsigned char c = 0,i=0;
    c =chr - ' '; //获取字符的偏移量
	 if(x>Max_Column)
	 {
	   x = 0;  //如果列出了范围,就从下两页的第0列开始
		 y=y+2;
	  
	 }
   if(SIZE == 16)   //字符大小如果为16 =8 *16
	 {
	   OLED_Set_Pos(x,y); //从x,y开始画点
		 for(i=0;i<8;i++)
	  OLED_WR_Byte(F8X16[c*16+i],OLED_DATA);//找出字符c的数组位数,先把第一列画完
	 	 OLED_Set_Pos(x,y+1); //从x,y开始画点
		 for(i=0;i<8;i++)
	  OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA);//找出字符c的数组位数,先把第一列画完

	 
	 }
	 else // 6 =6*8
	 {
	    	   OLED_Set_Pos(x,y); //从x,y开始画点

	 		    for(i=0;i<6;i++)
	       OLED_WR_Byte(F6x8[c][i],OLED_DATA);//找出字符c的数组位数,先把第一列画完

	 
	 
	 }

}

11.显示字符串

void OLED_ShowString(unsigned char x,unsigned char y,unsigned char *str){
      unsigned char j=0;
	    while(str[j]!='\0'){
			OLED_ShouChar(x,y,str[j]);
			x+=8;
			if(x>=128){
			x=0;
			y=y+2;
			}
			j++;		
			}
}

12.显示汉字

void OLED_ShowCHinese(unsigned char x,unsigned char y,unsigned char no)
{
    unsigned char t,adder = 0;
	  OLED_Set_Pos(x,y);
	for(t=0;t<16;t++)
	{ 
		 OLED_WR_Byte( Hzk[2*no][t],OLED_DATA);//画 no在数组位置的第一页16列的点
		 adder+=1; //数组地址+1
	}
		  OLED_Set_Pos(x,y+1);
	for(t=0;t<16;t++)
	{
     OLED_WR_Byte( Hzk[2*no+1][t],OLED_DATA);//画 no在数组位置的第2页16列的点
		 adder+=1; //数组地址+1

	}


}

13.字库H文件

unsigned char F16X16[] =
{
		0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
		0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00,/*"温度",0*/
		0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,
		0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,/*"湿度",1*/
};
const unsigned char F6x8[][6] =
{
	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
};
const unsigned char 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 16
  0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
  0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
  0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
  0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
  0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
  0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
  0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
  0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
  0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
  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
};

unsigned char 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,0x80,0xF0,0xFC,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xE0,0xFC,0xFF,0xFF,0xFF,0xFF,
0xFF,0x7F,0x0F,0x03,0x00,0x00,0xE0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x0F,0x01,
0x00,0x00,0xE0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x0F,0x81,0xE0,0xF0,0xF8,0xFC,
0xFE,0xFF,0x7F,0x3F,0x1F,0x07,0x03,0x01,0xC0,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,
0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,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,0xE0,0xFC,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,
0x03,0x00,0x00,0xC0,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x03,0x00,0x00,0xC0,
0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0x1F,0x0F,0x03,
0x01,0x00,0x00,0x00,0x00,0x80,0xF0,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xF0,
0xF0,0xF0,0xF0,0xF0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0xC0,0x00,0x00,0x00,0x00,0xC0,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,
0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x07,0x00,0x00,
0xC0,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x03,0x00,0x00,0xC0,0xF8,0xFE,0xFF,
0xFF,0xFF,0xFF,0xFF,0x1F,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x80,0xF0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x07,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0x40,0x60,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,
0x1F,0x03,0x00,0x00,0xC0,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x03,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x07,0x00,0x00,0x80,0xF0,0xFE,
0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x07,0x00,0x00,0x80,0xF0,0xFE,0xFF,0xFF,0xFF,0xFF,
0xFF,0x3F,0x07,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,
0xE0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
0xFC,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0x78,0x7C,0x7C,0x3C,0x3C,0x1E,
0x1E,0x1E,0x0E,0x0F,0x07,0x07,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0xE0,0xF0,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x80,0x81,0x81,0x81,0xC1,0xC1,0xC1,0xC1,
0xE1,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF1,0xF9,0xF9,0xF9,0xF9,0xFD,0xFD,0xFC,0xFC,
0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,
0x0F,0x07,0x07,0x03,0x03,0x03,0x01,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,
0xE0,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFC,0xF8,0xF0,0xE0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,
0xFE,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x3F,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x0F,0x07,0x07,
0x03,0x03,0x01,0x01,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,
0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x7F,0x7F,0x3F,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x07,0x03,0x03,0x01,
0x01,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,0x01,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,
0x3F,0x1F,0x1F,0x1F,0x0F,0x0F,0x0F,0x07,0x07,0x07,0x03,0x03,0x01,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,0x00,
};
unsigned char F16X16_1[]=
{	

0x00,0x04,0x04,0x04,0xFF,0x54,0x54,0x54,0x54,0x54,0xFF,0x04,0x04,0x04,0x00,0x00,
0x11,0x11,0x89,0x85,0x93,0x91,0x91,0xFD,0x91,0x91,0x93,0x85,0x89,0x11,0x11,0x00,/*"基",0*/

0xC8,0xB8,0x8F,0xE8,0x88,0x88,0x04,0xE4,0x24,0x24,0xFF,0x24,0x25,0xE6,0x04,0x00,
0x08,0x18,0x08,0xFF,0x04,0x04,0x00,0xFF,0x09,0x09,0x7F,0x09,0x89,0xFF,0x00,0x00,/*"辅",1*/

0x10,0x60,0x02,0x8C,0x00,0x40,0x20,0x90,0x0C,0x03,0x0C,0x90,0x20,0x40,0x40,0x00,
0x04,0x04,0x7E,0x01,0x00,0x00,0x00,0x3F,0x44,0x42,0x41,0x40,0x40,0x70,0x00,0x00,/*"沦",2*/

0x00,0xFE,0x22,0x5A,0x86,0x20,0x90,0x88,0x87,0x44,0x04,0x94,0x8C,0x80,0x00,0x00,
0x00,0xFF,0x04,0x08,0x07,0x00,0xFF,0x44,0x44,0x40,0x40,0x44,0x44,0xFF,0x00,0x00,/*"陷",3*/
};
unsigned char F16X16_2[]=
{	


0x00,0x80,0x60,0xF8,0x07,0x40,0x40,0x40,0x40,0x40,0xFF,0x40,0x40,0x40,0x40,0x00,
0x01,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,/*"什",0*/

0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0xC0,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x20,0x70,0x28,0x24,0x22,0x21,0x20,0x20,0x24,0x28,0x30,0x60,0x00,0x00,/*"么",1*/

0x00,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,
0x00,0x0F,0x04,0x04,0x04,0x0F,0x00,0x00,0x0F,0x04,0x02,0x02,0x01,0xFF,0x00,0x00,/*"叫",2*/

0x00,0x80,0x60,0xF8,0x87,0x80,0xFC,0x40,0x20,0xFF,0x10,0x08,0xF8,0x00,0x00,0x00,
0x01,0x00,0x00,0xFF,0x00,0x00,0x3F,0x40,0x40,0x4F,0x40,0x44,0x47,0x40,0x78,0x00,/*"他",3*/

0x10,0x10,0xF0,0x1F,0x10,0xF0,0x02,0xF2,0x82,0x82,0x82,0xFE,0x80,0x80,0x00,0x00,
0x40,0x22,0x15,0x08,0x16,0x61,0x08,0x08,0x08,0x08,0x48,0x88,0x40,0x3F,0x00,0x00,/*"妈",4*/

0x00,0x08,0x88,0x48,0x28,0x18,0x0F,0xE8,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
0x00,0x20,0x11,0x09,0x05,0x41,0x81,0x7F,0x01,0x01,0x05,0x09,0x11,0x20,0x00,0x00,/*"东",5*/

0x08,0x08,0x89,0xEE,0x98,0x00,0x00,0xF8,0x88,0x88,0xFF,0x88,0x88,0xF8,0x00,0x00,
0x02,0x01,0x00,0xFF,0x00,0x03,0x00,0x1F,0x08,0x08,0xFF,0x08,0x08,0x1F,0x00,0x00,/*"神",6*/

};
const unsigned char  Hzk[][32]={

{0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00},
{0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00},/*"技",0*/

{0x40,0x44,0x54,0x65,0xC6,0x64,0x54,0x44,0x00,0xFC,0x44,0x44,0xC4,0x42,0x40,0x00},
{0x20,0x12,0x4A,0x82,0x7F,0x02,0x0A,0x92,0x60,0x1F,0x00,0x00,0xFF,0x00,0x00,0x00},/*"新",1*/

{0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0xF8,0x00,0x00,0x00},
{0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0x7F,0x88,0x88,0x88,0x88,0x9F,0x80,0xF0,0x00},/*"电",2*/

{0x80,0x82,0x82,0x82,0x82,0x82,0x82,0xE2,0xA2,0x92,0x8A,0x86,0x82,0x80,0x80,0x00},
{0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"子",3*/

{0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00},
{0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00},/*"科",4*/

{0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00},
{0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00},/*"技",5*/


{0x00,0x00,0x00,0x10,0x20,0x60,0x00,0xFC,0x04,0x40,0xA0,0x98,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x01,0x41,0x49,0x49,0x29,0x25,0x25,0x24,0x3F,0x01,0x00,0x00,0x00},/*"当",6*/

{0x00,0x20,0x20,0xA0,0xA0,0xA4,0xA8,0x20,0x20,0x98,0x16,0xF0,0x10,0x10,0x10,0x00},
{0x00,0x00,0x00,0x1F,0x0A,0x2A,0x7F,0x00,0x00,0x0F,0x20,0x6F,0x30,0x00,0x00,0x00},/*"前",7*/


{0x00,0x00,0x40,0x08,0x18,0x00,0x08,0xF8,0xA8,0x68,0x68,0x74,0x18,0x00,0x00,0x00},
{0x00,0x00,0x30,0x0E,0x22,0x20,0x3E,0x22,0x1E,0x12,0x2E,0x22,0x1F,0x12,0x00,0x00},/*"温",8*/

{0x00,0x00,0x00,0x00,0xF0,0x90,0xB0,0xF0,0x56,0xD8,0x28,0x48,0x00,0x00,0x00,0x00},
{0x00,0x20,0x10,0x0C,0x43,0x40,0x40,0x2D,0x13,0x1E,0x22,0x60,0x40,0x40,0x40,0x00},/*"度",9*/


{0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x31,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/

{0x00,0x0C,0x12,0x0C,0x00,0xC0,0x70,0x10,0x08,0x08,0x08,0x08,0x10,0x30,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x0F,0x18,0x30,0x20,0x20,0x20,0x20,0x30,0x1C,0x00,0x00},/*"℃",11*/

{0x00,0x00,0x40,0x08,0x08,0x08,0xF8,0xA8,0xA8,0x58,0x48,0x7C,0x08,0x00,0x00,0x00},
{0x00,0x00,0x38,0x06,0x20,0x20,0x2C,0x3D,0x23,0x21,0x3F,0x24,0x23,0x20,0x20,0x00},/*"湿",12*/

{0x00,0xF0,0xF8,0x08,0x88,0xF8,0xF0,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x00},
{0x00,0x00,0x00,0x21,0x18,0x0C,0x02,0x01,0x00,0x1E,0x3F,0x21,0x21,0x1E,0x1E,0x00},/*"%",13*/

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x10,0x30,0x30,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",15*/


};

14.delay函数

#include "system.h"
#include "stm32f10x.h"

void initSysTick(void)
{
    SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); //设置时钟源8分频  1us=1x10^-6
    SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;            //使能中断
    SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;             //开定时器
    SysTick->LOAD = 9;                                    //随意设置一个重装载值
}
/**
 * 功能:微秒级延时函数
 * 参数:xus :具体延时时间  (单位:微秒)
 * 返回值:None
 */
void delay_us(u32 xus)
{
    SysTick->LOAD = 9 * xus;                               //计9次为1us,xus则重装载值要*9
    SysTick->VAL = 0;                                      //计数器归零
    while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)); //等待计数完成
}
/**
 * 功能:毫秒级延时函数
 * 参数:xms :具体延时时间  (单位:毫秒)
 * 返回值:None
 */
void delay_ms(u32 xms)
{
    SysTick->LOAD = 9000;                                      //计9次为1us,1000次为1ms
    SysTick->VAL = 0;                                          //计数器归零
    while (xms--)
    {
        while (!(SysTick->CTRL &SysTick_CTRL_COUNTFLAG_Msk)); //等待单次计数完成
    }
}

15.ALL

#include "stm32f10x.h"
#include "oled.h"
#include "system.h"
#include "codetab.h"
static void OLED_GPIO_Init(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;	//定义一个GPIO_InitTypeDef类型的结构体
	
	RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);	//打开GPIOC的外设时钟
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;	//选择控制的引脚
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;	//设置为通用开漏输出
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;	//设置输出速率为50MHz
	GPIO_Init(GPIOB,&GPIO_InitStructure);	//调用库函数初始化GPIOA
	
	OLED_SCLK_Set();	//设PC2(SCL)为高电平
	OLED_SDIN_Set();	//设PC3(SDA)为高电平
}


static void OLED_IIC_Start(void)
{

	OLED_SCLK_Set();	//时钟线置高
	OLED_SDIN_Set();	//信号线置高
	   delay_us(1);
	OLED_SDIN_CLr();	//信号线置低
	   delay_us(1);
	OLED_SCLK_CLr();	//时钟线置低
	  delay_us(1);
}

static void OLED_IIC_Stop(void)
{
	OLED_SDIN_CLr();	//信号线置低
	   delay_us(1);
	OLED_SCLK_Set();	//时钟线置高
	   delay_us(1);
	OLED_SDIN_Set();	//信号线置高
	   delay_us(1);
}


static unsigned char IIC_Wait_Ack(void)
{
	unsigned char ack;

	OLED_SCLK_CLr();	//时钟线置低
	 delay_us(1);
	OLED_SDIN_Set();	//信号线置高
	delay_us(1);
	OLED_SCLK_Set();	//时钟线置高
	 delay_us(1);

	if(OLED_READ_SDIN())	//读取SDA的电平
		ack = IIC_NO_ACK;	//如果为1,则从机没有应答
	else
		ack = IIC_ACK;		//如果为0,则从机应答

	OLED_SCLK_CLr();//时钟线置低
	 delay_us(1);

	return ack;	//返回读取到的应答信息
}


static void Write_IIC_Byte(unsigned char IIC_Byte)
{
	unsigned char i;  //定义变量
	for(i=0;i<8;i++) //for循环8次
	{
		OLED_SCLK_CLr();	//时钟线置低,为传输数据做准备
		 delay_us(1);

		if(IIC_Byte & 0x80)	//读取最高位
		  	OLED_SDIN_Set();//最高位为1
		else
			OLED_SDIN_CLr();	//最高位为0

		IIC_Byte <<= 1;  //数据左移1位
		 delay_us(1);
		OLED_SCLK_Set(); //时钟线置高,产生上升沿,把数据发送出去
		 delay_us(1);
	}
	OLED_SCLK_CLr();	//时钟线置低
		 delay_us(1);

	while(IIC_Wait_Ack());	//从机应答
}



static void Write_IIC_Command(unsigned char IIC_Command)
{
   OLED_IIC_Start();
   Write_IIC_Byte(0x78);//写入从机地址,SD0 = 0
   Write_IIC_Byte(0x00);//写入命令
   Write_IIC_Byte(IIC_Command);//数据
   OLED_IIC_Stop();  //发送停止信号
}


/*
	@brief			IIC写入数据
	@param			IIC_Data:数据
	@retval			无
 */
static void Write_IIC_Data(unsigned char IIC_Data)
{
   OLED_IIC_Start();
   Write_IIC_Byte(0x78);	//写入从机地址,SD0 = 0
   Write_IIC_Byte(0x40);	//写入数据
   Write_IIC_Byte(IIC_Data);//数据
   OLED_IIC_Stop();		//发送停止信号
}

//对OLED写入一个字节

void OLED_WR_Byte(unsigned char dat,unsigned char cmd)
{
	if(cmd) 
	  {
       Write_IIC_Data(dat); //写入数据
	  }
	else {
       Write_IIC_Command(dat); //写入命令
	}
}


//设置数据写入的起始行,列
//x: 列的起始低地址于起始高地址
//y: 页 起始页的地址 0-7

void OLED_Set_Pos(unsigned char x, unsigned char y) 
{ 
	OLED_WR_Byte(0xb0+y,OLED_CMD);//写入页地址
	OLED_WR_Byte((x&0x0f),OLED_CMD);  //写入列的地址  低半字节
	OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD);//写入列的地址 高半字节
}   	     	  


/*
	@brief			开显示
	@param			无
	@retval			无
 */ 
void OLED_Display_On(void)
{
	OLED_WR_Byte(0X8D,OLED_CMD);  //设置OLED电荷泵
	OLED_WR_Byte(0X14,OLED_CMD);  //使能,开
	OLED_WR_Byte(0XAF,OLED_CMD);  //开显示
}


/*
	@brief			关显示
	@param			无
	@retval			无
 */  
void OLED_Display_Off(void)
{
	OLED_WR_Byte(0XAE,OLED_CMD);  //关显示
	OLED_WR_Byte(0X8D,OLED_CMD);  //设置OLED电荷泵
	OLED_WR_Byte(0X10,OLED_CMD);  //失能,关
}		   			 

//清屏幕
void OLED_Clear(void)  
{  
	unsigned char i,n;		    //定义变量
	for(i=0;i<8;i++)  
	{  
		OLED_WR_Byte (0xb0+i,OLED_CMD);    //从0~7页依次写入
		OLED_WR_Byte (0x00,OLED_CMD);      //列低地址
		OLED_WR_Byte (0x10,OLED_CMD);      //列高地址  
		for(n=0;n<128;n++)OLED_WR_Byte(0,OLED_DATA); //写入 0 清屏
	}
}
void OLED_ShouChar(unsigned char x,unsigned char y,unsigned char chr)
{

    unsigned char c = 0,i=0;
    c =chr - ' '; //获取字符的偏移量
	 if(x>Max_Column)
	 {
	   x = 0;  //如果列出了范围,就从下两页的第0列开始
		 y=y+2;
	  
	 }
   if(SIZE == 16)   //字符大小如果为16 =8 *16
	 {
	   OLED_Set_Pos(x,y); //从x,y开始画点
		 for(i=0;i<8;i++)
	  OLED_WR_Byte(F8X16[c*16+i],OLED_DATA);//找出字符c的数组位数,先把第一列画完
	 	 OLED_Set_Pos(x,y+1); //从x,y开始画点
		 for(i=0;i<8;i++)
	  OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA);//找出字符c的数组位数,先把第一列画完

	 
	 }
	 else // 6 =6*8
	 {
	    	   OLED_Set_Pos(x,y); //从x,y开始画点

	 		    for(i=0;i<6;i++)
	       OLED_WR_Byte(F6x8[c][i],OLED_DATA);//找出字符c的数组位数,先把第一列画完

	 
	 
	 }

}
void OLED_Init(void)
{
	OLED_GPIO_Init();	//GPIO口初始化
 
	delay_ms(200);	//延迟,由于单片机上电初始化比OLED快,所以必须加上延迟,等待OLED上复位完成

	OLED_WR_Byte(0xAE,OLED_CMD);	//关闭显示

	OLED_WR_Byte(0x00,OLED_CMD);	//设置低列地址
	OLED_WR_Byte(0x10,OLED_CMD);	//设置高列地址
	OLED_WR_Byte(0x40,OLED_CMD);	//设置起始行地址
	OLED_WR_Byte(0xB0,OLED_CMD);	//设置页地址

	OLED_WR_Byte(0x81,OLED_CMD); 	// 对比度设置,可设置亮度
	OLED_WR_Byte(0xFF,OLED_CMD);	//  265  

	OLED_WR_Byte(0xA1,OLED_CMD);	//设置段(SEG)的起始映射地址0xa1正常
	OLED_WR_Byte(0xA6,OLED_CMD);	//正常显示;0xa7逆显示

	OLED_WR_Byte(0xA8,OLED_CMD);	//设置驱动路数(16~64)
	OLED_WR_Byte(0x3F,OLED_CMD);	//64duty
	
	OLED_WR_Byte(0xC8,OLED_CMD);	//重映射模式,COM[N-1]~COM0扫描

	OLED_WR_Byte(0xD3,OLED_CMD);	//设置显示偏移
	OLED_WR_Byte(0x00,OLED_CMD);	//无偏移
	
	OLED_WR_Byte(0xD5,OLED_CMD);	//设置震荡器分频
	OLED_WR_Byte(0x80,OLED_CMD);	//使用默认值
	
	OLED_WR_Byte(0xD9,OLED_CMD);	//设置 Pre-Charge Period
	OLED_WR_Byte(0xF1,OLED_CMD);	//使用官方推荐值
	
	OLED_WR_Byte(0xDA,OLED_CMD);	//设置 com pin configuartion
	OLED_WR_Byte(0x12,OLED_CMD);	//使用默认值
	
	OLED_WR_Byte(0xDB,OLED_CMD);	//设置 Vcomh,可调节亮度(默认)
	OLED_WR_Byte(0x40,OLED_CMD);	使用官方推荐值
	
	OLED_WR_Byte(0x8D,OLED_CMD);	//设置OLED电荷泵
	OLED_WR_Byte(0x14,OLED_CMD);	//开显示
	
	OLED_WR_Byte(0xAF,OLED_CMD);	//开启OLED面板显示
	OLED_Clear();        //清屏
	OLED_Set_Pos(0,0); 	 //设置数据写入的起始行、列
}  
//显示字符串
void OLED_ShowString(unsigned char x,unsigned char y,unsigned char *str){
      unsigned char j=0;
	    while(str[j]!='\0'){
			OLED_ShouChar(x,y,str[j]);
			x+=8;
			if(x>=128){
			x=0;
			y=y+2;
			}
			j++;		
			}
}
//m的n次方计算
unsigned int oled_pow(unsigned char m,unsigned char n){
    unsigned int result=1;
	  while(n--)
			result*=m;
		return result;
} 

void OLED_ShowNum(unsigned char x,unsigned char y,unsigned int num,unsigned char len,unsigned char size){
   unsigned char t,temp;
	 unsigned char enshow=0;
   for(t=0;t

你可能感兴趣的:(C语言,stm32,单片机,物联网)