本帖最后由 jinglixixi 于 2020-9-14 12:26 编辑
上次向大家介绍了I2C接口的OLED屏,这次介绍一下在HC32L072开发板上实现SPI接口的彩色OLED屏的显示,它在色彩和图像方面的表现力要更强。 该彩屏与MCU的连接关系为: SCLK--- PA05 SDIN--- PA06 DC --- PE15 RST --- PE14 CS --- PA04 BLKT--- PE13
使相关引脚输出高低电平的语句为: #define OLED_BLK_Set() Gpio_SetIO(GpioPortE, GpioPin13); //配置引脚PE1
#define OLED_CS_Set() Gpio_SetIO(GpioPortA, GpioPin4); //配置引脚PA04 #define OLED_CS_Clr() Gpio_ClrIO(GpioPortA, GpioPin4);
#define OLED_SCLK_Set() Gpio_SetIO(GpioPortA, GpioPin5); //配置引脚PA05 #define OLED_SCLK_Clr() Gpio_ClrIO(GpioPortA, GpioPin5);
#define OLED_SDIN_Set() Gpio_SetIO(GpioPortA, GpioPin6); //配置引脚PA06 #define OLED_SDIN_Clr() Gpio_ClrIO(GpioPortA, GpioPin6);
#define OLED_DC_Set() Gpio_SetIO(GpioPortE, GpioPin15); //配置引脚PE15 #define OLED_DC_Clr() Gpio_ClrIO(GpioPortE, GpioPin15);
#define OLED_RST_Set() Gpio_SetIO(GpioPortE, GpioPin14); //配置引脚PE14 #define OLED_RST_Clr() Gpio_ClrIO(GpioPortE, GpioPin14);
图片显示函数为: void LCD_ShowPicture(u16 x1,u16 y1,u16 x2,u16 y2)
{
int i;
LCD_Address_Set(x1,y1,x2,y2);
for(i=0;i<12800;i++)
{
LCD_WR_DATA8(gImage_moled[i*2]);
LCD_WR_DATA8(gImage_moled[i*2+1]);
}
}
实现图示效果的主程序如下: int32_t main(void)
{
//OLED端口初始化
App_OLEDInit();
delay1ms(200);
GPIO_Configuration();
Lcd_Init();
delay1ms(50);
LCD_Clear(WHITE);
LCD_ShowPicture(0,0,159,79);
while (1);
}
显示效果图
演示代码:
|