From cc87941bc7da4b22a9b8edb9f8dc797cacaf07a6 Mon Sep 17 00:00:00 2001 From: trsaunders Date: Sun, 22 Jul 2012 18:00:18 +0100 Subject: [PATCH] fix orientations in ssd1289 --- drivers/lcd/ssd1289_lld.c | 53 +++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/drivers/lcd/ssd1289_lld.c b/drivers/lcd/ssd1289_lld.c index 900e7163..75ebe732 100644 --- a/drivers/lcd/ssd1289_lld.c +++ b/drivers/lcd/ssd1289_lld.c @@ -202,15 +202,24 @@ void lld_lcdSetCursor(uint16_t x, uint16_t y) { * Reg 0x004F is 9 bit * Use a bit mask to make sure they are not set too high */ - - if(PORTRAIT) { - lld_lcdWriteReg(0x004e, x & 0x00FF); - lld_lcdWriteReg(0x004f, y & 0x01FF); - } else if(LANDSCAPE) { - lld_lcdWriteReg(0x004e, y & 0x00FF); - lld_lcdWriteReg(0x004f, x & 0x01FF); - } - + switch(lcdGetOrientation()) { + case portraitInv: + lld_lcdWriteReg(0x004e, (SCREEN_WIDTH-1-x) & 0x00FF); + lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT-1-y) & 0x01FF); + break; + case portrait: + 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) { @@ -218,26 +227,30 @@ void lld_lcdSetOrientation(uint8_t newOrientation) { switch(orientation) { case portrait: - lld_lcdWriteReg(0x0001, 0x2B3F); + lld_lcdWriteReg(0x0001, 0x2B3F); + /* ID = 11 AM = 0 */ lld_lcdWriteReg(0x0011, 0x6070); lcd_height = SCREEN_HEIGHT; lcd_width = SCREEN_WIDTH; break; case landscape: lld_lcdWriteReg(0x0001, 0x293F); + /* ID = 11 AM = 1 */ lld_lcdWriteReg(0x0011, 0x6078); lcd_height = SCREEN_WIDTH; lcd_width = SCREEN_HEIGHT; break; case portraitInv: - lld_lcdWriteReg(0x0001, 0x693F); - lld_lcdWriteReg(0x0011, 0x6040); + lld_lcdWriteReg(0x0001, 0x6B3F); + /* ID = 00 AM = 0 */ + lld_lcdWriteReg(0x0011, 0x6050); lcd_height = SCREEN_HEIGHT; lcd_width = SCREEN_WIDTH; break; case landscapeInv: - lld_lcdWriteReg(0x0001, 0x6B3F); - lld_lcdWriteReg(0x0011, 0x6048); + lld_lcdWriteReg(0x0001, 0x693F); + /* ID = 00 AM = 1 */ + lld_lcdWriteReg(0x0011, 0x6068); lcd_height = SCREEN_WIDTH; lcd_width = SCREEN_HEIGHT; 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); break; case portraitInv: - lld_lcdWriteReg(0x44, (((x1-1) << 8) & 0xFF00) | (x0 & 0x00FF)); - lld_lcdWriteReg(0x45, y0 & 0x01FF); - lld_lcdWriteReg(0x46, (y1-1) & 0x01FF); + lld_lcdWriteReg(0x44, (((x1-1) & 0x00FF) << 8) | ((x0) & 0x00FF)); + lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-y1) & 0x01FF); + lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y0-1) & 0x01FF); break; case landscapeInv: - lld_lcdWriteReg(0x44, (((y1-1) << 8) & 0xFF00) | (y1 & 0x00FF)); - lld_lcdWriteReg(0x45, x0 & 0x01FF); + lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y0 - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - y1) & 0x00FF)); + lld_lcdWriteReg(0x45, (x0) & 0x01FF); lld_lcdWriteReg(0x46, (x1-1) & 0x01FF); break; } + + lld_lcdSetCursor(x0, y0); } void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {