aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards/cannonkeys
diff options
context:
space:
mode:
authorWilba <Jason.S.Williams@gmail.com>2020-01-04 07:52:00 +1100
committerDrashna Jaelre <drashna@live.com>2020-01-03 12:52:00 -0800
commit320822d75b785401809f45007320e6fb6885b3fd (patch)
treec511d49a48b953ac29ffb4a51ac928319eb9fde4 /keyboards/cannonkeys
parentb36259566546eb884cc241bcfadb671051e5e75e (diff)
downloadfirmware-320822d75b785401809f45007320e6fb6885b3fd.tar.gz
firmware-320822d75b785401809f45007320e6fb6885b3fd.tar.bz2
firmware-320822d75b785401809f45007320e6fb6885b3fd.zip
VIA Configurator Refactor (#7268)
* VIA Refactor * Remove old code * review changes * review changes * Fix cannonkeys/satisfaction75/prototype:via build * Add via.h to quantum.h * Move backlight init to after backlight config load * Merge branch 'master' into via_refactor_pr * Update user's rules.mk to new way of enabling VIA * Added id_switch_matrix_state * Review changes
Diffstat (limited to 'keyboards/cannonkeys')
-rw-r--r--keyboards/cannonkeys/an_c/config.h23
-rw-r--r--keyboards/cannonkeys/an_c/keymaps/via/rules.mk6
-rw-r--r--keyboards/cannonkeys/an_c/rules.mk3
-rw-r--r--keyboards/cannonkeys/chimera65/config.h20
-rw-r--r--keyboards/cannonkeys/chimera65/keymaps/via/rules.mk6
-rw-r--r--keyboards/cannonkeys/chimera65/rules.mk3
-rw-r--r--keyboards/cannonkeys/instant60/config.h23
-rw-r--r--keyboards/cannonkeys/instant60/keymaps/via/rules.mk6
-rw-r--r--keyboards/cannonkeys/instant60/keymaps/via_standard/rules.mk6
-rw-r--r--keyboards/cannonkeys/instant60/rules.mk3
-rw-r--r--keyboards/cannonkeys/iron165/config.h22
-rw-r--r--keyboards/cannonkeys/satisfaction75/config.h43
-rw-r--r--keyboards/cannonkeys/satisfaction75/keymaps/boy_314/rules.mk3
-rw-r--r--keyboards/cannonkeys/satisfaction75/keymaps/via/rules.mk6
-rw-r--r--keyboards/cannonkeys/satisfaction75/prototype/prototype.h17
-rw-r--r--keyboards/cannonkeys/satisfaction75/rules.mk3
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.c288
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.h10
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c6
-rw-r--r--keyboards/cannonkeys/savage65/config.h22
-rw-r--r--keyboards/cannonkeys/stm32f072/keyboard.c266
-rw-r--r--keyboards/cannonkeys/stm32f072/keyboard.h4
-rw-r--r--keyboards/cannonkeys/tmov2/config.h22
23 files changed, 230 insertions, 581 deletions
diff --git a/keyboards/cannonkeys/an_c/config.h b/keyboards/cannonkeys/an_c/config.h
index ef480521b..55414ba50 100644
--- a/keyboards/cannonkeys/an_c/config.h
+++ b/keyboards/cannonkeys/an_c/config.h
@@ -58,26 +58,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PIN_WS2812 15
#define WS2812_SPI SPID2
-
-// EEPROM usage
-// TODO: refactor with new user EEPROM code (coming soon)
-#define EEPROM_MAGIC 0x451F
-#define EEPROM_MAGIC_ADDR 40
-// Bump this every time we change what we store
-// This will automatically reset the EEPROM with defaults
-// and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x03
-#define EEPROM_VERSION_ADDR 42
-
-
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-// Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600) = 635
-// start + layer * rows * col * 2
-#define DYNAMIC_KEYMAP_EEPROM_ADDR 43
-#define EEPROM_CUSTOM_BACKLIGHT 644
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 645
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 192
-#define DYNAMIC_KEYMAP_MACRO_COUNT 16
+// Backlight config starts after VIA's EEPROM usage,
+// dynamic keymaps start after this.
+#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
/*
* Feature disable options
diff --git a/keyboards/cannonkeys/an_c/keymaps/via/rules.mk b/keyboards/cannonkeys/an_c/keymaps/via/rules.mk
index d12497792..1e5b99807 100644
--- a/keyboards/cannonkeys/an_c/keymaps/via/rules.mk
+++ b/keyboards/cannonkeys/an_c/keymaps/via/rules.mk
@@ -1,5 +1 @@
-# rules.mk overrides to enable VIA
-
-RAW_ENABLE = yes
-DYNAMIC_KEYMAP_ENABLE = yes
-
+VIA_ENABLE = yes
diff --git a/keyboards/cannonkeys/an_c/rules.mk b/keyboards/cannonkeys/an_c/rules.mk
index 2f30956e7..f99075d81 100644
--- a/keyboards/cannonkeys/an_c/rules.mk
+++ b/keyboards/cannonkeys/an_c/rules.mk
@@ -53,7 +53,4 @@ CUSTOM_MATRIX = no # Custom matrix file
# BACKLIGHT_ENABLE = yes # This is broken on 072 for some reason
RGBLIGHT_ENABLE = yes
-# RAW_ENABLE = yes
-# DYNAMIC_KEYMAP_ENABLE = yes
-
LAYOUTS = 60_ansi 60_tsangan_hhkb
diff --git a/keyboards/cannonkeys/chimera65/config.h b/keyboards/cannonkeys/chimera65/config.h
index ace3565be..c76fd6c1c 100644
--- a/keyboards/cannonkeys/chimera65/config.h
+++ b/keyboards/cannonkeys/chimera65/config.h
@@ -50,26 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
-// EEPROM usage
-// TODO: refactor with new user EEPROM code (coming soon)
-#define EEPROM_MAGIC 0x451F
-#define EEPROM_MAGIC_ADDR 34
-// Bump this every time we change what we store
-// This will automatically reset the EEPROM with defaults
-// and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x02
-#define EEPROM_VERSION_ADDR 36
-
-
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-// Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600) = 635
-// start + layer * rows * col * 2
-#define DYNAMIC_KEYMAP_EEPROM_ADDR 37
-#define EEPROM_CUSTOM_BACKLIGHT 678
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 679
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 202
-#define DYNAMIC_KEYMAP_MACRO_COUNT 16
-
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/keyboards/cannonkeys/chimera65/keymaps/via/rules.mk b/keyboards/cannonkeys/chimera65/keymaps/via/rules.mk
index d12497792..1e5b99807 100644
--- a/keyboards/cannonkeys/chimera65/keymaps/via/rules.mk
+++ b/keyboards/cannonkeys/chimera65/keymaps/via/rules.mk
@@ -1,5 +1 @@
-# rules.mk overrides to enable VIA
-
-RAW_ENABLE = yes
-DYNAMIC_KEYMAP_ENABLE = yes
-
+VIA_ENABLE = yes
diff --git a/keyboards/cannonkeys/chimera65/rules.mk b/keyboards/cannonkeys/chimera65/rules.mk
index 580a7712c..cd6734a31 100644
--- a/keyboards/cannonkeys/chimera65/rules.mk
+++ b/keyboards/cannonkeys/chimera65/rules.mk
@@ -52,6 +52,3 @@ NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
# BACKLIGHT_ENABLE = yes # This is broken on 072 for some reason
RGBLIGHT_ENABLE = no
-
-# RAW_ENABLE = yes
-# DYNAMIC_KEYMAP_ENABLE = yes
diff --git a/keyboards/cannonkeys/instant60/config.h b/keyboards/cannonkeys/instant60/config.h
index 9da2043d2..2d23d5f83 100644
--- a/keyboards/cannonkeys/instant60/config.h
+++ b/keyboards/cannonkeys/instant60/config.h
@@ -58,26 +58,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PIN_WS2812 15
#define WS2812_SPI SPID2
-
-// EEPROM usage
-// TODO: refactor with new user EEPROM code (coming soon)
-#define EEPROM_MAGIC 0x451F
-#define EEPROM_MAGIC_ADDR 40
-// Bump this every time we change what we store
-// This will automatically reset the EEPROM with defaults
-// and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x03
-#define EEPROM_VERSION_ADDR 42
-
-
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-// Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600) = 635
-// start + layer * rows * col * 2
-#define DYNAMIC_KEYMAP_EEPROM_ADDR 43
-#define EEPROM_CUSTOM_BACKLIGHT 644
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 645
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 192
-#define DYNAMIC_KEYMAP_MACRO_COUNT 16
+// Backlight config starts after VIA's EEPROM usage,
+// dynamic keymaps start after this.
+#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
/*
* Feature disable options
diff --git a/keyboards/cannonkeys/instant60/keymaps/via/rules.mk b/keyboards/cannonkeys/instant60/keymaps/via/rules.mk
index d12497792..1e5b99807 100644
--- a/keyboards/cannonkeys/instant60/keymaps/via/rules.mk
+++ b/keyboards/cannonkeys/instant60/keymaps/via/rules.mk
@@ -1,5 +1 @@
-# rules.mk overrides to enable VIA
-
-RAW_ENABLE = yes
-DYNAMIC_KEYMAP_ENABLE = yes
-
+VIA_ENABLE = yes
diff --git a/keyboards/cannonkeys/instant60/keymaps/via_standard/rules.mk b/keyboards/cannonkeys/instant60/keymaps/via_standard/rules.mk
index d12497792..1e5b99807 100644
--- a/keyboards/cannonkeys/instant60/keymaps/via_standard/rules.mk
+++ b/keyboards/cannonkeys/instant60/keymaps/via_standard/rules.mk
@@ -1,5 +1 @@
-# rules.mk overrides to enable VIA
-
-RAW_ENABLE = yes
-DYNAMIC_KEYMAP_ENABLE = yes
-
+VIA_ENABLE = yes
diff --git a/keyboards/cannonkeys/instant60/rules.mk b/keyboards/cannonkeys/instant60/rules.mk
index 1ce6fa3b2..d1dd3b289 100644
--- a/keyboards/cannonkeys/instant60/rules.mk
+++ b/keyboards/cannonkeys/instant60/rules.mk
@@ -55,7 +55,4 @@ CUSTOM_MATRIX = no # Custom matrix file
# BACKLIGHT_ENABLE = yes # This is broken on 072 for some reason
RGBLIGHT_ENABLE = yes
-# RAW_ENABLE = yes
-# DYNAMIC_KEYMAP_ENABLE = yes
-
LAYOUTS = 60_ansi 60_tsangan_hhkb
diff --git a/keyboards/cannonkeys/iron165/config.h b/keyboards/cannonkeys/iron165/config.h
index c5fcd4518..640f6fb65 100644
--- a/keyboards/cannonkeys/iron165/config.h
+++ b/keyboards/cannonkeys/iron165/config.h
@@ -50,25 +50,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
-// EEPROM usage
-// TODO: refactor with new user EEPROM code (coming soon)
-#define EEPROM_MAGIC 0x451F
-#define EEPROM_MAGIC_ADDR 40
-// Bump this every time we change what we store
-// This will automatically reset the EEPROM with defaults
-// and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x02
-#define EEPROM_VERSION_ADDR 42
-
-
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-// Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600) = 635
-// start + layer * rows * col * 2
-#define DYNAMIC_KEYMAP_EEPROM_ADDR 43
-#define EEPROM_CUSTOM_BACKLIGHT 684
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 685
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 192
-#define DYNAMIC_KEYMAP_MACRO_COUNT 16
+// Backlight config starts after VIA's EEPROM usage,
+// dynamic keymaps start after this.
+#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
/*
* Feature disable options
diff --git a/keyboards/cannonkeys/satisfaction75/config.h b/keyboards/cannonkeys/satisfaction75/config.h
index 8387289d8..7a4354c8a 100644
--- a/keyboards/cannonkeys/satisfaction75/config.h
+++ b/keyboards/cannonkeys/satisfaction75/config.h
@@ -64,41 +64,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
-
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-
-// EEPROM usage
-
-// TODO: refactor with new user EEPROM code (coming soon)
-#define EEPROM_MAGIC 0x451F
-#define EEPROM_MAGIC_ADDR 40
-// Bump this every time we change what we store
-// This will automatically reset the EEPROM with defaults
-// and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x01
-#define EEPROM_VERSION_ADDR 42
-
-// Dynamic keymap starts after EEPROM version
-#define DYNAMIC_KEYMAP_EEPROM_ADDR 43
-
-// Dynamic macro starts after dynamic keymaps (35+(4*6*16*2)) = (35+768) = 803
-
-// I'm also putting my custom stuff after that
-// 1 for enabled encoder modes
-// 1 for custom backlighting controls
-// 1 for OLED default mode
-// 6 for 3x custom encoder settings, left, right, and press (18 total)
-
-#define DYNAMIC_KEYMAP_ENABLED_ENCODER_MODES 811
-#define DYNAMIC_KEYMAP_CUSTOM_BACKLIGHT 812
-#define DYNAMIC_KEYMAP_DEFAULT_OLED 813
-#define DYNAMIC_KEYMAP_CUSTOM_ENCODER 814
-
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 832
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 192
-#define DYNAMIC_KEYMAP_MACRO_COUNT 16
-
-
+// Custom config starts after VIA's EEPROM usage,
+// dynamic keymaps start after this.
+// Custom config Usage:
+// 1 for enabled encoder modes (1 byte)
+// 1 for custom backlighting controls (1 byte)
+// 1 for OLED default mode (1 byte)
+// 6 for 3x custom encoder settings, left, right, and press (18 bytes)
+#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 21
/*
* Feature disable options
diff --git a/keyboards/cannonkeys/satisfaction75/keymaps/boy_314/rules.mk b/keyboards/cannonkeys/satisfaction75/keymaps/boy_314/rules.mk
index 0dcaa7318..6f45dc73e 100644
--- a/keyboards/cannonkeys/satisfaction75/keymaps/boy_314/rules.mk
+++ b/keyboards/cannonkeys/satisfaction75/keymaps/boy_314/rules.mk
@@ -1,4 +1,3 @@
# rules.mk overrides to enable VIA
-RAW_ENABLE = yes
-DYNAMIC_KEYMAP_ENABLE = yes
+VIA_ENABLE = yes \ No newline at end of file
diff --git a/keyboards/cannonkeys/satisfaction75/keymaps/via/rules.mk b/keyboards/cannonkeys/satisfaction75/keymaps/via/rules.mk
index d12497792..1e5b99807 100644
--- a/keyboards/cannonkeys/satisfaction75/keymaps/via/rules.mk
+++ b/keyboards/cannonkeys/satisfaction75/keymaps/via/rules.mk
@@ -1,5 +1 @@
-# rules.mk overrides to enable VIA
-
-RAW_ENABLE = yes
-DYNAMIC_KEYMAP_ENABLE = yes
-
+VIA_ENABLE = yes
diff --git a/keyboards/cannonkeys/satisfaction75/prototype/prototype.h b/keyboards/cannonkeys/satisfaction75/prototype/prototype.h
index 42e574f3e..ed4c7d793 100644
--- a/keyboards/cannonkeys/satisfaction75/prototype/prototype.h
+++ b/keyboards/cannonkeys/satisfaction75/prototype/prototype.h
@@ -17,3 +17,20 @@
{ K400, K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, KC_NO, K413, KC_NO, K415 }, \
{ K500, K501, K502, KC_NO, KC_NO, K505, KC_NO, KC_NO, KC_NO, K509, K510, K511, K512, K513, KC_NO, K515 } \
}
+
+// Expose All Keys - Split backspace - ISO Extra keys - Split space bottom row
+#define LAYOUT_all( \
+ K000, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, \
+ K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, \
+ K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K215, \
+ K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, K315, \
+ K400, K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, K413, K415, \
+ K500, K501, K502, K503, K505, K507, K509, K510, K511, K512, K513, K515 \
+) { \
+ { K000, KC_NO, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, KC_NO, KC_NO }, \
+ { K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115 }, \
+ { K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, KC_NO, K215 }, \
+ { K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, KC_NO, K315 }, \
+ { K400, K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, K413, KC_NO, K415 }, \
+ { K500, K501, K502, K503, KC_NO, K505, KC_NO, K507, KC_NO, K509, K510, K511, K512, K513, KC_NO, K515 } \
+}
diff --git a/keyboards/cannonkeys/satisfaction75/rules.mk b/keyboards/cannonkeys/satisfaction75/rules.mk
index 3e2877200..e81448d62 100644
--- a/keyboards/cannonkeys/satisfaction75/rules.mk
+++ b/keyboards/cannonkeys/satisfaction75/rules.mk
@@ -51,7 +51,4 @@ ENCODER_ENABLE = yes
QWIIC_ENABLE += MICRO_OLED
#BACKLIGHT_ENABLE = yes
-# RAW_ENABLE = yes
-# DYNAMIC_KEYMAP_ENABLE = yes
-
DEFAULT_FOLDER = cannonkeys/satisfaction75/rev1
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.c b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
index 12d3660da..0fe09c384 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
@@ -15,11 +15,7 @@
#include "raw_hid.h"
#include "dynamic_keymap.h"
#include "tmk_core/common/eeprom.h"
-
-// HACK
-#include "keyboards/wilba_tech/via_api.h" // Temporary hack
-#include "keyboards/wilba_tech/via_keycodes.h" // Temporary hack
-
+#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
/* Artificial delay added to get media keys to work in the encoder*/
#define MEDIA_KEY_DELAY 10
@@ -58,56 +54,20 @@ backlight_config_t kb_backlight_config = {
.level = BACKLIGHT_LEVELS
};
-bool eeprom_is_valid(void)
-{
- return (eeprom_read_word(((void*)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC &&
- eeprom_read_byte(((void*)EEPROM_VERSION_ADDR)) == EEPROM_VERSION);
-}
-
-void eeprom_set_valid(bool valid)
+#ifdef VIA_ENABLE
+void raw_hid_receive_kb( uint8_t *data, uint8_t length )
{
- eeprom_update_word(((void*)EEPROM_MAGIC_ADDR), valid ? EEPROM_MAGIC : 0xFFFF);
- eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF);
-}
-
-void eeprom_reset(void)
-{
- // Set the VIA specific EEPROM state as invalid.
- eeprom_set_valid(false);
- // Set the TMK/QMK EEPROM state as invalid.
- eeconfig_disable();
-}
-
-#ifdef RAW_ENABLE
-
-void raw_hid_receive( uint8_t *data, uint8_t length )
-{
- uint8_t *command_id = &(data[0]);
- uint8_t *command_data = &(data[1]);
- switch ( *command_id )
- {
- case id_get_protocol_version:
- {
- command_data[0] = PROTOCOL_VERSION >> 8;
- command_data[1] = PROTOCOL_VERSION & 0xFF;
- break;
- }
- case id_get_keyboard_value:
- {
+ uint8_t *command_id = &(data[0]);
+ uint8_t *command_data = &(data[1]);
+ switch ( *command_id )
+ {
+ case id_get_keyboard_value:
+ {
switch( command_data[0])
{
- case id_uptime:
- {
- uint32_t value = timer_read32();
- command_data[1] = (value >> 24 ) & 0xFF;
- command_data[2] = (value >> 16 ) & 0xFF;
- command_data[3] = (value >> 8 ) & 0xFF;
- command_data[4] = value & 0xFF;
- break;
- }
case id_oled_default_mode:
{
- uint8_t default_oled = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_DEFAULT_OLED);
+ uint8_t default_oled = eeprom_read_byte((uint8_t*)EEPROM_DEFAULT_OLED);
command_data[1] = default_oled;
break;
}
@@ -141,15 +101,14 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
break;
}
}
- break;
+ break;
}
-#ifdef DYNAMIC_KEYMAP_ENABLE
case id_set_keyboard_value:
{
switch(command_data[0]){
case id_oled_default_mode:
{
- eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_DEFAULT_OLED, command_data[1]);
+ eeprom_update_byte((uint8_t*)EEPROM_DEFAULT_OLED, command_data[1]);
break;
}
case id_oled_mode:
@@ -161,7 +120,7 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
case id_encoder_modes:
{
enabled_encoder_modes = command_data[1];
- eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_ENABLED_ENCODER_MODES, enabled_encoder_modes);
+ eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, enabled_encoder_modes);
break;
}
case id_encoder_custom:
@@ -180,95 +139,15 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
}
break;
}
- case id_dynamic_keymap_get_keycode:
- {
- uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] );
- command_data[3] = keycode >> 8;
- command_data[4] = keycode & 0xFF;
- break;
- }
- case id_dynamic_keymap_set_keycode:
- {
- dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
- break;
- }
- case id_dynamic_keymap_reset:
- {
- dynamic_keymap_reset();
- break;
- }
- case id_dynamic_keymap_macro_get_count:
- {
- command_data[0] = dynamic_keymap_macro_get_count();
- break;
- }
- case id_dynamic_keymap_macro_get_buffer_size:
- {
- uint16_t size = dynamic_keymap_macro_get_buffer_size();
- command_data[0] = size >> 8;
- command_data[1] = size & 0xFF;
- break;
- }
- case id_dynamic_keymap_macro_get_buffer:
- {
- uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
- uint16_t size = command_data[2]; // size <= 28
- dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] );
- break;
- }
- case id_dynamic_keymap_macro_reset:
- {
- dynamic_keymap_macro_reset();
- break;
- }
- case id_dynamic_keymap_get_layer_count:
- {
- command_data[0] = dynamic_keymap_get_layer_count();
- break;
- }
- case id_dynamic_keymap_get_buffer:
- {
- uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
- uint16_t size = command_data[2]; // size <= 28
- dynamic_keymap_get_buffer( offset, size, &command_data[3] );
- break;
- }
- case id_dynamic_keymap_set_buffer:
- {
- uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
- uint16_t size = command_data[2]; // size <= 28
- dynamic_keymap_set_buffer( offset, size, &command_data[3] );
- break;
- }
-#endif // DYNAMIC_KEYMAP_ENABLE
- case id_eeprom_reset:
- {
- eeprom_reset();
- break;
- }
- case id_bootloader_jump:
- {
- // Need to send data back before the jump
- // Informs host that the command is handled
- raw_hid_send( data, length );
- // Give host time to read it
- wait_ms(100);
- bootloader_jump();
- break;
- }
- default:
- {
- // Unhandled message.
- *command_id = id_unhandled;
- break;
- }
- }
-
- // Return same buffer with values changed
- raw_hid_send( data, length );
-
+ default:
+ {
+ // Unhandled message.
+ *command_id = id_unhandled;
+ break;
+ }
+ }
+ // DO NOT call raw_hid_send(data,length) here, let caller do this
}
-
#endif
@@ -349,18 +228,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
break;
}
-#ifdef DYNAMIC_KEYMAP_ENABLE
- // Handle macros
- if (record->event.pressed) {
- if ( keycode >= MACRO00 && keycode <= MACRO15 )
- {
- uint8_t id = keycode - MACRO00;
- dynamic_keymap_macro_send(id);
- return false;
- }
- }
-#endif //DYNAMIC_KEYMAP_ENABLE
-
return process_record_user(keycode, record);
}
@@ -392,59 +259,56 @@ void encoder_update_kb(uint8_t index, bool clockwise) {
}
}
-void dynamic_keymap_custom_reset(void){
- void *p = (void*)(DYNAMIC_KEYMAP_CUSTOM_BACKLIGHT);
- void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
- while ( p != end ) {
- eeprom_update_byte(p, 0);
- ++p;
- }
- eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_ENABLED_ENCODER_MODES, 0x1F);
+void custom_config_reset(void){
+ void *p = (void*)(VIA_EEPROM_CUSTOM_CONFIG_ADDR);
+ void *end = (void*)(VIA_EEPROM_CUSTOM_CONFIG_ADDR+VIA_EEPROM_CUSTOM_CONFIG_SIZE);
+ while ( p != end ) {
+ eeprom_update_byte(p, 0);
+ ++p;
+ }
+ eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, 0x1F);
}
-void save_backlight_config_to_eeprom(){
- eeprom_update_byte((uint8_t*)DYNAMIC_KEYMAP_CUSTOM_BACKLIGHT, kb_backlight_config.raw);
+void backlight_config_save(){
+ eeprom_update_byte((uint8_t*)EEPROM_CUSTOM_BACKLIGHT, kb_backlight_config.raw);
}
-void load_custom_config(){
- kb_backlight_config.raw = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_CUSTOM_BACKLIGHT);
+void custom_config_load(){
+ kb_backlight_config.raw = eeprom_read_byte((uint8_t*)EEPROM_CUSTOM_BACKLIGHT);
#ifdef DYNAMIC_KEYMAP_ENABLE
- oled_mode = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_DEFAULT_OLED);
- enabled_encoder_modes = eeprom_read_byte((uint8_t*)DYNAMIC_KEYMAP_ENABLED_ENCODER_MODES);
+ oled_mode = eeprom_read_byte((uint8_t*)EEPROM_DEFAULT_OLED);
+ enabled_encoder_modes = eeprom_read_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES);
#endif
}
-void eeprom_init_kb(void)
+// Called from via_init() if VIA_ENABLE
+// Called from matrix_init_kb() if not VIA_ENABLE
+void via_init_kb(void)
{
- // If the EEPROM has the magic, the data is good.
- // OK to load from EEPROM.
- if (eeprom_is_valid()) {
- load_custom_config();
- } else {
- // If the EEPROM has not been saved before, or is out of date,
- // save the default values to the EEPROM. Default values
- // come from construction of the zeal_backlight_config instance.
- //backlight_config_save();
+ // If the EEPROM has the magic, the data is good.
+ // OK to load from EEPROM.
+ if (via_eeprom_is_valid()) {
+ custom_config_load();
+ } else {
#ifdef DYNAMIC_KEYMAP_ENABLE
- // This resets the keymaps in EEPROM to what is in flash.
- dynamic_keymap_reset();
- // This resets the macros in EEPROM to nothing.
- dynamic_keymap_macro_reset();
// Reset the custom stuff
- dynamic_keymap_custom_reset();
+ custom_config_reset();
#endif
- // Save the magic number last, in case saving was interrupted
- eeprom_set_valid(true);
- }
+ // DO NOT set EEPROM valid here, let caller do this
+ }
}
void matrix_init_kb(void)
{
- eeprom_init_kb();
+#ifndef VIA_ENABLE
+ via_init_kb();
+ via_eeprom_set_valid(true);
+#endif // VIA_ENABLE
+
rtcGetTime(&RTCD1, &last_timespec);
queue_for_send = true;
backlight_init_ports();
- matrix_init_user();
+ matrix_init_user();
}
@@ -472,3 +336,51 @@ void matrix_scan_kb(void) {
#endif
}
+//
+// In the case of VIA being disabled, we still need to check if
+// keyboard level EEPROM memory is valid before loading.
+// Thus these are copies of the same functions in VIA, since
+// the backlight settings reuse VIA's EEPROM magic/version,
+// and the ones in via.c won't be compiled in.
+//
+// Yes, this is sub-optimal, and is only here for completeness
+// (i.e. catering to the 1% of people that want wilba.tech LED bling
+// AND want persistent settings BUT DON'T want to use dynamic keymaps/VIA).
+//
+#ifndef VIA_ENABLE
+
+bool via_eeprom_is_valid(void)
+{
+ char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
+ uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
+ uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
+ uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
+
+ return (eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0 ) == magic0 &&
+ eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1 ) == magic1 &&
+ eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2 ) == magic2 );
+}
+
+// Sets VIA/keyboard level usage of EEPROM to valid/invalid
+// Keyboard level code (eg. via_init_kb()) should not call this
+void via_eeprom_set_valid(bool valid)
+{
+ char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
+ uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
+ uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
+ uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
+
+ eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0, valid ? magic0 : 0xFF);
+ eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1, valid ? magic1 : 0xFF);
+ eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2, valid ? magic2 : 0xFF);
+}
+
+void via_eeprom_reset(void)
+{
+ // Set the VIA specific EEPROM state as invalid.
+ via_eeprom_set_valid(false);
+ // Set the TMK/QMK EEPROM state as invalid.
+ eeconfig_disable();
+}
+
+#endif // VIA_ENABLE \ No newline at end of file
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.h b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
index 188a1d497..13aaf6888 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.h
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
@@ -8,6 +8,12 @@
#include "rev1.h"
#endif
+#include "via.h" // only for EEPROM address
+#define EEPROM_ENABLED_ENCODER_MODES (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
+#define EEPROM_CUSTOM_BACKLIGHT (VIA_EEPROM_CUSTOM_CONFIG_ADDR+1)
+#define EEPROM_DEFAULT_OLED (VIA_EEPROM_CUSTOM_CONFIG_ADDR+2)
+#define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+3)
+
/* screen off after this many milliseconds */
#define ScreenOffInterval 60000 /* milliseconds */
@@ -117,5 +123,5 @@ void backlight_set(uint8_t level);
bool is_breathing(void);
void breathing_enable(void);
void breathing_disable(void);
-void load_custom_config(void);
-void save_backlight_config_to_eeprom(void);
+void custom_config_load(void);
+void backlight_config_save(void);
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c
index e866d897c..8fcd720e2 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c
@@ -12,7 +12,7 @@ void pre_encoder_mode_change(){
timespec.millisecond = (hour_config * 60 + minute_config) * 60 * 1000;
rtcSetTime(&RTCD1, &timespec);
} else if (encoder_mode == ENC_MODE_BACKLIGHT){
- save_backlight_config_to_eeprom();
+ backlight_config_save();
}
}
@@ -221,7 +221,7 @@ uint16_t handle_encoder_press(){
uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior){
#ifdef DYNAMIC_KEYMAP_ENABLE
- void* addr = (void*)(DYNAMIC_KEYMAP_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
+ void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
//big endian
uint16_t keycode = eeprom_read_byte(addr) << 8;
keycode |= eeprom_read_byte(addr + 1);
@@ -233,7 +233,7 @@ uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior){
void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code){
#ifdef DYNAMIC_KEYMAP_ENABLE
- void* addr = (void*)(DYNAMIC_KEYMAP_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
+ void* addr = (void*)(EEPROM_CUSTOM_ENCODER + (encoder_idx * 6) + (behavior * 2));
eeprom_update_byte(addr, (uint8_t)(new_code >> 8));
eeprom_update_byte(addr + 1, (uint8_t)(new_code & 0xFF));
#endif
diff --git a/keyboards/cannonkeys/savage65/config.h b/keyboards/cannonkeys/savage65/config.h
index 996b93951..b69aba39e 100644
--- a/keyboards/cannonkeys/savage65/config.h
+++ b/keyboards/cannonkeys/savage65/config.h
@@ -58,25 +58,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PIN_WS2812 15
#define WS2812_SPI SPID2
-// EEPROM usage
-// TODO: refactor with new user EEPROM code (coming soon)
-#define EEPROM_MAGIC 0x451F
-#define EEPROM_MAGIC_ADDR 40
-// Bump this every time we change what we store
-// This will automatically reset the EEPROM with defaults
-// and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x02
-#define EEPROM_VERSION_ADDR 42
-
-
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-// Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600) = 635
-// start + layer * rows * col * 2
-#define DYNAMIC_KEYMAP_EEPROM_ADDR 43
-#define EEPROM_CUSTOM_BACKLIGHT 684
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 685
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 192
-#define DYNAMIC_KEYMAP_MACRO_COUNT 16
+// Backlight config starts after VIA's EEPROM usage,
+// dynamic keymaps start after this.
+#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
/*
* Feature disable options
diff --git a/keyboards/cannonkeys/stm32f072/keyboard.c b/keyboards/cannonkeys/stm32f072/keyboard.c
index 5a9ccafff..32e30f334 100644
--- a/keyboards/cannonkeys/stm32f072/keyboard.c
+++ b/keyboards/cannonkeys/stm32f072/keyboard.c
@@ -10,11 +10,10 @@
#include "raw_hid.h"
#include "dynamic_keymap.h"
#include "tmk_core/common/eeprom.h"
+#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
-// HACK
-#include "keyboards/wilba_tech/via_api.h" // Temporary hack
-#include "keyboards/wilba_tech/via_keycodes.h" // Temporary hack
-
+#include "via.h"
+#define EEPROM_CUSTOM_BACKLIGHT (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
backlight_config_t kb_backlight_config = {
.enable = true,
@@ -22,61 +21,29 @@ backlight_config_t kb_backlight_config = {
.level = BACKLIGHT_LEVELS
};
-bool eeprom_is_valid(void)
-{
- return (eeprom_read_word(((void*)EEPROM_MAGIC_ADDR)) == EEPROM_MAGIC &&
- eeprom_read_byte(((void*)EEPROM_VERSION_ADDR)) == EEPROM_VERSION);
-}
-
-void eeprom_set_valid(bool valid)
-{
- eeprom_update_word(((void*)EEPROM_MAGIC_ADDR), valid ? EEPROM_MAGIC : 0xFFFF);
- eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF);
-}
-
-void eeprom_reset(void)
-{
- eeprom_set_valid(false);
- eeconfig_disable();
-}
-
-void save_backlight_config_to_eeprom(){
+void backlight_config_save(){
eeprom_update_byte((uint8_t*)EEPROM_CUSTOM_BACKLIGHT, kb_backlight_config.raw);
}
-void load_custom_config(){
+void backlight_config_load(){
kb_backlight_config.raw = eeprom_read_byte((uint8_t*)EEPROM_CUSTOM_BACKLIGHT);
}
-#ifdef DYNAMIC_KEYMAP_ENABLE
-void dynamic_keymap_custom_reset(void){
- void *p = (void*)(EEPROM_CUSTOM_BACKLIGHT);
- void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
- while ( p != end ) {
- eeprom_update_byte(p, 0);
- ++p;
- }
-}
-#endif
-
-void eeprom_init_kb(void)
+// Called from via_init() if VIA_ENABLE
+// Called from matrix_init_kb() if not VIA_ENABLE
+void via_init_kb(void)
{
// If the EEPROM has the magic, the data is good.
// OK to load from EEPROM.
- if (eeprom_is_valid()) {
- load_custom_config();
+ if (via_eeprom_is_valid()) {
+ backlight_config_load();
} else {
-#ifdef DYNAMIC_KEYMAP_ENABLE
- // This resets the keymaps in EEPROM to what is in flash.
- dynamic_keymap_reset();
- // This resets the macros in EEPROM to nothing.
- dynamic_keymap_macro_reset();
- // Reset the custom stuff
- dynamic_keymap_custom_reset();
-#endif
- // Save the magic number last, in case saving was interrupted
- save_backlight_config_to_eeprom();
- eeprom_set_valid(true);
+ // If the EEPROM has not been saved before, or is out of date,
+ // save the default values to the EEPROM. Default values
+ // come from construction of the backlight_config instance.
+ backlight_config_save();
+
+ // DO NOT set EEPROM valid here, let caller do this
}
}
@@ -84,7 +51,13 @@ __attribute__ ((weak))
void matrix_init_board(void);
void matrix_init_kb(void){
- eeprom_init_kb();
+ // If VIA is disabled, we still need to load backlight settings.
+ // Call via_init_kb() the same way as via_init(), with setting
+ // EEPROM valid afterwards.
+#ifndef VIA_ENABLE
+ via_init_kb();
+ via_eeprom_set_valid(true);
+#endif // VIA_ENABLE
/* MOSI pin*/
#ifdef RGBLIGHT_ENABLE
palSetPadMode(PORT_WS2812, PIN_WS2812, PAL_MODE_ALTERNATE(0));
@@ -112,7 +85,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
kb_backlight_config.level = BACKLIGHT_LEVELS;
}
backlight_set(kb_backlight_config.level);
- save_backlight_config_to_eeprom();
+ backlight_config_save();
}
return false;
case BL_TOGG:
@@ -123,7 +96,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
} else {
backlight_set(0);
}
- save_backlight_config_to_eeprom();
+ backlight_config_save();
}
return false;
@@ -135,168 +108,71 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
kb_backlight_config.level = kb_backlight_config.level - 1;
}
backlight_set(kb_backlight_config.level);
- save_backlight_config_to_eeprom();
+ backlight_config_save();
}
return false;
case BL_BRTG:
if (record->event.pressed) {
kb_backlight_config.breathing = !kb_backlight_config.breathing;
breathing_toggle();
- save_backlight_config_to_eeprom();
+ backlight_config_save();
}
return false;
default:
break;
}
- #ifdef DYNAMIC_KEYMAP_ENABLE
- // Handle macros
- if (record->event.pressed) {
- if ( keycode >= MACRO00 && keycode <= MACRO15 )
- {
- uint8_t id = keycode - MACRO00;
- dynamic_keymap_macro_send(id);
- return false;
- }
- }
- #endif //DYNAMIC_KEYMAP_ENABLE
-
return process_record_user(keycode, record);;
}
-// Start Dynamic Keymap code
-#ifdef RAW_ENABLE
-void raw_hid_receive( uint8_t *data, uint8_t length )
-{
- uint8_t *command_id = &(data[0]);
- uint8_t *command_data = &(data[1]);
- switch ( *command_id )
- {
- case id_get_protocol_version:
- {
- command_data[0] = PROTOCOL_VERSION >> 8;
- command_data[1] = PROTOCOL_VERSION & 0xFF;
- break;
- }
- case id_get_keyboard_value:
- {
- switch( command_data[0])
- {
- case id_uptime:
- {
- uint32_t value = timer_read32();
- command_data[1] = (value >> 24 ) & 0xFF;
- command_data[2] = (value >> 16 ) & 0xFF;
- command_data[3] = (value >> 8 ) & 0xFF;
- command_data[4] = value & 0xFF;
- break;
- }
- default:
- {
- *command_id = id_unhandled;
- break;
- }
- }
- break;
- }
-#ifdef DYNAMIC_KEYMAP_ENABLE
- case id_dynamic_keymap_get_keycode:
- {
- uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] );
- command_data[3] = keycode >> 8;
- command_data[4] = keycode & 0xFF;
- break;
- }
- case id_dynamic_keymap_set_keycode:
- {
- dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
- break;
- }
- case id_dynamic_keymap_reset:
- {
- dynamic_keymap_reset();
- break;
- }
- case id_dynamic_keymap_macro_get_count:
- {
- command_data[0] = dynamic_keymap_macro_get_count();
- break;
- }
- case id_dynamic_keymap_macro_get_buffer_size:
- {
- uint16_t size = dynamic_keymap_macro_get_buffer_size();
- command_data[0] = size >> 8;
- command_data[1] = size & 0xFF;
- break;
- }
- case id_dynamic_keymap_macro_get_buffer:
- {
- uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
- uint16_t size = command_data[2]; // size <= 28
- dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] );
- break;
- }
- case id_dynamic_keymap_macro_set_buffer:
- {
- uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
- uint16_t size = command_data[2]; // size <= 28
- dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] );
- break;
- }
- case id_dynamic_keymap_macro_reset:
- {
- dynamic_keymap_macro_reset();
- break;
- }
- case id_dynamic_keymap_get_layer_count:
- {
- command_data[0] = dynamic_keymap_get_layer_count();
- break;
- }
- case id_dynamic_keymap_get_buffer:
- {
- uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
- uint16_t size = command_data[2]; // size <= 28
- dynamic_keymap_get_buffer( offset, size, &command_data[3] );
- break;
- }
- case id_dynamic_keymap_set_buffer:
- {
- uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
- uint16_t size = command_data[2]; // size <= 28
- dynamic_keymap_set_buffer( offset, size, &command_data[3] );
- break;
- }
-#endif // DYNAMIC_KEYMAP_ENABLE
- case id_eeprom_reset:
- {
- eeprom_reset();
- break;
- }
- case id_bootloader_jump:
- {
- // Need to send data back before the jump
- // Informs host that the command is handled
- raw_hid_send( data, length );
- // Give host time to read it
- wait_ms(100);
- bootloader_jump();
- break;
- }
- default:
- {
- // Unhandled message.
- *command_id = id_unhandled;
- break;
- }
- }
+//
+// In the case of VIA being disabled, we still need to check if
+// keyboard level EEPROM memory is valid before loading.
+// Thus these are copies of the same functions in VIA, since
+// the backlight settings reuse VIA's EEPROM magic/version,
+// and the ones in via.c won't be compiled in.
+//
+// Yes, this is sub-optimal, and is only here for completeness
+// (i.e. catering to the 1% of people that want wilba.tech LED bling
+// AND want persistent settings BUT DON'T want to use dynamic keymaps/VIA).
+//
+#ifndef VIA_ENABLE
- // Return same buffer with values changed
- raw_hid_send( data, length );
+bool via_eeprom_is_valid(void)
+{
+ char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
+ uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
+ uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
+ uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
+
+ return (eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0 ) == magic0 &&
+ eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1 ) == magic1 &&
+ eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2 ) == magic2 );
+}
+// Sets VIA/keyboard level usage of EEPROM to valid/invalid
+// Keyboard level code (eg. via_init_kb()) should not call this
+void via_eeprom_set_valid(bool valid)
+{
+ char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
+ uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F );
+ uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F );
+ uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
+
+ eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0, valid ? magic0 : 0xFF);
+ eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1, valid ? magic1 : 0xFF);
+ eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2, valid ? magic2 : 0xFF);
}
-#endif
+void via_eeprom_reset(void)
+{
+ // Set the VIA specific EEPROM state as invalid.
+ via_eeprom_set_valid(false);
+ // Set the TMK/QMK EEPROM state as invalid.
+ eeconfig_disable();
+}
+
+#endif // VIA_ENABLE \ No newline at end of file
diff --git a/keyboards/cannonkeys/stm32f072/keyboard.h b/keyboards/cannonkeys/stm32f072/keyboard.h
index 94c973d61..81dd1b704 100644
--- a/keyboards/cannonkeys/stm32f072/keyboard.h
+++ b/keyboards/cannonkeys/stm32f072/keyboard.h
@@ -19,5 +19,5 @@ void backlight_set(uint8_t level);
bool is_breathing(void);
void breathing_enable(void);
void breathing_disable(void);
-void load_custom_config(void);
-void save_backlight_config_to_eeprom(void);
+void backlight_config_load(void);
+void backlight_config_save(void);
diff --git a/keyboards/cannonkeys/tmov2/config.h b/keyboards/cannonkeys/tmov2/config.h
index 0c586de9e..d5f1d0788 100644
--- a/keyboards/cannonkeys/tmov2/config.h
+++ b/keyboards/cannonkeys/tmov2/config.h
@@ -58,25 +58,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PIN_WS2812 15
#define WS2812_SPI SPID2
-// EEPROM usage
-// TODO: refactor with new user EEPROM code (coming soon)
-#define EEPROM_MAGIC 0x451F
-#define EEPROM_MAGIC_ADDR 40
-// Bump this every time we change what we store
-// This will automatically reset the EEPROM with defaults
-// and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x02
-#define EEPROM_VERSION_ADDR 42
-
-
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-// Dynamic macro starts after dynamic keymaps (43+(4*4*15*2)) = (43+480) = 523
-// start + layer * rows * col * 2c
-#define DYNAMIC_KEYMAP_EEPROM_ADDR 43
-#define EEPROM_CUSTOM_BACKLIGHT 523
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 524
-#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 200
-#define DYNAMIC_KEYMAP_MACRO_COUNT 16
+// Backlight config starts after VIA's EEPROM usage,
+// dynamic keymaps start after this.
+#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 1
/*
* Feature disable options