Fix garbled code about bmp.h oled.c oled.h oledfont.h .

This commit is contained in:
IllusionLee
2019-10-04 17:23:41 +08:00
parent 3d5b7bd6a1
commit dba0bcf452
4 changed files with 138 additions and 143 deletions

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
// //
// //
//<EFBFBD>洢ͼƬ<EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ͼƬ<EFBFBD><EFBFBD>СΪ64*32<EFBFBD><EFBFBD><EFBFBD><EFBFBD> //存储图片数据,图片大小为64*32像素
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@@ -71,7 +71,7 @@ unsigned char BMP1[] =
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,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,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,0x00,0x1F,0x20,0x40,0x40, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x40,0x40,
0x40,0x50,0x20,0x5F,0x80,0x00,0x1F,0x20,0x40,0x40,0x40,0x50,0x20,0x5F,0x80,0x00,/*"C:\Users\evk\Desktop\??2014.bmp",0*/ 0x40,0x50,0x20,0x5F,0x80,0x00,0x1F,0x20,0x40,0x40,0x40,0x50,0x20,0x5F,0x80,0x00,
}; };

View File

@@ -1,15 +1,15 @@
#include "oled.h" #include "oled.h"
#include "stdlib.h" #include "stdlib.h"
#include "oledfont.h" #include "oledfont.h"
//OLED<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD> //OLED的显存
//<EFBFBD><EFBFBD><EFBFBD>Ÿ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>. //存放格式如下.
//----------------------------------- //-----------------------------------
//|x<EFBFBD><EFBFBD>[0,127] | //|x[0,127] |
//| OLED<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> | //| OLED显示坐标 |
//|y <EFBFBD><EFBFBD>Χ | //|y 范围 |
//|<EFBFBD><EFBFBD> | //| |
//|[0,31] | //|[0,31] |
//----------------------------------- //-----------------------------------
/********************************************** /**********************************************
//IIC Start //IIC Start
**********************************************/ **********************************************/
@@ -46,7 +46,7 @@ void Write_IIC_Byte(unsigned char IIC_Byte)
unsigned char m,da; unsigned char m,da;
da=IIC_Byte; da=IIC_Byte;
OLED_SCLK_Clr(); OLED_SCLK_Clr();
for(i=0;i<8;i++) for(i=0;i<8;i++)
{ {
m=da; m=da;
m=m&0x80; m=m&0x80;
@@ -54,7 +54,7 @@ void Write_IIC_Byte(unsigned char IIC_Byte)
{ {
OLED_SDIN_Set(); OLED_SDIN_Set();
} }
else else
OLED_SDIN_Clr(); OLED_SDIN_Clr();
da=da<<1; da=da<<1;
OLED_SCLK_Set(); OLED_SCLK_Set();
@@ -68,11 +68,11 @@ void Write_IIC_Command(unsigned char IIC_Command)
{ {
IIC_Start(); IIC_Start();
Write_IIC_Byte(0x78); //Slave address,SA0=0 Write_IIC_Byte(0x78); //Slave address,SA0=0
IIC_Wait_Ack(); IIC_Wait_Ack();
Write_IIC_Byte(0x00); //write command Write_IIC_Byte(0x00); //write command
IIC_Wait_Ack(); IIC_Wait_Ack();
Write_IIC_Byte(IIC_Command); Write_IIC_Byte(IIC_Command);
IIC_Wait_Ack(); IIC_Wait_Ack();
IIC_Stop(); IIC_Stop();
} }
/********************************************** /**********************************************
@@ -82,11 +82,11 @@ void Write_IIC_Data(unsigned char IIC_Data)
{ {
IIC_Start(); IIC_Start();
Write_IIC_Byte(0x78); //D/C#=0; R/W#=0 Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
IIC_Wait_Ack(); IIC_Wait_Ack();
Write_IIC_Byte(0x40); //write data Write_IIC_Byte(0x40); //write data
IIC_Wait_Ack(); IIC_Wait_Ack();
Write_IIC_Byte(IIC_Data); Write_IIC_Byte(IIC_Data);
IIC_Wait_Ack(); IIC_Wait_Ack();
IIC_Stop(); IIC_Stop();
} }
void OLED_WR_Byte(unsigned dat,unsigned cmd) void OLED_WR_Byte(unsigned dat,unsigned cmd)
@@ -95,9 +95,9 @@ void OLED_WR_Byte(unsigned dat,unsigned cmd)
{ {
Write_IIC_Data(dat); Write_IIC_Data(dat);
} }
else else
{ {
Write_IIC_Command(dat); Write_IIC_Command(dat);
} }
} }
@@ -120,96 +120,97 @@ void fill_picture(unsigned char fill_Data)
} }
} }
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //坐标设置
void OLED_Set_Pos(unsigned char x, unsigned char y) void OLED_Set_Pos(unsigned char x, unsigned char y)
{ {
OLED_WR_Byte(0xb0+y,OLED_CMD); OLED_WR_Byte(0xb0+y,OLED_CMD);
OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD); OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD);
OLED_WR_Byte((x&0x0f),OLED_CMD); OLED_WR_Byte((x&0x0f),OLED_CMD);
} }
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>OLED<EFBFBD><EFBFBD>ʾ //开启OLED显示
void OLED_Display_On(void) void OLED_Display_On(void)
{ {
OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC<EFBFBD><EFBFBD><EFBFBD><EFBFBD> OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令
OLED_WR_Byte(0X14,OLED_CMD); //DCDC ON OLED_WR_Byte(0X14,OLED_CMD); //DCDC ON
OLED_WR_Byte(0XAF,OLED_CMD); //DISPLAY ON OLED_WR_Byte(0XAF,OLED_CMD); //DISPLAY ON
} }
//<EFBFBD>ر<EFBFBD>OLED<EFBFBD><EFBFBD>ʾ //关闭OLED显示
void OLED_Display_Off(void) void OLED_Display_Off(void)
{ {
OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC<EFBFBD><EFBFBD><EFBFBD><EFBFBD> OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令
OLED_WR_Byte(0X10,OLED_CMD); //DCDC OFF OLED_WR_Byte(0X10,OLED_CMD); //DCDC OFF
OLED_WR_Byte(0XAE,OLED_CMD); //DISPLAY OFF OLED_WR_Byte(0XAE,OLED_CMD); //DISPLAY OFF
} }
//ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>Ǻ<EFBFBD>ɫ<EFBFBD><C9AB>!<21><>û<EFBFBD><C3BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>!!! //注意:清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!
void OLED_Clear(void) void OLED_Clear(void)
{ {
uint8_t i,n; uint8_t i,n;
for(i=0;i<8;i++) for(i=0;i<8;i++)
{ {
OLED_WR_Byte (0xb0+i,OLED_CMD); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>0~7<EFBFBD><EFBFBD> OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7
OLED_WR_Byte (0x00,OLED_CMD); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<EFBFBD>á<EFBFBD><EFBFBD>е͵<EFBFBD>ַ OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址
OLED_WR_Byte (0x10,OLED_CMD); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<EFBFBD>á<EFBFBD><EFBFBD>иߵ<EFBFBD>ַ OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址
for(n=0;n<128;n++) for(n=0;n<128;n++)
OLED_WR_Byte(0,OLED_DATA); OLED_WR_Byte(0,OLED_DATA);
} //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ } //更新显示
} }
void OLED_On(void) void OLED_On(void)
{ {
uint8_t i,n; uint8_t i,n;
for(i=0;i<8;i++) for(i=0;i<8;i++)
{ {
OLED_WR_Byte (0xb0+i,OLED_CMD); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>0~7<EFBFBD><EFBFBD> OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7
OLED_WR_Byte (0x00,OLED_CMD); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<EFBFBD>á<EFBFBD><EFBFBD>е͵<EFBFBD>ַ OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址
OLED_WR_Byte (0x10,OLED_CMD); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<EFBFBD>á<EFBFBD><EFBFBD>иߵ<EFBFBD>ַ OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址
for(n=0;n<128;n++)OLED_WR_Byte(1,OLED_DATA); for(n=0;n<128;n++)OLED_WR_Byte(1,OLED_DATA);
} //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ } //更新显示
} }
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾһ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD> //在指定位置显示一个字符,包括部分字符
//x:0~127 //x:0~127
//y:0~63 //y:0~63
// //
//size:ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 16/12 //size:选择字体 16/12
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size) void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
{ {
unsigned char c=0,i=0; unsigned char c=0,i=0;
c=chr-' ';//<EFBFBD>õ<EFBFBD>ƫ<EFBFBD>ƺ<EFBFBD><EFBFBD><EFBFBD>ֵ c=chr-' ';//得到偏移后的值
if(x>Max_Column-1){x=0;y=y+2;} if(x>Max_Column-1){x=0;y=y+2;}
if(Char_Size ==16) if(Char_Size ==16)
{ {
OLED_Set_Pos(x,y); OLED_Set_Pos(x,y);
for(i=0;i<8;i++) for(i=0;i<8;i++)
{ {
OLED_WR_Byte(F8X16[c*16+i],OLED_DATA); OLED_WR_Byte(F8X16[c*16+i],OLED_DATA);
} }
OLED_Set_Pos(x,y+1); OLED_Set_Pos(x,y+1);
for(i=0;i<8;i++) for(i=0;i<8;i++){
OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA); OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA);
}
} }
else else
{ {
OLED_Set_Pos(x,y); OLED_Set_Pos(x,y);
for(i=0;i<6;i++) for(i=0;i<6;i++)
OLED_WR_Byte(F6x8[c][i],OLED_DATA); OLED_WR_Byte(F6x8[c][i],OLED_DATA);
} }
} }
//m^n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> //m^n函数
uint32_t oled_pow(uint8_t m,uint8_t n) uint32_t oled_pow(uint8_t m,uint8_t n)
{ {
uint32_t result=1; uint32_t result=1;
while(n--)result*=m; while(n--)result*=m;
return result; return result;
} }
//<EFBFBD><EFBFBD>ʾ2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //显示2个数字
//x,y :<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //x,y :起点坐标
//len :<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>λ<EFBFBD><EFBFBD> //len :数字的位数
//size:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С //size:字体大小
// //
//num:<EFBFBD><EFBFBD>ֵ(0~4294967295); //num:数值(0~4294967295);
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size2) void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size2)
{ {
uint8_t t,temp; uint8_t t,temp;
uint8_t enshow=0; uint8_t enshow=0;
for(t=0;t<len;t++) for(t=0;t<len;t++)
{ {
temp=(num/oled_pow(10,len-t-1))%10; temp=(num/oled_pow(10,len-t-1))%10;
@@ -219,18 +220,18 @@ void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size2)
{ {
OLED_ShowChar(x+(size2/2)*t,y,' ',size2); OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
continue; continue;
}else }else
enshow=1; enshow=1;
} }
OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2); OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
} }
} }
//<EFBFBD><EFBFBD>ʾһ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>Ŵ<EFBFBD> //显示一个字符号串
void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size) void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
{ {
unsigned char j=0; unsigned char j=0;
while (chr[j]!='\0') while (chr[j]!='\0')
{ {
OLED_ShowChar(x,y,chr[j],Char_Size); OLED_ShowChar(x,y,chr[j],Char_Size);
x+=8; x+=8;
if(x>120) if(x>120)
@@ -240,60 +241,60 @@ void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
j++; j++;
} }
} }
//<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> //显示汉字
void OLED_ShowCHinese(uint8_t x,uint8_t y,uint8_t no) void OLED_ShowCHinese(uint8_t x,uint8_t y,uint8_t no)
{ {
uint8_t t,adder=0; uint8_t t,adder=0;
OLED_Set_Pos(x,y); OLED_Set_Pos(x,y);
for(t=0;t<16;t++) for(t=0;t<16;t++)
{ {
OLED_WR_Byte(Hzk[2*no][t],OLED_DATA); OLED_WR_Byte(Hzk[2*no][t],OLED_DATA);
adder+=1; adder+=1;
} }
OLED_Set_Pos(x,y+1); OLED_Set_Pos(x,y+1);
for(t=0;t<16;t++) for(t=0;t<16;t++)
{ {
OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA); OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA);
adder+=1; adder+=1;
} }
} }
/***********<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ʾBMPͼƬ128<EFBFBD><EFBFBD>64<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(x,y),x<>ķ<EFBFBD>Χ0<CEA7><30>127<32><37>yΪҳ<CEAA>ķ<EFBFBD>Χ0<CEA7><30>7*****************/ /***********功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0〜127y为页的范围0〜7*****************/
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]) void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[])
{ {
unsigned int j=0; unsigned int j=0;
unsigned char x,y; unsigned char x,y;
if(y1%8==0) y=y1/8; if(y1%8==0) y=y1/8;
else y=y1/8+1; else y=y1/8+1;
for(y=y0;y<y1;y++) for(y=y0;y<y1;y++)
{ {
OLED_Set_Pos(x0,y); OLED_Set_Pos(x0,y);
for(x=x0;x<x1;x++) for(x=x0;x<x1;x++)
{ {
OLED_WR_Byte(BMP[j++],OLED_DATA); OLED_WR_Byte(BMP[j++],OLED_DATA);
} }
} }
} }
//<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>OLED //初始化OLED
void OLED_Init(void) void OLED_Init(void)
{ {
HAL_Delay(200); HAL_Delay(200);
OLED_WR_Byte(0xAE,OLED_CMD);//<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>ʾ OLED_WR_Byte(0xAE,OLED_CMD);//关闭显示
OLED_WR_Byte(0x40,OLED_CMD);//---set low column address OLED_WR_Byte(0x40,OLED_CMD);//---set low column address
OLED_WR_Byte(0xB0,OLED_CMD);//---set high column address OLED_WR_Byte(0xB0,OLED_CMD);//---set high column address
OLED_WR_Byte(0xC8,OLED_CMD);//-not offset OLED_WR_Byte(0xC8,OLED_CMD);//-not offset
OLED_WR_Byte(0x81,OLED_CMD);//<EFBFBD><EFBFBD><EFBFBD>öԱȶ<EFBFBD> OLED_WR_Byte(0x81,OLED_CMD);//设置对比度
OLED_WR_Byte(0xff,OLED_CMD); OLED_WR_Byte(0xff,OLED_CMD);
OLED_WR_Byte(0xa1,OLED_CMD);//<EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> OLED_WR_Byte(0xa1,OLED_CMD);//段重定向设置
OLED_WR_Byte(0xa6,OLED_CMD);// OLED_WR_Byte(0xa6,OLED_CMD);//
OLED_WR_Byte(0xa8,OLED_CMD);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD> OLED_WR_Byte(0xa8,OLED_CMD);//设置驱动路数
OLED_WR_Byte(0x1f,OLED_CMD); OLED_WR_Byte(0x1f,OLED_CMD);
OLED_WR_Byte(0xd3,OLED_CMD); OLED_WR_Byte(0xd3,OLED_CMD);
@@ -316,4 +317,4 @@ void OLED_Init(void)
OLED_WR_Byte(0xaf,OLED_CMD); OLED_WR_Byte(0xaf,OLED_CMD);
OLED_Clear(); OLED_Clear();
} }

