diff options
Diffstat (limited to 'quantum/visualizer')
| -rw-r--r-- | quantum/visualizer/led_test.c | 4 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.c | 14 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.h | 2 | ||||
| -rw-r--r-- | quantum/visualizer/visualizer.mk | 36 |
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]; | |||
| 89 | static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; | 89 | static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; |
| 90 | 90 | ||
| 91 | static uint8_t compute_gradient_color(float t, float index, float num) { | 91 | static 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 |
| 76 | static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {}; | 74 | static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {}; |
| 77 | 75 | ||
| 78 | #ifdef USE_SERIAL_LINK | 76 | #ifdef SERIAL_LINK_ENABLE |
| 79 | MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t); | 77 | MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t); |
| 80 | 78 | ||
| 81 | static remote_object_t* remote_objects[] = { | 79 | static remote_object_t* remote_objects[] = { |
| @@ -458,15 +456,13 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 458 | } | 456 | } |
| 459 | 457 | ||
| 460 | void visualizer_init(void) { | 458 | void 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 | ||
| 23 | GFXLIB = $(VISUALIZER_DIR)/ugfx | ||
| 24 | SRC += $(VISUALIZER_DIR)/visualizer.c | 23 | SRC += $(VISUALIZER_DIR)/visualizer.c |
| 25 | UINCDIR += $(GFXINC) $(VISUALIZER_DIR) | 24 | EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR) |
| 25 | GFXLIB = $(LIB_PATH)/ugfx | ||
| 26 | VPATH += $(VISUALIZER_PATH) | ||
| 27 | |||
| 28 | OPT_DEFS += -DVISUALIZER_ENABLE | ||
| 26 | 29 | ||
| 27 | ifdef LCD_ENABLE | 30 | ifdef LCD_ENABLE |
| 28 | UDEFS += -DLCD_ENABLE | 31 | OPT_DEFS += -DLCD_ENABLE |
| 29 | ULIBS += -lm | 32 | ULIBS += -lm |
| 30 | USE_UGFX = yes | ||
| 31 | endif | 33 | endif |
| 32 | 34 | ||
| 33 | ifdef LCD_BACKLIGHT_ENABLE | 35 | ifdef LCD_BACKLIGHT_ENABLE |
| 34 | SRC += $(VISUALIZER_DIR)/lcd_backlight.c | 36 | SRC += $(VISUALIZER_DIR)/lcd_backlight.c |
| 35 | ifndef EMULATOR | 37 | OPT_DEFS += -DLCD_BACKLIGHT_ENABLE |
| 36 | SRC += lcd_backlight_hal.c | ||
| 37 | endif | ||
| 38 | UDEFS += -DLCD_BACKLIGHT_ENABLE | ||
| 39 | endif | 38 | endif |
| 40 | 39 | ||
| 41 | ifdef LED_ENABLE | 40 | ifdef LED_ENABLE |
| 42 | SRC += $(VISUALIZER_DIR)/led_test.c | 41 | SRC += $(VISUALIZER_DIR)/led_test.c |
| 43 | UDEFS += -DLED_ENABLE | 42 | OPT_DEFS += -DLED_ENABLE |
| 44 | USE_UGFX = yes | ||
| 45 | endif | 43 | endif |
| 46 | 44 | ||
| 47 | ifdef USE_UGFX | ||
| 48 | include $(GFXLIB)/gfx.mk | 45 | include $(GFXLIB)/gfx.mk |
| 49 | SRC += $(GFXSRC) | 46 | SRC += $(patsubst $(TOP_DIR)/%,%,$(GFXSRC)) |
| 50 | UDEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) | 47 | OPT_DEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) |
| 51 | ULIBS += $(patsubst %,-l%,$(patsubst -l%,%,$(GFXLIBS))) | ||
| 52 | endif | ||
| 53 | 48 | ||
| 54 | ifndef VISUALIZER_USER | 49 | ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","") |
| 55 | VISUALIZER_USER = visualizer_user.c | 50 | SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c |
| 51 | else | ||
| 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 | ||
| 56 | endif | 57 | endif |
| 57 | SRC += $(VISUALIZER_USER) | ||
| 58 | 58 | ||
| 59 | ifdef EMULATOR | 59 | ifdef EMULATOR |
| 60 | UINCDIR += $(TMK_DIR)/common | 60 | UINCDIR += $(TMK_DIR)/common |
