Files
qmk_firmware/keyboards/keychron/k17_max/ansi_encoder/rgb/config.h
T
rootiest 1b0e83b1d6 feat(k17_max): enable Keychron RGB and fix EEPROM persistence
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
2026-04-13 13:20:47 -04:00

63 lines
2.4 KiB
C

/* Copyright 2024 @ Keychron (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// Pin VIA keymap storage to a fixed EEPROM address. By default VIA places its
// magic/keymap block immediately after EECONFIG_KB_DATA_SIZE, so any growth in
// the Keychron custom-RGB EEPROM region shifts the keymap silently and corrupts
// the stored layout (observed as layer 0 keys reverting to KC_TRNS on boot).
// 552 is past the current Keychron data region end (540) and leaves headroom
// for further EEPROM additions without requiring another VIA reset.
#define VIA_EEPROM_MAGIC_ADDR 552
#ifdef RGB_MATRIX_ENABLE
/* RGB Matrix driver configuration */
# define RGB_MATRIX_LED_COUNT 103
# define DRIVER_COUNT 2
# define DRIVER_CS_PINS \
{ B8, B9 }
/* Scan phase of led driver set as MSKPHASE_12CHANNEL(defined as 0x03 in snled27351.h) */
# define SNLED27351_PHASE_CHANNEL MSKPHASE_12CHANNEL
/* Set LED driver current */
# define SNLED27351_CURRENT_TUNE \
{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }
/* Set to infinit, which is use in USB mode by default */
# define RGB_MATRIX_TIMEOUT RGB_MATRIX_TIMEOUT_INFINITE
/* Allow shutdown of led driver to save power */
# define RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
/* Turn off backlight on low brightness to save power */
# define RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL 48
/* Indications */
# define CAPS_LOCK_INDEX 57
# define NUM_LOCK_INDEX 34
# define LOW_BAT_IND_INDEX \
{ 94 }
# define BT_HOST_LED_MATRIX_LIST \
{ 20, 21, 22 }
# define P2P4G_HOST_LED_MATRIX_LIST \
{ 23 }
# define BAT_LEVEL_LED_LIST \
{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }
# define RGB_MATRIX_KEYPRESSES
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
#endif