分页型Memory LCD显存管理与emWin移植
上一篇随笔整理了一下逐行扫描型Memory LCD的显存管理与emWin移植,这篇就整理一下分页型Memory LCD显存管理与emWin移植。
//此处以SSD1306作为实例
//OLED的显存
//存放格式如下.
//[0]0 1 2 3 ... 127
//[1]0 1 2 3 ... 127
//[2]0 1 2 3 ... 127
//[3]0 1 2 3 ... 127
//[4]0 1 2 3 ... 127
//[5]0 1 2 3 ... 127
//[6]0 1 2 3 ... 127
//[7]0 1 2 3 ... 127
uint8_t OLED_GRAM[128][8];
//画点
//x:0~127
//y:0~63
//t:1 填充 0,清空
void OLED_DrawPoint(uint8_t x,uint8_t y,uint8_t t)
{
uint8_t pos,bx,temp=0;
if(x>127||y>63)return;//超出范围了.
pos=7-y/8;
bx=y%8;
temp=1<<(7-bx);
if(t)OLED_GRAM[x][pos]|=temp;
else OLED_GRAM[x][pos]&=~temp;
}
/*
void OLED_Fill(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2,uint8_t dot)
{
uint8_t x,y;
for(x=x1;x<=x2;x++)
{
for(y=y1;y<=y2;y++)OLED_DrawPoint(x,y,dot);
}
OLED_Refresh_Gram();//更新显示
}
*/
void OLED_FillRect(uint16_t x,uint16_t y,uint16_t w,uint16_t h,bool bDraw)
{
uint16_t wi,hi;
for(hi=0;hi<h;hi++){
for(wi=0;wi<w;wi++)
OLED_DrawPoint(x+wi,y+hi,bDraw);
}
}
void OLED_FillRectByXY(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,bool bDraw)
{
uint16_t xStart=0,yStart=0;
uint16_t w,h;
if(x0<x1){
xStart=x0;
w=x1-x0+1;
}else{
xStart=x1;
w=x0-x1+1;
}
if(y0<y1){
yStart=y0;
h=y1-y0+1;
}else{
yStart=y1;
h=y0-y1+1;
}
OLED_FillRect(xStart,yStart,w,h,bDraw);
}
uint32_t OLED_GetPoint(uint16_t x,uint16_t y)
{
}