Merge pull request #14 from trsaunders/master
Fix orientations in SSD1189
This commit is contained in:
commit
188bd0ba29
1 changed files with 34 additions and 19 deletions
|
@ -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) {
|
||||
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);
|
||||
} else if(LANDSCAPE) {
|
||||
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) {
|
||||
|
@ -219,25 +228,29 @@ void lld_lcdSetOrientation(uint8_t newOrientation) {
|
|||
switch(orientation) {
|
||||
case portrait:
|
||||
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 = 01 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 = 10 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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue