Add backlight control to the IS31FL3731 driver

This commit is contained in:
Fred Sundvik 2017-06-03 21:30:52 +03:00
parent effffa33a5
commit 2a7f9a7e46

View File

@ -43,7 +43,7 @@ extern const uint8_t CIE1931_CURVE[];
#define GDISP_INITIAL_CONTRAST 0
#endif
#ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100
#define GDISP_INITIAL_BACKLIGHT 0
#endif
#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;
for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) {
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;
}
}
@ -297,7 +298,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
g->g.Orientation = (orientation_t)g->p.ptr;
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;
}
}