文章目录[隐藏]
一、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
暂无评论