逐行扫描型Memory LCD显存管理与emWin移植
因为Memory LCD 的特性,不能设置像素坐标,只能用缓存整体刷新。
所以对于Memory LCD来说,emWin移植仅与打点函数有关,这里用Sharp Memory LCD(ls013b7dh03)作为实例。
//LCD的显存,逐行扫描
//存放格式如下.
//[0]0 1 2 3 ... 16
//[1]0 1 2 3 ... 16
//[2]0 1 2 3 ... 16
//[3]0 1 2 3 ... 16
//[4]0 1 2 3 ... 16
//[5]0 1 2 3 ... 16
//[6]0 1 2 3 ... 16
//[7]0 1 2 3 ... 16
...
//[127]0 1 2 3 ... 16
#define OLED_MAX_X 128
#define OLED_MAX_Y 128
#define LINE (128) #define LINE_SIZE (16) static char LCD_GRAM[LINE][LINE_SIZE];
void lcd_drawpoint(uint16_t x,uint16_t y,bool bDraw){ uint16_t pos,bx,tmp; if(x>OLED_MAX_X-1||y>OLED_MAX_Y-1) return; pos=15-y/8; bx=y%8; tmp=1<<(bx); if(bDraw) LCD_GRAM[x][pos]|= tmp; else LCD_GRAM[x][pos]&= ~tmp; } void lcd_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++) lcd_drawpoint(x+wi,y+hi,bDraw); } } void lcd_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; } lcd_fillRect(xStart,yStart,w,h,bDraw); } uint32_t lcd_getpoint(uint16_t x,uint16_t y) { }