Add backlight control to the IS31FL3731 driver
This commit is contained in:
parent
effffa33a5
commit
2a7f9a7e46
1 changed files with 10 additions and 4 deletions
|
@ -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,8 +298,13 @@ 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:
|
||||||
return;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // GDISP_NEED_CONTROL
|
#endif // GDISP_NEED_CONTROL
|
||||||
|
|
Loading…
Reference in a new issue