diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2017-06-18 10:15:02 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-18 10:15:02 -0400 |
| commit | 51a86b85f35769533124d209c990aee18965ea6b (patch) | |
| tree | 9951b7b99125472ffc4c4af15a764a0083dc1297 | |
| parent | 7feadbd66d5c80b1c39c565864bb1af0d1e87874 (diff) | |
| parent | 086aad0d7e5770e0be36498e5f569af5a23b111c (diff) | |
| download | qmk_firmware-51a86b85f35769533124d209c990aee18965ea6b.tar.gz qmk_firmware-51a86b85f35769533124d209c990aee18965ea6b.zip | |
Merge pull request #1361 from fredizzimo/ergodox_infinity_backlight
Add Ergodox Infinity backlight support
| -rw-r--r-- | build_keyboard.mk | 6 | ||||
| -rw-r--r-- | keyboards/ergodox/infinity/animations.c | 73 | ||||
| -rw-r--r-- | keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c | 18 | ||||
| -rw-r--r-- | keyboards/ergodox/infinity/rules.mk | 9 | ||||
| -rw-r--r-- | keyboards/ergodox/keymaps/333fred/Makefile | 2 | ||||
| -rw-r--r-- | quantum/visualizer/led_keyframes.c | 14 | ||||
| -rw-r--r-- | quantum/visualizer/led_keyframes.h | 3 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.c | 34 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.h | 9 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.mk | 3 | ||||
| -rw-r--r-- | tmk_core/common/backlight.c | 3 |
11 files changed, 139 insertions, 35 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index 9fa8c3126..36eab3a9e 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
| @@ -233,8 +233,10 @@ ifeq ($(strip $(LCD_ENABLE)), yes) | |||
| 233 | CIE1931_CURVE = yes | 233 | CIE1931_CURVE = yes |
| 234 | endif | 234 | endif |
| 235 | 235 | ||
| 236 | ifeq ($(strip $(LED_ENABLE)), yes) | 236 | ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) |
| 237 | CIE1931_CURVE = yes | 237 | ifeq ($(strip $(VISUALIZER_ENABLE)), yes) |
| 238 | CIE1931_CURVE = yes | ||
| 239 | endif | ||
| 238 | endif | 240 | endif |
| 239 | 241 | ||
| 240 | ifeq ($(strip $(CIE1931_CURVE)), yes) | 242 | ifeq ($(strip $(CIE1931_CURVE)), yes) |
diff --git a/keyboards/ergodox/infinity/animations.c b/keyboards/ergodox/infinity/animations.c index 4c9f6d9c8..ebc08fde3 100644 --- a/keyboards/ergodox/infinity/animations.c +++ b/keyboards/ergodox/infinity/animations.c | |||
| @@ -25,43 +25,90 @@ | |||
| 25 | #include "lcd_backlight_keyframes.h" | 25 | #include "lcd_backlight_keyframes.h" |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #ifdef LED_ENABLE | 28 | #ifdef BACKLIGHT_ENABLE |
| 29 | #include "led_keyframes.h" | 29 | #include "led_keyframes.h" |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #include "visualizer_keyframes.h" | 32 | #include "visualizer_keyframes.h" |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | #if defined(LCD_ENABLE) && defined(LCD_BACKLIGHT_ENABLE) | 35 | #if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) |
| 36 | |||
| 37 | static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 38 | #ifdef LCD_ENABLE | ||
| 39 | lcd_keyframe_enable(animation, state); | ||
| 40 | #endif | ||
| 41 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 42 | backlight_keyframe_enable(animation, state); | ||
| 43 | #endif | ||
| 44 | #ifdef BACKLIGHT_ENABLE | ||
| 45 | led_keyframe_enable(animation, state); | ||
| 46 | #endif | ||
| 47 | return false; | ||
| 48 | } | ||
| 49 | |||
| 50 | static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 51 | #ifdef LCD_ENABLE | ||
| 52 | lcd_keyframe_disable(animation, state); | ||
| 53 | #endif | ||
| 54 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 55 | backlight_keyframe_disable(animation, state); | ||
| 56 | #endif | ||
| 57 | #ifdef BACKLIGHT_ENABLE | ||
| 58 | led_keyframe_disable(animation, state); | ||
| 59 | #endif | ||
| 60 | return false; | ||
| 61 | } | ||
| 62 | |||
| 63 | static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 64 | bool ret = false; | ||
| 65 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 66 | ret |= backlight_keyframe_animate_color(animation, state); | ||
| 67 | #endif | ||
| 68 | #ifdef BACKLIGHT_ENABLE | ||
| 69 | ret |= led_keyframe_fade_in_all(animation, state); | ||
| 70 | #endif | ||
| 71 | return ret; | ||
| 72 | } | ||
| 73 | |||
| 74 | static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 75 | bool ret = false; | ||
| 76 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 77 | ret |= backlight_keyframe_animate_color(animation, state); | ||
| 78 | #endif | ||
| 79 | #ifdef BACKLIGHT_ENABLE | ||
| 80 | ret |= led_keyframe_fade_out_all(animation, state); | ||
| 81 | #endif | ||
| 82 | return ret; | ||
| 83 | } | ||
| 84 | |||
| 36 | 85 | ||
| 37 | // Don't worry, if the startup animation is long, you can use the keyboard like normal | 86 | // Don't worry, if the startup animation is long, you can use the keyboard like normal |
| 38 | // during that time | 87 | // during that time |
| 39 | keyframe_animation_t default_startup_animation = { | 88 | keyframe_animation_t default_startup_animation = { |
| 40 | .num_frames = 4, | 89 | .num_frames = 3, |
| 41 | .loop = false, | 90 | .loop = false, |
| 42 | .frame_lengths = {0, 0, 0, gfxMillisecondsToTicks(5000), 0}, | 91 | .frame_lengths = {0, 0, gfxMillisecondsToTicks(5000)}, |
| 43 | .frame_functions = { | 92 | .frame_functions = { |
| 44 | lcd_keyframe_enable, | 93 | keyframe_enable, |
| 45 | backlight_keyframe_enable, | ||
| 46 | lcd_keyframe_draw_logo, | 94 | lcd_keyframe_draw_logo, |
| 47 | backlight_keyframe_animate_color, | 95 | keyframe_fade_in, |
| 48 | }, | 96 | }, |
| 49 | }; | 97 | }; |
| 50 | 98 | ||
| 51 | keyframe_animation_t default_suspend_animation = { | 99 | keyframe_animation_t default_suspend_animation = { |
| 52 | .num_frames = 4, | 100 | .num_frames = 3, |
| 53 | .loop = false, | 101 | .loop = false, |
| 54 | .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0, 0}, | 102 | .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0}, |
| 55 | .frame_functions = { | 103 | .frame_functions = { |
| 56 | lcd_keyframe_display_layer_text, | 104 | lcd_keyframe_display_layer_text, |
| 57 | backlight_keyframe_animate_color, | 105 | keyframe_fade_out, |
| 58 | lcd_keyframe_disable, | 106 | keyframe_disable, |
| 59 | backlight_keyframe_disable, | ||
| 60 | }, | 107 | }, |
| 61 | }; | 108 | }; |
| 62 | #endif | 109 | #endif |
| 63 | 110 | ||
| 64 | #if defined(LED_ENABLE) | 111 | #if defined(BACKLIGHT_ENABLE) |
| 65 | #define CROSSFADE_TIME 1000 | 112 | #define CROSSFADE_TIME 1000 |
| 66 | #define GRADIENT_TIME 3000 | 113 | #define GRADIENT_TIME 3000 |
| 67 | 114 | ||
diff --git a/keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c b/keyboards/ergodox/infinity/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c index ea09c4bb0..b4a5c84b0 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[]; | |||
| 43 | #define GDISP_INITIAL_CONTRAST 0 | 43 | #define GDISP_INITIAL_CONTRAST 0 |
| 44 | #endif | 44 | #endif |
| 45 | #ifndef GDISP_INITIAL_BACKLIGHT | 45 | #ifndef GDISP_INITIAL_BACKLIGHT |
| 46 | #define GDISP_INITIAL_BACKLIGHT 100 | 46 | #define GDISP_INITIAL_BACKLIGHT 0 |
| 47 | #endif | 47 | #endif |
| 48 | 48 | ||
| 49 | #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) | 49 | #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) |
| @@ -173,7 +173,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | |||
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | // software shutdown disable (i.e. turn stuff on) | 175 | // software shutdown disable (i.e. turn stuff on) |
| 176 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON); | 176 | write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); |
| 177 | gfxSleepMilliseconds(10); | 177 | gfxSleepMilliseconds(10); |
| 178 | 178 | ||
| 179 | // Finish Init | 179 | // Finish Init |
| @@ -183,7 +183,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | |||
| 183 | g->g.Width = GDISP_SCREEN_WIDTH; | 183 | g->g.Width = GDISP_SCREEN_WIDTH; |
| 184 | g->g.Height = GDISP_SCREEN_HEIGHT; | 184 | g->g.Height = GDISP_SCREEN_HEIGHT; |
| 185 | g->g.Orientation = GDISP_ROTATE_0; | 185 | g->g.Orientation = GDISP_ROTATE_0; |
| 186 | g->g.Powermode = powerOn; | 186 | g->g.Powermode = powerOff; |
| 187 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; | 187 | g->g.Backlight = GDISP_INITIAL_BACKLIGHT; |
| 188 | g->g.Contrast = GDISP_INITIAL_CONTRAST; | 188 | g->g.Contrast = GDISP_INITIAL_CONTRAST; |
| 189 | return TRUE; | 189 | return TRUE; |
| @@ -204,7 +204,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | |||
| 204 | uint8_t* src = PRIV(g)->frame_buffer; | 204 | uint8_t* src = PRIV(g)->frame_buffer; |
| 205 | for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) { | 205 | for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) { |
| 206 | for (int x=0;x<GDISP_SCREEN_WIDTH;x++) { | 206 | for (int x=0;x<GDISP_SCREEN_WIDTH;x++) { |
| 207 | PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[*src]; | 207 | uint8_t val = (uint16_t)*src * g->g.Backlight / 100; |
| 208 | PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[val]; | ||
| 208 | ++src; | 209 | ++src; |
| 209 | } | 210 | } |
| 210 | } | 211 | } |
| @@ -297,8 +298,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { | |||
| 297 | g->g.Orientation = (orientation_t)g->p.ptr; | 298 | g->g.Orientation = (orientation_t)g->p.ptr; |
| 298 | return; | 299 | return; |
| 299 | 300 | ||
| 300 | case GDISP_CONTROL_CONTRAST: | 301 | case GDISP_CONTROL_BACKLIGHT: |
| 301 | return; | 302 | if (g->g.Backlight == (unsigned)g->p.ptr) |
| 303 | return; | ||
| 304 | unsigned val = (unsigned)g->p.ptr; | ||
| 305 | g->g.Backlight = val > 100 ? 100 : val; | ||
| 306 | g->flags |= GDISP_FLG_NEEDFLUSH; | ||
| 307 | return; | ||
| 302 | } | 308 | } |
| 303 | } | 309 | } |
| 304 | #endif // GDISP_NEED_CONTROL | 310 | #endif // GDISP_NEED_CONTROL |
diff --git a/keyboards/ergodox/infinity/rules.mk b/keyboards/ergodox/infinity/rules.mk index 9e6170d89..af29ebce8 100644 --- a/keyboards/ergodox/infinity/rules.mk +++ b/keyboards/ergodox/infinity/rules.mk | |||
| @@ -62,15 +62,10 @@ CUSTOM_MATRIX ?= yes # Custom matrix file | |||
| 62 | SERIAL_LINK_ENABLE = yes | 62 | SERIAL_LINK_ENABLE = yes |
| 63 | VISUALIZER_ENABLE ?= yes | 63 | VISUALIZER_ENABLE ?= yes |
| 64 | LCD_ENABLE ?= yes | 64 | LCD_ENABLE ?= yes |
| 65 | LED_ENABLE ?= no | 65 | BACKLIGHT_ENABLE ?= yes |
| 66 | LCD_BACKLIGHT_ENABLE ?= yes | 66 | LCD_BACKLIGHT_ENABLE ?= yes |
| 67 | MIDI_ENABLE = no | 67 | MIDI_ENABLE = no |
| 68 | RGBLIGHT_ENABLE = no | 68 | RGBLIGHT_ENABLE = no |
| 69 | 69 | ||
| 70 | ifdef LCD_ENABLE | ||
| 71 | include $(SUBPROJECT_PATH)/drivers/gdisp/st7565ergodox/driver.mk | 70 | include $(SUBPROJECT_PATH)/drivers/gdisp/st7565ergodox/driver.mk |
| 72 | endif | 71 | include $(SUBPROJECT_PATH)/drivers/gdisp/IS31FL3731C/driver.mk \ No newline at end of file |
| 73 | |||
| 74 | ifdef LED_ENABLE | ||
| 75 | include $(SUBPROJECT_PATH)/drivers/gdisp/IS31FL3731C/driver.mk | ||
| 76 | endif \ No newline at end of file | ||
diff --git a/keyboards/ergodox/keymaps/333fred/Makefile b/keyboards/ergodox/keymaps/333fred/Makefile index 87985bda1..b977722a2 100644 --- a/keyboards/ergodox/keymaps/333fred/Makefile +++ b/keyboards/ergodox/keymaps/333fred/Makefile | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | SUBPROJECT_DEFAULT = infinity | 1 | SUBPROJECT_DEFAULT = infinity |
| 2 | LCD_BACKLIGHT_ENABLE = yes | 2 | LCD_BACKLIGHT_ENABLE = yes |
| 3 | LCD_ENABLE = yes | 3 | LCD_ENABLE = yes |
| 4 | LED_ENABLE = yes | 4 | BACKLIGHT_ENABLE = yes |
| 5 | BACKLIGHT_ENABLE = yes | 5 | BACKLIGHT_ENABLE = yes |
| 6 | NKRO_ENABLE = yes | 6 | NKRO_ENABLE = yes |
| 7 | TAP_DANCE_ENABLE = yes | 7 | TAP_DANCE_ENABLE = yes |
diff --git a/quantum/visualizer/led_keyframes.c b/quantum/visualizer/led_keyframes.c index 2dacd990d..c14491e5e 100644 --- a/quantum/visualizer/led_keyframes.c +++ b/quantum/visualizer/led_keyframes.c | |||
| @@ -127,3 +127,17 @@ bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer | |||
| 127 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); | 127 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); |
| 128 | return false; | 128 | return false; |
| 129 | } | 129 | } |
| 130 | |||
| 131 | bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 132 | (void)state; | ||
| 133 | (void)animation; | ||
| 134 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | ||
| 135 | return false; | ||
| 136 | } | ||
| 137 | |||
| 138 | bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 139 | (void)state; | ||
| 140 | (void)animation; | ||
| 141 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | ||
| 142 | return false; | ||
| 143 | } | ||
diff --git a/quantum/visualizer/led_keyframes.h b/quantum/visualizer/led_keyframes.h index a68943041..a59a4f37d 100644 --- a/quantum/visualizer/led_keyframes.h +++ b/quantum/visualizer/led_keyframes.h | |||
| @@ -35,6 +35,9 @@ bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* | |||
| 35 | bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | 35 | bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); |
| 36 | bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | 36 | bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); |
| 37 | 37 | ||
| 38 | bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 39 | bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 40 | |||
| 38 | extern keyframe_animation_t led_test_animation; | 41 | extern keyframe_animation_t led_test_animation; |
| 39 | 42 | ||
| 40 | 43 | ||
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 6f134097f..486ff25b3 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c | |||
| @@ -58,8 +58,11 @@ SOFTWARE. | |||
| 58 | static visualizer_keyboard_status_t current_status = { | 58 | static visualizer_keyboard_status_t current_status = { |
| 59 | .layer = 0xFFFFFFFF, | 59 | .layer = 0xFFFFFFFF, |
| 60 | .default_layer = 0xFFFFFFFF, | 60 | .default_layer = 0xFFFFFFFF, |
| 61 | .mods = 0xFF, | ||
| 62 | .leds = 0xFFFFFFFF, | 61 | .leds = 0xFFFFFFFF, |
| 62 | #ifdef BACKLIGHT_ENABLE | ||
| 63 | .backlight_level = 0, | ||
| 64 | #endif | ||
| 65 | .mods = 0xFF, | ||
| 63 | .suspended = false, | 66 | .suspended = false, |
| 64 | #ifdef VISUALIZER_USER_DATA_SIZE | 67 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 65 | .user_data = {0} | 68 | .user_data = {0} |
| @@ -72,6 +75,9 @@ static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboa | |||
| 72 | status1->mods == status2->mods && | 75 | status1->mods == status2->mods && |
| 73 | status1->leds == status2->leds && | 76 | status1->leds == status2->leds && |
| 74 | status1->suspended == status2->suspended | 77 | status1->suspended == status2->suspended |
| 78 | #ifdef BACKLIGHT_ENABLE | ||
| 79 | && status1->backlight_level == status2->backlight_level | ||
| 80 | #endif | ||
| 75 | #ifdef VISUALIZER_USER_DATA_SIZE | 81 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 76 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 | 82 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 |
| 77 | #endif | 83 | #endif |
| @@ -279,6 +285,18 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 279 | bool enabled = visualizer_enabled; | 285 | bool enabled = visualizer_enabled; |
| 280 | if (force_update || !same_status(&state.status, ¤t_status)) { | 286 | if (force_update || !same_status(&state.status, ¤t_status)) { |
| 281 | force_update = false; | 287 | force_update = false; |
| 288 | #if BACKLIGHT_ENABLE | ||
| 289 | if(current_status.backlight_level != state.status.backlight_level) { | ||
| 290 | if (current_status.backlight_level != 0) { | ||
| 291 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | ||
| 292 | uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; | ||
| 293 | gdispGSetBacklight(LED_DISPLAY, percent); | ||
| 294 | } | ||
| 295 | else { | ||
| 296 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | ||
| 297 | } | ||
| 298 | } | ||
| 299 | #endif | ||
| 282 | if (visualizer_enabled) { | 300 | if (visualizer_enabled) { |
| 283 | if (current_status.suspended) { | 301 | if (current_status.suspended) { |
| 284 | stop_all_keyframe_animations(); | 302 | stop_all_keyframe_animations(); |
| @@ -309,7 +327,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 309 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); | 327 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); |
| 310 | } | 328 | } |
| 311 | } | 329 | } |
| 312 | #ifdef LED_ENABLE | 330 | #ifdef BACKLIGHT_ENABLE |
| 313 | gdispGFlush(LED_DISPLAY); | 331 | gdispGFlush(LED_DISPLAY); |
| 314 | #endif | 332 | #endif |
| 315 | 333 | ||
| @@ -372,7 +390,7 @@ void visualizer_init(void) { | |||
| 372 | #ifdef LCD_ENABLE | 390 | #ifdef LCD_ENABLE |
| 373 | LCD_DISPLAY = get_lcd_display(); | 391 | LCD_DISPLAY = get_lcd_display(); |
| 374 | #endif | 392 | #endif |
| 375 | #ifdef LED_ENABLE | 393 | #ifdef BACKLIGHT_ENABLE |
| 376 | LED_DISPLAY = get_led_display(); | 394 | LED_DISPLAY = get_led_display(); |
| 377 | #endif | 395 | #endif |
| 378 | 396 | ||
| @@ -445,6 +463,9 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uin | |||
| 445 | .default_layer = default_state, | 463 | .default_layer = default_state, |
| 446 | .mods = mods, | 464 | .mods = mods, |
| 447 | .leds = leds, | 465 | .leds = leds, |
| 466 | #ifdef BACKLIGHT_ENABLE | ||
| 467 | .backlight_level = current_status.backlight_level, | ||
| 468 | #endif | ||
| 448 | .suspended = current_status.suspended, | 469 | .suspended = current_status.suspended, |
| 449 | }; | 470 | }; |
| 450 | #ifdef VISUALIZER_USER_DATA_SIZE | 471 | #ifdef VISUALIZER_USER_DATA_SIZE |
| @@ -467,3 +488,10 @@ void visualizer_resume(void) { | |||
| 467 | current_status.suspended = false; | 488 | current_status.suspended = false; |
| 468 | update_status(true); | 489 | update_status(true); |
| 469 | } | 490 | } |
| 491 | |||
| 492 | #ifdef BACKLIGHT_ENABLE | ||
| 493 | void backlight_set(uint8_t level) { | ||
| 494 | current_status.backlight_level = level; | ||
| 495 | update_status(true); | ||
| 496 | } | ||
| 497 | #endif | ||
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h index d6f279e10..1c567440f 100644 --- a/quantum/visualizer/visualizer.h +++ b/quantum/visualizer/visualizer.h | |||
| @@ -34,6 +34,10 @@ SOFTWARE. | |||
| 34 | #include "lcd_backlight.h" | 34 | #include "lcd_backlight.h" |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #ifdef BACKLIGHT_ENABLE | ||
| 38 | #include "backlight.h" | ||
| 39 | #endif | ||
| 40 | |||
| 37 | // use this function to merge both real_mods and oneshot_mods in a uint16_t | 41 | // use this function to merge both real_mods and oneshot_mods in a uint16_t |
| 38 | uint8_t visualizer_get_mods(void); | 42 | uint8_t visualizer_get_mods(void); |
| 39 | 43 | ||
| @@ -65,9 +69,12 @@ struct keyframe_animation_t; | |||
| 65 | typedef struct { | 69 | typedef struct { |
| 66 | uint32_t layer; | 70 | uint32_t layer; |
| 67 | uint32_t default_layer; | 71 | uint32_t default_layer; |
| 68 | uint8_t mods; | ||
| 69 | uint32_t leds; // See led.h for available statuses | 72 | uint32_t leds; // See led.h for available statuses |
| 73 | uint8_t mods; | ||
| 70 | bool suspended; | 74 | bool suspended; |
| 75 | #ifdef BACKLIGHT_ENABLE | ||
| 76 | uint8_t backlight_level; | ||
| 77 | #endif | ||
| 71 | #ifdef VISUALIZER_USER_DATA_SIZE | 78 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 72 | uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; | 79 | uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; |
| 73 | #endif | 80 | #endif |
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index 5f710124b..6f97603bd 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk | |||
| @@ -42,9 +42,8 @@ SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c | |||
| 42 | OPT_DEFS += -DLCD_BACKLIGHT_ENABLE | 42 | OPT_DEFS += -DLCD_BACKLIGHT_ENABLE |
| 43 | endif | 43 | endif |
| 44 | 44 | ||
| 45 | ifeq ($(strip $(LED_ENABLE)), yes) | 45 | ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) |
| 46 | SRC += $(VISUALIZER_DIR)/led_keyframes.c | 46 | SRC += $(VISUALIZER_DIR)/led_keyframes.c |
| 47 | OPT_DEFS += -DLED_ENABLE | ||
| 48 | endif | 47 | endif |
| 49 | 48 | ||
| 50 | include $(GFXLIB)/gfx.mk | 49 | include $(GFXLIB)/gfx.mk |
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c index 0e0ad2d15..d03bfe931 100644 --- a/tmk_core/common/backlight.c +++ b/tmk_core/common/backlight.c | |||
| @@ -28,6 +28,9 @@ void backlight_init(void) | |||
| 28 | eeconfig_init(); | 28 | eeconfig_init(); |
| 29 | } | 29 | } |
| 30 | backlight_config.raw = eeconfig_read_backlight(); | 30 | backlight_config.raw = eeconfig_read_backlight(); |
| 31 | if (backlight_config.level > BACKLIGHT_LEVELS) { | ||
| 32 | backlight_config.level = BACKLIGHT_LEVELS; | ||
| 33 | } | ||
| 31 | backlight_set(backlight_config.enable ? backlight_config.level : 0); | 34 | backlight_set(backlight_config.enable ? backlight_config.level : 0); |
| 32 | } | 35 | } |
| 33 | 36 | ||
