aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-11-15 02:55:21 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-11-15 02:55:21 +1000
commit4d521cff13cb24ee839986e2c2ddcdd56874d279 (patch)
treee3f7c410ab7c0694741c6da077f3f5dcce6d3e10 /drivers
parent00f95af7f8164b1300fc40748134bada9acf0483 (diff)
downloaduGFX-4d521cff13cb24ee839986e2c2ddcdd56874d279.tar.gz
uGFX-4d521cff13cb24ee839986e2c2ddcdd56874d279.tar.bz2
uGFX-4d521cff13cb24ee839986e2c2ddcdd56874d279.zip
Gdisp lld driver corrections
Corrections to Nokia gdisp driver - Fix for the application calling the unsupported gdispSetOrientation and gdispSetPower - Implemented full backlight control (on/off only currently) Corrections to the Ili9320 driver - Fix for the application calling the unsupported gdispSetOrientation - Fix for initialisation of the backlight - Fix for backlight when using display low power modes.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gdisp/ILI9320/gdisp_lld.c17
-rw-r--r--drivers/gdisp/Nokia6610/gdisp_lld.c46
-rw-r--r--drivers/gdisp/Nokia6610/gdisp_lld_board_example.h15
-rw-r--r--drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h11
4 files changed, 64 insertions, 25 deletions
diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c
index 7b9eda27..0641985a 100644
--- a/drivers/gdisp/ILI9320/gdisp_lld.c
+++ b/drivers/gdisp/ILI9320/gdisp_lld.c
@@ -56,6 +56,9 @@
#define GDISP_SCREEN_WIDTH 240
#define GDISP_SCREEN_HEIGHT 320
+#define GDISP_INITIAL_CONTRAST 50
+#define GDISP_INITIAL_BACKLIGHT 100
+
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
@@ -206,13 +209,16 @@ bool_t GDISP_LLD(init)(void) {
lld_lcdWriteReg(0x0098, 0x0110); //
lld_lcdWriteReg(0x0007, 0x0173); //display On
+ // Turn on the backlight
+ GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT);
+
/* Initialise the GDISP structure */
GDISP.Width = GDISP_SCREEN_WIDTH;
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Orientation = GDISP_ROTATE_0;
GDISP.Powermode = powerOn;
- GDISP.Backlight = 0;
- GDISP.Contrast = 50;
+ GDISP.Backlight = GDISP_INITIAL_BACKLIGHT;
+ GDISP.Contrast = GDISP_INITIAL_CONTRAST;
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
GDISP.clipx0 = 0;
GDISP.clipy0 = 0;
@@ -418,6 +424,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
lld_lcdWriteReg(0x0011, 0x0000);
lld_lcdWriteReg(0x0012, 0x0000);
lld_lcdWriteReg(0x0013, 0x0000);
+ GDISP_LLD(set_backlight)(0);
break;
case powerOn:
@@ -436,6 +443,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
lld_lcdWriteReg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */
lld_lcdDelay(500);
lld_lcdWriteReg(0x0007, 0x0173); /* 262K color and display ON */
+ GDISP_LLD(set_backlight)(GDISP.Backlight);
if(GDISP.Powermode != powerSleep || GDISP.Powermode != powerDeepSleep)
GDISP_LLD(init)();
break;
@@ -448,6 +456,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
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 */
+ GDISP_LLD(set_backlight)(0);
break;
case powerDeepSleep:
@@ -458,6 +467,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
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 */
+ GDISP_LLD(set_backlight)(0);
break;
default:
@@ -466,6 +476,8 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
GDISP.Powermode = (gdisp_powermode_t)value;
return;
+#if 0
+ // NOT IMPLEMENTED YET
case GDISP_CONTROL_ORIENTATION:
if(GDISP.Orientation == (gdisp_orientation_t)value)
return;
@@ -506,6 +518,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
#endif
GDISP.Orientation = (gdisp_orientation_t)value;
return;
+#endif
case GDISP_CONTROL_BACKLIGHT:
if((unsigned)value > 100) value = (void *)100;
diff --git a/drivers/gdisp/Nokia6610/gdisp_lld.c b/drivers/gdisp/Nokia6610/gdisp_lld.c
index e5a3160b..2bc7f33b 100644
--- a/drivers/gdisp/Nokia6610/gdisp_lld.c
+++ b/drivers/gdisp/Nokia6610/gdisp_lld.c
@@ -57,7 +57,9 @@
#endif
#define GDISP_SCREEN_HEIGHT 132
#define GDISP_SCREEN_WIDTH 132
+
#define GDISP_INITIAL_CONTRAST 38
+#define GDISP_INITIAL_BACKLIGHT 100
/*===========================================================================*/
/* Driver exported variables. */
@@ -214,14 +216,14 @@ bool_t GDISP_LLD(init)(void) {
#endif
/* Turn on the back-light */
- GDISP_LLD(setpin_backlight)(TRUE);
+ GDISP_LLD(set_backlight)(GDISP_INITIAL_BACKLIGHT);
/* Initialise the GDISP structure to match */
GDISP.Width = GDISP_SCREEN_WIDTH;
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Orientation = GDISP_ROTATE_0;
GDISP.Powermode = powerOn;
- GDISP.Backlight = 100;
+ GDISP.Backlight = GDISP_INITIAL_BACKLIGHT;
GDISP.Contrast = GDISP_INITIAL_CONTRAST;
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
GDISP.clipx0 = 0;
@@ -466,28 +468,28 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
* @notapi
*/
void GDISP_LLD(control)(unsigned what, void *value) {
- /* NOT IMPLEMENTED YET */
/* The hardware is capable of supporting...
- * GDISP_CONTROL_POWER
- * GDISP_CONTROL_ORIENTATION
- * GDISP_CONTROL_BACKLIGHT (at least on the Olimex board)
- * GDISP_CONTROL_CONTRAST
- * We don't currently implement any of it.
+ * GDISP_CONTROL_POWER - not implemented yet
+ * GDISP_CONTROL_ORIENTATION - not implemented yet
+ * GDISP_CONTROL_BACKLIGHT - supported (the OlimexSAM7EX256 board.h currently only implements off/on although PWM is supported by the hardware)
+ * GDISP_CONTROL_CONTRAST - supported
*/
switch(what) {
+#if 0
+ // NOT IMPLEMENTED YET
case GDISP_CONTROL_POWER:
if (GDISP.Powermode == (gdisp_powermode_t)value)
return;
switch((gdisp_powermode_t)value) {
case powerOff:
- /* Code here */
+ // Code here
break;
case powerOn:
- /* Code here */
+ // Code here
/* You may need this ---
- if (GDISP.Powermode != powerSleep)
- GDISP_LLD(init)();
- */
+ * if (GDISP.Powermode != powerSleep)
+ * GDISP_LLD(init)();
+ */
break;
case powerSleep:
/* Code here */
@@ -497,6 +499,9 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
}
GDISP.Powermode = (gdisp_powermode_t)value;
return;
+#endif
+#if 0
+ // NOT IMPLEMENTED YET
case GDISP_CONTROL_ORIENTATION:
if (GDISP.Orientation == (gdisp_orientation_t)value)
return;
@@ -504,22 +509,22 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
// WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb)
switch((gdisp_orientation_t)value) {
case GDISP_ROTATE_0:
- /* Code here */
+ // Code here
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
- /* Code here */
+ // Code here
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
case GDISP_ROTATE_180:
- /* Code here */
+ // Code here
GDISP.Height = GDISP_SCREEN_HEIGHT;
GDISP.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_270:
- /* Code here */
+ // Code here
GDISP.Height = GDISP_SCREEN_WIDTH;
GDISP.Width = GDISP_SCREEN_HEIGHT;
break;
@@ -534,9 +539,12 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
#endif
GDISP.Orientation = (gdisp_orientation_t)value;
return;
-/*
+#endif
case GDISP_CONTROL_BACKLIGHT:
-*/
+ if ((unsigned)value > 100) value = (void *)100;
+ GDISP_LLD(set_backlight)((uint8_t)(unsigned)value);
+ GDISP.Backlight = (unsigned)value;
+ return;
case GDISP_CONTROL_CONTRAST:
if ((unsigned)value > 100) value = (void *)100;
#if defined(GDISP_USE_GE8)
diff --git a/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h b/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h
index c76cf83c..e78c1653 100644
--- a/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h
+++ b/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h
@@ -57,6 +57,21 @@ static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
}
/**
+ * @brief Set the lcd back-light level.
+ * @note For now 0% turns the backlight off, anything else the backlight is on.
+ * While the hardware supports PWM backlight control, we are not using it
+ * yet.
+ *
+ * @param[in] percent 0 to 100%
+ *
+ * @notapi
+ */
+static __inline void GDISP_LLD(set_backlight)(uint8_t percent) {
+ /* Code here */
+#error "gdispNokia6610: You must supply a definition for set_backlight for your board"
+}
+
+/**
* @brief Send an 8 bit command to the lcd.
*
* @param[in] data The command to send
diff --git a/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h
index 6ab59c3e..9f85fc10 100644
--- a/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h
+++ b/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h
@@ -156,14 +156,17 @@ static __inline void GDISP_LLD(setpin_reset)(bool_t state) {
}
/**
- * @brief Set or clear the lcd back-light pin.
+ * @brief Set the lcd back-light level.
+ * @note For now 0% turns the backlight off, anything else the backlight is on.
+ * While the hardware supports PWM backlight control, we are not using it
+ * yet.
*
- * @param[in] state TRUE = lcd back-light on, FALSE = lcd back-light off
+ * @param[in] percent 0 to 100%
*
* @notapi
*/
-static __inline void GDISP_LLD(setpin_backlight)(bool_t state) {
- if (state)
+static __inline void GDISP_LLD(set_backlight)(uint8_t percent) {
+ if (percent)
palSetPad(IOPORT2, PIOB_LCD_BL);
// pPIOB->PIO_SODR = PIOB_LCD_BL_MASK;
else