Add backlight control to the IS31FL3731 driver

pull/1361/head
Fred Sundvik 8 years ago
parent effffa33a5
commit 2a7f9a7e46

@ -43,7 +43,7 @@ extern const uint8_t CIE1931_CURVE[];
#define GDISP_INITIAL_CONTRAST 0 #define GDISP_INITIAL_CONTRAST 0
#endif #endif
#ifndef GDISP_INITIAL_BACKLIGHT #ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100 #define GDISP_INITIAL_BACKLIGHT 0
#endif #endif
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
@ -204,7 +204,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint8_t* src = PRIV(g)->frame_buffer; uint8_t* src = PRIV(g)->frame_buffer;
for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) { for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) {
for (int x=0;x<GDISP_SCREEN_WIDTH;x++) { for (int x=0;x<GDISP_SCREEN_WIDTH;x++) {
PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[*src]; uint8_t val = (uint16_t)*src * g->g.Backlight / 100;
PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[val];
++src; ++src;
} }
} }
@ -297,7 +298,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
g->g.Orientation = (orientation_t)g->p.ptr; g->g.Orientation = (orientation_t)g->p.ptr;
return; return;
case GDISP_CONTROL_CONTRAST: case GDISP_CONTROL_BACKLIGHT:
if (g->g.Backlight == (unsigned)g->p.ptr)
return;
unsigned val = (unsigned)g->p.ptr;
g->g.Backlight = val > 255 ? 255 : val;
g->flags |= GDISP_FLG_NEEDFLUSH;
return; return;
} }
} }

Loading…
Cancel
Save