51或stm32单片机OLED显示屏驱动及代码演示

OLED显示

基本参数:

•OLED(Organic Light Emitting Diode):有机发光二极管

•OLED显示屏:性能优异的新型显示屏,具有功耗低、相应速度快、宽视角、轻薄柔韧等特点

•0.96寸OLED模块:小巧玲珑、占用接口少、简单易用,是电子设计中非常常见的显示屏模块

•供电:3~5.5V,通信协议:I2C/SPI,分辨率:128*64

本篇文章默认你是有一些I2C通讯的基础知识的,所以在源码展示部分有直接调用的 I2C_SAND_BYTE(),I2C发送数据函数,如果对I2C的驱动函数不知道如何编写可以移步至我的这篇文章:I2C驱动代码

常见的硬件连接方式:
51或stm32单片机OLED显示屏驱动及代码演示_第1张图片
51或stm32单片机OLED显示屏驱动及代码演示_第2张图片

电亮方式:

将分辨率为128*64的屏幕分为多个8x8像素块来显示:

那么以8x8像素块为基本单位而言,行就有8个像素块,列就有16个像素块
51或stm32单片机OLED显示屏驱动及代码演示_第3张图片

单独对于一个小的8x8像素块而言,根据芯片的配置,采用“纵向取模下高位的方式”。即如图电亮第一列的像素点需要输入的数据为0x47,转化为二进制数据为0100 0111。二进制数的高位在下,低位在上。“1”表示电亮,“0”表示熄灭

51或stm32单片机OLED显示屏驱动及代码演示_第4张图片
对于英文,数字,汉字而言需要用不同方式的8x8元素块进行拼接显示,这样显示的效果最好,后续会详细说明

51或stm32单片机OLED显示屏驱动及代码演示_第5张图片
(下面的代码注释紊乱是编码的问题,复制到Keil5里选择ANSI编码就没问题了)

OLED初始化
#define OLED0561_ADD	0x78  // OLEDµÄI2CµØÖ·£¨½ûÖ¹Ð޸ģ©
#define COM				0x00  // OLED Ö¸Á½ûÖ¹Ð޸ģ©
#define DAT 			0x40  // OLED Êý¾Ý£¨½ûÖ¹Ð޸ģ©
void OLED0561_Init (void){//OLEDÆÁ¿ªÏÔʾ³õʼ»¯
	 OLED_DISPLAY_OFF(); //OLED¹ØÏÔʾ
 	 OLED_DISPLAY_CLEAR(); //Çå¿ÕÆÁÄ»ÄÚÈÝ
	 OLED_DISPLAY_ON(); //OLEDÆÁ³õʼֵÉèÖò¢¿ªÏÔʾ

}

void OLED_DISPLAY_ON (void){//OLEDÆÁ³õʼֵÉèÖò¢¿ªÏÔʾ
	u8 buf[28]={
	0xae,//0xae:¹ØÏÔʾ£¬0xaf:¿ªÏÔʾ
    0x00,0x10,//¿ªÊ¼µØÖ·£¨Ë«×Ö½Ú£©       
	0xd5,0x80,//ÏÔʾʱÖÓƵÂÊ£¿
	0xa8,0x3f,//¸´ÓÃÂÊ£¿
	0xd3,0x00,//ÏÔʾƫÒÆ£¿
	0XB0,//дÈëҳλÖã¨0xB0~7£©
	0x40,//ÏÔʾ¿ªÊ¼Ïß
	0x8d,0x14,//VCCµçÔ´
	0xa1,//ÉèÖöÎÖØÐÂÓ³É䣿
	0xc8,//COMÊä³ö·½Ê½£¿
	0xda,0x12,//COMÊä³ö·½Ê½£¿
	0x81,0xff,//¶Ô±È¶È£¬Ö¸Á0x81£¬Êý¾Ý£º0~255£¨255×î¸ß£©
	0xd9,0xf1,//³äµçÖÜÆÚ£¿
	0xdb,0x30,//VCCµçѹÊä³ö
	0x20,0x00,//ˮƽѰַÉèÖÃ
	0xa4,//0xa4:Õý³£ÏÔʾ£¬0xa5:ÕûÌåµãÁÁ
	0xa6,//0xa6:Õý³£ÏÔʾ£¬0xa7:·´É«ÏÔʾ
	0xaf//0xae:¹ØÏÔʾ£¬0xaf:¿ªÏÔʾ
	}; //
	I2C_SAND_BUFFER(OLED0561_ADD,COM,buf,28);
}

