找到一块OLED显示屏,便写了一个可以显示字符,数字,图片的程序(这里一显示51黑电子和QQ图标为例,显示其他,可通过取模软件进行更改)在压缩包中附有工程文件,和取模软件,以及使用方法
制作出来的实物图如下:
#include "OLED.h"
#inclide "intrins.h"
/******************************************************************************/
// 定义显示字符:51
/******************************************************************************/
uint8 code oledTable2[] = {
0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00,//5
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00};//1
/******************************************************************************/
// 定义显示汉字:黑电子
/******************************************************************************/
uint8 code oledTable3[]={
0x00,0x00,0x3E,0x22,0x2A,0x32,0x22,0xFE,0x22,0x32,0x2A,0x22,0x3E,0x00,0x00,0x00,
0x88,0x68,0x09,0x09,0x29,0xC9,0x09,0x0F,0x29,0xC9,0x09,0x09,0x29,0xC8,0x08,0x00,//黑0
0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0xF8,0x00,0x00,0x00,
0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0x7F,0x88,0x88,0x88,0x88,0x9F,0x80,0xF0,0x00,//电1
0x80,0x82,0x82,0x82,0x82,0x82,0x82,0xE2,0xA2,0x92,0x8A,0x86,0x82,0x80,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//子2
/******************************************************************************/
// 定义显示图画
/******************************************************************************/
//QQ图标
uint8 code oledTable4[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
......详见附件...........
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00};//C:UsersxzsDesktop捕获.bmp0//C:UsersxzsDesktop捕获.bmp0
void display2(uint8 page,uint8 lie,uint8 *p)
{//显示一个字符
uint8 i;
Oled_Write_Cmd(0xb0+page); //page 0
Oled_Write_Cmd(0x00+lie); //low
Oled_Write_Cmd(0x10+lie); //high
for(i=0;i<8;i++){
Oled_Write_Data(p[i]);//写数据oledTable1
}
Oled_Write_Cmd(0xb1+page); //page 1
Oled_Write_Cmd(0x00+lie); //low
Oled_Write_Cmd(0x10+lie); //high
for(i=0;i<8;i++){
Oled_Write_Data(p[i+8]);//写数据oledTable1
}}
void display3(uint8 page,uint8 lie,uint8 *p)
{//显示汉字
uint8 i;
Oled_Write_Cmd(0xb0+page); //page 0
Oled_Write_Cmd(0x00+lie); //low
Oled_Write_Cmd(0x10+lie); //high
for(i=0;i<16;i++){
Oled_Write_Data(p[i]);//写数据oledTable1
}
Oled_Write_Cmd(0xb1+page); //page 1
Oled_Write_Cmd(0x00+lie); //low
Oled_Write_Cmd(0x10+lie); //high
for(i=0;i<16;i++){
Oled_Write_Data(p[i+16]);//写数据oledTable1
}}
void display4()
{//显示一幅图
uint8 i;
Oled_Init();
Oled_Screen_Clear();
Oled_Write_Cmd(0xb0); //page 0
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i]);//写数据oledTable1
}
Oled_Write_Cmd(0xb1); //page 1
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i+128]);//写数据oledTable1
}
Oled_Write_Cmd(0xb2); //page 2
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i+256]);//写数据oledTable1
}
Oled_Write_Cmd(0xb3); //page 3
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i+384]);//写数据oledTable1
}
Oled_Write_Cmd(0xb4); //page 4
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i+512]);//写数据oledTable1
}
Oled_Write_Cmd(0xb5); //page 5
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i+640]);//写数据oledTable1
}
Oled_Write_Cmd(0xb6); //page 6
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i+768]);//写数据oledTable1
}
Oled_Write_Cmd(0xb7); //page 7
Oled_Write_Cmd(0x00); //low
Oled_Write_Cmd(0x10); //high
for(i=0;i<128;i++){
Oled_Write_Data(oledTable4[i+896]);//写数据oledTable1
}
}
int main(void)
{ Oled_Init();
Oled_Screen_Clear();
display2(0,0,oledTable2);//51黑电子
display2(0,1,oledTable2+16);
display3(0,2,oledTable3);
display3(0,3,oledTable3+32);
display3(0,4,oledTable3+64);
//display4();//qq图标的显示
while(1);
}
上一篇:单片机+NRF2401+DHT11远程温湿度控制程序
下一篇:单片机LED调光程序,状态机按键处理,效果比较好
推荐阅读最新更新时间:2024-10-26 23:15
设计资源 培训 开发板 精华推荐
- 使用 Analog Devices 的 LTC1261CS 的参考设计
- ADR03 的典型应用电路,用于精密升压输出稳压器的 2.5V 电压基准
- ESP-01S MOS开关管(代替继电器)
- MPC5746R发动机管理评估系统
- ADR3433 3.3V 输出微功率、高精度电压基准的典型应用
- L7815A 光控制器稳压器的典型应用 (Vo(min) = Vxx + VBE)
- ELRS 2.4G接收机
- 使用 ROHM Semiconductor 的 BD4831 的参考设计
- HFBR-0503Z,用于 DC - 40 KBd 多功能链路的评估套件
- LTC1261LIS8-4 5V 输入、-4V 输出 GaAs FET 偏置发生器的典型应用电路