constants.py 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. """Information that should be available to the python library.
  2. """
  3. from os import environ
  4. from datetime import date
  5. from pathlib import Path
  6. # The root of the qmk_firmware tree.
  7. QMK_FIRMWARE = Path.cwd()
  8. # Upstream repo url
  9. QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware'
  10. # This is the number of directories under `qmk_firmware/keyboards` that will be traversed. This is currently a limitation of our make system.
  11. MAX_KEYBOARD_SUBFOLDERS = 5
  12. # Supported processor types
  13. CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71'
  14. LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
  15. VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
  16. # Bootloaders of the supported processors
  17. MCU2BOOTLOADER = {
  18. "MKL26Z64": "halfkay",
  19. "MK20DX128": "halfkay",
  20. "MK20DX256": "halfkay",
  21. "MK66FX1M0": "halfkay",
  22. "STM32F042": "stm32-dfu",
  23. "STM32F072": "stm32-dfu",
  24. "STM32F103": "stm32duino",
  25. "STM32F303": "stm32-dfu",
  26. "STM32F401": "stm32-dfu",
  27. "STM32F405": "stm32-dfu",
  28. "STM32F407": "stm32-dfu",
  29. "STM32F411": "stm32-dfu",
  30. "STM32F446": "stm32-dfu",
  31. "STM32G431": "stm32-dfu",
  32. "STM32G474": "stm32-dfu",
  33. "STM32L412": "stm32-dfu",
  34. "STM32L422": "stm32-dfu",
  35. "STM32L432": "stm32-dfu",
  36. "STM32L433": "stm32-dfu",
  37. "STM32L442": "stm32-dfu",
  38. "STM32L443": "stm32-dfu",
  39. "GD32VF103": "gd32v-dfu",
  40. "WB32F3G71": "wb32-dfu",
  41. "atmega16u2": "atmel-dfu",
  42. "atmega32u2": "atmel-dfu",
  43. "atmega16u4": "atmel-dfu",
  44. "atmega32u4": "atmel-dfu",
  45. "at90usb162": "atmel-dfu",
  46. "at90usb646": "atmel-dfu",
  47. "at90usb647": "atmel-dfu",
  48. "at90usb1286": "atmel-dfu",
  49. "at90usb1287": "atmel-dfu",
  50. "atmega32a": "bootloadhid",
  51. "atmega328p": "usbasploader",
  52. "atmega328": "usbasploader",
  53. }
  54. # Common format strings
  55. DATE_FORMAT = '%Y-%m-%d'
  56. DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
  57. TIME_FORMAT = '%H:%M:%S'
  58. # Used when generating matrix locations
  59. COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz'
  60. ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
  61. # Mapping between info.json and config.h keys
  62. LED_INDICATORS = {
  63. 'caps_lock': 'LED_CAPS_LOCK_PIN',
  64. 'num_lock': 'LED_NUM_LOCK_PIN',
  65. 'scroll_lock': 'LED_SCROLL_LOCK_PIN',
  66. }
  67. # Constants that should match their counterparts in make
  68. BUILD_DIR = environ.get('BUILD_DIR', '.build')
  69. KEYBOARD_OUTPUT_PREFIX = f'{BUILD_DIR}/obj_'
  70. # Headers for generated files
  71. this_year = date.today().year
  72. GPL2_HEADER_C_LIKE = f'''\
  73. /* Copyright {this_year} QMK
  74. *
  75. * This program is free software: you can redistribute it and/or modify
  76. * it under the terms of the GNU General Public License as published by
  77. * the Free Software Foundation, either version 2 of the License, or
  78. * (at your option) any later version.
  79. *
  80. * This program is distributed in the hope that it will be useful,
  81. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  82. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  83. * GNU General Public License for more details.
  84. *
  85. * You should have received a copy of the GNU General Public License
  86. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  87. */
  88. '''
  89. GPL2_HEADER_SH_LIKE = f'''\
  90. # Copyright {this_year} QMK
  91. #
  92. # This program is free software: you can redistribute it and/or modify
  93. # it under the terms of the GNU General Public License as published by
  94. # the Free Software Foundation, either version 2 of the License, or
  95. # (at your option) any later version.
  96. #
  97. # This program is distributed in the hope that it will be useful,
  98. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  99. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  100. # GNU General Public License for more details.
  101. #
  102. # You should have received a copy of the GNU General Public License
  103. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  104. '''
  105. GENERATED_HEADER_C_LIKE = '''\
  106. /*******************************************************************************
  107. 88888888888 888 d8b .d888 d8b 888 d8b
  108. 888 888 Y8P d88P" Y8P 888 Y8P
  109. 888 888 888 888
  110. 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
  111. 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
  112. 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
  113. 888 888 888 888 X88 888 888 888 Y8b. 888 X88
  114. 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
  115. 888 888
  116. 888 888
  117. 888 888
  118. .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
  119. d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
  120. 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
  121. Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
  122. "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
  123. 888
  124. Y8b d88P
  125. "Y88P"
  126. *******************************************************************************/
  127. '''
  128. GENERATED_HEADER_SH_LIKE = '''\
  129. ################################################################################
  130. #
  131. # 88888888888 888 d8b .d888 d8b 888 d8b
  132. # 888 888 Y8P d88P" Y8P 888 Y8P
  133. # 888 888 888 888
  134. # 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
  135. # 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
  136. # 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
  137. # 888 888 888 888 X88 888 888 888 Y8b. 888 X88
  138. # 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
  139. #
  140. # 888 888
  141. # 888 888
  142. # 888 888
  143. # .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
  144. # d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
  145. # 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
  146. # Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
  147. # "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
  148. # 888
  149. # Y8b d88P
  150. # "Y88P"
  151. #
  152. ################################################################################
  153. '''