summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2022-10-31 18:02:43 -0700
committerGitHub <noreply@github.com>2022-11-01 01:02:43 +0000
commitae5f818d5a1efa321ffc0c6e659fa8fb47e79a01 (patch)
tree5759b942070201c838fbcedea78d157e93d60d7b
parent7ebc3968761b01202a36c57bb98e90067e733074 (diff)
Simplify Keymap Config EEPROM (#18886)
* Simplify Keymap Config EEPROM * Decrement eeconfig magic number due to eeconfig changes * Update quantum/eeconfig.h Co-authored-by: Joel Challis <git@zvecr.com>
-rw-r--r--quantum/eeconfig.c11
-rw-r--r--quantum/eeconfig.h11
2 files changed, 7 insertions, 15 deletions
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c
index 27a0f6d48f..2e2df11d69 100644
--- a/quantum/eeconfig.c
+++ b/quantum/eeconfig.c
@@ -45,10 +45,8 @@ void eeconfig_init_quantum(void) {
45 eeprom_update_byte(EECONFIG_DEBUG, 0); 45 eeprom_update_byte(EECONFIG_DEBUG, 0);
46 eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0); 46 eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
47 default_layer_state = 0; 47 default_layer_state = 0;
48 eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, 0); 48 // Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000
49 // Enable oneshot and autocorrect by default: 0b0001 0100 49 eeprom_update_word(EECONFIG_KEYMAP, 0x1400);
50 eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0x14);
51 eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
52 eeprom_update_byte(EECONFIG_BACKLIGHT, 0); 50 eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
53 eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default 51 eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
54 eeprom_update_dword(EECONFIG_RGBLIGHT, 0); 52 eeprom_update_dword(EECONFIG_RGBLIGHT, 0);
@@ -167,15 +165,14 @@ void eeconfig_update_default_layer(uint8_t val) {
167 * FIXME: needs doc 165 * FIXME: needs doc
168 */ 166 */
169uint16_t eeconfig_read_keymap(void) { 167uint16_t eeconfig_read_keymap(void) {
170 return (eeprom_read_byte(EECONFIG_KEYMAP_LOWER_BYTE) | (eeprom_read_byte(EECONFIG_KEYMAP_UPPER_BYTE) << 8)); 168 return eeprom_read_word(EECONFIG_KEYMAP);
171} 169}
172/** \brief eeconfig update keymap 170/** \brief eeconfig update keymap
173 * 171 *
174 * FIXME: needs doc 172 * FIXME: needs doc
175 */ 173 */
176void eeconfig_update_keymap(uint16_t val) { 174void eeconfig_update_keymap(uint16_t val) {
177 eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, val & 0xFF); 175 eeprom_update_word(EECONFIG_KEYMAP, val);
178 eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, (val >> 8) & 0xFF);
179} 176}
180 177
181/** \brief eeconfig read audio 178/** \brief eeconfig read audio
diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h
index 565a0dbe5b..9c4617c962 100644
--- a/quantum/eeconfig.h
+++ b/quantum/eeconfig.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <stdbool.h> 21#include <stdbool.h>
22 22
23#ifndef EECONFIG_MAGIC_NUMBER 23#ifndef EECONFIG_MAGIC_NUMBER
24# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE8 // When changing, decrement this value to avoid future re-init issues 24# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE7 // When changing, decrement this value to avoid future re-init issues
25#endif 25#endif
26#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF 26#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
27 27
@@ -29,8 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29#define EECONFIG_MAGIC (uint16_t *)0 29#define EECONFIG_MAGIC (uint16_t *)0
30#define EECONFIG_DEBUG (uint8_t *)2 30#define EECONFIG_DEBUG (uint8_t *)2
31#define EECONFIG_DEFAULT_LAYER (uint8_t *)3 31#define EECONFIG_DEFAULT_LAYER (uint8_t *)3
32#define EECONFIG_KEYMAP (uint8_t *)4 32#define EECONFIG_KEYMAP (uint16_t *)4
33#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
34#define EECONFIG_BACKLIGHT (uint8_t *)6 33#define EECONFIG_BACKLIGHT (uint8_t *)6
35#define EECONFIG_AUDIO (uint8_t *)7 34#define EECONFIG_AUDIO (uint8_t *)7
36#define EECONFIG_RGBLIGHT (uint32_t *)8 35#define EECONFIG_RGBLIGHT (uint32_t *)8
@@ -51,10 +50,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
51#define EECONFIG_LED_MATRIX_EXTENDED (uint16_t *)32 50#define EECONFIG_LED_MATRIX_EXTENDED (uint16_t *)32
52#define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32 51#define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32
53 52
54// TODO: Combine these into a single word and single block of EEPROM
55#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)34
56// Size of EEPROM being used, other code can refer to this for available EEPROM 53// Size of EEPROM being used, other code can refer to this for available EEPROM
57#define EECONFIG_SIZE 35 54#define EECONFIG_SIZE 34
58/* debug bit */ 55/* debug bit */
59#define EECONFIG_DEBUG_ENABLE (1 << 0) 56#define EECONFIG_DEBUG_ENABLE (1 << 0)
60#define EECONFIG_DEBUG_MATRIX (1 << 1) 57#define EECONFIG_DEBUG_MATRIX (1 << 1)
@@ -71,8 +68,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
71#define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1 << 6) 68#define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1 << 6)
72#define EECONFIG_KEYMAP_NKRO (1 << 7) 69#define EECONFIG_KEYMAP_NKRO (1 << 7)
73 70
74#define EECONFIG_KEYMAP_LOWER_BYTE EECONFIG_KEYMAP
75
76bool eeconfig_is_enabled(void); 71bool eeconfig_is_enabled(void);
77bool eeconfig_is_disabled(void); 72bool eeconfig_is_disabled(void);
78 73