C51--OLED

2023-12-15 07:43:25

GME12864-12

OLED写入指令数据:

在这里插入图片描述
1、start()开始
2、slave address 存积地址:011110 xx
写入:b 0111 1000 (0x78)(R / W位置为0时,表示写入)
3、ACK
4、cotrol byte:(Co) (D / C)000000

(Co置为0时,接下来传输的信息包含数据字节data byte)
(D / C位置为0时,表示为命令;为 1 时,表示为数据)
0000 0000 写入命令
0100 0000 写入数据

5、ACK
6、写入指令/数据
7、ACK
8、STOP

//写入命令
void Oled_Write_Cmd(char dataCmd)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x00);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataCmd); //  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、STOP
}

//写入数据
void Oled_Write_Data(char dataData)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x40);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataData);//  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、STOP
}

OLED显示点:

VDD = 1.65V——3.3V
VCC = 7V —— 15V

128x64个点阵组成:

64=8Page*8bit
自动右移
横向:SEG0——SEG127
竖向:Page0——Page7

寻址模式:

页地址模式:

在这里插入图片描述
水平横向寻址,写到127时,他会返回到该行的头部。

1、发送cmd:0x20
2、发送cmd:0x02;(默认为页模式)

水平地址模式:

在这里插入图片描述
水平横向寻址,写到127时,他会返回到下一行的头部

垂直地址模式:

在这里插入图片描述
竖向寻址,到尾部时,会返回下一列的头部继续

页模式:显示一个点

配置页地址模式:
Oled_Write_Cmd(0x20);
Oled_Write_Cmd(0x02);
配置显示地址:
Oled_Write_Cmd(0xB0);//配置page1-8
Oled_Write_Cmd(0x00);//列地址,从头开始
Oled_Write_Cmd(0x10);

主函数:
1、OLED初始化
2、选择一个位置
2.1、确认为页面寻址模式

Oled_Write_Cmd(0x20);
Oled_Write_Cmd(0x02);

2.2、选择PAGE0

Oled_Write_Cmd(0xB0);//1011 0000(0xB0)配置page1-8.

3、显示一个点

#include "reg52.h"
#include "intrins.h"

sbit SCL = P0^1;
sbit SDA = P0^3;


void ICC_Start()
{
	SDA = 1;
	SCL = 1;
	_nop_();	//一个nop用时5us
	SDA = 0;
	_nop_();
}

void ICC_Stop()
{
	SDA = 0;
	SCL = 1;
	_nop_();
	SDA = 1;
	_nop_();
}

char ICC_ACK()
{
	char flag;
	
	SDA = 1;		//在时钟脉冲9期间释放
	_nop_();
	SCL = 1;
	_nop_();
	flag = SDA;
	_nop_();
	SCL = 0;
	_nop_();
	
	return flag;
}

void IIC_Send_Byte(char dataSend)
{
	int i;
	
	for(i = 0;i < 8;i++){
		SCL = 0;						//SCL低电平,让SDA做好数据准备
		SDA = dataSend & 0x80;			//与上1000 0000 获得dataSend的最高位,给SDA
		_nop_();						//发送数据建立的时间
		SCL = 1;						//SCL高电平,开始发送数据
		_nop_();						//发送数据需要时间
		SCL= 0;						//发送完毕,SCL拉回低电平
		_nop_();
		dataSend = dataSend << 1;
	}
}

//写入命令
void Oled_Write_Cmd(char dataCmd)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x00);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataCmd); //  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、STOP
}

//写入数据
void Oled_Write_Data(char dataData)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x40);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataData);//  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、STOP
}

