diff options
| author | Wilba <Jason.S.Williams@gmail.com> | 2018-12-01 03:43:34 +1100 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-11-30 08:43:34 -0800 |
| commit | d7f1e072a859d7fcbaccd675b4bad7d02d214e52 (patch) | |
| tree | fb24714b6f37ef58f265802897a5225abf171753 | |
| parent | b10aad45b60326c7e9f2d1fc67e45bd201341552 (diff) | |
| download | qmk_firmware-d7f1e072a859d7fcbaccd675b4bad7d02d214e52.tar.gz qmk_firmware-d7f1e072a859d7fcbaccd675b4bad7d02d214e52.zip | |
Added macros to Dynamic Keymaps, Zeal60 RGB backlight improvements (#4520)
* Refactored M6-B to use Zeal60 RGB backlight code
* Fixed M6-B LED co-ordinates
* Minor changes to RGB config for Zeal65
* Added dynamic keymaps to WT80-A, WT60-A, WT-80A, U80-A
* Macro implementation
* Implemented macros, API protocol version 8, RGB backlight fixes
* Improved radial effects for M6-B
* Fixed undefined references when building an RGB keyboard after M6-A
| -rw-r--r-- | keyboards/rama/m60_a/config.h | 13 | ||||
| -rw-r--r-- | keyboards/rama/m60_a/rules.mk | 4 | ||||
| -rw-r--r-- | keyboards/rama/m6_a/config.h | 14 | ||||
| -rw-r--r-- | keyboards/rama/m6_a/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/rama/m6_b/config.h | 11 | ||||
| -rw-r--r-- | keyboards/rama/m6_b/rules.mk | 4 | ||||
| -rw-r--r-- | keyboards/rama/u80_a/config.h | 10 | ||||
| -rw-r--r-- | keyboards/wilba_tech/wt60_a/config.h | 12 | ||||
| -rw-r--r-- | keyboards/wilba_tech/wt65_a/config.h | 12 | ||||
| -rw-r--r-- | keyboards/wilba_tech/wt80_a/config.h | 12 | ||||
| -rw-r--r-- | keyboards/wilba_tech/wt_main.c | 92 | ||||
| -rw-r--r-- | keyboards/zeal60/config.h | 10 | ||||
| -rw-r--r-- | keyboards/zeal60/rgb_backlight.c | 131 | ||||
| -rw-r--r-- | keyboards/zeal60/rgb_backlight.h | 25 | ||||
| -rw-r--r-- | keyboards/zeal60/rgb_backlight_api.h | 3 | ||||
| -rw-r--r-- | keyboards/zeal60/zeal60.c | 88 | ||||
| -rw-r--r-- | keyboards/zeal60/zeal60_api.h | 10 | ||||
| -rw-r--r-- | keyboards/zeal60/zeal60_keycodes.h | 18 | ||||
| -rw-r--r-- | keyboards/zeal65/config.h | 10 | ||||
| -rw-r--r-- | keyboards/zeal65/rules.mk | 4 | ||||
| -rw-r--r-- | quantum/dynamic_keymap.c | 147 | ||||
| -rw-r--r-- | quantum/dynamic_keymap.h | 35 |
22 files changed, 561 insertions, 106 deletions
diff --git a/keyboards/rama/m60_a/config.h b/keyboards/rama/m60_a/config.h index 03794965f..01cfe05a5 100644 --- a/keyboards/rama/m60_a/config.h +++ b/keyboards/rama/m60_a/config.h | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #define MATRIX_ROWS 5 | 31 | #define MATRIX_ROWS 5 |
| 32 | #define MATRIX_COLS 14 | 32 | #define MATRIX_COLS 14 |
| 33 | 33 | ||
| 34 | // Zeal60 PCB default pin-out | 34 | // M60-A PCB default pin-out |
| 35 | #define MATRIX_ROW_PINS { F0, F1, F4, F6, F7 } | 35 | #define MATRIX_ROW_PINS { F0, F1, F4, F6, F7 } |
| 36 | #define MATRIX_COL_PINS { F5, D5, B1, B2, B3, D3, D2, C7, C6, B6, B5, B4, D7, D6 } | 36 | #define MATRIX_COL_PINS { F5, D5, B1, B2, B3, D3, D2, C7, C6, B6, B5, B4, D7, D6 } |
| 37 | #define UNUSED_PINS | 37 | #define UNUSED_PINS |
| @@ -118,11 +118,14 @@ | |||
| 118 | // Bump this every time we change what we store | 118 | // Bump this every time we change what we store |
| 119 | // This will automatically reset the EEPROM with defaults | 119 | // This will automatically reset the EEPROM with defaults |
| 120 | // and avoid loading invalid data from the EEPROM | 120 | // and avoid loading invalid data from the EEPROM |
| 121 | #define EEPROM_VERSION 0x07 | 121 | #define EEPROM_VERSION 0x08 |
| 122 | #define EEPROM_VERSION_ADDR 34 | 122 | #define EEPROM_VERSION_ADDR 34 |
| 123 | 123 | ||
| 124 | // Backlight config starts after EEPROM version | 124 | // Backlight config starts after EEPROM version |
| 125 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 125 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 |
| 126 | // Dynamic keymap starts after backlight config (35+37) | 126 | // Dynamic keymap starts after backlight config (35+31) |
| 127 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 127 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 66 |
| 128 | 128 | // Dynamic macro starts after dynamic keymaps (66+(4*5*14*2)) = (66+560) | |
| 129 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 626 | ||
| 130 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 398 | ||
| 131 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
diff --git a/keyboards/rama/m60_a/rules.mk b/keyboards/rama/m60_a/rules.mk index 9c1a2d9df..09ed03e95 100644 --- a/keyboards/rama/m60_a/rules.mk +++ b/keyboards/rama/m60_a/rules.mk | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | 1 | ||
| 2 | 2 | ||
| 3 | # project specific files | 3 | # project specific files |
| 4 | SRC = ../zeal60/zeal60.c \ | 4 | SRC = keyboards/zeal60/zeal60.c \ |
| 5 | ../zeal60/rgb_backlight.c \ | 5 | keyboards/zeal60/rgb_backlight.c \ |
| 6 | quantum/color.c \ | 6 | quantum/color.c \ |
| 7 | drivers/issi/is31fl3731.c \ | 7 | drivers/issi/is31fl3731.c \ |
| 8 | drivers/avr/i2c_master.c | 8 | drivers/avr/i2c_master.c |
diff --git a/keyboards/rama/m6_a/config.h b/keyboards/rama/m6_a/config.h index 63da79274..049749bd7 100644 --- a/keyboards/rama/m6_a/config.h +++ b/keyboards/rama/m6_a/config.h | |||
| @@ -119,11 +119,17 @@ | |||
| 119 | // Bump this every time we change what we store | 119 | // Bump this every time we change what we store |
| 120 | // This will automatically reset the EEPROM with defaults | 120 | // This will automatically reset the EEPROM with defaults |
| 121 | // and avoid loading invalid data from the EEPROM | 121 | // and avoid loading invalid data from the EEPROM |
| 122 | #define EEPROM_VERSION 0x07 | 122 | #define EEPROM_VERSION 0x08 |
| 123 | #define EEPROM_VERSION_ADDR 34 | 123 | #define EEPROM_VERSION_ADDR 34 |
| 124 | 124 | ||
| 125 | // NOTE: M6-A doesn't use RGB backlight, but we keep this | ||
| 126 | // consistent with M6-B which does. | ||
| 127 | |||
| 125 | // Backlight config starts after EEPROM version | 128 | // Backlight config starts after EEPROM version |
| 126 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 129 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 |
| 127 | // Dynamic keymap starts after backlight config (35+37) | 130 | // Dynamic keymap starts after backlight config (35+43) |
| 128 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 131 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 78 |
| 129 | 132 | // Dynamic macro starts after dynamic keymaps (78+(4*6*2)) = (78+48) | |
| 133 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 126 | ||
| 134 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 898 | ||
| 135 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
diff --git a/keyboards/rama/m6_a/rules.mk b/keyboards/rama/m6_a/rules.mk index ff1706918..399e9e80d 100644 --- a/keyboards/rama/m6_a/rules.mk +++ b/keyboards/rama/m6_a/rules.mk | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # project specific files | 1 | # project specific files |
| 2 | SRC = ../zeal60/zeal60.c | 2 | SRC = keyboards/zeal60/zeal60.c |
| 3 | 3 | ||
| 4 | # MCU name | 4 | # MCU name |
| 5 | MCU = atmega32u4 | 5 | MCU = atmega32u4 |
diff --git a/keyboards/rama/m6_b/config.h b/keyboards/rama/m6_b/config.h index c016703e0..67034ef8c 100644 --- a/keyboards/rama/m6_b/config.h +++ b/keyboards/rama/m6_b/config.h | |||
| @@ -150,11 +150,14 @@ | |||
| 150 | // Bump this every time we change what we store | 150 | // Bump this every time we change what we store |
| 151 | // This will automatically reset the EEPROM with defaults | 151 | // This will automatically reset the EEPROM with defaults |
| 152 | // and avoid loading invalid data from the EEPROM | 152 | // and avoid loading invalid data from the EEPROM |
| 153 | #define EEPROM_VERSION 0x07 | 153 | #define EEPROM_VERSION 0x08 |
| 154 | #define EEPROM_VERSION_ADDR 34 | 154 | #define EEPROM_VERSION_ADDR 34 |
| 155 | 155 | ||
| 156 | // Backlight config starts after EEPROM version | 156 | // Backlight config starts after EEPROM version |
| 157 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 157 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 |
| 158 | // Dynamic keymap starts after backlight config (35+37) | 158 | // Dynamic keymap starts after backlight config (35+43) |
| 159 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 159 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 78 |
| 160 | 160 | // Dynamic macro starts after dynamic keymaps (78+(4*6*2)) = (78+48) | |
| 161 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 126 | ||
| 162 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 898 | ||
| 163 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
diff --git a/keyboards/rama/m6_b/rules.mk b/keyboards/rama/m6_b/rules.mk index 1a7466af3..b7a76b8dd 100644 --- a/keyboards/rama/m6_b/rules.mk +++ b/keyboards/rama/m6_b/rules.mk | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # project specific files | 1 | # project specific files |
| 2 | SRC = ../zeal60/zeal60.c \ | 2 | SRC = keyboards/zeal60/zeal60.c \ |
| 3 | ../zeal60/rgb_backlight.c \ | 3 | keyboards/zeal60/rgb_backlight.c \ |
| 4 | quantum/color.c \ | 4 | quantum/color.c \ |
| 5 | drivers/issi/is31fl3218.c \ | 5 | drivers/issi/is31fl3218.c \ |
| 6 | drivers/avr/i2c_master.c | 6 | drivers/avr/i2c_master.c |
diff --git a/keyboards/rama/u80_a/config.h b/keyboards/rama/u80_a/config.h index 9c74735ad..b5dc27598 100644 --- a/keyboards/rama/u80_a/config.h +++ b/keyboards/rama/u80_a/config.h | |||
| @@ -198,7 +198,9 @@ | |||
| 198 | #define EEPROM_VERSION 0x07 | 198 | #define EEPROM_VERSION 0x07 |
| 199 | #define EEPROM_VERSION_ADDR 34 | 199 | #define EEPROM_VERSION_ADDR 34 |
| 200 | 200 | ||
| 201 | // Backlight config starts after EEPROM version | 201 | // Dynamic keymap starts after EEPROM version |
| 202 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 202 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 35 |
| 203 | // Dynamic keymap starts after backlight config (35+37) | 203 | // Dynamic macro starts after dynamic keymaps (35+(4*6*17*2)) = (35+816) |
| 204 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 204 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 851 |
| 205 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 173 | ||
| 206 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
diff --git a/keyboards/wilba_tech/wt60_a/config.h b/keyboards/wilba_tech/wt60_a/config.h index 26f9ed2ba..8c18582a8 100644 --- a/keyboards/wilba_tech/wt60_a/config.h +++ b/keyboards/wilba_tech/wt60_a/config.h | |||
| @@ -195,10 +195,12 @@ | |||
| 195 | // Bump this every time we change what we store | 195 | // Bump this every time we change what we store |
| 196 | // This will automatically reset the EEPROM with defaults | 196 | // This will automatically reset the EEPROM with defaults |
| 197 | // and avoid loading invalid data from the EEPROM | 197 | // and avoid loading invalid data from the EEPROM |
| 198 | #define EEPROM_VERSION 0x07 | 198 | #define EEPROM_VERSION 0x08 |
| 199 | #define EEPROM_VERSION_ADDR 34 | 199 | #define EEPROM_VERSION_ADDR 34 |
| 200 | 200 | ||
| 201 | // Backlight config starts after EEPROM version | 201 | // Dynamic keymap starts after EEPROM version |
| 202 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 202 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 35 |
| 203 | // Dynamic keymap starts after backlight config (35+37) | 203 | // Dynamic macro starts after dynamic keymaps (35+(4*5*14*2)) = (35+560) |
| 204 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 204 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 595 |
| 205 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 429 | ||
| 206 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
diff --git a/keyboards/wilba_tech/wt65_a/config.h b/keyboards/wilba_tech/wt65_a/config.h index 5f535c6a7..88e902353 100644 --- a/keyboards/wilba_tech/wt65_a/config.h +++ b/keyboards/wilba_tech/wt65_a/config.h | |||
| @@ -195,10 +195,12 @@ | |||
| 195 | // Bump this every time we change what we store | 195 | // Bump this every time we change what we store |
| 196 | // This will automatically reset the EEPROM with defaults | 196 | // This will automatically reset the EEPROM with defaults |
| 197 | // and avoid loading invalid data from the EEPROM | 197 | // and avoid loading invalid data from the EEPROM |
| 198 | #define EEPROM_VERSION 0x07 | 198 | #define EEPROM_VERSION 0x08 |
| 199 | #define EEPROM_VERSION_ADDR 34 | 199 | #define EEPROM_VERSION_ADDR 34 |
| 200 | 200 | ||
| 201 | // Backlight config starts after EEPROM version | 201 | // Dynamic keymap starts after EEPROM version |
| 202 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 202 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 35 |
| 203 | // Dynamic keymap starts after backlight config (35+37) | 203 | // Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600) |
| 204 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 204 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 635 |
| 205 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 389 | ||
| 206 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
diff --git a/keyboards/wilba_tech/wt80_a/config.h b/keyboards/wilba_tech/wt80_a/config.h index f78ce7fb3..ca03c366e 100644 --- a/keyboards/wilba_tech/wt80_a/config.h +++ b/keyboards/wilba_tech/wt80_a/config.h | |||
| @@ -195,10 +195,12 @@ | |||
| 195 | // Bump this every time we change what we store | 195 | // Bump this every time we change what we store |
| 196 | // This will automatically reset the EEPROM with defaults | 196 | // This will automatically reset the EEPROM with defaults |
| 197 | // and avoid loading invalid data from the EEPROM | 197 | // and avoid loading invalid data from the EEPROM |
| 198 | #define EEPROM_VERSION 0x07 | 198 | #define EEPROM_VERSION 0x08 |
| 199 | #define EEPROM_VERSION_ADDR 34 | 199 | #define EEPROM_VERSION_ADDR 34 |
| 200 | 200 | ||
| 201 | // Backlight config starts after EEPROM version | 201 | // Dynamic keymap starts after EEPROM version |
| 202 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 202 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 35 |
| 203 | // Dynamic keymap starts after backlight config (35+37) | 203 | // Dynamic macro starts after dynamic keymaps (35+(4*6*17*2)) = (35+816) |
| 204 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 204 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 851 |
| 205 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 173 | ||
| 206 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c index 23f07d7eb..de6d7b92c 100644 --- a/keyboards/wilba_tech/wt_main.c +++ b/keyboards/wilba_tech/wt_main.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "quantum.h" | 17 | #include "quantum.h" |
| 18 | #include "keyboards/wilba_tech/wt_mono_backlight.h" | 18 | #include "keyboards/wilba_tech/wt_mono_backlight.h" |
| 19 | #include "keyboards/zeal60/zeal60_api.h" // Temporary hack | 19 | #include "keyboards/zeal60/zeal60_api.h" // Temporary hack |
| 20 | #include "keyboards/zeal60/zeal60_keycodes.h" // Temporary hack | ||
| 20 | 21 | ||
| 21 | #include "raw_hid.h" | 22 | #include "raw_hid.h" |
| 22 | #include "dynamic_keymap.h" | 23 | #include "dynamic_keymap.h" |
| @@ -91,22 +92,57 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 91 | dynamic_keymap_reset(); | 92 | dynamic_keymap_reset(); |
| 92 | break; | 93 | break; |
| 93 | } | 94 | } |
| 94 | #endif // DYNAMIC_KEYMAP_ENABLE | 95 | case id_dynamic_keymap_macro_get_count: |
| 95 | case id_backlight_config_set_value: | 96 | { |
| 97 | command_data[0] = dynamic_keymap_macro_get_count(); | ||
| 98 | break; | ||
| 99 | } | ||
| 100 | case id_dynamic_keymap_macro_get_buffer_size: | ||
| 101 | { | ||
| 102 | uint16_t size = dynamic_keymap_macro_get_buffer_size(); | ||
| 103 | command_data[0] = size >> 8; | ||
| 104 | command_data[1] = size & 0xFF; | ||
| 105 | break; | ||
| 106 | } | ||
| 107 | case id_dynamic_keymap_macro_get_buffer: | ||
| 108 | { | ||
| 109 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 110 | uint16_t size = command_data[2]; // size <= 28 | ||
| 111 | dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] ); | ||
| 112 | break; | ||
| 113 | } | ||
| 114 | case id_dynamic_keymap_macro_set_buffer: | ||
| 115 | { | ||
| 116 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 117 | uint16_t size = command_data[2]; // size <= 28 | ||
| 118 | dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] ); | ||
| 119 | break; | ||
| 120 | } | ||
| 121 | case id_dynamic_keymap_macro_reset: | ||
| 122 | { | ||
| 123 | dynamic_keymap_macro_reset(); | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | case id_dynamic_keymap_get_layer_count: | ||
| 96 | { | 127 | { |
| 97 | //backlight_config_set_value(command_data); | 128 | command_data[0] = dynamic_keymap_get_layer_count(); |
| 98 | break; | 129 | break; |
| 99 | } | 130 | } |
| 100 | case id_backlight_config_get_value: | 131 | case id_dynamic_keymap_get_buffer: |
| 101 | { | 132 | { |
| 102 | //backlight_config_get_value(command_data); | 133 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; |
| 134 | uint16_t size = command_data[2]; // size <= 28 | ||
| 135 | dynamic_keymap_get_buffer( offset, size, &command_data[3] ); | ||
| 103 | break; | 136 | break; |
| 104 | } | 137 | } |
| 105 | case id_backlight_config_save: | 138 | case id_dynamic_keymap_set_buffer: |
| 106 | { | 139 | { |
| 107 | //backlight_config_save(); | 140 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; |
| 141 | uint16_t size = command_data[2]; // size <= 28 | ||
| 142 | dynamic_keymap_set_buffer( offset, size, &command_data[3] ); | ||
| 108 | break; | 143 | break; |
| 109 | } | 144 | } |
| 145 | #endif // DYNAMIC_KEYMAP_ENABLE | ||
| 110 | case id_eeprom_reset: | 146 | case id_eeprom_reset: |
| 111 | { | 147 | { |
| 112 | eeprom_reset(); | 148 | eeprom_reset(); |
| @@ -151,6 +187,8 @@ void main_init(void) | |||
| 151 | #ifdef DYNAMIC_KEYMAP_ENABLE | 187 | #ifdef DYNAMIC_KEYMAP_ENABLE |
| 152 | // This resets the keymaps in EEPROM to what is in flash. | 188 | // This resets the keymaps in EEPROM to what is in flash. |
| 153 | dynamic_keymap_reset(); | 189 | dynamic_keymap_reset(); |
| 190 | // This resets the macros in EEPROM to nothing. | ||
| 191 | dynamic_keymap_macro_reset(); | ||
| 154 | #endif | 192 | #endif |
| 155 | // Save the magic number last, in case saving was interrupted | 193 | // Save the magic number last, in case saving was interrupted |
| 156 | eeprom_set_valid(true); | 194 | eeprom_set_valid(true); |
| @@ -196,3 +234,43 @@ void matrix_scan_kb(void) | |||
| 196 | backlight_update_pwm_buffers(); | 234 | backlight_update_pwm_buffers(); |
| 197 | matrix_scan_user(); | 235 | matrix_scan_user(); |
| 198 | } | 236 | } |
| 237 | |||
| 238 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) | ||
| 239 | { | ||
| 240 | switch(keycode) { | ||
| 241 | case FN_MO13: | ||
| 242 | if (record->event.pressed) { | ||
| 243 | layer_on(1); | ||
| 244 | update_tri_layer(1, 2, 3); | ||
| 245 | } else { | ||
| 246 | layer_off(1); | ||
| 247 | update_tri_layer(1, 2, 3); | ||
| 248 | } | ||
| 249 | return false; | ||
| 250 | break; | ||
| 251 | case FN_MO23: | ||
| 252 | if (record->event.pressed) { | ||
| 253 | layer_on(2); | ||
| 254 | update_tri_layer(1, 2, 3); | ||
| 255 | } else { | ||
| 256 | layer_off(2); | ||
| 257 | update_tri_layer(1, 2, 3); | ||
| 258 | } | ||
| 259 | return false; | ||
| 260 | break; | ||
| 261 | } | ||
| 262 | |||
| 263 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 264 | // Handle macros | ||
| 265 | if (record->event.pressed) { | ||
| 266 | if ( keycode >= MACRO00 && keycode <= MACRO15 ) | ||
| 267 | { | ||
| 268 | uint8_t id = keycode - MACRO00; | ||
| 269 | dynamic_keymap_macro_send(id); | ||
| 270 | return false; | ||
| 271 | } | ||
| 272 | } | ||
| 273 | #endif //DYNAMIC_KEYMAP_ENABLE | ||
| 274 | |||
| 275 | return process_record_user(keycode, record); | ||
| 276 | } | ||
diff --git a/keyboards/zeal60/config.h b/keyboards/zeal60/config.h index baa4978a8..d1bd3f6a1 100644 --- a/keyboards/zeal60/config.h +++ b/keyboards/zeal60/config.h | |||
| @@ -115,11 +115,15 @@ | |||
| 115 | // Bump this every time we change what we store | 115 | // Bump this every time we change what we store |
| 116 | // This will automatically reset the EEPROM with defaults | 116 | // This will automatically reset the EEPROM with defaults |
| 117 | // and avoid loading invalid data from the EEPROM | 117 | // and avoid loading invalid data from the EEPROM |
| 118 | #define EEPROM_VERSION 0x07 | 118 | #define EEPROM_VERSION 0x08 |
| 119 | #define EEPROM_VERSION_ADDR 34 | 119 | #define EEPROM_VERSION_ADDR 34 |
| 120 | 120 | ||
| 121 | // Backlight config starts after EEPROM version | 121 | // Backlight config starts after EEPROM version |
| 122 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 122 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 |
| 123 | // Dynamic keymap starts after backlight config (35+37) | 123 | // Dynamic keymap starts after backlight config (35+31) |
| 124 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 124 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 66 |
| 125 | // Dynamic macro starts after dynamic keymaps (66+(4*5*14*2)) = (66+560) | ||
| 126 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 626 | ||
| 127 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 398 | ||
| 128 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
| 125 | 129 | ||
diff --git a/keyboards/zeal60/rgb_backlight.c b/keyboards/zeal60/rgb_backlight.c index c3dade123..64b95059e 100644 --- a/keyboards/zeal60/rgb_backlight.c +++ b/keyboards/zeal60/rgb_backlight.c | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #if RGB_BACKLIGHT_ENABLED | 16 | #if RGB_BACKLIGHT_ENABLED |
| 17 | 17 | ||
| 18 | #if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A) || defined(RGB_BACKLIGHT_M6_B) | 18 | #if defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_ZEAL65) || defined (RGB_BACKLIGHT_M60_A) || defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_KOYU) |
| 19 | #else | 19 | #else |
| 20 | #error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A, RGB_BACKLIGHT_M6_B | 20 | #error None of the following was defined: RGB_BACKLIGHT_ZEAL60, RGB_BACKLIGHT_ZEAL65, RGB_BACKLIGHT_M60_A, RGB_BACKLIGHT_M6_B, RGB_BACKLIGHT_KOYU |
| 21 | #endif | 21 | #endif |
| 22 | 22 | ||
| 23 | #include "quantum.h" | 23 | #include "quantum.h" |
| @@ -55,18 +55,21 @@ backlight_config g_config = { | |||
| 55 | .brightness = 255, | 55 | .brightness = 255, |
| 56 | .effect = RGB_BACKLIGHT_EFFECT, | 56 | .effect = RGB_BACKLIGHT_EFFECT, |
| 57 | .effect_speed = 0, | 57 | .effect_speed = 0, |
| 58 | .color_1 = { .h = 0, .s = 255, .v = 255 }, | 58 | .color_1 = { .h = 0, .s = 255 }, |
| 59 | .color_2 = { .h = 127, .s = 255, .v = 255 }, | 59 | .color_2 = { .h = 127, .s = 255 }, |
| 60 | .caps_lock_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 }, | 60 | .caps_lock_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 }, |
| 61 | .layer_1_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 }, | 61 | .layer_1_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 }, |
| 62 | .layer_2_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 }, | 62 | .layer_2_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 }, |
| 63 | .layer_3_indicator = { .color = { .h = 0, .s = 0, .v = 255 }, .index = 255 }, | 63 | .layer_3_indicator = { .color = { .h = 0, .s = 0 }, .index = 255 }, |
| 64 | .alphas_mods = { | 64 | .alphas_mods = { |
| 65 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_0, | 65 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_0, |
| 66 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_1, | 66 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_1, |
| 67 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_2, | 67 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_2, |
| 68 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_3, | 68 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_3, |
| 69 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 } | 69 | RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 }, |
| 70 | #if defined(RGB_BACKLIGHT_M6_B) | ||
| 71 | .custom_color = { { 0, 255 }, { 43, 255 }, { 85, 255 }, { 128, 255 }, { 171, 255 }, { 213, 255 } } | ||
| 72 | #endif | ||
| 70 | }; | 73 | }; |
| 71 | 74 | ||
| 72 | bool g_suspend_state = false; | 75 | bool g_suspend_state = false; |
| @@ -199,7 +202,7 @@ const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { | |||
| 199 | }; | 202 | }; |
| 200 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { | 203 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { |
| 201 | // LA0..LA17 | 204 | // LA0..LA17 |
| 202 | {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,247}, | 205 | {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,243}, |
| 203 | {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255}, | 206 | {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255}, |
| 204 | // LB0..LB17 | 207 | // LB0..LB17 |
| 205 | {56,255}, {51,255}, {46,255}, {42,255}, {37,255}, {35,255}, {32,255}, {19,255}, {0,255}, | 208 | {56,255}, {51,255}, {46,255}, {42,255}, {37,255}, {35,255}, {32,255}, {19,255}, {0,255}, |
| @@ -208,8 +211,37 @@ const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { | |||
| 208 | {184,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {255,255}, {167,255}, {165,255}, | 211 | {184,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {255,255}, {167,255}, {165,255}, |
| 209 | {128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {145,233}, {148,255}, {161,255}, | 212 | {128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {145,233}, {148,255}, {161,255}, |
| 210 | // LD0..LD17 | 213 | // LD0..LD17 |
| 211 | {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {255,201}, {224,181}, {230,217}, {235,255}, | 214 | {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {0,201}, {224,181}, {230,217}, {235,255}, |
| 212 | {189,128}, {200,131}, {210,141}, {218,159}, {201,228}, {201,228}, {206,255}, {213,255}, {218,255} | 215 | {189,128}, {200,131}, {210,141}, {218,159}, {255,255}, {201,228}, {206,255}, {213,255}, {218,255} |
| 216 | }; | ||
| 217 | #elif defined (RGB_BACKLIGHT_KOYU) | ||
| 218 | const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { | ||
| 219 | // LA0..LA17 | ||
| 220 | {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32}, | ||
| 221 | {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0}, | ||
| 222 | // LB0..LB17 | ||
| 223 | {144,0}, {160,0}, {176,0}, {192,0}, {208,0}, {224,0}, {240,0}, {240,16}, {240,32}, | ||
| 224 | {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {220,16}, {240,48}, {240,64}, {224,64}, | ||
| 225 | // LC0..LC17 | ||
| 226 | {112,64}, {100,48}, {84,48}, {68,48}, {52,48}, {36,48}, {64,60}, {44,60}, {24,64}, | ||
| 227 | {108,32}, {92,32}, {76,32}, {60,32}, {44,32}, {28,32}, {255,255}, {10,48}, {4,64}, | ||
| 228 | // LD0..LD17 | ||
| 229 | {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48}, | ||
| 230 | {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {160,60}, {180,64}, {208,64}, {255,255} | ||
| 231 | }; | ||
| 232 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { | ||
| 233 | // LA0..LA17 | ||
| 234 | {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,243}, | ||
| 235 | {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255}, | ||
| 236 | // LB0..LB17 | ||
| 237 | {56,255}, {51,255}, {46,255}, {42,255}, {38,255}, {35,255}, {32,255}, {19,255}, {0,255}, | ||
| 238 | {53,132}, {44,145}, {37,164}, {31,187}, {26,213}, {22,249}, {237,255}, {224,255}, {221,255}, | ||
| 239 | // LC0..LC17 | ||
| 240 | {189,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {172,252}, {169,255}, {165,255}, | ||
| 241 | {128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {255,255}, {148,255}, {161,255}, | ||
| 242 | // LD0..LD17 | ||
| 243 | {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {0,201}, {224,181}, {230,217}, {235,255}, | ||
| 244 | {189,128}, {200,131}, {210,141}, {218,159}, {255,255}, {207,238}, {211,255}, {218,255}, {255,255} | ||
| 213 | }; | 245 | }; |
| 214 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) | 246 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) |
| 215 | const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { | 247 | const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { |
| @@ -248,7 +280,7 @@ const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = { | |||
| 248 | {0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0} | 280 | {0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0} |
| 249 | }; | 281 | }; |
| 250 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { | 282 | const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = { |
| 251 | {0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0} | 283 | {160,255}, {96,255}, {77,255}, {179,255}, {51,255}, {205,255} |
| 252 | }; | 284 | }; |
| 253 | #endif | 285 | #endif |
| 254 | 286 | ||
| @@ -318,7 +350,7 @@ void map_led_to_point_polar( uint8_t index, Point *point ) | |||
| 318 | 350 | ||
| 319 | 351 | ||
| 320 | #if defined (RGB_BACKLIGHT_ZEAL65) | 352 | #if defined (RGB_BACKLIGHT_ZEAL65) |
| 321 | // Note: Left spacebar stab is at 4,3 (LC7) | 353 | // Note: Left spacebar stab is at 4,2 (LC7) |
| 322 | // Right spacebar stab is at 4,9 (D14) | 354 | // Right spacebar stab is at 4,9 (D14) |
| 323 | // | 355 | // |
| 324 | // A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B6 | 356 | // A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B6 |
| @@ -333,6 +365,22 @@ const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | |||
| 333 | { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+15 }, | 365 | { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+15 }, |
| 334 | { 36+17, 36+8, 36+7, 255, 255, 255, 255, 36+0, 255, 54+14, 54+15, 54+16, 54+17, 18+17, 18+16 } | 366 | { 36+17, 36+8, 36+7, 255, 255, 255, 255, 36+0, 255, 54+14, 54+15, 54+16, 54+17, 18+17, 18+16 } |
| 335 | }; | 367 | }; |
| 368 | #elif defined(RGB_BACKLIGHT_KOYU) | ||
| 369 | // Note: Left spacebar stab is at 4,4 (LC6) | ||
| 370 | // Right spacebar stab is at 4,10 (D14) | ||
| 371 | // | ||
| 372 | // A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B6 | ||
| 373 | // A7, A6, A5, A4, A3, A2, A1, A0, B9, B10, B11, B12, B13, B14, B7 | ||
| 374 | // A8, C14, C13, C12, C11, C10, C9, D0, D1, D2, D3, D4, D5, B5, B8 | ||
| 375 | // C16, C15, C5, C4, C3, C2, C1, D9, D10, D11, D12, D6, D7, D8, B15 | ||
| 376 | // C17, C8, C7, C6, ---, ---, ---, C0, ---, ---, D14, D15, D16, B17, B16 | ||
| 377 | const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | ||
| 378 | { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4, 18+6 }, | ||
| 379 | { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14, 18+7 }, | ||
| 380 | { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 18+5, 18+8 }, | ||
| 381 | { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+15 }, | ||
| 382 | { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 255, 54+14, 54+15, 54+16, 18+17, 18+16 } | ||
| 383 | }; | ||
| 336 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) | 384 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) |
| 337 | // Note: Left spacebar stab is at 4,3 (LC6) | 385 | // Note: Left spacebar stab is at 4,3 (LC6) |
| 338 | // Right spacebar stab is at 4,9 (LD13) or 4,10 (LD14) | 386 | // Right spacebar stab is at 4,9 (LD13) or 4,10 (LD14) |
| @@ -781,8 +829,24 @@ void backlight_effect_cycle_radial2(void) | |||
| 781 | } | 829 | } |
| 782 | } | 830 | } |
| 783 | 831 | ||
| 784 | void backlight_effect_indicators_set_colors( uint8_t index, HSV hsv ) | 832 | #if defined(RGB_BACKLIGHT_M6_B) |
| 833 | void backlight_effect_custom_colors(void) | ||
| 785 | { | 834 | { |
| 835 | RGB rgb; | ||
| 836 | for ( uint8_t i = 0; i < 6; i++ ) | ||
| 837 | { | ||
| 838 | HSV hsv = { .h = g_config.custom_color[i].h, .s = g_config.custom_color[i].s, .v = g_config.brightness }; | ||
| 839 | rgb = hsv_to_rgb( hsv ); | ||
| 840 | uint8_t led; | ||
| 841 | map_row_column_to_led( 0, i, &led ); | ||
| 842 | backlight_set_color( led, rgb.r, rgb.g, rgb.b ); | ||
| 843 | } | ||
| 844 | } | ||
| 845 | #endif | ||
| 846 | |||
| 847 | void backlight_effect_indicators_set_colors( uint8_t index, HS color ) | ||
| 848 | { | ||
| 849 | HSV hsv = { .h = color.h, .s = color.s, .v = g_config.brightness }; | ||
| 786 | RGB rgb = hsv_to_rgb( hsv ); | 850 | RGB rgb = hsv_to_rgb( hsv ); |
| 787 | if ( index == 254 ) | 851 | if ( index == 254 ) |
| 788 | { | 852 | { |
| @@ -799,6 +863,9 @@ void backlight_effect_indicators_set_colors( uint8_t index, HSV hsv ) | |||
| 799 | #if defined (RGB_BACKLIGHT_ZEAL65) | 863 | #if defined (RGB_BACKLIGHT_ZEAL65) |
| 800 | backlight_set_color( 36+7, rgb.r, rgb.g, rgb.b ); // LC7 | 864 | backlight_set_color( 36+7, rgb.r, rgb.g, rgb.b ); // LC7 |
| 801 | backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14 | 865 | backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14 |
| 866 | #elif defined (RGB_BACKLIGHT_KOYU) | ||
| 867 | backlight_set_color( 36+6, rgb.r, rgb.g, rgb.b ); // LC6 | ||
| 868 | backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14 | ||
| 802 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) | 869 | #elif defined (RGB_BACKLIGHT_ZEAL60) || defined (RGB_BACKLIGHT_M60_A) |
| 803 | backlight_set_color( 36+6, rgb.r, rgb.g, rgb.b ); // LC6 | 870 | backlight_set_color( 36+6, rgb.r, rgb.g, rgb.b ); // LC6 |
| 804 | backlight_set_color( 54+13, rgb.r, rgb.g, rgb.b ); // LD13 | 871 | backlight_set_color( 54+13, rgb.r, rgb.g, rgb.b ); // LD13 |
| @@ -911,7 +978,11 @@ ISR(TIMER3_COMPA_vect) | |||
| 911 | backlight_effect_solid_color(); | 978 | backlight_effect_solid_color(); |
| 912 | break; | 979 | break; |
| 913 | case 2: | 980 | case 2: |
| 981 | #if defined(RGB_BACKLIGHT_M6_B) | ||
| 982 | backlight_effect_custom_colors(); | ||
| 983 | #else | ||
| 914 | backlight_effect_alphas_mods(); | 984 | backlight_effect_alphas_mods(); |
| 985 | #endif | ||
| 915 | break; | 986 | break; |
| 916 | case 3: | 987 | case 3: |
| 917 | backlight_effect_gradient_up_down(); | 988 | backlight_effect_gradient_up_down(); |
| @@ -989,18 +1060,16 @@ void backlight_get_indicator_row_col( uint8_t index, uint8_t *row, uint8_t *colu | |||
| 989 | } | 1060 | } |
| 990 | 1061 | ||
| 991 | // Some helpers for setting/getting HSV | 1062 | // Some helpers for setting/getting HSV |
| 992 | void _set_color( HSV *color, uint8_t *data ) | 1063 | void _set_color( HS *color, uint8_t *data ) |
| 993 | { | 1064 | { |
| 994 | color->h = data[0]; | 1065 | color->h = data[0]; |
| 995 | color->s = data[1]; | 1066 | color->s = data[1]; |
| 996 | color->v = data[2]; | ||
| 997 | } | 1067 | } |
| 998 | 1068 | ||
| 999 | void _get_color( HSV *color, uint8_t *data ) | 1069 | void _get_color( HS *color, uint8_t *data ) |
| 1000 | { | 1070 | { |
| 1001 | data[0] = color->h; | 1071 | data[0] = color->h; |
| 1002 | data[1] = color->s; | 1072 | data[1] = color->s; |
| 1003 | data[2] = color->v; | ||
| 1004 | } | 1073 | } |
| 1005 | 1074 | ||
| 1006 | void backlight_config_set_value( uint8_t *data ) | 1075 | void backlight_config_set_value( uint8_t *data ) |
| @@ -1132,6 +1201,16 @@ void backlight_config_set_value( uint8_t *data ) | |||
| 1132 | g_config.alphas_mods[i] = ( *(value_data+i*2) << 8 ) | ( *(value_data+i*2+1) ); | 1201 | g_config.alphas_mods[i] = ( *(value_data+i*2) << 8 ) | ( *(value_data+i*2+1) ); |
| 1133 | } | 1202 | } |
| 1134 | } | 1203 | } |
| 1204 | #if defined(RGB_BACKLIGHT_M6_B) | ||
| 1205 | case id_custom_color: | ||
| 1206 | { | ||
| 1207 | uint8_t index = value_data[0]; | ||
| 1208 | if ( index >= 0 && index <= 6 ) | ||
| 1209 | { | ||
| 1210 | _set_color( &(g_config.custom_color[index]), &(value_data[1]) ); | ||
| 1211 | } | ||
| 1212 | } | ||
| 1213 | #endif | ||
| 1135 | } | 1214 | } |
| 1136 | 1215 | ||
| 1137 | if ( reinitialize ) | 1216 | if ( reinitialize ) |
| @@ -1259,6 +1338,16 @@ void backlight_config_get_value( uint8_t *data ) | |||
| 1259 | *(value_data+i*2+1) = g_config.alphas_mods[i] & 0xFF; | 1338 | *(value_data+i*2+1) = g_config.alphas_mods[i] & 0xFF; |
| 1260 | } | 1339 | } |
| 1261 | } | 1340 | } |
| 1341 | #if defined(RGB_BACKLIGHT_M6_B) | ||
| 1342 | case id_custom_color: | ||
| 1343 | { | ||
| 1344 | uint8_t index = value_data[0]; | ||
| 1345 | if ( index >= 0 && index <= 6 ) | ||
| 1346 | { | ||
| 1347 | _get_color( &(g_config.custom_color[index]), &(value_data[1]) ); | ||
| 1348 | } | ||
| 1349 | } | ||
| 1350 | #endif | ||
| 1262 | } | 1351 | } |
| 1263 | } | 1352 | } |
| 1264 | 1353 | ||
| @@ -1301,6 +1390,10 @@ void backlight_init_drivers(void) | |||
| 1301 | bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5 | 1390 | bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5 |
| 1302 | ( index == 36+6 ) || // LC6 | 1391 | ( index == 36+6 ) || // LC6 |
| 1303 | ( index == 54+13 ) ); // LD13 | 1392 | ( index == 54+13 ) ); // LD13 |
| 1393 | #elif defined (RGB_BACKLIGHT_KOYU) | ||
| 1394 | bool enabled = !( ( index == 36+15 ) || // LC15 | ||
| 1395 | ( index == 54+13 ) || // LD13 | ||
| 1396 | ( index == 54+17 ) ); // LD17 | ||
| 1304 | #elif defined (RGB_BACKLIGHT_M60_A) | 1397 | #elif defined (RGB_BACKLIGHT_M60_A) |
| 1305 | bool enabled = !( | 1398 | bool enabled = !( |
| 1306 | // LB6 LB7 LB8 LB15 LB16 LB17 not present on M60-A | 1399 | // LB6 LB7 LB8 LB15 LB16 LB17 not present on M60-A |
diff --git a/keyboards/zeal60/rgb_backlight.h b/keyboards/zeal60/rgb_backlight.h index 60f2ace51..aa24e3491 100644 --- a/keyboards/zeal60/rgb_backlight.h +++ b/keyboards/zeal60/rgb_backlight.h | |||
| @@ -25,9 +25,15 @@ | |||
| 25 | 25 | ||
| 26 | #include "quantum/color.h" | 26 | #include "quantum/color.h" |
| 27 | 27 | ||
| 28 | typedef struct PACKED | ||
| 29 | { | ||
| 30 | uint8_t h; | ||
| 31 | uint8_t s; | ||
| 32 | } HS; | ||
| 33 | |||
| 28 | typedef struct | 34 | typedef struct |
| 29 | { | 35 | { |
| 30 | HSV color; | 36 | HS color; |
| 31 | uint8_t index; | 37 | uint8_t index; |
| 32 | } backlight_config_indicator; | 38 | } backlight_config_indicator; |
| 33 | 39 | ||
| @@ -45,14 +51,17 @@ typedef struct | |||
| 45 | uint8_t brightness; // 1 byte | 51 | uint8_t brightness; // 1 byte |
| 46 | uint8_t effect; // 1 byte | 52 | uint8_t effect; // 1 byte |
| 47 | uint8_t effect_speed; // 1 byte | 53 | uint8_t effect_speed; // 1 byte |
| 48 | HSV color_1; // 3 bytes | 54 | HS color_1; // 2 bytes |
| 49 | HSV color_2; // 3 bytes | 55 | HS color_2; // 2 bytes |
| 50 | backlight_config_indicator caps_lock_indicator; // 4 bytes | 56 | backlight_config_indicator caps_lock_indicator; // 3 bytes |
| 51 | backlight_config_indicator layer_1_indicator; // 4 bytes | 57 | backlight_config_indicator layer_1_indicator; // 3 bytes |
| 52 | backlight_config_indicator layer_2_indicator; // 4 bytes | 58 | backlight_config_indicator layer_2_indicator; // 3 bytes |
| 53 | backlight_config_indicator layer_3_indicator; // 4 bytes | 59 | backlight_config_indicator layer_3_indicator; // 3 bytes |
| 54 | uint16_t alphas_mods[5]; // 10 bytes | 60 | uint16_t alphas_mods[5]; // 10 bytes |
| 55 | } backlight_config; // = 37 bytes | 61 | #if defined(RGB_BACKLIGHT_M6_B) |
| 62 | HS custom_color[6]; // 12 bytes | ||
| 63 | #endif | ||
| 64 | } backlight_config; // = 31 bytes (M6-B = 43 bytes) | ||
| 56 | 65 | ||
| 57 | void backlight_config_load(void); | 66 | void backlight_config_load(void); |
| 58 | void backlight_config_save(void); | 67 | void backlight_config_save(void); |
diff --git a/keyboards/zeal60/rgb_backlight_api.h b/keyboards/zeal60/rgb_backlight_api.h index 01827e849..680ba4d99 100644 --- a/keyboards/zeal60/rgb_backlight_api.h +++ b/keyboards/zeal60/rgb_backlight_api.h | |||
| @@ -38,5 +38,6 @@ enum backlight_config_value | |||
| 38 | id_layer_2_indicator_row_col = 0x13, | 38 | id_layer_2_indicator_row_col = 0x13, |
| 39 | id_layer_3_indicator_color = 0x14, | 39 | id_layer_3_indicator_color = 0x14, |
| 40 | id_layer_3_indicator_row_col = 0x15, | 40 | id_layer_3_indicator_row_col = 0x15, |
| 41 | id_alphas_mods = 0x16 | 41 | id_alphas_mods = 0x16, |
| 42 | id_custom_color = 0x17 | ||
| 42 | }; | 43 | }; |
diff --git a/keyboards/zeal60/zeal60.c b/keyboards/zeal60/zeal60.c index b3b5d03fd..5f93c571a 100644 --- a/keyboards/zeal60/zeal60.c +++ b/keyboards/zeal60/zeal60.c | |||
| @@ -94,6 +94,56 @@ void raw_hid_receive( uint8_t *data, uint8_t length ) | |||
| 94 | dynamic_keymap_reset(); | 94 | dynamic_keymap_reset(); |
| 95 | break; | 95 | break; |
| 96 | } | 96 | } |
| 97 | case id_dynamic_keymap_macro_get_count: | ||
| 98 | { | ||
| 99 | command_data[0] = dynamic_keymap_macro_get_count(); | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | case id_dynamic_keymap_macro_get_buffer_size: | ||
| 103 | { | ||
| 104 | uint16_t size = dynamic_keymap_macro_get_buffer_size(); | ||
| 105 | command_data[0] = size >> 8; | ||
| 106 | command_data[1] = size & 0xFF; | ||
| 107 | break; | ||
| 108 | } | ||
| 109 | case id_dynamic_keymap_macro_get_buffer: | ||
| 110 | { | ||
| 111 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 112 | uint16_t size = command_data[2]; // size <= 28 | ||
| 113 | dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] ); | ||
| 114 | break; | ||
| 115 | } | ||
| 116 | case id_dynamic_keymap_macro_set_buffer: | ||
| 117 | { | ||
| 118 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 119 | uint16_t size = command_data[2]; // size <= 28 | ||
| 120 | dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] ); | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | case id_dynamic_keymap_macro_reset: | ||
| 124 | { | ||
| 125 | dynamic_keymap_macro_reset(); | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | case id_dynamic_keymap_get_layer_count: | ||
| 129 | { | ||
| 130 | command_data[0] = dynamic_keymap_get_layer_count(); | ||
| 131 | break; | ||
| 132 | } | ||
| 133 | case id_dynamic_keymap_get_buffer: | ||
| 134 | { | ||
| 135 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 136 | uint16_t size = command_data[2]; // size <= 28 | ||
| 137 | dynamic_keymap_get_buffer( offset, size, &command_data[3] ); | ||
| 138 | break; | ||
| 139 | } | ||
| 140 | case id_dynamic_keymap_set_buffer: | ||
| 141 | { | ||
| 142 | uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; | ||
| 143 | uint16_t size = command_data[2]; // size <= 28 | ||
| 144 | dynamic_keymap_set_buffer( offset, size, &command_data[3] ); | ||
| 145 | break; | ||
| 146 | } | ||
| 97 | #endif // DYNAMIC_KEYMAP_ENABLE | 147 | #endif // DYNAMIC_KEYMAP_ENABLE |
| 98 | #if RGB_BACKLIGHT_ENABLED | 148 | #if RGB_BACKLIGHT_ENABLED |
| 99 | case id_backlight_config_set_value: | 149 | case id_backlight_config_set_value: |
| @@ -160,6 +210,8 @@ void main_init(void) | |||
| 160 | #ifdef DYNAMIC_KEYMAP_ENABLE | 210 | #ifdef DYNAMIC_KEYMAP_ENABLE |
| 161 | // This resets the keymaps in EEPROM to what is in flash. | 211 | // This resets the keymaps in EEPROM to what is in flash. |
| 162 | dynamic_keymap_reset(); | 212 | dynamic_keymap_reset(); |
| 213 | // This resets the macros in EEPROM to nothing. | ||
| 214 | dynamic_keymap_macro_reset(); | ||
| 163 | #endif | 215 | #endif |
| 164 | // Save the magic number last, in case saving was interrupted | 216 | // Save the magic number last, in case saving was interrupted |
| 165 | eeprom_set_valid(true); | 217 | eeprom_set_valid(true); |
| @@ -238,7 +290,19 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) | |||
| 238 | return false; | 290 | return false; |
| 239 | break; | 291 | break; |
| 240 | } | 292 | } |
| 241 | 293 | ||
| 294 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 295 | // Handle macros | ||
| 296 | if (record->event.pressed) { | ||
| 297 | if ( keycode >= MACRO00 && keycode <= MACRO15 ) | ||
| 298 | { | ||
| 299 | uint8_t id = keycode - MACRO00; | ||
| 300 | dynamic_keymap_macro_send(id); | ||
| 301 | return false; | ||
| 302 | } | ||
| 303 | } | ||
| 304 | #endif //DYNAMIC_KEYMAP_ENABLE | ||
| 305 | |||
| 242 | return process_record_user(keycode, record); | 306 | return process_record_user(keycode, record); |
| 243 | } | 307 | } |
| 244 | 308 | ||
| @@ -263,28 +327,6 @@ uint16_t keymap_function_id_to_action( uint16_t function_id ) | |||
| 263 | } | 327 | } |
| 264 | } | 328 | } |
| 265 | 329 | ||
| 266 | #if USE_KEYMAPS_IN_EEPROM | ||
| 267 | |||
| 268 | #if 0 | ||
| 269 | // This is how to implement actions stored in EEPROM. | ||
| 270 | // Not yet implemented. Not sure if it's worth the trouble | ||
| 271 | // before we have a nice GUI for keymap editing. | ||
| 272 | if ( eeprom_is_valid() && | ||
| 273 | function_id < 32 ) // TODO: replace magic number | ||
| 274 | { | ||
| 275 | uint16_t action = keymap_action_load(function_id); | ||
| 276 | |||
| 277 | // If action is not "empty", return it, otherwise | ||
| 278 | // drop down to return the one in flash | ||
| 279 | if ( action != 0x0000 ) // TODO: replace magic number | ||
| 280 | { | ||
| 281 | return action; | ||
| 282 | } | ||
| 283 | } | ||
| 284 | #endif | ||
| 285 | |||
| 286 | #endif // USE_KEYMAPS_IN_EEPROM | ||
| 287 | |||
| 288 | return pgm_read_word(&fn_actions[function_id]); | 330 | return pgm_read_word(&fn_actions[function_id]); |
| 289 | } | 331 | } |
| 290 | 332 | ||
diff --git a/keyboards/zeal60/zeal60_api.h b/keyboards/zeal60/zeal60_api.h index a65bf2f50..8061146fd 100644 --- a/keyboards/zeal60/zeal60_api.h +++ b/keyboards/zeal60/zeal60_api.h | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #pragma once | 16 | #pragma once |
| 17 | 17 | ||
| 18 | #define PROTOCOL_VERSION 0x0007 | 18 | #define PROTOCOL_VERSION 0x0008 |
| 19 | 19 | ||
| 20 | enum zeal60_command_id | 20 | enum zeal60_command_id |
| 21 | { | 21 | { |
| @@ -30,6 +30,14 @@ enum zeal60_command_id | |||
| 30 | id_backlight_config_save, | 30 | id_backlight_config_save, |
| 31 | id_eeprom_reset, | 31 | id_eeprom_reset, |
| 32 | id_bootloader_jump, | 32 | id_bootloader_jump, |
| 33 | id_dynamic_keymap_macro_get_count, | ||
| 34 | id_dynamic_keymap_macro_get_buffer_size, | ||
| 35 | id_dynamic_keymap_macro_get_buffer, | ||
| 36 | id_dynamic_keymap_macro_set_buffer, | ||
| 37 | id_dynamic_keymap_macro_reset, | ||
| 38 | id_dynamic_keymap_get_layer_count, | ||
| 39 | id_dynamic_keymap_get_buffer, | ||
| 40 | id_dynamic_keymap_set_buffer, | ||
| 33 | id_unhandled = 0xFF, | 41 | id_unhandled = 0xFF, |
| 34 | }; | 42 | }; |
| 35 | 43 | ||
diff --git a/keyboards/zeal60/zeal60_keycodes.h b/keyboards/zeal60/zeal60_keycodes.h index 9511801eb..d9abf602b 100644 --- a/keyboards/zeal60/zeal60_keycodes.h +++ b/keyboards/zeal60/zeal60_keycodes.h | |||
| @@ -22,7 +22,23 @@ | |||
| 22 | // Backlight keycodes are in range 0x5F00-0x5F0F | 22 | // Backlight keycodes are in range 0x5F00-0x5F0F |
| 23 | enum zeal60_keycodes { | 23 | enum zeal60_keycodes { |
| 24 | FN_MO13 = 0x5F10, | 24 | FN_MO13 = 0x5F10, |
| 25 | FN_MO23 | 25 | FN_MO23, |
| 26 | MACRO00, | ||
| 27 | MACRO01, | ||
| 28 | MACRO02, | ||
| 29 | MACRO03, | ||
| 30 | MACRO04, | ||
| 31 | MACRO05, | ||
| 32 | MACRO06, | ||
| 33 | MACRO07, | ||
| 34 | MACRO08, | ||
| 35 | MACRO09, | ||
| 36 | MACRO10, | ||
| 37 | MACRO11, | ||
| 38 | MACRO12, | ||
| 39 | MACRO13, | ||
| 40 | MACRO14, | ||
| 41 | MACRO15, | ||
| 26 | }; | 42 | }; |
| 27 | 43 | ||
| 28 | // Zeal60 specific "action functions" | 44 | // Zeal60 specific "action functions" |
diff --git a/keyboards/zeal65/config.h b/keyboards/zeal65/config.h index 683df2038..63ce1c12a 100644 --- a/keyboards/zeal65/config.h +++ b/keyboards/zeal65/config.h | |||
| @@ -115,11 +115,15 @@ | |||
| 115 | // Bump this every time we change what we store | 115 | // Bump this every time we change what we store |
| 116 | // This will automatically reset the EEPROM with defaults | 116 | // This will automatically reset the EEPROM with defaults |
| 117 | // and avoid loading invalid data from the EEPROM | 117 | // and avoid loading invalid data from the EEPROM |
| 118 | #define EEPROM_VERSION 0x07 | 118 | #define EEPROM_VERSION 0x08 |
| 119 | #define EEPROM_VERSION_ADDR 34 | 119 | #define EEPROM_VERSION_ADDR 34 |
| 120 | 120 | ||
| 121 | // Backlight config starts after EEPROM version | 121 | // Backlight config starts after EEPROM version |
| 122 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 | 122 | #define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR 35 |
| 123 | // Dynamic keymap starts after backlight config (35+37) | 123 | // Dynamic keymap starts after backlight config (35+31) |
| 124 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 72 | 124 | #define DYNAMIC_KEYMAP_EEPROM_ADDR 66 |
| 125 | // Dynamic macro starts after dynamic keymaps (66+(4*5*15*2)) = (66+600) | ||
| 126 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 666 | ||
| 127 | #define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 358 | ||
| 128 | #define DYNAMIC_KEYMAP_MACRO_COUNT 16 | ||
| 125 | 129 | ||
diff --git a/keyboards/zeal65/rules.mk b/keyboards/zeal65/rules.mk index 7ab1b7d3b..596c1e649 100644 --- a/keyboards/zeal65/rules.mk +++ b/keyboards/zeal65/rules.mk | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | 1 | ||
| 2 | 2 | ||
| 3 | # project specific files | 3 | # project specific files |
| 4 | SRC = ../zeal60/zeal60.c \ | 4 | SRC = keyboards/zeal60/zeal60.c \ |
| 5 | ../zeal60/rgb_backlight.c \ | 5 | keyboards/zeal60/rgb_backlight.c \ |
| 6 | quantum/color.c \ | 6 | quantum/color.c \ |
| 7 | drivers/issi/is31fl3731.c \ | 7 | drivers/issi/is31fl3731.c \ |
| 8 | drivers/avr/i2c_master.c | 8 | drivers/avr/i2c_master.c |
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index ee39a2025..14627a93d 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include "keymap.h" // to get keymaps[][][] | 18 | #include "keymap.h" // to get keymaps[][][] |
| 19 | #include "tmk_core/common/eeprom.h" | 19 | #include "tmk_core/common/eeprom.h" |
| 20 | #include "progmem.h" // to read default from flash | 20 | #include "progmem.h" // to read default from flash |
| 21 | 21 | #include "quantum.h" // for send_string() | |
| 22 | #include "dynamic_keymap.h" | 22 | #include "dynamic_keymap.h" |
| 23 | 23 | ||
| 24 | #ifdef DYNAMIC_KEYMAP_ENABLE | 24 | #ifdef DYNAMIC_KEYMAP_ENABLE |
| @@ -31,6 +31,23 @@ | |||
| 31 | #error DYNAMIC_KEYMAP_LAYER_COUNT not defined | 31 | #error DYNAMIC_KEYMAP_LAYER_COUNT not defined |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 34 | #ifndef DYNAMIC_KEYMAP_MACRO_COUNT | ||
| 35 | #error DYNAMIC_KEYMAP_MACRO_COUNT not defined | ||
| 36 | #endif | ||
| 37 | |||
| 38 | #ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR | ||
| 39 | #error DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR not defined | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE | ||
| 43 | #error DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE not defined | ||
| 44 | #endif | ||
| 45 | |||
| 46 | uint8_t dynamic_keymap_get_layer_count(void) | ||
| 47 | { | ||
| 48 | return DYNAMIC_KEYMAP_LAYER_COUNT; | ||
| 49 | } | ||
| 50 | |||
| 34 | void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) | 51 | void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) |
| 35 | { | 52 | { |
| 36 | // TODO: optimize this with some left shifts | 53 | // TODO: optimize this with some left shifts |
| @@ -69,6 +86,36 @@ void dynamic_keymap_reset(void) | |||
| 69 | } | 86 | } |
| 70 | } | 87 | } |
| 71 | 88 | ||
| 89 | void dynamic_keymap_get_buffer( uint16_t offset, uint16_t size, uint8_t *data ) | ||
| 90 | { | ||
| 91 | uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2; | ||
| 92 | void *source = (void*)(DYNAMIC_KEYMAP_EEPROM_ADDR+offset); | ||
| 93 | uint8_t *target = data; | ||
| 94 | for ( uint16_t i = 0; i < size; i++ ) { | ||
| 95 | if ( offset + i < dynamic_keymap_eeprom_size ) { | ||
| 96 | *target = eeprom_read_byte(source); | ||
| 97 | } else { | ||
| 98 | *target = 0x00; | ||
| 99 | } | ||
| 100 | source++; | ||
| 101 | target++; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | void dynamic_keymap_set_buffer( uint16_t offset, uint16_t size, uint8_t *data ) | ||
| 106 | { | ||
| 107 | uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2; | ||
| 108 | void *target = (void*)(DYNAMIC_KEYMAP_EEPROM_ADDR+offset); | ||
| 109 | uint8_t *source = data; | ||
| 110 | for ( uint16_t i = 0; i < size; i++ ) { | ||
| 111 | if ( offset + i < dynamic_keymap_eeprom_size ) { | ||
| 112 | eeprom_update_byte(target, *source); | ||
| 113 | } | ||
| 114 | source++; | ||
| 115 | target++; | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 72 | // This overrides the one in quantum/keymap_common.c | 119 | // This overrides the one in quantum/keymap_common.c |
| 73 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) | 120 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) |
| 74 | { | 121 | { |
| @@ -81,5 +128,103 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) | |||
| 81 | } | 128 | } |
| 82 | } | 129 | } |
| 83 | 130 | ||
| 131 | |||
| 132 | |||
| 133 | uint8_t dynamic_keymap_macro_get_count(void) | ||
| 134 | { | ||
| 135 | return DYNAMIC_KEYMAP_MACRO_COUNT; | ||
| 136 | } | ||
| 137 | |||
| 138 | uint16_t dynamic_keymap_macro_get_buffer_size(void) | ||
| 139 | { | ||
| 140 | return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; | ||
| 141 | } | ||
| 142 | |||
| 143 | void dynamic_keymap_macro_get_buffer( uint16_t offset, uint16_t size, uint8_t *data ) | ||
| 144 | { | ||
| 145 | void *source = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+offset); | ||
| 146 | uint8_t *target = data; | ||
| 147 | for ( uint16_t i = 0; i < size; i++ ) { | ||
| 148 | if ( offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE ) { | ||
| 149 | *target = eeprom_read_byte(source); | ||
| 150 | } else { | ||
| 151 | *target = 0x00; | ||
| 152 | } | ||
| 153 | source++; | ||
| 154 | target++; | ||
| 155 | } | ||
| 156 | } | ||
| 157 | |||
| 158 | void dynamic_keymap_macro_set_buffer( uint16_t offset, uint16_t size, uint8_t *data ) | ||
| 159 | { | ||
| 160 | void *target = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+offset); | ||
| 161 | uint8_t *source = data; | ||
| 162 | for ( uint16_t i = 0; i < size; i++ ) { | ||
| 163 | if ( offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE ) { | ||
| 164 | eeprom_update_byte(target, *source); | ||
| 165 | } | ||
| 166 | source++; | ||
| 167 | target++; | ||
| 168 | } | ||
| 169 | } | ||
| 170 | |||
| 171 | void dynamic_keymap_macro_reset(void) | ||
| 172 | { | ||
| 173 | void *p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); | ||
| 174 | void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); | ||
| 175 | while ( p != end ) { | ||
| 176 | eeprom_update_byte(p, 0); | ||
| 177 | ++p; | ||
| 178 | } | ||
| 179 | } | ||
| 180 | |||
| 181 | void dynamic_keymap_macro_send( uint8_t id ) | ||
| 182 | { | ||
| 183 | if ( id >= DYNAMIC_KEYMAP_MACRO_COUNT ) { | ||
| 184 | return; | ||
| 185 | } | ||
| 186 | |||
| 187 | // Check the last byte of the buffer. | ||
| 188 | // If it's not zero, then we are in the middle | ||
| 189 | // of buffer writing, possibly an aborted buffer | ||
| 190 | // write. So do nothing. | ||
| 191 | void *p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE-1); | ||
| 192 | if ( eeprom_read_byte(p) != 0 ) { | ||
| 193 | return; | ||
| 194 | } | ||
| 195 | |||
| 196 | // Skip N null characters | ||
| 197 | // p will then point to the Nth macro | ||
| 198 | p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); | ||
| 199 | void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); | ||
| 200 | while ( id > 0 ) { | ||
| 201 | // If we are past the end of the buffer, then the buffer | ||
| 202 | // contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT | ||
| 203 | // nulls in the buffer. | ||
| 204 | if ( p == end ) { | ||
| 205 | return; | ||
| 206 | } | ||
| 207 | if ( eeprom_read_byte(p) == 0 ) { | ||
| 208 | --id; | ||
| 209 | } | ||
| 210 | ++p; | ||
| 211 | } | ||
| 212 | |||
| 213 | // Send the macro string one char at a time | ||
| 214 | // by making temporary 1 char strings | ||
| 215 | char data[2] = { 0, 0 }; | ||
| 216 | // We already checked there was a null at the end of | ||
| 217 | // the buffer, so this cannot go past the end | ||
| 218 | while ( 1 ) { | ||
| 219 | data[0] = eeprom_read_byte(p); | ||
| 220 | // Stop at the null terminator of this macro string | ||
| 221 | if ( data[0] == 0 ) { | ||
| 222 | break; | ||
| 223 | } | ||
| 224 | send_string(data); | ||
| 225 | ++p; | ||
| 226 | } | ||
| 227 | } | ||
| 228 | |||
| 84 | #endif // DYNAMIC_KEYMAP_ENABLE | 229 | #endif // DYNAMIC_KEYMAP_ENABLE |
| 85 | 230 | ||
diff --git a/quantum/dynamic_keymap.h b/quantum/dynamic_keymap.h index bd76adae2..63653f6cb 100644 --- a/quantum/dynamic_keymap.h +++ b/quantum/dynamic_keymap.h | |||
| @@ -18,11 +18,46 @@ | |||
| 18 | #include <stdint.h> | 18 | #include <stdint.h> |
| 19 | #include <stdbool.h> | 19 | #include <stdbool.h> |
| 20 | 20 | ||
| 21 | uint8_t dynamic_keymap_get_layer_count(void); | ||
| 21 | void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column); | 22 | void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column); |
| 22 | uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column); | 23 | uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column); |
| 23 | void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode); | 24 | void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode); |
| 24 | void dynamic_keymap_reset(void); | 25 | void dynamic_keymap_reset(void); |
| 26 | // These get/set the keycodes as stored in the EEPROM buffer | ||
| 27 | // Data is big-endian 16-bit values (the keycodes) | ||
| 28 | // Order is by layer/row/column | ||
| 29 | // Thus offset 0 = 0,0,0, offset MATRIX_COLS*2 = 0,1,0, offset MATRIX_ROWS*MATRIX_COLS*2 = 1,0,0 | ||
| 30 | // Note the *2, because offset is in bytes and keycodes are two bytes | ||
| 31 | // This is only really useful for host applications that want to get a whole keymap fast, | ||
| 32 | // by reading 14 keycodes (28 bytes) at a time, reducing the number of raw HID transfers by | ||
| 33 | // a factor of 14. | ||
| 34 | void dynamic_keymap_get_buffer( uint16_t offset, uint16_t size, uint8_t *data ); | ||
| 35 | void dynamic_keymap_set_buffer( uint16_t offset, uint16_t size, uint8_t *data ); | ||
| 25 | 36 | ||
| 26 | // This overrides the one in quantum/keymap_common.c | 37 | // This overrides the one in quantum/keymap_common.c |
| 27 | // uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); | 38 | // uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); |
| 28 | 39 | ||
| 40 | |||
| 41 | |||
| 42 | // Note regarding dynamic_keymap_macro_set_buffer(): | ||
| 43 | // The last byte of the buffer is used as a valid flag, | ||
| 44 | // so macro sending is disabled during writing a new buffer, | ||
| 45 | // should it happen during, or after an interrupted transfer. | ||
| 46 | // | ||
| 47 | // Users writing to the buffer must first set the last byte of the buffer | ||
| 48 | // to non-zero (i.e. 0xFF). After (or during) the final write, set the | ||
| 49 | // last byte of the buffer to zero. | ||
| 50 | // | ||
| 51 | // Since the contents of the buffer must be a list of null terminated | ||
| 52 | // strings, the last byte must be a null when at maximum capacity, | ||
| 53 | // and it not being null means the buffer can be considered in an | ||
| 54 | // invalid state. | ||
| 55 | |||
| 56 | uint8_t dynamic_keymap_macro_get_count(void); | ||
| 57 | uint16_t dynamic_keymap_macro_get_buffer_size(void); | ||
| 58 | void dynamic_keymap_macro_get_buffer( uint16_t offset, uint16_t size, uint8_t *data ); | ||
| 59 | void dynamic_keymap_macro_set_buffer( uint16_t offset, uint16_t size, uint8_t *data ); | ||
| 60 | void dynamic_keymap_macro_reset(void); | ||
| 61 | |||
| 62 | void dynamic_keymap_macro_send( uint8_t id ); | ||
| 63 | |||
