From a916f4e8b897b6b8925d7113d84f9eac7e7b67be Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 3 Jun 2017 14:34:50 +0300 Subject: Let BACKLIGHT_ENABLE control the Infinity LEDs --- quantum/visualizer/visualizer.c | 4 ++-- quantum/visualizer/visualizer.mk | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 6f134097f..cd2dff6a6 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -309,7 +309,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { update_keyframe_animation(animations[i], &state, delta, &sleep_time); } } -#ifdef LED_ENABLE +#ifdef BACKLIGHT_ENABLE gdispGFlush(LED_DISPLAY); #endif @@ -372,7 +372,7 @@ void visualizer_init(void) { #ifdef LCD_ENABLE LCD_DISPLAY = get_lcd_display(); #endif -#ifdef LED_ENABLE +#ifdef BACKLIGHT_ENABLE LED_DISPLAY = get_led_display(); #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 OPT_DEFS += -DLCD_BACKLIGHT_ENABLE endif -ifeq ($(strip $(LED_ENABLE)), yes) +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) SRC += $(VISUALIZER_DIR)/led_keyframes.c -OPT_DEFS += -DLED_ENABLE endif include $(GFXLIB)/gfx.mk -- cgit v1.2.3-24-g4f1b From effffa33a503a093be4fa00b570df7a4e2996edc Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 3 Jun 2017 21:14:26 +0300 Subject: Backlight level handling for the visualizer --- quantum/visualizer/visualizer.c | 30 +++++++++++++++++++++++++++++- quantum/visualizer/visualizer.h | 9 ++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index cd2dff6a6..29db7005c 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -58,8 +58,11 @@ SOFTWARE. static visualizer_keyboard_status_t current_status = { .layer = 0xFFFFFFFF, .default_layer = 0xFFFFFFFF, - .mods = 0xFF, .leds = 0xFFFFFFFF, +#ifdef BACKLIGHT_ENABLE + .backlight_level = 0, +#endif + .mods = 0xFF, .suspended = false, #ifdef VISUALIZER_USER_DATA_SIZE .user_data = {0} @@ -72,6 +75,9 @@ static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboa status1->mods == status2->mods && status1->leds == status2->leds && status1->suspended == status2->suspended +#ifdef BACKLIGHT_ENABLE + && status1->backlight_level == status2->backlight_level +#endif #ifdef VISUALIZER_USER_DATA_SIZE && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 #endif @@ -279,6 +285,18 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { bool enabled = visualizer_enabled; if (force_update || !same_status(&state.status, ¤t_status)) { force_update = false; + #if BACKLIGHT_ENABLE + if(current_status.backlight_level != state.status.backlight_level) { + if (current_status.backlight_level != 0) { + gdispGSetPowerMode(LED_DISPLAY, powerOn); + uint16_t percent = (uint16_t)current_status.backlight_level * 100 / 255; + gdispGSetBacklight(LED_DISPLAY, percent); + } + else { + gdispGSetPowerMode(LED_DISPLAY, powerOff); + } + } + #endif if (visualizer_enabled) { if (current_status.suspended) { stop_all_keyframe_animations(); @@ -445,6 +463,9 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uin .default_layer = default_state, .mods = mods, .leds = leds, +#ifdef BACKLIGHT_ENABLE + .backlight_level = current_status.backlight_level, +#endif .suspended = current_status.suspended, }; #ifdef VISUALIZER_USER_DATA_SIZE @@ -467,3 +488,10 @@ void visualizer_resume(void) { current_status.suspended = false; update_status(true); } + +#ifdef BACKLIGHT_ENABLE +void backlight_set(uint8_t level) { + current_status.backlight_level = level; + update_status(true); +} +#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. #include "lcd_backlight.h" #endif +#ifdef BACKLIGHT_ENABLE +#include "backlight.h" +#endif + // use this function to merge both real_mods and oneshot_mods in a uint16_t uint8_t visualizer_get_mods(void); @@ -65,9 +69,12 @@ struct keyframe_animation_t; typedef struct { uint32_t layer; uint32_t default_layer; - uint8_t mods; uint32_t leds; // See led.h for available statuses + uint8_t mods; bool suspended; +#ifdef BACKLIGHT_ENABLE + uint8_t backlight_level; +#endif #ifdef VISUALIZER_USER_DATA_SIZE uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; #endif -- cgit v1.2.3-24-g4f1b From b51a0db6ed03d939baad7cb9d87ed13c3653c7d2 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 3 Jun 2017 22:04:10 +0300 Subject: Add backlight support to the default Ergodox Infinity animations --- quantum/visualizer/led_keyframes.c | 14 ++++++++++++++ quantum/visualizer/led_keyframes.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'quantum') 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 gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); return false; } + +bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + (void)animation; + gdispGSetPowerMode(LED_DISPLAY, powerOff); + return false; +} + +bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + (void)animation; + gdispGSetPowerMode(LED_DISPLAY, powerOn); + return false; +} 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* bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); +bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); +bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); + extern keyframe_animation_t led_test_animation; -- cgit v1.2.3-24-g4f1b From 7d5606085fbd775019fc514f3ffca84edfc11aa6 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 02:01:02 +0300 Subject: Correctly calculate backlight level --- quantum/visualizer/visualizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 29db7005c..486ff25b3 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c @@ -289,7 +289,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { if(current_status.backlight_level != state.status.backlight_level) { if (current_status.backlight_level != 0) { gdispGSetPowerMode(LED_DISPLAY, powerOn); - uint16_t percent = (uint16_t)current_status.backlight_level * 100 / 255; + uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; gdispGSetBacklight(LED_DISPLAY, percent); } else { -- cgit v1.2.3-24-g4f1b