implemented power modes for ILI9320

ugfx_release_2.6
Joel Bodenmann 2012-11-12 02:35:06 +01:00
parent fafe23f2e4
commit 7ccd3da85f
2 changed files with 111 additions and 66 deletions

View File

@ -409,30 +409,66 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
void GDISP_LLD(control)(unsigned what, void *value) { void GDISP_LLD(control)(unsigned what, void *value) {
switch(what) { switch(what) {
case GDISP_CONTROL_POWER: case GDISP_CONTROL_POWER:
if (GDISP.Powermode == (gdisp_powermode_t)value) if(GDISP.Powermode == (gdisp_powermode_t)value)
return; return;
switch((gdisp_powermode_t)value) { switch((gdisp_powermode_t)value) {
case powerOff: case powerOff:
lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode lld_lcdWriteReg(0x0007, 0x0000);
lld_lcdWriteReg(0x0007, 0x0000); // halt operation lld_lcdWriteReg(0x0010, 0x0000);
lld_lcdWriteReg(0x0000, 0x0000); // turn off oszillator lld_lcdWriteReg(0x0011, 0x0000);
lld_lcdWriteReg(0x0010, 0x0001); // enter sleepmode lld_lcdWriteReg(0x0012, 0x0000);
lld_lcdWriteReg(0x0013, 0x0000);
break; break;
case powerOn: case powerOn:
lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode //*************Power On sequence ******************//
if (GDISP.Powermode != powerSleep) lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
lld_lcdWriteReg(0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
lld_lcdWriteReg(0x0011, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */
lld_lcdDelay(500);
lld_lcdWriteReg(0x0012, 0x013C); /* VREG1OUT voltage */
lld_lcdDelay(500);
lld_lcdWriteReg(0x0013, 0x0E00); /* VDV[4:0] for VCOM amplitude */
lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */
lld_lcdDelay(500);
lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */
if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep)
GDISP_LLD(init)(); GDISP_LLD(init)();
break; break;
case powerSleep: case powerSleep:
lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
break; break;
case powerDeepSleep:
lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
lld_lcdWriteReg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
break;
default: default:
return; return;
} }
GDISP.Powermode = (gdisp_powermode_t)value; GDISP.Powermode = (gdisp_powermode_t)value;
return; return;
case GDISP_CONTROL_ORIENTATION: case GDISP_CONTROL_ORIENTATION:
if (GDISP.Orientation == (gdisp_orientation_t)value) if(GDISP.Orientation == (gdisp_orientation_t)value)
return; return;
switch((gdisp_orientation_t)value) { switch((gdisp_orientation_t)value) {
case GDISP_ROTATE_0: case GDISP_ROTATE_0:
@ -442,6 +478,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_HEIGHT; GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH; GDISP.Width = GDISP_SCREEN_WIDTH;
break; break;
case GDISP_ROTATE_90: case GDISP_ROTATE_90:
lld_lcdWriteReg(0x0001, 0x293F); lld_lcdWriteReg(0x0001, 0x293F);
/* ID = 11 AM = 1 */ /* ID = 11 AM = 1 */
@ -449,6 +486,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_WIDTH; GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT; GDISP.Width = GDISP_SCREEN_HEIGHT;
break; break;
case GDISP_ROTATE_180: case GDISP_ROTATE_180:
lld_lcdWriteReg(0x0001, 0x2B3F); lld_lcdWriteReg(0x0001, 0x2B3F);
/* ID = 01 AM = 0 */ /* ID = 01 AM = 0 */
@ -456,6 +494,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_HEIGHT; GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH; GDISP.Width = GDISP_SCREEN_WIDTH;
break; break;
case GDISP_ROTATE_270: case GDISP_ROTATE_270:
lld_lcdWriteReg(0x0001, 0x293F); lld_lcdWriteReg(0x0001, 0x293F);
/* ID = 01 AM = 1 */ /* ID = 01 AM = 1 */
@ -463,9 +502,11 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
GDISP.Height = GDISP_SCREEN_WIDTH; GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT; GDISP.Width = GDISP_SCREEN_HEIGHT;
break; break;
default: default:
return; return;
} }
#if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
GDISP.clipx0 = 0; GDISP.clipx0 = 0;
GDISP.clipy0 = 0; GDISP.clipy0 = 0;
@ -474,10 +515,14 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
#endif #endif
GDISP.Orientation = (gdisp_orientation_t)value; GDISP.Orientation = (gdisp_orientation_t)value;
return; return;
/*
case GDISP_CONTROL_BACKLIGHT: case GDISP_CONTROL_BACKLIGHT:
/* ToDo */
break;
case GDISP_CONTROL_CONTRAST: case GDISP_CONTROL_CONTRAST:
*/ /* ToDo */
break;
} }
} }

View File

@ -556,7 +556,7 @@ typedef enum orientation {GDISP_ROTATE_0, GDISP_ROTATE_90, GDISP_ROTATE_180, GDI
/** /**
* @brief Type for the available power modes for the screen. * @brief Type for the available power modes for the screen.
*/ */
typedef enum powermode {powerOff, powerSleep, powerOn} gdisp_powermode_t; typedef enum powermode {powerOff, powerSleep, powerDeepSleep, powerOn} gdisp_powermode_t;
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */