You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
12 KiB

  1. # Split Keyboard
  2. Many keyboards in the QMK Firmware repo are "split" keyboards. They use two controllers—one plugging into USB, and the second connected by a serial or an I<sup>2</sup>C connection over a TRRS or similar cable.
  3. Split keyboards can have a lot of benefits, but there is some additional work needed to get them enabled.
  4. QMK Firmware has a generic implementation that is usable by any board, as well as numerous board specific implementations.
  5. For this, we will mostly be talking about the generic implementation used by the Let's Split and other keyboards.
  6. !> ARM is not yet fully supported for Split Keyboards and has many limitations. Progress is being made, but we have not yet reached 100% feature parity.
  7. ## Compatibility Overview
  8. | Transport | AVR | ARM |
  9. |------------------------------|--------------------|--------------------|
  10. | ['serial'](serial_driver.md) | :heavy_check_mark: | :white_check_mark: <sup>1</sup> |
  11. | I2C | :heavy_check_mark: | |
  12. Notes:
  13. 1. Both hardware and software limitations are detailed within the [driver documentation](serial_driver.md).
  14. ## Hardware Configuration
  15. This assumes that you're using two Pro Micro-compatible controllers, and are using TRRS jacks to connect to two halves.
  16. ### Required Hardware
  17. Apart from diodes and key switches for the keyboard matrix in each half, you will need 2x TRRS sockets and 1x TRRS cable.
  18. Alternatively, you can use any sort of cable and socket that has at least 3 wires.
  19. If you want to use I<sup>2</sup>C to communicate between halves, you will need a cable with at least 4 wires and 2x 4.7kΩ pull-up resistors.
  20. #### Considerations
  21. The most commonly used connection is a TRRS cable and jacks. These provide 4 wires, making them very useful for split keyboards, and are easy to find.
  22. However, since one of the wires carries VCC, this means that the boards are not hot pluggable. You should always disconnect the board from USB before unplugging and plugging in TRRS cables, or you can short the controller, or worse.
  23. Another option is to use phone cables (as in, old school RJ-11/RJ-14 cables). Make sure that you use one that actually supports 4 wires/lanes.
  24. However, USB cables, SATA cables, and even just 4 wires have been known to be used for communication between the controllers.
  25. !> Using USB cables for communication between the controllers works just fine, but the connector could be mistaken for a normal USB connection and potentially short out the keyboard, depending on how it's wired. For this reason, they are not recommended for connecting split keyboards.
  26. ### Serial Wiring
  27. The 3 wires of the TRS/TRRS cable need to connect GND, VCC, and D0/D1/D2/D3 (aka PD0/PD1/PD2/PD3) between the two Pro Micros.
  28. ?> Note that the pin used here is actually set by `SOFT_SERIAL_PIN` below.
  29. <img alt="sk-pd0-connection-mono" src="https://user-images.githubusercontent.com/2170248/92296488-28e9ad80-ef70-11ea-98be-c40cb48a0319.JPG" width="48%"/>
  30. <img alt="sk-pd2-connection-mono" src="https://user-images.githubusercontent.com/2170248/92296490-2d15cb00-ef70-11ea-801f-5ace313013e6.JPG" width="48%"/>
  31. ### I<sup>2</sup>C Wiring
  32. The 4 wires of the TRRS cable need to connect GND, VCC, and SCL and SDA (aka PD0/pin 3 and PD1/pin 2, respectively) between the two Pro Micros.
  33. The pull-up resistors may be placed on either half. If you wish to use the halves independently, it is also possible to use 4 resistors and have the pull-ups in both halves.
  34. <img alt="sk-i2c-connection-mono" src="https://user-images.githubusercontent.com/2170248/92297182-92b98580-ef77-11ea-9d7d-d6033914af43.JPG" width="50%"/>
  35. ## Firmware Configuration
  36. To enable the split keyboard feature, add the following to your `rules.mk`:
  37. ```make
  38. SPLIT_KEYBOARD = yes
  39. ```
  40. If you're using a custom transport (communication method), then you will also need to add:
  41. ```make
  42. SPLIT_TRANSPORT = custom
  43. ```
  44. ### Setting Handedness
  45. By default, the firmware does not know which side is which; it needs some help to determine that. There are several ways to do this, listed in order of precedence.
  46. #### Handedness by Pin
  47. You can configure the firmware to read a pin on the controller to determine handedness. To do this, add the following to your `config.h` file:
  48. ```c
  49. #define SPLIT_HAND_PIN B7
  50. ```
  51. This will read the specified pin. If it's high, then the controller assumes it is the left hand, and if it's low, it's assumed to be the right side.
  52. #### Handedness by Matrix Pin
  53. You can configure the firmware to read key matrix pins on the controller to determine handedness. To do this, add the following to your `config.h` file:
  54. ```c
  55. #define SPLIT_HAND_MATRIX_GRID D0, F1
  56. ```
  57. The first pin is the output pin and the second is the input pin.
  58. Some keyboards have unused intersections in the key matrix. This setting uses one of these unused intersections to determine the handness.
  59. Normally, when a diode is connected to an intersection, it is judged to be left. If you add the following definition, it will be judged to be right.
  60. ```c
  61. #define SPLIT_HAND_MATRIX_GRID_LOW_IS_RIGHT
  62. ```
  63. #### Handedness by EEPROM
  64. This method sets the keyboard's handedness by setting a flag in the persistent storage (`EEPROM`). This is checked when the controller first starts up, and determines what half the keyboard is, and how to orient the keyboard layout.
  65. To enable this method, add the following to your `config.h` file:
  66. ```c
  67. #define EE_HANDS
  68. ```
  69. However, you'll have to flash the EEPROM files for the correct hand to each controller. You can do this manually, or there are targets for avrdude and dfu to do this, while flashing the firmware:
  70. * `:avrdude-split-left`
  71. * `:avrdude-split-right`
  72. * `:dfu-split-left`
  73. * `:dfu-split-right`
  74. * `:dfu-util-split-left`
  75. * `:dfu-util-split-right`
  76. This setting is not changed when re-initializing the EEPROM using the `EEP_RST` key, or using the `eeconfig_init()` function. However, if you reset the EEPROM outside of the firmware's built in options (such as flashing a file that overwrites the `EEPROM`, like how the [QMK Toolbox]()'s "Reset EEPROM" button works), you'll need to re-flash the controller with the `EEPROM` files.
  77. You can find the `EEPROM` files in the QMK firmware repo, [here](https://github.com/qmk/qmk_firmware/tree/master/quantum/split_common).
  78. #### Handedness by `#define`
  79. You can set the handedness at compile time. This is done by adding the following to your `config.h` file:
  80. ```c
  81. #define MASTER_RIGHT
  82. ```
  83. or
  84. ```c
  85. #define MASTER_LEFT
  86. ```
  87. If neither are defined, the handedness defaults to `MASTER_LEFT`.
  88. ### Communication Options
  89. Because not every split keyboard is identical, there are a number of additional options that can be configured in your `config.h` file.
  90. ```c
  91. #define USE_I2C
  92. ```
  93. This enables I<sup>2</sup>C support for split keyboards. This isn't strictly for communication, but can be used for OLED or other I<sup>2</sup>C-based devices.
  94. ```c
  95. #define SOFT_SERIAL_PIN D0
  96. ```
  97. This sets the pin to be used for serial communication. If you're not using serial, you shouldn't need to define this.
  98. However, if you are using serial and I<sup>2</sup>C on the board, you will need to set this, and to something other than D0 and D1 (as these are used for I<sup>2</sup>C communication).
  99. ```c
  100. #define SELECT_SOFT_SERIAL_SPEED {#}`
  101. ```
  102. If you're having issues with serial communication, you can change this value, as it controls the communication speed for serial. The default is 1, and the possible values are:
  103. * **`0`**: about 189kbps (Experimental only)
  104. * **`1`**: about 137kbps (default)
  105. * **`2`**: about 75kbps
  106. * **`3`**: about 39kbps
  107. * **`4`**: about 26kbps
  108. * **`5`**: about 20kbps
  109. ```c
  110. #define SPLIT_MODS_ENABLE
  111. ```
  112. This enables transmitting modifier state (normal, weak and oneshot) to the non
  113. primary side of the split keyboard. This adds a few bytes of data to the split
  114. communication protocol and may impact the matrix scan speed when enabled.
  115. The purpose of this feature is to support cosmetic use of modifer state (e.g.
  116. displaying status on an OLED screen).
  117. ```c
  118. #define SPLIT_TRANSPORT_MIRROR
  119. ```
  120. This mirrors the master side matrix to the slave side for features that react or require knowledge of master side key presses on the slave side. This adds a few bytes of data to the split communication protocol and may impact the matrix scan speed when enabled. The purpose of this feature is to support cosmetic use of key events (e.g. RGB reacting to Keypresses).
  121. ### Hardware Configuration Options
  122. There are some settings that you may need to configure, based on how the hardware is set up.
  123. ```c
  124. #define MATRIX_ROW_PINS_RIGHT { <row pins> }
  125. #define MATRIX_COL_PINS_RIGHT { <col pins> }
  126. ```
  127. This allows you to specify a different set of pins for the matrix on the right side. This is useful if you have a board with differently-shaped halves that requires a different configuration (such as Keebio's Quefrency).
  128. ```c
  129. #define DIRECT_PINS_RIGHT { { F1, F0, B0, C7 }, { F4, F5, F6, F7 } }
  130. ```
  131. This allows you to specify a different set of direct pins for the right side.
  132. ```c
  133. #define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
  134. #define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
  135. ```
  136. This allows you to specify a different set of encoder pins for the right side.
  137. ```c
  138. #define RGBLIGHT_SPLIT
  139. ```
  140. This option enables synchronization of the RGB Light modes between the controllers of the split keyboard. This is for keyboards that have RGB LEDs that are directly wired to the controller (that is, they are not using the "extra data" option on the TRRS cable).
  141. ```c
  142. #define RGBLED_SPLIT { 6, 6 }
  143. ```
  144. This sets how many LEDs are directly connected to each controller. The first number is the left side, and the second number is the right side.
  145. ?> This setting implies that `RGBLIGHT_SPLIT` is enabled, and will forcibly enable it, if it's not.
  146. ```c
  147. #define SPLIT_USB_DETECT
  148. ```
  149. This option changes the startup behavior to detect an active USB connection when delegating master/slave. If this operation times out, then the half is assume to be a slave. This is the default behavior for ARM, and required for AVR Teensy boards (due to hardware limitations).
  150. ?> This setting will stop the ability to demo using battery packs.
  151. ```c
  152. #define SPLIT_USB_TIMEOUT 2000
  153. ```
  154. This sets the maximum timeout when detecting master/slave when using `SPLIT_USB_DETECT`.
  155. ```c
  156. #define SPLIT_USB_TIMEOUT_POLL 10
  157. ```
  158. This sets the poll frequency when detecting master/slave when using `SPLIT_USB_DETECT`
  159. ## Hardware Considerations and Mods
  160. While most any Pro Micro can be used, micro controllers like the AVR Teensys and most (if not all) ARM boards require the Split USB Detect.
  161. However, with the Teensy 2.0 and Teensy++ 2.0, there is a simple hardware mod that you can perform to add VBUS detection, so you don't need the Split USB detection option.
  162. You'll only need a few things:
  163. * A knife (x-acto knife, ideally)
  164. * A solder station or hot air station
  165. * An appropriate Schottky diode, such as the [PMEG2005EH](https://www.digikey.com/en/products/detail/nexperia-usa-inc/PMEG2005EH,115/1589924)
  166. You'll need to cut the small trace between the 5V and center pads on the back of the Teensy.
  167. Once you have done that, you will want to solder the diode from the 5V pad to the center pad.
  168. You may need to use the 5V pad from the regulator block above as the pads were too small and placed too closely together to place the Schottky diode properly.
  169. ![Teensy++ 2.0](https://i.imgur.com/BPEC5n5.png)
  170. ## Additional Resources
  171. Nicinabox has a [very nice and detailed guide](https://github.com/nicinabox/lets-split-guide) for the Let's Split keyboard, that covers most everything you need to know, including troubleshooting information.
  172. However, the RGB Light section is out of date, as it was written long before the RGB Split code was added to QMK Firmware. Instead, wire each strip up directly to the controller.
  173. <!-- I may port this information later, but for now ... it's very nice, and covers everything -->