aboutsummaryrefslogtreecommitdiffstats
path: root/glcd.c
diff options
context:
space:
mode:
authorTectu <joel@unormal.org>2012-06-08 01:41:56 +0200
committerTectu <joel@unormal.org>2012-06-08 01:41:56 +0200
commit634908c66df9d609839b3877725e7e33f3507066 (patch)
treefc7854ca1d69c9e3090e03d6f2bcdbef602fe9c6 /glcd.c
parent9e3f9665564f73820d43dafd0415adb910a57bc0 (diff)
downloaduGFX-634908c66df9d609839b3877725e7e33f3507066.tar.gz
uGFX-634908c66df9d609839b3877725e7e33f3507066.tar.bz2
uGFX-634908c66df9d609839b3877725e7e33f3507066.zip
fixes
Diffstat (limited to 'glcd.c')
-rw-r--r--glcd.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/glcd.c b/glcd.c
index 977c3412..f1f8e977 100644
--- a/glcd.c
+++ b/glcd.c
@@ -145,31 +145,40 @@ uint16_t lcdGetOrientation(void) {
return orientation;
}
-void lcdSetWindow(uint16_t x, uint16_t y, uint16_t width, uint16_t height) {
- if(lcdGetOrientation() == portrait) {
- lcdWriteReg(0x0050, x); /* Horizontal GRAM Start Address */
- lcdWriteReg(0x0051, x+width-1); /* Horizontal GRAM End Address (-1) */
- lcdWriteReg(0x0052, y); /* Vertical GRAM Start Address */
- lcdWriteReg(0x0053, y+height-1); /* Vertical GRAM End Address (-1) */
- lcdWriteReg(0x0020, x);
- lcdWriteReg(0x0021, y);
- } else if(lcdGetOrientation() == landscape) {
- lcdWriteReg(0x0050, y); /* Vertical GRAM Start Address */
- lcdWriteReg(0x0051, y+height-1); /* Vertical GRAM End Address (-1) */
- lcdWriteReg(0x0052, x); /* Horizontal GRAM Start Address */
- lcdWriteReg(0x0053, x+width-1); /* Horizontal GRAM End Address (-1) */
- lcdWriteReg(0x0020, y);
- lcdWriteReg(0x0021, x);
+void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
+ lcdSetCursor(x0, y0);
+
+ switch(lcdGetOrientation()) {
+ case portrait:
+ lcdWriteReg(0x44, ((x0+x1-1) << 8) | x0);
+ lcdWriteReg(0x45, y0);
+ lcdWriteReg(0x46, y0+y1-1);
+ break;
+ case landscape:
+ lcdWriteReg(0x44, ((y0+y1-1) << 8) | y1);
+ lcdWriteReg(0x45, x0);
+ lcdWriteReg(0x46, x0+x1-1);
+ break;
+ case portraitInv:
+ lcdWriteReg(0x44, ((x0+x1-1) << 8) | x0);
+ lcdWriteReg(0x45, y0);
+ lcdWriteReg(0x46, y0+y1-1);
+ break;
+ case landscapeInv:
+ lcdWriteReg(0x44, ((y0+y1-1) << 8) | y1);
+ lcdWriteReg(0x45, x0);
+ lcdWriteReg(0x46, x0+x1-1);
+ break;
}
}
void lcdClear(uint16_t color) {
- uint32_t index=0;
+ uint32_t index = 0;
lcdSetCursor(0,0);
Clr_CS;
lcdWriteIndex(0x0022);
- for(index=0;index<76800;index++)
+ for(index = 0; index < SCREEN_WIDTH * SCREEN_HEIGHT; index++)
lcdWriteData(color);
Set_CS;
}
@@ -307,7 +316,19 @@ uint16_t lcdBGR2RGB(uint16_t color) {
}
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
- lcdDrawRect(x0, y0, x1, y1, 1, 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) {