View File

@@ -1,45 +1,41 @@
#ifndef __OLED_H #ifndef __OLED_H
#define __OLED_H #define __OLED_H
#include "stm32l4xx_hal.h" #include "stm32l4xx_hal.h"
#include "stdlib.h" #include "stdlib.h"
#define OLED_MODE 0 #define OLED_MODE 0
#define OLED_SIZE 8 #define OLED_SIZE 8
#define XLevelL 0x00 #define XLevelL 0x00
#define XLevelH 0x10 #define XLevelH 0x10
#define Max_Column 128 #define Max_Column 128
#define Max_Row 64 #define Max_Row 64
#define Brightness 0xFF #define Brightness 0xFF
#define X_WIDTH 128 #define X_WIDTH 128
#define Y_WIDTH 64 #define Y_WIDTH 64
//-----------------OLED IIC<EFBFBD>˿ڶ<EFBFBD><EFBFBD><EFBFBD>---------------- //-----------------OLED IIC端口定义----------------
//HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState); //HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
#define OLED_SCLK_Clr() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10, GPIO_PIN_RESET);//SDA IIC<EFBFBD>ӿڵ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> #define OLED_SCLK_Clr() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10, GPIO_PIN_RESET);//SDA IIC接口的时钟信号
#define OLED_SCLK_Set() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10, GPIO_PIN_SET); #define OLED_SCLK_Set() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10, GPIO_PIN_SET);
#define OLED_SDIN_Clr() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_3, GPIO_PIN_RESET);//SCL IIC<EFBFBD>ӿڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> #define OLED_SDIN_Clr() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_3, GPIO_PIN_RESET);//SCL IIC接口的数据信号
#define OLED_SDIN_Set() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_3, GPIO_PIN_SET); #define OLED_SDIN_Set() HAL_GPIO_WritePin(GPIOB,GPIO_PIN_3, GPIO_PIN_SET);
#define OLED_CMD 0 //д<EFBFBD><EFBFBD><EFBFBD><EFBFBD> #define OLED_CMD 0 //写命令
#define OLED_DATA 1 //д<EFBFBD><EFBFBD><EFBFBD><EFBFBD> #define OLED_DATA 1 //写数据
//OLED<EFBFBD>ӿڿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD> //OLED接口控制用函数
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size); void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size);
void OLED_ShowString(uint8_t x,uint8_t y, uint8_t *p,uint8_t Char_Size); void OLED_ShowString(uint8_t x,uint8_t y, uint8_t *p,uint8_t Char_Size);
void OLED_ShowCHinese(uint8_t x,uint8_t y,uint8_t no); void OLED_ShowCHinese(uint8_t x,uint8_t y,uint8_t no);
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]); void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
//OLED<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //OLED基础函数
void OLED_Init(void); void OLED_Init(void);
void OLED_Clear(void); void OLED_Clear(void);
void OLED_Display_On(void); void OLED_Display_On(void);
void OLED_Display_Off(void); void OLED_Display_Off(void);
void OLED_Set_Pos(unsigned char x, unsigned char y); void OLED_Set_Pos(unsigned char x, unsigned char y);
#endif #endif