void Oled_Init()
{

	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 main()
{
	
	Oled_Init();				//OLED初始化
	Oled_Write_Cmd(0x20);		//选择一个位置,确认为页面寻址模式
	Oled_Write_Cmd(0x02);
	Oled_Write_Cmd(0xB0);		//1011 0000(0xB0)配置page1-8.
								//显示一个点
	while(1);
}

页模式:显示字符

选择列地址显示
主函数:
1、OLED初始化
2、选择一个位置
2.1、确认为页面寻址模式

Oled_Write_Cmd(0x20);
Oled_Write_Cmd(0x02);

2.2、选择PAGE0

Oled_Write_Cmd(0xB0);//1011 0000(0xB0)配置page1-8.
Oled_Write_Cmd(0x00);//列地址,从头开始
Oled_Write_Cmd(0x10);

3、显示屏写入数据

用点阵液晶取模工具取模
要勾选纵向取模,文字倒序

显示字符A:

#include "reg52.h"
#include "intrins.h"

sbit SCL = P0^1;
sbit SDA = P0^3;


void ICC_Start()
{
	SCL = 0;	//防止雪花屏
	SDA = 1;
	SCL = 1;
	_nop_();	//一个nop用时5us
	SDA = 0;
	_nop_();
}

void ICC_Stop()
{
	SCL = 0;	//防止雪花屏
	SDA = 0;
	SCL = 1;
	_nop_();
	SDA = 1;
	_nop_();
}

char ICC_ACK()
{
	char flag;
	
	SDA = 1;		//在时钟脉冲9期间释放
	_nop_();
	SCL = 1;
	_nop_();
	flag = SDA;
	_nop_();
	SCL = 0;
	_nop_();
	
	return flag;
}

void IIC_Send_Byte(char dataSend)
{
	int i;
	
	for(i = 0;i < 8;i++){
		SCL = 0;						//SCL低电平,让SDA做好数据准备
		SDA = dataSend & 0x80;			//与上1000 0000 获得dataSend的最高位,给SDA
		_nop_();						//发送数据建立的时间
		SCL = 1;						//SCL高电平,开始发送数据
		_nop_();						//发送数据需要时间
		SCL= 0;						//发送完毕,SCL拉回低电平
		_nop_();
		dataSend = dataSend << 1;
	}
}

//写入命令
void Oled_Write_Cmd(char dataCmd)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x00);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataCmd); //  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、STOP
}

//写入数据
void Oled_Write_Data(char dataData)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x40);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataData);//  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、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()
{
	int i,j;
	//unsigned char i,j;		char范围-128——127,定义char类型会产生越界
	
	for(i = 0;i < 8;i++){
		Oled_Write_Cmd(0xB0 + i);		//Page0——Page7
		Oled_Write_Cmd(0x00);			//每个Page从0开始
		Oled_Write_Cmd(0x10);
		for(j = 0;j < 128;j++){			//0——127列,依次写入0,每写入数据列地址自动偏移。
			Oled_Write_Data(0);			
		}
	}
}

/*--  文字:  A  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   (一个Page为8位)--*/
char A1[8] = {0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00};

char A2[8] = {0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20};

void main()
{
	int i;
	
	Oled_Init();				//OLED初始化
	Oled_Write_Cmd(0x20);		//选择一个位置,确认为页面寻址模式
	Oled_Write_Cmd(0x02);
	
	Oled_Clear();				//清屏
	Oled_Write_Cmd(0xB0);		//1011 0000(0xB0)配置page1-8.
								//显示一个点
	Oled_Write_Cmd(0x00);		//列地址,从头开始
	Oled_Write_Cmd(0x10);
	
	for(i = 0;i < 8;i++){
		Oled_Write_Data(A1[i]);
	}

	Oled_Write_Cmd(0xB1);	
	Oled_Write_Cmd(0x00);
	Oled_Write_Cmd(0x10);
	
	for(i = 0;i < 8;i++){
		Oled_Write_Data(A2[i]);
	}
	while(1);
}
各数据类型大小和取值范围:
https://blog.csdn.net/weixin_42856843/article/details/81989737

页模式:显示图片

大小:128x64像素
保存模式:bmp模式

位图(Bitmap)模式:它没有进行数据压缩,其内部存储的色彩信息(灰度图,RGB 或 ARGB)直接以二进制的形式暴露在外,也十分方便借助计算机软件进行简单或深入的分析。

#include "reg52.h"
#include "intrins.h"

sbit SCL = P0^1;
sbit SDA = P0^3;


void ICC_Start()
{
	SCL = 0;	//防止雪花屏
	SDA = 1;
	SCL = 1;
	_nop_();	//一个nop用时5us
	SDA = 0;
	_nop_();
}

void ICC_Stop()
{
	SCL = 0;	//防止雪花屏
	SDA = 0;
	SCL = 1;
	_nop_();
	SDA = 1;
	_nop_();
}

char ICC_ACK()
{
	char flag;
	
	SDA = 1;		//在时钟脉冲9期间释放
	_nop_();
	SCL = 1;
	_nop_();
	flag = SDA;
	_nop_();
	SCL = 0;
	_nop_();
	
	return flag;
}

void IIC_Send_Byte(char dataSend)
{
	int i;
	
	for(i = 0;i < 8;i++){
		SCL = 0;						//SCL低电平,让SDA做好数据准备
		SDA = dataSend & 0x80;			//与上1000 0000 获得dataSend的最高位,给SDA
		_nop_();						//发送数据建立的时间
		SCL = 1;						//SCL高电平,开始发送数据
		_nop_();						//发送数据需要时间
		SCL= 0;						//发送完毕,SCL拉回低电平
		_nop_();
		dataSend = dataSend << 1;
	}
}

