local_features.mk 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #
  2. # local_features.mk contains post-processing rules for the Helix keyboard.
  3. #
  4. # Post-processing rules convert keyboard-specific shortcuts (that represent
  5. # combinations of standard options) into QMK standard options.
  6. #
  7. KEYBOARD_LOCAL_FEATURES_MK :=
  8. define HELIX_CUSTOMISE_MSG
  9. $(info Helix Spacific Build Options)
  10. $(info - OLED_ENABLE = $(OLED_ENABLE))
  11. $(info - OLED_SELECT = $(OLED_SELECT))
  12. $(info - LED_BACK_ENABLE = $(LED_BACK_ENABLE))
  13. $(info - LED_UNDERGLOW_ENABLE = $(LED_UNDERGLOW_ENABLE))
  14. $(info - LED_ANIMATIONS = $(LED_ANIMATIONS))
  15. $(info - IOS_DEVICE_ENABLE = $(IOS_DEVICE_ENABLE))
  16. $(info )
  17. endef
  18. define HELIX_HELP_MSG
  19. $(info Helix keyboard convenient command line option)
  20. $(info - make HELIX=<options> helix:<keymap>)
  21. $(info - option= oled | core-oled | local-oled | no-oled )
  22. $(info - back | no-back | under | na | no-ani )
  23. $(info - ios | sc | split-common | scan | verbose)
  24. $(info - eg.)
  25. $(info - make HELIX=no-oled helix:<keymap>)
  26. $(info - make HELIX=oled,no-back helix:<keymap>)
  27. $(info - make HELIX=oled,under helix:<keymap>)
  28. $(info - make HELIX=oled,back,na helix:<keymap>)
  29. $(info - make HELIX=oled,back,ios helix:<keymap>)
  30. $(info )
  31. endef
  32. ifneq ($(strip $(HELIX)),)
  33. define HELIX_OPTION_PARSE
  34. # parce 'oled' 'back' 'under' 'ios' etc.
  35. $(if $(SHOW_PARCE),$(info parse .$1.)) #debug
  36. ifeq ($(strip $1),help)
  37. HELP=on
  38. endif
  39. ifneq ($(filter nooled no-oled,$(strip $1)),)
  40. OLED_ENABLE = no
  41. endif
  42. ifeq ($(strip $1),oled)
  43. OLED_ENABLE = yes
  44. endif
  45. ifneq ($(filter core-oled core_oled newoled new-oled olednew oled-new,$(strip $1)),)
  46. OLED_ENABLE = yes
  47. OLED_SELECT = core
  48. endif
  49. ifneq ($(filter local-oled local_oled oldoled old-oled oledold oled-old,$(strip $1)),)
  50. OLED_ENABLE = yes
  51. OLED_SELECT = local
  52. endif
  53. ifneq ($(filter noback no-back nounder no-under,$(strip $1)),)
  54. LED_BACK_ENABLE = no
  55. LED_UNDERGLOW_ENABLE = no
  56. endif
  57. ifeq ($(strip $1),back)
  58. LED_BACK_ENABLE = yes
  59. LED_UNDERGLOW_ENABLE = no
  60. endif
  61. ifeq ($(strip $1),under)
  62. LED_BACK_ENABLE = no
  63. LED_UNDERGLOW_ENABLE = yes
  64. endif
  65. ifneq ($(filter na no_ani no-ani,$(strip $1)),)
  66. LED_ANIMATIONS = no
  67. endif
  68. ifeq ($(strip $1),ios)
  69. IOS_DEVICE_ENABLE = yes
  70. endif
  71. ifneq ($(filter sc split-common split_common,$(strip $1)),)
  72. SPLIT_KEYBOARD = yes
  73. endif
  74. ifneq ($(filter nosc no-sc no-split-common no-split_common,$(strip $1)),)
  75. SPLIT_KEYBOARD = no
  76. endif
  77. ifeq ($(strip $1),scan)
  78. # use DEBUG_MATRIX_SCAN_RATE
  79. # see docs/newbs_testing_debugging.md
  80. OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
  81. CONSOLE_ENABLE = yes
  82. SHOW_VERBOSE_INFO = yes
  83. endif
  84. ifeq ($(strip $1),verbose)
  85. SHOW_VERBOSE_INFO = yes
  86. endif
  87. ifeq ($(strip $1),lto)
  88. LTO_ENABLE = yes
  89. endif
  90. ifneq ($(filter nolto no-lto no_lto,$(strip $1)),)
  91. LTO_ENABLE = no
  92. endif
  93. endef # end of HELIX_OPTION_PARSE
  94. COMMA=,
  95. $(eval $(foreach A_OPTION_NAME,$(subst $(COMMA), ,$(HELIX)), \
  96. $(call HELIX_OPTION_PARSE,$(A_OPTION_NAME))))
  97. ifeq ($(strip $(HELP)),on)
  98. $(eval $(call HELIX_HELP_MSG))
  99. $(error )
  100. endif
  101. SHOW_HELIX_OPTIONS = yes
  102. endif
  103. ifneq ($(strip $(SPLIT_KEYBOARD)), yes)
  104. SRC += local_drivers/serial.c
  105. KEYBOARD_PATHS += $(HELIX_TOP_DIR)/local_drivers
  106. # A workaround until #7089 is merged.
  107. # serial.c must not be compiled with the -lto option.
  108. # The current LIB_SRC has a side effect with the -fno-lto option, so use it.
  109. LIB_SRC += local_drivers/serial.c
  110. CUSTOM_MATRIX = yes
  111. SRC += rev2/matrix.c
  112. SRC += rev2/split_util.c
  113. SRC += rev2/split_scomm.c
  114. endif
  115. ########
  116. # convert Helix-specific options (that represent combinations of standard options)
  117. # into QMK standard options.
  118. ifneq ($(strip $(HELIX_ROWS)), 4)
  119. ifneq ($(strip $(HELIX_ROWS)), 5)
  120. $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value)
  121. endif
  122. endif
  123. OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS))
  124. ifeq ($(strip $(LED_BACK_ENABLE)), yes)
  125. RGBLIGHT_ENABLE = yes
  126. OPT_DEFS += -DRGBLED_BACK
  127. ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
  128. $(eval $(call HELIX_CUSTOMISE_MSG))
  129. $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes')
  130. endif
  131. else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
  132. RGBLIGHT_ENABLE = yes
  133. endif
  134. ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes)
  135. OPT_DEFS += -DIOS_DEVICE_ENABLE
  136. endif
  137. ifeq ($(strip $(LED_ANIMATIONS)), yes)
  138. OPT_DEFS += -DLED_ANIMATIONS
  139. endif
  140. ifeq ($(strip $(OLED_ENABLE)), yes)
  141. ifeq ($(strip $(OLED_SELECT)),core)
  142. OLED_DRIVER_ENABLE = yes
  143. ifeq ($(strip $(LOCAL_GLCDFONT)), yes)
  144. OPT_DEFS += -DOLED_FONT_H=\<helixfont.h\>
  145. else
  146. OPT_DEFS += -DOLED_FONT_H=\"common/glcdfont.c\"
  147. endif
  148. else
  149. SRC += local_drivers/i2c.c
  150. SRC += local_drivers/ssd1306.c
  151. KEYBOARD_PATHS += $(HELIX_TOP_DIR)/local_drivers
  152. OPT_DEFS += -DOLED_ENABLE
  153. ifeq ($(strip $(LOCAL_GLCDFONT)), yes)
  154. OPT_DEFS += -DLOCAL_GLCDFONT
  155. endif
  156. endif
  157. endif
  158. ifneq ($(strip $(SHOW_HELIX_OPTIONS)),)
  159. $(eval $(call HELIX_CUSTOMISE_MSG))
  160. ifneq ($(strip $(SHOW_VERBOSE_INFO)),)
  161. $(info -- RGBLIGHT_ENABLE = $(RGBLIGHT_ENABLE))
  162. $(info -- OLED_DRIVER_ENABLE = $(OLED_DRIVER_ENABLE))
  163. $(info -- CONSOLE_ENABLE = $(CONSOLE_ENABLE))
  164. $(info -- OPT_DEFS = $(OPT_DEFS))
  165. $(info -- SPLIT_KEYBOARD = $(SPLIT_KEYBOARD))
  166. $(info -- LTO_ENABLE = $(LTO_ENABLE))
  167. $(info )
  168. endif
  169. endif