View File

@@ -1,12 +1,12 @@
#ifndef __OLEDFONT_H #ifndef __OLEDFONT_H
#define __OLEDFONT_H #define __OLEDFONT_H
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ASCII<EFBFBD><EFBFBD> //常用ASCII
//ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>32 //偏移量32
//ASCII<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD> //ASCII字符集
//ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>32 //偏移量32
//<EFBFBD><EFBFBD>С:12*6 //大小:12*6
/************************************6*8<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>************************************/ /************************************6*8的点阵************************************/
const unsigned char F6x8[][6] = const unsigned char F6x8[][6] =
{ {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},// sp {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},// sp
{0x00, 0x00, 0x00, 0x2f, 0x00, 0x00},// ! {0x00, 0x00, 0x00, 0x2f, 0x00, 0x00},// !
@@ -101,8 +101,8 @@ const unsigned char F6x8[][6] =
{0x00, 0x44, 0x64, 0x54, 0x4C, 0x44},// z {0x00, 0x44, 0x64, 0x54, 0x4C, 0x44},// z
{0x14, 0x14, 0x14, 0x14, 0x14, 0x14},// horiz lines {0x14, 0x14, 0x14, 0x14, 0x14, 0x14},// horiz lines
}; };
/****************************************8*16<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>************************************/ /****************************************8*16的点阵************************************/
const unsigned char F8X16[]= const unsigned char F8X16[]=
{ {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
@@ -203,30 +203,28 @@ const unsigned char F8X16[]=
char Hzk[][32]={ char Hzk[][32]={
{0x40,0x3C,0x10,0xFF,0x10,0x10,0x20,0x10,0x8F,0x78,0x08,0xF8,0x08,0xF8,0x00,0x00}, {0x40,0x3C,0x10,0xFF,0x10,0x10,0x20,0x10,0x8F,0x78,0x08,0xF8,0x08,0xF8,0x00,0x00},
{0x02,0x06,0x02,0xFF,0x01,0x01,0x04,0x42,0x21,0x18,0x46,0x81,0x40,0x3F,0x00,0x00},/*"<EFBFBD><EFBFBD>",0*/ {0x02,0x06,0x02,0xFF,0x01,0x01,0x04,0x42,0x21,0x18,0x46,0x81,0x40,0x3F,0x00,0x00},/*"",0*/
/* (16 X 16 , <EFBFBD><EFBFBD><EFBFBD><EFBFBD> )*/ /* (16 X 16 , 宋体 )*/
{0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0x10,0x11,0x16,0xF0,0x14,0x13,0x10,0x00,0x00}, {0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0x10,0x11,0x16,0xF0,0x14,0x13,0x10,0x00,0x00},
{0x10,0x1F,0x08,0x08,0xFF,0x04,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x00},/*"<EFBFBD><EFBFBD>",1*/ {0x10,0x1F,0x08,0x08,0xFF,0x04,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x00},/*"",1*/
/* (16 X 16 , <EFBFBD><EFBFBD><EFBFBD><EFBFBD> )*/ /* (16 X 16 , 宋体 )*/
{0x00,0xFE,0x02,0x22,0x42,0x82,0x72,0x02,0x22,0x42,0x82,0x72,0x02,0xFE,0x00,0x00}, {0x00,0xFE,0x02,0x22,0x42,0x82,0x72,0x02,0x22,0x42,0x82,0x72,0x02,0xFE,0x00,0x00},
{0x00,0xFF,0x10,0x08,0x06,0x01,0x0E,0x10,0x08,0x06,0x01,0x4E,0x80,0x7F,0x00,0x00},/*"<EFBFBD><EFBFBD>",2*/ {0x00,0xFF,0x10,0x08,0x06,0x01,0x0E,0x10,0x08,0x06,0x01,0x4E,0x80,0x7F,0x00,0x00},/*"",2*/
/* (16 X 16 , <EFBFBD><EFBFBD><EFBFBD><EFBFBD> )*/ /* (16 X 16 , 宋体 )*/
{0x00,0x80,0x60,0xF8,0x07,0x00,0xFE,0x52,0x52,0x52,0x52,0x52,0xFE,0x00,0x00,0x00}, {0x00,0x80,0x60,0xF8,0x07,0x00,0xFE,0x52,0x52,0x52,0x52,0x52,0xFE,0x00,0x00,0x00},
{0x01,0x00,0x00,0xFF,0x08,0x88,0x4F,0x29,0x09,0x09,0x09,0x29,0x4F,0x88,0x08,0x00},/*"<EFBFBD><EFBFBD>",3*/ {0x01,0x00,0x00,0xFF,0x08,0x88,0x4F,0x29,0x09,0x09,0x09,0x29,0x4F,0x88,0x08,0x00},/*"",3*/
/* (16 X 16 , <EFBFBD><EFBFBD><EFBFBD><EFBFBD> )*/ /* (16 X 16 , 宋体 )*/
{0x00,0x00,0xE0,0x9C,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0x80,0x00,0x00}, {0x00,0x00,0xE0,0x9C,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0x80,0x00,0x00},
{0x00,0x20,0x10,0x08,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x08,0x30,0x00,0x00},/*"<EFBFBD><EFBFBD>",4*/ {0x00,0x20,0x10,0x08,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x08,0x30,0x00,0x00},/*"",4*/
/* (16 X 16 , <EFBFBD><EFBFBD><EFBFBD><EFBFBD> )*/ /* (16 X 16 , 宋体 )*/
{0x40,0x44,0x54,0x65,0x46,0x44,0x64,0x54,0x44,0x40,0xFE,0x02,0x22,0xDA,0x06,0x00}, {0x40,0x44,0x54,0x65,0x46,0x44,0x64,0x54,0x44,0x40,0xFE,0x02,0x22,0xDA,0x06,0x00},
{0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0xFF,0x08,0x10,0x08,0x07,0x00},/*"<EFBFBD><EFBFBD>",5*/ {0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0xFF,0x08,0x10,0x08,0x07,0x00},/*"",5*/
/* (16 X 16 , <EFBFBD><EFBFBD><EFBFBD><EFBFBD> )*/ /* (16 X 16 , 宋体 )*/
}; };
#endif #endif