diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2017-06-03 21:30:52 +0300 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2017-06-03 21:30:52 +0300 |
commit | 2a7f9a7e46e1f4350be249c267fa7c35fd6562b5 (patch) | |
tree | 371987383b46263043ea9a9cad73ad33a5ce277f | |
parent | effffa33a503a093be4fa00b570df7a4e2996edc (diff) |
Add backlight control to the IS31FL3731 driver
-rw-r--r-- | keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c b/keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c index 2472694466..0b48783d6a 100644 --- a/keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c +++ b/keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c @@ -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,8 +298,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { g->g.Orientation = (orientation_t)g->p.ptr; return; - case GDISP_CONTROL_CONTRAST: - return; + 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; } } #endif // GDISP_NEED_CONTROL |