0.96寸OLED在STM32f103上实现滚动显示长字符

一、OLED屏的滚屏命令

  • 水平左右移
OLED_WR_Byte(0x2E,OLED_CMD);        //关闭滚动
OLED_WR_Byte(0x26,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);        //虚拟字节
OLED_WR_Byte(0x2F,OLED_CMD);        //开启滚动

本篇博客只用到了水平移动,其余详情请前往:SSD1306(OLED驱动芯片)指令详解

二、对需要显示的文字进行取模

  "晓",0x00,0x80,0x00,0x80,0x78,0xBC,0x4B,0xC0,0x48,0x50,0x48,0x24,0x48,0xD4,0x7B,0x0C,
  0x48,0x00,0x4B,0xFE,0x48,0x90,0x48,0x90,0x79,0x12,0x49,0x12,0x02,0x0E,0x04,0x00,/*"晓",0*/
  "看",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,/*"看",1*/
  "天",0x00,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,
  0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x08,0xC0,0x06,/*"天",2*/
  "色",0x08,0x00,0x08,0x00,0x1F,0xE0,0x20,0x20,0x40,0x40,0xBF,0xF8,0x21,0x08,0x21,0x08,
  0x21,0x08,0x3F,0xF8,0x20,0x00,0x20,0x02,0x20,0x02,0x20,0x02,0x1F,0xFE,0x00,0x00,/*"色",3*/
  "暮",0x04,0x40,0x7F,0xFC,0x04,0x40,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,
  0x04,0x00,0xFF,0xFE,0x10,0x10,0x2F,0xE8,0xC8,0x26,0x0F,0xE0,0x08,0x20,0x0F,0xE0,/*"暮",4*/
  "看",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,/*"看",5*/
  "云",0x00,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x02,0x00,
  0x04,0x00,0x04,0x00,0x08,0x40,0x10,0x20,0x20,0x10,0x7F,0xF8,0x20,0x08,0x00,0x08,/*"云",6*/

三、修改程序代码

  • main函数:
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);        //开启滚动

}

  • 显示数据函数
void TEST_MainPage(void)
{	
	GUI_ShowCHinese(10,20,16,"晓看天色暮看云",1);
	delay_ms(1500);		
	delay_ms(1500);
}

四、烧录运行结果

在这里插入图片描述

五、总结

本次实验相比上次多出了让数据滚动的功能,主要差别在主函数中的代码,其他的和上次实验几乎相同。

六、参考文献

SSD1306(OLED驱动芯片)指令详解
0.96寸OLED在STM32f103上实现滚动显示长字符

版权声明:本文为CSDN博主「觉觉睡了没醒」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_61682562/article/details/121561821

生成海报
点赞 0

觉觉睡了没醒

我还没有学会写个人说明!

暂无评论

发表评论

相关推荐

4路红外循迹模块使用教程

4路红外循迹模块使用教程 个人原创博客:点击浏览模块详细信息: 工作电压:DC 3.3V~5V 工作电流:尽量选择1A以上电源供电 工作温度:-10℃~50℃ 安装孔

拉绳位移传感器在接线时需要注意哪几点?

拉绳位移传感器在接线时需要注意哪几点? 1、拉绳位移传感器在接线时务必确认在电源关闭的情况下进行接线,接线应采用锡焊工艺,各引脚应焊接牢固,避免虚焊情况发生。焊接各引脚时应严格按照传感器厂

为什么重写printf函数没有用?

以前在网上找了无数方法去重写printf函数,但发现都没效果,今天偶然发现重写printf函数可以了,原因是以前没有勾选微库(Use MicroLlB)! 这里