5_OLED液晶屏使用文档
文件网盘链接:https://pan.baidu.com/s/158e_RyHuAqLyWNqZZhgi2A?pwd=1111 提取码:1111
一、OLED液晶屏使用逻辑
二、OLED液晶屏硬件说明
OLED液晶屏可以使用IIC、6800并行接口、8080并行接口、4线串口和3线串口五种接口协议。每种协议所接硬件引脚和指令时序图都不同。本例程以IIC协议为例,使用IIC协议的液晶屏硬件引脚如下表所示:
IIC协议将设备分为主机和从机,单片机是主机,OLED液晶屏是从机。液晶屏的地址在硬件上面设置,如下图红框所示,通过移动电阻的位置改变从机地址为0x78或0x7A。
从机地址指令格式如下表所示。
三、IIC协议时序图
1、IIC的开始、停止、应答和不应答信号时序图
开始信号:SCL高电平,SDA高电平,SDA低电平,SCL低电平
停止信号:SCL高电平,SDA低电平,SDA高电平
应答信号(ACK):SCL低电平,SDA低电平,SCL高电平,SCL低电平
不应答信号(NACK):SCL低电平,SDA高电平,SCL高电平,SCL低电平
根据后面介绍的液晶屏指令格式可以知道,对液晶屏操作不需要使用NACK信号,因此了解即可。
2、IIC的数据传输
传输“1”:SCL低电平,SDA高电平,SCL高电平,SCL低电平
传输“0”:SCL低电平,SDA低电平,SCL高电平,SCL低电平
在SCL低电平期间,改变SDA的电平。在SCL高电平期间,保持SDA电平稳定
四、OLED液晶屏指令格式
液晶屏一条指令的组成部分如下:
开始信号+从机地址+ACK+控制字节+ACK+数据字节+ACK+停止信号
1、从机地址如下表所示,本例程SA0=0,R/W#=0,因此从机地址为0x78。
2、控制字节如下表所示,本例程Co位固定为0,发指令时(D/C#=0),控制字节为0x00。发显示数据时(D/C#=1),控制字节为0x40。
五、液晶屏的寻址模式
在液晶屏上显示字符或画图时,首先要写地址,然后再向该地址里写字符或图片编码的数据。因此首先要知道液晶屏的地址分布和寻址模式。液晶屏的寻址模式分为三种:页寻址、水平寻址和垂直寻址。
1、地址分布
液晶屏纵向分为8页(每页8行),横向分为127列。其中页0页7地址是0xb00xb7。列0列127地址是0x000x7f。如下表所示。
2、页寻址模式
页寻址方向如下图所示。每写完一个地址的数据后,地址计数器AC自动加一,指向下一列。当写完第127列后,AC自动回到第0列,页数不变,因此写完一页后,我们要手动改变页数才能在下一页写数。
3、水平寻址模式
水平寻址方向如下图所示。写完最后一列时,AC自动回到第0列,页地址计数器自动加一。当写完页7的第127列后,自动回到页0的第0列。
我们可以通过指令设置水平寻址区域的起始页为n、起始列为m(默认是页0和列0)。
4、垂直寻址模式
垂直寻址方向如下图所示。每写完一个地址的数据后,页地址计数器自动加一。当写完第0列后,页地址计数器自动回到页0,列地址计数器AC自动加一。当写完页7的第127列后,自动回到页0的第0列。
我们可以通过指令设置垂直寻址区域的起始页为n、起始列为m(默认是页0和列0)。
六、在液晶屏上写字
本例程以页寻址模式为例,在液晶屏上写字的步骤:
1、设置页寻址模式(本例程在代码初始化函数中设置了页寻址模式,页寻址模式指令0x20)
2、设置起始页地址(页0页7地址是0xb00xb7)
3、设置列地址(SSD1306驱动芯片指令规则,8位列地址先设置高4位,再设置低4位,具体的指令内容查看下面的指令表和代码例程解释)
4、写字符数据
七、在液晶屏上画图
本例程以页寻址模式为例,在液晶屏上画图的步骤:
1、设置页寻址模式(本例程在代码初始化函数中设置了页寻址模式,页寻址模式指令0x20)
2、设置起始页地址和起始列地址
3、逐一给起始列到最后一列每个位置写图片数据
4、一页写完后,重复步骤2,设置新的起始页地址和起始列地址,然后写数据。直到图片数据发完完成
八、OLED液晶屏指令表
OLED液晶屏常用指令如下表所示(不清晰的话请查看网盘原件)
九、原理图
本次例程是用IIC协议的OLED液晶屏(硬件4个引脚)。液晶屏外接3.3V电压和GND,然后在单片机上面飞出3根线接液晶屏的SCL时钟口、SDA数据口、GND即可。这次不画原理图了,可以使用面包板飞线比较方便。
十、代码
1、oled的h文件
点击查看代码
#ifndef __OLED_H_
#define __OLED_H_
#define uint8 unsigned char
#define uint16 unsigned int
#define uint32 unsigned long
sbit OLED_SCL = P1 ^ 0; //SCL脚(时钟)
sbit OLED_SDA = P1 ^ 1; //SDA脚(数据)
#define SCL_L() OLED_SCL = 0 //SCL置1
#define SCL_H() OLED_SCL = 1 //SCL置0
#define SDA_L() OLED_SDA = 0 //SDA置1
#define SDA_H() OLED_SDA = 1 //SDA置0
void Delay_1ms(uint16 xms);
void OLED_Init();
void IIC_Start();
void IIC_Stop();
void IIC_Ack();
void Write_IIC_Byte(uint8 IIC_Byte);
void Write_IIC_Command(uint8 IIC_Command);
void Write_IIC_Data(uint8 IIC_Data);
void OLED_Set_Pos(uint8 x, uint8 y);
void OLED_Clear();
void OLED_Display_On();
void OLED_Display_Off();
void OLED_ShowChar(uint8 x, uint8 y, uint8 ch);
void OLED_ShowNum(uint8 x, uint8 y, uint32 number);
void OLED_ShowString(uint8 x,uint8 y,uint8 *str);
void OLED_ShowChinese(uint8 x,uint8 y,uint8 pos);
void OLED_DrawBMP(uint8 x0, uint8 y0, uint8 x1, uint8 y1, uint8 *p_bmp);
#endif
2、oled的c文件
点击查看代码
/*
*** OLED的GDDRAM地址分布
*** 页寻址模式
*** 纵坐标是页地址(取值范围0~7),每页8行
*** 横坐标是列地址(取值范围0~127)
*** 即64行*128列
*/
#include <reg52.h>
#include "oled.h"
#include "oledfont.h"
/**********************************************************
函数名:Delay_1ms(uint16 xms)
函数功能:粗略延时xms
参数列表:uint16 xms 要延时的毫秒数
函数返回值:无
***********************************************************/
void Delay_1ms(uint16 xms)
{
uint16 x,y;
for(x=xms;x>0;x--)
{
for(y=114;y>0;y--);
}
}
/**********************************************************
函数名:OLED_Init()
函数功能:液晶屏初始化
参数列表:无
函数返回值:无
注意:初始化过程请参考具体厂家给出的步骤
***********************************************************/
void OLED_Init()
{
Write_IIC_Command(0xAE); //关显示
Write_IIC_Command(0xD5); //设置显示器时钟分频率和晶振频率
Write_IIC_Command(0x80); //默认值,晶振频率8,显示器时钟分频率1
Write_IIC_Command(0xA8); //设置复用率(默认值)
Write_IIC_Command(0x3F); //屏幕的0~63行都使用
Write_IIC_Command(0xD3); //设置垂直方向显示偏移量
Write_IIC_Command(0x00); //垂直方向显示不偏移
Write_IIC_Command(0x40); //设置起始行地址,第0行
Write_IIC_Command(0xA1); //设置SEG重映射,软件第127列对应硬件第0列
Write_IIC_Command(0xC8); //设置COM口扫描方向,从COM63~COM0逆向扫描
Write_IIC_Command(0xDA); //设置COM口引脚配置
Write_IIC_Command(0x12); //禁止COM口左/右重映射,COM口引脚交叉配置
Write_IIC_Command(0x81); //设置对比度
Write_IIC_Command(0xFF); //对比度等级255级
Write_IIC_Command(0xD9); //设置预充电周期
Write_IIC_Command(0xF1);
Write_IIC_Command(0xDB); //设置VCOMH取消选择水平
Write_IIC_Command(0x30);
Write_IIC_Command(0xA4); //开显示后屏幕会根据显示数据的变化而变化
Write_IIC_Command(0xA6); //正常显示(像素点写1点亮)
Write_IIC_Command(0x8D); //进入充电泵设置
Write_IIC_Command(0x14); //使能充电泵
Write_IIC_Command(0xAF); //开显示
Write_IIC_Command(0x20); //进入内存寻址模式设置
Write_IIC_Command(0x02); //设置页寻址模式
Write_IIC_Command(0xB0); //设置页地址页0(起始页页0)
Write_IIC_Command(0x10); //设置列地址高4位(起始列第0列)
Write_IIC_Command(0x00); //设置列地址低4位
}
/**********************************************************
函数名:IIC_Start()
函数功能:IIC起始信号
参数列表:无
函数返回值:无
***********************************************************/
void IIC_Start()
{
SCL_H(); //SCL置1
SDA_H(); //SDA置1
//单片机频率高的需要在此考虑延时,SCL维持高电平要大于4us
SDA_L(); //SDA置0
SCL_L(); //SCL置0,钳住IIC总线,准备后续发送或接收数据
}
/**********************************************************
函数名:IIC_Stop()
函数功能:IIC终止信号
参数列表:无
函数返回值:无
***********************************************************/
void IIC_Stop()
{
SCL_H(); //SCL置1
SDA_L(); //SDA置0
//单片机频率高的需要在此考虑延时,SCL维持高电平要大于4us
SDA_H(); //SDA置1
}
/**********************************************************
函数名:IIC_Ack()
函数功能:IIC应答信号
参数列表:无
函数返回值:无
***********************************************************/
void IIC_Ack()
{
SCL_L(); //SCL置0
SDA_L(); //SDA置0
SCL_H(); //SCL置1
SCL_L(); //SCL置0
}
/**********************************************************
函数名:Write_IIC_Byte()
函数功能:发一个字节数据
参数列表:uint8 IIC_Byte 要发送的一个字节数据
函数返回值:无
***********************************************************/
void Write_IIC_Byte(uint8 IIC_Byte)
{
uint8 i, tmp;
tmp = IIC_Byte; //暂存IIC数据
//IIC发数据时序
//SCL高电平,SDA置1表示发1(置0表示发0)
//SCL低电平,SDA存储下一轮要发的数
SCL_L(); //SCL置0
for (i = 0; i < 8;i++) //从高位到低位发送IIC_Byte
{
if(tmp&0x80) //最高位是1,SDA发1
{
SDA_H();
}
else //最高位是0,SDA发0
{
SDA_L();
}
tmp = tmp << 1; //tmp左移1位准备下一轮发数
SCL_H(); //SCL置1
//单片机频率高的需要在此考虑延时,SCL维持高电平要大于4us
SCL_L(); //SCL置0
}
}
/**********************************************************
函数名:Write_IIC_Command()
函数功能:发送指令
参数列表:uint8 IIC_Command 要发送的指令数据
函数返回值:无
***********************************************************/
void Write_IIC_Command(uint8 IIC_Command)
{
IIC_Start(); //起始信号
Write_IIC_Byte(0x78); //发OLED的硬件地址,R/W#位置0
IIC_Ack(); //等待应答
//发控制字节。Co位置0,发完控制字节后还会发一字节数据。D/C#置0,在控制字节后面发的是指令数据
Write_IIC_Byte(0x00);
IIC_Ack();
Write_IIC_Byte(IIC_Command); //一字节指令数据
IIC_Ack();
IIC_Stop(); //停止信号
}
/**********************************************************
函数名:Write_IIC_Data()
函数功能:发送指令
参数列表:uint8 IIC_Data 要发送的显示数据(如字符编码、图片编码)
函数返回值:无
***********************************************************/
void Write_IIC_Data(uint8 IIC_Data)
{
IIC_Start();
Write_IIC_Byte(0x78); //发OLED的硬件地址,R/W#位置0
IIC_Ack();
//发控制字节,Co位置0。D/C#置1,在控制字节后面发的是显示数据
Write_IIC_Byte(0x40);
IIC_Ack();
Write_IIC_Byte(IIC_Data); //一字节显示数据
IIC_Ack();
IIC_Stop();
}
/**********************************************************
函数名:OLED_Set_Pos()
函数功能:设置液晶屏地址(页地址和列地址)
参数列表:
uint8 x 列地址(取值范围0~127)
uint8 y 页地址(取值范围0~7)
函数返回值:无
***********************************************************/
void OLED_Set_Pos(uint8 x, uint8 y)
{
Write_IIC_Command(0xB0 + y); //设置页地址(页0地址0xB0)
Write_IIC_Command(((x & 0xF0) >> 4) | 0x10); //设置列地址高4位
Write_IIC_Command((x & 0x0F)); //设置列地址低4位
//OLED的8位列地址要先设置高4位,再设置低4位
//1、设置列地址低4位的指令格式(高位到低位):0 0 0 0 L3 L2 L1 L0(L3~L0是列地址的低4位)
//2、设置列地址高4位的指令格式(高位到低位):0 0 0 1 H3 H2 H1 H0(H3~H0是列地址的高4位)
//例如:要在第127列写显示数据(列的序号从0开始),127的二进制是0111 1111,拆分出高4位是0111,低4位是1111
//因此得到设置列地址低4位的指令是0000 1111(即0x0F),设置列地址高4位的指令是0001 0111(即0x17)
//Write_IIC_Command(0x17); //设置127列的列地址高4位
//Write_IIC_Command(0x0F); //设置127列的列地址低4位
}
/**********************************************************
函数名:OLED_Clear()
函数功能:清屏,清屏后全黑
参数列表:无
函数返回值:无
***********************************************************/
void OLED_Clear()
{
uint8 i,j;
for(i=0;i<8;i++) //OLED有8页
{
//页寻址模式,每轮开始要手动改变页地址。列地址可以只写一次,之后地址计数器AC会自动加1
Write_IIC_Command(0xB0+i); //写页地址(页0地址0xB0)
Write_IIC_Command(0x00); //设置列地址高4位
Write_IIC_Command(0x10); //设置列地址低4位
for(j=0;j<128;j++) //OLED有128列
{
Write_IIC_Data(0); //OLED是共阴接法,写0是灭
}
}
}
/**********************************************************
函数名:OLED_Display_On()
函数功能:液晶屏开显示
参数列表:无
函数返回值:无
***********************************************************/
void OLED_Display_On()
{
Write_IIC_Command(0X8D); //进入充电泵设置
Write_IIC_Command(0X14); //使能充电泵
Write_IIC_Command(0XAF); //开显示
}
/**********************************************************
函数名:OLED_Display_Off()
函数功能:液晶屏关显示
参数列表:无
函数返回值:无
***********************************************************/
void OLED_Display_Off()
{
Write_IIC_Command(0X8D); //进入充电泵设置
Write_IIC_Command(0X10); //失能充电泵
Write_IIC_Command(0XAE); //关显示
}
/**********************************************************
函数名:OLED_ShowChar()
函数功能:在x列y页显示字符ch
参数列表:
uint8 x 列地址(取值范围0~127)
uint8 y 页地址(取值范围0~6),因为每个ASCII码尺寸16行*8列,因此参数页地址最大值是6,在代码中自动使用第7页
uint8 ch 要显示的ASCII字符
函数返回值:无
***********************************************************/
void OLED_ShowChar(uint8 x,uint8 y,uint8 ch)
{
uint8 pos = 0, i = 0;
//将ASCII码表的“空格”至“~”字符转换为OLED字符编码表CHAR_ASCII[](数组下标从0开始,单个字符尺寸16行*8列)
pos = ch - ' '; //获取要显示的字符ch在CHAR_ASCII[]中的位置
//ASCII码字符尺寸16行*8列,每页有8行,因此需要分成2页写数据
OLED_Set_Pos(x,y); //先写第y页的页地址和列地址
for(i=0;i<8;i++) //每页8个字节数据
{
Write_IIC_Data(CHAR_ASCII[pos*16+i]);
}
OLED_Set_Pos(x,y+1); //再写第y+1页的页地址和列地址
for(i=0;i<8;i++)
{
Write_IIC_Data(CHAR_ASCII[pos*16+i+8]);
}
}
/***********************************************************
函数名:void OLED_ShowNum()
函数功能:在液晶屏指定位置写一个十进制数
参数列表:
uint8 x 列地址(取值范围0~127)
uint8 y 页地址(取值范围0~6),因为每个ASCII码尺寸16行*8列,因此参数页地址最大值是6,在代码中自动使用第7页
uint32 number 要显示的十进制数(位数不超过10位)(uint32取值范围0~4294967295)
函数返回值:无
***********************************************************/
void OLED_ShowNum(uint8 x,uint8 y,uint32 number)
{
uint32 tmp=number; //暂存number的值
uint8 number_arr[10]={0}; //将tmp按位存入number_arr[]中
uint8 count_num = 0, ch = 0, i = 0, j = 0; // count_num记录本次要显示的十进制位数,ch记录十进制数当前要输出的那位数字
uint8 pos;
do
{
number_arr[count_num++] = (uint8)(tmp % 10); //将tmp从低位到高位存入number_arr[]中
tmp/=10; //舍弃tmp的个位
}while(tmp!=0); //当tmp等于0时结束循环
for(i=0;i<count_num;i++) //从高位到低位输出十进制数字
{
//获取本轮要输出的数字ch的ASCII码值。将10进制数字加上'0'的ASCII码转换为该10进制数字的ASCII码
ch = number_arr[count_num - 1 - i] + '0';
pos = ch - ' '; //获取要显示的字符ch在CHAR_ASCII[]中的位置
//ASCII码字符尺寸16行*8列,每页有8行,因此需要分成2页写数据
OLED_Set_Pos(x+i*8,y); //先写第y页的页地址和列地址(一个ASCII字符占8列,因此第i个字符在第x+i*8列)
for(j=0;j<8;j++) //每页8个字节数据
{
Write_IIC_Data(CHAR_ASCII[pos*16+j]);
}
OLED_Set_Pos(x+i*8,y+1); //再写第y+1页的页地址和列地址
for(j=0;j<8;j++)
{
Write_IIC_Data(CHAR_ASCII[pos*16+j+8]);
}
}
}
/***********************************************************
函数名:void OLED_ShowString()
函数功能:在液晶屏指定位置写一个ASCII型字符串
参数列表:
uint8 x 列地址(取值范围0~127)
uint8 y 页地址(取值范围0~6),因为每个ASCII码尺寸16行*8列,因此参数页地址最大值是6,在代码中自动使用第7页
uint8 *str 指向要显示的字符串的指针
函数返回值:无
***********************************************************/
void OLED_ShowString(uint8 x,uint8 y,uint8 *str)
{
uint8 j=0;
while (str[j]!='\0')
{
OLED_ShowChar(x,y,str[j]);
x+=8; //ASCII字符尺寸16行*8列,因此下一个字符的列地址要加8
if(x>120) //超出列地址范围(0~127)
{
x=0; //列地址归0
y+=2; //页地址加2(因为1个ASCII字符占16行,即2页)
}
j++; //指向下一个要显示的字符
}
}
/***********************************************************
函数名:void OLED_ShowChinese()
函数功能:在液晶屏指定位置写一个汉字
参数列表:
uint8 x 列地址(取值范围0~127)
uint8 y 页地址(取值范围0~6),因为每个汉字尺寸16行*16列,因此参数页地址最大值是6,在代码中自动使用第7页
uint8 pos 要显示的汉字在汉字编码表中的位置,CHAR_CHINESE[pos][16]
函数返回值:无
***********************************************************/
void OLED_ShowChinese(uint8 x,uint8 y,uint8 pos)
{
uint8 i=0;
//汉字尺寸16行*16列,每页有8行,因此需要分成2页写数据
OLED_Set_Pos(x,y); //先写第y页的页地址和列地址
for(i=0;i<16;i++) //汉字一页有16字节数据
{
Write_IIC_Data(CHAR_CHINESE[2*pos][i]);
}
OLED_Set_Pos(x,y+1); //再写第y+1页的页地址和列地址
for(i=0;i<16;i++)
{
Write_IIC_Data(CHAR_CHINESE[2*pos+1][i]);
}
}
/***********************************************************
函数名:void OLED_DrawBMP()
函数功能:在液晶屏上画图(尺寸128列*64行)
参数列表:
uint8 x0 图片起点列地址(取值范围0~128),第128列只用于if判断,没有实际写数
uint8 y0 图片起点页地址(取值范围0~8),第8页只用于if判断,没有实际写数
uint8 x1 图片终点列地址(取值范围x1>=x0)
uint8 y1 图片终点页地址(取值范围y1>=y0)
uint8* p_bmp 指向存储图片编码数据数组的指针
函数返回值:无
***********************************************************/
void OLED_DrawBMP(uint8 x0, uint8 y0,uint8 x1, uint8 y1,uint8* p_bmp)
{
uint8 x,y;
for(y=y0;y<y1;y++) //循环写页y0到页y1的数据
{
OLED_Set_Pos(x0,y); //设置第y页地址和第x0列地址
for(x=x0;x<x1;x++) //每页都从第x0列开始写数
{
Write_IIC_Data(*p_bmp++);
//p_bmp++; //指向下一个字节数据
}
}
}
3、oled字符和图片编码数据h文件
3.1 OLED字符编码数据h文件
点击查看代码
#ifndef __OLEDFONT_H__
#define __OLEDFONT_H__
#define uint8 unsigned char
/*
*** ASCII码的“空格”至“~”字符转换为OLDE液晶屏编码表
*** ASCII码尺寸:16行*8列。编码表存储在ROM中
*/
uint8 code CHAR_ASCII[]=
{
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
};
/*
*** 汉字编码表
*** 汉字尺寸16行*16列。编码表存储在ROM中
*/
uint8 code CHAR_CHINESE[][16]={
/* GB2312 16x16点阵字库*/
/* 你[0xC4E3] 16x16 */
{0x40,0x20,0xF8,0x07,0x40,0x20,0x18,0x0F,0x08,0xC8,0x08,0x08,0x28,0x18,0x00,0x00},
{0x00,0x00,0xFF,0x00,0x00,0x08,0x04,0x43,0x80,0x7F,0x00,0x01,0x06,0x0C,0x00,0x00},
/* 好[0xBAC3] 16x16 */
{0x10,0x10,0xF0,0x1F,0x10,0xF0,0x80,0x82,0x82,0x82,0xE2,0x92,0x8A,0xC6,0x80,0x00},
{0x40,0x22,0x15,0x08,0x14,0x63,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00}
};
#endif
3.2 图片编码数据
点击查看代码
#ifndef __BMP_H__
#define __BMP_H__
#define uint8 unsigned char
//图片编码数据,图片是一个微笑
uint8 code BMP[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,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,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x3C,0xC0,0x00,
0x00,0x00,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,0x1F,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,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,
0x0C,0x08,0x10,0x10,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x10,0x1C,0x06,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
#endif
4、main函数的c文件
点击查看代码
/*
功能:0.96寸OLED程序示例
引脚接线:
OLED的SCL->单片机P1.0
OLED的SDA->单片机P1.1
OLED的VCC->电源3.3~5V
电源、OLED、单片机要共地
*/
#include <reg52.h>
#include "oled.h"
#include "bmp.h"
void main()
{
uint8 *p_bmp = BMP; //p_bmp指针指向BMP[]图片编码数据数组
OLED_Init(); //初始化OLED
OLED_Clear(); //清屏
OLED_DrawBMP(0,0,128,8,p_bmp); //显示图片
Delay_1ms(2000); //延时2秒
OLED_Clear(); //清屏
while(1)
{
OLED_ShowChar(0,0,'a'); //在第0列第0页显示字符a
OLED_ShowChar(0,2,'b'); //在第0列第2页显示字符b
Delay_1ms(2000); //延时2秒
OLED_Clear(); //清屏
OLED_ShowNum(0, 0, 4294967295); //在第0列第0页显示10进制数字4294967295
OLED_ShowNum(0, 2, 4294967296); //在第0列第2页显示数字0(4294967296超出uint32范围变成0)
Delay_1ms(2000); //延时2秒
OLED_Clear(); //清屏
OLED_ShowString(0, 0, " hello world! "); //在第0列第0页显示字符串
OLED_ShowString(0, 2, " hello world! "); //在第0列第2页显示字符串
Delay_1ms(2000); //延时2秒
OLED_Clear(); //清屏
OLED_ShowChinese(0, 0, 0); //在第0列第0页显示汉字CHAR_CHINESE[0][16],即汉字:你
OLED_ShowChinese(0, 2, 1); //在第0列第2页显示汉字CHAR_CHINESE[1][16],即汉字:好
Delay_1ms(2000); //延时2秒
OLED_Clear(); //清屏
}
}
十一、字符和图片取模步骤
本次字符和图片取模使用软件PCtoLCD2002,先设置要对字符还是图片取模,如下图所示。
然后进入【选项】菜单,设置取模规则,如下图所示。
如下图所示,输入要取模的字符,然后生成字模数据即可。
点击【模式】菜单栏可以修改为图形模式。填写液晶屏尺寸128列*64行,如下图所示。
鼠标左键或右键点击像素点,可以点亮或熄灭像素点,画完图后点击生成字模,然后复制图片编码数据即可,如下图所示。