visualizer.mk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # The MIT License (MIT)
  2. #
  3. # Copyright (c) 2016 Fred Sundvik
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in all
  13. # copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22. define ADD_DRIVER
  23. $(1)_DRIVER:=$(strip $($(1)_DRIVER))
  24. $(1)_WIDTH:=$(strip $($(1)_WIDTH))
  25. $(1)_HEIGHT:=$(strip $($(1)_HEIGHT))
  26. ifeq ($($(1)_DRIVER),)
  27. $$(error $(1)_DRIVER is not defined)
  28. endif
  29. ifeq ($($(1)_WIDTH),)
  30. $$(error $(1)_WIDTH is not defined)
  31. endif
  32. ifeq ($($(1)_HEIGHT),)
  33. $$(error $(1)_HEIGHT is not defined)
  34. endif
  35. OPT_DEFS+=-D$(1)_WIDTH=$($(1)_WIDTH)
  36. OPT_DEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT)
  37. GFXDEFS+=-D$(1)_WIDTH=$($(1)_WIDTH)
  38. GFXDEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT)
  39. $(1)_DISPLAY_NUMBER:=$$(words $$(GDISP_DRIVER_LIST))
  40. OPT_DEFS+=-D$(1)_DISPLAY_NUMBER=$$($(1)_DISPLAY_NUMBER)
  41. include $(TOP_DIR)/drivers/ugfx/gdisp/$($(1)_DRIVER)/driver.mk
  42. endef
  43. GDISP_DRIVER_LIST:=
  44. SRC += $(VISUALIZER_DIR)/visualizer.c \
  45. $(VISUALIZER_DIR)/visualizer_keyframes.c
  46. EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
  47. GFXLIB = $(LIB_PATH)/ugfx
  48. VPATH += $(VISUALIZER_PATH)
  49. OPT_DEFS += -DVISUALIZER_ENABLE
  50. ifdef LCD_ENABLE
  51. OPT_DEFS += -DLCD_ENABLE
  52. ULIBS += -lm
  53. endif
  54. ifeq ($(strip $(LCD_ENABLE)), yes)
  55. SRC += $(VISUALIZER_DIR)/lcd_backlight.c
  56. SRC += $(VISUALIZER_DIR)/lcd_keyframes.c
  57. SRC += $(VISUALIZER_DIR)/lcd_backlight_keyframes.c
  58. # Note, that the linker will strip out any resources that are not actually in use
  59. SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c
  60. OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
  61. $(eval $(call ADD_DRIVER,LCD))
  62. endif
  63. ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
  64. SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c
  65. $(eval $(call ADD_DRIVER,LED))
  66. endif
  67. SRC += $(VISUALIZER_DIR)/default_animations.c
  68. include $(GFXLIB)/gfx.mk
  69. # For the common_gfxconf.h
  70. GFXINC += quantum/visualizer
  71. GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC))
  72. GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
  73. GDISP_LIST_COMMA=,
  74. GDISP_LIST_EMPTY=
  75. GDISP_LIST_SPACE=$(GDISP_LIST_EMPTY) $(GDISP_LIST_EMPTY)
  76. GDISP_DRIVER_LIST := $(strip $(GDISP_DRIVER_LIST))
  77. GDISP_DRIVER_LIST := $(subst $(GDISP_LIST_SPACE),$(GDISP_LIST_COMMA),$(GDISP_DRIVER_LIST))
  78. GFXDEFS +=-DGDISP_DRIVER_LIST="$(GDISP_DRIVER_LIST)"
  79. ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","")
  80. SRC += $(KEYMAP_PATH)/visualizer.c
  81. else
  82. ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/visualizer.c)","")
  83. ifeq ("$(wildcard $(SUBPROJECT_PATH)/visualizer.c)","")
  84. ifeq ("$(wildcard $(KEYBOARD_PATH)/visualizer.c)","")
  85. $(error "visualizer.c" not found")
  86. else
  87. SRC += keyboards/$(KEYBOARD)/visualizer.c
  88. endif
  89. else
  90. SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/visualizer.c
  91. endif
  92. else
  93. SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/visualizer.c
  94. endif
  95. endif
  96. ifdef EMULATOR
  97. UINCDIR += $(TMK_DIR)/common
  98. endif