void OLED_DISPLAY_OFF (void){//OLEDÆÁ¹ØÏÔʾ
	u8 buf[3]={
		0xae,//0xae:¹ØÏÔʾ£¬0xaf:¿ªÏÔʾ
		0x8d,0x10,//VCCµçÔ´
	}; //
	I2C_SAND_BUFFER(OLED0561_ADD,COM,buf,3);
}

void OLED_DISPLAY_LIT (u8 x){//OLEDÆÁÁÁ¶ÈÉèÖã¨0~255£©
	I2C_SAND_BYTE(OLED0561_ADD,COM,0x81);
	I2C_SAND_BYTE(OLED0561_ADD,COM,x);//ÁÁ¶ÈÖµ
}

void OLED_DISPLAY_CLEAR(void){//ÇåÆÁ²Ù×÷
	u8 j,t;
	for(t=0xB0;t<0xB8;t++){	//ÉèÖÃÆðʼҳµØַΪ0xB0
		I2C_SAND_BYTE(OLED0561_ADD,COM,t); 	//Ò³µØÖ·£¨´Ó0xB0µ½0xB7£©
		
		I2C_SAND_BYTE(OLED0561_ADD,COM,0x10); //ÆðʼÁеØÖ·µÄ¸ß4λ
		I2C_SAND_BYTE(OLED0561_ADD,COM,0x00); //ÆðʼÁеØÖ·µÄµÍ4λ
		                                      //0x1000Ϊ128£¬ÕýºÃ¶ÔÓ¦ÏÔʾ×Ö·ûʱºòµÄ128ÁÐ  
		for(j=0;j<132;j++){	//ÕûÒ³ÄÚÈÝÌî³ä(²¿·ÖÆÁĻʵ¼Ê¿ÉÒÔÇý¶¯132ÁУ¬µ«ÊÇÖ»ÄÜÏÔʾÖмäµÄ128ÁУ¬ËùÒÔÕâÀïΪÁËÇåÆÁ³ä·Ö£¬¶Ô132ÁÐдÈë0)
 			I2C_SAND_BYTE(OLED0561_ADD,DAT,0x00);
 		}
	}
}
OLED显示ASCLL表里面的字符
//ÏÔʾӢÎÄÓëÊý×Ö8*16µÄASCIIÂ루ÏÂÃæµÄ×¢ÊÍÓÐÎ󣬺º×Ö±äΪӢÎÄ£©
//È¡Ä£´óСΪ8*16£¬È¡Ä£·½Ê½Îª¡°´ÓÉϵ½Ï¡±¡°×ÝÏò8µãϸßλ¡±
void OLED_DISPLAY_8x16(u8 x, //ÏÔʾºº×ÖµÄÒ³×ø±ê£¨´Ó0µ½7£©£¨´Ë´¦²»¿ÉÐ޸ģ©
					   u8 y, //ÏÔʾºº×ÖµÄÁÐ×ø±ê£¨´Ó0µ½128ÁУ¬Ã¿8ÁÐΪһ¸ö»ù±¾µ¥Î»£¬×î¶à16*8£¬ÊäÈëµÄʱºòÒ²ÊÇÒÔx*8À´ÊäÈ룩
					   u16 w){ //ÒªÏÔʾºº×ֵıàºÅ
	u8 j,t,c=0;
	y=y+2; //ÒòOLEDÆÁµÄÄÚÖÃÇý¶¯Ð¾Æ¬ÊÇ´Ó0x02ÁÐ×÷ΪÆÁÉÏ×î×óÒ»ÁУ¬ËùÒÔÒª¼ÓÉÏÆ«ÒÆÁ¿(ʵ¼Ê¿ÉÒÔÇý¶¯132ÐУ¬µ«ÊÇÖ»ÏÔʾÖмäµÄ128ÐУ¬ËùÒÔ+2±£Ö¤×Ö·û²»Ïò×óÆ«ÒÆ2¸öÏñËØ£¬¶ÔÓÚÕâ¿îOLEDµÄÄÚÖÃÇý¶¯Ð¾Æ¬¶øÑÔ£¬²»Í¬µÄоƬ²»Ò»Ñù)
	for(t=0;t<2;t++){
		I2C_SAND_BYTE(OLED0561_ADD,COM,0xb0+x);    //Ò³µØÖ·£¨´Ó0xB0µ½0xB7£©
		I2C_SAND_BYTE(OLED0561_ADD,COM,y/16+0x10); //ÆðʼÁеØÖ·µÄ¸ß4λ(×¢Òâ¼ÓÉÏÆ«ÒÆÖµ0x10)
		I2C_SAND_BYTE(OLED0561_ADD,COM,y%16);	   //ÆðʼÁеØÖ·µÄµÍ4λ
		for(j=0;j<8;j++)//ÕûÒ³ÄÚÈÝÌî³ä
		{ 
 			I2C_SAND_BYTE(OLED0561_ADD,DAT,ASCII_8x16[(w*16)+c-512]);//ΪÁ˺ÍASII±í¶ÔÓ¦Òª¼õ512(ÕâÀï¹¹½¨µÄ±íÊÇ´ÓASCLL±íµÄÊ®½øÖÆ32µ½127µÄ×Ö·û£¬ËùÒÔÒªÏÔʾ32ºÅ×Ö·ûʱ£º32*16-512=0¾ÍÈ¡µÄÊDZíÖеĵÚÒ»¸öÔªËØ)
			c++;
		}
		    x++; //Ò³µØÖ·¼Ó1(ÊäÈëÓ¢ÎÄʱ£¬´Ó×óµ½ÓÒµÄÁеØÖ·²»±ä£¬ÐÐ+1)
	}
}
		

