diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/bootmagic/bootmagic.h | 24 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_full.c | 147 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_full.h | 115 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_lite.c | 66 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_lite.h | 25 | ||||
| -rw-r--r-- | quantum/bootmagic/magic.c | 54 | ||||
| -rw-r--r-- | quantum/bootmagic/magic.h | 18 | ||||
| -rw-r--r-- | quantum/keycode_config.h | 1 | ||||
| -rw-r--r-- | quantum/led_matrix.c | 82 | ||||
| -rw-r--r-- | quantum/led_matrix.h | 7 | ||||
| -rw-r--r-- | quantum/led_matrix_drivers.c | 7 | ||||
| -rw-r--r-- | quantum/led_matrix_types.h | 27 | ||||
| -rw-r--r-- | quantum/mcu_selection.mk | 27 | ||||
| -rw-r--r-- | quantum/process_keycode/process_backlight.c | 29 | ||||
| -rw-r--r-- | quantum/quantum.c | 28 | ||||
| -rw-r--r-- | quantum/quantum.h | 55 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 14 | ||||
| -rw-r--r-- | quantum/rgb_matrix.c | 34 | ||||
| -rw-r--r-- | quantum/rgb_matrix_types.h | 9 | ||||
| -rw-r--r-- | quantum/split_common/split_util.c | 70 | ||||
| -rw-r--r-- | quantum/split_common/transport.c | 45 |
21 files changed, 716 insertions, 168 deletions
diff --git a/quantum/bootmagic/bootmagic.h b/quantum/bootmagic/bootmagic.h new file mode 100644 index 000000000..959750178 --- /dev/null +++ b/quantum/bootmagic/bootmagic.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #if defined(BOOTMAGIC_ENABLE) | ||
| 19 | # include "bootmagic_full.h" | ||
| 20 | #elif defined(BOOTMAGIC_LITE) | ||
| 21 | # include "bootmagic_lite.h" | ||
| 22 | #endif | ||
| 23 | |||
| 24 | void bootmagic(void); | ||
diff --git a/quantum/bootmagic/bootmagic_full.c b/quantum/bootmagic/bootmagic_full.c new file mode 100644 index 000000000..a7a0dcfcb --- /dev/null +++ b/quantum/bootmagic/bootmagic_full.c | |||
| @@ -0,0 +1,147 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include <stdint.h> | ||
| 17 | #include <stdbool.h> | ||
| 18 | #include "wait.h" | ||
| 19 | #include "matrix.h" | ||
| 20 | #include "bootloader.h" | ||
| 21 | #include "debug.h" | ||
| 22 | #include "keymap.h" | ||
| 23 | #include "host.h" | ||
| 24 | #include "action_layer.h" | ||
| 25 | #include "eeconfig.h" | ||
| 26 | #include "bootmagic.h" | ||
| 27 | |||
| 28 | /** \brief Scan Keycode | ||
| 29 | * | ||
| 30 | * FIXME: needs doc | ||
| 31 | */ | ||
| 32 | static bool scan_keycode(uint8_t keycode) { | ||
| 33 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { | ||
| 34 | matrix_row_t matrix_row = matrix_get_row(r); | ||
| 35 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | ||
| 36 | if (matrix_row & ((matrix_row_t)1 << c)) { | ||
| 37 | if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) { | ||
| 38 | return true; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | } | ||
| 43 | return false; | ||
| 44 | } | ||
| 45 | |||
| 46 | /** \brief Bootmagic Scan Keycode | ||
| 47 | * | ||
| 48 | * FIXME: needs doc | ||
| 49 | */ | ||
| 50 | static bool bootmagic_scan_keycode(uint8_t keycode) { | ||
| 51 | if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false; | ||
| 52 | |||
| 53 | return scan_keycode(keycode); | ||
| 54 | } | ||
| 55 | |||
| 56 | void bootmagic(void) { | ||
| 57 | /* do scans in case of bounce */ | ||
| 58 | print("bootmagic scan: ... "); | ||
| 59 | uint8_t scan = 100; | ||
| 60 | while (scan--) { | ||
| 61 | matrix_scan(); | ||
| 62 | wait_ms(10); | ||
| 63 | } | ||
| 64 | print("done.\n"); | ||
| 65 | |||
| 66 | /* bootmagic skip */ | ||
| 67 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SKIP)) { | ||
| 68 | return; | ||
| 69 | } | ||
| 70 | |||
| 71 | /* eeconfig clear */ | ||
| 72 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) { | ||
| 73 | eeconfig_init(); | ||
| 74 | } | ||
| 75 | |||
| 76 | /* bootloader */ | ||
| 77 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_BOOTLOADER)) { | ||
| 78 | bootloader_jump(); | ||
| 79 | } | ||
| 80 | |||
| 81 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { | ||
| 82 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { | ||
| 83 | debug_config.matrix = !debug_config.matrix; | ||
| 84 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_KEYBOARD)) { | ||
| 85 | debug_config.keyboard = !debug_config.keyboard; | ||
| 86 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MOUSE)) { | ||
| 87 | debug_config.mouse = !debug_config.mouse; | ||
| 88 | } else { | ||
| 89 | debug_config.enable = !debug_config.enable; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | eeconfig_update_debug(debug_config.raw); | ||
| 93 | |||
| 94 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { | ||
| 95 | keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; | ||
| 96 | } | ||
| 97 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { | ||
| 98 | keymap_config.capslock_to_control = !keymap_config.capslock_to_control; | ||
| 99 | } | ||
| 100 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_LALT_LGUI)) { | ||
| 101 | keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; | ||
| 102 | } | ||
| 103 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_RALT_RGUI)) { | ||
| 104 | keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; | ||
| 105 | } | ||
| 106 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_NO_GUI)) { | ||
| 107 | keymap_config.no_gui = !keymap_config.no_gui; | ||
| 108 | } | ||
| 109 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_GRAVE_ESC)) { | ||
| 110 | keymap_config.swap_grave_esc = !keymap_config.swap_grave_esc; | ||
| 111 | } | ||
| 112 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { | ||
| 113 | keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; | ||
| 114 | } | ||
| 115 | if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) { | ||
| 116 | keymap_config.nkro = !keymap_config.nkro; | ||
| 117 | } | ||
| 118 | eeconfig_update_keymap(keymap_config.raw); | ||
| 119 | |||
| 120 | /* default layer */ | ||
| 121 | uint8_t default_layer = 0; | ||
| 122 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { | ||
| 123 | default_layer |= (1 << 0); | ||
| 124 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { | ||
| 125 | default_layer |= (1 << 1); | ||
| 126 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { | ||
| 127 | default_layer |= (1 << 2); | ||
| 128 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { | ||
| 129 | default_layer |= (1 << 3); | ||
| 130 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { | ||
| 131 | default_layer |= (1 << 4); | ||
| 132 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { | ||
| 133 | default_layer |= (1 << 5); | ||
| 134 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { | ||
| 135 | default_layer |= (1 << 6); | ||
| 136 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { | ||
| 137 | default_layer |= (1 << 7); | ||
| 138 | } | ||
| 139 | eeconfig_update_default_layer(default_layer); | ||
| 140 | |||
| 141 | /* EE_HANDS handedness */ | ||
| 142 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { | ||
| 143 | eeconfig_update_handedness(true); | ||
| 144 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) { | ||
| 145 | eeconfig_update_handedness(false); | ||
| 146 | } | ||
| 147 | } | ||
diff --git a/quantum/bootmagic/bootmagic_full.h b/quantum/bootmagic/bootmagic_full.h new file mode 100644 index 000000000..28f914c1b --- /dev/null +++ b/quantum/bootmagic/bootmagic_full.h | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | /* FIXME: Add special doxygen comments for defines here. */ | ||
| 20 | |||
| 21 | /* bootmagic salt key */ | ||
| 22 | #ifndef BOOTMAGIC_KEY_SALT | ||
| 23 | # define BOOTMAGIC_KEY_SALT KC_SPACE | ||
| 24 | #endif | ||
| 25 | |||
| 26 | /* skip bootmagic and eeconfig */ | ||
| 27 | #ifndef BOOTMAGIC_KEY_SKIP | ||
| 28 | # define BOOTMAGIC_KEY_SKIP KC_ESC | ||
| 29 | #endif | ||
| 30 | |||
| 31 | /* eeprom clear */ | ||
| 32 | #ifndef BOOTMAGIC_KEY_EEPROM_CLEAR | ||
| 33 | # define BOOTMAGIC_KEY_EEPROM_CLEAR KC_BSPACE | ||
| 34 | #endif | ||
| 35 | |||
| 36 | /* kick up bootloader */ | ||
| 37 | #ifndef BOOTMAGIC_KEY_BOOTLOADER | ||
| 38 | # define BOOTMAGIC_KEY_BOOTLOADER KC_B | ||
| 39 | #endif | ||
| 40 | |||
| 41 | /* debug enable */ | ||
| 42 | #ifndef BOOTMAGIC_KEY_DEBUG_ENABLE | ||
| 43 | # define BOOTMAGIC_KEY_DEBUG_ENABLE KC_D | ||
| 44 | #endif | ||
| 45 | #ifndef BOOTMAGIC_KEY_DEBUG_MATRIX | ||
| 46 | # define BOOTMAGIC_KEY_DEBUG_MATRIX KC_X | ||
| 47 | #endif | ||
| 48 | #ifndef BOOTMAGIC_KEY_DEBUG_KEYBOARD | ||
| 49 | # define BOOTMAGIC_KEY_DEBUG_KEYBOARD KC_K | ||
| 50 | #endif | ||
| 51 | #ifndef BOOTMAGIC_KEY_DEBUG_MOUSE | ||
| 52 | # define BOOTMAGIC_KEY_DEBUG_MOUSE KC_M | ||
| 53 | #endif | ||
| 54 | #ifndef BOOTMAGIC_KEY_EE_HANDS_LEFT | ||
| 55 | # define BOOTMAGIC_KEY_EE_HANDS_LEFT KC_L | ||
| 56 | #endif | ||
| 57 | #ifndef BOOTMAGIC_KEY_EE_HANDS_RIGHT | ||
| 58 | # define BOOTMAGIC_KEY_EE_HANDS_RIGHT KC_R | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* | ||
| 62 | * keymap config | ||
| 63 | */ | ||
| 64 | #ifndef BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK | ||
| 65 | # define BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK KC_LCTRL | ||
| 66 | #endif | ||
| 67 | #ifndef BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL | ||
| 68 | # define BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL KC_CAPSLOCK | ||
| 69 | #endif | ||
| 70 | #ifndef BOOTMAGIC_KEY_SWAP_LALT_LGUI | ||
| 71 | # define BOOTMAGIC_KEY_SWAP_LALT_LGUI KC_LALT | ||
| 72 | #endif | ||
| 73 | #ifndef BOOTMAGIC_KEY_SWAP_RALT_RGUI | ||
| 74 | # define BOOTMAGIC_KEY_SWAP_RALT_RGUI KC_RALT | ||
| 75 | #endif | ||
| 76 | #ifndef BOOTMAGIC_KEY_NO_GUI | ||
| 77 | # define BOOTMAGIC_KEY_NO_GUI KC_LGUI | ||
| 78 | #endif | ||
| 79 | #ifndef BOOTMAGIC_KEY_SWAP_GRAVE_ESC | ||
| 80 | # define BOOTMAGIC_KEY_SWAP_GRAVE_ESC KC_GRAVE | ||
| 81 | #endif | ||
| 82 | #ifndef BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE | ||
| 83 | # define BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE KC_BSLASH | ||
| 84 | #endif | ||
| 85 | #ifndef BOOTMAGIC_HOST_NKRO | ||
| 86 | # define BOOTMAGIC_HOST_NKRO KC_N | ||
| 87 | #endif | ||
| 88 | |||
| 89 | /* | ||
| 90 | * change default layer | ||
| 91 | */ | ||
| 92 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_0 | ||
| 93 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_0 KC_0 | ||
| 94 | #endif | ||
| 95 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_1 | ||
| 96 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_1 KC_1 | ||
| 97 | #endif | ||
| 98 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_2 | ||
| 99 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_2 KC_2 | ||
| 100 | #endif | ||
| 101 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_3 | ||
| 102 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_3 KC_3 | ||
| 103 | #endif | ||
| 104 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_4 | ||
| 105 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_4 KC_4 | ||
| 106 | #endif | ||
| 107 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_5 | ||
| 108 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_5 KC_5 | ||
| 109 | #endif | ||
| 110 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_6 | ||
| 111 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_6 KC_6 | ||
| 112 | #endif | ||
| 113 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7 | ||
| 114 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7 | ||
| 115 | #endif \ No newline at end of file | ||
diff --git a/quantum/bootmagic/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c new file mode 100644 index 000000000..9cbdcb0bb --- /dev/null +++ b/quantum/bootmagic/bootmagic_lite.c | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "quantum.h" | ||
| 17 | |||
| 18 | /** \brief Reset eeprom | ||
| 19 | * | ||
| 20 | * ...just incase someone wants to only change the eeprom behaviour | ||
| 21 | */ | ||
| 22 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { | ||
| 23 | #if defined(VIA_ENABLE) | ||
| 24 | via_eeprom_reset(); | ||
| 25 | #else | ||
| 26 | eeconfig_disable(); | ||
| 27 | #endif | ||
| 28 | } | ||
| 29 | |||
| 30 | /** \brief The lite version of TMK's bootmagic based on Wilba. | ||
| 31 | * | ||
| 32 | * 100% less potential for accidentally making the keyboard do stupid things. | ||
| 33 | */ | ||
| 34 | __attribute__((weak)) void bootmagic_lite(void) { | ||
| 35 | // We need multiple scans because debouncing can't be turned off. | ||
| 36 | matrix_scan(); | ||
| 37 | #if defined(DEBOUNCE) && DEBOUNCE > 0 | ||
| 38 | wait_ms(DEBOUNCE * 2); | ||
| 39 | #else | ||
| 40 | wait_ms(30); | ||
| 41 | #endif | ||
| 42 | matrix_scan(); | ||
| 43 | |||
| 44 | // If the configured key (commonly Esc) is held down on power up, | ||
| 45 | // reset the EEPROM valid state and jump to bootloader. | ||
| 46 | // This isn't very generalized, but we need something that doesn't | ||
| 47 | // rely on user's keymaps in firmware or EEPROM. | ||
| 48 | uint8_t row = BOOTMAGIC_LITE_ROW; | ||
| 49 | uint8_t col = BOOTMAGIC_LITE_COLUMN; | ||
| 50 | |||
| 51 | #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) | ||
| 52 | if (!is_keyboard_left()) { | ||
| 53 | row = BOOTMAGIC_LITE_ROW_RIGHT; | ||
| 54 | col = BOOTMAGIC_LITE_COLUMN_RIGHT; | ||
| 55 | } | ||
| 56 | #endif | ||
| 57 | |||
| 58 | if (matrix_get_row(row) & (1 << col)) { | ||
| 59 | bootmagic_lite_reset_eeprom(); | ||
| 60 | |||
| 61 | // Jump to bootloader. | ||
| 62 | bootloader_jump(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | void bootmagic(void) { bootmagic_lite(); } | ||
diff --git a/quantum/bootmagic/bootmagic_lite.h b/quantum/bootmagic/bootmagic_lite.h new file mode 100644 index 000000000..17777e6b4 --- /dev/null +++ b/quantum/bootmagic/bootmagic_lite.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #ifndef BOOTMAGIC_LITE_COLUMN | ||
| 19 | # define BOOTMAGIC_LITE_COLUMN 0 | ||
| 20 | #endif | ||
| 21 | #ifndef BOOTMAGIC_LITE_ROW | ||
| 22 | # define BOOTMAGIC_LITE_ROW 0 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | void bootmagic_lite(void); | ||
diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c new file mode 100644 index 000000000..f1cb11c39 --- /dev/null +++ b/quantum/bootmagic/magic.c | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include <stdint.h> | ||
| 17 | #include <stdbool.h> | ||
| 18 | #include "wait.h" | ||
| 19 | #include "matrix.h" | ||
| 20 | #include "bootloader.h" | ||
| 21 | #include "debug.h" | ||
| 22 | #include "keymap.h" | ||
| 23 | #include "host.h" | ||
| 24 | #include "action_layer.h" | ||
| 25 | #include "eeconfig.h" | ||
| 26 | #include "bootmagic.h" | ||
| 27 | |||
| 28 | keymap_config_t keymap_config; | ||
| 29 | |||
| 30 | __attribute__((weak)) void bootmagic(void) {} | ||
| 31 | |||
| 32 | /** \brief Magic | ||
| 33 | * | ||
| 34 | * FIXME: Needs doc | ||
| 35 | */ | ||
| 36 | void magic(void) { | ||
| 37 | /* check signature */ | ||
| 38 | if (!eeconfig_is_enabled()) { | ||
| 39 | eeconfig_init(); | ||
| 40 | } | ||
| 41 | |||
| 42 | /* init globals */ | ||
| 43 | debug_config.raw = eeconfig_read_debug(); | ||
| 44 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 45 | |||
| 46 | bootmagic(); | ||
| 47 | |||
| 48 | /* read here just incase bootmagic process changed its value */ | ||
| 49 | layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer(); | ||
| 50 | default_layer_set(default_layer); | ||
| 51 | |||
| 52 | /* Also initialize layer state to trigger callback functions for layer_state */ | ||
| 53 | layer_state_set_kb((layer_state_t)layer_state); | ||
| 54 | } | ||
diff --git a/quantum/bootmagic/magic.h b/quantum/bootmagic/magic.h new file mode 100644 index 000000000..2c3969b85 --- /dev/null +++ b/quantum/bootmagic/magic.h | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | void magic(void); | ||
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index f878168c5..d7e334fdc 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h | |||
| @@ -37,6 +37,7 @@ typedef union { | |||
| 37 | bool nkro : 1; | 37 | bool nkro : 1; |
| 38 | bool swap_lctl_lgui : 1; | 38 | bool swap_lctl_lgui : 1; |
| 39 | bool swap_rctl_rgui : 1; | 39 | bool swap_rctl_rgui : 1; |
| 40 | bool oneshot_disable : 1; | ||
| 40 | }; | 41 | }; |
| 41 | } keymap_config_t; | 42 | } keymap_config_t; |
| 42 | 43 | ||
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c index 4f1f06c7a..ceb236809 100644 --- a/quantum/led_matrix.c +++ b/quantum/led_matrix.c | |||
| @@ -17,9 +17,6 @@ | |||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #include <stdint.h> | ||
| 21 | #include <stdbool.h> | ||
| 22 | #include "quantum.h" | ||
| 23 | #include "led_matrix.h" | 20 | #include "led_matrix.h" |
| 24 | #include "progmem.h" | 21 | #include "progmem.h" |
| 25 | #include "config.h" | 22 | #include "config.h" |
| @@ -37,20 +34,41 @@ led_eeconfig_t led_matrix_eeconfig; | |||
| 37 | # define MIN(a, b) ((a) < (b) ? (a) : (b)) | 34 | # define MIN(a, b) ((a) < (b) ? (a) : (b)) |
| 38 | #endif | 35 | #endif |
| 39 | 36 | ||
| 40 | #ifndef LED_DISABLE_AFTER_TIMEOUT | 37 | #if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT) |
| 41 | # define LED_DISABLE_AFTER_TIMEOUT 0 | 38 | # define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL) |
| 39 | #endif | ||
| 40 | |||
| 41 | #ifndef LED_DISABLE_TIMEOUT | ||
| 42 | # define LED_DISABLE_TIMEOUT 0 | ||
| 42 | #endif | 43 | #endif |
| 43 | 44 | ||
| 44 | #ifndef LED_DISABLE_WHEN_USB_SUSPENDED | 45 | #ifndef LED_DISABLE_WHEN_USB_SUSPENDED |
| 45 | # define LED_DISABLE_WHEN_USB_SUSPENDED false | 46 | # define LED_DISABLE_WHEN_USB_SUSPENDED false |
| 46 | #endif | 47 | #endif |
| 47 | 48 | ||
| 48 | #ifndef EECONFIG_LED_MATRIX | 49 | #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX |
| 49 | # define EECONFIG_LED_MATRIX EECONFIG_RGBLIGHT | 50 | # undef LED_MATRIX_MAXIMUM_BRIGHTNESS |
| 51 | # define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #if !defined(LED_MATRIX_VAL_STEP) | ||
| 55 | # define LED_MATRIX_VAL_STEP 8 | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #if !defined(LED_MATRIX_SPD_STEP) | ||
| 59 | # define LED_MATRIX_SPD_STEP 16 | ||
| 50 | #endif | 60 | #endif |
| 51 | 61 | ||
| 52 | #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > 255 | 62 | #if !defined(LED_MATRIX_STARTUP_MODE) |
| 53 | # define LED_MATRIX_MAXIMUM_BRIGHTNESS 255 | 63 | # define LED_MATRIX_STARTUP_MODE LED_MATRIX_UNIFORM_BRIGHTNESS |
| 64 | #endif | ||
| 65 | |||
| 66 | #if !defined(LED_MATRIX_STARTUP_VAL) | ||
| 67 | # define LED_MATRIX_STARTUP_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS | ||
| 68 | #endif | ||
| 69 | |||
| 70 | #if !defined(LED_MATRIX_STARTUP_SPD) | ||
| 71 | # define LED_MATRIX_STARTUP_SPD UINT8_MAX / 2 | ||
| 54 | #endif | 72 | #endif |
| 55 | 73 | ||
| 56 | bool g_suspend_state = false; | 74 | bool g_suspend_state = false; |
| @@ -64,21 +82,21 @@ uint8_t g_key_hit[DRIVER_LED_TOTAL]; | |||
| 64 | // Ticks since any key was last hit. | 82 | // Ticks since any key was last hit. |
| 65 | uint32_t g_any_key_hit = 0; | 83 | uint32_t g_any_key_hit = 0; |
| 66 | 84 | ||
| 67 | uint32_t eeconfig_read_led_matrix(void) { return eeprom_read_dword(EECONFIG_LED_MATRIX); } | 85 | void eeconfig_read_led_matrix(void) { eeprom_read_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); } |
| 68 | 86 | ||
| 69 | void eeconfig_update_led_matrix(uint32_t config_value) { eeprom_update_dword(EECONFIG_LED_MATRIX, config_value); } | 87 | void eeconfig_update_led_matrix(void) { eeprom_update_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); } |
| 70 | 88 | ||
| 71 | void eeconfig_update_led_matrix_default(void) { | 89 | void eeconfig_update_led_matrix_default(void) { |
| 72 | dprintf("eeconfig_update_led_matrix_default\n"); | 90 | dprintf("eeconfig_update_led_matrix_default\n"); |
| 73 | led_matrix_eeconfig.enable = 1; | 91 | led_matrix_eeconfig.enable = 1; |
| 74 | led_matrix_eeconfig.mode = LED_MATRIX_UNIFORM_BRIGHTNESS; | 92 | led_matrix_eeconfig.mode = LED_MATRIX_STARTUP_MODE; |
| 75 | led_matrix_eeconfig.val = 128; | 93 | led_matrix_eeconfig.val = LED_MATRIX_STARTUP_VAL; |
| 76 | led_matrix_eeconfig.speed = 0; | 94 | led_matrix_eeconfig.speed = LED_MATRIX_STARTUP_SPD; |
| 77 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 95 | eeconfig_update_led_matrix(); |
| 78 | } | 96 | } |
| 79 | 97 | ||
| 80 | void eeconfig_debug_led_matrix(void) { | 98 | void eeconfig_debug_led_matrix(void) { |
| 81 | dprintf("led_matrix_eeconfig eeprom\n"); | 99 | dprintf("led_matrix_eeconfig EEPROM\n"); |
| 82 | dprintf("led_matrix_eeconfig.enable = %d\n", led_matrix_eeconfig.enable); | 100 | dprintf("led_matrix_eeconfig.enable = %d\n", led_matrix_eeconfig.enable); |
| 83 | dprintf("led_matrix_eeconfig.mode = %d\n", led_matrix_eeconfig.mode); | 101 | dprintf("led_matrix_eeconfig.mode = %d\n", led_matrix_eeconfig.mode); |
| 84 | dprintf("led_matrix_eeconfig.val = %d\n", led_matrix_eeconfig.val); | 102 | dprintf("led_matrix_eeconfig.val = %d\n", led_matrix_eeconfig.val); |
| @@ -135,7 +153,7 @@ void led_matrix_set_suspend_state(bool state) { g_suspend_state = state; } | |||
| 135 | void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); } | 153 | void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); } |
| 136 | 154 | ||
| 137 | // Uniform brightness | 155 | // Uniform brightness |
| 138 | void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(LED_MATRIX_MAXIMUM_BRIGHTNESS / BACKLIGHT_LEVELS * led_matrix_eeconfig.val); } | 156 | void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(led_matrix_eeconfig.val); } |
| 139 | 157 | ||
| 140 | void led_matrix_custom(void) {} | 158 | void led_matrix_custom(void) {} |
| 141 | 159 | ||
| @@ -161,7 +179,7 @@ void led_matrix_task(void) { | |||
| 161 | 179 | ||
| 162 | // Ideally we would also stop sending zeros to the LED driver PWM buffers | 180 | // Ideally we would also stop sending zeros to the LED driver PWM buffers |
| 163 | // while suspended and just do a software shutdown. This is a cheap hack for now. | 181 | // while suspended and just do a software shutdown. This is a cheap hack for now. |
| 164 | bool suspend_backlight = ((g_suspend_state && LED_DISABLE_WHEN_USB_SUSPENDED) || (LED_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > LED_DISABLE_AFTER_TIMEOUT * 60 * 20)); | 182 | bool suspend_backlight = ((g_suspend_state && LED_DISABLE_WHEN_USB_SUSPENDED) || (LED_DISABLE_TIMEOUT > 0 && g_any_key_hit > LED_DISABLE_TIMEOUT)); |
| 165 | uint8_t effect = suspend_backlight ? 0 : led_matrix_eeconfig.mode; | 183 | uint8_t effect = suspend_backlight ? 0 : led_matrix_eeconfig.mode; |
| 166 | 184 | ||
| 167 | // this gets ticked at 20 Hz. | 185 | // this gets ticked at 20 Hz. |
| @@ -227,12 +245,10 @@ void led_matrix_init(void) { | |||
| 227 | eeconfig_update_led_matrix_default(); | 245 | eeconfig_update_led_matrix_default(); |
| 228 | } | 246 | } |
| 229 | 247 | ||
| 230 | led_matrix_eeconfig.raw = eeconfig_read_led_matrix(); | 248 | eeconfig_read_led_matrix(); |
| 231 | |||
| 232 | if (!led_matrix_eeconfig.mode) { | 249 | if (!led_matrix_eeconfig.mode) { |
| 233 | dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n"); | 250 | dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n"); |
| 234 | eeconfig_update_led_matrix_default(); | 251 | eeconfig_update_led_matrix_default(); |
| 235 | led_matrix_eeconfig.raw = eeconfig_read_led_matrix(); | ||
| 236 | } | 252 | } |
| 237 | 253 | ||
| 238 | eeconfig_debug_led_matrix(); // display current eeprom values | 254 | eeconfig_debug_led_matrix(); // display current eeprom values |
| @@ -276,19 +292,19 @@ uint32_t led_matrix_get_tick(void) { return g_tick; } | |||
| 276 | 292 | ||
| 277 | void led_matrix_toggle(void) { | 293 | void led_matrix_toggle(void) { |
| 278 | led_matrix_eeconfig.enable ^= 1; | 294 | led_matrix_eeconfig.enable ^= 1; |
| 279 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 295 | eeconfig_update_led_matrix(); |
| 280 | } | 296 | } |
| 281 | 297 | ||
| 282 | void led_matrix_enable(void) { | 298 | void led_matrix_enable(void) { |
| 283 | led_matrix_eeconfig.enable = 1; | 299 | led_matrix_eeconfig.enable = 1; |
| 284 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 300 | eeconfig_update_led_matrix(); |
| 285 | } | 301 | } |
| 286 | 302 | ||
| 287 | void led_matrix_enable_noeeprom(void) { led_matrix_eeconfig.enable = 1; } | 303 | void led_matrix_enable_noeeprom(void) { led_matrix_eeconfig.enable = 1; } |
| 288 | 304 | ||
| 289 | void led_matrix_disable(void) { | 305 | void led_matrix_disable(void) { |
| 290 | led_matrix_eeconfig.enable = 0; | 306 | led_matrix_eeconfig.enable = 0; |
| 291 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 307 | eeconfig_update_led_matrix(); |
| 292 | } | 308 | } |
| 293 | 309 | ||
| 294 | void led_matrix_disable_noeeprom(void) { led_matrix_eeconfig.enable = 0; } | 310 | void led_matrix_disable_noeeprom(void) { led_matrix_eeconfig.enable = 0; } |
| @@ -298,7 +314,7 @@ void led_matrix_step(void) { | |||
| 298 | if (led_matrix_eeconfig.mode >= LED_MATRIX_EFFECT_MAX) { | 314 | if (led_matrix_eeconfig.mode >= LED_MATRIX_EFFECT_MAX) { |
| 299 | led_matrix_eeconfig.mode = 1; | 315 | led_matrix_eeconfig.mode = 1; |
| 300 | } | 316 | } |
| 301 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 317 | eeconfig_update_led_matrix(); |
| 302 | } | 318 | } |
| 303 | 319 | ||
| 304 | void led_matrix_step_reverse(void) { | 320 | void led_matrix_step_reverse(void) { |
| @@ -306,33 +322,33 @@ void led_matrix_step_reverse(void) { | |||
| 306 | if (led_matrix_eeconfig.mode < 1) { | 322 | if (led_matrix_eeconfig.mode < 1) { |
| 307 | led_matrix_eeconfig.mode = LED_MATRIX_EFFECT_MAX - 1; | 323 | led_matrix_eeconfig.mode = LED_MATRIX_EFFECT_MAX - 1; |
| 308 | } | 324 | } |
| 309 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 325 | eeconfig_update_led_matrix(); |
| 310 | } | 326 | } |
| 311 | 327 | ||
| 312 | void led_matrix_increase_val(void) { | 328 | void led_matrix_increase_val(void) { |
| 313 | led_matrix_eeconfig.val = increment(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS); | 329 | led_matrix_eeconfig.val = increment(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS); |
| 314 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 330 | eeconfig_update_led_matrix(); |
| 315 | } | 331 | } |
| 316 | 332 | ||
| 317 | void led_matrix_decrease_val(void) { | 333 | void led_matrix_decrease_val(void) { |
| 318 | led_matrix_eeconfig.val = decrement(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS); | 334 | led_matrix_eeconfig.val = decrement(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS); |
| 319 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 335 | eeconfig_update_led_matrix(); |
| 320 | } | 336 | } |
| 321 | 337 | ||
| 322 | void led_matrix_increase_speed(void) { | 338 | void led_matrix_increase_speed(void) { |
| 323 | led_matrix_eeconfig.speed = increment(led_matrix_eeconfig.speed, 1, 0, 3); | 339 | led_matrix_eeconfig.speed = increment(led_matrix_eeconfig.speed, 1, 0, 3); |
| 324 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); // EECONFIG needs to be increased to support this | 340 | eeconfig_update_led_matrix(); // EECONFIG needs to be increased to support this |
| 325 | } | 341 | } |
| 326 | 342 | ||
| 327 | void led_matrix_decrease_speed(void) { | 343 | void led_matrix_decrease_speed(void) { |
| 328 | led_matrix_eeconfig.speed = decrement(led_matrix_eeconfig.speed, 1, 0, 3); | 344 | led_matrix_eeconfig.speed = decrement(led_matrix_eeconfig.speed, 1, 0, 3); |
| 329 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); // EECONFIG needs to be increased to support this | 345 | eeconfig_update_led_matrix(); // EECONFIG needs to be increased to support this |
| 330 | } | 346 | } |
| 331 | 347 | ||
| 332 | void led_matrix_mode(uint8_t mode, bool eeprom_write) { | 348 | void led_matrix_mode(uint8_t mode, bool eeprom_write) { |
| 333 | led_matrix_eeconfig.mode = mode; | 349 | led_matrix_eeconfig.mode = mode; |
| 334 | if (eeprom_write) { | 350 | if (eeprom_write) { |
| 335 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 351 | eeconfig_update_led_matrix(); |
| 336 | } | 352 | } |
| 337 | } | 353 | } |
| 338 | 354 | ||
| @@ -342,7 +358,5 @@ void led_matrix_set_value_noeeprom(uint8_t val) { led_matrix_eeconfig.val = val; | |||
| 342 | 358 | ||
| 343 | void led_matrix_set_value(uint8_t val) { | 359 | void led_matrix_set_value(uint8_t val) { |
| 344 | led_matrix_set_value_noeeprom(val); | 360 | led_matrix_set_value_noeeprom(val); |
| 345 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 361 | eeconfig_update_led_matrix(); |
| 346 | } | 362 | } |
| 347 | |||
| 348 | void backlight_set(uint8_t val) { led_matrix_set_value(val); } | ||
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h index 85bae43c1..e4322a150 100644 --- a/quantum/led_matrix.h +++ b/quantum/led_matrix.h | |||
| @@ -19,10 +19,13 @@ | |||
| 19 | 19 | ||
| 20 | #pragma once | 20 | #pragma once |
| 21 | 21 | ||
| 22 | #include <stdint.h> | ||
| 23 | #include <stdbool.h> | ||
| 22 | #include "led_matrix_types.h" | 24 | #include "led_matrix_types.h" |
| 25 | #include "quantum.h" | ||
| 23 | 26 | ||
| 24 | #ifndef BACKLIGHT_ENABLE | 27 | #ifdef IS31FL3731 |
| 25 | # error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE | 28 | # include "is31fl3731-simple.h" |
| 26 | #endif | 29 | #endif |
| 27 | 30 | ||
| 28 | enum led_matrix_effects { | 31 | enum led_matrix_effects { |
diff --git a/quantum/led_matrix_drivers.c b/quantum/led_matrix_drivers.c index eddf3f286..370c5e685 100644 --- a/quantum/led_matrix_drivers.c +++ b/quantum/led_matrix_drivers.c | |||
| @@ -15,9 +15,6 @@ | |||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #include "quantum.h" | ||
| 21 | #include "led_matrix.h" | 18 | #include "led_matrix.h" |
| 22 | 19 | ||
| 23 | /* Each driver needs to define a struct: | 20 | /* Each driver needs to define a struct: |
| @@ -30,10 +27,6 @@ | |||
| 30 | 27 | ||
| 31 | #if defined(IS31FL3731) || defined(IS31FL3733) | 28 | #if defined(IS31FL3731) || defined(IS31FL3733) |
| 32 | 29 | ||
| 33 | # if defined(IS31FL3731) | ||
| 34 | # include "is31fl3731-simple.h" | ||
| 35 | # endif | ||
| 36 | |||
| 37 | # include "i2c_master.h" | 30 | # include "i2c_master.h" |
| 38 | 31 | ||
| 39 | static void init(void) { | 32 | static void init(void) { |
diff --git a/quantum/led_matrix_types.h b/quantum/led_matrix_types.h index 669b67042..be0e10bb9 100644 --- a/quantum/led_matrix_types.h +++ b/quantum/led_matrix_types.h | |||
| @@ -29,16 +29,43 @@ | |||
| 29 | # pragma pack(push, 1) | 29 | # pragma pack(push, 1) |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES) | ||
| 33 | # define LED_MATRIX_KEYREACTIVE_ENABLED | ||
| 34 | #endif | ||
| 35 | |||
| 32 | // Last led hit | 36 | // Last led hit |
| 33 | #ifndef LED_HITS_TO_REMEMBER | 37 | #ifndef LED_HITS_TO_REMEMBER |
| 34 | # define LED_HITS_TO_REMEMBER 8 | 38 | # define LED_HITS_TO_REMEMBER 8 |
| 35 | #endif // LED_HITS_TO_REMEMBER | 39 | #endif // LED_HITS_TO_REMEMBER |
| 36 | 40 | ||
| 41 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | ||
| 42 | typedef struct PACKED { | ||
| 43 | uint8_t count; | ||
| 44 | uint8_t x[LED_HITS_TO_REMEMBER]; | ||
| 45 | uint8_t y[LED_HITS_TO_REMEMBER]; | ||
| 46 | uint8_t index[LED_HITS_TO_REMEMBER]; | ||
| 47 | uint16_t tick[LED_HITS_TO_REMEMBER]; | ||
| 48 | } last_hit_t; | ||
| 49 | #endif // LED_MATRIX_KEYREACTIVE_ENABLED | ||
| 50 | |||
| 51 | typedef enum led_task_states { STARTING, RENDERING, FLUSHING, SYNCING } led_task_states; | ||
| 52 | |||
| 53 | typedef uint8_t led_flags_t; | ||
| 54 | |||
| 55 | typedef struct PACKED { | ||
| 56 | uint8_t iter; | ||
| 57 | led_flags_t flags; | ||
| 58 | bool init; | ||
| 59 | } effect_params_t; | ||
| 60 | |||
| 37 | typedef struct PACKED { | 61 | typedef struct PACKED { |
| 38 | uint8_t x; | 62 | uint8_t x; |
| 39 | uint8_t y; | 63 | uint8_t y; |
| 40 | } point_t; | 64 | } point_t; |
| 41 | 65 | ||
| 66 | #define HAS_FLAGS(bits, flags) ((bits & flags) == flags) | ||
| 67 | #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) | ||
| 68 | |||
| 42 | #define LED_FLAG_ALL 0xFF | 69 | #define LED_FLAG_ALL 0xFF |
| 43 | #define LED_FLAG_NONE 0x00 | 70 | #define LED_FLAG_NONE 0x00 |
| 44 | #define LED_FLAG_MODIFIER 0x01 | 71 | #define LED_FLAG_MODIFIER 0x01 |
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk index f7329fc4d..53e03a805 100644 --- a/quantum/mcu_selection.mk +++ b/quantum/mcu_selection.mk | |||
| @@ -81,6 +81,33 @@ ifneq ($(findstring MK20DX256, $(MCU)),) | |||
| 81 | BOARD ?= PJRC_TEENSY_3_1 | 81 | BOARD ?= PJRC_TEENSY_3_1 |
| 82 | endif | 82 | endif |
| 83 | 83 | ||
| 84 | ifneq ($(findstring MK66F18, $(MCU)),) | ||
| 85 | # Cortex version | ||
| 86 | MCU = cortex-m4 | ||
| 87 | |||
| 88 | # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 | ||
| 89 | ARMV = 7 | ||
| 90 | |||
| 91 | ## chip/board settings | ||
| 92 | # - the next two should match the directories in | ||
| 93 | # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) | ||
| 94 | MCU_FAMILY = KINETIS | ||
| 95 | MCU_SERIES = MK66F18 | ||
| 96 | |||
| 97 | # Linker script to use | ||
| 98 | # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/ | ||
| 99 | # or <keyboard_dir>/ld/ | ||
| 100 | MCU_LDSCRIPT ?= MK66FX1M0 | ||
| 101 | |||
| 102 | # Startup code to use | ||
| 103 | # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/ | ||
| 104 | MCU_STARTUP ?= MK66F18 | ||
| 105 | |||
| 106 | # Board: it should exist either in <chibios>/os/hal/boards/, | ||
| 107 | # <keyboard_dir>/boards/, or drivers/boards/ | ||
| 108 | BOARD ?= PJRC_TEENSY_3_6 | ||
| 109 | endif | ||
| 110 | |||
| 84 | ifneq ($(findstring STM32F042, $(MCU)),) | 111 | ifneq ($(findstring STM32F042, $(MCU)),) |
| 85 | # Cortex version | 112 | # Cortex version |
| 86 | MCU = cortex-m0 | 113 | MCU = cortex-m0 |
diff --git a/quantum/process_keycode/process_backlight.c b/quantum/process_keycode/process_backlight.c index 4d12f6813..8b70339a5 100644 --- a/quantum/process_keycode/process_backlight.c +++ b/quantum/process_keycode/process_backlight.c | |||
| @@ -16,11 +16,35 @@ | |||
| 16 | 16 | ||
| 17 | #include "process_backlight.h" | 17 | #include "process_backlight.h" |
| 18 | 18 | ||
| 19 | #include "backlight.h" | 19 | #ifdef LED_MATRIX_ENABLE |
| 20 | # include "led_matrix.h" | ||
| 21 | #else | ||
| 22 | # include "backlight.h" | ||
| 23 | #endif | ||
| 20 | 24 | ||
| 21 | bool process_backlight(uint16_t keycode, keyrecord_t *record) { | 25 | bool process_backlight(uint16_t keycode, keyrecord_t *record) { |
| 22 | if (record->event.pressed) { | 26 | if (record->event.pressed) { |
| 23 | switch (keycode) { | 27 | switch (keycode) { |
| 28 | #ifdef LED_MATRIX_ENABLE | ||
| 29 | case BL_ON: | ||
| 30 | led_matrix_enable(); | ||
| 31 | return false; | ||
| 32 | case BL_OFF: | ||
| 33 | led_matrix_disable(); | ||
| 34 | return false; | ||
| 35 | case BL_DEC: | ||
| 36 | led_matrix_decrease_val(); | ||
| 37 | return false; | ||
| 38 | case BL_INC: | ||
| 39 | led_matrix_increase_val(); | ||
| 40 | return false; | ||
| 41 | case BL_TOGG: | ||
| 42 | led_matrix_toggle(); | ||
| 43 | return false; | ||
| 44 | case BL_STEP: | ||
| 45 | led_matrix_step(); | ||
| 46 | return false; | ||
| 47 | #else | ||
| 24 | case BL_ON: | 48 | case BL_ON: |
| 25 | backlight_level(BACKLIGHT_LEVELS); | 49 | backlight_level(BACKLIGHT_LEVELS); |
| 26 | return false; | 50 | return false; |
| @@ -39,10 +63,11 @@ bool process_backlight(uint16_t keycode, keyrecord_t *record) { | |||
| 39 | case BL_STEP: | 63 | case BL_STEP: |
| 40 | backlight_step(); | 64 | backlight_step(); |
| 41 | return false; | 65 | return false; |
| 42 | #ifdef BACKLIGHT_BREATHING | 66 | # ifdef BACKLIGHT_BREATHING |
| 43 | case BL_BRTG: | 67 | case BL_BRTG: |
| 44 | backlight_toggle_breathing(); | 68 | backlight_toggle_breathing(); |
| 45 | return false; | 69 | return false; |
| 70 | # endif | ||
| 46 | #endif | 71 | #endif |
| 47 | } | 72 | } |
| 48 | } | 73 | } |
diff --git a/quantum/quantum.c b/quantum/quantum.c index b40b40544..8ccdb774b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "quantum.h" | 17 | #include "quantum.h" |
| 18 | #include "magic.h" | ||
| 18 | 19 | ||
| 19 | #ifdef BLUETOOTH_ENABLE | 20 | #ifdef BLUETOOTH_ENABLE |
| 20 | # include "outputselect.h" | 21 | # include "outputselect.h" |
| @@ -233,7 +234,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 233 | #ifdef AUDIO_ENABLE | 234 | #ifdef AUDIO_ENABLE |
| 234 | process_audio(keycode, record) && | 235 | process_audio(keycode, record) && |
| 235 | #endif | 236 | #endif |
| 236 | #ifdef BACKLIGHT_ENABLE | 237 | #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) |
| 237 | process_backlight(keycode, record) && | 238 | process_backlight(keycode, record) && |
| 238 | #endif | 239 | #endif |
| 239 | #ifdef STENO_ENABLE | 240 | #ifdef STENO_ENABLE |
| @@ -318,6 +319,17 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 318 | set_output(OUTPUT_BLUETOOTH); | 319 | set_output(OUTPUT_BLUETOOTH); |
| 319 | return false; | 320 | return false; |
| 320 | #endif | 321 | #endif |
| 322 | #ifndef NO_ACTION_ONESHOT | ||
| 323 | case ONESHOT_TOGGLE: | ||
| 324 | oneshot_toggle(); | ||
| 325 | break; | ||
| 326 | case ONESHOT_ENABLE: | ||
| 327 | oneshot_enable(); | ||
| 328 | break; | ||
| 329 | case ONESHOT_DISABLE: | ||
| 330 | oneshot_disable(); | ||
| 331 | break; | ||
| 332 | #endif | ||
| 321 | } | 333 | } |
| 322 | } | 334 | } |
| 323 | 335 | ||
| @@ -341,26 +353,20 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_ | |||
| 341 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } | 353 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } |
| 342 | 354 | ||
| 343 | void matrix_init_quantum() { | 355 | void matrix_init_quantum() { |
| 344 | #ifdef BOOTMAGIC_LITE | 356 | magic(); |
| 345 | bootmagic_lite(); | ||
| 346 | #endif | ||
| 347 | if (!eeconfig_is_enabled()) { | ||
| 348 | eeconfig_init(); | ||
| 349 | } | ||
| 350 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) | 357 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) |
| 351 | // TODO: remove calls to led_init_ports from keyboards and remove ifdef | 358 | // TODO: remove calls to led_init_ports from keyboards and remove ifdef |
| 352 | led_init_ports(); | 359 | led_init_ports(); |
| 353 | #endif | 360 | #endif |
| 354 | #ifdef BACKLIGHT_ENABLE | 361 | #ifdef BACKLIGHT_ENABLE |
| 355 | # ifdef LED_MATRIX_ENABLE | ||
| 356 | led_matrix_init(); | ||
| 357 | # else | ||
| 358 | backlight_init_ports(); | 362 | backlight_init_ports(); |
| 359 | # endif | ||
| 360 | #endif | 363 | #endif |
| 361 | #ifdef AUDIO_ENABLE | 364 | #ifdef AUDIO_ENABLE |
| 362 | audio_init(); | 365 | audio_init(); |
| 363 | #endif | 366 | #endif |
| 367 | #ifdef LED_MATRIX_ENABLE | ||
| 368 | led_matrix_init(); | ||
| 369 | #endif | ||
| 364 | #ifdef RGB_MATRIX_ENABLE | 370 | #ifdef RGB_MATRIX_ENABLE |
| 365 | rgb_matrix_init(); | 371 | rgb_matrix_init(); |
| 366 | #endif | 372 | #endif |
diff --git a/quantum/quantum.h b/quantum/quantum.h index e24a4c43a..fe6bf310a 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -30,11 +30,11 @@ | |||
| 30 | #include "keymap.h" | 30 | #include "keymap.h" |
| 31 | 31 | ||
| 32 | #ifdef BACKLIGHT_ENABLE | 32 | #ifdef BACKLIGHT_ENABLE |
| 33 | # ifdef LED_MATRIX_ENABLE | 33 | # include "backlight.h" |
| 34 | # include "led_matrix.h" | 34 | #endif |
| 35 | # else | 35 | |
| 36 | # include "backlight.h" | 36 | #ifdef LED_MATRIX_ENABLE |
| 37 | # endif | 37 | # include "led_matrix.h" |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #if defined(RGBLIGHT_ENABLE) | 40 | #if defined(RGBLIGHT_ENABLE) |
| @@ -52,6 +52,7 @@ | |||
| 52 | #include "action_layer.h" | 52 | #include "action_layer.h" |
| 53 | #include "eeconfig.h" | 53 | #include "eeconfig.h" |
| 54 | #include "bootloader.h" | 54 | #include "bootloader.h" |
| 55 | #include "bootmagic.h" | ||
| 55 | #include "timer.h" | 56 | #include "timer.h" |
| 56 | #include "sync_timer.h" | 57 | #include "sync_timer.h" |
| 57 | #include "config_common.h" | 58 | #include "config_common.h" |
| @@ -97,7 +98,7 @@ extern layer_state_t layer_state; | |||
| 97 | # include "process_music.h" | 98 | # include "process_music.h" |
| 98 | #endif | 99 | #endif |
| 99 | 100 | ||
| 100 | #ifdef BACKLIGHT_ENABLE | 101 | #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) |
| 101 | # include "process_backlight.h" | 102 | # include "process_backlight.h" |
| 102 | #endif | 103 | #endif |
| 103 | 104 | ||
| @@ -199,39 +200,6 @@ extern layer_state_t layer_state; | |||
| 199 | # include "usbpd.h" | 200 | # include "usbpd.h" |
| 200 | #endif | 201 | #endif |
| 201 | 202 | ||
| 202 | // Function substitutions to ease GPIO manipulation | ||
| 203 | #if defined(__AVR__) | ||
| 204 | |||
| 205 | /* The AVR series GPIOs have a one clock read delay for changes in the digital input signal. | ||
| 206 | * But here's more margin to make it two clocks. */ | ||
| 207 | # if !defined(GPIO_INPUT_PIN_DELAY) | ||
| 208 | # define GPIO_INPUT_PIN_DELAY 2 | ||
| 209 | # endif | ||
| 210 | # define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY) | ||
| 211 | |||
| 212 | #elif defined(__ARMEL__) || defined(__ARMEB__) | ||
| 213 | |||
| 214 | /* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus | ||
| 215 | * to which the GPIO is connected. | ||
| 216 | * The connected buses differ depending on the various series of MCUs. | ||
| 217 | * And since the instruction execution clock of the CPU and the bus clock of GPIO are different, | ||
| 218 | * there is a delay of several clocks to read the change of the input signal. | ||
| 219 | * | ||
| 220 | * Define this delay with the GPIO_INPUT_PIN_DELAY macro. | ||
| 221 | * If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used. | ||
| 222 | * (A fairly large value of 0.25 microseconds is set.) | ||
| 223 | */ | ||
| 224 | # if !defined(GPIO_INPUT_PIN_DELAY) | ||
| 225 | # if defined(STM32_SYSCLK) | ||
| 226 | # define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4) | ||
| 227 | # elif defined(KINETIS_SYSCLK_FREQUENCY) | ||
| 228 | # define GPIO_INPUT_PIN_DELAY (KINETIS_SYSCLK_FREQUENCY / 1000000L / 4) | ||
| 229 | # endif | ||
| 230 | # endif | ||
| 231 | # define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY) | ||
| 232 | |||
| 233 | #endif | ||
| 234 | |||
| 235 | // For tri-layer | 203 | // For tri-layer |
| 236 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); | 204 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); |
| 237 | layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3); | 205 | layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3); |
| @@ -256,15 +224,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record); | |||
| 256 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record); | 224 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record); |
| 257 | void post_process_record_user(uint16_t keycode, keyrecord_t *record); | 225 | void post_process_record_user(uint16_t keycode, keyrecord_t *record); |
| 258 | 226 | ||
| 259 | #ifndef BOOTMAGIC_LITE_COLUMN | ||
| 260 | # define BOOTMAGIC_LITE_COLUMN 0 | ||
| 261 | #endif | ||
| 262 | #ifndef BOOTMAGIC_LITE_ROW | ||
| 263 | # define BOOTMAGIC_LITE_ROW 0 | ||
| 264 | #endif | ||
| 265 | |||
| 266 | void bootmagic_lite(void); | ||
| 267 | |||
| 268 | void reset_keyboard(void); | 227 | void reset_keyboard(void); |
| 269 | 228 | ||
| 270 | void startup_user(void); | 229 | void startup_user(void); |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index e49f8dcda..0361e4cf9 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -573,6 +573,10 @@ enum quantum_keycodes { | |||
| 573 | 573 | ||
| 574 | #endif | 574 | #endif |
| 575 | 575 | ||
| 576 | ONESHOT_ENABLE, | ||
| 577 | ONESHOT_DISABLE, | ||
| 578 | ONESHOT_TOGGLE, | ||
| 579 | |||
| 576 | // always leave at the end | 580 | // always leave at the end |
| 577 | SAFE_RANGE | 581 | SAFE_RANGE |
| 578 | }; | 582 | }; |
| @@ -680,16 +684,13 @@ enum quantum_keycodes { | |||
| 680 | 684 | ||
| 681 | #define KC_DELT KC_DELETE // Del key (four letter code) | 685 | #define KC_DELT KC_DELETE // Del key (four letter code) |
| 682 | 686 | ||
| 683 | // Alias for function layers than expand past FN31 | ||
| 684 | #define FUNC(kc) (QK_FUNCTION | (kc)) | ||
| 685 | |||
| 686 | // Aliases | 687 | // Aliases |
| 687 | #define C(kc) LCTL(kc) | 688 | #define C(kc) LCTL(kc) |
| 688 | #define S(kc) LSFT(kc) | 689 | #define S(kc) LSFT(kc) |
| 689 | #define A(kc) LALT(kc) | 690 | #define A(kc) LALT(kc) |
| 690 | #define G(kc) LGUI(kc) | 691 | #define G(kc) LGUI(kc) |
| 691 | 692 | ||
| 692 | #define F(kc) FUNC(kc) | 693 | #define F(kc) (QK_FUNCTION | (kc)) |
| 693 | #define M(kc) (QK_MACRO | (kc)) | 694 | #define M(kc) (QK_MACRO | (kc)) |
| 694 | 695 | ||
| 695 | #define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc)) | 696 | #define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc)) |
| @@ -874,3 +875,8 @@ enum quantum_keycodes { | |||
| 874 | #define DM_RSTP DYN_REC_STOP | 875 | #define DM_RSTP DYN_REC_STOP |
| 875 | #define DM_PLY1 DYN_MACRO_PLAY1 | 876 | #define DM_PLY1 DYN_MACRO_PLAY1 |
| 876 | #define DM_PLY2 DYN_MACRO_PLAY2 | 877 | #define DM_PLY2 DYN_MACRO_PLAY2 |
| 878 | |||
| 879 | // One Shot toggle | ||
| 880 | #define OS_TOGG ONESHOT_TOGGLE | ||
| 881 | #define OS_ON ONESHOT_ENABLE | ||
| 882 | #define OS_OFF ONESHOT_DISABLE | ||
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index ec17b4d72..8aae48603 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
| @@ -131,7 +131,7 @@ last_hit_t g_last_hit_tracker; | |||
| 131 | // internals | 131 | // internals |
| 132 | static uint8_t rgb_last_enable = UINT8_MAX; | 132 | static uint8_t rgb_last_enable = UINT8_MAX; |
| 133 | static uint8_t rgb_last_effect = UINT8_MAX; | 133 | static uint8_t rgb_last_effect = UINT8_MAX; |
| 134 | static effect_params_t rgb_effect_params = {0, 0xFF}; | 134 | static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; |
| 135 | static rgb_task_states rgb_task_state = SYNCING; | 135 | static rgb_task_states rgb_task_state = SYNCING; |
| 136 | #if RGB_DISABLE_TIMEOUT > 0 | 136 | #if RGB_DISABLE_TIMEOUT > 0 |
| 137 | static uint32_t rgb_anykey_timer; | 137 | static uint32_t rgb_anykey_timer; |
| @@ -143,6 +143,11 @@ static uint32_t rgb_timer_buffer; | |||
| 143 | static last_hit_t last_hit_buffer; | 143 | static last_hit_t last_hit_buffer; |
| 144 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 144 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
| 145 | 145 | ||
| 146 | // split rgb matrix | ||
| 147 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 148 | const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; | ||
| 149 | #endif | ||
| 150 | |||
| 146 | void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } | 151 | void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } |
| 147 | 152 | ||
| 148 | void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } | 153 | void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } |
| @@ -153,6 +158,7 @@ void eeconfig_update_rgb_matrix_default(void) { | |||
| 153 | rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; | 158 | rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; |
| 154 | rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL}; | 159 | rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL}; |
| 155 | rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD; | 160 | rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD; |
| 161 | rgb_matrix_config.flags = LED_FLAG_ALL; | ||
| 156 | eeconfig_update_rgb_matrix(); | 162 | eeconfig_update_rgb_matrix(); |
| 157 | } | 163 | } |
| 158 | 164 | ||
| @@ -164,6 +170,7 @@ void eeconfig_debug_rgb_matrix(void) { | |||
| 164 | dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s); | 170 | dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s); |
| 165 | dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v); | 171 | dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v); |
| 166 | dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); | 172 | dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); |
| 173 | dprintf("rgb_matrix_config.flags = %d\n", rgb_matrix_config.flags); | ||
| 167 | } | 174 | } |
| 168 | 175 | ||
| 169 | __attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } | 176 | __attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } |
| @@ -180,9 +187,22 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l | |||
| 180 | 187 | ||
| 181 | void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } | 188 | void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } |
| 182 | 189 | ||
| 183 | void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); } | 190 | void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 191 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 192 | if (!is_keyboard_left() && index >= k_rgb_matrix_split[0]) | ||
| 193 | rgb_matrix_driver.set_color(index - k_rgb_matrix_split[0], red, green, blue); | ||
| 194 | else if (is_keyboard_left() && index < k_rgb_matrix_split[0]) | ||
| 195 | #endif | ||
| 196 | rgb_matrix_driver.set_color(index, red, green, blue); | ||
| 197 | } | ||
| 184 | 198 | ||
| 185 | void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); } | 199 | void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 200 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 201 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) rgb_matrix_set_color(i, red, green, blue); | ||
| 202 | #else | ||
| 203 | rgb_matrix_driver.set_color_all(red, green, blue); | ||
| 204 | #endif | ||
| 205 | } | ||
| 186 | 206 | ||
| 187 | void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { | 207 | void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { |
| 188 | #ifndef RGB_MATRIX_SPLIT | 208 | #ifndef RGB_MATRIX_SPLIT |
| @@ -315,6 +335,10 @@ static void rgb_task_start(void) { | |||
| 315 | static void rgb_task_render(uint8_t effect) { | 335 | static void rgb_task_render(uint8_t effect) { |
| 316 | bool rendering = false; | 336 | bool rendering = false; |
| 317 | rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable); | 337 | rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable); |
| 338 | if (rgb_effect_params.flags != rgb_matrix_config.flags) { | ||
| 339 | rgb_effect_params.flags = rgb_matrix_config.flags; | ||
| 340 | rgb_matrix_set_color_all(0, 0, 0); | ||
| 341 | } | ||
| 318 | 342 | ||
| 319 | // each effect can opt to do calculations | 343 | // each effect can opt to do calculations |
| 320 | // and/or request PWM buffer updates. | 344 | // and/or request PWM buffer updates. |
| @@ -618,6 +642,6 @@ void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_spe | |||
| 618 | void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } | 642 | void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } |
| 619 | void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } | 643 | void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } |
| 620 | 644 | ||
| 621 | led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; } | 645 | led_flags_t rgb_matrix_get_flags(void) { return rgb_matrix_config.flags; } |
| 622 | 646 | ||
| 623 | void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; } | 647 | void rgb_matrix_set_flags(led_flags_t flags) { rgb_matrix_config.flags = flags; } |
diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h index 7b8171fb2..1a37922af 100644 --- a/quantum/rgb_matrix_types.h +++ b/quantum/rgb_matrix_types.h | |||
| @@ -85,10 +85,11 @@ typedef struct PACKED { | |||
| 85 | typedef union { | 85 | typedef union { |
| 86 | uint32_t raw; | 86 | uint32_t raw; |
| 87 | struct PACKED { | 87 | struct PACKED { |
| 88 | uint8_t enable : 2; | 88 | uint8_t enable : 2; |
| 89 | uint8_t mode : 6; | 89 | uint8_t mode : 6; |
| 90 | HSV hsv; | 90 | HSV hsv; |
| 91 | uint8_t speed; // EECONFIG needs to be increased to support this | 91 | uint8_t speed; // EECONFIG needs to be increased to support this |
| 92 | led_flags_t flags; | ||
| 92 | }; | 93 | }; |
| 93 | } rgb_config_t; | 94 | } rgb_config_t; |
| 94 | 95 | ||
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 2ae44e6e1..9e75e19ce 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "split_util.h" | 16 | #include "split_util.h" |
| 2 | #include "matrix.h" | 17 | #include "matrix.h" |
| 3 | #include "keyboard.h" | 18 | #include "keyboard.h" |
| @@ -6,14 +21,7 @@ | |||
| 6 | #include "transport.h" | 21 | #include "transport.h" |
| 7 | #include "quantum.h" | 22 | #include "quantum.h" |
| 8 | #include "wait.h" | 23 | #include "wait.h" |
| 9 | 24 | #include "usb_util.h" | |
| 10 | #ifdef PROTOCOL_LUFA | ||
| 11 | # include <LUFA/Drivers/USB/USB.h> | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #ifdef PROTOCOL_VUSB | ||
| 15 | # include <usbdrv/usbdrv.h> | ||
| 16 | #endif | ||
| 17 | 25 | ||
| 18 | #ifdef EE_HANDS | 26 | #ifdef EE_HANDS |
| 19 | # include "eeconfig.h" | 27 | # include "eeconfig.h" |
| @@ -31,56 +39,21 @@ | |||
| 31 | # define SPLIT_USB_TIMEOUT_POLL 10 | 39 | # define SPLIT_USB_TIMEOUT_POLL 10 |
| 32 | #endif | 40 | #endif |
| 33 | 41 | ||
| 34 | #ifdef PROTOCOL_CHIBIOS | ||
| 35 | # define SPLIT_USB_DETECT // Force this on for now | ||
| 36 | #endif | ||
| 37 | |||
| 38 | volatile bool isLeftHand = true; | 42 | volatile bool isLeftHand = true; |
| 39 | 43 | ||
| 40 | #if defined(SPLIT_USB_DETECT) | 44 | #if defined(SPLIT_USB_DETECT) |
| 41 | # if defined(PROTOCOL_LUFA) | 45 | static bool usbIsActive(void) { |
| 42 | static inline bool usbHasActiveConnection(void) { return USB_Device_IsAddressSet(); } | ||
| 43 | static inline void usbDisable(void) { | ||
| 44 | USB_Disable(); | ||
| 45 | USB_DeviceState = DEVICE_STATE_Unattached; | ||
| 46 | } | ||
| 47 | # elif defined(PROTOCOL_CHIBIOS) | ||
| 48 | static inline bool usbHasActiveConnection(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } | ||
| 49 | static inline void usbDisable(void) { usbStop(&USBD1); } | ||
| 50 | # elif defined(PROTOCOL_VUSB) | ||
| 51 | static inline bool usbHasActiveConnection(void) { | ||
| 52 | usbPoll(); | ||
| 53 | return usbConfiguration; | ||
| 54 | } | ||
| 55 | static inline void usbDisable(void) { usbDeviceDisconnect(); } | ||
| 56 | # else | ||
| 57 | static inline bool usbHasActiveConnection(void) { return true; } | ||
| 58 | static inline void usbDisable(void) {} | ||
| 59 | # endif | ||
| 60 | |||
| 61 | bool usbIsActive(void) { | ||
| 62 | for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) { | 46 | for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) { |
| 63 | // This will return true if a USB connection has been established | 47 | // This will return true if a USB connection has been established |
| 64 | if (usbHasActiveConnection()) { | 48 | if (usb_connected_state()) { |
| 65 | return true; | 49 | return true; |
| 66 | } | 50 | } |
| 67 | wait_ms(SPLIT_USB_TIMEOUT_POLL); | 51 | wait_ms(SPLIT_USB_TIMEOUT_POLL); |
| 68 | } | 52 | } |
| 69 | |||
| 70 | // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow | ||
| 71 | usbDisable(); | ||
| 72 | |||
| 73 | return false; | 53 | return false; |
| 74 | } | 54 | } |
| 75 | #elif defined(PROTOCOL_LUFA) && defined(OTGPADE) | ||
| 76 | static inline bool usbIsActive(void) { | ||
| 77 | USB_OTGPAD_On(); // enables VBUS pad | ||
| 78 | wait_us(5); | ||
| 79 | |||
| 80 | return USB_VBUS_GetStatus(); // checks state of VBUS | ||
| 81 | } | ||
| 82 | #else | 55 | #else |
| 83 | static inline bool usbIsActive(void) { return true; } | 56 | static inline bool usbIsActive(void) { return usb_vbus_state(); } |
| 84 | #endif | 57 | #endif |
| 85 | 58 | ||
| 86 | #ifdef SPLIT_HAND_MATRIX_GRID | 59 | #ifdef SPLIT_HAND_MATRIX_GRID |
| @@ -126,6 +99,11 @@ __attribute__((weak)) bool is_keyboard_master(void) { | |||
| 126 | // only check once, as this is called often | 99 | // only check once, as this is called often |
| 127 | if (usbstate == UNKNOWN) { | 100 | if (usbstate == UNKNOWN) { |
| 128 | usbstate = usbIsActive() ? MASTER : SLAVE; | 101 | usbstate = usbIsActive() ? MASTER : SLAVE; |
| 102 | |||
| 103 | // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow | ||
| 104 | if (usbstate == SLAVE) { | ||
| 105 | usb_disable(); | ||
| 106 | } | ||
| 129 | } | 107 | } |
| 130 | 108 | ||
| 131 | return (usbstate == MASTER); | 109 | return (usbstate == MASTER); |
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 61b61ea08..27a1c0d3a 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c | |||
| @@ -22,6 +22,10 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A; | |||
| 22 | # define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t)) | 22 | # define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t)) |
| 23 | #endif | 23 | #endif |
| 24 | 24 | ||
| 25 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 26 | # include "rgb_matrix.h" | ||
| 27 | #endif | ||
| 28 | |||
| 25 | #if defined(USE_I2C) | 29 | #if defined(USE_I2C) |
| 26 | 30 | ||
| 27 | # include "i2c_master.h" | 31 | # include "i2c_master.h" |
| @@ -54,6 +58,10 @@ typedef struct _I2C_slave_buffer_t { | |||
| 54 | # ifdef WPM_ENABLE | 58 | # ifdef WPM_ENABLE |
| 55 | uint8_t current_wpm; | 59 | uint8_t current_wpm; |
| 56 | # endif | 60 | # endif |
| 61 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 62 | rgb_config_t rgb_matrix; | ||
| 63 | bool rgb_suspend_state; | ||
| 64 | # endif | ||
| 57 | } I2C_slave_buffer_t; | 65 | } I2C_slave_buffer_t; |
| 58 | 66 | ||
| 59 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; | 67 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; |
| @@ -68,6 +76,8 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re | |||
| 68 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) | 76 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) |
| 69 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) | 77 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) |
| 70 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) | 78 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) |
| 79 | # define I2C_RGB_MATRIX_START offsetof(I2C_slave_buffer_t, rgb_matrix) | ||
| 80 | # define I2C_RGB_SUSPEND_START offsetof(I2C_slave_buffer_t, rgb_suspend_state) | ||
| 71 | 81 | ||
| 72 | # define TIMEOUT 100 | 82 | # define TIMEOUT 100 |
| 73 | 83 | ||
| @@ -141,6 +151,11 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 141 | # endif | 151 | # endif |
| 142 | # endif | 152 | # endif |
| 143 | 153 | ||
| 154 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 155 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_START, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix), TIMEOUT); | ||
| 156 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_SUSPEND_START, (void *)g_suspend_state, sizeof(i2c_buffer->rgb_suspend_state), TIMEOUT); | ||
| 157 | # endif | ||
| 158 | |||
| 144 | # ifndef DISABLE_SYNC_TIMER | 159 | # ifndef DISABLE_SYNC_TIMER |
| 145 | i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | 160 | i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; |
| 146 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT); | 161 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT); |
| @@ -186,6 +201,11 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 186 | set_oneshot_mods(i2c_buffer->oneshot_mods); | 201 | set_oneshot_mods(i2c_buffer->oneshot_mods); |
| 187 | # endif | 202 | # endif |
| 188 | # endif | 203 | # endif |
| 204 | |||
| 205 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 206 | memcpy((void *)i2c_buffer->rgb_matrix, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix)); | ||
| 207 | memcpy((void *)i2c_buffer->rgb_suspend_state, (void *)g_suspend_state, sizeof(i2c_buffer->rgb_suspend_state)); | ||
| 208 | # endif | ||
| 189 | } | 209 | } |
| 190 | 210 | ||
| 191 | void transport_master_init(void) { i2c_init(); } | 211 | void transport_master_init(void) { i2c_init(); } |
| @@ -226,6 +246,10 @@ typedef struct _Serial_m2s_buffer_t { | |||
| 226 | # ifdef WPM_ENABLE | 246 | # ifdef WPM_ENABLE |
| 227 | uint8_t current_wpm; | 247 | uint8_t current_wpm; |
| 228 | # endif | 248 | # endif |
| 249 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 250 | rgb_config_t rgb_matrix; | ||
| 251 | bool rgb_suspend_state; | ||
| 252 | # endif | ||
| 229 | } Serial_m2s_buffer_t; | 253 | } Serial_m2s_buffer_t; |
| 230 | 254 | ||
| 231 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 255 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| @@ -333,18 +357,24 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 333 | 357 | ||
| 334 | # ifdef WPM_ENABLE | 358 | # ifdef WPM_ENABLE |
| 335 | // Write wpm to slave | 359 | // Write wpm to slave |
| 336 | serial_m2s_buffer.current_wpm = get_current_wpm(); | 360 | serial_m2s_buffer.current_wpm = get_current_wpm(); |
| 337 | # endif | 361 | # endif |
| 338 | 362 | ||
| 339 | # ifdef SPLIT_MODS_ENABLE | 363 | # ifdef SPLIT_MODS_ENABLE |
| 340 | serial_m2s_buffer.real_mods = get_mods(); | 364 | serial_m2s_buffer.real_mods = get_mods(); |
| 341 | serial_m2s_buffer.weak_mods = get_weak_mods(); | 365 | serial_m2s_buffer.weak_mods = get_weak_mods(); |
| 342 | # ifndef NO_ACTION_ONESHOT | 366 | # ifndef NO_ACTION_ONESHOT |
| 343 | serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); | 367 | serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); |
| 344 | # endif | 368 | # endif |
| 345 | # endif | 369 | # endif |
| 370 | |||
| 371 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 372 | serial_m2s_buffer.rgb_matrix = rgb_matrix_config; | ||
| 373 | serial_m2s_buffer.rgb_suspend_state = g_suspend_state; | ||
| 374 | # endif | ||
| 375 | |||
| 346 | # ifndef DISABLE_SYNC_TIMER | 376 | # ifndef DISABLE_SYNC_TIMER |
| 347 | serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | 377 | serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; |
| 348 | # endif | 378 | # endif |
| 349 | return true; | 379 | return true; |
| 350 | } | 380 | } |
| @@ -381,6 +411,11 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 381 | set_oneshot_mods(serial_m2s_buffer.oneshot_mods); | 411 | set_oneshot_mods(serial_m2s_buffer.oneshot_mods); |
| 382 | # endif | 412 | # endif |
| 383 | # endif | 413 | # endif |
| 414 | |||
| 415 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 416 | rgb_matrix_config = serial_m2s_buffer.rgb_matrix; | ||
| 417 | g_suspend_state = serial_m2s_buffer.rgb_suspend_state; | ||
| 418 | # endif | ||
| 384 | } | 419 | } |
| 385 | 420 | ||
| 386 | #endif | 421 | #endif |
