中景园2.13寸黑白电子墨水屏全刷局刷驱动
一、屏幕初始化
//初始化屏幕
void OLED_GUIInit(void)
{
OLED_GPIOInit();
OLED_RES_Clr(); // Module reset
delay_ms(20); //At least 10ms delay
OLED_RES_Set();
delay_ms(20); //At least 10ms delay
Epaper_READBUSY();
OLED_WR_REG(0x12); //SWRESET
Epaper_READBUSY();
OLED_WR_REG(0x01); //Driver output control
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
OLED_WR_DATA8(0x01);
OLED_WR_REG(0x11); //data entry mode
OLED_WR_DATA8(0x01);
OLED_WR_REG(0x44); //set Ram-X address start/end position
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x0F); //0x0F-->(15+1)*8=128
OLED_WR_REG(0x45); //set Ram-Y address start/end position
OLED_WR_DATA8(0x27); //0xF9-->(249+1)=250
OLED_WR_DATA8(0x01);
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x3C); //BorderWavefrom
OLED_WR_DATA8(0x05);
OLED_WR_REG(0x21); // Display update control
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x80);
OLED_WR_REG(0x18); //Read built-in temperature sensor
OLED_WR_DATA8(0x80);
OLED_WR_REG(0x4E); // set RAM x address count to 0;
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x4F); // set RAM y address count to 0X199;
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
Epaper_READBUSY();
}
二、全刷/快刷/局刷
中景园以及佳显的2.13寸水墨屏是一样的,都支持全刷,局刷,快刷三种刷新模式
void EPD_Update(void) //全刷
{
OLED_WR_REG(0x22);
OLED_WR_DATA8(0xF7);
OLED_WR_REG(0x20);
Epaper_READBUSY();
}
void EPD_Update_Fast(void) //快刷
{
OLED_WR_REG(0x22);
OLED_WR_DATA8(0xC7);
OLED_WR_REG(0x20);
Epaper_READBUSY();
}
void EPD_Update_Partial(void) //局刷
{
OLED_WR_REG(0x22);
OLED_WR_DATA8(0xFF);
OLED_WR_REG(0x20);
Epaper_READBUSY();
}
三、全刷
//全刷到显存
void OLED_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
u32 k=0;
Width = 250;
Height = 16;
OLED_WR_REG(0x24);
for ( j = 0; j < Height; j++)
{
for ( i = 0; i < Width; i++)
{
OLED_WR_DATA8(Image[k]);
k++;
}
}
EPD_Update(); //快刷则是把此处替换为 EPD_Update_Fast();
}
四、局刷
这里的局刷是在全屏区域内开设一个局部刷新区域,屏幕不会闪烁。
void EPD_Dis_Part_RAM(u8 x_start,u8 y_start,const u8 * datas,u16 PART_COLUMN,u16 PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
OLED_RES_Clr(); // Module reset
delay_ms(20); //At least 10ms delay
OLED_RES_Set();
delay_ms(20); //At least 10ms delay
OLED_WR_REG(0x3C);
OLED_WR_DATA8(0x80);
OLED_WR_REG(0x44); // set RAM x address start/end
OLED_WR_DATA8(x_start); //x address start
OLED_WR_DATA8(x_end); //y address end
OLED_WR_REG(0x45); // set RAM y address start/end
OLED_WR_DATA8(y_start%256); //y address start2
OLED_WR_DATA8(y_start/256); //y address start1
OLED_WR_DATA8(y_end%256); //y address end2
OLED_WR_DATA8(y_end/256); //y address end1
OLED_WR_REG(0x4E); // set RAM x address count to 0;
OLED_WR_DATA8(x_start); //x start address
OLED_WR_REG(0x4F); // set RAM y address count to 0X127;
OLED_WR_DATA8(y_start%256); //y address start2
OLED_WR_DATA8(y_start/256); //y address start1
OLED_WR_REG(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
OLED_WR_DATA8(datas[i]);
}
}
五、用局刷的方式刷全屏
局刷区域为全屏,屏幕不会闪烁!中景园没有局刷的示例代码,佳显的局刷全屏代码有误,没有重新设置坐标,连续局刷全屏会出现偏移想象!
void EPD_Dis_PartAll(unsigned char *Image)
{
unsigned int Width, Height,i,j;
u32 k=0;
Width = 250;
Height = 16;
OLED_RES_Clr();
delay_ms(20);
OLED_RES_Set();
delay_ms(20);
OLED_WR_REG(0x3C);
OLED_WR_DATA8(0x80);
//一定要重新设置窗口与坐标!
OLED_WR_REG(0x44);
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x0F);
OLED_WR_REG(0x45);
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x4E);
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x4F);
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
OLED_WR_REG(0x24);
for ( j = 0; j < Height; j++)
{
for ( i = 0; i < Width; i++)
{
OLED_WR_DATA8(Image[k]);
k++;
}
}
EPD_Update_Partial();
}
六、使用示例
static u8 refresh_count=9;
refresh_count++;
if(refresh_count==10) //局刷10次全刷1次
{
OLED_GUIInit();
OLED_Display(Image_BW);
refresh_count=0;
}
else EPD_Dis_PartAll(Image_BW);
OLED_Sleep(); //深度睡眠
七、完整封装代码
oled.c
#include "oled.h"
#include "oledfont.h"
//初始化GPIO
void OLED_GPIOInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//SDA SCL CS D/C RES
GPIO_InitStructure.Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.Mode = GPIO_PullUp; //上拉准双向口
GPIO_Inilize(GPIO_P3, &GPIO_InitStructure);
}
//模拟SPI时序
void OLED_WR_Bus(u8 dat)
{
u8 i;
OLED_CS_Clr();
for(i=0;i<8;i++)
{
OLED_SCL_Clr();
if(dat&0x80)
{
OLED_SDA_Set();
}
else
{
OLED_SDA_Clr();
}
OLED_SCL_Set();
dat<<=1;
}
OLED_CS_Set();
}
//写入一个命令
void OLED_WR_REG(u8 reg)
{
OLED_DC_Clr();
OLED_WR_Bus(reg);
OLED_DC_Set();
}
//写入一个字节
void OLED_WR_DATA8(u8 dat)
{
OLED_WR_Bus(dat);
}
PAINT Paint;
void Epaper_READBUSY()
{
while(1)
{
if(OLED_BUSY()==0)
{
break;
}
}
}
//初始化屏幕
void OLED_GUIInit(void)
{
OLED_GPIOInit();
OLED_RES_Clr(); // Module reset
delay_ms(20); //At least 10ms delay
OLED_RES_Set();
delay_ms(20); //At least 10ms delay
Epaper_READBUSY();
OLED_WR_REG(0x12); //SWRESET
Epaper_READBUSY();
OLED_WR_REG(0x01); //Driver output control
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
OLED_WR_DATA8(0x01);
OLED_WR_REG(0x11); //data entry mode
OLED_WR_DATA8(0x01);
OLED_WR_REG(0x44); //set Ram-X address start/end position
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x0F); //0x0F-->(15+1)*8=128
OLED_WR_REG(0x45); //set Ram-Y address start/end position
OLED_WR_DATA8(0x27); //0xF9-->(249+1)=250
OLED_WR_DATA8(0x01);
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x3C); //BorderWavefrom
OLED_WR_DATA8(0x05);
OLED_WR_REG(0x21); // Display update control
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x80);
OLED_WR_REG(0x18); //Read built-in temperature sensor
OLED_WR_DATA8(0x80);
OLED_WR_REG(0x4E); // set RAM x address count to 0;
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x4F); // set RAM y address count to 0X199;
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
Epaper_READBUSY();
}
void EPD_Update(void) //全刷
{
OLED_WR_REG(0x22);
OLED_WR_DATA8(0xF7);
OLED_WR_REG(0x20);
Epaper_READBUSY();
}
void EPD_Update_Fast(void) //快刷
{
OLED_WR_REG(0x22);
OLED_WR_DATA8(0xC7);
OLED_WR_REG(0x20);
Epaper_READBUSY();
}
void EPD_Update_Partial(void) //局刷
{
OLED_WR_REG(0x22);
OLED_WR_DATA8(0xFF);
OLED_WR_REG(0x20);
Epaper_READBUSY();
}
//全刷到显存
void OLED_Display(unsigned char *Image)
{
unsigned int Width, Height,i,j;
u32 k=0;
Width = 250;
Height = 16;
OLED_WR_REG(0x24);
for ( j = 0; j < Height; j++)
{
for ( i = 0; i < Width; i++)
{
OLED_WR_DATA8(Image[k]);
k++;
}
}
EPD_Update();
}
//用局刷的方式刷新全屏
void EPD_Dis_PartAll(unsigned char *Image)
{
unsigned int Width, Height,i,j;
u32 k=0;
Width = 250;
Height = 16;
OLED_RES_Clr();
delay_ms(20);
OLED_RES_Set();
delay_ms(20);
OLED_WR_REG(0x3C);
OLED_WR_DATA8(0x80);
//一定要重新设置窗口与坐标!
OLED_WR_REG(0x44);
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x0F);
OLED_WR_REG(0x45);
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
OLED_WR_DATA8(0x00);
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x4E);
OLED_WR_DATA8(0x00);
OLED_WR_REG(0x4F);
OLED_WR_DATA8(0x27);
OLED_WR_DATA8(0x01);
OLED_WR_REG(0x24);
for ( j = 0; j < Height; j++)
{
for ( i = 0; i < Width; i++)
{
OLED_WR_DATA8(Image[k]);
k++;
}
}
EPD_Update_Partial();
}
//局刷
void EPD_Dis_Part_RAM(u8 x_start,u8 y_start,const u8 * datas,u16 PART_COLUMN,u16 PART_LINE)
{
unsigned int i;
unsigned int x_end,y_end;
x_start=x_start/8; //x address start
x_end=x_start+PART_LINE/8-1; //x address end
y_start=y_start-1; //Y address start
y_end=y_start+PART_COLUMN-1; //Y address end
OLED_RES_Clr(); // Module reset
delay_ms(20); //At least 10ms delay
OLED_RES_Set();
delay_ms(20); //At least 10ms delay
OLED_WR_REG(0x3C);
OLED_WR_DATA8(0x80);
OLED_WR_REG(0x44); // set RAM x address start/end
OLED_WR_DATA8(x_start); //x address start
OLED_WR_DATA8(x_end); //y address end
OLED_WR_REG(0x45); // set RAM y address start/end
OLED_WR_DATA8(y_start%256); //y address start2
OLED_WR_DATA8(y_start/256); //y address start1
OLED_WR_DATA8(y_end%256); //y address end2
OLED_WR_DATA8(y_end/256); //y address end1
OLED_WR_REG(0x4E); // set RAM x address count to 0;
OLED_WR_DATA8(x_start); //x start address
OLED_WR_REG(0x4F); // set RAM y address count to 0X127;
OLED_WR_DATA8(y_start%256); //y address start2
OLED_WR_DATA8(y_start/256); //y address start1
OLED_WR_REG(0x24); //Write Black and White image to RAM
for(i=0;i<PART_COLUMN*PART_LINE/8;i++)
{
OLED_WR_DATA8(datas[i]);
}
}
//Partial refresh of background display, this function is necessary, please do not delete it!!!
void EPD_SetRAMValue_BaseMap(unsigned char *Image)
{
unsigned int i;
OLED_WR_REG(0x24);
for ( i = 0; i < 4000; i++)
{
OLED_WR_DATA8(Image[i]);
}
OLED_WR_REG(0x26);
for ( i = 0; i < 4000; i++)
{
OLED_WR_DATA8(Image[i]);
}
EPD_Update();
}
//清屏白色
void EPD_WhiteScreen_White(void)
{
unsigned int i;
OLED_WR_REG(0x24);
for(i=0;i<4000;i++)
{
OLED_WR_DATA8(0xff);
}
EPD_Update();
}
//深度睡眠
void OLED_Sleep()
{
OLED_WR_REG(0x10); //Deep Sleep Mode
OLED_WR_DATA8(0x01);
}
/************************************************************************/
void Paint_NewImage(u8 *image,u16 Width,u16 Height,u16 Rotate,u16 Color)
{
Paint.Image = 0x00;
Paint.Image = image;
Paint.WidthMemory = Width;
Paint.HeightMemory = Height;
Paint.Color = Color;
Paint.WidthByte = (Width % 8 == 0)? (Width / 8 ): (Width / 8 + 1);
Paint.HeightByte = Height;
Paint.Rotate = Rotate;
if(Rotate == ROTATE_0 || Rotate == ROTATE_180) {
Paint.Width = Height;
Paint.Height = Width;
} else {
Paint.Width = Width;
Paint.Height = Height;
}
}
void Paint_SetPixel(u16 Xpoint,u16 Ypoint,u16 Color)
{
u16 X, Y;
u32 Addr;
u8 Rdata;
switch(Paint.Rotate) {
case 0:
X = Paint.WidthMemory - Ypoint - 1;
Y = Xpoint;
break;
case 90:
X = Paint.WidthMemory - Xpoint - 1;
Y = Paint.HeightMemory - Ypoint - 1;
break;
case 180:
X = Ypoint;
Y = Paint.HeightMemory - Xpoint - 1;
break;
case 270:
X = Xpoint;
Y = Ypoint;
break;
default:
return;
}
Addr = X / 8 + Y * Paint.WidthByte;
Rdata = Paint.Image[Addr];
if(Color == BLACK)
{
Paint.Image[Addr] = Rdata & ~(0x80 >> (X % 8)); //将对应数据位置0
}
else
Paint.Image[Addr] = Rdata | (0x80 >> (X % 8)); //将对应数据位置1
}
//清屏函数
void OLED_Clear(u16 Color)
{
u16 X,Y;
u32 Addr;
for (Y = 0; Y < Paint.HeightByte; Y++) {
for (X = 0; X < Paint.WidthByte; X++) {//8 pixel = 1 byte
Addr = X + Y*Paint.WidthByte;
Paint.Image[Addr] = Color;
}
}
}
//画点函数
void OLED_DrawPoint(u16 Xpoint,u16 Ypoint,u16 Color)
{
Paint_SetPixel(Xpoint-1, Ypoint-1, Color);
}
void OLED_DrawLine(u16 x1,u16 y1,u16 x2,u16 y2,u16 color)
{
u16 i=0;
if(x1<1) x1=1;
if(x2>250) x2=250;
if(y1==y2) //画横线
for(i=x1;i<x2;i++)
OLED_DrawPoint(i,y1,color);
else //画竖线
for(i=y1;i<y2;i++)
OLED_DrawPoint(x1,i,color);
}
//画矩形
void OLED_DrawRectangle(u16 Xstart,u16 Ystart,u16 Xend,u16 Yend,u16 Color,u8 mode)
{
u16 i;
if (mode)
{
for(i = Ystart; i < Yend; i++)
{
OLED_DrawLine(Xstart,i,Xend,i,Color);
}
}
else
{
OLED_DrawLine(Xstart, Ystart, Xend, Ystart, Color);
OLED_DrawLine(Xstart, Ystart, Xstart, Yend, Color);
OLED_DrawLine(Xend, Yend, Xend, Ystart, Color);
OLED_DrawLine(Xend, Yend, Xstart, Yend, Color);
}
}
//画圆形
void OLED_DrawCircle(u16 X_Center,u16 Y_Center,u16 Radius,u16 Color,u8 mode)
{
u16 Esp, sCountY;
u16 XCurrent, YCurrent;
XCurrent = 0;
YCurrent = Radius;
Esp = 3 - (Radius << 1 );
if (mode) {
while (XCurrent <= YCurrent ) { //Realistic circles
for (sCountY = XCurrent; sCountY <= YCurrent; sCountY ++ ) {
OLED_DrawPoint(X_Center + XCurrent, Y_Center + sCountY, Color);//1
OLED_DrawPoint(X_Center - XCurrent, Y_Center + sCountY, Color);//2
OLED_DrawPoint(X_Center - sCountY, Y_Center + XCurrent, Color);//3
OLED_DrawPoint(X_Center - sCountY, Y_Center - XCurrent, Color);//4
OLED_DrawPoint(X_Center - XCurrent, Y_Center - sCountY, Color);//5
OLED_DrawPoint(X_Center + XCurrent, Y_Center - sCountY, Color);//6
OLED_DrawPoint(X_Center + sCountY, Y_Center - XCurrent, Color);//7
OLED_DrawPoint(X_Center + sCountY, Y_Center + XCurrent, Color);
}
if ((int)Esp < 0 )
Esp += 4 * XCurrent + 6;
else {
Esp += 10 + 4 * (XCurrent - YCurrent );
YCurrent --;
}
XCurrent ++;
}
} else { //Draw a hollow circle
while (XCurrent <= YCurrent ) {
OLED_DrawPoint(X_Center + XCurrent, Y_Center + YCurrent, Color);//1
OLED_DrawPoint(X_Center - XCurrent, Y_Center + YCurrent, Color);//2
OLED_DrawPoint(X_Center - YCurrent, Y_Center + XCurrent, Color);//3
OLED_DrawPoint(X_Center - YCurrent, Y_Center - XCurrent, Color);//4
OLED_DrawPoint(X_Center - XCurrent, Y_Center - YCurrent, Color);//5
OLED_DrawPoint(X_Center + XCurrent, Y_Center - YCurrent, Color);//6
OLED_DrawPoint(X_Center + YCurrent, Y_Center - XCurrent, Color);//7
OLED_DrawPoint(X_Center + YCurrent, Y_Center + XCurrent, Color);//0
if ((int)Esp < 0 )
Esp += 4 * XCurrent + 6;
else {
Esp += 10 + 4 * (XCurrent - YCurrent );
YCurrent --;
}
XCurrent ++;
}
}
}
//显示字符
void OLED_ShowChar(u16 x,u16 y,u16 chr,u16 size1,u16 color)
{
u16 i,m,temp,size2,chr1;
u16 x0,y0;
x+=1,y+=1,x0=x,y0=y;
size2=(size1/8+((size1%8)?1:0))*(size1/2);
//获取到偏移量,也就是减去数组的第一个字符
if(size1 == 64 || size1 == 112) chr1=chr-'0'; //0~9数字
else chr1=chr-' '; //ASCII码表
for(i=0;i<size2;i++)
{
if(size1==12)
{temp=asc2_1206[chr1][i];} //调用1206字体
else if(size1==16)
{temp=asc2_1608[chr1][i];} //调用1608字体
else if(size1==24)
{temp=asc2_2412[chr1][i];} //调用2412字体
else if(size1==64)
{temp=DS_Digital6432[chr1][i];} //调用64*32数码管数字
else if(size1==112) //调用112*56普通数字
{temp=Num11256[chr1][i];}
else return;
for(m=0;m<8;m++) //逐列式,从左到右
{
if(temp&0x01)OLED_DrawPoint(x,y,color);
else OLED_DrawPoint(x,y,!color);
temp>>=1;
y++;
}
x++;
if((x-x0)==size1/2)
{x=x0;y0=y0+8;}
y=y0;
}
}
//显示字符串
//x,y:起点坐标
//size1:字体大小
//*chr:字符串起始地址
//mode:0,反色显示;1,正常显示
void OLED_ShowString(u16 x,u16 y,u8 *chr,u16 size1,u16 color)
{
while(*chr!='')//判断是不是非法字符!
{
OLED_ShowChar(x,y,*chr,size1,color);
chr++;
if(x>230) {
y+=size1;
x=0;
}
x+=size1/2;
}
}
//m^n
u32 OLED_Pow(u16 m,u16 n)
{
u32 result=1;
while(n--)
{
result*=m;
}
return result;
}
//显示数字
//x,y :起点坐标
//num :要显示的数字
//len :数字的位数
//size:字体大小
//mode:0,反色显示;1,正常显示
void OLED_ShowNum(u16 x,u16 y,u32 num,u16 len,u16 size1,u16 color)
{
u8 t,temp,m=0;
if(size1==8)m=2;
for(t=0;t<len;t++)
{
temp=(num/OLED_Pow(10,len-t-1))%10;
if(temp==0)
{
OLED_ShowChar(x+(size1/2+m)*t,y,'0',size1,color);
}
else
{
OLED_ShowChar(x+(size1/2+m)*t,y,temp+'0',size1,color);
}
}
}
//显示汉字
//x,y:起点坐标
//num:汉字对应的序号
//mode:0,反色显示;1,正常显示
void OLED_ShowChinese(u16 x,u16 y,u16 num,u16 size1,u16 color)
{
u16 m,temp;
u16 x0,y0;
u16 i,size3=(size1/8+((size1%8)?1:0))*size1; //得到字体一个字符对应点阵集所占的字节数
x+=1,y+=1,x0=x,y0=y;
for(i=0;i<size3;i++)
{
if(size1==16)
{temp=Hzk1[num][i];}//调用16*16字体
//else if(size1==24)
//{temp=Hzk2[num][i];}//调用24*24字体
//else if(size1==32)
//{temp=Hzk3[num][i];}//调用32*32字体
//else if(size1==64)
//{temp=Hzk4[num][i];}//调用64*64字体
else if(size1==112)
{temp=Hzk2[num][i];} //调用112*112字体
else return;
for(m=0;m<8;m++)
{
if(temp&0x01)OLED_DrawPoint(x,y,color);
else OLED_DrawPoint(x,y,!color);
temp>>=1;
y++;
}
x++;
if((x-x0)==size1)
{x=x0;y0=y0+8;}
y=y0;
}
}
//显示图片
// x,y:起点坐标
// sizex:图片宽度
// sizey:图片长度
// BMP:图片数组
// mode:图片显示的颜色
void OLED_ShowPicture(u16 x,u16 y,u16 sizex,u16 sizey,const u8 BMP[],u16 Color)
{
u16 j=0;
u16 i,n,temp,m;
u16 x0,y0;
x+=1,y+=1,x0=x,y0=y;
sizey=sizey/8+((sizey%8)?1:0);
for(n=0;n<sizey;n++)
{
for(i=0;i<sizex;i++)
{
temp=BMP[j];
j++;
for(m=0;m<8;m++)
{
if(temp&0x01)OLED_DrawPoint(x,y,Color);
else OLED_DrawPoint(x,y,!Color);
temp>>=1;
y++;
}
x++;
if((x-x0)==sizex)
{
x=x0;
y0=y0+8;
}
y=y0;
}
}
}
oled.h
#ifndef __OLED_H
#define __OLED_H
#include "config.h"
//-----------------OLED端口定义----------------
#define OLED_SCL_Clr() P33=0 //SCL
#define OLED_SCL_Set() P33=1
#define OLED_SDA_Clr() P32=0 //SDA
#define OLED_SDA_Set() P32=1
#define OLED_RES_Clr() P36=0 //RES
#define OLED_RES_Set() P36=1
#define OLED_DC_Clr() P35=0 //DC
#define OLED_DC_Set() P35=1
#define OLED_CS_Clr() P34=0 //CS
#define OLED_CS_Set() P34=1
#define OLED_BUSY() P37 //BUSY
#define OLED_W 122
#define OLED_H 250
typedef struct {
u8 *Image;
u16 Width;
u16 Height;
u16 WidthMemory;
u16 HeightMemory;
u16 Color;
u16 Rotate;
u16 WidthByte;
u16 HeightByte;
} PAINT;
extern PAINT Paint;
#define ROTATE_0 0 //屏幕正向显示
#define ROTATE_90 90 //屏幕旋转90度显示
#define ROTATE_180 180 //屏幕旋转180度显示
#define ROTATE_270 270 //屏幕旋转270度显示
#define WHITE 0xFF //显示白色
#define BLACK 0x00 //显示黑色
void OLED_GPIOInit(void); //初始化GPIO
void Power_Init(void);
void OLED_WR_Bus(u8 dat); //模拟SPI时序
void OLED_WR_REG(u8 reg); //写入一个命令
void OLED_WR_DATA8(u8 dat); //写入一个字节
void OLED_AddressSet(u16 xs,u16 ys,u16 xe,u16 ye); //设置位置函数
void OLED_Init(void); //初始化屏幕
void Epaper_READBUSY(void);
void EPD_Update(void);
void EPD_Update_Partial(void); //局刷
void EPD_WhiteScreen_White(void);
void OLED_Sleep(void); //深度睡眠
void Paint_NewImage(u8 *image,u16 Width,u16 Height,u16 Rotate,u16 Color); //创建画布控制显示方向
void OLED_Clear(u16 Color); //清屏函数
void OLED_DrawPoint(u16 Xpoint,u16 Ypoint,u16 Color); //画点
void OLED_DrawLine(u16 Xstart,u16 Ystart,u16 Xend,u16 Yend,u16 Color); //画线
void OLED_DrawRectangle(u16 Xstart,u16 Ystart,u16 Xend,u16 Yend,u16 Color,u8 mode); //画矩形
void OLED_DrawCircle(u16 X_Center,u16 Y_Center,u16 Radius,u16 Color,u8 mode); //画圆
void OLED_ShowChar(u16 x,u16 y,u16 chr,u16 size1,u16 color); //显示字符
void OLED_ShowString(u16 x,u16 y,u8 *chr,u16 size1,u16 color); //显示字符串
void OLED_ShowNum(u16 x,u16 y,u32 num,u16 len,u16 size1,u16 color); //显示数字
void OLED_ShowChinese(u16 x,u16 y,u16 num,u16 size1,u16 color); //显示中文
void OLED_ShowPicture(u16 x,u16 y,u16 sizex,u16 sizey,const u8 BMP[],u16 color); //显示图片
void OLED_Display(unsigned char *Image); //更新到屏幕
void EPD_Dis_PartAll(unsigned char *Image);
void EPD_SetRAMValue_BaseMap( const unsigned char * datas);
void EPD_Dis_Part_RAM(u8 x_start,u8 y_start,const u8 * datas,u16 PART_COLUMN,u16 PART_LINE);
void OLED_GUIInit(void); //屏幕GUI初始化
#endif
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
二维码