void OLED_DISPLAY_8x16(u8 x , u8 y , u16 w)

这里需要说明的是 y 的取值范围为0 ~ 128列,调用函数的时候,y输入x*8,x=0 ~ 15,一共可以表示16列字母或者数字。当然如果你觉得位置不如意的话,依据可以将y设置为0 ~ 128中间的一个数字,而不仅仅局限于那16个固定的列坐标。在设计函数的时候并没有将y设计成只输入8x8块元素的列数,而是128列像素点的列数,这样显示的时候更具有灵活性。

当然如果你觉得输入x * 8比较麻烦,也可以将y=y * 8内嵌到函数中。后面的显示字符串也确实是这么处理的

发送数据函数

void OLED_DISPLAY_8x16(u8 x , u8 y , u16 w)里面嵌套的for循环:

这里的 j 就是显示多少列的意思,对于显示ASCLL码,8列就够了,显示汉字的时候需要16列,显示图片的时候就是显示图片的宽度像素值,0~128中间的某个值。

{(w*16)+c-512}是一个将ASCLL对应字符的标号转化为数组ASCII_8x16中的序号的公式,很简单验证:因为我们这里是ASCLL表中第32号到127号,如果我们要表示ASCLL中的第32号元素那么有:(32 * 16)-512=0,恰好是数组中的第一个元素。(ASCLL数组在文末有展示)

