summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-02-12 10:29:31 -0800
committerGitHub <noreply@github.com>2022-02-12 18:29:31 +0000
commit63646e8906e062d1c1de3925cba70c4e3426a855 (patch)
tree4e91648b77b838e1125cf86331d7e84bde6d07a9 /quantum
parentafcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff)
Format code according to conventions (#16322)
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c50
-rw-r--r--quantum/action_layer.c88
-rw-r--r--quantum/action_tapping.c16
-rw-r--r--quantum/action_util.c132
-rw-r--r--quantum/action_util.h12
-rw-r--r--quantum/audio/audio.c78
-rw-r--r--quantum/audio/audio.h6
-rw-r--r--quantum/audio/song_list.h2
-rw-r--r--quantum/audio/voices.c48
-rw-r--r--quantum/audio/voices.h2
-rw-r--r--quantum/backlight/backlight.c54
-rw-r--r--quantum/backlight/backlight.h2
-rw-r--r--quantum/backlight/backlight_avr.c50
-rw-r--r--quantum/backlight/backlight_chibios.c16
-rw-r--r--quantum/backlight/backlight_driver_common.c8
-rw-r--r--quantum/backlight/backlight_software.c12
-rw-r--r--quantum/backlight/backlight_timer.c32
-rw-r--r--quantum/bitwise.c9
-rw-r--r--quantum/bootmagic/bootmagic_lite.c8
-rw-r--r--quantum/color.c4
-rw-r--r--quantum/command.c2
-rw-r--r--quantum/debounce/sym_defer_g.c2
-rw-r--r--quantum/debounce/sym_defer_pr.c4
-rw-r--r--quantum/debounce/sym_eager_pk.c2
-rw-r--r--quantum/debounce/tests/debounce_test_common.cpp4
-rw-r--r--quantum/deferred_exec.c16
-rw-r--r--quantum/digitizer.c8
-rw-r--r--quantum/dip_switch.c16
-rw-r--r--quantum/dynamic_keymap.c20
-rw-r--r--quantum/eeconfig.c70
-rw-r--r--quantum/eeconfig.h52
-rw-r--r--quantum/encoder.c14
-rw-r--r--quantum/encoder/tests/mock.c4
-rw-r--r--quantum/encoder/tests/mock_split.c4
-rw-r--r--quantum/haptic.c4
-rw-r--r--quantum/keyboard.c58
-rw-r--r--quantum/keyboard.h36
-rw-r--r--quantum/keycode.h26
-rw-r--r--quantum/keymap_common.c2
-rw-r--r--quantum/keymap_extras/keymap_nordic.h2
-rw-r--r--quantum/keymap_extras/keymap_steno.h2
-rw-r--r--quantum/led.c12
-rw-r--r--quantum/led_matrix/animations/alpha_mods_anim.h4
-rw-r--r--quantum/led_matrix/animations/band_anim.h8
-rw-r--r--quantum/led_matrix/animations/band_pinwheel_anim.h12
-rw-r--r--quantum/led_matrix/animations/band_spiral_anim.h12
-rw-r--r--quantum/led_matrix/animations/breathing_anim.h4
-rw-r--r--quantum/led_matrix/animations/cycle_left_right_anim.h12
-rw-r--r--quantum/led_matrix/animations/cycle_out_in_anim.h12
-rw-r--r--quantum/led_matrix/animations/cycle_up_down_anim.h12
-rw-r--r--quantum/led_matrix/animations/dual_beacon_anim.h12
-rw-r--r--quantum/led_matrix/animations/runners/effect_runner_reactive.h2
-rw-r--r--quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h2
-rw-r--r--quantum/led_matrix/animations/solid_anim.h2
-rw-r--r--quantum/led_matrix/animations/solid_reactive_cross.h14
-rw-r--r--quantum/led_matrix/animations/solid_reactive_nexus.h14
-rw-r--r--quantum/led_matrix/animations/solid_reactive_simple_anim.h14
-rw-r--r--quantum/led_matrix/animations/solid_reactive_wide.h14
-rw-r--r--quantum/led_matrix/animations/solid_splash_anim.h14
-rw-r--r--quantum/led_matrix/animations/wave_left_right_anim.h12
-rw-r--r--quantum/led_matrix/animations/wave_up_down_anim.h12
-rw-r--r--quantum/led_matrix/led_matrix.c179
-rw-r--r--quantum/led_matrix/led_matrix_types.h6
-rw-r--r--quantum/logging/debug.c10
-rw-r--r--quantum/logging/print.c12
-rw-r--r--quantum/logging/print.h2
-rw-r--r--quantum/logging/sendchar.c4
-rw-r--r--quantum/main.c4
-rw-r--r--quantum/matrix.c28
-rw-r--r--quantum/matrix_common.c44
-rw-r--r--quantum/mousekey.c4
-rw-r--r--quantum/pointing_device.c40
-rw-r--r--quantum/pointing_device.h4
-rw-r--r--quantum/pointing_device_drivers.c24
-rw-r--r--quantum/process_keycode/process_audio.c12
-rw-r--r--quantum/process_keycode/process_auto_shift.c36
-rw-r--r--quantum/process_keycode/process_clicky.c32
-rw-r--r--quantum/process_keycode/process_combo.c40
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c16
-rw-r--r--quantum/process_keycode/process_joystick.c4
-rw-r--r--quantum/process_keycode/process_key_override.c24
-rw-r--r--quantum/process_keycode/process_leader.c4
-rw-r--r--quantum/process_keycode/process_magic.c8
-rw-r--r--quantum/process_keycode/process_midi.c26
-rw-r--r--quantum/process_keycode/process_midi.h4
-rw-r--r--quantum/process_keycode/process_music.c26
-rw-r--r--quantum/process_keycode/process_music.h8
-rw-r--r--quantum/process_keycode/process_printer.c7
-rw-r--r--quantum/process_keycode/process_printer_bb.c23
-rw-r--r--quantum/process_keycode/process_steno.c24
-rw-r--r--quantum/process_keycode/process_tap_dance.c4
-rw-r--r--quantum/process_keycode/process_terminal.c34
-rw-r--r--quantum/process_keycode/process_ucis.c2
-rw-r--r--quantum/process_keycode/process_unicode_common.c24
-rw-r--r--quantum/process_keycode/process_unicode_common.h12
-rw-r--r--quantum/programmable_button.c28
-rw-r--r--quantum/quantum.c39
-rw-r--r--quantum/quantum_keycodes.h714
-rw-r--r--quantum/rgb_matrix/animations/alpha_mods_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/breathing_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/colorband_sat_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/colorband_spiral_val_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/colorband_val_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/cycle_all_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/cycle_left_right_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/cycle_out_in_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/cycle_pinwheel_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/cycle_spiral_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/cycle_up_down_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/digital_rain_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/dual_beacon_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/gradient_left_right_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/gradient_up_down_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/hue_breathing_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/hue_pendulum_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/hue_wave_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/jellybean_raindrops_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/pixel_flow_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/pixel_fractal_anim.h12
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/rainbow_beacon_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h8
-rw-r--r--quantum/rgb_matrix/animations/raindrops_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_reactive.h2
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h2
-rw-r--r--quantum/rgb_matrix/animations/solid_color_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_anim.h10
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_cross.h14
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_nexus.h14
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_simple_anim.h10
-rw-r--r--quantum/rgb_matrix/animations/solid_reactive_wide.h14
-rw-r--r--quantum/rgb_matrix/animations/solid_splash_anim.h14
-rw-r--r--quantum/rgb_matrix/animations/splash_anim.h14
-rw-r--r--quantum/rgb_matrix/animations/typing_heatmap_anim.h4
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c249
-rw-r--r--quantum/rgb_matrix/rgb_matrix_types.h6
-rw-r--r--quantum/rgblight/rgblight.c226
-rw-r--r--quantum/rgblight/rgblight.h10
-rw-r--r--quantum/ring_buffer.h8
-rw-r--r--quantum/send_string.c22
-rw-r--r--quantum/sequencer/sequencer.c62
-rw-r--r--quantum/sequencer/sequencer.h8
-rw-r--r--quantum/sequencer/tests/midi_mock.c12
-rw-r--r--quantum/sequencer/tests/sequencer_tests.cpp4
-rw-r--r--quantum/split_common/post_config.h2
-rw-r--r--quantum/split_common/split_util.c20
-rw-r--r--quantum/split_common/transaction_id_define.h36
-rw-r--r--quantum/split_common/transactions.c94
-rw-r--r--quantum/split_common/transport.c30
-rw-r--r--quantum/split_common/transport.h60
-rw-r--r--quantum/sync_timer.c4
-rw-r--r--quantum/velocikey.c8
-rw-r--r--quantum/via.c18
-rw-r--r--quantum/via.h6
-rw-r--r--quantum/wpm.c22
160 files changed, 2471 insertions, 1437 deletions
diff --git a/quantum/action.c b/quantum/action.c
index d932c01688..2bb1c34985 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -53,14 +53,20 @@ int retro_tapping_counter = 0;
53#endif 53#endif
54 54
55#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY 55#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
56__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { return false; } 56__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
57 return false;
58}
57#endif 59#endif
58 60
59#ifdef RETRO_TAPPING_PER_KEY 61#ifdef RETRO_TAPPING_PER_KEY
60__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; } 62__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
63 return false;
64}
61#endif 65#endif
62 66
63__attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { return true; } 67__attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) {
68 return true;
69}
64 70
65/** \brief Called to execute an action. 71/** \brief Called to execute an action.
66 * 72 *
@@ -163,10 +169,14 @@ void process_record_nocache(keyrecord_t *record) {
163 disable_action_cache = false; 169 disable_action_cache = false;
164} 170}
165#else 171#else
166void process_record_nocache(keyrecord_t *record) { process_record(record); } 172void process_record_nocache(keyrecord_t *record) {
173 process_record(record);
174}
167#endif 175#endif
168 176
169__attribute__((weak)) bool process_record_quantum(keyrecord_t *record) { return true; } 177__attribute__((weak)) bool process_record_quantum(keyrecord_t *record) {
178 return true;
179}
170 180
171__attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {} 181__attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {}
172 182
@@ -688,7 +698,7 @@ void process_action(keyrecord_t *record, action_t action) {
688 /* tap key */ 698 /* tap key */
689 if (tap_count > 0) { 699 if (tap_count > 0) {
690 if (swap_held) { 700 if (swap_held) {
691 swap_hands = !swap_hands; // undo hold set up in _tap_hint 701 swap_hands = !swap_hands; // undo hold set up in _tap_hint
692 swap_held = false; 702 swap_held = false;
693 } 703 }
694 if (event.pressed) { 704 if (event.pressed) {
@@ -696,11 +706,11 @@ void process_action(keyrecord_t *record, action_t action) {
696 } else { 706 } else {
697 wait_ms(TAP_CODE_DELAY); 707 wait_ms(TAP_CODE_DELAY);
698 unregister_code(action.swap.code); 708 unregister_code(action.swap.code);
699 *record = (keyrecord_t){}; // hack: reset tap mode 709 *record = (keyrecord_t){}; // hack: reset tap mode
700 } 710 }
701 } else { 711 } else {
702 if (swap_held && !event.pressed) { 712 if (swap_held && !event.pressed) {
703 swap_hands = !swap_hands; // undo hold set up in _tap_hint 713 swap_hands = !swap_hands; // undo hold set up in _tap_hint
704 swap_held = false; 714 swap_held = false;
705 } 715 }
706 } 716 }
@@ -862,9 +872,13 @@ __attribute__((weak)) void register_code(uint8_t code) {
862 } 872 }
863#ifdef EXTRAKEY_ENABLE 873#ifdef EXTRAKEY_ENABLE
864 else if 874 else if
865 IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); } 875 IS_SYSTEM(code) {
876 host_system_send(KEYCODE2SYSTEM(code));
877 }
866 else if 878 else if
867 IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); } 879 IS_CONSUMER(code) {
880 host_consumer_send(KEYCODE2CONSUMER(code));
881 }
868#endif 882#endif
869#ifdef MOUSEKEY_ENABLE 883#ifdef MOUSEKEY_ENABLE
870 else if 884 else if
@@ -927,9 +941,13 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
927 send_keyboard_report(); 941 send_keyboard_report();
928 } 942 }
929 else if 943 else if
930 IS_SYSTEM(code) { host_system_send(0); } 944 IS_SYSTEM(code) {
945 host_system_send(0);
946 }
931 else if 947 else if
932 IS_CONSUMER(code) { host_consumer_send(0); } 948 IS_CONSUMER(code) {
949 host_consumer_send(0);
950 }
933#ifdef MOUSEKEY_ENABLE 951#ifdef MOUSEKEY_ENABLE
934 else if 952 else if
935 IS_MOUSEKEY(code) { 953 IS_MOUSEKEY(code) {
@@ -956,7 +974,9 @@ __attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) {
956 * 974 *
957 * \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined. 975 * \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
958 */ 976 */
959__attribute__((weak)) void tap_code(uint8_t code) { tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); } 977__attribute__((weak)) void tap_code(uint8_t code) {
978 tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
979}
960 980
961/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately. 981/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
962 * 982 *
@@ -1100,7 +1120,9 @@ bool is_tap_action(action_t action) {
1100 * 1120 *
1101 * FIXME: Needs documentation. 1121 * FIXME: Needs documentation.
1102 */ 1122 */
1103void debug_event(keyevent_t event) { dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time); } 1123void debug_event(keyevent_t event) {
1124 dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
1125}
1104/** \brief Debug print (FIXME: Needs better description) 1126/** \brief Debug print (FIXME: Needs better description)
1105 * 1127 *
1106 * FIXME: Needs documentation. 1128 * FIXME: Needs documentation.
diff --git a/quantum/action_layer.c b/quantum/action_layer.c
index ed1a4bd20d..e20eedee40 100644
--- a/quantum/action_layer.c
+++ b/quantum/action_layer.c
@@ -18,13 +18,17 @@ layer_state_t default_layer_state = 0;
18 * 18 *
19 * Run user code on default layer state change 19 * Run user code on default layer state change
20 */ 20 */
21__attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state) { return state; } 21__attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state) {
22 return state;
23}
22 24
23/** \brief Default Layer State Set At Keyboard Level 25/** \brief Default Layer State Set At Keyboard Level
24 * 26 *
25 * Run keyboard code on default layer state change 27 * Run keyboard code on default layer state change
26 */ 28 */
27__attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state) { return default_layer_state_set_user(state); } 29__attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state) {
30 return default_layer_state_set_user(state);
31}
28 32
29/** \brief Default Layer State Set 33/** \brief Default Layer State Set
30 * 34 *
@@ -39,9 +43,9 @@ static void default_layer_state_set(layer_state_t state) {
39 default_layer_debug(); 43 default_layer_debug();
40 debug("\n"); 44 debug("\n");
41#ifdef STRICT_LAYER_RELEASE 45#ifdef STRICT_LAYER_RELEASE
42 clear_keyboard_but_mods(); // To avoid stuck keys 46 clear_keyboard_but_mods(); // To avoid stuck keys
43#else 47#else
44 clear_keyboard_but_mods_and_keys(); // Don't reset held keys 48 clear_keyboard_but_mods_and_keys(); // Don't reset held keys
45#endif 49#endif
46} 50}
47 51
@@ -49,30 +53,40 @@ static void default_layer_state_set(layer_state_t state) {
49 * 53 *
50 * Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit. 54 * Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit.
51 */ 55 */
52void default_layer_debug(void) { dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state)); } 56void default_layer_debug(void) {
57 dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state));
58}
53 59
54/** \brief Default Layer Set 60/** \brief Default Layer Set
55 * 61 *
56 * Sets the default layer state. 62 * Sets the default layer state.
57 */ 63 */
58void default_layer_set(layer_state_t state) { default_layer_state_set(state); } 64void default_layer_set(layer_state_t state) {
65 default_layer_state_set(state);
66}
59 67
60#ifndef NO_ACTION_LAYER 68#ifndef NO_ACTION_LAYER
61/** \brief Default Layer Or 69/** \brief Default Layer Or
62 * 70 *
63 * Turns on the default layer based on matching bits between specifed layer and existing layer state 71 * Turns on the default layer based on matching bits between specifed layer and existing layer state
64 */ 72 */
65void default_layer_or(layer_state_t state) { default_layer_state_set(default_layer_state | state); } 73void default_layer_or(layer_state_t state) {
74 default_layer_state_set(default_layer_state | state);
75}
66/** \brief Default Layer And 76/** \brief Default Layer And
67 * 77 *
68 * Turns on default layer based on matching enabled bits between specifed layer and existing layer state 78 * Turns on default layer based on matching enabled bits between specifed layer and existing layer state
69 */ 79 */
70void default_layer_and(layer_state_t state) { default_layer_state_set(default_layer_state & state); } 80void default_layer_and(layer_state_t state) {
81 default_layer_state_set(default_layer_state & state);
82}
71/** \brief Default Layer Xor 83/** \brief Default Layer Xor
72 * 84 *
73 * Turns on default layer based on non-matching bits between specifed layer and existing layer state 85 * Turns on default layer based on non-matching bits between specifed layer and existing layer state
74 */ 86 */
75void default_layer_xor(layer_state_t state) { default_layer_state_set(default_layer_state ^ state); } 87void default_layer_xor(layer_state_t state) {
88 default_layer_state_set(default_layer_state ^ state);
89}
76#endif 90#endif
77 91
78#ifndef NO_ACTION_LAYER 92#ifndef NO_ACTION_LAYER
@@ -84,13 +98,17 @@ layer_state_t layer_state = 0;
84 * 98 *
85 * Runs user code on layer state change 99 * Runs user code on layer state change
86 */ 100 */
87__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) { return state; } 101__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
102 return state;
103}
88 104
89/** \brief Layer state set keyboard 105/** \brief Layer state set keyboard
90 * 106 *
91 * Runs keyboard code on layer state change 107 * Runs keyboard code on layer state change
92 */ 108 */
93__attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { return layer_state_set_user(state); } 109__attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) {
110 return layer_state_set_user(state);
111}
94 112
95/** \brief Layer state set 113/** \brief Layer state set
96 * 114 *
@@ -105,9 +123,9 @@ void layer_state_set(layer_state_t state) {
105 layer_debug(); 123 layer_debug();
106 dprintln(); 124 dprintln();
107# ifdef STRICT_LAYER_RELEASE 125# ifdef STRICT_LAYER_RELEASE
108 clear_keyboard_but_mods(); // To avoid stuck keys 126 clear_keyboard_but_mods(); // To avoid stuck keys
109# else 127# else
110 clear_keyboard_but_mods_and_keys(); // Don't reset held keys 128 clear_keyboard_but_mods_and_keys(); // Don't reset held keys
111# endif 129# endif
112} 130}
113 131
@@ -115,13 +133,17 @@ void layer_state_set(layer_state_t state) {
115 * 133 *
116 * Turn off all layers 134 * Turn off all layers
117 */ 135 */
118void layer_clear(void) { layer_state_set(0); } 136void layer_clear(void) {
137 layer_state_set(0);
138}
119 139
120/** \brief Layer state is 140/** \brief Layer state is
121 * 141 *
122 * Return whether the given state is on (it might still be shadowed by a higher state, though) 142 * Return whether the given state is on (it might still be shadowed by a higher state, though)
123 */ 143 */
124bool layer_state_is(uint8_t layer) { return layer_state_cmp(layer_state, layer); } 144bool layer_state_is(uint8_t layer) {
145 return layer_state_cmp(layer_state, layer);
146}
125 147
126/** \brief Layer state compare 148/** \brief Layer state compare
127 * 149 *
@@ -138,47 +160,63 @@ bool layer_state_cmp(layer_state_t cmp_layer_state, uint8_t layer) {
138 * 160 *
139 * Turns on the given layer and turn off all other layers 161 * Turns on the given layer and turn off all other layers
140 */ 162 */
141void layer_move(uint8_t layer) { layer_state_set((layer_state_t)1 << layer); } 163void layer_move(uint8_t layer) {
164 layer_state_set((layer_state_t)1 << layer);
165}
142 166
143/** \brief Layer on 167/** \brief Layer on
144 * 168 *
145 * Turns on given layer 169 * Turns on given layer
146 */ 170 */
147void layer_on(uint8_t layer) { layer_state_set(layer_state | ((layer_state_t)1 << layer)); } 171void layer_on(uint8_t layer) {
172 layer_state_set(layer_state | ((layer_state_t)1 << layer));
173}
148 174
149/** \brief Layer off 175/** \brief Layer off
150 * 176 *
151 * Turns off given layer 177 * Turns off given layer
152 */ 178 */
153void layer_off(uint8_t layer) { layer_state_set(layer_state & ~((layer_state_t)1 << layer)); } 179void layer_off(uint8_t layer) {
180 layer_state_set(layer_state & ~((layer_state_t)1 << layer));
181}
154 182
155/** \brief Layer invert 183/** \brief Layer invert
156 * 184 *
157 * Toggle the given layer (set it if it's unset, or unset it if it's set) 185 * Toggle the given layer (set it if it's unset, or unset it if it's set)
158 */ 186 */
159void layer_invert(uint8_t layer) { layer_state_set(layer_state ^ ((layer_state_t)1 << layer)); } 187void layer_invert(uint8_t layer) {
188 layer_state_set(layer_state ^ ((layer_state_t)1 << layer));
189}
160 190
161/** \brief Layer or 191/** \brief Layer or
162 * 192 *
163 * Turns on layers based on matching bits between specifed layer and existing layer state 193 * Turns on layers based on matching bits between specifed layer and existing layer state
164 */ 194 */
165void layer_or(layer_state_t state) { layer_state_set(layer_state | state); } 195void layer_or(layer_state_t state) {
196 layer_state_set(layer_state | state);
197}
166/** \brief Layer and 198/** \brief Layer and
167 * 199 *
168 * Turns on layers based on matching enabled bits between specifed layer and existing layer state 200 * Turns on layers based on matching enabled bits between specifed layer and existing layer state
169 */ 201 */
170void layer_and(layer_state_t state) { layer_state_set(layer_state & state); } 202void layer_and(layer_state_t state) {
203 layer_state_set(layer_state & state);
204}
171/** \brief Layer xor 205/** \brief Layer xor
172 * 206 *
173 * Turns on layers based on non-matching bits between specifed layer and existing layer state 207 * Turns on layers based on non-matching bits between specifed layer and existing layer state
174 */ 208 */
175void layer_xor(layer_state_t state) { layer_state_set(layer_state ^ state); } 209void layer_xor(layer_state_t state) {
210 layer_state_set(layer_state ^ state);
211}
176 212
177/** \brief Layer debug printing 213/** \brief Layer debug printing
178 * 214 *
179 * Print out the hex value of the 32-bit layer state, as well as the value of the highest bit. 215 * Print out the hex value of the 32-bit layer state, as well as the value of the highest bit.
180 */ 216 */
181void layer_debug(void) { dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state)); } 217void layer_debug(void) {
218 dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state));
219}
182#endif 220#endif
183 221
184#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) 222#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
@@ -276,4 +314,6 @@ uint8_t layer_switch_get_layer(keypos_t key) {
276 * 314 *
277 * Gets action code based on key position 315 * Gets action code based on key position
278 */ 316 */
279action_t layer_switch_get_action(keypos_t key) { return action_for_key(layer_switch_get_layer(key), key); } 317action_t layer_switch_get_action(keypos_t key) {
318 return action_for_key(layer_switch_get_layer(key), key);
319}
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c
index 4ba38bee8d..6f8b4f8c56 100644
--- a/quantum/action_tapping.c
+++ b/quantum/action_tapping.c
@@ -26,7 +26,9 @@
26 26
27uint16_t g_tapping_term = TAPPING_TERM; 27uint16_t g_tapping_term = TAPPING_TERM;
28 28
29__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return g_tapping_term; } 29__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
30 return g_tapping_term;
31}
30 32
31# ifdef TAPPING_TERM_PER_KEY 33# ifdef TAPPING_TERM_PER_KEY
32# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_record_keycode(&tapping_key, false), &tapping_key)) 34# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_record_keycode(&tapping_key, false), &tapping_key))
@@ -35,15 +37,21 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *r
35# endif 37# endif
36 38
37# ifdef TAPPING_FORCE_HOLD_PER_KEY 39# ifdef TAPPING_FORCE_HOLD_PER_KEY
38__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; } 40__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
41 return false;
42}
39# endif 43# endif
40 44
41# ifdef PERMISSIVE_HOLD_PER_KEY 45# ifdef PERMISSIVE_HOLD_PER_KEY
42__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { return false; } 46__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) {
47 return false;
48}
43# endif 49# endif
44 50
45# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY 51# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
46__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { return false; } 52__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
53 return false;
54}
47# endif 55# endif
48 56
49# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) 57# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
diff --git a/quantum/action_util.c b/quantum/action_util.c
index 9eb2a6d30d..64a1b6b30d 100644
--- a/quantum/action_util.c
+++ b/quantum/action_util.c
@@ -43,8 +43,10 @@ extern inline void clear_keys(void);
43#ifndef NO_ACTION_ONESHOT 43#ifndef NO_ACTION_ONESHOT
44static uint8_t oneshot_mods = 0; 44static uint8_t oneshot_mods = 0;
45static uint8_t oneshot_locked_mods = 0; 45static uint8_t oneshot_locked_mods = 0;
46uint8_t get_oneshot_locked_mods(void) { return oneshot_locked_mods; } 46uint8_t get_oneshot_locked_mods(void) {
47void set_oneshot_locked_mods(uint8_t mods) { 47 return oneshot_locked_mods;
48}
49void set_oneshot_locked_mods(uint8_t mods) {
48 if (mods != oneshot_locked_mods) { 50 if (mods != oneshot_locked_mods) {
49 oneshot_locked_mods = mods; 51 oneshot_locked_mods = mods;
50 oneshot_locked_mods_changed_kb(oneshot_locked_mods); 52 oneshot_locked_mods_changed_kb(oneshot_locked_mods);
@@ -58,9 +60,13 @@ void clear_oneshot_locked_mods(void) {
58} 60}
59# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) 61# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
60static uint16_t oneshot_time = 0; 62static uint16_t oneshot_time = 0;
61bool has_oneshot_mods_timed_out(void) { return TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT; } 63bool has_oneshot_mods_timed_out(void) {
64 return TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT;
65}
62# else 66# else
63bool has_oneshot_mods_timed_out(void) { return false; } 67bool has_oneshot_mods_timed_out(void) {
68 return false;
69}
64# endif 70# endif
65#endif 71#endif
66 72
@@ -74,24 +80,32 @@ bool has_oneshot_mods_timed_out(void) { return false; }
74 */ 80 */
75static int8_t oneshot_layer_data = 0; 81static int8_t oneshot_layer_data = 0;
76 82
77inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; } 83inline uint8_t get_oneshot_layer(void) {
78inline uint8_t get_oneshot_layer_state(void) { return oneshot_layer_data & 0b111; } 84 return oneshot_layer_data >> 3;
85}
86inline uint8_t get_oneshot_layer_state(void) {
87 return oneshot_layer_data & 0b111;
88}
79 89
80# ifdef SWAP_HANDS_ENABLE 90# ifdef SWAP_HANDS_ENABLE
81enum { 91enum {
82 SHO_OFF, 92 SHO_OFF,
83 SHO_ACTIVE, // Swap hands button was pressed, and we didn't send any swapped keys yet 93 SHO_ACTIVE, // Swap hands button was pressed, and we didn't send any swapped keys yet
84 SHO_PRESSED, // Swap hands button is currently pressed 94 SHO_PRESSED, // Swap hands button is currently pressed
85 SHO_USED, // Swap hands button is still pressed, and we already sent swapped keys 95 SHO_USED, // Swap hands button is still pressed, and we already sent swapped keys
86} swap_hands_oneshot = SHO_OFF; 96} swap_hands_oneshot = SHO_OFF;
87# endif 97# endif
88 98
89# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) 99# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
90static uint16_t oneshot_layer_time = 0; 100static uint16_t oneshot_layer_time = 0;
91inline bool has_oneshot_layer_timed_out() { return TIMER_DIFF_16(timer_read(), oneshot_layer_time) >= ONESHOT_TIMEOUT && !(get_oneshot_layer_state() & ONESHOT_TOGGLED); } 101inline bool has_oneshot_layer_timed_out() {
102 return TIMER_DIFF_16(timer_read(), oneshot_layer_time) >= ONESHOT_TIMEOUT && !(get_oneshot_layer_state() & ONESHOT_TOGGLED);
103}
92# ifdef SWAP_HANDS_ENABLE 104# ifdef SWAP_HANDS_ENABLE
93static uint16_t oneshot_swaphands_time = 0; 105static uint16_t oneshot_swaphands_time = 0;
94inline bool has_oneshot_swaphands_timed_out() { return TIMER_DIFF_16(timer_read(), oneshot_swaphands_time) >= ONESHOT_TIMEOUT && (swap_hands_oneshot == SHO_ACTIVE); } 106inline bool has_oneshot_swaphands_timed_out() {
107 return TIMER_DIFF_16(timer_read(), oneshot_swaphands_time) >= ONESHOT_TIMEOUT && (swap_hands_oneshot == SHO_ACTIVE);
108}
95# endif 109# endif
96# endif 110# endif
97 111
@@ -179,7 +193,9 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
179 * 193 *
180 * FIXME: needs doc 194 * FIXME: needs doc
181 */ 195 */
182bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); } 196bool is_oneshot_layer_active(void) {
197 return get_oneshot_layer_state();
198}
183 199
184/** \brief set oneshot 200/** \brief set oneshot
185 * 201 *
@@ -198,21 +214,29 @@ void oneshot_set(bool active) {
198 * 214 *
199 * FIXME: needs doc 215 * FIXME: needs doc
200 */ 216 */
201void oneshot_toggle(void) { oneshot_set(!keymap_config.oneshot_disable); } 217void oneshot_toggle(void) {
218 oneshot_set(!keymap_config.oneshot_disable);
219}
202 220
203/** \brief enable oneshot 221/** \brief enable oneshot
204 * 222 *
205 * FIXME: needs doc 223 * FIXME: needs doc
206 */ 224 */
207void oneshot_enable(void) { oneshot_set(true); } 225void oneshot_enable(void) {
226 oneshot_set(true);
227}
208 228
209/** \brief disable oneshot 229/** \brief disable oneshot
210 * 230 *
211 * FIXME: needs doc 231 * FIXME: needs doc
212 */ 232 */
213void oneshot_disable(void) { oneshot_set(false); } 233void oneshot_disable(void) {
234 oneshot_set(false);
235}
214 236
215bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; } 237bool is_oneshot_enabled(void) {
238 return keymap_config.oneshot_disable;
239}
216 240
217#endif 241#endif
218 242
@@ -259,68 +283,96 @@ void send_keyboard_report(void) {
259 * 283 *
260 * FIXME: needs doc 284 * FIXME: needs doc
261 */ 285 */
262uint8_t get_mods(void) { return real_mods; } 286uint8_t get_mods(void) {
287 return real_mods;
288}
263/** \brief add mods 289/** \brief add mods
264 * 290 *
265 * FIXME: needs doc 291 * FIXME: needs doc
266 */ 292 */
267void add_mods(uint8_t mods) { real_mods |= mods; } 293void add_mods(uint8_t mods) {
294 real_mods |= mods;
295}
268/** \brief del mods 296/** \brief del mods
269 * 297 *
270 * FIXME: needs doc 298 * FIXME: needs doc
271 */ 299 */
272void del_mods(uint8_t mods) { real_mods &= ~mods; } 300void del_mods(uint8_t mods) {
301 real_mods &= ~mods;
302}
273/** \brief set mods 303/** \brief set mods
274 * 304 *
275 * FIXME: needs doc 305 * FIXME: needs doc
276 */ 306 */
277void set_mods(uint8_t mods) { real_mods = mods; } 307void set_mods(uint8_t mods) {
308 real_mods = mods;
309}
278/** \brief clear mods 310/** \brief clear mods
279 * 311 *
280 * FIXME: needs doc 312 * FIXME: needs doc
281 */ 313 */
282void clear_mods(void) { real_mods = 0; } 314void clear_mods(void) {
315 real_mods = 0;
316}
283 317
284/** \brief get weak mods 318/** \brief get weak mods
285 * 319 *
286 * FIXME: needs doc 320 * FIXME: needs doc
287 */ 321 */
288uint8_t get_weak_mods(void) { return weak_mods; } 322uint8_t get_weak_mods(void) {
323 return weak_mods;
324}
289/** \brief add weak mods 325/** \brief add weak mods
290 * 326 *
291 * FIXME: needs doc 327 * FIXME: needs doc
292 */ 328 */
293void add_weak_mods(uint8_t mods) { weak_mods |= mods; } 329void add_weak_mods(uint8_t mods) {
330 weak_mods |= mods;
331}
294/** \brief del weak mods 332/** \brief del weak mods
295 * 333 *
296 * FIXME: needs doc 334 * FIXME: needs doc
297 */ 335 */
298void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; } 336void del_weak_mods(uint8_t mods) {
337 weak_mods &= ~mods;
338}
299/** \brief set weak mods 339/** \brief set weak mods
300 * 340 *
301 * FIXME: needs doc 341 * FIXME: needs doc
302 */ 342 */
303void set_weak_mods(uint8_t mods) { weak_mods = mods; } 343void set_weak_mods(uint8_t mods) {
344 weak_mods = mods;
345}
304/** \brief clear weak mods 346/** \brief clear weak mods
305 * 347 *
306 * FIXME: needs doc 348 * FIXME: needs doc
307 */ 349 */
308void clear_weak_mods(void) { weak_mods = 0; } 350void clear_weak_mods(void) {
351 weak_mods = 0;
352}
309 353
310#ifdef KEY_OVERRIDE_ENABLE 354#ifdef KEY_OVERRIDE_ENABLE
311/** \brief set weak mods used by key overrides. DO not call this manually 355/** \brief set weak mods used by key overrides. DO not call this manually
312 */ 356 */
313void set_weak_override_mods(uint8_t mods) { weak_override_mods = mods; } 357void set_weak_override_mods(uint8_t mods) {
358 weak_override_mods = mods;
359}
314/** \brief clear weak mods used by key overrides. DO not call this manually 360/** \brief clear weak mods used by key overrides. DO not call this manually
315 */ 361 */
316void clear_weak_override_mods(void) { weak_override_mods = 0; } 362void clear_weak_override_mods(void) {
363 weak_override_mods = 0;
364}
317 365
318/** \brief set suppressed mods used by key overrides. DO not call this manually 366/** \brief set suppressed mods used by key overrides. DO not call this manually
319 */ 367 */
320void set_suppressed_override_mods(uint8_t mods) { suppressed_mods = mods; } 368void set_suppressed_override_mods(uint8_t mods) {
369 suppressed_mods = mods;
370}
321/** \brief clear suppressed mods used by key overrides. DO not call this manually 371/** \brief clear suppressed mods used by key overrides. DO not call this manually
322 */ 372 */
323void clear_suppressed_override_mods(void) { suppressed_mods = 0; } 373void clear_suppressed_override_mods(void) {
374 suppressed_mods = 0;
375}
324#endif 376#endif
325 377
326#ifndef NO_ACTION_ONESHOT 378#ifndef NO_ACTION_ONESHOT
@@ -328,7 +380,9 @@ void clear_suppressed_override_mods(void) { suppressed_mods = 0; }
328 * 380 *
329 * FIXME: needs doc 381 * FIXME: needs doc
330 */ 382 */
331uint8_t get_oneshot_mods(void) { return oneshot_mods; } 383uint8_t get_oneshot_mods(void) {
384 return oneshot_mods;
385}
332 386
333void add_oneshot_mods(uint8_t mods) { 387void add_oneshot_mods(uint8_t mods) {
334 if ((oneshot_mods & mods) != mods) { 388 if ((oneshot_mods & mods) != mods) {
@@ -391,7 +445,9 @@ __attribute__((weak)) void oneshot_locked_mods_changed_user(uint8_t mods) {}
391 * 445 *
392 * \param mods Contains the active modifiers active after the change. 446 * \param mods Contains the active modifiers active after the change.
393 */ 447 */
394__attribute__((weak)) void oneshot_locked_mods_changed_kb(uint8_t mods) { oneshot_locked_mods_changed_user(mods); } 448__attribute__((weak)) void oneshot_locked_mods_changed_kb(uint8_t mods) {
449 oneshot_locked_mods_changed_user(mods);
450}
395 451
396/** \brief Called when the one shot modifiers have been changed. 452/** \brief Called when the one shot modifiers have been changed.
397 * 453 *
@@ -403,7 +459,9 @@ __attribute__((weak)) void oneshot_mods_changed_user(uint8_t mods) {}
403 * 459 *
404 * \param mods Contains the active modifiers active after the change. 460 * \param mods Contains the active modifiers active after the change.
405 */ 461 */
406__attribute__((weak)) void oneshot_mods_changed_kb(uint8_t mods) { oneshot_mods_changed_user(mods); } 462__attribute__((weak)) void oneshot_mods_changed_kb(uint8_t mods) {
463 oneshot_mods_changed_user(mods);
464}
407 465
408/** \brief Called when the one shot layers have been changed. 466/** \brief Called when the one shot layers have been changed.
409 * 467 *
@@ -415,10 +473,14 @@ __attribute__((weak)) void oneshot_layer_changed_user(uint8_t layer) {}
415 * 473 *
416 * \param layer Contains the layer that is toggled on, or zero when toggled off. 474 * \param layer Contains the layer that is toggled on, or zero when toggled off.
417 */ 475 */
418__attribute__((weak)) void oneshot_layer_changed_kb(uint8_t layer) { oneshot_layer_changed_user(layer); } 476__attribute__((weak)) void oneshot_layer_changed_kb(uint8_t layer) {
477 oneshot_layer_changed_user(layer);
478}
419 479
420/** \brief inspect keyboard state 480/** \brief inspect keyboard state
421 * 481 *
422 * FIXME: needs doc 482 * FIXME: needs doc
423 */ 483 */
424uint8_t has_anymod(void) { return bitpop(real_mods); } 484uint8_t has_anymod(void) {
485 return bitpop(real_mods);
486}
diff --git a/quantum/action_util.h b/quantum/action_util.h
index bfd0a6cf95..6f1f09c4bd 100644
--- a/quantum/action_util.h
+++ b/quantum/action_util.h
@@ -29,11 +29,17 @@ extern report_keyboard_t *keyboard_report;
29void send_keyboard_report(void); 29void send_keyboard_report(void);
30 30
31/* key */ 31/* key */
32inline void add_key(uint8_t key) { add_key_to_report(keyboard_report, key); } 32inline void add_key(uint8_t key) {
33 add_key_to_report(keyboard_report, key);
34}
33 35
34inline void del_key(uint8_t key) { del_key_from_report(keyboard_report, key); } 36inline void del_key(uint8_t key) {
37 del_key_from_report(keyboard_report, key);
38}
35 39
36inline void clear_keys(void) { clear_keys_from_report(keyboard_report); } 40inline void clear_keys(void) {
41 clear_keys_from_report(keyboard_report);
42}
37 43
38/* modifier */ 44/* modifier */
39uint8_t get_mods(void); 45uint8_t get_mods(void);
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index b3d6389dd5..c6523b908c 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -64,21 +64,21 @@
64#ifndef AUDIO_TONE_STACKSIZE 64#ifndef AUDIO_TONE_STACKSIZE
65# define AUDIO_TONE_STACKSIZE 8 65# define AUDIO_TONE_STACKSIZE 8
66#endif 66#endif
67uint8_t active_tones = 0; // number of tones pushed onto the stack by audio_play_tone - might be more than the hardware is able to reproduce at any single time 67uint8_t active_tones = 0; // number of tones pushed onto the stack by audio_play_tone - might be more than the hardware is able to reproduce at any single time
68musical_tone_t tones[AUDIO_TONE_STACKSIZE]; // stack of currently active tones 68musical_tone_t tones[AUDIO_TONE_STACKSIZE]; // stack of currently active tones
69 69
70bool playing_melody = false; // playing a SONG? 70bool playing_melody = false; // playing a SONG?
71bool playing_note = false; // or (possibly multiple simultaneous) tones 71bool playing_note = false; // or (possibly multiple simultaneous) tones
72bool state_changed = false; // global flag, which is set if anything changes with the active_tones 72bool state_changed = false; // global flag, which is set if anything changes with the active_tones
73 73
74// melody/SONG related state variables 74// melody/SONG related state variables
75float (*notes_pointer)[][2]; // SONG, an array of MUSICAL_NOTEs 75float (*notes_pointer)[][2]; // SONG, an array of MUSICAL_NOTEs
76uint16_t notes_count; // length of the notes_pointer array 76uint16_t notes_count; // length of the notes_pointer array
77bool notes_repeat; // PLAY_SONG or PLAY_LOOP? 77bool notes_repeat; // PLAY_SONG or PLAY_LOOP?
78uint16_t melody_current_note_duration = 0; // duration of the currently playing note from the active melody, in ms 78uint16_t melody_current_note_duration = 0; // duration of the currently playing note from the active melody, in ms
79uint8_t note_tempo = TEMPO_DEFAULT; // beats-per-minute 79uint8_t note_tempo = TEMPO_DEFAULT; // beats-per-minute
80uint16_t current_note = 0; // index into the array at notes_pointer 80uint16_t current_note = 0; // index into the array at notes_pointer
81bool note_resting = false; // if a short pause was introduced between two notes with the same frequency while playing a melody 81bool note_resting = false; // if a short pause was introduced between two notes with the same frequency while playing a melody
82uint16_t last_timestamp = 0; 82uint16_t last_timestamp = 0;
83 83
84#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING 84#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
@@ -86,7 +86,7 @@ uint16_t last_timestamp = 0;
86# define AUDIO_MAX_SIMULTANEOUS_TONES 3 86# define AUDIO_MAX_SIMULTANEOUS_TONES 3
87# endif 87# endif
88uint16_t tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT; 88uint16_t tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT;
89uint8_t tone_multiplexing_index_shift = 0; // offset used on active-tone array access 89uint8_t tone_multiplexing_index_shift = 0; // offset used on active-tone array access
90#endif 90#endif
91 91
92// provided and used by voices.c 92// provided and used by voices.c
@@ -123,12 +123,12 @@ void audio_init() {
123 eeconfig_init(); 123 eeconfig_init();
124 } 124 }
125 audio_config.raw = eeconfig_read_audio(); 125 audio_config.raw = eeconfig_read_audio();
126#else // EEPROM settings 126#else // EEPROM settings
127 audio_config.enable = true; 127 audio_config.enable = true;
128# ifdef AUDIO_CLICKY_ON 128# ifdef AUDIO_CLICKY_ON
129 audio_config.clicky_enable = true; 129 audio_config.clicky_enable = true;
130# endif 130# endif
131#endif // EEPROM settings 131#endif // EEPROM settings
132 132
133 for (uint8_t i = 0; i < AUDIO_TONE_STACKSIZE; i++) { 133 for (uint8_t i = 0; i < AUDIO_TONE_STACKSIZE; i++) {
134 tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0}; 134 tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0};
@@ -181,7 +181,9 @@ void audio_off(void) {
181 eeconfig_update_audio(audio_config.raw); 181 eeconfig_update_audio(audio_config.raw);
182} 182}
183 183
184bool audio_is_on(void) { return (audio_config.enable != 0); } 184bool audio_is_on(void) {
185 return (audio_config.enable != 0);
186}
185 187
186void audio_stop_all() { 188void audio_stop_all() {
187 if (audio_driver_stopped) { 189 if (audio_driver_stopped) {
@@ -268,7 +270,7 @@ void audio_play_note(float pitch, uint16_t duration) {
268 tones[j] = tones[j + 1]; 270 tones[j] = tones[j + 1];
269 tones[j + 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration}; 271 tones[j + 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration};
270 } 272 }
271 return; // since this frequency played already, the hardware was already started 273 return; // since this frequency played already, the hardware was already started
272 } 274 }
273 } 275 }
274 276
@@ -286,7 +288,7 @@ void audio_play_note(float pitch, uint16_t duration) {
286 tones[active_tones - 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration}; 288 tones[active_tones - 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration};
287 289
288 // TODO: needs to be handled per note/tone -> use its timestamp instead? 290 // TODO: needs to be handled per note/tone -> use its timestamp instead?
289 voices_timer = timer_read(); // reset to zero, for the effects added by voices.c 291 voices_timer = timer_read(); // reset to zero, for the effects added by voices.c
290 292
291 if (audio_driver_stopped) { 293 if (audio_driver_stopped) {
292 audio_driver_start(); 294 audio_driver_start();
@@ -294,7 +296,9 @@ void audio_play_note(float pitch, uint16_t duration) {
294 } 296 }
295} 297}
296 298
297void audio_play_tone(float pitch) { audio_play_note(pitch, 0xffff); } 299void audio_play_tone(float pitch) {
300 audio_play_note(pitch, 0xffff);
301}
298 302
299void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) { 303void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) {
300 if (!audio_config.enable) { 304 if (!audio_config.enable) {
@@ -316,7 +320,7 @@ void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) {
316 notes_count = n_count; 320 notes_count = n_count;
317 notes_repeat = n_repeat; 321 notes_repeat = n_repeat;
318 322
319 current_note = 0; // note in the melody-array/list at note_pointer 323 current_note = 0; // note in the melody-array/list at note_pointer
320 324
321 // start first note manually, which also starts the audio_driver 325 // start first note manually, which also starts the audio_driver
322 // all following/remaining notes are played by 'audio_update_state' 326 // all following/remaining notes are played by 'audio_update_state'
@@ -347,11 +351,17 @@ void audio_play_click(uint16_t delay, float pitch, uint16_t duration) {
347 } 351 }
348} 352}
349 353
350bool audio_is_playing_note(void) { return playing_note; } 354bool audio_is_playing_note(void) {
355 return playing_note;
356}
351 357
352bool audio_is_playing_melody(void) { return playing_melody; } 358bool audio_is_playing_melody(void) {
359 return playing_melody;
360}
353 361
354uint8_t audio_get_number_of_active_tones(void) { return active_tones; } 362uint8_t audio_get_number_of_active_tones(void) {
363 return active_tones;
364}
355 365
356float audio_get_frequency(uint8_t tone_index) { 366float audio_get_frequency(uint8_t tone_index) {
357 if (tone_index >= active_tones) { 367 if (tone_index >= active_tones) {
@@ -370,7 +380,7 @@ float audio_get_processed_frequency(uint8_t tone_index) {
370 380
371#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING 381#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
372 index = index - tone_multiplexing_index_shift; 382 index = index - tone_multiplexing_index_shift;
373 if (index < 0) // wrap around 383 if (index < 0) // wrap around
374 index += active_tones; 384 index += active_tones;
375#endif 385#endif
376 386
@@ -396,7 +406,7 @@ bool audio_update_state(void) {
396 last_timestamp = current_time; 406 last_timestamp = current_time;
397 uint16_t previous_note = current_note; 407 uint16_t previous_note = current_note;
398 current_note++; 408 current_note++;
399 voices_timer = timer_read(); // reset to zero, for the effects added by voices.c 409 voices_timer = timer_read(); // reset to zero, for the effects added by voices.c
400 410
401 if (current_note >= notes_count) { 411 if (current_note >= notes_count) {
402 if (notes_repeat) { 412 if (notes_repeat) {
@@ -466,11 +476,11 @@ bool audio_update_state(void) {
466 476
467 // housekeeping: stop notes that have no playtime left 477 // housekeeping: stop notes that have no playtime left
468 for (int i = 0; i < active_tones; i++) { 478 for (int i = 0; i < active_tones; i++) {
469 if ((tones[i].duration != 0xffff) // indefinitely playing notes, started by 'audio_play_tone' 479 if ((tones[i].duration != 0xffff) // indefinitely playing notes, started by 'audio_play_tone'
470 && (tones[i].duration != 0) // 'uninitialized' 480 && (tones[i].duration != 0) // 'uninitialized'
471 ) { 481 ) {
472 if (timer_elapsed(tones[i].time_started) >= tones[i].duration) { 482 if (timer_elapsed(tones[i].time_started) >= tones[i].duration) {
473 audio_stop_tone(tones[i].pitch); // also sets 'state_changed=true' 483 audio_stop_tone(tones[i].pitch); // also sets 'state_changed=true'
474 } 484 }
475 } 485 }
476 } 486 }
@@ -487,9 +497,15 @@ bool audio_update_state(void) {
487 497
488// Tone-multiplexing functions 498// Tone-multiplexing functions
489#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING 499#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
490void audio_set_tone_multiplexing_rate(uint16_t rate) { tone_multiplexing_rate = rate; } 500void audio_set_tone_multiplexing_rate(uint16_t rate) {
491void audio_enable_tone_multiplexing(void) { tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT; } 501 tone_multiplexing_rate = rate;
492void audio_disable_tone_multiplexing(void) { tone_multiplexing_rate = 0; } 502}
503void audio_enable_tone_multiplexing(void) {
504 tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT;
505}
506void audio_disable_tone_multiplexing(void) {
507 tone_multiplexing_rate = 0;
508}
493void audio_increase_tone_multiplexing_rate(uint16_t change) { 509void audio_increase_tone_multiplexing_rate(uint16_t change) {
494 if ((0xffff - change) > tone_multiplexing_rate) { 510 if ((0xffff - change) > tone_multiplexing_rate) {
495 tone_multiplexing_rate += change; 511 tone_multiplexing_rate += change;
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index 290d461f5a..fe23cf3ed1 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -54,9 +54,9 @@ typedef union {
54 * "A musical tone is characterized by its duration, pitch, intensity (or loudness), and timbre (or quality)" 54 * "A musical tone is characterized by its duration, pitch, intensity (or loudness), and timbre (or quality)"
55 */ 55 */
56typedef struct { 56typedef struct {
57 uint16_t time_started; // timestamp the tone/note was started, system time runs with 1ms resolution -> 16bit timer overflows every ~64 seconds, long enough under normal circumstances; but might be too soon for long-duration notes when the note_tempo is set to a very low value 57 uint16_t time_started; // timestamp the tone/note was started, system time runs with 1ms resolution -> 16bit timer overflows every ~64 seconds, long enough under normal circumstances; but might be too soon for long-duration notes when the note_tempo is set to a very low value
58 float pitch; // aka frequency, in Hz 58 float pitch; // aka frequency, in Hz
59 uint16_t duration; // in ms, converted from the musical_notes.h unit which has 64parts to a beat, factoring in the current tempo in beats-per-minute 59 uint16_t duration; // in ms, converted from the musical_notes.h unit which has 64parts to a beat, factoring in the current tempo in beats-per-minute
60 // float intensity; // aka volume [0,1] TODO: not used at the moment; pwm drivers can't handle it 60 // float intensity; // aka volume [0,1] TODO: not used at the moment; pwm drivers can't handle it
61 // uint8_t timbre; // range: [0,100] TODO: this currently kept track of globally, should we do this per tone instead? 61 // uint8_t timbre; // range: [0,100] TODO: this currently kept track of globally, should we do this per tone instead?
62} musical_tone_t; 62} musical_tone_t;
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index 8e80a016aa..3e425abb47 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -22,7 +22,7 @@
22 22
23#if __has_include("user_song_list.h") 23#if __has_include("user_song_list.h")
24# include "user_song_list.h" 24# include "user_song_list.h"
25#endif // if file exists 25#endif // if file exists
26 26
27#define NO_SOUND 27#define NO_SOUND
28 28
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
index 8988d827e9..1c08a3af36 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -32,11 +32,17 @@ voice_type voice = AUDIO_VOICE_DEFAULT;
32voice_type voice = default_voice; 32voice_type voice = default_voice;
33#endif 33#endif
34 34
35void set_voice(voice_type v) { voice = v; } 35void set_voice(voice_type v) {
36 voice = v;
37}
36 38
37void voice_iterate() { voice = (voice + 1) % number_of_voices; } 39void voice_iterate() {
40 voice = (voice + 1) % number_of_voices;
41}
38 42
39void voice_deiterate() { voice = (voice - 1 + number_of_voices) % number_of_voices; } 43void voice_deiterate() {
44 voice = (voice - 1 + number_of_voices) % number_of_voices;
45}
40 46
41#ifdef AUDIO_VOICES 47#ifdef AUDIO_VOICES
42float mod(float a, int b) { 48float mod(float a, int b) {
@@ -67,8 +73,8 @@ float voice_envelope(float frequency) {
67 // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz 73 // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz
68// __attribute__((unused)) uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); 74// __attribute__((unused)) uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency));
69#ifdef AUDIO_VOICES 75#ifdef AUDIO_VOICES
70 uint16_t envelope_index = timer_elapsed(voices_timer); // TODO: multiply in some factor? 76 uint16_t envelope_index = timer_elapsed(voices_timer); // TODO: multiply in some factor?
71 uint16_t compensated_index = envelope_index / 100; // TODO: correct factor would be? 77 uint16_t compensated_index = envelope_index / 100; // TODO: correct factor would be?
72#endif 78#endif
73 79
74 switch (voice) { 80 switch (voice) {
@@ -303,7 +309,7 @@ float voice_envelope(float frequency) {
303 // note_timbre = TIMBRE_25; 309 // note_timbre = TIMBRE_25;
304 // break; 310 // break;
305 311
306#endif // AUDIO_VOICES 312#endif // AUDIO_VOICES
307 313
308 default: 314 default:
309 break; 315 break;
@@ -318,19 +324,31 @@ float voice_envelope(float frequency) {
318 // TODO: where to keep track of the start-frequency? 324 // TODO: where to keep track of the start-frequency?
319 // frequency = voice_add_glissando(??, frequency); 325 // frequency = voice_add_glissando(??, frequency);
320 } 326 }
321#endif // AUDIO_VOICES 327#endif // AUDIO_VOICES
322 328
323 return frequency; 329 return frequency;
324} 330}
325 331
326// Vibrato functions 332// Vibrato functions
327 333
328void voice_set_vibrato_rate(float rate) { vibrato_rate = rate; } 334void voice_set_vibrato_rate(float rate) {
329void voice_increase_vibrato_rate(float change) { vibrato_rate *= change; } 335 vibrato_rate = rate;
330void voice_decrease_vibrato_rate(float change) { vibrato_rate /= change; } 336}
331void voice_set_vibrato_strength(float strength) { vibrato_strength = strength; } 337void voice_increase_vibrato_rate(float change) {
332void voice_increase_vibrato_strength(float change) { vibrato_strength *= change; } 338 vibrato_rate *= change;
333void voice_decrease_vibrato_strength(float change) { vibrato_strength /= change; } 339}
340void voice_decrease_vibrato_rate(float change) {
341 vibrato_rate /= change;
342}
343void voice_set_vibrato_strength(float strength) {
344 vibrato_strength = strength;
345}
346void voice_increase_vibrato_strength(float change) {
347 vibrato_strength *= change;
348}
349void voice_decrease_vibrato_strength(float change) {
350 vibrato_strength /= change;
351}
334 352
335// Timbre functions 353// Timbre functions
336 354
@@ -339,4 +357,6 @@ void voice_set_timbre(uint8_t timbre) {
339 note_timbre = timbre; 357 note_timbre = timbre;
340 } 358 }
341} 359}
342uint8_t voice_get_timbre(void) { return note_timbre; } 360uint8_t voice_get_timbre(void) {
361 return note_timbre;
362}
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h
index 1f402e7e12..fcab9db556 100644
--- a/quantum/audio/voices.h
+++ b/quantum/audio/voices.h
@@ -40,7 +40,7 @@ typedef enum {
40// duty_third_down, 40// duty_third_down,
41// duty_fifth_third_down, 41// duty_fifth_third_down,
42#endif 42#endif
43 number_of_voices // important that this is last 43 number_of_voices // important that this is last
44} voice_type; 44} voice_type;
45 45
46void set_voice(voice_type v); 46void set_voice(voice_type v);
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c
index dfb98419e6..52ec086bb0 100644
--- a/quantum/backlight/backlight.c
+++ b/quantum/backlight/backlight.c
@@ -95,10 +95,10 @@ void backlight_toggle(void) {
95 * FIXME: needs doc 95 * FIXME: needs doc
96 */ 96 */
97void backlight_enable(void) { 97void backlight_enable(void) {
98 if (backlight_config.enable) return; // do nothing if backlight is already on 98 if (backlight_config.enable) return; // do nothing if backlight is already on
99 99
100 backlight_config.enable = true; 100 backlight_config.enable = true;
101 if (backlight_config.raw == 1) // enabled but level == 0 101 if (backlight_config.raw == 1) // enabled but level == 0
102 backlight_config.level = 1; 102 backlight_config.level = 1;
103 eeconfig_update_backlight(backlight_config.raw); 103 eeconfig_update_backlight(backlight_config.raw);
104 dprintf("backlight enable\n"); 104 dprintf("backlight enable\n");
@@ -110,7 +110,7 @@ void backlight_enable(void) {
110 * FIXME: needs doc 110 * FIXME: needs doc
111 */ 111 */
112void backlight_disable(void) { 112void backlight_disable(void) {
113 if (!backlight_config.enable) return; // do nothing if backlight is already off 113 if (!backlight_config.enable) return; // do nothing if backlight is already off
114 114
115 backlight_config.enable = false; 115 backlight_config.enable = false;
116 eeconfig_update_backlight(backlight_config.raw); 116 eeconfig_update_backlight(backlight_config.raw);
@@ -122,7 +122,9 @@ void backlight_disable(void) {
122 * 122 *
123 * FIXME: needs doc 123 * FIXME: needs doc
124 */ 124 */
125bool is_backlight_enabled(void) { return backlight_config.enable; } 125bool is_backlight_enabled(void) {
126 return backlight_config.enable;
127}
126 128
127/** \brief Backlight step through levels 129/** \brief Backlight step through levels
128 * 130 *
@@ -158,11 +160,17 @@ void backlight_level(uint8_t level) {
158 eeconfig_update_backlight(backlight_config.raw); 160 eeconfig_update_backlight(backlight_config.raw);
159} 161}
160 162
161uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } 163uint8_t eeconfig_read_backlight(void) {
164 return eeprom_read_byte(EECONFIG_BACKLIGHT);
165}
162 166
163void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); } 167void eeconfig_update_backlight(uint8_t val) {
168 eeprom_update_byte(EECONFIG_BACKLIGHT, val);
169}
164 170
165void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); } 171void eeconfig_update_backlight_current(void) {
172 eeconfig_update_backlight(backlight_config.raw);
173}
166 174
167void eeconfig_update_backlight_default(void) { 175void eeconfig_update_backlight_default(void) {
168 backlight_config.enable = 1; 176 backlight_config.enable = 1;
@@ -179,7 +187,9 @@ void eeconfig_update_backlight_default(void) {
179 * 187 *
180 * FIXME: needs doc 188 * FIXME: needs doc
181 */ 189 */
182uint8_t get_backlight_level(void) { return backlight_config.level; } 190uint8_t get_backlight_level(void) {
191 return backlight_config.level;
192}
183 193
184#ifdef BACKLIGHT_BREATHING 194#ifdef BACKLIGHT_BREATHING
185/** \brief Backlight breathing toggle 195/** \brief Backlight breathing toggle
@@ -200,7 +210,7 @@ void backlight_toggle_breathing(void) {
200 * FIXME: needs doc 210 * FIXME: needs doc
201 */ 211 */
202void backlight_enable_breathing(void) { 212void backlight_enable_breathing(void) {
203 if (backlight_config.breathing) return; // do nothing if breathing is already on 213 if (backlight_config.breathing) return; // do nothing if breathing is already on
204 214
205 backlight_config.breathing = true; 215 backlight_config.breathing = true;
206 eeconfig_update_backlight(backlight_config.raw); 216 eeconfig_update_backlight(backlight_config.raw);
@@ -213,7 +223,7 @@ void backlight_enable_breathing(void) {
213 * FIXME: needs doc 223 * FIXME: needs doc
214 */ 224 */
215void backlight_disable_breathing(void) { 225void backlight_disable_breathing(void) {
216 if (!backlight_config.breathing) return; // do nothing if breathing is already off 226 if (!backlight_config.breathing) return; // do nothing if breathing is already off
217 227
218 backlight_config.breathing = false; 228 backlight_config.breathing = false;
219 eeconfig_update_backlight(backlight_config.raw); 229 eeconfig_update_backlight(backlight_config.raw);
@@ -225,18 +235,30 @@ void backlight_disable_breathing(void) {
225 * 235 *
226 * FIXME: needs doc 236 * FIXME: needs doc
227 */ 237 */
228bool is_backlight_breathing(void) { return backlight_config.breathing; } 238bool is_backlight_breathing(void) {
239 return backlight_config.breathing;
240}
229 241
230// following are marked as weak purely for backwards compatibility 242// following are marked as weak purely for backwards compatibility
231__attribute__((weak)) void breathing_period_set(uint8_t value) { breathing_period = value ? value : 1; } 243__attribute__((weak)) void breathing_period_set(uint8_t value) {
244 breathing_period = value ? value : 1;
245}
232 246
233__attribute__((weak)) uint8_t get_breathing_period(void) { return breathing_period; } 247__attribute__((weak)) uint8_t get_breathing_period(void) {
248 return breathing_period;
249}
234 250
235__attribute__((weak)) void breathing_period_default(void) { breathing_period_set(BREATHING_PERIOD); } 251__attribute__((weak)) void breathing_period_default(void) {
252 breathing_period_set(BREATHING_PERIOD);
253}
236 254
237__attribute__((weak)) void breathing_period_inc(void) { breathing_period_set(breathing_period + 1); } 255__attribute__((weak)) void breathing_period_inc(void) {
256 breathing_period_set(breathing_period + 1);
257}
238 258
239__attribute__((weak)) void breathing_period_dec(void) { breathing_period_set(breathing_period - 1); } 259__attribute__((weak)) void breathing_period_dec(void) {
260 breathing_period_set(breathing_period - 1);
261}
240 262
241__attribute__((weak)) void breathing_toggle(void) { 263__attribute__((weak)) void breathing_toggle(void) {
242 if (is_breathing()) 264 if (is_breathing())
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h
index c30c70fd62..ff9c8de420 100644
--- a/quantum/backlight/backlight.h
+++ b/quantum/backlight/backlight.h
@@ -39,7 +39,7 @@ typedef union {
39 struct { 39 struct {
40 bool enable : 1; 40 bool enable : 1;
41 bool breathing : 1; 41 bool breathing : 1;
42 uint8_t reserved : 1; // Reserved for possible future backlight modes 42 uint8_t reserved : 1; // Reserved for possible future backlight modes
43 uint8_t level : 5; 43 uint8_t level : 5;
44 }; 44 };
45} backlight_config_t; 45} backlight_config_t;
diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c
index 9c972ae02e..f3a0252270 100644
--- a/quantum/backlight/backlight_avr.c
+++ b/quantum/backlight/backlight_avr.c
@@ -136,7 +136,7 @@
136# define TCCRxB TCCR1B 136# define TCCRxB TCCR1B
137# define TIMERx_COMPA_vect TIMER1_COMPA_vect 137# define TIMERx_COMPA_vect TIMER1_COMPA_vect
138# define TIMERx_OVF_vect TIMER1_OVF_vect 138# define TIMERx_OVF_vect TIMER1_OVF_vect
139# if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register 139# if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register
140# define TIMSKx TIMSK 140# define TIMSKx TIMSK
141# else 141# else
142# define TIMSKx TIMSK1 142# define TIMSKx TIMSK1
@@ -166,7 +166,7 @@ error("Please set 'BACKLIGHT_DRIVER = custom' within rules.mk")
166error("Please set 'BACKLIGHT_DRIVER = software' within rules.mk") 166error("Please set 'BACKLIGHT_DRIVER = software' within rules.mk")
167#endif 167#endif
168 168
169#ifndef BACKLIGHT_PWM_TIMER // pwm through software 169#ifndef BACKLIGHT_PWM_TIMER // pwm through software
170 170
171static inline void enable_pwm(void) { 171static inline void enable_pwm(void) {
172# if BACKLIGHT_ON_STATE == 1 172# if BACKLIGHT_ON_STATE == 1
@@ -203,7 +203,9 @@ static inline void disable_pwm(void) {
203// or F_CPU/BACKLIGHT_CUSTOM_RESOLUTION if used. 203// or F_CPU/BACKLIGHT_CUSTOM_RESOLUTION if used.
204 204
205// Triggered when the counter reaches the OCRx value 205// Triggered when the counter reaches the OCRx value
206ISR(TIMERx_COMPA_vect) { backlight_pins_off(); } 206ISR(TIMERx_COMPA_vect) {
207 backlight_pins_off();
208}
207 209
208// Triggered when the counter reaches the TOP value 210// Triggered when the counter reaches the TOP value
209// this one triggers at F_CPU/ICRx = 16MHz/65536 =~ 244 Hz 211// this one triggers at F_CPU/ICRx = 16MHz/65536 =~ 244 Hz
@@ -232,15 +234,15 @@ ISR(TIMERx_OVF_vect) {
232 234
233// See http://jared.geek.nz/2013/feb/linear-led-pwm 235// See http://jared.geek.nz/2013/feb/linear-led-pwm
234static uint16_t cie_lightness(uint16_t v) { 236static uint16_t cie_lightness(uint16_t v) {
235 if (v <= (uint32_t)ICRx / 12) // If the value is less than or equal to ~8% of max 237 if (v <= (uint32_t)ICRx / 12) // If the value is less than or equal to ~8% of max
236 { 238 {
237 return v / 9; // Same as dividing by 900% 239 return v / 9; // Same as dividing by 900%
238 } else { 240 } else {
239 // In the next two lines values are bit-shifted. This is to avoid loosing decimals in integer math. 241 // In the next two lines values are bit-shifted. This is to avoid loosing decimals in integer math.
240 uint32_t y = (((uint32_t)v + (uint32_t)ICRx / 6) << 5) / ((uint32_t)ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max) 242 uint32_t y = (((uint32_t)v + (uint32_t)ICRx / 6) << 5) / ((uint32_t)ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max)
241 uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing) 243 uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing)
242 244
243 if (out > ICRx) // Avoid overflows 245 if (out > ICRx) // Avoid overflows
244 { 246 {
245 out = ICRx; 247 out = ICRx;
246 } 248 }
@@ -249,10 +251,14 @@ static uint16_t cie_lightness(uint16_t v) {
249} 251}
250 252
251// rescale the supplied backlight value to be in terms of the value limit // range for val is [0..ICRx]. PWM pin is high while the timer count is below val. 253// rescale the supplied backlight value to be in terms of the value limit // range for val is [0..ICRx]. PWM pin is high while the timer count is below val.
252static uint32_t rescale_limit_val(uint32_t val) { return (val * (BACKLIGHT_LIMIT_VAL + 1)) / 256; } 254static uint32_t rescale_limit_val(uint32_t val) {
255 return (val * (BACKLIGHT_LIMIT_VAL + 1)) / 256;
256}
253 257
254// range for val is [0..ICRx]. PWM pin is high while the timer count is below val. 258// range for val is [0..ICRx]. PWM pin is high while the timer count is below val.
255static inline void set_pwm(uint16_t val) { OCRxx = val; } 259static inline void set_pwm(uint16_t val) {
260 OCRxx = val;
261}
256 262
257void backlight_set(uint8_t level) { 263void backlight_set(uint8_t level) {
258 if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; 264 if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS;
@@ -303,7 +309,9 @@ static uint16_t breathing_freq_scale_factor = 2;
303# ifdef BACKLIGHT_PWM_TIMER 309# ifdef BACKLIGHT_PWM_TIMER
304static bool breathing = false; 310static bool breathing = false;
305 311
306bool is_breathing(void) { return breathing; } 312bool is_breathing(void) {
313 return breathing;
314}
307 315
308# define breathing_interrupt_enable() \ 316# define breathing_interrupt_enable() \
309 do { \ 317 do { \
@@ -315,7 +323,9 @@ bool is_breathing(void) { return breathing; }
315 } while (0) 323 } while (0)
316# else 324# else
317 325
318bool is_breathing(void) { return !!(TIMSKx & _BV(TOIEx)); } 326bool is_breathing(void) {
327 return !!(TIMSKx & _BV(TOIEx));
328}
319 329
320# define breathing_interrupt_enable() \ 330# define breathing_interrupt_enable() \
321 do { \ 331 do { \
@@ -370,7 +380,9 @@ void breathing_self_disable(void) {
370static const uint8_t breathing_table[BREATHING_STEPS] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 380static const uint8_t breathing_table[BREATHING_STEPS] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
371 381
372// Use this before the cie_lightness function. 382// Use this before the cie_lightness function.
373static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } 383static inline uint16_t scale_backlight(uint16_t v) {
384 return v / BACKLIGHT_LEVELS * get_backlight_level();
385}
374 386
375# ifdef BACKLIGHT_PWM_TIMER 387# ifdef BACKLIGHT_PWM_TIMER
376void breathing_task(void) 388void breathing_task(void)
@@ -403,7 +415,7 @@ ISR(TIMERx_OVF_vect)
403 set_pwm(cie_lightness(rescale_limit_val(scale_backlight((uint16_t)pgm_read_byte(&breathing_table[index]) * ICRx / 255)))); 415 set_pwm(cie_lightness(rescale_limit_val(scale_backlight((uint16_t)pgm_read_byte(&breathing_table[index]) * ICRx / 255))));
404} 416}
405 417
406#endif // BACKLIGHT_BREATHING 418#endif // BACKLIGHT_BREATHING
407 419
408void backlight_init_ports(void) { 420void backlight_init_ports(void) {
409 // Setup backlight pin as output and output to on state. 421 // Setup backlight pin as output and output to on state.
@@ -415,10 +427,10 @@ void backlight_init_ports(void) {
415 427
416#ifdef BACKLIGHT_PWM_TIMER 428#ifdef BACKLIGHT_PWM_TIMER
417 // TimerX setup, Fast PWM mode count to TOP set in ICRx 429 // TimerX setup, Fast PWM mode count to TOP set in ICRx
418 TCCRxA = _BV(WGM11); // = 0b00000010; 430 TCCRxA = _BV(WGM11); // = 0b00000010;
419 // clock select clk/1 431 // clock select clk/1
420 TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; 432 TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
421#else // hardware PWM 433#else // hardware PWM
422 // Pin PB7 = OCR1C (Timer 1, Channel C) 434 // Pin PB7 = OCR1C (Timer 1, Channel C)
423 // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 435 // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
424 // (i.e. start high, go low when counter matches.) 436 // (i.e. start high, go low when counter matches.)
@@ -430,8 +442,8 @@ void backlight_init_ports(void) {
430 "In fast PWM mode, the compare units allow generation of PWM waveforms on the OCnx pins. Setting the COMnx1:0 bits to two will produce a non-inverted PWM [..]." 442 "In fast PWM mode, the compare units allow generation of PWM waveforms on the OCnx pins. Setting the COMnx1:0 bits to two will produce a non-inverted PWM [..]."
431 "In fast PWM mode the counter is incremented until the counter value matches either one of the fixed values 0x00FF, 0x01FF, or 0x03FF (WGMn3:0 = 5, 6, or 7), the value in ICRn (WGMn3:0 = 14), or the value in OCRnA (WGMn3:0 = 15)." 443 "In fast PWM mode the counter is incremented until the counter value matches either one of the fixed values 0x00FF, 0x01FF, or 0x03FF (WGMn3:0 = 5, 6, or 7), the value in ICRn (WGMn3:0 = 14), or the value in OCRnA (WGMn3:0 = 15)."
432 */ 444 */
433 TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010; 445 TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010;
434 TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; 446 TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
435#endif 447#endif
436 448
437#ifdef BACKLIGHT_CUSTOM_RESOLUTION 449#ifdef BACKLIGHT_CUSTOM_RESOLUTION
diff --git a/quantum/backlight/backlight_chibios.c b/quantum/backlight/backlight_chibios.c
index 7c6edd10d6..e8f9e70f78 100644
--- a/quantum/backlight/backlight_chibios.c
+++ b/quantum/backlight/backlight_chibios.c
@@ -53,14 +53,14 @@ static PWMConfig pwmCFG = {0xFFFF, /* PWM clock frequency */
53 53
54// See http://jared.geek.nz/2013/feb/linear-led-pwm 54// See http://jared.geek.nz/2013/feb/linear-led-pwm
55static uint16_t cie_lightness(uint16_t v) { 55static uint16_t cie_lightness(uint16_t v) {
56 if (v <= 5243) // if below 8% of max 56 if (v <= 5243) // if below 8% of max
57 return v / 9; // same as dividing by 900% 57 return v / 9; // same as dividing by 900%
58 else { 58 else {
59 uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare 59 uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
60 // to get a useful result with integer division, we shift left in the expression above 60 // to get a useful result with integer division, we shift left in the expression above
61 // and revert what we've done again after squaring. 61 // and revert what we've done again after squaring.
62 y = y * y * y >> 8; 62 y = y * y * y >> 8;
63 if (y > 0xFFFFUL) // prevent overflow 63 if (y > 0xFFFFUL) // prevent overflow
64 return 0xFFFFU; 64 return 0xFFFFU;
65 else 65 else
66 return (uint16_t)y; 66 return (uint16_t)y;
@@ -117,7 +117,9 @@ static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0,
117 117
118void breathing_callback(PWMDriver *pwmp); 118void breathing_callback(PWMDriver *pwmp);
119 119
120bool is_breathing(void) { return pwmCFG.callback != NULL; } 120bool is_breathing(void) {
121 return pwmCFG.callback != NULL;
122}
121 123
122void breathing_enable(void) { 124void breathing_enable(void) {
123 pwmCFG.callback = breathing_callback; 125 pwmCFG.callback = breathing_callback;
@@ -133,7 +135,9 @@ void breathing_disable(void) {
133} 135}
134 136
135// Use this before the cie_lightness function. 137// Use this before the cie_lightness function.
136static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } 138static inline uint16_t scale_backlight(uint16_t v) {
139 return v / BACKLIGHT_LEVELS * get_backlight_level();
140}
137 141
138void breathing_callback(PWMDriver *pwmp) { 142void breathing_callback(PWMDriver *pwmp) {
139 uint8_t breathing_period = get_breathing_period(); 143 uint8_t breathing_period = get_breathing_period();
diff --git a/quantum/backlight/backlight_driver_common.c b/quantum/backlight/backlight_driver_common.c
index 270a43c67e..e4c2e90b5f 100644
--- a/quantum/backlight/backlight_driver_common.c
+++ b/quantum/backlight/backlight_driver_common.c
@@ -44,6 +44,10 @@ void backlight_pins_init(void) {
44 FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);) 44 FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);)
45} 45}
46 46
47void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) } 47void backlight_pins_on(void) {
48 FOR_EACH_LED(backlight_on(backlight_pin);)
49}
48 50
49void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) } 51void backlight_pins_off(void) {
52 FOR_EACH_LED(backlight_off(backlight_pin);)
53}
diff --git a/quantum/backlight/backlight_software.c b/quantum/backlight/backlight_software.c
index 709304f559..3d412cab52 100644
--- a/quantum/backlight/backlight_software.c
+++ b/quantum/backlight/backlight_software.c
@@ -30,11 +30,17 @@ static const uint16_t backlight_duty_table[] = {
30 30
31// clang-format on 31// clang-format on
32 32
33static uint8_t scale_backlight(uint8_t v) { return v * (backlight_duty_table_size - 1) / BACKLIGHT_LEVELS; } 33static uint8_t scale_backlight(uint8_t v) {
34 return v * (backlight_duty_table_size - 1) / BACKLIGHT_LEVELS;
35}
34 36
35void backlight_init_ports(void) { backlight_pins_init(); } 37void backlight_init_ports(void) {
38 backlight_pins_init();
39}
36 40
37void backlight_set(uint8_t level) { s_duty_pattern = backlight_duty_table[scale_backlight(level)]; } 41void backlight_set(uint8_t level) {
42 s_duty_pattern = backlight_duty_table[scale_backlight(level)];
43}
38 44
39void backlight_task(void) { 45void backlight_task(void) {
40 static uint8_t backlight_tick = 0; 46 static uint8_t backlight_tick = 0;
diff --git a/quantum/backlight/backlight_timer.c b/quantum/backlight/backlight_timer.c
index c32c35c154..82fb6a6a83 100644
--- a/quantum/backlight/backlight_timer.c
+++ b/quantum/backlight/backlight_timer.c
@@ -14,14 +14,14 @@ static uint16_t backlight_timer_get_duty(void);
14 14
15// See http://jared.geek.nz/2013/feb/linear-led-pwm 15// See http://jared.geek.nz/2013/feb/linear-led-pwm
16static uint16_t cie_lightness(uint16_t v) { 16static uint16_t cie_lightness(uint16_t v) {
17 if (v <= 5243) // if below 8% of max 17 if (v <= 5243) // if below 8% of max
18 return v / 9; // same as dividing by 900% 18 return v / 9; // same as dividing by 900%
19 else { 19 else {
20 uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare 20 uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
21 // to get a useful result with integer division, we shift left in the expression above 21 // to get a useful result with integer division, we shift left in the expression above
22 // and revert what we've done again after squaring. 22 // and revert what we've done again after squaring.
23 y = y * y * y >> 8; 23 y = y * y * y >> 8;
24 if (y > 0xFFFFUL) // prevent overflow 24 if (y > 0xFFFFUL) // prevent overflow
25 return 0xFFFFU; 25 return 0xFFFFU;
26 else 26 else
27 return (uint16_t)y; 27 return (uint16_t)y;
@@ -61,7 +61,9 @@ static void backlight_timer_top(void) {
61 } 61 }
62} 62}
63 63
64static void backlight_timer_cmp(void) { backlight_pins_off(); } 64static void backlight_timer_cmp(void) {
65 backlight_pins_off();
66}
65 67
66void backlight_task(void) {} 68void backlight_task(void) {}
67 69
@@ -77,7 +79,9 @@ static uint16_t breathing_counter = 0;
77static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 79static const uint8_t breathing_table[BREATHING_STEPS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
78 80
79// Use this before the cie_lightness function. 81// Use this before the cie_lightness function.
80static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); } 82static inline uint16_t scale_backlight(uint16_t v) {
83 return v / BACKLIGHT_LEVELS * get_backlight_level();
84}
81 85
82void breathing_task(void) { 86void breathing_task(void) {
83 uint8_t breathing_period = get_breathing_period(); 87 uint8_t breathing_period = get_breathing_period();
@@ -91,13 +95,17 @@ void breathing_task(void) {
91 backlight_timer_set_duty(cie_lightness(scale_backlight((uint16_t)breathing_table[index] * 256))); 95 backlight_timer_set_duty(cie_lightness(scale_backlight((uint16_t)breathing_table[index] * 256)));
92} 96}
93 97
94bool is_breathing(void) { return breathing; } 98bool is_breathing(void) {
99 return breathing;
100}
95 101
96void breathing_enable(void) { 102void breathing_enable(void) {
97 breathing_counter = 0; 103 breathing_counter = 0;
98 breathing = true; 104 breathing = true;
99} 105}
100void breathing_disable(void) { breathing = false; } 106void breathing_disable(void) {
107 breathing = false;
108}
101 109
102void breathing_pulse(void) { 110void breathing_pulse(void) {
103 backlight_set(is_backlight_enabled() ? 0 : BACKLIGHT_LEVELS); 111 backlight_set(is_backlight_enabled() ? 0 : BACKLIGHT_LEVELS);
@@ -140,8 +148,12 @@ static void timerCallback(void) {
140 } 148 }
141} 149}
142 150
143static void backlight_timer_set_duty(uint16_t duty) { s_duty = duty; } 151static void backlight_timer_set_duty(uint16_t duty) {
144static uint16_t backlight_timer_get_duty(void) { return s_duty; } 152 s_duty = duty;
153}
154static uint16_t backlight_timer_get_duty(void) {
155 return s_duty;
156}
145 157
146// ChibiOS - Map GPT timer onto Software PWM 158// ChibiOS - Map GPT timer onto Software PWM
147static void gptTimerCallback(GPTDriver *gptp) { 159static void gptTimerCallback(GPTDriver *gptp) {
diff --git a/quantum/bitwise.c b/quantum/bitwise.c
index 861cca0054..1868e14932 100644
--- a/quantum/bitwise.c
+++ b/quantum/bitwise.c
@@ -20,7 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20// bit population - return number of on-bit 20// bit population - return number of on-bit
21__attribute__((noinline)) uint8_t bitpop(uint8_t bits) { 21__attribute__((noinline)) uint8_t bitpop(uint8_t bits) {
22 uint8_t c; 22 uint8_t c;
23 for (c = 0; bits; c++) bits &= bits - 1; 23 for (c = 0; bits; c++)
24 bits &= bits - 1;
24 return c; 25 return c;
25 /* 26 /*
26 const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; 27 const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
@@ -30,13 +31,15 @@ __attribute__((noinline)) uint8_t bitpop(uint8_t bits) {
30 31
31uint8_t bitpop16(uint16_t bits) { 32uint8_t bitpop16(uint16_t bits) {
32 uint8_t c; 33 uint8_t c;
33 for (c = 0; bits; c++) bits &= bits - 1; 34 for (c = 0; bits; c++)
35 bits &= bits - 1;
34 return c; 36 return c;
35} 37}
36 38
37uint8_t bitpop32(uint32_t bits) { 39uint8_t bitpop32(uint32_t bits) {
38 uint8_t c; 40 uint8_t c;
39 for (c = 0; bits; c++) bits &= bits - 1; 41 for (c = 0; bits; c++)
42 bits &= bits - 1;
40 return c; 43 return c;
41} 44}
42 45
diff --git a/quantum/bootmagic/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c
index 54bbf5a2ee..f63c71fc6b 100644
--- a/quantum/bootmagic/bootmagic_lite.c
+++ b/quantum/bootmagic/bootmagic_lite.c
@@ -19,7 +19,9 @@
19 * 19 *
20 * ...just incase someone wants to only change the eeprom behaviour 20 * ...just incase someone wants to only change the eeprom behaviour
21 */ 21 */
22__attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { eeconfig_disable(); } 22__attribute__((weak)) void bootmagic_lite_reset_eeprom(void) {
23 eeconfig_disable();
24}
23 25
24/** \brief The lite version of TMK's bootmagic based on Wilba. 26/** \brief The lite version of TMK's bootmagic based on Wilba.
25 * 27 *
@@ -57,4 +59,6 @@ __attribute__((weak)) void bootmagic_lite(void) {
57 } 59 }
58} 60}
59 61
60void bootmagic(void) { bootmagic_lite(); } 62void bootmagic(void) {
63 bootmagic_lite();
64}
diff --git a/quantum/color.c b/quantum/color.c
index 1c5128e4a2..c80078dbf2 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -104,7 +104,9 @@ RGB hsv_to_rgb(HSV hsv) {
104#endif 104#endif
105} 105}
106 106
107RGB hsv_to_rgb_nocie(HSV hsv) { return hsv_to_rgb_impl(hsv, false); } 107RGB hsv_to_rgb_nocie(HSV hsv) {
108 return hsv_to_rgb_impl(hsv, false);
109}
108 110
109#ifdef RGBW 111#ifdef RGBW
110# ifndef MIN 112# ifndef MIN
diff --git a/quantum/command.c b/quantum/command.c
index 6d56a25ea1..f90d73207c 100644
--- a/quantum/command.c
+++ b/quantum/command.c
@@ -446,7 +446,7 @@ static bool command_common(uint8_t code) {
446 446
447 // NKRO toggle 447 // NKRO toggle
448 case MAGIC_KC(MAGIC_KEY_NKRO): 448 case MAGIC_KC(MAGIC_KEY_NKRO):
449 clear_keyboard(); // clear to prevent stuck keys 449 clear_keyboard(); // clear to prevent stuck keys
450 keymap_config.nkro = !keymap_config.nkro; 450 keymap_config.nkro = !keymap_config.nkro;
451 if (keymap_config.nkro) { 451 if (keymap_config.nkro) {
452 print("NKRO: on\n"); 452 print("NKRO: on\n");
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c
index 8cac1c37f9..47450992a4 100644
--- a/quantum/debounce/sym_defer_g.c
+++ b/quantum/debounce/sym_defer_g.c
@@ -45,6 +45,6 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
45} 45}
46 46
47void debounce_free(void) {} 47void debounce_free(void) {}
48#else // no debouncing. 48#else // no debouncing.
49# include "none.c" 49# include "none.c"
50#endif 50#endif
diff --git a/quantum/debounce/sym_defer_pr.c b/quantum/debounce/sym_defer_pr.c
index 8b33acc6a2..ce24f0922f 100644
--- a/quantum/debounce/sym_defer_pr.c
+++ b/quantum/debounce/sym_defer_pr.c
@@ -69,4 +69,6 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
69 } 69 }
70} 70}
71 71
72bool debounce_active(void) { return true; } 72bool debounce_active(void) {
73 return true;
74}
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c
index deec463649..fe3e88bb06 100644
--- a/quantum/debounce/sym_eager_pk.c
+++ b/quantum/debounce/sym_eager_pk.c
@@ -131,7 +131,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
131 if (*debounce_pointer == DEBOUNCE_ELAPSED) { 131 if (*debounce_pointer == DEBOUNCE_ELAPSED) {
132 *debounce_pointer = DEBOUNCE; 132 *debounce_pointer = DEBOUNCE;
133 counters_need_update = true; 133 counters_need_update = true;
134 existing_row ^= col_mask; // flip the bit. 134 existing_row ^= col_mask; // flip the bit.
135 } 135 }
136 } 136 }
137 debounce_pointer++; 137 debounce_pointer++;
diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp
index f9414e571d..0d5a7bb766 100644
--- a/quantum/debounce/tests/debounce_test_common.cpp
+++ b/quantum/debounce/tests/debounce_test_common.cpp
@@ -31,7 +31,9 @@ void set_time(uint32_t t);
31void advance_time(uint32_t ms); 31void advance_time(uint32_t ms);
32} 32}
33 33
34void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) { events_.insert(events_.end(), events.begin(), events.end()); } 34void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) {
35 events_.insert(events_.end(), events.begin(), events.end());
36}
35 37
36void DebounceTest::runEvents() { 38void DebounceTest::runEvents() {
37 /* Run the test multiple times, from 1kHz to 10kHz scan rate */ 39 /* Run the test multiple times, from 1kHz to 10kHz scan rate */
diff --git a/quantum/deferred_exec.c b/quantum/deferred_exec.c
index a64b451df2..a0046a9648 100644
--- a/quantum/deferred_exec.c
+++ b/quantum/deferred_exec.c
@@ -157,7 +157,15 @@ void deferred_exec_advanced_task(deferred_executor_t *table, size_t table_count,
157static uint32_t last_deferred_exec_check = 0; 157static uint32_t last_deferred_exec_check = 0;
158static deferred_executor_t basic_executors[MAX_DEFERRED_EXECUTORS] = {0}; 158static deferred_executor_t basic_executors[MAX_DEFERRED_EXECUTORS] = {0};
159 159
160deferred_token defer_exec(uint32_t delay_ms, deferred_exec_callback callback, void *cb_arg) { return defer_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, delay_ms, callback, cb_arg); } 160deferred_token defer_exec(uint32_t delay_ms, deferred_exec_callback callback, void *cb_arg) {
161bool extend_deferred_exec(deferred_token token, uint32_t delay_ms) { return extend_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token, delay_ms); } 161 return defer_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, delay_ms, callback, cb_arg);
162bool cancel_deferred_exec(deferred_token token) { return cancel_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token); } 162}
163void deferred_exec_task(void) { deferred_exec_advanced_task(basic_executors, MAX_DEFERRED_EXECUTORS, &last_deferred_exec_check); } 163bool extend_deferred_exec(deferred_token token, uint32_t delay_ms) {
164 return extend_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token, delay_ms);
165}
166bool cancel_deferred_exec(deferred_token token) {
167 return cancel_deferred_exec_advanced(basic_executors, MAX_DEFERRED_EXECUTORS, token);
168}
169void deferred_exec_task(void) {
170 deferred_exec_advanced_task(basic_executors, MAX_DEFERRED_EXECUTORS, &last_deferred_exec_check);
171}
diff --git a/quantum/digitizer.c b/quantum/digitizer.c
index e299867429..7925129d0c 100644
--- a/quantum/digitizer.c
+++ b/quantum/digitizer.c
@@ -24,9 +24,13 @@ __attribute__((weak)) void digitizer_send(void) {
24 } 24 }
25} 25}
26 26
27__attribute__((weak)) void digitizer_task(void) { digitizer_send(); } 27__attribute__((weak)) void digitizer_task(void) {
28 digitizer_send();
29}
28 30
29digitizer_t digitizer_get_report(void) { return digitizerReport; } 31digitizer_t digitizer_get_report(void) {
32 return digitizerReport;
33}
30 34
31void digitizer_set_report(digitizer_t newDigitizerReport) { 35void digitizer_set_report(digitizer_t newDigitizerReport) {
32 digitizerReport = newDigitizerReport; 36 digitizerReport = newDigitizerReport;
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c
index 133ec85027..eee29aaf91 100644
--- a/quantum/dip_switch.c
+++ b/quantum/dip_switch.c
@@ -52,13 +52,21 @@ static uint16_t scan_count;
52static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; 52static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
53static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0}; 53static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
54 54
55__attribute__((weak)) bool dip_switch_update_user(uint8_t index, bool active) { return true; } 55__attribute__((weak)) bool dip_switch_update_user(uint8_t index, bool active) {
56 return true;
57}
56 58
57__attribute__((weak)) bool dip_switch_update_kb(uint8_t index, bool active) { return dip_switch_update_user(index, active); } 59__attribute__((weak)) bool dip_switch_update_kb(uint8_t index, bool active) {
60 return dip_switch_update_user(index, active);
61}
58 62
59__attribute__((weak)) bool dip_switch_update_mask_user(uint32_t state) { return true; } 63__attribute__((weak)) bool dip_switch_update_mask_user(uint32_t state) {
64 return true;
65}
60 66
61__attribute__((weak)) bool dip_switch_update_mask_kb(uint32_t state) { return dip_switch_update_mask_user(state); } 67__attribute__((weak)) bool dip_switch_update_mask_kb(uint32_t state) {
68 return dip_switch_update_mask_user(state);
69}
62 70
63void dip_switch_init(void) { 71void dip_switch_init(void) {
64#ifdef DIP_SWITCH_PINS 72#ifdef DIP_SWITCH_PINS
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 8f1f39bc0f..f070375ff3 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -14,12 +14,12 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include "keymap.h" // to get keymaps[][][] 17#include "keymap.h" // to get keymaps[][][]
18#include "eeprom.h" 18#include "eeprom.h"
19#include "progmem.h" // to read default from flash 19#include "progmem.h" // to read default from flash
20#include "quantum.h" // for send_string() 20#include "quantum.h" // for send_string()
21#include "dynamic_keymap.h" 21#include "dynamic_keymap.h"
22#include "via.h" // for default VIA_EEPROM_ADDR_END 22#include "via.h" // for default VIA_EEPROM_ADDR_END
23 23
24#ifndef DYNAMIC_KEYMAP_LAYER_COUNT 24#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
25# define DYNAMIC_KEYMAP_LAYER_COUNT 4 25# define DYNAMIC_KEYMAP_LAYER_COUNT 4
@@ -79,7 +79,9 @@
79# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1) 79# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1)
80#endif 80#endif
81 81
82uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; } 82uint8_t dynamic_keymap_get_layer_count(void) {
83 return DYNAMIC_KEYMAP_LAYER_COUNT;
84}
83 85
84void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) { 86void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) {
85 // TODO: optimize this with some left shifts 87 // TODO: optimize this with some left shifts
@@ -151,9 +153,13 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) {
151 } 153 }
152} 154}
153 155
154uint8_t dynamic_keymap_macro_get_count(void) { return DYNAMIC_KEYMAP_MACRO_COUNT; } 156uint8_t dynamic_keymap_macro_get_count(void) {
157 return DYNAMIC_KEYMAP_MACRO_COUNT;
158}
155 159
156uint16_t dynamic_keymap_macro_get_buffer_size(void) { return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; } 160uint16_t dynamic_keymap_macro_get_buffer_size(void) {
161 return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE;
162}
157 163
158void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) { 164void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) {
159 void * source = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); 165 void * source = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset);
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c
index 4c2ad2490c..14cd5887f4 100644
--- a/quantum/eeconfig.c
+++ b/quantum/eeconfig.c
@@ -49,7 +49,7 @@ void eeconfig_init_quantum(void) {
49 eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0); 49 eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0);
50 eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0); 50 eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
51 eeprom_update_byte(EECONFIG_BACKLIGHT, 0); 51 eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
52 eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default 52 eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
53 eeprom_update_dword(EECONFIG_RGBLIGHT, 0); 53 eeprom_update_dword(EECONFIG_RGBLIGHT, 0);
54 eeprom_update_byte(EECONFIG_STENOMODE, 0); 54 eeprom_update_byte(EECONFIG_STENOMODE, 0);
55 eeprom_update_dword(EECONFIG_HAPTIC, 0); 55 eeprom_update_dword(EECONFIG_HAPTIC, 0);
@@ -90,13 +90,17 @@ void eeconfig_init_quantum(void) {
90 * 90 *
91 * FIXME: needs doc 91 * FIXME: needs doc
92 */ 92 */
93void eeconfig_init(void) { eeconfig_init_quantum(); } 93void eeconfig_init(void) {
94 eeconfig_init_quantum();
95}
94 96
95/** \brief eeconfig enable 97/** \brief eeconfig enable
96 * 98 *
97 * FIXME: needs doc 99 * FIXME: needs doc
98 */ 100 */
99void eeconfig_enable(void) { eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); } 101void eeconfig_enable(void) {
102 eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
103}
100 104
101/** \brief eeconfig disable 105/** \brief eeconfig disable
102 * 106 *
@@ -141,29 +145,39 @@ bool eeconfig_is_disabled(void) {
141 * 145 *
142 * FIXME: needs doc 146 * FIXME: needs doc
143 */ 147 */
144uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } 148uint8_t eeconfig_read_debug(void) {
149 return eeprom_read_byte(EECONFIG_DEBUG);
150}
145/** \brief eeconfig update debug 151/** \brief eeconfig update debug
146 * 152 *
147 * FIXME: needs doc 153 * FIXME: needs doc
148 */ 154 */
149void eeconfig_update_debug(uint8_t val) { eeprom_update_byte(EECONFIG_DEBUG, val); } 155void eeconfig_update_debug(uint8_t val) {
156 eeprom_update_byte(EECONFIG_DEBUG, val);
157}
150 158
151/** \brief eeconfig read default layer 159/** \brief eeconfig read default layer
152 * 160 *
153 * FIXME: needs doc 161 * FIXME: needs doc
154 */ 162 */
155uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } 163uint8_t eeconfig_read_default_layer(void) {
164 return eeprom_read_byte(EECONFIG_DEFAULT_LAYER);
165}
156/** \brief eeconfig update default layer 166/** \brief eeconfig update default layer
157 * 167 *
158 * FIXME: needs doc 168 * FIXME: needs doc
159 */ 169 */
160void eeconfig_update_default_layer(uint8_t val) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); } 170void eeconfig_update_default_layer(uint8_t val) {
171 eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val);
172}
161 173
162/** \brief eeconfig read keymap 174/** \brief eeconfig read keymap
163 * 175 *
164 * FIXME: needs doc 176 * FIXME: needs doc
165 */ 177 */
166uint16_t eeconfig_read_keymap(void) { return (eeprom_read_byte(EECONFIG_KEYMAP_LOWER_BYTE) | (eeprom_read_byte(EECONFIG_KEYMAP_UPPER_BYTE) << 8)); } 178uint16_t eeconfig_read_keymap(void) {
179 return (eeprom_read_byte(EECONFIG_KEYMAP_LOWER_BYTE) | (eeprom_read_byte(EECONFIG_KEYMAP_UPPER_BYTE) << 8));
180}
167/** \brief eeconfig update keymap 181/** \brief eeconfig update keymap
168 * 182 *
169 * FIXME: needs doc 183 * FIXME: needs doc
@@ -177,53 +191,73 @@ void eeconfig_update_keymap(uint16_t val) {
177 * 191 *
178 * FIXME: needs doc 192 * FIXME: needs doc
179 */ 193 */
180uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); } 194uint8_t eeconfig_read_audio(void) {
195 return eeprom_read_byte(EECONFIG_AUDIO);
196}
181/** \brief eeconfig update audio 197/** \brief eeconfig update audio
182 * 198 *
183 * FIXME: needs doc 199 * FIXME: needs doc
184 */ 200 */
185void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); } 201void eeconfig_update_audio(uint8_t val) {
202 eeprom_update_byte(EECONFIG_AUDIO, val);
203}
186 204
187/** \brief eeconfig read kb 205/** \brief eeconfig read kb
188 * 206 *
189 * FIXME: needs doc 207 * FIXME: needs doc
190 */ 208 */
191uint32_t eeconfig_read_kb(void) { return eeprom_read_dword(EECONFIG_KEYBOARD); } 209uint32_t eeconfig_read_kb(void) {
210 return eeprom_read_dword(EECONFIG_KEYBOARD);
211}
192/** \brief eeconfig update kb 212/** \brief eeconfig update kb
193 * 213 *
194 * FIXME: needs doc 214 * FIXME: needs doc
195 */ 215 */
196void eeconfig_update_kb(uint32_t val) { eeprom_update_dword(EECONFIG_KEYBOARD, val); } 216void eeconfig_update_kb(uint32_t val) {
217 eeprom_update_dword(EECONFIG_KEYBOARD, val);
218}
197 219
198/** \brief eeconfig read user 220/** \brief eeconfig read user
199 * 221 *
200 * FIXME: needs doc 222 * FIXME: needs doc
201 */ 223 */
202uint32_t eeconfig_read_user(void) { return eeprom_read_dword(EECONFIG_USER); } 224uint32_t eeconfig_read_user(void) {
225 return eeprom_read_dword(EECONFIG_USER);
226}
203/** \brief eeconfig update user 227/** \brief eeconfig update user
204 * 228 *
205 * FIXME: needs doc 229 * FIXME: needs doc
206 */ 230 */
207void eeconfig_update_user(uint32_t val) { eeprom_update_dword(EECONFIG_USER, val); } 231void eeconfig_update_user(uint32_t val) {
232 eeprom_update_dword(EECONFIG_USER, val);
233}
208 234
209/** \brief eeconfig read haptic 235/** \brief eeconfig read haptic
210 * 236 *
211 * FIXME: needs doc 237 * FIXME: needs doc
212 */ 238 */
213uint32_t eeconfig_read_haptic(void) { return eeprom_read_dword(EECONFIG_HAPTIC); } 239uint32_t eeconfig_read_haptic(void) {
240 return eeprom_read_dword(EECONFIG_HAPTIC);
241}
214/** \brief eeconfig update haptic 242/** \brief eeconfig update haptic
215 * 243 *
216 * FIXME: needs doc 244 * FIXME: needs doc
217 */ 245 */
218void eeconfig_update_haptic(uint32_t val) { eeprom_update_dword(EECONFIG_HAPTIC, val); } 246void eeconfig_update_haptic(uint32_t val) {
247 eeprom_update_dword(EECONFIG_HAPTIC, val);
248}
219 249
220/** \brief eeconfig read split handedness 250/** \brief eeconfig read split handedness
221 * 251 *
222 * FIXME: needs doc 252 * FIXME: needs doc
223 */ 253 */
224bool eeconfig_read_handedness(void) { return !!eeprom_read_byte(EECONFIG_HANDEDNESS); } 254bool eeconfig_read_handedness(void) {
255 return !!eeprom_read_byte(EECONFIG_HANDEDNESS);
256}
225/** \brief eeconfig update split handedness 257/** \brief eeconfig update split handedness
226 * 258 *
227 * FIXME: needs doc 259 * FIXME: needs doc
228 */ 260 */
229void eeconfig_update_handedness(bool val) { eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); } 261void eeconfig_update_handedness(bool val) {
262 eeprom_update_byte(EECONFIG_HANDEDNESS, !!val);
263}
diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h
index 22d874273c..f3cd1867ab 100644
--- a/quantum/eeconfig.h
+++ b/quantum/eeconfig.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <stdbool.h> 21#include <stdbool.h>
22 22
23#ifndef EECONFIG_MAGIC_NUMBER 23#ifndef EECONFIG_MAGIC_NUMBER
24# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE9 // When changing, decrement this value to avoid future re-init issues 24# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE9 // When changing, decrement this value to avoid future re-init issues
25#endif 25#endif
26#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF 26#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
27 27
@@ -112,28 +112,30 @@ void eeconfig_update_haptic(uint32_t val);
112bool eeconfig_read_handedness(void); 112bool eeconfig_read_handedness(void);
113void eeconfig_update_handedness(bool val); 113void eeconfig_update_handedness(bool val);
114 114
115#define EECONFIG_DEBOUNCE_HELPER(name, offset, config) \ 115#define EECONFIG_DEBOUNCE_HELPER(name, offset, config) \
116 static uint8_t dirty_##name = false; \ 116 static uint8_t dirty_##name = false; \
117 \ 117 \
118 static inline void eeconfig_init_##name(void) { \ 118 static inline void eeconfig_init_##name(void) { \
119 eeprom_read_block(&config, offset, sizeof(config)); \ 119 eeprom_read_block(&config, offset, sizeof(config)); \
120 dirty_##name = false; \ 120 dirty_##name = false; \
121 } \ 121 } \
122 static inline void eeconfig_flush_##name(bool force) { \ 122 static inline void eeconfig_flush_##name(bool force) { \
123 if (force || dirty_##name) { \ 123 if (force || dirty_##name) { \
124 eeprom_update_block(&config, offset, sizeof(config)); \ 124 eeprom_update_block(&config, offset, sizeof(config)); \
125 dirty_##name = false; \ 125 dirty_##name = false; \
126 } \ 126 } \
127 } \ 127 } \
128 static inline void eeconfig_flush_##name##_task(uint16_t timeout) { \ 128 static inline void eeconfig_flush_##name##_task(uint16_t timeout) { \
129 static uint16_t flush_timer = 0; \ 129 static uint16_t flush_timer = 0; \
130 if (timer_elapsed(flush_timer) > timeout) { \ 130 if (timer_elapsed(flush_timer) > timeout) { \
131 eeconfig_flush_##name(false); \ 131 eeconfig_flush_##name(false); \
132 flush_timer = timer_read(); \ 132 flush_timer = timer_read(); \
133 } \ 133 } \
134 } \ 134 } \
135 static inline void eeconfig_flag_##name(bool v) { dirty_##name |= v; } \ 135 static inline void eeconfig_flag_##name(bool v) { \
136 static inline void eeconfig_write_##name(typeof(config) conf) { \ 136 dirty_##name |= v; \
137 memcpy(&config, &conf, sizeof(config)); \ 137 } \
138 eeconfig_flag_##name(true); \ 138 static inline void eeconfig_write_##name(typeof(config) conf) { \
139 memcpy(&config, &conf, sizeof(config)); \
140 eeconfig_flag_##name(true); \
139 } 141 }
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 8fb87281c2..59133f872a 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -59,9 +59,13 @@ static uint8_t thisHand, thatHand;
59static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; 59static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
60#endif 60#endif
61 61
62__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; } 62__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) {
63 return true;
64}
63 65
64__attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); } 66__attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) {
67 return encoder_update_user(index, clockwise);
68}
65 69
66void encoder_init(void) { 70void encoder_init(void) {
67#if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT) 71#if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT)
@@ -113,7 +117,7 @@ static bool encoder_update(uint8_t index, uint8_t state) {
113 changed = true; 117 changed = true;
114 encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); 118 encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE);
115 } 119 }
116 if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise 120 if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise
117 encoder_value[index]--; 121 encoder_value[index]--;
118 changed = true; 122 changed = true;
119 encoder_update_kb(index, ENCODER_CLOCKWISE); 123 encoder_update_kb(index, ENCODER_CLOCKWISE);
@@ -140,7 +144,9 @@ bool encoder_read(void) {
140#ifdef SPLIT_KEYBOARD 144#ifdef SPLIT_KEYBOARD
141void last_encoder_activity_trigger(void); 145void last_encoder_activity_trigger(void);
142 146
143void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, &encoder_value[thisHand], sizeof(uint8_t) * NUMBER_OF_ENCODERS); } 147void encoder_state_raw(uint8_t* slave_state) {
148 memcpy(slave_state, &encoder_value[thisHand], sizeof(uint8_t) * NUMBER_OF_ENCODERS);
149}
144 150
145void encoder_update_raw(uint8_t* slave_state) { 151void encoder_update_raw(uint8_t* slave_state) {
146 bool changed = false; 152 bool changed = false;
diff --git a/quantum/encoder/tests/mock.c b/quantum/encoder/tests/mock.c
index d0506a938f..10a00cb8f2 100644
--- a/quantum/encoder/tests/mock.c
+++ b/quantum/encoder/tests/mock.c
@@ -26,7 +26,9 @@ uint8_t mockSetPinInputHigh(pin_t pin) {
26 return 0; 26 return 0;
27} 27}
28 28
29bool mockReadPin(pin_t pin) { return pins[pin]; } 29bool mockReadPin(pin_t pin) {
30 return pins[pin];
31}
30 32
31bool setPin(pin_t pin, bool val) { 33bool setPin(pin_t pin, bool val) {
32 pins[pin] = val; 34 pins[pin] = val;
diff --git a/quantum/encoder/tests/mock_split.c b/quantum/encoder/tests/mock_split.c
index 68bf3af599..dd3c26d958 100644
--- a/quantum/encoder/tests/mock_split.c
+++ b/quantum/encoder/tests/mock_split.c
@@ -26,7 +26,9 @@ uint8_t mockSetPinInputHigh(pin_t pin) {
26 return 0; 26 return 0;
27} 27}
28 28
29bool mockReadPin(pin_t pin) { return pins[pin]; } 29bool mockReadPin(pin_t pin) {
30 return pins[pin];
31}
30 32
31bool setPin(pin_t pin, bool val) { 33bool setPin(pin_t pin, bool val) {
32 pins[pin] = val; 34 pins[pin] = val;
diff --git a/quantum/haptic.c b/quantum/haptic.c
index f915acf946..31d1114806 100644
--- a/quantum/haptic.c
+++ b/quantum/haptic.c
@@ -247,7 +247,9 @@ void haptic_set_dwell(uint8_t dwell) {
247 xprintf("haptic_config.dwell = %u\n", haptic_config.dwell); 247 xprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
248} 248}
249 249
250uint8_t haptic_get_enable(void) { return haptic_config.enable; } 250uint8_t haptic_get_enable(void) {
251 return haptic_config.enable;
252}
251 253
252uint8_t haptic_get_mode(void) { 254uint8_t haptic_get_mode(void) {
253 if (!haptic_config.enable) { 255 if (!haptic_config.enable) {
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index 6bb2800910..ba5609f0aa 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -110,18 +110,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
110#endif 110#endif
111 111
112static uint32_t last_input_modification_time = 0; 112static uint32_t last_input_modification_time = 0;
113uint32_t last_input_activity_time(void) { return last_input_modification_time; } 113uint32_t last_input_activity_time(void) {
114uint32_t last_input_activity_elapsed(void) { return timer_elapsed32(last_input_modification_time); } 114 return last_input_modification_time;
115}
116uint32_t last_input_activity_elapsed(void) {
117 return timer_elapsed32(last_input_modification_time);
118}
115 119
116static uint32_t last_matrix_modification_time = 0; 120static uint32_t last_matrix_modification_time = 0;
117uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } 121uint32_t last_matrix_activity_time(void) {
118uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } 122 return last_matrix_modification_time;
119void last_matrix_activity_trigger(void) { last_matrix_modification_time = last_input_modification_time = timer_read32(); } 123}
124uint32_t last_matrix_activity_elapsed(void) {
125 return timer_elapsed32(last_matrix_modification_time);
126}
127void last_matrix_activity_trigger(void) {
128 last_matrix_modification_time = last_input_modification_time = timer_read32();
129}
120 130
121static uint32_t last_encoder_modification_time = 0; 131static uint32_t last_encoder_modification_time = 0;
122uint32_t last_encoder_activity_time(void) { return last_encoder_modification_time; } 132uint32_t last_encoder_activity_time(void) {
123uint32_t last_encoder_activity_elapsed(void) { return timer_elapsed32(last_encoder_modification_time); } 133 return last_encoder_modification_time;
124void last_encoder_activity_trigger(void) { last_encoder_modification_time = last_input_modification_time = timer_read32(); } 134}
135uint32_t last_encoder_activity_elapsed(void) {
136 return timer_elapsed32(last_encoder_modification_time);
137}
138void last_encoder_activity_trigger(void) {
139 last_encoder_modification_time = last_input_modification_time = timer_read32();
140}
125 141
126// Only enable this if console is enabled to print to 142// Only enable this if console is enabled to print to
127#if defined(DEBUG_MATRIX_SCAN_RATE) 143#if defined(DEBUG_MATRIX_SCAN_RATE)
@@ -143,7 +159,9 @@ void matrix_scan_perf_task(void) {
143 } 159 }
144} 160}
145 161
146uint32_t get_matrix_scan_rate(void) { return last_matrix_scan_count; } 162uint32_t get_matrix_scan_rate(void) {
163 return last_matrix_scan_count;
164}
147#else 165#else
148# define matrix_scan_perf_task() 166# define matrix_scan_perf_task()
149#endif 167#endif
@@ -163,7 +181,7 @@ static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) {
163} 181}
164 182
165static inline bool popcount_more_than_one(matrix_row_t rowdata) { 183static inline bool popcount_more_than_one(matrix_row_t rowdata) {
166 rowdata &= rowdata - 1; // if there are less than two bits (keys) set, rowdata will become zero 184 rowdata &= rowdata - 1; // if there are less than two bits (keys) set, rowdata will become zero
167 return rowdata; 185 return rowdata;
168} 186}
169 187
@@ -220,7 +238,9 @@ __attribute__((weak)) void keyboard_pre_init_user(void) {}
220 * 238 *
221 * FIXME: needs doc 239 * FIXME: needs doc
222 */ 240 */
223__attribute__((weak)) void keyboard_pre_init_kb(void) { keyboard_pre_init_user(); } 241__attribute__((weak)) void keyboard_pre_init_kb(void) {
242 keyboard_pre_init_user();
243}
224 244
225/** \brief keyboard_post_init_user 245/** \brief keyboard_post_init_user
226 * 246 *
@@ -234,7 +254,9 @@ __attribute__((weak)) void keyboard_post_init_user() {}
234 * FIXME: needs doc 254 * FIXME: needs doc
235 */ 255 */
236 256
237__attribute__((weak)) void keyboard_post_init_kb(void) { keyboard_post_init_user(); } 257__attribute__((weak)) void keyboard_post_init_kb(void) {
258 keyboard_post_init_user();
259}
238 260
239/** \brief keyboard_setup 261/** \brief keyboard_setup
240 * 262 *
@@ -258,13 +280,17 @@ void keyboard_setup(void) {
258 * 280 *
259 * FIXME: needs doc 281 * FIXME: needs doc
260 */ 282 */
261__attribute__((weak)) bool is_keyboard_master(void) { return true; } 283__attribute__((weak)) bool is_keyboard_master(void) {
284 return true;
285}
262 286
263/** \brief is_keyboard_left 287/** \brief is_keyboard_left
264 * 288 *
265 * FIXME: needs doc 289 * FIXME: needs doc
266 */ 290 */
267__attribute__((weak)) bool is_keyboard_left(void) { return true; } 291__attribute__((weak)) bool is_keyboard_left(void) {
292 return true;
293}
268 294
269#endif 295#endif
270 296
@@ -273,7 +299,9 @@ __attribute__((weak)) bool is_keyboard_left(void) { return true; }
273 * Override this function if you have a condition where keypresses processing should change: 299 * Override this function if you have a condition where keypresses processing should change:
274 * - splits where the slave side needs to process for rgb/oled functionality 300 * - splits where the slave side needs to process for rgb/oled functionality
275 */ 301 */
276__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); } 302__attribute__((weak)) bool should_process_keypress(void) {
303 return is_keyboard_master();
304}
277 305
278/** \brief housekeeping_task_kb 306/** \brief housekeeping_task_kb
279 * 307 *
diff --git a/quantum/keyboard.h b/quantum/keyboard.h
index 9b0fb3cef8..e122b38264 100644
--- a/quantum/keyboard.h
+++ b/quantum/keyboard.h
@@ -44,13 +44,21 @@ typedef struct {
44 * 1) (time == 0) to handle (keyevent_t){} as empty event 44 * 1) (time == 0) to handle (keyevent_t){} as empty event
45 * 2) Matrix(255, 255) to make TICK event available 45 * 2) Matrix(255, 255) to make TICK event available
46 */ 46 */
47static inline bool IS_NOEVENT(keyevent_t event) { return event.time == 0 || (event.key.row == 255 && event.key.col == 255); } 47static inline bool IS_NOEVENT(keyevent_t event) {
48static inline bool IS_PRESSED(keyevent_t event) { return (!IS_NOEVENT(event) && event.pressed); } 48 return event.time == 0 || (event.key.row == 255 && event.key.col == 255);
49static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && !event.pressed); } 49}
50static inline bool IS_PRESSED(keyevent_t event) {
51 return (!IS_NOEVENT(event) && event.pressed);
52}
53static inline bool IS_RELEASED(keyevent_t event) {
54 return (!IS_NOEVENT(event) && !event.pressed);
55}
50 56
51/* Tick event */ 57/* Tick event */
52#define TICK \ 58#define TICK \
53 (keyevent_t) { .key = (keypos_t){.row = 255, .col = 255}, .pressed = false, .time = (timer_read() | 1) } 59 (keyevent_t) { \
60 .key = (keypos_t){.row = 255, .col = 255}, .pressed = false, .time = (timer_read() | 1) \
61 }
54 62
55/* it runs once at early stage of startup before keyboard_init. */ 63/* it runs once at early stage of startup before keyboard_init. */
56void keyboard_setup(void); 64void keyboard_setup(void);
@@ -68,18 +76,18 @@ void keyboard_pre_init_user(void);
68void keyboard_post_init_kb(void); 76void keyboard_post_init_kb(void);
69void keyboard_post_init_user(void); 77void keyboard_post_init_user(void);
70 78
71void housekeeping_task(void); // To be executed by the main loop in each backend TMK protocol 79void housekeeping_task(void); // To be executed by the main loop in each backend TMK protocol
72void housekeeping_task_kb(void); // To be overridden by keyboard-level code 80void housekeeping_task_kb(void); // To be overridden by keyboard-level code
73void housekeeping_task_user(void); // To be overridden by user/keymap-level code 81void housekeeping_task_user(void); // To be overridden by user/keymap-level code
74 82
75uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity 83uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity
76uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity 84uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity
77 85
78uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity 86uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity
79uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity 87uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity
80 88
81uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity 89uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity
82uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity 90uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity
83 91
84uint32_t get_matrix_scan_rate(void); 92uint32_t get_matrix_scan_rate(void);
85 93
diff --git a/quantum/keycode.h b/quantum/keycode.h
index a932550635..3c80a386d1 100644
--- a/quantum/keycode.h
+++ b/quantum/keycode.h
@@ -251,7 +251,7 @@ enum hid_keyboard_keypad_usage {
251 KC_J, 251 KC_J,
252 KC_K, 252 KC_K,
253 KC_L, 253 KC_L,
254 KC_M, // 0x10 254 KC_M, // 0x10
255 KC_N, 255 KC_N,
256 KC_O, 256 KC_O,
257 KC_P, 257 KC_P,
@@ -267,7 +267,7 @@ enum hid_keyboard_keypad_usage {
267 KC_Z, 267 KC_Z,
268 KC_1, 268 KC_1,
269 KC_2, 269 KC_2,
270 KC_3, // 0x20 270 KC_3, // 0x20
271 KC_4, 271 KC_4,
272 KC_5, 272 KC_5,
273 KC_6, 273 KC_6,
@@ -283,7 +283,7 @@ enum hid_keyboard_keypad_usage {
283 KC_MINUS, 283 KC_MINUS,
284 KC_EQUAL, 284 KC_EQUAL,
285 KC_LEFT_BRACKET, 285 KC_LEFT_BRACKET,
286 KC_RIGHT_BRACKET, // 0x30 286 KC_RIGHT_BRACKET, // 0x30
287 KC_BACKSLASH, 287 KC_BACKSLASH,
288 KC_NONUS_HASH, 288 KC_NONUS_HASH,
289 KC_SEMICOLON, 289 KC_SEMICOLON,
@@ -299,7 +299,7 @@ enum hid_keyboard_keypad_usage {
299 KC_F4, 299 KC_F4,
300 KC_F5, 300 KC_F5,
301 KC_F6, 301 KC_F6,
302 KC_F7, // 0x40 302 KC_F7, // 0x40
303 KC_F8, 303 KC_F8,
304 KC_F9, 304 KC_F9,
305 KC_F10, 305 KC_F10,
@@ -315,7 +315,7 @@ enum hid_keyboard_keypad_usage {
315 KC_END, 315 KC_END,
316 KC_PAGE_DOWN, 316 KC_PAGE_DOWN,
317 KC_RIGHT, 317 KC_RIGHT,
318 KC_LEFT, // 0x50 318 KC_LEFT, // 0x50
319 KC_DOWN, 319 KC_DOWN,
320 KC_UP, 320 KC_UP,
321 KC_NUM_LOCK, 321 KC_NUM_LOCK,
@@ -331,7 +331,7 @@ enum hid_keyboard_keypad_usage {
331 KC_KP_5, 331 KC_KP_5,
332 KC_KP_6, 332 KC_KP_6,
333 KC_KP_7, 333 KC_KP_7,
334 KC_KP_8, // 0x60 334 KC_KP_8, // 0x60
335 KC_KP_9, 335 KC_KP_9,
336 KC_KP_0, 336 KC_KP_0,
337 KC_KP_DOT, 337 KC_KP_DOT,
@@ -347,7 +347,7 @@ enum hid_keyboard_keypad_usage {
347 KC_F18, 347 KC_F18,
348 KC_F19, 348 KC_F19,
349 KC_F20, 349 KC_F20,
350 KC_F21, // 0x70 350 KC_F21, // 0x70
351 KC_F22, 351 KC_F22,
352 KC_F23, 352 KC_F23,
353 KC_F24, 353 KC_F24,
@@ -363,7 +363,7 @@ enum hid_keyboard_keypad_usage {
363 KC_PASTE, 363 KC_PASTE,
364 KC_FIND, 364 KC_FIND,
365 KC_KB_MUTE, 365 KC_KB_MUTE,
366 KC_KB_VOLUME_UP, // 0x80 366 KC_KB_VOLUME_UP, // 0x80
367 KC_KB_VOLUME_DOWN, 367 KC_KB_VOLUME_DOWN,
368 KC_LOCKING_CAPS_LOCK, 368 KC_LOCKING_CAPS_LOCK,
369 KC_LOCKING_NUM_LOCK, 369 KC_LOCKING_NUM_LOCK,
@@ -379,7 +379,7 @@ enum hid_keyboard_keypad_usage {
379 KC_INTERNATIONAL_7, 379 KC_INTERNATIONAL_7,
380 KC_INTERNATIONAL_8, 380 KC_INTERNATIONAL_8,
381 KC_INTERNATIONAL_9, 381 KC_INTERNATIONAL_9,
382 KC_LANGUAGE_1, // 0x90 382 KC_LANGUAGE_1, // 0x90
383 KC_LANGUAGE_2, 383 KC_LANGUAGE_2,
384 KC_LANGUAGE_3, 384 KC_LANGUAGE_3,
385 KC_LANGUAGE_4, 385 KC_LANGUAGE_4,
@@ -395,7 +395,7 @@ enum hid_keyboard_keypad_usage {
395 KC_PRIOR, 395 KC_PRIOR,
396 KC_RETURN, 396 KC_RETURN,
397 KC_SEPARATOR, 397 KC_SEPARATOR,
398 KC_OUT, // 0xA0 398 KC_OUT, // 0xA0
399 KC_OPER, 399 KC_OPER,
400 KC_CLEAR_AGAIN, 400 KC_CLEAR_AGAIN,
401 KC_CRSEL, 401 KC_CRSEL,
@@ -488,7 +488,7 @@ enum internal_special_keycodes {
488 KC_MEDIA_STOP, 488 KC_MEDIA_STOP,
489 KC_MEDIA_PLAY_PAUSE, 489 KC_MEDIA_PLAY_PAUSE,
490 KC_MEDIA_SELECT, 490 KC_MEDIA_SELECT,
491 KC_MEDIA_EJECT, // 0xB0 491 KC_MEDIA_EJECT, // 0xB0
492 KC_MAIL, 492 KC_MAIL,
493 KC_CALCULATOR, 493 KC_CALCULATOR,
494 KC_MY_COMPUTER, 494 KC_MY_COMPUTER,
@@ -514,7 +514,7 @@ enum mouse_keys {
514#endif 514#endif
515 KC_MS_DOWN, 515 KC_MS_DOWN,
516 KC_MS_LEFT, 516 KC_MS_LEFT,
517 KC_MS_RIGHT, // 0xF0 517 KC_MS_RIGHT, // 0xF0
518 KC_MS_BTN1, 518 KC_MS_BTN1,
519 KC_MS_BTN2, 519 KC_MS_BTN2,
520 KC_MS_BTN3, 520 KC_MS_BTN3,
@@ -539,7 +539,7 @@ enum mouse_keys {
539 /* Acceleration */ 539 /* Acceleration */
540 KC_MS_ACCEL0, 540 KC_MS_ACCEL0,
541 KC_MS_ACCEL1, 541 KC_MS_ACCEL1,
542 KC_MS_ACCEL2 // 0xFF 542 KC_MS_ACCEL2 // 0xFF
543}; 543};
544 544
545#include "keycode_legacy.h" 545#include "keycode_legacy.h"
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index cd67f71a8f..a91b2a0b36 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -77,7 +77,7 @@ action_t action_for_keycode(uint16_t keycode) {
77 case QK_MODS ... QK_MODS_MAX:; 77 case QK_MODS ... QK_MODS_MAX:;
78 // Has a modifier 78 // Has a modifier
79 // Split it up 79 // Split it up
80 action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key 80 action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
81 break; 81 break;
82#ifndef NO_ACTION_LAYER 82#ifndef NO_ACTION_LAYER
83 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: 83 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h
index 76d2f4f6b0..55a58a25b0 100644
--- a/quantum/keymap_extras/keymap_nordic.h
+++ b/quantum/keymap_extras/keymap_nordic.h
@@ -24,7 +24,7 @@
24#define NO_ACUT KC_EQL 24#define NO_ACUT KC_EQL
25 25
26#define NO_AM KC_LBRC 26#define NO_AM KC_LBRC
27#define NO_QUOT KC_RBRC // this is the "umlaut" char on Nordic keyboards, Apple layout 27#define NO_QUOT KC_RBRC // this is the "umlaut" char on Nordic keyboards, Apple layout
28#define NO_AE KC_SCLN 28#define NO_AE KC_SCLN
29#define NO_OSLH KC_QUOT 29#define NO_OSLH KC_QUOT
30#define NO_APOS KC_NUHS 30#define NO_APOS KC_NUHS
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h
index 310aa07409..e888ccd643 100644
--- a/quantum/keymap_extras/keymap_steno.h
+++ b/quantum/keymap_extras/keymap_steno.h
@@ -70,7 +70,7 @@ enum steno_keycodes {
70 STN_NB, 70 STN_NB,
71 STN_NC, 71 STN_NC,
72 STN_ZR, 72 STN_ZR,
73 STN__MAX = STN_ZR, // must be less than QK_STENO_BOLT 73 STN__MAX = STN_ZR, // must be less than QK_STENO_BOLT
74}; 74};
75 75
76#ifdef STENO_COMBINEDMAP 76#ifdef STENO_COMBINEDMAP
diff --git a/quantum/led.c b/quantum/led.c
index 7b3f877208..c5ddbc22c5 100644
--- a/quantum/led.c
+++ b/quantum/led.c
@@ -64,13 +64,17 @@ __attribute__((weak)) void led_set_user(uint8_t usb_led) {}
64 * 64 *
65 * \deprecated Use led_update_kb() instead. 65 * \deprecated Use led_update_kb() instead.
66 */ 66 */
67__attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } 67__attribute__((weak)) void led_set_kb(uint8_t usb_led) {
68 led_set_user(usb_led);
69}
68 70
69/** \brief Lock LED update callback - keymap/user level 71/** \brief Lock LED update callback - keymap/user level
70 * 72 *
71 * \return True if led_update_kb() should run its own code, false otherwise. 73 * \return True if led_update_kb() should run its own code, false otherwise.
72 */ 74 */
73__attribute__((weak)) bool led_update_user(led_t led_state) { return true; } 75__attribute__((weak)) bool led_update_user(led_t led_state) {
76 return true;
77}
74 78
75/** \brief Lock LED update callback - keyboard level 79/** \brief Lock LED update callback - keyboard level
76 * 80 *
@@ -156,7 +160,9 @@ void led_suspend(void) {
156 160
157/** \brief Trigger behaviour on transition from suspend 161/** \brief Trigger behaviour on transition from suspend
158 */ 162 */
159void led_wakeup(void) { led_set(host_keyboard_leds()); } 163void led_wakeup(void) {
164 led_set(host_keyboard_leds());
165}
160 166
161/** \brief set host led state 167/** \brief set host led state
162 * 168 *
diff --git a/quantum/led_matrix/animations/alpha_mods_anim.h b/quantum/led_matrix/animations/alpha_mods_anim.h
index 4d017894a1..01acb3f933 100644
--- a/quantum/led_matrix/animations/alpha_mods_anim.h
+++ b/quantum/led_matrix/animations/alpha_mods_anim.h
@@ -20,5 +20,5 @@ bool ALPHAS_MODS(effect_params_t* params) {
20 return led_matrix_check_finished_leds(led_max); 20 return led_matrix_check_finished_leds(led_max);
21} 21}
22 22
23# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 23# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
24#endif // ENABLE_LED_MATRIX_ALPHAS_MODS 24#endif // ENABLE_LED_MATRIX_ALPHAS_MODS
diff --git a/quantum/led_matrix/animations/band_anim.h b/quantum/led_matrix/animations/band_anim.h
index 293be4f67a..d9491849ea 100644
--- a/quantum/led_matrix/animations/band_anim.h
+++ b/quantum/led_matrix/animations/band_anim.h
@@ -7,7 +7,9 @@ static uint8_t BAND_math(uint8_t val, uint8_t i, uint8_t time) {
7 return scale8(v < 0 ? 0 : v, val); 7 return scale8(v < 0 ? 0 : v, val);
8} 8}
9 9
10bool BAND(effect_params_t* params) { return effect_runner_i(params, &BAND_math); } 10bool BAND(effect_params_t* params) {
11 return effect_runner_i(params, &BAND_math);
12}
11 13
12# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_LED_MATRIX_BAND 15#endif // ENABLE_LED_MATRIX_BAND
diff --git a/quantum/led_matrix/animations/band_pinwheel_anim.h b/quantum/led_matrix/animations/band_pinwheel_anim.h
index f47a3869ce..482d183eb6 100644
--- a/quantum/led_matrix/animations/band_pinwheel_anim.h
+++ b/quantum/led_matrix/animations/band_pinwheel_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(BAND_PINWHEEL) 2LED_MATRIX_EFFECT(BAND_PINWHEEL)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t BAND_PINWHEEL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t time) { return scale8(val - time - atan2_8(dy, dx) * 3, val); } 5static uint8_t BAND_PINWHEEL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t time) {
6 return scale8(val - time - atan2_8(dy, dx) * 3, val);
7}
6 8
7bool BAND_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_math); } 9bool BAND_PINWHEEL(effect_params_t* params) {
10 return effect_runner_dx_dy(params, &BAND_PINWHEEL_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_BAND_PINWHEEL 14#endif // ENABLE_LED_MATRIX_BAND_PINWHEEL
diff --git a/quantum/led_matrix/animations/band_spiral_anim.h b/quantum/led_matrix/animations/band_spiral_anim.h
index a4bd382181..ef93d19270 100644
--- a/quantum/led_matrix/animations/band_spiral_anim.h
+++ b/quantum/led_matrix/animations/band_spiral_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(BAND_SPIRAL) 2LED_MATRIX_EFFECT(BAND_SPIRAL)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t BAND_SPIRAL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { return scale8(val + dist - time - atan2_8(dy, dx), val); } 5static uint8_t BAND_SPIRAL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 return scale8(val + dist - time - atan2_8(dy, dx), val);
7}
6 8
7bool BAND_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_math); } 9bool BAND_SPIRAL(effect_params_t* params) {
10 return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_BAND_SPIRAL 14#endif // ENABLE_LED_MATRIX_BAND_SPIRAL
diff --git a/quantum/led_matrix/animations/breathing_anim.h b/quantum/led_matrix/animations/breathing_anim.h
index 899925f516..0bd4cb0cc3 100644
--- a/quantum/led_matrix/animations/breathing_anim.h
+++ b/quantum/led_matrix/animations/breathing_anim.h
@@ -15,5 +15,5 @@ bool BREATHING(effect_params_t* params) {
15 return led_matrix_check_finished_leds(led_max); 15 return led_matrix_check_finished_leds(led_max);
16} 16}
17 17
18# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 18# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
19#endif // ENABLE_LED_MATRIX_BREATHING 19#endif // ENABLE_LED_MATRIX_BREATHING
diff --git a/quantum/led_matrix/animations/cycle_left_right_anim.h b/quantum/led_matrix/animations/cycle_left_right_anim.h
index 1a8999b831..0a339e6d62 100644
--- a/quantum/led_matrix/animations/cycle_left_right_anim.h
+++ b/quantum/led_matrix/animations/cycle_left_right_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(CYCLE_LEFT_RIGHT) 2LED_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t CYCLE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(g_led_config.point[i].x - time, val); } 5static uint8_t CYCLE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(g_led_config.point[i].x - time, val);
7}
6 8
7bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); } 9bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
10 return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_CYCLE_LEFT_RIGHT 14#endif // ENABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
diff --git a/quantum/led_matrix/animations/cycle_out_in_anim.h b/quantum/led_matrix/animations/cycle_out_in_anim.h
index 77d3a14b6f..8311d97fe8 100644
--- a/quantum/led_matrix/animations/cycle_out_in_anim.h
+++ b/quantum/led_matrix/animations/cycle_out_in_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(CYCLE_OUT_IN) 2LED_MATRIX_EFFECT(CYCLE_OUT_IN)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t CYCLE_OUT_IN_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { return scale8(3 * dist / 2 + time, val); } 5static uint8_t CYCLE_OUT_IN_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
6 return scale8(3 * dist / 2 + time, val);
7}
6 8
7bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); } 9bool CYCLE_OUT_IN(effect_params_t* params) {
10 return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_CYCLE_OUT_IN 14#endif // ENABLE_LED_MATRIX_CYCLE_OUT_IN
diff --git a/quantum/led_matrix/animations/cycle_up_down_anim.h b/quantum/led_matrix/animations/cycle_up_down_anim.h
index b25947199c..7e2d71a0f1 100644
--- a/quantum/led_matrix/animations/cycle_up_down_anim.h
+++ b/quantum/led_matrix/animations/cycle_up_down_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(CYCLE_UP_DOWN) 2LED_MATRIX_EFFECT(CYCLE_UP_DOWN)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t CYCLE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(g_led_config.point[i].y - time, val); } 5static uint8_t CYCLE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(g_led_config.point[i].y - time, val);
7}
6 8
7bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); } 9bool CYCLE_UP_DOWN(effect_params_t* params) {
10 return effect_runner_i(params, &CYCLE_UP_DOWN_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_CYCLE_UP_DOWN 14#endif // ENABLE_LED_MATRIX_CYCLE_UP_DOWN
diff --git a/quantum/led_matrix/animations/dual_beacon_anim.h b/quantum/led_matrix/animations/dual_beacon_anim.h
index 81735e323c..1dfb5ffe52 100644
--- a/quantum/led_matrix/animations/dual_beacon_anim.h
+++ b/quantum/led_matrix/animations/dual_beacon_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(DUAL_BEACON) 2LED_MATRIX_EFFECT(DUAL_BEACON)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t DUAL_BEACON_math(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { return scale8(((g_led_config.point[i].y - k_led_matrix_center.y) * cos + (g_led_config.point[i].x - k_led_matrix_center.x) * sin) / 128, val); } 5static uint8_t DUAL_BEACON_math(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
6 return scale8(((g_led_config.point[i].y - k_led_matrix_center.y) * cos + (g_led_config.point[i].x - k_led_matrix_center.x) * sin) / 128, val);
7}
6 8
7bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); } 9bool DUAL_BEACON(effect_params_t* params) {
10 return effect_runner_sin_cos_i(params, &DUAL_BEACON_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_DUAL_BEACON 14#endif // ENABLE_LED_MATRIX_DUAL_BEACON
diff --git a/quantum/led_matrix/animations/runners/effect_runner_reactive.h b/quantum/led_matrix/animations/runners/effect_runner_reactive.h
index be3090aa53..8468458744 100644
--- a/quantum/led_matrix/animations/runners/effect_runner_reactive.h
+++ b/quantum/led_matrix/animations/runners/effect_runner_reactive.h
@@ -25,4 +25,4 @@ bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
25 return led_matrix_check_finished_leds(led_max); 25 return led_matrix_check_finished_leds(led_max);
26} 26}
27 27
28#endif // LED_MATRIX_KEYREACTIVE_ENABLED 28#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h
index f6ffc825a1..aec4a6ffda 100644
--- a/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h
+++ b/quantum/led_matrix/animations/runners/effect_runner_reactive_splash.h
@@ -23,4 +23,4 @@ bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, react
23 return led_matrix_check_finished_leds(led_max); 23 return led_matrix_check_finished_leds(led_max);
24} 24}
25 25
26#endif // LED_MATRIX_KEYREACTIVE_ENABLED 26#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix/animations/solid_anim.h b/quantum/led_matrix/animations/solid_anim.h
index c728dbcc98..895542e152 100644
--- a/quantum/led_matrix/animations/solid_anim.h
+++ b/quantum/led_matrix/animations/solid_anim.h
@@ -12,4 +12,4 @@ bool SOLID(effect_params_t* params) {
12 return led_matrix_check_finished_leds(led_max); 12 return led_matrix_check_finished_leds(led_max);
13} 13}
14 14
15#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 15#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/led_matrix/animations/solid_reactive_cross.h b/quantum/led_matrix/animations/solid_reactive_cross.h
index a149e9a929..55a2556996 100644
--- a/quantum/led_matrix/animations/solid_reactive_cross.h
+++ b/quantum/led_matrix/animations/solid_reactive_cross.h
@@ -23,13 +23,17 @@ static uint8_t SOLID_REACTIVE_CROSS_math(uint8_t val, int16_t dx, int16_t dy, ui
23} 23}
24 24
25# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS 25# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
26bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); } 26bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
27 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math);
28}
27# endif 29# endif
28 30
29# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS 31# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
30bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); } 32bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
33 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math);
34}
31# endif 35# endif
32 36
33# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 37# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
34# endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS) 38# endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS)
35#endif // LED_MATRIX_KEYREACTIVE_ENABLED 39#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix/animations/solid_reactive_nexus.h b/quantum/led_matrix/animations/solid_reactive_nexus.h
index 5a86e48c6c..b1ec54e3b1 100644
--- a/quantum/led_matrix/animations/solid_reactive_nexus.h
+++ b/quantum/led_matrix/animations/solid_reactive_nexus.h
@@ -20,13 +20,17 @@ static uint8_t SOLID_REACTIVE_NEXUS_math(uint8_t val, int16_t dx, int16_t dy, ui
20} 20}
21 21
22# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS 22# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
23bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); } 23bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
24 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math);
25}
24# endif 26# endif
25 27
26# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS 28# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
27bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); } 29bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
30 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math);
31}
28# endif 32# endif
29 33
30# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 34# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
31# endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS) 35# endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS)
32#endif // LED_MATRIX_KEYREACTIVE_ENABLED 36#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix/animations/solid_reactive_simple_anim.h b/quantum/led_matrix/animations/solid_reactive_simple_anim.h
index 14f5e90730..3b289c78dd 100644
--- a/quantum/led_matrix/animations/solid_reactive_simple_anim.h
+++ b/quantum/led_matrix/animations/solid_reactive_simple_anim.h
@@ -3,10 +3,14 @@
3LED_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) 3LED_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
4# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 4# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
5 5
6static uint8_t SOLID_REACTIVE_SIMPLE_math(uint8_t val, uint16_t offset) { return scale8(255 - offset, val); } 6static uint8_t SOLID_REACTIVE_SIMPLE_math(uint8_t val, uint16_t offset) {
7 return scale8(255 - offset, val);
8}
7 9
8bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); } 10bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) {
11 return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math);
12}
9 13
10# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
11# endif // ENABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE 15# endif // ENABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
12#endif // LED_MATRIX_KEYREACTIVE_ENABLED 16#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix/animations/solid_reactive_wide.h b/quantum/led_matrix/animations/solid_reactive_wide.h
index 3aa88063a7..96338113f1 100644
--- a/quantum/led_matrix/animations/solid_reactive_wide.h
+++ b/quantum/led_matrix/animations/solid_reactive_wide.h
@@ -18,13 +18,17 @@ static uint8_t SOLID_REACTIVE_WIDE_math(uint8_t val, int16_t dx, int16_t dy, uin
18} 18}
19 19
20# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE 20# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
21bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); } 21bool SOLID_REACTIVE_WIDE(effect_params_t* params) {
22 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math);
23}
22# endif 24# endif
23 25
24# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE 26# ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
25bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); } 27bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) {
28 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math);
29}
26# endif 30# endif
27 31
28# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 32# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
29# endif // !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE) 33# endif // !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE)
30#endif // LED_MATRIX_KEYREACTIVE_ENABLED 34#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix/animations/solid_splash_anim.h b/quantum/led_matrix/animations/solid_splash_anim.h
index 17b692a09a..b8b6e8ea5e 100644
--- a/quantum/led_matrix/animations/solid_splash_anim.h
+++ b/quantum/led_matrix/animations/solid_splash_anim.h
@@ -18,13 +18,17 @@ uint8_t SOLID_SPLASH_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uin
18} 18}
19 19
20# ifdef ENABLE_LED_MATRIX_SOLID_SPLASH 20# ifdef ENABLE_LED_MATRIX_SOLID_SPLASH
21bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); } 21bool SOLID_SPLASH(effect_params_t* params) {
22 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math);
23}
22# endif 24# endif
23 25
24# ifdef ENABLE_LED_MATRIX_SOLID_MULTISPLASH 26# ifdef ENABLE_LED_MATRIX_SOLID_MULTISPLASH
25bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); } 27bool SOLID_MULTISPLASH(effect_params_t* params) {
28 return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math);
29}
26# endif 30# endif
27 31
28# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 32# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
29# endif // defined(ENABLE_LED_MATRIX_SPLASH) || defined(ENABLE_LED_MATRIX_MULTISPLASH) 33# endif // defined(ENABLE_LED_MATRIX_SPLASH) || defined(ENABLE_LED_MATRIX_MULTISPLASH)
30#endif // LED_MATRIX_KEYREACTIVE_ENABLED 34#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix/animations/wave_left_right_anim.h b/quantum/led_matrix/animations/wave_left_right_anim.h
index 76487f8515..8dedd64738 100644
--- a/quantum/led_matrix/animations/wave_left_right_anim.h
+++ b/quantum/led_matrix/animations/wave_left_right_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(WAVE_LEFT_RIGHT) 2LED_MATRIX_EFFECT(WAVE_LEFT_RIGHT)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t WAVE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(sin8(g_led_config.point[i].x - time), val); } 5static uint8_t WAVE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(sin8(g_led_config.point[i].x - time), val);
7}
6 8
7bool WAVE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &WAVE_LEFT_RIGHT_math); } 9bool WAVE_LEFT_RIGHT(effect_params_t* params) {
10 return effect_runner_i(params, &WAVE_LEFT_RIGHT_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_WAVE_LEFT_RIGHT 14#endif // ENABLE_LED_MATRIX_WAVE_LEFT_RIGHT
diff --git a/quantum/led_matrix/animations/wave_up_down_anim.h b/quantum/led_matrix/animations/wave_up_down_anim.h
index 94710f5c6e..4564f3e493 100644
--- a/quantum/led_matrix/animations/wave_up_down_anim.h
+++ b/quantum/led_matrix/animations/wave_up_down_anim.h
@@ -2,9 +2,13 @@
2LED_MATRIX_EFFECT(WAVE_UP_DOWN) 2LED_MATRIX_EFFECT(WAVE_UP_DOWN)
3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS 3# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
4 4
5static uint8_t WAVE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(sin8(g_led_config.point[i].y - time), val); } 5static uint8_t WAVE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) {
6 return scale8(sin8(g_led_config.point[i].y - time), val);
7}
6 8
7bool WAVE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &WAVE_UP_DOWN_math); } 9bool WAVE_UP_DOWN(effect_params_t* params) {
10 return effect_runner_i(params, &WAVE_UP_DOWN_math);
11}
8 12
9# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS 13# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
10#endif // ENABLE_LED_MATRIX_WAVE_UP_DOWN 14#endif // ENABLE_LED_MATRIX_WAVE_UP_DOWN
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c
index be1494e884..38ed79bed0 100644
--- a/quantum/led_matrix/led_matrix.c
+++ b/quantum/led_matrix/led_matrix.c
@@ -88,14 +88,14 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER;
88#endif 88#endif
89 89
90// globals 90// globals
91led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr 91led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
92uint32_t g_led_timer; 92uint32_t g_led_timer;
93#ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS 93#ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS
94uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; 94uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
95#endif // LED_MATRIX_FRAMEBUFFER_EFFECTS 95#endif // LED_MATRIX_FRAMEBUFFER_EFFECTS
96#ifdef LED_MATRIX_KEYREACTIVE_ENABLED 96#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
97last_hit_t g_last_hit_tracker; 97last_hit_t g_last_hit_tracker;
98#endif // LED_MATRIX_KEYREACTIVE_ENABLED 98#endif // LED_MATRIX_KEYREACTIVE_ENABLED
99 99
100// internals 100// internals
101static bool suspend_state = false; 101static bool suspend_state = false;
@@ -105,13 +105,13 @@ static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
105static led_task_states led_task_state = SYNCING; 105static led_task_states led_task_state = SYNCING;
106#if LED_DISABLE_TIMEOUT > 0 106#if LED_DISABLE_TIMEOUT > 0
107static uint32_t led_anykey_timer; 107static uint32_t led_anykey_timer;
108#endif // LED_DISABLE_TIMEOUT > 0 108#endif // LED_DISABLE_TIMEOUT > 0
109 109
110// double buffers 110// double buffers
111static uint32_t led_timer_buffer; 111static uint32_t led_timer_buffer;
112#ifdef LED_MATRIX_KEYREACTIVE_ENABLED 112#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
113static last_hit_t last_hit_buffer; 113static last_hit_t last_hit_buffer;
114#endif // LED_MATRIX_KEYREACTIVE_ENABLED 114#endif // LED_MATRIX_KEYREACTIVE_ENABLED
115 115
116// split led matrix 116// split led matrix
117#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 117#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
@@ -120,7 +120,9 @@ const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
120 120
121EECONFIG_DEBOUNCE_HELPER(led_matrix, EECONFIG_LED_MATRIX, led_matrix_eeconfig); 121EECONFIG_DEBOUNCE_HELPER(led_matrix, EECONFIG_LED_MATRIX, led_matrix_eeconfig);
122 122
123void eeconfig_update_led_matrix(void) { eeconfig_flush_led_matrix(true); } 123void eeconfig_update_led_matrix(void) {
124 eeconfig_flush_led_matrix(true);
125}
124 126
125void eeconfig_update_led_matrix_default(void) { 127void eeconfig_update_led_matrix_default(void) {
126 dprintf("eeconfig_update_led_matrix_default\n"); 128 dprintf("eeconfig_update_led_matrix_default\n");
@@ -141,7 +143,9 @@ void eeconfig_debug_led_matrix(void) {
141 dprintf("led_matrix_eeconfig.flags = %d\n", led_matrix_eeconfig.flags); 143 dprintf("led_matrix_eeconfig.flags = %d\n", led_matrix_eeconfig.flags);
142} 144}
143 145
144__attribute__((weak)) uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } 146__attribute__((weak)) uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) {
147 return 0;
148}
145 149
146uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { 150uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
147 uint8_t led_count = led_matrix_map_row_column_to_led_kb(row, column, led_i); 151 uint8_t led_count = led_matrix_map_row_column_to_led_kb(row, column, led_i);
@@ -153,7 +157,9 @@ uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
153 return led_count; 157 return led_count;
154} 158}
155 159
156void led_matrix_update_pwm_buffers(void) { led_matrix_driver.flush(); } 160void led_matrix_update_pwm_buffers(void) {
161 led_matrix_driver.flush();
162}
157 163
158void led_matrix_set_value(int index, uint8_t value) { 164void led_matrix_set_value(int index, uint8_t value) {
159#ifdef USE_CIE1931_CURVE 165#ifdef USE_CIE1931_CURVE
@@ -164,7 +170,8 @@ void led_matrix_set_value(int index, uint8_t value) {
164 170
165void led_matrix_set_value_all(uint8_t value) { 171void led_matrix_set_value_all(uint8_t value) {
166#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 172#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
167 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) led_matrix_set_value(i, value); 173 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++)
174 led_matrix_set_value(i, value);
168#else 175#else
169# ifdef USE_CIE1931_CURVE 176# ifdef USE_CIE1931_CURVE
170 led_matrix_driver.set_value_all(pgm_read_byte(&CIE1931_CURVE[value])); 177 led_matrix_driver.set_value_all(pgm_read_byte(&CIE1931_CURVE[value]));
@@ -180,7 +187,7 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) {
180#endif 187#endif
181#if LED_DISABLE_TIMEOUT > 0 188#if LED_DISABLE_TIMEOUT > 0
182 led_anykey_timer = 0; 189 led_anykey_timer = 0;
183#endif // LED_DISABLE_TIMEOUT > 0 190#endif // LED_DISABLE_TIMEOUT > 0
184 191
185#ifdef LED_MATRIX_KEYREACTIVE_ENABLED 192#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
186 uint8_t led[LED_HITS_TO_REMEMBER]; 193 uint8_t led[LED_HITS_TO_REMEMBER];
@@ -190,7 +197,7 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) {
190 if (!pressed) 197 if (!pressed)
191# elif defined(LED_MATRIX_KEYPRESSES) 198# elif defined(LED_MATRIX_KEYPRESSES)
192 if (pressed) 199 if (pressed)
193# endif // defined(LED_MATRIX_KEYRELEASES) 200# endif // defined(LED_MATRIX_KEYRELEASES)
194 { 201 {
195 led_count = led_matrix_map_row_column_to_led(row, col, led); 202 led_count = led_matrix_map_row_column_to_led(row, col, led);
196 } 203 }
@@ -198,7 +205,7 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) {
198 if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { 205 if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
199 memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); 206 memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count);
200 memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); 207 memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count);
201 memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit 208 memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit
202 memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); 209 memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count);
203 last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; 210 last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count;
204 } 211 }
@@ -211,13 +218,13 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) {
211 last_hit_buffer.tick[index] = 0; 218 last_hit_buffer.tick[index] = 0;
212 last_hit_buffer.count++; 219 last_hit_buffer.count++;
213 } 220 }
214#endif // LED_MATRIX_KEYREACTIVE_ENABLED 221#endif // LED_MATRIX_KEYREACTIVE_ENABLED
215 222
216#if defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP) 223#if defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP)
217 if (led_matrix_eeconfig.mode == LED_MATRIX_TYPING_HEATMAP) { 224 if (led_matrix_eeconfig.mode == LED_MATRIX_TYPING_HEATMAP) {
218 process_led_matrix_typing_heatmap(row, col); 225 process_led_matrix_typing_heatmap(row, col);
219 } 226 }
220#endif // defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP) 227#endif // defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP)
221} 228}
222 229
223static bool led_matrix_none(effect_params_t *params) { 230static bool led_matrix_none(effect_params_t *params) {
@@ -232,7 +239,7 @@ static bool led_matrix_none(effect_params_t *params) {
232static void led_task_timers(void) { 239static void led_task_timers(void) {
233#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 240#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0
234 uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); 241 uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer);
235#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 242#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0
236 led_timer_buffer = sync_timer_read32(); 243 led_timer_buffer = sync_timer_read32();
237 244
238 // Update double buffer timers 245 // Update double buffer timers
@@ -244,7 +251,7 @@ static void led_task_timers(void) {
244 led_anykey_timer += deltaTime; 251 led_anykey_timer += deltaTime;
245 } 252 }
246 } 253 }
247#endif // LED_DISABLE_TIMEOUT > 0 254#endif // LED_DISABLE_TIMEOUT > 0
248 255
249 // Update double buffer last hit timers 256 // Update double buffer last hit timers
250#ifdef LED_MATRIX_KEYREACTIVE_ENABLED 257#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
@@ -256,7 +263,7 @@ static void led_task_timers(void) {
256 } 263 }
257 last_hit_buffer.tick[i] += deltaTime; 264 last_hit_buffer.tick[i] += deltaTime;
258 } 265 }
259#endif // LED_MATRIX_KEYREACTIVE_ENABLED 266#endif // LED_MATRIX_KEYREACTIVE_ENABLED
260} 267}
261 268
262static void led_task_sync(void) { 269static void led_task_sync(void) {
@@ -273,7 +280,7 @@ static void led_task_start(void) {
273 g_led_timer = led_timer_buffer; 280 g_led_timer = led_timer_buffer;
274#ifdef LED_MATRIX_KEYREACTIVE_ENABLED 281#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
275 g_last_hit_tracker = last_hit_buffer; 282 g_last_hit_tracker = last_hit_buffer;
276#endif // LED_MATRIX_KEYREACTIVE_ENABLED 283#endif // LED_MATRIX_KEYREACTIVE_ENABLED
277 284
278 // next task 285 // next task
279 led_task_state = RENDERING; 286 led_task_state = RENDERING;
@@ -352,7 +359,7 @@ void led_matrix_task(void) {
352 bool suspend_backlight = suspend_state || 359 bool suspend_backlight = suspend_state ||
353#if LED_DISABLE_TIMEOUT > 0 360#if LED_DISABLE_TIMEOUT > 0
354 (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) || 361 (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) ||
355#endif // LED_DISABLE_TIMEOUT > 0 362#endif // LED_DISABLE_TIMEOUT > 0
356 false; 363 false;
357 364
358 uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode; 365 uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode;
@@ -421,7 +428,7 @@ void led_matrix_init(void) {
421 for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { 428 for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
422 last_hit_buffer.tick[i] = UINT16_MAX; 429 last_hit_buffer.tick[i] = UINT16_MAX;
423 } 430 }
424#endif // LED_MATRIX_KEYREACTIVE_ENABLED 431#endif // LED_MATRIX_KEYREACTIVE_ENABLED
425 432
426 if (!eeconfig_is_enabled()) { 433 if (!eeconfig_is_enabled()) {
427 dprintf("led_matrix_init_drivers eeconfig is not enabled.\n"); 434 dprintf("led_matrix_init_drivers eeconfig is not enabled.\n");
@@ -434,20 +441,22 @@ void led_matrix_init(void) {
434 dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n"); 441 dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n");
435 eeconfig_update_led_matrix_default(); 442 eeconfig_update_led_matrix_default();
436 } 443 }
437 eeconfig_debug_led_matrix(); // display current eeprom values 444 eeconfig_debug_led_matrix(); // display current eeprom values
438} 445}
439 446
440void led_matrix_set_suspend_state(bool state) { 447void led_matrix_set_suspend_state(bool state) {
441#ifdef LED_DISABLE_WHEN_USB_SUSPENDED 448#ifdef LED_DISABLE_WHEN_USB_SUSPENDED
442 if (state && !suspend_state && is_keyboard_master()) { // only run if turning off, and only once 449 if (state && !suspend_state && is_keyboard_master()) { // only run if turning off, and only once
443 led_task_render(0); // turn off all LEDs when suspending 450 led_task_render(0); // turn off all LEDs when suspending
444 led_task_flush(0); // and actually flash led state to LEDs 451 led_task_flush(0); // and actually flash led state to LEDs
445 } 452 }
446 suspend_state = state; 453 suspend_state = state;
447#endif 454#endif
448} 455}
449 456
450bool led_matrix_get_suspend_state(void) { return suspend_state; } 457bool led_matrix_get_suspend_state(void) {
458 return suspend_state;
459}
451 460
452void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { 461void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
453 led_matrix_eeconfig.enable ^= 1; 462 led_matrix_eeconfig.enable ^= 1;
@@ -455,8 +464,12 @@ void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
455 eeconfig_flag_led_matrix(write_to_eeprom); 464 eeconfig_flag_led_matrix(write_to_eeprom);
456 dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable); 465 dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable);
457} 466}
458void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); } 467void led_matrix_toggle_noeeprom(void) {
459void led_matrix_toggle(void) { led_matrix_toggle_eeprom_helper(true); } 468 led_matrix_toggle_eeprom_helper(false);
469}
470void led_matrix_toggle(void) {
471 led_matrix_toggle_eeprom_helper(true);
472}
460 473
461void led_matrix_enable(void) { 474void led_matrix_enable(void) {
462 led_matrix_enable_noeeprom(); 475 led_matrix_enable_noeeprom();
@@ -478,7 +491,9 @@ void led_matrix_disable_noeeprom(void) {
478 led_matrix_eeconfig.enable = 0; 491 led_matrix_eeconfig.enable = 0;
479} 492}
480 493
481uint8_t led_matrix_is_enabled(void) { return led_matrix_eeconfig.enable; } 494uint8_t led_matrix_is_enabled(void) {
495 return led_matrix_eeconfig.enable;
496}
482 497
483void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { 498void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
484 if (!led_matrix_eeconfig.enable) { 499 if (!led_matrix_eeconfig.enable) {
@@ -495,24 +510,38 @@ void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
495 eeconfig_flag_led_matrix(write_to_eeprom); 510 eeconfig_flag_led_matrix(write_to_eeprom);
496 dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); 511 dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode);
497} 512}
498void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); } 513void led_matrix_mode_noeeprom(uint8_t mode) {
499void led_matrix_mode(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, true); } 514 led_matrix_mode_eeprom_helper(mode, false);
515}
516void led_matrix_mode(uint8_t mode) {
517 led_matrix_mode_eeprom_helper(mode, true);
518}
500 519
501uint8_t led_matrix_get_mode(void) { return led_matrix_eeconfig.mode; } 520uint8_t led_matrix_get_mode(void) {
521 return led_matrix_eeconfig.mode;
522}
502 523
503void led_matrix_step_helper(bool write_to_eeprom) { 524void led_matrix_step_helper(bool write_to_eeprom) {
504 uint8_t mode = led_matrix_eeconfig.mode + 1; 525 uint8_t mode = led_matrix_eeconfig.mode + 1;
505 led_matrix_mode_eeprom_helper((mode < LED_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); 526 led_matrix_mode_eeprom_helper((mode < LED_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom);
506} 527}
507void led_matrix_step_noeeprom(void) { led_matrix_step_helper(false); } 528void led_matrix_step_noeeprom(void) {
508void led_matrix_step(void) { led_matrix_step_helper(true); } 529 led_matrix_step_helper(false);
530}
531void led_matrix_step(void) {
532 led_matrix_step_helper(true);
533}
509 534
510void led_matrix_step_reverse_helper(bool write_to_eeprom) { 535void led_matrix_step_reverse_helper(bool write_to_eeprom) {
511 uint8_t mode = led_matrix_eeconfig.mode - 1; 536 uint8_t mode = led_matrix_eeconfig.mode - 1;
512 led_matrix_mode_eeprom_helper((mode < 1) ? LED_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); 537 led_matrix_mode_eeprom_helper((mode < 1) ? LED_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom);
513} 538}
514void led_matrix_step_reverse_noeeprom(void) { led_matrix_step_reverse_helper(false); } 539void led_matrix_step_reverse_noeeprom(void) {
515void led_matrix_step_reverse(void) { led_matrix_step_reverse_helper(true); } 540 led_matrix_step_reverse_helper(false);
541}
542void led_matrix_step_reverse(void) {
543 led_matrix_step_reverse_helper(true);
544}
516 545
517void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) { 546void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) {
518 if (!led_matrix_eeconfig.enable) { 547 if (!led_matrix_eeconfig.enable) {
@@ -522,37 +551,77 @@ void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) {
522 eeconfig_flag_led_matrix(write_to_eeprom); 551 eeconfig_flag_led_matrix(write_to_eeprom);
523 dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val); 552 dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val);
524} 553}
525void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); } 554void led_matrix_set_val_noeeprom(uint8_t val) {
526void led_matrix_set_val(uint8_t val) { led_matrix_set_val_eeprom_helper(val, true); } 555 led_matrix_set_val_eeprom_helper(val, false);
556}
557void led_matrix_set_val(uint8_t val) {
558 led_matrix_set_val_eeprom_helper(val, true);
559}
527 560
528uint8_t led_matrix_get_val(void) { return led_matrix_eeconfig.val; } 561uint8_t led_matrix_get_val(void) {
562 return led_matrix_eeconfig.val;
563}
529 564
530void led_matrix_increase_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qadd8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); } 565void led_matrix_increase_val_helper(bool write_to_eeprom) {
531void led_matrix_increase_val_noeeprom(void) { led_matrix_increase_val_helper(false); } 566 led_matrix_set_val_eeprom_helper(qadd8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom);
532void led_matrix_increase_val(void) { led_matrix_increase_val_helper(true); } 567}
568void led_matrix_increase_val_noeeprom(void) {
569 led_matrix_increase_val_helper(false);
570}
571void led_matrix_increase_val(void) {
572 led_matrix_increase_val_helper(true);
573}
533 574
534void led_matrix_decrease_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qsub8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); } 575void led_matrix_decrease_val_helper(bool write_to_eeprom) {
535void led_matrix_decrease_val_noeeprom(void) { led_matrix_decrease_val_helper(false); } 576 led_matrix_set_val_eeprom_helper(qsub8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom);
536void led_matrix_decrease_val(void) { led_matrix_decrease_val_helper(true); } 577}
578void led_matrix_decrease_val_noeeprom(void) {
579 led_matrix_decrease_val_helper(false);
580}
581void led_matrix_decrease_val(void) {
582 led_matrix_decrease_val_helper(true);
583}
537 584
538void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { 585void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
539 led_matrix_eeconfig.speed = speed; 586 led_matrix_eeconfig.speed = speed;
540 eeconfig_flag_led_matrix(write_to_eeprom); 587 eeconfig_flag_led_matrix(write_to_eeprom);
541 dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed); 588 dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed);
542} 589}
543void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); } 590void led_matrix_set_speed_noeeprom(uint8_t speed) {
544void led_matrix_set_speed(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, true); } 591 led_matrix_set_speed_eeprom_helper(speed, false);
592}
593void led_matrix_set_speed(uint8_t speed) {
594 led_matrix_set_speed_eeprom_helper(speed, true);
595}
545 596
546uint8_t led_matrix_get_speed(void) { return led_matrix_eeconfig.speed; } 597uint8_t led_matrix_get_speed(void) {
598 return led_matrix_eeconfig.speed;
599}
547 600
548void led_matrix_increase_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qadd8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); } 601void led_matrix_increase_speed_helper(bool write_to_eeprom) {
549void led_matrix_increase_speed_noeeprom(void) { led_matrix_increase_speed_helper(false); } 602 led_matrix_set_speed_eeprom_helper(qadd8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom);
550void led_matrix_increase_speed(void) { led_matrix_increase_speed_helper(true); } 603}
604void led_matrix_increase_speed_noeeprom(void) {
605 led_matrix_increase_speed_helper(false);
606}
607void led_matrix_increase_speed(void) {
608 led_matrix_increase_speed_helper(true);
609}
551 610
552void led_matrix_decrease_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qsub8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); } 611void led_matrix_decrease_speed_helper(bool write_to_eeprom) {
553void led_matrix_decrease_speed_noeeprom(void) { led_matrix_decrease_speed_helper(false); } 612 led_matrix_set_speed_eeprom_helper(qsub8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom);
554void led_matrix_decrease_speed(void) { led_matrix_decrease_speed_helper(true); } 613}
614void led_matrix_decrease_speed_noeeprom(void) {
615 led_matrix_decrease_speed_helper(false);
616}
617void led_matrix_decrease_speed(void) {
618 led_matrix_decrease_speed_helper(true);
619}
555 620
556led_flags_t led_matrix_get_flags(void) { return led_matrix_eeconfig.flags; } 621led_flags_t led_matrix_get_flags(void) {
622 return led_matrix_eeconfig.flags;
623}
557 624
558void led_matrix_set_flags(led_flags_t flags) { led_matrix_eeconfig.flags = flags; } 625void led_matrix_set_flags(led_flags_t flags) {
626 led_matrix_eeconfig.flags = flags;
627}
diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h
index 61cdbd9b8e..3dc533100f 100644
--- a/quantum/led_matrix/led_matrix_types.h
+++ b/quantum/led_matrix/led_matrix_types.h
@@ -36,7 +36,7 @@
36// Last led hit 36// Last led hit
37#ifndef LED_HITS_TO_REMEMBER 37#ifndef LED_HITS_TO_REMEMBER
38# define LED_HITS_TO_REMEMBER 8 38# define LED_HITS_TO_REMEMBER 8
39#endif // LED_HITS_TO_REMEMBER 39#endif // LED_HITS_TO_REMEMBER
40 40
41#ifdef LED_MATRIX_KEYREACTIVE_ENABLED 41#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
42typedef struct PACKED { 42typedef struct PACKED {
@@ -46,7 +46,7 @@ typedef struct PACKED {
46 uint8_t index[LED_HITS_TO_REMEMBER]; 46 uint8_t index[LED_HITS_TO_REMEMBER];
47 uint16_t tick[LED_HITS_TO_REMEMBER]; 47 uint16_t tick[LED_HITS_TO_REMEMBER];
48} last_hit_t; 48} last_hit_t;
49#endif // LED_MATRIX_KEYREACTIVE_ENABLED 49#endif // LED_MATRIX_KEYREACTIVE_ENABLED
50 50
51typedef enum led_task_states { STARTING, RENDERING, FLUSHING, SYNCING } led_task_states; 51typedef enum led_task_states { STARTING, RENDERING, FLUSHING, SYNCING } led_task_states;
52 52
@@ -87,7 +87,7 @@ typedef union {
87 uint8_t mode : 6; 87 uint8_t mode : 6;
88 uint16_t reserved; 88 uint16_t reserved;
89 uint8_t val; 89 uint8_t val;
90 uint8_t speed; // EECONFIG needs to be increased to support this 90 uint8_t speed; // EECONFIG needs to be increased to support this
91 led_flags_t flags; 91 led_flags_t flags;
92 }; 92 };
93} led_eeconfig_t; 93} led_eeconfig_t;
diff --git a/quantum/logging/debug.c b/quantum/logging/debug.c
index ea62deaa8c..ca7654eda2 100644
--- a/quantum/logging/debug.c
+++ b/quantum/logging/debug.c
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "debug.h" 17#include "debug.h"
18 18
19debug_config_t debug_config = { 19debug_config_t debug_config = {
20 .enable = false, // 20 .enable = false, //
21 .matrix = false, // 21 .matrix = false, //
22 .keyboard = false, // 22 .keyboard = false, //
23 .mouse = false, // 23 .mouse = false, //
24 .reserved = 0 // 24 .reserved = 0 //
25}; 25};
diff --git a/quantum/logging/print.c b/quantum/logging/print.c
index e8440e55ee..50a6b826ee 100644
--- a/quantum/logging/print.c
+++ b/quantum/logging/print.c
@@ -19,9 +19,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20// bind lib/printf to console interface - sendchar 20// bind lib/printf to console interface - sendchar
21 21
22static int8_t null_sendchar_func(uint8_t c) { return 0; } 22static int8_t null_sendchar_func(uint8_t c) {
23 return 0;
24}
23static sendchar_func_t func = null_sendchar_func; 25static sendchar_func_t func = null_sendchar_func;
24 26
25void print_set_sendchar(sendchar_func_t send) { func = send; } 27void print_set_sendchar(sendchar_func_t send) {
28 func = send;
29}
26 30
27void _putchar(char character) { func(character); } 31void _putchar(char character) {
32 func(character);
33}
diff --git a/quantum/logging/print.h b/quantum/logging/print.h
index 8c055f549e..aa72fc7074 100644
--- a/quantum/logging/print.h
+++ b/quantum/logging/print.h
@@ -37,7 +37,7 @@ void print_set_sendchar(sendchar_func_t func);
37# include_next "_print.h" /* Include the platforms print.h */ 37# include_next "_print.h" /* Include the platforms print.h */
38# else 38# else
39// Fall back to lib/printf 39// Fall back to lib/printf
40# include "printf.h" // lib/printf/printf.h 40# include "printf.h" // lib/printf/printf.h
41 41
42// Create user & normal print defines 42// Create user & normal print defines
43# define print(s) printf(s) 43# define print(s) printf(s)
diff --git a/quantum/logging/sendchar.c b/quantum/logging/sendchar.c
index 9422382f6f..5bc744b743 100644
--- a/quantum/logging/sendchar.c
+++ b/quantum/logging/sendchar.c
@@ -17,4 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "sendchar.h" 17#include "sendchar.h"
18 18
19/* default noop "null" implementation */ 19/* default noop "null" implementation */
20__attribute__((weak)) int8_t sendchar(uint8_t c) { return 0; } 20__attribute__((weak)) int8_t sendchar(uint8_t c) {
21 return 0;
22}
diff --git a/quantum/main.c b/quantum/main.c
index 6ed6b95741..faba668056 100644
--- a/quantum/main.c
+++ b/quantum/main.c
@@ -45,7 +45,7 @@ void protocol_task(void) {
45 45
46#ifdef DEFERRED_EXEC_ENABLE 46#ifdef DEFERRED_EXEC_ENABLE
47void deferred_exec_task(void); 47void deferred_exec_task(void);
48#endif // DEFERRED_EXEC_ENABLE 48#endif // DEFERRED_EXEC_ENABLE
49 49
50/** \brief Main 50/** \brief Main
51 * 51 *
@@ -66,7 +66,7 @@ int main(void) {
66#ifdef DEFERRED_EXEC_ENABLE 66#ifdef DEFERRED_EXEC_ENABLE
67 // Run deferred executions 67 // Run deferred executions
68 deferred_exec_task(); 68 deferred_exec_task();
69#endif // DEFERRED_EXEC_ENABLE 69#endif // DEFERRED_EXEC_ENABLE
70 70
71 housekeeping_task(); 71 housekeeping_task();
72 } 72 }
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 0b16184e12..db59b73754 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -51,15 +51,15 @@ static SPLIT_MUTABLE pin_t direct_pins[ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS
51#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) 51#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
52# ifdef MATRIX_ROW_PINS 52# ifdef MATRIX_ROW_PINS
53static SPLIT_MUTABLE_ROW pin_t row_pins[ROWS_PER_HAND] = MATRIX_ROW_PINS; 53static SPLIT_MUTABLE_ROW pin_t row_pins[ROWS_PER_HAND] = MATRIX_ROW_PINS;
54# endif // MATRIX_ROW_PINS 54# endif // MATRIX_ROW_PINS
55# ifdef MATRIX_COL_PINS 55# ifdef MATRIX_COL_PINS
56static SPLIT_MUTABLE_COL pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; 56static SPLIT_MUTABLE_COL pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
57# endif // MATRIX_COL_PINS 57# endif // MATRIX_COL_PINS
58#endif 58#endif
59 59
60/* matrix state(1:on, 0:off) */ 60/* matrix state(1:on, 0:off) */
61extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values 61extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
62extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values 62extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
63 63
64#ifdef SPLIT_KEYBOARD 64#ifdef SPLIT_KEYBOARD
65// row offsets for each hand 65// row offsets for each hand
@@ -86,7 +86,9 @@ static inline void setPinOutput_writeHigh(pin_t pin) {
86} 86}
87 87
88static inline void setPinInputHigh_atomic(pin_t pin) { 88static inline void setPinInputHigh_atomic(pin_t pin) {
89 ATOMIC_BLOCK_FORCEON { setPinInputHigh(pin); } 89 ATOMIC_BLOCK_FORCEON {
90 setPinInputHigh(pin);
91 }
90} 92}
91 93
92static inline uint8_t readMatrixPin(pin_t pin) { 94static inline uint8_t readMatrixPin(pin_t pin) {
@@ -171,8 +173,8 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[]
171 // Start with a clear matrix row 173 // Start with a clear matrix row
172 matrix_row_t current_row_value = 0; 174 matrix_row_t current_row_value = 0;
173 175
174 if (!select_row(current_row)) { // Select row 176 if (!select_row(current_row)) { // Select row
175 return; // skip NO_PIN row 177 return; // skip NO_PIN row
176 } 178 }
177 matrix_output_select_delay(); 179 matrix_output_select_delay();
178 180
@@ -187,7 +189,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[]
187 189
188 // Unselect row 190 // Unselect row
189 unselect_row(current_row); 191 unselect_row(current_row);
190 matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for all Col signals to go HIGH 192 matrix_output_unselect_delay(current_row, current_row_value != 0); // wait for all Col signals to go HIGH
191 193
192 // Update the matrix 194 // Update the matrix
193 current_matrix[current_row] = current_row_value; 195 current_matrix[current_row] = current_row_value;
@@ -234,8 +236,8 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[]
234 bool key_pressed = false; 236 bool key_pressed = false;
235 237
236 // Select col 238 // Select col
237 if (!select_col(current_col)) { // select col 239 if (!select_col(current_col)) { // select col
238 return; // skip NO_PIN col 240 return; // skip NO_PIN col
239 } 241 }
240 matrix_output_select_delay(); 242 matrix_output_select_delay();
241 243
@@ -254,13 +256,13 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[]
254 256
255 // Unselect col 257 // Unselect col
256 unselect_col(current_col); 258 unselect_col(current_col);
257 matrix_output_unselect_delay(current_col, key_pressed); // wait for all Row signals to go HIGH 259 matrix_output_unselect_delay(current_col, key_pressed); // wait for all Row signals to go HIGH
258} 260}
259 261
260# else 262# else
261# error DIODE_DIRECTION must be one of COL2ROW or ROW2COL! 263# error DIODE_DIRECTION must be one of COL2ROW or ROW2COL!
262# endif 264# endif
263# endif // defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS) 265# endif // defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS)
264#else 266#else
265# error DIODE_DIRECTION is not defined! 267# error DIODE_DIRECTION is not defined!
266#endif 268#endif
@@ -311,7 +313,7 @@ void matrix_init(void) {
311// Fallback implementation for keyboards not using the standard split_util.c 313// Fallback implementation for keyboards not using the standard split_util.c
312__attribute__((weak)) bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { 314__attribute__((weak)) bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
313 transport_master(master_matrix, slave_matrix); 315 transport_master(master_matrix, slave_matrix);
314 return true; // Treat the transport as always connected 316 return true; // Treat the transport as always connected
315} 317}
316#endif 318#endif
317 319
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c
index d67aaf508c..1497ceae71 100644
--- a/quantum/matrix_common.c
+++ b/quantum/matrix_common.c
@@ -33,9 +33,13 @@ extern const matrix_row_t matrix_mask[];
33 33
34// user-defined overridable functions 34// user-defined overridable functions
35 35
36__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); } 36__attribute__((weak)) void matrix_init_kb(void) {
37 matrix_init_user();
38}
37 39
38__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } 40__attribute__((weak)) void matrix_scan_kb(void) {
41 matrix_scan_user();
42}
39 43
40__attribute__((weak)) void matrix_init_user(void) {} 44__attribute__((weak)) void matrix_init_user(void) {}
41 45
@@ -43,11 +47,17 @@ __attribute__((weak)) void matrix_scan_user(void) {}
43 47
44// helper functions 48// helper functions
45 49
46inline uint8_t matrix_rows(void) { return MATRIX_ROWS; } 50inline uint8_t matrix_rows(void) {
51 return MATRIX_ROWS;
52}
47 53
48inline uint8_t matrix_cols(void) { return MATRIX_COLS; } 54inline uint8_t matrix_cols(void) {
55 return MATRIX_COLS;
56}
49 57
50inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); } 58inline bool matrix_is_on(uint8_t row, uint8_t col) {
59 return (matrix[row] & ((matrix_row_t)1 << col));
60}
51 61
52inline matrix_row_t matrix_get_row(uint8_t row) { 62inline matrix_row_t matrix_get_row(uint8_t row) {
53 // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a 63 // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
@@ -124,16 +134,26 @@ bool matrix_post_scan(void) {
124#endif 134#endif
125 135
126/* `matrix_io_delay ()` exists for backwards compatibility. From now on, use matrix_output_unselect_delay(). */ 136/* `matrix_io_delay ()` exists for backwards compatibility. From now on, use matrix_output_unselect_delay(). */
127__attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); } 137__attribute__((weak)) void matrix_io_delay(void) {
128__attribute__((weak)) void matrix_output_select_delay(void) { waitInputPinDelay(); } 138 wait_us(MATRIX_IO_DELAY);
129__attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) { matrix_io_delay(); } 139}
140__attribute__((weak)) void matrix_output_select_delay(void) {
141 waitInputPinDelay();
142}
143__attribute__((weak)) void matrix_output_unselect_delay(uint8_t line, bool key_pressed) {
144 matrix_io_delay();
145}
130 146
131// CUSTOM MATRIX 'LITE' 147// CUSTOM MATRIX 'LITE'
132__attribute__((weak)) void matrix_init_custom(void) {} 148__attribute__((weak)) void matrix_init_custom(void) {}
133__attribute__((weak)) bool matrix_scan_custom(matrix_row_t current_matrix[]) { return true; } 149__attribute__((weak)) bool matrix_scan_custom(matrix_row_t current_matrix[]) {
150 return true;
151}
134 152
135#ifdef SPLIT_KEYBOARD 153#ifdef SPLIT_KEYBOARD
136__attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); } 154__attribute__((weak)) void matrix_slave_scan_kb(void) {
155 matrix_slave_scan_user();
156}
137__attribute__((weak)) void matrix_slave_scan_user(void) {} 157__attribute__((weak)) void matrix_slave_scan_user(void) {}
138#endif 158#endif
139 159
@@ -170,4 +190,6 @@ __attribute__((weak)) uint8_t matrix_scan(void) {
170 return changed; 190 return changed;
171} 191}
172 192
173__attribute__((weak)) bool peek_matrix(uint8_t row_index, uint8_t col_index, bool raw) { return 0 != ((raw ? raw_matrix[row_index] : matrix[row_index]) & (MATRIX_ROW_SHIFTER << col_index)); } 193__attribute__((weak)) bool peek_matrix(uint8_t row_index, uint8_t col_index, bool raw) {
194 return 0 != ((raw ? raw_matrix[row_index] : matrix[row_index]) & (MATRIX_ROW_SHIFTER << col_index));
195}
diff --git a/quantum/mousekey.c b/quantum/mousekey.c
index c2291fb397..8bafbf977a 100644
--- a/quantum/mousekey.c
+++ b/quantum/mousekey.c
@@ -487,4 +487,6 @@ static void mousekey_debug(void) {
487 print(")\n"); 487 print(")\n");
488} 488}
489 489
490report_mouse_t mousekey_get_report(void) { return mouse_report; } 490report_mouse_t mousekey_get_report(void) {
491 return mouse_report;
492}
diff --git a/quantum/pointing_device.c b/quantum/pointing_device.c
index cce292e0bf..9627cab4b8 100644
--- a/quantum/pointing_device.c
+++ b/quantum/pointing_device.c
@@ -39,7 +39,9 @@ uint16_t shared_cpi = 0;
39 * 39 *
40 * @param[in] new_mouse_report report_mouse_t 40 * @param[in] new_mouse_report report_mouse_t
41 */ 41 */
42void pointing_device_set_shared_report(report_mouse_t new_mouse_report) { shared_mouse_report = new_mouse_report; } 42void pointing_device_set_shared_report(report_mouse_t new_mouse_report) {
43 shared_mouse_report = new_mouse_report;
44}
43 45
44/** 46/**
45 * @brief Gets current pointing device CPI if supported 47 * @brief Gets current pointing device CPI if supported
@@ -50,7 +52,9 @@ void pointing_device_set_shared_report(report_mouse_t new_mouse_report) { shared
50 * 52 *
51 * @return cpi value as uint16_t 53 * @return cpi value as uint16_t
52 */ 54 */
53uint16_t pointing_device_get_shared_cpi(void) { return shared_cpi; } 55uint16_t pointing_device_get_shared_cpi(void) {
56 return shared_cpi;
57}
54 58
55# if defined(POINTING_DEVICE_LEFT) 59# if defined(POINTING_DEVICE_LEFT)
56# define POINTING_DEVICE_THIS_SIDE is_keyboard_left() 60# define POINTING_DEVICE_THIS_SIDE is_keyboard_left()
@@ -60,7 +64,7 @@ uint16_t pointing_device_get_shared_cpi(void) { return shared_cpi; }
60# define POINTING_DEVICE_THIS_SIDE true 64# define POINTING_DEVICE_THIS_SIDE true
61# endif 65# endif
62 66
63#endif // defined(SPLIT_POINTING_ENABLE) 67#endif // defined(SPLIT_POINTING_ENABLE)
64 68
65static report_mouse_t local_mouse_report = {}; 69static report_mouse_t local_mouse_report = {};
66 70
@@ -73,7 +77,9 @@ extern const pointing_device_driver_t pointing_device_driver;
73 * @param[in] old report_mouse_t 77 * @param[in] old report_mouse_t
74 * @return bool result 78 * @return bool result
75 */ 79 */
76__attribute__((weak)) bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old) { return memcmp(&new, &old, sizeof(new)); } 80__attribute__((weak)) bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old) {
81 return memcmp(&new, &old, sizeof(new));
82}
77 83
78/** 84/**
79 * @brief Keyboard level code pointing device initialisation 85 * @brief Keyboard level code pointing device initialisation
@@ -95,7 +101,9 @@ __attribute__((weak)) void pointing_device_init_user(void) {}
95 * @param[in] mouse_report report_mouse_t 101 * @param[in] mouse_report report_mouse_t
96 * @return report_mouse_t 102 * @return report_mouse_t
97 */ 103 */
98__attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { return pointing_device_task_user(mouse_report); } 104__attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
105 return pointing_device_task_user(mouse_report);
106}
99 107
100/** 108/**
101 * @brief Weak function allowing for user level mouse report modification 109 * @brief Weak function allowing for user level mouse report modification
@@ -105,7 +113,9 @@ __attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mous
105 * @param[in] mouse_report report_mouse_t 113 * @param[in] mouse_report report_mouse_t
106 * @return report_mouse_t 114 * @return report_mouse_t
107 */ 115 */
108__attribute__((weak)) report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { return mouse_report; } 116__attribute__((weak)) report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
117 return mouse_report;
118}
109 119
110/** 120/**
111 * @brief Handles pointing device buttons 121 * @brief Handles pointing device buttons
@@ -246,7 +256,7 @@ __attribute__((weak)) void pointing_device_task(void) {
246# endif 256# endif
247#else 257#else
248 local_mouse_report = pointing_device_driver.get_report(local_mouse_report); 258 local_mouse_report = pointing_device_driver.get_report(local_mouse_report);
249#endif // defined(SPLIT_POINTING_ENABLE) 259#endif // defined(SPLIT_POINTING_ENABLE)
250 260
251 // allow kb to intercept and modify report 261 // allow kb to intercept and modify report
252#if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED) 262#if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED)
@@ -275,14 +285,18 @@ __attribute__((weak)) void pointing_device_task(void) {
275 * 285 *
276 * @return report_mouse_t 286 * @return report_mouse_t
277 */ 287 */
278report_mouse_t pointing_device_get_report(void) { return local_mouse_report; } 288report_mouse_t pointing_device_get_report(void) {
289 return local_mouse_report;
290}
279 291
280/** 292/**
281 * @brief Sets mouse report used be pointing device task 293 * @brief Sets mouse report used be pointing device task
282 * 294 *
283 * @param[in] new_mouse_report 295 * @param[in] new_mouse_report
284 */ 296 */
285void pointing_device_set_report(report_mouse_t new_mouse_report) { local_mouse_report = new_mouse_report; } 297void pointing_device_set_report(report_mouse_t new_mouse_report) {
298 local_mouse_report = new_mouse_report;
299}
286 300
287/** 301/**
288 * @brief Gets current pointing device CPI if supported 302 * @brief Gets current pointing device CPI if supported
@@ -422,7 +436,9 @@ report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_repo
422 * @param[in] right_report report_mouse_t 436 * @param[in] right_report report_mouse_t
423 * @return pointing_device_task_combined_user(left_report, right_report) by default 437 * @return pointing_device_task_combined_user(left_report, right_report) by default
424 */ 438 */
425__attribute__((weak)) report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report) { return pointing_device_task_combined_user(left_report, right_report); } 439__attribute__((weak)) report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report) {
440 return pointing_device_task_combined_user(left_report, right_report);
441}
426 442
427/** 443/**
428 * @brief Weak function allowing for user level mouse report modification 444 * @brief Weak function allowing for user level mouse report modification
@@ -435,5 +451,7 @@ __attribute__((weak)) report_mouse_t pointing_device_task_combined_kb(report_mou
435 * @param[in] right_report report_mouse_t 451 * @param[in] right_report report_mouse_t
436 * @return pointing_device_combine_reports(left_report, right_report) by default 452 * @return pointing_device_combine_reports(left_report, right_report) by default
437 */ 453 */
438__attribute__((weak)) report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report) { return pointing_device_combine_reports(left_report, right_report); } 454__attribute__((weak)) report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report) {
455 return pointing_device_combine_reports(left_report, right_report);
456}
439#endif 457#endif
diff --git a/quantum/pointing_device.h b/quantum/pointing_device.h
index 8394c20952..5f3845227a 100644
--- a/quantum/pointing_device.h
+++ b/quantum/pointing_device.h
@@ -103,5 +103,5 @@ report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, repor
103report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report); 103report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report);
104report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report); 104report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report);
105report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report); 105report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report);
106# endif // defined(POINTING_DEVICE_COMBINED) 106# endif // defined(POINTING_DEVICE_COMBINED)
107#endif // defined(SPLIT_POINTING_ENABLE) 107#endif // defined(SPLIT_POINTING_ENABLE)
diff --git a/quantum/pointing_device_drivers.c b/quantum/pointing_device_drivers.c
index 7702958f88..b8ef6e67e5 100644
--- a/quantum/pointing_device_drivers.c
+++ b/quantum/pointing_device_drivers.c
@@ -120,7 +120,7 @@ report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) {
120 int8_t report_x = 0, report_y = 0; 120 int8_t report_x = 0, report_y = 0;
121 static bool is_z_down = false; 121 static bool is_z_down = false;
122 122
123 cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); // Scale coordinates to arbitrary X, Y resolution 123 cirque_pinnacle_scale_data(&touchData, cirque_pinnacle_get_scale(), cirque_pinnacle_get_scale()); // Scale coordinates to arbitrary X, Y resolution
124 124
125 if (x && y && touchData.xValue && touchData.yValue) { 125 if (x && y && touchData.xValue && touchData.yValue) {
126 report_x = (int8_t)(touchData.xValue - x); 126 report_x = (int8_t)(touchData.xValue - x);
@@ -207,11 +207,13 @@ const pointing_device_driver_t pointing_device_driver = {
207}; 207};
208// clang-format on 208// clang-format on
209#elif defined(POINTING_DEVICE_DRIVER_pmw3360) 209#elif defined(POINTING_DEVICE_DRIVER_pmw3360)
210static void pmw3360_device_init(void) { pmw3360_init(); } 210static void pmw3360_device_init(void) {
211 pmw3360_init();
212}
211 213
212report_mouse_t pmw3360_get_report(report_mouse_t mouse_report) { 214report_mouse_t pmw3360_get_report(report_mouse_t mouse_report) {
213 report_pmw3360_t data = pmw3360_read_burst(); 215 report_pmw3360_t data = pmw3360_read_burst();
214 static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state 216 static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
215 217
216 if (data.isOnSurface && data.isMotion) { 218 if (data.isOnSurface && data.isMotion) {
217 // Reset timer if stopped moving 219 // Reset timer if stopped moving
@@ -243,11 +245,13 @@ const pointing_device_driver_t pointing_device_driver = {
243}; 245};
244// clang-format on 246// clang-format on
245#elif defined(POINTING_DEVICE_DRIVER_pmw3389) 247#elif defined(POINTING_DEVICE_DRIVER_pmw3389)
246static void pmw3389_device_init(void) { pmw3389_init(); } 248static void pmw3389_device_init(void) {
249 pmw3389_init();
250}
247 251
248report_mouse_t pmw3389_get_report(report_mouse_t mouse_report) { 252report_mouse_t pmw3389_get_report(report_mouse_t mouse_report) {
249 report_pmw3389_t data = pmw3389_read_burst(); 253 report_pmw3389_t data = pmw3389_read_burst();
250 static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state 254 static uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
251 255
252 if (data.isOnSurface && data.isMotion) { 256 if (data.isOnSurface && data.isMotion) {
253 // Reset timer if stopped moving 257 // Reset timer if stopped moving
@@ -280,9 +284,13 @@ const pointing_device_driver_t pointing_device_driver = {
280// clang-format on 284// clang-format on
281#else 285#else
282__attribute__((weak)) void pointing_device_driver_init(void) {} 286__attribute__((weak)) void pointing_device_driver_init(void) {}
283__attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { return mouse_report; } 287__attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
284__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) { return 0; } 288 return mouse_report;
285__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {} 289}
290__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) {
291 return 0;
292}
293__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {}
286 294
287// clang-format off 295// clang-format off
288const pointing_device_driver_t pointing_device_driver = { 296const pointing_device_driver_t pointing_device_driver = {
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c
index 23664721e8..e7fe453308 100644
--- a/quantum/process_keycode/process_audio.c
+++ b/quantum/process_keycode/process_audio.c
@@ -50,11 +50,17 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
50 return true; 50 return true;
51} 51}
52 52
53void process_audio_noteon(uint8_t note) { play_note(compute_freq_for_midi_note(note), 0xF); } 53void process_audio_noteon(uint8_t note) {
54 play_note(compute_freq_for_midi_note(note), 0xF);
55}
54 56
55void process_audio_noteoff(uint8_t note) { stop_note(compute_freq_for_midi_note(note)); } 57void process_audio_noteoff(uint8_t note) {
58 stop_note(compute_freq_for_midi_note(note));
59}
56 60
57void process_audio_all_notes_off(void) { stop_all_notes(); } 61void process_audio_all_notes_off(void) {
62 stop_all_notes();
63}
58 64
59__attribute__((weak)) void audio_on_user() {} 65__attribute__((weak)) void audio_on_user() {}
60__attribute__((weak)) void audio_off_user() {} 66__attribute__((weak)) void audio_off_user() {}
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index bbc6367ff1..2150edd7b2 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -62,7 +62,9 @@ static struct {
62// clang-format on 62// clang-format on
63 63
64/** \brief Called on physical press, returns whether key should be added to Auto Shift */ 64/** \brief Called on physical press, returns whether key should be added to Auto Shift */
65__attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { return false; } 65__attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
66 return false;
67}
66 68
67/** \brief Called on physical press, returns whether is Auto Shift key */ 69/** \brief Called on physical press, returns whether is Auto Shift key */
68__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { 70__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
@@ -82,8 +84,12 @@ __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *r
82} 84}
83 85
84/** \brief Called to check whether defines should apply if PER_KEY is set for it */ 86/** \brief Called to check whether defines should apply if PER_KEY is set for it */
85__attribute__((weak)) bool get_auto_shift_repeat(uint16_t keycode, keyrecord_t *record) { return true; } 87__attribute__((weak)) bool get_auto_shift_repeat(uint16_t keycode, keyrecord_t *record) {
86__attribute__((weak)) bool get_auto_shift_no_auto_repeat(uint16_t keycode, keyrecord_t *record) { return true; } 88 return true;
89}
90__attribute__((weak)) bool get_auto_shift_no_auto_repeat(uint16_t keycode, keyrecord_t *record) {
91 return true;
92}
87 93
88/** \brief Called when an Auto Shift key needs to be pressed */ 94/** \brief Called when an Auto Shift key needs to be pressed */
89__attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) { 95__attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) {
@@ -94,7 +100,9 @@ __attribute__((weak)) void autoshift_press_user(uint16_t keycode, bool shifted,
94} 100}
95 101
96/** \brief Called when an Auto Shift key needs to be released */ 102/** \brief Called when an Auto Shift key needs to be released */
97__attribute__((weak)) void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) { unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode); } 103__attribute__((weak)) void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) {
104 unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode);
105}
98 106
99/** \brief Sets the shift state to use when keyrepeating, required by custom shifts */ 107/** \brief Sets the shift state to use when keyrepeating, required by custom shifts */
100void set_autoshift_shift_state(uint16_t keycode, bool shifted) { 108void set_autoshift_shift_state(uint16_t keycode, bool shifted) {
@@ -311,7 +319,9 @@ void autoshift_toggle(void) {
311 autoshift_flush_shift(); 319 autoshift_flush_shift();
312} 320}
313 321
314void autoshift_enable(void) { autoshift_flags.enabled = true; } 322void autoshift_enable(void) {
323 autoshift_flags.enabled = true;
324}
315 325
316void autoshift_disable(void) { 326void autoshift_disable(void) {
317 autoshift_flags.enabled = false; 327 autoshift_flags.enabled = false;
@@ -328,12 +338,20 @@ void autoshift_timer_report(void) {
328} 338}
329# endif 339# endif
330 340
331bool get_autoshift_state(void) { return autoshift_flags.enabled; } 341bool get_autoshift_state(void) {
342 return autoshift_flags.enabled;
343}
332 344
333uint16_t get_generic_autoshift_timeout() { return autoshift_timeout; } 345uint16_t get_generic_autoshift_timeout() {
334__attribute__((weak)) uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) { return autoshift_timeout; } 346 return autoshift_timeout;
347}
348__attribute__((weak)) uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) {
349 return autoshift_timeout;
350}
335 351
336void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } 352void set_autoshift_timeout(uint16_t timeout) {
353 autoshift_timeout = timeout;
354}
337 355
338bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { 356bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
339 // Note that record->event.time isn't reliable, see: 357 // Note that record->event.time isn't reliable, see:
diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c
index 6ab382d4aa..9795734984 100644
--- a/quantum/process_keycode/process_clicky.c
+++ b/quantum/process_keycode/process_clicky.c
@@ -5,40 +5,40 @@
5 5
6# ifndef AUDIO_CLICKY_DELAY_DURATION 6# ifndef AUDIO_CLICKY_DELAY_DURATION
7# define AUDIO_CLICKY_DELAY_DURATION 1 7# define AUDIO_CLICKY_DELAY_DURATION 1
8# endif // !AUDIO_CLICKY_DELAY_DURATION 8# endif // !AUDIO_CLICKY_DELAY_DURATION
9# ifndef AUDIO_CLICKY_FREQ_DEFAULT 9# ifndef AUDIO_CLICKY_FREQ_DEFAULT
10# define AUDIO_CLICKY_FREQ_DEFAULT 440.0f 10# define AUDIO_CLICKY_FREQ_DEFAULT 440.0f
11# endif // !AUDIO_CLICKY_FREQ_DEFAULT 11# endif // !AUDIO_CLICKY_FREQ_DEFAULT
12# ifndef AUDIO_CLICKY_FREQ_MIN 12# ifndef AUDIO_CLICKY_FREQ_MIN
13# define AUDIO_CLICKY_FREQ_MIN 65.0f 13# define AUDIO_CLICKY_FREQ_MIN 65.0f
14# endif // !AUDIO_CLICKY_FREQ_MIN 14# endif // !AUDIO_CLICKY_FREQ_MIN
15# ifndef AUDIO_CLICKY_FREQ_MAX 15# ifndef AUDIO_CLICKY_FREQ_MAX
16# define AUDIO_CLICKY_FREQ_MAX 1500.0f 16# define AUDIO_CLICKY_FREQ_MAX 1500.0f
17# endif // !AUDIO_CLICKY_FREQ_MAX 17# endif // !AUDIO_CLICKY_FREQ_MAX
18# ifndef AUDIO_CLICKY_FREQ_FACTOR 18# ifndef AUDIO_CLICKY_FREQ_FACTOR
19# define AUDIO_CLICKY_FREQ_FACTOR 1.18921f 19# define AUDIO_CLICKY_FREQ_FACTOR 1.18921f
20# endif // !AUDIO_CLICKY_FREQ_FACTOR 20# endif // !AUDIO_CLICKY_FREQ_FACTOR
21# ifndef AUDIO_CLICKY_FREQ_RANDOMNESS 21# ifndef AUDIO_CLICKY_FREQ_RANDOMNESS
22# define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f 22# define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f
23# endif // !AUDIO_CLICKY_FREQ_RANDOMNESS 23# endif // !AUDIO_CLICKY_FREQ_RANDOMNESS
24 24
25float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; 25float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
26float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS; 26float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS;
27 27
28// the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky" 28// the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky"
29float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations 29float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_MIN, AUDIO_CLICKY_DELAY_DURATION}, {AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
30 30
31extern audio_config_t audio_config; 31extern audio_config_t audio_config;
32 32
33# ifndef NO_MUSIC_MODE 33# ifndef NO_MUSIC_MODE
34extern bool music_activated; 34extern bool music_activated;
35extern bool midi_activated; 35extern bool midi_activated;
36# endif // !NO_MUSIC_MODE 36# endif // !NO_MUSIC_MODE
37 37
38void clicky_play(void) { 38void clicky_play(void) {
39# ifndef NO_MUSIC_MODE 39# ifndef NO_MUSIC_MODE
40 if (music_activated || midi_activated || !audio_config.enable) return; 40 if (music_activated || midi_activated || !audio_config.enable) return;
41# endif // !NO_MUSIC_MODE 41# endif // !NO_MUSIC_MODE
42 clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); 42 clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX))));
43 clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX)))); 43 clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX))));
44 PLAY_SONG(clicky_song); 44 PLAY_SONG(clicky_song);
@@ -58,7 +58,9 @@ void clicky_freq_down(void) {
58 } 58 }
59} 59}
60 60
61void clicky_freq_reset(void) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; } 61void clicky_freq_reset(void) {
62 clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
63}
62 64
63void clicky_toggle(void) { 65void clicky_toggle(void) {
64 audio_config.clicky_enable ^= 1; 66 audio_config.clicky_enable ^= 1;
@@ -75,7 +77,9 @@ void clicky_off(void) {
75 eeconfig_update_audio(audio_config.raw); 77 eeconfig_update_audio(audio_config.raw);
76} 78}
77 79
78bool is_clicky_on(void) { return (audio_config.clicky_enable != 0); } 80bool is_clicky_on(void) {
81 return (audio_config.clicky_enable != 0);
82}
79 83
80bool process_clicky(uint16_t keycode, keyrecord_t *record) { 84bool process_clicky(uint16_t keycode, keyrecord_t *record) {
81 if (keycode == CLICKY_TOGGLE && record->event.pressed) { 85 if (keycode == CLICKY_TOGGLE && record->event.pressed) {
@@ -101,8 +105,8 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) {
101 } 105 }
102 106
103 if (audio_config.enable && audio_config.clicky_enable) { 107 if (audio_config.enable && audio_config.clicky_enable) {
104 if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound 108 if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound
105 if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM 109 if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM
106 clicky_play(); 110 clicky_play();
107 } 111 }
108 } 112 }
@@ -110,4 +114,4 @@ bool process_clicky(uint16_t keycode, keyrecord_t *record) {
110 return true; 114 return true;
111} 115}
112 116
113#endif // AUDIO_CLICKY 117#endif // AUDIO_CLICKY
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 21fd737ab7..efaf8fe0e9 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -30,33 +30,45 @@ extern uint16_t COMBO_LEN;
30__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} 30__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {}
31 31
32#ifdef COMBO_MUST_HOLD_PER_COMBO 32#ifdef COMBO_MUST_HOLD_PER_COMBO
33__attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) { return false; } 33__attribute__((weak)) bool get_combo_must_hold(uint16_t index, combo_t *combo) {
34 return false;
35}
34#endif 36#endif
35 37
36#ifdef COMBO_MUST_TAP_PER_COMBO 38#ifdef COMBO_MUST_TAP_PER_COMBO
37__attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) { return false; } 39__attribute__((weak)) bool get_combo_must_tap(uint16_t index, combo_t *combo) {
40 return false;
41}
38#endif 42#endif
39 43
40#ifdef COMBO_TERM_PER_COMBO 44#ifdef COMBO_TERM_PER_COMBO
41__attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) { return COMBO_TERM; } 45__attribute__((weak)) uint16_t get_combo_term(uint16_t index, combo_t *combo) {
46 return COMBO_TERM;
47}
42#endif 48#endif
43 49
44#ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO 50#ifdef COMBO_MUST_PRESS_IN_ORDER_PER_COMBO
45__attribute__((weak)) bool get_combo_must_press_in_order(uint16_t combo_index, combo_t *combo) { return true; } 51__attribute__((weak)) bool get_combo_must_press_in_order(uint16_t combo_index, combo_t *combo) {
52 return true;
53}
46#endif 54#endif
47 55
48#ifdef COMBO_PROCESS_KEY_RELEASE 56#ifdef COMBO_PROCESS_KEY_RELEASE
49__attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) { return false; } 57__attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) {
58 return false;
59}
50#endif 60#endif
51 61
52#ifdef COMBO_SHOULD_TRIGGER 62#ifdef COMBO_SHOULD_TRIGGER
53__attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) { return true; } 63__attribute__((weak)) bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) {
64 return true;
65}
54#endif 66#endif
55 67
56#ifndef COMBO_NO_TIMER 68#ifndef COMBO_NO_TIMER
57static uint16_t timer = 0; 69static uint16_t timer = 0;
58#endif 70#endif
59static bool b_combo_enable = true; // defaults to enabled 71static bool b_combo_enable = true; // defaults to enabled
60static uint16_t longest_term = 0; 72static uint16_t longest_term = 0;
61 73
62typedef struct { 74typedef struct {
@@ -462,7 +474,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
462 // get possible longer waiting time for tap-/hold-only combos. 474 // get possible longer waiting time for tap-/hold-only combos.
463 longest_term = _get_wait_time(combo_index, combo); 475 longest_term = _get_wait_time(combo_index, combo);
464 } 476 }
465 } // if timer elapsed end 477 } // if timer elapsed end
466 } 478 }
467 } else { 479 } else {
468 // chord releases 480 // chord releases
@@ -477,7 +489,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
477 else if (get_combo_must_tap(combo_index, combo)) { 489 else if (get_combo_must_tap(combo_index, combo)) {
478 // immediately apply tap-only combo 490 // immediately apply tap-only combo
479 apply_combo(combo_index, combo); 491 apply_combo(combo_index, combo);
480 apply_combos(); // also apply other prepared combos and dump key buffer 492 apply_combos(); // also apply other prepared combos and dump key buffer
481# ifdef COMBO_PROCESS_KEY_RELEASE 493# ifdef COMBO_PROCESS_KEY_RELEASE
482 if (process_combo_key_release(combo_index, combo, key_index, keycode)) { 494 if (process_combo_key_release(combo_index, combo, key_index, keycode)) {
483 release_combo(combo_index, combo); 495 release_combo(combo_index, combo);
@@ -559,7 +571,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
559 key_buffer[key_buffer_size++] = (queued_record_t){ 571 key_buffer[key_buffer_size++] = (queued_record_t){
560 .record = *record, 572 .record = *record,
561 .keycode = keycode, 573 .keycode = keycode,
562 .combo_index = -1, // this will be set when applying combos 574 .combo_index = -1, // this will be set when applying combos
563 }; 575 };
564 } 576 }
565 } else { 577 } else {
@@ -598,7 +610,9 @@ void combo_task(void) {
598#endif 610#endif
599} 611}
600 612
601void combo_enable(void) { b_combo_enable = true; } 613void combo_enable(void) {
614 b_combo_enable = true;
615}
602 616
603void combo_disable(void) { 617void combo_disable(void) {
604#ifndef COMBO_NO_TIMER 618#ifndef COMBO_NO_TIMER
@@ -618,4 +632,6 @@ void combo_toggle(void) {
618 } 632 }
619} 633}
620 634
621bool is_combo_enabled(void) { return b_combo_enable; } 635bool is_combo_enabled(void) {
636 return b_combo_enable;
637}
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c
index 0feb634014..a1ada2d5a2 100644
--- a/quantum/process_keycode/process_dynamic_macro.c
+++ b/quantum/process_keycode/process_dynamic_macro.c
@@ -29,13 +29,21 @@ void dynamic_macro_led_blink(void) {
29 29
30/* User hooks for Dynamic Macros */ 30/* User hooks for Dynamic Macros */
31 31
32__attribute__((weak)) void dynamic_macro_record_start_user(void) { dynamic_macro_led_blink(); } 32__attribute__((weak)) void dynamic_macro_record_start_user(void) {
33 dynamic_macro_led_blink();
34}
33 35
34__attribute__((weak)) void dynamic_macro_play_user(int8_t direction) { dynamic_macro_led_blink(); } 36__attribute__((weak)) void dynamic_macro_play_user(int8_t direction) {
37 dynamic_macro_led_blink();
38}
35 39
36__attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) { dynamic_macro_led_blink(); } 40__attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) {
41 dynamic_macro_led_blink();
42}
37 43
38__attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) { dynamic_macro_led_blink(); } 44__attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) {
45 dynamic_macro_led_blink();
46}
39 47
40/* Convenience macros used for retrieving the debug info. All of them 48/* Convenience macros used for retrieving the debug info. All of them
41 * need a `direction` variable accessible at the call site. 49 * need a `direction` variable accessible at the call site.
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c
index fa9c2c1dbc..2fb092c573 100644
--- a/quantum/process_keycode/process_joystick.c
+++ b/quantum/process_keycode/process_joystick.c
@@ -74,7 +74,9 @@ void restorePinState(pin_t pin, uint16_t restoreState) {
74#endif 74#endif
75} 75}
76 76
77__attribute__((weak)) bool process_joystick_analogread() { return process_joystick_analogread_quantum(); } 77__attribute__((weak)) bool process_joystick_analogread() {
78 return process_joystick_analogread_quantum();
79}
78 80
79bool process_joystick_analogread_quantum() { 81bool process_joystick_analogread_quantum() {
80#if JOYSTICK_AXES_COUNT > 0 82#if JOYSTICK_AXES_COUNT > 0
diff --git a/quantum/process_keycode/process_key_override.c b/quantum/process_keycode/process_key_override.c
index 09b2725079..ad9683d106 100644
--- a/quantum/process_keycode/process_key_override.c
+++ b/quantum/process_keycode/process_key_override.c
@@ -106,7 +106,9 @@ void key_override_toggle(void) {
106 } 106 }
107} 107}
108 108
109bool key_override_is_enabled(void) { return enabled; } 109bool key_override_is_enabled(void) {
110 return enabled;
111}
110 112
111// Returns whether the modifiers that are pressed are such that the override should activate 113// Returns whether the modifiers that are pressed are such that the override should activate
112static bool key_override_matches_active_modifiers(const key_override_t *override, const uint8_t mods) { 114static bool key_override_matches_active_modifiers(const key_override_t *override, const uint8_t mods) {
@@ -150,7 +152,7 @@ static void schedule_deferred_register(const uint16_t keycode) {
150 } else { 152 } else {
151 // Wait a very short time when a modifier event triggers the override to avoid false activations when e.g. a modifier is pressed just before a key is released (with the intention of pairing the modifier with a different key), or a modifier is lifted shortly before the trigger key is lifted. Operating systems by default reject modifier-events that happen very close to a non-modifier event. 153 // Wait a very short time when a modifier event triggers the override to avoid false activations when e.g. a modifier is pressed just before a key is released (with the intention of pairing the modifier with a different key), or a modifier is lifted shortly before the trigger key is lifted. Operating systems by default reject modifier-events that happen very close to a non-modifier event.
152 defer_reference_time = timer_read32(); 154 defer_reference_time = timer_read32();
153 defer_delay = 50; // 50ms 155 defer_delay = 50; // 50ms
154 } 156 }
155 deferred_register = keycode; 157 deferred_register = keycode;
156} 158}
@@ -174,8 +176,8 @@ const key_override_t *clear_active_override(const bool allow_reregister) {
174 176
175 const uint8_t mod_free_replacement = clear_mods_from(active_override->replacement); 177 const uint8_t mod_free_replacement = clear_mods_from(active_override->replacement);
176 178
177 bool unregister_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered 179 bool unregister_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered
178 mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered 180 mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered
179 181
180 // Try firing the custom handler 182 // Try firing the custom handler
181 if (active_override->custom_action != NULL) { 183 if (active_override->custom_action != NULL) {
@@ -195,11 +197,11 @@ const key_override_t *clear_active_override(const bool allow_reregister) {
195 197
196 const uint16_t trigger = active_override->trigger; 198 const uint16_t trigger = active_override->trigger;
197 199
198 const bool reregister_trigger = allow_reregister && // Check if allowed from caller 200 const bool reregister_trigger = allow_reregister && // Check if allowed from caller
199 (active_override->options & ko_option_no_reregister_trigger) == 0 && // Check if override allows 201 (active_override->options & ko_option_no_reregister_trigger) == 0 && // Check if override allows
200 active_override_trigger_is_down && // Check if trigger is even down 202 active_override_trigger_is_down && // Check if trigger is even down
201 trigger != KC_NO && // KC_NO is never registered 203 trigger != KC_NO && // KC_NO is never registered
202 trigger < SAFE_RANGE; // A custom keycode should not be registered 204 trigger < SAFE_RANGE; // A custom keycode should not be registered
203 205
204 // Optionally re-register the trigger if it is still down 206 // Optionally re-register the trigger if it is still down
205 if (reregister_trigger) { 207 if (reregister_trigger) {
@@ -336,8 +338,8 @@ static bool try_activating_override(const uint16_t keycode, const uint8_t layer,
336 338
337 const uint16_t mod_free_replacement = clear_mods_from(override->replacement); 339 const uint16_t mod_free_replacement = clear_mods_from(override->replacement);
338 340
339 bool register_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered 341 bool register_replacement = mod_free_replacement != KC_NO && // KC_NO is never registered
340 mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered 342 mod_free_replacement < SAFE_RANGE; // Custom keycodes are never registered
341 343
342 // Try firing the custom handler 344 // Try firing the custom handler
343 if (override->custom_action != NULL) { 345 if (override->custom_action != NULL) {
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index cf63f25141..c2fd02e5c7 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -51,13 +51,13 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) {
51 if (leading) { 51 if (leading) {
52# ifndef LEADER_NO_TIMEOUT 52# ifndef LEADER_NO_TIMEOUT
53 if (timer_elapsed(leader_time) < LEADER_TIMEOUT) 53 if (timer_elapsed(leader_time) < LEADER_TIMEOUT)
54# endif // LEADER_NO_TIMEOUT 54# endif // LEADER_NO_TIMEOUT
55 { 55 {
56# ifndef LEADER_KEY_STRICT_KEY_PROCESSING 56# ifndef LEADER_KEY_STRICT_KEY_PROCESSING
57 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { 57 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
58 keycode = keycode & 0xFF; 58 keycode = keycode & 0xFF;
59 } 59 }
60# endif // LEADER_KEY_STRICT_KEY_PROCESSING 60# endif // LEADER_KEY_STRICT_KEY_PROCESSING
61 if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) { 61 if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) {
62 leader_sequence[leader_sequence_size] = keycode; 62 leader_sequence[leader_sequence_size] = keycode;
63 leader_sequence_size++; 63 leader_sequence_size++;
diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c
index 6332be647c..10161adda3 100644
--- a/quantum/process_keycode/process_magic.c
+++ b/quantum/process_keycode/process_magic.c
@@ -76,7 +76,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
76 keymap_config.swap_backslash_backspace = true; 76 keymap_config.swap_backslash_backspace = true;
77 break; 77 break;
78 case MAGIC_HOST_NKRO: 78 case MAGIC_HOST_NKRO:
79 clear_keyboard(); // clear first buffer to prevent stuck keys 79 clear_keyboard(); // clear first buffer to prevent stuck keys
80 keymap_config.nkro = true; 80 keymap_config.nkro = true;
81 break; 81 break;
82 case MAGIC_SWAP_ALT_GUI: 82 case MAGIC_SWAP_ALT_GUI:
@@ -119,7 +119,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
119 keymap_config.swap_backslash_backspace = false; 119 keymap_config.swap_backslash_backspace = false;
120 break; 120 break;
121 case MAGIC_UNHOST_NKRO: 121 case MAGIC_UNHOST_NKRO:
122 clear_keyboard(); // clear first buffer to prevent stuck keys 122 clear_keyboard(); // clear first buffer to prevent stuck keys
123 keymap_config.nkro = false; 123 keymap_config.nkro = false;
124 break; 124 break;
125 case MAGIC_UNSWAP_ALT_GUI: 125 case MAGIC_UNSWAP_ALT_GUI:
@@ -157,7 +157,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
157#endif 157#endif
158 break; 158 break;
159 case MAGIC_TOGGLE_NKRO: 159 case MAGIC_TOGGLE_NKRO:
160 clear_keyboard(); // clear first buffer to prevent stuck keys 160 clear_keyboard(); // clear first buffer to prevent stuck keys
161 keymap_config.nkro = !keymap_config.nkro; 161 keymap_config.nkro = !keymap_config.nkro;
162 break; 162 break;
163 case MAGIC_EE_HANDS_LEFT: 163 case MAGIC_EE_HANDS_LEFT:
@@ -175,7 +175,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
175 } 175 }
176 176
177 eeconfig_update_keymap(keymap_config.raw); 177 eeconfig_update_keymap(keymap_config.raw);
178 clear_keyboard(); // clear to prevent stuck keys 178 clear_keyboard(); // clear to prevent stuck keys
179 179
180 return false; 180 return false;
181 } 181 }
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index 9632d2b757..c49c31a525 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -22,13 +22,19 @@
22 22
23# ifdef MIDI_BASIC 23# ifdef MIDI_BASIC
24 24
25void process_midi_basic_noteon(uint8_t note) { midi_send_noteon(&midi_device, 0, note, 127); } 25void process_midi_basic_noteon(uint8_t note) {
26 midi_send_noteon(&midi_device, 0, note, 127);
27}
26 28
27void process_midi_basic_noteoff(uint8_t note) { midi_send_noteoff(&midi_device, 0, note, 0); } 29void process_midi_basic_noteoff(uint8_t note) {
30 midi_send_noteoff(&midi_device, 0, note, 0);
31}
28 32
29void process_midi_all_notes_off(void) { midi_send_cc(&midi_device, 0, 0x7B, 0); } 33void process_midi_all_notes_off(void) {
34 midi_send_cc(&midi_device, 0, 0x7B, 0);
35}
30 36
31# endif // MIDI_BASIC 37# endif // MIDI_BASIC
32 38
33# ifdef MIDI_ADVANCED 39# ifdef MIDI_ADVANCED
34 40
@@ -41,7 +47,9 @@ static int8_t midi_modulation_step;
41static uint16_t midi_modulation_timer; 47static uint16_t midi_modulation_timer;
42midi_config_t midi_config; 48midi_config_t midi_config;
43 49
44inline uint8_t compute_velocity(uint8_t setting) { return setting * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN)); } 50inline uint8_t compute_velocity(uint8_t setting) {
51 return setting * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN));
52}
45 53
46void midi_init(void) { 54void midi_init(void) {
47 midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN; 55 midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN;
@@ -60,7 +68,9 @@ void midi_init(void) {
60 midi_modulation_timer = 0; 68 midi_modulation_timer = 0;
61} 69}
62 70
63uint8_t midi_compute_note(uint16_t keycode) { return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose; } 71uint8_t midi_compute_note(uint16_t keycode) {
72 return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose;
73}
64 74
65bool process_midi(uint16_t keycode, keyrecord_t *record) { 75bool process_midi(uint16_t keycode, keyrecord_t *record) {
66 switch (keycode) { 76 switch (keycode) {
@@ -238,7 +248,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) {
238 return true; 248 return true;
239} 249}
240 250
241# endif // MIDI_ADVANCED 251# endif // MIDI_ADVANCED
242 252
243void midi_task(void) { 253void midi_task(void) {
244 midi_device_process(&midi_device); 254 midi_device_process(&midi_device);
@@ -263,4 +273,4 @@ void midi_task(void) {
263# endif 273# endif
264} 274}
265 275
266#endif // MIDI_ENABLE 276#endif // MIDI_ENABLE
diff --git a/quantum/process_keycode/process_midi.h b/quantum/process_keycode/process_midi.h
index 68c6eda666..e528c6ec0c 100644
--- a/quantum/process_keycode/process_midi.h
+++ b/quantum/process_keycode/process_midi.h
@@ -49,6 +49,6 @@ bool process_midi(uint16_t keycode, keyrecord_t *record);
49# define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1) 49# define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1)
50 50
51uint8_t midi_compute_note(uint16_t keycode); 51uint8_t midi_compute_note(uint16_t keycode);
52# endif // MIDI_ADVANCED 52# endif // MIDI_ADVANCED
53 53
54#endif // MIDI_ENABLE 54#endif // MIDI_ENABLE
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c
index 6822c5e289..eeec0c28a4 100644
--- a/quantum/process_keycode/process_music.c
+++ b/quantum/process_keycode/process_music.c
@@ -146,7 +146,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
146 146
147 if (music_activated || midi_activated) { 147 if (music_activated || midi_activated) {
148 if (record->event.pressed) { 148 if (record->event.pressed) {
149 if (keycode == KC_LEFT_CTRL) { // Start recording 149 if (keycode == KC_LEFT_CTRL) { // Start recording
150 music_all_notes_off(); 150 music_all_notes_off();
151 music_sequence_recording = true; 151 music_sequence_recording = true;
152 music_sequence_recorded = false; 152 music_sequence_recorded = false;
@@ -155,9 +155,9 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
155 return false; 155 return false;
156 } 156 }
157 157
158 if (keycode == KC_LEFT_ALT) { // Stop recording/playing 158 if (keycode == KC_LEFT_ALT) { // Stop recording/playing
159 music_all_notes_off(); 159 music_all_notes_off();
160 if (music_sequence_recording) { // was recording 160 if (music_sequence_recording) { // was recording
161 music_sequence_recorded = true; 161 music_sequence_recorded = true;
162 } 162 }
163 music_sequence_recording = false; 163 music_sequence_recording = false;
@@ -165,7 +165,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
165 return false; 165 return false;
166 } 166 }
167 167
168 if (keycode == KC_LEFT_GUI && music_sequence_recorded) { // Start playing 168 if (keycode == KC_LEFT_GUI && music_sequence_recorded) { // Start playing
169 music_all_notes_off(); 169 music_all_notes_off();
170 music_sequence_recording = false; 170 music_sequence_recording = false;
171 music_sequence_playing = true; 171 music_sequence_playing = true;
@@ -230,11 +230,17 @@ bool music_mask(uint16_t keycode) {
230# endif 230# endif
231} 231}
232 232
233__attribute__((weak)) bool music_mask_kb(uint16_t keycode) { return music_mask_user(keycode); } 233__attribute__((weak)) bool music_mask_kb(uint16_t keycode) {
234 return music_mask_user(keycode);
235}
234 236
235__attribute__((weak)) bool music_mask_user(uint16_t keycode) { return keycode < 0xFF; } 237__attribute__((weak)) bool music_mask_user(uint16_t keycode) {
238 return keycode < 0xFF;
239}
236 240
237bool is_music_on(void) { return (music_activated != 0); } 241bool is_music_on(void) {
242 return (music_activated != 0);
243}
238 244
239void music_toggle(void) { 245void music_toggle(void) {
240 if (!music_activated) { 246 if (!music_activated) {
@@ -260,7 +266,9 @@ void music_off(void) {
260# endif 266# endif
261} 267}
262 268
263bool is_midi_on(void) { return (midi_activated != 0); } 269bool is_midi_on(void) {
270 return (midi_activated != 0);
271}
264 272
265void midi_toggle(void) { 273void midi_toggle(void) {
266 if (!midi_activated) { 274 if (!midi_activated) {
@@ -315,4 +323,4 @@ __attribute__((weak)) void midi_on_user() {}
315 323
316__attribute__((weak)) void music_scale_user() {} 324__attribute__((weak)) void music_scale_user() {}
317 325
318#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) 326#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h
index e275cd9d26..83726a05ba 100644
--- a/quantum/process_keycode/process_music.h
+++ b/quantum/process_keycode/process_music.h
@@ -51,8 +51,10 @@ bool music_mask_kb(uint16_t keycode);
51bool music_mask_user(uint16_t keycode); 51bool music_mask_user(uint16_t keycode);
52 52
53# ifndef SCALE 53# ifndef SCALE
54# define SCALE \ 54# define SCALE \
55 (int8_t[]) { 0 + (12 * 0), 2 + (12 * 0), 4 + (12 * 0), 5 + (12 * 0), 7 + (12 * 0), 9 + (12 * 0), 11 + (12 * 0), 0 + (12 * 1), 2 + (12 * 1), 4 + (12 * 1), 5 + (12 * 1), 7 + (12 * 1), 9 + (12 * 1), 11 + (12 * 1), 0 + (12 * 2), 2 + (12 * 2), 4 + (12 * 2), 5 + (12 * 2), 7 + (12 * 2), 9 + (12 * 2), 11 + (12 * 2), 0 + (12 * 3), 2 + (12 * 3), 4 + (12 * 3), 5 + (12 * 3), 7 + (12 * 3), 9 + (12 * 3), 11 + (12 * 3), 0 + (12 * 4), 2 + (12 * 4), 4 + (12 * 4), 5 + (12 * 4), 7 + (12 * 4), 9 + (12 * 4), 11 + (12 * 4), } 55 (int8_t[]) { \
56 0 + (12 * 0), 2 + (12 * 0), 4 + (12 * 0), 5 + (12 * 0), 7 + (12 * 0), 9 + (12 * 0), 11 + (12 * 0), 0 + (12 * 1), 2 + (12 * 1), 4 + (12 * 1), 5 + (12 * 1), 7 + (12 * 1), 9 + (12 * 1), 11 + (12 * 1), 0 + (12 * 2), 2 + (12 * 2), 4 + (12 * 2), 5 + (12 * 2), 7 + (12 * 2), 9 + (12 * 2), 11 + (12 * 2), 0 + (12 * 3), 2 + (12 * 3), 4 + (12 * 3), 5 + (12 * 3), 7 + (12 * 3), 9 + (12 * 3), 11 + (12 * 3), 0 + (12 * 4), 2 + (12 * 4), 4 + (12 * 4), 5 + (12 * 4), 7 + (12 * 4), 9 + (12 * 4), 11 + (12 * 4), \
57 }
56# endif 58# endif
57 59
58#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) 60#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c
index 0801f078ef..6dd1f28c9b 100644
--- a/quantum/process_keycode/process_printer.c
+++ b/quantum/process_keycode/process_printer.c
@@ -26,7 +26,9 @@ void enable_printing(void) {
26 uart_init(19200); 26 uart_init(19200);
27} 27}
28 28
29void disable_printing(void) { printing_enabled = false; } 29void disable_printing(void) {
30 printing_enabled = false;
31}
30 32
31uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; 33uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29};
32 34
@@ -41,7 +43,8 @@ void print_char(char c) {
41} 43}
42 44
43void print_string(char c[]) { 45void print_string(char c[]) {
44 for (uint8_t i = 0; i < strlen(c); i++) print_char(c[i]); 46 for (uint8_t i = 0; i < strlen(c); i++)
47 print_char(c[i]);
45} 48}
46 49
47void print_box_string(const char text[]) { 50void print_box_string(const char text[]) {
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c
index 6c91bd27ef..88a9f33994 100644
--- a/quantum/process_keycode/process_printer_bb.c
+++ b/quantum/process_keycode/process_printer_bb.c
@@ -25,13 +25,21 @@ uint8_t character_shift = 0;
25#define SERIAL_PIN_MASK _BV(PD3) 25#define SERIAL_PIN_MASK _BV(PD3)
26#define SERIAL_DELAY 52 26#define SERIAL_DELAY 52
27 27
28inline static void serial_delay(void) { _delay_us(SERIAL_DELAY); } 28inline static void serial_delay(void) {
29 _delay_us(SERIAL_DELAY);
30}
29 31
30inline static void serial_high(void) { SERIAL_PIN_PORT |= SERIAL_PIN_MASK; } 32inline static void serial_high(void) {
33 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
34}
31 35
32inline static void serial_low(void) { SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; } 36inline static void serial_low(void) {
37 SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
38}
33 39
34inline static void serial_output(void) { SERIAL_PIN_DDR |= SERIAL_PIN_MASK; } 40inline static void serial_output(void) {
41 SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
42}
35 43
36void enable_printing() { 44void enable_printing() {
37 printing_enabled = true; 45 printing_enabled = true;
@@ -39,7 +47,9 @@ void enable_printing() {
39 serial_high(); 47 serial_high();
40} 48}
41 49
42void disable_printing() { printing_enabled = false; } 50void disable_printing() {
51 printing_enabled = false;
52}
43 53
44uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; 54uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29};
45 55
@@ -61,7 +71,8 @@ void print_char(char c) {
61} 71}
62 72
63void print_string(char c[]) { 73void print_string(char c[]) {
64 for (uint8_t i = 0; i < strlen(c); i++) print_char(c[i]); 74 for (uint8_t i = 0; i < strlen(c); i++)
75 print_char(c[i]);
65} 76}
66 77
67bool process_printer(uint16_t keycode, keyrecord_t *record) { 78bool process_printer(uint16_t keycode, keyrecord_t *record) {
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
index 5d0bb313b4..12ee898212 100644
--- a/quantum/process_keycode/process_steno.c
+++ b/quantum/process_keycode/process_steno.c
@@ -102,11 +102,17 @@ void steno_set_mode(steno_mode_t new_mode) {
102/* override to intercept chords right before they get sent. 102/* override to intercept chords right before they get sent.
103 * return zero to suppress normal sending behavior. 103 * return zero to suppress normal sending behavior.
104 */ 104 */
105__attribute__((weak)) bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) { return true; } 105__attribute__((weak)) bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) {
106 return true;
107}
106 108
107__attribute__((weak)) bool postprocess_steno_user(uint16_t keycode, keyrecord_t *record, steno_mode_t mode, uint8_t chord[6], int8_t pressed) { return true; } 109__attribute__((weak)) bool postprocess_steno_user(uint16_t keycode, keyrecord_t *record, steno_mode_t mode, uint8_t chord[6], int8_t pressed) {
110 return true;
111}
108 112
109__attribute__((weak)) bool process_steno_user(uint16_t keycode, keyrecord_t *record) { return true; } 113__attribute__((weak)) bool process_steno_user(uint16_t keycode, keyrecord_t *record) {
114 return true;
115}
110 116
111static void send_steno_chord(void) { 117static void send_steno_chord(void) {
112 if (send_steno_chord_user(mode, chord)) { 118 if (send_steno_chord_user(mode, chord)) {
@@ -114,11 +120,11 @@ static void send_steno_chord(void) {
114 case STENO_MODE_BOLT: 120 case STENO_MODE_BOLT:
115 send_steno_state(BOLT_STATE_SIZE, false); 121 send_steno_state(BOLT_STATE_SIZE, false);
116#ifdef VIRTSER_ENABLE 122#ifdef VIRTSER_ENABLE
117 virtser_send(0); // terminating byte 123 virtser_send(0); // terminating byte
118#endif 124#endif
119 break; 125 break;
120 case STENO_MODE_GEMINI: 126 case STENO_MODE_GEMINI:
121 chord[0] |= 0x80; // Indicate start of packet 127 chord[0] |= 0x80; // Indicate start of packet
122 send_steno_state(GEMINI_STATE_SIZE, true); 128 send_steno_state(GEMINI_STATE_SIZE, true);
123 break; 129 break;
124 } 130 }
@@ -126,9 +132,13 @@ static void send_steno_chord(void) {
126 steno_clear_state(); 132 steno_clear_state();
127} 133}
128 134
129uint8_t *steno_get_state(void) { return &state[0]; } 135uint8_t *steno_get_state(void) {
136 return &state[0];
137}
130 138
131uint8_t *steno_get_chord(void) { return &chord[0]; } 139uint8_t *steno_get_chord(void) {
140 return &chord[0];
141}
132 142
133static bool update_state_bolt(uint8_t key, bool press) { 143static bool update_state_bolt(uint8_t key, bool press) {
134 uint8_t boltcode = pgm_read_byte(boltmap + key); 144 uint8_t boltcode = pgm_read_byte(boltmap + key);
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 035c9c265d..e99119b2ae 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -86,7 +86,9 @@ static inline void _process_tap_dance_action_fn(qk_tap_dance_state_t *state, voi
86 } 86 }
87} 87}
88 88
89static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) { _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap); } 89static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) {
90 _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap);
91}
90 92
91static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) { 93static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) {
92 if (action->state.finished) return; 94 if (action->state.finished) return;
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c
index a059f3a521..da1c4d506f 100644
--- a/quantum/process_keycode/process_terminal.c
+++ b/quantum/process_keycode/process_terminal.c
@@ -27,12 +27,12 @@
27bool terminal_enabled = false; 27bool terminal_enabled = false;
28char buffer[80] = ""; 28char buffer[80] = "";
29char cmd_buffer[CMD_BUFF_SIZE][80]; 29char cmd_buffer[CMD_BUFF_SIZE][80];
30bool cmd_buffer_enabled = true; // replace with ifdef? 30bool cmd_buffer_enabled = true; // replace with ifdef?
31char newline[2] = "\n"; 31char newline[2] = "\n";
32char arguments[6][20]; 32char arguments[6][20];
33bool firstTime = true; 33bool firstTime = true;
34 34
35short int current_cmd_buffer_pos = 0; // used for up/down arrows - keeps track of where you are in the command buffer 35short int current_cmd_buffer_pos = 0; // used for up/down arrows - keeps track of where you are in the command buffer
36 36
37__attribute__((weak)) const char terminal_prompt[8] = "> "; 37__attribute__((weak)) const char terminal_prompt[8] = "> ";
38 38
@@ -59,7 +59,8 @@ void enable_terminal(void) {
59 terminal_enabled = true; 59 terminal_enabled = true;
60 strcpy(buffer, ""); 60 strcpy(buffer, "");
61 memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80); 61 memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80);
62 for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); 62 for (int i = 0; i < 6; i++)
63 strcpy(arguments[i], "");
63 // select all text to start over 64 // select all text to start over
64 // SEND_STRING(SS_LCTL("a")); 65 // SEND_STRING(SS_LCTL("a"));
65 send_string(terminal_prompt); 66 send_string(terminal_prompt);
@@ -160,7 +161,7 @@ void print_cmd_buff(void) {
160 for (int i = 0; i < CMD_BUFF_SIZE; i++) { 161 for (int i = 0; i < CMD_BUFF_SIZE; i++) {
161 char tmpChar = ' '; 162 char tmpChar = ' ';
162 itoa(i, &tmpChar, 10); 163 itoa(i, &tmpChar, 10);
163 const char *tmpCnstCharStr = &tmpChar; // because sned_string wont take a normal char * 164 const char *tmpCnstCharStr = &tmpChar; // because sned_string wont take a normal char *
164 send_string(tmpCnstCharStr); 165 send_string(tmpCnstCharStr);
165 SEND_STRING(". "); 166 SEND_STRING(". ");
166 send_string(cmd_buffer[i]); 167 send_string(cmd_buffer[i]);
@@ -185,7 +186,7 @@ void terminal_help(void) {
185} 186}
186 187
187void command_not_found(void) { 188void command_not_found(void) {
188 wait_ms(50); // sometimes buffer isnt grabbed quick enough 189 wait_ms(50); // sometimes buffer isnt grabbed quick enough
189 SEND_STRING("command \""); 190 SEND_STRING("command \"");
190 send_string(buffer); 191 send_string(buffer);
191 SEND_STRING("\" not found\n"); 192 SEND_STRING("\" not found\n");
@@ -217,15 +218,16 @@ void process_terminal_command(void) {
217 218
218 if (terminal_enabled) { 219 if (terminal_enabled) {
219 strcpy(buffer, ""); 220 strcpy(buffer, "");
220 for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); 221 for (int i = 0; i < 6; i++)
222 strcpy(arguments[i], "");
221 SEND_STRING(SS_TAP(X_HOME)); 223 SEND_STRING(SS_TAP(X_HOME));
222 send_string(terminal_prompt); 224 send_string(terminal_prompt);
223 } 225 }
224} 226}
225void check_pos(void) { 227void check_pos(void) {
226 if (current_cmd_buffer_pos >= CMD_BUFF_SIZE) { // if over the top, move it back down to the top of the buffer so you can climb back down... 228 if (current_cmd_buffer_pos >= CMD_BUFF_SIZE) { // if over the top, move it back down to the top of the buffer so you can climb back down...
227 current_cmd_buffer_pos = CMD_BUFF_SIZE - 1; 229 current_cmd_buffer_pos = CMD_BUFF_SIZE - 1;
228 } else if (current_cmd_buffer_pos < 0) { //...and if you fall under the bottom of the buffer, reset back to 0 so you can climb back up 230 } else if (current_cmd_buffer_pos < 0) { //...and if you fall under the bottom of the buffer, reset back to 0 so you can climb back up
229 current_cmd_buffer_pos = 0; 231 current_cmd_buffer_pos = 0;
230 } 232 }
231} 233}
@@ -278,33 +280,33 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) {
278 case KC_RIGHT: 280 case KC_RIGHT:
279 return false; 281 return false;
280 break; 282 break;
281 case KC_UP: // 0 = recent 283 case KC_UP: // 0 = recent
282 check_pos(); // check our current buffer position is valid 284 check_pos(); // check our current buffer position is valid
283 if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { // once we get to the top, dont do anything 285 if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { // once we get to the top, dont do anything
284 str_len = strlen(buffer); 286 str_len = strlen(buffer);
285 for (int i = 0; i < str_len; ++i) { 287 for (int i = 0; i < str_len; ++i) {
286 send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already 288 send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already
287 // process_terminal(KC_BACKSPACE,record); 289 // process_terminal(KC_BACKSPACE,record);
288 } 290 }
289 strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80); 291 strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80);
290 292
291 send_string(buffer); 293 send_string(buffer);
292 ++current_cmd_buffer_pos; // get ready to access the above cmd if up/down is pressed again 294 ++current_cmd_buffer_pos; // get ready to access the above cmd if up/down is pressed again
293 } 295 }
294 return false; 296 return false;
295 break; 297 break;
296 case KC_DOWN: 298 case KC_DOWN:
297 check_pos(); 299 check_pos();
298 if (current_cmd_buffer_pos >= 0) { // once we get to the bottom, dont do anything 300 if (current_cmd_buffer_pos >= 0) { // once we get to the bottom, dont do anything
299 str_len = strlen(buffer); 301 str_len = strlen(buffer);
300 for (int i = 0; i < str_len; ++i) { 302 for (int i = 0; i < str_len; ++i) {
301 send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already 303 send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already
302 // process_terminal(KC_BACKSPACE,record); 304 // process_terminal(KC_BACKSPACE,record);
303 } 305 }
304 strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79); 306 strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79);
305 307
306 send_string(buffer); 308 send_string(buffer);
307 --current_cmd_buffer_pos; // get ready to access the above cmd if down/up is pressed again 309 --current_cmd_buffer_pos; // get ready to access the above cmd if down/up is pressed again
308 } 310 }
309 return false; 311 return false;
310 break; 312 break;
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c
index d084d2b66c..6a8d8f0ff6 100644
--- a/quantum/process_keycode/process_ucis.c
+++ b/quantum/process_keycode/process_ucis.c
@@ -27,7 +27,7 @@ void qk_ucis_start(void) {
27 27
28__attribute__((weak)) void qk_ucis_start_user(void) { 28__attribute__((weak)) void qk_ucis_start_user(void) {
29 unicode_input_start(); 29 unicode_input_start();
30 register_hex(0x2328); // ⌨ 30 register_hex(0x2328); // ⌨
31 unicode_input_finish(); 31 unicode_input_finish();
32} 32}
33 33
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 7685bb1c99..46b77e14ba 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -54,7 +54,9 @@ void unicode_input_mode_init(void) {
54 dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode); 54 dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode);
55} 55}
56 56
57uint8_t get_unicode_input_mode(void) { return unicode_config.input_mode; } 57uint8_t get_unicode_input_mode(void) {
58 return unicode_config.input_mode;
59}
58 60
59void set_unicode_input_mode(uint8_t mode) { 61void set_unicode_input_mode(uint8_t mode) {
60 unicode_config.input_mode = mode; 62 unicode_config.input_mode = mode;
@@ -76,7 +78,9 @@ void cycle_unicode_input_mode(int8_t offset) {
76#endif 78#endif
77} 79}
78 80
79void persist_unicode_input_mode(void) { eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); } 81void persist_unicode_input_mode(void) {
82 eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode);
83}
80 84
81__attribute__((weak)) void unicode_input_start(void) { 85__attribute__((weak)) void unicode_input_start(void) {
82 unicode_saved_caps_lock = host_keyboard_led_state().caps_lock; 86 unicode_saved_caps_lock = host_keyboard_led_state().caps_lock;
@@ -90,8 +94,8 @@ __attribute__((weak)) void unicode_input_start(void) {
90 tap_code(KC_CAPS_LOCK); 94 tap_code(KC_CAPS_LOCK);
91 } 95 }
92 96
93 unicode_saved_mods = get_mods(); // Save current mods 97 unicode_saved_mods = get_mods(); // Save current mods
94 clear_mods(); // Unregister mods to start from a clean state 98 clear_mods(); // Unregister mods to start from a clean state
95 99
96 switch (unicode_config.input_mode) { 100 switch (unicode_config.input_mode) {
97 case UC_MAC: 101 case UC_MAC:
@@ -140,7 +144,7 @@ __attribute__((weak)) void unicode_input_finish(void) {
140 break; 144 break;
141 } 145 }
142 146
143 set_mods(unicode_saved_mods); // Reregister previously set mods 147 set_mods(unicode_saved_mods); // Reregister previously set mods
144} 148}
145 149
146__attribute__((weak)) void unicode_input_cancel(void) { 150__attribute__((weak)) void unicode_input_cancel(void) {
@@ -165,7 +169,7 @@ __attribute__((weak)) void unicode_input_cancel(void) {
165 break; 169 break;
166 } 170 }
167 171
168 set_mods(unicode_saved_mods); // Reregister previously set mods 172 set_mods(unicode_saved_mods); // Reregister previously set mods
169} 173}
170 174
171// clang-format off 175// clang-format off
@@ -262,16 +266,16 @@ void send_unicode_hex_string(const char *str) {
262static const char *decode_utf8(const char *str, int32_t *code_point) { 266static const char *decode_utf8(const char *str, int32_t *code_point) {
263 const char *next; 267 const char *next;
264 268
265 if (str[0] < 0x80) { // U+0000-007F 269 if (str[0] < 0x80) { // U+0000-007F
266 *code_point = str[0]; 270 *code_point = str[0];
267 next = str + 1; 271 next = str + 1;
268 } else if ((str[0] & 0xE0) == 0xC0) { // U+0080-07FF 272 } else if ((str[0] & 0xE0) == 0xC0) { // U+0080-07FF
269 *code_point = ((int32_t)(str[0] & 0x1F) << 6) | ((int32_t)(str[1] & 0x3F) << 0); 273 *code_point = ((int32_t)(str[0] & 0x1F) << 6) | ((int32_t)(str[1] & 0x3F) << 0);
270 next = str + 2; 274 next = str + 2;
271 } else if ((str[0] & 0xF0) == 0xE0) { // U+0800-FFFF 275 } else if ((str[0] & 0xF0) == 0xE0) { // U+0800-FFFF
272 *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); 276 *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0);
273 next = str + 3; 277 next = str + 3;
274 } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF 278 } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF
275 *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0); 279 *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0);
276 next = str + 4; 280 next = str + 4;
277 } else { 281 } else {
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h
index 72defb445e..1a6607c757 100644
--- a/quantum/process_keycode/process_unicode_common.h
+++ b/quantum/process_keycode/process_unicode_common.h
@@ -59,12 +59,12 @@
59#define UC_OSX UC_MAC 59#define UC_OSX UC_MAC
60 60
61enum unicode_input_modes { 61enum unicode_input_modes {
62 UC_MAC, // macOS using Unicode Hex Input 62 UC_MAC, // macOS using Unicode Hex Input
63 UC_LNX, // Linux using IBus 63 UC_LNX, // Linux using IBus
64 UC_WIN, // Windows using EnableHexNumpad 64 UC_WIN, // Windows using EnableHexNumpad
65 UC_BSD, // BSD (not implemented) 65 UC_BSD, // BSD (not implemented)
66 UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) 66 UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose)
67 UC__COUNT // Number of available input modes (always leave at the end) 67 UC__COUNT // Number of available input modes (always leave at the end)
68}; 68};
69 69
70typedef union { 70typedef union {
diff --git a/quantum/programmable_button.c b/quantum/programmable_button.c
index be828fd17c..a3ef42d82b 100644
--- a/quantum/programmable_button.c
+++ b/quantum/programmable_button.c
@@ -22,16 +22,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22 22
23static uint32_t programmable_button_report = 0; 23static uint32_t programmable_button_report = 0;
24 24
25void programmable_button_clear(void) { programmable_button_report = 0; } 25void programmable_button_clear(void) {
26 programmable_button_report = 0;
27}
26 28
27void programmable_button_send(void) { host_programmable_button_send(programmable_button_report); } 29void programmable_button_send(void) {
30 host_programmable_button_send(programmable_button_report);
31}
28 32
29void programmable_button_on(uint8_t index) { programmable_button_report |= REPORT_BIT(index); } 33void programmable_button_on(uint8_t index) {
34 programmable_button_report |= REPORT_BIT(index);
35}
30 36
31void programmable_button_off(uint8_t index) { programmable_button_report &= ~REPORT_BIT(index); } 37void programmable_button_off(uint8_t index) {
38 programmable_button_report &= ~REPORT_BIT(index);
39}
32 40
33bool programmable_button_is_on(uint8_t index) { return !!(programmable_button_report & REPORT_BIT(index)); }; 41bool programmable_button_is_on(uint8_t index) {
42 return !!(programmable_button_report & REPORT_BIT(index));
43};
34 44
35uint32_t programmable_button_get_report(void) { return programmable_button_report; }; 45uint32_t programmable_button_get_report(void) {
46 return programmable_button_report;
47};
36 48
37void programmable_button_set_report(uint32_t report) { programmable_button_report = report; } 49void programmable_button_set_report(uint32_t report) {
50 programmable_button_report = report;
51}
diff --git a/quantum/quantum.c b/quantum/quantum.c
index fb6220efa2..dce41c08ae 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -56,7 +56,7 @@ uint8_t extract_mod_bits(uint16_t code) {
56 56
57 uint8_t mods_to_send = 0; 57 uint8_t mods_to_send = 0;
58 58
59 if (code & QK_RMODS_MIN) { // Right mod flag is set 59 if (code & QK_RMODS_MIN) { // Right mod flag is set
60 if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RIGHT_CTRL); 60 if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RIGHT_CTRL);
61 if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT); 61 if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT);
62 if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT); 62 if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT);
@@ -71,7 +71,9 @@ uint8_t extract_mod_bits(uint16_t code) {
71 return mods_to_send; 71 return mods_to_send;
72} 72}
73 73
74void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); } 74void do_code16(uint16_t code, void (*f)(uint8_t)) {
75 f(extract_mod_bits(code));
76}
75 77
76__attribute__((weak)) void register_code16(uint16_t code) { 78__attribute__((weak)) void register_code16(uint16_t code) {
77 if (IS_MOD(code) || code == KC_NO) { 79 if (IS_MOD(code) || code == KC_NO) {
@@ -101,13 +103,21 @@ __attribute__((weak)) void tap_code16(uint16_t code) {
101 unregister_code16(code); 103 unregister_code16(code);
102} 104}
103 105
104__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; } 106__attribute__((weak)) bool process_action_kb(keyrecord_t *record) {
107 return true;
108}
105 109
106__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); } 110__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
111 return process_record_user(keycode, record);
112}
107 113
108__attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } 114__attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) {
115 return true;
116}
109 117
110__attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { post_process_record_user(keycode, record); } 118__attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) {
119 post_process_record_user(keycode, record);
120}
111 121
112__attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {} 122__attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {}
113 123
@@ -123,7 +133,8 @@ void reset_keyboard(void) {
123 uint16_t timer_start = timer_read(); 133 uint16_t timer_start = timer_read();
124 PLAY_SONG(goodbye_song); 134 PLAY_SONG(goodbye_song);
125 shutdown_user(); 135 shutdown_user();
126 while (timer_elapsed(timer_start) < 250) wait_ms(1); 136 while (timer_elapsed(timer_start) < 250)
137 wait_ms(1);
127 stop_all_notes(); 138 stop_all_notes();
128#else 139#else
129 shutdown_user(); 140 shutdown_user();
@@ -178,7 +189,7 @@ bool pre_process_record_quantum(keyrecord_t *record) {
178 true)) { 189 true)) {
179 return false; 190 return false;
180 } 191 }
181 return true; // continue processing 192 return true; // continue processing
182} 193}
183 194
184/* Get keycode, and then call keyboard function */ 195/* Get keycode, and then call keyboard function */
@@ -367,11 +378,17 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_
367 return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); 378 return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3);
368} 379}
369 380
370void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } 381void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
382 layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3));
383}
371 384
372// TODO: remove legacy api 385// TODO: remove legacy api
373void matrix_init_quantum() { matrix_init_kb(); } 386void matrix_init_quantum() {
374void matrix_scan_quantum() { matrix_scan_kb(); } 387 matrix_init_kb();
388}
389void matrix_scan_quantum() {
390 matrix_scan_kb();
391}
375 392
376//------------------------------------------------------------------------------ 393//------------------------------------------------------------------------------
377// Override these functions in your keymap file to play different tunes on 394// Override these functions in your keymap file to play different tunes on
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index b5b3566786..2552c48165 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -77,421 +77,421 @@ enum quantum_keycodes {
77 77
78 // Loose keycodes - to be used directly 78 // Loose keycodes - to be used directly
79 QK_BOOTLOADER = 0x5C00, 79 QK_BOOTLOADER = 0x5C00,
80 QK_DEBUG_TOGGLE, // 5C01 80 QK_DEBUG_TOGGLE, // 5C01
81 81
82 // Magic 82 // Magic
83 MAGIC_SWAP_CONTROL_CAPSLOCK, // 5C02 83 MAGIC_SWAP_CONTROL_CAPSLOCK, // 5C02
84 MAGIC_CAPSLOCK_TO_CONTROL, // 5C03 84 MAGIC_CAPSLOCK_TO_CONTROL, // 5C03
85 MAGIC_SWAP_LALT_LGUI, // 5C04 85 MAGIC_SWAP_LALT_LGUI, // 5C04
86 MAGIC_SWAP_RALT_RGUI, // 5C05 86 MAGIC_SWAP_RALT_RGUI, // 5C05
87 MAGIC_NO_GUI, // 5C06 87 MAGIC_NO_GUI, // 5C06
88 MAGIC_SWAP_GRAVE_ESC, // 5C07 88 MAGIC_SWAP_GRAVE_ESC, // 5C07
89 MAGIC_SWAP_BACKSLASH_BACKSPACE, // 5C08 89 MAGIC_SWAP_BACKSLASH_BACKSPACE, // 5C08
90 MAGIC_HOST_NKRO, // 5C09 90 MAGIC_HOST_NKRO, // 5C09
91 MAGIC_SWAP_ALT_GUI, // 5C0A 91 MAGIC_SWAP_ALT_GUI, // 5C0A
92 MAGIC_UNSWAP_CONTROL_CAPSLOCK, // 5C0B 92 MAGIC_UNSWAP_CONTROL_CAPSLOCK, // 5C0B
93 MAGIC_UNCAPSLOCK_TO_CONTROL, // 5C0C 93 MAGIC_UNCAPSLOCK_TO_CONTROL, // 5C0C
94 MAGIC_UNSWAP_LALT_LGUI, // 5C0D 94 MAGIC_UNSWAP_LALT_LGUI, // 5C0D
95 MAGIC_UNSWAP_RALT_RGUI, // 5C0E 95 MAGIC_UNSWAP_RALT_RGUI, // 5C0E
96 MAGIC_UNNO_GUI, // 5C0F 96 MAGIC_UNNO_GUI, // 5C0F
97 MAGIC_UNSWAP_GRAVE_ESC, // 5C10 97 MAGIC_UNSWAP_GRAVE_ESC, // 5C10
98 MAGIC_UNSWAP_BACKSLASH_BACKSPACE, // 5C11 98 MAGIC_UNSWAP_BACKSLASH_BACKSPACE, // 5C11
99 MAGIC_UNHOST_NKRO, // 5C12 99 MAGIC_UNHOST_NKRO, // 5C12
100 MAGIC_UNSWAP_ALT_GUI, // 5C13 100 MAGIC_UNSWAP_ALT_GUI, // 5C13
101 MAGIC_TOGGLE_NKRO, // 5C14 101 MAGIC_TOGGLE_NKRO, // 5C14
102 MAGIC_TOGGLE_ALT_GUI, // 5C15 102 MAGIC_TOGGLE_ALT_GUI, // 5C15
103 103
104 // Grave Escape 104 // Grave Escape
105 QK_GRAVE_ESCAPE, // 5C16 105 QK_GRAVE_ESCAPE, // 5C16
106 106
107 // Auto Shift 107 // Auto Shift
108 KC_ASUP, // 5C17 108 KC_ASUP, // 5C17
109 KC_ASDN, // 5C18 109 KC_ASDN, // 5C18
110 KC_ASRP, // 5C19 110 KC_ASRP, // 5C19
111 KC_ASTG, // 5C1A 111 KC_ASTG, // 5C1A
112 KC_ASON, // 5C1B 112 KC_ASON, // 5C1B
113 KC_ASOFF, // 5C1C 113 KC_ASOFF, // 5C1C
114 114
115 // Audio 115 // Audio
116 AU_ON, // 5C1D 116 AU_ON, // 5C1D
117 AU_OFF, // 5C1E 117 AU_OFF, // 5C1E
118 AU_TOG, // 5C1F 118 AU_TOG, // 5C1F
119 119
120 // Audio Clicky 120 // Audio Clicky
121 CLICKY_TOGGLE, // 5C20 121 CLICKY_TOGGLE, // 5C20
122 CLICKY_ENABLE, // 5C21 122 CLICKY_ENABLE, // 5C21
123 CLICKY_DISABLE, // 5C22 123 CLICKY_DISABLE, // 5C22
124 CLICKY_UP, // 5C23 124 CLICKY_UP, // 5C23
125 CLICKY_DOWN, // 5C24 125 CLICKY_DOWN, // 5C24
126 CLICKY_RESET, // 5C25 126 CLICKY_RESET, // 5C25
127 127
128 // Music mode 128 // Music mode
129 MU_ON, // 5C26 129 MU_ON, // 5C26
130 MU_OFF, // 5C27 130 MU_OFF, // 5C27
131 MU_TOG, // 5C28 131 MU_TOG, // 5C28
132 MU_MOD, // 5C29 132 MU_MOD, // 5C29
133 MUV_IN, // 5C2A 133 MUV_IN, // 5C2A
134 MUV_DE, // 5C2B 134 MUV_DE, // 5C2B
135 135
136 // MIDI 136 // MIDI
137 MI_ON, // 5C2C 137 MI_ON, // 5C2C
138 MI_OFF, // 5C2D 138 MI_OFF, // 5C2D
139 MI_TOG, // 5C2E 139 MI_TOG, // 5C2E
140 140
141 MI_C, // 5C2F 141 MI_C, // 5C2F
142 MI_Cs, // 5C30 142 MI_Cs, // 5C30
143 MI_Db = MI_Cs, 143 MI_Db = MI_Cs,
144 MI_D, // 5C31 144 MI_D, // 5C31
145 MI_Ds, // 5C32 145 MI_Ds, // 5C32
146 MI_Eb = MI_Ds, 146 MI_Eb = MI_Ds,
147 MI_E, // 5C33 147 MI_E, // 5C33
148 MI_F, // 5C34 148 MI_F, // 5C34
149 MI_Fs, // 5C35 149 MI_Fs, // 5C35
150 MI_Gb = MI_Fs, 150 MI_Gb = MI_Fs,
151 MI_G, // 5C36 151 MI_G, // 5C36
152 MI_Gs, // 5C37 152 MI_Gs, // 5C37
153 MI_Ab = MI_Gs, 153 MI_Ab = MI_Gs,
154 MI_A, // 5C38 154 MI_A, // 5C38
155 MI_As, // 5C39 155 MI_As, // 5C39
156 MI_Bb = MI_As, 156 MI_Bb = MI_As,
157 MI_B, // 5C3A 157 MI_B, // 5C3A
158 158
159 MI_C_1, // 5C3B 159 MI_C_1, // 5C3B
160 MI_Cs_1, // 5C3C 160 MI_Cs_1, // 5C3C
161 MI_Db_1 = MI_Cs_1, 161 MI_Db_1 = MI_Cs_1,
162 MI_D_1, // 5C3D 162 MI_D_1, // 5C3D
163 MI_Ds_1, // 5C3E 163 MI_Ds_1, // 5C3E
164 MI_Eb_1 = MI_Ds_1, 164 MI_Eb_1 = MI_Ds_1,
165 MI_E_1, // 5C3F 165 MI_E_1, // 5C3F
166 MI_F_1, // 5C40 166 MI_F_1, // 5C40
167 MI_Fs_1, // 5C41 167 MI_Fs_1, // 5C41
168 MI_Gb_1 = MI_Fs_1, 168 MI_Gb_1 = MI_Fs_1,
169 MI_G_1, // 5C42 169 MI_G_1, // 5C42
170 MI_Gs_1, // 5C43 170 MI_Gs_1, // 5C43
171 MI_Ab_1 = MI_Gs_1, 171 MI_Ab_1 = MI_Gs_1,
172 MI_A_1, // 5C44 172 MI_A_1, // 5C44
173 MI_As_1, // 5C45 173 MI_As_1, // 5C45
174 MI_Bb_1 = MI_As_1, 174 MI_Bb_1 = MI_As_1,
175 MI_B_1, // 5C46 175 MI_B_1, // 5C46
176 176
177 MI_C_2, // 5C47 177 MI_C_2, // 5C47
178 MI_Cs_2, // 5C48 178 MI_Cs_2, // 5C48
179 MI_Db_2 = MI_Cs_2, 179 MI_Db_2 = MI_Cs_2,
180 MI_D_2, // 5C49 180 MI_D_2, // 5C49
181 MI_Ds_2, // 5C4A 181 MI_Ds_2, // 5C4A
182 MI_Eb_2 = MI_Ds_2, 182 MI_Eb_2 = MI_Ds_2,
183 MI_E_2, // 5C4B 183 MI_E_2, // 5C4B
184 MI_F_2, // 5C4C 184 MI_F_2, // 5C4C
185 MI_Fs_2, // 5C4D 185 MI_Fs_2, // 5C4D
186 MI_Gb_2 = MI_Fs_2, 186 MI_Gb_2 = MI_Fs_2,
187 MI_G_2, // 5C4E 187 MI_G_2, // 5C4E
188 MI_Gs_2, // 5C4F 188 MI_Gs_2, // 5C4F
189 MI_Ab_2 = MI_Gs_2, 189 MI_Ab_2 = MI_Gs_2,
190 MI_A_2, // 5C50 190 MI_A_2, // 5C50
191 MI_As_2, // 5C51 191 MI_As_2, // 5C51
192 MI_Bb_2 = MI_As_2, 192 MI_Bb_2 = MI_As_2,
193 MI_B_2, // 5C52 193 MI_B_2, // 5C52
194 194
195 MI_C_3, // 5C53 195 MI_C_3, // 5C53
196 MI_Cs_3, // 5C54 196 MI_Cs_3, // 5C54
197 MI_Db_3 = MI_Cs_3, 197 MI_Db_3 = MI_Cs_3,
198 MI_D_3, // 5C55 198 MI_D_3, // 5C55
199 MI_Ds_3, // 5C56 199 MI_Ds_3, // 5C56
200 MI_Eb_3 = MI_Ds_3, 200 MI_Eb_3 = MI_Ds_3,
201 MI_E_3, // 5C57 201 MI_E_3, // 5C57
202 MI_F_3, // 5C58 202 MI_F_3, // 5C58
203 MI_Fs_3, // 5C59 203 MI_Fs_3, // 5C59
204 MI_Gb_3 = MI_Fs_3, 204 MI_Gb_3 = MI_Fs_3,
205 MI_G_3, // 5C5A 205 MI_G_3, // 5C5A
206 MI_Gs_3, // 5C5B 206 MI_Gs_3, // 5C5B
207 MI_Ab_3 = MI_Gs_3, 207 MI_Ab_3 = MI_Gs_3,
208 MI_A_3, // 5C5C 208 MI_A_3, // 5C5C
209 MI_As_3, // 5C5D 209 MI_As_3, // 5C5D
210 MI_Bb_3 = MI_As_3, 210 MI_Bb_3 = MI_As_3,
211 MI_B_3, // 5C5E 211 MI_B_3, // 5C5E
212 212
213 MI_C_4, // 5C5F 213 MI_C_4, // 5C5F
214 MI_Cs_4, // 5C60 214 MI_Cs_4, // 5C60
215 MI_Db_4 = MI_Cs_4, 215 MI_Db_4 = MI_Cs_4,
216 MI_D_4, // 5C61 216 MI_D_4, // 5C61
217 MI_Ds_4, // 5C62 217 MI_Ds_4, // 5C62
218 MI_Eb_4 = MI_Ds_4, 218 MI_Eb_4 = MI_Ds_4,
219 MI_E_4, // 5C63 219 MI_E_4, // 5C63
220 MI_F_4, // 5C64 220 MI_F_4, // 5C64
221 MI_Fs_4, // 5C65 221 MI_Fs_4, // 5C65
222 MI_Gb_4 = MI_Fs_4, 222 MI_Gb_4 = MI_Fs_4,
223 MI_G_4, // 5C66 223 MI_G_4, // 5C66
224 MI_Gs_4, // 5C67 224 MI_Gs_4, // 5C67
225 MI_Ab_4 = MI_Gs_4, 225 MI_Ab_4 = MI_Gs_4,
226 MI_A_4, // 5C68 226 MI_A_4, // 5C68
227 MI_As_4, // 5C69 227 MI_As_4, // 5C69
228 MI_Bb_4 = MI_As_4, 228 MI_Bb_4 = MI_As_4,
229 MI_B_4, // 5C6A 229 MI_B_4, // 5C6A
230 230
231 MI_C_5, // 5C6B 231 MI_C_5, // 5C6B
232 MI_Cs_5, // 5C6C 232 MI_Cs_5, // 5C6C
233 MI_Db_5 = MI_Cs_5, 233 MI_Db_5 = MI_Cs_5,
234 MI_D_5, // 5C6D 234 MI_D_5, // 5C6D
235 MI_Ds_5, // 5C6E 235 MI_Ds_5, // 5C6E
236 MI_Eb_5 = MI_Ds_5, 236 MI_Eb_5 = MI_Ds_5,
237 MI_E_5, // 5C6F 237 MI_E_5, // 5C6F
238 MI_F_5, // 5C70 238 MI_F_5, // 5C70
239 MI_Fs_5, // 5C71 239 MI_Fs_5, // 5C71
240 MI_Gb_5 = MI_Fs_5, 240 MI_Gb_5 = MI_Fs_5,
241 MI_G_5, // 5C72 241 MI_G_5, // 5C72
242 MI_Gs_5, // 5C73 242 MI_Gs_5, // 5C73
243 MI_Ab_5 = MI_Gs_5, 243 MI_Ab_5 = MI_Gs_5,
244 MI_A_5, // 5C74 244 MI_A_5, // 5C74
245 MI_As_5, // 5C75 245 MI_As_5, // 5C75
246 MI_Bb_5 = MI_As_5, 246 MI_Bb_5 = MI_As_5,
247 MI_B_5, // 5C76 247 MI_B_5, // 5C76
248 248
249 MI_OCT_N2, // 5C77 249 MI_OCT_N2, // 5C77
250 MI_OCT_N1, // 5C78 250 MI_OCT_N1, // 5C78
251 MI_OCT_0, // 5C79 251 MI_OCT_0, // 5C79
252 MI_OCT_1, // 5C7A 252 MI_OCT_1, // 5C7A
253 MI_OCT_2, // 5C7B 253 MI_OCT_2, // 5C7B
254 MI_OCT_3, // 5C7C 254 MI_OCT_3, // 5C7C
255 MI_OCT_4, // 5C7D 255 MI_OCT_4, // 5C7D
256 MI_OCT_5, // 5C7E 256 MI_OCT_5, // 5C7E
257 MI_OCT_6, // 5C7F 257 MI_OCT_6, // 5C7F
258 MI_OCT_7, // 5C80 258 MI_OCT_7, // 5C80
259 MI_OCTD, // 5C81 259 MI_OCTD, // 5C81
260 MI_OCTU, // 5C82 260 MI_OCTU, // 5C82
261 261
262 MI_TRNS_N6, // 5C83 262 MI_TRNS_N6, // 5C83
263 MI_TRNS_N5, // 5C84 263 MI_TRNS_N5, // 5C84
264 MI_TRNS_N4, // 5C85 264 MI_TRNS_N4, // 5C85
265 MI_TRNS_N3, // 5C86 265 MI_TRNS_N3, // 5C86
266 MI_TRNS_N2, // 5C87 266 MI_TRNS_N2, // 5C87
267 MI_TRNS_N1, // 5C88 267 MI_TRNS_N1, // 5C88
268 MI_TRNS_0, // 5C89 268 MI_TRNS_0, // 5C89
269 MI_TRNS_1, // 5C8A 269 MI_TRNS_1, // 5C8A
270 MI_TRNS_2, // 5C8B 270 MI_TRNS_2, // 5C8B
271 MI_TRNS_3, // 5C8C 271 MI_TRNS_3, // 5C8C
272 MI_TRNS_4, // 5C8D 272 MI_TRNS_4, // 5C8D
273 MI_TRNS_5, // 5C8E 273 MI_TRNS_5, // 5C8E
274 MI_TRNS_6, // 5C8F 274 MI_TRNS_6, // 5C8F
275 MI_TRNSD, // 5C90 275 MI_TRNSD, // 5C90
276 MI_TRNSU, // 5C91 276 MI_TRNSU, // 5C91
277 277
278 MI_VEL_0, // 5C92 278 MI_VEL_0, // 5C92
279#ifdef VIA_ENABLE 279#ifdef VIA_ENABLE
280 MI_VEL_1 = MI_VEL_0, 280 MI_VEL_1 = MI_VEL_0,
281#else 281#else
282 MI_VEL_1, // 5C93 282 MI_VEL_1, // 5C93
283#endif 283#endif
284 MI_VEL_2, // 5C94 284 MI_VEL_2, // 5C94
285 MI_VEL_3, // 5C95 285 MI_VEL_3, // 5C95
286 MI_VEL_4, // 5C96 286 MI_VEL_4, // 5C96
287 MI_VEL_5, // 5C97 287 MI_VEL_5, // 5C97
288 MI_VEL_6, // 5C98 288 MI_VEL_6, // 5C98
289 MI_VEL_7, // 5C99 289 MI_VEL_7, // 5C99
290 MI_VEL_8, // 5C9A 290 MI_VEL_8, // 5C9A
291 MI_VEL_9, // 5C9B 291 MI_VEL_9, // 5C9B
292 MI_VEL_10, // 5C9C 292 MI_VEL_10, // 5C9C
293 MI_VELD, // 5C9D 293 MI_VELD, // 5C9D
294 MI_VELU, // 5C9E 294 MI_VELU, // 5C9E
295 295
296 MI_CH1, // 5C9F 296 MI_CH1, // 5C9F
297 MI_CH2, // 5CA0 297 MI_CH2, // 5CA0
298 MI_CH3, // 5CA1 298 MI_CH3, // 5CA1
299 MI_CH4, // 5CA2 299 MI_CH4, // 5CA2
300 MI_CH5, // 5CA3 300 MI_CH5, // 5CA3
301 MI_CH6, // 5CA4 301 MI_CH6, // 5CA4
302 MI_CH7, // 5CA5 302 MI_CH7, // 5CA5
303 MI_CH8, // 5CA6 303 MI_CH8, // 5CA6
304 MI_CH9, // 5CA7 304 MI_CH9, // 5CA7
305 MI_CH10, // 5CA8 305 MI_CH10, // 5CA8
306 MI_CH11, // 5CA9 306 MI_CH11, // 5CA9
307 MI_CH12, // 5CAA 307 MI_CH12, // 5CAA
308 MI_CH13, // 5CAB 308 MI_CH13, // 5CAB
309 MI_CH14, // 5CAC 309 MI_CH14, // 5CAC
310 MI_CH15, // 5CAD 310 MI_CH15, // 5CAD
311 MI_CH16, // 5CAE 311 MI_CH16, // 5CAE
312 MI_CHD, // 5CAF 312 MI_CHD, // 5CAF
313 MI_CHU, // 5CB0 313 MI_CHU, // 5CB0
314 314
315 MI_ALLOFF, // 5CB1 315 MI_ALLOFF, // 5CB1
316 316
317 MI_SUS, // 5CB2 317 MI_SUS, // 5CB2
318 MI_PORT, // 5CB3 318 MI_PORT, // 5CB3
319 MI_SOST, // 5CB4 319 MI_SOST, // 5CB4
320 MI_SOFT, // 5CB5 320 MI_SOFT, // 5CB5
321 MI_LEG, // 5CB6 321 MI_LEG, // 5CB6
322 322
323 MI_MOD, // 5CB7 323 MI_MOD, // 5CB7
324 MI_MODSD, // 5CB8 324 MI_MODSD, // 5CB8
325 MI_MODSU, // 5CB9 325 MI_MODSU, // 5CB9
326 326
327 MI_BENDD, // 5CBA 327 MI_BENDD, // 5CBA
328 MI_BENDU, // 5CBB 328 MI_BENDU, // 5CBB
329 329
330 // Backlight 330 // Backlight
331 BL_ON, // 5CBC 331 BL_ON, // 5CBC
332 BL_OFF, // 5CBD 332 BL_OFF, // 5CBD
333 BL_DEC, // 5CBE 333 BL_DEC, // 5CBE
334 BL_INC, // 5CBF 334 BL_INC, // 5CBF
335 BL_TOGG, // 5CC0 335 BL_TOGG, // 5CC0
336 BL_STEP, // 5CC1 336 BL_STEP, // 5CC1
337 BL_BRTG, // 5CC2 337 BL_BRTG, // 5CC2
338 338
339 // RGB underglow/matrix 339 // RGB underglow/matrix
340 RGB_TOG, // 5CC3 340 RGB_TOG, // 5CC3
341 RGB_MODE_FORWARD, // 5CC4 341 RGB_MODE_FORWARD, // 5CC4
342 RGB_MODE_REVERSE, // 5CC5 342 RGB_MODE_REVERSE, // 5CC5
343 RGB_HUI, // 5CC6 343 RGB_HUI, // 5CC6
344 RGB_HUD, // 5CC7 344 RGB_HUD, // 5CC7
345 RGB_SAI, // 5CC8 345 RGB_SAI, // 5CC8
346 RGB_SAD, // 5CC9 346 RGB_SAD, // 5CC9
347 RGB_VAI, // 5CCA 347 RGB_VAI, // 5CCA
348 RGB_VAD, // 5CCB 348 RGB_VAD, // 5CCB
349 RGB_SPI, // 5CCC 349 RGB_SPI, // 5CCC
350 RGB_SPD, // 5CCD 350 RGB_SPD, // 5CCD
351 RGB_MODE_PLAIN, // 5CCE 351 RGB_MODE_PLAIN, // 5CCE
352 RGB_MODE_BREATHE, // 5CCF 352 RGB_MODE_BREATHE, // 5CCF
353 RGB_MODE_RAINBOW, // 5CD0 353 RGB_MODE_RAINBOW, // 5CD0
354 RGB_MODE_SWIRL, // 5CD1 354 RGB_MODE_SWIRL, // 5CD1
355 RGB_MODE_SNAKE, // 5CD2 355 RGB_MODE_SNAKE, // 5CD2
356 RGB_MODE_KNIGHT, // 5CD3 356 RGB_MODE_KNIGHT, // 5CD3
357 RGB_MODE_XMAS, // 5CD4 357 RGB_MODE_XMAS, // 5CD4
358 RGB_MODE_GRADIENT, // 5CD5 358 RGB_MODE_GRADIENT, // 5CD5
359 RGB_MODE_RGBTEST, // 5CD6 359 RGB_MODE_RGBTEST, // 5CD6
360 360
361 // Velocikey 361 // Velocikey
362 VLK_TOG, // 5CD7 362 VLK_TOG, // 5CD7
363 363
364 // Space Cadet 364 // Space Cadet
365 KC_LSPO, // 5CD8 365 KC_LSPO, // 5CD8
366 KC_RSPC, // 5CD9 366 KC_RSPC, // 5CD9
367 KC_SFTENT, // 5CDA 367 KC_SFTENT, // 5CDA
368 368
369 // Thermal Printer 369 // Thermal Printer
370 PRINT_ON, // 5CDB 370 PRINT_ON, // 5CDB
371 PRINT_OFF, // 5CDC 371 PRINT_OFF, // 5CDC
372 372
373 // Bluetooth: output selection 373 // Bluetooth: output selection
374 OUT_AUTO, // 5CDD 374 OUT_AUTO, // 5CDD
375 OUT_USB, // 5CDE 375 OUT_USB, // 5CDE
376 376
377 // Clear EEPROM 377 // Clear EEPROM
378 QK_CLEAR_EEPROM, // 5CDF 378 QK_CLEAR_EEPROM, // 5CDF
379 379
380 // Unicode 380 // Unicode
381 UNICODE_MODE_FORWARD, // 5CE0 381 UNICODE_MODE_FORWARD, // 5CE0
382 UNICODE_MODE_REVERSE, // 5CE1 382 UNICODE_MODE_REVERSE, // 5CE1
383 UNICODE_MODE_MAC, // 5CE2 383 UNICODE_MODE_MAC, // 5CE2
384 UNICODE_MODE_LNX, // 5CE3 384 UNICODE_MODE_LNX, // 5CE3
385 UNICODE_MODE_WIN, // 5CE4 385 UNICODE_MODE_WIN, // 5CE4
386 UNICODE_MODE_BSD, // 5CE5 386 UNICODE_MODE_BSD, // 5CE5
387 UNICODE_MODE_WINC, // 5CE6 387 UNICODE_MODE_WINC, // 5CE6
388 388
389 // Haptic 389 // Haptic
390 HPT_ON, // 5CE7 390 HPT_ON, // 5CE7
391 HPT_OFF, // 5CE8 391 HPT_OFF, // 5CE8
392 HPT_TOG, // 5CE9 392 HPT_TOG, // 5CE9
393 HPT_RST, // 5CEA 393 HPT_RST, // 5CEA
394 HPT_FBK, // 5CEB 394 HPT_FBK, // 5CEB
395 HPT_BUZ, // 5CEC 395 HPT_BUZ, // 5CEC
396 HPT_MODI, // 5CED 396 HPT_MODI, // 5CED
397 HPT_MODD, // 5CEE 397 HPT_MODD, // 5CEE
398 HPT_CONT, // 5CEF 398 HPT_CONT, // 5CEF
399 HPT_CONI, // 5CF0 399 HPT_CONI, // 5CF0
400 HPT_COND, // 5CF1 400 HPT_COND, // 5CF1
401 HPT_DWLI, // 5CF2 401 HPT_DWLI, // 5CF2
402 HPT_DWLD, // 5CF3 402 HPT_DWLD, // 5CF3
403 403
404 // Space Cadet (continued) 404 // Space Cadet (continued)
405 KC_LCPO, // 5CF4 405 KC_LCPO, // 5CF4
406 KC_RCPC, // 5CF5 406 KC_RCPC, // 5CF5
407 KC_LAPO, // 5CF6 407 KC_LAPO, // 5CF6
408 KC_RAPC, // 5CF7 408 KC_RAPC, // 5CF7
409 409
410 // Combos 410 // Combos
411 CMB_ON, // 5CF8 411 CMB_ON, // 5CF8
412 CMB_OFF, // 5CF9 412 CMB_OFF, // 5CF9
413 CMB_TOG, // 5CFA 413 CMB_TOG, // 5CFA
414 414
415 // Magic (continued) 415 // Magic (continued)
416 MAGIC_SWAP_LCTL_LGUI, // 5CFB 416 MAGIC_SWAP_LCTL_LGUI, // 5CFB
417 MAGIC_SWAP_RCTL_RGUI, // 5CFC 417 MAGIC_SWAP_RCTL_RGUI, // 5CFC
418 MAGIC_UNSWAP_LCTL_LGUI, // 5CFD 418 MAGIC_UNSWAP_LCTL_LGUI, // 5CFD
419 MAGIC_UNSWAP_RCTL_RGUI, // 5CFE 419 MAGIC_UNSWAP_RCTL_RGUI, // 5CFE
420 MAGIC_SWAP_CTL_GUI, // 5CFF 420 MAGIC_SWAP_CTL_GUI, // 5CFF
421 MAGIC_UNSWAP_CTL_GUI, // 5D00 421 MAGIC_UNSWAP_CTL_GUI, // 5D00
422 MAGIC_TOGGLE_CTL_GUI, // 5D01 422 MAGIC_TOGGLE_CTL_GUI, // 5D01
423 MAGIC_EE_HANDS_LEFT, // 5D02 423 MAGIC_EE_HANDS_LEFT, // 5D02
424 MAGIC_EE_HANDS_RIGHT, // 5D03 424 MAGIC_EE_HANDS_RIGHT, // 5D03
425 425
426 // Dynamic Macros 426 // Dynamic Macros
427 DYN_REC_START1, // 5D04 427 DYN_REC_START1, // 5D04
428 DYN_REC_START2, // 5D05 428 DYN_REC_START2, // 5D05
429 DYN_REC_STOP, // 5D06 429 DYN_REC_STOP, // 5D06
430 DYN_MACRO_PLAY1, // 5D07 430 DYN_MACRO_PLAY1, // 5D07
431 DYN_MACRO_PLAY2, // 5D08 431 DYN_MACRO_PLAY2, // 5D08
432 432
433 // Joystick 433 // Joystick
434 JS_BUTTON0, // 5D09 434 JS_BUTTON0, // 5D09
435 JS_BUTTON1, // 5D0A 435 JS_BUTTON1, // 5D0A
436 JS_BUTTON2, // 5D0B 436 JS_BUTTON2, // 5D0B
437 JS_BUTTON3, // 5D0C 437 JS_BUTTON3, // 5D0C
438 JS_BUTTON4, // 5D0D 438 JS_BUTTON4, // 5D0D
439 JS_BUTTON5, // 5D0E 439 JS_BUTTON5, // 5D0E
440 JS_BUTTON6, // 5D0F 440 JS_BUTTON6, // 5D0F
441 JS_BUTTON7, // 5D10 441 JS_BUTTON7, // 5D10
442 JS_BUTTON8, // 5D11 442 JS_BUTTON8, // 5D11
443 JS_BUTTON9, // 5D12 443 JS_BUTTON9, // 5D12
444 JS_BUTTON10, // 5D13 444 JS_BUTTON10, // 5D13
445 JS_BUTTON11, // 5D14 445 JS_BUTTON11, // 5D14
446 JS_BUTTON12, // 5D15 446 JS_BUTTON12, // 5D15
447 JS_BUTTON13, // 5D16 447 JS_BUTTON13, // 5D16
448 JS_BUTTON14, // 5D17 448 JS_BUTTON14, // 5D17
449 JS_BUTTON15, // 5D18 449 JS_BUTTON15, // 5D18
450 JS_BUTTON16, // 5D19 450 JS_BUTTON16, // 5D19
451 JS_BUTTON17, // 5D1A 451 JS_BUTTON17, // 5D1A
452 JS_BUTTON18, // 5D1B 452 JS_BUTTON18, // 5D1B
453 JS_BUTTON19, // 5D1C 453 JS_BUTTON19, // 5D1C
454 JS_BUTTON20, // 5D1D 454 JS_BUTTON20, // 5D1D
455 JS_BUTTON21, // 5D1E 455 JS_BUTTON21, // 5D1E
456 JS_BUTTON22, // 5D1F 456 JS_BUTTON22, // 5D1F
457 JS_BUTTON23, // 5D20 457 JS_BUTTON23, // 5D20
458 JS_BUTTON24, // 5D21 458 JS_BUTTON24, // 5D21
459 JS_BUTTON25, // 5D22 459 JS_BUTTON25, // 5D22
460 JS_BUTTON26, // 5D23 460 JS_BUTTON26, // 5D23
461 JS_BUTTON27, // 5D24 461 JS_BUTTON27, // 5D24
462 JS_BUTTON28, // 5D25 462 JS_BUTTON28, // 5D25
463 JS_BUTTON29, // 5D26 463 JS_BUTTON29, // 5D26
464 JS_BUTTON30, // 5D27 464 JS_BUTTON30, // 5D27
465 JS_BUTTON31, // 5D28 465 JS_BUTTON31, // 5D28
466 466
467 // Leader Key 467 // Leader Key
468 KC_LEAD, // 5D29 468 KC_LEAD, // 5D29
469 469
470 // Bluetooth: output selection (continued) 470 // Bluetooth: output selection (continued)
471 OUT_BT, // 5D2A 471 OUT_BT, // 5D2A
472 472
473 // Lock Key 473 // Lock Key
474 KC_LOCK, // 5D2B 474 KC_LOCK, // 5D2B
475 475
476 // Terminal 476 // Terminal
477 TERM_ON, // 5D2C 477 TERM_ON, // 5D2C
478 TERM_OFF, // 5D2D 478 TERM_OFF, // 5D2D
479 479
480 // Sequencer 480 // Sequencer
481 SQ_ON, // 5D2E 481 SQ_ON, // 5D2E
482 SQ_OFF, // 5D2F 482 SQ_OFF, // 5D2F
483 SQ_TOG, // 5D30 483 SQ_TOG, // 5D30
484 484
485 SQ_TMPD, // 5D31 485 SQ_TMPD, // 5D31
486 SQ_TMPU, // 5D32 486 SQ_TMPU, // 5D32
487 487
488 SQ_RESD, // 5D33 488 SQ_RESD, // 5D33
489 SQ_RESU, // 5D34 489 SQ_RESU, // 5D34
490 490
491 SQ_SALL, // 5D35 491 SQ_SALL, // 5D35
492 SQ_SCLR, // 5D36 492 SQ_SCLR, // 5D36
493 493
494 SEQUENCER_STEP_MIN, // 5D37 494 SEQUENCER_STEP_MIN, // 5D37
495 SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS, 495 SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS,
496 496
497 SEQUENCER_RESOLUTION_MIN, 497 SEQUENCER_RESOLUTION_MIN,
@@ -636,69 +636,69 @@ enum quantum_keycodes {
636#define MOD_MEH 0x7 636#define MOD_MEH 0x7
637 637
638// US ANSI shifted keycode aliases 638// US ANSI shifted keycode aliases
639#define KC_TILDE LSFT(KC_GRAVE) // ~ 639#define KC_TILDE LSFT(KC_GRAVE) // ~
640#define KC_TILD KC_TILDE 640#define KC_TILD KC_TILDE
641 641
642#define KC_EXCLAIM LSFT(KC_1) // ! 642#define KC_EXCLAIM LSFT(KC_1) // !
643#define KC_EXLM KC_EXCLAIM 643#define KC_EXLM KC_EXCLAIM
644 644
645#define KC_AT LSFT(KC_2) // @ 645#define KC_AT LSFT(KC_2) // @
646 646
647#define KC_HASH LSFT(KC_3) // # 647#define KC_HASH LSFT(KC_3) // #
648 648
649#define KC_DOLLAR LSFT(KC_4) // $ 649#define KC_DOLLAR LSFT(KC_4) // $
650#define KC_DLR KC_DOLLAR 650#define KC_DLR KC_DOLLAR
651 651
652#define KC_PERCENT LSFT(KC_5) // % 652#define KC_PERCENT LSFT(KC_5) // %
653#define KC_PERC KC_PERCENT 653#define KC_PERC KC_PERCENT
654 654
655#define KC_CIRCUMFLEX LSFT(KC_6) // ^ 655#define KC_CIRCUMFLEX LSFT(KC_6) // ^
656#define KC_CIRC KC_CIRCUMFLEX 656#define KC_CIRC KC_CIRCUMFLEX
657 657
658#define KC_AMPERSAND LSFT(KC_7) // & 658#define KC_AMPERSAND LSFT(KC_7) // &
659#define KC_AMPR KC_AMPERSAND 659#define KC_AMPR KC_AMPERSAND
660 660
661#define KC_ASTERISK LSFT(KC_8) // * 661#define KC_ASTERISK LSFT(KC_8) // *
662#define KC_ASTR KC_ASTERISK 662#define KC_ASTR KC_ASTERISK
663 663
664#define KC_LEFT_PAREN LSFT(KC_9) // ( 664#define KC_LEFT_PAREN LSFT(KC_9) // (
665#define KC_LPRN KC_LEFT_PAREN 665#define KC_LPRN KC_LEFT_PAREN
666 666
667#define KC_RIGHT_PAREN LSFT(KC_0) // ) 667#define KC_RIGHT_PAREN LSFT(KC_0) // )
668#define KC_RPRN KC_RIGHT_PAREN 668#define KC_RPRN KC_RIGHT_PAREN
669 669
670#define KC_UNDERSCORE LSFT(KC_MINUS) // _ 670#define KC_UNDERSCORE LSFT(KC_MINUS) // _
671#define KC_UNDS KC_UNDERSCORE 671#define KC_UNDS KC_UNDERSCORE
672 672
673#define KC_PLUS LSFT(KC_EQUAL) // + 673#define KC_PLUS LSFT(KC_EQUAL) // +
674 674
675#define KC_LEFT_CURLY_BRACE LSFT(KC_LEFT_BRACKET) // { 675#define KC_LEFT_CURLY_BRACE LSFT(KC_LEFT_BRACKET) // {
676#define KC_LCBR KC_LEFT_CURLY_BRACE 676#define KC_LCBR KC_LEFT_CURLY_BRACE
677 677
678#define KC_RIGHT_CURLY_BRACE LSFT(KC_RIGHT_BRACKET) // } 678#define KC_RIGHT_CURLY_BRACE LSFT(KC_RIGHT_BRACKET) // }
679#define KC_RCBR KC_RIGHT_CURLY_BRACE 679#define KC_RCBR KC_RIGHT_CURLY_BRACE
680 680
681#define KC_LEFT_ANGLE_BRACKET LSFT(KC_COMMA) // < 681#define KC_LEFT_ANGLE_BRACKET LSFT(KC_COMMA) // <
682#define KC_LABK KC_LEFT_ANGLE_BRACKET 682#define KC_LABK KC_LEFT_ANGLE_BRACKET
683#define KC_LT KC_LEFT_ANGLE_BRACKET 683#define KC_LT KC_LEFT_ANGLE_BRACKET
684 684
685#define KC_RIGHT_ANGLE_BRACKET LSFT(KC_DOT) // > 685#define KC_RIGHT_ANGLE_BRACKET LSFT(KC_DOT) // >
686#define KC_RABK KC_RIGHT_ANGLE_BRACKET 686#define KC_RABK KC_RIGHT_ANGLE_BRACKET
687#define KC_GT KC_RIGHT_ANGLE_BRACKET 687#define KC_GT KC_RIGHT_ANGLE_BRACKET
688 688
689#define KC_COLON LSFT(KC_SEMICOLON) // : 689#define KC_COLON LSFT(KC_SEMICOLON) // :
690#define KC_COLN KC_COLON 690#define KC_COLN KC_COLON
691 691
692#define KC_PIPE LSFT(KC_BACKSLASH) // | 692#define KC_PIPE LSFT(KC_BACKSLASH) // |
693 693
694#define KC_QUESTION LSFT(KC_SLASH) // ? 694#define KC_QUESTION LSFT(KC_SLASH) // ?
695#define KC_QUES KC_QUESTION 695#define KC_QUES KC_QUESTION
696 696
697#define KC_DOUBLE_QUOTE LSFT(KC_QUOTE) // " 697#define KC_DOUBLE_QUOTE LSFT(KC_QUOTE) // "
698#define KC_DQUO KC_DOUBLE_QUOTE 698#define KC_DQUO KC_DOUBLE_QUOTE
699#define KC_DQT KC_DOUBLE_QUOTE 699#define KC_DQT KC_DOUBLE_QUOTE
700 700
701#define KC_DELT KC_DELETE // Del key (four letter code) 701#define KC_DELT KC_DELETE // Del key (four letter code)
702 702
703// Modified keycode aliases 703// Modified keycode aliases
704#define C(kc) LCTL(kc) 704#define C(kc) LCTL(kc)
@@ -841,22 +841,22 @@ enum quantum_keycodes {
841#define CMD_T(kc) LCMD_T(kc) 841#define CMD_T(kc) LCMD_T(kc)
842#define WIN_T(kc) LWIN_T(kc) 842#define WIN_T(kc) LWIN_T(kc)
843 843
844#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal 844#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
845#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt 845#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt
846#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI 846#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
847#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI 847#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
848#define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ 848#define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
849#define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI 849#define LSG_T(kc) MT(MOD_LSFT | MOD_LGUI, kc) // Left Shift + GUI
850#define SGUI_T(kc) LSG_T(kc) 850#define SGUI_T(kc) LSG_T(kc)
851#define SCMD_T(kc) LSG_T(kc) 851#define SCMD_T(kc) LSG_T(kc)
852#define SWIN_T(kc) LSG_T(kc) 852#define SWIN_T(kc) LSG_T(kc)
853#define LAG_T(kc) MT(MOD_LALT | MOD_LGUI, kc) // Left Alt + GUI 853#define LAG_T(kc) MT(MOD_LALT | MOD_LGUI, kc) // Left Alt + GUI
854#define RSG_T(kc) MT(MOD_RSFT | MOD_RGUI, kc) // Right Shift + GUI 854#define RSG_T(kc) MT(MOD_RSFT | MOD_RGUI, kc) // Right Shift + GUI
855#define RAG_T(kc) MT(MOD_RALT | MOD_RGUI, kc) // Right Alt + GUI 855#define RAG_T(kc) MT(MOD_RALT | MOD_RGUI, kc) // Right Alt + GUI
856#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt 856#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt
857#define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc) // Left Shift + Alt 857#define LSA_T(kc) MT(MOD_LSFT | MOD_LALT, kc) // Left Shift + Alt
858#define RSA_T(kc) MT(MOD_RSFT | MOD_RALT, kc) // Right Shift + Alt 858#define RSA_T(kc) MT(MOD_RSFT | MOD_RALT, kc) // Right Shift + Alt
859#define RCS_T(kc) MT(MOD_RCTL | MOD_RSFT, kc) // Right Control + Shift 859#define RCS_T(kc) MT(MOD_RCTL | MOD_RSFT, kc) // Right Control + Shift
860#define SAGR_T(kc) RSA_T(kc) 860#define SAGR_T(kc) RSA_T(kc)
861 861
862#define ALL_T(kc) HYPR_T(kc) 862#define ALL_T(kc) HYPR_T(kc)
@@ -870,14 +870,14 @@ enum quantum_keycodes {
870#define UC(c) (QK_UNICODE | (c)) 870#define UC(c) (QK_UNICODE | (c))
871// UNICODEMAP_ENABLE - Allows Unicode input up to 0x10FFFF, requires unicode_map 871// UNICODEMAP_ENABLE - Allows Unicode input up to 0x10FFFF, requires unicode_map
872#define X(i) (QK_UNICODEMAP | (i)) 872#define X(i) (QK_UNICODEMAP | (i))
873#define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j 873#define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j
874 874
875#define UC_MOD UNICODE_MODE_FORWARD 875#define UC_MOD UNICODE_MODE_FORWARD
876#define UC_RMOD UNICODE_MODE_REVERSE 876#define UC_RMOD UNICODE_MODE_REVERSE
877 877
878#define UC_M_MA UNICODE_MODE_MAC 878#define UC_M_MA UNICODE_MODE_MAC
879#define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias 879#define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias
880#define UC_M_OS UNICODE_MODE_MAC // Deprecated alias 880#define UC_M_OS UNICODE_MODE_MAC // Deprecated alias
881#define UC_M_LN UNICODE_MODE_LNX 881#define UC_M_LN UNICODE_MODE_LNX
882#define UC_M_WI UNICODE_MODE_WIN 882#define UC_M_WI UNICODE_MODE_WIN
883#define UC_M_BS UNICODE_MODE_BSD 883#define UC_M_BS UNICODE_MODE_BSD
diff --git a/quantum/rgb_matrix/animations/alpha_mods_anim.h b/quantum/rgb_matrix/animations/alpha_mods_anim.h
index d6136f1ba4..59b8381d69 100644
--- a/quantum/rgb_matrix/animations/alpha_mods_anim.h
+++ b/quantum/rgb_matrix/animations/alpha_mods_anim.h
@@ -22,5 +22,5 @@ bool ALPHAS_MODS(effect_params_t* params) {
22 return rgb_matrix_check_finished_leds(led_max); 22 return rgb_matrix_check_finished_leds(led_max);
23} 23}
24 24
25# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 25# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
26#endif // ENABLE_RGB_MATRIX_ALPHAS_MODS 26#endif // ENABLE_RGB_MATRIX_ALPHAS_MODS
diff --git a/quantum/rgb_matrix/animations/breathing_anim.h b/quantum/rgb_matrix/animations/breathing_anim.h
index 29187e1543..e9a3c96e1b 100644
--- a/quantum/rgb_matrix/animations/breathing_anim.h
+++ b/quantum/rgb_matrix/animations/breathing_anim.h
@@ -16,5 +16,5 @@ bool BREATHING(effect_params_t* params) {
16 return rgb_matrix_check_finished_leds(led_max); 16 return rgb_matrix_check_finished_leds(led_max);
17} 17}
18 18
19# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 19# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
20#endif // ENABLE_RGB_MATRIX_BREATHING 20#endif // ENABLE_RGB_MATRIX_BREATHING
diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h
index 0375d4937d..06aa8b5ed5 100644
--- a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h
+++ b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h
@@ -7,7 +7,9 @@ static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time)
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool BAND_PINWHEEL_SAT(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); } 10bool BAND_PINWHEEL_SAT(effect_params_t* params) {
11 return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT 15#endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h
index e40bf4cd1f..bcbc319498 100644
--- a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h
+++ b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h
@@ -7,7 +7,9 @@ static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time)
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool BAND_PINWHEEL_VAL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); } 10bool BAND_PINWHEEL_VAL(effect_params_t* params) {
11 return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL 15#endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
diff --git a/quantum/rgb_matrix/animations/colorband_sat_anim.h b/quantum/rgb_matrix/animations/colorband_sat_anim.h
index 1c4f7de575..cb0897ad3e 100644
--- a/quantum/rgb_matrix/animations/colorband_sat_anim.h
+++ b/quantum/rgb_matrix/animations/colorband_sat_anim.h
@@ -8,7 +8,9 @@ static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) {
8 return hsv; 8 return hsv;
9} 9}
10 10
11bool BAND_SAT(effect_params_t* params) { return effect_runner_i(params, &BAND_SAT_math); } 11bool BAND_SAT(effect_params_t* params) {
12 return effect_runner_i(params, &BAND_SAT_math);
13}
12 14
13# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 15# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
14#endif // ENABLE_RGB_MATRIX_BAND_SAT 16#endif // ENABLE_RGB_MATRIX_BAND_SAT
diff --git a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h
index cdd02b3797..d26eb37855 100644
--- a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h
+++ b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h
@@ -7,7 +7,9 @@ static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, u
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool BAND_SPIRAL_SAT(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); } 10bool BAND_SPIRAL_SAT(effect_params_t* params) {
11 return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT 15#endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
diff --git a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h
index e1331eaebe..3ae34bb6f0 100644
--- a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h
+++ b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h
@@ -7,7 +7,9 @@ static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, u
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool BAND_SPIRAL_VAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); } 10bool BAND_SPIRAL_VAL(effect_params_t* params) {
11 return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL 15#endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
diff --git a/quantum/rgb_matrix/animations/colorband_val_anim.h b/quantum/rgb_matrix/animations/colorband_val_anim.h
index 02ee4add67..69c29f53a3 100644
--- a/quantum/rgb_matrix/animations/colorband_val_anim.h
+++ b/quantum/rgb_matrix/animations/colorband_val_anim.h
@@ -8,7 +8,9 @@ static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) {
8 return hsv; 8 return hsv;
9} 9}
10 10
11bool BAND_VAL(effect_params_t* params) { return effect_runner_i(params, &BAND_VAL_math); } 11bool BAND_VAL(effect_params_t* params) {
12 return effect_runner_i(params, &BAND_VAL_math);
13}
12 14
13# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 15# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
14#endif // ENABLE_RGB_MATRIX_BAND_VAL 16#endif // ENABLE_RGB_MATRIX_BAND_VAL
diff --git a/quantum/rgb_matrix/animations/cycle_all_anim.h b/quantum/rgb_matrix/animations/cycle_all_anim.h
index 3b73b9d385..d8c7220d95 100644
--- a/quantum/rgb_matrix/animations/cycle_all_anim.h
+++ b/quantum/rgb_matrix/animations/cycle_all_anim.h
@@ -7,7 +7,9 @@ static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time) {
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool CYCLE_ALL(effect_params_t* params) { return effect_runner_i(params, &CYCLE_ALL_math); } 10bool CYCLE_ALL(effect_params_t* params) {
11 return effect_runner_i(params, &CYCLE_ALL_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_CYCLE_ALL 15#endif // ENABLE_RGB_MATRIX_CYCLE_ALL
diff --git a/quantum/rgb_matrix/animations/cycle_left_right_anim.h b/quantum/rgb_matrix/animations/cycle_left_right_anim.h
index bf6a574069..84c2127aff 100644
--- a/quantum/rgb_matrix/animations/cycle_left_right_anim.h
+++ b/quantum/rgb_matrix/animations/cycle_left_right_anim.h
@@ -7,7 +7,9 @@ static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) {
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); } 10bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
11 return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT 15#endif // ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
diff --git a/quantum/rgb_matrix/animations/cycle_out_in_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_anim.h
index 2bdb9d9375..9513fe9593 100644
--- a/quantum/rgb_matrix/animations/cycle_out_in_anim.h
+++ b/quantum/rgb_matrix/animations/cycle_out_in_anim.h
@@ -7,7 +7,9 @@ static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); } 10bool CYCLE_OUT_IN(effect_params_t* params) {
11 return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN 15#endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN
diff --git a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h
index 51979c44fe..3cca45f27a 100644
--- a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h
+++ b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h
@@ -9,7 +9,9 @@ static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time)
9 return hsv; 9 return hsv;
10} 10}
11 11
12bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); } 12bool CYCLE_OUT_IN_DUAL(effect_params_t* params) {
13 return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math);
14}
13 15
14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 16# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
15#endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL 17#endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
diff --git a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h
index 10ba2b7c2c..de5993992c 100644
--- a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h
+++ b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h
@@ -7,7 +7,9 @@ static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool CYCLE_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); } 10bool CYCLE_PINWHEEL(effect_params_t* params) {
11 return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_CYCLE_PINWHEEL 15#endif // ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
diff --git a/quantum/rgb_matrix/animations/cycle_spiral_anim.h b/quantum/rgb_matrix/animations/cycle_spiral_anim.h
index 482c7e7da6..904450179e 100644
--- a/quantum/rgb_matrix/animations/cycle_spiral_anim.h
+++ b/quantum/rgb_matrix/animations/cycle_spiral_anim.h
@@ -7,7 +7,9 @@ static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool CYCLE_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); } 10bool CYCLE_SPIRAL(effect_params_t* params) {
11 return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_CYCLE_SPIRAL 15#endif // ENABLE_RGB_MATRIX_CYCLE_SPIRAL
diff --git a/quantum/rgb_matrix/animations/cycle_up_down_anim.h b/quantum/rgb_matrix/animations/cycle_up_down_anim.h
index 277edccb2f..dce05fecff 100644
--- a/quantum/rgb_matrix/animations/cycle_up_down_anim.h
+++ b/quantum/rgb_matrix/animations/cycle_up_down_anim.h
@@ -7,7 +7,9 @@ static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) {
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); } 10bool CYCLE_UP_DOWN(effect_params_t* params) {
11 return effect_runner_i(params, &CYCLE_UP_DOWN_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_CYCLE_UP_DOWN 15#endif // ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
diff --git a/quantum/rgb_matrix/animations/digital_rain_anim.h b/quantum/rgb_matrix/animations/digital_rain_anim.h
index 8ce8fd7039..4633145ff6 100644
--- a/quantum/rgb_matrix/animations/digital_rain_anim.h
+++ b/quantum/rgb_matrix/animations/digital_rain_anim.h
@@ -71,5 +71,5 @@ bool DIGITAL_RAIN(effect_params_t* params) {
71 return false; 71 return false;
72} 72}
73 73
74# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 74# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
75#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) 75#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN)
diff --git a/quantum/rgb_matrix/animations/dual_beacon_anim.h b/quantum/rgb_matrix/animations/dual_beacon_anim.h
index dbe9b3ecf1..5585015b86 100644
--- a/quantum/rgb_matrix/animations/dual_beacon_anim.h
+++ b/quantum/rgb_matrix/animations/dual_beacon_anim.h
@@ -7,7 +7,9 @@ static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); } 10bool DUAL_BEACON(effect_params_t* params) {
11 return effect_runner_sin_cos_i(params, &DUAL_BEACON_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_DUAL_BEACON 15#endif // ENABLE_RGB_MATRIX_DUAL_BEACON
diff --git a/quantum/rgb_matrix/animations/gradient_left_right_anim.h b/quantum/rgb_matrix/animations/gradient_left_right_anim.h
index 8bb5e570bd..ebb06f59f2 100644
--- a/quantum/rgb_matrix/animations/gradient_left_right_anim.h
+++ b/quantum/rgb_matrix/animations/gradient_left_right_anim.h
@@ -18,5 +18,5 @@ bool GRADIENT_LEFT_RIGHT(effect_params_t* params) {
18 return rgb_matrix_check_finished_leds(led_max); 18 return rgb_matrix_check_finished_leds(led_max);
19} 19}
20 20
21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
22#endif // ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT 22#endif // ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
diff --git a/quantum/rgb_matrix/animations/gradient_up_down_anim.h b/quantum/rgb_matrix/animations/gradient_up_down_anim.h
index a5674583e3..febc3919a8 100644
--- a/quantum/rgb_matrix/animations/gradient_up_down_anim.h
+++ b/quantum/rgb_matrix/animations/gradient_up_down_anim.h
@@ -18,5 +18,5 @@ bool GRADIENT_UP_DOWN(effect_params_t* params) {
18 return rgb_matrix_check_finished_leds(led_max); 18 return rgb_matrix_check_finished_leds(led_max);
19} 19}
20 20
21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
22#endif // ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN 22#endif // ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/quantum/rgb_matrix/animations/hue_breathing_anim.h b/quantum/rgb_matrix/animations/hue_breathing_anim.h
index 82be1a4424..8537762832 100644
--- a/quantum/rgb_matrix/animations/hue_breathing_anim.h
+++ b/quantum/rgb_matrix/animations/hue_breathing_anim.h
@@ -18,5 +18,5 @@ bool HUE_BREATHING(effect_params_t* params) {
18 return rgb_matrix_check_finished_leds(led_max); 18 return rgb_matrix_check_finished_leds(led_max);
19} 19}
20 20
21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
22#endif // DISABLE_RGB_HUE_BREATHING 22#endif // DISABLE_RGB_HUE_BREATHING
diff --git a/quantum/rgb_matrix/animations/hue_pendulum_anim.h b/quantum/rgb_matrix/animations/hue_pendulum_anim.h
index a6e1c1074d..7d8cbcdfb2 100644
--- a/quantum/rgb_matrix/animations/hue_pendulum_anim.h
+++ b/quantum/rgb_matrix/animations/hue_pendulum_anim.h
@@ -11,7 +11,9 @@ static HSV HUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) {
11 return hsv; 11 return hsv;
12} 12}
13 13
14bool HUE_PENDULUM(effect_params_t* params) { return effect_runner_i(params, &HUE_PENDULUM_math); } 14bool HUE_PENDULUM(effect_params_t* params) {
15 return effect_runner_i(params, &HUE_PENDULUM_math);
16}
15 17
16# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 18# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
17#endif // DISABLE_RGB_HUE_PENDULUM 19#endif // DISABLE_RGB_HUE_PENDULUM
diff --git a/quantum/rgb_matrix/animations/hue_wave_anim.h b/quantum/rgb_matrix/animations/hue_wave_anim.h
index b1c72b7336..81aa7e139e 100644
--- a/quantum/rgb_matrix/animations/hue_wave_anim.h
+++ b/quantum/rgb_matrix/animations/hue_wave_anim.h
@@ -11,7 +11,9 @@ static HSV HUE_WAVE_math(HSV hsv, uint8_t i, uint8_t time) {
11 return hsv; 11 return hsv;
12} 12}
13 13
14bool HUE_WAVE(effect_params_t* params) { return effect_runner_i(params, &HUE_WAVE_math); } 14bool HUE_WAVE(effect_params_t* params) {
15 return effect_runner_i(params, &HUE_WAVE_math);
16}
15 17
16# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 18# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
17#endif // DISABLE_RGB_HUE_WAVE 19#endif // DISABLE_RGB_HUE_WAVE
diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h
index 3ffb57eb35..31dffcbc5a 100644
--- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h
+++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h
@@ -25,5 +25,5 @@ bool JELLYBEAN_RAINDROPS(effect_params_t* params) {
25 return rgb_matrix_check_finished_leds(led_max); 25 return rgb_matrix_check_finished_leds(led_max);
26} 26}
27 27
28# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 28# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
29#endif // ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS 29#endif // ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h
index 312c87628c..714f5d174e 100644
--- a/quantum/rgb_matrix/animations/pixel_flow_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_flow_anim.h
@@ -14,7 +14,9 @@ static bool PIXEL_FLOW(effect_params_t* params) {
14 return false; 14 return false;
15 } 15 }
16 16
17 inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } 17 inline uint32_t interval(void) {
18 return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16);
19 }
18 20
19 if (params->init) { 21 if (params->init) {
20 // Clear LEDs and fill the state array 22 // Clear LEDs and fill the state array
@@ -45,5 +47,5 @@ static bool PIXEL_FLOW(effect_params_t* params) {
45 return rgb_matrix_check_finished_leds(led_max); 47 return rgb_matrix_check_finished_leds(led_max);
46} 48}
47 49
48# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 50# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
49#endif // ENABLE_RGB_MATRIX_PIXEL_FLOW 51#endif // ENABLE_RGB_MATRIX_PIXEL_FLOW
diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
index 35187b92de..906da1a48e 100644
--- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_fractal_anim.h
@@ -29,7 +29,9 @@ static bool PIXEL_FRACTAL(effect_params_t* params) {
29 return false; 29 return false;
30 } 30 }
31 31
32 inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } 32 inline uint32_t interval(void) {
33 return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16);
34 }
33 35
34 if (params->init) { 36 if (params->init) {
35 rgb_matrix_set_color_all(0, 0, 0); 37 rgb_matrix_set_color_all(0, 0, 0);
@@ -37,7 +39,7 @@ static bool PIXEL_FRACTAL(effect_params_t* params) {
37 39
38 RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); 40 RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv);
39 for (uint8_t h = 0; h < MATRIX_ROWS; ++h) { 41 for (uint8_t h = 0; h < MATRIX_ROWS; ++h) {
40 for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards 42 for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards
41 if (led[h][l]) { 43 if (led[h][l]) {
42 rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b); 44 rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b);
43 } else { 45 } else {
@@ -46,7 +48,7 @@ static bool PIXEL_FRACTAL(effect_params_t* params) {
46 led[h][l] = led[h][l + 1]; 48 led[h][l] = led[h][l + 1];
47 } 49 }
48 50
49 for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards 51 for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards
50 if (led[h][r]) { 52 if (led[h][r]) {
51 rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b); 53 rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b);
52 } else { 54 } else {
@@ -74,5 +76,5 @@ static bool PIXEL_FRACTAL(effect_params_t* params) {
74 wait_timer = g_rgb_timer + interval(); 76 wait_timer = g_rgb_timer + interval();
75 return false; 77 return false;
76} 78}
77# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 79# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
78#endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL 80#endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL
diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h
index 001649aa6e..03488b43df 100644
--- a/quantum/rgb_matrix/animations/pixel_rain_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h
@@ -24,7 +24,9 @@ static bool PIXEL_RAIN(effect_params_t* params) {
24 return false; 24 return false;
25 } 25 }
26 26
27 inline uint32_t interval(void) { return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } 27 inline uint32_t interval(void) {
28 return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16);
29 }
28 30
29 bool rain_pixel(uint8_t i, effect_params_t * params, bool off) { 31 bool rain_pixel(uint8_t i, effect_params_t * params, bool off) {
30 if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) { 32 if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) {
@@ -44,5 +46,5 @@ static bool PIXEL_RAIN(effect_params_t* params) {
44 return rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2); 46 return rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2);
45} 47}
46 48
47# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 49# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
48#endif // ENABLE_RGB_MATRIX_PIXEL_RAIN 50#endif // ENABLE_RGB_MATRIX_PIXEL_RAIN
diff --git a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h
index cd529958db..bdcca5530f 100644
--- a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h
+++ b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h
@@ -7,7 +7,9 @@ static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } 10bool RAINBOW_BEACON(effect_params_t* params) {
11 return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_RAINBOW_BEACON 15#endif // ENABLE_RGB_MATRIX_RAINBOW_BEACON
diff --git a/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h
index 2f3de64e9d..f7b8f6c2f3 100644
--- a/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h
+++ b/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h
@@ -7,7 +7,9 @@ static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) {
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); } 10bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) {
11 return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON 15#endif // ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
diff --git a/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h
index dae2b5d190..91e31ea8cc 100644
--- a/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h
+++ b/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h
@@ -7,7 +7,9 @@ static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, ui
7 return hsv; 7 return hsv;
8} 8}
9 9
10bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); } 10bool RAINBOW_PINWHEELS(effect_params_t* params) {
11 return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math);
12}
11 13
12# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 14# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
13#endif // ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS 15#endif // ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h
index 4b1b9dd9ec..2d4b53b7b0 100644
--- a/quantum/rgb_matrix/animations/raindrops_anim.h
+++ b/quantum/rgb_matrix/animations/raindrops_anim.h
@@ -35,5 +35,5 @@ bool RAINDROPS(effect_params_t* params) {
35 return rgb_matrix_check_finished_leds(led_max); 35 return rgb_matrix_check_finished_leds(led_max);
36} 36}
37 37
38# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 38# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
39#endif // ENABLE_RGB_MATRIX_RAINDROPS 39#endif // ENABLE_RGB_MATRIX_RAINDROPS
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h
index d5c1a26cef..f9584d7071 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h
@@ -26,4 +26,4 @@ bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
26 return rgb_matrix_check_finished_leds(led_max); 26 return rgb_matrix_check_finished_leds(led_max);
27} 27}
28 28
29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h
index d3a6e4e72f..41020eb47f 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h
@@ -26,4 +26,4 @@ bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, react
26 return rgb_matrix_check_finished_leds(led_max); 26 return rgb_matrix_check_finished_leds(led_max);
27} 27}
28 28
29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/solid_color_anim.h b/quantum/rgb_matrix/animations/solid_color_anim.h
index 4209959468..c8762dcbc2 100644
--- a/quantum/rgb_matrix/animations/solid_color_anim.h
+++ b/quantum/rgb_matrix/animations/solid_color_anim.h
@@ -12,4 +12,4 @@ bool SOLID_COLOR(effect_params_t* params) {
12 return rgb_matrix_check_finished_leds(led_max); 12 return rgb_matrix_check_finished_leds(led_max);
13} 13}
14 14
15#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 15#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h
index 360d05a67a..d3a7ebbdf7 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_anim.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h
@@ -8,8 +8,10 @@ static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) {
8 return hsv; 8 return hsv;
9} 9}
10 10
11bool SOLID_REACTIVE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_math); } 11bool SOLID_REACTIVE(effect_params_t* params) {
12 return effect_runner_reactive(params, &SOLID_REACTIVE_math);
13}
12 14
13# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 15# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
14# endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE 16# endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE
15#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 17#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/solid_reactive_cross.h b/quantum/rgb_matrix/animations/solid_reactive_cross.h
index 496651f8a5..043a369b73 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_cross.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_cross.h
@@ -24,13 +24,17 @@ static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
24} 24}
25 25
26# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS 26# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
27bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); } 27bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
28 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math);
29}
28# endif 30# endif
29 31
30# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS 32# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
31bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); } 33bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
34 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math);
35}
32# endif 36# endif
33 37
34# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 38# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
35# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) 39# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
36#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 40#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/solid_reactive_nexus.h b/quantum/rgb_matrix/animations/solid_reactive_nexus.h
index 3562e74a72..8d62a49fea 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_nexus.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_nexus.h
@@ -22,13 +22,17 @@ static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
22} 22}
23 23
24# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS 24# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
25bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); } 25bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
26 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math);
27}
26# endif 28# endif
27 29
28# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS 30# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
29bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); } 31bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
32 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math);
33}
30# endif 34# endif
31 35
32# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 36# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
33# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) 37# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
34#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 38#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
index 69189f636b..0d0a424cf3 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h
@@ -8,8 +8,10 @@ static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) {
8 return hsv; 8 return hsv;
9} 9}
10 10
11bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); } 11bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) {
12 return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math);
13}
12 14
13# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 15# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
14# endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE 16# endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
15#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 17#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/solid_reactive_wide.h b/quantum/rgb_matrix/animations/solid_reactive_wide.h
index a613c7ff5f..7598796316 100644
--- a/quantum/rgb_matrix/animations/solid_reactive_wide.h
+++ b/quantum/rgb_matrix/animations/solid_reactive_wide.h
@@ -19,13 +19,17 @@ static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dis
19} 19}
20 20
21# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE 21# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
22bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); } 22bool SOLID_REACTIVE_WIDE(effect_params_t* params) {
23 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math);
24}
23# endif 25# endif
24 26
25# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE 27# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
26bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); } 28bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) {
29 return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math);
30}
27# endif 31# endif
28 32
29# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 33# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
30# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) 34# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
31#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 35#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/solid_splash_anim.h b/quantum/rgb_matrix/animations/solid_splash_anim.h
index bd9c1cfe2b..77d6f8c5eb 100644
--- a/quantum/rgb_matrix/animations/solid_splash_anim.h
+++ b/quantum/rgb_matrix/animations/solid_splash_anim.h
@@ -19,13 +19,17 @@ HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t ti
19} 19}
20 20
21# ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH 21# ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH
22bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); } 22bool SOLID_SPLASH(effect_params_t* params) {
23 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math);
24}
23# endif 25# endif
24 26
25# ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH 27# ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
26bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); } 28bool SOLID_MULTISPLASH(effect_params_t* params) {
29 return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math);
30}
27# endif 31# endif
28 32
29# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 33# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
30# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) && !defined(ENABLE_RGB_MATRIX_MULTISPLASH) 34# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) && !defined(ENABLE_RGB_MATRIX_MULTISPLASH)
31#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 35#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/splash_anim.h b/quantum/rgb_matrix/animations/splash_anim.h
index 382355e9ed..06459e1b0a 100644
--- a/quantum/rgb_matrix/animations/splash_anim.h
+++ b/quantum/rgb_matrix/animations/splash_anim.h
@@ -20,13 +20,17 @@ HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
20} 20}
21 21
22# ifdef ENABLE_RGB_MATRIX_SPLASH 22# ifdef ENABLE_RGB_MATRIX_SPLASH
23bool SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); } 23bool SPLASH(effect_params_t* params) {
24 return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math);
25}
24# endif 26# endif
25 27
26# ifdef ENABLE_RGB_MATRIX_MULTISPLASH 28# ifdef ENABLE_RGB_MATRIX_MULTISPLASH
27bool MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SPLASH_math); } 29bool MULTISPLASH(effect_params_t* params) {
30 return effect_runner_reactive_splash(0, params, &SPLASH_math);
31}
28# endif 32# endif
29 33
30# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 34# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
31# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) || !defined(ENABLE_RGB_MATRIX_MULTISPLASH) 35# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) || !defined(ENABLE_RGB_MATRIX_MULTISPLASH)
32#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 36#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/typing_heatmap_anim.h b/quantum/rgb_matrix/animations/typing_heatmap_anim.h
index b66667b9b8..f3a94280c0 100644
--- a/quantum/rgb_matrix/animations/typing_heatmap_anim.h
+++ b/quantum/rgb_matrix/animations/typing_heatmap_anim.h
@@ -82,5 +82,5 @@ bool TYPING_HEATMAP(effect_params_t* params) {
82 return led_max < sizeof(g_rgb_frame_buffer); 82 return led_max < sizeof(g_rgb_frame_buffer);
83} 83}
84 84
85# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 85# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
86#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) 86#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP)
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index 5a4556f097..f721dfc7f2 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -31,7 +31,9 @@ const led_point_t k_rgb_matrix_center = {112, 32};
31const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; 31const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
32#endif 32#endif
33 33
34__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); } 34__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) {
35 return hsv_to_rgb(hsv);
36}
35 37
36// Generic effect runners 38// Generic effect runners
37#include "rgb_matrix_runners.inc" 39#include "rgb_matrix_runners.inc"
@@ -109,14 +111,14 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv
109#endif 111#endif
110 112
111// globals 113// globals
112rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr 114rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
113uint32_t g_rgb_timer; 115uint32_t g_rgb_timer;
114#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS 116#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
115uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; 117uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
116#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS 118#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS
117#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 119#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
118last_hit_t g_last_hit_tracker; 120last_hit_t g_last_hit_tracker;
119#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 121#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
120 122
121// internals 123// internals
122static bool suspend_state = false; 124static bool suspend_state = false;
@@ -126,13 +128,13 @@ static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
126static rgb_task_states rgb_task_state = SYNCING; 128static rgb_task_states rgb_task_state = SYNCING;
127#if RGB_DISABLE_TIMEOUT > 0 129#if RGB_DISABLE_TIMEOUT > 0
128static uint32_t rgb_anykey_timer; 130static uint32_t rgb_anykey_timer;
129#endif // RGB_DISABLE_TIMEOUT > 0 131#endif // RGB_DISABLE_TIMEOUT > 0
130 132
131// double buffers 133// double buffers
132static uint32_t rgb_timer_buffer; 134static uint32_t rgb_timer_buffer;
133#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 135#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
134static last_hit_t last_hit_buffer; 136static last_hit_t last_hit_buffer;
135#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 137#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
136 138
137// split rgb matrix 139// split rgb matrix
138#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 140#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
@@ -141,7 +143,9 @@ const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
141 143
142EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config); 144EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config);
143 145
144void eeconfig_update_rgb_matrix(void) { eeconfig_flush_rgb_matrix(true); } 146void eeconfig_update_rgb_matrix(void) {
147 eeconfig_flush_rgb_matrix(true);
148}
145 149
146void eeconfig_update_rgb_matrix_default(void) { 150void eeconfig_update_rgb_matrix_default(void) {
147 dprintf("eeconfig_update_rgb_matrix_default\n"); 151 dprintf("eeconfig_update_rgb_matrix_default\n");
@@ -168,13 +172,15 @@ void rgb_matrix_reload_from_eeprom(void) {
168 rgb_matrix_disable_noeeprom(); 172 rgb_matrix_disable_noeeprom();
169 /* Reset back to what we have in eeprom */ 173 /* Reset back to what we have in eeprom */
170 eeconfig_init_rgb_matrix(); 174 eeconfig_init_rgb_matrix();
171 eeconfig_debug_rgb_matrix(); // display current eeprom values 175 eeconfig_debug_rgb_matrix(); // display current eeprom values
172 if (rgb_matrix_config.enable) { 176 if (rgb_matrix_config.enable) {
173 rgb_matrix_mode_noeeprom(rgb_matrix_config.mode); 177 rgb_matrix_mode_noeeprom(rgb_matrix_config.mode);
174 } 178 }
175} 179}
176 180
177__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } 181__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) {
182 return 0;
183}
178 184
179uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { 185uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
180 uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); 186 uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i);
@@ -186,13 +192,18 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
186 return led_count; 192 return led_count;
187} 193}
188 194
189void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } 195void rgb_matrix_update_pwm_buffers(void) {
196 rgb_matrix_driver.flush();
197}
190 198
191void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); } 199void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
200 rgb_matrix_driver.set_color(index, red, green, blue);
201}
192 202
193void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { 203void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
194#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 204#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
195 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) rgb_matrix_set_color(i, red, green, blue); 205 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++)
206 rgb_matrix_set_color(i, red, green, blue);
196#else 207#else
197 rgb_matrix_driver.set_color_all(red, green, blue); 208 rgb_matrix_driver.set_color_all(red, green, blue);
198#endif 209#endif
@@ -204,7 +215,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
204#endif 215#endif
205#if RGB_DISABLE_TIMEOUT > 0 216#if RGB_DISABLE_TIMEOUT > 0
206 rgb_anykey_timer = 0; 217 rgb_anykey_timer = 0;
207#endif // RGB_DISABLE_TIMEOUT > 0 218#endif // RGB_DISABLE_TIMEOUT > 0
208 219
209#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 220#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
210 uint8_t led[LED_HITS_TO_REMEMBER]; 221 uint8_t led[LED_HITS_TO_REMEMBER];
@@ -214,7 +225,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
214 if (!pressed) 225 if (!pressed)
215# elif defined(RGB_MATRIX_KEYPRESSES) 226# elif defined(RGB_MATRIX_KEYPRESSES)
216 if (pressed) 227 if (pressed)
217# endif // defined(RGB_MATRIX_KEYRELEASES) 228# endif // defined(RGB_MATRIX_KEYRELEASES)
218 { 229 {
219 led_count = rgb_matrix_map_row_column_to_led(row, col, led); 230 led_count = rgb_matrix_map_row_column_to_led(row, col, led);
220 } 231 }
@@ -222,7 +233,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
222 if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { 233 if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
223 memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); 234 memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count);
224 memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); 235 memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count);
225 memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit 236 memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit
226 memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); 237 memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count);
227 last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; 238 last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count;
228 } 239 }
@@ -235,13 +246,13 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
235 last_hit_buffer.tick[index] = 0; 246 last_hit_buffer.tick[index] = 0;
236 last_hit_buffer.count++; 247 last_hit_buffer.count++;
237 } 248 }
238#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 249#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
239 250
240#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) 251#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP)
241 if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { 252 if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) {
242 process_rgb_matrix_typing_heatmap(row, col); 253 process_rgb_matrix_typing_heatmap(row, col);
243 } 254 }
244#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) 255#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP)
245} 256}
246 257
247void rgb_matrix_test(void) { 258void rgb_matrix_test(void) {
@@ -280,7 +291,7 @@ static bool rgb_matrix_none(effect_params_t *params) {
280static void rgb_task_timers(void) { 291static void rgb_task_timers(void) {
281#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 292#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
282 uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); 293 uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer);
283#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 294#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
284 rgb_timer_buffer = sync_timer_read32(); 295 rgb_timer_buffer = sync_timer_read32();
285 296
286 // Update double buffer timers 297 // Update double buffer timers
@@ -288,7 +299,7 @@ static void rgb_task_timers(void) {
288 if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { 299 if (rgb_anykey_timer + deltaTime <= UINT32_MAX) {
289 rgb_anykey_timer += deltaTime; 300 rgb_anykey_timer += deltaTime;
290 } 301 }
291#endif // RGB_DISABLE_TIMEOUT > 0 302#endif // RGB_DISABLE_TIMEOUT > 0
292 303
293 // Update double buffer last hit timers 304 // Update double buffer last hit timers
294#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 305#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
@@ -300,7 +311,7 @@ static void rgb_task_timers(void) {
300 } 311 }
301 last_hit_buffer.tick[i] += deltaTime; 312 last_hit_buffer.tick[i] += deltaTime;
302 } 313 }
303#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 314#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
304} 315}
305 316
306static void rgb_task_sync(void) { 317static void rgb_task_sync(void) {
@@ -317,7 +328,7 @@ static void rgb_task_start(void) {
317 g_rgb_timer = rgb_timer_buffer; 328 g_rgb_timer = rgb_timer_buffer;
318#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 329#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
319 g_last_hit_tracker = last_hit_buffer; 330 g_last_hit_tracker = last_hit_buffer;
320#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 331#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
321 332
322 // next task 333 // next task
323 rgb_task_state = RENDERING; 334 rgb_task_state = RENDERING;
@@ -403,7 +414,7 @@ void rgb_matrix_task(void) {
403 bool suspend_backlight = suspend_state || 414 bool suspend_backlight = suspend_state ||
404#if RGB_DISABLE_TIMEOUT > 0 415#if RGB_DISABLE_TIMEOUT > 0
405 (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) || 416 (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) ||
406#endif // RGB_DISABLE_TIMEOUT > 0 417#endif // RGB_DISABLE_TIMEOUT > 0
407 false; 418 false;
408 419
409 uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; 420 uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
@@ -472,7 +483,7 @@ void rgb_matrix_init(void) {
472 for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { 483 for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
473 last_hit_buffer.tick[i] = UINT16_MAX; 484 last_hit_buffer.tick[i] = UINT16_MAX;
474 } 485 }
475#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 486#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
476 487
477 if (!eeconfig_is_enabled()) { 488 if (!eeconfig_is_enabled()) {
478 dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); 489 dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n");
@@ -485,20 +496,22 @@ void rgb_matrix_init(void) {
485 dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); 496 dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n");
486 eeconfig_update_rgb_matrix_default(); 497 eeconfig_update_rgb_matrix_default();
487 } 498 }
488 eeconfig_debug_rgb_matrix(); // display current eeprom values 499 eeconfig_debug_rgb_matrix(); // display current eeprom values
489} 500}
490 501
491void rgb_matrix_set_suspend_state(bool state) { 502void rgb_matrix_set_suspend_state(bool state) {
492#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED 503#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
493 if (state && !suspend_state) { // only run if turning off, and only once 504 if (state && !suspend_state) { // only run if turning off, and only once
494 rgb_task_render(0); // turn off all LEDs when suspending 505 rgb_task_render(0); // turn off all LEDs when suspending
495 rgb_task_flush(0); // and actually flash led state to LEDs 506 rgb_task_flush(0); // and actually flash led state to LEDs
496 } 507 }
497 suspend_state = state; 508 suspend_state = state;
498#endif 509#endif
499} 510}
500 511
501bool rgb_matrix_get_suspend_state(void) { return suspend_state; } 512bool rgb_matrix_get_suspend_state(void) {
513 return suspend_state;
514}
502 515
503void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { 516void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
504 rgb_matrix_config.enable ^= 1; 517 rgb_matrix_config.enable ^= 1;
@@ -506,8 +519,12 @@ void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
506 eeconfig_flag_rgb_matrix(write_to_eeprom); 519 eeconfig_flag_rgb_matrix(write_to_eeprom);
507 dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable); 520 dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable);
508} 521}
509void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); } 522void rgb_matrix_toggle_noeeprom(void) {
510void rgb_matrix_toggle(void) { rgb_matrix_toggle_eeprom_helper(true); } 523 rgb_matrix_toggle_eeprom_helper(false);
524}
525void rgb_matrix_toggle(void) {
526 rgb_matrix_toggle_eeprom_helper(true);
527}
511 528
512void rgb_matrix_enable(void) { 529void rgb_matrix_enable(void) {
513 rgb_matrix_enable_noeeprom(); 530 rgb_matrix_enable_noeeprom();
@@ -529,7 +546,9 @@ void rgb_matrix_disable_noeeprom(void) {
529 rgb_matrix_config.enable = 0; 546 rgb_matrix_config.enable = 0;
530} 547}
531 548
532uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; } 549uint8_t rgb_matrix_is_enabled(void) {
550 return rgb_matrix_config.enable;
551}
533 552
534void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { 553void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
535 if (!rgb_matrix_config.enable) { 554 if (!rgb_matrix_config.enable) {
@@ -546,24 +565,38 @@ void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
546 eeconfig_flag_rgb_matrix(write_to_eeprom); 565 eeconfig_flag_rgb_matrix(write_to_eeprom);
547 dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); 566 dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode);
548} 567}
549void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); } 568void rgb_matrix_mode_noeeprom(uint8_t mode) {
550void rgb_matrix_mode(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, true); } 569 rgb_matrix_mode_eeprom_helper(mode, false);
570}
571void rgb_matrix_mode(uint8_t mode) {
572 rgb_matrix_mode_eeprom_helper(mode, true);
573}
551 574
552uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; } 575uint8_t rgb_matrix_get_mode(void) {
576 return rgb_matrix_config.mode;
577}
553 578
554void rgb_matrix_step_helper(bool write_to_eeprom) { 579void rgb_matrix_step_helper(bool write_to_eeprom) {
555 uint8_t mode = rgb_matrix_config.mode + 1; 580 uint8_t mode = rgb_matrix_config.mode + 1;
556 rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); 581 rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom);
557} 582}
558void rgb_matrix_step_noeeprom(void) { rgb_matrix_step_helper(false); } 583void rgb_matrix_step_noeeprom(void) {
559void rgb_matrix_step(void) { rgb_matrix_step_helper(true); } 584 rgb_matrix_step_helper(false);
585}
586void rgb_matrix_step(void) {
587 rgb_matrix_step_helper(true);
588}
560 589
561void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { 590void rgb_matrix_step_reverse_helper(bool write_to_eeprom) {
562 uint8_t mode = rgb_matrix_config.mode - 1; 591 uint8_t mode = rgb_matrix_config.mode - 1;
563 rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); 592 rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom);
564} 593}
565void rgb_matrix_step_reverse_noeeprom(void) { rgb_matrix_step_reverse_helper(false); } 594void rgb_matrix_step_reverse_noeeprom(void) {
566void rgb_matrix_step_reverse(void) { rgb_matrix_step_reverse_helper(true); } 595 rgb_matrix_step_reverse_helper(false);
596}
597void rgb_matrix_step_reverse(void) {
598 rgb_matrix_step_reverse_helper(true);
599}
567 600
568void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { 601void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
569 if (!rgb_matrix_config.enable) { 602 if (!rgb_matrix_config.enable) {
@@ -575,56 +608,126 @@ void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, boo
575 eeconfig_flag_rgb_matrix(write_to_eeprom); 608 eeconfig_flag_rgb_matrix(write_to_eeprom);
576 dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); 609 dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v);
577} 610}
578void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); } 611void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
579void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); } 612 rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false);
613}
614void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
615 rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true);
616}
580 617
581HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; } 618HSV rgb_matrix_get_hsv(void) {
582uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; } 619 return rgb_matrix_config.hsv;
583uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; } 620}
584uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; } 621uint8_t rgb_matrix_get_hue(void) {
622 return rgb_matrix_config.hsv.h;
623}
624uint8_t rgb_matrix_get_sat(void) {
625 return rgb_matrix_config.hsv.s;
626}
627uint8_t rgb_matrix_get_val(void) {
628 return rgb_matrix_config.hsv.v;
629}
585 630
586void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } 631void rgb_matrix_increase_hue_helper(bool write_to_eeprom) {
587void rgb_matrix_increase_hue_noeeprom(void) { rgb_matrix_increase_hue_helper(false); } 632 rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom);
588void rgb_matrix_increase_hue(void) { rgb_matrix_increase_hue_helper(true); } 633}
634void rgb_matrix_increase_hue_noeeprom(void) {
635 rgb_matrix_increase_hue_helper(false);
636}
637void rgb_matrix_increase_hue(void) {
638 rgb_matrix_increase_hue_helper(true);
639}
589 640
590void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } 641void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) {
591void rgb_matrix_decrease_hue_noeeprom(void) { rgb_matrix_decrease_hue_helper(false); } 642 rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom);
592void rgb_matrix_decrease_hue(void) { rgb_matrix_decrease_hue_helper(true); } 643}
644void rgb_matrix_decrease_hue_noeeprom(void) {
645 rgb_matrix_decrease_hue_helper(false);
646}
647void rgb_matrix_decrease_hue(void) {
648 rgb_matrix_decrease_hue_helper(true);
649}
593 650
594void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } 651void rgb_matrix_increase_sat_helper(bool write_to_eeprom) {
595void rgb_matrix_increase_sat_noeeprom(void) { rgb_matrix_increase_sat_helper(false); } 652 rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom);
596void rgb_matrix_increase_sat(void) { rgb_matrix_increase_sat_helper(true); } 653}
654void rgb_matrix_increase_sat_noeeprom(void) {
655 rgb_matrix_increase_sat_helper(false);
656}
657void rgb_matrix_increase_sat(void) {
658 rgb_matrix_increase_sat_helper(true);
659}
597 660
598void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } 661void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) {
599void rgb_matrix_decrease_sat_noeeprom(void) { rgb_matrix_decrease_sat_helper(false); } 662 rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom);
600void rgb_matrix_decrease_sat(void) { rgb_matrix_decrease_sat_helper(true); } 663}
664void rgb_matrix_decrease_sat_noeeprom(void) {
665 rgb_matrix_decrease_sat_helper(false);
666}
667void rgb_matrix_decrease_sat(void) {
668 rgb_matrix_decrease_sat_helper(true);
669}
601 670
602void rgb_matrix_increase_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } 671void rgb_matrix_increase_val_helper(bool write_to_eeprom) {
603void rgb_matrix_increase_val_noeeprom(void) { rgb_matrix_increase_val_helper(false); } 672 rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom);
604void rgb_matrix_increase_val(void) { rgb_matrix_increase_val_helper(true); } 673}
674void rgb_matrix_increase_val_noeeprom(void) {
675 rgb_matrix_increase_val_helper(false);
676}
677void rgb_matrix_increase_val(void) {
678 rgb_matrix_increase_val_helper(true);
679}
605 680
606void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } 681void rgb_matrix_decrease_val_helper(bool write_to_eeprom) {
607void rgb_matrix_decrease_val_noeeprom(void) { rgb_matrix_decrease_val_helper(false); } 682 rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom);
608void rgb_matrix_decrease_val(void) { rgb_matrix_decrease_val_helper(true); } 683}
684void rgb_matrix_decrease_val_noeeprom(void) {
685 rgb_matrix_decrease_val_helper(false);
686}
687void rgb_matrix_decrease_val(void) {
688 rgb_matrix_decrease_val_helper(true);
689}
609 690
610void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { 691void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
611 rgb_matrix_config.speed = speed; 692 rgb_matrix_config.speed = speed;
612 eeconfig_flag_rgb_matrix(write_to_eeprom); 693 eeconfig_flag_rgb_matrix(write_to_eeprom);
613 dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed); 694 dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed);
614} 695}
615void rgb_matrix_set_speed_noeeprom(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, false); } 696void rgb_matrix_set_speed_noeeprom(uint8_t speed) {
616void rgb_matrix_set_speed(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, true); } 697 rgb_matrix_set_speed_eeprom_helper(speed, false);
698}
699void rgb_matrix_set_speed(uint8_t speed) {
700 rgb_matrix_set_speed_eeprom_helper(speed, true);
701}
617 702
618uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; } 703uint8_t rgb_matrix_get_speed(void) {
704 return rgb_matrix_config.speed;
705}
619 706
620void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } 707void rgb_matrix_increase_speed_helper(bool write_to_eeprom) {
621void rgb_matrix_increase_speed_noeeprom(void) { rgb_matrix_increase_speed_helper(false); } 708 rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom);
622void rgb_matrix_increase_speed(void) { rgb_matrix_increase_speed_helper(true); } 709}
710void rgb_matrix_increase_speed_noeeprom(void) {
711 rgb_matrix_increase_speed_helper(false);
712}
713void rgb_matrix_increase_speed(void) {
714 rgb_matrix_increase_speed_helper(true);
715}
623 716
624void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } 717void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) {
625void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } 718 rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom);
626void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } 719}
720void rgb_matrix_decrease_speed_noeeprom(void) {
721 rgb_matrix_decrease_speed_helper(false);
722}
723void rgb_matrix_decrease_speed(void) {
724 rgb_matrix_decrease_speed_helper(true);
725}
627 726
628led_flags_t rgb_matrix_get_flags(void) { return rgb_matrix_config.flags; } 727led_flags_t rgb_matrix_get_flags(void) {
728 return rgb_matrix_config.flags;
729}
629 730
630void rgb_matrix_set_flags(led_flags_t flags) { rgb_matrix_config.flags = flags; } 731void rgb_matrix_set_flags(led_flags_t flags) {
732 rgb_matrix_config.flags = flags;
733}
diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h
index df575d6577..d0ac4e4466 100644
--- a/quantum/rgb_matrix/rgb_matrix_types.h
+++ b/quantum/rgb_matrix/rgb_matrix_types.h
@@ -37,7 +37,7 @@
37// Last led hit 37// Last led hit
38#ifndef LED_HITS_TO_REMEMBER 38#ifndef LED_HITS_TO_REMEMBER
39# define LED_HITS_TO_REMEMBER 8 39# define LED_HITS_TO_REMEMBER 8
40#endif // LED_HITS_TO_REMEMBER 40#endif // LED_HITS_TO_REMEMBER
41 41
42#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 42#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
43typedef struct PACKED { 43typedef struct PACKED {
@@ -47,7 +47,7 @@ typedef struct PACKED {
47 uint8_t index[LED_HITS_TO_REMEMBER]; 47 uint8_t index[LED_HITS_TO_REMEMBER];
48 uint16_t tick[LED_HITS_TO_REMEMBER]; 48 uint16_t tick[LED_HITS_TO_REMEMBER];
49} last_hit_t; 49} last_hit_t;
50#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 50#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
51 51
52typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states; 52typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states;
53 53
@@ -88,7 +88,7 @@ typedef union {
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 led_flags_t flags;
93 }; 93 };
94} rgb_config_t; 94} rgb_config_t;
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index 148dae78f4..8f933a6e51 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -72,7 +72,7 @@ static uint8_t static_effect_table[] = {
72#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##msym, 72#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##msym,
73#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##msym, 73#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##msym,
74static uint8_t mode_base_table[] = { 74static uint8_t mode_base_table[] = {
75 0, // RGBLIGHT_MODE_zero 75 0, // RGBLIGHT_MODE_zero
76#include "rgblight_modes.h" 76#include "rgblight_modes.h"
77}; 77};
78 78
@@ -96,7 +96,9 @@ static uint8_t mode_base_table[] = {
96# define RGBLIGHT_DEFAULT_SPD 0 96# define RGBLIGHT_DEFAULT_SPD 0
97#endif 97#endif
98 98
99static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; } 99static inline int is_static_effect(uint8_t mode) {
100 return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL;
101}
100 102
101#ifdef RGBLIGHT_LED_MAP 103#ifdef RGBLIGHT_LED_MAP
102const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP; 104const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP;
@@ -143,7 +145,9 @@ void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds) {
143 rgblight_ranges.effect_num_leds = num_leds; 145 rgblight_ranges.effect_num_leds = num_leds;
144} 146}
145 147
146__attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); } 148__attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) {
149 return hsv_to_rgb(hsv);
150}
147 151
148void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { 152void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
149 HSV hsv = {hue, sat, val}; 153 HSV hsv = {hue, sat, val};
@@ -151,7 +155,9 @@ void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
151 setrgb(rgb.r, rgb.g, rgb.b, led1); 155 setrgb(rgb.r, rgb.g, rgb.b, led1);
152} 156}
153 157
154void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1); } 158void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
159 sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1);
160}
155 161
156void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { 162void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
157 led1->r = r; 163 led1->r = r;
@@ -191,7 +197,9 @@ void eeconfig_update_rgblight(uint32_t val) {
191#endif 197#endif
192} 198}
193 199
194void eeconfig_update_rgblight_current(void) { eeconfig_update_rgblight(rgblight_config.raw); } 200void eeconfig_update_rgblight_current(void) {
201 eeconfig_update_rgblight(rgblight_config.raw);
202}
195 203
196void eeconfig_update_rgblight_default(void) { 204void eeconfig_update_rgblight_default(void) {
197 rgblight_config.enable = 1; 205 rgblight_config.enable = 1;
@@ -238,9 +246,9 @@ void rgblight_init(void) {
238 } 246 }
239 rgblight_check_config(); 247 rgblight_check_config();
240 248
241 eeconfig_debug_rgblight(); // display current eeprom values 249 eeconfig_debug_rgblight(); // display current eeprom values
242 250
243 rgblight_timer_init(); // setup the timer 251 rgblight_timer_init(); // setup the timer
244 252
245 if (rgblight_config.enable) { 253 if (rgblight_config.enable) {
246 rgblight_mode_noeeprom(rgblight_config.mode); 254 rgblight_mode_noeeprom(rgblight_config.mode);
@@ -254,13 +262,15 @@ void rgblight_reload_from_eeprom(void) {
254 rgblight_config.raw = eeconfig_read_rgblight(); 262 rgblight_config.raw = eeconfig_read_rgblight();
255 RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; 263 RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
256 rgblight_check_config(); 264 rgblight_check_config();
257 eeconfig_debug_rgblight(); // display current eeprom values 265 eeconfig_debug_rgblight(); // display current eeprom values
258 if (rgblight_config.enable) { 266 if (rgblight_config.enable) {
259 rgblight_mode_noeeprom(rgblight_config.mode); 267 rgblight_mode_noeeprom(rgblight_config.mode);
260 } 268 }
261} 269}
262 270
263uint32_t rgblight_read_dword(void) { return rgblight_config.raw; } 271uint32_t rgblight_read_dword(void) {
272 return rgblight_config.raw;
273}
264 274
265void rgblight_update_dword(uint32_t dword) { 275void rgblight_update_dword(uint32_t dword) {
266 RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; 276 RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
@@ -296,8 +306,12 @@ void rgblight_step_helper(bool write_to_eeprom) {
296 } 306 }
297 rgblight_mode_eeprom_helper(mode, write_to_eeprom); 307 rgblight_mode_eeprom_helper(mode, write_to_eeprom);
298} 308}
299void rgblight_step_noeeprom(void) { rgblight_step_helper(false); } 309void rgblight_step_noeeprom(void) {
300void rgblight_step(void) { rgblight_step_helper(true); } 310 rgblight_step_helper(false);
311}
312void rgblight_step(void) {
313 rgblight_step_helper(true);
314}
301void rgblight_step_reverse_helper(bool write_to_eeprom) { 315void rgblight_step_reverse_helper(bool write_to_eeprom) {
302 uint8_t mode = 0; 316 uint8_t mode = 0;
303 mode = rgblight_config.mode - 1; 317 mode = rgblight_config.mode - 1;
@@ -306,8 +320,12 @@ void rgblight_step_reverse_helper(bool write_to_eeprom) {
306 } 320 }
307 rgblight_mode_eeprom_helper(mode, write_to_eeprom); 321 rgblight_mode_eeprom_helper(mode, write_to_eeprom);
308} 322}
309void rgblight_step_reverse_noeeprom(void) { rgblight_step_reverse_helper(false); } 323void rgblight_step_reverse_noeeprom(void) {
310void rgblight_step_reverse(void) { rgblight_step_reverse_helper(true); } 324 rgblight_step_reverse_helper(false);
325}
326void rgblight_step_reverse(void) {
327 rgblight_step_reverse_helper(true);
328}
311 329
312uint8_t rgblight_get_mode(void) { 330uint8_t rgblight_get_mode(void) {
313 if (!rgblight_config.enable) { 331 if (!rgblight_config.enable) {
@@ -346,9 +364,13 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
346 rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); 364 rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
347} 365}
348 366
349void rgblight_mode(uint8_t mode) { rgblight_mode_eeprom_helper(mode, true); } 367void rgblight_mode(uint8_t mode) {
368 rgblight_mode_eeprom_helper(mode, true);
369}
350 370
351void rgblight_mode_noeeprom(uint8_t mode) { rgblight_mode_eeprom_helper(mode, false); } 371void rgblight_mode_noeeprom(uint8_t mode) {
372 rgblight_mode_eeprom_helper(mode, false);
373}
352 374
353void rgblight_toggle(void) { 375void rgblight_toggle(void) {
354 dprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); 376 dprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
@@ -401,64 +423,98 @@ void rgblight_disable_noeeprom(void) {
401 rgblight_set(); 423 rgblight_set();
402} 424}
403 425
404bool rgblight_is_enabled(void) { return rgblight_config.enable; } 426bool rgblight_is_enabled(void) {
427 return rgblight_config.enable;
428}
405 429
406void rgblight_increase_hue_helper(bool write_to_eeprom) { 430void rgblight_increase_hue_helper(bool write_to_eeprom) {
407 uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; 431 uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP;
408 rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); 432 rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
409} 433}
410void rgblight_increase_hue_noeeprom(void) { rgblight_increase_hue_helper(false); } 434void rgblight_increase_hue_noeeprom(void) {
411void rgblight_increase_hue(void) { rgblight_increase_hue_helper(true); } 435 rgblight_increase_hue_helper(false);
436}
437void rgblight_increase_hue(void) {
438 rgblight_increase_hue_helper(true);
439}
412void rgblight_decrease_hue_helper(bool write_to_eeprom) { 440void rgblight_decrease_hue_helper(bool write_to_eeprom) {
413 uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP; 441 uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP;
414 rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); 442 rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
415} 443}
416void rgblight_decrease_hue_noeeprom(void) { rgblight_decrease_hue_helper(false); } 444void rgblight_decrease_hue_noeeprom(void) {
417void rgblight_decrease_hue(void) { rgblight_decrease_hue_helper(true); } 445 rgblight_decrease_hue_helper(false);
446}
447void rgblight_decrease_hue(void) {
448 rgblight_decrease_hue_helper(true);
449}
418void rgblight_increase_sat_helper(bool write_to_eeprom) { 450void rgblight_increase_sat_helper(bool write_to_eeprom) {
419 uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP); 451 uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
420 rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); 452 rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
421} 453}
422void rgblight_increase_sat_noeeprom(void) { rgblight_increase_sat_helper(false); } 454void rgblight_increase_sat_noeeprom(void) {
423void rgblight_increase_sat(void) { rgblight_increase_sat_helper(true); } 455 rgblight_increase_sat_helper(false);
456}
457void rgblight_increase_sat(void) {
458 rgblight_increase_sat_helper(true);
459}
424void rgblight_decrease_sat_helper(bool write_to_eeprom) { 460void rgblight_decrease_sat_helper(bool write_to_eeprom) {
425 uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP); 461 uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
426 rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); 462 rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
427} 463}
428void rgblight_decrease_sat_noeeprom(void) { rgblight_decrease_sat_helper(false); } 464void rgblight_decrease_sat_noeeprom(void) {
429void rgblight_decrease_sat(void) { rgblight_decrease_sat_helper(true); } 465 rgblight_decrease_sat_helper(false);
466}
467void rgblight_decrease_sat(void) {
468 rgblight_decrease_sat_helper(true);
469}
430void rgblight_increase_val_helper(bool write_to_eeprom) { 470void rgblight_increase_val_helper(bool write_to_eeprom) {
431 uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP); 471 uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP);
432 rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); 472 rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
433} 473}
434void rgblight_increase_val_noeeprom(void) { rgblight_increase_val_helper(false); } 474void rgblight_increase_val_noeeprom(void) {
435void rgblight_increase_val(void) { rgblight_increase_val_helper(true); } 475 rgblight_increase_val_helper(false);
476}
477void rgblight_increase_val(void) {
478 rgblight_increase_val_helper(true);
479}
436void rgblight_decrease_val_helper(bool write_to_eeprom) { 480void rgblight_decrease_val_helper(bool write_to_eeprom) {
437 uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP); 481 uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP);
438 rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); 482 rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
439} 483}
440void rgblight_decrease_val_noeeprom(void) { rgblight_decrease_val_helper(false); } 484void rgblight_decrease_val_noeeprom(void) {
441void rgblight_decrease_val(void) { rgblight_decrease_val_helper(true); } 485 rgblight_decrease_val_helper(false);
486}
487void rgblight_decrease_val(void) {
488 rgblight_decrease_val_helper(true);
489}
442 490
443void rgblight_increase_speed_helper(bool write_to_eeprom) { 491void rgblight_increase_speed_helper(bool write_to_eeprom) {
444 if (rgblight_config.speed < 3) rgblight_config.speed++; 492 if (rgblight_config.speed < 3) rgblight_config.speed++;
445 // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED? 493 // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?
446 if (write_to_eeprom) { 494 if (write_to_eeprom) {
447 eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this 495 eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
448 } 496 }
449} 497}
450void rgblight_increase_speed(void) { rgblight_increase_speed_helper(true); } 498void rgblight_increase_speed(void) {
451void rgblight_increase_speed_noeeprom(void) { rgblight_increase_speed_helper(false); } 499 rgblight_increase_speed_helper(true);
500}
501void rgblight_increase_speed_noeeprom(void) {
502 rgblight_increase_speed_helper(false);
503}
452 504
453void rgblight_decrease_speed_helper(bool write_to_eeprom) { 505void rgblight_decrease_speed_helper(bool write_to_eeprom) {
454 if (rgblight_config.speed > 0) rgblight_config.speed--; 506 if (rgblight_config.speed > 0) rgblight_config.speed--;
455 // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?? 507 // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED??
456 if (write_to_eeprom) { 508 if (write_to_eeprom) {
457 eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this 509 eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
458 } 510 }
459} 511}
460void rgblight_decrease_speed(void) { rgblight_decrease_speed_helper(true); } 512void rgblight_decrease_speed(void) {
461void rgblight_decrease_speed_noeeprom(void) { rgblight_decrease_speed_helper(false); } 513 rgblight_decrease_speed_helper(true);
514}
515void rgblight_decrease_speed_noeeprom(void) {
516 rgblight_decrease_speed_helper(false);
517}
462 518
463void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { 519void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
464 if (rgblight_config.enable) { 520 if (rgblight_config.enable) {
@@ -478,7 +534,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
478 rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); 534 rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
479 } else { 535 } else {
480 // all LEDs in same color 536 // all LEDs in same color
481 if (1 == 0) { // dummy 537 if (1 == 0) { // dummy
482 } 538 }
483#ifdef RGBLIGHT_EFFECT_BREATHING 539#ifdef RGBLIGHT_EFFECT_BREATHING
484 else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { 540 else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) {
@@ -540,33 +596,51 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
540 } 596 }
541} 597}
542 598
543void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, true); } 599void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) {
600 rgblight_sethsv_eeprom_helper(hue, sat, val, true);
601}
544 602
545void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, false); } 603void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) {
604 rgblight_sethsv_eeprom_helper(hue, sat, val, false);
605}
546 606
547uint8_t rgblight_get_speed(void) { return rgblight_config.speed; } 607uint8_t rgblight_get_speed(void) {
608 return rgblight_config.speed;
609}
548 610
549void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { 611void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
550 rgblight_config.speed = speed; 612 rgblight_config.speed = speed;
551 if (write_to_eeprom) { 613 if (write_to_eeprom) {
552 eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this 614 eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
553 dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed); 615 dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed);
554 } else { 616 } else {
555 dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed); 617 dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed);
556 } 618 }
557} 619}
558 620
559void rgblight_set_speed(uint8_t speed) { rgblight_set_speed_eeprom_helper(speed, true); } 621void rgblight_set_speed(uint8_t speed) {
622 rgblight_set_speed_eeprom_helper(speed, true);
623}
560 624
561void rgblight_set_speed_noeeprom(uint8_t speed) { rgblight_set_speed_eeprom_helper(speed, false); } 625void rgblight_set_speed_noeeprom(uint8_t speed) {
626 rgblight_set_speed_eeprom_helper(speed, false);
627}
562 628
563uint8_t rgblight_get_hue(void) { return rgblight_config.hue; } 629uint8_t rgblight_get_hue(void) {
630 return rgblight_config.hue;
631}
564 632
565uint8_t rgblight_get_sat(void) { return rgblight_config.sat; } 633uint8_t rgblight_get_sat(void) {
634 return rgblight_config.sat;
635}
566 636
567uint8_t rgblight_get_val(void) { return rgblight_config.val; } 637uint8_t rgblight_get_val(void) {
638 return rgblight_config.val;
639}
568 640
569HSV rgblight_get_hsv(void) { return (HSV){rgblight_config.hue, rgblight_config.sat, rgblight_config.val}; } 641HSV rgblight_get_hsv(void) {
642 return (HSV){rgblight_config.hue, rgblight_config.sat, rgblight_config.val};
643}
570 644
571void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { 645void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
572 if (!rgblight_config.enable) { 646 if (!rgblight_config.enable) {
@@ -648,14 +722,22 @@ void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start,
648} 722}
649 723
650#ifndef RGBLIGHT_SPLIT 724#ifndef RGBLIGHT_SPLIT
651void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { rgblight_setrgb_range(r, g, b, 0, (uint8_t)RGBLED_NUM / 2); } 725void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) {
726 rgblight_setrgb_range(r, g, b, 0, (uint8_t)RGBLED_NUM / 2);
727}
652 728
653void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) { rgblight_setrgb_range(r, g, b, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); } 729void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) {
730 rgblight_setrgb_range(r, g, b, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM);
731}
654 732
655void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_range(hue, sat, val, 0, (uint8_t)RGBLED_NUM / 2); } 733void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) {
734 rgblight_sethsv_range(hue, sat, val, 0, (uint8_t)RGBLED_NUM / 2);
735}
656 736
657void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_range(hue, sat, val, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); } 737void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) {
658#endif // ifndef RGBLIGHT_SPLIT 738 rgblight_sethsv_range(hue, sat, val, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM);
739}
740#endif // ifndef RGBLIGHT_SPLIT
659 741
660#ifdef RGBLIGHT_LAYERS 742#ifdef RGBLIGHT_LAYERS
661void rgblight_set_layer_state(uint8_t layer, bool enabled) { 743void rgblight_set_layer_state(uint8_t layer, bool enabled) {
@@ -693,18 +775,18 @@ static void rgblight_layers_write(void) {
693 // For each layer 775 // For each layer
694 for (const rgblight_segment_t *const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) { 776 for (const rgblight_segment_t *const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) {
695 if (!rgblight_get_layer_state(i)) { 777 if (!rgblight_get_layer_state(i)) {
696 continue; // Layer is disabled 778 continue; // Layer is disabled
697 } 779 }
698 const rgblight_segment_t *segment_ptr = pgm_read_ptr(layer_ptr); 780 const rgblight_segment_t *segment_ptr = pgm_read_ptr(layer_ptr);
699 if (segment_ptr == NULL) { 781 if (segment_ptr == NULL) {
700 break; // No more layers 782 break; // No more layers
701 } 783 }
702 // For each segment 784 // For each segment
703 while (1) { 785 while (1) {
704 rgblight_segment_t segment; 786 rgblight_segment_t segment;
705 memcpy_P(&segment, segment_ptr, sizeof(rgblight_segment_t)); 787 memcpy_P(&segment, segment_ptr, sizeof(rgblight_segment_t));
706 if (segment.index == RGBLIGHT_END_SEGMENT_INDEX) { 788 if (segment.index == RGBLIGHT_END_SEGMENT_INDEX) {
707 break; // No more segments 789 break; // No more segments
708 } 790 }
709 // Write segment.count LEDs 791 // Write segment.count LEDs
710 LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)]; 792 LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
@@ -726,7 +808,9 @@ static uint16_t _repeat_timer;
726static uint8_t _times_remaining; 808static uint8_t _times_remaining;
727static uint16_t _dur; 809static uint16_t _dur;
728 810
729void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { rgblight_blink_layer_repeat(layer, duration_ms, 1); } 811void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) {
812 rgblight_blink_layer_repeat(layer, duration_ms, 1);
813}
730 814
731void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times) { 815void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times) {
732 _times_remaining = times * 2; 816 _times_remaining = times * 2;
@@ -796,7 +880,9 @@ void rgblight_wakeup(void) {
796 880
797#endif 881#endif
798 882
799__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } 883__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
884 ws2812_setleds(start_led, num_leds);
885}
800 886
801#ifndef RGBLIGHT_CUSTOM_DRIVER 887#ifndef RGBLIGHT_CUSTOM_DRIVER
802 888
@@ -848,9 +934,13 @@ void rgblight_set(void) {
848 934
849#ifdef RGBLIGHT_SPLIT 935#ifdef RGBLIGHT_SPLIT
850/* for split keyboard master side */ 936/* for split keyboard master side */
851uint8_t rgblight_get_change_flags(void) { return rgblight_status.change_flags; } 937uint8_t rgblight_get_change_flags(void) {
938 return rgblight_status.change_flags;
939}
852 940
853void rgblight_clear_change_flags(void) { rgblight_status.change_flags = 0; } 941void rgblight_clear_change_flags(void) {
942 rgblight_status.change_flags = 0;
943}
854 944
855void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo) { 945void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo) {
856 syncinfo->config = rgblight_config; 946 syncinfo->config = rgblight_config;
@@ -866,7 +956,7 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) {
866# endif 956# endif
867 if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_MODE) { 957 if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_MODE) {
868 if (syncinfo->config.enable) { 958 if (syncinfo->config.enable) {
869 rgblight_config.enable = 1; // == rgblight_enable_noeeprom(); 959 rgblight_config.enable = 1; // == rgblight_enable_noeeprom();
870 rgblight_mode_eeprom_helper(syncinfo->config.mode, write_to_eeprom); 960 rgblight_mode_eeprom_helper(syncinfo->config.mode, write_to_eeprom);
871 } else { 961 } else {
872 rgblight_disable_noeeprom(); 962 rgblight_disable_noeeprom();
@@ -945,12 +1035,12 @@ static void rgblight_effect_dummy(animation_status_t *anim) {
945void rgblight_task(void) { 1035void rgblight_task(void) {
946 if (rgblight_status.timer_enabled) { 1036 if (rgblight_status.timer_enabled) {
947 effect_func_t effect_func = rgblight_effect_dummy; 1037 effect_func_t effect_func = rgblight_effect_dummy;
948 uint16_t interval_time = 2000; // dummy interval 1038 uint16_t interval_time = 2000; // dummy interval
949 uint8_t delta = rgblight_config.mode - rgblight_status.base_mode; 1039 uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
950 animation_status.delta = delta; 1040 animation_status.delta = delta;
951 1041
952 // static light mode, do nothing here 1042 // static light mode, do nothing here
953 if (1 == 0) { // dummy 1043 if (1 == 0) { // dummy
954 } 1044 }
955# ifdef RGBLIGHT_EFFECT_BREATHING 1045# ifdef RGBLIGHT_EFFECT_BREATHING
956 else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { 1046 else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) {
@@ -1016,7 +1106,7 @@ void rgblight_task(void) {
1016 if (animation_status.restart) { 1106 if (animation_status.restart) {
1017 animation_status.restart = false; 1107 animation_status.restart = false;
1018 animation_status.last_timer = sync_timer_read(); 1108 animation_status.last_timer = sync_timer_read();
1019 animation_status.pos16 = 0; // restart signal to local each effect 1109 animation_status.pos16 = 0; // restart signal to local each effect
1020 } 1110 }
1021 uint16_t now = sync_timer_read(); 1111 uint16_t now = sync_timer_read();
1022 if (timer_expired(now, animation_status.last_timer)) { 1112 if (timer_expired(now, animation_status.last_timer)) {
@@ -1055,7 +1145,7 @@ void rgblight_task(void) {
1055 1145
1056# ifndef RGBLIGHT_EFFECT_BREATHE_CENTER 1146# ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
1057# ifndef RGBLIGHT_BREATHE_TABLE_SIZE 1147# ifndef RGBLIGHT_BREATHE_TABLE_SIZE
1058# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64 1148# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64
1059# endif 1149# endif
1060# include <rgblight_breathe_table.h> 1150# include <rgblight_breathe_table.h>
1061# endif 1151# endif
@@ -1131,7 +1221,7 @@ void rgblight_effect_snake(animation_status_t *anim) {
1131 } 1221 }
1132 1222
1133# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) 1223# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
1134 if (anim->pos == 0) { // restart signal 1224 if (anim->pos == 0) { // restart signal
1135 if (increment == 1) { 1225 if (increment == 1) {
1136 pos = rgblight_ranges.effect_num_leds - 1; 1226 pos = rgblight_ranges.effect_num_leds - 1;
1137 } else { 1227 } else {
@@ -1194,7 +1284,7 @@ void rgblight_effect_knight(animation_status_t *anim) {
1194 uint8_t i, cur; 1284 uint8_t i, cur;
1195 1285
1196# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) 1286# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
1197 if (anim->pos == 0) { // restart signal 1287 if (anim->pos == 0) { // restart signal
1198 anim->pos = 1; 1288 anim->pos = 1;
1199 low_bound = 0; 1289 low_bound = 0;
1200 high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1; 1290 high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
@@ -1347,8 +1437,12 @@ void rgblight_effect_twinkle(animation_status_t *anim) {
1347 const uint8_t bottom = breathe_calc(0); 1437 const uint8_t bottom = breathe_calc(0);
1348 const uint8_t top = breathe_calc(127); 1438 const uint8_t top = breathe_calc(127);
1349 1439
1350 uint8_t frac(uint8_t n, uint8_t d) { return (uint16_t)255 * n / d; } 1440 uint8_t frac(uint8_t n, uint8_t d) {
1351 uint8_t scale(uint16_t v, uint8_t scale) { return (v * scale) >> 8; } 1441 return (uint16_t)255 * n / d;
1442 }
1443 uint8_t scale(uint16_t v, uint8_t scale) {
1444 return (v * scale) >> 8;
1445 }
1352 1446
1353 for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { 1447 for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) {
1354 TwinkleState *t = &(led_twinkle_state[i]); 1448 TwinkleState *t = &(led_twinkle_state[i]);
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index 5b90b8f49e..7076dc41ac 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -119,7 +119,7 @@ enum RGBLIGHT_EFFECT_MODE {
119// sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 119// sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85
120 120
121#ifndef RGBLIGHT_EFFECT_BREATHE_MAX 121#ifndef RGBLIGHT_EFFECT_BREATHE_MAX
122# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 122# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255
123#endif 123#endif
124 124
125#ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH 125#ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH
@@ -177,8 +177,8 @@ enum RGBLIGHT_EFFECT_MODE {
177 177
178#ifdef RGBLIGHT_LAYERS 178#ifdef RGBLIGHT_LAYERS
179typedef struct { 179typedef struct {
180 uint8_t index; // The first LED to light 180 uint8_t index; // The first LED to light
181 uint8_t count; // The number of LEDs to light 181 uint8_t count; // The number of LEDs to light
182 uint8_t hue; 182 uint8_t hue;
183 uint8_t sat; 183 uint8_t sat;
184 uint8_t val; 184 uint8_t val;
@@ -241,7 +241,7 @@ typedef union {
241 uint8_t hue : 8; 241 uint8_t hue : 8;
242 uint8_t sat : 8; 242 uint8_t sat : 8;
243 uint8_t val : 8; 243 uint8_t val : 8;
244 uint8_t speed : 8; // EECONFIG needs to be increased to support this 244 uint8_t speed : 8; // EECONFIG needs to be increased to support this
245 }; 245 };
246} rgblight_config_t; 246} rgblight_config_t;
247 247
@@ -271,7 +271,7 @@ extern rgblight_ranges_t rgblight_ranges;
271 271
272/* === Utility Functions ===*/ 272/* === Utility Functions ===*/
273void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); 273void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1);
274void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check 274void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check
275void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); 275void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1);
276 276
277/* === Low level Functions === */ 277/* === Low level Functions === */
diff --git a/quantum/ring_buffer.h b/quantum/ring_buffer.h
index 284745ca8e..85419de11b 100644
--- a/quantum/ring_buffer.h
+++ b/quantum/ring_buffer.h
@@ -36,9 +36,13 @@ static inline uint8_t rbuf_dequeue(void) {
36} 36}
37static inline bool rbuf_has_data(void) { 37static inline bool rbuf_has_data(void) {
38 bool has_data; 38 bool has_data;
39 ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { has_data = (rbuf_head != rbuf_tail); } 39 ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
40 has_data = (rbuf_head != rbuf_tail);
41 }
40 return has_data; 42 return has_data;
41} 43}
42static inline void rbuf_clear(void) { 44static inline void rbuf_clear(void) {
43 ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { rbuf_head = rbuf_tail = 0; } 45 ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
46 rbuf_head = rbuf_tail = 0;
47 }
44} 48}
diff --git a/quantum/send_string.c b/quantum/send_string.c
index 1a7f7a1315..0de12ba12d 100644
--- a/quantum/send_string.c
+++ b/quantum/send_string.c
@@ -142,9 +142,13 @@ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
142// Note: we bit-pack in "reverse" order to optimize loading 142// Note: we bit-pack in "reverse" order to optimize loading
143#define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01) 143#define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01)
144 144
145void send_string(const char *str) { send_string_with_delay(str, 0); } 145void send_string(const char *str) {
146 send_string_with_delay(str, 0);
147}
146 148
147void send_string_P(const char *str) { send_string_with_delay_P(str, 0); } 149void send_string_P(const char *str) {
150 send_string_with_delay_P(str, 0);
151}
148 152
149void send_string_with_delay(const char *str, uint8_t interval) { 153void send_string_with_delay(const char *str, uint8_t interval) {
150 while (1) { 154 while (1) {
@@ -173,7 +177,8 @@ void send_string_with_delay(const char *str, uint8_t interval) {
173 ms += keycode - '0'; 177 ms += keycode - '0';
174 keycode = *(++str); 178 keycode = *(++str);
175 } 179 }
176 while (ms--) wait_ms(1); 180 while (ms--)
181 wait_ms(1);
177 } 182 }
178 } else { 183 } else {
179 send_char(ascii_code); 184 send_char(ascii_code);
@@ -182,7 +187,8 @@ void send_string_with_delay(const char *str, uint8_t interval) {
182 // interval 187 // interval
183 { 188 {
184 uint8_t ms = interval; 189 uint8_t ms = interval;
185 while (ms--) wait_ms(1); 190 while (ms--)
191 wait_ms(1);
186 } 192 }
187 } 193 }
188} 194}
@@ -214,7 +220,8 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
214 ms += keycode - '0'; 220 ms += keycode - '0';
215 keycode = pgm_read_byte(++str); 221 keycode = pgm_read_byte(++str);
216 } 222 }
217 while (ms--) wait_ms(1); 223 while (ms--)
224 wait_ms(1);
218 } 225 }
219 } else { 226 } else {
220 send_char(ascii_code); 227 send_char(ascii_code);
@@ -223,14 +230,15 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
223 // interval 230 // interval
224 { 231 {
225 uint8_t ms = interval; 232 uint8_t ms = interval;
226 while (ms--) wait_ms(1); 233 while (ms--)
234 wait_ms(1);
227 } 235 }
228 } 236 }
229} 237}
230 238
231void send_char(char ascii_code) { 239void send_char(char ascii_code) {
232#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL) 240#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL)
233 if (ascii_code == '\a') { // BEL 241 if (ascii_code == '\a') { // BEL
234 PLAY_SONG(bell_song); 242 PLAY_SONG(bell_song);
235 return; 243 return;
236 } 244 }
diff --git a/quantum/sequencer/sequencer.c b/quantum/sequencer/sequencer.c
index 18a83661ec..2e92f7b3eb 100644
--- a/quantum/sequencer/sequencer.c
+++ b/quantum/sequencer/sequencer.c
@@ -25,16 +25,18 @@
25#endif 25#endif
26 26
27sequencer_config_t sequencer_config = { 27sequencer_config_t sequencer_config = {
28 false, // enabled 28 false, // enabled
29 {false}, // steps 29 {false}, // steps
30 {0}, // track notes 30 {0}, // track notes
31 60, // tempo 31 60, // tempo
32 SQ_RES_4, // resolution 32 SQ_RES_4, // resolution
33}; 33};
34 34
35sequencer_state_t sequencer_internal_state = {0, 0, 0, 0, SEQUENCER_PHASE_ATTACK}; 35sequencer_state_t sequencer_internal_state = {0, 0, 0, 0, SEQUENCER_PHASE_ATTACK};
36 36
37bool is_sequencer_on(void) { return sequencer_config.enabled; } 37bool is_sequencer_on(void) {
38 return sequencer_config.enabled;
39}
38 40
39void sequencer_on(void) { 41void sequencer_on(void) {
40 dprintln("sequencer on"); 42 dprintln("sequencer on");
@@ -65,7 +67,9 @@ void sequencer_set_track_notes(const uint16_t track_notes[SEQUENCER_TRACKS]) {
65 } 67 }
66} 68}
67 69
68bool is_sequencer_track_active(uint8_t track) { return (sequencer_internal_state.active_tracks >> track) & true; } 70bool is_sequencer_track_active(uint8_t track) {
71 return (sequencer_internal_state.active_tracks >> track) & true;
72}
69 73
70void sequencer_set_track_activation(uint8_t track, bool value) { 74void sequencer_set_track_activation(uint8_t track, bool value) {
71 if (value) { 75 if (value) {
@@ -76,7 +80,9 @@ void sequencer_set_track_activation(uint8_t track, bool value) {
76 dprintf("sequencer: track %d is %s\n", track, value ? "active" : "inactive"); 80 dprintf("sequencer: track %d is %s\n", track, value ? "active" : "inactive");
77} 81}
78 82
79void sequencer_toggle_track_activation(uint8_t track) { sequencer_set_track_activation(track, !is_sequencer_track_active(track)); } 83void sequencer_toggle_track_activation(uint8_t track) {
84 sequencer_set_track_activation(track, !is_sequencer_track_active(track));
85}
80 86
81void sequencer_toggle_single_active_track(uint8_t track) { 87void sequencer_toggle_single_active_track(uint8_t track) {
82 if (is_sequencer_track_active(track)) { 88 if (is_sequencer_track_active(track)) {
@@ -86,9 +92,13 @@ void sequencer_toggle_single_active_track(uint8_t track) {
86 } 92 }
87} 93}
88 94
89bool is_sequencer_step_on(uint8_t step) { return step < SEQUENCER_STEPS && (sequencer_config.steps[step] & sequencer_internal_state.active_tracks) > 0; } 95bool is_sequencer_step_on(uint8_t step) {
96 return step < SEQUENCER_STEPS && (sequencer_config.steps[step] & sequencer_internal_state.active_tracks) > 0;
97}
90 98
91bool is_sequencer_step_on_for_track(uint8_t step, uint8_t track) { return step < SEQUENCER_STEPS && (sequencer_config.steps[step] >> track) & true; } 99bool is_sequencer_step_on_for_track(uint8_t step, uint8_t track) {
100 return step < SEQUENCER_STEPS && (sequencer_config.steps[step] >> track) & true;
101}
92 102
93void sequencer_set_step(uint8_t step, bool value) { 103void sequencer_set_step(uint8_t step, bool value) {
94 if (step < SEQUENCER_STEPS) { 104 if (step < SEQUENCER_STEPS) {
@@ -122,7 +132,9 @@ void sequencer_set_all_steps(bool value) {
122 dprintf("sequencer: all steps are %s\n", value ? "on" : "off"); 132 dprintf("sequencer: all steps are %s\n", value ? "on" : "off");
123} 133}
124 134
125uint8_t sequencer_get_tempo(void) { return sequencer_config.tempo; } 135uint8_t sequencer_get_tempo(void) {
136 return sequencer_config.tempo;
137}
126 138
127void sequencer_set_tempo(uint8_t tempo) { 139void sequencer_set_tempo(uint8_t tempo) {
128 if (tempo > 0) { 140 if (tempo > 0) {
@@ -142,9 +154,13 @@ void sequencer_increase_tempo(void) {
142 } 154 }
143} 155}
144 156
145void sequencer_decrease_tempo(void) { sequencer_set_tempo(sequencer_config.tempo - 1); } 157void sequencer_decrease_tempo(void) {
158 sequencer_set_tempo(sequencer_config.tempo - 1);
159}
146 160
147sequencer_resolution_t sequencer_get_resolution(void) { return sequencer_config.resolution; } 161sequencer_resolution_t sequencer_get_resolution(void) {
162 return sequencer_config.resolution;
163}
148 164
149void sequencer_set_resolution(sequencer_resolution_t resolution) { 165void sequencer_set_resolution(sequencer_resolution_t resolution) {
150 if (resolution >= 0 && resolution < SEQUENCER_RESOLUTIONS) { 166 if (resolution >= 0 && resolution < SEQUENCER_RESOLUTIONS) {
@@ -155,11 +171,17 @@ void sequencer_set_resolution(sequencer_resolution_t resolution) {
155 } 171 }
156} 172}
157 173
158void sequencer_increase_resolution(void) { sequencer_set_resolution(sequencer_config.resolution + 1); } 174void sequencer_increase_resolution(void) {
175 sequencer_set_resolution(sequencer_config.resolution + 1);
176}
159 177
160void sequencer_decrease_resolution(void) { sequencer_set_resolution(sequencer_config.resolution - 1); } 178void sequencer_decrease_resolution(void) {
179 sequencer_set_resolution(sequencer_config.resolution - 1);
180}
161 181
162uint8_t sequencer_get_current_step(void) { return sequencer_internal_state.current_step; } 182uint8_t sequencer_get_current_step(void) {
183 return sequencer_internal_state.current_step;
184}
163 185
164void sequencer_phase_attack(void) { 186void sequencer_phase_attack(void) {
165 dprintf("sequencer: step %d\n", sequencer_internal_state.current_step); 187 dprintf("sequencer: step %d\n", sequencer_internal_state.current_step);
@@ -229,9 +251,13 @@ void sequencer_task(void) {
229 } 251 }
230} 252}
231 253
232uint16_t sequencer_get_beat_duration(void) { return get_beat_duration(sequencer_config.tempo); } 254uint16_t sequencer_get_beat_duration(void) {
255 return get_beat_duration(sequencer_config.tempo);
256}
233 257
234uint16_t sequencer_get_step_duration(void) { return get_step_duration(sequencer_config.tempo, sequencer_config.resolution); } 258uint16_t sequencer_get_step_duration(void) {
259 return get_step_duration(sequencer_config.tempo, sequencer_config.resolution);
260}
235 261
236uint16_t get_beat_duration(uint8_t tempo) { 262uint16_t get_beat_duration(uint8_t tempo) {
237 // Don’t crash in the unlikely case where the given tempo is 0 263 // Don’t crash in the unlikely case where the given tempo is 0
diff --git a/quantum/sequencer/sequencer.h b/quantum/sequencer/sequencer.h
index 4017ae764e..a8ea16eece 100644
--- a/quantum/sequencer/sequencer.h
+++ b/quantum/sequencer/sequencer.h
@@ -48,7 +48,7 @@ typedef struct {
48 bool enabled; 48 bool enabled;
49 uint8_t steps[SEQUENCER_STEPS]; 49 uint8_t steps[SEQUENCER_STEPS];
50 uint16_t track_notes[SEQUENCER_TRACKS]; 50 uint16_t track_notes[SEQUENCER_TRACKS];
51 uint8_t tempo; // Is a maximum tempo of 255 reasonable? 51 uint8_t tempo; // Is a maximum tempo of 255 reasonable?
52 sequencer_resolution_t resolution; 52 sequencer_resolution_t resolution;
53} sequencer_config_t; 53} sequencer_config_t;
54 54
@@ -57,9 +57,9 @@ typedef struct {
57 * We use a "phase" state machine to delay some of the events. 57 * We use a "phase" state machine to delay some of the events.
58 */ 58 */
59typedef enum sequencer_phase_t { 59typedef enum sequencer_phase_t {
60 SEQUENCER_PHASE_ATTACK, // t=0ms, send the MIDI note on signal 60 SEQUENCER_PHASE_ATTACK, // t=0ms, send the MIDI note on signal
61 SEQUENCER_PHASE_RELEASE, // t=SEQUENCER_PHASE_RELEASE_TIMEOUT ms, send the MIDI note off signal 61 SEQUENCER_PHASE_RELEASE, // t=SEQUENCER_PHASE_RELEASE_TIMEOUT ms, send the MIDI note off signal
62 SEQUENCER_PHASE_PAUSE // t=step duration ms, loop 62 SEQUENCER_PHASE_PAUSE // t=step duration ms, loop
63} sequencer_phase_t; 63} sequencer_phase_t;
64 64
65typedef struct { 65typedef struct {
diff --git a/quantum/sequencer/tests/midi_mock.c b/quantum/sequencer/tests/midi_mock.c
index 236e16f9d7..5bd945d615 100644
--- a/quantum/sequencer/tests/midi_mock.c
+++ b/quantum/sequencer/tests/midi_mock.c
@@ -19,8 +19,14 @@
19uint16_t last_noteon = 0; 19uint16_t last_noteon = 0;
20uint16_t last_noteoff = 0; 20uint16_t last_noteoff = 0;
21 21
22uint16_t midi_compute_note(uint16_t keycode) { return keycode; } 22uint16_t midi_compute_note(uint16_t keycode) {
23 return keycode;
24}
23 25
24void process_midi_basic_noteon(uint16_t note) { last_noteon = note; } 26void process_midi_basic_noteon(uint16_t note) {
27 last_noteon = note;
28}
25 29
26void process_midi_basic_noteoff(uint16_t note) { last_noteoff = note; } 30void process_midi_basic_noteoff(uint16_t note) {
31 last_noteoff = note;
32}
diff --git a/quantum/sequencer/tests/sequencer_tests.cpp b/quantum/sequencer/tests/sequencer_tests.cpp
index 290605a52a..05e58e4111 100644
--- a/quantum/sequencer/tests/sequencer_tests.cpp
+++ b/quantum/sequencer/tests/sequencer_tests.cpp
@@ -78,7 +78,9 @@ class SequencerTest : public ::testing::Test {
78 sequencer_state_t state_copy; 78 sequencer_state_t state_copy;
79}; 79};
80 80
81TEST_F(SequencerTest, TestOffByDefault) { EXPECT_EQ(is_sequencer_on(), false); } 81TEST_F(SequencerTest, TestOffByDefault) {
82 EXPECT_EQ(is_sequencer_on(), false);
83}
82 84
83TEST_F(SequencerTest, TestOn) { 85TEST_F(SequencerTest, TestOn) {
84 sequencer_config.enabled = false; 86 sequencer_config.enabled = false;
diff --git a/quantum/split_common/post_config.h b/quantum/split_common/post_config.h
index a4c0a1956b..8f79beb6ed 100644
--- a/quantum/split_common/post_config.h
+++ b/quantum/split_common/post_config.h
@@ -5,6 +5,6 @@
5# endif 5# endif
6 6
7# ifndef F_SCL 7# ifndef F_SCL
8# define F_SCL 100000UL // SCL frequency 8# define F_SCL 100000UL // SCL frequency
9# endif 9# endif
10#endif 10#endif
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index 35f0a9d181..7d50adf758 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -43,14 +43,14 @@
43// Set to 0 to disable the disconnection check altogether. 43// Set to 0 to disable the disconnection check altogether.
44#ifndef SPLIT_MAX_CONNECTION_ERRORS 44#ifndef SPLIT_MAX_CONNECTION_ERRORS
45# define SPLIT_MAX_CONNECTION_ERRORS 10 45# define SPLIT_MAX_CONNECTION_ERRORS 10
46#endif // SPLIT_MAX_CONNECTION_ERRORS 46#endif // SPLIT_MAX_CONNECTION_ERRORS
47 47
48// How long (in milliseconds) to block all connection attempts after the communication has been flagged as disconnected. 48// How long (in milliseconds) to block all connection attempts after the communication has been flagged as disconnected.
49// One communication attempt will be allowed everytime this amount of time has passed since the last attempt. If that attempt succeeds, the communication is seen as working again. 49// One communication attempt will be allowed everytime this amount of time has passed since the last attempt. If that attempt succeeds, the communication is seen as working again.
50// Set to 0 to disable communication throttling while disconnected 50// Set to 0 to disable communication throttling while disconnected
51#ifndef SPLIT_CONNECTION_CHECK_TIMEOUT 51#ifndef SPLIT_CONNECTION_CHECK_TIMEOUT
52# define SPLIT_CONNECTION_CHECK_TIMEOUT 500 52# define SPLIT_CONNECTION_CHECK_TIMEOUT 500
53#endif // SPLIT_CONNECTION_CHECK_TIMEOUT 53#endif // SPLIT_CONNECTION_CHECK_TIMEOUT
54 54
55static uint8_t connection_errors = 0; 55static uint8_t connection_errors = 0;
56 56
@@ -68,7 +68,9 @@ static bool usbIsActive(void) {
68 return false; 68 return false;
69} 69}
70#else 70#else
71static inline bool usbIsActive(void) { return usb_vbus_state(); } 71static inline bool usbIsActive(void) {
72 return usb_vbus_state();
73}
72#endif 74#endif
73 75
74#ifdef SPLIT_HAND_MATRIX_GRID 76#ifdef SPLIT_HAND_MATRIX_GRID
@@ -83,7 +85,7 @@ static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) {
83 uint8_t pin_state = readPin(in_pin); 85 uint8_t pin_state = readPin(in_pin);
84 // Set out_pin to a setting that is less susceptible to noise. 86 // Set out_pin to a setting that is less susceptible to noise.
85 setPinInputHigh(out_pin); 87 setPinInputHigh(out_pin);
86 matrix_io_delay(); // Wait for the pull-up to go HIGH. 88 matrix_io_delay(); // Wait for the pull-up to go HIGH.
87 return pin_state; 89 return pin_state;
88} 90}
89#endif 91#endif
@@ -158,7 +160,9 @@ void split_post_init(void) {
158 } 160 }
159} 161}
160 162
161bool is_transport_connected(void) { return connection_errors < SPLIT_MAX_CONNECTION_ERRORS; } 163bool is_transport_connected(void) {
164 return connection_errors < SPLIT_MAX_CONNECTION_ERRORS;
165}
162 166
163bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { 167bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
164#if SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 168#if SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0
@@ -169,7 +173,7 @@ bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t sl
169 if (is_disconnected && timer_elapsed(connection_check_timer) < SPLIT_CONNECTION_CHECK_TIMEOUT) { 173 if (is_disconnected && timer_elapsed(connection_check_timer) < SPLIT_CONNECTION_CHECK_TIMEOUT) {
170 return false; 174 return false;
171 } 175 }
172#endif // SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 176#endif // SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0
173 177
174 __attribute__((unused)) bool okay = transport_master(master_matrix, slave_matrix); 178 __attribute__((unused)) bool okay = transport_master(master_matrix, slave_matrix);
175#if SPLIT_MAX_CONNECTION_ERRORS > 0 179#if SPLIT_MAX_CONNECTION_ERRORS > 0
@@ -186,10 +190,10 @@ bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t sl
186 return connected; 190 return connected;
187 } else if (is_disconnected) { 191 } else if (is_disconnected) {
188 dprintln("Target connected"); 192 dprintln("Target connected");
189# endif // SPLIT_CONNECTION_CHECK_TIMEOUT > 0 193# endif // SPLIT_CONNECTION_CHECK_TIMEOUT > 0
190 } 194 }
191 195
192 connection_errors = 0; 196 connection_errors = 0;
193#endif // SPLIT_MAX_CONNECTION_ERRORS > 0 197#endif // SPLIT_MAX_CONNECTION_ERRORS > 0
194 return true; 198 return true;
195} 199}
diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h
index aa71c3621e..761a8884f4 100644
--- a/quantum/split_common/transaction_id_define.h
+++ b/quantum/split_common/transaction_id_define.h
@@ -19,87 +19,87 @@
19enum serial_transaction_id { 19enum serial_transaction_id {
20#ifdef USE_I2C 20#ifdef USE_I2C
21 I2C_EXECUTE_CALLBACK, 21 I2C_EXECUTE_CALLBACK,
22#endif // USE_I2C 22#endif // USE_I2C
23 23
24 GET_SLAVE_MATRIX_CHECKSUM, 24 GET_SLAVE_MATRIX_CHECKSUM,
25 GET_SLAVE_MATRIX_DATA, 25 GET_SLAVE_MATRIX_DATA,
26 26
27#ifdef SPLIT_TRANSPORT_MIRROR 27#ifdef SPLIT_TRANSPORT_MIRROR
28 PUT_MASTER_MATRIX, 28 PUT_MASTER_MATRIX,
29#endif // SPLIT_TRANSPORT_MIRROR 29#endif // SPLIT_TRANSPORT_MIRROR
30 30
31#ifdef ENCODER_ENABLE 31#ifdef ENCODER_ENABLE
32 GET_ENCODERS_CHECKSUM, 32 GET_ENCODERS_CHECKSUM,
33 GET_ENCODERS_DATA, 33 GET_ENCODERS_DATA,
34#endif // ENCODER_ENABLE 34#endif // ENCODER_ENABLE
35 35
36#ifndef DISABLE_SYNC_TIMER 36#ifndef DISABLE_SYNC_TIMER
37 PUT_SYNC_TIMER, 37 PUT_SYNC_TIMER,
38#endif // DISABLE_SYNC_TIMER 38#endif // DISABLE_SYNC_TIMER
39 39
40#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 40#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
41 PUT_LAYER_STATE, 41 PUT_LAYER_STATE,
42 PUT_DEFAULT_LAYER_STATE, 42 PUT_DEFAULT_LAYER_STATE,
43#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 43#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
44 44
45#ifdef SPLIT_LED_STATE_ENABLE 45#ifdef SPLIT_LED_STATE_ENABLE
46 PUT_LED_STATE, 46 PUT_LED_STATE,
47#endif // SPLIT_LED_STATE_ENABLE 47#endif // SPLIT_LED_STATE_ENABLE
48 48
49#ifdef SPLIT_MODS_ENABLE 49#ifdef SPLIT_MODS_ENABLE
50 PUT_MODS, 50 PUT_MODS,
51#endif // SPLIT_MODS_ENABLE 51#endif // SPLIT_MODS_ENABLE
52 52
53#ifdef BACKLIGHT_ENABLE 53#ifdef BACKLIGHT_ENABLE
54 PUT_BACKLIGHT, 54 PUT_BACKLIGHT,
55#endif // BACKLIGHT_ENABLE 55#endif // BACKLIGHT_ENABLE
56 56
57#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 57#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
58 PUT_RGBLIGHT, 58 PUT_RGBLIGHT,
59#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 59#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
60 60
61#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 61#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
62 PUT_LED_MATRIX, 62 PUT_LED_MATRIX,
63#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 63#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
64 64
65#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 65#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
66 PUT_RGB_MATRIX, 66 PUT_RGB_MATRIX,
67#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 67#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
68 68
69#if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) 69#if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
70 PUT_WPM, 70 PUT_WPM,
71#endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) 71#endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
72 72
73#if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) 73#if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
74 PUT_OLED, 74 PUT_OLED,
75#endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) 75#endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
76 76
77#if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) 77#if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
78 PUT_ST7565, 78 PUT_ST7565,
79#endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) 79#endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
80 80
81#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 81#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
82 GET_POINTING_CHECKSUM, 82 GET_POINTING_CHECKSUM,
83 GET_POINTING_DATA, 83 GET_POINTING_DATA,
84 PUT_POINTING_CPI, 84 PUT_POINTING_CPI,
85#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 85#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
86 86
87#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 87#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
88 PUT_RPC_INFO, 88 PUT_RPC_INFO,
89 PUT_RPC_REQ_DATA, 89 PUT_RPC_REQ_DATA,
90 EXECUTE_RPC, 90 EXECUTE_RPC,
91 GET_RPC_RESP_DATA, 91 GET_RPC_RESP_DATA,
92#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 92#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
93 93
94// keyboard-specific 94// keyboard-specific
95#ifdef SPLIT_TRANSACTION_IDS_KB 95#ifdef SPLIT_TRANSACTION_IDS_KB
96 SPLIT_TRANSACTION_IDS_KB, 96 SPLIT_TRANSACTION_IDS_KB,
97#endif // SPLIT_TRANSACTION_IDS_KB 97#endif // SPLIT_TRANSACTION_IDS_KB
98 98
99// user/keymap-specific 99// user/keymap-specific
100#ifdef SPLIT_TRANSACTION_IDS_USER 100#ifdef SPLIT_TRANSACTION_IDS_USER
101 SPLIT_TRANSACTION_IDS_USER, 101 SPLIT_TRANSACTION_IDS_USER,
102#endif // SPLIT_TRANSACTION_IDS_USER 102#endif // SPLIT_TRANSACTION_IDS_USER
103 103
104 NUM_TOTAL_TRANSACTIONS 104 NUM_TOTAL_TRANSACTIONS
105}; 105};
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
index 4b059a2b8a..cffbccaeee 100644
--- a/quantum/split_common/transactions.c
+++ b/quantum/split_common/transactions.c
@@ -30,7 +30,7 @@
30 30
31#ifndef FORCED_SYNC_THROTTLE_MS 31#ifndef FORCED_SYNC_THROTTLE_MS
32# define FORCED_SYNC_THROTTLE_MS 100 32# define FORCED_SYNC_THROTTLE_MS 100
33#endif // FORCED_SYNC_THROTTLE_MS 33#endif // FORCED_SYNC_THROTTLE_MS
34 34
35#define sizeof_member(type, member) sizeof(((type *)NULL)->member) 35#define sizeof_member(type, member) sizeof(((type *)NULL)->member)
36 36
@@ -49,7 +49,7 @@
49// Forward-declare the RPC callback handlers 49// Forward-declare the RPC callback handlers
50void slave_rpc_info_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); 50void slave_rpc_info_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer);
51void slave_rpc_exec_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); 51void slave_rpc_exec_callback(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer);
52#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 52#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
53 53
54//////////////////////////////////////////////////// 54////////////////////////////////////////////////////
55// Helpers 55// Helpers
@@ -63,7 +63,9 @@ static bool transaction_handler_master(matrix_row_t master_matrix[], matrix_row_
63 } 63 }
64 } 64 }
65 bool this_okay = true; 65 bool this_okay = true;
66 ATOMIC_BLOCK_FORCEON { this_okay = handler(master_matrix, slave_matrix); }; 66 ATOMIC_BLOCK_FORCEON {
67 this_okay = handler(master_matrix, slave_matrix);
68 };
67 if (this_okay) return true; 69 if (this_okay) return true;
68 } 70 }
69 dprintf("Failed to execute %s\n", prefix); 71 dprintf("Failed to execute %s\n", prefix);
@@ -75,9 +77,11 @@ static bool transaction_handler_master(matrix_row_t master_matrix[], matrix_row_
75 if (!transaction_handler_master(master_matrix, slave_matrix, #prefix, &prefix##_handlers_master)) return false; \ 77 if (!transaction_handler_master(master_matrix, slave_matrix, #prefix, &prefix##_handlers_master)) return false; \
76 } while (0) 78 } while (0)
77 79
78#define TRANSACTION_HANDLER_SLAVE(prefix) \ 80#define TRANSACTION_HANDLER_SLAVE(prefix) \
79 do { \ 81 do { \
80 ATOMIC_BLOCK_FORCEON { prefix##_handlers_slave(master_matrix, slave_matrix); }; \ 82 ATOMIC_BLOCK_FORCEON { \
83 prefix##_handlers_slave(master_matrix, slave_matrix); \
84 }; \
81 } while (0) 85 } while (0)
82 86
83inline static bool read_if_checksum_mismatch(int8_t trans_id_checksum, int8_t trans_id_retrieve, uint32_t *last_update, void *destination, const void *equiv_shmem, size_t length) { 87inline static bool read_if_checksum_mismatch(int8_t trans_id_checksum, int8_t trans_id_retrieve, uint32_t *last_update, void *destination, const void *equiv_shmem, size_t length) {
@@ -116,8 +120,8 @@ inline static bool send_if_data_mismatch(int8_t trans_id, uint32_t *last_update,
116 120
117static bool slave_matrix_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { 121static bool slave_matrix_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
118 static uint32_t last_update = 0; 122 static uint32_t last_update = 0;
119 static matrix_row_t last_matrix[(MATRIX_ROWS) / 2] = {0}; // last successfully-read matrix, so we can replicate if there are checksum errors 123 static matrix_row_t last_matrix[(MATRIX_ROWS) / 2] = {0}; // last successfully-read matrix, so we can replicate if there are checksum errors
120 matrix_row_t temp_matrix[(MATRIX_ROWS) / 2]; // holding area while we test whether or not checksum is correct 124 matrix_row_t temp_matrix[(MATRIX_ROWS) / 2]; // holding area while we test whether or not checksum is correct
121 125
122 bool okay = read_if_checksum_mismatch(GET_SLAVE_MATRIX_CHECKSUM, GET_SLAVE_MATRIX_DATA, &last_update, temp_matrix, split_shmem->smatrix.matrix, sizeof(split_shmem->smatrix.matrix)); 126 bool okay = read_if_checksum_mismatch(GET_SLAVE_MATRIX_CHECKSUM, GET_SLAVE_MATRIX_DATA, &last_update, temp_matrix, split_shmem->smatrix.matrix, sizeof(split_shmem->smatrix.matrix));
123 if (okay) { 127 if (okay) {
@@ -161,13 +165,13 @@ static void master_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_ro
161# define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix) 165# define TRANSACTIONS_MASTER_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(master_matrix)
162# define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix), 166# define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS [PUT_MASTER_MATRIX] = trans_initiator2target_initializer(mmatrix.matrix),
163 167
164#else // SPLIT_TRANSPORT_MIRROR 168#else // SPLIT_TRANSPORT_MIRROR
165 169
166# define TRANSACTIONS_MASTER_MATRIX_MASTER() 170# define TRANSACTIONS_MASTER_MATRIX_MASTER()
167# define TRANSACTIONS_MASTER_MATRIX_SLAVE() 171# define TRANSACTIONS_MASTER_MATRIX_SLAVE()
168# define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS 172# define TRANSACTIONS_MASTER_MATRIX_REGISTRATIONS
169 173
170#endif // SPLIT_TRANSPORT_MIRROR 174#endif // SPLIT_TRANSPORT_MIRROR
171 175
172//////////////////////////////////////////////////// 176////////////////////////////////////////////////////
173// Encoders 177// Encoders
@@ -200,13 +204,13 @@ static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sl
200 [GET_ENCODERS_DATA] = trans_target2initiator_initializer(encoders.state), 204 [GET_ENCODERS_DATA] = trans_target2initiator_initializer(encoders.state),
201// clang-format on 205// clang-format on
202 206
203#else // ENCODER_ENABLE 207#else // ENCODER_ENABLE
204 208
205# define TRANSACTIONS_ENCODERS_MASTER() 209# define TRANSACTIONS_ENCODERS_MASTER()
206# define TRANSACTIONS_ENCODERS_SLAVE() 210# define TRANSACTIONS_ENCODERS_SLAVE()
207# define TRANSACTIONS_ENCODERS_REGISTRATIONS 211# define TRANSACTIONS_ENCODERS_REGISTRATIONS
208 212
209#endif // ENCODER_ENABLE 213#endif // ENCODER_ENABLE
210 214
211//////////////////////////////////////////////////// 215////////////////////////////////////////////////////
212// Sync timer 216// Sync timer
@@ -239,13 +243,13 @@ static void sync_timer_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
239# define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer) 243# define TRANSACTIONS_SYNC_TIMER_SLAVE() TRANSACTION_HANDLER_SLAVE(sync_timer)
240# define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer), 244# define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS [PUT_SYNC_TIMER] = trans_initiator2target_initializer(sync_timer),
241 245
242#else // DISABLE_SYNC_TIMER 246#else // DISABLE_SYNC_TIMER
243 247
244# define TRANSACTIONS_SYNC_TIMER_MASTER() 248# define TRANSACTIONS_SYNC_TIMER_MASTER()
245# define TRANSACTIONS_SYNC_TIMER_SLAVE() 249# define TRANSACTIONS_SYNC_TIMER_SLAVE()
246# define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS 250# define TRANSACTIONS_SYNC_TIMER_REGISTRATIONS
247 251
248#endif // DISABLE_SYNC_TIMER 252#endif // DISABLE_SYNC_TIMER
249 253
250//////////////////////////////////////////////////// 254////////////////////////////////////////////////////
251// Layer state 255// Layer state
@@ -276,13 +280,13 @@ static void layer_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_
276 [PUT_DEFAULT_LAYER_STATE] = trans_initiator2target_initializer(layers.default_layer_state), 280 [PUT_DEFAULT_LAYER_STATE] = trans_initiator2target_initializer(layers.default_layer_state),
277// clang-format on 281// clang-format on
278 282
279#else // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 283#else // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
280 284
281# define TRANSACTIONS_LAYER_STATE_MASTER() 285# define TRANSACTIONS_LAYER_STATE_MASTER()
282# define TRANSACTIONS_LAYER_STATE_SLAVE() 286# define TRANSACTIONS_LAYER_STATE_SLAVE()
283# define TRANSACTIONS_LAYER_STATE_REGISTRATIONS 287# define TRANSACTIONS_LAYER_STATE_REGISTRATIONS
284 288
285#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 289#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
286 290
287//////////////////////////////////////////////////// 291////////////////////////////////////////////////////
288// LED state 292// LED state
@@ -304,13 +308,13 @@ static void led_state_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
304# define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state) 308# define TRANSACTIONS_LED_STATE_SLAVE() TRANSACTION_HANDLER_SLAVE(led_state)
305# define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state), 309# define TRANSACTIONS_LED_STATE_REGISTRATIONS [PUT_LED_STATE] = trans_initiator2target_initializer(led_state),
306 310
307#else // SPLIT_LED_STATE_ENABLE 311#else // SPLIT_LED_STATE_ENABLE
308 312
309# define TRANSACTIONS_LED_STATE_MASTER() 313# define TRANSACTIONS_LED_STATE_MASTER()
310# define TRANSACTIONS_LED_STATE_SLAVE() 314# define TRANSACTIONS_LED_STATE_SLAVE()
311# define TRANSACTIONS_LED_STATE_REGISTRATIONS 315# define TRANSACTIONS_LED_STATE_REGISTRATIONS
312 316
313#endif // SPLIT_LED_STATE_ENABLE 317#endif // SPLIT_LED_STATE_ENABLE
314 318
315//////////////////////////////////////////////////// 319////////////////////////////////////////////////////
316// Mods 320// Mods
@@ -336,7 +340,7 @@ static bool mods_handlers_master(matrix_row_t master_matrix[], matrix_row_t slav
336 if (!mods_need_sync && new_mods.oneshot_mods != split_shmem->mods.oneshot_mods) { 340 if (!mods_need_sync && new_mods.oneshot_mods != split_shmem->mods.oneshot_mods) {
337 mods_need_sync = true; 341 mods_need_sync = true;
338 } 342 }
339# endif // NO_ACTION_ONESHOT 343# endif // NO_ACTION_ONESHOT
340 344
341 bool okay = true; 345 bool okay = true;
342 if (mods_need_sync) { 346 if (mods_need_sync) {
@@ -361,13 +365,13 @@ static void mods_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave
361# define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods) 365# define TRANSACTIONS_MODS_SLAVE() TRANSACTION_HANDLER_SLAVE(mods)
362# define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods), 366# define TRANSACTIONS_MODS_REGISTRATIONS [PUT_MODS] = trans_initiator2target_initializer(mods),
363 367
364#else // SPLIT_MODS_ENABLE 368#else // SPLIT_MODS_ENABLE
365 369
366# define TRANSACTIONS_MODS_MASTER() 370# define TRANSACTIONS_MODS_MASTER()
367# define TRANSACTIONS_MODS_SLAVE() 371# define TRANSACTIONS_MODS_SLAVE()
368# define TRANSACTIONS_MODS_REGISTRATIONS 372# define TRANSACTIONS_MODS_REGISTRATIONS
369 373
370#endif // SPLIT_MODS_ENABLE 374#endif // SPLIT_MODS_ENABLE
371 375
372//////////////////////////////////////////////////// 376////////////////////////////////////////////////////
373// Backlight 377// Backlight
@@ -380,19 +384,21 @@ static bool backlight_handlers_master(matrix_row_t master_matrix[], matrix_row_t
380 return send_if_condition(PUT_BACKLIGHT, &last_update, (level != split_shmem->backlight_level), &level, sizeof(level)); 384 return send_if_condition(PUT_BACKLIGHT, &last_update, (level != split_shmem->backlight_level), &level, sizeof(level));
381} 385}
382 386
383static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { backlight_set(split_shmem->backlight_level); } 387static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
388 backlight_set(split_shmem->backlight_level);
389}
384 390
385# define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight) 391# define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight)
386# define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight) 392# define TRANSACTIONS_BACKLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(backlight)
387# define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level), 393# define TRANSACTIONS_BACKLIGHT_REGISTRATIONS [PUT_BACKLIGHT] = trans_initiator2target_initializer(backlight_level),
388 394
389#else // BACKLIGHT_ENABLE 395#else // BACKLIGHT_ENABLE
390 396
391# define TRANSACTIONS_BACKLIGHT_MASTER() 397# define TRANSACTIONS_BACKLIGHT_MASTER()
392# define TRANSACTIONS_BACKLIGHT_SLAVE() 398# define TRANSACTIONS_BACKLIGHT_SLAVE()
393# define TRANSACTIONS_BACKLIGHT_REGISTRATIONS 399# define TRANSACTIONS_BACKLIGHT_REGISTRATIONS
394 400
395#endif // BACKLIGHT_ENABLE 401#endif // BACKLIGHT_ENABLE
396 402
397//////////////////////////////////////////////////// 403////////////////////////////////////////////////////
398// RGBLIGHT 404// RGBLIGHT
@@ -423,13 +429,13 @@ static void rgblight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s
423# define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight) 429# define TRANSACTIONS_RGBLIGHT_SLAVE() TRANSACTION_HANDLER_SLAVE(rgblight)
424# define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync), 430# define TRANSACTIONS_RGBLIGHT_REGISTRATIONS [PUT_RGBLIGHT] = trans_initiator2target_initializer(rgblight_sync),
425 431
426#else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 432#else // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
427 433
428# define TRANSACTIONS_RGBLIGHT_MASTER() 434# define TRANSACTIONS_RGBLIGHT_MASTER()
429# define TRANSACTIONS_RGBLIGHT_SLAVE() 435# define TRANSACTIONS_RGBLIGHT_SLAVE()
430# define TRANSACTIONS_RGBLIGHT_REGISTRATIONS 436# define TRANSACTIONS_RGBLIGHT_REGISTRATIONS
431 437
432#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 438#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
433 439
434//////////////////////////////////////////////////// 440////////////////////////////////////////////////////
435// LED Matrix 441// LED Matrix
@@ -453,13 +459,13 @@ static void led_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
453# define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix) 459# define TRANSACTIONS_LED_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(led_matrix)
454# define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync), 460# define TRANSACTIONS_LED_MATRIX_REGISTRATIONS [PUT_LED_MATRIX] = trans_initiator2target_initializer(led_matrix_sync),
455 461
456#else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 462#else // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
457 463
458# define TRANSACTIONS_LED_MATRIX_MASTER() 464# define TRANSACTIONS_LED_MATRIX_MASTER()
459# define TRANSACTIONS_LED_MATRIX_SLAVE() 465# define TRANSACTIONS_LED_MATRIX_SLAVE()
460# define TRANSACTIONS_LED_MATRIX_REGISTRATIONS 466# define TRANSACTIONS_LED_MATRIX_REGISTRATIONS
461 467
462#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 468#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
463 469
464//////////////////////////////////////////////////// 470////////////////////////////////////////////////////
465// RGB Matrix 471// RGB Matrix
@@ -483,13 +489,13 @@ static void rgb_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
483# define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix) 489# define TRANSACTIONS_RGB_MATRIX_SLAVE() TRANSACTION_HANDLER_SLAVE(rgb_matrix)
484# define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync), 490# define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS [PUT_RGB_MATRIX] = trans_initiator2target_initializer(rgb_matrix_sync),
485 491
486#else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 492#else // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
487 493
488# define TRANSACTIONS_RGB_MATRIX_MASTER() 494# define TRANSACTIONS_RGB_MATRIX_MASTER()
489# define TRANSACTIONS_RGB_MATRIX_SLAVE() 495# define TRANSACTIONS_RGB_MATRIX_SLAVE()
490# define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS 496# define TRANSACTIONS_RGB_MATRIX_REGISTRATIONS
491 497
492#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 498#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
493 499
494//////////////////////////////////////////////////// 500////////////////////////////////////////////////////
495// WPM 501// WPM
@@ -502,19 +508,21 @@ static bool wpm_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave
502 return send_if_condition(PUT_WPM, &last_update, (current_wpm != split_shmem->current_wpm), &current_wpm, sizeof(current_wpm)); 508 return send_if_condition(PUT_WPM, &last_update, (current_wpm != split_shmem->current_wpm), &current_wpm, sizeof(current_wpm));
503} 509}
504 510
505static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { set_current_wpm(split_shmem->current_wpm); } 511static void wpm_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
512 set_current_wpm(split_shmem->current_wpm);
513}
506 514
507# define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm) 515# define TRANSACTIONS_WPM_MASTER() TRANSACTION_HANDLER_MASTER(wpm)
508# define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm) 516# define TRANSACTIONS_WPM_SLAVE() TRANSACTION_HANDLER_SLAVE(wpm)
509# define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm), 517# define TRANSACTIONS_WPM_REGISTRATIONS [PUT_WPM] = trans_initiator2target_initializer(current_wpm),
510 518
511#else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) 519#else // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
512 520
513# define TRANSACTIONS_WPM_MASTER() 521# define TRANSACTIONS_WPM_MASTER()
514# define TRANSACTIONS_WPM_SLAVE() 522# define TRANSACTIONS_WPM_SLAVE()
515# define TRANSACTIONS_WPM_REGISTRATIONS 523# define TRANSACTIONS_WPM_REGISTRATIONS
516 524
517#endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) 525#endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
518 526
519//////////////////////////////////////////////////// 527////////////////////////////////////////////////////
520// OLED 528// OLED
@@ -539,13 +547,13 @@ static void oled_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave
539# define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled) 547# define TRANSACTIONS_OLED_SLAVE() TRANSACTION_HANDLER_SLAVE(oled)
540# define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state), 548# define TRANSACTIONS_OLED_REGISTRATIONS [PUT_OLED] = trans_initiator2target_initializer(current_oled_state),
541 549
542#else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) 550#else // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
543 551
544# define TRANSACTIONS_OLED_MASTER() 552# define TRANSACTIONS_OLED_MASTER()
545# define TRANSACTIONS_OLED_SLAVE() 553# define TRANSACTIONS_OLED_SLAVE()
546# define TRANSACTIONS_OLED_REGISTRATIONS 554# define TRANSACTIONS_OLED_REGISTRATIONS
547 555
548#endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) 556#endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
549 557
550//////////////////////////////////////////////////// 558////////////////////////////////////////////////////
551// ST7565 559// ST7565
@@ -570,13 +578,13 @@ static void st7565_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla
570# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565) 578# define TRANSACTIONS_ST7565_SLAVE() TRANSACTION_HANDLER_SLAVE(st7565)
571# define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state), 579# define TRANSACTIONS_ST7565_REGISTRATIONS [PUT_ST7565] = trans_initiator2target_initializer(current_st7565_state),
572 580
573#else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) 581#else // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
574 582
575# define TRANSACTIONS_ST7565_MASTER() 583# define TRANSACTIONS_ST7565_MASTER()
576# define TRANSACTIONS_ST7565_SLAVE() 584# define TRANSACTIONS_ST7565_SLAVE()
577# define TRANSACTIONS_ST7565_REGISTRATIONS 585# define TRANSACTIONS_ST7565_REGISTRATIONS
578 586
579#endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) 587#endif // defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
580 588
581//////////////////////////////////////////////////// 589////////////////////////////////////////////////////
582// POINTING 590// POINTING
@@ -631,7 +639,7 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s
631 } 639 }
632 last_exec = timer_read32(); 640 last_exec = timer_read32();
633# endif 641# endif
634 temp_cpi = !pointing_device_driver.get_cpi ? 0 : pointing_device_driver.get_cpi(); // check for NULL 642 temp_cpi = !pointing_device_driver.get_cpi ? 0 : pointing_device_driver.get_cpi(); // check for NULL
635 if (split_shmem->pointing.cpi && memcmp(&split_shmem->pointing.cpi, &temp_cpi, sizeof(temp_cpi)) != 0) { 643 if (split_shmem->pointing.cpi && memcmp(&split_shmem->pointing.cpi, &temp_cpi, sizeof(temp_cpi)) != 0) {
636 if (pointing_device_driver.set_cpi) { 644 if (pointing_device_driver.set_cpi) {
637 pointing_device_driver.set_cpi(split_shmem->pointing.cpi); 645 pointing_device_driver.set_cpi(split_shmem->pointing.cpi);
@@ -648,13 +656,13 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s
648# define TRANSACTIONS_POINTING_SLAVE() TRANSACTION_HANDLER_SLAVE(pointing) 656# define TRANSACTIONS_POINTING_SLAVE() TRANSACTION_HANDLER_SLAVE(pointing)
649# define TRANSACTIONS_POINTING_REGISTRATIONS [GET_POINTING_CHECKSUM] = trans_target2initiator_initializer(pointing.checksum), [GET_POINTING_DATA] = trans_target2initiator_initializer(pointing.report), [PUT_POINTING_CPI] = trans_initiator2target_initializer(pointing.cpi), 657# define TRANSACTIONS_POINTING_REGISTRATIONS [GET_POINTING_CHECKSUM] = trans_target2initiator_initializer(pointing.checksum), [GET_POINTING_DATA] = trans_target2initiator_initializer(pointing.report), [PUT_POINTING_CPI] = trans_initiator2target_initializer(pointing.cpi),
650 658
651#else // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 659#else // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
652 660
653# define TRANSACTIONS_POINTING_MASTER() 661# define TRANSACTIONS_POINTING_MASTER()
654# define TRANSACTIONS_POINTING_SLAVE() 662# define TRANSACTIONS_POINTING_SLAVE()
655# define TRANSACTIONS_POINTING_REGISTRATIONS 663# define TRANSACTIONS_POINTING_REGISTRATIONS
656 664
657#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 665#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
658 666
659//////////////////////////////////////////////////// 667////////////////////////////////////////////////////
660 668
@@ -664,7 +672,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
664 672
665#ifdef USE_I2C 673#ifdef USE_I2C
666 [I2C_EXECUTE_CALLBACK] = trans_initiator2target_initializer(transaction_id), 674 [I2C_EXECUTE_CALLBACK] = trans_initiator2target_initializer(transaction_id),
667#endif // USE_I2C 675#endif // USE_I2C
668 676
669 // clang-format off 677 // clang-format off
670 TRANSACTIONS_SLAVE_MATRIX_REGISTRATIONS 678 TRANSACTIONS_SLAVE_MATRIX_REGISTRATIONS
@@ -689,7 +697,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
689 [PUT_RPC_REQ_DATA] = trans_initiator2target_initializer(rpc_m2s_buffer), 697 [PUT_RPC_REQ_DATA] = trans_initiator2target_initializer(rpc_m2s_buffer),
690 [EXECUTE_RPC] = trans_initiator2target_initializer_cb(rpc_info.transaction_id, slave_rpc_exec_callback), 698 [EXECUTE_RPC] = trans_initiator2target_initializer_cb(rpc_info.transaction_id, slave_rpc_exec_callback),
691 [GET_RPC_RESP_DATA] = trans_target2initiator_initializer(rpc_s2m_buffer), 699 [GET_RPC_RESP_DATA] = trans_target2initiator_initializer(rpc_s2m_buffer),
692#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 700#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
693}; 701};
694 702
695bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { 703bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
@@ -800,4 +808,4 @@ void slave_rpc_exec_callback(uint8_t initiator2target_buffer_size, const void *i
800 } 808 }
801} 809}
802 810
803#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 811#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index 060ba8a927..aade3c98d7 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -26,7 +26,7 @@
26 26
27# ifndef SLAVE_I2C_TIMEOUT 27# ifndef SLAVE_I2C_TIMEOUT
28# define SLAVE_I2C_TIMEOUT 100 28# define SLAVE_I2C_TIMEOUT 100
29# endif // SLAVE_I2C_TIMEOUT 29# endif // SLAVE_I2C_TIMEOUT
30 30
31# ifndef SLAVE_I2C_ADDRESS 31# ifndef SLAVE_I2C_ADDRESS
32# define SLAVE_I2C_ADDRESS 0x32 32# define SLAVE_I2C_ADDRESS 0x32
@@ -40,8 +40,12 @@ _Static_assert(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shar
40 40
41split_shared_memory_t *const split_shmem = (split_shared_memory_t *)i2c_slave_reg; 41split_shared_memory_t *const split_shmem = (split_shared_memory_t *)i2c_slave_reg;
42 42
43void transport_master_init(void) { i2c_init(); } 43void transport_master_init(void) {
44void transport_slave_init(void) { i2c_slave_init(SLAVE_I2C_ADDRESS); } 44 i2c_init();
45}
46void transport_slave_init(void) {
47 i2c_slave_init(SLAVE_I2C_ADDRESS);
48}
45 49
46i2c_status_t transport_trigger_callback(int8_t id) { 50i2c_status_t transport_trigger_callback(int8_t id) {
47 // If there's no callback, indicate that we were successful 51 // If there's no callback, indicate that we were successful
@@ -82,15 +86,19 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf,
82 return true; 86 return true;
83} 87}
84 88
85#else // USE_I2C 89#else // USE_I2C
86 90
87# include "serial.h" 91# include "serial.h"
88 92
89static split_shared_memory_t shared_memory; 93static split_shared_memory_t shared_memory;
90split_shared_memory_t *const split_shmem = &shared_memory; 94split_shared_memory_t *const split_shmem = &shared_memory;
91 95
92void transport_master_init(void) { soft_serial_initiator_init(); } 96void transport_master_init(void) {
93void transport_slave_init(void) { soft_serial_target_init(); } 97 soft_serial_initiator_init();
98}
99void transport_slave_init(void) {
100 soft_serial_target_init();
101}
94 102
95bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length) { 103bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length) {
96 split_transaction_desc_t *trans = &split_transaction_table[id]; 104 split_transaction_desc_t *trans = &split_transaction_table[id];
@@ -111,8 +119,12 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf,
111 return true; 119 return true;
112} 120}
113 121
114#endif // USE_I2C 122#endif // USE_I2C
115 123
116bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { return transactions_master(master_matrix, slave_matrix); } 124bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
125 return transactions_master(master_matrix, slave_matrix);
126}
117 127
118void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { transactions_slave(master_matrix, slave_matrix); } 128void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
129 transactions_slave(master_matrix, slave_matrix);
130}
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h
index 31b804908b..26bd136728 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -25,11 +25,11 @@
25 25
26#ifndef RPC_M2S_BUFFER_SIZE 26#ifndef RPC_M2S_BUFFER_SIZE
27# define RPC_M2S_BUFFER_SIZE 32 27# define RPC_M2S_BUFFER_SIZE 32
28#endif // RPC_M2S_BUFFER_SIZE 28#endif // RPC_M2S_BUFFER_SIZE
29 29
30#ifndef RPC_S2M_BUFFER_SIZE 30#ifndef RPC_S2M_BUFFER_SIZE
31# define RPC_S2M_BUFFER_SIZE 32 31# define RPC_S2M_BUFFER_SIZE 32
32#endif // RPC_S2M_BUFFER_SIZE 32#endif // RPC_S2M_BUFFER_SIZE
33 33
34void transport_master_init(void); 34void transport_master_init(void);
35void transport_slave_init(void); 35void transport_slave_init(void);
@@ -43,15 +43,15 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf,
43#ifdef ENCODER_ENABLE 43#ifdef ENCODER_ENABLE
44# include "encoder.h" 44# include "encoder.h"
45# define NUMBER_OF_ENCODERS (sizeof((pin_t[])ENCODERS_PAD_A) / sizeof(pin_t)) 45# define NUMBER_OF_ENCODERS (sizeof((pin_t[])ENCODERS_PAD_A) / sizeof(pin_t))
46#endif // ENCODER_ENABLE 46#endif // ENCODER_ENABLE
47 47
48#ifdef BACKLIGHT_ENABLE 48#ifdef BACKLIGHT_ENABLE
49# include "backlight.h" 49# include "backlight.h"
50#endif // BACKLIGHT_ENABLE 50#endif // BACKLIGHT_ENABLE
51 51
52#ifdef RGBLIGHT_ENABLE 52#ifdef RGBLIGHT_ENABLE
53# include "rgblight.h" 53# include "rgblight.h"
54#endif // RGBLIGHT_ENABLE 54#endif // RGBLIGHT_ENABLE
55 55
56typedef struct _split_slave_matrix_sync_t { 56typedef struct _split_slave_matrix_sync_t {
57 uint8_t checksum; 57 uint8_t checksum;
@@ -62,21 +62,21 @@ typedef struct _split_slave_matrix_sync_t {
62typedef struct _split_master_matrix_sync_t { 62typedef struct _split_master_matrix_sync_t {
63 matrix_row_t matrix[(MATRIX_ROWS) / 2]; 63 matrix_row_t matrix[(MATRIX_ROWS) / 2];
64} split_master_matrix_sync_t; 64} split_master_matrix_sync_t;
65#endif // SPLIT_TRANSPORT_MIRROR 65#endif // SPLIT_TRANSPORT_MIRROR
66 66
67#ifdef ENCODER_ENABLE 67#ifdef ENCODER_ENABLE
68typedef struct _split_slave_encoder_sync_t { 68typedef struct _split_slave_encoder_sync_t {
69 uint8_t checksum; 69 uint8_t checksum;
70 uint8_t state[NUMBER_OF_ENCODERS]; 70 uint8_t state[NUMBER_OF_ENCODERS];
71} split_slave_encoder_sync_t; 71} split_slave_encoder_sync_t;
72#endif // ENCODER_ENABLE 72#endif // ENCODER_ENABLE
73 73
74#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 74#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
75typedef struct _split_layers_sync_t { 75typedef struct _split_layers_sync_t {
76 layer_state_t layer_state; 76 layer_state_t layer_state;
77 layer_state_t default_layer_state; 77 layer_state_t default_layer_state;
78} split_layers_sync_t; 78} split_layers_sync_t;
79#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 79#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
80 80
81#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 81#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
82# include "led_matrix.h" 82# include "led_matrix.h"
@@ -85,7 +85,7 @@ typedef struct _led_matrix_sync_t {
85 led_eeconfig_t led_matrix; 85 led_eeconfig_t led_matrix;
86 bool led_suspend_state; 86 bool led_suspend_state;
87} led_matrix_sync_t; 87} led_matrix_sync_t;
88#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 88#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
89 89
90#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 90#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
91# include "rgb_matrix.h" 91# include "rgb_matrix.h"
@@ -94,7 +94,7 @@ typedef struct _rgb_matrix_sync_t {
94 rgb_config_t rgb_matrix; 94 rgb_config_t rgb_matrix;
95 bool rgb_suspend_state; 95 bool rgb_suspend_state;
96} rgb_matrix_sync_t; 96} rgb_matrix_sync_t;
97#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 97#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
98 98
99#ifdef SPLIT_MODS_ENABLE 99#ifdef SPLIT_MODS_ENABLE
100typedef struct _split_mods_sync_t { 100typedef struct _split_mods_sync_t {
@@ -102,9 +102,9 @@ typedef struct _split_mods_sync_t {
102 uint8_t weak_mods; 102 uint8_t weak_mods;
103# ifndef NO_ACTION_ONESHOT 103# ifndef NO_ACTION_ONESHOT
104 uint8_t oneshot_mods; 104 uint8_t oneshot_mods;
105# endif // NO_ACTION_ONESHOT 105# endif // NO_ACTION_ONESHOT
106} split_mods_sync_t; 106} split_mods_sync_t;
107#endif // SPLIT_MODS_ENABLE 107#endif // SPLIT_MODS_ENABLE
108 108
109#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 109#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
110# include "pointing_device.h" 110# include "pointing_device.h"
@@ -113,7 +113,7 @@ typedef struct _split_slave_pointing_sync_t {
113 report_mouse_t report; 113 report_mouse_t report;
114 uint16_t cpi; 114 uint16_t cpi;
115} split_slave_pointing_sync_t; 115} split_slave_pointing_sync_t;
116#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 116#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
117 117
118#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 118#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
119typedef struct _rpc_sync_info_t { 119typedef struct _rpc_sync_info_t {
@@ -121,76 +121,76 @@ typedef struct _rpc_sync_info_t {
121 uint8_t m2s_length; 121 uint8_t m2s_length;
122 uint8_t s2m_length; 122 uint8_t s2m_length;
123} rpc_sync_info_t; 123} rpc_sync_info_t;
124#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 124#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
125 125
126typedef struct _split_shared_memory_t { 126typedef struct _split_shared_memory_t {
127#ifdef USE_I2C 127#ifdef USE_I2C
128 int8_t transaction_id; 128 int8_t transaction_id;
129#endif // USE_I2C 129#endif // USE_I2C
130 130
131 split_slave_matrix_sync_t smatrix; 131 split_slave_matrix_sync_t smatrix;
132 132
133#ifdef SPLIT_TRANSPORT_MIRROR 133#ifdef SPLIT_TRANSPORT_MIRROR
134 split_master_matrix_sync_t mmatrix; 134 split_master_matrix_sync_t mmatrix;
135#endif // SPLIT_TRANSPORT_MIRROR 135#endif // SPLIT_TRANSPORT_MIRROR
136 136
137#ifdef ENCODER_ENABLE 137#ifdef ENCODER_ENABLE
138 split_slave_encoder_sync_t encoders; 138 split_slave_encoder_sync_t encoders;
139#endif // ENCODER_ENABLE 139#endif // ENCODER_ENABLE
140 140
141#ifndef DISABLE_SYNC_TIMER 141#ifndef DISABLE_SYNC_TIMER
142 uint32_t sync_timer; 142 uint32_t sync_timer;
143#endif // DISABLE_SYNC_TIMER 143#endif // DISABLE_SYNC_TIMER
144 144
145#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 145#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
146 split_layers_sync_t layers; 146 split_layers_sync_t layers;
147#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE) 147#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
148 148
149#ifdef SPLIT_LED_STATE_ENABLE 149#ifdef SPLIT_LED_STATE_ENABLE
150 uint8_t led_state; 150 uint8_t led_state;
151#endif // SPLIT_LED_STATE_ENABLE 151#endif // SPLIT_LED_STATE_ENABLE
152 152
153#ifdef SPLIT_MODS_ENABLE 153#ifdef SPLIT_MODS_ENABLE
154 split_mods_sync_t mods; 154 split_mods_sync_t mods;
155#endif // SPLIT_MODS_ENABLE 155#endif // SPLIT_MODS_ENABLE
156 156
157#ifdef BACKLIGHT_ENABLE 157#ifdef BACKLIGHT_ENABLE
158 uint8_t backlight_level; 158 uint8_t backlight_level;
159#endif // BACKLIGHT_ENABLE 159#endif // BACKLIGHT_ENABLE
160 160
161#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 161#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
162 rgblight_syncinfo_t rgblight_sync; 162 rgblight_syncinfo_t rgblight_sync;
163#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 163#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
164 164
165#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 165#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
166 led_matrix_sync_t led_matrix_sync; 166 led_matrix_sync_t led_matrix_sync;
167#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) 167#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
168 168
169#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 169#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
170 rgb_matrix_sync_t rgb_matrix_sync; 170 rgb_matrix_sync_t rgb_matrix_sync;
171#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 171#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
172 172
173#if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) 173#if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
174 uint8_t current_wpm; 174 uint8_t current_wpm;
175#endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE) 175#endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
176 176
177#if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) 177#if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
178 uint8_t current_oled_state; 178 uint8_t current_oled_state;
179#endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE) 179#endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
180 180
181#if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE) 181#if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
182 uint8_t current_st7565_state; 182 uint8_t current_st7565_state;
183#endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE) 183#endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE)
184 184
185#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 185#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
186 split_slave_pointing_sync_t pointing; 186 split_slave_pointing_sync_t pointing;
187#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE) 187#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
188 188
189#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 189#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
190 rpc_sync_info_t rpc_info; 190 rpc_sync_info_t rpc_info;
191 uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE]; 191 uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE];
192 uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE]; 192 uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE];
193#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 193#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
194} split_shared_memory_t; 194} split_shared_memory_t;
195 195
196extern split_shared_memory_t *const split_shmem; 196extern split_shared_memory_t *const split_shmem;
diff --git a/quantum/sync_timer.c b/quantum/sync_timer.c
index de24b463b6..217891233f 100644
--- a/quantum/sync_timer.c
+++ b/quantum/sync_timer.c
@@ -29,7 +29,9 @@ SOFTWARE.
29#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) 29#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER)
30volatile int32_t sync_timer_ms; 30volatile int32_t sync_timer_ms;
31 31
32void sync_timer_init(void) { sync_timer_ms = 0; } 32void sync_timer_init(void) {
33 sync_timer_ms = 0;
34}
33 35
34void sync_timer_update(uint32_t time) { 36void sync_timer_update(uint32_t time) {
35 if (is_keyboard_master()) return; 37 if (is_keyboard_master()) return;
diff --git a/quantum/velocikey.c b/quantum/velocikey.c
index 6b7f82d950..58e14215bb 100644
--- a/quantum/velocikey.c
+++ b/quantum/velocikey.c
@@ -13,7 +13,9 @@
13#define TYPING_SPEED_MAX_VALUE 200 13#define TYPING_SPEED_MAX_VALUE 200
14uint8_t typing_speed = 0; 14uint8_t typing_speed = 0;
15 15
16bool velocikey_enabled(void) { return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1; } 16bool velocikey_enabled(void) {
17 return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1;
18}
17 19
18void velocikey_toggle(void) { 20void velocikey_toggle(void) {
19 if (velocikey_enabled()) 21 if (velocikey_enabled())
@@ -39,4 +41,6 @@ void velocikey_decelerate(void) {
39 } 41 }
40} 42}
41 43
42uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); } 44uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) {
45 return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE));
46}
diff --git a/quantum/via.c b/quantum/via.c
index a3bd82d9b3..05ab799cbb 100644
--- a/quantum/via.c
+++ b/quantum/via.c
@@ -45,7 +45,7 @@
45#include "raw_hid.h" 45#include "raw_hid.h"
46#include "dynamic_keymap.h" 46#include "dynamic_keymap.h"
47#include "eeprom.h" 47#include "eeprom.h"
48#include "version.h" // for QMK_BUILDDATE used in EEPROM magic 48#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
49#include "via_ensure_keycode.h" 49#include "via_ensure_keycode.h"
50 50
51// Forward declare some helpers. 51// Forward declare some helpers.
@@ -62,7 +62,7 @@ void via_qmk_rgblight_get_value(uint8_t *data);
62// Can be called in an overriding via_init_kb() to test if keyboard level code usage of 62// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
63// EEPROM is invalid and use/save defaults. 63// EEPROM is invalid and use/save defaults.
64bool via_eeprom_is_valid(void) { 64bool via_eeprom_is_valid(void) {
65 char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" 65 char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
66 uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); 66 uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F);
67 uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); 67 uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F);
68 uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); 68 uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F);
@@ -73,7 +73,7 @@ bool via_eeprom_is_valid(void) {
73// Sets VIA/keyboard level usage of EEPROM to valid/invalid 73// Sets VIA/keyboard level usage of EEPROM to valid/invalid
74// Keyboard level code (eg. via_init_kb()) should not call this 74// Keyboard level code (eg. via_init_kb()) should not call this
75void via_eeprom_set_valid(bool valid) { 75void via_eeprom_set_valid(bool valid) {
76 char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" 76 char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
77 uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); 77 uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F);
78 uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); 78 uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F);
79 uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); 79 uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F);
@@ -347,13 +347,13 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
347 } 347 }
348 case id_dynamic_keymap_macro_get_buffer: { 348 case id_dynamic_keymap_macro_get_buffer: {
349 uint16_t offset = (command_data[0] << 8) | command_data[1]; 349 uint16_t offset = (command_data[0] << 8) | command_data[1];
350 uint16_t size = command_data[2]; // size <= 28 350 uint16_t size = command_data[2]; // size <= 28
351 dynamic_keymap_macro_get_buffer(offset, size, &command_data[3]); 351 dynamic_keymap_macro_get_buffer(offset, size, &command_data[3]);
352 break; 352 break;
353 } 353 }
354 case id_dynamic_keymap_macro_set_buffer: { 354 case id_dynamic_keymap_macro_set_buffer: {
355 uint16_t offset = (command_data[0] << 8) | command_data[1]; 355 uint16_t offset = (command_data[0] << 8) | command_data[1];
356 uint16_t size = command_data[2]; // size <= 28 356 uint16_t size = command_data[2]; // size <= 28
357 dynamic_keymap_macro_set_buffer(offset, size, &command_data[3]); 357 dynamic_keymap_macro_set_buffer(offset, size, &command_data[3]);
358 break; 358 break;
359 } 359 }
@@ -367,13 +367,13 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
367 } 367 }
368 case id_dynamic_keymap_get_buffer: { 368 case id_dynamic_keymap_get_buffer: {
369 uint16_t offset = (command_data[0] << 8) | command_data[1]; 369 uint16_t offset = (command_data[0] << 8) | command_data[1];
370 uint16_t size = command_data[2]; // size <= 28 370 uint16_t size = command_data[2]; // size <= 28
371 dynamic_keymap_get_buffer(offset, size, &command_data[3]); 371 dynamic_keymap_get_buffer(offset, size, &command_data[3]);
372 break; 372 break;
373 } 373 }
374 case id_dynamic_keymap_set_buffer: { 374 case id_dynamic_keymap_set_buffer: {
375 uint16_t offset = (command_data[0] << 8) | command_data[1]; 375 uint16_t offset = (command_data[0] << 8) | command_data[1];
376 uint16_t size = command_data[2]; // size <= 28 376 uint16_t size = command_data[2]; // size <= 28
377 dynamic_keymap_set_buffer(offset, size, &command_data[3]); 377 dynamic_keymap_set_buffer(offset, size, &command_data[3]);
378 break; 378 break;
379 } 379 }
@@ -438,7 +438,7 @@ void via_qmk_backlight_set_value(uint8_t *data) {
438 } 438 }
439} 439}
440 440
441#endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE) 441#endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE)
442 442
443#if defined(VIA_QMK_RGBLIGHT_ENABLE) 443#if defined(VIA_QMK_RGBLIGHT_ENABLE)
444 444
@@ -494,4 +494,4 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
494 } 494 }
495} 495}
496 496
497#endif // #if defined(VIA_QMK_RGBLIGHT_ENABLE) 497#endif // #if defined(VIA_QMK_RGBLIGHT_ENABLE)
diff --git a/quantum/via.h b/quantum/via.h
index 5d16917dfa..ac29a58902 100644
--- a/quantum/via.h
+++ b/quantum/via.h
@@ -16,7 +16,7 @@
16 16
17#pragma once 17#pragma once
18 18
19#include "eeconfig.h" // for EECONFIG_SIZE 19#include "eeconfig.h" // for EECONFIG_SIZE
20 20
21// Keyboard level code can change where VIA stores the magic. 21// Keyboard level code can change where VIA stores the magic.
22// The magic is the build date YYMMDD encoded as BCD in 3 bytes, 22// The magic is the build date YYMMDD encoded as BCD in 3 bytes,
@@ -59,7 +59,7 @@
59#define VIA_PROTOCOL_VERSION 0x0009 59#define VIA_PROTOCOL_VERSION 0x0009
60 60
61enum via_command_id { 61enum via_command_id {
62 id_get_protocol_version = 0x01, // always 0x01 62 id_get_protocol_version = 0x01, // always 0x01
63 id_get_keyboard_value = 0x02, 63 id_get_keyboard_value = 0x02,
64 id_set_keyboard_value = 0x03, 64 id_set_keyboard_value = 0x03,
65 id_dynamic_keymap_get_keycode = 0x04, 65 id_dynamic_keymap_get_keycode = 0x04,
@@ -82,7 +82,7 @@ enum via_command_id {
82}; 82};
83 83
84enum via_keyboard_value_id { 84enum via_keyboard_value_id {
85 id_uptime = 0x01, // 85 id_uptime = 0x01, //
86 id_layout_options = 0x02, 86 id_layout_options = 0x02,
87 id_switch_matrix_state = 0x03 87 id_switch_matrix_state = 0x03
88}; 88};
diff --git a/quantum/wpm.c b/quantum/wpm.c
index 62d4128b8e..b2e6fe0430 100644
--- a/quantum/wpm.c
+++ b/quantum/wpm.c
@@ -55,12 +55,20 @@ static uint8_t prev_wpm = 0;
55static uint8_t next_wpm = 0; 55static uint8_t next_wpm = 0;
56#endif 56#endif
57 57
58void set_current_wpm(uint8_t new_wpm) { current_wpm = new_wpm; } 58void set_current_wpm(uint8_t new_wpm) {
59uint8_t get_current_wpm(void) { return current_wpm; } 59 current_wpm = new_wpm;
60}
61uint8_t get_current_wpm(void) {
62 return current_wpm;
63}
60 64
61bool wpm_keycode(uint16_t keycode) { return wpm_keycode_kb(keycode); } 65bool wpm_keycode(uint16_t keycode) {
66 return wpm_keycode_kb(keycode);
67}
62 68
63__attribute__((weak)) bool wpm_keycode_kb(uint16_t keycode) { return wpm_keycode_user(keycode); } 69__attribute__((weak)) bool wpm_keycode_kb(uint16_t keycode) {
70 return wpm_keycode_user(keycode);
71}
64 72
65__attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) { 73__attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) {
66 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { 74 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
@@ -122,7 +130,7 @@ void decay_wpm(void) {
122 uint32_t duration = (((periods)*PERIOD_DURATION) + elapsed); 130 uint32_t duration = (((periods)*PERIOD_DURATION) + elapsed);
123 int32_t wpm_now = (60000 * presses) / (duration * WPM_ESTIMATED_WORD_SIZE); 131 int32_t wpm_now = (60000 * presses) / (duration * WPM_ESTIMATED_WORD_SIZE);
124 132
125 if (wpm_now < 0) // set some reasonable WPM measurement limits 133 if (wpm_now < 0) // set some reasonable WPM measurement limits
126 wpm_now = 0; 134 wpm_now = 0;
127 if (wpm_now > 240) wpm_now = 240; 135 if (wpm_now > 240) wpm_now = 240;
128 136
@@ -133,7 +141,7 @@ void decay_wpm(void) {
133 elapsed = 0; 141 elapsed = 0;
134 wpm_timer = timer_read32(); 142 wpm_timer = timer_read32();
135 } 143 }
136 if (presses < 2) // don't guess high WPM based on a single keypress. 144 if (presses < 2) // don't guess high WPM based on a single keypress.
137 wpm_now = 0; 145 wpm_now = 0;
138 146
139#if defined(WPM_LAUNCH_CONTROL) 147#if defined(WPM_LAUNCH_CONTROL)
@@ -150,7 +158,7 @@ void decay_wpm(void) {
150 wpm_now = 0; 158 wpm_now = 0;
151 period_presses[0] = 0; 159 period_presses[0] = 0;
152 } 160 }
153#endif // WPM_LAUNCH_CONTROL 161#endif // WPM_LAUNCH_CONTROL
154 162
155#if defined(WPM_UNFILTERED) 163#if defined(WPM_UNFILTERED)
156 current_wpm = wpm_now; 164 current_wpm = wpm_now;