feat(k17_max): enable Keychron RGB and fix EEPROM persistence #20

Merged
rootiest merged 1 commits from dev/k17 into main 2026-04-13 17:43:20 +00:00
Owner

Summary

Port the Keychron RGB EEPROM persistence work from the Q5 Max (PR #18) to the K17 Max ANSI Encoder RGB variant.

  • Enable KEYCHRON_RGB_ENABLE for the K17 Max, wiring up PER_KEY_RGB and MIXED_RGB effects with board-specific defaults
  • Pin VIA_EEPROM_MAGIC_ADDR to a fixed offset so Keychron EEPROM growth can't silently corrupt the stored keymap
  • Add boot-time and transport-change RGB persistence hooks matching the Q5 Max pattern

Changes by file

rules.mk

  • Add KEYCHRON_RGB_ENABLE = yes

ansi_encoder/rgb/rgb.c

  • Define default_per_key_led[] for 103 LEDs: red Esc and CapsLock, yellow modifiers/function row/numpad, blue alpha keys (Q–P, A–L, Z–M, Space)
  • Define default_region[] with all 103 keys in region 0

ansi_encoder/rgb/config.h

  • Define VIA_EEPROM_MAGIC_ADDR 552 — K17 Max Keychron EEPROM data ends at byte 540 (103 LEDs × layout); 552 gives 12 bytes of headroom matching the Q5 Max convention

k17_max.c

  • Add wireless_enter_connected_kb() hook: reloads Keychron RGB state and re-applies the saved QMK RGB mode after BT/2.4G reconnect if it drifted during the transport change sequence
  • Add eeconfig_init_custom_rgb() call in keyboard_post_init_kb() so Keychron RGB arrays are loaded from EEPROM on boot
  • Add missing keychron_wireless_common.h and battery.h includes needed by the wireless hook

Notes

  • RGB_MATRIX_DEFAULT_MODE is intentionally not set — the K17 Max uses QMK's stock default effect on a fresh flash rather than heatmap
  • The DIP switch on the K17 Max switches MAC/WIN base layers (not RGB), so no overlay handling is needed here
  • The common EEPROM bug fixes (keychron_rgb.c, mixed_rgb.c, rgb_matrix_kb.inc, eeconfig_kb.h) were already landed in PR #18 and are inherited by this branch

Test plan

  • Compile succeeds with no errors
  • Launcher-configured Mixed RGB mode survives power cycle
  • Launcher-configured Mixed RGB mode survives BT ↔ 2.4G ↔ USB transport change
  • Layer 0 keymap is preserved correctly across power cycles (no keys reverting to KC_TRNS)
  • DIP switch correctly switches between MAC and WIN base layers as before
## Summary Port the Keychron RGB EEPROM persistence work from the Q5 Max (PR #18) to the K17 Max ANSI Encoder RGB variant. - Enable `KEYCHRON_RGB_ENABLE` for the K17 Max, wiring up `PER_KEY_RGB` and `MIXED_RGB` effects with board-specific defaults - Pin `VIA_EEPROM_MAGIC_ADDR` to a fixed offset so Keychron EEPROM growth can't silently corrupt the stored keymap - Add boot-time and transport-change RGB persistence hooks matching the Q5 Max pattern ## Changes by file ### `rules.mk` - Add `KEYCHRON_RGB_ENABLE = yes` ### `ansi_encoder/rgb/rgb.c` - Define `default_per_key_led[]` for 103 LEDs: red Esc and CapsLock, yellow modifiers/function row/numpad, blue alpha keys (Q–P, A–L, Z–M, Space) - Define `default_region[]` with all 103 keys in region 0 ### `ansi_encoder/rgb/config.h` - Define `VIA_EEPROM_MAGIC_ADDR 552` — K17 Max Keychron EEPROM data ends at byte 540 (103 LEDs × layout); 552 gives 12 bytes of headroom matching the Q5 Max convention ### `k17_max.c` - Add `wireless_enter_connected_kb()` hook: reloads Keychron RGB state and re-applies the saved QMK RGB mode after BT/2.4G reconnect if it drifted during the transport change sequence - Add `eeconfig_init_custom_rgb()` call in `keyboard_post_init_kb()` so Keychron RGB arrays are loaded from EEPROM on boot - Add missing `keychron_wireless_common.h` and `battery.h` includes needed by the wireless hook ## Notes - `RGB_MATRIX_DEFAULT_MODE` is intentionally **not** set — the K17 Max uses QMK's stock default effect on a fresh flash rather than heatmap - The DIP switch on the K17 Max switches MAC/WIN base layers (not RGB), so no overlay handling is needed here - The common EEPROM bug fixes (`keychron_rgb.c`, `mixed_rgb.c`, `rgb_matrix_kb.inc`, `eeconfig_kb.h`) were already landed in PR #18 and are inherited by this branch ## Test plan - [ ] Compile succeeds with no errors - [ ] Launcher-configured Mixed RGB mode survives power cycle - [ ] Launcher-configured Mixed RGB mode survives BT ↔ 2.4G ↔ USB transport change - [ ] Layer 0 keymap is preserved correctly across power cycles (no keys reverting to KC_TRNS) - [ ] DIP switch correctly switches between MAC and WIN base layers as before
rootiest added 1 commit 2026-04-13 17:21:38 +00:00
Port the Keychron RGB EEPROM persistence work from the Q5 Max (PR #18)
to the K17 Max ANSI Encoder RGB variant.

- Add KEYCHRON_RGB_ENABLE = yes to rules.mk
- Define default_per_key_led[] (red Esc/CapsLock, yellow modifiers and
  numpad, blue alpha keys) and default_region[] for the 103-LED layout
  in ansi_encoder/rgb/rgb.c; both are extern'd by keychron_rgb.c
- Add wireless_enter_connected_kb() hook and eeconfig_init_custom_rgb()
  call in keyboard_post_init_kb() in k17_max.c, matching the Q5 Max
  pattern for boot-time and transport-change RGB persistence
- Define VIA_EEPROM_MAGIC_ADDR 552 in ansi_encoder/rgb/config.h to pin
  VIA keymap storage past the Keychron EEPROM data region end (540 for
  K17 with 103 LEDs); prevents keymap corruption if the KB data block
  grows in future
rootiest merged commit ff45e8e0d6 into main 2026-04-13 17:43:20 +00:00
Sign in to join this conversation.