aboutsummaryrefslogtreecommitdiff
path: root/quantum/visualizer
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/visualizer')
-rw-r--r--quantum/visualizer/led_test.c4
-rw-r--r--quantum/visualizer/visualizer.c14
-rw-r--r--quantum/visualizer/visualizer.h2
-rw-r--r--quantum/visualizer/visualizer.mk36
4 files changed, 25 insertions, 31 deletions
diff --git a/quantum/visualizer/led_test.c b/quantum/visualizer/led_test.c
index c2ea30b55..a9abace8d 100644
--- a/quantum/visualizer/led_test.c
+++ b/quantum/visualizer/led_test.c
@@ -89,8 +89,8 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
89static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; 89static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
90 90
91static uint8_t compute_gradient_color(float t, float index, float num) { 91static uint8_t compute_gradient_color(float t, float index, float num) {
92 const float two_pi = 2.0f * PI; 92 const float two_pi = M_2_PI;
93 float normalized_index = (1.0f - index / (num - 1)) * two_pi; 93 float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi;
94 float x = t * two_pi + normalized_index; 94 float x = t * two_pi + normalized_index;
95 float v = 0.5 * (cosf(x) + 1.0f); 95 float v = 0.5 * (cosf(x) + 1.0f);
96 return (uint8_t)(255.0f * v); 96 return (uint8_t)(255.0f * v);
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index c24073405..54f6faaa4 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -29,9 +29,7 @@ SOFTWARE.
29#include "ch.h" 29#include "ch.h"
30#endif 30#endif
31 31
32#ifdef LCD_ENABLE
33#include "gfx.h" 32#include "gfx.h"
34#endif
35 33
36#ifdef LCD_BACKLIGHT_ENABLE 34#ifdef LCD_BACKLIGHT_ENABLE
37#include "lcd_backlight.h" 35#include "lcd_backlight.h"
@@ -45,7 +43,7 @@ SOFTWARE.
45#include "nodebug.h" 43#include "nodebug.h"
46#endif 44#endif
47 45
48#ifdef USE_SERIAL_LINK 46#ifdef SERIAL_LINK_ENABLE
49#include "serial_link/protocol/transport.h" 47#include "serial_link/protocol/transport.h"
50#include "serial_link/system/serial_link.h" 48#include "serial_link/system/serial_link.h"
51#endif 49#endif
@@ -75,7 +73,7 @@ static bool visualizer_enabled = false;
75#define MAX_SIMULTANEOUS_ANIMATIONS 4 73#define MAX_SIMULTANEOUS_ANIMATIONS 4
76static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {}; 74static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {};
77 75
78#ifdef USE_SERIAL_LINK 76#ifdef SERIAL_LINK_ENABLE
79MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t); 77MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t);
80 78
81static remote_object_t* remote_objects[] = { 79static remote_object_t* remote_objects[] = {
@@ -458,15 +456,13 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
458} 456}
459 457
460void visualizer_init(void) { 458void visualizer_init(void) {
461#ifdef LCD_ENABLE
462 gfxInit(); 459 gfxInit();
463#endif
464 460
465#ifdef LCD_BACKLIGHT_ENABLE 461#ifdef LCD_BACKLIGHT_ENABLE
466 lcd_backlight_init(); 462 lcd_backlight_init();
467#endif 463#endif
468 464
469#ifdef USE_SERIAL_LINK 465#ifdef SERIAL_LINK_ENABLE
470 add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) ); 466 add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) );
471#endif 467#endif
472 468
@@ -490,7 +486,7 @@ void update_status(bool changed) {
490 geventSendEvent(listener); 486 geventSendEvent(listener);
491 } 487 }
492 } 488 }
493#ifdef USE_SERIAL_LINK 489#ifdef SERIAL_LINK_ENABLE
494 static systime_t last_update = 0; 490 static systime_t last_update = 0;
495 systime_t current_update = chVTGetSystemTimeX(); 491 systime_t current_update = chVTGetSystemTimeX();
496 systime_t delta = current_update - last_update; 492 systime_t delta = current_update - last_update;
@@ -510,7 +506,7 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
510 // Alternatively a mutex could be used instead of the volatile variables 506 // Alternatively a mutex could be used instead of the volatile variables
511 507
512 bool changed = false; 508 bool changed = false;
513#ifdef USE_SERIAL_LINK 509#ifdef SERIAL_LINK_ENABLE
514 if (is_serial_link_connected ()) { 510 if (is_serial_link_connected ()) {
515 visualizer_keyboard_status_t* new_status = read_current_status(); 511 visualizer_keyboard_status_t* new_status = read_current_status();
516 if (new_status) { 512 if (new_status) {
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h
index 45cfa9aa9..53e250725 100644
--- a/quantum/visualizer/visualizer.h
+++ b/quantum/visualizer/visualizer.h
@@ -28,9 +28,7 @@ SOFTWARE.
28#include <stdint.h> 28#include <stdint.h>
29#include <stdbool.h> 29#include <stdbool.h>
30 30
31#ifdef LCD_ENABLE
32#include "gfx.h" 31#include "gfx.h"
33#endif
34 32
35#ifdef LCD_BACKLIGHT_ENABLE 33#ifdef LCD_BACKLIGHT_ENABLE
36#include "lcd_backlight.h" 34#include "lcd_backlight.h"
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk
index 56525ffd9..2f4a41d66 100644
--- a/quantum/visualizer/visualizer.mk
+++ b/quantum/visualizer/visualizer.mk
@@ -20,41 +20,41 @@
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE. 21# SOFTWARE.
22 22
23GFXLIB = $(VISUALIZER_DIR)/ugfx
24SRC += $(VISUALIZER_DIR)/visualizer.c 23SRC += $(VISUALIZER_DIR)/visualizer.c
25UINCDIR += $(GFXINC) $(VISUALIZER_DIR) 24EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
25GFXLIB = $(LIB_PATH)/ugfx
26VPATH += $(VISUALIZER_PATH)
27
28OPT_DEFS += -DVISUALIZER_ENABLE
26 29
27ifdef LCD_ENABLE 30ifdef LCD_ENABLE
28UDEFS += -DLCD_ENABLE 31OPT_DEFS += -DLCD_ENABLE
29ULIBS += -lm 32ULIBS += -lm
30USE_UGFX = yes
31endif 33endif
32 34
33ifdef LCD_BACKLIGHT_ENABLE 35ifdef LCD_BACKLIGHT_ENABLE
34SRC += $(VISUALIZER_DIR)/lcd_backlight.c 36SRC += $(VISUALIZER_DIR)/lcd_backlight.c
35ifndef EMULATOR 37OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
36SRC += lcd_backlight_hal.c
37endif
38UDEFS += -DLCD_BACKLIGHT_ENABLE
39endif 38endif
40 39
41ifdef LED_ENABLE 40ifdef LED_ENABLE
42SRC += $(VISUALIZER_DIR)/led_test.c 41SRC += $(VISUALIZER_DIR)/led_test.c
43UDEFS += -DLED_ENABLE 42OPT_DEFS += -DLED_ENABLE
44USE_UGFX = yes
45endif 43endif
46 44
47ifdef USE_UGFX
48include $(GFXLIB)/gfx.mk 45include $(GFXLIB)/gfx.mk
49SRC += $(GFXSRC) 46SRC += $(patsubst $(TOP_DIR)/%,%,$(GFXSRC))
50UDEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) 47OPT_DEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
51ULIBS += $(patsubst %,-l%,$(patsubst -l%,%,$(GFXLIBS)))
52endif
53 48
54ifndef VISUALIZER_USER 49ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","")
55VISUALIZER_USER = visualizer_user.c 50 SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c
51else
52 ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/visualizer.c)","")
53$(error "$(KEYMAP_PATH)/visualizer.c" does not exist)
54 else
55 SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/visualizer.c
56 endif
56endif 57endif
57SRC += $(VISUALIZER_USER)
58 58
59ifdef EMULATOR 59ifdef EMULATOR
60UINCDIR += $(TMK_DIR)/common 60UINCDIR += $(TMK_DIR)/common