lcdFillArea now lld
This commit is contained in:
parent
8ebd8887d3
commit
49b3daab08
3 changed files with 104 additions and 99 deletions
|
@ -6,7 +6,7 @@ uint8_t orientation;
|
||||||
uint16_t DeviceCode;
|
uint16_t DeviceCode;
|
||||||
extern uint16_t lcd_width, lcd_height;
|
extern uint16_t lcd_width, lcd_height;
|
||||||
|
|
||||||
static __inline void lcdWriteIndex(uint16_t index) {
|
static __inline void lld_lcdWriteIndex(uint16_t index) {
|
||||||
Clr_RS;
|
Clr_RS;
|
||||||
Set_RD;
|
Set_RD;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ static __inline void lcdWriteIndex(uint16_t index) {
|
||||||
Set_WR;
|
Set_WR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void lcdWriteData(uint16_t data) {
|
static __inline void lld_lcdWriteData(uint16_t data) {
|
||||||
Set_RS;
|
Set_RS;
|
||||||
|
|
||||||
palWritePort(LCD_DATA_PORT, data);
|
palWritePort(LCD_DATA_PORT, data);
|
||||||
|
@ -25,14 +25,14 @@ static __inline void lcdWriteData(uint16_t data) {
|
||||||
Set_WR;
|
Set_WR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
|
static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
|
||||||
Clr_CS;
|
Clr_CS;
|
||||||
lcdWriteIndex(lcdReg);
|
lld_lcdWriteIndex(lcdReg);
|
||||||
lcdWriteData(lcdRegValue);
|
lld_lcdWriteData(lcdRegValue);
|
||||||
Set_CS;
|
Set_CS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t lcdReadData(void) {
|
static __inline uint16_t lld_lcdReadData(void) {
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
|
|
||||||
Set_RS;
|
Set_RS;
|
||||||
|
@ -55,12 +55,12 @@ static __inline uint16_t lcdReadData(void) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t lcdReadReg(uint16_t lcdReg) {
|
static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
|
||||||
uint16_t lcdRAM;
|
uint16_t lcdRAM;
|
||||||
|
|
||||||
Clr_CS;
|
Clr_CS;
|
||||||
lcdWriteIndex(lcdReg);
|
lld_lcdWriteIndex(lcdReg);
|
||||||
lcdRAM = lcdReadData();
|
lcdRAM = lld_lcdReadData();
|
||||||
|
|
||||||
Set_CS;
|
Set_CS;
|
||||||
|
|
||||||
|
@ -73,11 +73,11 @@ static __inline void lcdDelay(uint16_t us) {
|
||||||
|
|
||||||
void lld_lcdSetCursor(uint16_t x, uint16_t y) {
|
void lld_lcdSetCursor(uint16_t x, uint16_t y) {
|
||||||
if(PORTRAIT) {
|
if(PORTRAIT) {
|
||||||
lcdWriteReg(0x004e, x);
|
lld_lcdWriteReg(0x004e, x);
|
||||||
lcdWriteReg(0x004f, y);
|
lld_lcdWriteReg(0x004f, y);
|
||||||
} else if(LANDSCAPE) {
|
} else if(LANDSCAPE) {
|
||||||
lcdWriteReg(0x004e, y);
|
lld_lcdWriteReg(0x004e, y);
|
||||||
lcdWriteReg(0x004f, x);
|
lld_lcdWriteReg(0x004f, x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,26 +86,26 @@ void lld_lcdSetOrientation(uint8_t newOrientation) {
|
||||||
|
|
||||||
switch(orientation) {
|
switch(orientation) {
|
||||||
case portrait:
|
case portrait:
|
||||||
lcdWriteReg(0x0001, 0x2B3F);
|
lld_lcdWriteReg(0x0001, 0x2B3F);
|
||||||
lcdWriteReg(0x0011, 0x6070);
|
lld_lcdWriteReg(0x0011, 0x6070);
|
||||||
lcd_height = SCREEN_HEIGHT;
|
lcd_height = SCREEN_HEIGHT;
|
||||||
lcd_width = SCREEN_WIDTH;
|
lcd_width = SCREEN_WIDTH;
|
||||||
break;
|
break;
|
||||||
case landscape:
|
case landscape:
|
||||||
lcdWriteReg(0x0001, 0x293F);
|
lld_lcdWriteReg(0x0001, 0x293F);
|
||||||
lcdWriteReg(0x0011, 0x6078);
|
lld_lcdWriteReg(0x0011, 0x6078);
|
||||||
lcd_height = SCREEN_WIDTH;
|
lcd_height = SCREEN_WIDTH;
|
||||||
lcd_width = SCREEN_HEIGHT;
|
lcd_width = SCREEN_HEIGHT;
|
||||||
break;
|
break;
|
||||||
case portraitInv:
|
case portraitInv:
|
||||||
lcdWriteReg(0x0001, 0x693F);
|
lld_lcdWriteReg(0x0001, 0x693F);
|
||||||
lcdWriteReg(0x0011, 0x6040);
|
lld_lcdWriteReg(0x0011, 0x6040);
|
||||||
lcd_height = SCREEN_HEIGHT;
|
lcd_height = SCREEN_HEIGHT;
|
||||||
lcd_width = SCREEN_WIDTH;
|
lcd_width = SCREEN_WIDTH;
|
||||||
break;
|
break;
|
||||||
case landscapeInv:
|
case landscapeInv:
|
||||||
lcdWriteReg(0x0001, 0x6B3F);
|
lld_lcdWriteReg(0x0001, 0x6B3F);
|
||||||
lcdWriteReg(0x0011, 0x6048);
|
lld_lcdWriteReg(0x0011, 0x6048);
|
||||||
lcd_height = SCREEN_WIDTH;
|
lcd_height = SCREEN_WIDTH;
|
||||||
lcd_width = SCREEN_HEIGHT;
|
lcd_width = SCREEN_HEIGHT;
|
||||||
break;
|
break;
|
||||||
|
@ -113,40 +113,56 @@ void lld_lcdSetOrientation(uint8_t newOrientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
lcdSetCursor(x0, y0);
|
lld_lcdSetCursor(x0, y0);
|
||||||
|
|
||||||
|
x1 -= x0;
|
||||||
|
y1 -= y0;
|
||||||
|
|
||||||
switch(lcdGetOrientation()) {
|
switch(lcdGetOrientation()) {
|
||||||
case portrait:
|
case portrait:
|
||||||
lcdWriteReg(0x44, ((x0+x1-1) << 8) | x0);
|
lld_lcdWriteReg(0x44, ((x0+x1-1) << 8) | x0);
|
||||||
lcdWriteReg(0x45, y0);
|
lld_lcdWriteReg(0x45, y0);
|
||||||
lcdWriteReg(0x46, y0+y1-1);
|
lld_lcdWriteReg(0x46, y0+y1-1);
|
||||||
break;
|
break;
|
||||||
case landscape:
|
case landscape:
|
||||||
lcdWriteReg(0x44, ((y0+y1-1) << 8) | y1);
|
lld_lcdWriteReg(0x44, ((y0+y1-1) << 8) | y1);
|
||||||
lcdWriteReg(0x45, x0);
|
lld_lcdWriteReg(0x45, x0);
|
||||||
lcdWriteReg(0x46, x0+x1-1);
|
lld_lcdWriteReg(0x46, x0+x1-1);
|
||||||
break;
|
break;
|
||||||
case portraitInv:
|
case portraitInv:
|
||||||
lcdWriteReg(0x44, ((x0+x1-1) << 8) | x0);
|
lld_lcdWriteReg(0x44, ((x0+x1-1) << 8) | x0);
|
||||||
lcdWriteReg(0x45, y0);
|
lld_lcdWriteReg(0x45, y0);
|
||||||
lcdWriteReg(0x46, y0+y1-1);
|
lld_lcdWriteReg(0x46, y0+y1-1);
|
||||||
break;
|
break;
|
||||||
case landscapeInv:
|
case landscapeInv:
|
||||||
lcdWriteReg(0x44, ((y0+y1-1) << 8) | y1);
|
lld_lcdWriteReg(0x44, ((y0+y1-1) << 8) | y1);
|
||||||
lcdWriteReg(0x45, x0);
|
lld_lcdWriteReg(0x45, x0);
|
||||||
lcdWriteReg(0x46, x0+x1-1);
|
lld_lcdWriteReg(0x46, x0+x1-1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
||||||
|
uint32_t index = 0, area;
|
||||||
|
|
||||||
|
area = ((x1-x0)*(y1-y0));
|
||||||
|
|
||||||
|
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||||
|
Clr_CS;
|
||||||
|
lld_lcdWriteIndex(0x0022);
|
||||||
|
for(index = 0; index < area; index++)
|
||||||
|
lld_lcdWriteData(color);
|
||||||
|
Set_CS;
|
||||||
|
}
|
||||||
|
|
||||||
void lld_lcdClear(uint16_t color) {
|
void lld_lcdClear(uint16_t color) {
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
|
|
||||||
lld_lcdSetCursor(0, 0);
|
lld_lcdSetCursor(0, 0);
|
||||||
Clr_CS;
|
Clr_CS;
|
||||||
lcdWriteIndex(0x0022);
|
lld_lcdWriteIndex(0x0022);
|
||||||
for(index = 0; index < SCREEN_WIDTH * SCREEN_HEIGHT; index++)
|
for(index = 0; index < SCREEN_WIDTH * SCREEN_HEIGHT; index++)
|
||||||
lcdWriteData(color);
|
lld_lcdWriteData(color);
|
||||||
Set_CS;
|
Set_CS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,9 +171,9 @@ uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y) {
|
||||||
|
|
||||||
lld_lcdSetCursor(x,y);
|
lld_lcdSetCursor(x,y);
|
||||||
Clr_CS;
|
Clr_CS;
|
||||||
lcdWriteIndex(0x0022);
|
lld_lcdWriteIndex(0x0022);
|
||||||
dummy = lcdReadData();
|
dummy = lld_lcdReadData();
|
||||||
dummy = lcdReadData();
|
dummy = lld_lcdReadData();
|
||||||
Set_CS;
|
Set_CS;
|
||||||
|
|
||||||
return dummy;
|
return dummy;
|
||||||
|
@ -165,53 +181,53 @@ uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y) {
|
||||||
|
|
||||||
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
|
||||||
lld_lcdSetCursor(x, y);
|
lld_lcdSetCursor(x, y);
|
||||||
lcdWriteReg(0x0022, color);
|
lld_lcdWriteReg(0x0022, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lld_lcdInit(void) {
|
void lld_lcdInit(void) {
|
||||||
DeviceCode = lcdReadReg(0x0000);
|
DeviceCode = lld_lcdReadReg(0x0000);
|
||||||
|
|
||||||
lcdWriteReg(0x0000,0x0001); lcdDelay(5);
|
lld_lcdWriteReg(0x0000,0x0001); lcdDelay(5);
|
||||||
lcdWriteReg(0x0003,0xA8A4); lcdDelay(5);
|
lld_lcdWriteReg(0x0003,0xA8A4); lcdDelay(5);
|
||||||
lcdWriteReg(0x000C,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x000C,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x000D,0x080C); lcdDelay(5);
|
lld_lcdWriteReg(0x000D,0x080C); lcdDelay(5);
|
||||||
lcdWriteReg(0x000E,0x2B00); lcdDelay(5);
|
lld_lcdWriteReg(0x000E,0x2B00); lcdDelay(5);
|
||||||
lcdWriteReg(0x001E,0x00B0); lcdDelay(5);
|
lld_lcdWriteReg(0x001E,0x00B0); lcdDelay(5);
|
||||||
lcdWriteReg(0x0001,0x2B3F); lcdDelay(5);
|
lld_lcdWriteReg(0x0001,0x2B3F); lcdDelay(5);
|
||||||
lcdWriteReg(0x0002,0x0600); lcdDelay(5);
|
lld_lcdWriteReg(0x0002,0x0600); lcdDelay(5);
|
||||||
lcdWriteReg(0x0010,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0010,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0011,0x6070); lcdDelay(5);
|
lld_lcdWriteReg(0x0011,0x6070); lcdDelay(5);
|
||||||
lcdWriteReg(0x0005,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0005,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0006,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0006,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0016,0xEF1C); lcdDelay(5);
|
lld_lcdWriteReg(0x0016,0xEF1C); lcdDelay(5);
|
||||||
lcdWriteReg(0x0017,0x0003); lcdDelay(5);
|
lld_lcdWriteReg(0x0017,0x0003); lcdDelay(5);
|
||||||
lcdWriteReg(0x0007,0x0133); lcdDelay(5);
|
lld_lcdWriteReg(0x0007,0x0133); lcdDelay(5);
|
||||||
lcdWriteReg(0x000B,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x000B,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x000F,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x000F,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0041,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0041,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0042,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0042,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0048,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0048,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0049,0x013F); lcdDelay(5);
|
lld_lcdWriteReg(0x0049,0x013F); lcdDelay(5);
|
||||||
lcdWriteReg(0x004A,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x004A,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x004B,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x004B,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0044,0xEF00); lcdDelay(5);
|
lld_lcdWriteReg(0x0044,0xEF00); lcdDelay(5);
|
||||||
lcdWriteReg(0x0045,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0045,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0046,0x013F); lcdDelay(5);
|
lld_lcdWriteReg(0x0046,0x013F); lcdDelay(5);
|
||||||
lcdWriteReg(0x0030,0x0707); lcdDelay(5);
|
lld_lcdWriteReg(0x0030,0x0707); lcdDelay(5);
|
||||||
lcdWriteReg(0x0031,0x0204); lcdDelay(5);
|
lld_lcdWriteReg(0x0031,0x0204); lcdDelay(5);
|
||||||
lcdWriteReg(0x0032,0x0204); lcdDelay(5);
|
lld_lcdWriteReg(0x0032,0x0204); lcdDelay(5);
|
||||||
lcdWriteReg(0x0033,0x0502); lcdDelay(5);
|
lld_lcdWriteReg(0x0033,0x0502); lcdDelay(5);
|
||||||
lcdWriteReg(0x0034,0x0507); lcdDelay(5);
|
lld_lcdWriteReg(0x0034,0x0507); lcdDelay(5);
|
||||||
lcdWriteReg(0x0035,0x0204); lcdDelay(5);
|
lld_lcdWriteReg(0x0035,0x0204); lcdDelay(5);
|
||||||
lcdWriteReg(0x0036,0x0204); lcdDelay(5);
|
lld_lcdWriteReg(0x0036,0x0204); lcdDelay(5);
|
||||||
lcdWriteReg(0x0037,0x0502); lcdDelay(5);
|
lld_lcdWriteReg(0x0037,0x0502); lcdDelay(5);
|
||||||
lcdWriteReg(0x003A,0x0302); lcdDelay(5);
|
lld_lcdWriteReg(0x003A,0x0302); lcdDelay(5);
|
||||||
lcdWriteReg(0x003B,0x0302); lcdDelay(5);
|
lld_lcdWriteReg(0x003B,0x0302); lcdDelay(5);
|
||||||
lcdWriteReg(0x0023,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0023,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0024,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x0024,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x0025,0x8000); lcdDelay(5);
|
lld_lcdWriteReg(0x0025,0x8000); lcdDelay(5);
|
||||||
lcdWriteReg(0x004f,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x004f,0x0000); lcdDelay(5);
|
||||||
lcdWriteReg(0x004e,0x0000); lcdDelay(5);
|
lld_lcdWriteReg(0x004e,0x0000); lcdDelay(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t lld_lcdGetOrientation(void) {
|
uint16_t lld_lcdGetOrientation(void) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ void lld_lcdSetOrientation(uint8_t newOrientation);
|
||||||
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||||
void lld_lcdClear(uint16_t color);
|
void lld_lcdClear(uint16_t color);
|
||||||
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color);
|
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color);
|
||||||
|
void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
|
||||||
uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y);
|
uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y);
|
||||||
uint16_t lld_lcdGetOrientation(void);
|
uint16_t lld_lcdGetOrientation(void);
|
||||||
uint16_t lld_lcdGetHeight(void);
|
uint16_t lld_lcdGetHeight(void);
|
||||||
|
|
20
glcd.c
20
glcd.c
|
@ -43,6 +43,10 @@ void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
lld_lcdSetWindow(x0, y0, x1, y1);
|
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
||||||
|
lld_lcdFillArea(x0, y0, x1, y1, color);
|
||||||
|
}
|
||||||
|
|
||||||
void lcdClear(uint16_t color) {
|
void lcdClear(uint16_t color) {
|
||||||
lld_lcdClear(color);
|
lld_lcdClear(color);
|
||||||
}
|
}
|
||||||
|
@ -217,22 +221,6 @@ uint16_t lcdBGR2RGB(uint16_t color) {
|
||||||
return( rgb );
|
return( rgb );
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
|
|
||||||
lcdDrawRect(x0, y0, x1, y1, filled, color);
|
|
||||||
/*
|
|
||||||
uint32_t index = 0, area;
|
|
||||||
|
|
||||||
area = ((x1-x0)*(y1-y0));
|
|
||||||
|
|
||||||
lcdSetWindow(x0, y0, x1, y1);
|
|
||||||
Clr_CS;
|
|
||||||
lcdWriteIndex(0x0022);
|
|
||||||
for(index = 0; index < area; index++)
|
|
||||||
lcdWriteData(color);
|
|
||||||
Set_CS;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color) {
|
void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color) {
|
||||||
uint16_t i, TempX;
|
uint16_t i, TempX;
|
||||||
uint16_t j, TempY;
|
uint16_t j, TempY;
|
||||||
|
|
Loading…
Add table
Reference in a new issue