当前位置:网站首页>Based on STM32F103 0.96 inch OLED LCD driver (IIC communication)
Based on STM32F103 0.96 inch OLED LCD driver (IIC communication)
2022-06-24 19:23:00 【Me-Space】
One 、 summary
OLED The driving methods are 8080、6800、3 Line /4 Line SPI as well as IIC, Able to display characters 、 Picture of Chinese characters , No word library needs to obtain the display content array through the mold taking software . This experiment uses IIC Communication protocol ,SSD1306 Driver chip OLED screen .
Two 、 Experimental materials
1、0.96 " OLED screen .
2、 Minimum system STM32F103C8T6.
3、 There are several DuPont lines .
3、 ... and 、 connection
| Function pin | GPIO |
|---|---|
| GND | GND |
| VCC | VCC |
| SCL | PA6 |
| SDA | PA7 |
Four 、 Program code
1、GPIO initialization
void Oled_Init(void)
{
IIC_Pin_Init();//iic Pin initialization
OLED_Send_Command(0xAE);//--turn off oled panel
OLED_Send_Command(0x02);//---SET low column address
OLED_Send_Command(0x10);//---SET high column address
OLED_Send_Command(0x40);//--SET start line address SET Mapping RAM Display Start Line (0x00~0x3F)
OLED_Send_Command(0x81);//--SET contrast control register
OLED_Send_Command(0xCF); // SET SEG Output Current Brightness
OLED_Send_Command(0xA1);//--SET SEG/Column Mapping 0xa0 Reverse left and right 0xa1 normal
OLED_Send_Command(0xC8);//SET COM/Row Scan Direction 0xc0 Up and down reversed 0xc8 normal
OLED_Send_Command(0xA6);//--SET normal display
OLED_Send_Command(0xA8);//--SET multiplex ratio(1 to 64)
OLED_Send_Command(0x3f);//--1/64 duty
OLED_Send_Command(0xD3);//-SET display offSET Shift Mapping RAM Counter (0x00~0x3F)
OLED_Send_Command(0x00);//-not offSET
OLED_Send_Command(0xd5);//--SET display clock divide ratio/oscillator frequency
OLED_Send_Command(0x80);//--SET divide ratio, SET Clock as 100 Frames/Sec
OLED_Send_Command(0xD9);//--SET pre-charge period
OLED_Send_Command(0xF1);//SET Pre-Charge as 15 Clocks & Discharge as 1 Clock
OLED_Send_Command(0xDA);//--SET com pins hardware configuration
OLED_Send_Command(0x12);
OLED_Send_Command(0xDB);//--SET vcomh
OLED_Send_Command(0x40);//SET VCOM Deselect Level
OLED_Send_Command(0x20);//-SET Page Addressing Mode (0x00/0x01/0x02)
OLED_Send_Command(0x02);//
OLED_Send_Command(0x8D);//--SET Charge Pump enable/disable
OLED_Send_Command(0x14);//--SET(0x10) disable
OLED_Send_Command(0xA4);// Disable Entire Display On (0xa4/0xa5)
OLED_Send_Command(0xA6);// Disable Inverse Display On (0xa6/a7)
OLED_Send_Command(0xAF);//--turn on oled panel
OLED_Send_Command(0xAF); /*display ON*/
OLED_Clear(0x00); // Clear the screen
}
2、 Writing data
void Oled_Write_Data(u8 data)
{
IIC_Start();
IIC_Send_Data(0x78);// Address
IIC_Send_Data(0x40);// Writing data
IIC_Send_Data(data);// Instructions
IIC_Stop();
}
3、 Write orders
void OLED_Send_Command(u8 com)
{
IIC_Start();
IIC_Send_Data(0x78);// Address
IIC_Send_Data(0x00);// Write instructions The first 6 Bit control write data / command
IIC_Send_Data(com);// Instructions
IIC_Stop();
}
4、 Clear the screen
void OLED_Clear(u8 clear_dat)
{
u8 i = 0, j = 0;
for(i = 0; i < 8; i++)
{
OLED_Send_Command(0xB0 + i);
OLED_Send_Command(0X00); // Low column address
OLED_Send_Command(0X10); // High column address
for(j = 0; j < 128; j++)
{
Oled_Write_Data(clear_dat);
}
}
}
5、 Display position
void Oled_Address(u8 row,u8 col)
{
OLED_Send_Command(0xB0 + row);
OLED_Send_Command(0X10 + ((col & 0xf0) >> 4)); // High column address
OLED_Send_Command(0X00 + (col & 0x0f));
}
6、 Show characters
void Oled_Display_Char(u8 page,u8 col,char ch)
{
u8 loca = ch - ' ';
u8 i = 0;
// Page address
Oled_Address(page,col);
for(i = 0; i < 8; i++)
{
Oled_Write_Data(Aciss_8X16[loca * 16 + i]);
}
Oled_Address(page + 1,col);
for(i = 0; i < 8; i++)
{
Oled_Write_Data(Aciss_8X16[loca * 16 + 8 + i]);
}
}
7、 display string
void Oled_Display_String(u8 page,u8 col,char *str)
{
while(*str)
{
Oled_Display_Char(page,col,*str);
col += 8;
str++;
}
}
8、 Display Chinese characters or pictures
void Oled_Display_Pic(u8 wight,u8 high,u8 page,u8 col,u8 *str)
{
u8 i = 0, j = 0;
for(i = 0; i < high / 8; i++)
{
Oled_Address(page + i,col);
for(j = 0; j < wight;j++)
{
Oled_Write_Data(str[wight * i + j]);
}
}
}
9、 The main function
int main(void)
{
char buf[] = {
"There is no luck"};
char buf1[] = {
"There is only"};
char buf2[] = {
"word."};
char author[] = {
"Qing"};
Sys_Delay_Init();
Oled_Init();
// Oled_Display_Char(0,0,'A');// Displays a single character
//There is no luck.There is only work. Luck doesn't exist , Hard work is the last word .
Oled_Display_String(0,0,buf); // display string
Oled_Display_String(2,0,buf1); // display string
Oled_Display_String(4,0,buf2); // display string
Oled_Display_String(6,80,author);
while(1)
{
}
}
5、 ... and 、 Experimental results

