目录
起始信号
终止信号
应答信号
选择某一点点亮
页模式:
水平模式:
垂直模式:
选择行数
编辑 选择列数
清屏
Oled显示,我们会用到字模软件
显示图片
上图中SDA和SCL这两根线必须要接一个上接电阻,一般是4.7K。其余的IIC从器件都挂接到SDA和SCL这两根线上,这样就可以通过SDA和SCL这两根线来访问多个IIC设备。
通常我们为了方便把IIC设备分为主设备和从设备,基本上谁控制时钟线(即控制SCL的电平高低变换)谁就是主设备。
简单性和有效性。 由于接口直接在组件之上,因此IIC 总线占用的空间非常小,减少了电路板的空间和芯片管脚的数量,降 低了互联成本。总线的长度可高达25 英尺,并且能够 10Kbps 的最大传输速率支持 40 个组件 多主控(multimastering) 其中任何能够进行发送和接收的设备都可以成为主总线。一个主控能够控制信号的传输和时钟频率。当然,在任何时间点上只能有一个主控。
IIC 串行总线一般有两根信号线,一根是双向的数据线 SDA ,另一根是时钟线 SCL ,其时钟信号是由主控 器件产生。所有接到IIC 总线设备上的串行数据 SDA 都接到总线的 SDA 上,各设备的时钟线 SCL 接到总线 的SCL 上。对于并联在一条总线上的每个 IC 都有唯一的地址。
分析虚线区间可得:要发送起始信号,首先SCL为高电平,SDA也为高电平,延时>4.7us,SDA被拉低,再延时>4.7us
void IIC_Start()
{
SCL = 0;//防止雪花屏
SDA = 1;
SCL = 1;
_nop_();
SDA = 0;
_nop_();
}
分析虚线区域可得 :要发送终止信号,SCL为高电平,SDA为低电平,延时>4.7us后,SDA被拉高,延时>4.7us
void IIC_Stop()
{
SCL = 0;//防止雪花屏
SDA = 0;
SCL = 1;
_nop_();
SDA = 1;
_nop_();
}
发送器每发送一个字节(8个 bit ),就在时钟脉冲 9 期间释放(SDA置1)数据线,由接收器反馈一个应答信号。 应答信号为低电平时,规定为有效应答位(ACK ,简称应答位),表示接收器已经成功地接收了该字节应答信号为高电平时,规定为非应答位(NACK),一般表示接收器接收该字节没有成功。
检查应答信号:首先再时钟脉冲9释放数据线即将SDA置1,SCL为低电平,延时几位秒拉高SCL,延时>4us,检测若SDA为低电平则为应答模式,SDA为高电平则为非应答模式
char IIC_ACK()
{
char flag;
SDA = 1;//就在时钟脉冲9期间释放数据线
SCL = 0;
_nop_();//约5us
SCL = 1;
_nop_();
flag = SDA;//检测到底是0应答模式还是1非应答模式
_nop_();
SCL = 0;
_nop_();
return flag;
}
IIC发送数据分析
根据上面发送数据的时序图分析可知,SDA状态变换的时候一定是SCL为低电平,拉低SCL将数据的最高位取出,延时几微秒后释放SCL开始传输,数据传输结束后,拉低SCL为下一位传输做准备
void IIC_SendByte(char tmp)
{
unsigned char i;
for(i=0;i<8;i++){
SCL = 0;//观察时序图可知,只有在SCL=0的时候SDA才能做出状态变换
SDA = tmp & 0x80;//取出最高位因为IIC是从高位传输,如果tem最高位为0,那么0&1=0,将0传入SDA
_nop_();//延时约5us
SCL = 1;//释放SCL,让数据传输
_nop_();
SCL = 0;//拉低SCL为下一位传输做准备
_nop_();
tmp = tmp << 1;//tmp左移一位,传输第二位
}
}
IIC写模式配置
写模式分为:写数据,写命令
由上图可知,第一个配置的是:Slave Address: Slave Address前6位是固定的,为011110 后两位为SA0,R/W# 查询数据手册:
SA0主要是区分多个Oled挂在IIC上到底是哪一个,本次项目只有一个Oled,所以配置为0
R/W#:如果要配置为写模式,那么R/W#要配置为逻辑0
Slave Address 和 Control Byte之间有一个ACK!!!! Slave Address之前开有一个Start
第二个配置的是 Control Byte:
第一位为Co:有数据手册可知道,如果将Co配置成0,那么就是传输数据
第二位为D/C:将D/C配置成0,发送指令,配置成1,发送数据
void Oled_Write_Cmd(unsigned char cmd)
{
// IICStart
IIC_Start();
// Slave Address
IIC_SendByte(0x78);
// ACK
IIC_ACK();
// control byte data:(0)(1)000000 cmd:(0)(0)000000
IIC_SendByte(0x00);
// ACK
IIC_ACK();
//写入数据/指令
IIC_SendByte(cmd);
//ACK
IIC_ACK();
//STOP
IIC_Stop();
}
void Oled_Write_Data(unsigned char datas)
{
// IICStart
IIC_Start();
// Slave Address
IIC_SendByte(0x78);
// ACK
IIC_ACK();
// control byte data:(0)(1)000000 cmd:(0)(0)000000
IIC_SendByte(0x40);
// ACK
IIC_ACK();
//写入数据/指令
IIC_SendByte(datas);
//ACK
IIC_ACK();
//STOP
IIC_Stop();
}
根据数据手册可以查得Oled初始化程序
void Oled_Init(void){
Oled_Write_Cmd(0xAE);//--display off
Oled_Write_Cmd(0x00);//---set low column address
Oled_Write_Cmd(0x10);//---set high column address
Oled_Write_Cmd(0x40);//--set start line address
Oled_Write_Cmd(0xB0);//--set page address
Oled_Write_Cmd(0x81); // contract control
Oled_Write_Cmd(0xFF);//--128
Oled_Write_Cmd(0xA1);//set segment remap
Oled_Write_Cmd(0xA6);//--normal / reverse
Oled_Write_Cmd(0xA8);//--set multiplex ratio(1 to 64)
Oled_Write_Cmd(0x3F);//--1/32 duty
Oled_Write_Cmd(0xC8);//Com scan direction
Oled_Write_Cmd(0xD3);//-set display offset
Oled_Write_Cmd(0x00);//
Oled_Write_Cmd(0xD5);//set osc division
Oled_Write_Cmd(0x80);//
Oled_Write_Cmd(0xD8);//set area color mode off
Oled_Write_Cmd(0x05);//
Oled_Write_Cmd(0xD9);//Set Pre-Charge Period
Oled_Write_Cmd(0xF1);//
Oled_Write_Cmd(0xDA);//set com pin configuartion
Oled_Write_Cmd(0x12);//
Oled_Write_Cmd(0xDB);//set Vcomh
Oled_Write_Cmd(0x30);//
Oled_Write_Cmd(0x8D);//set charge pump enable
Oled_Write_Cmd(0x14);//
Oled_Write_Cmd(0xAF);//--turn on oled panel
}
Oled由三种点亮模式,页模式,水平模式,垂直模式
由上表可知,发送0x20选择配置Memory Addressing Mode,发送0x02就可以配置成页模式(不配置默认情况也是页模式),发送0x20,0x01配置垂直模式,发送0x20,0x00,配置水平模式
PAGE0----PAGE7
第一列
//2选择一个位置
//2.1选择页地址模式
Oled_Write_Cmd(0x20);
Oled_Write_Cmd(0x02);
//2.2选择PAGE0(第一行) 1011 0000
// 0x B 0
Oled_Write_Cmd(0xB0);
//选择列(第一列)
Oled_Write_Cmd(0x00);
Oled_Write_Cmd(0x10););
因为Oled会保留上一次得数据,所以每次显示可能会花屏,所以需要写一个清屏函数
void Oled_Clear()
{
unsigned int i,j;//用char也会出现雪花,因为char型的范围是-127 -- 128,for循环会到127的时候i++会越界
for(i=0;i<8;i++){
//PAGE0 --- PAGE7
Oled_Write_Cmd(0xB0+i);
//第0列
Oled_Write_Cmd(0x00);
Oled_Write_Cmd(0x10);
//0-127列依次写入0,写入数据自动偏移
for(j=0;j<128;j++){
Oled_Write_Data(0x00);//在PAGE0第一列写完后会自动跳到第二列,直到PAGE7第127列
}
}
}
先进行配置,配置好后再点击基本操作,输入好后,CTRL+Enter,再点击取模方式,选择C51
将生成的16进制数复制粘贴到程序中去可得
代码实现
#include "reg52.h"
#include
sbit SCL = P0^1;
sbit SDA = P0^3;
void IIC_Start()
{
SCL = 0;//防止雪花屏
SDA = 1;
SCL = 1;
_nop_();
SDA = 0;
_nop_();
}
void IIC_Stop()
{
SCL = 0;//防止雪花屏
SDA = 0;
SCL = 1;
_nop_();
SDA = 1;
_nop_();
}
char IIC_ACK()
{
char flag;
SDA = 1;//就在时钟脉冲9期间释放数据线
SCL = 0;
_nop_();//约5us
SCL = 1;
_nop_();
flag = SDA;//检测到底是0应答模式还是1非应答模式
_nop_();
SCL = 0;
_nop_();
return flag;
}
void IIC_SendByte(char tmp)
{
unsigned char i;
for(i=0;i<8;i++){
SCL = 0;//观察时序图可知,只有在SCL=0的时候SDA才能做出状态变换
SDA = tmp & 0x80;//取出最高位因为IIC是从高位传输,如果tem最高位为0,那么0&1=0,将0传入SDA
_nop_();//延时约5us
SCL = 1;//释放SCL,让数据传输
_nop_();
SCL = 0;//拉低SCL为下一位传输做准备
_nop_();
tmp = tmp << 1;//tmp左移一位,传输第二位
}
}
void Oled_Write_Cmd(unsigned char cmd)
{
// IICStart
IIC_Start();
// Slave Address
IIC_SendByte(0x78);
// ACK
IIC_ACK();
// control byte data:(0)(1)000000 cmd:(0)(0)000000
IIC_SendByte(0x00);
// ACK
IIC_ACK();
//写入数据/指令
IIC_SendByte(cmd);
//ACK
IIC_ACK();
//STOP
IIC_Stop();
}
void Oled_Write_Data (unsigned char datas)
{
// IICStart
IIC_Start();
// Slave Address
IIC_SendByte(0x78);
// ACK
IIC_ACK();
// control byte data:(0)(1)000000 cmd:(0)(0)000000
IIC_SendByte(0x40);
// ACK
IIC_ACK();
//写入数据/指令
IIC_SendByte(datas);
//ACK
IIC_ACK();
//STOP
IIC_Stop();
}
void Oled_Init(void){
Oled_Write_Cmd(0xAE);//--display off
Oled_Write_Cmd(0x00);//---set low column address
Oled_Write_Cmd(0x10);//---set high column address
Oled_Write_Cmd(0x40);//--set start line address
Oled_Write_Cmd(0xB0);//--set page address
Oled_Write_Cmd(0x81); // contract control
Oled_Write_Cmd(0xFF);//--128
Oled_Write_Cmd(0xA1);//set segment remap
Oled_Write_Cmd(0xA6);//--normal / reverse
Oled_Write_Cmd(0xA8);//--set multiplex ratio(1 to 64)
Oled_Write_Cmd(0x3F);//--1/32 duty
Oled_Write_Cmd(0xC8);//Com scan direction
Oled_Write_Cmd(0xD3);//-set display offset
Oled_Write_Cmd(0x00);//
Oled_Write_Cmd(0xD5);//set osc division
Oled_Write_Cmd(0x80);//
Oled_Write_Cmd(0xD8);//set area color mode off
Oled_Write_Cmd(0x05);//
Oled_Write_Cmd(0xD9);//Set Pre-Charge Period
Oled_Write_Cmd(0xF1);//
Oled_Write_Cmd(0xDA);//set com pin configuartion
Oled_Write_Cmd(0x12);//
Oled_Write_Cmd(0xDB);//set Vcomh
Oled_Write_Cmd(0x30);//
Oled_Write_Cmd(0x8D);//set charge pump enable
Oled_Write_Cmd(0x14);//
Oled_Write_Cmd(0xAF);//--turn on oled panel
}
void Oled_Clear()
{
unsigned int i,j;//用char也会出现雪花,因为char型的范围是-127 -- 128,for循环会到127的时候i++会越界
for(i=0;i<8;i++){
//PAGE0 --- PAGE7
Oled_Write_Cmd(0xB0+i);
//第0列
Oled_Write_Cmd(0x00);
Oled_Write_Cmd(0x10);
//0-127列依次写入0,写入数据自动偏移
for(j=0;j<128;j++){
Oled_Write_Data(0x00);//在PAGE0第一列写完后会自动跳到第二列,直到PAGE7第127列
}
}
}
/*-- 文字: 谭 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
char t1[16]={0x40,0x40,0x42,0xCC,0x00,0x00,0x3A,0xAA,0xAA,0xBE,0xAA,0xBE,0xAA,0xAA,0x3A,0x00};
char t2[16]={0x00,0x00,0x00,0x3F,0x10,0x08,0x20,0x2F,0x2A,0x2A,0xFA,0x2A,0x2A,0x2F,0x20,0x00};
/*-- 文字: 某 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
char m1[16]={0x04,0x04,0x04,0x04,0xFF,0x24,0x24,0x24,0x24,0x24,0xFF,0x04,0x04,0x04,0x04,0x00};
char m2[16]={0x44,0x44,0x24,0x24,0x15,0x0D,0x05,0xFF,0x05,0x0D,0x15,0x24,0x24,0x44,0x44,0x00};
/*-- 文字: 某 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
char m3[16]={0x04,0x04,0x04,0x04,0xFF,0x24,0x24,0x24,0x24,0x24,0xFF,0x04,0x04,0x04,0x04,0x00};
char m4[16]={0x44,0x44,0x24,0x24,0x15,0x0D,0x05,0xFF,0x05,0x0D,0x15,0x24,0x24,0x44,0x44,0x00};
void main()
{
unsigned int i;
_nop_();
Oled_Init();
//2选择一个位置
//2.1选择页地址模式
Oled_Write_Cmd(0x20);
Oled_Write_Cmd(0x02);
Oled_Clear();//清屏,否则会出现雪花(雪花是因为内存太杂乱造成的)
//2.2选择PAGE0(第一行) 1011 0000
// 0x B 0
Oled_Write_Cmd(0xB0);
//选择列(第一列)
Oled_Write_Cmd(0x00);
Oled_Write_Cmd(0x10);
//3.显示一个A
for(i=0;i<16;i++){
Oled_Write_Data(t1[i]);
}for(i=0;i<16;i++){
Oled_Write_Data(m1[i]);
}
for(i=0;i<16;i++){
Oled_Write_Data(m3[i]);
}
//选择第二行(用两行来显示字符,第一行显示字符上半部分,第二行显示字符下半部分)
Oled_Write_Cmd(0xB1);
//选择列(第一列)
Oled_Write_Cmd(0x00);
Oled_Write_Cmd(0x10);
//3.显示一个A
for(i=0;i<16;i++){
Oled_Write_Data(t2[i]);
}
for(i=0;i<16;i++){
Oled_Write_Data(m2[i]);
}
for(i=0;i<16;i++){
Oled_Write_Data(m4[i]);
}
while(1);
}
代码实现
#include "reg52.h"
#include
sbit SCL = P0^1;
sbit SDA = P0^3;
void IIC_Start()
{
SCL = 0;//防止雪花屏
SDA = 1;
SCL = 1;
_nop_();
SDA = 0;
_nop_();
}
void IIC_Stop()
{
SCL = 0;//防止雪花屏
SDA = 0;
SCL = 1;
_nop_();
SDA = 1;
_nop_();
}
char IIC_ACK()
{
char flag;
SDA = 1;//就在时钟脉冲9期间释放数据线
SCL = 0;
_nop_();//约5us
SCL = 1;
_nop_();
flag = SDA;//检测到底是0应答模式还是1非应答模式
_nop_();
SCL = 0;
_nop_();
return flag;
}
void IIC_SendByte(char tmp)
{
unsigned char i;
for(i=0;i<8;i++){
SCL = 0;//观察时序图可知,只有在SCL=0的时候SDA才能做出状态变换
SDA = tmp & 0x80;//取出最高位因为IIC是从高位传输,如果tem最高位为0,那么0&1=0,将0传入SDA
_nop_();//延时约5us
SCL = 1;//释放SCL,让数据传输
_nop_();
SCL = 0;//拉低SCL为下一位传输做准备
_nop_();
tmp = tmp << 1;//tmp左移一位,传输第二位
}
}
void Oled_Write_Cmd(unsigned char cmd)
{
// IICStart
IIC_Start();
// Slave Address
IIC_SendByte(0x78);
// ACK
IIC_ACK();
// control byte data:(0)(1)000000 cmd:(0)(0)000000
IIC_SendByte(0x00);
// ACK
IIC_ACK();
//写入数据/指令
IIC_SendByte(cmd);
//ACK
IIC_ACK();
//STOP
IIC_Stop();
}
void Oled_Write_Data (unsigned char datas)
{
// IICStart
IIC_Start();
// Slave Address
IIC_SendByte(0x78);
// ACK
IIC_ACK();
// control byte data:(0)(1)000000 cmd:(0)(0)000000
IIC_SendByte(0x40);
// ACK
IIC_ACK();
//写入数据/指令
IIC_SendByte(datas);
//ACK
IIC_ACK();
//STOP
IIC_Stop();
}
void Oled_Init(void){
Oled_Write_Cmd(0xAE);//--display off
Oled_Write_Cmd(0x00);//---set low column address
Oled_Write_Cmd(0x10);//---set high column address
Oled_Write_Cmd(0x40);//--set start line address
Oled_Write_Cmd(0xB0);//--set page address
Oled_Write_Cmd(0x81); // contract control
Oled_Write_Cmd(0xFF);//--128
Oled_Write_Cmd(0xA1);//set segment remap
Oled_Write_Cmd(0xA6);//--normal / reverse
Oled_Write_Cmd(0xA8);//--set multiplex ratio(1 to 64)
Oled_Write_Cmd(0x3F);//--1/32 duty
Oled_Write_Cmd(0xC8);//Com scan direction
Oled_Write_Cmd(0xD3);//-set display offset
Oled_Write_Cmd(0x00);//
Oled_Write_Cmd(0xD5);//set osc division
Oled_Write_Cmd(0x80);//
Oled_Write_Cmd(0xD8);//set area color mode off
Oled_Write_Cmd(0x05);//
Oled_Write_Cmd(0xD9);//Set Pre-Charge Period
Oled_Write_Cmd(0xF1);//
Oled_Write_Cmd(0xDA);//set com pin configuartion
Oled_Write_Cmd(0x12);//
Oled_Write_Cmd(0xDB);//set Vcomh
Oled_Write_Cmd(0x30);//
Oled_Write_Cmd(0x8D);//set charge pump enable
Oled_Write_Cmd(0x14);//
Oled_Write_Cmd(0xAF);//--turn on oled panel
}
void Oled_Clear()
{
unsigned int i,j;//用char也会出现雪花,因为char型的范围是-127 -- 128,for循环会到127的时候i++会越界
for(i=0;i<8;i++){
//PAGE0 --- PAGE7
Oled_Write_Cmd(0xB0+i);
//第0列
Oled_Write_Cmd(0x00);
Oled_Write_Cmd(0x10);
//0-127列依次写入0,写入数据自动偏移
for(j=0;j<128;j++){
Oled_Write_Data(0x00);//在PAGE0第一列写完后会自动跳到第二列,直到PAGE7第127列
}
}
}
/*-- 调入了一幅图像:C:\SIMATIC STEP7 V5.6 Chinese\无标题.bmp --*/
/*-- 宽度x高度=128x9x8位 --*/
code unsigned char buffer[] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF8,0x7C,0x3C,0x1E,
0x0E,0x0E,0x0E,0x1E,0x3C,0x7C,0xF8,0xF0,0xC0,0xC0,0xE0,0xF0,0xF0,0x78,0x38,0x3C,
0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0xF8,0xF0,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,0xE0,0xF0,0xF8,0x7C,0x3C,
0x1C,0x1C,0x1C,0x1C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFF,0xFE,0x80,
0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xFF,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,0xFE,0xFF,0xFF,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0F,0x0F,0x07,0x07,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFE,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x82,0x87,0x87,0xC7,0xCF,0xCE,0xEE,0xCE,
0x0E,0x1E,0x1C,0x9C,0x9C,0xDC,0xFC,0xFC,0xFC,0xFC,0x7C,0x3F,0x3F,0xFF,0xFC,0xE0,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xFC,0xF8,0x00,0x00,0xFF,0xFF,0xFF,0x07,
0x07,0x03,0x03,0x03,0x01,0x01,0x3F,0xFF,0xFF,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,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,
0xE0,0xE0,0xE0,0xF0,0x70,0x70,0x78,0x38,0x38,0x3C,0xFF,0xFF,0xFF,0x0E,0x0E,0x0E,
0x0E,0x0E,0x0F,0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x23,0x73,0x71,0x79,0x3D,0x3C,
0x1E,0x0E,0x0F,0x07,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,
0x1F,0x3E,0x3C,0x78,0x70,0x70,0x7C,0x7F,0x3F,0x0F,0x00,0x00,0x07,0x0F,0x1F,0x1C,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x7F,0xFF,0xFC,0x00,0x00,0x00,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,0xC0,0xC1,0xFF,0xFF,0xFF,0xF0,0xF0,0x78,
0x38,0x3C,0x1C,0x1C,0x1C,0x1E,0x0E,0x0F,0x07,0x03,0x03,0x03,0x03,0x01,0x01,0x01,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFC,0xFF,0xFF,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x80,0xC0,0xC0,0xC1,0xC3,0xE3,0xE3,0xE1,0xC1,0x00,0x01,0x03,0x0F,0x3F,
0x7E,0x78,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xFF,0x7F,0x1F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x03,0x03,0x03,0x01,0x0F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x03,0x07,0x07,0x0F,0x1E,0x1C,0x1C,0x3C,0x38,0x38,0x38,0x38,
0x38,0x38,0x38,0x3C,0x1C,0x1E,0x1F,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,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0xF0,0xF8,0xF1,0xE3,0xC3,0xE3,0xE0,0xF0,0x70,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1E,0x0F,0x0F,0x07,0x07,0x03,0x03,0x07,0x0F,0x1F,0x3E,0x3C,0x38,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void Oled_photo(unsigned char temp)
{
unsigned int i;//用char也会出现雪花,因为char型的范围是-127 -- 128,for循环会到127的时候i++会越界
unsigned int j;
for(i=0;i<8;i++){
//PAGE0 --- PAGE7
Oled_Write_Cmd(0xB0+i);
//第0列
Oled_Write_Cmd(0x00);
Oled_Write_Cmd(0x10);
//0-127列依次写入0,写入数据自动偏移
for(j=128*i;j