implemented contrast and backlight functions for GDISP. Implemented those into ILI9320
parent
2a01ab6762
commit
4467b814f2
|
@ -211,7 +211,7 @@ bool_t GDISP_LLD(init)(void) {
|
||||||
GDISP.Height = GDISP_SCREEN_HEIGHT;
|
GDISP.Height = GDISP_SCREEN_HEIGHT;
|
||||||
GDISP.Orientation = GDISP_ROTATE_0;
|
GDISP.Orientation = GDISP_ROTATE_0;
|
||||||
GDISP.Powermode = powerOn;
|
GDISP.Powermode = powerOn;
|
||||||
GDISP.Backlight = 100;
|
GDISP.Backlight = 0;
|
||||||
GDISP.Contrast = 50;
|
GDISP.Contrast = 50;
|
||||||
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
|
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
|
||||||
GDISP.clipx0 = 0;
|
GDISP.clipx0 = 0;
|
||||||
|
@ -411,7 +411,6 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
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(0x0007, 0x0000);
|
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)
|
if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep)
|
||||||
GDISP_LLD(init)();
|
GDISP_LLD(init)();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case powerSleep:
|
case powerSleep:
|
||||||
lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
|
lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
|
||||||
lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
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(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||||
lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
|
lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
|
||||||
lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||||
lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
|
lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
|
||||||
lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
lld_lcdWriteReg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case powerDeepSleep:
|
case powerDeepSleep:
|
||||||
lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
|
lld_lcdWriteReg(0x0007, 0x0000); /* display OFF */
|
||||||
lld_lcdWriteReg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
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(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||||
lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
|
lld_lcdWriteReg(0x0012, 0x0000); /* VREG1OUT voltage */
|
||||||
lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
lld_lcdWriteReg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||||
lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
|
lld_lcdDelay(2000); /* Dis-charge capacitor power voltage */
|
||||||
lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
lld_lcdWriteReg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -470,34 +469,34 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
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:
|
||||||
/* ToDo */
|
/* ToDo */
|
||||||
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:
|
||||||
/* ToDo */
|
/* ToDo */
|
||||||
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:
|
||||||
/* ToDo */
|
/* ToDo */
|
||||||
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:
|
||||||
/* ToDo */
|
/* ToDo */
|
||||||
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;
|
||||||
|
@ -509,13 +508,12 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case GDISP_CONTROL_BACKLIGHT:
|
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;
|
break;
|
||||||
|
|
||||||
case GDISP_CONTROL_CONTRAST:
|
|
||||||
/* ToDo */
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ static __inline void GDISP_LLD(init_board)(void) {
|
||||||
palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
||||||
palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
||||||
palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_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 = 0; */
|
||||||
const unsigned char FSMC_Bank = 6;
|
const unsigned char FSMC_Bank = 6;
|
||||||
|
@ -73,6 +74,13 @@ static __inline uint16_t GDISP_LLD(read_data)(void) {
|
||||||
return GDISP_RAM;
|
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 */
|
#endif /* GDISP_LLD_BOARD_H */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
|
@ -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);
|
void gdispPackPixels(const pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Macro definitions
|
void gdispSetBacklight(uint8_t percentage);
|
||||||
*
|
void gdispSetContrast(uint8_t percentage);
|
||||||
|
/*
|
||||||
|
* Macro definitions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Now obsolete functions */
|
/* Now obsolete functions */
|
||||||
#define gdispBlitArea(x, y, cx, cy, buffer) gdispBlitAreaEx(x, y, cx, cy, 0, 0, cx, buffer)
|
#define gdispBlitArea(x, y, cx, cy, buffer) gdispBlitAreaEx(x, y, cx, cy, 0, 0, cx, buffer)
|
||||||
|
|
||||||
/* Macro definitions for common gets and sets */
|
/* Macro definitions for common gets and sets */
|
||||||
#define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode))
|
#define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode))
|
||||||
#define gdispSetOrientation(newOrientation) gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(unsigned)(newOrientation))
|
#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 gdispGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH))
|
||||||
#define gdispGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT))
|
#define gdispGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT))
|
||||||
|
|
18
src/gdisp.c
18
src/gdisp.c
|
@ -1267,6 +1267,24 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
|
||||||
}
|
}
|
||||||
#endif
|
#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 /* GFX_USE_GDISP */
|
||||||
|
|
||||||
#endif /* _GDISP_C */
|
#endif /* _GDISP_C */
|
||||||
|
|
Loading…
Reference in New Issue