From a95c4933c4ef7631c077fc040076e71c8d46209a Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Tue, 13 Nov 2012 23:54:50 +0100 Subject: [PATCH] Backlight fix --- drivers/gdisp/ILI9320/gdisp_lld.c | 7 +++---- include/gdisp.h | 4 ++-- src/gdisp.c | 18 ------------------ 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c index 4b485d79..7b9eda27 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld.c +++ b/drivers/gdisp/ILI9320/gdisp_lld.c @@ -508,10 +508,9 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { return; case GDISP_CONTROL_BACKLIGHT: - if(GDISP.Backlight == (*(uint8_t*)value)) - return; - GDISP_LLD(set_backlight)(*(uint8_t*)value); - GDISP.Backlight = (*(uint8_t*)value); + if((unsigned)value > 100) value = (void *)100; + GDISP_LLD(set_backlight)((unsigned)value); + GDISP.Backlight = (unsigned)value; break; default: diff --git a/include/gdisp.h b/include/gdisp.h index f92ac8ac..760f14f6 100644 --- a/include/gdisp.h +++ b/include/gdisp.h @@ -287,8 +287,6 @@ 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 -void gdispSetBacklight(uint8_t percentage); -void gdispSetContrast(uint8_t percentage); /* * Macro definitions */ @@ -298,6 +296,8 @@ void gdispSetContrast(uint8_t percentage); /* 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 ddcf8546..81c06599 100644 --- a/src/gdisp.c +++ b/src/gdisp.c @@ -1267,24 +1267,6 @@ 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 */