Skip to content

Commit

Permalink
Simplify Keymap Config EEPROM (#18886)
Browse files Browse the repository at this point in the history
* Simplify Keymap Config EEPROM

* Decrement eeconfig magic number due to eeconfig changes

* Update quantum/eeconfig.h

Co-authored-by: Joel Challis <[email protected]>
  • Loading branch information
drashna and zvecr authored Nov 1, 2022
1 parent 7ebc396 commit ae5f818
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
11 changes: 4 additions & 7 deletions quantum/eeconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ void eeconfig_init_quantum(void) {
eeprom_update_byte(EECONFIG_DEBUG, 0);
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
default_layer_state = 0;
eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, 0);
// Enable oneshot and autocorrect by default: 0b0001 0100
eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0x14);
eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
// Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000
eeprom_update_word(EECONFIG_KEYMAP, 0x1400);
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
eeprom_update_dword(EECONFIG_RGBLIGHT, 0);
Expand Down Expand Up @@ -167,15 +165,14 @@ void eeconfig_update_default_layer(uint8_t val) {
* FIXME: needs doc
*/
uint16_t eeconfig_read_keymap(void) {
return (eeprom_read_byte(EECONFIG_KEYMAP_LOWER_BYTE) | (eeprom_read_byte(EECONFIG_KEYMAP_UPPER_BYTE) << 8));
return eeprom_read_word(EECONFIG_KEYMAP);
}
/** \brief eeconfig update keymap
*
* FIXME: needs doc
*/
void eeconfig_update_keymap(uint16_t val) {
eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, val & 0xFF);
eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, (val >> 8) & 0xFF);
eeprom_update_word(EECONFIG_KEYMAP, val);
}

/** \brief eeconfig read audio
Expand Down
11 changes: 3 additions & 8 deletions quantum/eeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>

#ifndef EECONFIG_MAGIC_NUMBER
# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE8 // When changing, decrement this value to avoid future re-init issues
# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE7 // When changing, decrement this value to avoid future re-init issues
#endif
#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF

/* EEPROM parameter address */
#define EECONFIG_MAGIC (uint16_t *)0
#define EECONFIG_DEBUG (uint8_t *)2
#define EECONFIG_DEFAULT_LAYER (uint8_t *)3
#define EECONFIG_KEYMAP (uint8_t *)4
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
#define EECONFIG_KEYMAP (uint16_t *)4
#define EECONFIG_BACKLIGHT (uint8_t *)6
#define EECONFIG_AUDIO (uint8_t *)7
#define EECONFIG_RGBLIGHT (uint32_t *)8
Expand All @@ -51,10 +50,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_LED_MATRIX_EXTENDED (uint16_t *)32
#define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32

// TODO: Combine these into a single word and single block of EEPROM
#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)34
// Size of EEPROM being used, other code can refer to this for available EEPROM
#define EECONFIG_SIZE 35
#define EECONFIG_SIZE 34
/* debug bit */
#define EECONFIG_DEBUG_ENABLE (1 << 0)
#define EECONFIG_DEBUG_MATRIX (1 << 1)
Expand All @@ -71,8 +68,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1 << 6)
#define EECONFIG_KEYMAP_NKRO (1 << 7)

#define EECONFIG_KEYMAP_LOWER_BYTE EECONFIG_KEYMAP

bool eeconfig_is_enabled(void);
bool eeconfig_is_disabled(void);

Expand Down

0 comments on commit ae5f818

Please sign in to comment.