我在开发中使用的是这一款OLED驱动:
根据厂家提供的开机例程。
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Initialization
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void OLED_Init()
{
OLED_RST_Clr();
Delay(10);
OLED_RST_Set();
Set_Power_Save(0x01); // Set Normal Driving Current
uDelay(200); // Disable Oscillator Power Down
// Enable Power Save Mode
Set_Power_Save(0x00); // Set Normal Driving Current
uDelay(200); // Disable Oscillator Power Down
// Disable Power Save Mode
Software_Reset(0x00); // Set All Internal Register Value as Normal Mode
Set_Display_On_Off(0x00); // Display Off (0x00/0x01)
Set_Clock_Control(0x01); // Set EXPORT1 Pin at Internal Clock
// Oscillator operates with external resister.
// Internal Oscillator On
Set_Display_Clock(0x30); // Set Clock as 90 Frames/Sec
Set_Multiplex_Ratio(0x7F); // 1/128 Duty (0x0F~0x7F)
Set_Display_Offset(0x00, 0x00); // Shift Mapping RAM Counter
Set_Start_Line(0x00); // Set Mapping RAM Display Start Line (0x00~0x7F)
Set_RGB_IF(0x31); // Set MCU Interface Mode
Set_RGB_POL(0x00); // Set RGB Interface Polarity as Active Low
// Dot Clock Polarity Sampled as Rising Edge
// Disable Vertical Synchronization Output on VSYNCO Pin
Set_Display_Mode(0x00); // Set Color Sequence D[15:0]=[RRRRR:GGGGGG:BBBBB]
// Alternative Gate Pin Configuration
// Scan from G0 to G127
// Column Address 0 Mapped to S0
// One Screen Mode
// Normal Display
Set_Pixel_Format(0x66 | ((Color_Depth << 4) & 0x70));
// Set Horizontal Address Increment
// Vertical Address Increment
// The data is continuously written horizontally.
// Enable 8-bit Bus Interface
// 65,536 Colors Mode (0x66)
// * 262,144 Colors Mode (0x76)
Set_Driving_Current(0x2F, 0x31, 0x1E); // Set Driving Current of Red
// Set Driving Current of Green
// Set Driving Current of Blue
Set_Gray_Scale_Table(); // Set Pulse Width for Gamma Table
Set_Precharge_Period(0x03, 0x04, 0x01); // Set Pre-Charge Time of Red
// Set Pre-Charge Time of Green
// Set Pre-Charge Time of Blue
Set_Precharge_Current(0x1A, 0x19, 0x0A); // Set Pre-Charge Current of Red
// Set Pre-Charge Current of Green
// Set Pre-Charge Current of Blue
Set_IREF(0x00); // Set Reference Voltage Controlled by External Resister
First_Screen(0x00, 0x9F, 0x00, 0x7F);
Fill_RAM(0x00, 0x00); // Clear Screen
Set_Display_On_Off(0x01); // Display On (0x00/0x01)
}
如代码所示,Set_Display_On_Off(0x01); // Display On (0x00/0x01),我们来看一下它的实现:
void Set_Display_On_Off(unsigned char d)
{
Write_Command(0x06); // Set Display On/Off (DISP_ON_OFF)
Write_Data(d); // Default => 0x00
// Scan signal is high level at pre-charge period.
// Display Off
}
对照厂家提供的芯片驱动手册对这个功能的解释:
将值写入0x06这个寄存器。
即当写入为1时候,打开OLED显示,反之,关闭OLED显示。
这个程序从例程上来说是一点问题都没有的,但是,如果在做产品过程中。
开机我需要刷入全屏数据,就会显得非常的慢了,至少产品体验非常不好,我是如何解决这个问题的呢?
将OLED_Init初始化函数中的设置显示功能注释,即上电默认就不打开显示。
然后当要刷入全屏数据时,关闭显示,刷入到缓存后,再打开显示,这样就可以看到一次性显示所有图片数据,完美解决全屏刷慢的问题。
转载:https://blog.csdn.net/morixinguan/article/details/100920793
查看评论