//写入命令
void Oled_Write_Cmd(char dataCmd)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x00);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataCmd); //  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、STOP
}

//写入数据
void Oled_Write_Data(char dataData)
{
	ICC_Start();			//	1、start()开始
	IIC_Send_Byte(0x78);	//	2、slave address  存积地址:011110 xx
							//	写入:b 0111 1000(0x78)(R/W位置为0时,表示写入)
	ICC_ACK();				//	3、ACK
	IIC_Send_Byte(0x40);	//	4、cotrol byte:(Co) (D/C)000000	

							//(Co置为0时,接下来传输的信息包含数据字节data byte)
							//(D / C位置为0时,表示为命令;为 1 时,表示为数据)
							//  0000 0000 写入命令
							//	0100 0000 写入数据
	ICC_ACK();				//	5、ACK
	IIC_Send_Byte(dataData);//  6、写入指令/数据
	ICC_ACK();				//	7、ACK
	ICC_Stop();				//	8、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()
{
	int i,j;
	//unsigned char i,j;		char范围-128——127,定义char类型会产生越界
	
	for(i = 0;i < 8;i++){
		Oled_Write_Cmd(0xB0 + i);		//Page0——Page7
		Oled_Write_Cmd(0x00);			//每个Page从0开始
		Oled_Write_Cmd(0x10);
		for(j = 0;j < 128;j++){			//0——127列,依次写入0,每写入数据列地址自动偏移。
			Oled_Write_Data(0);			
		}
	}
}

code unsigned char bmpImager[] = {

/*--  调入了一幅图像:12864演示图片.bmp  --*/
/*--  宽度x高度=128x64  (有128x8x8个数据)--*/
0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xF0,
0xF0,0xE0,0xE0,0x60,0x70,0x70,0x30,0x30,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x1C,
0x0C,0x1C,0x1C,0x1C,0x18,0x18,0x18,0x18,0x18,0x30,0x30,0x30,0x60,0x60,0xE0,0xE0,
0xE0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xF0,0xE0,0xC0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3E,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x1F,0x1F,0x07,0x07,0x03,
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,
0x01,0x01,0x03,0x07,0x0F,0x1F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,
0x7F,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0x70,0x30,0x30,0x30,0xF0,0xE0,0x00,0x00,
0x40,0xE0,0x70,0x30,0x30,0x30,0x70,0xF0,0xE0,0x00,0x00,0x00,0xF0,0xF0,0x70,0x30,
0x30,0x70,0xF0,0xE0,0x00,0x00,0xC0,0xE0,0x70,0x30,0x30,0x30,0x30,0x74,0xFF,0xFF,
0x00,0x00,0x00,0xE0,0xF0,0x30,0x30,0x30,0x70,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x07,0x0F,0x1F,0xFF,0xFF,0x0F,0x01,0x00,0x00,0x00,0x80,0xE0,0xF0,
0xF8,0xF8,0xFC,0xFC,0x7E,0x7E,0x7E,0xFE,0xFC,0xF8,0x60,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xF8,0xFC,0xFC,0xFE,0x7E,0xFE,0xFC,0xF8,
0xF8,0xF0,0xE0,0x80,0x00,0x00,0x00,0x01,0x0F,0xFF,0xFF,0x1F,0x0F,0x07,0x03,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x60,0x60,0xE0,0x60,0x7F,0x3F,0x02,0x00,
0x38,0x7D,0xFE,0x66,0xE6,0x66,0x76,0x7F,0x7F,0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,
0x00,0x00,0x7F,0x7F,0x00,0x00,0x1F,0x3F,0x7A,0x60,0xE0,0xE0,0x60,0x78,0x7F,0x7F,
0x00,0x00,0x38,0x7D,0x7F,0xE6,0x46,0x66,0x76,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xE0,0x00,0x00,0x00,0x3E,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x1F,0x03,0x00,0x00,0x00,0x60,0xF0,0xF8,
0xF8,0xF8,0xF0,0xF0,0x70,0x00,0x00,0x00,0x07,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0x00,0x80,0xE0,0xFF,0x3F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,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,0x01,0x03,0x0F,0x1C,0x38,0x60,0xE0,0xC1,0x81,
0x83,0x03,0x03,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x83,
0x83,0x83,0xC1,0xE0,0x70,0x38,0x1C,0x0F,0x03,0x80,0x80,0xA0,0xB0,0xB8,0xFC,0xF7,
0xF7,0x92,0x94,0xDC,0xF8,0xD0,0xC0,0x40,0x00,0x00,0x00,0xC0,0xC2,0x46,0xFC,0x40,
0x00,0x10,0x70,0xC7,0x9E,0xC0,0xFE,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xF0,
0xA0,0xB0,0xB3,0xFF,0xB2,0x90,0xB0,0xF0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x84,0x84,0x84,0x86,0xB6,0xE6,0x96,0x8E,0x86,0x86,0xC0,0xC0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x3F,0xFF,0xFF,0x7F,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0x7C,0x0C,0x0C,0x0C,0x0C,0x0C,
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFF,0x7F,0xFF,
0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x18,0x89,0x8C,0x96,0xB7,0xD5,0xD6,
0xD6,0xD6,0xDF,0xD7,0xCE,0x5C,0x18,0x18,0x08,0x00,0x00,0x00,0x00,0x40,0x7F,0xB0,
0xD8,0x6C,0x30,0x19,0x0F,0x1F,0x78,0xE0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x08,0x1F,
0x0C,0x0D,0x0C,0x7F,0xC4,0x84,0x86,0x87,0x80,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,
0x01,0x01,0x01,0x01,0x31,0x60,0xC0,0xFF,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0x7F,0xF8,0xE1,0xE1,0xC1,0xC1,0x81,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0xC1,0x81,0xC1,0xE1,0xF5,0xFE,0x1F,
0x01,0x00,0x00,0xE0,0xC0,0x60,0x60,0xC0,0xC0,0x00,0x01,0xE1,0xC1,0x61,0x61,0xC1,
0xC1,0x81,0x01,0x01,0xE1,0xE0,0x60,0x60,0xC0,0x80,0x00,0x60,0xF8,0xF8,0x40,0x01,
0xC1,0xE0,0x60,0x60,0xE0,0xC0,0x00,0x01,0xFD,0xF9,0x00,0xF8,0xFC,0x80,0xC0,0xE0,
0x60,0x00,0x00,0x00,0x01,0x01,0x01,0xC1,0xC1,0x61,0x61,0x61,0xE0,0xC0,0x00,0xC0,
0xE0,0x60,0x60,0x60,0xC0,0x00,0x01,0xE1,0xE0,0x60,0x60,0xE0,0xC0,0x60,0x60,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0x0F,0x0F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x03,0x07,0x03,0x03,
0x03,0x03,0x02,0x03,0x03,0x07,0x0F,0x1F,0x1F,0x1F,0x1F,0x1F,0x0F,0x07,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0x10,0x30,0x1F,0x0F,0x00,0x00,0xFF,0xBC,0x10,0x30,0x1F,
0x1F,0x0F,0x00,0x22,0xFF,0x18,0x10,0x10,0x1F,0x0F,0x00,0x00,0x1F,0x1F,0x10,0x08,
0x1E,0x1E,0x13,0x1B,0x1F,0x1F,0x00,0x00,0x1F,0x1F,0x00,0x1F,0x1F,0x03,0x07,0x1E,
0x18,0x00,0x00,0x18,0x18,0x00,0x04,0x0F,0x1D,0x30,0x10,0x10,0x1C,0x1C,0x00,0x0F,
0x1F,0x10,0x30,0x18,0x1F,0x07,0x00,0x1F,0x1F,0x00,0x00,0x1F,0x1F,0x00,0x00,0x1F,

};

void Oled_Show_Image(unsigned char *image)
{
	unsigned int j;
	unsigned char i;		//char范围-128——127,定义char类型会产生越界
	
	for(i = 0;i < 8;i++){
		Oled_Write_Cmd(0xB0 + i);		//Page0——Page7
		Oled_Write_Cmd(0x00);			//每个Page从0开始
		Oled_Write_Cmd(0x10);
		for(j = 128 * i;j < (128 * (i + 1));j++){			//0——127列,依次写入0,每写入数据列地址自动偏移。
			Oled_Write_Data(image[j]);			
		}
	}
}

void main()
{
	
	Oled_Init();				//OLED初始化
	Oled_Write_Cmd(0x20);		//选择一个位置,确认为页面寻址模式
	Oled_Write_Cmd(0x02);
	
	Oled_Clear();				//清屏
	Oled_Show_Image(bmpImager);
	

	while(1);
}

文章来源:https://blog.csdn.net/weixin_48208102/article/details/134866616
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。