]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Clarify naming between LCD_BACKLIGHT and LED_BACKLIGHT
authorFred Sundvik <fsundvik@gmail.com>
Sun, 9 Jul 2017 14:46:51 +0000 (17:46 +0300)
committerJack Humbert <jack.humb@gmail.com>
Mon, 10 Jul 2017 13:01:59 +0000 (09:01 -0400)
12 files changed:
keyboards/ergodox/infinity/animations.c
keyboards/ergodox/infinity/simple_visualizer.h
keyboards/ergodox/infinity/visualizer.c
keyboards/whitefox/animations.c
lcd_backlight_keyframes.h [new file with mode: 0644]
quantum/visualizer/lcd_backlight_keyframes.c
quantum/visualizer/lcd_backlight_keyframes.h [deleted file]
quantum/visualizer/led_backlight_keyframes.c [new file with mode: 0644]
quantum/visualizer/led_backlight_keyframes.h [new file with mode: 0644]
quantum/visualizer/led_keyframes.c [deleted file]
quantum/visualizer/led_keyframes.h [deleted file]
quantum/visualizer/visualizer.mk

index ebc08fde360d0c0ae850b59b81af7f3a4c4a28b8..faac96215a86a2abb526edcb0e0f7b101f167fd1 100644 (file)
@@ -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
index ded8a3222efa012c0c0a9f4269c3225335303a41..88e96f2af92181c8db5098193cce84ae91c9c2a5 100644 (file)
@@ -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) {
index 5b6b320074250e68943e01e8a272bcf9659ff67a..047a1119ceee2b8a2b22f03deeb4bfab5df1e88e 100644 (file)
@@ -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
index ed1d75efb8ea778200f78c54a044143913d648dc..a15d46ccdab9ce3175c42c69dc7393587e073814 100644 (file)
@@ -20,7 +20,7 @@
 #include "visualizer.h"
 
 #ifdef BACKLIGHT_ENABLE
-#include "led_keyframes.h"
+#include "led_backlight_keyframes.h"
 #endif
 
 #include "visualizer_keyframes.h"
 
 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 (file)
index 0000000..bde1184
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+
+#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_ */
index 8436d4e3ddae21a727279c995e25ed1fde74c525..8c402baf6ca772d47e0d009aed49e727ed071fc6 100644 (file)
@@ -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 (file)
index e1c125c..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-
-#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 (file)
index 0000000..d2921a3
--- /dev/null
@@ -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;i<NUM_ROWS;i++) {
+        for (int j=0;j<NUM_COLS;j++) {
+            dest[i*NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i);
+        }
+    }
+}
+bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) {
+    (void)state;
+    if (animation->first_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<NUM_ROWS;i++) {
+        for (int j=0;j<NUM_COLS;j++) {
+            color_t color  = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j]));
+            gdispGDrawPixel(LED_DISPLAY, j, i, color);
+        }
+    }
+    return true;
+}
+
+bool led_backlight_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
+    (void)state;
+    (void)animation;
+    gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180);
+    return false;
+}
+
+bool led_backlight_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
+    (void)state;
+    (void)animation;
+    gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0);
+    return false;
+}
+
+bool led_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
+    (void)state;
+    (void)animation;
+    gdispGSetPowerMode(LED_DISPLAY, powerOff);
+    return false;
+}
+
+bool led_backlight_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_backlight_keyframes.h b/quantum/visualizer/led_backlight_keyframes.h
new file mode 100644 (file)
index 0000000..4871510
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+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.
+*/
+
+#ifndef LED_BACKLIGHT_KEYFRAMES_H
+#define LED_BACKLIGHT_KEYFRAMES_H
+
+#include "visualizer.h"
+
+bool led_backlight_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state);
+bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state);
+bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
+bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
+bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state);
+bool led_backlight_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
+bool led_backlight_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
+
+bool led_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state);
+bool led_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state);
+
+extern keyframe_animation_t led_test_animation;
+
+
+#endif /* LED_KEYFRAMES_H */
diff --git a/quantum/visualizer/led_keyframes.c b/quantum/visualizer/led_keyframes.c
deleted file mode 100644 (file)
index 7e6e5d1..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-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_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_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;i<NUM_ROWS;i++) {
-        for (int j=0;j<NUM_COLS;j++) {
-            dest[i*NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i);
-        }
-    }
-}
-bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) {
-    (void)state;
-    if (animation->first_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<NUM_ROWS;i++) {
-        for (int j=0;j<NUM_COLS;j++) {
-            color_t color  = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j]));
-            gdispGDrawPixel(LED_DISPLAY, j, i, color);
-        }
-    }
-    return true;
-}
-
-bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
-    (void)state;
-    (void)animation;
-    gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180);
-    return false;
-}
-
-bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
-    (void)state;
-    (void)animation;
-    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
deleted file mode 100644 (file)
index a59a4f3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-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.
-*/
-
-#ifndef LED_KEYFRAMES_H
-#define LED_KEYFRAMES_H
-
-#include "visualizer.h"
-
-bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state);
-bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state);
-bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
-bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
-bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state);
-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;
-
-
-#endif /* LED_KEYFRAMES_H */
index 1fe7435d9759e174e0fe6f19cde06d1c7a585004..a04c9775fa859052917cbb4989cf227291fbfed9 100644 (file)
@@ -43,7 +43,7 @@ OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
 endif
 
 ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
-SRC += $(VISUALIZER_DIR)/led_keyframes.c
+SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c
 endif
 
 include $(GFXLIB)/gfx.mk