From d4825766560e27594abee4b3a00dff7fd4260826 Mon Sep 17 00:00:00 2001 From: Tectu Date: Tue, 29 May 2012 02:04:04 +0200 Subject: [PATCH] added portrait and landscape inverse mode --- glcd.c | 18 +++++++++++------- glcd.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/glcd.c b/glcd.c index be4e1694..5effa0eb 100755 --- a/glcd.c +++ b/glcd.c @@ -68,19 +68,19 @@ static __inline uint16_t lcdReadReg(uint16_t lcdReg) { static void lcdSetCursor(uint16_t x, uint16_t y) { if(DeviceCode==0x8989) { - if(orientation == portrait) { + if(orientation == portrait || orientation == portraitInv) { lcdWriteReg(0x004e, x); lcdWriteReg(0x004f, y); - } else if(orientation == landscape) { + } else if(orientation == landscape || orientation == landscapeInv) { lcdWriteReg(0x004e, y); lcdWriteReg(0x004f, x); } } else if(DeviceCode==0x9919) { - if(orientation == portrait) { + if(orientation == portrait || orientation == portraitInv) { lcdWriteReg(0x004e, x); lcdWriteReg(0x004f, y); - } else if(orientation == landscape) { + } else if(orientation == landscape || orientation == landscapeInv) { lcdWriteReg(0x004e, y); lcdWriteReg(0x004f, x); } @@ -94,7 +94,7 @@ static void lcdDelay(uint16_t nCount) { uint16_t TimingDelay; while(nCount--) { - for(TimingDelay=0;TimingDelay<10000;TimingDelay++) + for(TimingDelay=0; TimingDelay<10000; TimingDelay++) asm("nop"); } } @@ -111,9 +111,13 @@ void lcdSetOrientation(uint8_t newOrientation) { lcdWriteReg(0x0001, 0x293F); lcdWriteReg(0x0011, 0x6078); break; - case 2: + case portraitInv: + lcdWriteReg(0x0001, 0x693F); + lcdWriteReg(0x0011, 0x6040); break; - case 3: + case landscapeInv: + lcdWriteReg(0x0001, 0x6B3F); + lcdWriteReg(0x0011, 0x6048); break; } } diff --git a/glcd.h b/glcd.h index b0bf0b52..166fb10c 100755 --- a/glcd.h +++ b/glcd.h @@ -42,7 +42,7 @@ (( green >> 2 ) << 5 ) | \ ( blue >> 3 )) -enum orientation {portrait = 0, landscape = 1}; +enum orientation {portrait, landscape, portraitInv, landscapeInv}; void lcdInit(void); void lcdClear(uint16_t color);