for(j=0;j<8;j++)
{ 			I2C_SAND_BYTE(OLED0561_ADD,DAT,ASCII_8x16[(w*16)+c-512]);
c++;
}
OLED显示字符串
//ÏòLCM·¢ËÍÒ»¸ö×Ö·û´®,³¤¶È64×Ö·ûÖ®ÄÚ¡£
//Ó¦ÓãºOLED_DISPLAY_8_16_BUFFER(0," DoYoung Studio"); 
void OLED_DISPLAY_8x16_BUFFER(u8 row,u8 *str){
	u8 r=0;                      //Ó¢ÎÄ×Ö·û´Ó0¿ªÊ¼ÊäÈ룬ȻºóÈç¹ûÏëҪƫÒÆÒ»¸ö×Ö·ûµÄλÖ㬻òÕß˵8¸öÁÐÏñËØ£¬ÄÇôÔÚ×Ö·û´®ÀïÃæ´ò¿Õ¸ñ
	while(*str != '\0'){
		OLED_DISPLAY_8x16(row,r*8,*str++);
		r++;
    }	
}

对于字符串的表示,这里显然就用到我们刚刚说道的r*8来嵌入。

初始列默认为第0列(r=0),需要左移显示的字符时,进行空格操作。与显示单个字符一样,但是不管怎么说每行最多显示16列

OLED显示汉字
//ÏÔʾºº×Ö16*16
//È¡Ä£´óСΪ16*16£¬È¡Ä£·½Ê½Îª¡°´Ó×óµ½ÓÒ´ÓÉϵ½Ï¡±¡°×ÝÏò8µãϸßλ¡±
void OLED_DISPLAY_16x16(u8 x, //ÏÔʾºº×ÖµÄÒ³×ø±ê£¨´Ó0xB0µ½0xB7£©
			u8 y, //ÏÔʾºº×ÖµÄÁÐ×ø±ê£¨´Ó0µ½63£©
			u16 w){ //ÒªÏÔʾºº×ֵıàºÅ
	u8 j,t,c=0;
	for(t=0;t<2;t++){
		I2C_SAND_BYTE(OLED0561_ADD,COM,0xb0+x); //Ò³µØÖ·£¨´Ó0xB0µ½0xB7£©
		I2C_SAND_BYTE(OLED0561_ADD,COM,y/16+0x10); //ÆðʼÁеØÖ·µÄ¸ß4λ
		I2C_SAND_BYTE(OLED0561_ADD,COM,y%16);	//ÆðʼÁеØÖ·µÄµÍ4λ
		for(j=0;j<16;j++){ //ÕûÒ³ÄÚÈÝÌî³ä
 			I2C_SAND_BYTE(OLED0561_ADD,DAT,GB_16[(w*32)+c]);
			c++;}x++; //Ò³µØÖ·¼Ó1
	}
	I2C_SAND_BYTE(OLED0561_ADD,COM,0xAF); //¿ªÏÔʾ 
}

细心观察发现,汉字的显示和单个英文或者数字相似,只是第二个 for 循环中的 j 值的取值范围以及字库不同:GB_16[(w*32)+c]

汉字显示两行,每行有2个8x8方块,即16列,所以 j = 16

一共就有32列,所以,每个汉字由32个数据构成,即w后面乘以32

OLED显示图片

仔细观察发现与初始化的息屏操作相似,息屏是将每一个像素点都置0,这里是根据提前生产好的数组PIC1[,]来显示。

void OLED_DISPLAY_PIC1(void){ //ÏÔʾȫÆÁͼƬ
	u8 m,i;
	for(m=0;m<8;m++){//
		I2C_SAND_BYTE(OLED0561_ADD,COM,0xb0+m);
		I2C_SAND_BYTE(OLED0561_ADD,COM,0x10); //ÆðʼÁеØÖ·µÄ¸ß4λ
		I2C_SAND_BYTE(OLED0561_ADD,COM,0x02);	//ÆðʼÁеØÖ·µÄµÍ4λ
		for(i=0;i<128;i++){//ËÍÈë128´ÎͼƬÏÔʾÄÚÈÝ
			I2C_SAND_BYTE(OLED0561_ADD,DAT,PIC1[i+m*128]);}
	}
}
ASCLL库,字模库以及图片库的自定义化生成:

