一、了解OLED屏的滚屏命令
本OLED屏的芯片类型:SSD1306 详细命令的介绍,请查找SSD1306-OLED驱动中文手册或者参考下面链接进行了解 SSD1306(OLED驱动芯片)指令详解_朝气蓬勃-CSDN博客
1、左右水平移动
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); //开启滚动
2、垂直和水平移动
OLED_WR_Byte(0x2e,OLED_CMD); //关闭滚动
OLED_WR_Byte(0x29,OLED_CMD); //水平垂直和水平滚动左右 29/2a
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); //终止页 1
OLED_WR_Byte(0x01,OLED_CMD); //垂直滚动偏移量
OLED_WR_Byte(0x2F,OLED_CMD); //开启滚动
说明:设置前需要先发关闭滚动的指令2E,接着发滚动指令29(向右)或2A(向左)。紧接着发5条参数设置指令,用来设置持续水平滚动参数和决定滚动开始页,结束页,滚动速度和垂直滚动偏移的,最后才发开始滚屏指令2F。 注意:在发送开始滚屏(2F)前要先传输好显示数据,如果在滚屏的时候传输显示数据RAM中的内容可能被损坏,无法正常显示。
二、对显示文字进行取模
利用字模软件PCtoLCD2002
【资源下载】PCtoLCD2002 下载 资源分享 OLED取模软件_为丽力的博客-CSDN博客
这个博客里面有下载链接
{0x04,0x10,0x24,0x08,0x44,0x06,0x84,0x01,0x64,0x82,0x9C,0x4C,0x40,0x20,0x30,0x18},
{0x0F,0x06,0xC8,0x01,0x08,0x06,0x08,0x18,0x28,0x20,0x18,0x40,0x00,0x80,0x00,0x00},/*"欢",0*/
{0x40,0x00,0x40,0x40,0x42,0x20,0xCC,0x1F,0x00,0x20,0x00,0x40,0xFC,0x4F,0x04,0x44},
{0x02,0x42,0x00,0x40,0xFC,0x7F,0x04,0x42,0x04,0x44,0xFC,0x43,0x00,0x40,0x00,0x00},/*"迎",1*/
{0x00,0x21,0x08,0x21,0x08,0x11,0x28,0x11,0xC8,0x09,0x08,0x05,0x08,0x03,0xFF,0xFF},
{0x08,0x03,0x08,0x05,0x88,0x09,0x68,0x11,0x08,0x11,0x08,0x21,0x00,0x21,0x00,0x00},/*"来",2*/
{0x42,0x40,0x62,0xC4,0x52,0x44,0x4A,0x44,0xC6,0x7F,0x42,0x24,0x52,0x24,0x62,0x24},
{0xC2,0x20,0x00,0x00,0xF8,0x0F,0x00,0x40,0x00,0x80,0xFF,0x7F,0x00,0x00,0x00,0x00},/*"到",3*/
{0x10,0x40,0x10,0x40,0x14,0x50,0xD4,0x57,0x54,0x55,0x54,0x55,0x54,0x55,0xFC,0x7F},
{0x52,0x55,0x52,0x55,0x52,0x55,0xD3,0x57,0x12,0x50,0x10,0x40,0x10,0x40,0x00,0x00},/*"重",4*/
{0x00,0x40,0x00,0x30,0xFC,0x0F,0x04,0x80,0x84,0x40,0x84,0x20,0x84,0x18,0x85,0x06},
{0xF6,0x01,0x84,0x06,0x84,0x18,0x84,0x20,0x84,0x40,0x84,0x80,0x04,0x80,0x00,0x00},/*"庆",5*/
{0x08,0x80,0x08,0x81,0x88,0x40,0x68,0x40,0x08,0x21,0x08,0x22,0x09,0x14,0x0E,0x08},
{0x08,0x14,0x08,0x22,0x88,0x41,0x28,0x40,0x48,0x80,0x88,0x81,0x08,0x80,0x00,0x00},/*"交",6*/
{0x40,0x80,0x42,0x40,0xCC,0x3F,0x00,0x40,0x00,0x80,0xE2,0xFF,0x22,0x89,0x2A,0x89},
{0x2A,0x89,0xF2,0xBF,0x2A,0x89,0x26,0xA9,0x22,0xC9,0xE0,0xBF,0x00,0x80,0x00,0x00},/*"通",7*/
{0x20,0x80,0x20,0x80,0x20,0x40,0x20,0x20,0x20,0x10,0x20,0x0C,0x20,0x03,0xFF,0x00},
{0x20,0x03,0x20,0x0C,0x20,0x10,0x20,0x20,0x20,0x40,0x20,0x80,0x20,0x80,0x00,0x00},/*"大",8*/
{0x40,0x04,0x30,0x04,0x11,0x04,0x96,0x04,0x90,0x04,0x90,0x44,0x91,0x84,0x96,0x7E},
{0x90,0x06,0x90,0x05,0x98,0x04,0x14,0x04,0x13,0x04,0x50,0x04,0x30,0x04,0x00,0x00},/*"学",9*/
三、主要代码
main函数
#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); //开启滚动
}
显示函数
void TEST_MainPage(void)
{
GUI_ShowCHinese(10,20,16,"欢迎来到重庆交通大学",1);
delay_ms(1500);
delay_ms(1500);
}
效果显示
?
四、总结
这个滚动显示的效果就在温度显示的代码上加一个滚动效果的代码就好了
整个命令其实并不复杂,对应滚动停止命令,一旦使用后,其ROM中的内容就会被破坏,需要重新对内容进行传输保存,否则就不能够实现滚屏的效果。不过这种方式,好像只能够完成将内容写好后,显示在同一个面板上的滑动。
|