From f3c113fb5a5ea89762b5c51d5d182093f6fb999d Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 9 Jul 2017 14:31:38 +0300 Subject: Shared gfxconf --- quantum/visualizer/visualizer.mk | 3 +++ 1 file changed, 3 insertions(+) (limited to 'quantum/visualizer/visualizer.mk') diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index 0f7d8636c..1fe7435d9 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk @@ -47,6 +47,9 @@ SRC += $(VISUALIZER_DIR)/led_keyframes.c endif include $(GFXLIB)/gfx.mk +# For the common_gfxconf.h +GFXINC += quantum/visualizer + GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC)) GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) -- cgit v1.2.3 From 2251560256ff1a139178dc80b18dd8ef1d8e83d6 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 9 Jul 2017 17:46:51 +0300 Subject: Clarify naming between LCD_BACKLIGHT and LED_BACKLIGHT --- keyboards/ergodox/infinity/animations.c | 44 ++++---- keyboards/ergodox/infinity/simple_visualizer.h | 2 +- keyboards/ergodox/infinity/visualizer.c | 4 +- keyboards/whitefox/animations.c | 36 +++---- lcd_backlight_keyframes.h | 30 ++++++ quantum/visualizer/lcd_backlight_keyframes.c | 8 +- quantum/visualizer/lcd_backlight_keyframes.h | 30 ------ quantum/visualizer/led_backlight_keyframes.c | 143 +++++++++++++++++++++++++ quantum/visualizer/led_backlight_keyframes.h | 44 ++++++++ quantum/visualizer/led_keyframes.c | 143 ------------------------- quantum/visualizer/led_keyframes.h | 44 -------- quantum/visualizer/visualizer.mk | 2 +- 12 files changed, 265 insertions(+), 265 deletions(-) create mode 100644 lcd_backlight_keyframes.h delete mode 100644 quantum/visualizer/lcd_backlight_keyframes.h create mode 100644 quantum/visualizer/led_backlight_keyframes.c create mode 100644 quantum/visualizer/led_backlight_keyframes.h delete mode 100644 quantum/visualizer/led_keyframes.c delete mode 100644 quantum/visualizer/led_keyframes.h (limited to 'quantum/visualizer/visualizer.mk') diff --git a/keyboards/ergodox/infinity/animations.c b/keyboards/ergodox/infinity/animations.c index ebc08fde3..faac96215 100644 --- a/keyboards/ergodox/infinity/animations.c +++ b/keyboards/ergodox/infinity/animations.c @@ -26,7 +26,7 @@ #endif #ifdef BACKLIGHT_ENABLE -#include "led_keyframes.h" +#include "led_backlight_keyframes.h" #endif #include "visualizer_keyframes.h" @@ -39,10 +39,10 @@ static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* lcd_keyframe_enable(animation, state); #endif #ifdef LCD_BACKLIGHT_ENABLE - backlight_keyframe_enable(animation, state); + lcd_backlight_keyframe_enable(animation, state); #endif #ifdef BACKLIGHT_ENABLE - led_keyframe_enable(animation, state); + led_backlight_keyframe_enable(animation, state); #endif return false; } @@ -52,10 +52,10 @@ static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t lcd_keyframe_disable(animation, state); #endif #ifdef LCD_BACKLIGHT_ENABLE - backlight_keyframe_disable(animation, state); + lcd_backlight_keyframe_disable(animation, state); #endif #ifdef BACKLIGHT_ENABLE - led_keyframe_disable(animation, state); + led_backlight_keyframe_disable(animation, state); #endif return false; } @@ -63,10 +63,10 @@ static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { bool ret = false; #ifdef LCD_BACKLIGHT_ENABLE - ret |= backlight_keyframe_animate_color(animation, state); + ret |= lcd_backlight_keyframe_animate_color(animation, state); #endif #ifdef BACKLIGHT_ENABLE - ret |= led_keyframe_fade_in_all(animation, state); + ret |= led_backlight_keyframe_fade_in_all(animation, state); #endif return ret; } @@ -74,10 +74,10 @@ static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { bool ret = false; #ifdef LCD_BACKLIGHT_ENABLE - ret |= backlight_keyframe_animate_color(animation, state); + ret |= lcd_backlight_keyframe_animate_color(animation, state); #endif #ifdef BACKLIGHT_ENABLE - ret |= led_keyframe_fade_out_all(animation, state); + ret |= led_backlight_keyframe_fade_out_all(animation, state); #endif return ret; } @@ -133,20 +133,20 @@ keyframe_animation_t led_test_animation = { }, .frame_functions = { - led_keyframe_fade_in_all, + led_backlight_keyframe_fade_in_all, keyframe_no_operation, - led_keyframe_fade_out_all, - led_keyframe_crossfade, - led_keyframe_left_to_right_gradient, - led_keyframe_crossfade, - led_keyframe_top_to_bottom_gradient, - led_keyframe_mirror_orientation, - led_keyframe_crossfade, - led_keyframe_left_to_right_gradient, - led_keyframe_crossfade, - led_keyframe_top_to_bottom_gradient, - led_keyframe_normal_orientation, - led_keyframe_crossfade, + led_backlight_keyframe_fade_out_all, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_left_to_right_gradient, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_top_to_bottom_gradient, + led_backlight_keyframe_mirror_orientation, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_left_to_right_gradient, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_top_to_bottom_gradient, + led_backlight_keyframe_normal_orientation, + led_backlight_keyframe_crossfade, }, }; #endif diff --git a/keyboards/ergodox/infinity/simple_visualizer.h b/keyboards/ergodox/infinity/simple_visualizer.h index ded8a3222..88e96f2af 100644 --- a/keyboards/ergodox/infinity/simple_visualizer.h +++ b/keyboards/ergodox/infinity/simple_visualizer.h @@ -58,7 +58,7 @@ static keyframe_animation_t color_animation = { // this prevents the color from changing when activating the layer // momentarily .frame_lengths = {gfxMillisecondsToTicks(200), gfxMillisecondsToTicks(500)}, - .frame_functions = {keyframe_no_operation, backlight_keyframe_animate_color}, + .frame_functions = {keyframe_no_operation, lcd_backlight_keyframe_animate_color}, }; void initialize_user_visualizer(visualizer_state_t* state) { diff --git a/keyboards/ergodox/infinity/visualizer.c b/keyboards/ergodox/infinity/visualizer.c index 5b6b32007..047a1119c 100644 --- a/keyboards/ergodox/infinity/visualizer.c +++ b/keyboards/ergodox/infinity/visualizer.c @@ -79,7 +79,7 @@ static keyframe_animation_t one_led_color = { .num_frames = 1, .loop = false, .frame_lengths = {gfxMillisecondsToTicks(0)}, - .frame_functions = {backlight_keyframe_set_color}, + .frame_functions = {lcd_backlight_keyframe_set_color}, }; bool swap_led_target_color(keyframe_animation_t* animation, visualizer_state_t* state) { @@ -94,7 +94,7 @@ static keyframe_animation_t two_led_colors = { .num_frames = 2, .loop = true, .frame_lengths = {gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(0)}, - .frame_functions = {backlight_keyframe_set_color, swap_led_target_color}, + .frame_functions = {lcd_backlight_keyframe_set_color, swap_led_target_color}, }; // The LCD animation alternates between the layer name display and a diff --git a/keyboards/whitefox/animations.c b/keyboards/whitefox/animations.c index ed1d75efb..a15d46ccd 100644 --- a/keyboards/whitefox/animations.c +++ b/keyboards/whitefox/animations.c @@ -20,7 +20,7 @@ #include "visualizer.h" #ifdef BACKLIGHT_ENABLE -#include "led_keyframes.h" +#include "led_backlight_keyframes.h" #endif #include "visualizer_keyframes.h" @@ -30,14 +30,14 @@ static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { #ifdef BACKLIGHT_ENABLE - led_keyframe_enable(animation, state); + led_backlight_keyframe_enable(animation, state); #endif return false; } static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { #ifdef BACKLIGHT_ENABLE - led_keyframe_disable(animation, state); + led_backlight_keyframe_disable(animation, state); #endif return false; } @@ -45,7 +45,7 @@ static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { bool ret = false; #ifdef BACKLIGHT_ENABLE - ret |= led_keyframe_fade_in_all(animation, state); + ret |= led_backlight_keyframe_fade_in_all(animation, state); #endif return ret; } @@ -53,7 +53,7 @@ static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { bool ret = false; #ifdef BACKLIGHT_ENABLE - ret |= led_keyframe_fade_out_all(animation, state); + ret |= led_backlight_keyframe_fade_out_all(animation, state); #endif return ret; } @@ -107,20 +107,20 @@ keyframe_animation_t led_test_animation = { }, .frame_functions = { - led_keyframe_fade_in_all, + led_backlight_keyframe_fade_in_all, keyframe_no_operation, - led_keyframe_fade_out_all, - led_keyframe_crossfade, - led_keyframe_left_to_right_gradient, - led_keyframe_crossfade, - led_keyframe_top_to_bottom_gradient, - led_keyframe_mirror_orientation, - led_keyframe_crossfade, - led_keyframe_left_to_right_gradient, - led_keyframe_crossfade, - led_keyframe_top_to_bottom_gradient, - led_keyframe_normal_orientation, - led_keyframe_crossfade, + led_backlight_keyframe_fade_out_all, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_left_to_right_gradient, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_top_to_bottom_gradient, + led_backlight_keyframe_mirror_orientation, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_left_to_right_gradient, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_top_to_bottom_gradient, + led_backlight_keyframe_normal_orientation, + led_backlight_keyframe_crossfade, }, }; #endif diff --git a/lcd_backlight_keyframes.h b/lcd_backlight_keyframes.h new file mode 100644 index 000000000..bde118449 --- /dev/null +++ b/lcd_backlight_keyframes.h @@ -0,0 +1,30 @@ +/* Copyright 2017 Fred Sundvik + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ +#define QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ + +#include "visualizer.h" + +// Animates the LCD backlight color between the current color and the target color (of the state) +bool lcd_backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state); +// Sets the backlight color to the target color +bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state); + +bool lcd_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); +bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); + +#endif /* QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ */ diff --git a/quantum/visualizer/lcd_backlight_keyframes.c b/quantum/visualizer/lcd_backlight_keyframes.c index 8436d4e3d..8c402baf6 100644 --- a/quantum/visualizer/lcd_backlight_keyframes.c +++ b/quantum/visualizer/lcd_backlight_keyframes.c @@ -16,7 +16,7 @@ #include "lcd_backlight_keyframes.h" -bool backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state) { +bool lcd_backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state) { int frame_length = animation->frame_lengths[animation->current_frame]; int current_pos = frame_length - animation->time_left_in_frame; uint8_t t_h = LCD_HUE(state->target_lcd_color); @@ -49,7 +49,7 @@ bool backlight_keyframe_animate_color(keyframe_animation_t* animation, visualize return true; } -bool backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) { +bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) { (void)animation; state->prev_lcd_color = state->target_lcd_color; state->current_lcd_color = state->target_lcd_color; @@ -60,14 +60,14 @@ bool backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_st return false; } -bool backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { +bool lcd_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { (void)animation; (void)state; lcd_backlight_hal_color(0, 0, 0); return false; } -bool backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { +bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { (void)animation; (void)state; lcd_backlight_color(LCD_HUE(state->current_lcd_color), diff --git a/quantum/visualizer/lcd_backlight_keyframes.h b/quantum/visualizer/lcd_backlight_keyframes.h deleted file mode 100644 index e1c125cf9..000000000 --- a/quantum/visualizer/lcd_backlight_keyframes.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ -#define QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ - -#include "visualizer.h" - -// Animates the LCD backlight color between the current color and the target color (of the state) -bool backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state); -// Sets the backlight color to the target color -bool backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state); - -bool backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); -bool backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); - -#endif /* QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ */ diff --git a/quantum/visualizer/led_backlight_keyframes.c b/quantum/visualizer/led_backlight_keyframes.c new file mode 100644 index 000000000..d2921a391 --- /dev/null +++ b/quantum/visualizer/led_backlight_keyframes.c @@ -0,0 +1,143 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 Fred Sundvik + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +#include "gfx.h" +#include "math.h" +#include "led_backlight_keyframes.h" + +static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { + int frame_length = animation->frame_lengths[animation->current_frame]; + int current_pos = frame_length - animation->time_left_in_frame; + int delta = to - from; + int luma = (delta * current_pos) / frame_length; + luma += from; + return luma; +} + +static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) { + uint8_t luma = fade_led_color(animation, from, to); + color_t color = LUMA2COLOR(luma); + gdispGClear(LED_DISPLAY, color); +} + +// TODO: Should be customizable per keyboard +#define NUM_ROWS LED_NUM_ROWS +#define NUM_COLS LED_NUM_COLS + +static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; +static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; + +static uint8_t compute_gradient_color(float t, float index, float num) { + const float two_pi = M_PI * 2.0f; + float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; + float x = t * two_pi + normalized_index; + float v = 0.5 * (cosf(x) + 1.0f); + return (uint8_t)(255.0f * v); +} + +bool led_backlight_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + keyframe_fade_all_leds_from_to(animation, 0, 255); + return true; +} + +bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + keyframe_fade_all_leds_from_to(animation, 255, 0); + return true; +} + +bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + float frame_length = animation->frame_lengths[animation->current_frame]; + float current_pos = frame_length - animation->time_left_in_frame; + float t = current_pos / frame_length; + for (int i=0; i< NUM_COLS; i++) { + uint8_t color = compute_gradient_color(t, i, NUM_COLS); + gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); + } + return true; +} + +bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { + (void)state; + float frame_length = animation->frame_lengths[animation->current_frame]; + float current_pos = frame_length - animation->time_left_in_frame; + float t = current_pos / frame_length; + for (int i=0; i< NUM_ROWS; i++) { + uint8_t color = compute_gradient_color(t, i, NUM_ROWS); + gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color)); + } + return true; +} + +static void copy_current_led_state(uint8_t* dest) { + for (int i=0;ifirst_update_of_frame) { + copy_current_led_state(&crossfade_start_frame[0][0]); + run_next_keyframe(animation, state); + copy_current_led_state(&crossfade_end_frame[0][0]); + } + for (int i=0;iframe_lengths[animation->current_frame]; - int current_pos = frame_length - animation->time_left_in_frame; - int delta = to - from; - int luma = (delta * current_pos) / frame_length; - luma += from; - return luma; -} - -static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) { - uint8_t luma = fade_led_color(animation, from, to); - color_t color = LUMA2COLOR(luma); - gdispGClear(LED_DISPLAY, color); -} - -// TODO: Should be customizable per keyboard -#define NUM_ROWS LED_NUM_ROWS -#define NUM_COLS LED_NUM_COLS - -static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; -static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; - -static uint8_t compute_gradient_color(float t, float index, float num) { - const float two_pi = M_PI * 2.0f; - float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; - float x = t * two_pi + normalized_index; - float v = 0.5 * (cosf(x) + 1.0f); - return (uint8_t)(255.0f * v); -} - -bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state) { - (void)state; - keyframe_fade_all_leds_from_to(animation, 0, 255); - return true; -} - -bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state) { - (void)state; - keyframe_fade_all_leds_from_to(animation, 255, 0); - return true; -} - -bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { - (void)state; - float frame_length = animation->frame_lengths[animation->current_frame]; - float current_pos = frame_length - animation->time_left_in_frame; - float t = current_pos / frame_length; - for (int i=0; i< NUM_COLS; i++) { - uint8_t color = compute_gradient_color(t, i, NUM_COLS); - gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); - } - return true; -} - -bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { - (void)state; - float frame_length = animation->frame_lengths[animation->current_frame]; - float current_pos = frame_length - animation->time_left_in_frame; - float t = current_pos / frame_length; - for (int i=0; i< NUM_ROWS; i++) { - uint8_t color = compute_gradient_color(t, i, NUM_ROWS); - gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color)); - } - return true; -} - -static void copy_current_led_state(uint8_t* dest) { - for (int i=0;ifirst_update_of_frame) { - copy_current_led_state(&crossfade_start_frame[0][0]); - run_next_keyframe(animation, state); - copy_current_led_state(&crossfade_end_frame[0][0]); - } - for (int i=0;i. - */ - -#if defined(VISUALIZER_ENABLE) - -#include "animations.h" -#include "visualizer.h" -#ifdef LCD_ENABLE -#include "lcd_keyframes.h" -#endif -#ifdef LCD_BACKLIGHT_ENABLE -#include "lcd_backlight_keyframes.h" -#endif - -#ifdef BACKLIGHT_ENABLE -#include "led_backlight_keyframes.h" -#endif - -#include "visualizer_keyframes.h" - - -#if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) - -static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { -#ifdef LCD_ENABLE - lcd_keyframe_enable(animation, state); -#endif -#ifdef LCD_BACKLIGHT_ENABLE - lcd_backlight_keyframe_enable(animation, state); -#endif -#ifdef BACKLIGHT_ENABLE - led_backlight_keyframe_enable(animation, state); -#endif - return false; -} - -static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { -#ifdef LCD_ENABLE - lcd_keyframe_disable(animation, state); -#endif -#ifdef LCD_BACKLIGHT_ENABLE - lcd_backlight_keyframe_disable(animation, state); -#endif -#ifdef BACKLIGHT_ENABLE - led_backlight_keyframe_disable(animation, state); -#endif - return false; -} - -static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { - bool ret = false; -#ifdef LCD_BACKLIGHT_ENABLE - ret |= lcd_backlight_keyframe_animate_color(animation, state); -#endif -#ifdef BACKLIGHT_ENABLE - ret |= led_backlight_keyframe_fade_in_all(animation, state); -#endif - return ret; -} - -static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { - bool ret = false; -#ifdef LCD_BACKLIGHT_ENABLE - ret |= lcd_backlight_keyframe_animate_color(animation, state); -#endif -#ifdef BACKLIGHT_ENABLE - ret |= led_backlight_keyframe_fade_out_all(animation, state); -#endif - return ret; -} - - -// Don't worry, if the startup animation is long, you can use the keyboard like normal -// during that time -keyframe_animation_t default_startup_animation = { - .num_frames = 3, - .loop = false, - .frame_lengths = {0, 0, gfxMillisecondsToTicks(5000)}, - .frame_functions = { - keyframe_enable, - lcd_keyframe_draw_logo, - keyframe_fade_in, - }, -}; - -keyframe_animation_t default_suspend_animation = { - .num_frames = 3, - .loop = false, - .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0}, - .frame_functions = { - lcd_keyframe_display_layer_text, - keyframe_fade_out, - keyframe_disable, - }, -}; -#endif - -#if defined(BACKLIGHT_ENABLE) -#define CROSSFADE_TIME 1000 -#define GRADIENT_TIME 3000 - -keyframe_animation_t led_test_animation = { - .num_frames = 14, - .loop = true, - .frame_lengths = { - gfxMillisecondsToTicks(1000), // fade in - gfxMillisecondsToTicks(1000), // no op (leds on) - gfxMillisecondsToTicks(1000), // fade out - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom - 0, // mirror leds - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom - 0, // normal leds - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - - }, - .frame_functions = { - led_backlight_keyframe_fade_in_all, - keyframe_no_operation, - led_backlight_keyframe_fade_out_all, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_left_to_right_gradient, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_top_to_bottom_gradient, - led_backlight_keyframe_mirror_orientation, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_left_to_right_gradient, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_top_to_bottom_gradient, - led_backlight_keyframe_normal_orientation, - led_backlight_keyframe_crossfade, - }, -}; -#endif - -#endif diff --git a/keyboards/ergodox/infinity/animations.h b/keyboards/ergodox/infinity/animations.h deleted file mode 100644 index 6d8b9830d..000000000 --- a/keyboards/ergodox/infinity/animations.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ -#define KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ - -#include "visualizer.h" - -// You can use these default animations, but of course you can also write your own custom ones instead -extern keyframe_animation_t default_startup_animation; -extern keyframe_animation_t default_suspend_animation; - -// An animation for testing and demonstrating the led support, should probably not be used for real world -// cases -extern keyframe_animation_t led_test_animation; - -#endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */ diff --git a/keyboards/ergodox/infinity/rules.mk b/keyboards/ergodox/infinity/rules.mk index 18171560d..2ccf98b8c 100644 --- a/keyboards/ergodox/infinity/rules.mk +++ b/keyboards/ergodox/infinity/rules.mk @@ -1,7 +1,6 @@ # project specific files SRC = matrix.c \ - led.c \ - animations.c + led.c ## chip/board settings # - the next two should match the directories in diff --git a/keyboards/ergodox/infinity/simple_visualizer.h b/keyboards/ergodox/infinity/simple_visualizer.h index 88e96f2af..73d0e0887 100644 --- a/keyboards/ergodox/infinity/simple_visualizer.h +++ b/keyboards/ergodox/infinity/simple_visualizer.h @@ -34,7 +34,7 @@ #include "lcd_backlight_keyframes.h" #include "system/serial_link.h" #include "led.h" -#include "animations.h" +#include "default_animations.h" static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); static const uint32_t initial_color = LCD_COLOR(0, 0, 0); diff --git a/keyboards/ergodox/infinity/visualizer.c b/keyboards/ergodox/infinity/visualizer.c index 047a1119c..4b16021ab 100644 --- a/keyboards/ergodox/infinity/visualizer.c +++ b/keyboards/ergodox/infinity/visualizer.c @@ -31,7 +31,7 @@ along with this program. If not, see . #include "lcd_keyframes.h" #include "lcd_backlight_keyframes.h" #include "system/serial_link.h" -#include "animations.h" +#include "default_animations.h" static const uint32_t logo_background_color = LCD_COLOR(0x00, 0x00, 0xFF); static const uint32_t initial_color = LCD_COLOR(0, 0, 0); diff --git a/keyboards/whitefox/animations.c b/keyboards/whitefox/animations.c deleted file mode 100644 index a15d46ccd..000000000 --- a/keyboards/whitefox/animations.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#if defined(VISUALIZER_ENABLE) - -#include "animations.h" -#include "visualizer.h" - -#ifdef BACKLIGHT_ENABLE -#include "led_backlight_keyframes.h" -#endif - -#include "visualizer_keyframes.h" - - -#if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) - -static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { -#ifdef BACKLIGHT_ENABLE - led_backlight_keyframe_enable(animation, state); -#endif - return false; -} - -static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { -#ifdef BACKLIGHT_ENABLE - led_backlight_keyframe_disable(animation, state); -#endif - return false; -} - -static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { - bool ret = false; -#ifdef BACKLIGHT_ENABLE - ret |= led_backlight_keyframe_fade_in_all(animation, state); -#endif - return ret; -} - -static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { - bool ret = false; -#ifdef BACKLIGHT_ENABLE - ret |= led_backlight_keyframe_fade_out_all(animation, state); -#endif - return ret; -} - - -// Don't worry, if the startup animation is long, you can use the keyboard like normal -// during that time -keyframe_animation_t default_startup_animation = { - .num_frames = 2, - .loop = false, - .frame_lengths = {0, gfxMillisecondsToTicks(5000)}, - .frame_functions = { - keyframe_enable, - keyframe_fade_in, - }, -}; - -keyframe_animation_t default_suspend_animation = { - .num_frames = 2, - .loop = false, - .frame_lengths = {gfxMillisecondsToTicks(1000), 0}, - .frame_functions = { - keyframe_fade_out, - keyframe_disable, - }, -}; -#endif - -#if defined(BACKLIGHT_ENABLE) -#define CROSSFADE_TIME 1000 -#define GRADIENT_TIME 3000 - -keyframe_animation_t led_test_animation = { - .num_frames = 14, - .loop = true, - .frame_lengths = { - gfxMillisecondsToTicks(1000), // fade in - gfxMillisecondsToTicks(1000), // no op (leds on) - gfxMillisecondsToTicks(1000), // fade out - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom - 0, // mirror leds - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom - 0, // normal leds - gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade - - }, - .frame_functions = { - led_backlight_keyframe_fade_in_all, - keyframe_no_operation, - led_backlight_keyframe_fade_out_all, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_left_to_right_gradient, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_top_to_bottom_gradient, - led_backlight_keyframe_mirror_orientation, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_left_to_right_gradient, - led_backlight_keyframe_crossfade, - led_backlight_keyframe_top_to_bottom_gradient, - led_backlight_keyframe_normal_orientation, - led_backlight_keyframe_crossfade, - }, -}; -#endif - -#endif diff --git a/keyboards/whitefox/animations.h b/keyboards/whitefox/animations.h deleted file mode 100644 index 6d8b9830d..000000000 --- a/keyboards/whitefox/animations.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ -#define KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ - -#include "visualizer.h" - -// You can use these default animations, but of course you can also write your own custom ones instead -extern keyframe_animation_t default_startup_animation; -extern keyframe_animation_t default_suspend_animation; - -// An animation for testing and demonstrating the led support, should probably not be used for real world -// cases -extern keyframe_animation_t led_test_animation; - -#endif /* KEYBOARDS_ERGODOX_INFINITY_ANIMATIONS_H_ */ diff --git a/keyboards/whitefox/rules.mk b/keyboards/whitefox/rules.mk index c0effcb7b..391148071 100644 --- a/keyboards/whitefox/rules.mk +++ b/keyboards/whitefox/rules.mk @@ -1,7 +1,6 @@ # project specific files SRC = matrix.c \ - led.c \ - animations.c + led.c ## chip/board settings # - the next two should match the directories in diff --git a/keyboards/whitefox/visualizer.c b/keyboards/whitefox/visualizer.c index 167e0ec4d..e5bafcbe9 100644 --- a/keyboards/whitefox/visualizer.c +++ b/keyboards/whitefox/visualizer.c @@ -20,7 +20,7 @@ #include "visualizer.h" #include "visualizer_keyframes.h" #include "led.h" -#include "animations.h" +#include "default_animations.h" static bool initial_update = true; diff --git a/quantum/visualizer/default_animations.c b/quantum/visualizer/default_animations.c new file mode 100644 index 000000000..2d0327372 --- /dev/null +++ b/quantum/visualizer/default_animations.c @@ -0,0 +1,176 @@ +/* Copyright 2017 Fred Sundvik + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#if defined(VISUALIZER_ENABLE) + +#include "default_animations.h" +#include "visualizer.h" +#ifdef LCD_ENABLE +#include "lcd_keyframes.h" +#endif +#ifdef LCD_BACKLIGHT_ENABLE +#include "lcd_backlight_keyframes.h" +#endif + +#ifdef BACKLIGHT_ENABLE +#include "led_backlight_keyframes.h" +#endif + +#include "visualizer_keyframes.h" + + +#if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) + +static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { +#ifdef LCD_ENABLE + lcd_keyframe_enable(animation, state); +#endif +#ifdef LCD_BACKLIGHT_ENABLE + lcd_backlight_keyframe_enable(animation, state); +#endif +#ifdef BACKLIGHT_ENABLE + led_backlight_keyframe_enable(animation, state); +#endif + return false; +} + +static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { +#ifdef LCD_ENABLE + lcd_keyframe_disable(animation, state); +#endif +#ifdef LCD_BACKLIGHT_ENABLE + lcd_backlight_keyframe_disable(animation, state); +#endif +#ifdef BACKLIGHT_ENABLE + led_backlight_keyframe_disable(animation, state); +#endif + return false; +} + +static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { + bool ret = false; +#ifdef LCD_BACKLIGHT_ENABLE + ret |= lcd_backlight_keyframe_animate_color(animation, state); +#endif +#ifdef BACKLIGHT_ENABLE + ret |= led_backlight_keyframe_fade_in_all(animation, state); +#endif + return ret; +} + +static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { + bool ret = false; +#ifdef LCD_BACKLIGHT_ENABLE + ret |= lcd_backlight_keyframe_animate_color(animation, state); +#endif +#ifdef BACKLIGHT_ENABLE + ret |= led_backlight_keyframe_fade_out_all(animation, state); +#endif + return ret; +} + + +// Don't worry, if the startup animation is long, you can use the keyboard like normal +// during that time +keyframe_animation_t default_startup_animation = { +#if LCD_ENABLE + .num_frames = 3, +#else + .num_frames = 2, +#endif + .loop = false, + .frame_lengths = { + 0, +#if LCD_ENABLE + 0, +#endif + gfxMillisecondsToTicks(5000)}, + .frame_functions = { + keyframe_enable, +#if LCD_ENABLE + lcd_keyframe_draw_logo, +#endif + keyframe_fade_in, + }, +}; + +keyframe_animation_t default_suspend_animation = { +#if LCD_ENABLE + .num_frames = 3, +#else + .num_frames = 2, +#endif + .loop = false, + .frame_lengths = { +#if LCD_ENABLE + 0, +#endif + gfxMillisecondsToTicks(1000), + 0}, + .frame_functions = { +#if LCD_ENABLE + lcd_keyframe_display_layer_text, +#endif + keyframe_fade_out, + keyframe_disable, + }, +}; +#endif + +#if defined(BACKLIGHT_ENABLE) +#define CROSSFADE_TIME 1000 +#define GRADIENT_TIME 3000 + +keyframe_animation_t led_test_animation = { + .num_frames = 14, + .loop = true, + .frame_lengths = { + gfxMillisecondsToTicks(1000), // fade in + gfxMillisecondsToTicks(1000), // no op (leds on) + gfxMillisecondsToTicks(1000), // fade out + gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade + gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) + gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade + gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom + 0, // mirror leds + gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade + gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) + gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade + gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom + 0, // normal leds + gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade + + }, + .frame_functions = { + led_backlight_keyframe_fade_in_all, + keyframe_no_operation, + led_backlight_keyframe_fade_out_all, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_left_to_right_gradient, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_top_to_bottom_gradient, + led_backlight_keyframe_mirror_orientation, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_left_to_right_gradient, + led_backlight_keyframe_crossfade, + led_backlight_keyframe_top_to_bottom_gradient, + led_backlight_keyframe_normal_orientation, + led_backlight_keyframe_crossfade, + }, +}; +#endif + +#endif diff --git a/quantum/visualizer/default_animations.h b/quantum/visualizer/default_animations.h new file mode 100644 index 000000000..51320b8b8 --- /dev/null +++ b/quantum/visualizer/default_animations.h @@ -0,0 +1,30 @@ +/* Copyright 2017 Fred Sundvik + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DEFAULT_ANIMATIONS_H_ +#define DEFAULT_ANIMATIONS_H_ + +#include "visualizer.h" + +// You can use these default animations, but of course you can also write your own custom ones instead +extern keyframe_animation_t default_startup_animation; +extern keyframe_animation_t default_suspend_animation; + +// An animation for testing and demonstrating the led support, should probably not be used for real world +// cases +extern keyframe_animation_t led_test_animation; + +#endif /* DEFAULT_ANIMATIONS_H_ */ diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index a04c9775f..3a0f771bc 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk @@ -46,6 +46,8 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c endif +SRC += $(VISUALIZER_DIR)/default_animations.c + include $(GFXLIB)/gfx.mk # For the common_gfxconf.h GFXINC += quantum/visualizer -- cgit v1.2.3 From 9d8279960d8784d5602025f6845b0af92db12848 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 9 Jul 2017 20:35:33 +0300 Subject: Make it easier to use drivers --- drivers/ugfx/gdisp/is31fl3731c/driver.mk | 1 + drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c | 12 +++----- drivers/ugfx/gdisp/st7565/driver.mk | 1 + drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c | 4 +-- keyboards/ergodox/infinity/board_IS31FL3731C.h | 3 -- keyboards/ergodox/infinity/config.h | 5 ---- keyboards/ergodox/infinity/gfxconf.h | 6 ---- keyboards/ergodox/infinity/rules.mk | 9 ++++-- keyboards/whitefox/board_IS31FL3731C.h | 3 -- keyboards/whitefox/config.h | 8 +---- keyboards/whitefox/gfxconf.h | 4 --- keyboards/whitefox/rules.mk | 4 ++- quantum/visualizer/lcd_keyframes.c | 4 +-- quantum/visualizer/led_backlight_keyframes.c | 4 +-- quantum/visualizer/visualizer.mk | 35 ++++++++++++++++++++++ 15 files changed, 58 insertions(+), 45 deletions(-) (limited to 'quantum/visualizer/visualizer.mk') diff --git a/drivers/ugfx/gdisp/is31fl3731c/driver.mk b/drivers/ugfx/gdisp/is31fl3731c/driver.mk index c9de62d1e..4364787c9 100644 --- a/drivers/ugfx/gdisp/is31fl3731c/driver.mk +++ b/drivers/ugfx/gdisp/is31fl3731c/driver.mk @@ -1,2 +1,3 @@ GFXINC += drivers/ugfx/gdisp/is31fl3731c GFXSRC += drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c +GDISP_DRIVER_LIST += GDISPVMT_IS31FL3731C_QMK \ No newline at end of file diff --git a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c b/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c index 0691dbfbf..3faddcda8 100644 --- a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c +++ b/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c @@ -19,7 +19,10 @@ along with this program. If not, see . #if GFX_USE_GDISP -#define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK +#define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK +#define GDISP_SCREEN_HEIGHT LED_HEIGHT +#define GDISP_SCREEN_WIDTH LED_WIDTH + #include "gdisp_lld_config.h" #include "src/gdisp/gdisp_driver.h" @@ -33,12 +36,6 @@ extern const uint8_t CIE1931_CURVE[]; /* Driver local definitions. */ /*===========================================================================*/ -#ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 9 -#endif -#ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 16 -#endif #ifndef GDISP_INITIAL_CONTRAST #define GDISP_INITIAL_CONTRAST 0 #endif @@ -100,7 +97,6 @@ extern const uint8_t CIE1931_CURVE[]; #define IS31_PWM_SIZE 0x90 #define IS31_LED_MASK_SIZE 0x12 -#define IS31_SCREEN_WIDTH 16 #define IS31 diff --git a/drivers/ugfx/gdisp/st7565/driver.mk b/drivers/ugfx/gdisp/st7565/driver.mk index 0190b6019..31fc8f1c7 100644 --- a/drivers/ugfx/gdisp/st7565/driver.mk +++ b/drivers/ugfx/gdisp/st7565/driver.mk @@ -1,2 +1,3 @@ GFXINC += drivers/ugfx/gdisp/st7565 GFXSRC += drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c +GDISP_DRIVER_LIST += GDISPVMT_ST7565_QMK \ No newline at end of file diff --git a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c b/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c index 55552cb79..4a4c83e89 100644 --- a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c +++ b/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c @@ -20,10 +20,10 @@ /*===========================================================================*/ #ifndef GDISP_SCREEN_HEIGHT -#define GDISP_SCREEN_HEIGHT 32 +#define GDISP_SCREEN_HEIGHT LCD_HEIGHT #endif #ifndef GDISP_SCREEN_WIDTH -#define GDISP_SCREEN_WIDTH 128 +#define GDISP_SCREEN_WIDTH LCD_WIDTH #endif #ifndef GDISP_INITIAL_CONTRAST #define GDISP_INITIAL_CONTRAST 35 diff --git a/keyboards/ergodox/infinity/board_IS31FL3731C.h b/keyboards/ergodox/infinity/board_IS31FL3731C.h index 2ea73f1fb..f248cc25b 100644 --- a/keyboards/ergodox/infinity/board_IS31FL3731C.h +++ b/keyboards/ergodox/infinity/board_IS31FL3731C.h @@ -22,9 +22,6 @@ static const I2CConfig i2ccfg = { 400000 // clock speed (Hz); 400kHz max for IS31 }; -#define GDISP_SCREEN_WIDTH 7 -#define GDISP_SCREEN_HEIGHT 7 - static const uint8_t led_mask[] = { 0xFF, 0x00, /* C1-1 -> C1-16 */ 0xFF, 0x00, /* C2-1 -> C2-16 */ diff --git a/keyboards/ergodox/infinity/config.h b/keyboards/ergodox/infinity/config.h index fa157a893..c46edeb7b 100644 --- a/keyboards/ergodox/infinity/config.h +++ b/keyboards/ergodox/infinity/config.h @@ -54,11 +54,6 @@ along with this program. If not, see . #define VISUALIZER_USER_DATA_SIZE 16 -#define LCD_DISPLAY_NUMBER 0 -#define LED_DISPLAY_NUMBER 1 - -#define LED_NUM_ROWS 7 -#define LED_NUM_COLS 7 /* * Feature disable options * These options are also useful to firmware size reduction. diff --git a/keyboards/ergodox/infinity/gfxconf.h b/keyboards/ergodox/infinity/gfxconf.h index 0d017aea9..ca338399d 100644 --- a/keyboards/ergodox/infinity/gfxconf.h +++ b/keyboards/ergodox/infinity/gfxconf.h @@ -22,12 +22,6 @@ #ifndef _GFXCONF_H #define _GFXCONF_H -#ifndef EMULATOR -#define GDISP_DRIVER_LIST GDISPVMT_ST7565_QMK, GDISPVMT_IS31FL3731C_QMK -#else -#define GDISP_DRIVER_LIST GDISPVMT_EMULATOR_LCD_ERGODOX, GDISPVMT_EMULATOR_LED_ERGODOX -#endif - #include "common_gfxconf.h" #endif /* _GFXCONF_H */ diff --git a/keyboards/ergodox/infinity/rules.mk b/keyboards/ergodox/infinity/rules.mk index 2ccf98b8c..a341bbfce 100644 --- a/keyboards/ergodox/infinity/rules.mk +++ b/keyboards/ergodox/infinity/rules.mk @@ -66,5 +66,10 @@ LCD_BACKLIGHT_ENABLE = yes MIDI_ENABLE = no RGBLIGHT_ENABLE = no -include $(TOP_DIR)/drivers/ugfx/gdisp/st7565/driver.mk -include $(TOP_DIR)/drivers/ugfx/gdisp/is31fl3731c/driver.mk \ No newline at end of file +LCD_DRIVER = st7565 +LCD_WIDTH = 128 +LCD_HEIGHT = 32 + +LED_DRIVER = is31fl3731c +LED_WIDTH = 7 +LED_HEIGHT = 7 \ No newline at end of file diff --git a/keyboards/whitefox/board_IS31FL3731C.h b/keyboards/whitefox/board_IS31FL3731C.h index 3dc5327a5..dea643f10 100644 --- a/keyboards/whitefox/board_IS31FL3731C.h +++ b/keyboards/whitefox/board_IS31FL3731C.h @@ -22,9 +22,6 @@ static const I2CConfig i2ccfg = { 400000 // clock speed (Hz); 400kHz max for IS31 }; -#define GDISP_SCREEN_WIDTH 16 -#define GDISP_SCREEN_HEIGHT 5 - static const uint8_t led_mask[] = { 0xFF, 0x00, /* C1-1 -> C1-16 */ 0xFF, 0x00, /* C2-1 -> C2-16 */ diff --git a/keyboards/whitefox/config.h b/keyboards/whitefox/config.h index 76040bd74..dc33a7ce5 100644 --- a/keyboards/whitefox/config.h +++ b/keyboards/whitefox/config.h @@ -81,10 +81,4 @@ along with this program. If not, see . //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION -#endif - -// The visualizer needs gfx thread priorities -#define LED_DISPLAY_NUMBER 0 - -#define LED_NUM_ROWS 5 -#define LED_NUM_COLS 16 \ No newline at end of file +#endif \ No newline at end of file diff --git a/keyboards/whitefox/gfxconf.h b/keyboards/whitefox/gfxconf.h index eb93f92eb..ca338399d 100644 --- a/keyboards/whitefox/gfxconf.h +++ b/keyboards/whitefox/gfxconf.h @@ -22,10 +22,6 @@ #ifndef _GFXCONF_H #define _GFXCONF_H -#ifndef EMULATOR -#define GDISP_DRIVER_LIST GDISPVMT_IS31FL3731C_QMK -#endif - #include "common_gfxconf.h" #endif /* _GFXCONF_H */ diff --git a/keyboards/whitefox/rules.mk b/keyboards/whitefox/rules.mk index 391148071..32273e08a 100644 --- a/keyboards/whitefox/rules.mk +++ b/keyboards/whitefox/rules.mk @@ -69,4 +69,6 @@ CUSTOM_MATRIX = yes # Custom matrix file BACKLIGHT_ENABLE = yes VISUALIZER_ENABLE = yes -include $(TOP_DIR)/drivers/ugfx/gdisp/is31fl3731c/driver.mk +LED_DRIVER = is31fl3731c +LED_WIDTH = 16 +LED_HEIGHT = 5 \ No newline at end of file diff --git a/quantum/visualizer/lcd_keyframes.c b/quantum/visualizer/lcd_keyframes.c index 82e4184d2..75eb45700 100644 --- a/quantum/visualizer/lcd_keyframes.c +++ b/quantum/visualizer/lcd_keyframes.c @@ -166,8 +166,8 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t* // or state structs, here we use the image //gdispGBlitArea is a tricky function to use since it supports blitting part of the image - // if you have full screen image, then just use 128 and 32 for both source and target dimensions - gdispGBlitArea(GDISP, 0, 0, 128, 32, 0, 0, 128, (pixel_t*)resource_lcd_logo); + // if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions + gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo); return false; } diff --git a/quantum/visualizer/led_backlight_keyframes.c b/quantum/visualizer/led_backlight_keyframes.c index d2921a391..eb3f5561d 100644 --- a/quantum/visualizer/led_backlight_keyframes.c +++ b/quantum/visualizer/led_backlight_keyframes.c @@ -41,8 +41,8 @@ static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint } // TODO: Should be customizable per keyboard -#define NUM_ROWS LED_NUM_ROWS -#define NUM_COLS LED_NUM_COLS +#define NUM_ROWS LED_HEIGHT +#define NUM_COLS LED_WIDTH static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk index 3a0f771bc..102d23b7e 100644 --- a/quantum/visualizer/visualizer.mk +++ b/quantum/visualizer/visualizer.mk @@ -20,6 +20,30 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +define ADD_DRIVER + $(1)_DRIVER:=$(strip $($(1)_DRIVER)) + $(1)_WIDTH:=$(strip $($(1)_WIDTH)) + $(1)_HEIGHT:=$(strip $($(1)_HEIGHT)) + ifeq ($($(1)_DRIVER),) + $$(error $(1)_DRIVER is not defined) + endif + ifeq ($($(1)_WIDTH),) + $$(error $(1)_WIDTH is not defined) + endif + ifeq ($($(1)_HEIGHT),) + $$(error $(1)_HEIGHT is not defined) + endif + OPT_DEFS+=-D$(1)_WIDTH=$($(1)_WIDTH) + OPT_DEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT) + GFXDEFS+=-D$(1)_WIDTH=$($(1)_WIDTH) + GFXDEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT) + $(1)_DISPLAY_NUMBER:=$$(words $$(GDISP_DRIVER_LIST)) + OPT_DEFS+=-D$(1)_DISPLAY_NUMBER=$$($(1)_DISPLAY_NUMBER) + include $(TOP_DIR)/drivers/ugfx/gdisp/$($(1)_DRIVER)/driver.mk +endef + +GDISP_DRIVER_LIST:= + SRC += $(VISUALIZER_DIR)/visualizer.c \ $(VISUALIZER_DIR)/visualizer_keyframes.c EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR) @@ -40,10 +64,12 @@ SRC += $(VISUALIZER_DIR)/lcd_backlight_keyframes.c # Note, that the linker will strip out any resources that are not actually in use SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c OPT_DEFS += -DLCD_BACKLIGHT_ENABLE +$(eval $(call ADD_DRIVER,LCD)) endif ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c +$(eval $(call ADD_DRIVER,LED)) endif SRC += $(VISUALIZER_DIR)/default_animations.c @@ -55,6 +81,15 @@ GFXINC += quantum/visualizer GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC)) GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) +GDISP_LIST_COMMA=, +GDISP_LIST_EMPTY= +GDISP_LIST_SPACE=$(GDISP_LIST_EMPTY) $(GDISP_LIST_EMPTY) + +GDISP_DRIVER_LIST := $(strip $(GDISP_DRIVER_LIST)) +GDISP_DRIVER_LIST := $(subst $(GDISP_LIST_SPACE),$(GDISP_LIST_COMMA),$(GDISP_DRIVER_LIST)) + +GFXDEFS +=-DGDISP_DRIVER_LIST="$(GDISP_DRIVER_LIST)" + ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","") SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c else -- cgit v1.2.3