OLED相关显示

  • Post author:
  • Post category:其他




OLED屏(七线)接法

在这里插入图片描述



汉字取模

  • 点击新建图像->确定

    在这里插入图片描述

  • 输入需要取模的字并点击CTRL+Enter

    在这里插入图片描述

  • 取模方式选C51得到结果

    在这里插入图片描述



显示自己学号姓名

  • main.c
#include "delay.h"
#include "sys.h"
#include "oled.h"
#include "gui.h"
#include "test.h"
int main(void)
{	
	delay_init();	    	       //延时函数初始化	  
	NVIC_Configuration(); 	   //设置NVIC中断分组2:2位抢占优先级,2位响应优先级 	
	OLED_Init();			         //初始化OLED  
	OLED_Clear(0);             //清屏(全黑)
	while(1) 
	{	
		TEST_MainPage();         //主界面显示测试
		/*OLED_Clear(0); 
		Test_Color();            //刷屏测试
		OLED_Clear(0); 
		Test_Rectangular();      //矩形绘制测试
		OLED_Clear(0); 
		Test_Circle();           //圆形绘制测试
		OLED_Clear(0); 
		Test_Triangle();         //三角形绘制测试
		OLED_Clear(0);  
		
		TEST_English();          //英文显示测试
		OLED_Clear(0);
		TEST_Number_Character(); //数字和符号显示测试
		OLED_Clear(0); 
		
		TEST_Chinese();          //中文显示测试
		OLED_Clear(0); 
		TEST_BMP();              //BMP单色图片显示测试
		OLED_Clear(0); 
		TEST_Menu1();            //菜单1显示测试
		OLED_Clear(0); 
		TEST_Menu2();            //菜单2显示测试
		OLED_Clear(0); */
	}
}
  • test.c主要函数
void TEST_MainPage(void)
{	
//	GUI_ShowString(28,0,"Harriet",16,1);
	GUI_ShowCHinese(28,20,16,"刘珺琦",1);
	//GUI_ShowString(40,32,"64X128",16,1);
	GUI_ShowString(4,48,"632007090107",16,1);
	//GUI_ShowString(4,48,"www.lcdwiki.com",16,1);
	delay_ms(1500);		
	delay_ms(1500);
}
  • 取模语句如下
"刘",0x10,0x04,0x08,0x04,0x08,0x04,0xFF,0xA4,0x02,0x24,0x42,0x24,0x22,0x24,0x14,0x24,
  0x14,0x24,0x08,0x24,0x08,0x24,0x14,0x24,0x24,0x04,0x42,0x04,0x82,0x14,0x00,0x08,
	"珺",0x00,0x00,0x01,0xFC,0xFC,0x44,0x10,0x44,0x13,0xFE,0x10,0x44,0x7C,0x44,0x11,0xFC,
  0x10,0x80,0x10,0x80,0x11,0xFC,0x1E,0x84,0xE4,0x84,0x40,0x84,0x00,0xFC,0x00,0x84,
	"琦",0x00,0x40,0x00,0x40,0xFB,0xFC,0x20,0xA0,0x21,0x10,0x22,0x08,0x27,0xFE,0xF8,0x08,
  0x23,0xC8,0x22,0x48,0x22,0x48,0x3A,0x48,0xE3,0xC8,0x40,0x08,0x00,0x28,0x00,0x10,
  • 效果

在这里插入图片描述



滚动显示长字符

  • main.c
#include "delay.h"
#include "sys.h"
#include "oled.h"
#include "gui.h"
#include "test.h"
int main(void)
{	
	delay_init();	    	       //延时函数初始化	  
	NVIC_Configuration(); 	   //设置NVIC中断分组2:2位抢占优先级,2位响应优先级 	
	OLED_Init();			         //初始化OLED  
	OLED_Clear(0);             //清屏(全黑)
	OLED_WR_Byte(0x2E,OLED_CMD);        //关闭滚动
  OLED_WR_Byte(0x27,OLED_CMD);        //水平向左或者右滚动 26/27
  OLED_WR_Byte(0x00,OLED_CMD);        //虚拟字节
	OLED_WR_Byte(0x00,OLED_CMD);        //起始页 0
	OLED_WR_Byte(0x07,OLED_CMD);        //滚动时间间隔
	OLED_WR_Byte(0x07,OLED_CMD);        //终止页 7
	OLED_WR_Byte(0x00,OLED_CMD);        //虚拟字节
	OLED_WR_Byte(0xFF,OLED_CMD);        //虚拟字节
	TEST_MainPage();
	OLED_WR_Byte(0x2F,OLED_CMD);        //开启滚动
	while(1) 
	{	
		//TEST_MainPage();         //主界面显示测试
		

		//TEST_MainPage();
		/*OLED_Clear(0); 
		Test_Color();            //刷屏测试
		OLED_Clear(0); 
		Test_Rectangular();      //矩形绘制测试
		OLED_Clear(0); 
		Test_Circle();           //圆形绘制测试
		OLED_Clear(0); 
		Test_Triangle();         //三角形绘制测试
		OLED_Clear(0);  
		
		TEST_English();          //英文显示测试
		OLED_Clear(0);
		TEST_Number_Character(); //数字和符号显示测试
		OLED_Clear(0); 
		
		TEST_Chinese();          //中文显示测试
		OLED_Clear(0); 
		TEST_BMP();              //BMP单色图片显示测试
		OLED_Clear(0); 
		TEST_Menu1();            //菜单1显示测试
		OLED_Clear(0); 
		TEST_Menu2();            //菜单2显示测试
		OLED_Clear(0); */
	}
}
  • test.c主要函数
