aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gdisp/ILI9320/gdisp_lld.c86
-rw-r--r--drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h8
-rw-r--r--include/gdisp.h9
-rw-r--r--src/gdisp.c18
4 files changed, 72 insertions, 49 deletions
diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c
index 62cf7c09..f0cc6e51 100644
--- a/drivers/gdisp/ILI9320/gdisp_lld.c
+++ b/drivers/gdisp/ILI9320/gdisp_lld.c
@@ -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;
-
- case GDISP_ROTATE_90:
- /* ToDo */
- GDISP.Height = GDISP_SCREEN_WIDTH;
- GDISP.Width = GDISP_SCREEN_HEIGHT;
- 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_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;
}
diff --git a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h
index 6786e63f..0b926bb8 100644
--- a/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h
+++ b/drivers/gdisp/ILI9320/gdisp_lld_board_olimex_stm32_lcd.h
@@ -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 */
/** @} */
diff --git a/include/gdisp.h b/include/gdisp.h
index 9be97a12..f92ac8ac 100644
--- a/include/gdisp.h
+++ b/include/gdisp.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);
#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))
diff --git a/src/gdisp.c b/src/gdisp.c
index 81c06599..ddcf8546 100644
--- a/src/gdisp.c
+++ b/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
+/**
+ * @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 */