示例:

// ------------------  ASCII×ÖÄ£µÄÊý¾Ý±í ------------------------ //
// Âë±í´Ó0x20~0x7e                                                //
// ×Ö¿â:  ×ÝÏòȡģϸßλ// £¨µ÷ÓÃʱҪ¼õ512£©
// -------------------------------------------------------------- //
const u8 ASCII_8x16[] =  {            // ASCII
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // - -   //ÏÔʾһ¸ö×ÖĸÉÏÃæµÄ8x8ÏñËØ
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,           //ÏÔʾһ¸ö×ÖĸÏÂÃæµÄ8x8ÏñËØ
                                                       //ÿһÁеÄÔªËØת»¯Îª¶þ½øÖÆÒԺ󣬵ÍλÔÚÉÏ£¬¸ßλÔÚÏ£¬0ΪϨÃð£¬1ΪÏÔʾ
	0x00,0x00,0x38,0xFC,0xFC,0x38,0x00,0x00,  // -!-
	0x00,0x00,0x00,0x0D,0x0D,0x00,0x00,0x00,

	0x00,0x0E,0x1E,0x00,0x00,0x1E,0x0E,0x00,  // -"-
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

	0x20,0xF8,0xF8,0x20,0xF8,0xF8,0x20,0x00,  // -#-
	0x02,0x0F,0x0F,0x02,0x0F,0x0F,0x02,0x00,

	0x38,0x7C,0x44,0x47,0x47,0xCC,0x98,0x00,  // -$-
	0x03,0x06,0x04,0x1C,0x1C,0x07,0x03,0x00,

	0x30,0x30,0x00,0x80,0xC0,0x60,0x30,0x00,  // -%-
	0x0C,0x06,0x03,0x01,0x00,0x0C,0x0C,0x00,

	0x80,0xD8,0x7C,0xE4,0xBC,0xD8,0x40,0x00,  // -&-
	0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

	0x00,0x10,0x1E,0x0E,0x00,0x00,0x00,0x00,  // -'-
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

	0x00,0x00,0xF0,0xF8,0x0C,0x04,0x00,0x00,  // -(-
	0x00,0x00,0x03,0x07,0x0C,0x08,0x00,0x00,

	0x00,0x00,0x04,0x0C,0xF8,0xF0,0x00,0x00,  // -)-
	0x00,0x00,0x08,0x0C,0x07,0x03,0x00,0x00,

	0x80,0xA0,0xE0,0xC0,0xC0,0xE0,0xA0,0x80,  // -*-
	0x00,0x02,0x03,0x01,0x01,0x03,0x02,0x00,

	0x00,0x80,0x80,0xE0,0xE0,0x80,0x80,0x00,  // -+-
	0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00,

	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -,-
	0x00,0x00,0x10,0x1E,0x0E,0x00,0x00,0x00,

	0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,  // ---
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -.-
	0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,

	0x00,0x00,0x00,0x80,0xC0,0x60,0x30,0x00,  // -/-
	0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,

	0xF8,0xFC,0x04,0xC4,0x24,0xFC,0xF8,0x00,  // -0-
	0x07,0x0F,0x09,0x08,0x08,0x0F,0x07,0x00,

	0x00,0x10,0x18,0xFC,0xFC,0x00,0x00,0x00,  // -1-
	0x00,0x08,0x08,0x0F,0x0F,0x08,0x08,0x00,

	0x08,0x0C,0x84,0xC4,0x64,0x3C,0x18,0x00,  // -2-
	0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0C,0x00,

	0x08,0x0C,0x44,0x44,0x44,0xFC,0xB8,0x00,  // -3-
	0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,

	0xC0,0xE0,0xB0,0x98,0xFC,0xFC,0x80,0x00,  // -4-
	0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,

	0x7C,0x7C,0x44,0x44,0xC4,0xC4,0x84,0x00,  // -5-
	0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,

	0xF0,0xF8,0x4C,0x44,0x44,0xC0,0x80,0x00,  // -6-
	0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

	0x0C,0x0C,0x04,0x84,0xC4,0x7C,0x3C,0x00,  // -7-
	0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00,

	0xB8,0xFC,0x44,0x44,0x44,0xFC,0xB8,0x00,  // -8-
	0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

	0x38,0x7C,0x44,0x44,0x44,0xFC,0xF8,0x00,  // -9-
	0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00,

	0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,  // -:-
	0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00,

	0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,  // -;-
	0x00,0x00,0x08,0x0E,0x06,0x00,0x00,0x00,

	0x00,0x80,0xC0,0x60,0x30,0x18,0x08,0x00,  // -<-
	0x00,0x00,0x01,0x03,0x06,0x0C,0x08,0x00,

	0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,  // -=-
	0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,

	0x00,0x08,0x18,0x30,0x60,0xC0,0x80,0x00,  // ->-
	0x00,0x08,0x0C,0x06,0x03,0x01,0x00,0x00,

	0x18,0x1C,0x04,0xC4,0xE4,0x3C,0x18,0x00,  // -?-
	0x00,0x00,0x00,0x0D,0x0D,0x00,0x00,0x00,

	0xF0,0xF8,0x08,0xC8,0xC8,0xF8,0xF0,0x00,  // -@-
	0x07,0x0F,0x08,0x0B,0x0B,0x0B,0x01,0x00,

	0xE0,0xF0,0x98,0x8C,0x98,0xF0,0xE0,0x00,  // -A-
	0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

	0x04,0xFC,0xFC,0x44,0x44,0xFC,0xB8,0x00,  // -B-
	0x08,0x0F,0x0F,0x08,0x08,0x0F,0x07,0x00,

	0xF0,0xF8,0x0C,0x04,0x04,0x0C,0x18,0x00,  // -C-
	0x03,0x07,0x0C,0x08,0x08,0x0C,0x06,0x00,

	0x04,0xFC,0xFC,0x04,0x0C,0xF8,0xF0,0x00,  // -D-
	0x08,0x0F,0x0F,0x08,0x0C,0x07,0x03,0x00,

	0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,  // -E-
	0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00,

	0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,  // -F-
	0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

	0xF0,0xF8,0x0C,0x84,0x84,0x8C,0x98,0x00,  // -G-
	0x03,0x07,0x0C,0x08,0x08,0x07,0x0F,0x00,

	0xFC,0xFC,0x40,0x40,0x40,0xFC,0xFC,0x00,  // -H-
	0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

	0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,0x00,  // -I-
	0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

	0x00,0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,  // -J-
	0x07,0x0F,0x08,0x08,0x0F,0x07,0x00,0x00,

	0x04,0xFC,0xFC,0xC0,0xF0,0x3C,0x0C,0x00,  // -K-
	0x08,0x0F,0x0F,0x00,0x01,0x0F,0x0E,0x00,

	0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00,  // -L-
	0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00,

	0xFC,0xFC,0x38,0x70,0x38,0xFC,0xFC,0x00,  // -M-
	0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

	0xFC,0xFC,0x38,0x70,0xE0,0xFC,0xFC,0x00,  // -N-
	0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

	0xF0,0xF8,0x0C,0x04,0x0C,0xF8,0xF0,0x00,  // -O-
	0x03,0x07,0x0C,0x08,0x0C,0x07,0x03,0x00,

	0x04,0xFC,0xFC,0x44,0x44,0x7C,0x38,0x00,  // -P-
	0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

	0xF8,0xFC,0x04,0x04,0x04,0xFC,0xF8,0x00,  // -Q-
	0x07,0x0F,0x08,0x0E,0x3C,0x3F,0x27,0x00,

	0x04,0xFC,0xFC,0x44,0xC4,0xFC,0x38,0x00,  // -R-
	0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,

	0x18,0x3C,0x64,0x44,0xC4,0x9C,0x18,0x00,  // -S-
	0x06,0x0E,0x08,0x08,0x08,0x0F,0x07,0x00,

	0x00,0x1C,0x0C,0xFC,0xFC,0x0C,0x1C,0x00,  // -T-
	0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

	0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,  // -U-
	0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

	0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,  // -V-
	0x01,0x03,0x06,0x0C,0x06,0x03,0x01,0x00,

	0xFC,0xFC,0x00,0x80,0x00,0xFC,0xFC,0x00,  // -W-
	0x03,0x0F,0x0E,0x03,0x0E,0x0F,0x03,0x00,

	0x0C,0x3C,0xF0,0xC0,0xF0,0x3C,0x0C,0x00,  // -X-
	0x0C,0x0F,0x03,0x00,0x03,0x0F,0x0C,0x00,

	0x00,0x3C,0x7C,0xC0,0xC0,0x7C,0x3C,0x00,  // -Y-
	0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

	0x1C,0x0C,0x84,0xC4,0x64,0x3C,0x1C,0x00,  // -Z-
	0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0E,0x00,

	0x00,0x00,0xFC,0xFC,0x04,0x04,0x00,0x00,  // -[-
	0x00,0x00,0x0F,0x0F,0x08,0x08,0x00,0x00,

	0x38,0x70,0xE0,0xC0,0x80,0x00,0x00,0x00,  // -\-
	0x00,0x00,0x00,0x01,0x03,0x07,0x0E,0x00,

	0x00,0x00,0x04,0x04,0xFC,0xFC,0x00,0x00,  // -]-
	0x00,0x00,0x08,0x08,0x0F,0x0F,0x00,0x00,

	0x08,0x0C,0x06,0x03,0x06,0x0C,0x08,0x00,  // -^-
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -_-
	0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,

	0x00,0x00,0x03,0x07,0x04,0x00,0x00,0x00,  // -`-
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

	0x00,0xA0,0xA0,0xA0,0xE0,0xC0,0x00,0x00,  // -a-
	0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

	0x04,0xFC,0xFC,0x20,0x60,0xC0,0x80,0x00,  // -b-
	0x08,0x0F,0x07,0x08,0x08,0x0F,0x07,0x00,

	0xC0,0xE0,0x20,0x20,0x20,0x60,0x40,0x00,  // -c-
	0x07,0x0F,0x08,0x08,0x08,0x0C,0x04,0x00,

	0x80,0xC0,0x60,0x24,0xFC,0xFC,0x00,0x00,  // -d-
	0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

	0xC0,0xE0,0xA0,0xA0,0xA0,0xE0,0xC0,0x00,  // -e-
	0x07,0x0F,0x08,0x08,0x08,0x0C,0x04,0x00,

	0x40,0xF8,0xFC,0x44,0x0C,0x18,0x00,0x00,  // -f-
	0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

	0xC0,0xE0,0x20,0x20,0xC0,0xE0,0x20,0x00,  // -g-
	0x27,0x6F,0x48,0x48,0x7F,0x3F,0x00,0x00,

	0x04,0xFC,0xFC,0x40,0x20,0xE0,0xC0,0x00,  // -h-
	0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,

	0x00,0x00,0x20,0xEC,0xEC,0x00,0x00,0x00,  // -i-
	0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

	0x00,0x00,0x00,0x00,0x20,0xEC,0xEC,0x00,  // -j-
	0x00,0x30,0x70,0x40,0x40,0x7F,0x3F,0x00,

	0x04,0xFC,0xFC,0x80,0xC0,0x60,0x20,0x00,  // -k-
	0x08,0x0F,0x0F,0x01,0x03,0x0E,0x0C,0x00,

	0x00,0x00,0x04,0xFC,0xFC,0x00,0x00,0x00,  // -l-
	0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

	0xE0,0xE0,0x60,0xC0,0x60,0xE0,0xC0,0x00,  // -m-
	0x0F,0x0F,0x00,0x0F,0x00,0x0F,0x0F,0x00,

	0x20,0xE0,0xC0,0x20,0x20,0xE0,0xC0,0x00,  // -n-
	0x00,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,

	0xC0,0xE0,0x20,0x20,0x20,0xE0,0xC0,0x00,  // -o-
	0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

	0x20,0xE0,0xC0,0x20,0x20,0xE0,0xC0,0x00,  // -p-
	0x40,0x7F,0x7F,0x48,0x08,0x0F,0x07,0x00,

	0xC0,0xE0,0x20,0x20,0xC0,0xE0,0x20,0x00,  // -q-
	0x07,0x0F,0x08,0x48,0x7F,0x7F,0x40,0x00,

	0x20,0xE0,0xC0,0x60,0x20,0x60,0xC0,0x00,  // -r-
	0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

	0x40,0xE0,0xA0,0x20,0x20,0x60,0x40,0x00,  // -s-
	0x04,0x0C,0x09,0x09,0x0B,0x0E,0x04,0x00,

	0x20,0x20,0xF8,0xFC,0x20,0x20,0x00,0x00,  // -t-
	0x00,0x00,0x07,0x0F,0x08,0x0C,0x04,0x00,

	0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,0x00,  // -u-
	0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

	0x00,0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,  // -v-
	0x00,0x03,0x07,0x0C,0x0C,0x07,0x03,0x00,

	0xE0,0xE0,0x00,0x00,0x00,0xE0,0xE0,0x00,  // -w-
	0x07,0x0F,0x0C,0x07,0x0C,0x0F,0x07,0x00,

	0x20,0x60,0xC0,0x80,0xC0,0x60,0x20,0x00,  // -x-
	0x08,0x0C,0x07,0x03,0x07,0x0C,0x08,0x00,

	0xE0,0xE0,0x00,0x00,0x00,0xE0,0xE0,0x00,  // -y-
	0x47,0x4F,0x48,0x48,0x68,0x3F,0x1F,0x00,

	0x60,0x60,0x20,0xA0,0xE0,0x60,0x20,0x00,  // -z-
	0x0C,0x0E,0x0B,0x09,0x08,0x0C,0x0C,0x00,

	0x00,0x40,0x40,0xF8,0xBC,0x04,0x04,0x00,  // -{-
	0x00,0x00,0x00,0x07,0x0F,0x08,0x08,0x00,

	0x00,0x00,0x00,0xBC,0xBC,0x00,0x00,0x00,  // -|-
	0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,

	0x00,0x04,0x04,0xBC,0xF8,0x40,0x40,0x00,  // -}-
	0x00,0x08,0x08,0x0F,0x07,0x00,0x00,0x00,

	0x08,0x0C,0x04,0x0C,0x08,0x0C,0x04,0x00,  // -~-
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

	0x80,0xC0,0x60,0x30,0x60,0xC0,0x80,0x00,  // --
	0x07,0x07,0x04,0x04,0x04,0x07,0x07,0x00,
};

一般字库什么的都是用软件来生成的:

ASCLL:
51或stm32单片机OLED显示屏驱动及代码演示_第6张图片
汉字:
51或stm32单片机OLED显示屏驱动及代码演示_第7张图片
51或stm32单片机OLED显示屏驱动及代码演示_第8张图片

图片:

51或stm32单片机OLED显示屏驱动及代码演示_第9张图片
51或stm32单片机OLED显示屏驱动及代码演示_第10张图片

你可能感兴趣的:(C51单片机,stm32,51单片机,单片机,stm32,keil5,嵌入式硬件)