开发平台: MDK
开发板:AC7802
目地:利用AC7802开发板点亮OLED,并在屏上显示AC7802 TEST.
1、原理图,OLED与开发板连接:
利用杜绑线把OLED与开发板的PA7,PB8连接在一起
2.显示图片:
3、核心代码:
显示AC7802 TEST MEIYAO666:
OLED_ShowString(0,0," AC7802 Test ",16);
OLED_ShowString(16,4," MEIYAO666 ",16);
端口定义:
#define SCL_PORT (GPIOB)
#define SCL_PIN (GPIO_PIN7)
#define SDA_PORT (GPIOB)
#define SDA_PIN (GPIO_PIN8)
利用IIC点亮OLED显示,开启OLED显示,坐标设置,更新显示,显示字符等。
OLED初始:
OLED_WR_Byte(0xAE,OLED_CMD);//
OLED_WR_Byte(0x00,OLED_CMD);//---
OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
OLED_WR_Byte(0x40,OLED_CMD);//--set start line address
OLED_WR_Byte(0xB0,OLED_CMD);//--set page address
OLED_WR_Byte(0x81,OLED_CMD); // contract control
OLED_WR_Byte(0xFF,OLED_CMD);//
OLED_WR_Byte(0xA1,OLED_CMD);//set segment remap
OLED_WR_Byte(0xA6,OLED_CMD);//--normal / reverse
OLED_WR_Byte(0xA8,OLED_CMD);//
OLED_WR_Byte(0x3F,OLED_CMD);//--1/32 duty
OLED_WR_Byte(0xC8,OLED_CMD);//Com scan direction
OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset
OLED_WR_Byte(0x00,OLED_CMD);//
OLED_WR_Byte(0xD5,OLED_CMD);//set osc division
OLED_WR_Byte(0x80,OLED_CMD);//
OLED_WR_Byte(0xD8,OLED_CMD);//set area color mode off
OLED_WR_Byte(0x05,OLED_CMD);//
OLED_WR_Byte(0xD9,OLED_CMD);//Set Pre-Charge Period
OLED_WR_Byte(0xF1,OLED_CMD);//
OLED_WR_Byte(0xDA,OLED_CMD);//set com pin configuartion
OLED_WR_Byte(0x12,OLED_CMD);//
OLED_WR_Byte(0xDB,OLED_CMD);//set Vcomh
OLED_WR_Byte(0x30,OLED_CMD);//
OLED_WR_Byte(0x8D,OLED_CMD);//set charge pump enable
OLED_WR_Byte(0x14,OLED_CMD);//
OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
4、显示视频:
|