Procedures and relevant information
link :https://pan.baidu.com/s/1Bo093SotTLxs1NgNwa01nQ
Extraction code :ygrv
If there is any mistake, please point out , thank you !
边栏推荐
- LabView之MQTT协议使用
- IBPS开源表单设计器有什么功能?
- How to protect biological privacy in the AI era? Overview of the latest "privacy enhancement technology in biometrics" of the Autonomous University of Madrid, comprehensively detailing the biometric p
- Unity mobile game performance optimization spectrum CPU time-consuming optimization divided by engine modules
- mysql binlog 数据源配置文档麻烦分享一下
- Introduction to alos satellite
- 建立自己的网站(8)
- 对国产数据库厂商提几个关于SQL引擎的小需求
- starring开发HttpJson接入点+数据库
- 企业网络管理员必备的故障处理系统
猜你喜欢

对国产数据库厂商提几个关于SQL引擎的小需求

Using alicloud RDS for SQL Server Performance insight to optimize database load - first understanding of performance insight

模块五

How to use R package ggtreeextra to draw evolution tree

华为机器学习服务语音识别功能,让应用绘“声”绘色

Why useevent is not good enough

程序员如何做自媒体?

Experience of MDM master data project implementation for manufacturing projects

High dimension low code: component rendering sub component

Huawei machine learning service speech recognition function enables applications to paint "sound" and color
随机推荐
网络安全审查办公室对知网启动网络安全审查
Power efficiency test
The script implements the automated deployment of raid0
How do programmers do we media?
Kubernetes集群部署
Application DDoS attack principle and defense method
flink cdc全量读mysql老是报这个错怎么处理
Freeswitch使用originate转dialplan
Make track map
TKDE2022:基于知识增强采样的对话推荐系统
60 个神级 VS Code 插件!!
佛祖保佑 永无BUG
ls 常用参数
Volcano成Spark默認batch調度器
Experience of MDM master data project implementation for manufacturing projects
企业网络管理员必备的故障处理系统
微信小程序轮播图怎么自定义光标位置
R语言 4.1.0软件安装包和安装教程
Why are life science enterprises on the cloud in succession?
60 divine vs Code plug-ins!!