void TEST_MainPage(void)
{	

	GUI_ShowCHinese(20,12,16,"醉里挑灯看剑",1);
	GUI_ShowCHinese(10,30,16,"梦回吹角连营",1);
	
	//GUI_ShowString(40,32,"64X128",16,1);
	//GUI_ShowString(4,48,"www.lcdwiki.com",16,1);*/
	delay_ms(500);		
	delay_ms(500);
}
  • 取模语句
typedef struct 
{
	unsigned char Index[2];	
	char Msk[32];
}typFNT_GB16; 

//宋体
//16*16大小
//逐行式,顺向(高位在前)
const typFNT_GB16 cfont16[] = 
{
	"醉",0x00,0x40,0xFE,0x20,0x29,0xFE,0x28,0x00,0xFE,0x88,0xAA,0x88,0xAB,0x54,0xAA,0x22,
  0xAE,0x00,0xC2,0x20,0x83,0xFE,0xFE,0x20,0x82,0x20,0x82,0x20,0xFE,0x20,0x82,0x20,
	"里",0x00,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,
  0x01,0x00,0x01,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x00,0x00,
  "挑",0x10,0x90,0x10,0x90,0x10,0x90,0x12,0x92,0xFD,0x94,0x10,0x98,0x10,0x90,0x15,0x98,
  0x1A,0x94,0x34,0x92,0xD0,0x90,0x10,0x90,0x11,0x12,0x11,0x12,0x52,0x12,0x24,0x0E,
	"灯",0x10,0x00,0x10,0x00,0x13,0xFE,0x10,0x20,0x54,0x20,0x58,0x20,0x50,0x20,0x90,0x20,
  0x10,0x20,0x10,0x20,0x10,0x20,0x28,0x20,0x24,0x20,0x44,0x20,0x40,0xA0,0x80,0x40,
	"看",0x00,0xF8,0x7F,0x00,0x01,0x00,0x3F,0xF8,0x02,0x00,0xFF,0xFE,0x04,0x00,0x08,0x00,
  0x1F,0xF0,0x28,0x10,0x4F,0xF0,0x88,0x10,0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x08,0x10,
	"剑",0x08,0x04,0x08,0x04,0x14,0x04,0x12,0x24,0x21,0x24,0x40,0xA4,0xBE,0x24,0x00,0x24,
  0x11,0x24,0x09,0x24,0x49,0x24,0x22,0x24,0x22,0x04,0x07,0x84,0x78,0x14,0x20,0x08,
	"梦",0x08,0x20,0x08,0x20,0x7E,0xFC,0x08,0x20,0x1C,0x70,0x2A,0xA8,0xC8,0x26,0x04,0x00,
  0x07,0xF0,0x08,0x10,0x14,0x20,0x22,0x40,0x01,0x80,0x02,0x00,0x0C,0x00,0x70,0x00,
	"回",0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x27,0xC8,0x24,0x48,0x24,0x48,0x24,0x48,
  0x24,0x48,0x24,0x48,0x27,0xC8,0x20,0x08,0x20,0x08,0x3F,0xF8,0x20,0x08,0x00,0x00,
	"吹",0x00,0x80,0x00,0x80,0x78,0x80,0x48,0xFC,0x49,0x04,0x49,0x08,0x4A,0x40,0x4C,0x40,
  0x48,0x40,0x48,0xA0,0x78,0xA0,0x49,0x10,0x01,0x10,0x02,0x08,0x04,0x04,0x08,0x02,
	"角",0x08,0x00,0x08,0x00,0x1F,0xE0,0x20,0x20,0x40,0x40,0xBF,0xF8,0x21,0x08,0x21,0x08,
  0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x41,0x08,0x41,0x28,0x80,0x10,
	"连",0x00,0x40,0x20,0x40,0x17,0xFE,0x10,0x80,0x00,0xA0,0x01,0x20,0xF3,0xFC,0x10,0x20,
  0x10,0x20,0x10,0x20,0x17,0xFE,0x10,0x20,0x10,0x20,0x28,0x20,0x47,0xFE,0x00,0x00,
	"营",0x08,0x20,0x08,0x20,0xFF,0xFE,0x08,0x20,0x7F,0xFE,0x40,0x02,0x9F,0xF4,0x10,0x10,
  0x10,0x10,0x1F,0xF0,0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x3F,0xF8,0x20,0x08,
};
  • 效果

    在这里插入图片描述



OLED屏显示温湿度

  • main.c
#include "delay.h"
#include "usart.h"
#include "bsp_i2c.h"
#include "sys.h"

#include "oled.h"
#include "gui.h"
#include "test.h"

int main(void)
{	
	delay_init();	    	       //延时函数初始化    	  
	uart_init(115200);	 
	IIC_Init();
		  
	NVIC_Configuration(); 	   //设置NVIC中断分组2:2位抢占优先级,2位响应优先级 	
	OLED_Init();			         //初始化OLED  
	OLED_Clear(0); 
	while(1)
	{
		//printf("温度湿度显示");
		read_AHT20_once();
		OLED_Clear(0); 
		delay_ms(1500);
  }
}



版权声明:本文为qq_53203987原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。