fix orientations in ssd1289

ugfx_release_2.6
trsaunders 2012-07-22 18:00:18 +01:00
parent 2a2f5b2db7
commit cc87941bc7
1 changed files with 34 additions and 19 deletions

View File

@ -202,15 +202,24 @@ void lld_lcdSetCursor(uint16_t x, uint16_t y) {
* Reg 0x004F is 9 bit * Reg 0x004F is 9 bit
* Use a bit mask to make sure they are not set too high * Use a bit mask to make sure they are not set too high
*/ */
switch(lcdGetOrientation()) {
if(PORTRAIT) { case portraitInv:
lld_lcdWriteReg(0x004e, x & 0x00FF); lld_lcdWriteReg(0x004e, (SCREEN_WIDTH-1-x) & 0x00FF);
lld_lcdWriteReg(0x004f, y & 0x01FF); lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT-1-y) & 0x01FF);
} else if(LANDSCAPE) { break;
lld_lcdWriteReg(0x004e, y & 0x00FF); case portrait:
lld_lcdWriteReg(0x004f, x & 0x01FF); lld_lcdWriteReg(0x004e, x & 0x00FF);
} lld_lcdWriteReg(0x004f, y & 0x01FF);
break;
case landscape:
lld_lcdWriteReg(0x004e, y & 0x00FF);
lld_lcdWriteReg(0x004f, x & 0x01FF);
break;
case landscapeInv:
lld_lcdWriteReg(0x004e, (SCREEN_WIDTH - y - 1) & 0x00FF);
lld_lcdWriteReg(0x004f, (x) & 0x01FF);
break;
}
} }
void lld_lcdSetOrientation(uint8_t newOrientation) { void lld_lcdSetOrientation(uint8_t newOrientation) {
@ -218,26 +227,30 @@ void lld_lcdSetOrientation(uint8_t newOrientation) {
switch(orientation) { switch(orientation) {
case portrait: case portrait:
lld_lcdWriteReg(0x0001, 0x2B3F); lld_lcdWriteReg(0x0001, 0x2B3F);
/* ID = 11 AM = 0 */
lld_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:
lld_lcdWriteReg(0x0001, 0x293F); lld_lcdWriteReg(0x0001, 0x293F);
/* ID = 11 AM = 1 */
lld_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:
lld_lcdWriteReg(0x0001, 0x693F); lld_lcdWriteReg(0x0001, 0x6B3F);
lld_lcdWriteReg(0x0011, 0x6040); /* ID = 00 AM = 0 */
lld_lcdWriteReg(0x0011, 0x6050);
lcd_height = SCREEN_HEIGHT; lcd_height = SCREEN_HEIGHT;
lcd_width = SCREEN_WIDTH; lcd_width = SCREEN_WIDTH;
break; break;
case landscapeInv: case landscapeInv:
lld_lcdWriteReg(0x0001, 0x6B3F); lld_lcdWriteReg(0x0001, 0x693F);
lld_lcdWriteReg(0x0011, 0x6048); /* ID = 00 AM = 1 */
lld_lcdWriteReg(0x0011, 0x6068);
lcd_height = SCREEN_WIDTH; lcd_height = SCREEN_WIDTH;
lcd_width = SCREEN_HEIGHT; lcd_width = SCREEN_HEIGHT;
break; break;
@ -268,16 +281,18 @@ void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
lld_lcdWriteReg(0x46, (x1-1) & 0x01FF); lld_lcdWriteReg(0x46, (x1-1) & 0x01FF);
break; break;
case portraitInv: case portraitInv:
lld_lcdWriteReg(0x44, (((x1-1) << 8) & 0xFF00) | (x0 & 0x00FF)); lld_lcdWriteReg(0x44, (((x1-1) & 0x00FF) << 8) | ((x0) & 0x00FF));
lld_lcdWriteReg(0x45, y0 & 0x01FF); lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-y1) & 0x01FF);
lld_lcdWriteReg(0x46, (y1-1) & 0x01FF); lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y0-1) & 0x01FF);
break; break;
case landscapeInv: case landscapeInv:
lld_lcdWriteReg(0x44, (((y1-1) << 8) & 0xFF00) | (y1 & 0x00FF)); lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y0 - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - y1) & 0x00FF));
lld_lcdWriteReg(0x45, x0 & 0x01FF); lld_lcdWriteReg(0x45, (x0) & 0x01FF);
lld_lcdWriteReg(0x46, (x1-1) & 0x01FF); lld_lcdWriteReg(0x46, (x1-1) & 0x01FF);
break; break;
} }
lld_lcdSetCursor(x0, y0);
} }
void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) { void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {