implemented contrast and backlight functions for GDISP. Implemented those into ILI9320

ugfx_release_2.6
Joel Bodenmann 2012-11-13 23:31:21 +01:00
parent 2a01ab6762
commit 4467b814f2
4 changed files with 71 additions and 48 deletions

View File

@ -211,7 +211,7 @@ bool_t GDISP_LLD(init)(void) {
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Orientation = GDISP_ROTATE_0;
GDISP.Powermode = powerOn;
GDISP.Backlight = 100;
GDISP.Backlight = 0;
GDISP.Contrast = 50;
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
GDISP.clipx0 = 0;
@ -411,7 +411,6 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
case GDISP_CONTROL_POWER:
if(GDISP.Powermode == (gdisp_powermode_t)value)
return;
switch((gdisp_powermode_t)value) {
case powerOff:
lld_lcdWriteReg(0x0007, 0x0000);
@ -440,25 +439,25 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep)
GDISP_LLD(init)();
break;
case powerSleep:
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 */
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;
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 */
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:
@ -470,34 +469,34 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
case GDISP_CONTROL_ORIENTATION:
if(GDISP.Orientation == (gdisp_orientation_t)value)
return;
switch((gdisp_orientation_t)value) {
case GDISP_ROTATE_0:
/* ToDo */
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
switch((gdisp_orientation_t)value) {
case GDISP_ROTATE_0:
/* ToDo */
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
/* ToDo */
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_90:
/* ToDo */
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_180:
/* ToDo */
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_180:
/* ToDo */
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_270:
/* ToDo */
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_270:
/* ToDo */
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
default:
return;
}
default:
return;
}
#if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
GDISP.clipx0 = 0;
@ -509,13 +508,12 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
return;
case GDISP_CONTROL_BACKLIGHT:
/* ToDo */
if(GDISP.Backlight == (*(uint8_t*)value))
return;
GDISP_LLD(set_backlight)(*(uint8_t*)value);
GDISP.Backlight == (*(uint8_t*)value);
break;
case GDISP_CONTROL_CONTRAST:
/* ToDo */
break;
default:
return;
}

View File

@ -42,6 +42,7 @@ static __inline void GDISP_LLD(init_board)(void) {
palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL);
/* const unsigned char FSMC_Bank = 0; */
const unsigned char FSMC_Bank = 6;
@ -73,6 +74,13 @@ static __inline uint16_t GDISP_LLD(read_data)(void) {
return GDISP_RAM;
}
static __inline void GDISP_LLD(set_backlight)(uint8_t percent) {
if(percent == 100)
palClearPad(GPIOD, GPIOD_TFT_LIGHT);
else
palSetPad(GPIOD, GPIOD_TFT_LIGHT);
}
#endif /* GDISP_LLD_BOARD_H */
/** @} */

View File

@ -287,18 +287,17 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
void gdispPackPixels(const pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color);
#endif
/* Macro definitions
*
void gdispSetBacklight(uint8_t percentage);
void gdispSetContrast(uint8_t percentage);
/*
* Macro definitions
*/
/* Now obsolete functions */
#define gdispBlitArea(x, y, cx, cy, buffer) gdispBlitAreaEx(x, y, cx, cy, 0, 0, cx, buffer)
/* Macro definitions for common gets and sets */
#define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode))
#define gdispSetOrientation(newOrientation) gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(unsigned)(newOrientation))
#define gdispSetBacklight(percent) gdispControl(GDISP_CONTROL_BACKLIGHT, (void *)(unsigned)(percent))
#define gdispSetContrast(percent) gdispControl(GDISP_CONTROL_CONTRAST, (void *)(unsigned)(percent))
#define gdispGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH))
#define gdispGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT))

View File

@ -1267,6 +1267,24 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
}
#endif
/**
* @brief Control backlight brightness
*
* @param[in] percentage The percentage of the brightness (0 to 100)
*/
void gdispSetBacklight(uint8_t percentage) {
gdispControl(GDISP_CONTROL_BACKLIGHT, (void*)&percentage);
}
/**
* @brief Control display contrast
*
* @param[in] percentage The percentage of the contrast
*/
void gdispSetPercentage(uint8_t percentage){
gdispControl(GDISP_CONTROL_CONTRAST, (void*)&percentage);
}
#endif /* GFX_USE_GDISP */
#endif /* _GDISP_C */