dynamic keymap sanity check (#8181)
This commit is contained in:
parent
a2081171de
commit
79d5903b6c
@ -30,6 +30,14 @@
|
|||||||
# define DYNAMIC_KEYMAP_MACRO_COUNT 16
|
# define DYNAMIC_KEYMAP_MACRO_COUNT 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This is the default EEPROM max address to use for dynamic keymaps.
|
||||||
|
// The default is the ATmega32u4 EEPROM max address.
|
||||||
|
// Explicitly override it if the keyboard uses a microcontroller with
|
||||||
|
// more EEPROM *and* it makes sense to increase it.
|
||||||
|
#ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR
|
||||||
|
# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023
|
||||||
|
#endif
|
||||||
|
|
||||||
// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h,
|
// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h,
|
||||||
// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE
|
// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE
|
||||||
#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
|
#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
|
||||||
@ -45,11 +53,19 @@
|
|||||||
# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2))
|
# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Dynamic macro uses up all remaining memory
|
// Sanity check that dynamic keymaps fit in available EEPROM
|
||||||
// Assumes 1K EEPROM on ATMega32U4
|
// If there's not 100 bytes available for macros, then something is wrong.
|
||||||
// Override for anything different
|
// The keyboard should override DYNAMIC_KEYMAP_LAYER_COUNT to reduce it,
|
||||||
|
// or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has
|
||||||
|
// more than the default.
|
||||||
|
#if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR < 100
|
||||||
|
# error Dynamic keymaps are configured to use more EEPROM than is available.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Dynamic macros are stored after the keymaps and use what is available
|
||||||
|
// up to and including DYNAMIC_KEYMAP_EEPROM_MAX_ADDR.
|
||||||
#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
|
#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
|
||||||
# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (1024 - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR)
|
# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; }
|
uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; }
|
||||||
|
Loading…
Reference in New Issue
Block a user