summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/api.c115
-rw-r--r--quantum/api.h53
-rw-r--r--quantum/api/api_sysex.c29
-rw-r--r--quantum/api/api_sysex.h2
-rw-r--r--quantum/audio/audio.c740
-rw-r--r--quantum/audio/audio.h26
-rw-r--r--quantum/audio/audio_arm.c846
-rw-r--r--quantum/audio/audio_pwm.c637
-rw-r--r--quantum/audio/luts.c380
-rw-r--r--quantum/audio/luts.h18
-rw-r--r--quantum/audio/muse.c137
-rw-r--r--quantum/audio/musical_notes.h245
-rw-r--r--quantum/audio/song_list.h319
-rw-r--r--quantum/audio/voices.c250
-rw-r--r--quantum/audio/voices.h20
-rw-r--r--quantum/audio/wave.h273
-rw-r--r--quantum/backlight/backlight.c193
-rw-r--r--quantum/backlight/backlight.h62
-rw-r--r--quantum/backlight/backlight_arm.c218
-rw-r--r--quantum/backlight/backlight_avr.c509
-rw-r--r--quantum/backlight/backlight_soft.c66
-rw-r--r--quantum/color.c121
-rw-r--r--quantum/color.h45
-rw-r--r--quantum/config_common.h551
-rw-r--r--quantum/debounce/eager_pk.c94
-rw-r--r--quantum/debounce/eager_pr.c82
-rw-r--r--quantum/debounce/sym_g.c41
-rw-r--r--quantum/dip_switch.c64
-rw-r--r--quantum/dip_switch.h29
-rw-r--r--quantum/dynamic_keymap.c348
-rw-r--r--quantum/dynamic_keymap.h25
-rw-r--r--quantum/dynamic_macro.h157
-rw-r--r--quantum/encoder.c122
-rw-r--r--quantum/fauxclicky.c24
-rw-r--r--quantum/fauxclicky.h48
-rw-r--r--quantum/keycode_config.c50
-rw-r--r--quantum/keycode_config.h22
-rw-r--r--quantum/keymap.h11
-rw-r--r--quantum/keymap_common.c104
-rw-r--r--quantum/keymap_extras/keymap_belgian.h102
-rw-r--r--quantum/keymap_extras/keymap_bepo.h498
-rw-r--r--quantum/keymap_extras/keymap_br_abnt2.h74
-rw-r--r--quantum/keymap_extras/keymap_canadian_multilingual.h354
-rw-r--r--quantum/keymap_extras/keymap_colemak.h108
-rw-r--r--quantum/keymap_extras/keymap_dvorak.h136
-rw-r--r--quantum/keymap_extras/keymap_dvp.h136
-rw-r--r--quantum/keymap_extras/keymap_fr_ch.h70
-rw-r--r--quantum/keymap_extras/keymap_french.h114
-rw-r--r--quantum/keymap_extras/keymap_french_osx.h114
-rw-r--r--quantum/keymap_extras/keymap_german.h72
-rw-r--r--quantum/keymap_extras/keymap_german_ch.h82
-rw-r--r--quantum/keymap_extras/keymap_german_osx.h68
-rw-r--r--quantum/keymap_extras/keymap_hungarian.h78
-rw-r--r--quantum/keymap_extras/keymap_italian.h66
-rw-r--r--quantum/keymap_extras/keymap_italian_osx_ansi.h113
-rw-r--r--quantum/keymap_extras/keymap_italian_osx_iso.h113
-rw-r--r--quantum/keymap_extras/keymap_jp.h86
-rw-r--r--quantum/keymap_extras/keymap_nordic.h44
-rw-r--r--quantum/keymap_extras/keymap_norman.h55
-rw-r--r--quantum/keymap_extras/keymap_norwegian.h28
-rw-r--r--quantum/keymap_extras/keymap_plover.h44
-rw-r--r--quantum/keymap_extras/keymap_plover_dvorak.h44
-rw-r--r--quantum/keymap_extras/keymap_slovenian.h66
-rw-r--r--quantum/keymap_extras/keymap_spanish.h66
-rw-r--r--quantum/keymap_extras/keymap_steno.h98
-rw-r--r--quantum/keymap_extras/keymap_swedish.h85
-rw-r--r--quantum/keymap_extras/keymap_uk.h22
-rw-r--r--quantum/keymap_extras/keymap_workman.h104
-rw-r--r--quantum/keymap_extras/sendstring_belgian.h81
-rw-r--r--quantum/keymap_extras/sendstring_bepo.h100
-rw-r--r--quantum/keymap_extras/sendstring_colemak.h62
-rw-r--r--quantum/keymap_extras/sendstring_dvorak.h62
-rw-r--r--quantum/keymap_extras/sendstring_french.h99
-rw-r--r--quantum/keymap_extras/sendstring_german.h106
-rw-r--r--quantum/keymap_extras/sendstring_jis.h67
-rw-r--r--quantum/keymap_extras/sendstring_norman.h58
-rw-r--r--quantum/keymap_extras/sendstring_spanish.h98
-rw-r--r--quantum/keymap_extras/sendstring_uk.h63
-rw-r--r--quantum/keymap_extras/sendstring_workman.h62
-rw-r--r--quantum/led_matrix.c135
-rw-r--r--quantum/led_matrix_drivers.c193
-rw-r--r--quantum/led_tables.c53
-rw-r--r--quantum/ledmatrix.h78
-rw-r--r--quantum/matrix.c218
-rw-r--r--quantum/mcu_selection.mk51
-rw-r--r--quantum/pincontrol.h38
-rw-r--r--quantum/pointing_device.c45
-rw-r--r--quantum/pointing_device.h8
-rw-r--r--quantum/process_keycode/process_audio.c31
-rw-r--r--quantum/process_keycode/process_auto_shift.c248
-rw-r--r--quantum/process_keycode/process_auto_shift.h17
-rw-r--r--quantum/process_keycode/process_clicky.c131
-rw-r--r--quantum/process_keycode/process_combo.c244
-rw-r--r--quantum/process_keycode/process_combo.h33
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c257
-rw-r--r--quantum/process_keycode/process_dynamic_macro.h41
-rw-r--r--quantum/process_keycode/process_key_lock.c48
-rw-r--r--quantum/process_keycode/process_key_lock.h2
-rw-r--r--quantum/process_keycode/process_leader.c86
-rw-r--r--quantum/process_keycode/process_leader.h7
-rw-r--r--quantum/process_keycode/process_midi.c115
-rw-r--r--quantum/process_keycode/process_midi.h30
-rw-r--r--quantum/process_keycode/process_music.c354
-rw-r--r--quantum/process_keycode/process_music.h28
-rw-r--r--quantum/process_keycode/process_printer.c443
-rw-r--r--quantum/process_keycode/process_printer_bb.c435
-rw-r--r--quantum/process_keycode/process_space_cadet.c175
-rw-r--r--quantum/process_keycode/process_steno.c208
-rw-r--r--quantum/process_keycode/process_steno.h8
-rw-r--r--quantum/process_keycode/process_tap_dance.c268
-rw-r--r--quantum/process_keycode/process_tap_dance.h119
-rw-r--r--quantum/process_keycode/process_terminal.c271
-rw-r--r--quantum/process_keycode/process_terminal.h2
-rw-r--r--quantum/process_keycode/process_ucis.c210
-rw-r--r--quantum/process_keycode/process_ucis.h24
-rw-r--r--quantum/process_keycode/process_unicode.c12
-rw-r--r--quantum/process_keycode/process_unicode_common.c321
-rw-r--r--quantum/process_keycode/process_unicode_common.h246
-rw-r--r--quantum/process_keycode/process_unicodemap.c95
-rw-r--r--quantum/process_keycode/process_unicodemap.h4
-rw-r--r--quantum/quantum.c2211
-rw-r--r--quantum/quantum.h172
-rw-r--r--quantum/quantum_keycodes.h388
-rw-r--r--quantum/rgb.h33
-rw-r--r--quantum/rgb_matrix.c630
-rw-r--r--quantum/rgb_matrix.h187
-rw-r--r--quantum/rgb_matrix_animations/alpha_mods_anim.h32
-rw-r--r--quantum/rgb_matrix_animations/breathing_anim.h26
-rw-r--r--quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/colorband_sat_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/colorband_spiral_val_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/colorband_val_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/cycle_all_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/cycle_left_right_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/cycle_out_in_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/cycle_pinwheel_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/cycle_spiral_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/cycle_up_down_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/digital_rain_anim.h120
-rw-r--r--quantum/rgb_matrix_animations/dual_beacon_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/gradient_up_down_anim.h30
-rw-r--r--quantum/rgb_matrix_animations/jellybean_raindrops_anim.h36
-rw-r--r--quantum/rgb_matrix_animations/rainbow_beacon_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h12
-rw-r--r--quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h14
-rw-r--r--quantum/rgb_matrix_animations/raindrops_anim.h52
-rw-r--r--quantum/rgb_matrix_animations/solid_color_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_cross.h47
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_nexus.h45
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_simple_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_wide.h39
-rw-r--r--quantum/rgb_matrix_animations/solid_splash_anim.h39
-rw-r--r--quantum/rgb_matrix_animations/splash_anim.h39
-rw-r--r--quantum/rgb_matrix_animations/typing_heatmap_anim.h87
-rw-r--r--quantum/rgb_matrix_drivers.c125
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_dx_dy.h20
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h22
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_i.h16
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_reactive.h34
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_reactive_splash.h36
-rw-r--r--quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h20
-rw-r--r--quantum/rgb_matrix_types.h71
-rw-r--r--quantum/rgblight.c1473
-rw-r--r--quantum/rgblight.h212
-rw-r--r--quantum/rgblight_breathe_table.h562
-rw-r--r--quantum/rgblight_list.h253
-rw-r--r--quantum/rgblight_modes.h116
-rw-r--r--quantum/rgblight_post_config.h6
-rw-r--r--quantum/rgblight_reconfig.h41
-rw-r--r--quantum/send_string_keycodes.h392
-rw-r--r--quantum/serial_link/protocol/byte_stuffer.c55
-rw-r--r--quantum/serial_link/protocol/frame_router.c23
-rw-r--r--quantum/serial_link/protocol/frame_validator.c80
-rw-r--r--quantum/serial_link/protocol/transport.c61
-rw-r--r--quantum/serial_link/protocol/transport.h168
-rw-r--r--quantum/serial_link/protocol/triple_buffered_object.c7
-rw-r--r--quantum/serial_link/protocol/triple_buffered_object.h14
-rw-r--r--quantum/serial_link/system/serial_link.c113
-rw-r--r--quantum/serial_link/system/serial_link.h26
-rw-r--r--quantum/serial_link/tests/byte_stuffer_tests.cpp211
-rw-r--r--quantum/serial_link/tests/frame_router_tests.cpp81
-rw-r--r--quantum/serial_link/tests/frame_validator_tests.cpp45
-rw-r--r--quantum/serial_link/tests/transport_tests.cpp28
-rw-r--r--quantum/serial_link/tests/triple_buffered_object_tests.cpp18
-rw-r--r--quantum/split_common/matrix.c328
-rw-r--r--quantum/split_common/post_config.h28
-rw-r--r--quantum/split_common/serial.c748
-rw-r--r--quantum/split_common/serial.h18
-rw-r--r--quantum/split_common/split_util.c119
-rw-r--r--quantum/split_common/split_util.h3
-rw-r--r--quantum/split_common/transport.c272
-rw-r--r--quantum/stm32/chconf.h143
-rw-r--r--quantum/stm32/halconf.h244
-rw-r--r--quantum/stm32/mcuconf.h312
-rw-r--r--quantum/stm32/proton_c.mk8
-rw-r--r--quantum/template/avr/config.h27
-rw-r--r--quantum/template/avr/readme.md6
-rw-r--r--quantum/template/avr/rules.mk59
-rw-r--r--quantum/template/base/info.json18
-rw-r--r--quantum/template/base/keyboard.c (renamed from quantum/template/avr/template.c)27
-rw-r--r--quantum/template/base/keyboard.h (renamed from quantum/template/base/template.h)7
-rw-r--r--quantum/template/base/keymaps/default/keymap.c67
-rw-r--r--quantum/template/base/keymaps/default/readme.md2
-rw-r--r--quantum/template/ps2avrgb/config.h23
-rw-r--r--quantum/template/ps2avrgb/readme.md41
-rw-r--r--quantum/template/ps2avrgb/rules.mk45
-rw-r--r--quantum/template/ps2avrgb/template.c90
-rw-r--r--quantum/template/ps2avrgb/usbconfig.h102
-rw-r--r--quantum/variable_trace.c77
-rw-r--r--quantum/variable_trace.h13
-rw-r--r--quantum/velocikey.c36
-rw-r--r--quantum/velocikey.h8
-rw-r--r--quantum/visualizer/common_gfxconf.h103
-rw-r--r--quantum/visualizer/default_animations.c203
-rw-r--r--quantum/visualizer/lcd_backlight.c50
-rw-r--r--quantum/visualizer/lcd_backlight.h10
-rw-r--r--quantum/visualizer/lcd_backlight_keyframes.c42
-rw-r--r--quantum/visualizer/lcd_keyframes.c42
-rw-r--r--quantum/visualizer/lcd_keyframes.h1
-rw-r--r--quantum/visualizer/led_backlight_keyframes.c40
-rw-r--r--quantum/visualizer/led_backlight_keyframes.h1
-rw-r--r--quantum/visualizer/resources/lcd_logo.c41
-rw-r--r--quantum/visualizer/resources/resources.h1
-rw-r--r--quantum/visualizer/visualizer.c260
-rw-r--r--quantum/visualizer/visualizer.h29
229 files changed, 14350 insertions, 14442 deletions
diff --git a/quantum/api.c b/quantum/api.c
index 233f99636d..1685744589 100644
--- a/quantum/api.c
+++ b/quantum/api.c
@@ -17,40 +17,28 @@
#include "api.h"
#include "quantum.h"
-void dword_to_bytes(uint32_t dword, uint8_t * bytes) {
+void dword_to_bytes(uint32_t dword, uint8_t* bytes) {
bytes[0] = (dword >> 24) & 0xFF;
- bytes[1] = (dword >> 16) & 0xFF;
- bytes[2] = (dword >> 8) & 0xFF;
- bytes[3] = (dword >> 0) & 0xFF;
+ bytes[1] = (dword >> 16) & 0xFF;
+ bytes[2] = (dword >> 8) & 0xFF;
+ bytes[3] = (dword >> 0) & 0xFF;
}
-uint32_t bytes_to_dword(uint8_t * bytes, uint8_t index) {
- return ((uint32_t)bytes[index + 0] << 24) | ((uint32_t)bytes[index + 1] << 16) | ((uint32_t)bytes[index + 2] << 8) | (uint32_t)bytes[index + 3];
-}
+uint32_t bytes_to_dword(uint8_t* bytes, uint8_t index) { return ((uint32_t)bytes[index + 0] << 24) | ((uint32_t)bytes[index + 1] << 16) | ((uint32_t)bytes[index + 2] << 8) | (uint32_t)bytes[index + 3]; }
-__attribute__ ((weak))
-bool process_api_quantum(uint8_t length, uint8_t * data) {
- return process_api_keyboard(length, data);
-}
+__attribute__((weak)) bool process_api_quantum(uint8_t length, uint8_t* data) { return process_api_keyboard(length, data); }
-__attribute__ ((weak))
-bool process_api_keyboard(uint8_t length, uint8_t * data) {
- return process_api_user(length, data);
-}
+__attribute__((weak)) bool process_api_keyboard(uint8_t length, uint8_t* data) { return process_api_user(length, data); }
-__attribute__ ((weak))
-bool process_api_user(uint8_t length, uint8_t * data) {
- return true;
-}
+__attribute__((weak)) bool process_api_user(uint8_t length, uint8_t* data) { return true; }
-void process_api(uint16_t length, uint8_t * data) {
+void process_api(uint16_t length, uint8_t* data) {
// SEND_STRING("\nRX: ");
// for (uint8_t i = 0; i < length; i++) {
// send_byte(data[i]);
// SEND_STRING(" ");
// }
- if (!process_api_quantum(length, data))
- return;
+ if (!process_api_quantum(length, data)) return;
switch (data[0]) {
case MT_SET_DATA:
@@ -65,10 +53,10 @@ void process_api(uint16_t length, uint8_t * data) {
break;
}
case DT_RGBLIGHT: {
- #ifdef RGBLIGHT_ENABLE
- uint32_t rgblight = bytes_to_dword(data, 2);
- eeconfig_update_rgblight(rgblight);
- #endif
+#ifdef RGBLIGHT_ENABLE
+ uint32_t rgblight = bytes_to_dword(data, 2);
+ eeconfig_update_rgblight(rgblight);
+#endif
break;
}
}
@@ -79,12 +67,12 @@ void process_api(uint16_t length, uint8_t * data) {
break;
}
case DT_DEBUG: {
- uint8_t debug_bytes[1] = { eeprom_read_byte(EECONFIG_DEBUG) };
+ uint8_t debug_bytes[1] = {eeprom_read_byte(EECONFIG_DEBUG)};
MT_GET_DATA_ACK(DT_DEBUG, debug_bytes, 1);
break;
}
case DT_DEFAULT_LAYER: {
- uint8_t default_bytes[1] = { eeprom_read_byte(EECONFIG_DEFAULT_LAYER) };
+ uint8_t default_bytes[1] = {eeprom_read_byte(EECONFIG_DEFAULT_LAYER)};
MT_GET_DATA_ACK(DT_DEFAULT_LAYER, default_bytes, 1);
break;
}
@@ -95,35 +83,35 @@ void process_api(uint16_t length, uint8_t * data) {
break;
}
case DT_AUDIO: {
- #ifdef AUDIO_ENABLE
- uint8_t audio_bytes[1] = { eeprom_read_byte(EECONFIG_AUDIO) };
- MT_GET_DATA_ACK(DT_AUDIO, audio_bytes, 1);
- #else
- MT_GET_DATA_ACK(DT_AUDIO, NULL, 0);
- #endif
+#ifdef AUDIO_ENABLE
+ uint8_t audio_bytes[1] = {eeprom_read_byte(EECONFIG_AUDIO)};
+ MT_GET_DATA_ACK(DT_AUDIO, audio_bytes, 1);
+#else
+ MT_GET_DATA_ACK(DT_AUDIO, NULL, 0);
+#endif
break;
}
case DT_BACKLIGHT: {
- #ifdef BACKLIGHT_ENABLE
- uint8_t backlight_bytes[1] = { eeprom_read_byte(EECONFIG_BACKLIGHT) };
- MT_GET_DATA_ACK(DT_BACKLIGHT, backlight_bytes, 1);
- #else
- MT_GET_DATA_ACK(DT_BACKLIGHT, NULL, 0);
- #endif
+#ifdef BACKLIGHT_ENABLE
+ uint8_t backlight_bytes[1] = {eeprom_read_byte(EECONFIG_BACKLIGHT)};
+ MT_GET_DATA_ACK(DT_BACKLIGHT, backlight_bytes, 1);
+#else
+ MT_GET_DATA_ACK(DT_BACKLIGHT, NULL, 0);
+#endif
break;
}
case DT_RGBLIGHT: {
- #ifdef RGBLIGHT_ENABLE
- uint8_t rgblight_bytes[4];
- dword_to_bytes(eeconfig_read_rgblight(), rgblight_bytes);
- MT_GET_DATA_ACK(DT_RGBLIGHT, rgblight_bytes, 4);
- #else
- MT_GET_DATA_ACK(DT_RGBLIGHT, NULL, 0);
- #endif
+#ifdef RGBLIGHT_ENABLE
+ uint8_t rgblight_bytes[4];
+ dword_to_bytes(eeconfig_read_rgblight(), rgblight_bytes);
+ MT_GET_DATA_ACK(DT_RGBLIGHT, rgblight_bytes, 4);
+#else
+ MT_GET_DATA_ACK(DT_RGBLIGHT, NULL, 0);
+#endif
break;
}
case DT_KEYMAP_OPTIONS: {
- uint8_t keymap_bytes[1] = { eeconfig_read_keymap() };
+ uint8_t keymap_bytes[1] = {eeconfig_read_keymap()};
MT_GET_DATA_ACK(DT_KEYMAP_OPTIONS, keymap_bytes, 1);
break;
}
@@ -172,24 +160,23 @@ void process_api(uint16_t length, uint8_t * data) {
break;
case MT_TYPE_ERROR:
break;
- default: ; // command not recognised
+ default:; // command not recognised
SEND_BYTES(MT_TYPE_ERROR, DT_NONE, data, length);
break;
- // #ifdef RGBLIGHT_ENABLE
- // case 0x27: ; // RGB LED functions
- // switch (*data++) {
- // case 0x00: ; // Update HSV
- // rgblight_sethsv((data[0] << 8 | data[1]) % 360, data[2], data[3]);
- // break;
- // case 0x01: ; // Update RGB
- // break;
- // case 0x02: ; // Update mode
- // rgblight_mode(data[0]);
- // break;
- // }
- // break;
- // #endif
+ // #ifdef RGBLIGHT_ENABLE
+ // case 0x27: ; // RGB LED functions
+ // switch (*data++) {
+ // case 0x00: ; // Update HSV
+ // rgblight_sethsv((data[0] << 8 | data[1]) % 360, data[2], data[3]);
+ // break;
+ // case 0x01: ; // Update RGB
+ // break;
+ // case 0x02: ; // Update mode
+ // rgblight_mode(data[0]);
+ // break;
+ // }
+ // break;
+ // #endif
}
-
}
diff --git a/quantum/api.h b/quantum/api.h
index fc016391bc..90a4de8339 100644
--- a/quantum/api.h
+++ b/quantum/api.h
@@ -18,41 +18,25 @@
#define _API_H_
#ifdef __AVR__
-#include "lufa.h"
+# include "lufa.h"
#endif
enum MESSAGE_TYPE {
- MT_GET_DATA = 0x10, // Get data from keyboard
- MT_GET_DATA_ACK = 0x11, // returned data to process (ACK)
- MT_SET_DATA = 0x20, // Set data on keyboard
- MT_SET_DATA_ACK = 0x21, // returned data to confirm (ACK)
- MT_SEND_DATA = 0x30, // Sending data/action from keyboard
- MT_SEND_DATA_ACK = 0x31, // returned data/action confirmation (ACK)
- MT_EXE_ACTION = 0x40, // executing actions on keyboard
- MT_EXE_ACTION_ACK =0x41, // return confirmation/value (ACK)
- MT_TYPE_ERROR = 0x80 // type not recognised (ACK)
+ MT_GET_DATA = 0x10, // Get data from keyboard
+ MT_GET_DATA_ACK = 0x11, // returned data to process (ACK)
+ MT_SET_DATA = 0x20, // Set data on keyboard
+ MT_SET_DATA_ACK = 0x21, // returned data to confirm (ACK)
+ MT_SEND_DATA = 0x30, // Sending data/action from keyboard
+ MT_SEND_DATA_ACK = 0x31, // returned data/action confirmation (ACK)
+ MT_EXE_ACTION = 0x40, // executing actions on keyboard
+ MT_EXE_ACTION_ACK = 0x41, // return confirmation/value (ACK)
+ MT_TYPE_ERROR = 0x80 // type not recognised (ACK)
};
-enum DATA_TYPE {
- DT_NONE = 0x00,
- DT_HANDSHAKE,
- DT_DEFAULT_LAYER,
- DT_CURRENT_LAYER,
- DT_KEYMAP_OPTIONS,
- DT_BACKLIGHT,
- DT_RGBLIGHT,
- DT_UNICODE,
- DT_DEBUG,
- DT_AUDIO,
- DT_QUANTUM_ACTION,
- DT_KEYBOARD_ACTION,
- DT_USER_ACTION,
- DT_KEYMAP_SIZE,
- DT_KEYMAP
-};
+enum DATA_TYPE { DT_NONE = 0x00, DT_HANDSHAKE, DT_DEFAULT_LAYER, DT_CURRENT_LAYER, DT_KEYMAP_OPTIONS, DT_BACKLIGHT, DT_RGBLIGHT, DT_UNICODE, DT_DEBUG, DT_AUDIO, DT_QUANTUM_ACTION, DT_KEYBOARD_ACTION, DT_USER_ACTION, DT_KEYMAP_SIZE, DT_KEYMAP };
-void dword_to_bytes(uint32_t dword, uint8_t * bytes);
-uint32_t bytes_to_dword(uint8_t * bytes, uint8_t index);
+void dword_to_bytes(uint32_t dword, uint8_t* bytes);
+uint32_t bytes_to_dword(uint8_t* bytes, uint8_t index);
#define MT_GET_DATA(data_type, data, length) SEND_BYTES(MT_GET_DATA, data_type, data, length)
#define MT_GET_DATA_ACK(data_type, data, length) SEND_BYTES(MT_GET_DATA_ACK, data_type, data, length)
@@ -63,15 +47,12 @@ uint32_t bytes_to_dword(uint8_t * bytes, uint8_t index);
#define MT_EXE_ACTION(data_type, data, length) SEND_BYTES(MT_EXE_ACTION, data_type, data, length)
#define MT_EXE_ACTION_ACK(data_type, data, length) SEND_BYTES(MT_EXE_ACTION_ACK, data_type, data, length)
-void process_api(uint16_t length, uint8_t * data);
+void process_api(uint16_t length, uint8_t* data);
-__attribute__ ((weak))
-bool process_api_quantum(uint8_t length, uint8_t * data);
+__attribute__((weak)) bool process_api_quantum(uint8_t length, uint8_t* data);
-__attribute__ ((weak))
-bool process_api_keyboard(uint8_t length, uint8_t * data);
+__attribute__((weak)) bool process_api_keyboard(uint8_t length, uint8_t* data);
-__attribute__ ((weak))
-bool process_api_user(uint8_t length, uint8_t * data);
+__attribute__((weak)) bool process_api_user(uint8_t length, uint8_t* data);
#endif
diff --git a/quantum/api/api_sysex.c b/quantum/api/api_sysex.c
index 89c66a2a20..07c90cf804 100644
--- a/quantum/api/api_sysex.c
+++ b/quantum/api/api_sysex.c
@@ -18,7 +18,7 @@
#include "print.h"
#include "qmk_midi.h"
-void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint16_t length) {
+void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t* bytes, uint16_t length) {
// SEND_STRING("\nTX: ");
// for (uint8_t i = 0; i < length; i++) {
// send_byte(bytes[i]);
@@ -29,7 +29,6 @@ void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes,
return;
}
-
// The buffer size required is calculated as the following
// API_SYSEX_MAX_SIZE is the maximum length
// In addition to that we have a two byte message header consisting of the message_type and data_type
@@ -37,14 +36,14 @@ void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes,
// We just add one extra byte in case it's not divisible by 7
// Then we have an unencoded header consisting of 4 bytes
// Plus a one byte terminator
- const unsigned message_header = 2;
+ const unsigned message_header = 2;
const unsigned unencoded_message = API_SYSEX_MAX_SIZE + message_header;
const unsigned encoding_overhead = unencoded_message / 7 + 1;
- const unsigned encoded_size = unencoded_message + encoding_overhead;
- const unsigned unencoded_header = 4;
- const unsigned terminator = 1;
- const unsigned buffer_size = encoded_size + unencoded_header + terminator;
- uint8_t buffer[encoded_size + unencoded_header + terminator];
+ const unsigned encoded_size = unencoded_message + encoding_overhead;
+ const unsigned unencoded_header = 4;
+ const unsigned terminator = 1;
+ const unsigned buffer_size = encoded_size + unencoded_header + terminator;
+ uint8_t buffer[encoded_size + unencoded_header + terminator];
// The unencoded header
buffer[0] = 0xF0;
buffer[1] = 0x00;
@@ -53,16 +52,16 @@ void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes,
// We copy the message to the end of the array, this way we can do an inplace encoding, using the same
// buffer for both input and output
- const unsigned message_size = length + message_header;
- uint8_t* unencoded_start = buffer + buffer_size - message_size;
- uint8_t* ptr = unencoded_start;
- *(ptr++) = message_type;
- *(ptr++) = data_type;
+ const unsigned message_size = length + message_header;
+ uint8_t* unencoded_start = buffer + buffer_size - message_size;
+ uint8_t* ptr = unencoded_start;
+ *(ptr++) = message_type;
+ *(ptr++) = data_type;
memcpy(ptr, bytes, length);
unsigned encoded_length = sysex_encode(buffer + unencoded_header, unencoded_start, message_size);
- unsigned final_size = unencoded_header + encoded_length + terminator;
- buffer[final_size - 1] = 0xF7;
+ unsigned final_size = unencoded_header + encoded_length + terminator;
+ buffer[final_size - 1] = 0xF7;
midi_send_array(&midi_device, final_size, buffer);
// SEND_STRING("\nTD: ");
diff --git a/quantum/api/api_sysex.h b/quantum/api/api_sysex.h
index a23f00f572..58b8cbb663 100644
--- a/quantum/api/api_sysex.h
+++ b/quantum/api/api_sysex.h
@@ -19,7 +19,7 @@
#include "api.h"
-void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint16_t length);
+void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t* bytes, uint16_t length);
#define SEND_BYTES(mt, dt, b, l) send_bytes_sysex(mt, dt, b, l)
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index 3da164c736..781378788c 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -18,9 +18,9 @@
#include <string.h>
//#include <math.h>
#if defined(__AVR__)
- #include <avr/pgmspace.h>
- #include <avr/interrupt.h>
- #include <avr/io.h>
+# include <avr/pgmspace.h>
+# include <avr/interrupt.h>
+# include <avr/io.h>
#endif
#include "print.h"
#include "audio.h"
@@ -35,119 +35,118 @@
// Timer Abstractions
// -----------------------------------------------------------------------------
-//Currently we support timers 1 and 3 used at the sime time, channels A-C,
-//pins PB5, PB6, PB7, PC4, PC5, and PC6
+// Currently we support timers 1 and 3 used at the sime time, channels A-C,
+// pins PB5, PB6, PB7, PC4, PC5, and PC6
#if defined(C6_AUDIO)
- #define CPIN_AUDIO
- #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC6);
- #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
- #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A)
- #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A)
- #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1);
- #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0));
- #define TIMER_3_PERIOD ICR3
- #define TIMER_3_DUTY_CYCLE OCR3A
- #define TIMER3_AUDIO_vect TIMER3_COMPA_vect
+# define CPIN_AUDIO
+# define CPIN_SET_DIRECTION DDRC |= _BV(PORTC6);
+# define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
+# define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A)
+# define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A)
+# define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1);
+# define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0));
+# define TIMER_3_PERIOD ICR3
+# define TIMER_3_DUTY_CYCLE OCR3A
+# define TIMER3_AUDIO_vect TIMER3_COMPA_vect
#endif
#if defined(C5_AUDIO)
- #define CPIN_AUDIO
- #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC5);
- #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3B1) | (0 << COM3B0) | (1 << WGM31) | (0 << WGM30);
- #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3B)
- #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3B)
- #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3B1);
- #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3B1) | _BV(COM3B0));
- #define TIMER_3_PERIOD ICR3
- #define TIMER_3_DUTY_CYCLE OCR3B
- #define TIMER3_AUDIO_vect TIMER3_COMPB_vect
+# define CPIN_AUDIO
+# define CPIN_SET_DIRECTION DDRC |= _BV(PORTC5);
+# define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3B1) | (0 << COM3B0) | (1 << WGM31) | (0 << WGM30);
+# define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3B)
+# define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3B)
+# define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3B1);
+# define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3B1) | _BV(COM3B0));
+# define TIMER_3_PERIOD ICR3
+# define TIMER_3_DUTY_CYCLE OCR3B
+# define TIMER3_AUDIO_vect TIMER3_COMPB_vect
#endif
#if defined(C4_AUDIO)
- #define CPIN_AUDIO
- #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC4);
- #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3C1) | (0 << COM3C0) | (1 << WGM31) | (0 << WGM30);
- #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3C)
- #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3C)
- #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3C1);
- #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3C1) | _BV(COM3C0));
- #define TIMER_3_PERIOD ICR3
- #define TIMER_3_DUTY_CYCLE OCR3C
- #define TIMER3_AUDIO_vect TIMER3_COMPC_vect
+# define CPIN_AUDIO
+# define CPIN_SET_DIRECTION DDRC |= _BV(PORTC4);
+# define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3C1) | (0 << COM3C0) | (1 << WGM31) | (0 << WGM30);
+# define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3C)
+# define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3C)
+# define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3C1);
+# define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3C1) | _BV(COM3C0));
+# define TIMER_3_PERIOD ICR3
+# define TIMER_3_DUTY_CYCLE OCR3C
+# define TIMER3_AUDIO_vect TIMER3_COMPC_vect
#endif
#if defined(B5_AUDIO)
- #define BPIN_AUDIO
- #define BPIN_SET_DIRECTION DDRB |= _BV(PORTB5);
- #define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10);
- #define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1A)
- #define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1A)
- #define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1A1);
- #define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1A1) | _BV(COM1A0));
- #define TIMER_1_PERIOD ICR1
- #define TIMER_1_DUTY_CYCLE OCR1A
- #define TIMER1_AUDIO_vect TIMER1_COMPA_vect
+# define BPIN_AUDIO
+# define BPIN_SET_DIRECTION DDRB |= _BV(PORTB5);
+# define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10);
+# define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1A)
+# define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1A)
+# define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1A1);
+# define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1A1) | _BV(COM1A0));
+# define TIMER_1_PERIOD ICR1
+# define TIMER_1_DUTY_CYCLE OCR1A
+# define TIMER1_AUDIO_vect TIMER1_COMPA_vect
#endif
#if defined(B6_AUDIO)
- #define BPIN_AUDIO
- #define BPIN_SET_DIRECTION DDRB |= _BV(PORTB6);
- #define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1B1) | (0 << COM1B0) | (1 << WGM11) | (0 << WGM10);
- #define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1B)
- #define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1B)
- #define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1B1);
- #define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1B1) | _BV(COM1B0));
- #define TIMER_1_PERIOD ICR1
- #define TIMER_1_DUTY_CYCLE OCR1B
- #define TIMER1_AUDIO_vect TIMER1_COMPB_vect
+# define BPIN_AUDIO
+# define BPIN_SET_DIRECTION DDRB |= _BV(PORTB6);
+# define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1B1) | (0 << COM1B0) | (1 << WGM11) | (0 << WGM10);
+# define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1B)
+# define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1B)
+# define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1B1);
+# define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1B1) | _BV(COM1B0));
+# define TIMER_1_PERIOD ICR1
+# define TIMER_1_DUTY_CYCLE OCR1B
+# define TIMER1_AUDIO_vect TIMER1_COMPB_vect
#endif
#if defined(B7_AUDIO)
- #define BPIN_AUDIO
- #define BPIN_SET_DIRECTION DDRB |= _BV(PORTB7);
- #define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1C1) | (0 << COM1C0) | (1 << WGM11) | (0 << WGM10);
- #define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1C)
- #define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1C)
- #define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1C1);
- #define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1C1) | _BV(COM1C0));
- #define TIMER_1_PERIOD ICR1
- #define TIMER_1_DUTY_CYCLE OCR1C
- #define TIMER1_AUDIO_vect TIMER1_COMPC_vect
+# define BPIN_AUDIO
+# define BPIN_SET_DIRECTION DDRB |= _BV(PORTB7);
+# define INIT_AUDIO_COUNTER_1 TCCR1A = (0 << COM1C1) | (0 << COM1C0) | (1 << WGM11) | (0 << WGM10);
+# define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1C)
+# define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1C)
+# define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1C1);
+# define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1C1) | _BV(COM1C0));
+# define TIMER_1_PERIOD ICR1
+# define TIMER_1_DUTY_CYCLE OCR1C
+# define TIMER1_AUDIO_vect TIMER1_COMPC_vect
#endif
// -----------------------------------------------------------------------------
-
-int voices = 0;
-int voice_place = 0;
-float frequency = 0;
+int voices = 0;
+int voice_place = 0;
+float frequency = 0;
float frequency_alt = 0;
-int volume = 0;
-long position = 0;
+int volume = 0;
+long position = 0;
float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-bool sliding = false;
+int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+bool sliding = false;
float place = 0;
-uint8_t * sample;
+uint8_t* sample;
uint16_t sample_length = 0;
-bool playing_notes = false;
-bool playing_note = false;
+bool playing_notes = false;
+bool playing_note = false;
float note_frequency = 0;
-float note_length = 0;
-uint8_t note_tempo = TEMPO_DEFAULT;
-float note_timbre = TIMBRE_DEFAULT;
-uint16_t note_position = 0;
-float (* notes_pointer)[][2];
+float note_length = 0;
+uint8_t note_tempo = TEMPO_DEFAULT;
+float note_timbre = TIMBRE_DEFAULT;
+uint16_t note_position = 0;
+float (*notes_pointer)[][2];
uint16_t notes_count;
bool notes_repeat;
bool note_resting = false;
uint16_t current_note = 0;
-uint8_t rest_counter = 0;
+uint8_t rest_counter = 0;
#ifdef VIBRATO_ENABLE
-float vibrato_counter = 0;
+float vibrato_counter = 0;
float vibrato_strength = .5;
-float vibrato_rate = 0.125;
+float vibrato_rate = 0.125;
#endif
float polyphony_rate = 0;
@@ -157,73 +156,69 @@ static bool audio_initialized = false;
audio_config_t audio_config;
uint16_t envelope_index = 0;
-bool glissando = true;
+bool glissando = true;
#ifndef STARTUP_SONG
- #define STARTUP_SONG SONG(STARTUP_SOUND)
+# define STARTUP_SONG SONG(STARTUP_SOUND)
#endif
#ifndef AUDIO_ON_SONG
- #define AUDIO_ON_SONG SONG(AUDIO_ON_SOUND)
+# define AUDIO_ON_SONG SONG(AUDIO_ON_SOUND)
#endif
#ifndef AUDIO_OFF_SONG
- #define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
+# define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
#endif
-float startup_song[][2] = STARTUP_SONG;
-float audio_on_song[][2] = AUDIO_ON_SONG;
+float startup_song[][2] = STARTUP_SONG;
+float audio_on_song[][2] = AUDIO_ON_SONG;
float audio_off_song[][2] = AUDIO_OFF_SONG;
-void audio_init()
-{
-
+void audio_init() {
// Check EEPROM
- if (!eeconfig_is_enabled())
- {
+ if (!eeconfig_is_enabled()) {
eeconfig_init();
}
audio_config.raw = eeconfig_read_audio();
if (!audio_initialized) {
+// Set audio ports as output
+#ifdef CPIN_AUDIO
+ CPIN_SET_DIRECTION
+ DISABLE_AUDIO_COUNTER_3_ISR;
+#endif
+#ifdef BPIN_AUDIO
+ BPIN_SET_DIRECTION
+ DISABLE_AUDIO_COUNTER_1_ISR;
+#endif
- // Set audio ports as output
- #ifdef CPIN_AUDIO
- CPIN_SET_DIRECTION
- DISABLE_AUDIO_COUNTER_3_ISR;
- #endif
- #ifdef BPIN_AUDIO
- BPIN_SET_DIRECTION
- DISABLE_AUDIO_COUNTER_1_ISR;
- #endif
-
- // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers TCCR3A/TCCR3B, TCCR1A/TCCR1B
- // Compare Output Mode (COM3An and COM1An) = 0b00 = Normal port operation
- // OC3A -- PC6
- // OC3B -- PC5
- // OC3C -- PC4
- // OC1A -- PB5
- // OC1B -- PB6
- // OC1C -- PB7
-
- // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14. Period = ICR3, Duty Cycle OCR3A)
- // OCR3A - PC6
- // OCR3B - PC5
- // OCR3C - PC4
- // OCR1A - PB5
- // OCR1B - PB6
- // OCR1C - PB7
-
- // Clock Select (CS3n) = 0b010 = Clock / 8
- #ifdef CPIN_AUDIO
- INIT_AUDIO_COUNTER_3
- TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
- TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
- TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
- #endif
- #ifdef BPIN_AUDIO
- INIT_AUDIO_COUNTER_1
- TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10);
- TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
- TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
- #endif
+// TCCR3A / TCCR3B: Timer/Counter #3 Control Registers TCCR3A/TCCR3B, TCCR1A/TCCR1B
+// Compare Output Mode (COM3An and COM1An) = 0b00 = Normal port operation
+// OC3A -- PC6
+// OC3B -- PC5
+// OC3C -- PC4
+// OC1A -- PB5
+// OC1B -- PB6
+// OC1C -- PB7
+
+// Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14. Period = ICR3, Duty Cycle OCR3A)
+// OCR3A - PC6
+// OCR3B - PC5
+// OCR3C - PC4
+// OCR1A - PB5
+// OCR1B - PB6
+// OCR1C - PB7
+
+// Clock Select (CS3n) = 0b010 = Clock / 8
+#ifdef CPIN_AUDIO
+ INIT_AUDIO_COUNTER_3
+ TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
+ TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
+ TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
+#endif
+#ifdef BPIN_AUDIO
+ INIT_AUDIO_COUNTER_1
+ TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10);
+ TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
+ TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
+#endif
audio_initialized = true;
}
@@ -231,11 +226,9 @@ void audio_init()
if (audio_config.enable) {
PLAY_SONG(startup_song);
}
-
}
-void stop_all_notes()
-{
+void stop_all_notes() {
dprintf("audio stop all notes");
if (!audio_initialized) {
@@ -243,31 +236,29 @@ void stop_all_notes()
}
voices = 0;
- #ifdef CPIN_AUDIO
- DISABLE_AUDIO_COUNTER_3_ISR;
- DISABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
+#ifdef CPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_3_ISR;
+ DISABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
- #ifdef BPIN_AUDIO
- DISABLE_AUDIO_COUNTER_1_ISR;
- DISABLE_AUDIO_COUNTER_1_OUTPUT;
- #endif
+#ifdef BPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_1_ISR;
+ DISABLE_AUDIO_COUNTER_1_OUTPUT;
+#endif
playing_notes = false;
- playing_note = false;
- frequency = 0;
+ playing_note = false;
+ frequency = 0;
frequency_alt = 0;
- volume = 0;
+ volume = 0;
- for (uint8_t i = 0; i < 8; i++)
- {
+ for (uint8_t i = 0; i < 8; i++) {
frequencies[i] = 0;
- volumes[i] = 0;
+ volumes[i] = 0;
}
}
-void stop_note(float freq)
-{
+void stop_note(float freq) {
dprintf("audio stop note freq=%d", (int)freq);
if (playing_note) {
@@ -277,133 +268,129 @@ void stop_note(float freq)
for (int i = 7; i >= 0; i--) {
if (frequencies[i] == freq) {
frequencies[i] = 0;
- volumes[i] = 0;
+ volumes[i] = 0;
for (int j = i; (j < 7); j++) {
- frequencies[j] = frequencies[j+1];
- frequencies[j+1] = 0;
- volumes[j] = volumes[j+1];
- volumes[j+1] = 0;
+ frequencies[j] = frequencies[j + 1];
+ frequencies[j + 1] = 0;
+ volumes[j] = volumes[j + 1];
+ volumes[j + 1] = 0;
}
break;
}
}
voices--;
- if (voices < 0)
- voices = 0;
+ if (voices < 0) voices = 0;
if (voice_place >= voices) {
voice_place = 0;
}
if (voices == 0) {
- #ifdef CPIN_AUDIO
- DISABLE_AUDIO_COUNTER_3_ISR;
- DISABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
- #ifdef BPIN_AUDIO
- DISABLE_AUDIO_COUNTER_1_ISR;
- DISABLE_AUDIO_COUNTER_1_OUTPUT;
- #endif
- frequency = 0;
+#ifdef CPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_3_ISR;
+ DISABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
+#ifdef BPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_1_ISR;
+ DISABLE_AUDIO_COUNTER_1_OUTPUT;
+#endif
+ frequency = 0;
frequency_alt = 0;
- volume = 0;
- playing_note = false;
+ volume = 0;
+ playing_note = false;
}
}
}
#ifdef VIBRATO_ENABLE
-float mod(float a, int b)
-{
+float mod(float a, int b) {
float r = fmod(a, b);
return r < 0 ? r + b : r;
}
float vibrato(float average_freq) {
- #ifdef VIBRATO_STRENGTH_ENABLE
- float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength);
- #else
- float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter];
- #endif
- vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH);
+# ifdef VIBRATO_STRENGTH_ENABLE
+ float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength);
+# else
+ float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter];
+# endif
+ vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0 / average_freq)), VIBRATO_LUT_LENGTH);
return vibrated_freq;
}
#endif
#ifdef CPIN_AUDIO
-ISR(TIMER3_AUDIO_vect)
-{
+ISR(TIMER3_AUDIO_vect) {
float freq;
if (playing_note) {
if (voices > 0) {
-
- #ifdef BPIN_AUDIO
+# ifdef BPIN_AUDIO
float freq_alt = 0;
- if (voices > 1) {
- if (polyphony_rate == 0) {
- if (glissando) {
- if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440/frequencies[voices - 2]/12/2)) {
- frequency_alt = frequency_alt * pow(2, 440/frequency_alt/12/2);
- } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440/frequencies[voices - 2]/12/2)) {
- frequency_alt = frequency_alt * pow(2, -440/frequency_alt/12/2);
- } else {
- frequency_alt = frequencies[voices - 2];
- }
+ if (voices > 1) {
+ if (polyphony_rate == 0) {
+ if (glissando) {
+ if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440 / frequencies[voices - 2] / 12 / 2)) {
+ frequency_alt = frequency_alt * pow(2, 440 / frequency_alt / 12 / 2);
+ } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440 / frequencies[voices - 2] / 12 / 2)) {
+ frequency_alt = frequency_alt * pow(2, -440 / frequency_alt / 12 / 2);
} else {
frequency_alt = frequencies[voices - 2];
}
-
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq_alt = vibrato(frequency_alt);
- } else {
- freq_alt = frequency_alt;
- }
- #else
- freq_alt = frequency_alt;
- #endif
+ } else {
+ frequency_alt = frequencies[voices - 2];
}
- if (envelope_index < 65535) {
- envelope_index++;
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq_alt = vibrato(frequency_alt);
+ } else {
+ freq_alt = frequency_alt;
}
+# else
+ freq_alt = frequency_alt;
+# endif
+ }
- freq_alt = voice_envelope(freq_alt);
+ if (envelope_index < 65535) {
+ envelope_index++;
+ }
- if (freq_alt < 30.517578125) {
- freq_alt = 30.52;
- }
+ freq_alt = voice_envelope(freq_alt);
- TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq_alt * CPU_PRESCALER));
- TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq_alt * CPU_PRESCALER)) * note_timbre);
+ if (freq_alt < 30.517578125) {
+ freq_alt = 30.52;
}
- #endif
+
+ TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq_alt * CPU_PRESCALER));
+ TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq_alt * CPU_PRESCALER)) * note_timbre);
+ }
+# endif
if (polyphony_rate > 0) {
if (voices > 1) {
voice_place %= voices;
if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) {
voice_place = (voice_place + 1) % voices;
- place = 0.0;
+ place = 0.0;
}
}
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequencies[voice_place]);
- } else {
- freq = frequencies[voice_place];
- }
- #else
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequencies[voice_place]);
+ } else {
freq = frequencies[voice_place];
- #endif
+ }
+# else
+ freq = frequencies[voice_place];
+# endif
} else {
if (glissando) {
- if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, 440/frequency/12/2);
- } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, -440/frequency/12/2);
+ if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, 440 / frequency / 12 / 2);
+ } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, -440 / frequency / 12 / 2);
} else {
frequency = frequencies[voices - 1];
}
@@ -411,15 +398,15 @@ ISR(TIMER3_AUDIO_vect)
frequency = frequencies[voices - 1];
}
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequency);
- } else {
- freq = frequency;
- }
- #else
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequency);
+ } else {
freq = frequency;
- #endif
+ }
+# else
+ freq = frequency;
+# endif
}
if (envelope_index < 65535) {
@@ -432,32 +419,32 @@ ISR(TIMER3_AUDIO_vect)
freq = 30.52;
}
- TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
+ TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
}
}
if (playing_notes) {
if (note_frequency > 0) {
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(note_frequency);
- } else {
- freq = note_frequency;
- }
- #else
- freq = note_frequency;
- #endif
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(note_frequency);
+ } else {
+ freq = note_frequency;
+ }
+# else
+ freq = note_frequency;
+# endif
if (envelope_index < 65535) {
envelope_index++;
}
freq = voice_envelope(freq);
- TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
+ TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
} else {
- TIMER_3_PERIOD = 0;
+ TIMER_3_PERIOD = 0;
TIMER_3_DUTY_CYCLE = 0;
}
@@ -489,16 +476,16 @@ ISR(TIMER3_AUDIO_vect)
current_note--;
if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) {
note_frequency = 0;
- note_length = 1;
+ note_length = 1;
} else {
note_frequency = (*notes_pointer)[current_note][0];
- note_length = 1;
+ note_length = 1;
}
} else {
- note_resting = false;
+ note_resting = false;
envelope_index = 0;
note_frequency = (*notes_pointer)[current_note][0];
- note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
+ note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
}
note_position = 0;
@@ -507,15 +494,14 @@ ISR(TIMER3_AUDIO_vect)
if (!audio_config.enable) {
playing_notes = false;
- playing_note = false;
+ playing_note = false;
}
}
#endif
#ifdef BPIN_AUDIO
-ISR(TIMER1_AUDIO_vect)
-{
- #if defined(BPIN_AUDIO) && !defined(CPIN_AUDIO)
+ISR(TIMER1_AUDIO_vect) {
+# if defined(BPIN_AUDIO) && !defined(CPIN_AUDIO)
float freq = 0;
if (playing_note) {
@@ -525,25 +511,25 @@ ISR(TIMER1_AUDIO_vect)
voice_place %= voices;
if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) {
voice_place = (voice_place + 1) % voices;
- place = 0.0;
+ place = 0.0;
}
}
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequencies[voice_place]);
- } else {
- freq = frequencies[voice_place];
- }
- #else
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequencies[voice_place]);
+ } else {
freq = frequencies[voice_place];
- #endif
+ }
+# else
+ freq = frequencies[voice_place];
+# endif
} else {
if (glissando) {
- if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, 440/frequency/12/2);
- } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, -440/frequency/12/2);
+ if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, 440 / frequency / 12 / 2);
+ } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, -440 / frequency / 12 / 2);
} else {
frequency = frequencies[voices - 1];
}
@@ -551,15 +537,15 @@ ISR(TIMER1_AUDIO_vect)
frequency = frequencies[voices - 1];
}
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequency);
- } else {
- freq = frequency;
- }
- #else
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequency);
+ } else {
freq = frequency;
- #endif
+ }
+# else
+ freq = frequency;
+# endif
}
if (envelope_index < 65535) {
@@ -572,32 +558,32 @@ ISR(TIMER1_AUDIO_vect)
freq = 30.52;
}
- TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
+ TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
}
}
if (playing_notes) {
if (note_frequency > 0) {
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(note_frequency);
- } else {
- freq = note_frequency;
- }
- #else
- freq = note_frequency;
- #endif
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(note_frequency);
+ } else {
+ freq = note_frequency;
+ }
+# else
+ freq = note_frequency;
+# endif
if (envelope_index < 65535) {
envelope_index++;
}
freq = voice_envelope(freq);
- TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
+ TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
} else {
- TIMER_1_PERIOD = 0;
+ TIMER_1_PERIOD = 0;
TIMER_1_DUTY_CYCLE = 0;
}
@@ -629,16 +615,16 @@ ISR(TIMER1_AUDIO_vect)
current_note--;
if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) {
note_frequency = 0;
- note_length = 1;
+ note_length = 1;
} else {
note_frequency = (*notes_pointer)[current_note][0];
- note_length = 1;
+ note_length = 1;
}
} else {
- note_resting = false;
+ note_resting = false;
envelope_index = 0;
note_frequency = (*notes_pointer)[current_note][0];
- note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
+ note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
}
note_position = 0;
@@ -647,14 +633,13 @@ ISR(TIMER1_AUDIO_vect)
if (!audio_config.enable) {
playing_notes = false;
- playing_note = false;
+ playing_note = false;
}
-#endif
+# endif
}
#endif
void play_note(float freq, int vol) {
-
dprintf("audio play note freq=%d vol=%d", (int)freq, vol);
if (!audio_initialized) {
@@ -662,16 +647,15 @@ void play_note(float freq, int vol) {
}
if (audio_config.enable && voices < 8) {
- #ifdef CPIN_AUDIO
- DISABLE_AUDIO_COUNTER_3_ISR;
- #endif
- #ifdef BPIN_AUDIO
- DISABLE_AUDIO_COUNTER_1_ISR;
- #endif
+#ifdef CPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_3_ISR;
+#endif
+#ifdef BPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_1_ISR;
+#endif
// Cancel notes if notes are playing
- if (playing_notes)
- stop_all_notes();
+ if (playing_notes) stop_all_notes();
playing_note = true;
@@ -679,90 +663,78 @@ void play_note(float freq, int vol) {
if (freq > 0) {
frequencies[voices] = freq;
- volumes[voices] = vol;
+ volumes[voices] = vol;
voices++;
}
- #ifdef CPIN_AUDIO
- ENABLE_AUDIO_COUNTER_3_ISR;
- ENABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
- #ifdef BPIN_AUDIO
- #ifdef CPIN_AUDIO
- if (voices > 1) {
- ENABLE_AUDIO_COUNTER_1_ISR;
- ENABLE_AUDIO_COUNTER_1_OUTPUT;
- }
- #else
+#ifdef CPIN_AUDIO
+ ENABLE_AUDIO_COUNTER_3_ISR;
+ ENABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
+#ifdef BPIN_AUDIO
+# ifdef CPIN_AUDIO
+ if (voices > 1) {
ENABLE_AUDIO_COUNTER_1_ISR;
ENABLE_AUDIO_COUNTER_1_OUTPUT;
- #endif
- #endif
+ }
+# else
+ ENABLE_AUDIO_COUNTER_1_ISR;
+ ENABLE_AUDIO_COUNTER_1_OUTPUT;
+# endif
+#endif
}
-
}
-void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat)
-{
-
+void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) {
if (!audio_initialized) {
audio_init();
}
if (audio_config.enable) {
-
- #ifdef CPIN_AUDIO
- DISABLE_AUDIO_COUNTER_3_ISR;
- #endif
- #ifdef BPIN_AUDIO
- DISABLE_AUDIO_COUNTER_1_ISR;
- #endif
+#ifdef CPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_3_ISR;
+#endif
+#ifdef BPIN_AUDIO
+ DISABLE_AUDIO_COUNTER_1_ISR;
+#endif
// Cancel note if a note is playing
- if (playing_note)
- stop_all_notes();
+ if (playing_note) stop_all_notes();
playing_notes = true;
notes_pointer = np;
- notes_count = n_count;
- notes_repeat = n_repeat;
+ notes_count = n_count;
+ notes_repeat = n_repeat;
- place = 0;
+ place = 0;
current_note = 0;
note_frequency = (*notes_pointer)[current_note][0];
- note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
- note_position = 0;
+ note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
+ note_position = 0;
-
- #ifdef CPIN_AUDIO
- ENABLE_AUDIO_COUNTER_3_ISR;
- ENABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
- #ifdef BPIN_AUDIO
- #ifndef CPIN_AUDIO
- ENABLE_AUDIO_COUNTER_1_ISR;
- ENABLE_AUDIO_COUNTER_1_OUTPUT;
- #endif
- #endif
+#ifdef CPIN_AUDIO
+ ENABLE_AUDIO_COUNTER_3_ISR;
+ ENABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
+#ifdef BPIN_AUDIO
+# ifndef CPIN_AUDIO
+ ENABLE_AUDIO_COUNTER_1_ISR;
+ ENABLE_AUDIO_COUNTER_1_OUTPUT;
+# endif
+#endif
}
-
}
-bool is_playing_notes(void) {
- return playing_notes;
-}
+bool is_playing_notes(void) { return playing_notes; }
-bool is_audio_on(void) {
- return (audio_config.enable != 0);
-}
+bool is_audio_on(void) { return (audio_config.enable != 0); }
void audio_toggle(void) {
audio_config.enable ^= 1;
eeconfig_update_audio(audio_config.raw);
- if (audio_config.enable)
- audio_on_user();
+ if (audio_config.enable) audio_on_user();
}
void audio_on(void) {
@@ -784,73 +756,45 @@ void audio_off(void) {
// Vibrato rate functions
-void set_vibrato_rate(float rate) {
- vibrato_rate = rate;
-}
+void set_vibrato_rate(float rate) { vibrato_rate = rate; }
-void increase_vibrato_rate(float change) {
- vibrato_rate *= change;
-}
+void increase_vibrato_rate(float change) { vibrato_rate *= change; }
-void decrease_vibrato_rate(float change) {
- vibrato_rate /= change;
-}
+void decrease_vibrato_rate(float change) { vibrato_rate /= change; }
-#ifdef VIBRATO_STRENGTH_ENABLE
+# ifdef VIBRATO_STRENGTH_ENABLE
-void set_vibrato_strength(float strength) {
- vibrato_strength = strength;
-}
+void set_vibrato_strength(float strength) { vibrato_strength = strength; }
-void increase_vibrato_strength(float change) {
- vibrato_strength *= change;
-}
+void increase_vibrato_strength(float change) { vibrato_strength *= change; }
-void decrease_vibrato_strength(float change) {
- vibrato_strength /= change;
-}
+void decrease_vibrato_strength(float change) { vibrato_strength /= change; }
-#endif /* VIBRATO_STRENGTH_ENABLE */
+# endif /* VIBRATO_STRENGTH_ENABLE */
#endif /* VIBRATO_ENABLE */
// Polyphony functions
-void set_polyphony_rate(float rate) {
- polyphony_rate = rate;
-}
+void set_polyphony_rate(float rate) { polyphony_rate = rate; }
-void enable_polyphony() {
- polyphony_rate = 5;
-}
+void enable_polyphony() { polyphony_rate = 5; }
-void disable_polyphony() {
- polyphony_rate = 0;
-}
+void disable_polyphony() { polyphony_rate = 0; }
-void increase_polyphony_rate(float change) {
- polyphony_rate *= change;
-}
+void increase_polyphony_rate(float change) { polyphony_rate *= change; }
-void decrease_polyphony_rate(float change) {
- polyphony_rate /= change;
-}
+void decrease_polyphony_rate(float change) { polyphony_rate /= change; }
// Timbre function
-void set_timbre(float timbre) {
- note_timbre = timbre;
-}
+void set_timbre(float timbre) { note_timbre = timbre; }
// Tempo functions
-void set_tempo(uint8_t tempo) {
- note_tempo = tempo;
-}
+void set_tempo(uint8_t tempo) { note_tempo = tempo; }
-void decrease_tempo(uint8_t tempo_change) {
- note_tempo += tempo_change;
-}
+void decrease_tempo(uint8_t tempo_change) { note_tempo += tempo_change; }
void increase_tempo(uint8_t tempo_change) {
if (note_tempo - tempo_change < 10) {
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index 8136c5b258..2bcc27b4a1 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -19,7 +19,7 @@
#include <stdint.h>
#include <stdbool.h>
#if defined(__AVR__)
- #include <avr/io.h>
+# include <avr/io.h>
#endif
#include "wait.h"
#include "musical_notes.h"
@@ -39,9 +39,9 @@
typedef union {
uint8_t raw;
struct {
- bool enable :1;
- bool clicky_enable :1;
- uint8_t level :6;
+ bool enable : 1;
+ bool clicky_enable : 1;
+ uint8_t level : 6;
};
} audio_config_t;
@@ -58,13 +58,13 @@ void set_vibrato_rate(float rate);
void increase_vibrato_rate(float change);
void decrease_vibrato_rate(float change);
-#ifdef VIBRATO_STRENGTH_ENABLE
+# ifdef VIBRATO_STRENGTH_ENABLE
void set_vibrato_strength(float strength);
void increase_vibrato_strength(float change);
void decrease_vibrato_strength(float change);
-#endif
+# endif
#endif
@@ -85,25 +85,23 @@ void decrease_tempo(uint8_t tempo_change);
void audio_init(void);
#ifdef PWM_AUDIO
-void play_sample(uint8_t * s, uint16_t l, bool r);
+void play_sample(uint8_t* s, uint16_t l, bool r);
#endif
void play_note(float freq, int vol);
void stop_note(float freq);
void stop_all_notes(void);
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat);
-#define SCALE (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), }
+#define SCALE \
+ (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), }
// These macros are used to allow play_notes to play an array of indeterminate
// length. This works around the limitation of C's sizeof operation on pointers.
// The global float array for the song must be used here.
#define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0]))))
-#define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \
- _Pragma ("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"")
+#define PLAY_NOTE_ARRAY(note_array, note_repeat, deprecated_arg) \
+ play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat)); \
+ _Pragma("message \"'PLAY_NOTE_ARRAY' macro is deprecated\"")
#define PLAY_SONG(note_array) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), false)
#define PLAY_LOOP(note_array) play_notes(&note_array, NOTE_ARRAY_SIZE((note_array)), true)
diff --git a/quantum/audio/audio_arm.c b/quantum/audio/audio_arm.c
index de0cd15c58..87d625301f 100644
--- a/quantum/audio/audio_arm.c
+++ b/quantum/audio/audio_arm.c
@@ -26,41 +26,41 @@
// -----------------------------------------------------------------------------
-int voices = 0;
-int voice_place = 0;
-float frequency = 0;
+int voices = 0;
+int voice_place = 0;
+float frequency = 0;
float frequency_alt = 0;
-int volume = 0;
-long position = 0;
+int volume = 0;
+long position = 0;
float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-bool sliding = false;
+int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+bool sliding = false;
float place = 0;
-uint8_t * sample;
+uint8_t *sample;
uint16_t sample_length = 0;
-bool playing_notes = false;
-bool playing_note = false;
+bool playing_notes = false;
+bool playing_note = false;
float note_frequency = 0;
-float note_length = 0;
-uint8_t note_tempo = TEMPO_DEFAULT;
-float note_timbre = TIMBRE_DEFAULT;
-uint16_t note_position = 0;
-float (* notes_pointer)[][2];
+float note_length = 0;
+uint8_t note_tempo = TEMPO_DEFAULT;
+float note_timbre = TIMBRE_DEFAULT;
+uint16_t note_position = 0;
+float (*notes_pointer)[][2];
uint16_t notes_count;
bool notes_repeat;
bool note_resting = false;
uint16_t current_note = 0;
-uint8_t rest_counter = 0;
+uint8_t rest_counter = 0;
#ifdef VIBRATO_ENABLE
-float vibrato_counter = 0;
+float vibrato_counter = 0;
float vibrato_strength = .5;
-float vibrato_rate = 0.125;
+float vibrato_rate = 0.125;
#endif
float polyphony_rate = 0;
@@ -70,10 +70,10 @@ static bool audio_initialized = false;
audio_config_t audio_config;
uint16_t envelope_index = 0;
-bool glissando = true;
+bool glissando = true;
#ifndef STARTUP_SONG
- #define STARTUP_SONG SONG(STARTUP_SOUND)
+# define STARTUP_SONG SONG(STARTUP_SOUND)
#endif
float startup_song[][2] = STARTUP_SONG;
@@ -81,27 +81,32 @@ static void gpt_cb8(GPTDriver *gptp);
#define DAC_BUFFER_SIZE 100
#ifndef DAC_SAMPLE_MAX
-#define DAC_SAMPLE_MAX 65535U
+# define DAC_SAMPLE_MAX 65535U
#endif
-#define START_CHANNEL_1() gptStart(&GPTD6, &gpt6cfg1); \
+#define START_CHANNEL_1() \
+ gptStart(&GPTD6, &gpt6cfg1); \
gptStartContinuous(&GPTD6, 2U)
-#define START_CHANNEL_2() gptStart(&GPTD7, &gpt7cfg1); \
+#define START_CHANNEL_2() \
+ gptStart(&GPTD7, &gpt7cfg1); \
gptStartContinuous(&GPTD7, 2U)
#define STOP_CHANNEL_1() gptStopTimer(&GPTD6)
#define STOP_CHANNEL_2() gptStopTimer(&GPTD7)
-#define RESTART_CHANNEL_1() STOP_CHANNEL_1(); \
+#define RESTART_CHANNEL_1() \
+ STOP_CHANNEL_1(); \
START_CHANNEL_1()
-#define RESTART_CHANNEL_2() STOP_CHANNEL_2(); \
+#define RESTART_CHANNEL_2() \
+ STOP_CHANNEL_2(); \
START_CHANNEL_2()
-#define UPDATE_CHANNEL_1_FREQ(freq) gpt6cfg1.frequency = freq * DAC_BUFFER_SIZE; \
+#define UPDATE_CHANNEL_1_FREQ(freq) \
+ gpt6cfg1.frequency = freq * DAC_BUFFER_SIZE; \
RESTART_CHANNEL_1()
-#define UPDATE_CHANNEL_2_FREQ(freq) gpt7cfg1.frequency = freq * DAC_BUFFER_SIZE; \
+#define UPDATE_CHANNEL_2_FREQ(freq) \
+ gpt7cfg1.frequency = freq * DAC_BUFFER_SIZE; \
RESTART_CHANNEL_2()
#define GET_CHANNEL_1_FREQ (uint16_t)(gpt6cfg1.frequency * DAC_BUFFER_SIZE)
#define GET_CHANNEL_2_FREQ (uint16_t)(gpt7cfg1.frequency * DAC_BUFFER_SIZE)
-
/*
* GPT6 configuration.
*/
@@ -112,27 +117,20 @@ static void gpt_cb8(GPTDriver *gptp);
// .dier = 0U
// };
-GPTConfig gpt6cfg1 = {
- .frequency = 440U*DAC_BUFFER_SIZE,
- .callback = NULL,
- .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
- .dier = 0U
-};
+GPTConfig gpt6cfg1 = {.frequency = 440U * DAC_BUFFER_SIZE,
+ .callback = NULL,
+ .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
+ .dier = 0U};
-GPTConfig gpt7cfg1 = {
- .frequency = 440U*DAC_BUFFER_SIZE,
- .callback = NULL,
- .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
- .dier = 0U
-};
-
-GPTConfig gpt8cfg1 = {
- .frequency = 10,
- .callback = gpt_cb8,
- .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
- .dier = 0U
-};
+GPTConfig gpt7cfg1 = {.frequency = 440U * DAC_BUFFER_SIZE,
+ .callback = NULL,
+ .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
+ .dier = 0U};
+GPTConfig gpt8cfg1 = {.frequency = 10,
+ .callback = gpt_cb8,
+ .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
+ .dier = 0U};
/*
* DAC test buffer (sine wave).
@@ -205,122 +203,101 @@ GPTConfig gpt8cfg1 = {
// squarewave
static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
- // First half is max, second half is 0
- [0 ... DAC_BUFFER_SIZE/2-1] = DAC_SAMPLE_MAX,
- [DAC_BUFFER_SIZE/2 ... DAC_BUFFER_SIZE -1] = 0,
+ // First half is max, second half is 0
+ [0 ... DAC_BUFFER_SIZE / 2 - 1] = DAC_SAMPLE_MAX,
+ [DAC_BUFFER_SIZE / 2 ... DAC_BUFFER_SIZE - 1] = 0,
};
// squarewave
static const dacsample_t dac_buffer_2[DAC_BUFFER_SIZE] = {
- // opposite of dac_buffer above
- [0 ... DAC_BUFFER_SIZE/2-1] = 0,
- [DAC_BUFFER_SIZE/2 ... DAC_BUFFER_SIZE -1] = DAC_SAMPLE_MAX,
+ // opposite of dac_buffer above
+ [0 ... DAC_BUFFER_SIZE / 2 - 1] = 0,
+ [DAC_BUFFER_SIZE / 2 ... DAC_BUFFER_SIZE - 1] = DAC_SAMPLE_MAX,
};
/*
* DAC streaming callback.
*/
-size_t nx = 0, ny = 0, nz = 0;
+size_t nx = 0, ny = 0, nz = 0;
static void end_cb1(DACDriver *dacp, dacsample_t *buffer, size_t n) {
+ (void)dacp;
- (void)dacp;
-
- nz++;
- if (dac_buffer == buffer) {
- nx += n;
- }
- else {
- ny += n;
- }
+ nz++;
+ if (dac_buffer == buffer) {
+ nx += n;
+ } else {
+ ny += n;
+ }
- if ((nz % 1000) == 0) {
- // palTogglePad(GPIOD, GPIOD_LED3);
- }
+ if ((nz % 1000) == 0) {
+ // palTogglePad(GPIOD, GPIOD_LED3);
+ }
}
/*
* DAC error callback.
*/
static void error_cb1(DACDriver *dacp, dacerror_t err) {
+ (void)dacp;
+ (void)err;
- (void)dacp;
- (void)err;
-
- chSysHalt("DAC failure");
+ chSysHalt("DAC failure");
}
-static const DACConfig dac1cfg1 = {
- .init = DAC_SAMPLE_MAX,
- .datamode = DAC_DHRM_12BIT_RIGHT
-};
+static const DACConfig dac1cfg1 = {.init = DAC_SAMPLE_MAX, .datamode = DAC_DHRM_12BIT_RIGHT};
-static const DACConversionGroup dacgrpcfg1 = {
- .num_channels = 1U,
- .end_cb = end_cb1,
- .error_cb = error_cb1,
- .trigger = DAC_TRG(0)
-};
+static const DACConversionGroup dacgrpcfg1 = {.num_channels = 1U, .end_cb = end_cb1, .error_cb = error_cb1, .trigger = DAC_TRG(0)};
-static const DACConfig dac1cfg2 = {
- .init = DAC_SAMPLE_MAX,
- .datamode = DAC_DHRM_12BIT_RIGHT
-};
+static const DACConfig dac1cfg2 = {.init = DAC_SAMPLE_MAX, .datamode = DAC_DHRM_12BIT_RIGHT};
-static const DACConversionGroup dacgrpcfg2 = {
- .num_channels = 1U,
- .end_cb = end_cb1,
- .error_cb = error_cb1,
- .trigger = DAC_TRG(0)
-};
+static const DACConversionGroup dacgrpcfg2 = {.num_channels = 1U, .end_cb = end_cb1, .error_cb = error_cb1, .trigger = DAC_TRG(0)};
void audio_init() {
+ if (audio_initialized) {
+ return;
+ }
- if (audio_initialized) {
- return;
- }
-
- // Check EEPROM
- #if defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
+// Check EEPROM
+#if defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
if (!eeconfig_is_enabled()) {
- eeconfig_init();
+ eeconfig_init();
}
audio_config.raw = eeconfig_read_audio();
-#else // ARM EEPROM
- audio_config.enable = true;
- #ifdef AUDIO_CLICKY_ON
+#else // ARM EEPROM
+ audio_config.enable = true;
+# ifdef AUDIO_CLICKY_ON
audio_config.clicky_enable = true;
- #endif
-#endif // ARM EEPROM
-
- /*
- * Starting DAC1 driver, setting up the output pin as analog as suggested
- * by the Reference Manual.
- */
- palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
- palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG);
- dacStart(&DACD1, &dac1cfg1);
- dacStart(&DACD2, &dac1cfg2);
-
- /*
- * Starting GPT6/7 driver, it is used for triggering the DAC.
- */
- START_CHANNEL_1();
- START_CHANNEL_2();
-
- /*
- * Starting a continuous conversion.
- */
- dacStartConversion(&DACD1, &dacgrpcfg1, (dacsample_t *)dac_buffer, DAC_BUFFER_SIZE);
- dacStartConversion(&DACD2, &dacgrpcfg2, (dacsample_t *)dac_buffer_2, DAC_BUFFER_SIZE);
-
- audio_initialized = true;
-
- if (audio_config.enable) {
- PLAY_SONG(startup_song);
- } else {
- stop_all_notes();
- }
-
+# endif
+#endif // ARM EEPROM
+
+ /*
+ * Starting DAC1 driver, setting up the output pin as analog as suggested
+ * by the Reference Manual.
+ */
+ palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
+ palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG);
+ dacStart(&DACD1, &dac1cfg1);
+ dacStart(&DACD2, &dac1cfg2);
+
+ /*
+ * Starting GPT6/7 driver, it is used for triggering the DAC.
+ */
+ START_CHANNEL_1();
+ START_CHANNEL_2();
+
+ /*
+ * Starting a continuous conversion.
+ */
+ dacStartConversion(&DACD1, &dacgrpcfg1, (dacsample_t *)dac_buffer, DAC_BUFFER_SIZE);
+ dacStartConversion(&DACD2, &dacgrpcfg2, (dacsample_t *)dac_buffer_2, DAC_BUFFER_SIZE);
+
+ audio_initialized = true;
+
+ if (audio_config.enable) {
+ PLAY_SONG(startup_song);
+ } else {
+ stop_all_notes();
+ }
}
void stop_all_notes() {
@@ -336,437 +313,396 @@ void stop_all_notes() {
gptStopTimer(&GPTD8);
playing_notes = false;
- playing_note = false;
- frequency = 0;
+ playing_note = false;
+ frequency = 0;
frequency_alt = 0;
- volume = 0;
+ volume = 0;
- for (uint8_t i = 0; i < 8; i++)
- {
+ for (uint8_t i = 0; i < 8; i++) {
frequencies[i] = 0;
- volumes[i] = 0;
+ volumes[i] = 0;
}
}
void stop_note(float freq) {
- dprintf("audio stop note freq=%d", (int)freq);
+ dprintf("audio stop note freq=%d", (int)freq);
- if (playing_note) {
- if (!audio_initialized) {
- audio_init();
- }
- for (int i = 7; i >= 0; i--) {
- if (frequencies[i] == freq) {
- frequencies[i] = 0;
- volumes[i] = 0;
- for (int j = i; (j < 7); j++) {
- frequencies[j] = frequencies[j+1];
- frequencies[j+1] = 0;
- volumes[j] = volumes[j+1];
- volumes[j+1] = 0;
+ if (playing_note) {
+ if (!audio_initialized) {
+ audio_init();
+ }
+ for (int i = 7; i >= 0; i--) {
+ if (frequencies[i] == freq) {
+ frequencies[i] = 0;
+ volumes[i] = 0;
+ for (int j = i; (j < 7); j++) {
+ frequencies[j] = frequencies[j + 1];
+ frequencies[j + 1] = 0;
+ volumes[j] = volumes[j + 1];
+ volumes[j + 1] = 0;
+ }
+ break;
+ }
+ }
+ voices--;
+ if (voices < 0) {
+ voices = 0;
+ }
+ if (voice_place >= voices) {
+ voice_place = 0;
+ }
+ if (voices == 0) {
+ STOP_CHANNEL_1();
+ STOP_CHANNEL_2();
+ gptStopTimer(&GPTD8);
+ frequency = 0;
+ frequency_alt = 0;
+ volume = 0;
+ playing_note = false;
}
- break;
- }
- }
- voices--;
- if (voices < 0) {
- voices = 0;
- }
- if (voice_place >= voices) {
- voice_place = 0;
- }
- if (voices == 0) {
- STOP_CHANNEL_1();
- STOP_CHANNEL_2();
- gptStopTimer(&GPTD8);
- frequency = 0;
- frequency_alt = 0;
- volume = 0;
- playing_note = false;
}
- }
}
#ifdef VIBRATO_ENABLE
float mod(float a, int b) {
- float r = fmod(a, b);
- return r < 0 ? r + b : r;
+ float r = fmod(a, b);
+ return r < 0 ? r + b : r;
}
float vibrato(float average_freq) {
- #ifdef VIBRATO_STRENGTH_ENABLE
+# ifdef VIBRATO_STRENGTH_ENABLE
float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength);
- #else
+# else
float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter];
- #endif
- vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH);
- return vibrated_freq;
+# endif
+ vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0 / average_freq)), VIBRATO_LUT_LENGTH);
+ return vibrated_freq;
}
#endif
static void gpt_cb8(GPTDriver *gptp) {
- float freq;
-
- if (playing_note) {
- if (voices > 0) {
-
- float freq_alt = 0;
- if (voices > 1) {
- if (polyphony_rate == 0) {
- if (glissando) {
- if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440/frequencies[voices - 2]/12/2)) {
- frequency_alt = frequency_alt * pow(2, 440/frequency_alt/12/2);
- } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440/frequencies[voices - 2]/12/2)) {
- frequency_alt = frequency_alt * pow(2, -440/frequency_alt/12/2);
- } else {
- frequency_alt = frequencies[voices - 2];
- }
- } else {
- frequency_alt = frequencies[voices - 2];
- }
+ float freq;
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq_alt = vibrato(frequency_alt);
- } else {
- freq_alt = frequency_alt;
- }
- #else
- freq_alt = frequency_alt;
- #endif
- }
+ if (playing_note) {
+ if (voices > 0) {
+ float freq_alt = 0;
+ if (voices > 1) {
+ if (polyphony_rate == 0) {
+ if (glissando) {
+ if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440 / frequencies[voices - 2] / 12 / 2)) {
+ frequency_alt = frequency_alt * pow(2, 440 / frequency_alt / 12 / 2);
+ } else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440 / frequencies[voices - 2] / 12 / 2)) {
+ frequency_alt = frequency_alt * pow(2, -440 / frequency_alt / 12 / 2);
+ } else {
+ frequency_alt = frequencies[voices - 2];
+ }
+ } else {
+ frequency_alt = frequencies[voices - 2];
+ }
- if (envelope_index < 65535) {
- envelope_index++;
- }
+#ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq_alt = vibrato(frequency_alt);
+ } else {
+ freq_alt = frequency_alt;
+ }
+#else
+ freq_alt = frequency_alt;
+#endif
+ }
- freq_alt = voice_envelope(freq_alt);
+ if (envelope_index < 65535) {
+ envelope_index++;
+ }
- if (freq_alt < 30.517578125) {
- freq_alt = 30.52;
- }
+ freq_alt = voice_envelope(freq_alt);
- if (GET_CHANNEL_2_FREQ != (uint16_t)freq_alt) {
- UPDATE_CHANNEL_2_FREQ(freq_alt);
- } else {
- RESTART_CHANNEL_2();
- }
- //note_timbre;
- }
-
- if (polyphony_rate > 0) {
- if (voices > 1) {
- voice_place %= voices;
- if (place++ > (frequencies[voice_place] / polyphony_rate)) {
- voice_place = (voice_place + 1) % voices;
- place = 0.0;
- }
- }
+ if (freq_alt < 30.517578125) {
+ freq_alt = 30.52;
+ }
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequencies[voice_place]);
- } else {
- freq = frequencies[voice_place];
- }
- #else
- freq = frequencies[voice_place];
- #endif
- } else {
- if (glissando) {
- if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, 440/frequency/12/2);
- } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, -440/frequency/12/2);
- } else {
- frequency = frequencies[voices - 1];
- }
- } else {
- frequency = frequencies[voices - 1];
- }
+ if (GET_CHANNEL_2_FREQ != (uint16_t)freq_alt) {
+ UPDATE_CHANNEL_2_FREQ(freq_alt);
+ } else {
+ RESTART_CHANNEL_2();
+ }
+ // note_timbre;
+ }
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequency);
- } else {
- freq = frequency;
- }
- #else
- freq = frequency;
- #endif
- }
+ if (polyphony_rate > 0) {
+ if (voices > 1) {
+ voice_place %= voices;
+ if (place++ > (frequencies[voice_place] / polyphony_rate)) {
+ voice_place = (voice_place + 1) % voices;
+ place = 0.0;
+ }
+ }
- if (envelope_index < 65535) {
- envelope_index++;
- }
+#ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequencies[voice_place]);
+ } else {
+ freq = frequencies[voice_place];
+ }
+#else
+ freq = frequencies[voice_place];
+#endif
+ } else {
+ if (glissando) {
+ if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, 440 / frequency / 12 / 2);
+ } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, -440 / frequency / 12 / 2);
+ } else {
+ frequency = frequencies[voices - 1];
+ }
+ } else {
+ frequency = frequencies[voices - 1];
+ }
- freq = voice_envelope(freq);
+#ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequency);
+ } else {
+ freq = frequency;
+ }
+#else
+ freq = frequency;
+#endif
+ }
- if (freq < 30.517578125) {
- freq = 30.52;
- }
+ if (envelope_index < 65535) {
+ envelope_index++;
+ }
+ freq = voice_envelope(freq);
- if (GET_CHANNEL_1_FREQ != (uint16_t)freq) {
- UPDATE_CHANNEL_1_FREQ(freq);
- } else {
- RESTART_CHANNEL_1();
- }
- //note_timbre;
- }
- }
+ if (freq < 30.517578125) {
+ freq = 30.52;
+ }
- if (playing_notes) {
- if (note_frequency > 0) {
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(note_frequency);
- } else {
- freq = note_frequency;
+ if (GET_CHANNEL_1_FREQ != (uint16_t)freq) {
+ UPDATE_CHANNEL_1_FREQ(freq);
+ } else {
+ RESTART_CHANNEL_1();
+ }
+ // note_timbre;
}
- #else
- freq = note_frequency;
- #endif
-
- if (envelope_index < 65535) {
- envelope_index++;
- }
- freq = voice_envelope(freq);
-
-
- if (GET_CHANNEL_1_FREQ != (uint16_t)freq) {
- UPDATE_CHANNEL_1_FREQ(freq);
- UPDATE_CHANNEL_2_FREQ(freq);
- }
- //note_timbre;
- } else {
- // gptStopTimer(&GPTD6);
- // gptStopTimer(&GPTD7);
}
- note_position++;
- bool end_of_note = false;
- if (GET_CHANNEL_1_FREQ > 0) {
- if (!note_resting)
- end_of_note = (note_position >= (note_length*8 - 1));
- else
- end_of_note = (note_position >= (note_length*8));
- } else {
- end_of_note = (note_position >= (note_length*8));
- }
+ if (playing_notes) {
+ if (note_frequency > 0) {
+#ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(note_frequency);
+ } else {
+ freq = note_frequency;
+ }
+#else
+ freq = note_frequency;
+#endif
- if (end_of_note) {
- current_note++;
- if (current_note >= notes_count) {
- if (notes_repeat) {
- current_note = 0;
+ if (envelope_index < 65535) {
+ envelope_index++;
+ }
+ freq = voice_envelope(freq);
+
+ if (GET_CHANNEL_1_FREQ != (uint16_t)freq) {
+ UPDATE_CHANNEL_1_FREQ(freq);
+ UPDATE_CHANNEL_2_FREQ(freq);
+ }
+ // note_timbre;
} else {
- STOP_CHANNEL_1();
- STOP_CHANNEL_2();
- // gptStopTimer(&GPTD8);
- playing_notes = false;
- return;
+ // gptStopTimer(&GPTD6);
+ // gptStopTimer(&GPTD7);
}
- }
- if (!note_resting) {
- note_resting = true;
- current_note--;
- if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) {
- note_frequency = 0;
- note_length = 1;
+
+ note_position++;
+ bool end_of_note = false;
+ if (GET_CHANNEL_1_FREQ > 0) {
+ if (!note_resting)
+ end_of_note = (note_position >= (note_length * 8 - 1));
+ else
+ end_of_note = (note_position >= (note_length * 8));
} else {
- note_frequency = (*notes_pointer)[current_note][0];
- note_length = 1;
+ end_of_note = (note_position >= (note_length * 8));
}
- } else {
- note_resting = false;
- envelope_index = 0;
- note_frequency = (*notes_pointer)[current_note][0];
- note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
- }
- note_position = 0;
+ if (end_of_note) {
+ current_note++;
+ if (current_note >= notes_count) {
+ if (notes_repeat) {
+ current_note = 0;
+ } else {
+ STOP_CHANNEL_1();
+ STOP_CHANNEL_2();
+ // gptStopTimer(&GPTD8);
+ playing_notes = false;
+ return;
+ }
+ }
+ if (!note_resting) {
+ note_resting = true;
+ current_note--;
+ if ((*notes_pointer)[current_note][0] == (*notes_pointer)[current_note + 1][0]) {
+ note_frequency = 0;
+ note_length = 1;
+ } else {
+ note_frequency = (*notes_pointer)[current_note][0];
+ note_length = 1;
+ }
+ } else {
+ note_resting = false;
+ envelope_index = 0;
+ note_frequency = (*notes_pointer)[current_note][0];
+ note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
+ }
+
+ note_position = 0;
+ }
}
- }
- if (!audio_config.enable) {
- playing_notes = false;
- playing_note = false;
- }
+ if (!audio_config.enable) {
+ playing_notes = false;
+ playing_note = false;
+ }
}
void play_note(float freq, int vol) {
+ dprintf("audio play note freq=%d vol=%d", (int)freq, vol);
- dprintf("audio play note freq=%d vol=%d", (int)freq, vol);
-
- if (!audio_initialized) {
- audio_init();
- }
-
- if (audio_config.enable && voices < 8) {
-
- // Cancel notes if notes are playing
- if (playing_notes) {
- stop_all_notes();
+ if (!audio_initialized) {
+ audio_init();
}
- playing_note = true;
+ if (audio_config.enable && voices < 8) {
+ // Cancel notes if notes are playing
+ if (playing_notes) {
+ stop_all_notes();
+ }
- envelope_index = 0;
+ playing_note = true;
- if (freq > 0) {
- frequencies[voices] = freq;
- volumes[voices] = vol;
- voices++;
- }
+ envelope_index = 0;
- gptStart(&GPTD8, &gpt8cfg1);
- gptStartContinuous(&GPTD8, 2U);
- RESTART_CHANNEL_1();
- RESTART_CHANNEL_2();
- }
+ if (freq > 0) {
+ frequencies[voices] = freq;
+ volumes[voices] = vol;
+ voices++;
+ }
+ gptStart(&GPTD8, &gpt8cfg1);
+ gptStartContinuous(&GPTD8, 2U);
+ RESTART_CHANNEL_1();
+ RESTART_CHANNEL_2();
+ }
}
void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat) {
-
- if (!audio_initialized) {
- audio_init();
- }
-
- if (audio_config.enable) {
-
- // Cancel note if a note is playing
- if (playing_note) {
- stop_all_notes();
+ if (!audio_initialized) {
+ audio_init();
}
- playing_notes = true;
+ if (audio_config.enable) {
+ // Cancel note if a note is playing
+ if (playing_note) {
+ stop_all_notes();
+ }
- notes_pointer = np;
- notes_count = n_count;
- notes_repeat = n_repeat;
+ playing_notes = true;
- place = 0;
- current_note = 0;
+ notes_pointer = np;
+ notes_count = n_count;
+ notes_repeat = n_repeat;
- note_frequency = (*notes_pointer)[current_note][0];
- note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
- note_position = 0;
+ place = 0;
+ current_note = 0;
- gptStart(&GPTD8, &gpt8cfg1);
- gptStartContinuous(&GPTD8, 2U);
- RESTART_CHANNEL_1();
- RESTART_CHANNEL_2();
- }
-}
+ note_frequency = (*notes_pointer)[current_note][0];
+ note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
+ note_position = 0;
-bool is_playing_notes(void) {
- return playing_notes;
+ gptStart(&GPTD8, &gpt8cfg1);
+ gptStartContinuous(&GPTD8, 2U);
+ RESTART_CHANNEL_1();
+ RESTART_CHANNEL_2();
+ }
}
-bool is_audio_on(void) {
- return (audio_config.enable != 0);
-}
+bool is_playing_notes(void) { return playing_notes; }
+
+bool is_audio_on(void) { return (audio_config.enable != 0); }
void audio_toggle(void) {
- audio_config.enable ^= 1;
- eeconfig_update_audio(audio_config.raw);
- if (audio_config.enable) {
- audio_on_user();
- }
+ audio_config.enable ^= 1;
+ eeconfig_update_audio(audio_config.raw);
+ if (audio_config.enable) {
+ audio_on_user();
+ }
}
void audio_on(void) {
- audio_config.enable = 1;
- eeconfig_update_audio(audio_config.raw);
- audio_on_user();
+ audio_config.enable = 1;
+ eeconfig_update_audio(audio_config.raw);
+ audio_on_user();
}
void audio_off(void) {
- stop_all_notes();
- audio_config.enable = 0;
- eeconfig_update_audio(audio_config.raw);
+ stop_all_notes();
+ audio_config.enable = 0;
+ eeconfig_update_audio(audio_config.raw);
}
#ifdef VIBRATO_ENABLE
// Vibrato rate functions
-void set_vibrato_rate(float rate) {
- vibrato_rate = rate;
-}
+void set_vibrato_rate(float rate) { vibrato_rate = rate; }
-void increase_vibrato_rate(float change) {
- vibrato_rate *= change;
-}
+void increase_vibrato_rate(float change) { vibrato_rate *= change; }
-void decrease_vibrato_rate(float change) {
- vibrato_rate /= change;
-}
+void decrease_vibrato_rate(float change) { vibrato_rate /= change; }
-#ifdef VIBRATO_STRENGTH_ENABLE
+# ifdef VIBRATO_STRENGTH_ENABLE
-void set_vibrato_strength(float strength) {
- vibrato_strength = strength;
-}
+void set_vibrato_strength(float strength) { vibrato_strength = strength; }
-void increase_vibrato_strength(float change) {
- vibrato_strength *= change;
-}
+void increase_vibrato_strength(float change) { vibrato_strength *= change; }
-void decrease_vibrato_strength(float change) {
- vibrato_strength /= change;
-}
+void decrease_vibrato_strength(float change) { vibrato_strength /= change; }
-#endif /* VIBRATO_STRENGTH_ENABLE */
+# endif /* VIBRATO_STRENGTH_ENABLE */
#endif /* VIBRATO_ENABLE */
// Polyphony functions
-void set_polyphony_rate(float rate) {
- polyphony_rate = rate;
-}
+void set_polyphony_rate(float rate) { polyphony_rate = rate; }
-void enable_polyphony() {
- polyphony_rate = 5;
-}
+void enable_polyphony() { polyphony_rate = 5; }
-void disable_polyphony() {
- polyphony_rate = 0;
-}
+void disable_polyphony() { polyphony_rate = 0; }
-void increase_polyphony_rate(float change) {
- polyphony_rate *= change;
-}
+void increase_polyphony_rate(float change) { polyphony_rate *= change; }
-void decrease_polyphony_rate(float change) {
- polyphony_rate /= change;
-}
+void decrease_polyphony_rate(float change) { polyphony_rate /= change; }
// Timbre function
-void set_timbre(float timbre) {
- note_timbre = timbre;
-}
+void set_timbre(float timbre) { note_timbre = timbre; }
// Tempo functions
-void set_tempo(uint8_t tempo) {
- note_tempo = tempo;
-}
+void set_tempo(uint8_t tempo) { note_tempo = tempo; }
-void decrease_tempo(uint8_t tempo_change) {
- note_tempo += tempo_change;
-}
+void decrease_tempo(uint8_t tempo_change) { note_tempo += tempo_change; }
void increase_tempo(uint8_t tempo_change) {
- if (note_tempo - tempo_change < 10) {
- note_tempo = 10;
- } else {
- note_tempo -= tempo_change;
- }
+ if (note_tempo - tempo_change < 10) {
+ note_tempo = 10;
+ } else {
+ note_tempo -= tempo_change;
+ }
}
diff --git a/quantum/audio/audio_pwm.c b/quantum/audio/audio_pwm.c
index ed67136099..545aef6dd7 100644
--- a/quantum/audio/audio_pwm.c
+++ b/quantum/audio/audio_pwm.c
@@ -29,7 +29,6 @@
#define CPU_PRESCALER 8
-
// Timer Abstractions
// TIMSK3 - Timer/Counter #3 Interrupt Mask Register
@@ -37,70 +36,67 @@
#define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A)
#define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A)
-
// TCCR3A: Timer/Counter #3 Control Register
// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
#define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1);
#define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0));
-
#define NOTE_PERIOD ICR3
#define NOTE_DUTY_CYCLE OCR3A
-
#ifdef PWM_AUDIO
- #include "wave.h"
- #define SAMPLE_DIVIDER 39
- #define SAMPLE_RATE (2000000.0/SAMPLE_DIVIDER/2048)
- // Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap
-
- float places[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- uint16_t place_int = 0;
- bool repeat = true;
+# include "wave.h"
+# define SAMPLE_DIVIDER 39
+# define SAMPLE_RATE (2000000.0 / SAMPLE_DIVIDER / 2048)
+// Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap
+
+float places[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+uint16_t place_int = 0;
+bool repeat = true;
#endif
void delay_us(int count) {
- while(count--) {
- _delay_us(1);
- }
+ while (count--) {
+ _delay_us(1);
+ }
}
-int voices = 0;
-int voice_place = 0;
-float frequency = 0;
-int volume = 0;
-long position = 0;
+int voices = 0;
+int voice_place = 0;
+float frequency = 0;
+int volume = 0;
+long position = 0;
float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-bool sliding = false;
+int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+bool sliding = false;
float place = 0;
-uint8_t * sample;
+uint8_t* sample;
uint16_t sample_length = 0;
// float freq = 0;
-bool playing_notes = false;
-bool playing_note = false;
+bool playing_notes = false;
+bool playing_note = false;
float note_frequency = 0;
-float note_length = 0;
-uint8_t note_tempo = TEMPO_DEFAULT;
-float note_timbre = TIMBRE_DEFAULT;
-uint16_t note_position = 0;
-float (* notes_pointer)[][2];
+float note_length = 0;
+uint8_t note_tempo = TEMPO_DEFAULT;
+float note_timbre = TIMBRE_DEFAULT;
+uint16_t note_position = 0;
+float (*notes_pointer)[][2];
uint16_t notes_count;
bool notes_repeat;
float notes_rest;
bool note_resting = false;
uint16_t current_note = 0;
-uint8_t rest_counter = 0;
+uint8_t rest_counter = 0;
#ifdef VIBRATO_ENABLE
-float vibrato_counter = 0;
+float vibrato_counter = 0;
float vibrato_strength = .5;
-float vibrato_rate = 0.125;
+float vibrato_rate = 0.125;
#endif
float polyphony_rate = 0;
@@ -112,50 +108,49 @@ audio_config_t audio_config;
uint16_t envelope_index = 0;
void audio_init() {
-
// Check EEPROM
- if (!eeconfig_is_enabled())
- {
+ if (!eeconfig_is_enabled()) {
eeconfig_init();
}
audio_config.raw = eeconfig_read_audio();
- #ifdef PWM_AUDIO
+#ifdef PWM_AUDIO
- PLLFRQ = _BV(PDIV2);
- PLLCSR = _BV(PLLE);
- while(!(PLLCSR & _BV(PLOCK)));
- PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */
+ PLLFRQ = _BV(PDIV2);
+ PLLCSR = _BV(PLLE);
+ while (!(PLLCSR & _BV(PLOCK)))
+ ;
+ PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */
- /* Init a fast PWM on Timer4 */
- TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */
- TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */
- OCR4A = 0;
+ /* Init a fast PWM on Timer4 */
+ TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */
+ TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */
+ OCR4A = 0;
- /* Enable the OC4A output */
- DDRC |= _BV(PORTC6);
+ /* Enable the OC4A output */
+ DDRC |= _BV(PORTC6);
- DISABLE_AUDIO_COUNTER_3_ISR; // Turn off 3A interputs
+ DISABLE_AUDIO_COUNTER_3_ISR; // Turn off 3A interputs
- TCCR3A = 0x0; // Options not needed
- TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC
- OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback
+ TCCR3A = 0x0; // Options not needed
+ TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC
+ OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback
- #else
+#else
- // Set port PC6 (OC3A and /OC4A) as output
- DDRC |= _BV(PORTC6);
+ // Set port PC6 (OC3A and /OC4A) as output
+ DDRC |= _BV(PORTC6);
- DISABLE_AUDIO_COUNTER_3_ISR;
+ DISABLE_AUDIO_COUNTER_3_ISR;
- // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
- // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
- // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A)
- // Clock Select (CS3n) = 0b010 = Clock / 8
- TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
- TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
+ // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
+ // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
+ // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A)
+ // Clock Select (CS3n) = 0b010 = Clock / 8
+ TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
+ TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
- #endif
+#endif
audio_initialized = true;
}
@@ -165,62 +160,59 @@ void stop_all_notes() {
audio_init();
}
voices = 0;
- #ifdef PWM_AUDIO
- DISABLE_AUDIO_COUNTER_3_ISR;
- #else
- DISABLE_AUDIO_COUNTER_3_ISR;
- DISABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
+#ifdef PWM_AUDIO
+ DISABLE_AUDIO_COUNTER_3_ISR;
+#else
+ DISABLE_AUDIO_COUNTER_3_ISR;
+ DISABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
playing_notes = false;
- playing_note = false;
- frequency = 0;
- volume = 0;
+ playing_note = false;
+ frequency = 0;
+ volume = 0;
- for (uint8_t i = 0; i < 8; i++)
- {
+ for (uint8_t i = 0; i < 8; i++) {
frequencies[i] = 0;
- volumes[i] = 0;
+ volumes[i] = 0;
}
}
-void stop_note(float freq)
-{
+void stop_note(float freq) {
if (playing_note) {
if (!audio_initialized) {
audio_init();
}
- #ifdef PWM_AUDIO
- freq = freq / SAMPLE_RATE;
- #endif
+#ifdef PWM_AUDIO
+ freq = freq / SAMPLE_RATE;
+#endif
for (int i = 7; i >= 0; i--) {
if (frequencies[i] == freq) {
frequencies[i] = 0;
- volumes[i] = 0;
+ volumes[i] = 0;
for (int j = i; (j < 7); j++) {
- frequencies[j] = frequencies[j+1];
- frequencies[j+1] = 0;
- volumes[j] = volumes[j+1];
- volumes[j+1] = 0;
+ frequencies[j] = frequencies[j + 1];
+ frequencies[j + 1] = 0;
+ volumes[j] = volumes[j + 1];
+ volumes[j + 1] = 0;
}
break;
}
}
voices--;
- if (voices < 0)
- voices = 0;
+ if (voices < 0) voices = 0;
if (voice_place >= voices) {
voice_place = 0;
}
if (voices == 0) {
- #ifdef PWM_AUDIO
- DISABLE_AUDIO_COUNTER_3_ISR;
- #else
- DISABLE_AUDIO_COUNTER_3_ISR;
- DISABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
- frequency = 0;
- volume = 0;
+#ifdef PWM_AUDIO
+ DISABLE_AUDIO_COUNTER_3_ISR;
+#else
+ DISABLE_AUDIO_COUNTER_3_ISR;
+ DISABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
+ frequency = 0;
+ volume = 0;
playing_note = false;
}
}
@@ -228,126 +220,120 @@ void stop_note(float freq)
#ifdef VIBRATO_ENABLE
-float mod(float a, int b)
-{
+float mod(float a, int b) {
float r = fmod(a, b);
return r < 0 ? r + b : r;
}
float vibrato(float average_freq) {
- #ifdef VIBRATO_STRENGTH_ENABLE
- float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength);
- #else
- float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter];
- #endif
- vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH);
+# ifdef VIBRATO_STRENGTH_ENABLE
+ float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength);
+# else
+ float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter];
+# endif
+ vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0 / average_freq)), VIBRATO_LUT_LENGTH);
return vibrated_freq;
}
#endif
-ISR(TIMER3_COMPA_vect)
-{
+ISR(TIMER3_COMPA_vect) {
if (playing_note) {
- #ifdef PWM_AUDIO
- if (voices == 1) {
+#ifdef PWM_AUDIO
+ if (voices == 1) {
+ // SINE
+ OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2;
+
+ // SQUARE
+ // if (((int)place) >= 1024){
+ // OCR4A = 0xFF >> 2;
+ // } else {
+ // OCR4A = 0x00;
+ // }
+
+ // SAWTOOTH
+ // OCR4A = (int)place / 4;
+
+ // TRIANGLE
+ // if (((int)place) >= 1024) {
+ // OCR4A = (int)place / 2;
+ // } else {
+ // OCR4A = 2048 - (int)place / 2;
+ // }
+
+ place += frequency;
+
+ if (place >= SINE_LENGTH) place -= SINE_LENGTH;
+
+ } else {
+ int sum = 0;
+ for (int i = 0; i < voices; i++) {
// SINE
- OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2;
+ sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2;
// SQUARE
- // if (((int)place) >= 1024){
- // OCR4A = 0xFF >> 2;
+ // if (((int)places[i]) >= 1024){
+ // sum += 0xFF >> 2;
// } else {
- // OCR4A = 0x00;
+ // sum += 0x00;
// }
- // SAWTOOTH
- // OCR4A = (int)place / 4;
-
- // TRIANGLE
- // if (((int)place) >= 1024) {
- // OCR4A = (int)place / 2;
- // } else {
- // OCR4A = 2048 - (int)place / 2;
- // }
+ places[i] += frequencies[i];
- place += frequency;
-
- if (place >= SINE_LENGTH)
- place -= SINE_LENGTH;
-
- } else {
- int sum = 0;
- for (int i = 0; i < voices; i++) {
- // SINE
- sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2;
-
- // SQUARE
- // if (((int)places[i]) >= 1024){
- // sum += 0xFF >> 2;
- // } else {
- // sum += 0x00;
- // }
-
- places[i] += frequencies[i];
-
- if (places[i] >= SINE_LENGTH)
- places[i] -= SINE_LENGTH;
- }
- OCR4A = sum;
+ if (places[i] >= SINE_LENGTH) places[i] -= SINE_LENGTH;
}
- #else
- if (voices > 0) {
- float freq;
- if (polyphony_rate > 0) {
- if (voices > 1) {
- voice_place %= voices;
- if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) {
- voice_place = (voice_place + 1) % voices;
- place = 0.0;
- }
- }
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequencies[voice_place]);
- } else {
- #else
- {
- #endif
- freq = frequencies[voice_place];
+ OCR4A = sum;
+ }
+#else
+ if (voices > 0) {
+ float freq;
+ if (polyphony_rate > 0) {
+ if (voices > 1) {
+ voice_place %= voices;
+ if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) {
+ voice_place = (voice_place + 1) % voices;
+ place = 0.0;
}
+ }
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequencies[voice_place]);
} else {
- if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, 440/frequency/12/2);
- } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
- frequency = frequency * pow(2, -440/frequency/12/2);
- } else {
- frequency = frequencies[voices - 1];
- }
-
-
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(frequency);
- } else {
- #else
- {
- #endif
- freq = frequency;
- }
+# else
+ {
+# endif
+ freq = frequencies[voice_place];
+ }
+ } else {
+ if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, 440 / frequency / 12 / 2);
+ } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440 / frequencies[voices - 1] / 12 / 2)) {
+ frequency = frequency * pow(2, -440 / frequency / 12 / 2);
+ } else {
+ frequency = frequencies[voices - 1];
}
- if (envelope_index < 65535) {
- envelope_index++;
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(frequency);
+ } else {
+# else
+ {
+# endif
+ freq = frequency;
}
- freq = voice_envelope(freq);
+ }
- if (freq < 30.517578125)
- freq = 30.52;
- NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
- NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
+ if (envelope_index < 65535) {
+ envelope_index++;
}
- #endif
+ freq = voice_envelope(freq);
+
+ if (freq < 30.517578125) freq = 30.52;
+ NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
+ NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
+ }
+#endif
}
// SAMPLE
@@ -361,41 +347,38 @@ ISR(TIMER3_COMPA_vect)
// else
// DISABLE_AUDIO_COUNTER_3_ISR;
-
if (playing_notes) {
- #ifdef PWM_AUDIO
- OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0;
-
- place += note_frequency;
- if (place >= SINE_LENGTH)
- place -= SINE_LENGTH;
- #else
- if (note_frequency > 0) {
- float freq;
-
- #ifdef VIBRATO_ENABLE
- if (vibrato_strength > 0) {
- freq = vibrato(note_frequency);
- } else {
- #else
- {
- #endif
- freq = note_frequency;
- }
+#ifdef PWM_AUDIO
+ OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0;
- if (envelope_index < 65535) {
- envelope_index++;
- }
- freq = voice_envelope(freq);
+ place += note_frequency;
+ if (place >= SINE_LENGTH) place -= SINE_LENGTH;
+#else
+ if (note_frequency > 0) {
+ float freq;
- NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
- NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
+# ifdef VIBRATO_ENABLE
+ if (vibrato_strength > 0) {
+ freq = vibrato(note_frequency);
} else {
- NOTE_PERIOD = 0;
- NOTE_DUTY_CYCLE = 0;
+# else
+ {
+# endif
+ freq = note_frequency;
}
- #endif
+ if (envelope_index < 65535) {
+ envelope_index++;
+ }
+ freq = voice_envelope(freq);
+
+ NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period
+ NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period
+ } else {
+ NOTE_PERIOD = 0;
+ NOTE_DUTY_CYCLE = 0;
+ }
+#endif
note_position++;
bool end_of_note = false;
@@ -409,126 +392,116 @@ ISR(TIMER3_COMPA_vect)
if (notes_repeat) {
current_note = 0;
} else {
- #ifdef PWM_AUDIO
- DISABLE_AUDIO_COUNTER_3_ISR;
- #else
- DISABLE_AUDIO_COUNTER_3_ISR;
- DISABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
+#ifdef PWM_AUDIO
+ DISABLE_AUDIO_COUNTER_3_ISR;
+#else
+ DISABLE_AUDIO_COUNTER_3_ISR;
+ DISABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
playing_notes = false;
return;
}
}
if (!note_resting && (notes_rest > 0)) {
- note_resting = true;
+ note_resting = true;
note_frequency = 0;
- note_length = notes_rest;
+ note_length = notes_rest;
current_note--;
} else {
note_resting = false;
- #ifdef PWM_AUDIO
- note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
- note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100);
- #else
- envelope_index = 0;
- note_frequency = (*notes_pointer)[current_note][0];
- note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
- #endif
+#ifdef PWM_AUDIO
+ note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
+ note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100);
+#else
+ envelope_index = 0;
+ note_frequency = (*notes_pointer)[current_note][0];
+ note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
+#endif
}
note_position = 0;
}
-
}
if (!audio_config.enable) {
playing_notes = false;
- playing_note = false;
+ playing_note = false;
}
}
void play_note(float freq, int vol) {
-
if (!audio_initialized) {
audio_init();
}
- if (audio_config.enable && voices < 8) {
- DISABLE_AUDIO_COUNTER_3_ISR;
-
- // Cancel notes if notes are playing
- if (playing_notes)
- stop_all_notes();
+ if (audio_config.enable && voices < 8) {
+ DISABLE_AUDIO_COUNTER_3_ISR;
- playing_note = true;
+ // Cancel notes if notes are playing
+ if (playing_notes) stop_all_notes();
- envelope_index = 0;
+ playing_note = true;
- #ifdef PWM_AUDIO
- freq = freq / SAMPLE_RATE;
- #endif
- if (freq > 0) {
- frequencies[voices] = freq;
- volumes[voices] = vol;
- voices++;
- }
+ envelope_index = 0;
- #ifdef PWM_AUDIO
- ENABLE_AUDIO_COUNTER_3_ISR;
- #else
- ENABLE_AUDIO_COUNTER_3_ISR;
- ENABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
- }
+#ifdef PWM_AUDIO
+ freq = freq / SAMPLE_RATE;
+#endif
+ if (freq > 0) {
+ frequencies[voices] = freq;
+ volumes[voices] = vol;
+ voices++;
+ }
+#ifdef PWM_AUDIO
+ ENABLE_AUDIO_COUNTER_3_ISR;
+#else
+ ENABLE_AUDIO_COUNTER_3_ISR;
+ ENABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
+ }
}
-void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest)
-{
-
+void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) {
if (!audio_initialized) {
audio_init();
}
- if (audio_config.enable) {
-
- DISABLE_AUDIO_COUNTER_3_ISR;
-
- // Cancel note if a note is playing
- if (playing_note)
- stop_all_notes();
-
- playing_notes = true;
+ if (audio_config.enable) {
+ DISABLE_AUDIO_COUNTER_3_ISR;
- notes_pointer = np;
- notes_count = n_count;
- notes_repeat = n_repeat;
- notes_rest = n_rest;
+ // Cancel note if a note is playing
+ if (playing_note) stop_all_notes();
- place = 0;
- current_note = 0;
+ playing_notes = true;
- #ifdef PWM_AUDIO
- note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
- note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100);
- #else
- note_frequency = (*notes_pointer)[current_note][0];
- note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
- #endif
- note_position = 0;
+ notes_pointer = np;
+ notes_count = n_count;
+ notes_repeat = n_repeat;
+ notes_rest = n_rest;
+ place = 0;
+ current_note = 0;
- #ifdef PWM_AUDIO
- ENABLE_AUDIO_COUNTER_3_ISR;
- #else
- ENABLE_AUDIO_COUNTER_3_ISR;
- ENABLE_AUDIO_COUNTER_3_OUTPUT;
- #endif
- }
+#ifdef PWM_AUDIO
+ note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE;
+ note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100);
+#else
+ note_frequency = (*notes_pointer)[current_note][0];
+ note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
+#endif
+ note_position = 0;
+#ifdef PWM_AUDIO
+ ENABLE_AUDIO_COUNTER_3_ISR;
+#else
+ ENABLE_AUDIO_COUNTER_3_ISR;
+ ENABLE_AUDIO_COUNTER_3_OUTPUT;
+#endif
+ }
}
#ifdef PWM_AUDIO
-void play_sample(uint8_t * s, uint16_t l, bool r) {
+void play_sample(uint8_t* s, uint16_t l, bool r) {
if (!audio_initialized) {
audio_init();
}
@@ -536,17 +509,16 @@ void play_sample(uint8_t * s, uint16_t l, bool r) {
if (audio_config.enable) {
DISABLE_AUDIO_COUNTER_3_ISR;
stop_all_notes();
- place_int = 0;
- sample = s;
+ place_int = 0;
+ sample = s;
sample_length = l;
- repeat = r;
+ repeat = r;
ENABLE_AUDIO_COUNTER_3_ISR;
}
}
#endif
-
void audio_toggle(void) {
audio_config.enable ^= 1;
eeconfig_update_audio(audio_config.raw);
@@ -566,73 +538,45 @@ void audio_off(void) {
// Vibrato rate functions
-void set_vibrato_rate(float rate) {
- vibrato_rate = rate;
-}
+void set_vibrato_rate(float rate) { vibrato_rate = rate; }
-void increase_vibrato_rate(float change) {
- vibrato_rate *= change;
-}
+void increase_vibrato_rate(float change) { vibrato_rate *= change; }
-void decrease_vibrato_rate(float change) {
- vibrato_rate /= change;
-}
+void decrease_vibrato_rate(float change) { vibrato_rate /= change; }
-#ifdef VIBRATO_STRENGTH_ENABLE
+# ifdef VIBRATO_STRENGTH_ENABLE
-void set_vibrato_strength(float strength) {
- vibrato_strength = strength;
-}
+void set_vibrato_strength(float strength) { vibrato_strength = strength; }
-void increase_vibrato_strength(float change) {
- vibrato_strength *= change;
-}
+void increase_vibrato_strength(float change) { vibrato_strength *= change; }
-void decrease_vibrato_strength(float change) {
- vibrato_strength /= change;
-}
+void decrease_vibrato_strength(float change) { vibrato_strength /= change; }
-#endif /* VIBRATO_STRENGTH_ENABLE */
+# endif /* VIBRATO_STRENGTH_ENABLE */
#endif /* VIBRATO_ENABLE */
// Polyphony functions
-void set_polyphony_rate(float rate) {
- polyphony_rate = rate;
-}
+void set_polyphony_rate(float rate) { polyphony_rate = rate; }
-void enable_polyphony() {
- polyphony_rate = 5;
-}
+void enable_polyphony() { polyphony_rate = 5; }
-void disable_polyphony() {
- polyphony_rate = 0;
-}
+void disable_polyphony() { polyphony_rate = 0; }
-void increase_polyphony_rate(float change) {
- polyphony_rate *= change;
-}
+void increase_polyphony_rate(float change) { polyphony_rate *= change; }
-void decrease_polyphony_rate(float change) {
- polyphony_rate /= change;
-}
+void decrease_polyphony_rate(float change) { polyphony_rate /= change; }
// Timbre function
-void set_timbre(float timbre) {
- note_timbre = timbre;
-}
+void set_timbre(float timbre) { note_timbre = timbre; }
// Tempo functions
-void set_tempo(uint8_t tempo) {
- note_tempo = tempo;
-}
+void set_tempo(uint8_t tempo) { note_tempo = tempo; }
-void decrease_tempo(uint8_t tempo_change) {
- note_tempo += tempo_change;
-}
+void decrease_tempo(uint8_t tempo_change) { note_tempo += tempo_change; }
void increase_tempo(uint8_t tempo_change) {
if (note_tempo - tempo_change < 10) {
@@ -642,17 +586,10 @@ void increase_tempo(uint8_t tempo_change) {
}
}
-
//------------------------------------------------------------------------------
// Override these functions in your keymap file to play different tunes on
// startup and bootloader jump
-__attribute__ ((weak))
-void play_startup_tone()
-{
-}
+__attribute__((weak)) void play_startup_tone() {}
-__attribute__ ((weak))
-void play_goodbye_tone()
-{
-}
+__attribute__((weak)) void play_goodbye_tone() {}
//------------------------------------------------------------------------------
diff --git a/quantum/audio/luts.c b/quantum/audio/luts.c
index 4404aff434..e8f77a0f33 100644
--- a/quantum/audio/luts.c
+++ b/quantum/audio/luts.c
@@ -16,380 +16,12 @@
#include "luts.h"
-const float vibrato_lut[VIBRATO_LUT_LENGTH] =
-{
- 1.0022336811487,
- 1.0042529943610,
- 1.0058584256028,
- 1.0068905285205,
- 1.0072464122237,
- 1.0068905285205,
- 1.0058584256028,
- 1.0042529943610,
- 1.0022336811487,
- 1.0000000000000,
- 0.9977712970630,
- 0.9957650169978,
- 0.9941756956510,
- 0.9931566259436,
- 0.9928057204913,
- 0.9931566259436,
- 0.9941756956510,
- 0.9957650169978,
- 0.9977712970630,
- 1.0000000000000,
+const float vibrato_lut[VIBRATO_LUT_LENGTH] = {
+ 1.0022336811487, 1.0042529943610, 1.0058584256028, 1.0068905285205, 1.0072464122237, 1.0068905285205, 1.0058584256028, 1.0042529943610, 1.0022336811487, 1.0000000000000, 0.9977712970630, 0.9957650169978, 0.9941756956510, 0.9931566259436, 0.9928057204913, 0.9931566259436, 0.9941756956510, 0.9957650169978, 0.9977712970630, 1.0000000000000,
};
-const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH] =
-{
- 0x8E0B,
- 0x8C02,
- 0x8A00,
- 0x8805,
- 0x8612,
- 0x8426,
- 0x8241,
- 0x8063,
- 0x7E8C,
- 0x7CBB,
- 0x7AF2,
- 0x792E,
- 0x7772,
- 0x75BB,
- 0x740B,
- 0x7261,
- 0x70BD,
- 0x6F20,
- 0x6D88,
- 0x6BF6,
- 0x6A69,
- 0x68E3,
- 0x6762,
- 0x65E6,
- 0x6470,
- 0x6300,
- 0x6194,
- 0x602E,
- 0x5ECD,
- 0x5D71,
- 0x5C1A,
- 0x5AC8,
- 0x597B,
- 0x5833,
- 0x56EF,
- 0x55B0,
- 0x5475,
- 0x533F,
- 0x520E,
- 0x50E1,
- 0x4FB8,
- 0x4E93,
- 0x4D73,
- 0x4C57,
- 0x4B3E,
- 0x4A2A,
- 0x491A,
- 0x480E,
- 0x4705,
- 0x4601,
- 0x4500,
- 0x4402,
- 0x4309,
- 0x4213,
- 0x4120,
- 0x4031,
- 0x3F46,
- 0x3E5D,
- 0x3D79,
- 0x3C97,
- 0x3BB9,
- 0x3ADD,
- 0x3A05,
- 0x3930,
- 0x385E,
- 0x3790,
- 0x36C4,
- 0x35FB,
- 0x3534,
- 0x3471,
- 0x33B1,
- 0x32F3,
- 0x3238,
- 0x3180,
- 0x30CA,
- 0x3017,
- 0x2F66,
- 0x2EB8,
- 0x2E0D,
- 0x2D64,
- 0x2CBD,
- 0x2C19,
- 0x2B77,
- 0x2AD8,
- 0x2A3A,
- 0x299F,
- 0x2907,
- 0x2870,
- 0x27DC,
- 0x2749,
- 0x26B9,
- 0x262B,
- 0x259F,
- 0x2515,
- 0x248D,
- 0x2407,
- 0x2382,
- 0x2300,
- 0x2280,
- 0x2201,
- 0x2184,
- 0x2109,
- 0x2090,
- 0x2018,
- 0x1FA3,
- 0x1F2E,
- 0x1EBC,
- 0x1E4B,
- 0x1DDC,
- 0x1D6E,
- 0x1D02,
- 0x1C98,
- 0x1C2F,
- 0x1BC8,
- 0x1B62,
- 0x1AFD,
- 0x1A9A,
- 0x1A38,
- 0x19D8,
- 0x1979,
- 0x191C,
- 0x18C0,
- 0x1865,
- 0x180B,
- 0x17B3,
- 0x175C,
- 0x1706,
- 0x16B2,
- 0x165E,
- 0x160C,
- 0x15BB,
- 0x156C,
- 0x151D,
- 0x14CF,
- 0x1483,
- 0x1438,
- 0x13EE,
- 0x13A4,
- 0x135C,
- 0x1315,
- 0x12CF,
- 0x128A,
- 0x1246,
- 0x1203,
- 0x11C1,
- 0x1180,
- 0x1140,
- 0x1100,
- 0x10C2,
- 0x1084,
- 0x1048,
- 0x100C,
- 0xFD1,
- 0xF97,
- 0xF5E,
- 0xF25,
- 0xEEE,
- 0xEB7,
- 0xE81,
- 0xE4C,
- 0xE17,
- 0xDE4,
- 0xDB1,
- 0xD7E,
- 0xD4D,
- 0xD1C,
- 0xCEC,
- 0xCBC,
- 0xC8E,
- 0xC60,
- 0xC32,
- 0xC05,
- 0xBD9,
- 0xBAE,
- 0xB83,
- 0xB59,
- 0xB2F,
- 0xB06,
- 0xADD,
- 0xAB6,
- 0xA8E,
- 0xA67,
- 0xA41,
- 0xA1C,
- 0x9F7,
- 0x9D2,
- 0x9AE,
- 0x98A,
- 0x967,
- 0x945,
- 0x923,
- 0x901,
- 0x8E0,
- 0x8C0,
- 0x8A0,
- 0x880,
- 0x861,
- 0x842,
- 0x824,
- 0x806,
- 0x7E8,
- 0x7CB,
- 0x7AF,
- 0x792,
- 0x777,
- 0x75B,
- 0x740,
- 0x726,
- 0x70B,
- 0x6F2,
- 0x6D8,
- 0x6BF,
- 0x6A6,
- 0x68E,
- 0x676,
- 0x65E,
- 0x647,
- 0x630,
- 0x619,
- 0x602,
- 0x5EC,
- 0x5D7,
- 0x5C1,
- 0x5AC,
- 0x597,
- 0x583,
- 0x56E,
- 0x55B,
- 0x547,
- 0x533,
- 0x520,
- 0x50E,
- 0x4FB,
- 0x4E9,
- 0x4D7,
- 0x4C5,
- 0x4B3,
- 0x4A2,
- 0x491,
- 0x480,
- 0x470,
- 0x460,
- 0x450,
- 0x440,
- 0x430,
- 0x421,
- 0x412,
- 0x403,
- 0x3F4,
- 0x3E5,
- 0x3D7,
- 0x3C9,
- 0x3BB,
- 0x3AD,
- 0x3A0,
- 0x393,
- 0x385,
- 0x379,
- 0x36C,
- 0x35F,
- 0x353,
- 0x347,
- 0x33B,
- 0x32F,
- 0x323,
- 0x318,
- 0x30C,
- 0x301,
- 0x2F6,
- 0x2EB,
- 0x2E0,
- 0x2D6,
- 0x2CB,
- 0x2C1,
- 0x2B7,
- 0x2AD,
- 0x2A3,
- 0x299,
- 0x290,
- 0x287,
- 0x27D,
- 0x274,
- 0x26B,
- 0x262,
- 0x259,
- 0x251,
- 0x248,
- 0x240,
- 0x238,
- 0x230,
- 0x228,
- 0x220,
- 0x218,
- 0x210,
- 0x209,
- 0x201,
- 0x1FA,
- 0x1F2,
- 0x1EB,
- 0x1E4,
- 0x1DD,
- 0x1D6,
- 0x1D0,
- 0x1C9,
- 0x1C2,
- 0x1BC,
- 0x1B6,
- 0x1AF,
- 0x1A9,
- 0x1A3,
- 0x19D,
- 0x197,
- 0x191,
- 0x18C,
- 0x186,
- 0x180,
- 0x17B,
- 0x175,
- 0x170,
- 0x16B,
- 0x165,
- 0x160,
- 0x15B,
- 0x156,
- 0x151,
- 0x14C,
- 0x148,
- 0x143,
- 0x13E,
- 0x13A,
- 0x135,
- 0x131,
- 0x12C,
- 0x128,
- 0x124,
- 0x120,
- 0x11C,
- 0x118,
- 0x114,
- 0x110,
- 0x10C,
- 0x108,
- 0x104,
- 0x100,
- 0xFD,
- 0xF9,
- 0xF5,
- 0xF2,
- 0xEE,
+const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH] = {
+ 0x8E0B, 0x8C02, 0x8A00, 0x8805, 0x8612, 0x8426, 0x8241, 0x8063, 0x7E8C, 0x7CBB, 0x7AF2, 0x792E, 0x7772, 0x75BB, 0x740B, 0x7261, 0x70BD, 0x6F20, 0x6D88, 0x6BF6, 0x6A69, 0x68E3, 0x6762, 0x65E6, 0x6470, 0x6300, 0x6194, 0x602E, 0x5ECD, 0x5D71, 0x5C1A, 0x5AC8, 0x597B, 0x5833, 0x56EF, 0x55B0, 0x5475, 0x533F, 0x520E, 0x50E1, 0x4FB8, 0x4E93, 0x4D73, 0x4C57, 0x4B3E, 0x4A2A, 0x491A, 0x480E, 0x4705, 0x4601, 0x4500, 0x4402, 0x4309, 0x4213, 0x4120, 0x4031, 0x3F46, 0x3E5D, 0x3D79, 0x3C97, 0x3BB9, 0x3ADD, 0x3A05, 0x3930, 0x385E, 0x3790, 0x36C4, 0x35FB, 0x3534, 0x3471, 0x33B1, 0x32F3, 0x3238, 0x3180, 0x30CA, 0x3017, 0x2F66, 0x2EB8, 0x2E0D, 0x2D64, 0x2CBD, 0x2C19, 0x2B77, 0x2AD8, 0x2A3A, 0x299F, 0x2907, 0x2870, 0x27DC, 0x2749, 0x26B9, 0x262B, 0x259F, 0x2515, 0x248D, 0x2407, 0x2382, 0x2300, 0x2280, 0x2201, 0x2184, 0x2109, 0x2090, 0x2018, 0x1FA3, 0x1F2E, 0x1EBC, 0x1E4B, 0x1DDC, 0x1D6E, 0x1D02, 0x1C98, 0x1C2F, 0x1BC8, 0x1B62, 0x1AFD, 0x1A9A,
+ 0x1A38, 0x19D8, 0x1979, 0x191C, 0x18C0, 0x1865, 0x180B, 0x17B3, 0x175C, 0x1706, 0x16B2, 0x165E, 0x160C, 0x15BB, 0x156C, 0x151D, 0x14CF, 0x1483, 0x1438, 0x13EE, 0x13A4, 0x135C, 0x1315, 0x12CF, 0x128A, 0x1246, 0x1203, 0x11C1, 0x1180, 0x1140, 0x1100, 0x10C2, 0x1084, 0x1048, 0x100C, 0xFD1, 0xF97, 0xF5E, 0xF25, 0xEEE, 0xEB7, 0xE81, 0xE4C, 0xE17, 0xDE4, 0xDB1, 0xD7E, 0xD4D, 0xD1C, 0xCEC, 0xCBC, 0xC8E, 0xC60, 0xC32, 0xC05, 0xBD9, 0xBAE, 0xB83, 0xB59, 0xB2F, 0xB06, 0xADD, 0xAB6, 0xA8E, 0xA67, 0xA41, 0xA1C, 0x9F7, 0x9D2, 0x9AE, 0x98A, 0x967, 0x945, 0x923, 0x901, 0x8E0, 0x8C0, 0x8A0, 0x880, 0x861, 0x842, 0x824, 0x806, 0x7E8, 0x7CB, 0x7AF, 0x792, 0x777, 0x75B, 0x740, 0x726, 0x70B, 0x6F2, 0x6D8, 0x6BF, 0x6A6, 0x68E, 0x676, 0x65E, 0x647, 0x630, 0x619, 0x602, 0x5EC, 0x5D7, 0x5C1, 0x5AC, 0x597, 0x583, 0x56E, 0x55B, 0x547, 0x533, 0x520, 0x50E, 0x4FB, 0x4E9,
+ 0x4D7, 0x4C5, 0x4B3, 0x4A2, 0x491, 0x480, 0x470, 0x460, 0x450, 0x440, 0x430, 0x421, 0x412, 0x403, 0x3F4, 0x3E5, 0x3D7, 0x3C9, 0x3BB, 0x3AD, 0x3A0, 0x393, 0x385, 0x379, 0x36C, 0x35F, 0x353, 0x347, 0x33B, 0x32F, 0x323, 0x318, 0x30C, 0x301, 0x2F6, 0x2EB, 0x2E0, 0x2D6, 0x2CB, 0x2C1, 0x2B7, 0x2AD, 0x2A3, 0x299, 0x290, 0x287, 0x27D, 0x274, 0x26B, 0x262, 0x259, 0x251, 0x248, 0x240, 0x238, 0x230, 0x228, 0x220, 0x218, 0x210, 0x209, 0x201, 0x1FA, 0x1F2, 0x1EB, 0x1E4, 0x1DD, 0x1D6, 0x1D0, 0x1C9, 0x1C2, 0x1BC, 0x1B6, 0x1AF, 0x1A9, 0x1A3, 0x19D, 0x197, 0x191, 0x18C, 0x186, 0x180, 0x17B, 0x175, 0x170, 0x16B, 0x165, 0x160, 0x15B, 0x156, 0x151, 0x14C, 0x148, 0x143, 0x13E, 0x13A, 0x135, 0x131, 0x12C, 0x128, 0x124, 0x120, 0x11C, 0x118, 0x114, 0x110, 0x10C, 0x108, 0x104, 0x100, 0xFD, 0xF9, 0xF5, 0xF2, 0xEE,
};
-
diff --git a/quantum/audio/luts.h b/quantum/audio/luts.h
index a377a6c870..117d74cd00 100644
--- a/quantum/audio/luts.h
+++ b/quantum/audio/luts.h
@@ -15,22 +15,22 @@
*/
#if defined(__AVR__)
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <avr/pgmspace.h>
+# include <avr/io.h>
+# include <avr/interrupt.h>
+# include <avr/pgmspace.h>
#else
- #include "ch.h"
- #include "hal.h"
+# include "ch.h"
+# include "hal.h"
#endif
#ifndef LUTS_H
-#define LUTS_H
+# define LUTS_H
-#define VIBRATO_LUT_LENGTH 20
+# define VIBRATO_LUT_LENGTH 20
-#define FREQUENCY_LUT_LENGTH 349
+# define FREQUENCY_LUT_LENGTH 349
-extern const float vibrato_lut[VIBRATO_LUT_LENGTH];
+extern const float vibrato_lut[VIBRATO_LUT_LENGTH];
extern const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH];
#endif /* LUTS_H */
diff --git a/quantum/audio/muse.c b/quantum/audio/muse.c
index f3cb592d81..01b95671fd 100644
--- a/quantum/audio/muse.c
+++ b/quantum/audio/muse.c
@@ -1,111 +1,56 @@
#include "muse.h"
-enum {
- MUSE_OFF,
- MUSE_ON,
- MUSE_C_1_2,
- MUSE_C1,
- MUSE_C2,
- MUSE_C4,
- MUSE_C8,
- MUSE_C3,
- MUSE_C6,
- MUSE_B1,
- MUSE_B2,
- MUSE_B3,
- MUSE_B4,
- MUSE_B5,
- MUSE_B6,
- MUSE_B7,
- MUSE_B8,
- MUSE_B9,
- MUSE_B10,
- MUSE_B11,
- MUSE_B12,
- MUSE_B13,
- MUSE_B14,
- MUSE_B15,
- MUSE_B16,
- MUSE_B17,
- MUSE_B18,
- MUSE_B19,
- MUSE_B20,
- MUSE_B21,
- MUSE_B22,
- MUSE_B23,
- MUSE_B24,
- MUSE_B25,
- MUSE_B26,
- MUSE_B27,
- MUSE_B28,
- MUSE_B29,
- MUSE_B30,
- MUSE_B31
-};
+enum { MUSE_OFF, MUSE_ON, MUSE_C_1_2, MUSE_C1, MUSE_C2, MUSE_C4, MUSE_C8, MUSE_C3, MUSE_C6, MUSE_B1, MUSE_B2, MUSE_B3, MUSE_B4, MUSE_B5, MUSE_B6, MUSE_B7, MUSE_B8, MUSE_B9, MUSE_B10, MUSE_B11, MUSE_B12, MUSE_B13, MUSE_B14, MUSE_B15, MUSE_B16, MUSE_B17, MUSE_B18, MUSE_B19, MUSE_B20, MUSE_B21, MUSE_B22, MUSE_B23, MUSE_B24, MUSE_B25, MUSE_B26, MUSE_B27, MUSE_B28, MUSE_B29, MUSE_B30, MUSE_B31 };
-bool number_of_ones_to_bool[16] = {
- 1, 0, 0, 1, 0, 1, 1, 0,
- 0, 1, 1, 0, 1, 0, 0, 1
-};
+bool number_of_ones_to_bool[16] = {1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1};
-uint8_t muse_interval[4] = {MUSE_B7, MUSE_B19, MUSE_B3, MUSE_B28};
+uint8_t muse_interval[4] = {MUSE_B7, MUSE_B19, MUSE_B3, MUSE_B28};
uint8_t muse_theme[4] = {MUSE_B8, MUSE_B23, MUSE_B18, MUSE_B17};
-bool muse_timer_1bit = 0;
-uint8_t muse_timer_2bit = 0;
-uint8_t muse_timer_2bit_counter = 0;
-uint8_t muse_timer_4bit = 0;
-uint32_t muse_timer_31bit = 0;
+bool muse_timer_1bit = 0;
+uint8_t muse_timer_2bit = 0;
+uint8_t muse_timer_2bit_counter = 0;
+uint8_t muse_timer_4bit = 0;
+uint32_t muse_timer_31bit = 0;
bool bit_for_value(uint8_t value) {
- switch (value) {
- case MUSE_OFF:
- return 0;
- case MUSE_ON:
- return 1;
- case MUSE_C_1_2:
- return muse_timer_1bit;
- case MUSE_C1:
- return (muse_timer_4bit & 1);
- case MUSE_C2:
- return (muse_timer_4bit & 2);
- case MUSE_C4:
- return (muse_timer_4bit & 4);
- case MUSE_C8:
- return (muse_timer_4bit & 8);
- case MUSE_C3:
- return (muse_timer_2bit & 1);
- case MUSE_C6:
- return (muse_timer_2bit & 2);
- default:
- return muse_timer_31bit & (1UL << (value - MUSE_B1));
- }
+ switch (value) {
+ case MUSE_OFF:
+ return 0;
+ case MUSE_ON:
+ return 1;
+ case MUSE_C_1_2:
+ return muse_timer_1bit;
+ case MUSE_C1:
+ return (muse_timer_4bit & 1);
+ case MUSE_C2:
+ return (muse_timer_4bit & 2);
+ case MUSE_C4:
+ return (muse_timer_4bit & 4);
+ case MUSE_C8:
+ return (muse_timer_4bit & 8);
+ case MUSE_C3:
+ return (muse_timer_2bit & 1);
+ case MUSE_C6:
+ return (muse_timer_2bit & 2);
+ default:
+ return muse_timer_31bit & (1UL << (value - MUSE_B1));
+ }
}
uint8_t muse_clock_pulse(void) {
-
- bool top = number_of_ones_to_bool[
- bit_for_value(muse_theme[0]) +
- (bit_for_value(muse_theme[1]) << 1) +
- (bit_for_value(muse_theme[2]) << 2) +
- (bit_for_value(muse_theme[3]) << 3)
- ];
-
- if (muse_timer_1bit == 0) {
- if (muse_timer_2bit_counter == 0) {
- muse_timer_2bit = (muse_timer_2bit + 1) % 4;
+ bool top = number_of_ones_to_bool[bit_for_value(muse_theme[0]) + (bit_for_value(muse_theme[1]) << 1) + (bit_for_value(muse_theme[2]) << 2) + (bit_for_value(muse_theme[3]) << 3)];
+
+ if (muse_timer_1bit == 0) {
+ if (muse_timer_2bit_counter == 0) {
+ muse_timer_2bit = (muse_timer_2bit + 1) % 4;
+ }
+ muse_timer_2bit_counter = (muse_timer_2bit_counter + 1) % 3;
+ muse_timer_4bit = (muse_timer_4bit + 1) % 16;
+ muse_timer_31bit = (muse_timer_31bit << 1) + top;
}
- muse_timer_2bit_counter = (muse_timer_2bit_counter + 1) % 3;
- muse_timer_4bit = (muse_timer_4bit + 1) % 16;
- muse_timer_31bit = (muse_timer_31bit << 1) + top;
- }
-
- muse_timer_1bit = (muse_timer_1bit + 1) % 2;
- return
- bit_for_value(muse_interval[0]) +
- (bit_for_value(muse_interval[1]) << 1) +
- (bit_for_value(muse_interval[2]) << 2) +
- (bit_for_value(muse_interval[3]) << 3);
+ muse_timer_1bit = (muse_timer_1bit + 1) % 2;
+ return bit_for_value(muse_interval[0]) + (bit_for_value(muse_interval[1]) << 1) + (bit_for_value(muse_interval[2]) << 2) + (bit_for_value(muse_interval[3]) << 3);
}
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h
index cd54af38d2..9742e19c43 100644
--- a/quantum/audio/musical_notes.h
+++ b/quantum/audio/musical_notes.h
@@ -20,55 +20,55 @@
// Tempo Placeholder
#define TEMPO_DEFAULT 100
-
-#define SONG(notes...) { notes }
-
+#define SONG(notes...) \
+ { notes }
// Note Types
-#define MUSICAL_NOTE(note, duration) {(NOTE##note), duration}
-#define BREVE_NOTE(note) MUSICAL_NOTE(note, 128)
-#define WHOLE_NOTE(note) MUSICAL_NOTE(note, 64)
-#define HALF_NOTE(note) MUSICAL_NOTE(note, 32)
-#define QUARTER_NOTE(note) MUSICAL_NOTE(note, 16)
-#define EIGHTH_NOTE(note) MUSICAL_NOTE(note, 8)
-#define SIXTEENTH_NOTE(note) MUSICAL_NOTE(note, 4)
-
-#define BREVE_DOT_NOTE(note) MUSICAL_NOTE(note, 128+64)
-#define WHOLE_DOT_NOTE(note) MUSICAL_NOTE(note, 64+32)
-#define HALF_DOT_NOTE(note) MUSICAL_NOTE(note, 32+16)
-#define QUARTER_DOT_NOTE(note) MUSICAL_NOTE(note, 16+8)
-#define EIGHTH_DOT_NOTE(note) MUSICAL_NOTE(note, 8+4)
-#define SIXTEENTH_DOT_NOTE(note) MUSICAL_NOTE(note, 4+2)
+#define MUSICAL_NOTE(note, duration) \
+ { (NOTE##note), duration }
+#define BREVE_NOTE(note) MUSICAL_NOTE(note, 128)
+#define WHOLE_NOTE(note) MUSICAL_NOTE(note, 64)
+#define HALF_NOTE(note) MUSICAL_NOTE(note, 32)
+#define QUARTER_NOTE(note) MUSICAL_NOTE(note, 16)
+#define EIGHTH_NOTE(note) MUSICAL_NOTE(note, 8)
+#define SIXTEENTH_NOTE(note) MUSICAL_NOTE(note, 4)
+
+#define BREVE_DOT_NOTE(note) MUSICAL_NOTE(note, 128 + 64)
+#define WHOLE_DOT_NOTE(note) MUSICAL_NOTE(note, 64 + 32)
+#define HALF_DOT_NOTE(note) MUSICAL_NOTE(note, 32 + 16)
+#define QUARTER_DOT_NOTE(note) MUSICAL_NOTE(note, 16 + 8)
+#define EIGHTH_DOT_NOTE(note) MUSICAL_NOTE(note, 8 + 4)
+#define SIXTEENTH_DOT_NOTE(note) MUSICAL_NOTE(note, 4 + 2)
// Note Type Shortcuts
-#define M__NOTE(note, duration) MUSICAL_NOTE(note, duration)
-#define B__NOTE(n) BREVE_NOTE(n)
-#define W__NOTE(n) WHOLE_NOTE(n)
-#define H__NOTE(n) HALF_NOTE(n)
-#define Q__NOTE(n) QUARTER_NOTE(n)
-#define E__NOTE(n) EIGHTH_NOTE(n)
-#define S__NOTE(n) SIXTEENTH_NOTE(n)
-#define BD_NOTE(n) BREVE_DOT_NOTE(n)
-#define WD_NOTE(n) WHOLE_DOT_NOTE(n)
-#define HD_NOTE(n) HALF_DOT_NOTE(n)
-#define QD_NOTE(n) QUARTER_DOT_NOTE(n)
-#define ED_NOTE(n) EIGHTH_DOT_NOTE(n)
-#define SD_NOTE(n) SIXTEENTH_DOT_NOTE(n)
+#define M__NOTE(note, duration) MUSICAL_NOTE(note, duration)
+#define B__NOTE(n) BREVE_NOTE(n)
+#define W__NOTE(n) WHOLE_NOTE(n)
+#define H__NOTE(n) HALF_NOTE(n)
+#define Q__NOTE(n) QUARTER_NOTE(n)
+#define E__NOTE(n) EIGHTH_NOTE(n)
+#define S__NOTE(n) SIXTEENTH_NOTE(n)
+#define BD_NOTE(n) BREVE_DOT_NOTE(n)
+#define WD_NOTE(n) WHOLE_DOT_NOTE(n)
+#define HD_NOTE(n) HALF_DOT_NOTE(n)
+#define QD_NOTE(n) QUARTER_DOT_NOTE(n)
+#define ED_NOTE(n) EIGHTH_DOT_NOTE(n)
+#define SD_NOTE(n) SIXTEENTH_DOT_NOTE(n)
// Note Timbre
// Changes how the notes sound
-#define TIMBRE_12 0.125f
-#define TIMBRE_25 0.250f
-#define TIMBRE_50 0.500f
-#define TIMBRE_75 0.750f
-#define TIMBRE_DEFAULT TIMBRE_50
+#define TIMBRE_12 0.125f
+#define TIMBRE_25 0.250f
+#define TIMBRE_50 0.500f
+#define TIMBRE_75 0.750f
+#define TIMBRE_DEFAULT TIMBRE_50
// Notes - # = Octave
#ifdef __arm__
-#define NOTE_REST 1.00f
+# define NOTE_REST 1.00f
#else
-#define NOTE_REST 0.00f
+# define NOTE_REST 0.00f
#endif
/* These notes are currently bugged
@@ -97,91 +97,91 @@
#define NOTE_AS1 58.27f
*/
-#define NOTE_B1 61.74f
-#define NOTE_C2 65.41f
-#define NOTE_CS2 69.30f
-#define NOTE_D2 73.42f
-#define NOTE_DS2 77.78f
-#define NOTE_E2 82.41f
-#define NOTE_F2 87.31f
-#define NOTE_FS2 92.50f
-#define NOTE_G2 98.00f
-#define NOTE_GS2 103.83f
-#define NOTE_A2 110.00f
-#define NOTE_AS2 116.54f
-#define NOTE_B2 123.47f
-#define NOTE_C3 130.81f
-#define NOTE_CS3 138.59f
-#define NOTE_D3 146.83f
-#define NOTE_DS3 155.56f
-#define NOTE_E3 164.81f
-#define NOTE_F3 174.61f
-#define NOTE_FS3 185.00f
-#define NOTE_G3 196.00f
-#define NOTE_GS3 207.65f
-#define NOTE_A3 220.00f
-#define NOTE_AS3 233.08f
-#define NOTE_B3 246.94f
-#define NOTE_C4 261.63f
-#define NOTE_CS4 277.18f
-#define NOTE_D4 293.66f
-#define NOTE_DS4 311.13f
-#define NOTE_E4 329.63f
-#define NOTE_F4 349.23f
-#define NOTE_FS4 369.99f
-#define NOTE_G4 392.00f
-#define NOTE_GS4 415.30f
-#define NOTE_A4 440.00f
-#define NOTE_AS4 466.16f
-#define NOTE_B4 493.88f
-#define NOTE_C5 523.25f
-#define NOTE_CS5 554.37f
-#define NOTE_D5 587.33f
-#define NOTE_DS5 622.25f
-#define NOTE_E5 659.26f
-#define NOTE_F5 698.46f
-#define NOTE_FS5 739.99f
-#define NOTE_G5 783.99f
-#define NOTE_GS5 830.61f
-#define NOTE_A5 880.00f
-#define NOTE_AS5 932.33f
-#define NOTE_B5 987.77f
-#define NOTE_C6 1046.50f
-#define NOTE_CS6 1108.73f
-#define NOTE_D6 1174.66f
-#define NOTE_DS6 1244.51f
-#define NOTE_E6 1318.51f
-#define NOTE_F6 1396.91f
-#define NOTE_FS6 1479.98f
-#define NOTE_G6 1567.98f
-#define NOTE_GS6 1661.22f
-#define NOTE_A6 1760.00f
-#define NOTE_AS6 1864.66f
-#define NOTE_B6 1975.53f
-#define NOTE_C7 2093.00f
-#define NOTE_CS7 2217.46f
-#define NOTE_D7 2349.32f
-#define NOTE_DS7 2489.02f
-#define NOTE_E7 2637.02f
-#define NOTE_F7 2793.83f
-#define NOTE_FS7 2959.96f
-#define NOTE_G7 3135.96f
-#define NOTE_GS7 3322.44f
-#define NOTE_A7 3520.00f
-#define NOTE_AS7 3729.31f
-#define NOTE_B7 3951.07f
-#define NOTE_C8 4186.01f
-#define NOTE_CS8 4434.92f
-#define NOTE_D8 4698.64f
-#define NOTE_DS8 4978.03f
-#define NOTE_E8 5274.04f
-#define NOTE_F8 5587.65f
-#define NOTE_FS8 5919.91f
-#define NOTE_G8 6271.93f
-#define NOTE_GS8 6644.88f
-#define NOTE_A8 7040.00f
-#define NOTE_AS8 7458.62f
-#define NOTE_B8 7902.13f
+#define NOTE_B1 61.74f
+#define NOTE_C2 65.41f
+#define NOTE_CS2 69.30f
+#define NOTE_D2 73.42f
+#define NOTE_DS2 77.78f
+#define NOTE_E2 82.41f
+#define NOTE_F2 87.31f
+#define NOTE_FS2 92.50f
+#define NOTE_G2 98.00f
+#define NOTE_GS2 103.83f
+#define NOTE_A2 110.00f
+#define NOTE_AS2 116.54f
+#define NOTE_B2 123.47f
+#define NOTE_C3 130.81f
+#define NOTE_CS3 138.59f
+#define NOTE_D3 146.83f
+#define NOTE_DS3 155.56f
+#define NOTE_E3 164.81f
+#define NOTE_F3 174.61f
+#define NOTE_FS3 185.00f
+#define NOTE_G3 196.00f
+#define NOTE_GS3 207.65f
+#define NOTE_A3 220.00f
+#define NOTE_AS3 233.08f
+#define NOTE_B3 246.94f
+#define NOTE_C4 261.63f
+#define NOTE_CS4 277.18f
+#define NOTE_D4 293.66f
+#define NOTE_DS4 311.13f
+#define NOTE_E4 329.63f
+#define NOTE_F4 349.23f
+#define NOTE_FS4 369.99f
+#define NOTE_G4 392.00f
+#define NOTE_GS4 415.30f
+#define NOTE_A4 440.00f
+#define NOTE_AS4 466.16f
+#define NOTE_B4 493.88f
+#define NOTE_C5 523.25f
+#define NOTE_CS5 554.37f
+#define NOTE_D5 587.33f
+#define NOTE_DS5 622.25f
+#define NOTE_E5 659.26f
+#define NOTE_F5 698.46f
+#define NOTE_FS5 739.99f
+#define NOTE_G5 783.99f
+#define NOTE_GS5 830.61f
+#define NOTE_A5 880.00f
+#define NOTE_AS5 932.33f
+#define NOTE_B5 987.77f
+#define NOTE_C6 1046.50f
+#define NOTE_CS6 1108.73f
+#define NOTE_D6 1174.66f
+#define NOTE_DS6 1244.51f
+#define NOTE_E6 1318.51f
+#define NOTE_F6 1396.91f
+#define NOTE_FS6 1479.98f
+#define NOTE_G6 1567.98f
+#define NOTE_GS6 1661.22f
+#define NOTE_A6 1760.00f
+#define NOTE_AS6 1864.66f
+#define NOTE_B6 1975.53f
+#define NOTE_C7 2093.00f
+#define NOTE_CS7 2217.46f
+#define NOTE_D7 2349.32f
+#define NOTE_DS7 2489.02f
+#define NOTE_E7 2637.02f
+#define NOTE_F7 2793.83f
+#define NOTE_FS7 2959.96f
+#define NOTE_G7 3135.96f
+#define NOTE_GS7 3322.44f
+#define NOTE_A7 3520.00f
+#define NOTE_AS7 3729.31f
+#define NOTE_B7 3951.07f
+#define NOTE_C8 4186.01f
+#define NOTE_CS8 4434.92f
+#define NOTE_D8 4698.64f
+#define NOTE_DS8 4978.03f
+#define NOTE_E8 5274.04f
+#define NOTE_F8 5587.65f
+#define NOTE_FS8 5919.91f
+#define NOTE_G8 6271.93f
+#define NOTE_GS8 6644.88f
+#define NOTE_A8 7040.00f
+#define NOTE_AS8 7458.62f
+#define NOTE_B8 7902.13f
// Flat Aliases
#define NOTE_DF0 NOTE_CS0
@@ -230,5 +230,4 @@
#define NOTE_AF8 NOTE_GS8
#define NOTE_BF8 NOTE_AS8
-
#endif
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index 33dbcfcb1d..3d0e0e51ed 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -26,25 +26,15 @@
* Author: Friedrich Schiller
+ License: Public Domain
*/
-#define ODE_TO_JOY \
- Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), \
- Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), \
- Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), \
- QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4),
+#define ODE_TO_JOY Q__NOTE(_E4), Q__NOTE(_E4), Q__NOTE(_F4), Q__NOTE(_G4), Q__NOTE(_G4), Q__NOTE(_F4), Q__NOTE(_E4), Q__NOTE(_D4), Q__NOTE(_C4), Q__NOTE(_C4), Q__NOTE(_D4), Q__NOTE(_E4), QD_NOTE(_E4), E__NOTE(_D4), H__NOTE(_D4),
/* Rock-a-bye Baby
* Author: Unknown
+ License: Public Domain
*/
-#define ROCK_A_BYE_BABY \
- QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), \
- H__NOTE(_A5), Q__NOTE(_G5), \
- QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), \
- H__NOTE(_FS5),
+#define ROCK_A_BYE_BABY QD_NOTE(_B4), E__NOTE(_D4), Q__NOTE(_B5), H__NOTE(_A5), Q__NOTE(_G5), QD_NOTE(_B4), E__NOTE(_D5), Q__NOTE(_G5), H__NOTE(_FS5),
-
-#define CLUEBOARD_SOUND \
- HD_NOTE(_C3), HD_NOTE(_D3), HD_NOTE(_E3), HD_NOTE(_F3), HD_NOTE(_G3), HD_NOTE(_A4), HD_NOTE(_B4), HD_NOTE(_C4)
+#define CLUEBOARD_SOUND HD_NOTE(_C3), HD_NOTE(_D3), HD_NOTE(_E3), HD_NOTE(_F3), HD_NOTE(_G3), HD_NOTE(_A4), HD_NOTE(_B4), HD_NOTE(_C4)
/*
HD_NOTE(_G3), HD_NOTE(_E3), HD_NOTE(_C3), \
Q__NOTE(_E3), Q__NOTE(_C3), Q__NOTE(_G3), \
@@ -56,258 +46,93 @@
Q__NOTE(_F3)
*/
-#define STARTUP_SOUND \
- E__NOTE(_E6), \
- E__NOTE(_A6), \
- ED_NOTE(_E7),
-
-#define GOODBYE_SOUND \
- E__NOTE(_E7), \
- E__NOTE(_A6), \
- ED_NOTE(_E6),
-
-#define PLANCK_SOUND \
- ED_NOTE(_E7 ), \
- E__NOTE(_CS7), \
- E__NOTE(_E6 ), \
- E__NOTE(_A6 ), \
- M__NOTE(_CS7, 20),
-
-#define PREONIC_SOUND \
- M__NOTE(_B5, 20), \
- E__NOTE(_B6), \
- M__NOTE(_DS6, 20), \
- E__NOTE(_B6),
-
-#define QWERTY_SOUND \
- E__NOTE(_GS6 ), \
- E__NOTE(_A6 ), \
- S__NOTE(_REST), \
- Q__NOTE(_E7 ),
-
-#define COLEMAK_SOUND \
- E__NOTE(_GS6 ), \
- E__NOTE(_A6 ), \
- S__NOTE(_REST), \
- ED_NOTE(_E7 ), \
- S__NOTE(_REST), \
- ED_NOTE(_GS7 ),
-
-#define DVORAK_SOUND \
- E__NOTE(_GS6 ), \
- E__NOTE(_A6 ), \
- S__NOTE(_REST), \
- E__NOTE(_E7 ), \
- S__NOTE(_REST), \
- E__NOTE(_FS7 ), \
- S__NOTE(_REST), \
- E__NOTE(_E7 ),
-
-#define WORKMAN_SOUND \
- E__NOTE(_GS6 ), \
- E__NOTE(_A6 ), \
- S__NOTE(_REST), \
- E__NOTE(_GS6 ), \
- E__NOTE(_A6 ), \
- S__NOTE(_REST), \
- ED_NOTE(_FS7 ), \
- S__NOTE(_REST), \
- ED_NOTE(_A7 ),
-
-#define PLOVER_SOUND \
- E__NOTE(_GS6 ), \
- E__NOTE(_A6 ), \
- S__NOTE(_REST), \
- ED_NOTE(_E7 ), \
- S__NOTE(_REST), \
- ED_NOTE(_A7 ),
-
-#define PLOVER_GOODBYE_SOUND \
- E__NOTE(_GS6 ), \
- E__NOTE(_A6 ), \
- S__NOTE(_REST), \
- ED_NOTE(_A7 ), \
- S__NOTE(_REST), \
- ED_NOTE(_E7 ),
-
-#define MUSIC_ON_SOUND \
- E__NOTE(_A5 ), \
- E__NOTE(_B5 ), \
- E__NOTE(_CS6), \
- E__NOTE(_D6 ), \
- E__NOTE(_E6 ), \
- E__NOTE(_FS6), \
- E__NOTE(_GS6), \
- E__NOTE(_A6 ),
-
-#define AUDIO_ON_SOUND \
- E__NOTE(_A5 ), \
- E__NOTE(_A6 ),
-
-#define AUDIO_OFF_SOUND \
- E__NOTE(_A6 ), \
- E__NOTE(_A5 ),
+#define STARTUP_SOUND E__NOTE(_E6), E__NOTE(_A6), ED_NOTE(_E7),
+
+#define GOODBYE_SOUND E__NOTE(_E7), E__NOTE(_A6), ED_NOTE(_E6),
+
+#define PLANCK_SOUND ED_NOTE(_E7), E__NOTE(_CS7), E__NOTE(_E6), E__NOTE(_A6), M__NOTE(_CS7, 20),
+
+#define PREONIC_SOUND M__NOTE(_B5, 20), E__NOTE(_B6), M__NOTE(_DS6, 20), E__NOTE(_B6),
+
+#define QWERTY_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), Q__NOTE(_E7),
+
+#define COLEMAK_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_E7), S__NOTE(_REST), ED_NOTE(_GS7),
+
+#define DVORAK_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), E__NOTE(_E7), S__NOTE(_REST), E__NOTE(_FS7), S__NOTE(_REST), E__NOTE(_E7),
+
+#define WORKMAN_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_FS7), S__NOTE(_REST), ED_NOTE(_A7),
+
+#define PLOVER_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_E7), S__NOTE(_REST), ED_NOTE(_A7),
+
+#define PLOVER_GOODBYE_SOUND E__NOTE(_GS6), E__NOTE(_A6), S__NOTE(_REST), ED_NOTE(_A7), S__NOTE(_REST), ED_NOTE(_E7),
+
+#define MUSIC_ON_SOUND E__NOTE(_A5), E__NOTE(_B5), E__NOTE(_CS6), E__NOTE(_D6), E__NOTE(_E6), E__NOTE(_FS6), E__NOTE(_GS6), E__NOTE(_A6),
+
+#define AUDIO_ON_SOUND E__NOTE(_A5), E__NOTE(_A6),
+
+#define AUDIO_OFF_SOUND E__NOTE(_A6), E__NOTE(_A5),
#define MUSIC_SCALE_SOUND MUSIC_ON_SOUND
-#define MUSIC_OFF_SOUND \
- E__NOTE(_A6 ), \
- E__NOTE(_GS6 ), \
- E__NOTE(_FS6), \
- E__NOTE(_E6 ), \
- E__NOTE(_D6 ), \
- E__NOTE(_CS6), \
- E__NOTE(_B5), \
- E__NOTE(_A5 ),
-
-#define VOICE_CHANGE_SOUND \
- Q__NOTE(_A5 ), \
- Q__NOTE(_CS6), \
- Q__NOTE(_E6 ), \
- Q__NOTE(_A6 ),
-
-#define CHROMATIC_SOUND \
- Q__NOTE(_A5 ), \
- Q__NOTE(_AS5 ), \
- Q__NOTE(_B5), \
- Q__NOTE(_C6 ), \
- Q__NOTE(_CS6 ),
-
-#define MAJOR_SOUND \
- Q__NOTE(_A5 ), \
- Q__NOTE(_B5 ), \
- Q__NOTE(_CS6), \
- Q__NOTE(_D6 ), \
- Q__NOTE(_E6 ),
-
-#define MINOR_SOUND \
- Q__NOTE(_A5 ), \
- Q__NOTE(_B5 ), \
- Q__NOTE(_C6 ), \
- Q__NOTE(_D6 ), \
- Q__NOTE(_E6 ),
-
-#define GUITAR_SOUND \
- Q__NOTE(_E5 ), \
- Q__NOTE(_A5), \
- Q__NOTE(_D6 ), \
- Q__NOTE(_G6 ),
-
-#define VIOLIN_SOUND \
- Q__NOTE(_G5 ), \
- Q__NOTE(_D6), \
- Q__NOTE(_A6 ), \
- Q__NOTE(_E7 ),
-
-#define CAPS_LOCK_ON_SOUND \
- E__NOTE(_A3), \
- E__NOTE(_B3),
-
-#define CAPS_LOCK_OFF_SOUND \
- E__NOTE(_B3), \
- E__NOTE(_A3),
-
-#define SCROLL_LOCK_ON_SOUND \
- E__NOTE(_D4), \
- E__NOTE(_E4),
-
-#define SCROLL_LOCK_OFF_SOUND \
- E__NOTE(_E4), \
- E__NOTE(_D4),
-
-#define NUM_LOCK_ON_SOUND \
- E__NOTE(_D5), \
- E__NOTE(_E5),
-
-#define NUM_LOCK_OFF_SOUND \
- E__NOTE(_E5), \
- E__NOTE(_D5),
-
-#define AG_NORM_SOUND \
- E__NOTE(_A5), \
- E__NOTE(_A5),
-
-#define AG_SWAP_SOUND \
- SD_NOTE(_B5), \
- SD_NOTE(_A5), \
- SD_NOTE(_B5), \
- SD_NOTE(_A5),
-
-#define UNICODE_WINDOWS \
- E__NOTE(_B5), \
- S__NOTE(_E6),
-
-#define UNICODE_LINUX \
- E__NOTE(_E6), \
- S__NOTE(_B5),
-
-
-#define TERMINAL_SOUND \
- E__NOTE(_C5 )
+#define MUSIC_OFF_SOUND E__NOTE(_A6), E__NOTE(_GS6), E__NOTE(_FS6), E__NOTE(_E6), E__NOTE(_D6), E__NOTE(_CS6), E__NOTE(_B5), E__NOTE(_A5),
+
+#define VOICE_CHANGE_SOUND Q__NOTE(_A5), Q__NOTE(_CS6), Q__NOTE(_E6), Q__NOTE(_A6),
+
+#define CHROMATIC_SOUND Q__NOTE(_A5), Q__NOTE(_AS5), Q__NOTE(_B5), Q__NOTE(_C6), Q__NOTE(_CS6),
+
+#define MAJOR_SOUND Q__NOTE(_A5), Q__NOTE(_B5), Q__NOTE(_CS6), Q__NOTE(_D6), Q__NOTE(_E6),
+
+#define MINOR_SOUND Q__NOTE(_A5), Q__NOTE(_B5), Q__NOTE(_C6), Q__NOTE(_D6), Q__NOTE(_E6),
+
+#define GUITAR_SOUND Q__NOTE(_E5), Q__NOTE(_A5), Q__NOTE(_D6), Q__NOTE(_G6),
+#define VIOLIN_SOUND Q__NOTE(_G5), Q__NOTE(_D6), Q__NOTE(_A6), Q__NOTE(_E7),
+
+#define CAPS_LOCK_ON_SOUND E__NOTE(_A3), E__NOTE(_B3),
+
+#define CAPS_LOCK_OFF_SOUND E__NOTE(_B3), E__NOTE(_A3),
+
+#define SCROLL_LOCK_ON_SOUND E__NOTE(_D4), E__NOTE(_E4),
+
+#define SCROLL_LOCK_OFF_SOUND E__NOTE(_E4), E__NOTE(_D4),
+
+#define NUM_LOCK_ON_SOUND E__NOTE(_D5), E__NOTE(_E5),
+
+#define NUM_LOCK_OFF_SOUND E__NOTE(_E5), E__NOTE(_D5),
+
+#define AG_NORM_SOUND E__NOTE(_A5), E__NOTE(_A5),
+
+#define AG_SWAP_SOUND SD_NOTE(_B5), SD_NOTE(_A5), SD_NOTE(_B5), SD_NOTE(_A5),
+
+#define UNICODE_WINDOWS E__NOTE(_B5), S__NOTE(_E6),
+
+#define UNICODE_LINUX E__NOTE(_E6), S__NOTE(_B5),
+
+#define TERMINAL_SOUND E__NOTE(_C5)
/* Title: La Campanella
* Author/Composer: Frank Lizst
+ License: Public Domain
*/
-#define CAMPANELLA \
- Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), \
- E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), \
- Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_GS4), \
- E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), \
- E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS6), \
- Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_E5), E__NOTE(_E5), E__NOTE(_DS6), Q__NOTE(_DS5), \
- E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), \
- E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), \
- Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), \
- E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), \
- E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), \
- Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), Q__NOTE(_CS6), E__NOTE(_CS6), E__NOTE(_DS7), Q__NOTE(_B5), \
- E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_B5), E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), \
- E__NOTE(_DS7), Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_G5), E__NOTE(_G5), E__NOTE(_DS7), \
- Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), E__NOTE(_DS7), Q__NOTE(_DS5), \
- E__NOTE(_DS5), E__NOTE(_DS7), W__NOTE(_DS6), W__NOTE(_GS5),
-
-
-
+#define CAMPANELLA \
+ Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_E5), E__NOTE(_E5), E__NOTE(_DS6), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_CS5), E__NOTE(_CS5), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_B4), E__NOTE(_B4), E__NOTE(_DS6), Q__NOTE(_AS4), E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_G4), E__NOTE(_G4), E__NOTE(_DS6), Q__NOTE(_GS4), E__NOTE(_GS4), E__NOTE(_DS6), Q__NOTE(_AS4), \
+ E__NOTE(_AS4), E__NOTE(_DS6), Q__NOTE(_DS4), E__NOTE(_DS4), E__NOTE(_DS5), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS6), Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), Q__NOTE(_DS6), E__NOTE(_DS6), E__NOTE(_DS7), Q__NOTE(_CS6), E__NOTE(_CS6), E__NOTE(_DS7), Q__NOTE(_B5), E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_B5), E__NOTE(_B5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), E__NOTE(_DS7), Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_G5), E__NOTE(_G5), E__NOTE(_DS7), Q__NOTE(_GS5), E__NOTE(_GS5), E__NOTE(_DS7), Q__NOTE(_AS5), E__NOTE(_AS5), E__NOTE(_DS7), Q__NOTE(_DS5), E__NOTE(_DS5), E__NOTE(_DS7), W__NOTE(_DS6), W__NOTE(_GS5),
/* Title: Fantaisie-Impromptu
* Author/Composer: Chopin
* License: Public Domain
-*/
-#define FANTASIE_IMPROMPTU \
- E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), \
- E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_A4), \
- E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), \
- E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_A4), E__NOTE(_CS5), E__NOTE(_DS5), \
- E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_CS6), E__NOTE(_DS6), E__NOTE(_B6), E__NOTE(_A6), E__NOTE(_GS6), E__NOTE(_FS6), \
- E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_FS6), E__NOTE(_CS6), E__NOTE(_C5), E__NOTE(_DS6), E__NOTE(_A5), E__NOTE(_GS5), \
- E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_FS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_DS5), \
- E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_B4), E__NOTE(_A4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), \
- E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), \
- E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_AS4), E__NOTE(_GS4), E__NOTE(_REST), \
- E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), \
- E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_DS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_REST), E__NOTE(_DS5), \
- E__NOTE(_B5), E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_CS6), E__NOTE(_B5), \
- E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_AS5), WD_NOTE(_GS5),
-
+ */
+#define FANTASIE_IMPROMPTU \
+ E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_A4), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_CS6), E__NOTE(_DS6), E__NOTE(_B6), E__NOTE(_A6), E__NOTE(_GS6), E__NOTE(_FS6), E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_FS6), E__NOTE(_CS6), E__NOTE(_C5), E__NOTE(_DS6), E__NOTE(_A5), E__NOTE(_GS5), E__NOTE(_FS5), E__NOTE(_A5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_FS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_DS5), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_B4), E__NOTE(_A4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_A4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), \
+ E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_GS4), E__NOTE(_AS4), E__NOTE(_GS4), E__NOTE(_REST), E__NOTE(_GS4), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_DS5), E__NOTE(_CS5), E__NOTE(_C5), E__NOTE(_CS5), E__NOTE(_E5), E__NOTE(_GS5), E__NOTE(_DS5), E__NOTE(_E5), E__NOTE(_DS5), E__NOTE(_REST), E__NOTE(_DS5), E__NOTE(_B5), E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_E6), E__NOTE(_DS6), E__NOTE(_CS6), E__NOTE(_B5), E__NOTE(_AS5), E__NOTE(_GS5), E__NOTE(_REST), E__NOTE(_AS5), WD_NOTE(_GS5),
/* Title: Nocturne Op. 9 No. 1 in B flat minor
* Author/Composer: Chopin
License: Public Domain
*/
-#define NOCTURNE_OP_9_NO_1 \
- H__NOTE(_BF5), H__NOTE(_C6), H__NOTE(_DF6), H__NOTE(_A5), H__NOTE(_BF5), H__NOTE(_GF5), W__NOTE(_F5), W__NOTE(_F5), W__NOTE(_F5), \
- W__NOTE(_F5), H__NOTE(_GF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_C5), B__NOTE(_DF5), W__NOTE(_BF4), Q__NOTE(_BF5), \
- Q__NOTE(_C6), Q__NOTE(_DF6), Q__NOTE(_A5), Q__NOTE(_BF5), Q__NOTE(_A5), Q__NOTE(_GS5), Q__NOTE(_A5), Q__NOTE(_C6), \
- Q__NOTE(_BF5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_GF5), Q__NOTE(_E5), Q__NOTE(_F5), Q__NOTE(_BF5), Q__NOTE(_A5), \
- Q__NOTE(_AF5), Q__NOTE(_G5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), Q__NOTE(_D5), Q__NOTE(_DF5), \
- Q__NOTE(_C5), Q__NOTE(_DF5), Q__NOTE(_C5), Q__NOTE(_B4), Q__NOTE(_C5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), \
- B__NOTE(_DF5), W__NOTE(_BF4), W__NOTE(_BF5), W__NOTE(_BF5), W__NOTE(_BF5), BD_NOTE(_AF5), W__NOTE(_DF5), H__NOTE(_BF4), \
- H__NOTE(_C5), H__NOTE(_DF5), H__NOTE(_GF5), H__NOTE(_GF5), BD_NOTE(_F5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), \
- H__NOTE(_DF5), H__NOTE(_A4), B__NOTE(_AF4), W__NOTE(_DF5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_DF5), \
- H__NOTE(_EF5), BD_NOTE(_F5),
-
+#define NOCTURNE_OP_9_NO_1 \
+ H__NOTE(_BF5), H__NOTE(_C6), H__NOTE(_DF6), H__NOTE(_A5), H__NOTE(_BF5), H__NOTE(_GF5), W__NOTE(_F5), W__NOTE(_F5), W__NOTE(_F5), W__NOTE(_F5), H__NOTE(_GF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_C5), B__NOTE(_DF5), W__NOTE(_BF4), Q__NOTE(_BF5), Q__NOTE(_C6), Q__NOTE(_DF6), Q__NOTE(_A5), Q__NOTE(_BF5), Q__NOTE(_A5), Q__NOTE(_GS5), Q__NOTE(_A5), Q__NOTE(_C6), Q__NOTE(_BF5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_GF5), Q__NOTE(_E5), Q__NOTE(_F5), Q__NOTE(_BF5), Q__NOTE(_A5), Q__NOTE(_AF5), Q__NOTE(_G5), Q__NOTE(_GF5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), Q__NOTE(_D5), Q__NOTE(_DF5), Q__NOTE(_C5), Q__NOTE(_DF5), Q__NOTE(_C5), Q__NOTE(_B4), Q__NOTE(_C5), Q__NOTE(_F5), Q__NOTE(_E5), Q__NOTE(_EF5), B__NOTE(_DF5), W__NOTE(_BF4), W__NOTE(_BF5), W__NOTE(_BF5), W__NOTE(_BF5), BD_NOTE(_AF5), W__NOTE(_DF5), H__NOTE(_BF4), H__NOTE(_C5), H__NOTE(_DF5), H__NOTE(_GF5), H__NOTE(_GF5), BD_NOTE(_F5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_DF5), H__NOTE(_A4), B__NOTE(_AF4), \
+ W__NOTE(_DF5), W__NOTE(_EF5), H__NOTE(_F5), H__NOTE(_EF5), H__NOTE(_DF5), H__NOTE(_EF5), BD_NOTE(_F5),
/* Removed sounds
+ This list is here solely for compatibility, so that removed songs don't just break things
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
index 94147ccb66..53a65e4e37 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -19,40 +19,33 @@
// these are imported from audio.c
extern uint16_t envelope_index;
-extern float note_timbre;
-extern float polyphony_rate;
-extern bool glissando;
+extern float note_timbre;
+extern float polyphony_rate;
+extern bool glissando;
voice_type voice = default_voice;
-void set_voice(voice_type v) {
- voice = v;
-}
+void set_voice(voice_type v) { voice = v; }
-void voice_iterate() {
- voice = (voice + 1) % number_of_voices;
-}
+void voice_iterate() { voice = (voice + 1) % number_of_voices; }
-void voice_deiterate() {
- voice = (voice - 1 + number_of_voices) % number_of_voices;
-}
+void voice_deiterate() { voice = (voice - 1 + number_of_voices) % number_of_voices; }
float voice_envelope(float frequency) {
// envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz
- __attribute__ ((unused))
- uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency));
+ __attribute__((unused)) uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency));
switch (voice) {
case default_voice:
- glissando = false;
- note_timbre = TIMBRE_50;
+ glissando = false;
+ note_timbre = TIMBRE_50;
polyphony_rate = 0;
- break;
+ break;
- #ifdef AUDIO_VOICES
+#ifdef AUDIO_VOICES
case something:
- glissando = false;
+ glissando = false;
polyphony_rate = 0;
switch (compensated_index) {
case 0 ... 9:
@@ -74,25 +67,23 @@ float voice_envelope(float frequency) {
break;
case drums:
- glissando = false;
+ glissando = false;
polyphony_rate = 0;
- // switch (compensated_index) {
- // case 0 ... 10:
- // note_timbre = 0.5;
- // break;
- // case 11 ... 20:
- // note_timbre = 0.5 * (21 - compensated_index) / 10;
- // break;
- // default:
- // note_timbre = 0;
- // break;
- // }
- // frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8);
+ // switch (compensated_index) {
+ // case 0 ... 10:
+ // note_timbre = 0.5;
+ // break;
+ // case 11 ... 20:
+ // note_timbre = 0.5 * (21 - compensated_index) / 10;
+ // break;
+ // default:
+ // note_timbre = 0;
+ // break;
+ // }
+ // frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8);
if (frequency < 80.0) {
-
} else if (frequency < 160.0) {
-
// Bass drum: 60 - 100 Hz
frequency = (rand() % (int)(40)) + 60;
switch (envelope_index) {
@@ -108,8 +99,6 @@ float voice_envelope(float frequency) {
}
} else if (frequency < 320.0) {
-
-
// Snare drum: 1 - 2 KHz
frequency = (rand() % (int)(1000)) + 1000;
switch (envelope_index) {
@@ -125,7 +114,6 @@ float voice_envelope(float frequency) {
}
} else if (frequency < 640.0) {
-
// Closed Hi-hat: 3 - 5 KHz
frequency = (rand() % (int)(2000)) + 3000;
switch (envelope_index) {
@@ -141,7 +129,6 @@ float voice_envelope(float frequency) {
}
} else if (frequency < 1280.0) {
-
// Open Hi-hat: 3 - 5 KHz
frequency = (rand() % (int)(2000)) + 3000;
switch (envelope_index) {
@@ -155,141 +142,138 @@ float voice_envelope(float frequency) {
note_timbre = 0;
break;
}
-
}
break;
case butts_fader:
- glissando = true;
+ glissando = true;
polyphony_rate = 0;
switch (compensated_index) {
case 0 ... 9:
- frequency = frequency / 4;
+ frequency = frequency / 4;
note_timbre = TIMBRE_12;
- break;
+ break;
case 10 ... 19:
- frequency = frequency / 2;
+ frequency = frequency / 2;
note_timbre = TIMBRE_12;
- break;
+ break;
case 20 ... 200:
- note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125;
- break;
+ note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2) * .125;
+ break;
default:
note_timbre = 0;
- break;
+ break;
}
- break;
-
- // case octave_crunch:
- // polyphony_rate = 0;
- // switch (compensated_index) {
- // case 0 ... 9:
- // case 20 ... 24:
- // case 30 ... 32:
- // frequency = frequency / 2;
- // note_timbre = TIMBRE_12;
- // break;
-
- // case 10 ... 19:
- // case 25 ... 29:
- // case 33 ... 35:
- // frequency = frequency * 2;
- // note_timbre = TIMBRE_12;
- // break;
+ break;
- // default:
- // note_timbre = TIMBRE_12;
- // break;
- // }
- // break;
+ // case octave_crunch:
+ // polyphony_rate = 0;
+ // switch (compensated_index) {
+ // case 0 ... 9:
+ // case 20 ... 24:
+ // case 30 ... 32:
+ // frequency = frequency / 2;
+ // note_timbre = TIMBRE_12;
+ // break;
+
+ // case 10 ... 19:
+ // case 25 ... 29:
+ // case 33 ... 35:
+ // frequency = frequency * 2;
+ // note_timbre = TIMBRE_12;
+ // break;
+
+ // default:
+ // note_timbre = TIMBRE_12;
+ // break;
+ // }
+ // break;
case duty_osc:
// This slows the loop down a substantial amount, so higher notes may freeze
- glissando = true;
+ glissando = true;
polyphony_rate = 0;
switch (compensated_index) {
default:
- #define OCS_SPEED 10
- #define OCS_AMP .25
+# define OCS_SPEED 10
+# define OCS_AMP .25
// sine wave is slow
// note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5;
// triangle wave is a bit faster
- note_timbre = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2;
- break;
+ note_timbre = (float)abs((compensated_index * OCS_SPEED % 3000) - 1500) * (OCS_AMP / 1500) + (1 - OCS_AMP) / 2;
+ break;
}
- break;
+ break;
case duty_octave_down:
- glissando = true;
+ glissando = true;
polyphony_rate = 0;
- note_timbre = (envelope_index % 2) * .125 + .375 * 2;
- if ((envelope_index % 4) == 0)
- note_timbre = 0.5;
- if ((envelope_index % 8) == 0)
- note_timbre = 0;
+ note_timbre = (envelope_index % 2) * .125 + .375 * 2;
+ if ((envelope_index % 4) == 0) note_timbre = 0.5;
+ if ((envelope_index % 8) == 0) note_timbre = 0;
break;
case delayed_vibrato:
- glissando = true;
+ glissando = true;
polyphony_rate = 0;
- note_timbre = TIMBRE_50;
- #define VOICE_VIBRATO_DELAY 150
- #define VOICE_VIBRATO_SPEED 50
+ note_timbre = TIMBRE_50;
+# define VOICE_VIBRATO_DELAY 150
+# define VOICE_VIBRATO_SPEED 50
switch (compensated_index) {
case 0 ... VOICE_VIBRATO_DELAY:
break;
default:
- frequency = frequency * vibrato_lut[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)];
+ frequency = frequency * vibrato_lut[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1)) / 1000 * VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)];
break;
}
break;
- // case delayed_vibrato_octave:
- // polyphony_rate = 0;
- // if ((envelope_index % 2) == 1) {
- // note_timbre = 0.55;
- // } else {
- // note_timbre = 0.45;
- // }
- // #define VOICE_VIBRATO_DELAY 150
- // #define VOICE_VIBRATO_SPEED 50
- // switch (compensated_index) {
- // case 0 ... VOICE_VIBRATO_DELAY:
- // break;
- // default:
- // frequency = frequency * VIBRATO_LUT[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)];
- // break;
- // }
- // break;
- // case duty_fifth_down:
- // note_timbre = 0.5;
- // if ((envelope_index % 3) == 0)
- // note_timbre = 0.75;
- // break;
- // case duty_fourth_down:
- // note_timbre = 0.0;
- // if ((envelope_index % 12) == 0)
- // note_timbre = 0.75;
- // if (((envelope_index % 12) % 4) != 1)
- // note_timbre = 0.75;
- // break;
- // case duty_third_down:
- // note_timbre = 0.5;
- // if ((envelope_index % 5) == 0)
- // note_timbre = 0.75;
- // break;
- // case duty_fifth_third_down:
- // note_timbre = 0.5;
- // if ((envelope_index % 5) == 0)
- // note_timbre = 0.75;
- // if ((envelope_index % 3) == 0)
- // note_timbre = 0.25;
- // break;
-
- #endif
-
- default:
- break;
+ // case delayed_vibrato_octave:
+ // polyphony_rate = 0;
+ // if ((envelope_index % 2) == 1) {
+ // note_timbre = 0.55;
+ // } else {
+ // note_timbre = 0.45;
+ // }
+ // #define VOICE_VIBRATO_DELAY 150
+ // #define VOICE_VIBRATO_SPEED 50
+ // switch (compensated_index) {
+ // case 0 ... VOICE_VIBRATO_DELAY:
+ // break;
+ // default:
+ // frequency = frequency * VIBRATO_LUT[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)];
+ // break;
+ // }
+ // break;
+ // case duty_fifth_down:
+ // note_timbre = 0.5;
+ // if ((envelope_index % 3) == 0)
+ // note_timbre = 0.75;
+ // break;
+ // case duty_fourth_down:
+ // note_timbre = 0.0;
+ // if ((envelope_index % 12) == 0)
+ // note_timbre = 0.75;
+ // if (((envelope_index % 12) % 4) != 1)
+ // note_timbre = 0.75;
+ // break;
+ // case duty_third_down:
+ // note_timbre = 0.5;
+ // if ((envelope_index % 5) == 0)
+ // note_timbre = 0.75;
+ // break;
+ // case duty_fifth_third_down:
+ // note_timbre = 0.5;
+ // if ((envelope_index % 5) == 0)
+ // note_timbre = 0.75;
+ // if ((envelope_index % 3) == 0)
+ // note_timbre = 0.25;
+ // break;
+
+#endif
+
+ default:
+ break;
}
return frequency;
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h
index 1cf33095a4..0c45b0720e 100644
--- a/quantum/audio/voices.h
+++ b/quantum/audio/voices.h
@@ -16,19 +16,19 @@
#include <stdint.h>
#include <stdbool.h>
#if defined(__AVR__)
- #include <avr/io.h>
+# include <avr/io.h>
#endif
#include "wait.h"
#include "luts.h"
#ifndef VOICES_H
-#define VOICES_H
+# define VOICES_H
float voice_envelope(float frequency);
typedef enum {
default_voice,
- #ifdef AUDIO_VOICES
+# ifdef AUDIO_VOICES
something,
drums,
butts_fader,
@@ -36,13 +36,13 @@ typedef enum {
duty_osc,
duty_octave_down,
delayed_vibrato,
- // delayed_vibrato_octave,
- // duty_fifth_down,
- // duty_fourth_down,
- // duty_third_down,
- // duty_fifth_third_down,
- #endif
- number_of_voices // important that this is last
+// delayed_vibrato_octave,
+// duty_fifth_down,
+// duty_fourth_down,
+// duty_third_down,
+// duty_fifth_third_down,
+# endif
+ number_of_voices // important that this is last
} voice_type;
void set_voice(voice_type v);
diff --git a/quantum/audio/wave.h b/quantum/audio/wave.h
index f15615dd1b..48210a944e 100644
--- a/quantum/audio/wave.h
+++ b/quantum/audio/wave.h
@@ -20,262 +20,17 @@
#define SINE_LENGTH 2048
-const uint8_t sinewave[] PROGMEM= //2048 values
-{
-0x80,0x80,0x80,0x81,0x81,0x81,0x82,0x82,
-0x83,0x83,0x83,0x84,0x84,0x85,0x85,0x85,
-0x86,0x86,0x87,0x87,0x87,0x88,0x88,0x88,
-0x89,0x89,0x8a,0x8a,0x8a,0x8b,0x8b,0x8c,
-0x8c,0x8c,0x8d,0x8d,0x8e,0x8e,0x8e,0x8f,
-0x8f,0x8f,0x90,0x90,0x91,0x91,0x91,0x92,
-0x92,0x93,0x93,0x93,0x94,0x94,0x95,0x95,
-0x95,0x96,0x96,0x96,0x97,0x97,0x98,0x98,
-0x98,0x99,0x99,0x9a,0x9a,0x9a,0x9b,0x9b,
-0x9b,0x9c,0x9c,0x9d,0x9d,0x9d,0x9e,0x9e,
-0x9e,0x9f,0x9f,0xa0,0xa0,0xa0,0xa1,0xa1,
-0xa2,0xa2,0xa2,0xa3,0xa3,0xa3,0xa4,0xa4,
-0xa5,0xa5,0xa5,0xa6,0xa6,0xa6,0xa7,0xa7,
-0xa7,0xa8,0xa8,0xa9,0xa9,0xa9,0xaa,0xaa,
-0xaa,0xab,0xab,0xac,0xac,0xac,0xad,0xad,
-0xad,0xae,0xae,0xae,0xaf,0xaf,0xb0,0xb0,
-0xb0,0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb3,
-0xb3,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb6,
-0xb6,0xb6,0xb7,0xb7,0xb7,0xb8,0xb8,0xb8,
-0xb9,0xb9,0xba,0xba,0xba,0xbb,0xbb,0xbb,
-0xbc,0xbc,0xbc,0xbd,0xbd,0xbd,0xbe,0xbe,
-0xbe,0xbf,0xbf,0xbf,0xc0,0xc0,0xc0,0xc1,
-0xc1,0xc1,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3,
-0xc4,0xc4,0xc4,0xc5,0xc5,0xc5,0xc6,0xc6,
-0xc6,0xc7,0xc7,0xc7,0xc8,0xc8,0xc8,0xc9,
-0xc9,0xc9,0xca,0xca,0xca,0xcb,0xcb,0xcb,
-0xcb,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xce,
-0xce,0xce,0xcf,0xcf,0xcf,0xcf,0xd0,0xd0,
-0xd0,0xd1,0xd1,0xd1,0xd2,0xd2,0xd2,0xd2,
-0xd3,0xd3,0xd3,0xd4,0xd4,0xd4,0xd5,0xd5,
-0xd5,0xd5,0xd6,0xd6,0xd6,0xd7,0xd7,0xd7,
-0xd7,0xd8,0xd8,0xd8,0xd9,0xd9,0xd9,0xd9,
-0xda,0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdc,
-0xdc,0xdc,0xdc,0xdd,0xdd,0xdd,0xdd,0xde,
-0xde,0xde,0xde,0xdf,0xdf,0xdf,0xe0,0xe0,
-0xe0,0xe0,0xe1,0xe1,0xe1,0xe1,0xe2,0xe2,
-0xe2,0xe2,0xe3,0xe3,0xe3,0xe3,0xe4,0xe4,
-0xe4,0xe4,0xe4,0xe5,0xe5,0xe5,0xe5,0xe6,
-0xe6,0xe6,0xe6,0xe7,0xe7,0xe7,0xe7,0xe8,
-0xe8,0xe8,0xe8,0xe8,0xe9,0xe9,0xe9,0xe9,
-0xea,0xea,0xea,0xea,0xea,0xeb,0xeb,0xeb,
-0xeb,0xeb,0xec,0xec,0xec,0xec,0xec,0xed,
-0xed,0xed,0xed,0xed,0xee,0xee,0xee,0xee,
-0xee,0xef,0xef,0xef,0xef,0xef,0xf0,0xf0,
-0xf0,0xf0,0xf0,0xf0,0xf1,0xf1,0xf1,0xf1,
-0xf1,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2,0xf3,
-0xf3,0xf3,0xf3,0xf3,0xf3,0xf4,0xf4,0xf4,
-0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf5,
-0xf5,0xf5,0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,
-0xf6,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,
-0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,
-0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,
-0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,
-0xfa,0xfa,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,
-0xfb,0xfb,0xfb,0xfb,0xfc,0xfc,0xfc,0xfc,
-0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,
-0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,
-0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe,
-0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
-0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
-0xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfe,
-0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
-0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
-0xfe,0xfe,0xfe,0xfd,0xfd,0xfd,0xfd,0xfd,
-0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,
-0xfd,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,
-0xfc,0xfc,0xfc,0xfc,0xfc,0xfb,0xfb,0xfb,
-0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfa,
-0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,
-0xfa,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,
-0xf9,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,0xf8,
-0xf8,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,
-0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,0xf6,0xf5,
-0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xf4,0xf4,
-0xf4,0xf4,0xf4,0xf4,0xf3,0xf3,0xf3,0xf3,
-0xf3,0xf3,0xf2,0xf2,0xf2,0xf2,0xf2,0xf2,
-0xf1,0xf1,0xf1,0xf1,0xf1,0xf0,0xf0,0xf0,
-0xf0,0xf0,0xf0,0xef,0xef,0xef,0xef,0xef,
-0xee,0xee,0xee,0xee,0xee,0xed,0xed,0xed,
-0xed,0xed,0xec,0xec,0xec,0xec,0xec,0xeb,
-0xeb,0xeb,0xeb,0xeb,0xea,0xea,0xea,0xea,
-0xea,0xe9,0xe9,0xe9,0xe9,0xe8,0xe8,0xe8,
-0xe8,0xe8,0xe7,0xe7,0xe7,0xe7,0xe6,0xe6,
-0xe6,0xe6,0xe5,0xe5,0xe5,0xe5,0xe4,0xe4,
-0xe4,0xe4,0xe4,0xe3,0xe3,0xe3,0xe3,0xe2,
-0xe2,0xe2,0xe2,0xe1,0xe1,0xe1,0xe1,0xe0,
-0xe0,0xe0,0xe0,0xdf,0xdf,0xdf,0xde,0xde,
-0xde,0xde,0xdd,0xdd,0xdd,0xdd,0xdc,0xdc,
-0xdc,0xdc,0xdb,0xdb,0xdb,0xda,0xda,0xda,
-0xda,0xd9,0xd9,0xd9,0xd9,0xd8,0xd8,0xd8,
-0xd7,0xd7,0xd7,0xd7,0xd6,0xd6,0xd6,0xd5,
-0xd5,0xd5,0xd5,0xd4,0xd4,0xd4,0xd3,0xd3,
-0xd3,0xd2,0xd2,0xd2,0xd2,0xd1,0xd1,0xd1,
-0xd0,0xd0,0xd0,0xcf,0xcf,0xcf,0xcf,0xce,
-0xce,0xce,0xcd,0xcd,0xcd,0xcc,0xcc,0xcc,
-0xcb,0xcb,0xcb,0xcb,0xca,0xca,0xca,0xc9,
-0xc9,0xc9,0xc8,0xc8,0xc8,0xc7,0xc7,0xc7,
-0xc6,0xc6,0xc6,0xc5,0xc5,0xc5,0xc4,0xc4,
-0xc4,0xc3,0xc3,0xc3,0xc2,0xc2,0xc2,0xc1,
-0xc1,0xc1,0xc0,0xc0,0xc0,0xbf,0xbf,0xbf,
-0xbe,0xbe,0xbe,0xbd,0xbd,0xbd,0xbc,0xbc,
-0xbc,0xbb,0xbb,0xbb,0xba,0xba,0xba,0xb9,
-0xb9,0xb8,0xb8,0xb8,0xb7,0xb7,0xb7,0xb6,
-0xb6,0xb6,0xb5,0xb5,0xb5,0xb4,0xb4,0xb4,
-0xb3,0xb3,0xb2,0xb2,0xb2,0xb1,0xb1,0xb1,
-0xb0,0xb0,0xb0,0xaf,0xaf,0xae,0xae,0xae,
-0xad,0xad,0xad,0xac,0xac,0xac,0xab,0xab,
-0xaa,0xaa,0xaa,0xa9,0xa9,0xa9,0xa8,0xa8,
-0xa7,0xa7,0xa7,0xa6,0xa6,0xa6,0xa5,0xa5,
-0xa5,0xa4,0xa4,0xa3,0xa3,0xa3,0xa2,0xa2,
-0xa2,0xa1,0xa1,0xa0,0xa0,0xa0,0x9f,0x9f,
-0x9e,0x9e,0x9e,0x9d,0x9d,0x9d,0x9c,0x9c,
-0x9b,0x9b,0x9b,0x9a,0x9a,0x9a,0x99,0x99,
-0x98,0x98,0x98,0x97,0x97,0x96,0x96,0x96,
-0x95,0x95,0x95,0x94,0x94,0x93,0x93,0x93,
-0x92,0x92,0x91,0x91,0x91,0x90,0x90,0x8f,
-0x8f,0x8f,0x8e,0x8e,0x8e,0x8d,0x8d,0x8c,
-0x8c,0x8c,0x8b,0x8b,0x8a,0x8a,0x8a,0x89,
-0x89,0x88,0x88,0x88,0x87,0x87,0x87,0x86,
-0x86,0x85,0x85,0x85,0x84,0x84,0x83,0x83,
-0x83,0x82,0x82,0x81,0x81,0x81,0x80,0x80,
-0x80,0x7f,0x7f,0x7e,0x7e,0x7e,0x7d,0x7d,
-0x7c,0x7c,0x7c,0x7b,0x7b,0x7a,0x7a,0x7a,
-0x79,0x79,0x78,0x78,0x78,0x77,0x77,0x77,
-0x76,0x76,0x75,0x75,0x75,0x74,0x74,0x73,
-0x73,0x73,0x72,0x72,0x71,0x71,0x71,0x70,
-0x70,0x70,0x6f,0x6f,0x6e,0x6e,0x6e,0x6d,
-0x6d,0x6c,0x6c,0x6c,0x6b,0x6b,0x6a,0x6a,
-0x6a,0x69,0x69,0x69,0x68,0x68,0x67,0x67,
-0x67,0x66,0x66,0x65,0x65,0x65,0x64,0x64,
-0x64,0x63,0x63,0x62,0x62,0x62,0x61,0x61,
-0x61,0x60,0x60,0x5f,0x5f,0x5f,0x5e,0x5e,
-0x5d,0x5d,0x5d,0x5c,0x5c,0x5c,0x5b,0x5b,
-0x5a,0x5a,0x5a,0x59,0x59,0x59,0x58,0x58,
-0x58,0x57,0x57,0x56,0x56,0x56,0x55,0x55,
-0x55,0x54,0x54,0x53,0x53,0x53,0x52,0x52,
-0x52,0x51,0x51,0x51,0x50,0x50,0x4f,0x4f,
-0x4f,0x4e,0x4e,0x4e,0x4d,0x4d,0x4d,0x4c,
-0x4c,0x4b,0x4b,0x4b,0x4a,0x4a,0x4a,0x49,
-0x49,0x49,0x48,0x48,0x48,0x47,0x47,0x47,
-0x46,0x46,0x45,0x45,0x45,0x44,0x44,0x44,
-0x43,0x43,0x43,0x42,0x42,0x42,0x41,0x41,
-0x41,0x40,0x40,0x40,0x3f,0x3f,0x3f,0x3e,
-0x3e,0x3e,0x3d,0x3d,0x3d,0x3c,0x3c,0x3c,
-0x3b,0x3b,0x3b,0x3a,0x3a,0x3a,0x39,0x39,
-0x39,0x38,0x38,0x38,0x37,0x37,0x37,0x36,
-0x36,0x36,0x35,0x35,0x35,0x34,0x34,0x34,
-0x34,0x33,0x33,0x33,0x32,0x32,0x32,0x31,
-0x31,0x31,0x30,0x30,0x30,0x30,0x2f,0x2f,
-0x2f,0x2e,0x2e,0x2e,0x2d,0x2d,0x2d,0x2d,
-0x2c,0x2c,0x2c,0x2b,0x2b,0x2b,0x2a,0x2a,
-0x2a,0x2a,0x29,0x29,0x29,0x28,0x28,0x28,
-0x28,0x27,0x27,0x27,0x26,0x26,0x26,0x26,
-0x25,0x25,0x25,0x25,0x24,0x24,0x24,0x23,
-0x23,0x23,0x23,0x22,0x22,0x22,0x22,0x21,
-0x21,0x21,0x21,0x20,0x20,0x20,0x1f,0x1f,
-0x1f,0x1f,0x1e,0x1e,0x1e,0x1e,0x1d,0x1d,
-0x1d,0x1d,0x1c,0x1c,0x1c,0x1c,0x1b,0x1b,
-0x1b,0x1b,0x1b,0x1a,0x1a,0x1a,0x1a,0x19,
-0x19,0x19,0x19,0x18,0x18,0x18,0x18,0x17,
-0x17,0x17,0x17,0x17,0x16,0x16,0x16,0x16,
-0x15,0x15,0x15,0x15,0x15,0x14,0x14,0x14,
-0x14,0x14,0x13,0x13,0x13,0x13,0x13,0x12,
-0x12,0x12,0x12,0x12,0x11,0x11,0x11,0x11,
-0x11,0x10,0x10,0x10,0x10,0x10,0xf,0xf,
-0xf,0xf,0xf,0xf,0xe,0xe,0xe,0xe,
-0xe,0xd,0xd,0xd,0xd,0xd,0xd,0xc,
-0xc,0xc,0xc,0xc,0xc,0xb,0xb,0xb,
-0xb,0xb,0xb,0xa,0xa,0xa,0xa,0xa,
-0xa,0xa,0x9,0x9,0x9,0x9,0x9,0x9,
-0x9,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
-0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,
-0x6,0x6,0x6,0x6,0x6,0x6,0x6,0x6,
-0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,
-0x5,0x5,0x4,0x4,0x4,0x4,0x4,0x4,
-0x4,0x4,0x4,0x4,0x3,0x3,0x3,0x3,
-0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,
-0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,
-0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x1,
-0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,
-0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,
-0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,
-0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
-0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
-0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
-0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
-0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
-0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
-0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1,
-0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,
-0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,
-0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x2,
-0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,
-0x2,0x3,0x3,0x3,0x3,0x3,0x3,0x3,
-0x3,0x3,0x3,0x3,0x3,0x4,0x4,0x4,
-0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x5,
-0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,
-0x5,0x6,0x6,0x6,0x6,0x6,0x6,0x6,
-0x6,0x7,0x7,0x7,0x7,0x7,0x7,0x7,
-0x7,0x8,0x8,0x8,0x8,0x8,0x8,0x8,
-0x9,0x9,0x9,0x9,0x9,0x9,0x9,0xa,
-0xa,0xa,0xa,0xa,0xa,0xa,0xb,0xb,
-0xb,0xb,0xb,0xb,0xc,0xc,0xc,0xc,
-0xc,0xc,0xd,0xd,0xd,0xd,0xd,0xd,
-0xe,0xe,0xe,0xe,0xe,0xf,0xf,0xf,
-0xf,0xf,0xf,0x10,0x10,0x10,0x10,0x10,
-0x11,0x11,0x11,0x11,0x11,0x12,0x12,0x12,
-0x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14,
-0x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15,
-0x15,0x16,0x16,0x16,0x16,0x17,0x17,0x17,
-0x17,0x17,0x18,0x18,0x18,0x18,0x19,0x19,
-0x19,0x19,0x1a,0x1a,0x1a,0x1a,0x1b,0x1b,
-0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1c,0x1d,
-0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1e,0x1f,
-0x1f,0x1f,0x1f,0x20,0x20,0x20,0x21,0x21,
-0x21,0x21,0x22,0x22,0x22,0x22,0x23,0x23,
-0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,
-0x25,0x26,0x26,0x26,0x26,0x27,0x27,0x27,
-0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x2a,
-0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,
-0x2c,0x2d,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,
-0x2f,0x2f,0x2f,0x30,0x30,0x30,0x30,0x31,
-0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,
-0x34,0x34,0x34,0x34,0x35,0x35,0x35,0x36,
-0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38,
-0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,
-0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,
-0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40,
-0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,
-0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,
-0x46,0x47,0x47,0x47,0x48,0x48,0x48,0x49,
-0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,
-0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,
-0x4f,0x4f,0x4f,0x50,0x50,0x51,0x51,0x51,
-0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,
-0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,
-0x58,0x58,0x58,0x59,0x59,0x59,0x5a,0x5a,
-0x5a,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,
-0x5d,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,
-0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,
-0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,
-0x67,0x67,0x67,0x68,0x68,0x69,0x69,0x69,
-0x6a,0x6a,0x6a,0x6b,0x6b,0x6c,0x6c,0x6c,
-0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x70,
-0x70,0x70,0x71,0x71,0x71,0x72,0x72,0x73,
-0x73,0x73,0x74,0x74,0x75,0x75,0x75,0x76,
-0x76,0x77,0x77,0x77,0x78,0x78,0x78,0x79,
-0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7c,0x7c,
-0x7c,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f
-};
+const uint8_t sinewave[] PROGMEM = // 2048 values
+ {0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x82, 0x82, 0x83, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x89, 0x89, 0x8a, 0x8a, 0x8a, 0x8b, 0x8b, 0x8c, 0x8c, 0x8c, 0x8d, 0x8d, 0x8e, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f, 0x90, 0x90, 0x91, 0x91, 0x91, 0x92, 0x92, 0x93, 0x93, 0x93, 0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96, 0x97, 0x97, 0x98, 0x98, 0x98, 0x99, 0x99, 0x9a, 0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f, 0xa0, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa5, 0xa6, 0xa6, 0xa6, 0xa7, 0xa7, 0xa7, 0xa8, 0xa8, 0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab, 0xac, 0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae, 0xaf, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1, 0xb1, 0xb1, 0xb2, 0xb2, 0xb2, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4, 0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7, 0xb8, 0xb8, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xba, 0xbb,
+ 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3, 0xc3, 0xc4, 0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6, 0xc7, 0xc7, 0xc7, 0xc8, 0xc8, 0xc8, 0xc9, 0xc9, 0xc9, 0xca, 0xca, 0xca, 0xcb, 0xcb, 0xcb, 0xcb, 0xcc, 0xcc, 0xcc, 0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf, 0xcf, 0xcf, 0xd0, 0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2, 0xd2, 0xd3, 0xd3, 0xd3, 0xd4, 0xd4, 0xd4, 0xd5, 0xd5, 0xd5, 0xd5, 0xd6, 0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd7, 0xd8, 0xd8, 0xd8, 0xd9, 0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xda, 0xdb, 0xdb, 0xdb, 0xdc, 0xdc, 0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde, 0xde, 0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0xe0, 0xe1, 0xe1, 0xe1, 0xe1, 0xe2, 0xe2, 0xe2, 0xe2, 0xe3, 0xe3, 0xe3, 0xe3, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe5, 0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7, 0xe7, 0xe7, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8,
+ 0xe9, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea, 0xea, 0xea, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xed, 0xed, 0xee, 0xee, 0xee, 0xee, 0xee, 0xef, 0xef, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+ 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7,
+ 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xef, 0xef, 0xef, 0xef, 0xef, 0xee, 0xee, 0xee, 0xee, 0xee, 0xed, 0xed, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec, 0xec, 0xec, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xea, 0xe9, 0xe9, 0xe9, 0xe9, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe7, 0xe7, 0xe7, 0xe7, 0xe6, 0xe6, 0xe6, 0xe6, 0xe5, 0xe5, 0xe5, 0xe5, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe3, 0xe3, 0xe3, 0xe3, 0xe2, 0xe2, 0xe2, 0xe2, 0xe1, 0xe1, 0xe1, 0xe1, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf, 0xdf, 0xdf, 0xde, 0xde, 0xde, 0xde, 0xdd, 0xdd, 0xdd, 0xdd, 0xdc, 0xdc, 0xdc, 0xdc, 0xdb, 0xdb, 0xdb, 0xda, 0xda, 0xda, 0xda, 0xd9, 0xd9, 0xd9, 0xd9, 0xd8, 0xd8, 0xd8, 0xd7, 0xd7, 0xd7, 0xd7, 0xd6, 0xd6, 0xd6, 0xd5, 0xd5, 0xd5, 0xd5, 0xd4, 0xd4, 0xd4,
+ 0xd3, 0xd3, 0xd3, 0xd2, 0xd2, 0xd2, 0xd2, 0xd1, 0xd1, 0xd1, 0xd0, 0xd0, 0xd0, 0xcf, 0xcf, 0xcf, 0xcf, 0xce, 0xce, 0xce, 0xcd, 0xcd, 0xcd, 0xcc, 0xcc, 0xcc, 0xcb, 0xcb, 0xcb, 0xcb, 0xca, 0xca, 0xca, 0xc9, 0xc9, 0xc9, 0xc8, 0xc8, 0xc8, 0xc7, 0xc7, 0xc7, 0xc6, 0xc6, 0xc6, 0xc5, 0xc5, 0xc5, 0xc4, 0xc4, 0xc4, 0xc3, 0xc3, 0xc3, 0xc2, 0xc2, 0xc2, 0xc1, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0xbf, 0xbf, 0xbf, 0xbe, 0xbe, 0xbe, 0xbd, 0xbd, 0xbd, 0xbc, 0xbc, 0xbc, 0xbb, 0xbb, 0xbb, 0xba, 0xba, 0xba, 0xb9, 0xb9, 0xb8, 0xb8, 0xb8, 0xb7, 0xb7, 0xb7, 0xb6, 0xb6, 0xb6, 0xb5, 0xb5, 0xb5, 0xb4, 0xb4, 0xb4, 0xb3, 0xb3, 0xb2, 0xb2, 0xb2, 0xb1, 0xb1, 0xb1, 0xb0, 0xb0, 0xb0, 0xaf, 0xaf, 0xae, 0xae, 0xae, 0xad, 0xad, 0xad, 0xac, 0xac, 0xac, 0xab, 0xab, 0xaa, 0xaa, 0xaa, 0xa9, 0xa9, 0xa9, 0xa8, 0xa8, 0xa7, 0xa7, 0xa7, 0xa6, 0xa6, 0xa6, 0xa5, 0xa5, 0xa5, 0xa4, 0xa4, 0xa3, 0xa3, 0xa3, 0xa2, 0xa2, 0xa2, 0xa1, 0xa1, 0xa0, 0xa0, 0xa0, 0x9f, 0x9f, 0x9e, 0x9e, 0x9e, 0x9d,
+ 0x9d, 0x9d, 0x9c, 0x9c, 0x9b, 0x9b, 0x9b, 0x9a, 0x9a, 0x9a, 0x99, 0x99, 0x98, 0x98, 0x98, 0x97, 0x97, 0x96, 0x96, 0x96, 0x95, 0x95, 0x95, 0x94, 0x94, 0x93, 0x93, 0x93, 0x92, 0x92, 0x91, 0x91, 0x91, 0x90, 0x90, 0x8f, 0x8f, 0x8f, 0x8e, 0x8e, 0x8e, 0x8d, 0x8d, 0x8c, 0x8c, 0x8c, 0x8b, 0x8b, 0x8a, 0x8a, 0x8a, 0x89, 0x89, 0x88, 0x88, 0x88, 0x87, 0x87, 0x87, 0x86, 0x86, 0x85, 0x85, 0x85, 0x84, 0x84, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x81, 0x80, 0x80, 0x80, 0x7f, 0x7f, 0x7e, 0x7e, 0x7e, 0x7d, 0x7d, 0x7c, 0x7c, 0x7c, 0x7b, 0x7b, 0x7a, 0x7a, 0x7a, 0x79, 0x79, 0x78, 0x78, 0x78, 0x77, 0x77, 0x77, 0x76, 0x76, 0x75, 0x75, 0x75, 0x74, 0x74, 0x73, 0x73, 0x73, 0x72, 0x72, 0x71, 0x71, 0x71, 0x70, 0x70, 0x70, 0x6f, 0x6f, 0x6e, 0x6e, 0x6e, 0x6d, 0x6d, 0x6c, 0x6c, 0x6c, 0x6b, 0x6b, 0x6a, 0x6a, 0x6a, 0x69, 0x69, 0x69, 0x68, 0x68, 0x67, 0x67, 0x67, 0x66, 0x66, 0x65, 0x65, 0x65, 0x64, 0x64, 0x64, 0x63, 0x63, 0x62, 0x62, 0x62, 0x61, 0x61, 0x61, 0x60,
+ 0x60, 0x5f, 0x5f, 0x5f, 0x5e, 0x5e, 0x5d, 0x5d, 0x5d, 0x5c, 0x5c, 0x5c, 0x5b, 0x5b, 0x5a, 0x5a, 0x5a, 0x59, 0x59, 0x59, 0x58, 0x58, 0x58, 0x57, 0x57, 0x56, 0x56, 0x56, 0x55, 0x55, 0x55, 0x54, 0x54, 0x53, 0x53, 0x53, 0x52, 0x52, 0x52, 0x51, 0x51, 0x51, 0x50, 0x50, 0x4f, 0x4f, 0x4f, 0x4e, 0x4e, 0x4e, 0x4d, 0x4d, 0x4d, 0x4c, 0x4c, 0x4b, 0x4b, 0x4b, 0x4a, 0x4a, 0x4a, 0x49, 0x49, 0x49, 0x48, 0x48, 0x48, 0x47, 0x47, 0x47, 0x46, 0x46, 0x45, 0x45, 0x45, 0x44, 0x44, 0x44, 0x43, 0x43, 0x43, 0x42, 0x42, 0x42, 0x41, 0x41, 0x41, 0x40, 0x40, 0x40, 0x3f, 0x3f, 0x3f, 0x3e, 0x3e, 0x3e, 0x3d, 0x3d, 0x3d, 0x3c, 0x3c, 0x3c, 0x3b, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39, 0x39, 0x39, 0x38, 0x38, 0x38, 0x37, 0x37, 0x37, 0x36, 0x36, 0x36, 0x35, 0x35, 0x35, 0x34, 0x34, 0x34, 0x34, 0x33, 0x33, 0x33, 0x32, 0x32, 0x32, 0x31, 0x31, 0x31, 0x30, 0x30, 0x30, 0x30, 0x2f, 0x2f, 0x2f, 0x2e, 0x2e, 0x2e, 0x2d, 0x2d, 0x2d, 0x2d, 0x2c, 0x2c, 0x2c, 0x2b, 0x2b, 0x2b, 0x2a, 0x2a,
+ 0x2a, 0x2a, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x27, 0x27, 0x27, 0x26, 0x26, 0x26, 0x26, 0x25, 0x25, 0x25, 0x25, 0x24, 0x24, 0x24, 0x23, 0x23, 0x23, 0x23, 0x22, 0x22, 0x22, 0x22, 0x21, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e, 0x1e, 0x1d, 0x1d, 0x1d, 0x1d, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1a, 0x1a, 0x1a, 0x1a, 0x19, 0x19, 0x19, 0x19, 0x18, 0x18, 0x18, 0x18, 0x17, 0x17, 0x17, 0x17, 0x17, 0x16, 0x16, 0x16, 0x16, 0x15, 0x15, 0x15, 0x15, 0x15, 0x14, 0x14, 0x14, 0x14, 0x14, 0x13, 0x13, 0x13, 0x13, 0x13, 0x12, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x10, 0x10, 0x10, 0x10, 0x10, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xe, 0xe, 0xe, 0xe, 0xe, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xc, 0xc, 0xc, 0xc, 0xc, 0xc, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x8, 0x8, 0x8, 0x8, 0x8,
+ 0x8, 0x8, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
+ 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xa, 0xb, 0xb, 0xb, 0xb, 0xb, 0xb, 0xc, 0xc, 0xc, 0xc, 0xc, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xe, 0xe, 0xe, 0xe, 0xe, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17,
+ 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1a, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3c, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e, 0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x46,
+ 0x46, 0x47, 0x47, 0x47, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5f, 0x5f, 0x5f, 0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x63, 0x63, 0x64, 0x64, 0x64, 0x65, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b, 0x6c, 0x6c, 0x6c, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, 0x70, 0x70, 0x70, 0x71, 0x71, 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x74, 0x75, 0x75, 0x75, 0x76, 0x76, 0x77, 0x77, 0x77, 0x78, 0x78, 0x78, 0x79, 0x79, 0x7a, 0x7a, 0x7a, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x7f, 0x7f};
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c
new file mode 100644
index 0000000000..708022f68f
--- /dev/null
+++ b/quantum/backlight/backlight.c
@@ -0,0 +1,193 @@
+/*
+Copyright 2013 Mathias Andersson <wraul@dbox.se>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "backlight.h"
+#include "eeconfig.h"
+#include "debug.h"
+
+backlight_config_t backlight_config;
+
+/** \brief Backlight initialization
+ *
+ * FIXME: needs doc
+ */
+void backlight_init(void) {
+ /* check signature */
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+ backlight_config.raw = eeconfig_read_backlight();
+ if (backlight_config.level > BACKLIGHT_LEVELS) {
+ backlight_config.level = BACKLIGHT_LEVELS;
+ }
+ backlight_set(backlight_config.enable ? backlight_config.level : 0);
+}
+
+/** \brief Backlight increase
+ *
+ * FIXME: needs doc
+ */
+void backlight_increase(void) {
+ if (backlight_config.level < BACKLIGHT_LEVELS) {
+ backlight_config.level++;
+ }
+ backlight_config.enable = 1;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight increase: %u\n", backlight_config.level);
+ backlight_set(backlight_config.level);
+}
+
+/** \brief Backlight decrease
+ *
+ * FIXME: needs doc
+ */
+void backlight_decrease(void) {
+ if (backlight_config.level > 0) {
+ backlight_config.level--;
+ backlight_config.enable = !!backlight_config.level;
+ eeconfig_update_backlight(backlight_config.raw);
+ }
+ dprintf("backlight decrease: %u\n", backlight_config.level);
+ backlight_set(backlight_config.level);
+}
+
+/** \brief Backlight toggle
+ *
+ * FIXME: needs doc
+ */
+void backlight_toggle(void) {
+ bool enabled = backlight_config.enable;
+ dprintf("backlight toggle: %u\n", enabled);
+ if (enabled)
+ backlight_disable();
+ else
+ backlight_enable();
+}
+
+/** \brief Enable backlight
+ *
+ * FIXME: needs doc
+ */
+void backlight_enable(void) {
+ if (backlight_config.enable) return; // do nothing if backlight is already on
+
+ backlight_config.enable = true;
+ if (backlight_config.raw == 1) // enabled but level == 0
+ backlight_config.level = 1;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight enable\n");
+ backlight_set(backlight_config.level);
+}
+
+/** \brief Disable backlight
+ *
+ * FIXME: needs doc
+ */
+void backlight_disable(void) {
+ if (!backlight_config.enable) return; // do nothing if backlight is already off
+
+ backlight_config.enable = false;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight disable\n");
+ backlight_set(0);
+}
+
+/** /brief Get the backlight status
+ *
+ * FIXME: needs doc
+ */
+bool is_backlight_enabled(void) { return backlight_config.enable; }
+
+/** \brief Backlight step through levels
+ *
+ * FIXME: needs doc
+ */
+void backlight_step(void) {
+ backlight_config.level++;
+ if (backlight_config.level > BACKLIGHT_LEVELS) {
+ backlight_config.level = 0;
+ }
+ backlight_config.enable = !!backlight_config.level;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight step: %u\n", backlight_config.level);
+ backlight_set(backlight_config.level);
+}
+
+/** \brief Backlight set level
+ *
+ * FIXME: needs doc
+ */
+void backlight_level(uint8_t level) {
+ if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS;
+ backlight_config.level = level;
+ backlight_config.enable = !!backlight_config.level;
+ eeconfig_update_backlight(backlight_config.raw);
+ backlight_set(backlight_config.level);
+}
+
+/** \brief Get backlight level
+ *
+ * FIXME: needs doc
+ */
+uint8_t get_backlight_level(void) { return backlight_config.level; }
+
+#ifdef BACKLIGHT_BREATHING
+/** \brief Backlight breathing toggle
+ *
+ * FIXME: needs doc
+ */
+void backlight_toggle_breathing(void) {
+ bool breathing = backlight_config.breathing;
+ dprintf("backlight breathing toggle: %u\n", breathing);
+ if (breathing)
+ backlight_disable_breathing();
+ else
+ backlight_enable_breathing();
+}
+
+/** \brief Enable backlight breathing
+ *
+ * FIXME: needs doc
+ */
+void backlight_enable_breathing(void) {
+ if (backlight_config.breathing) return; // do nothing if breathing is already on
+
+ backlight_config.breathing = true;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight breathing enable\n");
+ breathing_enable();
+}
+
+/** \brief Disable backlight breathing
+ *
+ * FIXME: needs doc
+ */
+void backlight_disable_breathing(void) {
+ if (!backlight_config.breathing) return; // do nothing if breathing is already off
+
+ backlight_config.breathing = false;
+ eeconfig_update_backlight(backlight_config.raw);
+ dprintf("backlight breathing disable\n");
+ breathing_disable();
+}
+
+/** \brief Get the backlight breathing status
+ *
+ * FIXME: needs doc
+ */
+bool is_backlight_breathing(void) { return backlight_config.breathing; }
+#endif
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h
new file mode 100644
index 0000000000..1e581055db
--- /dev/null
+++ b/quantum/backlight/backlight.h
@@ -0,0 +1,62 @@
+/*
+Copyright 2013 Mathias Andersson <wraul@dbox.se>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifndef BACKLIGHT_LEVELS
+# define BACKLIGHT_LEVELS 3
+#elif BACKLIGHT_LEVELS > 31
+# error "Maximum value of BACKLIGHT_LEVELS is 31"
+#endif
+
+#ifndef BREATHING_PERIOD
+# define BREATHING_PERIOD 6
+#endif
+
+typedef union {
+ uint8_t raw;
+ struct {
+ bool enable : 1;
+ bool breathing : 1;
+ uint8_t reserved : 1; // Reserved for possible future backlight modes
+ uint8_t level : 5;
+ };
+} backlight_config_t;
+
+void backlight_init(void);
+void backlight_increase(void);
+void backlight_decrease(void);
+void backlight_toggle(void);
+void backlight_enable(void);
+void backlight_disable(void);
+bool is_backlight_enabled(void);
+void backlight_step(void);
+void backlight_set(uint8_t level);
+void backlight_level(uint8_t level);
+uint8_t get_backlight_level(void);
+
+#ifdef BACKLIGHT_BREATHING
+void backlight_toggle_breathing(void);
+void backlight_enable_breathing(void);
+void backlight_disable_breathing(void);
+bool is_backlight_breathing(void);
+void breathing_enable(void);
+void breathing_disable(void);
+#endif
diff --git a/quantum/backlight/backlight_arm.c b/quantum/backlight/backlight_arm.c
new file mode 100644
index 0000000000..3f94ccef8e
--- /dev/null
+++ b/quantum/backlight/backlight_arm.c
@@ -0,0 +1,218 @@
+#include "quantum.h"
+#include "backlight.h"
+#include <hal.h>
+#include "debug.h"
+
+// TODO: remove short term bodge when refactoring BACKLIGHT_CUSTOM_DRIVER out
+#ifdef BACKLIGHT_PIN
+
+# if defined(STM32F0XX) || defined(STM32F0xx)
+# error "Backlight support for STMF072 is not available. Please disable."
+# endif
+
+# if defined(STM32F1XX) || defined(STM32F1xx)
+# define USE_GPIOV1
+# endif
+
+// GPIOV2 && GPIOV3
+# ifndef BACKLIGHT_PAL_MODE
+# define BACKLIGHT_PAL_MODE 2
+# endif
+
+// GENERIC
+# ifndef BACKLIGHT_PWM_DRIVER
+# define BACKLIGHT_PWM_DRIVER PWMD4
+# endif
+# ifndef BACKLIGHT_PWM_CHANNEL
+# define BACKLIGHT_PWM_CHANNEL 3
+# endif
+
+static void breathing_callback(PWMDriver *pwmp);
+
+static PWMConfig pwmCFG = {0xFFFF, /* PWM clock frequency */
+ 256, /* PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */
+ NULL, /* No Callback */
+ { /* Default all channels to disabled - Channels will be configured durring init */
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL}},
+ 0, /* HW dependent part.*/
+ 0};
+
+static PWMConfig pwmCFG_breathing = {0xFFFF, /** PWM clock frequency */
+ 256, /* PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */
+ breathing_callback, /* Breathing Callback */
+ { /* Default all channels to disabled - Channels will be configured durring init */
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL}},
+ 0, /* HW dependent part.*/
+ 0};
+
+// See http://jared.geek.nz/2013/feb/linear-led-pwm
+static uint16_t cie_lightness(uint16_t v) {
+ if (v <= 5243) // if below 8% of max
+ return v / 9; // same as dividing by 900%
+ else {
+ uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
+ // to get a useful result with integer division, we shift left in the expression above
+ // and revert what we've done again after squaring.
+ y = y * y * y >> 8;
+ if (y > 0xFFFFUL) // prevent overflow
+ return 0xFFFFU;
+ else
+ return (uint16_t)y;
+ }
+}
+
+void backlight_init_ports(void) {
+ // printf("backlight_init_ports()\n");
+
+# ifdef USE_GPIOV1
+ palSetPadMode(PAL_PORT(BACKLIGHT_PIN), PAL_PAD(BACKLIGHT_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL);
+# else
+ palSetPadMode(PAL_PORT(BACKLIGHT_PIN), PAL_PAD(BACKLIGHT_PIN), PAL_MODE_ALTERNATE(BACKLIGHT_PAL_MODE));
+# endif
+
+ pwmCFG.channels[BACKLIGHT_PWM_CHANNEL - 1].mode = PWM_OUTPUT_ACTIVE_HIGH;
+ pwmCFG_breathing.channels[BACKLIGHT_PWM_CHANNEL - 1].mode = PWM_OUTPUT_ACTIVE_HIGH;
+ pwmStart(&BACKLIGHT_PWM_DRIVER, &pwmCFG);
+
+ backlight_set(get_backlight_level());
+ if (is_backlight_breathing()) {
+ breathing_enable();
+ }
+}
+
+void backlight_set(uint8_t level) {
+ // printf("backlight_set(%d)\n", level);
+ if (level == 0) {
+ // Turn backlight off
+ pwmDisableChannel(&BACKLIGHT_PWM_DRIVER, BACKLIGHT_PWM_CHANNEL - 1);
+ } else {
+ // Turn backlight on
+ if (!is_breathing()) {
+ uint32_t duty = (uint32_t)(cie_lightness(0xFFFF * (uint32_t)level / BACKLIGHT_LEVELS));
+ // printf("duty: (%d)\n", duty);
+ pwmEnableChannel(&BACKLIGHT_PWM_DRIVER, BACKLIGHT_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&BACKLIGHT_PWM_DRIVER, 0xFFFF, duty));
+ }
+ }
+}
+
+uint8_t backlight_tick = 0;
+
+void backlight_task(void) {}
+
+# define BREATHING_NO_HALT 0
+# define BREATHING_HALT_OFF 1
+# define BREATHING_HALT_ON 2
+# define BREATHING_STEPS 128
+
+static uint8_t breathing_period = BREATHING_PERIOD;
+static uint8_t breathing_halt = BREATHING_NO_HALT;
+static uint16_t breathing_counter = 0;
+
+bool is_breathing(void) { return BACKLIGHT_PWM_DRIVER.config == &pwmCFG_breathing; }
+
+static inline void breathing_min(void) { breathing_counter = 0; }
+
+static inline void breathing_max(void) { breathing_counter = breathing_period * 256 / 2; }
+
+void breathing_interrupt_enable(void) {
+ pwmStop(&BACKLIGHT_PWM_DRIVER);
+ pwmStart(&BACKLIGHT_PWM_DRIVER, &pwmCFG_breathing);
+ chSysLockFromISR();
+ pwmEnablePeriodicNotification(&BACKLIGHT_PWM_DRIVER);
+ pwmEnableChannelI(&BACKLIGHT_PWM_DRIVER, BACKLIGHT_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&BACKLIGHT_PWM_DRIVER, 0xFFFF, 0xFFFF));
+ chSysUnlockFromISR();
+}
+
+void breathing_interrupt_disable(void) {
+ pwmStop(&BACKLIGHT_PWM_DRIVER);
+ pwmStart(&BACKLIGHT_PWM_DRIVER, &pwmCFG);
+}
+
+void breathing_enable(void) {
+ breathing_counter = 0;
+ breathing_halt = BREATHING_NO_HALT;
+ breathing_interrupt_enable();
+}
+
+void breathing_pulse(void) {
+ if (get_backlight_level() == 0)
+ breathing_min();
+ else
+ breathing_max();
+ breathing_halt = BREATHING_HALT_ON;
+ breathing_interrupt_enable();
+}
+
+void breathing_disable(void) {
+ // printf("breathing_disable()\n");
+ breathing_interrupt_disable();
+ // Restore backlight level
+ backlight_set(get_backlight_level());
+}
+
+void breathing_self_disable(void) {
+ if (get_backlight_level() == 0)
+ breathing_halt = BREATHING_HALT_OFF;
+ else
+ breathing_halt = BREATHING_HALT_ON;
+}
+
+void breathing_toggle(void) {
+ if (is_breathing())
+ breathing_disable();
+ else
+ breathing_enable();
+}
+
+void breathing_period_set(uint8_t value) {
+ if (!value) value = 1;
+ breathing_period = value;
+}
+
+void breathing_period_default(void) { breathing_period_set(BREATHING_PERIOD); }
+
+void breathing_period_inc(void) { breathing_period_set(breathing_period + 1); }
+
+void breathing_period_dec(void) { breathing_period_set(breathing_period - 1); }
+
+/* To generate breathing curve in python:
+ * from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
+ */
+static 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};
+
+// Use this before the cie_lightness function.
+static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); }
+
+static void breathing_callback(PWMDriver *pwmp) {
+ (void)pwmp;
+ uint16_t interval = (uint16_t)breathing_period * 256 / BREATHING_STEPS;
+ // resetting after one period to prevent ugly reset at overflow.
+ breathing_counter = (breathing_counter + 1) % (breathing_period * 256);
+ uint8_t index = breathing_counter / interval % BREATHING_STEPS;
+
+ if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) || ((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1))) {
+ breathing_interrupt_disable();
+ }
+
+ uint32_t duty = cie_lightness(scale_backlight(breathing_table[index] * 256));
+
+ chSysLockFromISR();
+ pwmEnableChannelI(&BACKLIGHT_PWM_DRIVER, BACKLIGHT_PWM_CHANNEL - 1, PWM_FRACTION_TO_WIDTH(&BACKLIGHT_PWM_DRIVER, 0xFFFF, duty));
+ chSysUnlockFromISR();
+}
+
+#else
+
+__attribute__((weak)) void backlight_init_ports(void) {}
+
+__attribute__((weak)) void backlight_set(uint8_t level) {}
+
+__attribute__((weak)) void backlight_task(void) {}
+
+#endif
diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c
new file mode 100644
index 0000000000..edda6ea0b6
--- /dev/null
+++ b/quantum/backlight/backlight_avr.c
@@ -0,0 +1,509 @@
+#include "quantum.h"
+#include "backlight.h"
+#include "debug.h"
+
+#if defined(BACKLIGHT_ENABLE) && (defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS))
+
+// This logic is a bit complex, we support 3 setups:
+//
+// 1. Hardware PWM when backlight is wired to a PWM pin.
+// Depending on this pin, we use a different output compare unit.
+// 2. Software PWM with hardware timers, but the used timer
+// depends on the Audio setup (Audio wins over Backlight).
+// 3. Full software PWM, driven by the matrix scan, if both timers are used by Audio.
+
+# if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) && (BACKLIGHT_PIN == B5 || BACKLIGHT_PIN == B6 || BACKLIGHT_PIN == B7)
+# define HARDWARE_PWM
+# define ICRx ICR1
+# define TCCRxA TCCR1A
+# define TCCRxB TCCR1B
+# define TIMERx_OVF_vect TIMER1_OVF_vect
+# define TIMSKx TIMSK1
+# define TOIEx TOIE1
+
+# if BACKLIGHT_PIN == B5
+# define COMxx1 COM1A1
+# define OCRxx OCR1A
+# elif BACKLIGHT_PIN == B6
+# define COMxx1 COM1B1
+# define OCRxx OCR1B
+# elif BACKLIGHT_PIN == B7
+# define COMxx1 COM1C1
+# define OCRxx OCR1C
+# endif
+# elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) && (BACKLIGHT_PIN == C4 || BACKLIGHT_PIN == C5 || BACKLIGHT_PIN == C6)
+# define HARDWARE_PWM
+# define ICRx ICR3
+# define TCCRxA TCCR3A
+# define TCCRxB TCCR3B
+# define TIMERx_OVF_vect TIMER3_OVF_vect
+# define TIMSKx TIMSK3
+# define TOIEx TOIE3
+
+# if BACKLIGHT_PIN == C4
+# if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+# error This MCU has no C4 pin!
+# else
+# define COMxx1 COM3C1
+# define OCRxx OCR3C
+# endif
+# elif BACKLIGHT_PIN == C5
+# if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+# error This MCU has no C5 pin!
+# else
+# define COMxx1 COM3B1
+# define OCRxx OCR3B
+# endif
+# elif BACKLIGHT_PIN == C6
+# define COMxx1 COM3A1
+# define OCRxx OCR3A
+# endif
+# elif (defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)) && (BACKLIGHT_PIN == B7 || BACKLIGHT_PIN == C5 || BACKLIGHT_PIN == C6)
+# define HARDWARE_PWM
+# define ICRx ICR1
+# define TCCRxA TCCR1A
+# define TCCRxB TCCR1B
+# define TIMERx_OVF_vect TIMER1_OVF_vect
+# define TIMSKx TIMSK1
+# define TOIEx TOIE1
+
+# if BACKLIGHT_PIN == B7
+# define COMxx1 COM1C1
+# define OCRxx OCR1C
+# elif BACKLIGHT_PIN == C5
+# define COMxx1 COM1B1
+# define OCRxx OCR1B
+# elif BACKLIGHT_PIN == C6
+# define COMxx1 COM1A1
+# define OCRxx OCR1A
+# endif
+# elif defined(__AVR_ATmega32A__) && (BACKLIGHT_PIN == D4 || BACKLIGHT_PIN == D5)
+# define HARDWARE_PWM
+# define ICRx ICR1
+# define TCCRxA TCCR1A
+# define TCCRxB TCCR1B
+# define TIMERx_OVF_vect TIMER1_OVF_vect
+# define TIMSKx TIMSK
+# define TOIEx TOIE1
+
+# if BACKLIGHT_PIN == D4
+# define COMxx1 COM1B1
+# define OCRxx OCR1B
+# elif BACKLIGHT_PIN == D5
+# define COMxx1 COM1A1
+# define OCRxx OCR1A
+# endif
+# elif defined(__AVR_ATmega328P__) && (BACKLIGHT_PIN == B1 || BACKLIGHT_PIN == B2)
+# define HARDWARE_PWM
+# define ICRx ICR1
+# define TCCRxA TCCR1A
+# define TCCRxB TCCR1B
+# define TIMERx_OVF_vect TIMER1_OVF_vect
+# define TIMSKx TIMSK1
+# define TOIEx TOIE1
+
+# if BACKLIGHT_PIN == B1
+# define COMxx1 COM1A1
+# define OCRxx OCR1A
+# elif BACKLIGHT_PIN == B2
+# define COMxx1 COM1B1
+# define OCRxx OCR1B
+# endif
+# else
+# if !defined(BACKLIGHT_CUSTOM_DRIVER)
+# if !defined(B5_AUDIO) && !defined(B6_AUDIO) && !defined(B7_AUDIO)
+// Timer 1 is not in use by Audio feature, Backlight can use it
+# pragma message "Using hardware timer 1 with software PWM"
+# define HARDWARE_PWM
+# define BACKLIGHT_PWM_TIMER
+# define ICRx ICR1
+# define TCCRxA TCCR1A
+# define TCCRxB TCCR1B
+# define TIMERx_COMPA_vect TIMER1_COMPA_vect
+# define TIMERx_OVF_vect TIMER1_OVF_vect
+# if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register
+# define TIMSKx TIMSK
+# else
+# define TIMSKx TIMSK1
+# endif
+# define TOIEx TOIE1
+
+# define OCIExA OCIE1A
+# define OCRxx OCR1A
+# elif !defined(C6_AUDIO) && !defined(C5_AUDIO) && !defined(C4_AUDIO)
+# pragma message "Using hardware timer 3 with software PWM"
+// Timer 3 is not in use by Audio feature, Backlight can use it
+# define HARDWARE_PWM
+# define BACKLIGHT_PWM_TIMER
+# define ICRx ICR1
+# define TCCRxA TCCR3A
+# define TCCRxB TCCR3B
+# define TIMERx_COMPA_vect TIMER3_COMPA_vect
+# define TIMERx_OVF_vect TIMER3_OVF_vect
+# define TIMSKx TIMSK3
+# define TOIEx TOIE3
+
+# define OCIExA OCIE3A
+# define OCRxx OCR3A
+# else
+# pragma message "Audio in use - using pure software PWM"
+# define NO_HARDWARE_PWM
+# endif
+# else
+# pragma message "Custom driver defined - using pure software PWM"
+# define NO_HARDWARE_PWM
+# endif
+# endif
+
+# ifndef BACKLIGHT_ON_STATE
+# define BACKLIGHT_ON_STATE 0
+# endif
+
+void backlight_on(pin_t backlight_pin) {
+# if BACKLIGHT_ON_STATE == 0
+ writePinLow(backlight_pin);
+# else
+ writePinHigh(backlight_pin);
+# endif
+}
+
+void backlight_off(pin_t backlight_pin) {
+# if BACKLIGHT_ON_STATE == 0
+ writePinHigh(backlight_pin);
+# else
+ writePinLow(backlight_pin);
+# endif
+}
+
+# if defined(NO_HARDWARE_PWM) || defined(BACKLIGHT_PWM_TIMER) // pwm through software
+
+// we support multiple backlight pins
+# ifndef BACKLIGHT_LED_COUNT
+# define BACKLIGHT_LED_COUNT 1
+# endif
+
+# if BACKLIGHT_LED_COUNT == 1
+# define BACKLIGHT_PIN_INIT \
+ { BACKLIGHT_PIN }
+# else
+# define BACKLIGHT_PIN_INIT BACKLIGHT_PINS
+# endif
+
+# define FOR_EACH_LED(x) \
+ for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \
+ pin_t backlight_pin = backlight_pins[i]; \
+ { x } \
+ }
+
+static const pin_t backlight_pins[BACKLIGHT_LED_COUNT] = BACKLIGHT_PIN_INIT;
+
+# else // full hardware PWM
+
+// we support only one backlight pin
+static const pin_t backlight_pin = BACKLIGHT_PIN;
+# define FOR_EACH_LED(x) x
+
+# endif
+
+# ifdef NO_HARDWARE_PWM
+__attribute__((weak)) void backlight_init_ports(void) {
+ // Setup backlight pin as output and output to on state.
+ FOR_EACH_LED(setPinOutput(backlight_pin); backlight_on(backlight_pin);)
+
+# ifdef BACKLIGHT_BREATHING
+ if (is_backlight_breathing()) {
+ breathing_enable();
+ }
+# endif
+}
+
+__attribute__((weak)) void backlight_set(uint8_t level) {}
+
+uint8_t backlight_tick = 0;
+
+# ifndef BACKLIGHT_CUSTOM_DRIVER
+void backlight_task(void) {
+ if ((0xFFFF >> ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) {
+ FOR_EACH_LED(backlight_on(backlight_pin);)
+ } else {
+ FOR_EACH_LED(backlight_off(backlight_pin);)
+ }
+ backlight_tick = (backlight_tick + 1) % 16;
+}
+# endif
+
+# ifdef BACKLIGHT_BREATHING
+# ifndef BACKLIGHT_CUSTOM_DRIVER
+# error "Backlight breathing only available with hardware PWM. Please disable."
+# endif
+# endif
+
+# else // hardware pwm through timer
+
+# ifdef BACKLIGHT_PWM_TIMER
+
+// The idea of software PWM assisted by hardware timers is the following
+// we use the hardware timer in fast PWM mode like for hardware PWM, but
+// instead of letting the Output Match Comparator control the led pin
+// (which is not possible since the backlight is not wired to PWM pins on the
+// CPU), we do the LED on/off by oursleves.
+// The timer is setup to count up to 0xFFFF, and we set the Output Compare
+// register to the current 16bits backlight level (after CIE correction).
+// This means the CPU will trigger a compare match interrupt when the counter
+// reaches the backlight level, where we turn off the LEDs,
+// but also an overflow interrupt when the counter rolls back to 0,
+// in which we're going to turn on the LEDs.
+// The LED will then be on for OCRxx/0xFFFF time, adjusted every 244Hz.
+
+// Triggered when the counter reaches the OCRx value
+ISR(TIMERx_COMPA_vect) { FOR_EACH_LED(backlight_off(backlight_pin);) }
+
+// Triggered when the counter reaches the TOP value
+// this one triggers at F_CPU/65536 =~ 244 Hz
+ISR(TIMERx_OVF_vect) {
+# ifdef BACKLIGHT_BREATHING
+ if (is_breathing()) {
+ breathing_task();
+ }
+# endif
+ // for very small values of OCRxx (or backlight level)
+ // we can't guarantee this whole code won't execute
+ // at the same time as the compare match interrupt
+ // which means that we might turn on the leds while
+ // trying to turn them off, leading to flickering
+ // artifacts (especially while breathing, because breathing_task
+ // takes many computation cycles).
+ // so better not turn them on while the counter TOP is very low.
+ if (OCRxx > 256) {
+ FOR_EACH_LED(backlight_on(backlight_pin);)
+ }
+}
+
+# endif
+
+# define TIMER_TOP 0xFFFFU
+
+// See http://jared.geek.nz/2013/feb/linear-led-pwm
+static uint16_t cie_lightness(uint16_t v) {
+ if (v <= 5243) // if below 8% of max
+ return v / 9; // same as dividing by 900%
+ else {
+ uint32_t y = (((uint32_t)v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
+ // to get a useful result with integer division, we shift left in the expression above
+ // and revert what we've done again after squaring.
+ y = y * y * y >> 8;
+ if (y > 0xFFFFUL) // prevent overflow
+ return 0xFFFFU;
+ else
+ return (uint16_t)y;
+ }
+}
+
+// range for val is [0..TIMER_TOP]. PWM pin is high while the timer count is below val.
+static inline void set_pwm(uint16_t val) { OCRxx = val; }
+
+# ifndef BACKLIGHT_CUSTOM_DRIVER
+__attribute__((weak)) void backlight_set(uint8_t level) {
+ if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS;
+
+ if (level == 0) {
+# ifdef BACKLIGHT_PWM_TIMER
+ if (OCRxx) {
+ TIMSKx &= ~(_BV(OCIExA));
+ TIMSKx &= ~(_BV(TOIEx));
+ FOR_EACH_LED(backlight_off(backlight_pin);)
+ }
+# else
+ // Turn off PWM control on backlight pin
+ TCCRxA &= ~(_BV(COMxx1));
+# endif
+ } else {
+# ifdef BACKLIGHT_PWM_TIMER
+ if (!OCRxx) {
+ TIMSKx |= _BV(OCIExA);
+ TIMSKx |= _BV(TOIEx);
+ }
+# else
+ // Turn on PWM control of backlight pin
+ TCCRxA |= _BV(COMxx1);
+# endif
+ }
+ // Set the brightness
+ set_pwm(cie_lightness(TIMER_TOP * (uint32_t)level / BACKLIGHT_LEVELS));
+}
+
+void backlight_task(void) {}
+# endif // BACKLIGHT_CUSTOM_DRIVER
+
+# ifdef BACKLIGHT_BREATHING
+
+# define BREATHING_NO_HALT 0
+# define BREATHING_HALT_OFF 1
+# define BREATHING_HALT_ON 2
+# define BREATHING_STEPS 128
+
+static uint8_t breathing_period = BREATHING_PERIOD;
+static uint8_t breathing_halt = BREATHING_NO_HALT;
+static uint16_t breathing_counter = 0;
+
+# ifdef BACKLIGHT_PWM_TIMER
+static bool breathing = false;
+
+bool is_breathing(void) { return breathing; }
+
+# define breathing_interrupt_enable() \
+ do { \
+ breathing = true; \
+ } while (0)
+# define breathing_interrupt_disable() \
+ do { \
+ breathing = false; \
+ } while (0)
+# else
+
+bool is_breathing(void) { return !!(TIMSKx & _BV(TOIEx)); }
+
+# define breathing_interrupt_enable() \
+ do { \
+ TIMSKx |= _BV(TOIEx); \
+ } while (0)
+# define breathing_interrupt_disable() \
+ do { \
+ TIMSKx &= ~_BV(TOIEx); \
+ } while (0)
+# endif
+
+# define breathing_min() \
+ do { \
+ breathing_counter = 0; \
+ } while (0)
+# define breathing_max() \
+ do { \
+ breathing_counter = breathing_period * 244 / 2; \
+ } while (0)
+
+void breathing_enable(void) {
+ breathing_counter = 0;
+ breathing_halt = BREATHING_NO_HALT;
+ breathing_interrupt_enable();
+}
+
+void breathing_pulse(void) {
+ if (get_backlight_level() == 0)
+ breathing_min();
+ else
+ breathing_max();
+ breathing_halt = BREATHING_HALT_ON;
+ breathing_interrupt_enable();
+}
+
+void breathing_disable(void) {
+ breathing_interrupt_disable();
+ // Restore backlight level
+ backlight_set(get_backlight_level());
+}
+
+void breathing_self_disable(void) {
+ if (get_backlight_level() == 0)
+ breathing_halt = BREATHING_HALT_OFF;
+ else
+ breathing_halt = BREATHING_HALT_ON;
+}
+
+void breathing_toggle(void) {
+ if (is_breathing())
+ breathing_disable();
+ else
+ breathing_enable();
+}
+
+void breathing_period_set(uint8_t value) {
+ if (!value) value = 1;
+ breathing_period = value;
+}
+
+void breathing_period_default(void) { breathing_period_set(BREATHING_PERIOD); }
+
+void breathing_period_inc(void) { breathing_period_set(breathing_period + 1); }
+
+void breathing_period_dec(void) { breathing_period_set(breathing_period - 1); }
+
+/* To generate breathing curve in python:
+ * from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
+ */
+static 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};
+
+// Use this before the cie_lightness function.
+static inline uint16_t scale_backlight(uint16_t v) { return v / BACKLIGHT_LEVELS * get_backlight_level(); }
+
+# ifdef BACKLIGHT_PWM_TIMER
+void breathing_task(void)
+# else
+/* Assuming a 16MHz CPU clock and a timer that resets at 64k (ICR1), the following interrupt handler will run
+ * about 244 times per second.
+ */
+ISR(TIMERx_OVF_vect)
+# endif
+{
+ uint16_t interval = (uint16_t)breathing_period * 244 / BREATHING_STEPS;
+ // resetting after one period to prevent ugly reset at overflow.
+ breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
+ uint8_t index = breathing_counter / interval % BREATHING_STEPS;
+
+ if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) || ((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1))) {
+ breathing_interrupt_disable();
+ }
+
+ set_pwm(cie_lightness(scale_backlight((uint16_t)pgm_read_byte(&breathing_table[index]) * 0x0101U)));
+}
+
+# endif // BACKLIGHT_BREATHING
+
+__attribute__((weak)) void backlight_init_ports(void) {
+ // Setup backlight pin as output and output to on state.
+ FOR_EACH_LED(setPinOutput(backlight_pin); backlight_on(backlight_pin);)
+
+ // I could write a wall of text here to explain... but TL;DW
+ // Go read the ATmega32u4 datasheet.
+ // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
+
+# ifdef BACKLIGHT_PWM_TIMER
+ // TimerX setup, Fast PWM mode count to TOP set in ICRx
+ TCCRxA = _BV(WGM11); // = 0b00000010;
+ // clock select clk/1
+ TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+# else // hardware PWM
+ // Pin PB7 = OCR1C (Timer 1, Channel C)
+ // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
+ // (i.e. start high, go low when counter matches.)
+ // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
+ // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
+
+ /*
+ 14.8.3:
+ "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 [..]."
+ "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)."
+ */
+ TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010;
+ TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+# endif
+ // Use full 16-bit resolution. Counter counts to ICR1 before reset to 0.
+ ICRx = TIMER_TOP;
+
+ backlight_init();
+# ifdef BACKLIGHT_BREATHING
+ if (is_backlight_breathing()) {
+ breathing_enable();
+ }
+# endif
+}
+
+# endif // hardware backlight
+
+#else // no backlight
+
+__attribute__((weak)) void backlight_init_ports(void) {}
+
+__attribute__((weak)) void backlight_set(uint8_t level) {}
+
+#endif // backlight \ No newline at end of file
diff --git a/quantum/backlight/backlight_soft.c b/quantum/backlight/backlight_soft.c
new file mode 100644
index 0000000000..a6aba7782c
--- /dev/null
+++ b/quantum/backlight/backlight_soft.c
@@ -0,0 +1,66 @@
+#include "quantum.h"
+#include "backlight.h"
+
+#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS)
+# error "Backlight pin/pins not defined. Please configure."
+#endif
+
+#ifdef BACKLIGHT_BREATHING
+# error "Backlight breathing is not available for software PWM. Please disable."
+#endif
+
+#ifndef BACKLIGHT_ON_STATE
+# define BACKLIGHT_ON_STATE 0
+#endif
+
+#ifdef BACKLIGHT_PINS
+# define BACKLIGHT_PIN_INIT BACKLIGHT_PINS
+#else
+# define BACKLIGHT_PIN_INIT \
+ { BACKLIGHT_PIN }
+#endif
+
+static const pin_t backlight_pins[] = BACKLIGHT_PIN_INIT;
+#define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t))
+
+#define FOR_EACH_LED(x) \
+ for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \
+ pin_t backlight_pin = backlight_pins[i]; \
+ { x } \
+ }
+
+void backlight_on(pin_t backlight_pin) {
+#if BACKLIGHT_ON_STATE == 0
+ writePinLow(backlight_pin);
+#else
+ writePinHigh(backlight_pin);
+#endif
+}
+
+void backlight_off(pin_t backlight_pin) {
+#if BACKLIGHT_ON_STATE == 0
+ writePinHigh(backlight_pin);
+#else
+ writePinLow(backlight_pin);
+#endif
+}
+
+void backlight_init_ports(void) {
+ // Setup backlight pin as output and output to on state.
+ FOR_EACH_LED(setPinOutput(backlight_pin); backlight_on(backlight_pin);)
+}
+
+void backlight_task(void) {
+ static uint8_t backlight_tick = 0;
+
+ if ((0xFFFF >> (get_backlight_level() * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) {
+ FOR_EACH_LED(backlight_on(backlight_pin);)
+ } else {
+ FOR_EACH_LED(backlight_off(backlight_pin);)
+ }
+ backlight_tick = (backlight_tick + 1) % 16;
+}
+
+void backlight_set(uint8_t level) {
+ // noop as backlight_task uses get_backlight_level()
+}
diff --git a/quantum/color.c b/quantum/color.c
index a309da379a..1f398e2403 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -14,81 +14,74 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include "color.h"
#include "led_tables.h"
#include "progmem.h"
-RGB hsv_to_rgb( HSV hsv )
-{
- RGB rgb;
- uint8_t region, remainder, p, q, t;
- uint16_t h, s, v;
+RGB hsv_to_rgb(HSV hsv) {
+ RGB rgb;
+ uint8_t region, remainder, p, q, t;
+ uint16_t h, s, v;
- if ( hsv.s == 0 )
- {
+ if (hsv.s == 0) {
#ifdef USE_CIE1931_CURVE
- rgb.r = rgb.g = rgb.b = pgm_read_byte( &CIE1931_CURVE[hsv.v] );
+ rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
#else
- rgb.r = hsv.v;
- rgb.g = hsv.v;
- rgb.b = hsv.v;
+ rgb.r = hsv.v;
+ rgb.g = hsv.v;
+ rgb.b = hsv.v;
#endif
- return rgb;
- }
-
- h = hsv.h;
- s = hsv.s;
- v = hsv.v;
+ return rgb;
+ }
- region = h * 6 / 255;
- remainder = (h * 2 - region * 85) * 3;
+ h = hsv.h;
+ s = hsv.s;
+#ifdef USE_CIE1931_CURVE
+ v = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
+#else
+ v = hsv.v;
+#endif
- p = (v * (255 - s)) >> 8;
- q = (v * (255 - ((s * remainder) >> 8))) >> 8;
- t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
+ region = h * 6 / 255;
+ remainder = (h * 2 - region * 85) * 3;
- switch ( region )
- {
- case 6:
- case 0:
- rgb.r = v;
- rgb.g = t;
- rgb.b = p;
- break;
- case 1:
- rgb.r = q;
- rgb.g = v;
- rgb.b = p;
- break;
- case 2:
- rgb.r = p;
- rgb.g = v;
- rgb.b = t;
- break;
- case 3:
- rgb.r = p;
- rgb.g = q;
- rgb.b = v;
- break;
- case 4:
- rgb.r = t;
- rgb.g = p;
- rgb.b = v;
- break;
- default:
- rgb.r = v;
- rgb.g = p;
- rgb.b = q;
- break;
- }
+ p = (v * (255 - s)) >> 8;
+ q = (v * (255 - ((s * remainder) >> 8))) >> 8;
+ t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
-#ifdef USE_CIE1931_CURVE
- rgb.r = pgm_read_byte( &CIE1931_CURVE[rgb.r] );
- rgb.g = pgm_read_byte( &CIE1931_CURVE[rgb.g] );
- rgb.b = pgm_read_byte( &CIE1931_CURVE[rgb.b] );
-#endif
+ switch (region) {
+ case 6:
+ case 0:
+ rgb.r = v;
+ rgb.g = t;
+ rgb.b = p;
+ break;
+ case 1:
+ rgb.r = q;
+ rgb.g = v;
+ rgb.b = p;
+ break;
+ case 2:
+ rgb.r = p;
+ rgb.g = v;
+ rgb.b = t;
+ break;
+ case 3:
+ rgb.r = p;
+ rgb.g = q;
+ rgb.b = v;
+ break;
+ case 4:
+ rgb.r = t;
+ rgb.g = p;
+ rgb.b = v;
+ break;
+ default:
+ rgb.r = v;
+ rgb.g = p;
+ rgb.b = q;
+ break;
+ }
- return rgb;
+ return rgb;
}
-
diff --git a/quantum/color.h b/quantum/color.h
index 22bb083519..6781646628 100644
--- a/quantum/color.h
+++ b/quantum/color.h
@@ -14,60 +14,55 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifndef COLOR_H
#define COLOR_H
#include <stdint.h>
#include <stdbool.h>
-
#if defined(__GNUC__)
-#define PACKED __attribute__ ((__packed__))
+# define PACKED __attribute__((__packed__))
#else
-#define PACKED
+# define PACKED
#endif
#if defined(_MSC_VER)
-#pragma pack( push, 1 )
+# pragma pack(push, 1)
#endif
#ifdef RGBW
- #define LED_TYPE cRGBW
+# define LED_TYPE cRGBW
#else
- #define LED_TYPE RGB
+# define LED_TYPE RGB
#endif
// WS2812 specific layout
-typedef struct PACKED
-{
- uint8_t g;
- uint8_t r;
- uint8_t b;
+typedef struct PACKED {
+ uint8_t g;
+ uint8_t r;
+ uint8_t b;
} cRGB;
typedef cRGB RGB;
// WS2812 specific layout
-typedef struct PACKED
-{
- uint8_t g;
- uint8_t r;
- uint8_t b;
- uint8_t w;
+typedef struct PACKED {
+ uint8_t g;
+ uint8_t r;
+ uint8_t b;
+ uint8_t w;
} cRGBW;
-typedef struct PACKED
-{
- uint8_t h;
- uint8_t s;
- uint8_t v;
+typedef struct PACKED {
+ uint8_t h;
+ uint8_t s;
+ uint8_t v;
} HSV;
#if defined(_MSC_VER)
-#pragma pack( pop )
+# pragma pack(pop)
#endif
RGB hsv_to_rgb(HSV hsv);
-#endif // COLOR_H
+#endif // COLOR_H
diff --git a/quantum/config_common.h b/quantum/config_common.h
index bc4d9ec1af..c1c1d4bd42 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -17,284 +17,315 @@
#pragma once
/* diode directions */
-#define COL2ROW 0
-#define ROW2COL 1
+#define COL2ROW 0
+#define ROW2COL 1
#define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */
// useful for direct pin mapping
#define NO_PIN (~0)
#ifdef __AVR__
- #ifndef __ASSEMBLER__
- #include <avr/io.h>
- #endif
- #define PORT_SHIFTER 4 // this may be 4 for all AVR chips
+# ifndef __ASSEMBLER__
+# include <avr/io.h>
+# endif
+# define PORT_SHIFTER 4 // this may be 4 for all AVR chips
- // If you want to add more to this list, reference the PINx definitions in these header
- // files: https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/include/avr
+// If you want to add more to this list, reference the PINx definitions in these header
+// files: https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/include/avr
- #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
- #define ADDRESS_BASE 0x00
- #define PINB_ADDRESS 0x3
- #define PINC_ADDRESS 0x6
- #define PIND_ADDRESS 0x9
- #define PINE_ADDRESS 0xC
- #define PINF_ADDRESS 0xF
- #elif defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__)
- #define ADDRESS_BASE 0x00
- #define PINB_ADDRESS 0x3
- #define PINC_ADDRESS 0x6
- #define PIND_ADDRESS 0x9
- #elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__)
- #define ADDRESS_BASE 0x00
- #define PINA_ADDRESS 0x0
- #define PINB_ADDRESS 0x3
- #define PINC_ADDRESS 0x6
- #define PIND_ADDRESS 0x9
- #define PINE_ADDRESS 0xC
- #define PINF_ADDRESS 0xF
- #elif defined(__AVR_ATmega32A__)
- #define ADDRESS_BASE 0x10
- #define PIND_ADDRESS 0x0
- #define PINC_ADDRESS 0x3
- #define PINB_ADDRESS 0x6
- #define PINA_ADDRESS 0x9
- #elif defined(__AVR_ATmega328P__)
- #define ADDRESS_BASE 0x00
- #define PINB_ADDRESS 0x3
- #define PINC_ADDRESS 0x6
- #define PIND_ADDRESS 0x9
- #else
- #error "Pins are not defined"
- #endif
+# if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
+# define ADDRESS_BASE 0x00
+# define PINB_ADDRESS 0x3
+# define PINC_ADDRESS 0x6
+# define PIND_ADDRESS 0x9
+# define PINE_ADDRESS 0xC
+# define PINF_ADDRESS 0xF
+# elif defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__)
+# define ADDRESS_BASE 0x00
+# define PINB_ADDRESS 0x3
+# define PINC_ADDRESS 0x6
+# define PIND_ADDRESS 0x9
+# elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__)
+# define ADDRESS_BASE 0x00
+# define PINA_ADDRESS 0x0
+# define PINB_ADDRESS 0x3
+# define PINC_ADDRESS 0x6
+# define PIND_ADDRESS 0x9
+# define PINE_ADDRESS 0xC
+# define PINF_ADDRESS 0xF
+# elif defined(__AVR_ATmega32A__)
+# define ADDRESS_BASE 0x10
+# define PIND_ADDRESS 0x0
+# define PINC_ADDRESS 0x3
+# define PINB_ADDRESS 0x6
+# define PINA_ADDRESS 0x9
+# elif defined(__AVR_ATmega328P__)
+# define ADDRESS_BASE 0x00
+# define PINB_ADDRESS 0x3
+# define PINC_ADDRESS 0x6
+# define PIND_ADDRESS 0x9
+# else
+# error "Pins are not defined"
+# endif
- /* I/O pins */
- #define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin)
+/* I/O pins */
+# define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin)
- #ifdef PORTA
- #define A0 PINDEF(A, 0)
- #define A1 PINDEF(A, 1)
- #define A2 PINDEF(A, 2)
- #define A3 PINDEF(A, 3)
- #define A4 PINDEF(A, 4)
- #define A5 PINDEF(A, 5)
- #define A6 PINDEF(A, 6)
- #define A7 PINDEF(A, 7)
- #endif
- #ifdef PORTB
- #define B0 PINDEF(B, 0)
- #define B1 PINDEF(B, 1)
- #define B2 PINDEF(B, 2)
- #define B3 PINDEF(B, 3)
- #define B4 PINDEF(B, 4)
- #define B5 PINDEF(B, 5)
- #define B6 PINDEF(B, 6)
- #define B7 PINDEF(B, 7)
- #endif
- #ifdef PORTC
- #define C0 PINDEF(C, 0)
- #define C1 PINDEF(C, 1)
- #define C2 PINDEF(C, 2)
- #define C3 PINDEF(C, 3)
- #define C4 PINDEF(C, 4)
- #define C5 PINDEF(C, 5)
- #define C6 PINDEF(C, 6)
- #define C7 PINDEF(C, 7)
- #endif
- #ifdef PORTD
- #define D0 PINDEF(D, 0)
- #define D1 PINDEF(D, 1)
- #define D2 PINDEF(D, 2)
- #define D3 PINDEF(D, 3)
- #define D4 PINDEF(D, 4)
- #define D5 PINDEF(D, 5)
- #define D6 PINDEF(D, 6)
- #define D7 PINDEF(D, 7)
- #endif
- #ifdef PORTE
- #define E0 PINDEF(E, 0)
- #define E1 PINDEF(E, 1)
- #define E2 PINDEF(E, 2)
- #define E3 PINDEF(E, 3)
- #define E4 PINDEF(E, 4)
- #define E5 PINDEF(E, 5)
- #define E6 PINDEF(E, 6)
- #define E7 PINDEF(E, 7)
- #endif
- #ifdef PORTF
- #define F0 PINDEF(F, 0)
- #define F1 PINDEF(F, 1)
- #define F2 PINDEF(F, 2)
- #define F3 PINDEF(F, 3)
- #define F4 PINDEF(F, 4)
- #define F5 PINDEF(F, 5)
- #define F6 PINDEF(F, 6)
- #define F7 PINDEF(F, 7)
- #endif
+# ifdef PORTA
+# define A0 PINDEF(A, 0)
+# define A1 PINDEF(A, 1)
+# define A2 PINDEF(A, 2)
+# define A3 PINDEF(A, 3)
+# define A4 PINDEF(A, 4)
+# define A5 PINDEF(A, 5)
+# define A6 PINDEF(A, 6)
+# define A7 PINDEF(A, 7)
+# endif
+# ifdef PORTB
+# define B0 PINDEF(B, 0)
+# define B1 PINDEF(B, 1)
+# define B2 PINDEF(B, 2)
+# define B3 PINDEF(B, 3)
+# define B4 PINDEF(B, 4)
+# define B5 PINDEF(B, 5)
+# define B6 PINDEF(B, 6)
+# define B7 PINDEF(B, 7)
+# endif
+# ifdef PORTC
+# define C0 PINDEF(C, 0)
+# define C1 PINDEF(C, 1)
+# define C2 PINDEF(C, 2)
+# define C3 PINDEF(C, 3)
+# define C4 PINDEF(C, 4)
+# define C5 PINDEF(C, 5)
+# define C6 PINDEF(C, 6)
+# define C7 PINDEF(C, 7)
+# endif
+# ifdef PORTD
+# define D0 PINDEF(D, 0)
+# define D1 PINDEF(D, 1)
+# define D2 PINDEF(D, 2)
+# define D3 PINDEF(D, 3)
+# define D4 PINDEF(D, 4)
+# define D5 PINDEF(D, 5)
+# define D6 PINDEF(D, 6)
+# define D7 PINDEF(D, 7)
+# endif
+# ifdef PORTE
+# define E0 PINDEF(E, 0)
+# define E1 PINDEF(E, 1)
+# define E2 PINDEF(E, 2)
+# define E3 PINDEF(E, 3)
+# define E4 PINDEF(E, 4)
+# define E5 PINDEF(E, 5)
+# define E6 PINDEF(E, 6)
+# define E7 PINDEF(E, 7)
+# endif
+# ifdef PORTF
+# define F0 PINDEF(F, 0)
+# define F1 PINDEF(F, 1)
+# define F2 PINDEF(F, 2)
+# define F3 PINDEF(F, 3)
+# define F4 PINDEF(F, 4)
+# define F5 PINDEF(F, 5)
+# define F6 PINDEF(F, 6)
+# define F7 PINDEF(F, 7)
+# endif
+
+# ifndef __ASSEMBLER__
+# define _PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + (p >> PORT_SHIFTER) + offset)
+// Port X Input Pins Address
+# define PINx_ADDRESS(p) _PIN_ADDRESS(p, 0)
+// Port X Data Direction Register, 0:input 1:output
+# define DDRx_ADDRESS(p) _PIN_ADDRESS(p, 1)
+// Port X Data Register
+# define PORTx_ADDRESS(p) _PIN_ADDRESS(p, 2)
+# endif
#elif defined(PROTOCOL_CHIBIOS)
- // Defines mapping for Proton C replacement
- #ifdef CONVERT_TO_PROTON_C
- // Left side (front)
- #define D3 PAL_LINE(GPIOA, 9)
- #define D2 PAL_LINE(GPIOA, 10)
- // GND
- // GND
- #define D1 PAL_LINE(GPIOB, 7)
- #define D0 PAL_LINE(GPIOB, 6)
- #define D4 PAL_LINE(GPIOB, 5)
- #define C6 PAL_LINE(GPIOB, 4)
- #define D7 PAL_LINE(GPIOB, 3)
- #define E6 PAL_LINE(GPIOB, 2)
- #define B4 PAL_LINE(GPIOB, 1)
- #define B5 PAL_LINE(GPIOB, 0)
+// Defines mapping for Proton C replacement
+# ifdef CONVERT_TO_PROTON_C
+// Left side (front)
+# define D3 PAL_LINE(GPIOA, 9)
+# define D2 PAL_LINE(GPIOA, 10)
+// GND
+// GND
+# define D1 PAL_LINE(GPIOB, 7)
+# define D0 PAL_LINE(GPIOB, 6)
+# define D4 PAL_LINE(GPIOB, 5)
+# define C6 PAL_LINE(GPIOB, 4)
+# define D7 PAL_LINE(GPIOB, 3)
+# define E6 PAL_LINE(GPIOB, 2)
+# define B4 PAL_LINE(GPIOB, 1)
+# define B5 PAL_LINE(GPIOB, 0)
- // Right side (front)
- // RAW
- // GND
- // RESET
- // VCC
- #define F4 PAL_LINE(GPIOA, 2)
- #define F5 PAL_LINE(GPIOA, 1)
- #define F6 PAL_LINE(GPIOA, 0)
- #define F7 PAL_LINE(GPIOB, 8)
- #define B1 PAL_LINE(GPIOB, 13)
- #define B3 PAL_LINE(GPIOB, 14)
- #define B2 PAL_LINE(GPIOB, 15)
- #define B6 PAL_LINE(GPIOB, 9)
+// Right side (front)
+// RAW
+// GND
+// RESET
+// VCC
+# define F4 PAL_LINE(GPIOA, 2)
+# define F5 PAL_LINE(GPIOA, 1)
+# define F6 PAL_LINE(GPIOA, 0)
+# define F7 PAL_LINE(GPIOB, 8)
+# define B1 PAL_LINE(GPIOB, 13)
+# define B3 PAL_LINE(GPIOB, 14)
+# define B2 PAL_LINE(GPIOB, 15)
+# define B6 PAL_LINE(GPIOB, 9)
- // LEDs (only D5/C13 uses an actual LED)
- #ifdef CONVERT_TO_PROTON_C_RXLED
- #define D5 PAL_LINE(GPIOC, 13)
- #define B0 PAL_LINE(GPIOC, 13)
- #else
- #define D5 PAL_LINE(GPIOC, 13)
- #define B0 PAL_LINE(GPIOC, 14)
- #endif
- #else
- #define A0 PAL_LINE(GPIOA, 0)
- #define A1 PAL_LINE(GPIOA, 1)
- #define A2 PAL_LINE(GPIOA, 2)
- #define A3 PAL_LINE(GPIOA, 3)
- #define A4 PAL_LINE(GPIOA, 4)
- #define A5 PAL_LINE(GPIOA, 5)
- #define A6 PAL_LINE(GPIOA, 6)
- #define A7 PAL_LINE(GPIOA, 7)
- #define A8 PAL_LINE(GPIOA, 8)
- #define A9 PAL_LINE(GPIOA, 9)
- #define A10 PAL_LINE(GPIOA, 10)
- #define A11 PAL_LINE(GPIOA, 11)
- #define A12 PAL_LINE(GPIOA, 12)
- #define A13 PAL_LINE(GPIOA, 13)
- #define A14 PAL_LINE(GPIOA, 14)
- #define A15 PAL_LINE(GPIOA, 15)
- #define B0 PAL_LINE(GPIOB, 0)
- #define B1 PAL_LINE(GPIOB, 1)
- #define B2 PAL_LINE(GPIOB, 2)
- #define B3 PAL_LINE(GPIOB, 3)
- #define B4 PAL_LINE(GPIOB, 4)
- #define B5 PAL_LINE(GPIOB, 5)
- #define B6 PAL_LINE(GPIOB, 6)
- #define B7 PAL_LINE(GPIOB, 7)
- #define B8 PAL_LINE(GPIOB, 8)
- #define B9 PAL_LINE(GPIOB, 9)
- #define B10 PAL_LINE(GPIOB, 10)
- #define B11 PAL_LINE(GPIOB, 11)
- #define B12 PAL_LINE(GPIOB, 12)
- #define B13 PAL_LINE(GPIOB, 13)
- #define B14 PAL_LINE(GPIOB, 14)
- #define B15 PAL_LINE(GPIOB, 15)
- #define B16 PAL_LINE(GPIOB, 16)
- #define B17 PAL_LINE(GPIOB, 17)
- #define C0 PAL_LINE(GPIOC, 0)
- #define C1 PAL_LINE(GPIOC, 1)
- #define C2 PAL_LINE(GPIOC, 2)
- #define C3 PAL_LINE(GPIOC, 3)
- #define C4 PAL_LINE(GPIOC, 4)
- #define C5 PAL_LINE(GPIOC, 5)
- #define C6 PAL_LINE(GPIOC, 6)
- #define C7 PAL_LINE(GPIOC, 7)
- #define C8 PAL_LINE(GPIOC, 8)
- #define C9 PAL_LINE(GPIOC, 9)
- #define C10 PAL_LINE(GPIOC, 10)
- #define C11 PAL_LINE(GPIOC, 11)
- #define C12 PAL_LINE(GPIOC, 12)
- #define C13 PAL_LINE(GPIOC, 13)
- #define C14 PAL_LINE(GPIOC, 14)
- #define C15 PAL_LINE(GPIOC, 15)
- #define D0 PAL_LINE(GPIOD, 0)
- #define D1 PAL_LINE(GPIOD, 1)
- #define D2 PAL_LINE(GPIOD, 2)
- #define D3 PAL_LINE(GPIOD, 3)
- #define D4 PAL_LINE(GPIOD, 4)
- #define D5 PAL_LINE(GPIOD, 5)
- #define D6 PAL_LINE(GPIOD, 6)
- #define D7 PAL_LINE(GPIOD, 7)
- #define D8 PAL_LINE(GPIOD, 8)
- #define D9 PAL_LINE(GPIOD, 9)
- #define D10 PAL_LINE(GPIOD, 10)
- #define D11 PAL_LINE(GPIOD, 11)
- #define D12 PAL_LINE(GPIOD, 12)
- #define D13 PAL_LINE(GPIOD, 13)
- #define D14 PAL_LINE(GPIOD, 14)
- #define D15 PAL_LINE(GPIOD, 15)
- #define E0 PAL_LINE(GPIOE, 0)
- #define E1 PAL_LINE(GPIOE, 1)
- #define E2 PAL_LINE(GPIOE, 2)
- #define E3 PAL_LINE(GPIOE, 3)
- #define E4 PAL_LINE(GPIOE, 4)
- #define E5 PAL_LINE(GPIOE, 5)
- #define E6 PAL_LINE(GPIOE, 6)
- #define E7 PAL_LINE(GPIOE, 7)
- #define E8 PAL_LINE(GPIOE, 8)
- #define E9 PAL_LINE(GPIOE, 9)
- #define E10 PAL_LINE(GPIOE, 10)
- #define E11 PAL_LINE(GPIOE, 11)
- #define E12 PAL_LINE(GPIOE, 12)
- #define E13 PAL_LINE(GPIOE, 13)
- #define E14 PAL_LINE(GPIOE, 14)
- #define E15 PAL_LINE(GPIOE, 15)
- #define F0 PAL_LINE(GPIOF, 0)
- #define F1 PAL_LINE(GPIOF, 1)
- #define F2 PAL_LINE(GPIOF, 2)
- #define F3 PAL_LINE(GPIOF, 3)
- #define F4 PAL_LINE(GPIOF, 4)
- #define F5 PAL_LINE(GPIOF, 5)
- #define F6 PAL_LINE(GPIOF, 6)
- #define F7 PAL_LINE(GPIOF, 7)
- #define F8 PAL_LINE(GPIOF, 8)
- #define F9 PAL_LINE(GPIOF, 9)
- #define F10 PAL_LINE(GPIOF, 10)
- #define F11 PAL_LINE(GPIOF, 11)
- #define F12 PAL_LINE(GPIOF, 12)
- #define F13 PAL_LINE(GPIOF, 13)
- #define F14 PAL_LINE(GPIOF, 14)
- #define F15 PAL_LINE(GPIOF, 15)
- #endif
+// LEDs (only D5/C13 uses an actual LED)
+# ifdef CONVERT_TO_PROTON_C_RXLED
+# define D5 PAL_LINE(GPIOC, 14)
+# define B0 PAL_LINE(GPIOC, 13)
+# else
+# define D5 PAL_LINE(GPIOC, 13)
+# define B0 PAL_LINE(GPIOC, 14)
+# endif
+# else
+# define A0 PAL_LINE(GPIOA, 0)
+# define A1 PAL_LINE(GPIOA, 1)
+# define A2 PAL_LINE(GPIOA, 2)
+# define A3 PAL_LINE(GPIOA, 3)
+# define A4 PAL_LINE(GPIOA, 4)
+# define A5 PAL_LINE(GPIOA, 5)
+# define A6 PAL_LINE(GPIOA, 6)
+# define A7 PAL_LINE(GPIOA, 7)
+# define A8 PAL_LINE(GPIOA, 8)
+# define A9 PAL_LINE(GPIOA, 9)
+# define A10 PAL_LINE(GPIOA, 10)
+# define A11 PAL_LINE(GPIOA, 11)
+# define A12 PAL_LINE(GPIOA, 12)
+# define A13 PAL_LINE(GPIOA, 13)
+# define A14 PAL_LINE(GPIOA, 14)
+# define A15 PAL_LINE(GPIOA, 15)
+# define B0 PAL_LINE(GPIOB, 0)
+# define B1 PAL_LINE(GPIOB, 1)
+# define B2 PAL_LINE(GPIOB, 2)
+# define B3 PAL_LINE(GPIOB, 3)
+# define B4 PAL_LINE(GPIOB, 4)
+# define B5 PAL_LINE(GPIOB, 5)
+# define B6 PAL_LINE(GPIOB, 6)
+# define B7 PAL_LINE(GPIOB, 7)
+# define B8 PAL_LINE(GPIOB, 8)
+# define B9 PAL_LINE(GPIOB, 9)
+# define B10 PAL_LINE(GPIOB, 10)
+# define B11 PAL_LINE(GPIOB, 11)
+# define B12 PAL_LINE(GPIOB, 12)
+# define B13 PAL_LINE(GPIOB, 13)
+# define B14 PAL_LINE(GPIOB, 14)
+# define B15 PAL_LINE(GPIOB, 15)
+# define B16 PAL_LINE(GPIOB, 16)
+# define B17 PAL_LINE(GPIOB, 17)
+# define C0 PAL_LINE(GPIOC, 0)
+# define C1 PAL_LINE(GPIOC, 1)
+# define C2 PAL_LINE(GPIOC, 2)
+# define C3 PAL_LINE(GPIOC, 3)
+# define C4 PAL_LINE(GPIOC, 4)
+# define C5 PAL_LINE(GPIOC, 5)
+# define C6 PAL_LINE(GPIOC, 6)
+# define C7 PAL_LINE(GPIOC, 7)
+# define C8 PAL_LINE(GPIOC, 8)
+# define C9 PAL_LINE(GPIOC, 9)
+# define C10 PAL_LINE(GPIOC, 10)
+# define C11 PAL_LINE(GPIOC, 11)
+# define C12 PAL_LINE(GPIOC, 12)
+# define C13 PAL_LINE(GPIOC, 13)
+# define C14 PAL_LINE(GPIOC, 14)
+# define C15 PAL_LINE(GPIOC, 15)
+# define D0 PAL_LINE(GPIOD, 0)
+# define D1 PAL_LINE(GPIOD, 1)
+# define D2 PAL_LINE(GPIOD, 2)
+# define D3 PAL_LINE(GPIOD, 3)
+# define D4 PAL_LINE(GPIOD, 4)
+# define D5 PAL_LINE(GPIOD, 5)
+# define D6 PAL_LINE(GPIOD, 6)
+# define D7 PAL_LINE(GPIOD, 7)
+# define D8 PAL_LINE(GPIOD, 8)
+# define D9 PAL_LINE(GPIOD, 9)
+# define D10 PAL_LINE(GPIOD, 10)
+# define D11 PAL_LINE(GPIOD, 11)
+# define D12 PAL_LINE(GPIOD, 12)
+# define D13 PAL_LINE(GPIOD, 13)
+# define D14 PAL_LINE(GPIOD, 14)
+# define D15 PAL_LINE(GPIOD, 15)
+# define E0 PAL_LINE(GPIOE, 0)
+# define E1 PAL_LINE(GPIOE, 1)
+# define E2 PAL_LINE(GPIOE, 2)
+# define E3 PAL_LINE(GPIOE, 3)
+# define E4 PAL_LINE(GPIOE, 4)
+# define E5 PAL_LINE(GPIOE, 5)
+# define E6 PAL_LINE(GPIOE, 6)
+# define E7 PAL_LINE(GPIOE, 7)
+# define E8 PAL_LINE(GPIOE, 8)
+# define E9 PAL_LINE(GPIOE, 9)
+# define E10 PAL_LINE(GPIOE, 10)
+# define E11 PAL_LINE(GPIOE, 11)
+# define E12 PAL_LINE(GPIOE, 12)
+# define E13 PAL_LINE(GPIOE, 13)
+# define E14 PAL_LINE(GPIOE, 14)
+# define E15 PAL_LINE(GPIOE, 15)
+# define F0 PAL_LINE(GPIOF, 0)
+# define F1 PAL_LINE(GPIOF, 1)
+# define F2 PAL_LINE(GPIOF, 2)
+# define F3 PAL_LINE(GPIOF, 3)
+# define F4 PAL_LINE(GPIOF, 4)
+# define F5 PAL_LINE(GPIOF, 5)
+# define F6 PAL_LINE(GPIOF, 6)
+# define F7 PAL_LINE(GPIOF, 7)
+# define F8 PAL_LINE(GPIOF, 8)
+# define F9 PAL_LINE(GPIOF, 9)
+# define F10 PAL_LINE(GPIOF, 10)
+# define F11 PAL_LINE(GPIOF, 11)
+# define F12 PAL_LINE(GPIOF, 12)
+# define F13 PAL_LINE(GPIOF, 13)
+# define F14 PAL_LINE(GPIOF, 14)
+# define F15 PAL_LINE(GPIOF, 15)
+# endif
#endif
/* USART configuration */
#ifdef BLUETOOTH_ENABLE
-# ifdef __AVR_ATmega32U4__
-# define SERIAL_UART_BAUD 9600
-# define SERIAL_UART_DATA UDR1
-# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
-# define SERIAL_UART_RXD_VECT USART1_RX_vect
-# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
-# define SERIAL_UART_INIT() do { \
- /* baud rate */ \
- UBRR1L = SERIAL_UART_UBRR; \
- /* baud rate */ \
- UBRR1H = SERIAL_UART_UBRR >> 8; \
- /* enable TX */ \
- UCSR1B = _BV(TXEN1); \
- /* 8-bit data */ \
- UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
- sei(); \
- } while(0)
-# else
-# error "USART configuration is needed."
-# endif
+# ifdef __AVR_ATmega32U4__
+# define SERIAL_UART_BAUD 9600
+# define SERIAL_UART_DATA UDR1
+# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
+# define SERIAL_UART_RXD_VECT USART1_RX_vect
+# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
+# define SERIAL_UART_INIT() \
+ do { \
+ /* baud rate */ \
+ UBRR1L = SERIAL_UART_UBRR; \
+ /* baud rate */ \
+ UBRR1H = SERIAL_UART_UBRR >> 8; \
+ /* enable TX */ \
+ UCSR1B = _BV(TXEN1); \
+ /* 8-bit data */ \
+ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
+ sei(); \
+ } while (0)
+# elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
+# define SERIAL_UART_BAUD 115200
+# define SERIAL_UART_DATA UDR1
+/* UBRR should result in ~16 and set UCSR1A = _BV(U2X1) as per rn42 documentation. HC05 needs baudrate configured accordingly */
+# define SERIAL_UART_UBRR (F_CPU / (8UL * SERIAL_UART_BAUD) - 1)
+# define SERIAL_UART_RXD_VECT USART1_RX_vect
+# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
+# define SERIAL_UART_INIT() \
+ do { \
+ UCSR1A = _BV(U2X1); \
+ /* baud rate */ \
+ UBRR1L = SERIAL_UART_UBRR; \
+ /* baud rate */ \
+ UBRR1H = SERIAL_UART_UBRR >> 8; \
+ /* enable TX */ \
+ UCSR1B = _BV(TXEN1); \
+ /* 8-bit data */ \
+ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
+ sei(); \
+ } while (0)
+# else
+# error "USART configuration is needed."
+# endif
#endif
#define API_SYSEX_MAX_SIZE 32
diff --git a/quantum/debounce/eager_pk.c b/quantum/debounce/eager_pk.c
index c07be18f8d..76b978d059 100644
--- a/quantum/debounce/eager_pk.c
+++ b/quantum/debounce/eager_pk.c
@@ -24,15 +24,15 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
#include <stdlib.h>
#ifndef DEBOUNCE
-# define DEBOUNCE 5
+# define DEBOUNCE 5
#endif
#if (MATRIX_COLS <= 8)
-# define ROW_SHIFTER ((uint8_t)1)
+# define ROW_SHIFTER ((uint8_t)1)
#elif (MATRIX_COLS <= 16)
-# define ROW_SHIFTER ((uint16_t)1)
+# define ROW_SHIFTER ((uint16_t)1)
#elif (MATRIX_COLS <= 32)
-# define ROW_SHIFTER ((uint32_t)1)
+# define ROW_SHIFTER ((uint32_t)1)
#endif
#define debounce_counter_t uint8_t
@@ -49,66 +49,66 @@ void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t n
// we use num_rows rather than MATRIX_ROWS to support split keyboards
void debounce_init(uint8_t num_rows) {
- debounce_counters = (debounce_counter_t *)malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
- int i = 0;
- for (uint8_t r = 0; r < num_rows; r++) {
- for (uint8_t c = 0; c < MATRIX_COLS; c++) {
- debounce_counters[i++] = DEBOUNCE_ELAPSED;
+ debounce_counters = (debounce_counter_t *)malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
+ int i = 0;
+ for (uint8_t r = 0; r < num_rows; r++) {
+ for (uint8_t c = 0; c < MATRIX_COLS; c++) {
+ debounce_counters[i++] = DEBOUNCE_ELAPSED;
+ }
}
- }
}
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
- uint8_t current_time = timer_read() % MAX_DEBOUNCE;
- if (counters_need_update) {
- update_debounce_counters(num_rows, current_time);
- }
+ uint8_t current_time = timer_read() % MAX_DEBOUNCE;
+ if (counters_need_update) {
+ update_debounce_counters(num_rows, current_time);
+ }
- if (changed || matrix_need_update) {
- transfer_matrix_values(raw, cooked, num_rows, current_time);
- }
+ if (changed || matrix_need_update) {
+ transfer_matrix_values(raw, cooked, num_rows, current_time);
+ }
}
// If the current time is > debounce counter, set the counter to enable input.
void update_debounce_counters(uint8_t num_rows, uint8_t current_time) {
- counters_need_update = false;
- debounce_counter_t *debounce_pointer = debounce_counters;
- for (uint8_t row = 0; row < num_rows; row++) {
- for (uint8_t col = 0; col < MATRIX_COLS; col++) {
- if (*debounce_pointer != DEBOUNCE_ELAPSED) {
- if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
- *debounce_pointer = DEBOUNCE_ELAPSED;
- } else {
- counters_need_update = true;
+ counters_need_update = false;
+ debounce_counter_t *debounce_pointer = debounce_counters;
+ for (uint8_t row = 0; row < num_rows; row++) {
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ if (*debounce_pointer != DEBOUNCE_ELAPSED) {
+ if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
+ *debounce_pointer = DEBOUNCE_ELAPSED;
+ } else {
+ counters_need_update = true;
+ }
+ }
+ debounce_pointer++;
}
- }
- debounce_pointer++;
}
- }
}
// upload from raw_matrix to final matrix;
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) {
- matrix_need_update = false;
- debounce_counter_t *debounce_pointer = debounce_counters;
- for (uint8_t row = 0; row < num_rows; row++) {
- matrix_row_t delta = raw[row] ^ cooked[row];
- matrix_row_t existing_row = cooked[row];
- for (uint8_t col = 0; col < MATRIX_COLS; col++) {
- matrix_row_t col_mask = (ROW_SHIFTER << col);
- if (delta & col_mask) {
- if (*debounce_pointer == DEBOUNCE_ELAPSED) {
- *debounce_pointer = current_time;
- counters_need_update = true;
- existing_row ^= col_mask; // flip the bit.
- } else {
- matrix_need_update = true;
+ matrix_need_update = false;
+ debounce_counter_t *debounce_pointer = debounce_counters;
+ for (uint8_t row = 0; row < num_rows; row++) {
+ matrix_row_t delta = raw[row] ^ cooked[row];
+ matrix_row_t existing_row = cooked[row];
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ matrix_row_t col_mask = (ROW_SHIFTER << col);
+ if (delta & col_mask) {
+ if (*debounce_pointer == DEBOUNCE_ELAPSED) {
+ *debounce_pointer = current_time;
+ counters_need_update = true;
+ existing_row ^= col_mask; // flip the bit.
+ } else {
+ matrix_need_update = true;
+ }
+ }
+ debounce_pointer++;
}
- }
- debounce_pointer++;
+ cooked[row] = existing_row;
}
- cooked[row] = existing_row;
- }
}
bool debounce_active(void) { return true; }
diff --git a/quantum/debounce/eager_pr.c b/quantum/debounce/eager_pr.c
index 8dbfa3fcfa..173ad15ee9 100644
--- a/quantum/debounce/eager_pr.c
+++ b/quantum/debounce/eager_pr.c
@@ -24,11 +24,11 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
#include <stdlib.h>
#ifndef DEBOUNCE
-# define DEBOUNCE 5
+# define DEBOUNCE 5
#endif
#define debounce_counter_t uint8_t
-static bool matrix_need_update;
+static bool matrix_need_update;
static debounce_counter_t *debounce_counters;
static bool counters_need_update;
@@ -41,60 +41,60 @@ void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t n
// we use num_rows rather than MATRIX_ROWS to support split keyboards
void debounce_init(uint8_t num_rows) {
- debounce_counters = (debounce_counter_t *)malloc(num_rows * sizeof(debounce_counter_t));
- for (uint8_t r = 0; r < num_rows; r++) {
- debounce_counters[r] = DEBOUNCE_ELAPSED;
- }
+ debounce_counters = (debounce_counter_t *)malloc(num_rows * sizeof(debounce_counter_t));
+ for (uint8_t r = 0; r < num_rows; r++) {
+ debounce_counters[r] = DEBOUNCE_ELAPSED;
+ }
}
void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
- uint8_t current_time = timer_read() % MAX_DEBOUNCE;
- bool needed_update = counters_need_update;
- if (counters_need_update) {
- update_debounce_counters(num_rows, current_time);
- }
+ uint8_t current_time = timer_read() % MAX_DEBOUNCE;
+ bool needed_update = counters_need_update;
+ if (counters_need_update) {
+ update_debounce_counters(num_rows, current_time);
+ }
- if (changed || (needed_update && !counters_need_update) || matrix_need_update) {
- transfer_matrix_values(raw, cooked, num_rows, current_time);
- }
+ if (changed || (needed_update && !counters_need_update) || matrix_need_update) {
+ transfer_matrix_values(raw, cooked, num_rows, current_time);
+ }
}
// If the current time is > debounce counter, set the counter to enable input.
void update_debounce_counters(uint8_t num_rows, uint8_t current_time) {
- counters_need_update = false;
- debounce_counter_t *debounce_pointer = debounce_counters;
- for (uint8_t row = 0; row < num_rows; row++) {
- if (*debounce_pointer != DEBOUNCE_ELAPSED) {
- if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
- *debounce_pointer = DEBOUNCE_ELAPSED;
- } else {
- counters_need_update = true;
- }
+ counters_need_update = false;
+ debounce_counter_t *debounce_pointer = debounce_counters;
+ for (uint8_t row = 0; row < num_rows; row++) {
+ if (*debounce_pointer != DEBOUNCE_ELAPSED) {
+ if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) {
+ *debounce_pointer = DEBOUNCE_ELAPSED;
+ } else {
+ counters_need_update = true;
+ }
+ }
+ debounce_pointer++;
}
- debounce_pointer++;
- }
}
// upload from raw_matrix to final matrix;
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) {
- matrix_need_update = false;
- debounce_counter_t *debounce_pointer = debounce_counters;
- for (uint8_t row = 0; row < num_rows; row++) {
- matrix_row_t existing_row = cooked[row];
- matrix_row_t raw_row = raw[row];
+ matrix_need_update = false;
+ debounce_counter_t *debounce_pointer = debounce_counters;
+ for (uint8_t row = 0; row < num_rows; row++) {
+ matrix_row_t existing_row = cooked[row];
+ matrix_row_t raw_row = raw[row];
- // determine new value basd on debounce pointer + raw value
- if (existing_row != raw_row) {
- if (*debounce_pointer == DEBOUNCE_ELAPSED) {
- *debounce_pointer = current_time;
- cooked[row] = raw_row;
- counters_need_update = true;
- } else {
- matrix_need_update = true;
- }
+ // determine new value basd on debounce pointer + raw value
+ if (existing_row != raw_row) {
+ if (*debounce_pointer == DEBOUNCE_ELAPSED) {
+ *debounce_pointer = current_time;
+ cooked[row] = raw_row;
+ counters_need_update = true;
+ } else {
+ matrix_need_update = true;
+ }
+ }
+ debounce_pointer++;
}
- debounce_pointer++;
- }
}
bool debounce_active(void) { return true; }
diff --git a/quantum/debounce/sym_g.c b/quantum/debounce/sym_g.c
index c8ab34e1a0..3ed9055d2a 100644
--- a/quantum/debounce/sym_g.c
+++ b/quantum/debounce/sym_g.c
@@ -20,38 +20,33 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
#include "timer.h"
#include "quantum.h"
#ifndef DEBOUNCE
- #define DEBOUNCE 5
+# define DEBOUNCE 5
#endif
-void debounce_init(uint8_t num_rows) {}
+void debounce_init(uint8_t num_rows) {}
static bool debouncing = false;
#if DEBOUNCE > 0
static uint16_t debouncing_time;
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
-{
- if (changed) {
- debouncing = true;
- debouncing_time = timer_read();
- }
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ if (changed) {
+ debouncing = true;
+ debouncing_time = timer_read();
+ }
- if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
- for (int i = 0; i < num_rows; i++) {
- cooked[i] = raw[i];
+ if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
+ for (int i = 0; i < num_rows; i++) {
+ cooked[i] = raw[i];
+ }
+ debouncing = false;
}
- debouncing = false;
- }
}
-#else //no debouncing.
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed)
-{
- for (int i = 0; i < num_rows; i++) {
- cooked[i] = raw[i];
- }
+#else // no debouncing.
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ for (int i = 0; i < num_rows; i++) {
+ cooked[i] = raw[i];
+ }
}
#endif
-bool debounce_active(void) {
- return debouncing;
-}
-
+bool debounce_active(void) { return debouncing; }
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c
new file mode 100644
index 0000000000..ab74222d10
--- /dev/null
+++ b/quantum/dip_switch.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2018 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2019 Drashna Jaelre (Christopher Courtney) <drashna@live.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "dip_switch.h"
+
+// for memcpy
+#include <string.h>
+
+#if !defined(DIP_SWITCH_PINS)
+# error "No DIP switch pads defined by DIP_SWITCH_PINS"
+#endif
+
+#define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t))
+static pin_t dip_switch_pad[] = DIP_SWITCH_PINS;
+static bool dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
+static bool last_dip_switch_state[NUMBER_OF_DIP_SWITCHES] = {0};
+
+__attribute__((weak)) void dip_switch_update_user(uint8_t index, bool active) {}
+
+__attribute__((weak)) void dip_switch_update_kb(uint8_t index, bool active) { dip_switch_update_user(index, active); }
+
+__attribute__((weak)) void dip_switch_update_mask_user(uint32_t state) {}
+
+__attribute__((weak)) void dip_switch_update_mask_kb(uint32_t state) { dip_switch_update_mask_user(state); }
+
+void dip_switch_init(void) {
+ for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) {
+ setPinInputHigh(dip_switch_pad[i]);
+ }
+ dip_switch_read(true);
+}
+
+void dip_switch_read(bool forced) {
+ bool has_dip_state_changed = false;
+ uint32_t dip_switch_mask = 0;
+
+ for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) {
+ dip_switch_state[i] = !readPin(dip_switch_pad[i]);
+ dip_switch_mask |= dip_switch_state[i] << i;
+ if (last_dip_switch_state[i] ^ dip_switch_state[i] || forced) {
+ has_dip_state_changed = true;
+ dip_switch_update_kb(i, dip_switch_state[i]);
+ }
+ }
+ if (has_dip_state_changed) {
+ dip_switch_update_mask_kb(dip_switch_mask);
+ }
+ memcpy(last_dip_switch_state, dip_switch_state, sizeof(&dip_switch_state));
+}
diff --git a/quantum/dip_switch.h b/quantum/dip_switch.h
new file mode 100644
index 0000000000..61ef1cc19d
--- /dev/null
+++ b/quantum/dip_switch.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2018 Drashna Jaelre (Christopher Courtney) <drashna@live.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "quantum.h"
+
+void dip_switch_update_kb(uint8_t index, bool active);
+void dip_switch_update_user(uint8_t index, bool active);
+void dip_switch_update_mask_user(uint32_t state);
+void dip_switch_update_mask_kb(uint32_t state);
+
+void dip_switch_init(void);
+void dip_switch_read(bool forced);
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 38400e36f1..ca056f630e 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -15,224 +15,198 @@
*/
#include "config.h"
-#include "keymap.h" // to get keymaps[][][]
+#include "keymap.h" // to get keymaps[][][]
#include "tmk_core/common/eeprom.h"
-#include "progmem.h" // to read default from flash
-#include "quantum.h" // for send_string()
+#include "progmem.h" // to read default from flash
+#include "quantum.h" // for send_string()
#include "dynamic_keymap.h"
#ifdef DYNAMIC_KEYMAP_ENABLE
-#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
-#error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
-#endif
+# ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
+# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
+# endif
-#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
-#error DYNAMIC_KEYMAP_LAYER_COUNT not defined
-#endif
+# ifndef DYNAMIC_KEYMAP_LAYER_COUNT
+# error DYNAMIC_KEYMAP_LAYER_COUNT not defined
+# endif
-#ifndef DYNAMIC_KEYMAP_MACRO_COUNT
-#error DYNAMIC_KEYMAP_MACRO_COUNT not defined
-#endif
+# ifndef DYNAMIC_KEYMAP_MACRO_COUNT
+# error DYNAMIC_KEYMAP_MACRO_COUNT not defined
+# endif
-#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
-#error DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR not defined
-#endif
+# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
+# error DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR not defined
+# endif
-#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
-#error DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE not defined
-#endif
+# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
+# error DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE not defined
+# endif
-uint8_t dynamic_keymap_get_layer_count(void)
-{
- return DYNAMIC_KEYMAP_LAYER_COUNT;
-}
+uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; }
-void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column)
-{
- // TODO: optimize this with some left shifts
- return ((void*)DYNAMIC_KEYMAP_EEPROM_ADDR) + ( layer * MATRIX_ROWS * MATRIX_COLS * 2 ) +
- ( row * MATRIX_COLS * 2 ) + ( column * 2 );
+void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) {
+ // TODO: optimize this with some left shifts
+ return ((void *)DYNAMIC_KEYMAP_EEPROM_ADDR) + (layer * MATRIX_ROWS * MATRIX_COLS * 2) + (row * MATRIX_COLS * 2) + (column * 2);
}
-uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column)
-{
- void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
- // Big endian, so we can read/write EEPROM directly from host if we want
- uint16_t keycode = eeprom_read_byte(address) << 8;
- keycode |= eeprom_read_byte(address + 1);
- return keycode;
+uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column) {
+ void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
+ // Big endian, so we can read/write EEPROM directly from host if we want
+ uint16_t keycode = eeprom_read_byte(address) << 8;
+ keycode |= eeprom_read_byte(address + 1);
+ return keycode;
}
-void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode)
-{
- void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
- // Big endian, so we can read/write EEPROM directly from host if we want
- eeprom_update_byte(address, (uint8_t)(keycode >> 8));
- eeprom_update_byte(address+1, (uint8_t)(keycode & 0xFF));
+void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode) {
+ void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
+ // Big endian, so we can read/write EEPROM directly from host if we want
+ eeprom_update_byte(address, (uint8_t)(keycode >> 8));
+ eeprom_update_byte(address + 1, (uint8_t)(keycode & 0xFF));
}
-void dynamic_keymap_reset(void)
-{
- // Reset the keymaps in EEPROM to what is in flash.
- // All keyboards using dynamic keymaps should define a layout
- // for the same number of layers as DYNAMIC_KEYMAP_LAYER_COUNT.
- for ( int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++ ) {
- for ( int row = 0; row < MATRIX_ROWS; row++ ) {
- for ( int column = 0; column < MATRIX_COLS; column++ ) {
- dynamic_keymap_set_keycode(layer, row, column, pgm_read_word(&keymaps[layer][row][column]));
- }
- }
- }
+void dynamic_keymap_reset(void) {
+ // Reset the keymaps in EEPROM to what is in flash.
+ // All keyboards using dynamic keymaps should define a layout
+ // for the same number of layers as DYNAMIC_KEYMAP_LAYER_COUNT.
+ for (int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++) {
+ for (int row = 0; row < MATRIX_ROWS; row++) {
+ for (int column = 0; column < MATRIX_COLS; column++) {
+ dynamic_keymap_set_keycode(layer, row, column, pgm_read_word(&keymaps[layer][row][column]));
+ }
+ }
+ }
}
-void dynamic_keymap_get_buffer( uint16_t offset, uint16_t size, uint8_t *data )
-{
- uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2;
- void *source = (void*)(DYNAMIC_KEYMAP_EEPROM_ADDR+offset);
- uint8_t *target = data;
- for ( uint16_t i = 0; i < size; i++ ) {
- if ( offset + i < dynamic_keymap_eeprom_size ) {
- *target = eeprom_read_byte(source);
- } else {
- *target = 0x00;
- }
- source++;
- target++;
- }
+void dynamic_keymap_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) {
+ uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2;
+ void * source = (void *)(DYNAMIC_KEYMAP_EEPROM_ADDR + offset);
+ uint8_t *target = data;
+ for (uint16_t i = 0; i < size; i++) {
+ if (offset + i < dynamic_keymap_eeprom_size) {
+ *target = eeprom_read_byte(source);
+ } else {
+ *target = 0x00;
+ }
+ source++;
+ target++;
+ }
}
-void dynamic_keymap_set_buffer( uint16_t offset, uint16_t size, uint8_t *data )
-{
- uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2;
- void *target = (void*)(DYNAMIC_KEYMAP_EEPROM_ADDR+offset);
- uint8_t *source = data;
- for ( uint16_t i = 0; i < size; i++ ) {
- if ( offset + i < dynamic_keymap_eeprom_size ) {
- eeprom_update_byte(target, *source);
- }
- source++;
- target++;
- }
+void dynamic_keymap_set_buffer(uint16_t offset, uint16_t size, uint8_t *data) {
+ uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2;
+ void * target = (void *)(DYNAMIC_KEYMAP_EEPROM_ADDR + offset);
+ uint8_t *source = data;
+ for (uint16_t i = 0; i < size; i++) {
+ if (offset + i < dynamic_keymap_eeprom_size) {
+ eeprom_update_byte(target, *source);
+ }
+ source++;
+ target++;
+ }
}
// This overrides the one in quantum/keymap_common.c
-uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
-{
- if ( layer < DYNAMIC_KEYMAP_LAYER_COUNT &&
- key.row < MATRIX_ROWS &&
- key.col < MATRIX_COLS ) {
- return dynamic_keymap_get_keycode(layer, key.row, key.col);
- } else {
- return KC_NO;
- }
-}
-
-
-
-uint8_t dynamic_keymap_macro_get_count(void)
-{
- return DYNAMIC_KEYMAP_MACRO_COUNT;
-}
-
-uint16_t dynamic_keymap_macro_get_buffer_size(void)
-{
- return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE;
+uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) {
+ if (layer < DYNAMIC_KEYMAP_LAYER_COUNT && key.row < MATRIX_ROWS && key.col < MATRIX_COLS) {
+ return dynamic_keymap_get_keycode(layer, key.row, key.col);
+ } else {
+ return KC_NO;
+ }
}
-void dynamic_keymap_macro_get_buffer( uint16_t offset, uint16_t size, uint8_t *data )
-{
- void *source = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+offset);
- uint8_t *target = data;
- for ( uint16_t i = 0; i < size; i++ ) {
- if ( offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE ) {
- *target = eeprom_read_byte(source);
- } else {
- *target = 0x00;
- }
- source++;
- target++;
- }
+uint8_t dynamic_keymap_macro_get_count(void) { return DYNAMIC_KEYMAP_MACRO_COUNT; }
+
+uint16_t dynamic_keymap_macro_get_buffer_size(void) { return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; }
+
+void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) {
+ void * source = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset);
+ uint8_t *target = data;
+ for (uint16_t i = 0; i < size; i++) {
+ if (offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE) {
+ *target = eeprom_read_byte(source);
+ } else {
+ *target = 0x00;
+ }
+ source++;
+ target++;
+ }
}
-void dynamic_keymap_macro_set_buffer( uint16_t offset, uint16_t size, uint8_t *data )
-{
- void *target = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+offset);
- uint8_t *source = data;
- for ( uint16_t i = 0; i < size; i++ ) {
- if ( offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE ) {
- eeprom_update_byte(target, *source);
- }
- source++;
- target++;
- }
+void dynamic_keymap_macro_set_buffer(uint16_t offset, uint16_t size, uint8_t *data) {
+ void * target = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset);
+ uint8_t *source = data;
+ for (uint16_t i = 0; i < size; i++) {
+ if (offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE) {
+ eeprom_update_byte(target, *source);
+ }
+ source++;
+ target++;
+ }
}
-void dynamic_keymap_macro_reset(void)
-{
- void *p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
- void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
- while ( p != end ) {
- eeprom_update_byte(p, 0);
- ++p;
- }
+void dynamic_keymap_macro_reset(void) {
+ void *p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
+ void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
+ while (p != end) {
+ eeprom_update_byte(p, 0);
+ ++p;
+ }
}
-void dynamic_keymap_macro_send( uint8_t id )
-{
- if ( id >= DYNAMIC_KEYMAP_MACRO_COUNT ) {
- return;
- }
-
- // Check the last byte of the buffer.
- // If it's not zero, then we are in the middle
- // of buffer writing, possibly an aborted buffer
- // write. So do nothing.
- void *p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE-1);
- if ( eeprom_read_byte(p) != 0 ) {
- return;
- }
-
- // Skip N null characters
- // p will then point to the Nth macro
- p = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
- void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR+DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
- while ( id > 0 ) {
- // If we are past the end of the buffer, then the buffer
- // contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT
- // nulls in the buffer.
- if ( p == end ) {
- return;
- }
- if ( eeprom_read_byte(p) == 0 ) {
- --id;
- }
- ++p;
- }
-
- // Send the macro string one or two chars at a time
- // by making temporary 1 or 2 char strings
- char data[3] = { 0, 0, 0 };
- // We already checked there was a null at the end of
- // the buffer, so this cannot go past the end
- while ( 1 ) {
- data[0] = eeprom_read_byte(p++);
- data[1] = 0;
- // Stop at the null terminator of this macro string
- if ( data[0] == 0 ) {
- break;
- }
- // If the char is magic (tap, down, up),
- // add the next char (key to use) and send a 2 char string.
- if ( data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE ) {
- data[1] = eeprom_read_byte(p++);
- if ( data[1] == 0 ) {
- break;
- }
- }
- send_string(data);
- }
+void dynamic_keymap_macro_send(uint8_t id) {
+ if (id >= DYNAMIC_KEYMAP_MACRO_COUNT) {
+ return;
+ }
+
+ // Check the last byte of the buffer.
+ // If it's not zero, then we are in the middle
+ // of buffer writing, possibly an aborted buffer
+ // write. So do nothing.
+ void *p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE - 1);
+ if (eeprom_read_byte(p) != 0) {
+ return;
+ }
+
+ // Skip N null characters
+ // p will then point to the Nth macro
+ p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
+ void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
+ while (id > 0) {
+ // If we are past the end of the buffer, then the buffer
+ // contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT
+ // nulls in the buffer.
+ if (p == end) {
+ return;
+ }
+ if (eeprom_read_byte(p) == 0) {
+ --id;
+ }
+ ++p;
+ }
+
+ // Send the macro string one or two chars at a time
+ // by making temporary 1 or 2 char strings
+ char data[3] = {0, 0, 0};
+ // We already checked there was a null at the end of
+ // the buffer, so this cannot go past the end
+ while (1) {
+ data[0] = eeprom_read_byte(p++);
+ data[1] = 0;
+ // Stop at the null terminator of this macro string
+ if (data[0] == 0) {
+ break;
+ }
+ // If the char is magic (tap, down, up),
+ // add the next char (key to use) and send a 2 char string.
+ if (data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE) {
+ data[1] = eeprom_read_byte(p++);
+ if (data[1] == 0) {
+ break;
+ }
+ }
+ send_string(data);
+ }
}
-#endif // DYNAMIC_KEYMAP_ENABLE
-
+#endif // DYNAMIC_KEYMAP_ENABLE
diff --git a/quantum/dynamic_keymap.h b/quantum/dynamic_keymap.h
index 63653f6cb7..55676172b6 100644
--- a/quantum/dynamic_keymap.h
+++ b/quantum/dynamic_keymap.h
@@ -18,11 +18,11 @@
#include <stdint.h>
#include <stdbool.h>
-uint8_t dynamic_keymap_get_layer_count(void);
-void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column);
+uint8_t dynamic_keymap_get_layer_count(void);
+void * dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column);
uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column);
-void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode);
-void dynamic_keymap_reset(void);
+void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode);
+void dynamic_keymap_reset(void);
// These get/set the keycodes as stored in the EEPROM buffer
// Data is big-endian 16-bit values (the keycodes)
// Order is by layer/row/column
@@ -31,14 +31,12 @@ void dynamic_keymap_reset(void);
// This is only really useful for host applications that want to get a whole keymap fast,
// by reading 14 keycodes (28 bytes) at a time, reducing the number of raw HID transfers by
// a factor of 14.
-void dynamic_keymap_get_buffer( uint16_t offset, uint16_t size, uint8_t *data );
-void dynamic_keymap_set_buffer( uint16_t offset, uint16_t size, uint8_t *data );
+void dynamic_keymap_get_buffer(uint16_t offset, uint16_t size, uint8_t *data);
+void dynamic_keymap_set_buffer(uint16_t offset, uint16_t size, uint8_t *data);
// This overrides the one in quantum/keymap_common.c
// uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
-
-
// Note regarding dynamic_keymap_macro_set_buffer():
// The last byte of the buffer is used as a valid flag,
// so macro sending is disabled during writing a new buffer,
@@ -53,11 +51,10 @@ void dynamic_keymap_set_buffer( uint16_t offset, uint16_t size, uint8_t *data );
// and it not being null means the buffer can be considered in an
// invalid state.
-uint8_t dynamic_keymap_macro_get_count(void);
+uint8_t dynamic_keymap_macro_get_count(void);
uint16_t dynamic_keymap_macro_get_buffer_size(void);
-void dynamic_keymap_macro_get_buffer( uint16_t offset, uint16_t size, uint8_t *data );
-void dynamic_keymap_macro_set_buffer( uint16_t offset, uint16_t size, uint8_t *data );
-void dynamic_keymap_macro_reset(void);
-
-void dynamic_keymap_macro_send( uint8_t id );
+void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data);
+void dynamic_keymap_macro_set_buffer(uint16_t offset, uint16_t size, uint8_t *data);
+void dynamic_keymap_macro_reset(void);
+void dynamic_keymap_macro_send(uint8_t id);
diff --git a/quantum/dynamic_macro.h b/quantum/dynamic_macro.h
index 07cba19f60..fe9de6fa65 100644
--- a/quantum/dynamic_macro.h
+++ b/quantum/dynamic_macro.h
@@ -15,8 +15,10 @@
*/
/* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */
-#ifndef DYNAMIC_MACROS_H
-#define DYNAMIC_MACROS_H
+#pragma once
+
+/* Warn users that this is now deprecated and they should use the core feature instead. */
+#pragma message "Dynamic Macros is now a core feature. See updated documentation to see how to configure it: https://docs.qmk.fm/#/feature_dynamic_macros"
#include "action_layer.h"
@@ -30,24 +32,11 @@
* there have been reports of it being too much in some users' cases,
* so 128 is considered a safe default.
*/
-#define DYNAMIC_MACRO_SIZE 128
+# define DYNAMIC_MACRO_SIZE 128
#endif
-/* DYNAMIC_MACRO_RANGE must be set as the last element of user's
- * "planck_keycodes" enum prior to including this header. This allows
- * us to 'extend' it.
- */
-enum dynamic_macro_keycodes {
- DYN_REC_START1 = DYNAMIC_MACRO_RANGE,
- DYN_REC_START2,
- DYN_REC_STOP,
- DYN_MACRO_PLAY1,
- DYN_MACRO_PLAY2,
-};
-
/* Blink the LEDs to notify the user about some event. */
-void dynamic_macro_led_blink(void)
-{
+void dynamic_macro_led_blink(void) {
#ifdef BACKLIGHT_ENABLE
backlight_toggle();
wait_ms(100);
@@ -59,10 +48,8 @@ void dynamic_macro_led_blink(void)
* need a `direction` variable accessible at the call site.
*/
#define DYNAMIC_MACRO_CURRENT_SLOT() (direction > 0 ? 1 : 2)
-#define DYNAMIC_MACRO_CURRENT_LENGTH(BEGIN, POINTER) \
- ((int)(direction * ((POINTER) - (BEGIN))))
-#define DYNAMIC_MACRO_CURRENT_CAPACITY(BEGIN, END2) \
- ((int)(direction * ((END2) - (BEGIN)) + 1))
+#define DYNAMIC_MACRO_CURRENT_LENGTH(BEGIN, POINTER) ((int)(direction * ((POINTER) - (BEGIN))))
+#define DYNAMIC_MACRO_CURRENT_CAPACITY(BEGIN, END2) ((int)(direction * ((END2) - (BEGIN)) + 1))
/**
* Start recording of the dynamic macro.
@@ -70,9 +57,7 @@ void dynamic_macro_led_blink(void)
* @param[out] macro_pointer The new macro buffer iterator.
* @param[in] macro_buffer The macro buffer used to initialize macro_pointer.
*/
-void dynamic_macro_record_start(
- keyrecord_t **macro_pointer, keyrecord_t *macro_buffer)
-{
+void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer) {
dprintln("dynamic macro recording: started");
dynamic_macro_led_blink();
@@ -89,9 +74,7 @@ void dynamic_macro_record_start(
* @param macro_end[in] The element after the last macro buffer element.
* @param direction[in] Either +1 or -1, which way to iterate the buffer.
*/
-void dynamic_macro_play(
- keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_t direction)
-{
+void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_t direction) {
dprintf("dynamic macro: slot %d playback\n", DYNAMIC_MACRO_CURRENT_SLOT());
uint32_t saved_layer_state = layer_state;
@@ -118,13 +101,7 @@ void dynamic_macro_play(
* @param direction[in] Either +1 or -1, which way to iterate the buffer.
* @param record[in] The current keypress.
*/
-void dynamic_macro_record_key(
- keyrecord_t *macro_buffer,
- keyrecord_t **macro_pointer,
- keyrecord_t *macro2_end,
- int8_t direction,
- keyrecord_t *record)
-{
+void dynamic_macro_record_key(keyrecord_t *macro_buffer, keyrecord_t **macro_pointer, keyrecord_t *macro2_end, int8_t direction, keyrecord_t *record) {
/* If we've just started recording, ignore all the key releases. */
if (!record->event.pressed && *macro_pointer == macro_buffer) {
dprintln("dynamic macro: ignoring a leading key-up event");
@@ -141,38 +118,25 @@ void dynamic_macro_record_key(
dynamic_macro_led_blink();
}
- dprintf(
- "dynamic macro: slot %d length: %d/%d\n",
- DYNAMIC_MACRO_CURRENT_SLOT(),
- DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, *macro_pointer),
- DYNAMIC_MACRO_CURRENT_CAPACITY(macro_buffer, macro2_end));
+ dprintf("dynamic macro: slot %d length: %d/%d\n", DYNAMIC_MACRO_CURRENT_SLOT(), DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, *macro_pointer), DYNAMIC_MACRO_CURRENT_CAPACITY(macro_buffer, macro2_end));
}
/**
* End recording of the dynamic macro. Essentially just update the
* pointer to the end of the macro.
*/
-void dynamic_macro_record_end(
- keyrecord_t *macro_buffer,
- keyrecord_t *macro_pointer,
- int8_t direction,
- keyrecord_t **macro_end)
-{
+void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_pointer, int8_t direction, keyrecord_t **macro_end) {
dynamic_macro_led_blink();
/* Do not save the keys being held when stopping the recording,
* i.e. the keys used to access the layer DYN_REC_STOP is on.
*/
- while (macro_pointer != macro_buffer &&
- (macro_pointer - direction)->event.pressed) {
+ while (macro_pointer != macro_buffer && (macro_pointer - direction)->event.pressed) {
dprintln("dynamic macro: trimming a trailing key-down event");
macro_pointer -= direction;
}
- dprintf(
- "dynamic macro: slot %d saved, length: %d\n",
- DYNAMIC_MACRO_CURRENT_SLOT(),
- DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, macro_pointer));
+ dprintf("dynamic macro: slot %d saved, length: %d\n", DYNAMIC_MACRO_CURRENT_SLOT(), DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, macro_pointer));
*macro_end = macro_pointer;
}
@@ -187,8 +151,7 @@ void dynamic_macro_record_end(
* <...THE REST OF THE FUNCTION...>
* }
*/
-bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record)
-{
+bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
/* Both macros use the same buffer but read/write on different
* ends of it.
*
@@ -239,57 +202,57 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record)
/* No macro recording in progress. */
if (!record->event.pressed) {
switch (keycode) {
- case DYN_REC_START1:
- dynamic_macro_record_start(&macro_pointer, macro_buffer);
- macro_id = 1;
- return false;
- case DYN_REC_START2:
- dynamic_macro_record_start(&macro_pointer, r_macro_buffer);
- macro_id = 2;
- return false;
- case DYN_MACRO_PLAY1:
- dynamic_macro_play(macro_buffer, macro_end, +1);
- return false;
- case DYN_MACRO_PLAY2:
- dynamic_macro_play(r_macro_buffer, r_macro_end, -1);
- return false;
+ case DYN_REC_START1:
+ dynamic_macro_record_start(&macro_pointer, macro_buffer);
+ macro_id = 1;
+ return false;
+ case DYN_REC_START2:
+ dynamic_macro_record_start(&macro_pointer, r_macro_buffer);
+ macro_id = 2;
+ return false;
+ case DYN_MACRO_PLAY1:
+ dynamic_macro_play(macro_buffer, macro_end, +1);
+ return false;
+ case DYN_MACRO_PLAY2:
+ dynamic_macro_play(r_macro_buffer, r_macro_end, -1);
+ return false;
}
}
} else {
/* A macro is being recorded right now. */
switch (keycode) {
- case DYN_REC_STOP:
- /* Stop the macro recording. */
- if (record->event.pressed) { /* Ignore the initial release
- * just after the recoding
- * starts. */
+ case DYN_REC_STOP:
+ /* Stop the macro recording. */
+ if (record->event.pressed) { /* Ignore the initial release
+ * just after the recoding
+ * starts. */
+ switch (macro_id) {
+ case 1:
+ dynamic_macro_record_end(macro_buffer, macro_pointer, +1, &macro_end);
+ break;
+ case 2:
+ dynamic_macro_record_end(r_macro_buffer, macro_pointer, -1, &r_macro_end);
+ break;
+ }
+ macro_id = 0;
+ }
+ return false;
+ case DYN_MACRO_PLAY1:
+ case DYN_MACRO_PLAY2:
+ dprintln("dynamic macro: ignoring macro play key while recording");
+ return false;
+ default:
+ /* Store the key in the macro buffer and process it normally. */
switch (macro_id) {
- case 1:
- dynamic_macro_record_end(macro_buffer, macro_pointer, +1, &macro_end);
- break;
- case 2:
- dynamic_macro_record_end(r_macro_buffer, macro_pointer, -1, &r_macro_end);
- break;
+ case 1:
+ dynamic_macro_record_key(macro_buffer, &macro_pointer, r_macro_end, +1, record);
+ break;
+ case 2:
+ dynamic_macro_record_key(r_macro_buffer, &macro_pointer, macro_end, -1, record);
+ break;
}
- macro_id = 0;
- }
- return false;
- case DYN_MACRO_PLAY1:
- case DYN_MACRO_PLAY2:
- dprintln("dynamic macro: ignoring macro play key while recording");
- return false;
- default:
- /* Store the key in the macro buffer and process it normally. */
- switch (macro_id) {
- case 1:
- dynamic_macro_record_key(macro_buffer, &macro_pointer, r_macro_end, +1, record);
+ return true;
break;
- case 2:
- dynamic_macro_record_key(r_macro_buffer, &macro_pointer, macro_end, -1, record);
- break;
- }
- return true;
- break;
}
}
@@ -299,5 +262,3 @@ bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record)
#undef DYNAMIC_MACRO_CURRENT_SLOT
#undef DYNAMIC_MACRO_CURRENT_LENGTH
#undef DYNAMIC_MACRO_CURRENT_CAPACITY
-
-#endif
diff --git a/quantum/encoder.c b/quantum/encoder.c
index ddf6234ab8..4aeb3d0cde 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -16,84 +16,110 @@
*/
#include "encoder.h"
+#ifdef SPLIT_KEYBOARD
+# include "split_util.h"
+#endif
// for memcpy
#include <string.h>
-
#ifndef ENCODER_RESOLUTION
- #define ENCODER_RESOLUTION 4
-#endif
-
-#ifndef NUMBER_OF_ENCODERS
- #error "Number of encoders not defined by NUMBER_OF_ENCODERS"
+# define ENCODER_RESOLUTION 4
#endif
#if !defined(ENCODERS_PAD_A) || !defined(ENCODERS_PAD_B)
- #error "No encoder pads defined by ENCODERS_PAD_A and ENCODERS_PAD_B"
+# error "No encoder pads defined by ENCODERS_PAD_A and ENCODERS_PAD_B"
#endif
-static pin_t encoders_pad_a[NUMBER_OF_ENCODERS] = ENCODERS_PAD_A;
-static pin_t encoders_pad_b[NUMBER_OF_ENCODERS] = ENCODERS_PAD_B;
+#define NUMBER_OF_ENCODERS (sizeof(encoders_pad_a) / sizeof(pin_t))
+static pin_t encoders_pad_a[] = ENCODERS_PAD_A;
+static pin_t encoders_pad_b[] = ENCODERS_PAD_B;
-static int8_t encoder_LUT[] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 };
+static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0};
-static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0};
+static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0};
+static int8_t encoder_pulses[NUMBER_OF_ENCODERS] = {0};
#ifdef SPLIT_KEYBOARD
-// slave half encoders come over as second set of encoders
-static int8_t encoder_value[NUMBER_OF_ENCODERS * 2] = {0};
+// right half encoders come over as second set of encoders
+static uint8_t encoder_value[NUMBER_OF_ENCODERS * 2] = {0};
+// row offsets for each hand
+static uint8_t thisHand, thatHand;
#else
-static int8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
+static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
#endif
-__attribute__ ((weak))
-void encoder_update_user(int8_t index, bool clockwise) { }
+__attribute__((weak)) void encoder_update_user(int8_t index, bool clockwise) {}
-__attribute__ ((weak))
-void encoder_update_kb(int8_t index, bool clockwise) {
- encoder_update_user(index, clockwise);
-}
+__attribute__((weak)) void encoder_update_kb(int8_t index, bool clockwise) { encoder_update_user(index, clockwise); }
void encoder_init(void) {
- for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
- setPinInputHigh(encoders_pad_a[i]);
- setPinInputHigh(encoders_pad_b[i]);
+#if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT)
+ if (!isLeftHand) {
+ const pin_t encoders_pad_a_right[] = ENCODERS_PAD_A_RIGHT;
+ const pin_t encoders_pad_b_right[] = ENCODERS_PAD_B_RIGHT;
+ for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) {
+ encoders_pad_a[i] = encoders_pad_a_right[i];
+ encoders_pad_b[i] = encoders_pad_b_right[i];
+ }
+ }
+#endif
+
+ for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
+ setPinInputHigh(encoders_pad_a[i]);
+ setPinInputHigh(encoders_pad_b[i]);
+
+ encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
+ }
- encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
- }
+#ifdef SPLIT_KEYBOARD
+ thisHand = isLeftHand ? 0 : NUMBER_OF_ENCODERS;
+ thatHand = NUMBER_OF_ENCODERS - thisHand;
+#endif
}
-void encoder_read(void) {
- for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
- encoder_state[i] <<= 2;
- encoder_state[i] |= (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
- encoder_value[i] += encoder_LUT[encoder_state[i] & 0xF];
- if (encoder_value[i] >= ENCODER_RESOLUTION) {
- encoder_update_kb(i, false);
+static void encoder_update(int8_t index, uint8_t state) {
+ encoder_pulses[index] += encoder_LUT[state & 0xF];
+ if (encoder_pulses[index] >= ENCODER_RESOLUTION) {
+ encoder_value[index]++;
+ encoder_update_kb(index, true);
}
- if (encoder_value[i] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
- encoder_update_kb(i, true);
+ if (encoder_pulses[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
+ encoder_value[index]--;
+ encoder_update_kb(index, false);
}
- encoder_value[i] %= ENCODER_RESOLUTION;
- }
+ encoder_pulses[index] %= ENCODER_RESOLUTION;
}
-#ifdef SPLIT_KEYBOARD
-void encoder_state_raw(uint8_t* slave_state) {
- memcpy(slave_state, encoder_state, sizeof(encoder_state));
+void encoder_read(void) {
+ for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
+ encoder_state[i] <<= 2;
+ encoder_state[i] |= (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
+#if SPLIT_KEYBOARD
+ encoder_update(i + thisHand, encoder_state[i]);
+#else
+ encoder_update(i, encoder_state[i]);
+#endif
+ }
}
+#ifdef SPLIT_KEYBOARD
+void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, &encoder_value[thisHand], sizeof(uint8_t) * NUMBER_OF_ENCODERS); }
+
void encoder_update_raw(uint8_t* slave_state) {
- for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
- encoder_value[NUMBER_OF_ENCODERS + i] += encoder_LUT[slave_state[i] & 0xF];
- if (encoder_value[NUMBER_OF_ENCODERS + i] >= ENCODER_RESOLUTION) {
- encoder_update_kb(NUMBER_OF_ENCODERS + i, false);
- }
- if (encoder_value[NUMBER_OF_ENCODERS + i] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
- encoder_update_kb(NUMBER_OF_ENCODERS + i, true);
+ for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
+ uint8_t index = i + thatHand;
+ int8_t delta = slave_state[i] - encoder_value[index];
+ while (delta > 0) {
+ delta--;
+ encoder_value[index]++;
+ encoder_update_kb(index, true);
+ }
+ while (delta < 0) {
+ delta++;
+ encoder_value[index]--;
+ encoder_update_kb(index, false);
+ }
}
- encoder_value[NUMBER_OF_ENCODERS + i] %= ENCODER_RESOLUTION;
- }
}
#endif
diff --git a/quantum/fauxclicky.c b/quantum/fauxclicky.c
index c3341ca332..a57e2ed075 100644
--- a/quantum/fauxclicky.c
+++ b/quantum/fauxclicky.c
@@ -20,23 +20,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include <musical_notes.h>
-bool fauxclicky_enabled = true;
-uint16_t note_start = 0;
-bool note_playing = false;
-uint16_t note_period = 0;
+bool fauxclicky_enabled = true;
+uint16_t note_start = 0;
+bool note_playing = false;
+uint16_t note_period = 0;
-void fauxclicky_init()
-{
+void fauxclicky_init() {
// Set port PC6 (OC3A and /OC4A) as output
DDRC |= _BV(PORTC6);
// TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
- TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
+ TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
}
-void fauxclicky_stop()
-{
+void fauxclicky_stop() {
FAUXCLICKY_DISABLE_OUTPUT;
note_playing = false;
}
@@ -45,10 +43,10 @@ void fauxclicky_play(float note[]) {
if (!fauxclicky_enabled) return;
if (note_playing) fauxclicky_stop();
FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER));
- FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)) / (float)2);
- note_playing = true;
- note_period = (note[1] / (float)16) * ((float)60 / (float)FAUXCLICKY_TEMPO) * 1000;
- note_start = timer_read();
+ FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)) / (float)2);
+ note_playing = true;
+ note_period = (note[1] / (float)16) * ((float)60 / (float)FAUXCLICKY_TEMPO) * 1000;
+ note_start = timer_read();
FAUXCLICKY_ENABLE_OUTPUT;
}
diff --git a/quantum/fauxclicky.h b/quantum/fauxclicky.h
index 1a8e188dd5..5c056918a7 100644
--- a/quantum/fauxclicky.h
+++ b/quantum/fauxclicky.h
@@ -14,18 +14,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef AUDIO_ENABLE
-#error "AUDIO_ENABLE and FAUXCLICKY_ENABLE cannot be both enabled"
+# error "AUDIO_ENABLE and FAUXCLICKY_ENABLE cannot be both enabled"
#endif
#include "musical_notes.h"
#include "stdbool.h"
-__attribute__ ((weak))
-float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_D4, 0.25);
-__attribute__ ((weak))
-float fauxclicky_released_note[2] = MUSICAL_NOTE(_C4, 0.125);
-__attribute__ ((weak))
-float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C4, 0.25);
+__attribute__((weak)) float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_D4, 0.25);
+__attribute__((weak)) float fauxclicky_released_note[2] = MUSICAL_NOTE(_C4, 0.125);
+__attribute__((weak)) float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C4, 0.25);
bool fauxclicky_enabled;
@@ -34,7 +31,7 @@ bool fauxclicky_enabled;
//
#ifndef FAUXCLICKY_TEMPO
-#define FAUXCLICKY_TEMPO TEMPO_DEFAULT
+# define FAUXCLICKY_TEMPO TEMPO_DEFAULT
#endif
// beep on press
@@ -50,42 +47,44 @@ bool fauxclicky_enabled;
#define FAUXCLICKY_ON fauxclicky_enabled = true
// disable
-#define FAUXCLICKY_OFF do { \
- fauxclicky_enabled = false; \
- fauxclicky_stop(); \
-} while (0)
+#define FAUXCLICKY_OFF \
+ do { \
+ fauxclicky_enabled = false; \
+ fauxclicky_stop(); \
+ } while (0)
// toggle
-#define FAUXCLICKY_TOGGLE do { \
- if (fauxclicky_enabled) { \
- FAUXCLICKY_OFF; \
- } else { \
- FAUXCLICKY_ON; \
- } \
-} while (0)
+#define FAUXCLICKY_TOGGLE \
+ do { \
+ if (fauxclicky_enabled) { \
+ FAUXCLICKY_OFF; \
+ } else { \
+ FAUXCLICKY_ON; \
+ } \
+ } while (0)
//
// pin configuration
//
#ifndef FAUXCLICKY_CPU_PRESCALER
-#define FAUXCLICKY_CPU_PRESCALER 8
+# define FAUXCLICKY_CPU_PRESCALER 8
#endif
#ifndef FAUXCLICKY_ENABLE_OUTPUT
-#define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1)
+# define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1)
#endif
#ifndef FAUXCLICKY_DISABLE_OUTPUT
-#define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0))
+# define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0))
#endif
#ifndef FAUXCLICKY_TIMER_PERIOD
-#define FAUXCLICKY_TIMER_PERIOD ICR3
+# define FAUXCLICKY_TIMER_PERIOD ICR3
#endif
#ifndef FAUXCLICKY_DUTY_CYCLE
-#define FAUXCLICKY_DUTY_CYCLE OCR3A
+# define FAUXCLICKY_DUTY_CYCLE OCR3A
#endif
//
@@ -96,4 +95,3 @@ void fauxclicky_init(void);
void fauxclicky_stop(void);
void fauxclicky_play(float note[2]);
void fauxclicky_check(void);
-
diff --git a/quantum/keycode_config.c b/quantum/keycode_config.c
index 0dc5105d21..f340905eab 100644
--- a/quantum/keycode_config.c
+++ b/quantum/keycode_config.c
@@ -18,8 +18,12 @@
extern keymap_config_t keymap_config;
+/** \brief keycode_config
+ *
+ * This function is used to check a specific keycode against the bootmagic config,
+ * and will return the corrected keycode, when appropriate.
+ */
uint16_t keycode_config(uint16_t keycode) {
-
switch (keycode) {
case KC_CAPSLOCK:
case KC_LOCKING_CAPS:
@@ -31,6 +35,12 @@ uint16_t keycode_config(uint16_t keycode) {
if (keymap_config.swap_control_capslock) {
return KC_CAPSLOCK;
}
+ if (keymap_config.swap_lctl_lgui) {
+ if (keymap_config.no_gui) {
+ return KC_NO;
+ }
+ return KC_LGUI;
+ }
return KC_LCTL;
case KC_LALT:
if (keymap_config.swap_lalt_lgui) {
@@ -44,10 +54,21 @@ uint16_t keycode_config(uint16_t keycode) {
if (keymap_config.swap_lalt_lgui) {
return KC_LALT;
}
+ if (keymap_config.swap_lctl_lgui) {
+ return KC_LCTRL;
+ }
if (keymap_config.no_gui) {
return KC_NO;
}
return KC_LGUI;
+ case KC_RCTL:
+ if (keymap_config.swap_rctl_rgui) {
+ if (keymap_config.no_gui) {
+ return KC_NO;
+ }
+ return KC_RGUI;
+ }
+ return KC_RCTL;
case KC_RALT:
if (keymap_config.swap_ralt_rgui) {
if (keymap_config.no_gui) {
@@ -60,6 +81,9 @@ uint16_t keycode_config(uint16_t keycode) {
if (keymap_config.swap_ralt_rgui) {
return KC_RALT;
}
+ if (keymap_config.swap_rctl_rgui) {
+ return KC_RCTL;
+ }
if (keymap_config.no_gui) {
return KC_NO;
}
@@ -89,6 +113,12 @@ uint16_t keycode_config(uint16_t keycode) {
}
}
+/** \brief mod_config
+ *
+ * This function checks the mods passed to it against the bootmagic config,
+ * and will remove or replace mods, based on that.
+ */
+
uint8_t mod_config(uint8_t mod) {
if (keymap_config.swap_lalt_lgui) {
if ((mod & MOD_RGUI) == MOD_LGUI) {
@@ -108,6 +138,24 @@ uint8_t mod_config(uint8_t mod) {
mod |= MOD_RGUI;
}
}
+ if (keymap_config.swap_lctl_lgui) {
+ if ((mod & MOD_RGUI) == MOD_LGUI) {
+ mod &= ~MOD_LGUI;
+ mod |= MOD_LCTL;
+ } else if ((mod & MOD_RCTL) == MOD_LCTL) {
+ mod &= ~MOD_LCTL;
+ mod |= MOD_LGUI;
+ }
+ }
+ if (keymap_config.swap_rctl_rgui) {
+ if ((mod & MOD_RGUI) == MOD_RGUI) {
+ mod &= ~MOD_RGUI;
+ mod |= MOD_RCTL;
+ } else if ((mod & MOD_RCTL) == MOD_RCTL) {
+ mod &= ~MOD_RCTL;
+ mod |= MOD_RGUI;
+ }
+ }
if (keymap_config.no_gui) {
mod &= ~MOD_LGUI;
mod &= ~MOD_RGUI;
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h
index 022f4bd19b..aa75ba2c13 100644
--- a/quantum/keycode_config.h
+++ b/quantum/keycode_config.h
@@ -19,23 +19,25 @@
#include "action_code.h"
#ifndef KEYCODE_CONFIG_H
-#define KEYCODE_CONFIG_H
+# define KEYCODE_CONFIG_H
uint16_t keycode_config(uint16_t keycode);
-uint8_t mod_config(uint8_t mod);
+uint8_t mod_config(uint8_t mod);
/* NOTE: Not portable. Bit field order depends on implementation */
typedef union {
uint16_t raw;
struct {
- bool swap_control_capslock:1;
- bool capslock_to_control:1;
- bool swap_lalt_lgui:1;
- bool swap_ralt_rgui:1;
- bool no_gui:1;
- bool swap_grave_esc:1;
- bool swap_backslash_backspace:1;
- bool nkro:1;
+ bool swap_control_capslock : 1;
+ bool capslock_to_control : 1;
+ bool swap_lalt_lgui : 1;
+ bool swap_ralt_rgui : 1;
+ bool no_gui : 1;
+ bool swap_grave_esc : 1;
+ bool swap_backslash_backspace : 1;
+ bool nkro : 1;
+ bool swap_lctl_lgui : 1;
+ bool swap_rctl_rgui : 1;
};
} keymap_config_t;
diff --git a/quantum/keymap.h b/quantum/keymap.h
index bfcb2f7cd5..34a9c8f8c6 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -22,10 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include "action.h"
#if defined(__AVR__)
-#include <avr/pgmspace.h>
+# include <avr/pgmspace.h>
#elif defined PROTOCOL_CHIBIOS
-//We need to ensure that chibios is include before redefining reset
-#include "ch.h"
+// We need to ensure that chibios is include before redefining reset
+# include "ch.h"
#endif
#include "keycode.h"
#include "action_macro.h"
@@ -38,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// ChibiOS uses RESET in its FlagStatus enumeration
// Therefore define it as QK_RESET here, to avoid name collision
#if defined(PROTOCOL_CHIBIOS)
-#define RESET QK_RESET
+# define RESET QK_RESET
#endif
#include "quantum_keycodes.h"
@@ -47,10 +47,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
// translates function id to action
-uint16_t keymap_function_id_to_action( uint16_t function_id );
+uint16_t keymap_function_id_to_action(uint16_t function_id);
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];
-
#endif
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index eef739a14a..4fa45ac37b 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -20,17 +20,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keycode.h"
#include "action_layer.h"
#if defined(__AVR__)
-#include <util/delay.h>
-#include <stdio.h>
+# include <util/delay.h>
+# include <stdio.h>
#endif
#include "action.h"
#include "action_macro.h"
#include "debug.h"
-#include "backlight.h"
#include "quantum.h"
+#ifdef BACKLIGHT_ENABLE
+# include "backlight.h"
+#endif
+
#ifdef MIDI_ENABLE
- #include "process_midi.h"
+# include "process_midi.h"
#endif
extern keymap_config_t keymap_config;
@@ -38,8 +41,7 @@ extern keymap_config_t keymap_config;
#include <inttypes.h>
/* converts key to action */
-action_t action_for_key(uint8_t layer, keypos_t key)
-{
+action_t action_for_key(uint8_t layer, keypos_t key) {
// 16bit keycodes - important
uint16_t keycode = keymap_key_to_keycode(layer, key);
@@ -47,7 +49,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
keycode = keycode_config(keycode);
action_t action;
- uint8_t action_layer, when, mod;
+ uint8_t action_layer, when, mod;
switch (keycode) {
case KC_FN0 ... KC_FN31:
@@ -69,18 +71,18 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case KC_TRNS:
action.code = ACTION_TRANSPARENT;
break;
- case QK_MODS ... QK_MODS_MAX: ;
+ case QK_MODS ... QK_MODS_MAX:;
// Has a modifier
// Split it up
- action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
+ action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
break;
- case QK_FUNCTION ... QK_FUNCTION_MAX: ;
+ case QK_FUNCTION ... QK_FUNCTION_MAX:;
// Is a shortcut for function action_layer, pull last 12bits
// This means we have 4,096 FN macros at our disposal
- action.code = keymap_function_id_to_action( (int)keycode & 0xFFF );
+ action.code = keymap_function_id_to_action((int)keycode & 0xFFF);
break;
case QK_MACRO ... QK_MACRO_MAX:
- if (keycode & 0x800) // tap macros have upper bit set
+ if (keycode & 0x800) // tap macros have upper bit set
action.code = ACTION_MACRO_TAP(keycode & 0xFF);
else
action.code = ACTION_MACRO(keycode & 0xFF);
@@ -88,50 +90,50 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
break;
- case QK_TO ... QK_TO_MAX: ;
+ case QK_TO ... QK_TO_MAX:;
// Layer set "GOTO"
- when = (keycode >> 0x4) & 0x3;
+ when = (keycode >> 0x4) & 0x3;
action_layer = keycode & 0xF;
- action.code = ACTION_LAYER_SET(action_layer, when);
+ action.code = ACTION_LAYER_SET(action_layer, when);
break;
- case QK_MOMENTARY ... QK_MOMENTARY_MAX: ;
+ case QK_MOMENTARY ... QK_MOMENTARY_MAX:;
// Momentary action_layer
action_layer = keycode & 0xFF;
- action.code = ACTION_LAYER_MOMENTARY(action_layer);
+ action.code = ACTION_LAYER_MOMENTARY(action_layer);
break;
- case QK_DEF_LAYER ... QK_DEF_LAYER_MAX: ;
+ case QK_DEF_LAYER ... QK_DEF_LAYER_MAX:;
// Set default action_layer
action_layer = keycode & 0xFF;
- action.code = ACTION_DEFAULT_LAYER_SET(action_layer);
+ action.code = ACTION_DEFAULT_LAYER_SET(action_layer);
break;
- case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: ;
+ case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX:;
// Set toggle
action_layer = keycode & 0xFF;
- action.code = ACTION_LAYER_TOGGLE(action_layer);
+ action.code = ACTION_LAYER_TOGGLE(action_layer);
break;
- case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: ;
+ case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX:;
// OSL(action_layer) - One-shot action_layer
action_layer = keycode & 0xFF;
- action.code = ACTION_LAYER_ONESHOT(action_layer);
+ action.code = ACTION_LAYER_ONESHOT(action_layer);
break;
- case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: ;
+ case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:;
// OSM(mod) - One-shot mod
- mod = mod_config(keycode & 0xFF);
+ mod = mod_config(keycode & 0xFF);
action.code = ACTION_MODS_ONESHOT(mod);
break;
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF);
break;
case QK_LAYER_MOD ... QK_LAYER_MOD_MAX:
- mod = mod_config(keycode & 0xF);
+ mod = mod_config(keycode & 0xF);
action_layer = (keycode >> 4) & 0xF;
- action.code = ACTION_LAYER_MODS(action_layer, mod);
+ action.code = ACTION_LAYER_MODS(action_layer, mod);
break;
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
- mod = mod_config((keycode >> 0x8) & 0x1F);
+ mod = mod_config((keycode >> 0x8) & 0x1F);
action.code = ACTION_MODS_TAP_KEY(mod, keycode & 0xFF);
break;
- #ifdef BACKLIGHT_ENABLE
+#ifdef BACKLIGHT_ENABLE
case BL_ON:
action.code = ACTION_BACKLIGHT_ON();
break;
@@ -150,12 +152,12 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case BL_STEP:
action.code = ACTION_BACKLIGHT_STEP();
break;
- #endif
- #ifdef SWAP_HANDS_ENABLE
+#endif
+#ifdef SWAP_HANDS_ENABLE
case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
action.code = ACTION(ACT_SWAP_HANDS, keycode & 0xff);
break;
- #endif
+#endif
default:
action.code = ACTION_NO;
@@ -164,42 +166,30 @@ action_t action_for_key(uint8_t layer, keypos_t key)
return action;
}
-__attribute__ ((weak))
-const uint16_t PROGMEM fn_actions[] = {
+__attribute__((weak)) const uint16_t PROGMEM fn_actions[] = {
};
/* Macro */
-__attribute__ ((weak))
-const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
-{
- return MACRO_NONE;
-}
+__attribute__((weak)) const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; }
/* Function */
-__attribute__ ((weak))
-void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
-{
-}
+__attribute__((weak)) void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {}
// translates key to keycode
-__attribute__ ((weak))
-uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
-{
+__attribute__((weak)) uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) {
// Read entire word (16bits)
return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
}
// translates function id to action
-__attribute__ ((weak))
-uint16_t keymap_function_id_to_action( uint16_t function_id )
-{
- // The compiler sees the empty (weak) fn_actions and generates a warning
- // This function should not be called in that case, so the warning is too strict
- // If this function is called however, the keymap should have overridden fn_actions, and then the compile
- // is comparing against the wrong array
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Warray-bounds"
- return pgm_read_word(&fn_actions[function_id]);
- #pragma GCC diagnostic pop
+__attribute__((weak)) uint16_t keymap_function_id_to_action(uint16_t function_id) {
+// The compiler sees the empty (weak) fn_actions and generates a warning
+// This function should not be called in that case, so the warning is too strict
+// If this function is called however, the keymap should have overridden fn_actions, and then the compile
+// is comparing against the wrong array
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+ return pgm_read_word(&fn_actions[function_id]);
+#pragma GCC diagnostic pop
}
diff --git a/quantum/keymap_extras/keymap_belgian.h b/quantum/keymap_extras/keymap_belgian.h
index ab89fbabfe..55a0d892c5 100644
--- a/quantum/keymap_extras/keymap_belgian.h
+++ b/quantum/keymap_extras/keymap_belgian.h
@@ -20,86 +20,86 @@
// Normal characters
// Line 1
-#define BE_SUP2 KC_GRV
-#define BE_AMP KC_1
-#define BE_EACU KC_2
-#define BE_QUOT KC_3
-#define BE_APOS KC_4
-#define BE_LPRN KC_5
-#define BE_PARA KC_6
-#define BE_EGRV KC_7
-#define BE_EXLM KC_8
-#define BE_CCED KC_9
-#define BE_AGRV KC_0
-#define BE_RPRN KC_MINS
-#define BE_MINS KC_EQL
+#define BE_SUP2 KC_GRV
+#define BE_AMP KC_1
+#define BE_EACU KC_2
+#define BE_QUOT KC_3
+#define BE_APOS KC_4
+#define BE_LPRN KC_5
+#define BE_PARA KC_6
+#define BE_EGRV KC_7
+#define BE_EXLM KC_8
+#define BE_CCED KC_9
+#define BE_AGRV KC_0
+#define BE_RPRN KC_MINS
+#define BE_MINS KC_EQL
// Line 2
-#define BE_A KC_Q
-#define BE_Z KC_W
-#define BE_CIRC KC_LBRC
-#define BE_DLR KC_RBRC
+#define BE_A KC_Q
+#define BE_Z KC_W
+#define BE_CIRC KC_LBRC
+#define BE_DLR KC_RBRC
// Line 3
-#define BE_Q KC_A
-#define BE_M KC_SCLN
-#define BE_UGRV KC_QUOT
-#define BE_MU KC_NUHS
+#define BE_Q KC_A
+#define BE_M KC_SCLN
+#define BE_UGRV KC_QUOT
+#define BE_MU KC_NUHS
// Line 4
-#define BE_LESS KC_NUBS
-#define BE_W KC_Z
-#define BE_COMM KC_M
-#define BE_SCLN KC_COMM
-#define BE_COLN KC_DOT
-#define BE_EQL KC_SLSH
+#define BE_LESS KC_NUBS
+#define BE_W KC_Z
+#define BE_COMM KC_M
+#define BE_SCLN KC_COMM
+#define BE_COLN KC_DOT
+#define BE_EQL KC_SLSH
// Shifted characters
// Line 1
#define BE_SUP3 KC_TILD
-#define BE_1 LSFT(KC_1)
-#define BE_2 LSFT(KC_2)
-#define BE_3 LSFT(KC_3)
-#define BE_4 LSFT(KC_4)
-#define BE_5 LSFT(KC_5)
-#define BE_6 LSFT(KC_6)
-#define BE_7 LSFT(KC_7)
-#define BE_8 LSFT(KC_8)
-#define BE_9 LSFT(KC_9)
-#define BE_0 LSFT(KC_0)
-#define BE_OVRR KC_UNDS
+#define BE_1 LSFT(KC_1)
+#define BE_2 LSFT(KC_2)
+#define BE_3 LSFT(KC_3)
+#define BE_4 LSFT(KC_4)
+#define BE_5 LSFT(KC_5)
+#define BE_6 LSFT(KC_6)
+#define BE_7 LSFT(KC_7)
+#define BE_8 LSFT(KC_8)
+#define BE_9 LSFT(KC_9)
+#define BE_0 LSFT(KC_0)
+#define BE_OVRR KC_UNDS
#define BE_UNDS KC_PLUS
// Line 2
-#define BE_UMLT LSFT(BE_CIRC)
-#define BE_PND LSFT(BE_DLR)
+#define BE_UMLT LSFT(BE_CIRC)
+#define BE_PND LSFT(BE_DLR)
// Line 3
-#define BE_PERC LSFT(BE_UGRV)
+#define BE_PERC LSFT(BE_UGRV)
// Line 4
-#define BE_GRTR LSFT(BE_LESS)
-#define BE_QUES LSFT(BE_COMM)
-#define BE_DOT LSFT(BE_SCLN)
-#define BE_SLSH LSFT(BE_COLN)
-#define BE_PLUS LSFT(BE_EQL)
+#define BE_GRTR LSFT(BE_LESS)
+#define BE_QUES LSFT(BE_COMM)
+#define BE_DOT LSFT(BE_SCLN)
+#define BE_SLSH LSFT(BE_COLN)
+#define BE_PLUS LSFT(BE_EQL)
// Alt Gr-ed characters
// Line 1
#define BE_PIPE ALGR(KC_1)
-#define BE_AT ALGR(KC_2)
-#define BE_HASH ALGR(KC_3)
+#define BE_AT ALGR(KC_2)
+#define BE_HASH ALGR(KC_3)
#define BE_LCBR ALGR(KC_9)
-#define BE_RCBR ALGR(KC_0)
+#define BE_RCBR ALGR(KC_0)
// Line 2
-#define BE_EURO ALGR(KC_E)
+#define BE_EURO ALGR(KC_E)
#define BE_LSBR ALGR(BE_CIRC)
#define BE_RSBR ALGR(BE_DLR)
// Line 3
#define BE_ACUT ALGR(BE_UGRV)
-#define BE_GRV ALGR(BE_MU)
+#define BE_GRV ALGR(BE_MU)
// Line 4
#define BE_BSLS ALGR(BE_LESS)
diff --git a/quantum/keymap_extras/keymap_bepo.h b/quantum/keymap_extras/keymap_bepo.h
index 8d7b36ca3d..718baaa683 100644
--- a/quantum/keymap_extras/keymap_bepo.h
+++ b/quantum/keymap_extras/keymap_bepo.h
@@ -21,297 +21,297 @@
// Normal characters
// First row (on usual keyboards)
-#define BP_DOLLAR KC_GRAVE // $
-#define BP_DLR BP_DOLLAR
-#define BP_DOUBLE_QUOTE KC_1 // "
-#define BP_DQOT BP_DOUBLE_QUOTE
-#define BP_LEFT_GUILLEMET KC_2 // «
-#define BP_LGIL BP_LEFT_GUILLEMET
-#define BP_RIGHT_GUILLEMET KC_3 // »
-#define BP_RGIL BP_RIGHT_GUILLEMET
-#define BP_LEFT_PAREN KC_4 // (
-#define BP_LPRN BP_LEFT_PAREN
-#define BP_RIGHT_PAREN KC_5 // )
-#define BP_RPRN BP_RIGHT_PAREN
-#define BP_AT KC_6 // @
-#define BP_PLUS KC_7 // +
-#define BP_MINUS KC_8 // -
-#define BP_MINS BP_MINUS
-#define BP_SLASH KC_9 // /
-#define BP_SLSH BP_SLASH
-#define BP_ASTERISK KC_0 // *
-#define BP_ASTR BP_ASTERISK
-#define BP_EQUAL KC_MINUS // =
-#define BP_EQL BP_EQUAL
-#define BP_PERCENT KC_EQUAL // %
-#define BP_PERC BP_PERCENT
+#define BP_DOLLAR KC_GRAVE // $
+#define BP_DLR BP_DOLLAR
+#define BP_DOUBLE_QUOTE KC_1 // "
+#define BP_DQOT BP_DOUBLE_QUOTE
+#define BP_LEFT_GUILLEMET KC_2 // «
+#define BP_LGIL BP_LEFT_GUILLEMET
+#define BP_RIGHT_GUILLEMET KC_3 // »
+#define BP_RGIL BP_RIGHT_GUILLEMET
+#define BP_LEFT_PAREN KC_4 // (
+#define BP_LPRN BP_LEFT_PAREN
+#define BP_RIGHT_PAREN KC_5 // )
+#define BP_RPRN BP_RIGHT_PAREN
+#define BP_AT KC_6 // @
+#define BP_PLUS KC_7 // +
+#define BP_MINUS KC_8 // -
+#define BP_MINS BP_MINUS
+#define BP_SLASH KC_9 // /
+#define BP_SLSH BP_SLASH
+#define BP_ASTERISK KC_0 // *
+#define BP_ASTR BP_ASTERISK
+#define BP_EQUAL KC_MINUS // =
+#define BP_EQL BP_EQUAL
+#define BP_PERCENT KC_EQUAL // %
+#define BP_PERC BP_PERCENT
// Second row
-#define BP_B KC_Q
-#define BP_E_ACUTE KC_W // é
-#define BP_ECUT BP_E_ACUTE
-#define BP_P KC_E
-#define BP_O KC_R
-#define BP_E_GRAVE KC_T // è
-#define BP_EGRV BP_E_GRAVE
-#define BP_DEAD_CIRCUMFLEX KC_Y // dead ^
-#define BP_DCRC BP_DEAD_CIRCUMFLEX
-#define BP_V KC_U
-#define BP_D KC_I
-#define BP_L KC_O
-#define BP_J KC_P
-#define BP_Z KC_LBRACKET
-#define BP_W KC_RBRACKET
+#define BP_B KC_Q
+#define BP_E_ACUTE KC_W // é
+#define BP_ECUT BP_E_ACUTE
+#define BP_P KC_E
+#define BP_O KC_R
+#define BP_E_GRAVE KC_T // è
+#define BP_EGRV BP_E_GRAVE
+#define BP_DEAD_CIRCUMFLEX KC_Y // dead ^
+#define BP_DCRC BP_DEAD_CIRCUMFLEX
+#define BP_V KC_U
+#define BP_D KC_I
+#define BP_L KC_O
+#define BP_J KC_P
+#define BP_Z KC_LBRACKET
+#define BP_W KC_RBRACKET
// Third row
-#define BP_A KC_A
-#define BP_U KC_S
-#define BP_I KC_D
-#define BP_E KC_F
-#define BP_COMMA KC_G // ,
-#define BP_COMM BP_COMMA
-#define BP_C KC_H
-#define BP_T KC_J
-#define BP_S KC_K
-#define BP_R KC_L
-#define BP_N KC_SCOLON
-#define BP_M KC_QUOTE
-#define BP_C_CEDILLA KC_BSLASH // ç
-#define BP_CCED BP_C_CEDILLA
+#define BP_A KC_A
+#define BP_U KC_S
+#define BP_I KC_D
+#define BP_E KC_F
+#define BP_COMMA KC_G // ,
+#define BP_COMM BP_COMMA
+#define BP_C KC_H
+#define BP_T KC_J
+#define BP_S KC_K
+#define BP_R KC_L
+#define BP_N KC_SCOLON
+#define BP_M KC_QUOTE
+#define BP_C_CEDILLA KC_BSLASH // ç
+#define BP_CCED BP_C_CEDILLA
// Fourth row
-#define BP_E_CIRCUMFLEX KC_NONUS_BSLASH // ê
-#define BP_ECRC BP_E_CIRCUMFLEX
-#define BP_A_GRAVE KC_Z // à
-#define BP_AGRV BP_A_GRAVE
-#define BP_Y KC_X
-#define BP_X KC_C
-#define BP_DOT KC_V // .
-#define BP_K KC_B
-#define BP_APOSTROPHE KC_N
-#define BP_APOS BP_APOSTROPHE // '
-#define BP_Q KC_M
-#define BP_G KC_COMMA
-#define BP_H KC_DOT
-#define BP_F KC_SLASH
+#define BP_E_CIRCUMFLEX KC_NONUS_BSLASH // ê
+#define BP_ECRC BP_E_CIRCUMFLEX
+#define BP_A_GRAVE KC_Z // à
+#define BP_AGRV BP_A_GRAVE
+#define BP_Y KC_X
+#define BP_X KC_C
+#define BP_DOT KC_V // .
+#define BP_K KC_B
+#define BP_APOSTROPHE KC_N
+#define BP_APOS BP_APOSTROPHE // '
+#define BP_Q KC_M
+#define BP_G KC_COMMA
+#define BP_H KC_DOT
+#define BP_F KC_SLASH
// Shifted characters
// First row
-#define BP_HASH LSFT(BP_DOLLAR) // #
-#define BP_1 LSFT(KC_1)
-#define BP_2 LSFT(KC_2)
-#define BP_3 LSFT(KC_3)
-#define BP_4 LSFT(KC_4)
-#define BP_5 LSFT(KC_5)
-#define BP_6 LSFT(KC_6)
-#define BP_7 LSFT(KC_7)
-#define BP_8 LSFT(KC_8)
-#define BP_9 LSFT(KC_9)
-#define BP_0 LSFT(KC_0)
-#define BP_DEGREE LSFT(BP_EQUAL) // °
-#define BP_DEGR BP_DEGREE
-#define BP_GRAVE LSFT(BP_PERCENT) // `
-#define BP_GRV BP_GRAVE
+#define BP_HASH LSFT(BP_DOLLAR) // #
+#define BP_1 LSFT(KC_1)
+#define BP_2 LSFT(KC_2)
+#define BP_3 LSFT(KC_3)
+#define BP_4 LSFT(KC_4)
+#define BP_5 LSFT(KC_5)
+#define BP_6 LSFT(KC_6)
+#define BP_7 LSFT(KC_7)
+#define BP_8 LSFT(KC_8)
+#define BP_9 LSFT(KC_9)
+#define BP_0 LSFT(KC_0)
+#define BP_DEGREE LSFT(BP_EQUAL) // °
+#define BP_DEGR BP_DEGREE
+#define BP_GRAVE LSFT(BP_PERCENT) // `
+#define BP_GRV BP_GRAVE
// Second row
-#define BP_EXCLAIM LSFT(BP_DEAD_CIRCUMFLEX) // !
-#define BP_EXLM BP_EXCLAIM
+#define BP_EXCLAIM LSFT(BP_DEAD_CIRCUMFLEX) // !
+#define BP_EXLM BP_EXCLAIM
// Third row
-#define BP_SCOLON LSFT(BP_COMMA) // ;
-#define BP_SCLN BP_SCOLON
+#define BP_SCOLON LSFT(BP_COMMA) // ;
+#define BP_SCLN BP_SCOLON
// Fourth row
-#define BP_COLON LSFT(BP_DOT) // :
-#define BP_COLN BP_COLON
+#define BP_COLON LSFT(BP_DOT) // :
+#define BP_COLN BP_COLON
#define BP_QUESTION LSFT(BP_APOS) // ?
-#define BP_QEST BP_QUESTION
+#define BP_QEST BP_QUESTION
// Space bar
-#define BP_NON_BREAKING_SPACE LSFT(KC_SPACE)
-#define BP_NBSP BP_NON_BREAKING_SPACE
+#define BP_NON_BREAKING_SPACE LSFT(KC_SPACE)
+#define BP_NBSP BP_NON_BREAKING_SPACE
// AltGr-ed characters
// First row
-#define BP_EN_DASH ALGR(BP_DOLLAR) // –
-#define BP_NDSH BP_EN_DASH
-#define BP_EM_DASH ALGR(KC_1) // —
-#define BP_MDSH BP_EM_DASH
-#define BP_LESS ALGR(KC_2) // <
-#define BP_GREATER ALGR(KC_3) // >
-#define BP_GRTR BP_GREATER
-#define BP_LBRACKET ALGR(KC_4) // [
-#define BP_LBRC BP_LBRACKET
-#define BP_RBRACKET ALGR(KC_5) // ]
-#define BP_RBRC BP_RBRACKET
-#define BP_CIRCUMFLEX ALGR(KC_6) // ^
-#define BP_CIRC BP_CIRCUMFLEX
-#define BP_PLUS_MINUS ALGR(KC_7) // ±
-#define BP_PSMS BP_PLUS_MINUS
-#define BP_MATH_MINUS ALGR(KC_8) // −
-#define BP_MMNS BP_MATH_MINUS
-#define BP_OBELUS ALGR(KC_9) // ÷
-#define BP_OBEL BP_OBELUS
+#define BP_EN_DASH ALGR(BP_DOLLAR) // –
+#define BP_NDSH BP_EN_DASH
+#define BP_EM_DASH ALGR(KC_1) // —
+#define BP_MDSH BP_EM_DASH
+#define BP_LESS ALGR(KC_2) // <
+#define BP_GREATER ALGR(KC_3) // >
+#define BP_GRTR BP_GREATER
+#define BP_LBRACKET ALGR(KC_4) // [
+#define BP_LBRC BP_LBRACKET
+#define BP_RBRACKET ALGR(KC_5) // ]
+#define BP_RBRC BP_RBRACKET
+#define BP_CIRCUMFLEX ALGR(KC_6) // ^
+#define BP_CIRC BP_CIRCUMFLEX
+#define BP_PLUS_MINUS ALGR(KC_7) // ±
+#define BP_PSMS BP_PLUS_MINUS
+#define BP_MATH_MINUS ALGR(KC_8) // −
+#define BP_MMNS BP_MATH_MINUS
+#define BP_OBELUS ALGR(KC_9) // ÷
+#define BP_OBEL BP_OBELUS
// more conventional name of the symbol
-#define BP_DIVISION_SIGN BP_OBELUS
-#define BP_DVSN BP_DIVISION_SIGN
-#define BP_TIMES ALGR(KC_0) // ×
-#define BP_TIMS BP_TIMES
-#define BP_DIFFERENT ALGR(BP_EQUAL) // ≠
-#define BP_DIFF BP_DIFFERENT
-#define BP_PERMILLE ALGR(BP_PERCENT) // ‰
-#define BP_PMIL BP_PERMILLE
+#define BP_DIVISION_SIGN BP_OBELUS
+#define BP_DVSN BP_DIVISION_SIGN
+#define BP_TIMES ALGR(KC_0) // ×
+#define BP_TIMS BP_TIMES
+#define BP_DIFFERENT ALGR(BP_EQUAL) // ≠
+#define BP_DIFF BP_DIFFERENT
+#define BP_PERMILLE ALGR(BP_PERCENT) // ‰
+#define BP_PMIL BP_PERMILLE
// Second row
-#define BP_PIPE ALGR(BP_B) // |
-#define BP_DEAD_ACUTE ALGR(BP_E_ACUTE) // dead ´
-#define BP_DACT BP_DEAD_ACUTE
-#define BP_AMPERSAND ALGR(BP_P) // &
-#define BP_AMPR BP_AMPERSAND
-#define BP_OE_LIGATURE ALGR(BP_O) // œ
-#define BP_OE BP_OE_LIGATURE
-#define BP_DEAD_GRAVE ALGR(BP_E_GRAVE) // `
-#define BP_DGRV BP_DEAD_GRAVE
-#define BP_INVERTED_EXCLAIM ALGR(BP_DEAD_CIRCUMFLEX) // ¡
-#define BP_IXLM BP_INVERTED_EXCLAIM
-#define BP_DEAD_CARON ALGR(BP_V) // dead ˇ
-#define BP_DCAR BP_DEAD_CARON
-#define BP_ETH ALGR(BP_D) // ð
-#define BP_DEAD_SLASH ALGR(BP_L) // dead /
-#define BP_DSLH BP_DEAD_SLASH
-#define BP_IJ_LIGATURE ALGR(BP_J) // ij
-#define BP_IJ BP_IJ_LIGATURE
-#define BP_SCHWA ALGR(BP_Z) // ə
-#define BP_SCWA BP_SCHWA
-#define BP_DEAD_BREVE ALGR(BP_W) // dead ˘
-#define BP_DBRV BP_DEAD_BREVE
+#define BP_PIPE ALGR(BP_B) // |
+#define BP_DEAD_ACUTE ALGR(BP_E_ACUTE) // dead ´
+#define BP_DACT BP_DEAD_ACUTE
+#define BP_AMPERSAND ALGR(BP_P) // &
+#define BP_AMPR BP_AMPERSAND
+#define BP_OE_LIGATURE ALGR(BP_O) // œ
+#define BP_OE BP_OE_LIGATURE
+#define BP_DEAD_GRAVE ALGR(BP_E_GRAVE) // `
+#define BP_DGRV BP_DEAD_GRAVE
+#define BP_INVERTED_EXCLAIM ALGR(BP_DEAD_CIRCUMFLEX) // ¡
+#define BP_IXLM BP_INVERTED_EXCLAIM
+#define BP_DEAD_CARON ALGR(BP_V) // dead ˇ
+#define BP_DCAR BP_DEAD_CARON
+#define BP_ETH ALGR(BP_D) // ð
+#define BP_DEAD_SLASH ALGR(BP_L) // dead /
+#define BP_DSLH BP_DEAD_SLASH
+#define BP_IJ_LIGATURE ALGR(BP_J) // ij
+#define BP_IJ BP_IJ_LIGATURE
+#define BP_SCHWA ALGR(BP_Z) // ə
+#define BP_SCWA BP_SCHWA
+#define BP_DEAD_BREVE ALGR(BP_W) // dead ˘
+#define BP_DBRV BP_DEAD_BREVE
// Third row
-#define BP_AE_LIGATURE ALGR(BP_A) // æ
-#define BP_AE BP_AE_LIGATURE
-#define BP_U_GRAVE ALGR(BP_U) // ù
-#define BP_UGRV BP_U_GRAVE
-#define BP_DEAD_TREMA ALGR(BP_I) // dead ¨ (trema/umlaut/diaresis)
-#define BP_DTRM BP_DEAD_TREMA
-#define BP_EURO ALGR(BP_E) // €
-#define BP_TYPOGRAPHICAL_APOSTROPHE ALGR(BP_COMMA) // ’
-#define BP_TAPO BP_TYPOGRAPHICAL_APOSTROPHE
-#define BP_COPYRIGHT ALGR(BP_C) // ©
-#define BP_CPRT BP_COPYRIGHT
-#define BP_THORN ALGR(BP_T) // þ
-#define BP_THRN BP_THORN
-#define BP_SHARP_S ALGR(BP_S) // ß
-#define BP_SRPS BP_SHARP_S
-#define BP_REGISTERED_TRADEMARK ALGR(BP_R) // ®
-#define BP_RTM BP_REGISTERED_TRADEMARK
-#define BP_DEAD_TILDE ALGR(BP_N) // dead ~
-#define BP_DTLD BP_DEAD_TILDE
-#define BP_DEAD_MACRON ALGR(BP_M) // dead ¯
-#define BP_DMCR BP_DEAD_MACRON
-#define BP_DEAD_CEDILLA ALGR(BP_C_CEDILLA) // dead ¸
-#define BP_DCED BP_DEAD_CEDILLA
+#define BP_AE_LIGATURE ALGR(BP_A) // æ
+#define BP_AE BP_AE_LIGATURE
+#define BP_U_GRAVE ALGR(BP_U) // ù
+#define BP_UGRV BP_U_GRAVE
+#define BP_DEAD_TREMA ALGR(BP_I) // dead ¨ (trema/umlaut/diaresis)
+#define BP_DTRM BP_DEAD_TREMA
+#define BP_EURO ALGR(BP_E) // €
+#define BP_TYPOGRAPHICAL_APOSTROPHE ALGR(BP_COMMA) // ’
+#define BP_TAPO BP_TYPOGRAPHICAL_APOSTROPHE
+#define BP_COPYRIGHT ALGR(BP_C) // ©
+#define BP_CPRT BP_COPYRIGHT
+#define BP_THORN ALGR(BP_T) // þ
+#define BP_THRN BP_THORN
+#define BP_SHARP_S ALGR(BP_S) // ß
+#define BP_SRPS BP_SHARP_S
+#define BP_REGISTERED_TRADEMARK ALGR(BP_R) // ®
+#define BP_RTM BP_REGISTERED_TRADEMARK
+#define BP_DEAD_TILDE ALGR(BP_N) // dead ~
+#define BP_DTLD BP_DEAD_TILDE
+#define BP_DEAD_MACRON ALGR(BP_M) // dead ¯
+#define BP_DMCR BP_DEAD_MACRON
+#define BP_DEAD_CEDILLA ALGR(BP_C_CEDILLA) // dead ¸
+#define BP_DCED BP_DEAD_CEDILLA
// Fourth row
-#define BP_NONUS_SLASH ALGR(BP_E_CIRCUMFLEX) // / on non-us backslash key (102nd key, ê in bépo)
-#define BP_NUSL BP_NONUS_SLASH
-#define BP_BACKSLASH ALGR(BP_A_GRAVE) /* \ */
-#define BP_BSLS BP_BACKSLASH
-#define BP_LEFT_CURLY_BRACE ALGR(BP_Y) // {
-#define BP_LCBR BP_LEFT_CURLY_BRACE
-#define BP_RIGHT_CURLY_BRACE ALGR(BP_X) // }
-#define BP_RCBR BP_RIGHT_CURLY_BRACE
-#define BP_ELLIPSIS ALGR(BP_DOT) // …
-#define BP_ELPS BP_ELLIPSIS
-#define BP_TILDE ALGR(BP_K) // ~
-#define BP_TILD BP_TILDE
-#define BP_INVERTED_QUESTION ALGR(BP_QUESTION) // ¿
-#define BP_IQST BP_INVERTED_QUESTION
-#define BP_DEAD_RING ALGR(BP_Q) // dead °
-#define BP_DRNG BP_DEAD_RING
-#define BP_DEAD_GREEK ALGR(BP_G) // dead Greek key (following key will make a Greek letter)
-#define BP_DGRK BP_DEAD_GREEK
-#define BP_DAGGER ALGR(BP_H) // †
-#define BP_DAGR BP_DAGGER
-#define BP_DEAD_OGONEK ALGR(BP_F) // dead ˛
-#define BP_DOGO BP_DEAD_OGONEK
+#define BP_NONUS_SLASH ALGR(BP_E_CIRCUMFLEX) // / on non-us backslash key (102nd key, ê in bépo)
+#define BP_NUSL BP_NONUS_SLASH
+#define BP_BACKSLASH ALGR(BP_A_GRAVE) /* \ */
+#define BP_BSLS BP_BACKSLASH
+#define BP_LEFT_CURLY_BRACE ALGR(BP_Y) // {
+#define BP_LCBR BP_LEFT_CURLY_BRACE
+#define BP_RIGHT_CURLY_BRACE ALGR(BP_X) // }
+#define BP_RCBR BP_RIGHT_CURLY_BRACE
+#define BP_ELLIPSIS ALGR(BP_DOT) // …
+#define BP_ELPS BP_ELLIPSIS
+#define BP_TILDE ALGR(BP_K) // ~
+#define BP_TILD BP_TILDE
+#define BP_INVERTED_QUESTION ALGR(BP_QUESTION) // ¿
+#define BP_IQST BP_INVERTED_QUESTION
+#define BP_DEAD_RING ALGR(BP_Q) // dead °
+#define BP_DRNG BP_DEAD_RING
+#define BP_DEAD_GREEK ALGR(BP_G) // dead Greek key (following key will make a Greek letter)
+#define BP_DGRK BP_DEAD_GREEK
+#define BP_DAGGER ALGR(BP_H) // †
+#define BP_DAGR BP_DAGGER
+#define BP_DEAD_OGONEK ALGR(BP_F) // dead ˛
+#define BP_DOGO BP_DEAD_OGONEK
// Space bar
-#define BP_UNDERSCORE ALGR(KC_SPACE) // _
-#define BP_UNDS BP_UNDERSCORE
+#define BP_UNDERSCORE ALGR(KC_SPACE) // _
+#define BP_UNDS BP_UNDERSCORE
// AltGr-Shifted characters (different from capitalised AltGr-ed characters)
// First row
-#define BP_PARAGRAPH ALGR(BP_HASH) // ¶
-#define BP_PARG BP_PARAGRAPH
-#define BP_LOW_DOUBLE_QUOTE ALGR(BP_1) // „
-#define BP_LWQT BP_LOW_DOUBLE_QUOTE
-#define BP_LEFT_DOUBLE_QUOTE ALGR(BP_2) // “
-#define BP_LDQT BP_LEFT_DOUBLE_QUOTE
-#define BP_RIGHT_DOUBLE_QUOTE ALGR(BP_3) // ”
-#define BP_RDQT BP_RIGHT_DOUBLE_QUOTE
-#define BP_LESS_OR_EQUAL ALGR(BP_4) // ≤
-#define BP_LEQL BP_LESS_OR_EQUAL
-#define BP_GREATER_OR_EQUAL ALGR(BP_5) // ≥
-#define BP_GEQL BP_GREATER_OR_EQUAL
+#define BP_PARAGRAPH ALGR(BP_HASH) // ¶
+#define BP_PARG BP_PARAGRAPH
+#define BP_LOW_DOUBLE_QUOTE ALGR(BP_1) // „
+#define BP_LWQT BP_LOW_DOUBLE_QUOTE
+#define BP_LEFT_DOUBLE_QUOTE ALGR(BP_2) // “
+#define BP_LDQT BP_LEFT_DOUBLE_QUOTE
+#define BP_RIGHT_DOUBLE_QUOTE ALGR(BP_3) // ”
+#define BP_RDQT BP_RIGHT_DOUBLE_QUOTE
+#define BP_LESS_OR_EQUAL ALGR(BP_4) // ≤
+#define BP_LEQL BP_LESS_OR_EQUAL
+#define BP_GREATER_OR_EQUAL ALGR(BP_5) // ≥
+#define BP_GEQL BP_GREATER_OR_EQUAL
// nothing on ALGR(BP_6)
-#define BP_NEGATION ALGR(BP_7) // ¬
-#define BP_NEGT BP_NEGATION
-#define BP_ONE_QUARTER ALGR(BP_8) // ¼
-#define BP_1QRT BP_ONE_QUARTER
-#define BP_ONE_HALF ALGR(BP_9) // ½
-#define BP_1HLF BP_ONE_HALF
-#define BP_THREE_QUARTERS ALGR(BP_0) // ¾
-#define BP_3QRT BP_THREE_QUARTERS
-#define BP_MINUTES ALGR(BP_DEGREE) // ′
-#define BP_MNUT BP_MINUTES
-#define BP_SECONDS ALGR(BP_GRAVE) // ″
-#define BP_SCND BP_SECONDS
+#define BP_NEGATION ALGR(BP_7) // ¬
+#define BP_NEGT BP_NEGATION
+#define BP_ONE_QUARTER ALGR(BP_8) // ¼
+#define BP_1QRT BP_ONE_QUARTER
+#define BP_ONE_HALF ALGR(BP_9) // ½
+#define BP_1HLF BP_ONE_HALF
+#define BP_THREE_QUARTERS ALGR(BP_0) // ¾
+#define BP_3QRT BP_THREE_QUARTERS
+#define BP_MINUTES ALGR(BP_DEGREE) // ′
+#define BP_MNUT BP_MINUTES
+#define BP_SECONDS ALGR(BP_GRAVE) // ″
+#define BP_SCND BP_SECONDS
// Second row
-#define BP_BROKEN_PIPE LSFT(BP_PIPE) // ¦
-#define BP_BPIP BP_BROKEN_PIPE
-#define BP_DEAD_DOUBLE_ACUTE LSFT(BP_DEAD_ACUTE) // ˝
-#define BP_DDCT BP_DEAD_DOUBLE_ACUTE
-#define BP_SECTION ALGR(LSFT(BP_P)) // §
-#define BP_SECT BP_SECTION
+#define BP_BROKEN_PIPE LSFT(BP_PIPE) // ¦
+#define BP_BPIP BP_BROKEN_PIPE
+#define BP_DEAD_DOUBLE_ACUTE LSFT(BP_DEAD_ACUTE) // ˝
+#define BP_DDCT BP_DEAD_DOUBLE_ACUTE
+#define BP_SECTION ALGR(LSFT(BP_P)) // §
+#define BP_SECT BP_SECTION
// LSFT(BP_DEAD_GRAVE) is actually the same character as LSFT(BP_PERCENT)
-#define BP_GRAVE_BIS LSFT(BP_DEAD_GRAVE) // `
-#define BP_GRVB BP_GRAVE_BIS
+#define BP_GRAVE_BIS LSFT(BP_DEAD_GRAVE) // `
+#define BP_GRVB BP_GRAVE_BIS
// Third row
-#define BP_DEAD_DOT_ABOVE LSFT(BP_DEAD_TREMA) // dead ˙
-#define BP_DDTA BP_DEAD_DOT_ABOVE
-#define BP_DEAD_CURRENCY LSFT(BP_EURO) // dead ¤ (next key will generate a currency code like ¥ or £)
-#define BP_DCUR BP_DEAD_CURRENCY
-#define BP_DEAD_HORN LSFT(ALGR(BP_COMMA)) // dead ̛
-#define BP_DHRN BP_DEAD_HORN
-#define BP_LONG_S LSFT(ALGR(BP_C)) // ſ
-#define BP_LNGS BP_LONG_S
-#define BP_TRADEMARK LSFT(BP_REGISTERED_TRADEMARK) // ™
-#define BP_TM BP_TRADEMARK
-#define BP_ORDINAL_INDICATOR_O LSFT(ALGR(BP_M)) // º
-#define BP_ORDO BP_ORDINAL_INDICATOR_O
-#define BP_DEAD_COMMA LSFT(BP_DEAD_CEDILLA) // dead ˛
-#define BP_DCOM BP_DEAD_COMMA
+#define BP_DEAD_DOT_ABOVE LSFT(BP_DEAD_TREMA) // dead ˙
+#define BP_DDTA BP_DEAD_DOT_ABOVE
+#define BP_DEAD_CURRENCY LSFT(BP_EURO) // dead ¤ (next key will generate a currency code like ¥ or £)
+#define BP_DCUR BP_DEAD_CURRENCY
+#define BP_DEAD_HORN LSFT(ALGR(BP_COMMA)) // dead ̛
+#define BP_DHRN BP_DEAD_HORN
+#define BP_LONG_S LSFT(ALGR(BP_C)) // ſ
+#define BP_LNGS BP_LONG_S
+#define BP_TRADEMARK LSFT(BP_REGISTERED_TRADEMARK) // ™
+#define BP_TM BP_TRADEMARK
+#define BP_ORDINAL_INDICATOR_O LSFT(ALGR(BP_M)) // º
+#define BP_ORDO BP_ORDINAL_INDICATOR_O
+#define BP_DEAD_COMMA LSFT(BP_DEAD_CEDILLA) // dead ˛
+#define BP_DCOM BP_DEAD_COMMA
// Fourth row
-#define BP_LEFT_QUOTE LSFT(ALGR(BP_Y)) // ‘
-#define BP_LQOT BP_LEFT_QUOTE
-#define BP_RIGHT_QUOTE LSFT(ALGR(BP_X)) // ’
-#define BP_RQOT BP_RIGHT_QUOTE
-#define BP_INTERPUNCT LSFT(ALGR(BP_DOT)) // ·
-#define BP_IPCT BP_INTERPUNCT
-#define BP_DEAD_HOOK_ABOVE LSFT(ALGR(BP_QUESTION)) // dead ̉
-#define BP_DHKA BP_DEAD_HOOK_ABOVE
-#define BP_DEAD_UNDERDOT LSFT(BP_DEAD_RING) // dead ̣
-#define BP_DUDT BP_DEAD_UNDERDOT
-#define BP_DOUBLE_DAGGER LSFT(BP_DAGGER) // ‡
-#define BP_DDGR BP_DOUBLE_DAGGER
-#define BP_ORDINAL_INDICATOR_A LSFT(ALGR(BP_F)) // ª
-#define BP_ORDA BP_ORDINAL_INDICATOR_A
+#define BP_LEFT_QUOTE LSFT(ALGR(BP_Y)) // ‘
+#define BP_LQOT BP_LEFT_QUOTE
+#define BP_RIGHT_QUOTE LSFT(ALGR(BP_X)) // ’
+#define BP_RQOT BP_RIGHT_QUOTE
+#define BP_INTERPUNCT LSFT(ALGR(BP_DOT)) // ·
+#define BP_IPCT BP_INTERPUNCT
+#define BP_DEAD_HOOK_ABOVE LSFT(ALGR(BP_QUESTION)) // dead ̉
+#define BP_DHKA BP_DEAD_HOOK_ABOVE
+#define BP_DEAD_UNDERDOT LSFT(BP_DEAD_RING) // dead ̣
+#define BP_DUDT BP_DEAD_UNDERDOT
+#define BP_DOUBLE_DAGGER LSFT(BP_DAGGER) // ‡
+#define BP_DDGR BP_DOUBLE_DAGGER
+#define BP_ORDINAL_INDICATOR_A LSFT(ALGR(BP_F)) // ª
+#define BP_ORDA BP_ORDINAL_INDICATOR_A
// Space bar
-#define BP_NARROW_NON_BREAKING_SPACE ALGR(BP_NON_BREAKING_SPACE)
-#define BP_NNBS BP_NARROW_NON_BREAKING_SPACE
+#define BP_NARROW_NON_BREAKING_SPACE ALGR(BP_NON_BREAKING_SPACE)
+#define BP_NNBS BP_NARROW_NON_BREAKING_SPACE
#endif
diff --git a/quantum/keymap_extras/keymap_br_abnt2.h b/quantum/keymap_extras/keymap_br_abnt2.h
index b001139dd4..eecd6f2b0b 100644
--- a/quantum/keymap_extras/keymap_br_abnt2.h
+++ b/quantum/keymap_extras/keymap_br_abnt2.h
@@ -17,58 +17,58 @@
#ifndef KEYMAP_BR_ABNT2_H
#define KEYMAP_BR_ABNT2_H
-#include "keymap_common.h"
+#include "keymap.h"
/* Scan codes for the Brazilian ABNT2 keyboard layout */
-#define BR_CCDL KC_SCLN // Ç same scancode as ;: on US layout
-#define BR_SCLN KC_SLSH // ;: same scancode as /? on US layout
-#define BR_QUOT KC_GRV // '" same scancode as `~ on US layout
-#define BR_TILD KC_QUOT // ~^ dead keys, same scancode as '" on US layout
-#define BR_ACUT KC_LBRC // ´` dead keys, same scancode as [{ on US layout
-#define BR_LBRC KC_RBRC // [{ same scancode as ]} on US layout
-#define BR_RBRC KC_BSLS // ]} same scancode as \| on US layout
-#define BR_BSLS KC_NUBS // \| uses the non-US hash scancode (#~, sometimes §±)
-#define BR_SLSH KC_INT1 // /? uses the INTL1 scancode
+#define BR_CCDL KC_SCLN // Ç same scancode as ;: on US layout
+#define BR_SCLN KC_SLSH // ;: same scancode as /? on US layout
+#define BR_QUOT KC_GRV // '" same scancode as `~ on US layout
+#define BR_TILD KC_QUOT // ~^ dead keys, same scancode as '" on US layout
+#define BR_ACUT KC_LBRC // ´` dead keys, same scancode as [{ on US layout
+#define BR_LBRC KC_RBRC // [{ same scancode as ]} on US layout
+#define BR_RBRC KC_BSLS // ]} same scancode as \| on US layout
+#define BR_BSLS KC_NUBS // \| uses the non-US hash scancode (#~, sometimes §±)
+#define BR_SLSH KC_INT1 // /? uses the INTL1 scancode
-#define BR_COLN LSFT(BR_SCLN) // shifted :
-#define BR_DQT LSFT(BR_QUOT) // shifted "
-#define BR_CIRC LSFT(BR_TILD) // shifted ^ (dead key)
-#define BR_GRAV LSFT(BR_ACUT) // shifted ` (dead key)
-#define BR_LCBR LSFT(BR_LBRC) // shifted {
-#define BR_RCBR LSFT(BR_RBRC) // shifted }
-#define BR_PIPE LSFT(BR_BSLS) // shifted |
-#define BR_QUES LSFT(BR_SLSH) // shifted ?
-#define BR_TRMA LSFT(KC_6) // shifted ¨ (dead key - trema accent)
+#define BR_COLN LSFT(BR_SCLN) // shifted :
+#define BR_DQT LSFT(BR_QUOT) // shifted "
+#define BR_CIRC LSFT(BR_TILD) // shifted ^ (dead key)
+#define BR_GRAV LSFT(BR_ACUT) // shifted ` (dead key)
+#define BR_LCBR LSFT(BR_LBRC) // shifted {
+#define BR_RCBR LSFT(BR_RBRC) // shifted }
+#define BR_PIPE LSFT(BR_BSLS) // shifted |
+#define BR_QUES LSFT(BR_SLSH) // shifted ?
+#define BR_TRMA LSFT(KC_6) // shifted ¨ (dead key - trema accent)
// On the ABNT2 the keypad comma and the keypad dot scancodes are switched
// (presumably because in Brazil comma is used as the decimal separator)
#define BR_KPDT KC_KP_COMMA // keypad .
#define BR_KPCM KC_KP_DOT // keypad ,
-#define BR_1UP LALT(KC_1) // 1 superscript ¹ alt+1
-#define BR_2UP LALT(KC_2) // 2 superscript ² alt+2
-#define BR_3UP LALT(KC_3) // 3 superscript ³ alt+3
-#define BR_PND LALT(KC_4) // Pound sign £ alt+4
-#define BR_CENT LALT(KC_5) // Cent sign ¢ alt+5
-#define BR_NOT LALT(KC_6) // Not sign ¬ alt+6
-#define BR_SECT LALT(KC_EQL) // Section sign § alt+=
-#define BR_FORD LALT(BR_LBRC) // Feminine Ordinal Sign ª alt+[
-#define BR_MORD LALT(BR_RBRC) // Masculine Ordinal Sign º alt+]
-#define BR_DGRE LALT(BR_SLSH) // Degree sign ° alt+/
+#define BR_1UP LALT(KC_1) // 1 superscript ¹ alt+1
+#define BR_2UP LALT(KC_2) // 2 superscript ² alt+2
+#define BR_3UP LALT(KC_3) // 3 superscript ³ alt+3
+#define BR_PND LALT(KC_4) // Pound sign £ alt+4
+#define BR_CENT LALT(KC_5) // Cent sign ¢ alt+5
+#define BR_NOT LALT(KC_6) // Not sign ¬ alt+6
+#define BR_SECT LALT(KC_EQL) // Section sign § alt+=
+#define BR_FORD LALT(BR_LBRC) // Feminine Ordinal Sign ª alt+[
+#define BR_MORD LALT(BR_RBRC) // Masculine Ordinal Sign º alt+]
+#define BR_DGRE LALT(BR_SLSH) // Degree sign ° alt+/
-#define BR_EURO LALT(KC_E) // Euro sign € alt+e
-#define BR_NDTD LALT(BR_TILD) // Non-dead key tilde ~ alt+~
-#define BR_NDAC LALT(BR_ACUT) // Non-dead key acute accent ´ alt+´
-#define BR_NDGV LALT(BR_QUOT) // Non-dead key grave accent ` alt+'
-#define BR_NDCR LALT(BR_CIRC) // Non-dead key circumflex accent ^ alt+^ (alt+shift+~)
-#define BR_NDTR LALT(BR_TRMA) // Non-dead key trema accent ¨ alt+¨ (alt+shift+6)
+#define BR_EURO LALT(KC_E) // Euro sign € alt+e
+#define BR_NDTD LALT(BR_TILD) // Non-dead key tilde ~ alt+~
+#define BR_NDAC LALT(BR_ACUT) // Non-dead key acute accent ´ alt+´
+#define BR_NDGV LALT(BR_QUOT) // Non-dead key grave accent ` alt+'
+#define BR_NDCR LALT(BR_CIRC) // Non-dead key circumflex accent ^ alt+^ (alt+shift+~)
+#define BR_NDTR LALT(BR_TRMA) // Non-dead key trema accent ¨ alt+¨ (alt+shift+6)
// For 101-key keyboard layouts, the ABNT2 layout allows
// the slash and question mark to be typed using alt+q and alt+w.
// The shortcuts are provided here for completeness' sake,
// but it's recommended to use BR_SLSH and BR_QUES instead
-#define BR_ASLS LALT(KC_Q)
-#define BR_AQST LALT(KC_W)
+#define BR_ASLS LALT(KC_Q)
+#define BR_AQST LALT(KC_W)
#endif
diff --git a/quantum/keymap_extras/keymap_canadian_multilingual.h b/quantum/keymap_extras/keymap_canadian_multilingual.h
index 2b5b95d6fa..4fc174e735 100644
--- a/quantum/keymap_extras/keymap_canadian_multilingual.h
+++ b/quantum/keymap_extras/keymap_canadian_multilingual.h
@@ -19,241 +19,241 @@
#include "keymap.h"
#ifndef GR2A
-#define GR2A(kc) RCTL(kc)
+# define GR2A(kc) RCTL(kc)
#endif
// Normal characters
// First row
-#define CSA_SLASH KC_GRV // /
-#define CSA_SLSH CSA_SLASH
+#define CSA_SLASH KC_GRV // /
+#define CSA_SLSH CSA_SLASH
// Second row
-#define CSA_DEAD_CIRCUMFLEX KC_LBRACKET // dead ^
-#define CSA_DCRC CSA_DEAD_CIRCUMFLEX
-#define CSA_C_CEDILLA KC_RBRACKET // Ç
-#define CSA_CCED CSA_C_CEDILLA
+#define CSA_DEAD_CIRCUMFLEX KC_LBRACKET // dead ^
+#define CSA_DCRC CSA_DEAD_CIRCUMFLEX
+#define CSA_C_CEDILLA KC_RBRACKET // Ç
+#define CSA_CCED CSA_C_CEDILLA
// Third row
-#define CSA_E_GRAVE KC_QUOT // è
-#define CSA_EGRV CSA_E_GRAVE
-#define CSA_A_GRAVE KC_BSLASH // à
-#define CSA_AGRV CSA_A_GRAVE
+#define CSA_E_GRAVE KC_QUOT // è
+#define CSA_EGRV CSA_E_GRAVE
+#define CSA_A_GRAVE KC_BSLASH // à
+#define CSA_AGRV CSA_A_GRAVE
// Fourth row
-#define CSA_U_GRAVE KC_NONUS_BSLASH // ù
-#define CSA_UGRV CSA_U_GRAVE
-#define CSA_E_ACUTE KC_SLSH // é
-#define CSA_ECUT CSA_E_ACUTE
+#define CSA_U_GRAVE KC_NONUS_BSLASH // ù
+#define CSA_UGRV CSA_U_GRAVE
+#define CSA_E_ACUTE KC_SLSH // é
+#define CSA_ECUT CSA_E_ACUTE
// Shifted characters
// First row
-#define CSA_BACKSLASH LSFT(CSA_SLASH) /* \ */
-#define CSA_BSLS CSA_BACKSLASH
-#define CSA_QUESTION LSFT(KC_6) // ?
-#define CSA_QEST CSA_QUESTION
+#define CSA_BACKSLASH LSFT(CSA_SLASH) /* \ */
+#define CSA_BSLS CSA_BACKSLASH
+#define CSA_QUESTION LSFT(KC_6) // ?
+#define CSA_QEST CSA_QUESTION
// Second row
-#define CSA_DEAD_TREMA LSFT(CSA_DEAD_CIRCUMFLEX) // dead trema/umlaut/diaresis for ä ë ï ö ü
-#define CSA_DTRM CSA_DEAD_TREMA
+#define CSA_DEAD_TREMA LSFT(CSA_DEAD_CIRCUMFLEX) // dead trema/umlaut/diaresis for ä ë ï ö ü
+#define CSA_DTRM CSA_DEAD_TREMA
// Third row
// all same as US-QWERTY, or capitalised character of the non-shifted key
// Fourth row
-#define CSA_APOSTROPHE LSFT(KC_COMMA) // '
-#define CSA_APOS CSA_APOSTROPHE
-#define CSA_DOUBLE_QUOTE LSFT(KC_DOT) // "
-#define CSA_DQOT CSA_DOUBLE_QUOTE
+#define CSA_APOSTROPHE LSFT(KC_COMMA) // '
+#define CSA_APOS CSA_APOSTROPHE
+#define CSA_DOUBLE_QUOTE LSFT(KC_DOT) // "
+#define CSA_DQOT CSA_DOUBLE_QUOTE
// Alt Gr-ed characters
// First row
-#define CSA_PIPE ALGR(CSA_SLASH) // |
-#define CSA_CURRENCY ALGR(KC_4) // ¤
-#define CSA_CURR CSA_CURRENCY
-#define CSA_LEFT_CURLY_BRACE ALGR(KC_7) // {
-#define CSA_LCBR CSA_LEFT_CURLY_BRACE
-#define CSA_RIGHT_CURLY_BRACE ALGR(KC_8) // }
-#define CSA_RCBR CSA_RIGHT_CURLY_BRACE
-#define CSA_LBRACKET ALGR(KC_9) // [
-#define CSA_LBRC CSA_LBRACKET
-#define CSA_RBRACKET ALGR(KC_0) // ]
-#define CSA_RBRC CSA_RBRACKET
-#define CSA_NEGATION ALGR(KC_EQUAL) // ¬
-#define CSA_NEGT CSA_NEGATION
+#define CSA_PIPE ALGR(CSA_SLASH) // |
+#define CSA_CURRENCY ALGR(KC_4) // ¤
+#define CSA_CURR CSA_CURRENCY
+#define CSA_LEFT_CURLY_BRACE ALGR(KC_7) // {
+#define CSA_LCBR CSA_LEFT_CURLY_BRACE
+#define CSA_RIGHT_CURLY_BRACE ALGR(KC_8) // }
+#define CSA_RCBR CSA_RIGHT_CURLY_BRACE
+#define CSA_LBRACKET ALGR(KC_9) // [
+#define CSA_LBRC CSA_LBRACKET
+#define CSA_RBRACKET ALGR(KC_0) // ]
+#define CSA_RBRC CSA_RBRACKET
+#define CSA_NEGATION ALGR(KC_EQUAL) // ¬
+#define CSA_NEGT CSA_NEGATION
// Second row
// euro symbol not available on Linux? (X.org)
-#define CSA_EURO ALGR(KC_E) // €
-#define CSA_DEAD_GRAVE ALGR(CSA_DEAD_CIRCUMFLEX)
-#define CSA_DGRV CSA_DEAD_GRAVE // dead `
-#define CSA_DEAD_TILDE ALGR(CSA_C_CEDILLA) // ~
-#define CSA_DTLD CSA_DEAD_TILDE
+#define CSA_EURO ALGR(KC_E) // €
+#define CSA_DEAD_GRAVE ALGR(CSA_DEAD_CIRCUMFLEX)
+#define CSA_DGRV CSA_DEAD_GRAVE // dead `
+#define CSA_DEAD_TILDE ALGR(CSA_C_CEDILLA) // ~
+#define CSA_DTLD CSA_DEAD_TILDE
// Third row
-#define CSA_DEGREE ALGR(KC_SCOLON) // °
-#define CSA_DEGR CSA_DEGREE
+#define CSA_DEGREE ALGR(KC_SCOLON) // °
+#define CSA_DEGR CSA_DEGREE
// Fourth row
-#define CSA_LEFT_GUILLEMET ALGR(KC_Z) // «
-#define CSA_LGIL CSA_LEFT_GUILLEMET
-#define CSA_RIGHT_GUILLEMET ALGR(KC_X) // »
-#define CSA_RGIL CSA_RIGHT_GUILLEMET
-#define CSA_LESS ALGR(KC_COMMA) // <
-#define CSA_GREATER ALGR(KC_DOT) // >
-#define CSA_GRTR CSA_GREATER
+#define CSA_LEFT_GUILLEMET ALGR(KC_Z) // «
+#define CSA_LGIL CSA_LEFT_GUILLEMET
+#define CSA_RIGHT_GUILLEMET ALGR(KC_X) // »
+#define CSA_RGIL CSA_RIGHT_GUILLEMET
+#define CSA_LESS ALGR(KC_COMMA) // <
+#define CSA_GREATER ALGR(KC_DOT) // >
+#define CSA_GRTR CSA_GREATER
// Space bar
-#define CSA_NON_BREAKING_SPACE ALGR(KC_SPACE)
-#define CSA_NBSP CSA_NON_BREAKING_SPACE
+#define CSA_NON_BREAKING_SPACE ALGR(KC_SPACE)
+#define CSA_NBSP CSA_NON_BREAKING_SPACE
// GR2A-ed characters
// First row
-#define CSA_SUPERSCRIPT_ONE GR2A(KC_1) // ¹
-#define CSA_SUP1 CSA_SUPERSCRIPT_ONE
-#define CSA_SUPERSCRIPT_TWO GR2A(KC_2) // ²
-#define CSA_SUP2 CSA_SUPERSCRIPT_TWO
-#define CSA_SUPERSCRIPT_THREE GR2A(KC_3) // ³
-#define CSA_SUP3 CSA_SUPERSCRIPT_THREE
-#define CSA_ONE_QUARTER GR2A(KC_4) // ¼
-#define CSA_1QRT CSA_ONE_QUARTER
-#define CSA_ONE_HALF GR2A(KC_5) // ½
-#define CSA_1HLF CSA_ONE_HALF
-#define CSA_THREE_QUARTERS GR2A(KC_6) // ¾
-#define CSA_3QRT CSA_THREE_QUARTERS
+#define CSA_SUPERSCRIPT_ONE GR2A(KC_1) // ¹
+#define CSA_SUP1 CSA_SUPERSCRIPT_ONE
+#define CSA_SUPERSCRIPT_TWO GR2A(KC_2) // ²
+#define CSA_SUP2 CSA_SUPERSCRIPT_TWO
+#define CSA_SUPERSCRIPT_THREE GR2A(KC_3) // ³
+#define CSA_SUP3 CSA_SUPERSCRIPT_THREE
+#define CSA_ONE_QUARTER GR2A(KC_4) // ¼
+#define CSA_1QRT CSA_ONE_QUARTER
+#define CSA_ONE_HALF GR2A(KC_5) // ½
+#define CSA_1HLF CSA_ONE_HALF
+#define CSA_THREE_QUARTERS GR2A(KC_6) // ¾
+#define CSA_3QRT CSA_THREE_QUARTERS
// nothing on 7-0 and -
-#define CSA_DEAD_CEDILLA GR2A(KC_EQUAL) // dead ¸
-#define CSA_DCED CSA_DEAD_CEDILLA
+#define CSA_DEAD_CEDILLA GR2A(KC_EQUAL) // dead ¸
+#define CSA_DCED CSA_DEAD_CEDILLA
// Second row
-#define CSA_OMEGA GR2A(KC_Q) // ω
-#define CSA_OMEG CSA_OMEGA
-#define CSA_L_STROKE GR2A(KC_W) // ł
-#define CSA_LSTK CSA_L_STROKE
-#define CSA_OE_LIGATURE GR2A(KC_E) // œ
-#define CSA_OE CSA_OE_LIGATURE
-#define CSA_PARAGRAPH GR2A(KC_R) // ¶
-#define CSA_PARG CSA_PARAGRAPH
-#define CSA_T_STROKE GR2A(KC_T) // ŧ
-#define CSA_LEFT_ARROW GR2A(KC_Y) // ←
-#define CSA_LARW CSA_LEFT_ARROW
-#define CSA_DOWN_ARROW GR2A(KC_U) // ↓
-#define CSA_DARW CSA_DOWN_ARROW
-#define CSA_RIGHT_ARROW GR2A(KC_I) // →
-#define CSA_RARW CSA_RIGHT_ARROW
-#define CSA_O_STROKE GR2A(KC_O) // ø
-#define CSA_OSTK CSA_O_STROKE
-#define CSA_THORN GR2A(KC_P) // þ
-#define CSA_THRN CSA_THORN
+#define CSA_OMEGA GR2A(KC_Q) // ω
+#define CSA_OMEG CSA_OMEGA
+#define CSA_L_STROKE GR2A(KC_W) // ł
+#define CSA_LSTK CSA_L_STROKE
+#define CSA_OE_LIGATURE GR2A(KC_E) // œ
+#define CSA_OE CSA_OE_LIGATURE
+#define CSA_PARAGRAPH GR2A(KC_R) // ¶
+#define CSA_PARG CSA_PARAGRAPH
+#define CSA_T_STROKE GR2A(KC_T) // ŧ
+#define CSA_LEFT_ARROW GR2A(KC_Y) // ←
+#define CSA_LARW CSA_LEFT_ARROW
+#define CSA_DOWN_ARROW GR2A(KC_U) // ↓
+#define CSA_DARW CSA_DOWN_ARROW
+#define CSA_RIGHT_ARROW GR2A(KC_I) // →
+#define CSA_RARW CSA_RIGHT_ARROW
+#define CSA_O_STROKE GR2A(KC_O) // ø
+#define CSA_OSTK CSA_O_STROKE
+#define CSA_THORN GR2A(KC_P) // þ
+#define CSA_THRN CSA_THORN
// nothing on ^
-#define CSA_TILDE GR2A(CSA_C_CEDILLA) // dead ~
-#define CSA_TILD CSA_TILDE
+#define CSA_TILDE GR2A(CSA_C_CEDILLA) // dead ~
+#define CSA_TILD CSA_TILDE
// Third row
-#define CSA_AE_LIGATURE GR2A(KC_A) // æ
-#define CSA_AE CSA_AE_LIGATURE
-#define CSA_SHARP_S GR2A(KC_S) // ß
-#define CSA_SRPS CSA_SHARP_S
-#define CSA_ETH GR2A(KC_D) // ð
+#define CSA_AE_LIGATURE GR2A(KC_A) // æ
+#define CSA_AE CSA_AE_LIGATURE
+#define CSA_SHARP_S GR2A(KC_S) // ß
+#define CSA_SRPS CSA_SHARP_S
+#define CSA_ETH GR2A(KC_D) // ð
// nothing on F
-#define CSA_ENG GR2A(KC_G) // ŋ
-#define CSA_H_SRTOKE GR2A(KC_H) // ħ
-#define CSA_HSTK CSA_H_SRTOKE
-#define CSA_IJ_LIGATURE GR2A(KC_J) // ij
-#define CSA_IJ CSA_IJ_LIGATURE
-#define CSA_KRA GR2A(KC_K) // ĸ
-#define CSA_L_FLOWN_DOT GR2A(KC_L) // ŀ
-#define CSA_LFLD CSA_L_FLOWN_DOT
-#define CSA_DEAD_ACUTE GR2A(KC_SCLN) // dead acute accent
-#define CSA_DACT CSA_DEAD_ACUTE
+#define CSA_ENG GR2A(KC_G) // ŋ
+#define CSA_H_SRTOKE GR2A(KC_H) // ħ
+#define CSA_HSTK CSA_H_SRTOKE
+#define CSA_IJ_LIGATURE GR2A(KC_J) // ij
+#define CSA_IJ CSA_IJ_LIGATURE
+#define CSA_KRA GR2A(KC_K) // ĸ
+#define CSA_L_FLOWN_DOT GR2A(KC_L) // ŀ
+#define CSA_LFLD CSA_L_FLOWN_DOT
+#define CSA_DEAD_ACUTE GR2A(KC_SCLN) // dead acute accent
+#define CSA_DACT CSA_DEAD_ACUTE
// nothing on È & À
// Fourth row
-#define CSA_CENT GR2A(KC_C) // ¢
-#define CSA_LEFT_DOUBLE_QUOTE GR2A(KC_V) // “
-#define CSA_LDQT CSA_LEFT_DOUBLE_QUOTE
-#define CSA_RIGHT_DOUBLE_QUOTE GR2A(KC_B) // ”
-#define CSA_RDQT CSA_RIGHT_DOUBLE_QUOTE
-#define CSA_N_APOSTROPHE GR2A(KC_N) // ʼn (deprecated unicode codepoint)
-#define CSA_NAPO CSA_N_APOSTROPHE
-#define CSA_MU GR2A(KC_M) // μ
-#define CSA_HORIZONTAL_BAR GR2A(KC_COMMA) // ―
-#define CSA_HZBR CSA_HORIZONTAL_BAR
-#define CSA_DEAD_DOT_ABOVE GR2A(KC_DOT) // dead ˙
-#define CSA_DDTA CSA_DEAD_DOT_ABOVE
+#define CSA_CENT GR2A(KC_C) // ¢
+#define CSA_LEFT_DOUBLE_QUOTE GR2A(KC_V) // “
+#define CSA_LDQT CSA_LEFT_DOUBLE_QUOTE
+#define CSA_RIGHT_DOUBLE_QUOTE GR2A(KC_B) // ”
+#define CSA_RDQT CSA_RIGHT_DOUBLE_QUOTE
+#define CSA_N_APOSTROPHE GR2A(KC_N) // ʼn (deprecated unicode codepoint)
+#define CSA_NAPO CSA_N_APOSTROPHE
+#define CSA_MU GR2A(KC_M) // μ
+#define CSA_HORIZONTAL_BAR GR2A(KC_COMMA) // ―
+#define CSA_HZBR CSA_HORIZONTAL_BAR
+#define CSA_DEAD_DOT_ABOVE GR2A(KC_DOT) // dead ˙
+#define CSA_DDTA CSA_DEAD_DOT_ABOVE
// GR2A-shifted characters (different from capitalised GR2A-ed characters)
// First row
-#define CSA_SOFT_HYPHEN GR2A(LSFT(CSA_SLASH)) // soft-hyphen, appears as a hyphen in wrapped word
-#define CSA_SHYP CSA_SOFT_HYPHEN
-#define CSA_INVERTED_EXCLAIM GR2A(KC_EXCLAIM) // ¡
-#define CSA_IXLM CSA_INVERTED_EXCLAIM
+#define CSA_SOFT_HYPHEN GR2A(LSFT(CSA_SLASH)) // soft-hyphen, appears as a hyphen in wrapped word
+#define CSA_SHYP CSA_SOFT_HYPHEN
+#define CSA_INVERTED_EXCLAIM GR2A(KC_EXCLAIM) // ¡
+#define CSA_IXLM CSA_INVERTED_EXCLAIM
// nothing on 2
-#define CSA_POUND GR2A(LSFT(KC_3)) // £
-#define CSA_GBP CSA_POUND_SIGN
+#define CSA_POUND GR2A(LSFT(KC_3)) // £
+#define CSA_GBP CSA_POUND_SIGN
// already on ALGR(KC_E)
-#define CSA_EURO_BIS GR2A(LSFT(KC_4)) // €
-#define CSA_EURB CSA_EURO_BIS
-#define CSA_THREE_EIGHTHS GR2A(LSFT(KC_5)) // ⅜
-#define CSA_3ON8 CSA_THREE_EIGHTHS
-#define CSA_FIVE_EIGHTHS GR2A(LSFT(KC_6)) // ⅝
-#define CSA_5ON8 CSA_FIVE_EIGHTHS
-#define CSA_SEVEN_EIGHTHS GR2A(LSFT(KC_7)) // ⅞
-#define CSA_7ON8 CSA_SEVEN_EIGHTHS
-#define CSA_TRADEMARK GR2A(LSFT(KC_8)) // ™
-#define CSA_TM CSA_TRADEMARK
-#define CSA_PLUS_MINUS GR2A(LSFT(KC_9)) // ±
-#define CSA_PSMS CSA_PLUS_MINUS
+#define CSA_EURO_BIS GR2A(LSFT(KC_4)) // €
+#define CSA_EURB CSA_EURO_BIS
+#define CSA_THREE_EIGHTHS GR2A(LSFT(KC_5)) // ⅜
+#define CSA_3ON8 CSA_THREE_EIGHTHS
+#define CSA_FIVE_EIGHTHS GR2A(LSFT(KC_6)) // ⅝
+#define CSA_5ON8 CSA_FIVE_EIGHTHS
+#define CSA_SEVEN_EIGHTHS GR2A(LSFT(KC_7)) // ⅞
+#define CSA_7ON8 CSA_SEVEN_EIGHTHS
+#define CSA_TRADEMARK GR2A(LSFT(KC_8)) // ™
+#define CSA_TM CSA_TRADEMARK
+#define CSA_PLUS_MINUS GR2A(LSFT(KC_9)) // ±
+#define CSA_PSMS CSA_PLUS_MINUS
// nothing on 0
-#define CSA_INVERTED_QUESTION GR2A(LSFT(KC_MINUS)) // ¿
-#define CSA_IQST CSA_INVERTED_QUESTION
-#define CSA_DEAD_OGONEK GR2A(LSFT(KC_EQUAL)) // dead ˛
-#define CSA_DOGO CSA_DEAD_OGONEK
+#define CSA_INVERTED_QUESTION GR2A(LSFT(KC_MINUS)) // ¿
+#define CSA_IQST CSA_INVERTED_QUESTION
+#define CSA_DEAD_OGONEK GR2A(LSFT(KC_EQUAL)) // dead ˛
+#define CSA_DOGO CSA_DEAD_OGONEK
// Second row
-#define CSA_REGISTERED_TRADEMARK GR2A(LSFT(KC_R)) // ®
-#define CSA_RTM CSA_REGISTERED_TRADEMARK
-#define CSA_YEN GR2A(LSFT(KC_Y)) // ¥
-#define CSA_YUAN CSA_YEN
-#define CSA_UP_ARROW LSFT(CSA_DOWN_ARROW) // ↑
-#define CSA_DOTLESS_I GR2A(LSFT(KC_I)) // ı
-#define CSA_DLSI CSA_DOTLESS_I
-#define CSA_DEAD_RING GR2A(LSFT(CSA_DCRC)) // dead °
-#define CSA_DRNG CSA_DEAD_RING
-#define CSA_DEAD_MACRON GR2A(LSFT(CSA_C_CEDILLA)) // dead ¯
-#define CSA_DMCR CSA_DEAD_MACRON
+#define CSA_REGISTERED_TRADEMARK GR2A(LSFT(KC_R)) // ®
+#define CSA_RTM CSA_REGISTERED_TRADEMARK
+#define CSA_YEN GR2A(LSFT(KC_Y)) // ¥
+#define CSA_YUAN CSA_YEN
+#define CSA_UP_ARROW LSFT(CSA_DOWN_ARROW) // ↑
+#define CSA_DOTLESS_I GR2A(LSFT(KC_I)) // ı
+#define CSA_DLSI CSA_DOTLESS_I
+#define CSA_DEAD_RING GR2A(LSFT(CSA_DCRC)) // dead °
+#define CSA_DRNG CSA_DEAD_RING
+#define CSA_DEAD_MACRON GR2A(LSFT(CSA_C_CEDILLA)) // dead ¯
+#define CSA_DMCR CSA_DEAD_MACRON
// Third row
-#define CSA_SECTION GR2A(LSFT(KC_S)) // §
-#define CSA_SECT CSA_SECTION
-#define CSA_ORDINAL_INDICATOR_A GR2A(LSFT(KC_F)) // ª
-#define CSA_ORDA CSA_ORDINAL_INDICATOR_A
-#define CSA_DEAD_DOUBLE_ACUTE LSFT(CSA_DEAD_ACUTE) // ˝
-#define CSA_DDCT CSA_DEAD_DOUBLE_ACUTE
-#define CSA_DEAD_CARON GR2A(LSFT(CSA_E_GRAVE)) // dead ˇ
-#define CSA_DCAR CSA_DEAD_CARON
-#define CSA_DEAD_BREVE GR2A(LSFT(CSA_A_GRAVE)) // dead ˘
-#define CSA_DBRV CSA_DEAD_BREVE
+#define CSA_SECTION GR2A(LSFT(KC_S)) // §
+#define CSA_SECT CSA_SECTION
+#define CSA_ORDINAL_INDICATOR_A GR2A(LSFT(KC_F)) // ª
+#define CSA_ORDA CSA_ORDINAL_INDICATOR_A
+#define CSA_DEAD_DOUBLE_ACUTE LSFT(CSA_DEAD_ACUTE) // ˝
+#define CSA_DDCT CSA_DEAD_DOUBLE_ACUTE
+#define CSA_DEAD_CARON GR2A(LSFT(CSA_E_GRAVE)) // dead ˇ
+#define CSA_DCAR CSA_DEAD_CARON
+#define CSA_DEAD_BREVE GR2A(LSFT(CSA_A_GRAVE)) // dead ˘
+#define CSA_DBRV CSA_DEAD_BREVE
// Fourth row
-#define CSA_BROKEN_PIPE GR2A(LSFT(CSA_U_GRAVE)) // ¦
-#define CSA_BPIP CSA_BROKEN_PIPE
-#define CSA_COPYRIGHT GR2A(LSFT(KC_C)) // ©
-#define CSA_CPRT CSA_COPYRIGHT
-#define CSA_LEFT_QUOTE GR2A(LSFT(KC_V)) // ‘
-#define CSA_LQOT CSA_LEFT_QUOTE
-#define CSA_RIGHT_QUOTE GR2A(LSFT(KC_B)) // ’
-#define CSA_RQOT CSA_RIGHT_QUOTE
-#define CSA_EIGHTH_NOTE GR2A(LSFT(KC_N)) // ♪
-#define CSA_8NOT CSA_EIGHTH_NOTE
-#define CSA_ORDINAL_INDICATOR_O GR2A(LSFT(KC_M)) // º
-#define CSA_ORDO CSA_ORDINAL_INDICATOR_O
-#define CSA_TIMES GR2A(LSFT(KC_COMMA)) // ×
-#define CSA_TIMS CSA_TIMES
-#define CSA_OBELUS GR2A(LSFT(KC_DOT)) // ÷
-#define CSA_OBEL CSA_OBELUS
+#define CSA_BROKEN_PIPE GR2A(LSFT(CSA_U_GRAVE)) // ¦
+#define CSA_BPIP CSA_BROKEN_PIPE
+#define CSA_COPYRIGHT GR2A(LSFT(KC_C)) // ©
+#define CSA_CPRT CSA_COPYRIGHT
+#define CSA_LEFT_QUOTE GR2A(LSFT(KC_V)) // ‘
+#define CSA_LQOT CSA_LEFT_QUOTE
+#define CSA_RIGHT_QUOTE GR2A(LSFT(KC_B)) // ’
+#define CSA_RQOT CSA_RIGHT_QUOTE
+#define CSA_EIGHTH_NOTE GR2A(LSFT(KC_N)) // ♪
+#define CSA_8NOT CSA_EIGHTH_NOTE
+#define CSA_ORDINAL_INDICATOR_O GR2A(LSFT(KC_M)) // º
+#define CSA_ORDO CSA_ORDINAL_INDICATOR_O
+#define CSA_TIMES GR2A(LSFT(KC_COMMA)) // ×
+#define CSA_TIMS CSA_TIMES
+#define CSA_OBELUS GR2A(LSFT(KC_DOT)) // ÷
+#define CSA_OBEL CSA_OBELUS
// more conventional name of the symbol
-#define CSA_DIVISION_SIGN CSA_OBELUS
-#define CSA_DVSN CSA_DIVISION_SIGN
+#define CSA_DIVISION_SIGN CSA_OBELUS
+#define CSA_DVSN CSA_DIVISION_SIGN
// TODO GR2A(LSFT(CSA_E_ACUTE))
#endif
diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h
index 2d3f9c06a5..166deeea42 100644
--- a/quantum/keymap_extras/keymap_colemak.h
+++ b/quantum/keymap_extras/keymap_colemak.h
@@ -18,73 +18,73 @@
#include "keymap.h"
// For software implementation of colemak
-#define CM_Q KC_Q
-#define CM_W KC_W
-#define CM_F KC_E
-#define CM_P KC_R
-#define CM_G KC_T
-#define CM_J KC_Y
-#define CM_L KC_U
-#define CM_U KC_I
-#define CM_Y KC_O
+#define CM_Q KC_Q
+#define CM_W KC_W
+#define CM_F KC_E
+#define CM_P KC_R
+#define CM_G KC_T
+#define CM_J KC_Y
+#define CM_L KC_U
+#define CM_U KC_I
+#define CM_Y KC_O
#define CM_SCLN KC_P
-#define CM_A KC_A
-#define CM_R KC_S
-#define CM_S KC_D
-#define CM_T KC_F
-#define CM_D KC_G
-#define CM_H KC_H
-#define CM_N KC_J
-#define CM_E KC_K
-#define CM_I KC_L
-#define CM_O KC_SCLN
+#define CM_A KC_A
+#define CM_R KC_S
+#define CM_S KC_D
+#define CM_T KC_F
+#define CM_D KC_G
+#define CM_H KC_H
+#define CM_N KC_J
+#define CM_E KC_K
+#define CM_I KC_L
+#define CM_O KC_SCLN
#define CM_COLN LSFT(CM_SCLN)
-#define CM_Z KC_Z
-#define CM_X KC_X
-#define CM_C KC_C
-#define CM_V KC_V
-#define CM_B KC_B
-#define CM_K KC_N
-#define CM_M KC_M
+#define CM_Z KC_Z
+#define CM_X KC_X
+#define CM_C KC_C
+#define CM_V KC_V
+#define CM_B KC_B
+#define CM_K KC_N
+#define CM_M KC_M
#define CM_COMM KC_COMM
-#define CM_DOT KC_DOT
+#define CM_DOT KC_DOT
#define CM_SLSH KC_SLSH
// Make it easy to support these in macros
// TODO: change macro implementation so these aren't needed
-#define KC_CM_Q CM_Q
-#define KC_CM_W CM_W
-#define KC_CM_F CM_F
-#define KC_CM_P CM_P
-#define KC_CM_G CM_G
-#define KC_CM_J CM_J
-#define KC_CM_L CM_L
-#define KC_CM_U CM_U
-#define KC_CM_Y CM_Y
+#define KC_CM_Q CM_Q
+#define KC_CM_W CM_W
+#define KC_CM_F CM_F
+#define KC_CM_P CM_P
+#define KC_CM_G CM_G
+#define KC_CM_J CM_J
+#define KC_CM_L CM_L
+#define KC_CM_U CM_U
+#define KC_CM_Y CM_Y
#define KC_CM_SCLN CM_SCLN
-#define KC_CM_A CM_A
-#define KC_CM_R CM_R
-#define KC_CM_S CM_S
-#define KC_CM_T CM_T
-#define KC_CM_D CM_D
-#define KC_CM_H CM_H
-#define KC_CM_N CM_N
-#define KC_CM_E CM_E
-#define KC_CM_I CM_I
-#define KC_CM_O CM_O
+#define KC_CM_A CM_A
+#define KC_CM_R CM_R
+#define KC_CM_S CM_S
+#define KC_CM_T CM_T
+#define KC_CM_D CM_D
+#define KC_CM_H CM_H
+#define KC_CM_N CM_N
+#define KC_CM_E CM_E
+#define KC_CM_I CM_I
+#define KC_CM_O CM_O
-#define KC_CM_Z CM_Z
-#define KC_CM_X CM_X
-#define KC_CM_C CM_C
-#define KC_CM_V CM_V
-#define KC_CM_B CM_B
-#define KC_CM_K CM_K
-#define KC_CM_M CM_M
+#define KC_CM_Z CM_Z
+#define KC_CM_X CM_X
+#define KC_CM_C CM_C
+#define KC_CM_V CM_V
+#define KC_CM_B CM_B
+#define KC_CM_K CM_K
+#define KC_CM_M CM_M
#define KC_CM_COMM CM_COMM
-#define KC_CM_DOT CM_DOT
+#define KC_CM_DOT CM_DOT
#define KC_CM_SLSH CM_SLSH
#endif
diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h
index b1d5604baf..11f13d6dcd 100644
--- a/quantum/keymap_extras/keymap_dvorak.h
+++ b/quantum/keymap_extras/keymap_dvorak.h
@@ -19,82 +19,82 @@
#include "keymap.h"
// Normal characters
-#define DV_GRV KC_GRV
-#define DV_1 KC_1
-#define DV_2 KC_2
-#define DV_3 KC_3
-#define DV_4 KC_4
-#define DV_5 KC_5
-#define DV_6 KC_6
-#define DV_7 KC_7
-#define DV_8 KC_8
-#define DV_9 KC_9
-#define DV_0 KC_0
-#define DV_LBRC KC_MINS
-#define DV_RBRC KC_EQL
+#define DV_GRV KC_GRV
+#define DV_1 KC_1
+#define DV_2 KC_2
+#define DV_3 KC_3
+#define DV_4 KC_4
+#define DV_5 KC_5
+#define DV_6 KC_6
+#define DV_7 KC_7
+#define DV_8 KC_8
+#define DV_9 KC_9
+#define DV_0 KC_0
+#define DV_LBRC KC_MINS
+#define DV_RBRC KC_EQL
-#define DV_QUOT KC_Q
-#define DV_COMM KC_W
-#define DV_DOT KC_E
-#define DV_P KC_R
-#define DV_Y KC_T
-#define DV_F KC_Y
-#define DV_G KC_U
-#define DV_C KC_I
-#define DV_R KC_O
-#define DV_L KC_P
-#define DV_SLSH KC_LBRC
-#define DV_EQL KC_RBRC
-#define DV_BSLS KC_BSLS
+#define DV_QUOT KC_Q
+#define DV_COMM KC_W
+#define DV_DOT KC_E
+#define DV_P KC_R
+#define DV_Y KC_T
+#define DV_F KC_Y
+#define DV_G KC_U
+#define DV_C KC_I
+#define DV_R KC_O
+#define DV_L KC_P
+#define DV_SLSH KC_LBRC
+#define DV_EQL KC_RBRC
+#define DV_BSLS KC_BSLS
-#define DV_A KC_A
-#define DV_O KC_S
-#define DV_E KC_D
-#define DV_U KC_F
-#define DV_I KC_G
-#define DV_D KC_H
-#define DV_H KC_J
-#define DV_T KC_K
-#define DV_N KC_L
-#define DV_S KC_SCLN
-#define DV_MINS KC_QUOT
+#define DV_A KC_A
+#define DV_O KC_S
+#define DV_E KC_D
+#define DV_U KC_F
+#define DV_I KC_G
+#define DV_D KC_H
+#define DV_H KC_J
+#define DV_T KC_K
+#define DV_N KC_L
+#define DV_S KC_SCLN
+#define DV_MINS KC_QUOT
-#define DV_SCLN KC_Z
-#define DV_Q KC_X
-#define DV_J KC_C
-#define DV_K KC_V
-#define DV_X KC_B
-#define DV_B KC_N
-#define DV_M KC_M
-#define DV_W KC_COMM
-#define DV_V KC_DOT
-#define DV_Z KC_SLSH
+#define DV_SCLN KC_Z
+#define DV_Q KC_X
+#define DV_J KC_C
+#define DV_K KC_V
+#define DV_X KC_B
+#define DV_B KC_N
+#define DV_M KC_M
+#define DV_W KC_COMM
+#define DV_V KC_DOT
+#define DV_Z KC_SLSH
// Shifted characters
-#define DV_TILD LSFT(DV_GRV)
-#define DV_EXLM LSFT(DV_1)
-#define DV_AT LSFT(DV_2)
-#define DV_HASH LSFT(DV_3)
-#define DV_DLR LSFT(DV_4)
-#define DV_PERC LSFT(DV_5)
-#define DV_CIRC LSFT(DV_6)
-#define DV_AMPR LSFT(DV_7)
-#define DV_ASTR LSFT(DV_8)
-#define DV_LPRN LSFT(DV_9)
-#define DV_RPRN LSFT(DV_0)
-#define DV_LCBR LSFT(DV_LBRC)
-#define DV_RCBR LSFT(DV_RBRC)
+#define DV_TILD LSFT(DV_GRV)
+#define DV_EXLM LSFT(DV_1)
+#define DV_AT LSFT(DV_2)
+#define DV_HASH LSFT(DV_3)
+#define DV_DLR LSFT(DV_4)
+#define DV_PERC LSFT(DV_5)
+#define DV_CIRC LSFT(DV_6)
+#define DV_AMPR LSFT(DV_7)
+#define DV_ASTR LSFT(DV_8)
+#define DV_LPRN LSFT(DV_9)
+#define DV_RPRN LSFT(DV_0)
+#define DV_LCBR LSFT(DV_LBRC)
+#define DV_RCBR LSFT(DV_RBRC)
-#define DV_DQUO LSFT(DV_QUOT)
-#define DV_LABK LSFT(DV_COMM)
-#define DV_RABK LSFT(DV_DOT)
+#define DV_DQUO LSFT(DV_QUOT)
+#define DV_LABK LSFT(DV_COMM)
+#define DV_RABK LSFT(DV_DOT)
-#define DV_QUES LSFT(DV_SLSH)
-#define DV_PLUS LSFT(DV_EQL)
-#define DV_PIPE LSFT(DV_BSLS)
+#define DV_QUES LSFT(DV_SLSH)
+#define DV_PLUS LSFT(DV_EQL)
+#define DV_PIPE LSFT(DV_BSLS)
-#define DV_UNDS LSFT(DV_MINS)
+#define DV_UNDS LSFT(DV_MINS)
-#define DV_COLN LSFT(DV_SCLN)
+#define DV_COLN LSFT(DV_SCLN)
#endif
diff --git a/quantum/keymap_extras/keymap_dvp.h b/quantum/keymap_extras/keymap_dvp.h
index 50e2d1f461..4b60a67d4d 100644
--- a/quantum/keymap_extras/keymap_dvp.h
+++ b/quantum/keymap_extras/keymap_dvp.h
@@ -20,79 +20,79 @@
#include "keymap.h"
// Normal characters
-#define DP_DLR KC_GRV
-#define DP_AMPR KC_1
-#define DP_LBRC KC_2
-#define DP_LCBR KC_3
-#define DP_RCBR KC_4
-#define DP_LPRN KC_5
-#define DP_EQL KC_6
-#define DP_ASTR KC_7
-#define DP_RPRN KC_8
-#define DP_PLUS KC_9
-#define DP_RBRC KC_0
-#define DP_EXLM KC_MINS
-#define DP_HASH KC_EQL
+#define DP_DLR KC_GRV
+#define DP_AMPR KC_1
+#define DP_LBRC KC_2
+#define DP_LCBR KC_3
+#define DP_RCBR KC_4
+#define DP_LPRN KC_5
+#define DP_EQL KC_6
+#define DP_ASTR KC_7
+#define DP_RPRN KC_8
+#define DP_PLUS KC_9
+#define DP_RBRC KC_0
+#define DP_EXLM KC_MINS
+#define DP_HASH KC_EQL
-#define DP_SCLN KC_Q
-#define DP_COMM KC_W
-#define DP_DOT KC_E
-#define DP_P KC_R
-#define DP_Y KC_T
-#define DP_F KC_Y
-#define DP_G KC_U
-#define DP_C KC_I
-#define DP_R KC_O
-#define DP_L KC_P
-#define DP_SLSH KC_LBRC
-#define DP_AT KC_RBRC
-#define DP_BSLS KC_BSLS
+#define DP_SCLN KC_Q
+#define DP_COMM KC_W
+#define DP_DOT KC_E
+#define DP_P KC_R
+#define DP_Y KC_T
+#define DP_F KC_Y
+#define DP_G KC_U
+#define DP_C KC_I
+#define DP_R KC_O
+#define DP_L KC_P
+#define DP_SLSH KC_LBRC
+#define DP_AT KC_RBRC
+#define DP_BSLS KC_BSLS
-#define DP_A KC_A
-#define DP_O KC_S
-#define DP_E KC_D
-#define DP_U KC_F
-#define DP_I KC_G
-#define DP_D KC_H
-#define DP_H KC_J
-#define DP_T KC_K
-#define DP_N KC_L
-#define DP_S KC_SCLN
-#define DP_MINS KC_QUOT
+#define DP_A KC_A
+#define DP_O KC_S
+#define DP_E KC_D
+#define DP_U KC_F
+#define DP_I KC_G
+#define DP_D KC_H
+#define DP_H KC_J
+#define DP_T KC_K
+#define DP_N KC_L
+#define DP_S KC_SCLN
+#define DP_MINS KC_QUOT
-#define DP_QUOT KC_Z
-#define DP_Q KC_X
-#define DP_J KC_C
-#define DP_K KC_V
-#define DP_X KC_B
-#define DP_B KC_N
-#define DP_M KC_M
-#define DP_W KC_COMM
-#define DP_V KC_DOT
-#define DP_Z KC_SLSH
+#define DP_QUOT KC_Z
+#define DP_Q KC_X
+#define DP_J KC_C
+#define DP_K KC_V
+#define DP_X KC_B
+#define DP_B KC_N
+#define DP_M KC_M
+#define DP_W KC_COMM
+#define DP_V KC_DOT
+#define DP_Z KC_SLSH
// Shifted characters
-#define DP_TILD LSFT(DP_DLR)
-#define DP_PERC LSFT(DP_AMPR)
-#define DP_7 LSFT(DP_LBRC)
-#define DP_5 LSFT(DP_LCBR)
-#define DP_3 LSFT(DP_RCBR)
-#define DP_1 LSFT(DP_LPRN)
-#define DP_9 LSFT(DP_EQL)
-#define DP_0 LSFT(DP_ASTR)
-#define DP_2 LSFT(DP_RPRN)
-#define DP_4 LSFT(DP_PLUS)
-#define DP_6 LSFT(DP_RBRC)
-#define DP_8 LSFT(DP_EXLM)
-#define DP_GRV LSFT(DP_HASH)
+#define DP_TILD LSFT(DP_DLR)
+#define DP_PERC LSFT(DP_AMPR)
+#define DP_7 LSFT(DP_LBRC)
+#define DP_5 LSFT(DP_LCBR)
+#define DP_3 LSFT(DP_RCBR)
+#define DP_1 LSFT(DP_LPRN)
+#define DP_9 LSFT(DP_EQL)
+#define DP_0 LSFT(DP_ASTR)
+#define DP_2 LSFT(DP_RPRN)
+#define DP_4 LSFT(DP_PLUS)
+#define DP_6 LSFT(DP_RBRC)
+#define DP_8 LSFT(DP_EXLM)
+#define DP_GRV LSFT(DP_HASH)
-#define DP_COLN LSFT(DP_SCLN)
-#define DP_LABK LSFT(DP_COMM)
-#define DP_RABK LSFT(DP_DOT)
-#define DP_QUES LSFT(DP_SLSH)
-#define DP_CIRC LSFT(DP_AT)
-#define DP_PIPE LSFT(DP_BSLS)
-#define DP_UNDS LSFT(DP_MINS)
-#define DP_DQUO LSFT(DP_QUOT)
+#define DP_COLN LSFT(DP_SCLN)
+#define DP_LABK LSFT(DP_COMM)
+#define DP_RABK LSFT(DP_DOT)
+#define DP_QUES LSFT(DP_SLSH)
+#define DP_CIRC LSFT(DP_AT)
+#define DP_PIPE LSFT(DP_BSLS)
+#define DP_UNDS LSFT(DP_MINS)
+#define DP_DQUO LSFT(DP_QUOT)
#endif
diff --git a/quantum/keymap_extras/keymap_fr_ch.h b/quantum/keymap_extras/keymap_fr_ch.h
index 69f9547bb9..8da5ae6aa5 100644
--- a/quantum/keymap_extras/keymap_fr_ch.h
+++ b/quantum/keymap_extras/keymap_fr_ch.h
@@ -66,44 +66,44 @@
#define FR_CH_UE KC_LBRC
#define FR_CH_OE KC_SCLN
-#define FR_CH_CIRC KC_EQL // accent circumflex ^ and grave ` and ~
-#define FR_CH_LESS KC_NUBS // < and > and backslash
-#define FR_CH_MINS KC_SLSH // - and _
-#define FR_CH_DLR KC_BSLS // $, £ and }
-#define FR_CH_PARA KC_GRV // § and ring °
-#define FR_CH_DIAE KC_RBRC // accent ¨
+#define FR_CH_CIRC KC_EQL // accent circumflex ^ and grave ` and ~
+#define FR_CH_LESS KC_NUBS // < and > and backslash
+#define FR_CH_MINS KC_SLSH // - and _
+#define FR_CH_DLR KC_BSLS // $, £ and }
+#define FR_CH_PARA KC_GRV // § and ring °
+#define FR_CH_DIAE KC_RBRC // accent ¨
// shifted characters
-#define FR_CH_RING LSFT(KC_GRV) // °
-#define FR_CH_EXLM LSFT(KC_RBRC) // !
-#define FR_CH_PLUS LSFT(KC_1) // +
-#define FR_CH_DQOT LSFT(KC_2) // "
-#define FR_CH_ASTR LSFT(KC_3) // *
-#define FR_CH_PERC LSFT(KC_5) // %
-#define FR_CH_AMPR LSFT(KC_6) // &
-#define FR_CH_SLSH LSFT(KC_7) // /
-#define FR_CH_LPRN LSFT(KC_8) // (
-#define FR_CH_RPRN LSFT(KC_9) // )
-#define FR_CH_EQL LSFT(KC_0) // =
-#define FR_CH_QST LSFT(FR_CH_QUOT) // ?
-#define FR_CH_MORE LSFT(FR_CH_LESS) // >
-#define FR_CH_COLN LSFT(KC_DOT) // :
-#define FR_CH_SCLN LSFT(KC_COMM) // ;
-#define FR_CH_UNDS LSFT(FR_CH_MINS) // _
-#define FR_CH_CCED LSFT(KC_4) // ç
-#define FR_CH_GRV LSFT(FR_CH_CIRC) // accent grave `
+#define FR_CH_RING LSFT(KC_GRV) // °
+#define FR_CH_EXLM LSFT(KC_RBRC) // !
+#define FR_CH_PLUS LSFT(KC_1) // +
+#define FR_CH_DQOT LSFT(KC_2) // "
+#define FR_CH_ASTR LSFT(KC_3) // *
+#define FR_CH_PERC LSFT(KC_5) // %
+#define FR_CH_AMPR LSFT(KC_6) // &
+#define FR_CH_SLSH LSFT(KC_7) // /
+#define FR_CH_LPRN LSFT(KC_8) // (
+#define FR_CH_RPRN LSFT(KC_9) // )
+#define FR_CH_EQL LSFT(KC_0) // =
+#define FR_CH_QST LSFT(FR_CH_QUOT) // ?
+#define FR_CH_MORE LSFT(FR_CH_LESS) // >
+#define FR_CH_COLN LSFT(KC_DOT) // :
+#define FR_CH_SCLN LSFT(KC_COMM) // ;
+#define FR_CH_UNDS LSFT(FR_CH_MINS) // _
+#define FR_CH_CCED LSFT(KC_4) // ç
+#define FR_CH_GRV LSFT(FR_CH_CIRC) // accent grave `
// Alt Gr-ed characters
-#define FR_CH_LCBR ALGR(KC_QUOT) // {
-#define FR_CH_LBRC ALGR(KC_LBRC) // [
-#define FR_CH_RBRC ALGR(KC_9) // ]
-#define FR_CH_RCBR ALGR(KC_0) // }
-#define FR_CH_BSLS ALGR(FR_CH_LESS) // backslash
-#define FR_CH_AT ALGR(KC_2) // @
-#define FR_CH_EURO ALGR(KC_E) // €
-#define FR_CH_TILD ALGR(FR_CH_CIRC) // ~
-#define FR_CH_PIPE ALGR(KC_1) // |
-#define FR_CH_HASH ALGR(KC_3) // #
-#define FR_CH_ACUT ALGR(FR_CH_QUOT) // accent acute ´
+#define FR_CH_LCBR ALGR(KC_QUOT) // {
+#define FR_CH_LBRC ALGR(KC_LBRC) // [
+#define FR_CH_RBRC ALGR(KC_9) // ]
+#define FR_CH_RCBR ALGR(KC_0) // }
+#define FR_CH_BSLS ALGR(FR_CH_LESS) // backslash
+#define FR_CH_AT ALGR(KC_2) // @
+#define FR_CH_EURO ALGR(KC_E) // €
+#define FR_CH_TILD ALGR(FR_CH_CIRC) // ~
+#define FR_CH_PIPE ALGR(KC_1) // |
+#define FR_CH_HASH ALGR(KC_3) // #
+#define FR_CH_ACUT ALGR(FR_CH_QUOT) // accent acute ´
#endif
diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h
index bef7754707..2d6881e20e 100644
--- a/quantum/keymap_extras/keymap_french.h
+++ b/quantum/keymap_extras/keymap_french.h
@@ -19,76 +19,76 @@
#include "keymap.h"
// Normal characters
-#define FR_SUP2 KC_GRV
-#define FR_AMP KC_1
-#define FR_EACU KC_2
-#define FR_QUOT KC_3
-#define FR_APOS KC_4
-#define FR_LPRN KC_5
-#define FR_MINS KC_6
-#define FR_EGRV KC_7
-#define FR_UNDS KC_8
-#define FR_CCED KC_9
-#define FR_AGRV KC_0
-#define FR_RPRN KC_MINS
-#define FR_EQL KC_EQL
+#define FR_SUP2 KC_GRV
+#define FR_AMP KC_1
+#define FR_EACU KC_2
+#define FR_QUOT KC_3
+#define FR_APOS KC_4
+#define FR_LPRN KC_5
+#define FR_MINS KC_6
+#define FR_EGRV KC_7
+#define FR_UNDS KC_8
+#define FR_CCED KC_9
+#define FR_AGRV KC_0
+#define FR_RPRN KC_MINS
+#define FR_EQL KC_EQL
-#define FR_A KC_Q
-#define FR_Z KC_W
-#define FR_CIRC KC_LBRC
-#define FR_DLR KC_RBRC
+#define FR_A KC_Q
+#define FR_Z KC_W
+#define FR_CIRC KC_LBRC
+#define FR_DLR KC_RBRC
-#define FR_Q KC_A
-#define FR_M KC_SCLN
-#define FR_UGRV KC_QUOT
-#define FR_ASTR KC_NUHS
+#define FR_Q KC_A
+#define FR_M KC_SCLN
+#define FR_UGRV KC_QUOT
+#define FR_ASTR KC_NUHS
-#define FR_LESS KC_NUBS
-#define FR_W KC_Z
-#define FR_COMM KC_M
-#define FR_SCLN KC_COMM
-#define FR_COLN KC_DOT
-#define FR_EXLM KC_SLSH
+#define FR_LESS KC_NUBS
+#define FR_W KC_Z
+#define FR_COMM KC_M
+#define FR_SCLN KC_COMM
+#define FR_COLN KC_DOT
+#define FR_EXLM KC_SLSH
// Shifted characters
-#define FR_1 LSFT(KC_1)
-#define FR_2 LSFT(KC_2)
-#define FR_3 LSFT(KC_3)
-#define FR_4 LSFT(KC_4)
-#define FR_5 LSFT(KC_5)
-#define FR_6 LSFT(KC_6)
-#define FR_7 LSFT(KC_7)
-#define FR_8 LSFT(KC_8)
-#define FR_9 LSFT(KC_9)
-#define FR_0 LSFT(KC_0)
-#define FR_OVRR LSFT(FR_RPRN)
+#define FR_1 LSFT(KC_1)
+#define FR_2 LSFT(KC_2)
+#define FR_3 LSFT(KC_3)
+#define FR_4 LSFT(KC_4)
+#define FR_5 LSFT(KC_5)
+#define FR_6 LSFT(KC_6)
+#define FR_7 LSFT(KC_7)
+#define FR_8 LSFT(KC_8)
+#define FR_9 LSFT(KC_9)
+#define FR_0 LSFT(KC_0)
+#define FR_OVRR LSFT(FR_RPRN)
#define FR_PLUS LSFT(FR_EQL)
-#define FR_UMLT LSFT(FR_CIRC)
-#define FR_PND LSFT(FR_DLR)
-#define FR_PERC LSFT(FR_UGRV)
-#define FR_MU LSFT(FR_ASTR)
+#define FR_UMLT LSFT(FR_CIRC)
+#define FR_PND LSFT(FR_DLR)
+#define FR_PERC LSFT(FR_UGRV)
+#define FR_MU LSFT(FR_ASTR)
-#define FR_GRTR LSFT(FR_LESS)
-#define FR_QUES LSFT(FR_COMM)
-#define FR_DOT LSFT(FR_SCLN)
-#define FR_SLSH LSFT(FR_COLN)
-#define FR_SECT LSFT(FR_EXLM)
+#define FR_GRTR LSFT(FR_LESS)
+#define FR_QUES LSFT(FR_COMM)
+#define FR_DOT LSFT(FR_SCLN)
+#define FR_SLSH LSFT(FR_COLN)
+#define FR_SECT LSFT(FR_EXLM)
// Alt Gr-ed characters
-#define FR_TILD ALGR(KC_2)
-#define FR_HASH ALGR(KC_3)
+#define FR_TILD ALGR(KC_2)
+#define FR_HASH ALGR(KC_3)
#define FR_LCBR ALGR(KC_4)
-#define FR_LBRC ALGR(KC_5)
+#define FR_LBRC ALGR(KC_5)
#define FR_PIPE ALGR(KC_6)
-#define FR_GRV ALGR(KC_7)
-#define FR_BSLS ALGR(KC_8)
-#define FR_CCIRC ALGR(KC_9)
-#define FR_AT ALGR(KC_0)
-#define FR_RBRC ALGR(FR_RPRN)
+#define FR_GRV ALGR(KC_7)
+#define FR_BSLS ALGR(KC_8)
+#define FR_CCIRC ALGR(KC_9)
+#define FR_AT ALGR(KC_0)
+#define FR_RBRC ALGR(FR_RPRN)
#define FR_RCBR ALGR(FR_EQL)
-#define FR_EURO ALGR(KC_E)
-#define FR_BULT ALGR(FR_DLR)
+#define FR_EURO ALGR(KC_E)
+#define FR_BULT ALGR(FR_DLR)
#endif
diff --git a/quantum/keymap_extras/keymap_french_osx.h b/quantum/keymap_extras/keymap_french_osx.h
index ecade3fe98..3a231874a4 100644
--- a/quantum/keymap_extras/keymap_french_osx.h
+++ b/quantum/keymap_extras/keymap_french_osx.h
@@ -19,74 +19,74 @@
#include "keymap.h"
// Normal characters
-#define FR_AT KC_GRV
-#define FR_AMP KC_1
-#define FR_EACU KC_2
-#define FR_QUOT KC_3
-#define FR_APOS KC_4
-#define FR_LPRN KC_5
-#define FR_SECT KC_6
-#define FR_EGRV KC_7
-#define FR_EXLM KC_8
-#define FR_CCED KC_9
-#define FR_AGRV KC_0
-#define FR_RPRN KC_MINS
-#define FR_MINS KC_EQL
+#define FR_AT KC_GRV
+#define FR_AMP KC_1
+#define FR_EACU KC_2
+#define FR_QUOT KC_3
+#define FR_APOS KC_4
+#define FR_LPRN KC_5
+#define FR_SECT KC_6
+#define FR_EGRV KC_7
+#define FR_EXLM KC_8
+#define FR_CCED KC_9
+#define FR_AGRV KC_0
+#define FR_RPRN KC_MINS
+#define FR_MINS KC_EQL
-#define FR_A KC_Q
-#define FR_Z KC_W
-#define FR_CIRC KC_LBRC
-#define FR_DLR KC_RBRC
+#define FR_A KC_Q
+#define FR_Z KC_W
+#define FR_CIRC KC_LBRC
+#define FR_DLR KC_RBRC
-#define FR_Q KC_A
-#define FR_M KC_SCLN
-#define FR_UGRV KC_QUOT
-#define FR_GRV KC_NUHS
+#define FR_Q KC_A
+#define FR_M KC_SCLN
+#define FR_UGRV KC_QUOT
+#define FR_GRV KC_NUHS
-#define FR_LESS KC_NUBS
-#define FR_W KC_Z
-#define FR_COMM KC_M
-#define FR_SCLN KC_COMM
-#define FR_COLN KC_DOT
-#define FR_EQL KC_SLSH
+#define FR_LESS KC_NUBS
+#define FR_W KC_Z
+#define FR_COMM KC_M
+#define FR_SCLN KC_COMM
+#define FR_COLN KC_DOT
+#define FR_EQL KC_SLSH
// Shifted characters
-#define FR_HASH LSFT(KC_GRV)
-#define FR_1 LSFT(KC_1)
-#define FR_2 LSFT(KC_2)
-#define FR_3 LSFT(KC_3)
-#define FR_4 LSFT(KC_4)
-#define FR_5 LSFT(KC_5)
-#define FR_6 LSFT(KC_6)
-#define FR_7 LSFT(KC_7)
-#define FR_8 LSFT(KC_8)
-#define FR_9 LSFT(KC_9)
-#define FR_0 LSFT(KC_0)
-#define FR_UNDS LSFT(FR_MINS)
+#define FR_HASH LSFT(KC_GRV)
+#define FR_1 LSFT(KC_1)
+#define FR_2 LSFT(KC_2)
+#define FR_3 LSFT(KC_3)
+#define FR_4 LSFT(KC_4)
+#define FR_5 LSFT(KC_5)
+#define FR_6 LSFT(KC_6)
+#define FR_7 LSFT(KC_7)
+#define FR_8 LSFT(KC_8)
+#define FR_9 LSFT(KC_9)
+#define FR_0 LSFT(KC_0)
+#define FR_UNDS LSFT(FR_MINS)
-#define FR_UMLT LSFT(FR_CIRC)
-#define FR_ASTR LSFT(FR_DLR)
+#define FR_UMLT LSFT(FR_CIRC)
+#define FR_ASTR LSFT(FR_DLR)
-#define FR_PERC LSFT(FR_UGRV)
-#define FR_PND LSFT(FR_GRV)
+#define FR_PERC LSFT(FR_UGRV)
+#define FR_PND LSFT(FR_GRV)
-#define FR_GRTR LSFT(FR_LESS)
-#define FR_QUES LSFT(FR_COMM)
-#define FR_DOT LSFT(FR_SCLN)
-#define FR_SLSH LSFT(FR_COLN)
-#define FR_PLUS LSFT(FR_EQL)
+#define FR_GRTR LSFT(FR_LESS)
+#define FR_QUES LSFT(FR_COMM)
+#define FR_DOT LSFT(FR_SCLN)
+#define FR_SLSH LSFT(FR_COLN)
+#define FR_PLUS LSFT(FR_EQL)
// Alted characters
-#define FR_LCBR LALT(KC_5)
-#define FR_RCBR LALT(FR_RPRN)
-#define FR_EURO LALT(KC_E)
-#define FR_BULT LALT(FR_DLR)
-#define FR_TILD LALT(KC_N)
+#define FR_LCBR LALT(KC_5)
+#define FR_RCBR LALT(FR_RPRN)
+#define FR_EURO LALT(KC_E)
+#define FR_BULT LALT(FR_DLR)
+#define FR_TILD LALT(KC_N)
// Shift+Alt-ed characters
-#define FR_LBRC LSFT(LALT(KC_5))
-#define FR_RBRC LSFT(LALT(FR_RPRN))
-#define FR_PIPE LSFT(LALT(KC_L))
-#define FR_BSLS LSFT(LALT(FR_COLN))
+#define FR_LBRC LSFT(LALT(KC_5))
+#define FR_RBRC LSFT(LALT(FR_RPRN))
+#define FR_PIPE LSFT(LALT(KC_L))
+#define FR_BSLS LSFT(LALT(FR_COLN))
#endif
diff --git a/quantum/keymap_extras/keymap_german.h b/quantum/keymap_extras/keymap_german.h
index 0ba3570df7..b41b11d6ae 100644
--- a/quantum/keymap_extras/keymap_german.h
+++ b/quantum/keymap_extras/keymap_german.h
@@ -67,45 +67,45 @@
#define DE_UE KC_LBRC
#define DE_OE KC_SCLN
-#define DE_CIRC KC_GRAVE // accent circumflex ^ and ring °
-#define DE_ACUT KC_EQL // accent acute ´ and grave `
-#define DE_PLUS KC_RBRC // + and * and ~
-#define DE_HASH KC_BSLS // # and '
-#define DE_LESS KC_NUBS // < and > and |
-#define DE_MINS KC_SLSH // - and _
+#define DE_CIRC KC_GRAVE // accent circumflex ^ and ring °
+#define DE_ACUT KC_EQL // accent acute ´ and grave `
+#define DE_PLUS KC_RBRC // + and * and ~
+#define DE_HASH KC_BSLS // # and '
+#define DE_LESS KC_NUBS // < and > and |
+#define DE_MINS KC_SLSH // - and _
// shifted characters
-#define DE_RING LSFT(DE_CIRC) // °
-#define DE_EXLM LSFT(KC_1) // !
-#define DE_DQOT LSFT(KC_2) // "
-#define DE_PARA LSFT(KC_3) // §
-#define DE_DLR LSFT(KC_4) // $
-#define DE_PERC LSFT(KC_5) // %
-#define DE_AMPR LSFT(KC_6) // &
-#define DE_SLSH LSFT(KC_7) // /
-#define DE_LPRN LSFT(KC_8) // (
-#define DE_RPRN LSFT(KC_9) // )
-#define DE_EQL LSFT(KC_0) // =
-#define DE_QST LSFT(DE_SS) // ?
-#define DE_GRV LSFT(DE_ACUT) // `
-#define DE_ASTR LSFT(DE_PLUS) // *
-#define DE_QUOT LSFT(DE_HASH) // '
-#define DE_MORE LSFT(DE_LESS) // >
-#define DE_COLN LSFT(KC_DOT) // :
-#define DE_SCLN LSFT(KC_COMM) // ;
-#define DE_UNDS LSFT(DE_MINS) // _
+#define DE_RING LSFT(DE_CIRC) // °
+#define DE_EXLM LSFT(KC_1) // !
+#define DE_DQOT LSFT(KC_2) // "
+#define DE_PARA LSFT(KC_3) // §
+#define DE_DLR LSFT(KC_4) // $
+#define DE_PERC LSFT(KC_5) // %
+#define DE_AMPR LSFT(KC_6) // &
+#define DE_SLSH LSFT(KC_7) // /
+#define DE_LPRN LSFT(KC_8) // (
+#define DE_RPRN LSFT(KC_9) // )
+#define DE_EQL LSFT(KC_0) // =
+#define DE_QST LSFT(DE_SS) // ?
+#define DE_GRV LSFT(DE_ACUT) // `
+#define DE_ASTR LSFT(DE_PLUS) // *
+#define DE_QUOT LSFT(DE_HASH) // '
+#define DE_MORE LSFT(DE_LESS) // >
+#define DE_COLN LSFT(KC_DOT) // :
+#define DE_SCLN LSFT(KC_COMM) // ;
+#define DE_UNDS LSFT(DE_MINS) // _
// Alt Gr-ed characters
-#define DE_SQ2 ALGR(KC_2) // ²
-#define DE_SQ3 ALGR(KC_3) // ³
-#define DE_LCBR ALGR(KC_7) // {
-#define DE_LBRC ALGR(KC_8) // [
-#define DE_RBRC ALGR(KC_9) // ]
-#define DE_RCBR ALGR(KC_0) // }
-#define DE_BSLS ALGR(DE_SS) // backslash
-#define DE_AT ALGR(KC_Q) // @
-#define DE_EURO ALGR(KC_E) // €
-#define DE_TILD ALGR(DE_PLUS) // ~
-#define DE_PIPE ALGR(DE_LESS) // |
+#define DE_SQ2 ALGR(KC_2) // ²
+#define DE_SQ3 ALGR(KC_3) // ³
+#define DE_LCBR ALGR(KC_7) // {
+#define DE_LBRC ALGR(KC_8) // [
+#define DE_RBRC ALGR(KC_9) // ]
+#define DE_RCBR ALGR(KC_0) // }
+#define DE_BSLS ALGR(DE_SS) // backslash
+#define DE_AT ALGR(KC_Q) // @
+#define DE_EURO ALGR(KC_E) // €
+#define DE_TILD ALGR(DE_PLUS) // ~
+#define DE_PIPE ALGR(DE_LESS) // |
#endif
diff --git a/quantum/keymap_extras/keymap_german_ch.h b/quantum/keymap_extras/keymap_german_ch.h
index bd1ef89a19..19b3627587 100644
--- a/quantum/keymap_extras/keymap_german_ch.h
+++ b/quantum/keymap_extras/keymap_german_ch.h
@@ -31,7 +31,7 @@
#define CH_G KC_G
#ifdef CH_H
// The ChibiOS ch.h file defines this...
-#undef CH_H
+# undef CH_H
#endif
#define CH_H KC_H
#define CH_I KC_I
@@ -65,53 +65,53 @@
#define CH_DOT KC_DOT
#define CH_COMM KC_COMM
-#define CH_QUOT KC_MINS // ' ? ´
+#define CH_QUOT KC_MINS // ' ? ´
#define CH_AE KC_QUOT
#define CH_UE KC_LBRC
#define CH_OE KC_SCLN
-#define CH_PARA KC_GRAVE // secction sign § and °
-#define CH_CARR KC_EQL // carret ^ ` ~
-#define CH_DIER KC_RBRC // dieresis ¨ ! ]
-#define CH_DLR KC_BSLS // $ £ }
-#define CH_LESS KC_NUBS // < and > and backslash
-#define CH_MINS KC_SLSH // - and _
+#define CH_PARA KC_GRAVE // secction sign § and °
+#define CH_CARR KC_EQL // carret ^ ` ~
+#define CH_DIER KC_RBRC // dieresis ¨ ! ]
+#define CH_DLR KC_BSLS // $ £ }
+#define CH_LESS KC_NUBS // < and > and backslash
+#define CH_MINS KC_SLSH // - and _
// shifted characters
-#define CH_RING LSFT(CH_PARA) // °
-#define CH_PLUS LSFT(KC_1) // +
-#define CH_DQOT LSFT(KC_2) // "
-#define CH_PAST LSFT(KC_3) // *
-#define CH_CELA LSFT(KC_4) // ç
-#define CH_PERC LSFT(KC_5) // %
-#define CH_AMPR LSFT(KC_6) // &
-#define CH_SLSH LSFT(KC_7) // /
-#define CH_LPRN LSFT(KC_8) // (
-#define CH_RPRN LSFT(KC_9) // )
-#define CH_EQL LSFT(KC_0) // =
-#define CH_QST LSFT(CH_QUOT) // ?
-#define CH_GRV LSFT(CH_CARR) // `
-#define CH_EXLM LSFT(CH_DIER) // !
-#define CH_POND LSFT(CH_DLR) // £
-#define CH_MORE LSFT(CH_LESS) // >
-#define CH_COLN LSFT(KC_DOT) // :
-#define CH_SCLN LSFT(KC_COMM) // ;
-#define CH_UNDS LSFT(CH_MINS) // _
+#define CH_RING LSFT(CH_PARA) // °
+#define CH_PLUS LSFT(KC_1) // +
+#define CH_DQOT LSFT(KC_2) // "
+#define CH_PAST LSFT(KC_3) // *
+#define CH_CELA LSFT(KC_4) // ç
+#define CH_PERC LSFT(KC_5) // %
+#define CH_AMPR LSFT(KC_6) // &
+#define CH_SLSH LSFT(KC_7) // /
+#define CH_LPRN LSFT(KC_8) // (
+#define CH_RPRN LSFT(KC_9) // )
+#define CH_EQL LSFT(KC_0) // =
+#define CH_QST LSFT(CH_QUOT) // ?
+#define CH_GRV LSFT(CH_CARR) // `
+#define CH_EXLM LSFT(CH_DIER) // !
+#define CH_POND LSFT(CH_DLR) // £
+#define CH_MORE LSFT(CH_LESS) // >
+#define CH_COLN LSFT(KC_DOT) // :
+#define CH_SCLN LSFT(KC_COMM) // ;
+#define CH_UNDS LSFT(CH_MINS) // _
// Alt Gr-ed characters
-#define CH_BRBR ALGR(KC_1) // ¦ brocken bar
-#define CH_AT ALGR(KC_2) // @
-#define CH_HASH ALGR(KC_3) // #
-#define CH_NOTL ALGR(KC_6) // ¬ negative logic
-#define CH_PIPE ALGR(KC_7) // |
-#define CH_CENT ALGR(KC_8) // ¢ cent
-#define CH_ACUT ALGR(CH_QUOT) // ´
-#define CH_TILD ALGR(CH_CARR) // ~
-#define CH_EURO ALGR(KC_E) // €
-#define CH_LBRC ALGR(CH_UE) // [
-#define CH_RBRC ALGR(CH_DIER) // ]
-#define CH_LCBR ALGR(CH_AE) // {
-#define CH_RCBR ALGR(CH_DLR) // }
-#define CH_BSLS ALGR(CH_LESS) // backslash
+#define CH_BRBR ALGR(KC_1) // ¦ brocken bar
+#define CH_AT ALGR(KC_2) // @
+#define CH_HASH ALGR(KC_3) // #
+#define CH_NOTL ALGR(KC_6) // ¬ negative logic
+#define CH_PIPE ALGR(KC_7) // |
+#define CH_CENT ALGR(KC_8) // ¢ cent
+#define CH_ACUT ALGR(CH_QUOT) // ´
+#define CH_TILD ALGR(CH_CARR) // ~
+#define CH_EURO ALGR(KC_E) // €
+#define CH_LBRC ALGR(CH_UE) // [
+#define CH_RBRC ALGR(CH_DIER) // ]
+#define CH_LCBR ALGR(CH_AE) // {
+#define CH_RCBR ALGR(CH_DLR) // }
+#define CH_BSLS ALGR(CH_LESS) // backslash
#endif
diff --git a/quantum/keymap_extras/keymap_german_osx.h b/quantum/keymap_extras/keymap_german_osx.h
index 798bb75798..29dee07ee0 100644
--- a/quantum/keymap_extras/keymap_german_osx.h
+++ b/quantum/keymap_extras/keymap_german_osx.h
@@ -68,45 +68,45 @@
#define DE_OSX_UE KC_LBRC
#define DE_OSX_OE KC_SCLN
-#define DE_OSX_CIRC KC_NUBS // accent circumflex ^ and ring °
-#define DE_OSX_ACUT KC_EQL // accent acute ´ and grave `
-#define DE_OSX_PLUS KC_RBRC // + and * and ~
-#define DE_OSX_HASH KC_BSLS // # and '
-#define DE_OSX_LESS KC_GRV // < and > and |
-#define DE_OSX_MINS KC_SLSH // - and _
+#define DE_OSX_CIRC KC_NUBS // accent circumflex ^ and ring °
+#define DE_OSX_ACUT KC_EQL // accent acute ´ and grave `
+#define DE_OSX_PLUS KC_RBRC // + and * and ~
+#define DE_OSX_HASH KC_BSLS // # and '
+#define DE_OSX_LESS KC_GRV // < and > and |
+#define DE_OSX_MINS KC_SLSH // - and _
// shifted characters
-#define DE_OSX_RING LSFT(DE_OSX_CIRC) // °
-#define DE_OSX_EXLM LSFT(KC_1) // !
-#define DE_OSX_DQOT LSFT(KC_2) // "
-#define DE_OSX_PARA LSFT(KC_3) // §
-#define DE_OSX_DLR LSFT(KC_4) // $
-#define DE_OSX_PERC LSFT(KC_5) // %
-#define DE_OSX_AMPR LSFT(KC_6) // &
-#define DE_OSX_SLSH LSFT(KC_7) // /
-#define DE_OSX_LPRN LSFT(KC_8) // (
-#define DE_OSX_RPRN LSFT(KC_9) // )
-#define DE_OSX_EQL LSFT(KC_0) // =
-#define DE_OSX_QST LSFT(DE_OSX_SS) // ?
-#define DE_OSX_GRV LSFT(DE_OSX_ACUT) // `
-#define DE_OSX_ASTR LSFT(DE_OSX_PLUS) // *
-#define DE_OSX_QUOT LSFT(DE_OSX_HASH) // '
-#define DE_OSX_MORE LSFT(DE_OSX_LESS) // >
-#define DE_OSX_COLN LSFT(KC_DOT) // :
-#define DE_OSX_SCLN LSFT(KC_COMM) // ;
-#define DE_OSX_UNDS LSFT(DE_OSX_MINS) // _
+#define DE_OSX_RING LSFT(DE_OSX_CIRC) // °
+#define DE_OSX_EXLM LSFT(KC_1) // !
+#define DE_OSX_DQOT LSFT(KC_2) // "
+#define DE_OSX_PARA LSFT(KC_3) // §
+#define DE_OSX_DLR LSFT(KC_4) // $
+#define DE_OSX_PERC LSFT(KC_5) // %
+#define DE_OSX_AMPR LSFT(KC_6) // &
+#define DE_OSX_SLSH LSFT(KC_7) // /
+#define DE_OSX_LPRN LSFT(KC_8) // (
+#define DE_OSX_RPRN LSFT(KC_9) // )
+#define DE_OSX_EQL LSFT(KC_0) // =
+#define DE_OSX_QST LSFT(DE_OSX_SS) // ?
+#define DE_OSX_GRV LSFT(DE_OSX_ACUT) // `
+#define DE_OSX_ASTR LSFT(DE_OSX_PLUS) // *
+#define DE_OSX_QUOT LSFT(DE_OSX_HASH) // '
+#define DE_OSX_MORE LSFT(DE_OSX_LESS) // >
+#define DE_OSX_COLN LSFT(KC_DOT) // :
+#define DE_OSX_SCLN LSFT(KC_COMM) // ;
+#define DE_OSX_UNDS LSFT(DE_OSX_MINS) // _
// Alt-ed characters
//#define DE_OSX_SQ2 LALT(KC_2) // ²
//#define DE_OSX_SQ3 LALT(KC_3) // ³
-#define DE_OSX_LCBR LALT(KC_8) // {
-#define DE_OSX_LBRC LALT(KC_5) // [
-#define DE_OSX_RBRC LALT(KC_6) // ]
-#define DE_OSX_RCBR LALT(KC_9) // }
-#define DE_OSX_BSLS LALT(LSFT(KC_7)) // backslash
-#define DE_OSX_AT LALT(DE_OSX_L) // @
-#define DE_OSX_EURO LALT(KC_E) // €
-#define DE_OSX_TILD LALT(DE_OSX_N) // ~
-#define DE_OSX_PIPE LALT(DE_OSX_7) // |
+#define DE_OSX_LCBR LALT(KC_8) // {
+#define DE_OSX_LBRC LALT(KC_5) // [
+#define DE_OSX_RBRC LALT(KC_6) // ]
+#define DE_OSX_RCBR LALT(KC_9) // }
+#define DE_OSX_BSLS LALT(LSFT(KC_7)) // backslash
+#define DE_OSX_AT LALT(DE_OSX_L) // @
+#define DE_OSX_EURO LALT(KC_E) // €
+#define DE_OSX_TILD LALT(DE_OSX_N) // ~
+#define DE_OSX_PIPE LALT(DE_OSX_7) // |
#endif
diff --git a/quantum/keymap_extras/keymap_hungarian.h b/quantum/keymap_extras/keymap_hungarian.h
index ff43535f38..e92d1a3b18 100644
--- a/quantum/keymap_extras/keymap_hungarian.h
+++ b/quantum/keymap_extras/keymap_hungarian.h
@@ -73,64 +73,64 @@
#define HU_AA KC_QUOT
#define HU_UEE KC_NUHS
-#define HU_MINS KC_SLSH // -
+#define HU_MINS KC_SLSH // -
#define HU_DOT KC_DOT
#define HU_COMM KC_COMM
// shifted characters
// num row
-#define HU_PARA LSFT(HU_0) // §
-#define HU_QUOT LSFT(HU_1) // '
-#define HU_DQOT LSFT(HU_2) // "
-#define HU_PLUS LSFT(HU_3) // +
-#define HU_EXLM LSFT(HU_4) // !
-#define HU_PERC LSFT(HU_5) // %
-#define HU_SLSH LSFT(HU_6) // /
-#define HU_EQL LSFT(HU_7) // =
-#define HU_LPRN LSFT(HU_8) // (
-#define HU_RPRN LSFT(HU_9) // )
+#define HU_PARA LSFT(HU_0) // §
+#define HU_QUOT LSFT(HU_1) // '
+#define HU_DQOT LSFT(HU_2) // "
+#define HU_PLUS LSFT(HU_3) // +
+#define HU_EXLM LSFT(HU_4) // !
+#define HU_PERC LSFT(HU_5) // %
+#define HU_SLSH LSFT(HU_6) // /
+#define HU_EQL LSFT(HU_7) // =
+#define HU_LPRN LSFT(HU_8) // (
+#define HU_RPRN LSFT(HU_9) // )
// í,y row
-#define HU_II KC_NUBS
-#define HU_QST LSFT(HU_COMM) // ?
-#define HU_COLN LSFT(HU_DOT) // :
-#define HU_UNDS LSFT(HU_MINS) // _
+#define HU_II KC_NUBS
+#define HU_QST LSFT(HU_COMM) // ?
+#define HU_COLN LSFT(HU_DOT) // :
+#define HU_UNDS LSFT(HU_MINS) // _
// Alt Gr'd characters
// num row
-#define HU_TILD ALGR(HU_1) // ~
+#define HU_TILD ALGR(HU_1) // ~
//#define HU_?? ALGR(HU_2) // ˇ (proper name?)
-#define HU_CIRC ALGR(HU_3) // ^
-#define HU_BRV ALGR(HU_4) // ˘
-#define HU_RING ALGR(HU_5) // °
+#define HU_CIRC ALGR(HU_3) // ^
+#define HU_BRV ALGR(HU_4) // ˘
+#define HU_RING ALGR(HU_5) // °
//#define HU_?? ALGR(HU_6) // ˛ (proper name?)
-#define HU_GRV ALGR(HU_7) // `
+#define HU_GRV ALGR(HU_7) // `
//#define HU_?? ALGR(HU_8) // ˙ (proper name?)
-#define HU_ACUT ALGR(HU_9) // ´
+#define HU_ACUT ALGR(HU_9) // ´
// q row
-#define HU_BSLS ALGR(HU_Q) // \ backslash
-#define HU_PIPE ALGR(HU_W) // |
-#define HU_DIV ALGR(HU_OEE) // ÷
-#define HU_CRSS ALGR(HU_UU) // ×
-#define HU_EURO ALGR(HU_U) // €
+#define HU_BSLS ALGR(HU_Q) // \ backslash
+#define HU_PIPE ALGR(HU_W) // |
+#define HU_DIV ALGR(HU_OEE) // ÷
+#define HU_CRSS ALGR(HU_UU) // ×
+#define HU_EURO ALGR(HU_U) // €
// a row
-#define HU_LBRC ALGR(HU_F) // [
-#define HU_RBRC ALGR(HU_G) // ]
-#define HU_DLR ALGR(HU_EE) // $
-#define HU_SS ALGR(HU_AA) // ß
+#define HU_LBRC ALGR(HU_F) // [
+#define HU_RBRC ALGR(HU_G) // ]
+#define HU_DLR ALGR(HU_EE) // $
+#define HU_SS ALGR(HU_AA) // ß
// í,y row
-#define HU_LESS ALGR(KC_NUBS) // <
-#define HU_MORE ALGR(HU_Y) // >
-#define HU_HASH ALGR(HU_X) // #
-#define HU_AMPR ALGR(HU_C) // &
-#define HU_AT ALGR(HU_V) // @
-#define HU_LCBR ALGR(HU_B)// {
-#define HU_RCBR ALGR(HU_N) // }
-#define HU_SCLN ALGR(HU_COMM) // ;
-#define HU_ASTR ALGR(HU_MINS) // *
+#define HU_LESS ALGR(KC_NUBS) // <
+#define HU_MORE ALGR(HU_Y) // >
+#define HU_HASH ALGR(HU_X) // #
+#define HU_AMPR ALGR(HU_C) // &
+#define HU_AT ALGR(HU_V) // @
+#define HU_LCBR ALGR(HU_B) // {
+#define HU_RCBR ALGR(HU_N) // }
+#define HU_SCLN ALGR(HU_COMM) // ;
+#define HU_ASTR ALGR(HU_MINS) // *
#endif
diff --git a/quantum/keymap_extras/keymap_italian.h b/quantum/keymap_extras/keymap_italian.h
index fe0f5eb847..063700aa0b 100644
--- a/quantum/keymap_extras/keymap_italian.h
+++ b/quantum/keymap_extras/keymap_italian.h
@@ -70,46 +70,44 @@
#define IT_APOS KC_MINS // ', ?, ,
-
-
-#define IT_BKSL KC_GRAVE // backslash \, |
-
+#define IT_BKSL KC_GRAVE // backslash \, |
#define IT_ACUT // accent acute ´ and grave `
-#define IT_LESS KC_NUBS // < and > and |
-#define IT_MINS KC_SLSH // - and _
+#define IT_LESS KC_NUBS // < and > and |
+#define IT_MINS KC_SLSH // - and _
// shifted characters
-#define IT_PIPE LSFT(IT_BKSL) // °
-#define IT_EXLM LSFT(KC_1) // !
-#define IT_DQOT LSFT(KC_2) // "
-#define IT_STRL LSFT(KC_3) // £
-#define IT_DLR LSFT(KC_4) // $
-#define IT_PERC LSFT(KC_5) // %
-#define IT_AMPR LSFT(KC_6) // &
-#define IT_SLSH LSFT(KC_7) // /
-#define IT_LPRN LSFT(KC_8) // (
-#define IT_RPRN LSFT(KC_9) // )
-#define IT_EQL LSFT(KC_0) // =
-#define IT_QST LSFT(IT_APOS) // ?
-#define IT_CRC LSFT(IT_IACC) // ^
-#define IT_ASTR LSFT(IT_PLUS) // *
-#define IT_MORE LSFT(IT_LESS) // >
-#define IT_COLN LSFT(IT_DOT) // :
-#define IT_SCLN LSFT(IT_COMM) // ;
-#define IT_UNDS LSFT(IT_MINS) // _
+#define IT_DEGR LSFT(IT_AACC) // °
+#define IT_EXLM LSFT(KC_1) // !
+#define IT_DQOT LSFT(KC_2) // "
+#define IT_STRL LSFT(KC_3) // £
+#define IT_DLR LSFT(KC_4) // $
+#define IT_PERC LSFT(KC_5) // %
+#define IT_AMPR LSFT(KC_6) // &
+#define IT_SLSH LSFT(KC_7) // /
+#define IT_LPRN LSFT(KC_8) // (
+#define IT_RPRN LSFT(KC_9) // )
+#define IT_EQL LSFT(KC_0) // =
+#define IT_QST LSFT(IT_APOS) // ?
+#define IT_CRC LSFT(IT_IACC) // ^
+#define IT_ASTR LSFT(IT_PLUS) // *
+#define IT_MORE LSFT(IT_LESS) // >
+#define IT_COLN LSFT(IT_DOT) // :
+#define IT_SCLN LSFT(IT_COMM) // ;
+#define IT_UNDS LSFT(IT_MINS) // _
// Alt Gr-ed characters
-#define IT_LCBR ALGR(KC_7) // {
-#define IT_LBRC ALGR(IT_EACC) // [
-#define IT_RBRC ALGR(IT_PLUS) // ]
-#define IT_RCBR ALGR(KC_0) // }
-#define IT_AT ALGR(IT_OACC) // @
-#define IT_EURO ALGR(KC_E) // €
-#define IT_PIPE LSFT(IT_BKSL) // |
-#define IT_SHRP ALGR(IT_AACC) // #
-
-#define IT_X_PLUS X_RBRACKET // #
+#define IT_LCBR ALGR(KC_7) // {
+#define IT_LBRC ALGR(IT_EACC) // [
+#define IT_RBRC ALGR(IT_PLUS) // ]
+#define IT_RCBR ALGR(KC_0) // }
+#define IT_AT ALGR(IT_OACC) // @
+#define IT_EURO ALGR(KC_E) // €
+#define IT_PIPE LSFT(IT_BSLS) // |
+#define IT_SHRP ALGR(IT_AACC) // #
+
+// Deprecated
+#define IT_X_PLUS X_RBRACKET // #
#endif
diff --git a/quantum/keymap_extras/keymap_italian_osx_ansi.h b/quantum/keymap_extras/keymap_italian_osx_ansi.h
new file mode 100644
index 0000000000..fa12d05dce
--- /dev/null
+++ b/quantum/keymap_extras/keymap_italian_osx_ansi.h
@@ -0,0 +1,113 @@
+/* Copyright 2015-2016 Matthias Schmidtt
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// This is a clone of quantum/keymap_extra/keymap_italian.h intended to be used with Apple devices
+
+#ifndef KEYMAP_ITALIAN
+#define KEYMAP_ITALIAN
+
+#include "keymap.h"
+
+// normal characters
+#define IT_A KC_A
+#define IT_B KC_B
+#define IT_C KC_C
+#define IT_D KC_D
+#define IT_E KC_E
+#define IT_F KC_F
+#define IT_G KC_G
+#define IT_H KC_H
+#define IT_I KC_I
+#define IT_J KC_J
+#define IT_K KC_K
+#define IT_L KC_L
+#define IT_M KC_M
+#define IT_N KC_N
+#define IT_O KC_O
+#define IT_P KC_P
+#define IT_Q KC_Q
+#define IT_R KC_R
+#define IT_S KC_S
+#define IT_T KC_T
+#define IT_U KC_U
+#define IT_V KC_V
+#define IT_W KC_W
+#define IT_X KC_X
+#define IT_Y KC_Y
+#define IT_Z KC_Z
+
+#define IT_0 KC_0
+#define IT_1 KC_1
+#define IT_2 KC_2
+#define IT_3 KC_3
+#define IT_4 KC_4
+#define IT_5 KC_5
+#define IT_6 KC_6
+#define IT_7 KC_7
+#define IT_8 KC_8
+#define IT_9 KC_9
+
+// punctuation
+#define IT_DOT KC_DOT // . and :
+#define IT_COMM KC_COMM // , and ;
+#define IT_APOS KC_MINS // ' and ?
+#define IT_BSLS KC_NUBS // \ and |
+#define IT_LESS KC_GRV // < and >
+#define IT_MINS KC_SLSH // - and _
+
+// accented vowels (regular, with shift, with option, with option and shift)
+#define IT_EACC KC_LBRC // è, é, [, {
+#define IT_PLUS KC_RBRC // +, *, ], }
+#define IT_OACC KC_SCLN // ò, ç, @, Ç
+#define IT_AACC KC_QUOT // à, °, #, ∞
+#define IT_UACC KC_BSLS // ù, §, ¶, ◊
+#define IT_IACC KC_EQL // ì, ^, ˆ, ±
+
+// shifted characters
+#define IT_EXLM LSFT(KC_1) // !
+#define IT_DQOT LSFT(KC_2) // "
+#define IT_STRL LSFT(KC_3) // £
+#define IT_DLR LSFT(KC_4) // $
+#define IT_PERC LSFT(KC_5) // %
+#define IT_AMPR LSFT(KC_6) // &
+#define IT_SLSH LSFT(KC_7) // /
+#define IT_LPRN LSFT(KC_8) // (
+#define IT_RPRN LSFT(KC_9) // )
+#define IT_EQL LSFT(KC_0) // =
+#define IT_DEGR LSFT(IT_AACC) // °
+#define IT_QST LSFT(IT_APOS) // ?
+#define IT_CRC LSFT(IT_IACC) // ^
+#define IT_ASTR LSFT(IT_PLUS) // *
+#define IT_MORE LSFT(IT_LESS) // >
+#define IT_COLN LSFT(IT_DOT) // :
+#define IT_SCLN LSFT(IT_COMM) // ;
+#define IT_UNDS LSFT(IT_MINS) // _
+#define IT_LCBR LSFT(IT_LBRC) // {
+#define IT_RCBR LSFT(IT_RBRC) // }
+#define IT_PIPE LSFT(IT_BSLS) // |
+
+// Alt -ed characters
+#define IT_LBRC LALT(IT_EACC) // [
+#define IT_RBRC LALT(IT_PLUS) // ]
+#define IT_AT LALT(IT_OACC) // @
+#define IT_EURO LALT(KC_E) // €
+#define IT_SHRP LALT(IT_AACC) // #
+#define IT_ACUT LALT(KC_8) // ´
+#define IT_GRAVE LALT(KC_9) // `
+#define IT_TILDE LALT(KC_5) // ~
+#define IT_PLMN LALT(LSFT(IT_IACC)) // ±
+
+#endif
diff --git a/quantum/keymap_extras/keymap_italian_osx_iso.h b/quantum/keymap_extras/keymap_italian_osx_iso.h
new file mode 100644
index 0000000000..a9b36f16e6
--- /dev/null
+++ b/quantum/keymap_extras/keymap_italian_osx_iso.h
@@ -0,0 +1,113 @@
+/* Copyright 2015-2016 Matthias Schmidtt
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// This is a clone of quantum/keymap_extra/keymap_italian.h intended to be used with Apple devices
+
+#ifndef KEYMAP_ITALIAN
+#define KEYMAP_ITALIAN
+
+#include "keymap.h"
+
+// normal characters
+#define IT_A KC_A
+#define IT_B KC_B
+#define IT_C KC_C
+#define IT_D KC_D
+#define IT_E KC_E
+#define IT_F KC_F
+#define IT_G KC_G
+#define IT_H KC_H
+#define IT_I KC_I
+#define IT_J KC_J
+#define IT_K KC_K
+#define IT_L KC_L
+#define IT_M KC_M
+#define IT_N KC_N
+#define IT_O KC_O
+#define IT_P KC_P
+#define IT_Q KC_Q
+#define IT_R KC_R
+#define IT_S KC_S
+#define IT_T KC_T
+#define IT_U KC_U
+#define IT_V KC_V
+#define IT_W KC_W
+#define IT_X KC_X
+#define IT_Y KC_Y
+#define IT_Z KC_Z
+
+#define IT_0 KC_0
+#define IT_1 KC_1
+#define IT_2 KC_2
+#define IT_3 KC_3
+#define IT_4 KC_4
+#define IT_5 KC_5
+#define IT_6 KC_6
+#define IT_7 KC_7
+#define IT_8 KC_8
+#define IT_9 KC_9
+
+// punctuation
+#define IT_DOT KC_DOT // . and :
+#define IT_COMM KC_COMM // , and ;
+#define IT_APOS KC_MINS // ' and ?
+#define IT_BSLS KC_GRV // \ and |
+#define IT_LESS KC_NUBS // < and >
+#define IT_MINS KC_SLSH // - and _
+
+// accented vowels (regular, with shift, with option, with option and shift)
+#define IT_EACC KC_LBRC // è, é, [, {
+#define IT_PLUS KC_RBRC // +, *, ], }
+#define IT_OACC KC_SCLN // ò, ç, @, Ç
+#define IT_AACC KC_QUOT // à, °, #, ∞
+#define IT_UACC KC_BSLS // ù, §, ¶, ◊
+#define IT_IACC KC_EQL // ì, ^, ˆ, ±
+
+// shifted characters
+#define IT_EXLM LSFT(KC_1) // !
+#define IT_DQOT LSFT(KC_2) // "
+#define IT_STRL LSFT(KC_3) // £
+#define IT_DLR LSFT(KC_4) // $
+#define IT_PERC LSFT(KC_5) // %
+#define IT_AMPR LSFT(KC_6) // &
+#define IT_SLSH LSFT(KC_7) // /
+#define IT_LPRN LSFT(KC_8) // (
+#define IT_RPRN LSFT(KC_9) // )
+#define IT_EQL LSFT(KC_0) // =
+#define IT_DEGR LSFT(IT_AACC) // °
+#define IT_QST LSFT(IT_APOS) // ?
+#define IT_CRC LSFT(IT_IACC) // ^
+#define IT_ASTR LSFT(IT_PLUS) // *
+#define IT_MORE LSFT(IT_LESS) // >
+#define IT_COLN LSFT(IT_DOT) // :
+#define IT_SCLN LSFT(IT_COMM) // ;
+#define IT_UNDS LSFT(IT_MINS) // _
+#define IT_LCBR LSFT(IT_LBRC) // {
+#define IT_RCBR LSFT(IT_RBRC) // }
+#define IT_PIPE LSFT(IT_BSLS) // |
+
+// Alt -ed characters
+#define IT_LBRC LALT(IT_EACC) // [
+#define IT_RBRC LALT(IT_PLUS) // ]
+#define IT_AT LALT(IT_OACC) // @
+#define IT_EURO LALT(KC_E) // €
+#define IT_SHRP LALT(IT_AACC) // #
+#define IT_ACUT LALT(KC_8) // ´
+#define IT_GRAVE LALT(KC_9) // `
+#define IT_TILDE LALT(KC_5) // ~
+#define IT_PLMN LALT(LSFT(IT_IACC)) // ±
+
+#endif
diff --git a/quantum/keymap_extras/keymap_jp.h b/quantum/keymap_extras/keymap_jp.h
index b0235f1120..01586d5674 100644
--- a/quantum/keymap_extras/keymap_jp.h
+++ b/quantum/keymap_extras/keymap_jp.h
@@ -20,61 +20,55 @@
* note: This website is written in Japanese.
*/
-
#ifndef KEYMAP_JP_H
#define KEYMAP_JP_H
-
#include "keymap.h"
+#define JP_ZHTG KC_GRV // hankaku/zenkaku|kanzi
+#define JP_YEN KC_INT3 // yen, |
+#define JP_CIRC KC_EQL // ^, ~
+#define JP_AT KC_LBRC // @, `
+#define JP_LBRC KC_RBRC // [, {
+#define JP_COLN KC_QUOT // :, *
+#define JP_RBRC KC_NUHS // ], }
+#define JP_BSLS KC_INT1 // \, _
+#define JP_MHEN KC_INT5 // muhenkan
+#define JP_HENK KC_INT4 // henkan
+#define JP_KANA KC_INT2 // katakana/hiragana|ro-mazi
-#define JP_ZHTG KC_GRV // hankaku/zenkaku|kanzi
-#define JP_YEN KC_INT3 // yen, |
-#define JP_CIRC KC_EQL // ^, ~
-#define JP_AT KC_LBRC // @, `
-#define JP_LBRC KC_RBRC // [, {
-#define JP_COLN KC_QUOT // :, *
-#define JP_RBRC KC_NUHS // ], }
-#define JP_BSLS KC_INT1 // \, _
-#define JP_MHEN KC_INT5 // muhenkan
-#define JP_HENK KC_INT4 // henkan
-#define JP_KANA KC_INT2 // katakana/hiragana|ro-mazi
-
-#define JP_MKANA KC_LANG1 //kana on MacOSX
-#define JP_MEISU KC_LANG2 //eisu on MacOSX
-
-
-//Aliases for shifted symbols
-#define JP_DQT LSFT(KC_2) // "
-#define JP_AMPR LSFT(KC_6) // &
-#define JP_QUOT LSFT(KC_7) // '
-#define JP_LPRN LSFT(KC_8) // (
-#define JP_RPRN LSFT(KC_9) // )
-#define JP_EQL LSFT(KC_MINS) // =
-#define JP_TILD LSFT(JP_CIRC) // ~
-#define JP_PIPE LSFT(JP_YEN) // |
-#define JP_GRV LSFT(JP_AT) // `
-#define JP_LCBR LSFT(JP_LBRC) // {
-#define JP_PLUS LSFT(KC_SCLN) // +
-#define JP_ASTR LSFT(JP_COLN) // *
-#define JP_RCBR LSFT(JP_RBRC) // }
-#define JP_UNDS LSFT(JP_BSLS) // _
+#define JP_MKANA KC_LANG1 // kana on MacOSX
+#define JP_MEISU KC_LANG2 // eisu on MacOSX
+// Aliases for shifted symbols
+#define JP_DQT LSFT(KC_2) // "
+#define JP_AMPR LSFT(KC_6) // &
+#define JP_QUOT LSFT(KC_7) // '
+#define JP_LPRN LSFT(KC_8) // (
+#define JP_RPRN LSFT(KC_9) // )
+#define JP_EQL LSFT(KC_MINS) // =
+#define JP_TILD LSFT(JP_CIRC) // ~
+#define JP_PIPE LSFT(JP_YEN) // |
+#define JP_GRV LSFT(JP_AT) // `
+#define JP_LCBR LSFT(JP_LBRC) // {
+#define JP_PLUS LSFT(KC_SCLN) // +
+#define JP_ASTR LSFT(JP_COLN) // *
+#define JP_RCBR LSFT(JP_RBRC) // }
+#define JP_UNDS LSFT(JP_BSLS) // _
// These symbols are correspond to US101-layout.
-#define JP_MINS KC_MINS // -
-#define JP_SCLN KC_SCLN // ;
-#define JP_COMM KC_COMM // ,
-#define JP_DOT KC_DOT // .
-#define JP_SLSH KC_SLSH // /
+#define JP_MINS KC_MINS // -
+#define JP_SCLN KC_SCLN // ;
+#define JP_COMM KC_COMM // ,
+#define JP_DOT KC_DOT // .
+#define JP_SLSH KC_SLSH // /
// shifted
-#define JP_EXLM KC_EXLM // !
-#define JP_HASH KC_HASH // #
-#define JP_DLR KC_DLR // $
-#define JP_PERC KC_PERC // %
-#define JP_LT KC_LT // <
-#define JP_GT KC_GT // >
-#define JP_QUES KC_QUES // ?
-
+#define JP_EXLM KC_EXLM // !
+#define JP_HASH KC_HASH // #
+#define JP_DLR KC_DLR // $
+#define JP_PERC KC_PERC // %
+#define JP_LT KC_LT // <
+#define JP_GT KC_GT // >
+#define JP_QUES KC_QUES // ?
#endif
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h
index 551a4212b2..8d2f76f273 100644
--- a/quantum/keymap_extras/keymap_nordic.h
+++ b/quantum/keymap_extras/keymap_nordic.h
@@ -19,52 +19,52 @@
#include "keymap.h"
// Normal characters
-#define NO_HALF KC_GRV
-#define NO_PLUS KC_MINS
-#define NO_ACUT KC_EQL
+#define NO_HALF KC_GRV
+#define NO_PLUS KC_MINS
+#define NO_ACUT KC_EQL
-#define NO_AM KC_LBRC
-#define NO_QUOT KC_RBRC // this is the "umlaut" char on Nordic keyboards, Apple layout
-#define NO_AE KC_SCLN
-#define NO_OSLH KC_QUOT
-#define NO_APOS KC_NUHS
+#define NO_AM KC_LBRC
+#define NO_QUOT KC_RBRC // this is the "umlaut" char on Nordic keyboards, Apple layout
+#define NO_AE KC_SCLN
+#define NO_OSLH KC_QUOT
+#define NO_APOS KC_NUHS
-#define NO_LESS KC_NUBS
+#define NO_LESS KC_NUBS
#define NO_MINS KC_SLSH
// Shifted characters
#define NO_SECT LSFT(NO_HALF)
-#define NO_QUO2 LSFT(KC_2)
+#define NO_QUO2 LSFT(KC_2)
#define NO_BULT LSFT(KC_4)
-#define NO_AMPR LSFT(KC_6)
+#define NO_AMPR LSFT(KC_6)
#define NO_SLSH LSFT(KC_7)
-#define NO_LPRN LSFT(KC_8)
-#define NO_RPRN LSFT(KC_9)
-#define NO_EQL LSFT(KC_0)
-#define NO_QUES LSFT(NO_PLUS)
-#define NO_GRV LSFT(NO_ACUT)
+#define NO_LPRN LSFT(KC_8)
+#define NO_RPRN LSFT(KC_9)
+#define NO_EQL LSFT(KC_0)
+#define NO_QUES LSFT(NO_PLUS)
+#define NO_GRV LSFT(NO_ACUT)
#define NO_CIRC LSFT(NO_QUOT)
-#define NO_GRTR LSFT(NO_LESS)
+#define NO_GRTR LSFT(NO_LESS)
#define NO_SCLN LSFT(KC_COMM)
#define NO_COLN LSFT(KC_DOT)
#define NO_UNDS LSFT(NO_MINS)
// Alt Gr-ed characters
-#define NO_AT ALGR(KC_2)
-#define NO_PND ALGR(KC_3)
-#define NO_DLR ALGR(KC_4)
+#define NO_AT ALGR(KC_2)
+#define NO_PND ALGR(KC_3)
+#define NO_DLR ALGR(KC_4)
#define NO_LCBR ALGR(KC_7)
#define NO_LBRC ALGR(KC_8)
#define NO_RBRC ALGR(KC_9)
-#define NO_RCBR ALGR(KC_0)
+#define NO_RCBR ALGR(KC_0)
#define NO_PIPE ALGR(KC_NUBS)
#define NO_EURO ALGR(KC_E)
#define NO_TILD ALGR(NO_QUOT)
#define NO_BSLS ALGR(KC_MINS)
-#define NO_MU ALGR(KC_M)
+#define NO_MU ALGR(KC_M)
#endif
diff --git a/quantum/keymap_extras/keymap_norman.h b/quantum/keymap_extras/keymap_norman.h
index 995b1b8a02..e0f246f823 100644
--- a/quantum/keymap_extras/keymap_norman.h
+++ b/quantum/keymap_extras/keymap_norman.h
@@ -18,37 +18,36 @@
#include "keymap.h"
// For software implementation of norman
-#define NM_Q KC_Q
-#define NM_W KC_W
-#define NM_D KC_E
-#define NM_F KC_R
-#define NM_K KC_T
-#define NM_J KC_Y
-#define NM_U KC_U
-#define NM_R KC_I
-#define NM_L KC_O
+#define NM_Q KC_Q
+#define NM_W KC_W
+#define NM_D KC_E
+#define NM_F KC_R
+#define NM_K KC_T
+#define NM_J KC_Y
+#define NM_U KC_U
+#define NM_R KC_I
+#define NM_L KC_O
#define NM_SCLN KC_P
#define NM_COLN LSFT(NM_SCLN)
-#define NM_A KC_A
-#define NM_S KC_S
-#define NM_E KC_D
-#define NM_T KC_F
-#define NM_G KC_G
-#define NM_Y KC_H
-#define NM_N KC_J
-#define NM_I KC_K
-#define NM_O KC_L
-#define NM_H KC_SCLN
+#define NM_A KC_A
+#define NM_S KC_S
+#define NM_E KC_D
+#define NM_T KC_F
+#define NM_G KC_G
+#define NM_Y KC_H
+#define NM_N KC_J
+#define NM_I KC_K
+#define NM_O KC_L
+#define NM_H KC_SCLN
-#define NM_Z KC_Z
-#define NM_X KC_X
-#define NM_C KC_C
-#define NM_V KC_V
-#define NM_B KC_B
-#define NM_P KC_N
-#define NM_M KC_M
+#define NM_Z KC_Z
+#define NM_X KC_X
+#define NM_C KC_C
+#define NM_V KC_V
+#define NM_B KC_B
+#define NM_P KC_N
+#define NM_M KC_M
#define NM_COMM KC_COMM
-#define NM_DOT KC_DOT
+#define NM_DOT KC_DOT
#define NM_SLSH KC_SLSH
-
diff --git a/quantum/keymap_extras/keymap_norwegian.h b/quantum/keymap_extras/keymap_norwegian.h
index b7128973aa..eb3b0b040e 100644
--- a/quantum/keymap_extras/keymap_norwegian.h
+++ b/quantum/keymap_extras/keymap_norwegian.h
@@ -22,35 +22,35 @@
// Norwegian redifinitions from the nordic keyset
#undef NO_ACUT
-#define NO_ACUT ALGR(NO_BSLS) // ´
+#define NO_ACUT ALGR(NO_BSLS) // ´
#undef NO_AE
-#define NO_AE KC_QUOT // æ
+#define NO_AE KC_QUOT // æ
#undef NO_BSLS
#define NO_BSLS KC_EQL // '\'
#undef NO_CIRC
#define NO_CIRC LSFT(KC_RBRC) // ^
#undef NO_GRV
-#define NO_GRV LSFT(NO_BSLS) //
+#define NO_GRV LSFT(NO_BSLS) //
#undef NO_OSLH
-#define NO_OSLH KC_SCLN // ø
+#define NO_OSLH KC_SCLN // ø
#undef NO_PIPE
#define NO_PIPE KC_GRV // |
// Additional norwegian keys not defined in the nordic keyset
-#define NO_AA KC_LBRC // å
+#define NO_AA KC_LBRC // å
#define NO_ASTR LSFT(KC_BSLS) // *
// Norwegian unique MAC characters
-#define NO_ACUT_MAC KC_EQL // =
-#define NO_APOS_MAC KC_NUBS // '
-#define NO_AT_MAC KC_BSLS // @
-#define NO_BSLS_MAC ALGR(LSFT(KC_7)) // '\'
-#define NO_DLR_MAC LSFT(KC_4) // $
-#define NO_GRV_MAC ALGR(NO_BSLS) // `
-#define NO_GRTR_MAC LSFT(KC_GRV) // >
+#define NO_ACUT_MAC KC_EQL // =
+#define NO_APOS_MAC KC_NUBS // '
+#define NO_AT_MAC KC_BSLS // @
+#define NO_BSLS_MAC ALGR(LSFT(KC_7)) // '\'
+#define NO_DLR_MAC LSFT(KC_4) // $
+#define NO_GRV_MAC ALGR(NO_BSLS) // `
+#define NO_GRTR_MAC LSFT(KC_GRV) // >
#define NO_LCBR_MAC ALGR(LSFT(KC_8)) // }
-#define NO_LESS_MAC KC_GRV // >
-#define NO_PIPE_MAC ALGR(KC_7) // |
+#define NO_LESS_MAC KC_GRV // >
+#define NO_PIPE_MAC ALGR(KC_7) // |
#define NO_RCBR_MAC ALGR(LSFT(KC_9)) // }
#endif
diff --git a/quantum/keymap_extras/keymap_plover.h b/quantum/keymap_extras/keymap_plover.h
index de6d8c53f3..3bfcb7ad90 100644
--- a/quantum/keymap_extras/keymap_plover.h
+++ b/quantum/keymap_extras/keymap_plover.h
@@ -18,30 +18,30 @@
#include "keymap.h"
-#define PV_NUM KC_1
-#define PV_LS KC_Q
-#define PV_LT KC_W
-#define PV_LP KC_E
-#define PV_LH KC_R
-#define PV_LK KC_S
-#define PV_LW KC_D
-#define PV_LR KC_F
+#define PV_NUM KC_1
+#define PV_LS KC_Q
+#define PV_LT KC_W
+#define PV_LP KC_E
+#define PV_LH KC_R
+#define PV_LK KC_S
+#define PV_LW KC_D
+#define PV_LR KC_F
#define PV_STAR KC_Y
-#define PV_RF KC_U
-#define PV_RP KC_I
-#define PV_RL KC_O
-#define PV_RT KC_P
-#define PV_RD KC_LBRC
-#define PV_RR KC_J
-#define PV_RB KC_K
-#define PV_RG KC_L
-#define PV_RS KC_SCLN
-#define PV_RZ KC_QUOT
+#define PV_RF KC_U
+#define PV_RP KC_I
+#define PV_RL KC_O
+#define PV_RT KC_P
+#define PV_RD KC_LBRC
+#define PV_RR KC_J
+#define PV_RB KC_K
+#define PV_RG KC_L
+#define PV_RS KC_SCLN
+#define PV_RZ KC_QUOT
-#define PV_A KC_C
-#define PV_O KC_V
-#define PV_E KC_N
-#define PV_U KC_M
+#define PV_A KC_C
+#define PV_O KC_V
+#define PV_E KC_N
+#define PV_U KC_M
#endif
diff --git a/quantum/keymap_extras/keymap_plover_dvorak.h b/quantum/keymap_extras/keymap_plover_dvorak.h
index 83bb1e8b87..d40ff5c6bb 100644
--- a/quantum/keymap_extras/keymap_plover_dvorak.h
+++ b/quantum/keymap_extras/keymap_plover_dvorak.h
@@ -18,30 +18,30 @@
#include "keymap_dvorak.h"
-#define PD_NUM DV_1
-#define PD_LS DV_Q
-#define PD_LT DV_W
-#define PD_LP DV_E
-#define PD_LH DV_R
-#define PD_LK DV_S
-#define PD_LW DV_D
-#define PD_LR DV_F
+#define PD_NUM DV_1
+#define PD_LS DV_Q
+#define PD_LT DV_W
+#define PD_LP DV_E
+#define PD_LH DV_R
+#define PD_LK DV_S
+#define PD_LW DV_D
+#define PD_LR DV_F
#define PD_STAR DV_Y
-#define PD_RF DV_U
-#define PD_RP DV_I
-#define PD_RL DV_O
-#define PD_RT DV_P
-#define PD_RD DV_LBRC
-#define PD_RR DV_J
-#define PD_RB DV_K
-#define PD_RG DV_L
-#define PD_RS DV_SCLN
-#define PD_RZ DV_QUOT
+#define PD_RF DV_U
+#define PD_RP DV_I
+#define PD_RL DV_O
+#define PD_RT DV_P
+#define PD_RD DV_LBRC
+#define PD_RR DV_J
+#define PD_RB DV_K
+#define PD_RG DV_L
+#define PD_RS DV_SCLN
+#define PD_RZ DV_QUOT
-#define PD_A DV_C
-#define PD_O DV_V
-#define PD_E DV_N
-#define PD_U DV_M
+#define PD_A DV_C
+#define PD_O DV_V
+#define PD_E DV_N
+#define PD_U DV_M
#endif
diff --git a/quantum/keymap_extras/keymap_slovenian.h b/quantum/keymap_extras/keymap_slovenian.h
index 892283e702..7a8b7bec37 100644
--- a/quantum/keymap_extras/keymap_slovenian.h
+++ b/quantum/keymap_extras/keymap_slovenian.h
@@ -20,11 +20,11 @@
#include "keymap.h"
-//Swapped Z and Y
+// Swapped Z and Y
#define SI_Z KC_Y
#define SI_Y KC_Z
-//Special characters
+// Special characters
#define SI_CV KC_SCLN
#define SI_SV KC_LBRC
#define SI_ZV KC_BSLS
@@ -68,40 +68,40 @@
#define SI_DOT KC_DOT
#define SI_COMM KC_COMM
-#define SI_PLUS KC_EQL // + and * and ~
-#define SI_QOT KC_MINS // Single quote
-#define SI_MINS KC_SLSH // - and _
+#define SI_PLUS KC_EQL // + and * and ~
+#define SI_QOT KC_MINS // Single quote
+#define SI_MINS KC_SLSH // - and _
// shifted characters
-#define SI_EXLM LSFT(KC_1) // !
-#define SI_DQOT LSFT(KC_2) // "
-#define SI_HASH LSFT(KC_3) // #
-#define SI_DLR LSFT(KC_4) // $
-#define SI_PERC LSFT(KC_5) // %
-#define SI_AMPR LSFT(KC_6) // &
-#define SI_SLSH LSFT(KC_7) // /
-#define SI_LPRN LSFT(KC_8) // (
-#define SI_RPRN LSFT(KC_9) // )
-#define SI_EQL LSFT(KC_0) // =
-#define SI_QST LSFT(SI_QOT) // ?
-#define SI_ASTR LSFT(SI_PLUS) // *
-#define SI_COLN LSFT(KC_DOT) // :
-#define SI_SCLN LSFT(KC_COMM) // ;
-#define SI_UNDS LSFT(SI_MINS) // _
+#define SI_EXLM LSFT(KC_1) // !
+#define SI_DQOT LSFT(KC_2) // "
+#define SI_HASH LSFT(KC_3) // #
+#define SI_DLR LSFT(KC_4) // $
+#define SI_PERC LSFT(KC_5) // %
+#define SI_AMPR LSFT(KC_6) // &
+#define SI_SLSH LSFT(KC_7) // /
+#define SI_LPRN LSFT(KC_8) // (
+#define SI_RPRN LSFT(KC_9) // )
+#define SI_EQL LSFT(KC_0) // =
+#define SI_QST LSFT(SI_QOT) // ?
+#define SI_ASTR LSFT(SI_PLUS) // *
+#define SI_COLN LSFT(KC_DOT) // :
+#define SI_SCLN LSFT(KC_COMM) // ;
+#define SI_UNDS LSFT(SI_MINS) // _
// Alt Gr-ed characters
-#define SI_CIRC ALGR(KC_3) // ^
-#define SI_DEG ALGR(KC_5) // °
-#define SI_GRV ALGR(KC_7) // `
-#define SI_ACCU ALGR(KC_9) // ´
-#define SI_LCBR ALGR(KC_B) // {
-#define SI_RCBR ALGR(KC_N) // }
-#define SI_LBRC ALGR(KC_F) // [
-#define SI_RBRC ALGR(KC_G) // ]
-#define SI_BSLS ALGR(KC_Q) // backslash
-#define SI_AT ALGR(KC_V) // @
-#define SI_EURO ALGR(KC_E) // €
-#define SI_TILD ALGR(KC_1) // ~
-#define SI_PIPE ALGR(KC_W) // |
+#define SI_CIRC ALGR(KC_3) // ^
+#define SI_DEG ALGR(KC_5) // °
+#define SI_GRV ALGR(KC_7) // `
+#define SI_ACCU ALGR(KC_9) // ´
+#define SI_LCBR ALGR(KC_B) // {
+#define SI_RCBR ALGR(KC_N) // }
+#define SI_LBRC ALGR(KC_F) // [
+#define SI_RBRC ALGR(KC_G) // ]
+#define SI_BSLS ALGR(KC_Q) // backslash
+#define SI_AT ALGR(KC_V) // @
+#define SI_EURO ALGR(KC_E) // €
+#define SI_TILD ALGR(KC_1) // ~
+#define SI_PIPE ALGR(KC_W) // |
#endif
diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h
index 1f183327f9..19a3c5284b 100644
--- a/quantum/keymap_extras/keymap_spanish.h
+++ b/quantum/keymap_extras/keymap_spanish.h
@@ -20,54 +20,54 @@
// Normal characters
#define ES_OVRR KC_GRV
-#define ES_APOS KC_MINS
-#define ES_IEXL KC_EQL
+#define ES_APOS KC_MINS
+#define ES_IEXL KC_EQL
-#define ES_GRV KC_LBRC
-#define ES_PLUS KC_RBRC
+#define ES_GRV KC_LBRC
+#define ES_PLUS KC_RBRC
-#define ES_NTIL KC_SCLN
-#define ES_ACUT KC_QUOT
-#define ES_CCED KC_NUHS
+#define ES_NTIL KC_SCLN
+#define ES_ACUT KC_QUOT
+#define ES_CCED KC_NUHS
-#define ES_LESS KC_NUBS
-#define ES_MINS KC_SLSH
+#define ES_LESS KC_NUBS
+#define ES_MINS KC_SLSH
// Shifted characters
-#define ES_ASML LSFT(ES_OVRR)
-#define ES_QUOT LSFT(KC_2)
-#define ES_OVDT LSFT(KC_3)
-#define ES_AMPR LSFT(KC_6)
+#define ES_ASML LSFT(ES_OVRR)
+#define ES_QUOT LSFT(KC_2)
+#define ES_OVDT LSFT(KC_3)
+#define ES_AMPR LSFT(KC_6)
#define ES_SLSH LSFT(KC_7)
#define ES_LPRN LSFT(KC_8)
#define ES_RPRN LSFT(KC_9)
-#define ES_EQL LSFT(KC_0)
-#define ES_QUES LSFT(ES_APOS)
-#define ES_IQUE LSFT(ES_IEXL)
+#define ES_EQL LSFT(KC_0)
+#define ES_QUES LSFT(ES_APOS)
+#define ES_IQUE LSFT(ES_IEXL)
-#define ES_CIRC LSFT(ES_GRV)
-#define ES_ASTR LSFT(ES_PLUS)
+#define ES_CIRC LSFT(ES_GRV)
+#define ES_ASTR LSFT(ES_PLUS)
-#define ES_UMLT LSFT(ES_GRV)
+#define ES_UMLT LSFT(ES_GRV)
-#define ES_GRTR LSFT(ES_LESS)
-#define ES_SCLN LSFT(KC_COMM)
-#define ES_COLN LSFT(KC_DOT)
-#define ES_UNDS LSFT(ES_MINS)
+#define ES_GRTR LSFT(ES_LESS)
+#define ES_SCLN LSFT(KC_COMM)
+#define ES_COLN LSFT(KC_DOT)
+#define ES_UNDS LSFT(ES_MINS)
// Alt Gr-ed characters
-#define ES_BSLS ALGR(ES_OVRR)
-#define ES_PIPE ALGR(KC_1)
-#define ES_AT ALGR(KC_2)
-#define ES_HASH ALGR(KC_3)
-#define ES_TILD ALGR(ES_NTIL)
-#define ES_EURO ALGR(KC_5)
-#define ES_NOT ALGR(KC_6)
+#define ES_BSLS ALGR(ES_OVRR)
+#define ES_PIPE ALGR(KC_1)
+#define ES_AT ALGR(KC_2)
+#define ES_HASH ALGR(KC_3)
+#define ES_TILD ALGR(ES_NTIL)
+#define ES_EURO ALGR(KC_5)
+#define ES_NOT ALGR(KC_6)
-#define ES_LBRC ALGR(ES_GRV)
+#define ES_LBRC ALGR(ES_GRV)
#define ES_RBRC ALGR(ES_PLUS)
-#define ES_LCBR ALGR(ES_ACUT)
-#define ES_RCBR ALGR(ES_CCED)
+#define ES_LCBR ALGR(ES_ACUT)
+#define ES_RCBR ALGR(ES_CCED)
#endif
diff --git a/quantum/keymap_extras/keymap_steno.h b/quantum/keymap_extras/keymap_steno.h
index 4ce91cc135..31dcbf7064 100644
--- a/quantum/keymap_extras/keymap_steno.h
+++ b/quantum/keymap_extras/keymap_steno.h
@@ -22,55 +22,55 @@
// errors, this must be <= 42 total entries in order to
// support the GeminiPR protocol.
enum steno_keycodes {
- STN__MIN = QK_STENO,
- STN_FN = STN__MIN,
- STN_NUM,
- STN_N1 = STN_NUM,
- STN_N2,
- STN_N3,
- STN_N4,
- STN_N5,
- STN_N6,
- STN_SL,
- STN_S1 = STN_SL,
- STN_S2,
- STN_TL,
- STN_KL,
- STN_PL,
- STN_WL,
- STN_HL,
- STN_RL,
- STN_A,
- STN_O,
- STN_STR,
- STN_ST1 = STN_STR,
- STN_ST2,
- STN_RES1,
- STN_RE1 = STN_RES1,
- STN_RES2,
- STN_RE2 = STN_RES2,
- STN_PWR,
- STN_ST3,
- STN_ST4,
- STN_E,
- STN_U,
- STN_FR,
- STN_RR,
- STN_PR,
- STN_BR,
- STN_LR,
- STN_GR,
- STN_TR,
- STN_SR,
- STN_DR,
- STN_N7,
- STN_N8,
- STN_N9,
- STN_NA,
- STN_NB,
- STN_NC,
- STN_ZR,
- STN__MAX = STN_ZR, // must be less than QK_STENO_BOLT
+ STN__MIN = QK_STENO,
+ STN_FN = STN__MIN,
+ STN_NUM,
+ STN_N1 = STN_NUM,
+ STN_N2,
+ STN_N3,
+ STN_N4,
+ STN_N5,
+ STN_N6,
+ STN_SL,
+ STN_S1 = STN_SL,
+ STN_S2,
+ STN_TL,
+ STN_KL,
+ STN_PL,
+ STN_WL,
+ STN_HL,
+ STN_RL,
+ STN_A,
+ STN_O,
+ STN_STR,
+ STN_ST1 = STN_STR,
+ STN_ST2,
+ STN_RES1,
+ STN_RE1 = STN_RES1,
+ STN_RES2,
+ STN_RE2 = STN_RES2,
+ STN_PWR,
+ STN_ST3,
+ STN_ST4,
+ STN_E,
+ STN_U,
+ STN_FR,
+ STN_RR,
+ STN_PR,
+ STN_BR,
+ STN_LR,
+ STN_GR,
+ STN_TR,
+ STN_SR,
+ STN_DR,
+ STN_N7,
+ STN_N8,
+ STN_N9,
+ STN_NA,
+ STN_NB,
+ STN_NC,
+ STN_ZR,
+ STN__MAX = STN_ZR, // must be less than QK_STENO_BOLT
};
#endif
diff --git a/quantum/keymap_extras/keymap_swedish.h b/quantum/keymap_extras/keymap_swedish.h
index d1a0f4f227..96fd0c5c65 100644
--- a/quantum/keymap_extras/keymap_swedish.h
+++ b/quantum/keymap_extras/keymap_swedish.h
@@ -17,34 +17,71 @@
#ifndef KEYMAP_SWEDISH_H
#define KEYMAP_SWEDISH_H
-#include "keymap_nordic.h"
+#include "keymap.h"
-// There are slight differrences in the keyboards in the nordic contries
+// Normal characters
+#define SE_HALF KC_GRV
+#define SE_PLUS KC_MINS
+#define SE_ACUT KC_EQL
-// Swedish redifinitions from the nordic keyset
-#undef NO_AE
-#define NO_AE KC_QUOT // ä
-#undef NO_CIRC
-#define NO_CIRC LSFT(KC_RBRC) // ^
-#undef NO_OSLH
-#define NO_OSLH KC_SCLN // ö
+#define SE_AM KC_LBRC
+#define SE_QUOT KC_RBRC // this is the "umlaut" char on Nordic keyboards, Apple layout
+#define SE_AE KC_QUOT // ä
+#define SE_OSLH KC_SCLN // ö
+#define SE_APOS KC_NUHS
-// Additional Swedish keys not defined in the nordic keyset
-#define NO_AA KC_LBRC // å
-#define NO_ASTR LSFT(KC_BSLS) // *
+#define SE_LESS KC_NUBS
+#define SE_MINS KC_SLSH
+
+// Shifted characters
+#define SE_SECT LSFT(SE_HALF)
+#define SE_QUO2 LSFT(KC_2)
+#define SE_BULT LSFT(KC_4)
+#define SE_AMPR LSFT(KC_6)
+#define SE_SLSH LSFT(KC_7)
+#define SE_LPRN LSFT(KC_8)
+#define SE_RPRN LSFT(KC_9)
+#define SE_EQL LSFT(KC_0)
+#define SE_QUES LSFT(SE_PLUS)
+#define SE_GRV LSFT(SE_ACUT)
+
+#define SE_CIRC LSFT(KC_RBRC) // ^
+
+#define SE_GRTR LSFT(SE_LESS)
+#define SE_SCLN LSFT(KC_COMM)
+#define SE_COLN LSFT(KC_DOT)
+#define SE_UNDS LSFT(SE_MINS)
+
+// Alt Gr-ed characters
+#define SE_AT ALGR(KC_2)
+#define SE_PND ALGR(KC_3)
+#define SE_DLR ALGR(KC_4)
+#define SE_LCBR ALGR(KC_7)
+#define SE_LBRC ALGR(KC_8)
+#define SE_RBRC ALGR(KC_9)
+#define SE_RCBR ALGR(KC_0)
+#define SE_PIPE ALGR(KC_NUBS)
+
+#define SE_EURO ALGR(KC_E)
+#define SE_TILD ALGR(SE_QUOT)
+
+#define SE_BSLS ALGR(KC_MINS)
+#define SE_MU ALGR(KC_M)
+
+#define SE_AA KC_LBRC // å
+#define SE_ASTR LSFT(KC_BSLS) // *
// Norwegian unique MAC characters (not vetted for Swedish)
-#define NO_ACUT_MAC KC_EQL // =
-#define NO_APOS_MAC KC_NUBS // '
-#define NO_AT_MAC KC_BSLS // @
-#define NO_BSLS_MAC ALGR(LSFT(KC_7)) // '\'
-#define NO_DLR_MAC LSFT(KC_4) // $
-#define NO_GRV_MAC ALGR(NO_BSLS) // `
-#define NO_GRTR_MAC LSFT(KC_GRV) // >
-#define NO_LCBR_MAC ALGR(LSFT(KC_8)) // {
-#define NO_LESS_MAC KC_GRV // <
-#define NO_PIPE_MAC ALGR(KC_7) // |
-#define NO_RCBR_MAC ALGR(LSFT(KC_9)) // }
+#define SE_ACUT_MAC KC_EQL // =
+#define SE_APOS_MAC KC_NUBS // '
+#define SE_AT_MAC KC_BSLS // @
+#define SE_BSLS_MAC ALGR(LSFT(KC_7)) // '\'
+#define SE_DLR_MAC ALGR(KC_4) // $
+#define SE_GRV_MAC ALGR(SE_BSLS) // `
+#define SE_GRTR_MAC LSFT(KC_GRV) // >
+#define SE_LCBR_MAC ALGR(LSFT(KC_8)) // {
+#define SE_LESS_MAC KC_GRV // <
+#define SE_PIPE_MAC ALGR(KC_7) // |
+#define SE_RCBR_MAC ALGR(LSFT(KC_9)) // }
#endif
-
diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h
index cc3d0039e2..d4329e547d 100644
--- a/quantum/keymap_extras/keymap_uk.h
+++ b/quantum/keymap_extras/keymap_uk.h
@@ -20,21 +20,21 @@
// Normal characters
#define UK_HASH KC_NUHS
-#define UK_BSLS KC_NUBS
+#define UK_BSLS KC_NUBS
// Shifted characters
-#define UK_NOT LSFT(KC_GRV)
-#define UK_DQUO LSFT(KC_2)
-#define UK_PND LSFT(KC_3)
-#define UK_AT LSFT(KC_QUOT)
-#define UK_TILD LSFT(KC_NUHS)
-#define UK_PIPE LSFT(KC_NUBS)
+#define UK_NOT LSFT(KC_GRV)
+#define UK_DQUO LSFT(KC_2)
+#define UK_PND LSFT(KC_3)
+#define UK_AT LSFT(KC_QUOT)
+#define UK_TILD LSFT(KC_NUHS)
+#define UK_PIPE LSFT(KC_NUBS)
// Alt Gr-ed characters
-#define UK_BRKP ALGR(KC_GRV)
-#define UK_EURO ALGR(KC_4)
-#define UK_EACT ALGR(KC_E)
-#define UK_UACT ALGR(KC_U)
+#define UK_BRKP ALGR(KC_GRV)
+#define UK_EURO ALGR(KC_4)
+#define UK_EACT ALGR(KC_E)
+#define UK_UACT ALGR(KC_U)
#define UK_IACT ALGR(KC_I)
#define UK_OACT ALGR(KC_O)
#define UK_AACT ALGR(KC_A)
diff --git a/quantum/keymap_extras/keymap_workman.h b/quantum/keymap_extras/keymap_workman.h
index 97927bf50a..e608164d03 100644
--- a/quantum/keymap_extras/keymap_workman.h
+++ b/quantum/keymap_extras/keymap_workman.h
@@ -18,66 +18,66 @@
#include "keymap.h"
// For software implementation of workman
-#define WK_Q KC_Q
-#define WK_D KC_W
-#define WK_R KC_E
-#define WK_W KC_R
-#define WK_B KC_T
-#define WK_J KC_Y
-#define WK_F KC_U
-#define WK_U KC_I
-#define WK_P KC_O
+#define WK_Q KC_Q
+#define WK_D KC_W
+#define WK_R KC_E
+#define WK_W KC_R
+#define WK_B KC_T
+#define WK_J KC_Y
+#define WK_F KC_U
+#define WK_U KC_I
+#define WK_P KC_O
#define WK_SCLN KC_P
-#define WK_A KC_A
-#define WK_S KC_S
-#define WK_H KC_D
-#define WK_T KC_F
-#define WK_G KC_G
-#define WK_Y KC_H
-#define WK_N KC_J
-#define WK_E KC_K
-#define WK_O KC_L
-#define WK_I KC_SCLN
+#define WK_A KC_A
+#define WK_S KC_S
+#define WK_H KC_D
+#define WK_T KC_F
+#define WK_G KC_G
+#define WK_Y KC_H
+#define WK_N KC_J
+#define WK_E KC_K
+#define WK_O KC_L
+#define WK_I KC_SCLN
-#define WK_Z KC_Z
-#define WK_X KC_X
-#define WK_M KC_C
-#define WK_C KC_V
-#define WK_V KC_B
-#define WK_K KC_N
-#define WK_L KC_M
+#define WK_Z KC_Z
+#define WK_X KC_X
+#define WK_M KC_C
+#define WK_C KC_V
+#define WK_V KC_B
+#define WK_K KC_N
+#define WK_L KC_M
// Make it easy to support these in macros
// TODO: change macro implementation so these aren't needed
-#define KC_WK_Q WK_Q
-#define KC_WK_D WK_D
-#define KC_WK_R WK_R
-#define KC_WK_W WK_W
-#define KC_WK_B WK_B
-#define KC_WK_J WK_J
-#define KC_WK_F WK_F
-#define KC_WK_U WK_U
-#define KC_WK_P WK_P
+#define KC_WK_Q WK_Q
+#define KC_WK_D WK_D
+#define KC_WK_R WK_R
+#define KC_WK_W WK_W
+#define KC_WK_B WK_B
+#define KC_WK_J WK_J
+#define KC_WK_F WK_F
+#define KC_WK_U WK_U
+#define KC_WK_P WK_P
#define KC_WK_SCLN WK_SCLN
-#define KC_WK_A WK_A
-#define KC_WK_S WK_S
-#define KC_WK_H WK_H
-#define KC_WK_T WK_T
-#define KC_WK_G WK_G
-#define KC_WK_Y WK_Y
-#define KC_WK_N WK_N
-#define KC_WK_E WK_E
-#define KC_WK_O WK_O
-#define KC_WK_I WK_I
+#define KC_WK_A WK_A
+#define KC_WK_S WK_S
+#define KC_WK_H WK_H
+#define KC_WK_T WK_T
+#define KC_WK_G WK_G
+#define KC_WK_Y WK_Y
+#define KC_WK_N WK_N
+#define KC_WK_E WK_E
+#define KC_WK_O WK_O
+#define KC_WK_I WK_I
-#define KC_WK_Z WK_Z
-#define KC_WK_X WK_X
-#define KC_WK_M WK_M
-#define KC_WK_C WK_C
-#define KC_WK_V WK_V
-#define KC_WK_K WK_K
-#define KC_WK_L WK_L
+#define KC_WK_Z WK_Z
+#define KC_WK_X WK_X
+#define KC_WK_M WK_M
+#define KC_WK_C WK_C
+#define KC_WK_V WK_V
+#define KC_WK_K WK_K
+#define KC_WK_L WK_L
#endif
diff --git a/quantum/keymap_extras/sendstring_belgian.h b/quantum/keymap_extras/sendstring_belgian.h
index 77531a14ab..ca0edfb683 100644
--- a/quantum/keymap_extras/sendstring_belgian.h
+++ b/quantum/keymap_extras/sendstring_belgian.h
@@ -13,13 +13,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the belgian layout */
-#ifndef SENDSTRING_BELGIAN
-#define SENDSTRING_BELGIAN
+
+// Sendstring lookup tables for Belgian layouts
+
+#pragma once
#include "keymap_belgian.h"
-const bool ascii_to_shift_lut[0x80] PROGMEM = {
+// clang-format off
+
+const bool ascii_to_shift_lut[128] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -38,7 +41,8 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
-const bool ascii_to_altgr_lut[0x80] PROGMEM = {
+
+const bool ascii_to_altgr_lut[128] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -58,37 +62,38 @@ const bool ascii_to_altgr_lut[0x80] PROGMEM = {
0, 0, 0, 1, 1, 1, 1, 0
};
-// NOTE that you have to send the dead keys twice: tilda, circ
-// SEND_STRING(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^^``_abcdefghijklmnopqrstuvwxyz{|}~~");
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- /* SPACE ! " # $ % & ' */
- KC_SPC, BE_EXLM, BE_QUOT, BE_QUOT, BE_DLR,BE_UGRV,BE_AMP, BE_APOS ,
- /* ( ) * + , - . / */
- BE_LPRN, BE_RPRN, BE_DLR,BE_EQL, BE_COMM, BE_MINS, BE_SCLN, BE_COLN,
- /* 0 1 2 3 4 5 6 7 */
- BE_AGRV, BE_AMP, BE_EACU, BE_QUOT, BE_APOS, BE_LPRN, BE_PARA, BE_EGRV,
- /* 8 9 : ; < = > ? */
- BE_EXLM, BE_CCED, BE_COLN, BE_SCLN, BE_LESS, BE_EQL, BE_LESS, BE_COMM,
- /* @ A B C D E F G */
- BE_EACU, BE_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- /* H I J K L M N O */
- KC_H, KC_I, KC_J, KC_K, KC_L, BE_M, KC_N, KC_O,
- /* P Q R S T U V W */
- KC_P, BE_Q, KC_R, KC_S, KC_T, KC_U, KC_V, BE_W,
- /* X Y Z [ \ ] ^ _ */
- KC_X, KC_Y, BE_Z, BE_CIRC, BE_LESS, BE_DLR, BE_PARA, BE_MINS,
- /* ` a b c d e f g */
- BE_MU, BE_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- /* h i j k l m n o */
- KC_H, KC_I, KC_J, KC_K, KC_L, BE_M, KC_N, KC_O,
- /* p q r s t u v w */
- KC_P, BE_Q, KC_R, KC_S, KC_T, KC_U, KC_V, BE_W,
- /* x y z { | } ~ DELETE */
- KC_X, KC_Y, BE_Z, BE_CCED, BE_AMP, BE_AGRV, BE_EQL, KC_DEL
-};
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
-#endif
+ // ! " # $ % & '
+ KC_SPC, BE_EXLM, BE_QUOT, BE_QUOT, BE_DLR, BE_UGRV, BE_AMP, BE_APOS,
+ // ( ) * + , - . /
+ BE_LPRN, BE_RPRN, BE_DLR, BE_EQL, BE_COMM, BE_MINS, BE_SCLN, BE_COLN,
+ // 0 1 2 3 4 5 6 7
+ BE_AGRV, BE_AMP, BE_EACU, BE_QUOT, BE_APOS, BE_LPRN, BE_PARA, BE_EGRV,
+ // 8 9 : ; < = > ?
+ BE_EXLM, BE_CCED, BE_COLN, BE_SCLN, BE_LESS, BE_EQL, BE_LESS, BE_COMM,
+ // @ A B C D E F G
+ BE_EACU, BE_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // H I J K L M N O
+ KC_H, KC_I, KC_J, KC_K, KC_L, BE_M, KC_N, KC_O,
+ // P Q R S T U V W
+ KC_P, BE_Q, KC_R, KC_S, KC_T, KC_U, KC_V, BE_W,
+ // X Y Z [ \ ] ^ _
+ KC_X, KC_Y, BE_Z, BE_CIRC, BE_LESS, BE_DLR, BE_PARA, BE_MINS,
+ // ` a b c d e f g
+ BE_MU, BE_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // h i j k l m n o
+ KC_H, KC_I, KC_J, KC_K, KC_L, BE_M, KC_N, KC_O,
+ // p q r s t u v w
+ KC_P, BE_Q, KC_R, KC_S, KC_T, KC_U, KC_V, BE_W,
+ // x y z { | } ~ DEL
+ KC_X, KC_Y, BE_Z, BE_CCED, BE_AMP, BE_AGRV, BE_EQL, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_bepo.h b/quantum/keymap_extras/sendstring_bepo.h
index c7377e077d..ca5f73d7ec 100644
--- a/quantum/keymap_extras/sendstring_bepo.h
+++ b/quantum/keymap_extras/sendstring_bepo.h
@@ -13,29 +13,87 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the bépo layout */
-#ifndef SENDSTRING_BEPO
-#define SENDSTRING_BEPO
+
+// Sendstring lookup tables for BÉPO layouts
+
+#pragma once
#include "keymap_bepo.h"
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- KC_SPC, BP_DCRC, BP_DQOT, BP_DOLLAR, BP_DOLLAR, BP_PERCENT, BP_P, BP_APOS,
- BP_LPRN, BP_RPRN, BP_ASTR, BP_PLUS, BP_COMM, BP_MINUS, BP_DOT, BP_SLSH,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, BP_DOT, BP_DOT, KC_2, BP_EQUAL, KC_2, BP_APOS,
- BP_AT, BP_A, BP_B, BP_C, BP_D, BP_E, BP_F, BP_G,
- BP_H, BP_I, BP_J, BP_K, BP_L, BP_M, BP_N, BP_O,
- BP_P, BP_Q, BP_R, BP_S, BP_T, BP_U, BP_V, BP_W,
- BP_X, BP_Y, BP_Z, KC_4, BP_AGRV, KC_5, KC_5, KC_MINS,
- KC_2, BP_A, BP_B, BP_C, BP_D, BP_E, BP_F, BP_G,
- BP_H, BP_I, BP_J, BP_K, BP_L, BP_M, BP_N, BP_O,
- BP_P, BP_Q, BP_R, BP_S, BP_T, BP_U, BP_V, BP_W,
- BP_X, BP_Y, BP_Z, BP_Y, BP_B, BP_X, BP_K, KC_DEL,
+// clang-format off
+
+const bool ascii_to_shift_lut[128] PROGMEM = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 1, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 0, 0, 0, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
};
-#endif
+const bool ascii_to_altgr_lut[128] PROGMEM = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 0
+};
+
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, BP_DCRC, BP_DQOT, BP_DLR, BP_DLR, BP_PERC, BP_P, BP_APOS,
+ // ( ) * + , - . /
+ BP_LPRN, BP_RPRN, BP_ASTR, BP_PLUS, BP_COMM, BP_MINS, BP_DOT, BP_SLSH,
+ // 0 1 2 3 4 5 6 7
+ BP_ASTR, BP_DQOT, BP_LGIL, BP_RGIL, BP_LPRN, BP_RPRN, BP_AT, BP_PLUS,
+ // 8 9 : ; < = > ?
+ BP_MINS, BP_SLSH, BP_DOT, BP_COMM, BP_LGIL, BP_EQL, BP_RGIL, BP_APOS,
+ // @ A B C D E F G
+ BP_AT, BP_A, BP_B, BP_C, BP_D, BP_E, BP_F, BP_G,
+ // H I J K L M N O
+ BP_H, BP_I, BP_J, BP_K, BP_L, BP_M, BP_N, BP_O,
+ // P Q R S T U V W
+ BP_P, BP_Q, BP_R, BP_S, BP_T, BP_U, BP_V, BP_W,
+ // X Y Z [ \ ] ^ _
+ BP_X, BP_Y, BP_Z, BP_LPRN, BP_AGRV, BP_RPRN, BP_AT, KC_SPC,
+ // ` a b c d e f g
+ BP_PERC, BP_A, BP_B, BP_C, BP_D, BP_E, BP_F, BP_G,
+ // h i j k l m n o
+ BP_H, BP_I, BP_J, BP_K, BP_L, BP_M, BP_N, BP_O,
+ // p q r s t u v w
+ BP_P, BP_Q, BP_R, BP_S, BP_T, BP_U, BP_V, BP_W,
+ // x y z { | } ~ DEL
+ BP_X, BP_Y, BP_Z, BP_Y, BP_B, BP_X, BP_K, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_colemak.h b/quantum/keymap_extras/sendstring_colemak.h
index fa9ace9290..fddf4b590e 100644
--- a/quantum/keymap_extras/sendstring_colemak.h
+++ b/quantum/keymap_extras/sendstring_colemak.h
@@ -13,29 +13,47 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the Colemak layout */
-#ifndef SENDSTRING_COLEMAK
-#define SENDSTRING_COLEMAK
+
+// Sendstring lookup tables for Colemak layouts
+
+#pragma once
#include "keymap_colemak.h"
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
- KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
- KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
- CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
- CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
- CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
- KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
- CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
- CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
- CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
-};
+// clang-format off
-#endif
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
+ // ( ) * + , - . /
+ KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
+ // 0 1 2 3 4 5 6 7
+ KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ // 8 9 : ; < = > ?
+ KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
+ // @ A B C D E F G
+ KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
+ // H I J K L M N O
+ CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
+ // P Q R S T U V W
+ CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
+ // X Y Z [ \ ] ^ _
+ CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
+ // ` a b c d e f g
+ KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
+ // h i j k l m n o
+ CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
+ // p q r s t u v w
+ CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
+ // x y z { | } ~ DEL
+ CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_dvorak.h b/quantum/keymap_extras/sendstring_dvorak.h
index f5c5c818b8..25e1d31423 100644
--- a/quantum/keymap_extras/sendstring_dvorak.h
+++ b/quantum/keymap_extras/sendstring_dvorak.h
@@ -13,29 +13,47 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the Dvorak layout */
-#ifndef SENDSTRING_DVORAK
-#define SENDSTRING_DVORAK
+
+// Sendstring lookup tables for Dvorak layouts
+
+#pragma once
#include "keymap_dvorak.h"
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- KC_SPC, DV_1, DV_QUOT, DV_3, DV_4, DV_5, DV_7, DV_QUOT,
- DV_9, DV_0, DV_8, DV_EQL, DV_COMM, DV_MINS, DV_DOT, DV_SLSH,
- DV_0, DV_1, DV_2, DV_3, DV_4, DV_5, DV_6, DV_7,
- DV_8, DV_9, DV_SCLN, DV_SCLN, DV_COMM, DV_EQL, DV_DOT, DV_SLSH,
- DV_2, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G,
- DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O,
- DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W,
- DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_6, DV_MINS,
- DV_GRV, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G,
- DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O,
- DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W,
- DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_GRV, KC_DEL
-};
+// clang-format off
-#endif
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, DV_1, DV_QUOT, DV_3, DV_4, DV_5, DV_7, DV_QUOT,
+ // ( ) * + , - . /
+ DV_9, DV_0, DV_8, DV_EQL, DV_COMM, DV_MINS, DV_DOT, DV_SLSH,
+ // 0 1 2 3 4 5 6 7
+ DV_0, DV_1, DV_2, DV_3, DV_4, DV_5, DV_6, DV_7,
+ // 8 9 : ; < = > ?
+ DV_8, DV_9, DV_SCLN, DV_SCLN, DV_COMM, DV_EQL, DV_DOT, DV_SLSH,
+ // @ A B C D E F G
+ DV_2, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G,
+ // H I J K L M N O
+ DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O,
+ // P Q R S T U V W
+ DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W,
+ // X Y Z [ \ ] ^ _
+ DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_6, DV_MINS,
+ // ` a b c d e f g
+ DV_GRV, DV_A, DV_B, DV_C, DV_D, DV_E, DV_F, DV_G,
+ // h i j k l m n o
+ DV_H, DV_I, DV_J, DV_K, DV_L, DV_M, DV_N, DV_O,
+ // p q r s t u v w
+ DV_P, DV_Q, DV_R, DV_S, DV_T, DV_U, DV_V, DV_W,
+ // x y z { | } ~ DEL
+ DV_X, DV_Y, DV_Z, DV_LBRC, DV_BSLS, DV_RBRC, DV_GRV, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_french.h b/quantum/keymap_extras/sendstring_french.h
new file mode 100644
index 0000000000..966685ccca
--- /dev/null
+++ b/quantum/keymap_extras/sendstring_french.h
@@ -0,0 +1,99 @@
+/* Copyright 2016 Jack Humbert
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Sendstring lookup tables for French (AZERTY) layouts
+
+#pragma once
+
+#include "keymap_french.h"
+
+// clang-format off
+
+const bool ascii_to_shift_lut[128] PROGMEM = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 1, 0, 0,
+ 0, 0, 0, 1, 0, 0, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 0, 0, 0, 0, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+const bool ascii_to_altgr_lut[128] PROGMEM = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 0
+};
+
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, FR_EXLM, FR_QUOT, FR_QUOT, FR_DLR, FR_UGRV, FR_AMP, FR_APOS,
+ // ( ) * + , - . /
+ FR_LPRN, FR_RPRN, FR_ASTR, FR_EQL, FR_COMM, FR_MINS, FR_SCLN, FR_COLN,
+ // 0 1 2 3 4 5 6 7
+ FR_AGRV, FR_AMP, FR_EACU, FR_QUOT, FR_APOS, FR_LPRN, FR_MINS, FR_EGRV,
+ // 8 9 : ; < = > ?
+ FR_CCED, FR_AGRV, FR_COLN, FR_SCLN, FR_LESS, FR_EQL, FR_LESS, FR_COMM,
+ // @ A B C D E F G
+ FR_AGRV, FR_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // H I J K L M N O
+ KC_H, KC_I, KC_J, KC_K, KC_L, FR_M, KC_N, KC_O,
+ // P Q R S T U V W
+ KC_P, FR_Q, KC_R, KC_S, KC_T, KC_U, KC_V, FR_W,
+ // X Y Z [ \ ] ^ _
+ KC_X, KC_Y, FR_Z, FR_LPRN, FR_UNDS, FR_RPRN, FR_CCED, FR_UNDS,
+ // ` a b c d e f g
+ FR_EGRV, FR_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // h i j k l m n o
+ KC_H, KC_I, KC_J, KC_K, KC_L, FR_M, KC_N, KC_O,
+ // p q r s t u v w
+ KC_P, FR_Q, KC_R, KC_S, KC_T, KC_U, KC_V, FR_W,
+ // x y z { | } ~ DEL
+ KC_X, KC_Y, FR_Z, FR_APOS, FR_MINS, FR_EQL, FR_EACU, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_german.h b/quantum/keymap_extras/sendstring_german.h
index f20fab77d1..3f27a9b2ca 100644
--- a/quantum/keymap_extras/sendstring_german.h
+++ b/quantum/keymap_extras/sendstring_german.h
@@ -13,69 +13,87 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the German layout */
-#ifndef SENDSTRING_GERMAN
-#define SENDSTRING_GERMAN
+
+// Sendstring lookup tables for German layouts
+
+#pragma once
#include "keymap_german.h"
-const bool ascii_to_shift_lut[0x80] PROGMEM = {
+// clang-format off
+
+const bool ascii_to_shift_lut[128] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
-
+
0, 1, 1, 0, 1, 1, 1, 1,
1, 1, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 0, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1, 0
+ 0, 0, 0, 0, 0, 0, 0, 0
};
-/* Until an ALT table/functionality is added, the following symbols will not work:
-* § @ [ ] { } \ ~ äA öÖ ß ´
-* Following characters can be printed using other characters like so:
-* [ in makro will be ü
-* { in makro will be Ü
-* ~ in makro will be °
-*/
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
+const bool ascii_to_altgr_lut[128] PROGMEM = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
- /* SPACE ! " # $ % & ' */
- KC_SPC, KC_1, KC_2, DE_HASH, KC_4, KC_5, KC_6, DE_HASH,
- /* ( ) * + , - . / */
- KC_8, KC_9, DE_PLUS, DE_PLUS, KC_COMM, DE_MINS, KC_DOT, KC_7,
- /* 0 1 2 3 4 5 6 7 */
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- /* 8 9 : ; < = > ? */
- KC_8, KC_9, KC_DOT, KC_COMM, DE_LESS, KC_0, DE_LESS, KC_MINS,
- /* @ A B C D E F G */
- KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- /* H I J K L M N O */
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- /* P Q R S T U V W */
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- /* X Y Z [ \ ] ^ _ */
- KC_X, DE_Y, DE_Z, KC_LBRC, KC_BSLS, KC_RBRC, DE_CIRC, DE_MINS,
- /* ` a b c d e f g */
- DE_ACUT, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- /* h i j k l m n o */
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- /* p q r s t u v w */
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- /* x y z { | } ~ DELETE */
- KC_X, DE_Y, DE_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 0
};
-#endif
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, DE_1, DE_2, DE_HASH, DE_4, DE_5, DE_6, DE_HASH,
+ // ( ) * + , - . /
+ DE_8, DE_9, DE_PLUS, DE_PLUS, DE_COMM, DE_MINS, DE_DOT, DE_7,
+ // 0 1 2 3 4 5 6 7
+ DE_0, DE_1, DE_2, DE_3, DE_4, DE_5, DE_6, DE_7,
+ // 8 9 : ; < = > ?
+ DE_8, DE_9, DE_DOT, DE_COMM, DE_LESS, DE_0, DE_LESS, DE_SS,
+ // @ A B C D E F G
+ DE_Q, DE_A, DE_B, DE_C, DE_D, DE_E, DE_F, DE_G,
+ // H I J K L M N O
+ DE_H, DE_I, DE_J, DE_K, DE_L, DE_M, DE_N, DE_O,
+ // P Q R S T U V W
+ DE_P, DE_Q, DE_R, DE_S, DE_T, DE_U, DE_V, DE_W,
+ // X Y Z [ \ ] ^ _
+ DE_X, DE_Y, DE_Z, DE_8, DE_SS, DE_9, DE_CIRC, DE_MINS,
+ // ` a b c d e f g
+ DE_ACUT, DE_A, DE_B, DE_C, DE_D, DE_E, DE_F, DE_G,
+ // h i j k l m n o
+ DE_H, DE_I, DE_J, DE_K, DE_L, DE_M, DE_N, DE_O,
+ // p q r s t u v w
+ DE_P, DE_Q, DE_R, DE_S, DE_T, DE_U, DE_V, DE_W,
+ // x y z { | } ~ DEL
+ DE_X, DE_Y, DE_Z, DE_7, DE_LESS, DE_0, DE_PLUS, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_jis.h b/quantum/keymap_extras/sendstring_jis.h
index c5a38c6a5b..421ceb0438 100644
--- a/quantum/keymap_extras/sendstring_jis.h
+++ b/quantum/keymap_extras/sendstring_jis.h
@@ -13,15 +13,21 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the JIS keyboard layout */
-#ifndef SENDSTRING_JIS
-#define SENDSTRING_JIS
-const bool ascii_to_shift_lut[0x80] PROGMEM = {
+// Sendstring lookup tables for JIS layouts
+
+#pragma once
+
+#include "keymap_jp.h"
+
+// clang-format off
+
+const bool ascii_to_shift_lut[128] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
+
0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -36,23 +42,38 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = {
0, 0, 0, 1, 1, 1, 1, 0
};
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, KC_QUOT, KC_SCLN, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, KC_QUOT, KC_SCLN, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
- KC_LBRC, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- KC_X, KC_Y, KC_Z, KC_RBRC, KC_JYEN, KC_BSLS, KC_EQL, KC_RO,
- KC_LBRC, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- KC_X, KC_Y, KC_Z, KC_RBRC, KC_JYEN, KC_BSLS, KC_EQL, KC_DEL,
-};
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
-#endif
+ // ! " # $ % & '
+ KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ // ( ) * + , - . /
+ KC_8, KC_9, JP_COLN, JP_SCLN, JP_COMM, JP_MINS, JP_DOT, JP_SLSH,
+ // 0 1 2 3 4 5 6 7
+ KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ // 8 9 : ; < = > ?
+ KC_8, KC_9, JP_COLN, JP_SCLN, JP_COMM, JP_MINS, JP_DOT, JP_SLSH,
+ // @ A B C D E F G
+ JP_AT, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // H I J K L M N O
+ KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
+ // P Q R S T U V W
+ KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
+ // X Y Z [ \ ] ^ _
+ KC_X, KC_Y, KC_Z, JP_LBRC, JP_BSLS, JP_RBRC, JP_CIRC, JP_BSLS,
+ // ` a b c d e f g
+ JP_AT, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // h i j k l m n o
+ KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
+ // p q r s t u v w
+ KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
+ // x y z { | } ~ DEL
+ KC_X, KC_Y, KC_Z, JP_LBRC, JP_YEN, JP_RBRC, JP_CIRC, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_norman.h b/quantum/keymap_extras/sendstring_norman.h
index 57d450ca85..4146e6ca7b 100644
--- a/quantum/keymap_extras/sendstring_norman.h
+++ b/quantum/keymap_extras/sendstring_norman.h
@@ -13,27 +13,47 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the Colemak layout */
+
+// Sendstring lookup tables for Norman layouts
+
#pragma once
#include "keymap_norman.h"
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
- KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, NM_SCLN, NM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
- KC_2, NM_A, NM_B, NM_C, NM_D, NM_E, NM_F, NM_G,
- NM_H, NM_I, NM_J, NM_K, NM_L, NM_M, NM_N, NM_O,
- NM_P, NM_Q, NM_R, NM_S, NM_T, NM_U, NM_V, NM_W,
- NM_X, NM_Y, NM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
- KC_GRV, NM_A, NM_B, NM_C, NM_D, NM_E, NM_F, NM_G,
- NM_H, NM_I, NM_J, NM_K, NM_L, NM_M, NM_N, NM_O,
- NM_P, NM_Q, NM_R, NM_S, NM_T, NM_U, NM_V, NM_W,
- NM_X, NM_Y, NM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
-};
+// clang-format off
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
+ // ( ) * + , - . /
+ KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
+ // 0 1 2 3 4 5 6 7
+ KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ // 8 9 : ; < = > ?
+ KC_8, KC_9, NM_SCLN, NM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
+ // @ A B C D E F G
+ KC_2, NM_A, NM_B, NM_C, NM_D, NM_E, NM_F, NM_G,
+ // H I J K L M N O
+ NM_H, NM_I, NM_J, NM_K, NM_L, NM_M, NM_N, NM_O,
+ // P Q R S T U V W
+ NM_P, NM_Q, NM_R, NM_S, NM_T, NM_U, NM_V, NM_W,
+ // X Y Z [ \ ] ^ _
+ NM_X, NM_Y, NM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
+ // ` a b c d e f g
+ KC_GRV, NM_A, NM_B, NM_C, NM_D, NM_E, NM_F, NM_G,
+ // h i j k l m n o
+ NM_H, NM_I, NM_J, NM_K, NM_L, NM_M, NM_N, NM_O,
+ // p q r s t u v w
+ NM_P, NM_Q, NM_R, NM_S, NM_T, NM_U, NM_V, NM_W,
+ // x y z { | } ~ DEL
+ NM_X, NM_Y, NM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_spanish.h b/quantum/keymap_extras/sendstring_spanish.h
index 7194459290..92bada269a 100644
--- a/quantum/keymap_extras/sendstring_spanish.h
+++ b/quantum/keymap_extras/sendstring_spanish.h
@@ -13,59 +13,87 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the Spanish layout */
-#ifndef SENDSTRING_SPANISH
-#define SENDSTRING_SPANISH
+
+// Sendstring lookup tables for Spanish layouts
+
+#pragma once
#include "keymap_spanish.h"
-const bool ascii_to_shift_lut[0x80] PROGMEM = {
+// clang-format off
+
+const bool ascii_to_shift_lut[128] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 0, 1, 1, 1, 0,
1, 1, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
-
0, 0, 1, 1, 0, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
-
1, 1, 1, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1, 0
+ 0, 0, 0, 0, 0, 0, 0, 0
};
-/* Until an ALT table/functionality is added, the following symbols will not work:
- # @ [ ] { } | ~
-*/
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
-/* , ! " # $ % & ' */
- KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, ES_APOS,
-/* ( ) * + , - . / */
- KC_8, KC_9, ES_PLUS, ES_PLUS, KC_COMM, ES_MINS, KC_DOT, KC_7,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
-/* 8 9 : ; < = > ? */
- KC_8, KC_9, KC_DOT, KC_COMM, KC_NUBS, KC_0, KC_NUBS, ES_APOS,
-/* @ A B C D E F G */
- KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
-/* X Y Z [ \ ] ^ _ */
- KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, ES_GRV, ES_MINS,
- ES_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
+const bool ascii_to_altgr_lut[128] PROGMEM = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 0
};
-#endif
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, ES_APOS,
+ // ( ) * + , - . /
+ KC_8, KC_9, ES_PLUS, ES_PLUS, KC_COMM, ES_MINS, KC_DOT, KC_7,
+ // 0 1 2 3 4 5 6 7
+ KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ // 8 9 : ; < = > ?
+ KC_8, KC_9, KC_DOT, KC_COMM, ES_LESS, KC_0, ES_LESS, ES_APOS,
+ // @ A B C D E F G
+ KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // H I J K L M N O
+ KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
+ // P Q R S T U V W
+ KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
+ // X Y Z [ \ ] ^ _
+ KC_X, KC_Y, KC_Z, ES_GRV, ES_OVRR, ES_PLUS, ES_GRV, ES_MINS,
+ // ` a b c d e f g
+ ES_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // h i j k l m n o
+ KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
+ // p q r s t u v w
+ KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
+ // x y z { | } ~ DEL
+ KC_X, KC_Y, KC_Z, ES_ACUT, KC_1, ES_CCED, ES_NTIL, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_uk.h b/quantum/keymap_extras/sendstring_uk.h
index 2824e5d444..982456e40a 100644
--- a/quantum/keymap_extras/sendstring_uk.h
+++ b/quantum/keymap_extras/sendstring_uk.h
@@ -14,12 +14,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* SEND_STRING() LUTs for UK layouts */
+// Sendstring lookup tables for UK layouts
-#ifndef SENDSTRING_UK
-#define SENDSTRING_UK
+#pragma once
-const bool ascii_to_shift_lut[0x80] PROGMEM = {
+#include "keymap_uk.h"
+
+// clang-format off
+
+const bool ascii_to_shift_lut[128] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -39,24 +42,38 @@ const bool ascii_to_shift_lut[0x80] PROGMEM = {
0, 0, 0, 1, 1, 1, 1, 0
};
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
- KC_SPC, KC_1, KC_2, KC_NUHS, KC_4, KC_5, KC_7, KC_QUOT,
- KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
- KC_QUOT, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
- KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
+ // ! " # $ % & '
+ UK_SPC, UK_1, UK_2, UK_HASH, UK_4, UK_5, UK_7, UK_QUOT,
+ // ( ) * + , - . /
+ UK_9, UK_0, UK_8, UK_EQL, UK_COMM, UK_MINS, UK_DOT, UK_SLSH,
+ // 0 1 2 3 4 5 6 7
+ UK_0, UK_1, UK_2, UK_3, UK_4, UK_5, UK_6, UK_7,
+ // 8 9 : ; < = > ?
+ UK_8, UK_9, UK_SCLN, UK_SCLN, UK_COMM, UK_EQL, UK_DOT, UK_SLSH,
+ // @ A B C D E F G
+ UK_QUOT, UK_A, UK_B, UK_C, UK_D, UK_E, UK_F, UK_G,
+ // H I J K L M N O
+ UK_H, UK_I, UK_J, UK_K, UK_L, UK_M, UK_N, UK_O,
+ // P Q R S T U V W
+ UK_P, UK_Q, UK_R, UK_S, UK_T, UK_U, UK_V, UK_W,
+ // X Y Z [ \ ] ^ _
+ UK_X, UK_Y, UK_Z, UK_LBRC, UK_BSLS, UK_RBRC, UK_6, UK_MINS,
+ // ` a b c d e f g
+ UK_GRV, UK_A, UK_B, UK_C, UK_D, UK_E, UK_F, UK_G,
+ // h i j k l m n o
+ UK_H, UK_I, UK_J, UK_K, UK_L, UK_M, UK_N, UK_O,
+ // p q r s t u v w
+ UK_P, UK_Q, UK_R, UK_S, UK_T, UK_U, UK_V, UK_W,
+ // x y z { | } ~ DEL
+ UK_X, UK_Y, UK_Z, UK_LBRC, UK_BSLS, UK_RBRC, UK_HASH, KC_DEL
};
-
-#endif
diff --git a/quantum/keymap_extras/sendstring_workman.h b/quantum/keymap_extras/sendstring_workman.h
index a8571839da..434ef653b1 100644
--- a/quantum/keymap_extras/sendstring_workman.h
+++ b/quantum/keymap_extras/sendstring_workman.h
@@ -13,29 +13,47 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* Sendstring definitions for the Workman layout */
-#ifndef SENDSTRING_WORKMAN
-#define SENDSTRING_WORKMAN
+
+// Sendstring lookup tables for Workman layouts
+
+#pragma once
#include "keymap_workman.h"
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
- KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
- KC_2, WK_A, WK_B, WK_C, WK_D, WK_E, WK_F, WK_G,
- WK_H, WK_I, WK_J, WK_K, WK_L, WK_M, WK_N, WK_O,
- WK_P, WK_Q, WK_R, WK_S, WK_T, WK_U, WK_V, WK_W,
- WK_X, WK_Y, WK_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
- KC_GRV, WK_A, WK_B, WK_C, WK_D, WK_E, WK_F, WK_G,
- WK_H, WK_I, WK_J, WK_K, WK_L, WK_M, WK_N, WK_O,
- WK_P, WK_Q, WK_R, WK_S, WK_T, WK_U, WK_V, WK_W,
- WK_X, WK_Y, WK_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
-};
+// clang-format off
-#endif \ No newline at end of file
+const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
+ // NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
+ // ( ) * + , - . /
+ KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
+ // 0 1 2 3 4 5 6 7
+ KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ // 8 9 : ; < = > ?
+ KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
+ // @ A B C D E F G
+ KC_2, WK_A, WK_B, WK_C, WK_D, WK_E, WK_F, WK_G,
+ // H I J K L M N O
+ WK_H, WK_I, WK_J, WK_K, WK_L, WK_M, WK_N, WK_O,
+ // P Q R S T U V W
+ WK_P, WK_Q, WK_R, WK_S, WK_T, WK_U, WK_V, WK_W,
+ // X Y Z [ \ ] ^ _
+ WK_X, WK_Y, WK_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
+ // ` a b c d e f g
+ KC_GRV, WK_A, WK_B, WK_C, WK_D, WK_E, WK_F, WK_G,
+ // h i j k l m n o
+ WK_H, WK_I, WK_J, WK_K, WK_L, WK_M, WK_N, WK_O,
+ // p q r s t u v w
+ WK_P, WK_Q, WK_R, WK_S, WK_T, WK_U, WK_V, WK_W,
+ // x y z { | } ~ DEL
+ WK_X, WK_Y, WK_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
+};
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index 8ef8abe712..5c24c797a9 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -30,27 +30,27 @@
led_config_t led_matrix_config;
#ifndef MAX
- #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+# define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#endif
#ifndef MIN
- #define MIN(a,b) ((a) < (b)? (a): (b))
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef LED_DISABLE_AFTER_TIMEOUT
- #define LED_DISABLE_AFTER_TIMEOUT 0
+# define LED_DISABLE_AFTER_TIMEOUT 0
#endif
#ifndef LED_DISABLE_WHEN_USB_SUSPENDED
- #define LED_DISABLE_WHEN_USB_SUSPENDED false
+# define LED_DISABLE_WHEN_USB_SUSPENDED false
#endif
#ifndef EECONFIG_LED_MATRIX
- #define EECONFIG_LED_MATRIX EECONFIG_RGBLIGHT
+# define EECONFIG_LED_MATRIX EECONFIG_RGBLIGHT
#endif
#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > 255
- #define LED_MATRIX_MAXIMUM_BRIGHTNESS 255
+# define LED_MATRIX_MAXIMUM_BRIGHTNESS 255
#endif
bool g_suspend_state = false;
@@ -64,37 +64,33 @@ uint8_t g_key_hit[LED_DRIVER_LED_COUNT];
// Ticks since any key was last hit.
uint32_t g_any_key_hit = 0;
-uint32_t eeconfig_read_led_matrix(void) {
- return eeprom_read_dword(EECONFIG_LED_MATRIX);
-}
+uint32_t eeconfig_read_led_matrix(void) { return eeprom_read_dword(EECONFIG_LED_MATRIX); }
-void eeconfig_update_led_matrix(uint32_t config_value) {
- eeprom_update_dword(EECONFIG_LED_MATRIX, config_value);
-}
+void eeconfig_update_led_matrix(uint32_t config_value) { eeprom_update_dword(EECONFIG_LED_MATRIX, config_value); }
void eeconfig_update_led_matrix_default(void) {
- dprintf("eeconfig_update_led_matrix_default\n");
- led_matrix_config.enable = 1;
- led_matrix_config.mode = LED_MATRIX_UNIFORM_BRIGHTNESS;
- led_matrix_config.val = 128;
- led_matrix_config.speed = 0;
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ dprintf("eeconfig_update_led_matrix_default\n");
+ led_matrix_config.enable = 1;
+ led_matrix_config.mode = LED_MATRIX_UNIFORM_BRIGHTNESS;
+ led_matrix_config.val = 128;
+ led_matrix_config.speed = 0;
+ eeconfig_update_led_matrix(led_matrix_config.raw);
}
void eeconfig_debug_led_matrix(void) {
- dprintf("led_matrix_config eeprom\n");
- dprintf("led_matrix_config.enable = %d\n", led_matrix_config.enable);
- dprintf("led_matrix_config.mode = %d\n", led_matrix_config.mode);
- dprintf("led_matrix_config.val = %d\n", led_matrix_config.val);
- dprintf("led_matrix_config.speed = %d\n", led_matrix_config.speed);
+ dprintf("led_matrix_config eeprom\n");
+ dprintf("led_matrix_config.enable = %d\n", led_matrix_config.enable);
+ dprintf("led_matrix_config.mode = %d\n", led_matrix_config.mode);
+ dprintf("led_matrix_config.val = %d\n", led_matrix_config.val);
+ dprintf("led_matrix_config.speed = %d\n", led_matrix_config.speed);
}
// Last led hit
#ifndef LED_HITS_TO_REMEMBER
- #define LED_HITS_TO_REMEMBER 8
+# define LED_HITS_TO_REMEMBER 8
#endif
uint8_t g_last_led_hit[LED_HITS_TO_REMEMBER] = {255};
-uint8_t g_last_led_count = 0;
+uint8_t g_last_led_count = 0;
void map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i, uint8_t *led_count) {
led_matrix led;
@@ -110,17 +106,11 @@ void map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i, uint8_t
}
}
-void led_matrix_update_pwm_buffers(void) {
- led_matrix_driver.flush();
-}
+void led_matrix_update_pwm_buffers(void) { led_matrix_driver.flush(); }
-void led_matrix_set_index_value(int index, uint8_t value) {
- led_matrix_driver.set_value(index, value);
-}
+void led_matrix_set_index_value(int index, uint8_t value) { led_matrix_driver.set_value(index, value); }
-void led_matrix_set_index_value_all(uint8_t value) {
- led_matrix_driver.set_value_all(value);
-}
+void led_matrix_set_index_value_all(uint8_t value) { led_matrix_driver.set_value_all(value); }
bool process_led_matrix(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
@@ -131,37 +121,29 @@ bool process_led_matrix(uint16_t keycode, keyrecord_t *record) {
g_last_led_hit[i - 1] = g_last_led_hit[i - 2];
}
g_last_led_hit[0] = led[0];
- g_last_led_count = MIN(LED_HITS_TO_REMEMBER, g_last_led_count + 1);
+ g_last_led_count = MIN(LED_HITS_TO_REMEMBER, g_last_led_count + 1);
}
- for(uint8_t i = 0; i < led_count; i++)
- g_key_hit[led[i]] = 0;
+ for (uint8_t i = 0; i < led_count; i++) g_key_hit[led[i]] = 0;
g_any_key_hit = 0;
} else {
- #ifdef LED_MATRIX_KEYRELEASES
+#ifdef LED_MATRIX_KEYRELEASES
uint8_t led[8], led_count;
map_row_column_to_led(record->event.key.row, record->event.key.col, led, &led_count);
- for(uint8_t i = 0; i < led_count; i++)
- g_key_hit[led[i]] = 255;
+ for (uint8_t i = 0; i < led_count; i++) g_key_hit[led[i]] = 255;
g_any_key_hit = 255;
- #endif
+#endif
}
return true;
}
-void led_matrix_set_suspend_state(bool state) {
- g_suspend_state = state;
-}
+void led_matrix_set_suspend_state(bool state) { g_suspend_state = state; }
// All LEDs off
-void led_matrix_all_off(void) {
- led_matrix_set_index_value_all(0);
-}
+void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); }
// Uniform brightness
-void led_matrix_uniform_brightness(void) {
- led_matrix_set_index_value_all(LED_MATRIX_MAXIMUM_BRIGHTNESS / BACKLIGHT_LEVELS * led_matrix_config.val);
-}
+void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(LED_MATRIX_MAXIMUM_BRIGHTNESS / BACKLIGHT_LEVELS * led_matrix_config.val); }
void led_matrix_custom(void) {}
@@ -180,17 +162,15 @@ void led_matrix_task(void) {
for (int led = 0; led < LED_DRIVER_LED_COUNT; led++) {
if (g_key_hit[led] < 255) {
- if (g_key_hit[led] == 254)
- g_last_led_count = MAX(g_last_led_count - 1, 0);
+ if (g_key_hit[led] == 254) g_last_led_count = MAX(g_last_led_count - 1, 0);
g_key_hit[led]++;
}
}
// Ideally we would also stop sending zeros to the LED driver PWM buffers
// while suspended and just do a software shutdown. This is a cheap hack for now.
- bool suspend_backlight = ((g_suspend_state && LED_DISABLE_WHEN_USB_SUSPENDED) ||
- (LED_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > LED_DISABLE_AFTER_TIMEOUT * 60 * 20));
- uint8_t effect = suspend_backlight ? 0 : led_matrix_config.mode;
+ bool suspend_backlight = ((g_suspend_state && LED_DISABLE_WHEN_USB_SUSPENDED) || (LED_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > LED_DISABLE_AFTER_TIMEOUT * 60 * 20));
+ uint8_t effect = suspend_backlight ? 0 : led_matrix_config.mode;
// this gets ticked at 20 Hz.
// each effect can opt to do calculations
@@ -217,12 +197,9 @@ void led_matrix_indicators(void) {
led_matrix_indicators_user();
}
-__attribute__((weak))
-void led_matrix_indicators_kb(void) {}
-
-__attribute__((weak))
-void led_matrix_indicators_user(void) {}
+__attribute__((weak)) void led_matrix_indicators_kb(void) {}
+__attribute__((weak)) void led_matrix_indicators_user(void) {}
// void led_matrix_set_indicator_index(uint8_t *index, uint8_t row, uint8_t column)
// {
@@ -248,7 +225,7 @@ void led_matrix_init(void) {
wait_ms(500);
// clear the key hits
- for (int led=0; led<LED_DRIVER_LED_COUNT; led++) {
+ for (int led = 0; led < LED_DRIVER_LED_COUNT; led++) {
g_key_hit[led] = 255;
}
@@ -266,7 +243,7 @@ void led_matrix_init(void) {
led_matrix_config.raw = eeconfig_read_led_matrix();
}
- eeconfig_debug_led_matrix(); // display current eeprom values
+ eeconfig_debug_led_matrix(); // display current eeprom values
}
// Deals with the messy details of incrementing an integer
@@ -303,32 +280,26 @@ static uint8_t decrement(uint8_t value, uint8_t step, uint8_t min, uint8_t max)
// }
// }
-uint32_t led_matrix_get_tick(void) {
- return g_tick;
-}
+uint32_t led_matrix_get_tick(void) { return g_tick; }
void led_matrix_toggle(void) {
- led_matrix_config.enable ^= 1;
+ led_matrix_config.enable ^= 1;
eeconfig_update_led_matrix(led_matrix_config.raw);
}
void led_matrix_enable(void) {
- led_matrix_config.enable = 1;
+ led_matrix_config.enable = 1;
eeconfig_update_led_matrix(led_matrix_config.raw);
}
-void led_matrix_enable_noeeprom(void) {
- led_matrix_config.enable = 1;
-}
+void led_matrix_enable_noeeprom(void) { led_matrix_config.enable = 1; }
void led_matrix_disable(void) {
- led_matrix_config.enable = 0;
+ led_matrix_config.enable = 0;
eeconfig_update_led_matrix(led_matrix_config.raw);
}
-void led_matrix_disable_noeeprom(void) {
- led_matrix_config.enable = 0;
-}
+void led_matrix_disable_noeeprom(void) { led_matrix_config.enable = 0; }
void led_matrix_step(void) {
led_matrix_config.mode++;
@@ -358,12 +329,12 @@ void led_matrix_decrease_val(void) {
void led_matrix_increase_speed(void) {
led_matrix_config.speed = increment(led_matrix_config.speed, 1, 0, 3);
- eeconfig_update_led_matrix(led_matrix_config.raw);//EECONFIG needs to be increased to support this
+ eeconfig_update_led_matrix(led_matrix_config.raw); // EECONFIG needs to be increased to support this
}
void led_matrix_decrease_speed(void) {
led_matrix_config.speed = decrement(led_matrix_config.speed, 1, 0, 3);
- eeconfig_update_led_matrix(led_matrix_config.raw);//EECONFIG needs to be increased to support this
+ eeconfig_update_led_matrix(led_matrix_config.raw); // EECONFIG needs to be increased to support this
}
void led_matrix_mode(uint8_t mode, bool eeprom_write) {
@@ -373,19 +344,13 @@ void led_matrix_mode(uint8_t mode, bool eeprom_write) {
}
}
-uint8_t led_matrix_get_mode(void) {
- return led_matrix_config.mode;
-}
+uint8_t led_matrix_get_mode(void) { return led_matrix_config.mode; }
-void led_matrix_set_value_noeeprom(uint8_t val) {
- led_matrix_config.val = val;
-}
+void led_matrix_set_value_noeeprom(uint8_t val) { led_matrix_config.val = val; }
void led_matrix_set_value(uint8_t val) {
led_matrix_set_value_noeeprom(val);
eeconfig_update_led_matrix(led_matrix_config.raw);
}
-void backlight_set(uint8_t val) {
- led_matrix_set_value(val);
-}
+void backlight_set(uint8_t val) { led_matrix_set_value(val); }
diff --git a/quantum/led_matrix_drivers.c b/quantum/led_matrix_drivers.c
index cb91821a40..6877bf4c6b 100644
--- a/quantum/led_matrix_drivers.c
+++ b/quantum/led_matrix_drivers.c
@@ -30,120 +30,119 @@
#if defined(IS31FL3731) || defined(IS31FL3733)
-#if defined(IS31FL3731)
- #include "is31fl3731-simple.h"
-#endif
+# if defined(IS31FL3731)
+# include "is31fl3731-simple.h"
+# endif
-#include "i2c_master.h"
+# include "i2c_master.h"
static void init(void) {
i2c_init();
- #ifdef IS31FL3731
- #ifdef LED_DRIVER_ADDR_1
- IS31FL3731_init(LED_DRIVER_ADDR_1);
- #endif
- #ifdef LED_DRIVER_ADDR_2
- IS31FL3731_init(LED_DRIVER_ADDR_2);
- #endif
- #ifdef LED_DRIVER_ADDR_3
- IS31FL3731_init(LED_DRIVER_ADDR_3);
- #endif
- #ifdef LED_DRIVER_ADDR_4
- IS31FL3731_init(LED_DRIVER_ADDR_4);
- #endif
- #else
- #ifdef LED_DRIVER_ADDR_1
- IS31FL3733_init(LED_DRIVER_ADDR_1, 0 );
- #endif
- #ifdef LED_DRIVER_ADDR_2
- IS31FL3733_init(LED_DRIVER_ADDR_2, 0 );
- #endif
- #ifdef LED_DRIVER_ADDR_3
- IS31FL3733_init(LED_DRIVER_ADDR_3, 0 );
- #endif
- #ifdef LED_DRIVER_ADDR_4
- IS31FL3733_init(LED_DRIVER_ADDR_4, 0 );
- #endif
- #endif
+# ifdef IS31FL3731
+# ifdef LED_DRIVER_ADDR_1
+ IS31FL3731_init(LED_DRIVER_ADDR_1);
+# endif
+# ifdef LED_DRIVER_ADDR_2
+ IS31FL3731_init(LED_DRIVER_ADDR_2);
+# endif
+# ifdef LED_DRIVER_ADDR_3
+ IS31FL3731_init(LED_DRIVER_ADDR_3);
+# endif
+# ifdef LED_DRIVER_ADDR_4
+ IS31FL3731_init(LED_DRIVER_ADDR_4);
+# endif
+# else
+# ifdef LED_DRIVER_ADDR_1
+ IS31FL3733_init(LED_DRIVER_ADDR_1, 0);
+# endif
+# ifdef LED_DRIVER_ADDR_2
+ IS31FL3733_init(LED_DRIVER_ADDR_2, 0);
+# endif
+# ifdef LED_DRIVER_ADDR_3
+ IS31FL3733_init(LED_DRIVER_ADDR_3, 0);
+# endif
+# ifdef LED_DRIVER_ADDR_4
+ IS31FL3733_init(LED_DRIVER_ADDR_4, 0);
+# endif
+# endif
for (int index = 0; index < LED_DRIVER_LED_COUNT; index++) {
- #ifdef IS31FL3731
- IS31FL3731_set_led_control_register(index, true);
- #else
- IS31FL3733_set_led_control_register(index, true);
- #endif
+# ifdef IS31FL3731
+ IS31FL3731_set_led_control_register(index, true);
+# else
+ IS31FL3733_set_led_control_register(index, true);
+# endif
}
- // This actually updates the LED drivers
- #ifdef IS31FL3731
- #ifdef LED_DRIVER_ADDR_1
- IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
- #endif
- #ifdef LED_DRIVER_ADDR_2
- IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
- #endif
- #ifdef LED_DRIVER_ADDR_3
- IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
- #endif
- #ifdef LED_DRIVER_ADDR_4
- IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
- #endif
- #else
- #ifdef LED_DRIVER_ADDR_1
- IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
- #endif
- #ifdef LED_DRIVER_ADDR_2
- IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
- #endif
- #ifdef LED_DRIVER_ADDR_3
- IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
- #endif
- #ifdef LED_DRIVER_ADDR_4
- IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
- #endif
- #endif
+// This actually updates the LED drivers
+# ifdef IS31FL3731
+# ifdef LED_DRIVER_ADDR_1
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
+# endif
+# ifdef LED_DRIVER_ADDR_2
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
+# endif
+# ifdef LED_DRIVER_ADDR_3
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
+# endif
+# ifdef LED_DRIVER_ADDR_4
+ IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
+# endif
+# else
+# ifdef LED_DRIVER_ADDR_1
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
+# endif
+# ifdef LED_DRIVER_ADDR_2
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
+# endif
+# ifdef LED_DRIVER_ADDR_3
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
+# endif
+# ifdef LED_DRIVER_ADDR_4
+ IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
}
static void flush(void) {
- #ifdef IS31FL3731
- #ifdef LED_DRIVER_ADDR_1
- IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
- #endif
- #ifdef LED_DRIVER_ADDR_2
- IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
- #endif
- #ifdef LED_DRIVER_ADDR_3
- IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
- #endif
- #ifdef LED_DRIVER_ADDR_4
- IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
- #endif
- #else
- #ifdef LED_DRIVER_ADDR_1
- IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
- #endif
- #ifdef LED_DRIVER_ADDR_2
- IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
- #endif
- #ifdef LED_DRIVER_ADDR_3
- IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
- #endif
- #ifdef LED_DRIVER_ADDR_4
- IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
- #endif
- #endif
+# ifdef IS31FL3731
+# ifdef LED_DRIVER_ADDR_1
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
+# endif
+# ifdef LED_DRIVER_ADDR_2
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
+# endif
+# ifdef LED_DRIVER_ADDR_3
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
+# endif
+# ifdef LED_DRIVER_ADDR_4
+ IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
+# endif
+# else
+# ifdef LED_DRIVER_ADDR_1
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
+# endif
+# ifdef LED_DRIVER_ADDR_2
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
+# endif
+# ifdef LED_DRIVER_ADDR_3
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
+# endif
+# ifdef LED_DRIVER_ADDR_4
+ IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
}
const led_matrix_driver_t led_matrix_driver = {
- .init = init,
+ .init = init,
.flush = flush,
-#ifdef IS31FL3731
- .set_value = IS31FL3731_set_value,
+# ifdef IS31FL3731
+ .set_value = IS31FL3731_set_value,
.set_value_all = IS31FL3731_set_value_all,
-#else
+# else
.set_value = IS31FL3733_set_value,
.set_value_all = IS31FL3733_set_value_all,
-#endif
+# endif
};
-
#endif
diff --git a/quantum/led_tables.c b/quantum/led_tables.c
index 0eeb5c44b6..6eb2c09dc8 100644
--- a/quantum/led_tables.c
+++ b/quantum/led_tables.c
@@ -15,36 +15,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "led_tables.h"
+// clang-format off
#ifdef USE_CIE1931_CURVE
// Lightness curve using the CIE 1931 lightness formula
-//Generated by the python script provided in http://jared.geek.nz/2013/feb/linear-led-pwm
+// Generated by the python script provided in http://jared.geek.nz/2013/feb/linear-led-pwm
const uint8_t CIE1931_CURVE[256] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
- 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6,
- 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11,
- 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16,
- 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24,
- 25, 25, 26, 26, 27, 28, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34,
- 35, 35, 36, 37, 37, 38, 39, 40, 40, 41, 42, 43, 44, 44, 45, 46,
- 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78,
- 79, 80, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 96, 97, 99,
-100, 101, 103, 104, 106, 107, 108, 110, 111, 113, 114, 116, 118, 119, 121, 122,
-124, 125, 127, 129, 130, 132, 134, 135, 137, 139, 141, 142, 144, 146, 148, 149,
-151, 153, 155, 157, 159, 161, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180,
-182, 185, 187, 189, 191, 193, 195, 197, 200, 202, 204, 206, 208, 211, 213, 215,
-218, 220, 222, 225, 227, 230, 232, 234, 237, 239, 242, 244, 247, 249, 252, 255
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
+ 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7,
+ 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12,
+ 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17,
+ 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25,
+ 26, 26, 27, 27, 28, 29, 29, 30, 30, 31, 32, 32, 33, 34, 34, 35,
+ 36, 36, 37, 38, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47,
+ 48, 49, 50, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
+ 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79,
+ 80, 81, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 97, 98, 100,
+ 101, 102, 104, 105, 107, 108, 109, 111, 112, 114, 115, 117, 119, 120, 122, 123,
+ 125, 126, 128, 130, 131, 133, 135, 136, 138, 140, 142, 143, 145, 147, 149, 150,
+ 152, 154, 156, 158, 160, 162, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181,
+ 183, 186, 188, 190, 192, 194, 196, 198, 201, 203, 205, 207, 209, 212, 214, 216,
+ 219, 221, 223, 226, 228, 231, 233, 235, 238, 240, 243, 245, 248, 250, 253, 255
};
#endif
#ifdef USE_LED_BREATHING_TABLE
const uint8_t LED_BREATHING_TABLE[256] PROGMEM = {
- 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9,
- 10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35,
- 37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76,
- 79, 82, 85, 88, 90, 93, 97, 100, 103, 106, 109, 112, 115, 118, 121, 124,
+ 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9,
+ 10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35,
+ 37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76,
+ 79, 82, 85, 88, 90, 93, 97, 100, 103, 106, 109, 112, 115, 118, 121, 124,
127, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 162, 165, 167, 170, 173,
176, 179, 182, 185, 188, 190, 193, 196, 198, 201, 203, 206, 208, 211, 213, 215,
218, 220, 222, 224, 226, 228, 230, 232, 234, 235, 237, 238, 240, 241, 243, 244,
@@ -53,9 +54,11 @@ const uint8_t LED_BREATHING_TABLE[256] PROGMEM = {
245, 244, 243, 241, 240, 238, 237, 235, 234, 232, 230, 228, 226, 224, 222, 220,
218, 215, 213, 211, 208, 206, 203, 201, 198, 196, 193, 190, 188, 185, 182, 179,
176, 173, 170, 167, 165, 162, 158, 155, 152, 149, 146, 143, 140, 137, 134, 131,
- 128, 124, 121, 118, 115, 112, 109, 106, 103, 100, 97, 93, 90, 88, 85, 82,
- 79, 76, 73, 70, 67, 65, 62, 59, 57, 54, 52, 49, 47, 44, 42, 40,
- 37, 35, 33, 31, 29, 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11,
- 10, 9, 7, 6, 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0
+ 128, 124, 121, 118, 115, 112, 109, 106, 103, 100, 97, 93, 90, 88, 85, 82,
+ 79, 76, 73, 70, 67, 65, 62, 59, 57, 54, 52, 49, 47, 44, 42, 40,
+ 37, 35, 33, 31, 29, 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11,
+ 10, 9, 7, 6, 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0
};
#endif
+
+// clang-format on
diff --git a/quantum/ledmatrix.h b/quantum/ledmatrix.h
index 618c5d6767..5867ba9876 100644
--- a/quantum/ledmatrix.h
+++ b/quantum/ledmatrix.h
@@ -20,46 +20,44 @@
#ifndef LED_MATRIX_H
#define LED_MATRIX_H
-
#ifndef BACKLIGHT_ENABLE
- #error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE
+# error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE
#endif
-
typedef struct Point {
- uint8_t x;
- uint8_t y;
+ uint8_t x;
+ uint8_t y;
} __attribute__((packed)) Point;
typedef struct led_matrix {
- union {
- uint8_t raw;
- struct {
- uint8_t row:4; // 16 max
- uint8_t col:4; // 16 max
- };
- } matrix_co;
- Point point;
- uint8_t modifier:1;
+ union {
+ uint8_t raw;
+ struct {
+ uint8_t row : 4; // 16 max
+ uint8_t col : 4; // 16 max
+ };
+ } matrix_co;
+ Point point;
+ uint8_t modifier : 1;
} __attribute__((packed)) led_matrix;
extern const led_matrix g_leds[LED_DRIVER_LED_COUNT];
typedef struct {
- uint8_t index;
- uint8_t value;
+ uint8_t index;
+ uint8_t value;
} led_indicator;
typedef union {
- uint32_t raw;
- struct {
- bool enable :1;
- uint8_t mode :6;
- uint8_t hue :8; // Unused by led_matrix
- uint8_t sat :8; // Unused by led_matrix
- uint8_t val :8;
- uint8_t speed :8;//EECONFIG needs to be increased to support this
- };
+ uint32_t raw;
+ struct {
+ bool enable : 1;
+ uint8_t mode : 6;
+ uint8_t hue : 8; // Unused by led_matrix
+ uint8_t sat : 8; // Unused by led_matrix
+ uint8_t val : 8;
+ uint8_t speed : 8; // EECONFIG needs to be increased to support this
+ };
} led_config_t;
enum led_matrix_effects {
@@ -95,22 +93,22 @@ bool process_led_matrix(uint16_t keycode, keyrecord_t *record);
uint32_t led_matrix_get_tick(void);
-void led_matrix_toggle(void);
-void led_matrix_enable(void);
-void led_matrix_enable_noeeprom(void);
-void led_matrix_disable(void);
-void led_matrix_disable_noeeprom(void);
-void led_matrix_step(void);
-void led_matrix_step_reverse(void);
-void led_matrix_increase_val(void);
-void led_matrix_decrease_val(void);
-void led_matrix_increase_speed(void);
-void led_matrix_decrease_speed(void);
-void led_matrix_mode(uint8_t mode, bool eeprom_write);
-void led_matrix_mode_noeeprom(uint8_t mode);
+void led_matrix_toggle(void);
+void led_matrix_enable(void);
+void led_matrix_enable_noeeprom(void);
+void led_matrix_disable(void);
+void led_matrix_disable_noeeprom(void);
+void led_matrix_step(void);
+void led_matrix_step_reverse(void);
+void led_matrix_increase_val(void);
+void led_matrix_decrease_val(void);
+void led_matrix_increase_speed(void);
+void led_matrix_decrease_speed(void);
+void led_matrix_mode(uint8_t mode, bool eeprom_write);
+void led_matrix_mode_noeeprom(uint8_t mode);
uint8_t led_matrix_get_mode(void);
-void led_matrix_set_value(uint8_t mode);
-void led_matrix_set_value_noeeprom(uint8_t mode);
+void led_matrix_set_value(uint8_t mode);
+void led_matrix_set_value_noeeprom(uint8_t mode);
typedef struct {
/* Perform any initialisation required for the other driver functions to work. */
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 7ccac35331..907492a0f6 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -25,24 +25,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "quantum.h"
#if (MATRIX_COLS <= 8)
-# define print_matrix_header() print("\nr/c 01234567\n")
-# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
-# define matrix_bitpop(i) bitpop(matrix[i])
+# define print_matrix_header() print("\nr/c 01234567\n")
+# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
+# define matrix_bitpop(i) bitpop(matrix[i])
# define ROW_SHIFTER ((uint8_t)1)
#elif (MATRIX_COLS <= 16)
-# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
-# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
-# define matrix_bitpop(i) bitpop16(matrix[i])
+# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
+# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
+# define matrix_bitpop(i) bitpop16(matrix[i])
# define ROW_SHIFTER ((uint16_t)1)
#elif (MATRIX_COLS <= 32)
-# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
-# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
-# define matrix_bitpop(i) bitpop32(matrix[i])
-# define ROW_SHIFTER ((uint32_t)1)
+# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
+# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
+# define matrix_bitpop(i) bitpop32(matrix[i])
+# define ROW_SHIFTER ((uint32_t)1)
#endif
#ifdef MATRIX_MASKED
- extern const matrix_row_t matrix_mask[];
+extern const matrix_row_t matrix_mask[];
#endif
#ifdef DIRECT_PINS
@@ -53,63 +53,34 @@ static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#endif
/* matrix state(1:on, 0:off) */
-static matrix_row_t raw_matrix[MATRIX_ROWS]; //raw values
-static matrix_row_t matrix[MATRIX_ROWS]; //debounced values
+static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
+static matrix_row_t matrix[MATRIX_ROWS]; // debounced values
-__attribute__ ((weak))
-void matrix_init_quantum(void) {
- matrix_init_kb();
-}
+__attribute__((weak)) void matrix_init_quantum(void) { matrix_init_kb(); }
-__attribute__ ((weak))
-void matrix_scan_quantum(void) {
- matrix_scan_kb();
-}
+__attribute__((weak)) void matrix_scan_quantum(void) { matrix_scan_kb(); }
-__attribute__ ((weak))
-void matrix_init_kb(void) {
- matrix_init_user();
-}
+__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); }
-__attribute__ ((weak))
-void matrix_scan_kb(void) {
- matrix_scan_user();
-}
+__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); }
-__attribute__ ((weak))
-void matrix_init_user(void) {
-}
+__attribute__((weak)) void matrix_init_user(void) {}
-__attribute__ ((weak))
-void matrix_scan_user(void) {
-}
+__attribute__((weak)) void matrix_scan_user(void) {}
-inline
-uint8_t matrix_rows(void) {
- return MATRIX_ROWS;
-}
+inline uint8_t matrix_rows(void) { return MATRIX_ROWS; }
-inline
-uint8_t matrix_cols(void) {
- return MATRIX_COLS;
-}
+inline uint8_t matrix_cols(void) { return MATRIX_COLS; }
-//Deprecated.
-bool matrix_is_modified(void)
-{
+// Deprecated.
+bool matrix_is_modified(void) {
if (debounce_active()) return false;
return true;
}
-inline
-bool matrix_is_on(uint8_t row, uint8_t col)
-{
- return (matrix[row] & ((matrix_row_t)1<<col));
-}
+inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); }
-inline
-matrix_row_t matrix_get_row(uint8_t row)
-{
+inline matrix_row_t matrix_get_row(uint8_t row) {
// Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
// switch blocker installed and the switch is always pressed.
#ifdef MATRIX_MASKED
@@ -119,19 +90,18 @@ matrix_row_t matrix_get_row(uint8_t row)
#endif
}
-void matrix_print(void)
-{
+void matrix_print(void) {
print_matrix_header();
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- phex(row); print(": ");
+ phex(row);
+ print(": ");
print_matrix_row(row);
print("\n");
}
}
-uint8_t matrix_key_count(void)
-{
+uint8_t matrix_key_count(void) {
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += matrix_bitpop(i);
@@ -139,63 +109,56 @@ uint8_t matrix_key_count(void)
return count;
}
-
#ifdef DIRECT_PINS
static void init_pins(void) {
- for (int row = 0; row < MATRIX_ROWS; row++) {
- for (int col = 0; col < MATRIX_COLS; col++) {
- pin_t pin = direct_pins[row][col];
- if (pin != NO_PIN) {
- setPinInputHigh(pin);
- }
+ for (int row = 0; row < MATRIX_ROWS; row++) {
+ for (int col = 0; col < MATRIX_COLS; col++) {
+ pin_t pin = direct_pins[row][col];
+ if (pin != NO_PIN) {
+ setPinInputHigh(pin);
+ }
+ }
}
- }
}
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
- matrix_row_t last_row_value = current_matrix[current_row];
- current_matrix[current_row] = 0;
+ matrix_row_t last_row_value = current_matrix[current_row];
+ current_matrix[current_row] = 0;
- for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
- pin_t pin = direct_pins[current_row][col_index];
- if (pin != NO_PIN) {
- current_matrix[current_row] |= readPin(pin) ? 0 : (ROW_SHIFTER << col_index);
+ for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
+ pin_t pin = direct_pins[current_row][col_index];
+ if (pin != NO_PIN) {
+ current_matrix[current_row] |= readPin(pin) ? 0 : (ROW_SHIFTER << col_index);
+ }
}
- }
- return (last_row_value != current_matrix[current_row]);
+ return (last_row_value != current_matrix[current_row]);
}
#elif (DIODE_DIRECTION == COL2ROW)
-static void select_row(uint8_t row)
-{
+static void select_row(uint8_t row) {
setPinOutput(row_pins[row]);
writePinLow(row_pins[row]);
}
-static void unselect_row(uint8_t row)
-{
- setPinInputHigh(row_pins[row]);
-}
+static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); }
-static void unselect_rows(void)
-{
- for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
+static void unselect_rows(void) {
+ for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh(row_pins[x]);
}
}
static void init_pins(void) {
- unselect_rows();
- for (uint8_t x = 0; x < MATRIX_COLS; x++) {
- setPinInputHigh(col_pins[x]);
- }
+ unselect_rows();
+ for (uint8_t x = 0; x < MATRIX_COLS; x++) {
+ setPinInputHigh(col_pins[x]);
+ }
}
-static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
-{
+static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[current_row];
@@ -207,13 +170,12 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
wait_us(30);
// For each col...
- for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
-
+ for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
// Select the col pin to read (active low)
uint8_t pin_state = readPin(col_pins[col_index]);
// Populate the matrix row with the state of the col pin
- current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
+ current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
}
// Unselect row
@@ -224,33 +186,27 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
#elif (DIODE_DIRECTION == ROW2COL)
-static void select_col(uint8_t col)
-{
+static void select_col(uint8_t col) {
setPinOutput(col_pins[col]);
writePinLow(col_pins[col]);
}
-static void unselect_col(uint8_t col)
-{
- setPinInputHigh(col_pins[col]);
-}
+static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); }
-static void unselect_cols(void)
-{
- for(uint8_t x = 0; x < MATRIX_COLS; x++) {
+static void unselect_cols(void) {
+ for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh(col_pins[x]);
}
}
static void init_pins(void) {
- unselect_cols();
- for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
- setPinInputHigh(row_pins[x]);
- }
+ unselect_cols();
+ for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
+ setPinInputHigh(row_pins[x]);
+ }
}
-static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
-{
+static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
bool matrix_changed = false;
// Select col and wait for col selecton to stabilize
@@ -258,27 +214,21 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
wait_us(30);
// For each row...
- for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++)
- {
-
+ for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[row_index];
// Check row pin state
- if (readPin(row_pins[row_index]) == 0)
- {
+ if (readPin(row_pins[row_index]) == 0) {
// Pin LO, set col bit
current_matrix[row_index] |= (ROW_SHIFTER << current_col);
- }
- else
- {
+ } else {
// Pin HI, clear col bit
current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
}
// Determine if the matrix changed state
- if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
- {
+ if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
matrix_changed = true;
}
}
@@ -292,14 +242,13 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
#endif
void matrix_init(void) {
-
// initialize key pins
init_pins();
// initialize matrix state: all keys off
- for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
raw_matrix[i] = 0;
- matrix[i] = 0;
+ matrix[i] = 0;
}
debounce_init(MATRIX_ROWS);
@@ -307,24 +256,23 @@ void matrix_init(void) {
matrix_init_quantum();
}
-uint8_t matrix_scan(void)
-{
- bool changed = false;
+uint8_t matrix_scan(void) {
+ bool changed = false;
#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
- // Set row, read cols
- for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
- changed |= read_cols_on_row(raw_matrix, current_row);
- }
+ // Set row, read cols
+ for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
+ changed |= read_cols_on_row(raw_matrix, current_row);
+ }
#elif (DIODE_DIRECTION == ROW2COL)
- // Set col, read rows
- for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
- changed |= read_rows_on_col(raw_matrix, current_col);
- }
+ // Set col, read rows
+ for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
+ changed |= read_rows_on_col(raw_matrix, current_col);
+ }
#endif
- debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
+ debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
- matrix_scan_quantum();
- return (uint8_t)changed;
+ matrix_scan_quantum();
+ return (uint8_t)changed;
}
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk
index fa6dc8b53c..6815a0d8a5 100644
--- a/quantum/mcu_selection.mk
+++ b/quantum/mcu_selection.mk
@@ -1,4 +1,3 @@
-
ifneq ($(findstring STM32F303, $(MCU)),)
## chip/board settings
# - the next two should match the directories in
@@ -8,15 +7,15 @@ ifneq ($(findstring STM32F303, $(MCU)),)
# Linker script to use
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
- # or <this_dir>/ld/
+ # or <keyboard_dir>/ld/
MCU_LDSCRIPT ?= STM32F303xC
# Startup code to use
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
MCU_STARTUP ?= stm32f3xx
- # Board: it should exist either in <chibios>/os/hal/boards/
- # or <this_dir>/boards
+ # Board: it should exist either in <chibios>/os/hal/boards/,
+ # <keyboard_dir>/boards/, or drivers/boards/
BOARD ?= GENERIC_STM32_F303XC
# Cortex version
@@ -28,7 +27,7 @@ ifneq ($(findstring STM32F303, $(MCU)),)
USE_FPU = yes
# Vector table for application
- # 0x00000000-0x00001000 area is occupied by bootlaoder.*/
+ # 0x00000000-0x00001000 area is occupied by bootloader.*/
# The CORTEX_VTOR... is needed only for MCHCK/Infinity KB
# OPT_DEFS = -DCORTEX_VTOR_INIT=0x08005000
@@ -37,7 +36,7 @@ ifneq ($(findstring STM32F303, $(MCU)),)
DFU_SUFFIX_ARGS = -p DF11 -v 0483
endif
-ifneq (,$(filter $(MCU),atmega32u4 at90usb1286))
+ifneq (,$(filter $(MCU),atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb1286))
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
@@ -54,7 +53,7 @@ ifneq (,$(filter $(MCU),atmega32u4 at90usb1286))
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
- ARCH ?= AVR8
+ ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
@@ -68,4 +67,42 @@ ifneq (,$(filter $(MCU),atmega32u4 at90usb1286))
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB ?= $(F_CPU)
+
+ # Interrupt driven control endpoint task
+ ifeq (,$(filter $(NO_INTERRUPT_CONTROL_ENDPOINT),yes))
+ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+ endif
+endif
+
+ifneq (,$(filter $(MCU),atmega32a))
+ PROTOCOL = VUSB
+
+ # Processor frequency.
+ # This will define a symbol, F_CPU, in all source code files equal to the
+ # processor frequency in Hz. You can then use this symbol in your source code to
+ # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+ # automatically to create a 32-bit value in your source code.
+ F_CPU ?= 12000000
+
+ # unsupported features for now
+ NO_UART ?= yes
+ NO_SUSPEND_POWER_DOWN ?= yes
+
+ # Programming options
+ PROGRAM_CMD ?= ./util/atmega32a_program.py $(TARGET).hex
+endif
+
+ifneq (,$(filter $(MCU),atmega328p))
+ PROTOCOL = VUSB
+
+ # Processor frequency.
+ # This will define a symbol, F_CPU, in all source code files equal to the
+ # processor frequency in Hz. You can then use this symbol in your source code to
+ # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+ # automatically to create a 32-bit value in your source code.
+ F_CPU ?= 16000000
+
+ # unsupported features for now
+ NO_UART ?= yes
+ NO_SUSPEND_POWER_DOWN ?= yes
endif
diff --git a/quantum/pincontrol.h b/quantum/pincontrol.h
index d77977ebe2..204fddf30c 100644
--- a/quantum/pincontrol.h
+++ b/quantum/pincontrol.h
@@ -18,35 +18,33 @@
#include <avr/io.h>
enum {
- PinDirectionInput = 0,
- PinDirectionOutput = 1,
- PinLevelHigh = 1,
- PinLevelLow = 0,
+ PinDirectionInput = 0,
+ PinDirectionOutput = 1,
+ PinLevelHigh = 1,
+ PinLevelLow = 0,
};
// ex: pinMode(B0, PinDirectionOutput);
static inline void pinMode(uint8_t pin, int mode) {
- uint8_t bv = _BV(pin & 0xf);
- if (mode == PinDirectionOutput) {
- _SFR_IO8((pin >> 4) + 1) |= bv;
- } else {
- _SFR_IO8((pin >> 4) + 1) &= ~bv;
- _SFR_IO8((pin >> 4) + 2) &= ~bv;
- }
+ uint8_t bv = _BV(pin & 0xf);
+ if (mode == PinDirectionOutput) {
+ _SFR_IO8((pin >> 4) + 1) |= bv;
+ } else {
+ _SFR_IO8((pin >> 4) + 1) &= ~bv;
+ _SFR_IO8((pin >> 4) + 2) &= ~bv;
+ }
}
// ex: digitalWrite(B0, PinLevelHigh);
static inline void digitalWrite(uint8_t pin, int mode) {
- uint8_t bv = _BV(pin & 0xf);
- if (mode == PinLevelHigh) {
- _SFR_IO8((pin >> 4) + 2) |= bv;
- } else {
- _SFR_IO8((pin >> 4) + 2) &= ~bv;
- }
+ uint8_t bv = _BV(pin & 0xf);
+ if (mode == PinLevelHigh) {
+ _SFR_IO8((pin >> 4) + 2) |= bv;
+ } else {
+ _SFR_IO8((pin >> 4) + 2) &= ~bv;
+ }
}
// Return true if the pin is HIGH
// digitalRead(B0)
-static inline bool digitalRead(uint8_t pin) {
- return _SFR_IO8(pin >> 4) & _BV(pin & 0xf);
-}
+static inline bool digitalRead(uint8_t pin) { return _SFR_IO8(pin >> 4) & _BV(pin & 0xf); }
diff --git a/quantum/pointing_device.c b/quantum/pointing_device.c
index e60ae8d93e..24a487b9aa 100644
--- a/quantum/pointing_device.c
+++ b/quantum/pointing_device.c
@@ -25,38 +25,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static report_mouse_t mouseReport = {};
-__attribute__ ((weak))
-void pointing_device_init(void){
- //initialize device, if that needs to be done.
+__attribute__((weak)) void pointing_device_init(void) {
+ // initialize device, if that needs to be done.
}
-__attribute__ ((weak))
-void pointing_device_send(void){
- //If you need to do other things, like debugging, this is the place to do it.
+__attribute__((weak)) void pointing_device_send(void) {
+ // If you need to do other things, like debugging, this is the place to do it.
host_mouse_send(&mouseReport);
- //send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device
- mouseReport.x = 0;
- mouseReport.y = 0;
- mouseReport.v = 0;
- mouseReport.h = 0;
+ // send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device
+ mouseReport.x = 0;
+ mouseReport.y = 0;
+ mouseReport.v = 0;
+ mouseReport.h = 0;
}
-__attribute__ ((weak))
-void pointing_device_task(void){
- //gather info and put it in:
- //mouseReport.x = 127 max -127 min
- //mouseReport.y = 127 max -127 min
- //mouseReport.v = 127 max -127 min (scroll vertical)
- //mouseReport.h = 127 max -127 min (scroll horizontal)
- //mouseReport.buttons = 0x1F (decimal 31, binary 00011111) max (bitmask for mouse buttons 1-5, 1 is rightmost, 5 is leftmost) 0x00 min
- //send the report
+__attribute__((weak)) void pointing_device_task(void) {
+ // gather info and put it in:
+ // mouseReport.x = 127 max -127 min
+ // mouseReport.y = 127 max -127 min
+ // mouseReport.v = 127 max -127 min (scroll vertical)
+ // mouseReport.h = 127 max -127 min (scroll horizontal)
+ // mouseReport.buttons = 0x1F (decimal 31, binary 00011111) max (bitmask for mouse buttons 1-5, 1 is rightmost, 5 is leftmost) 0x00 min
+ // send the report
pointing_device_send();
}
-report_mouse_t pointing_device_get_report(void){
- return mouseReport;
-}
+report_mouse_t pointing_device_get_report(void) { return mouseReport; }
-void pointing_device_set_report(report_mouse_t newMouseReport){
- mouseReport = newMouseReport;
-} \ No newline at end of file
+void pointing_device_set_report(report_mouse_t newMouseReport) { mouseReport = newMouseReport; } \ No newline at end of file
diff --git a/quantum/pointing_device.h b/quantum/pointing_device.h
index 1944d82065..29398ebb3a 100644
--- a/quantum/pointing_device.h
+++ b/quantum/pointing_device.h
@@ -22,10 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "host.h"
#include "report.h"
-void pointing_device_init(void);
-void pointing_device_task(void);
-void pointing_device_send(void);
+void pointing_device_init(void);
+void pointing_device_task(void);
+void pointing_device_send(void);
report_mouse_t pointing_device_get_report(void);
-void pointing_device_set_report(report_mouse_t newMouseReport);
+void pointing_device_set_report(report_mouse_t newMouseReport);
#endif
diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c
index 0a25aa5354..3b5fa8490b 100644
--- a/quantum/process_keycode/process_audio.c
+++ b/quantum/process_keycode/process_audio.c
@@ -2,30 +2,28 @@
#include "process_audio.h"
#ifndef VOICE_CHANGE_SONG
- #define VOICE_CHANGE_SONG SONG(VOICE_CHANGE_SOUND)
+# define VOICE_CHANGE_SONG SONG(VOICE_CHANGE_SOUND)
#endif
float voice_change_song[][2] = VOICE_CHANGE_SONG;
#ifndef PITCH_STANDARD_A
- #define PITCH_STANDARD_A 440.0f
+# define PITCH_STANDARD_A 440.0f
#endif
-float compute_freq_for_midi_note(uint8_t note)
-{
+float compute_freq_for_midi_note(uint8_t note) {
// https://en.wikipedia.org/wiki/MIDI_tuning_standard
return pow(2.0, (note - 69) / 12.0) * PITCH_STANDARD_A;
}
bool process_audio(uint16_t keycode, keyrecord_t *record) {
-
if (keycode == AU_ON && record->event.pressed) {
- audio_on();
- return false;
+ audio_on();
+ return false;
}
if (keycode == AU_OFF && record->event.pressed) {
- audio_off();
- return false;
+ audio_off();
+ return false;
}
if (keycode == AU_TOG && record->event.pressed) {
@@ -52,17 +50,10 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
return true;
}
-void process_audio_noteon(uint8_t note) {
- play_note(compute_freq_for_midi_note(note), 0xF);
-}
+void process_audio_noteon(uint8_t note) { play_note(compute_freq_for_midi_note(note), 0xF); }
-void process_audio_noteoff(uint8_t note) {
- stop_note(compute_freq_for_midi_note(note));
-}
+void process_audio_noteoff(uint8_t note) { stop_note(compute_freq_for_midi_note(note)); }
-void process_audio_all_notes_off(void) {
- stop_all_notes();
-}
+void process_audio_all_notes_off(void) { stop_all_notes(); }
-__attribute__ ((weak))
-void audio_on_user() {}
+__attribute__((weak)) void audio_on_user() {}
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index 0d0930ee67..b474bda691 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -16,195 +16,125 @@
#ifdef AUTO_SHIFT_ENABLE
-#include <stdio.h>
+# include <stdio.h>
-#include "process_auto_shift.h"
+# include "process_auto_shift.h"
-#define TAP(key) \
- register_code(key); \
- unregister_code(key)
-
-#define TAP_WITH_MOD(mod, key) \
- register_code(mod); \
- register_code(key); \
- unregister_code(key); \
- unregister_code(mod)
-
-uint16_t autoshift_time = 0;
-uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
-uint16_t autoshift_lastkey = KC_NO;
+static bool autoshift_enabled = true;
+static uint16_t autoshift_time = 0;
+static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
+static uint16_t autoshift_lastkey = KC_NO;
void autoshift_timer_report(void) {
- char display[8];
+ char display[8];
- snprintf(display, 8, "\n%d\n", autoshift_timeout);
+ snprintf(display, 8, "\n%d\n", autoshift_timeout);
- send_string((const char *)display);
+ send_string((const char *)display);
}
void autoshift_on(uint16_t keycode) {
- autoshift_time = timer_read();
- autoshift_lastkey = keycode;
+ autoshift_time = timer_read();
+ autoshift_lastkey = keycode;
}
void autoshift_flush(void) {
- if (autoshift_lastkey != KC_NO) {
- uint16_t elapsed = timer_elapsed(autoshift_time);
-
- if (elapsed > autoshift_timeout) {
- register_code(KC_LSFT);
- }
+ if (autoshift_lastkey != KC_NO) {
+ uint16_t elapsed = timer_elapsed(autoshift_time);
- register_code(autoshift_lastkey);
- unregister_code(autoshift_lastkey);
+ if (elapsed > autoshift_timeout) {
+ tap_code16(LSFT(autoshift_lastkey));
+ } else {
+ tap_code(autoshift_lastkey);
+ }
- if (elapsed > autoshift_timeout) {
- unregister_code(KC_LSFT);
+ autoshift_time = 0;
+ autoshift_lastkey = KC_NO;
}
-
- autoshift_time = 0;
- autoshift_lastkey = KC_NO;
- }
}
-bool autoshift_enabled = true;
-
-void autoshift_enable(void) {
- autoshift_enabled = true;
-}
+void autoshift_enable(void) { autoshift_enabled = true; }
void autoshift_disable(void) {
- autoshift_enabled = false;
- autoshift_flush();
-}
-
-void autoshift_toggle(void) {
- if (autoshift_enabled) {
autoshift_enabled = false;
autoshift_flush();
- }
- else {
- autoshift_enabled = true;
- }
}
-bool autoshift_state(void) {
- return autoshift_enabled;
+void autoshift_toggle(void) {
+ if (autoshift_enabled) {
+ autoshift_enabled = false;
+ autoshift_flush();
+ } else {
+ autoshift_enabled = true;
+ }
}
-bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
-#ifndef AUTO_SHIFT_MODIFIERS
- static uint8_t any_mod_pressed;
-#endif
+bool get_autoshift_state(void) { return autoshift_enabled; }
- if (record->event.pressed) {
- switch (keycode) {
- case KC_ASUP:
- autoshift_timeout += 5;
- return false;
-
- case KC_ASDN:
- autoshift_timeout -= 5;
- return false;
-
- case KC_ASRP:
- autoshift_timer_report();
- return false;
-
- case KC_ASTG:
- autoshift_toggle();
- return false;
- case KC_ASON:
- autoshift_enable();
- return false;
- case KC_ASOFF:
- autoshift_disable();
- return false;
-
-#ifndef NO_AUTO_SHIFT_ALPHA
- case KC_A:
- case KC_B:
- case KC_C:
- case KC_D:
- case KC_E:
- case KC_F:
- case KC_G:
- case KC_H:
- case KC_I:
- case KC_J:
- case KC_K:
- case KC_L:
- case KC_M:
- case KC_N:
- case KC_O:
- case KC_P:
- case KC_Q:
- case KC_R:
- case KC_S:
- case KC_T:
- case KC_U:
- case KC_V:
- case KC_W:
- case KC_X:
- case KC_Y:
- case KC_Z:
-#endif
-#ifndef NO_AUTO_SHIFT_NUMERIC
- case KC_1:
- case KC_2:
- case KC_3:
- case KC_4:
- case KC_5:
- case KC_6:
- case KC_7:
- case KC_8:
- case KC_9:
- case KC_0:
-#endif
-#ifndef NO_AUTO_SHIFT_SPECIAL
- case KC_MINUS:
- case KC_EQL:
- case KC_TAB:
- case KC_LBRC:
- case KC_RBRC:
- case KC_BSLS:
- case KC_SCLN:
- case KC_QUOT:
- case KC_COMM:
- case KC_DOT:
- case KC_SLSH:
- case KC_GRAVE:
- case KC_NONUS_BSLASH:
- case KC_NONUS_HASH:
-#endif
+uint16_t get_autoshift_timeout(void) { return autoshift_timeout; }
- autoshift_flush();
- if (!autoshift_enabled) return true;
-
-#ifndef AUTO_SHIFT_MODIFIERS
- any_mod_pressed = get_mods() & (
- MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)|
- MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT)|
- MOD_BIT(KC_LCTL)|MOD_BIT(KC_RCTL)|
- MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)
- );
-
- if (any_mod_pressed) {
- return true;
- }
-#endif
-
- autoshift_on(keycode);
- return false;
+void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; }
- default:
+bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
+ if (record->event.pressed) {
+ switch (keycode) {
+ case KC_ASUP:
+ autoshift_timeout += 5;
+ return true;
+
+ case KC_ASDN:
+ autoshift_timeout -= 5;
+ return true;
+
+ case KC_ASRP:
+ autoshift_timer_report();
+ return true;
+
+ case KC_ASTG:
+ autoshift_toggle();
+ return true;
+ case KC_ASON:
+ autoshift_enable();
+ return true;
+ case KC_ASOFF:
+ autoshift_disable();
+ return true;
+
+# ifndef NO_AUTO_SHIFT_ALPHA
+ case KC_A ... KC_Z:
+# endif
+# ifndef NO_AUTO_SHIFT_NUMERIC
+ case KC_1 ... KC_0:
+# endif
+# ifndef NO_AUTO_SHIFT_SPECIAL
+ case KC_TAB:
+ case KC_MINUS ... KC_SLASH:
+ case KC_NONUS_BSLASH:
+# endif
+ autoshift_flush();
+ if (!autoshift_enabled) return true;
+
+# ifndef AUTO_SHIFT_MODIFIERS
+ if (get_mods()) {
+ return true;
+ }
+# endif
+ autoshift_on(keycode);
+
+ // We need some extra handling here for OSL edge cases
+# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
+ clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
+# endif
+ return false;
+
+ default:
+ autoshift_flush();
+ return true;
+ }
+ } else {
autoshift_flush();
- return true;
}
- } else {
- autoshift_flush();
- }
- return true;
+ return true;
}
#endif
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index a4abf04145..e86c4658e9 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -14,20 +14,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PROCESS_AUTO_SHIFT_H
-#define PROCESS_AUTO_SHIFT_H
+#pragma once
#include "quantum.h"
#ifndef AUTO_SHIFT_TIMEOUT
- #define AUTO_SHIFT_TIMEOUT 175
+# define AUTO_SHIFT_TIMEOUT 175
#endif
bool process_auto_shift(uint16_t keycode, keyrecord_t *record);
-void autoshift_enable(void);
-void autoshift_disable(void);
-void autoshift_toggle(void);
-bool autoshift_state(void);
-
-#endif
+void autoshift_enable(void);
+void autoshift_disable(void);
+void autoshift_toggle(void);
+bool get_autoshift_state(void);
+uint16_t get_autoshift_timeout(void);
+void set_autoshift_timeout(uint16_t timeout);
diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c
index 43b803afe7..6ab382d4aa 100644
--- a/quantum/process_keycode/process_clicky.c
+++ b/quantum/process_keycode/process_clicky.c
@@ -3,104 +3,111 @@
#ifdef AUDIO_CLICKY
-#ifndef AUDIO_CLICKY_DELAY_DURATION
-#define AUDIO_CLICKY_DELAY_DURATION 1
-#endif // !AUDIO_CLICKY_DELAY_DURATION
-#ifndef AUDIO_CLICKY_FREQ_DEFAULT
-#define AUDIO_CLICKY_FREQ_DEFAULT 440.0f
-#endif // !AUDIO_CLICKY_FREQ_DEFAULT
-#ifndef AUDIO_CLICKY_FREQ_MIN
-#define AUDIO_CLICKY_FREQ_MIN 65.0f
-#endif // !AUDIO_CLICKY_FREQ_MIN
-#ifndef AUDIO_CLICKY_FREQ_MAX
-#define AUDIO_CLICKY_FREQ_MAX 1500.0f
-#endif // !AUDIO_CLICKY_FREQ_MAX
-#ifndef AUDIO_CLICKY_FREQ_FACTOR
-#define AUDIO_CLICKY_FREQ_FACTOR 1.18921f
-#endif // !AUDIO_CLICKY_FREQ_FACTOR
-#ifndef AUDIO_CLICKY_FREQ_RANDOMNESS
-#define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f
-#endif // !AUDIO_CLICKY_FREQ_RANDOMNESS
+# ifndef AUDIO_CLICKY_DELAY_DURATION
+# define AUDIO_CLICKY_DELAY_DURATION 1
+# endif // !AUDIO_CLICKY_DELAY_DURATION
+# ifndef AUDIO_CLICKY_FREQ_DEFAULT
+# define AUDIO_CLICKY_FREQ_DEFAULT 440.0f
+# endif // !AUDIO_CLICKY_FREQ_DEFAULT
+# ifndef AUDIO_CLICKY_FREQ_MIN
+# define AUDIO_CLICKY_FREQ_MIN 65.0f
+# endif // !AUDIO_CLICKY_FREQ_MIN
+# ifndef AUDIO_CLICKY_FREQ_MAX
+# define AUDIO_CLICKY_FREQ_MAX 1500.0f
+# endif // !AUDIO_CLICKY_FREQ_MAX
+# ifndef AUDIO_CLICKY_FREQ_FACTOR
+# define AUDIO_CLICKY_FREQ_FACTOR 1.18921f
+# endif // !AUDIO_CLICKY_FREQ_FACTOR
+# ifndef AUDIO_CLICKY_FREQ_RANDOMNESS
+# define AUDIO_CLICKY_FREQ_RANDOMNESS 0.05f
+# endif // !AUDIO_CLICKY_FREQ_RANDOMNESS
float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS;
// the first "note" is an intentional delay; the 2nd and 3rd notes are the "clicky"
-float 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
+float 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
extern audio_config_t audio_config;
-#ifndef NO_MUSIC_MODE
+# ifndef NO_MUSIC_MODE
extern bool music_activated;
extern bool midi_activated;
-#endif // !NO_MUSIC_MODE
+# endif // !NO_MUSIC_MODE
void clicky_play(void) {
-#ifndef NO_MUSIC_MODE
- if (music_activated || midi_activated || !audio_config.enable) return;
-#endif // !NO_MUSIC_MODE
- clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
- clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
- PLAY_SONG(clicky_song);
+# ifndef NO_MUSIC_MODE
+ if (music_activated || midi_activated || !audio_config.enable) return;
+# endif // !NO_MUSIC_MODE
+ clicky_song[1][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX))));
+ clicky_song[2][0] = clicky_freq * (1.0f + clicky_rand * (((float)rand()) / ((float)(RAND_MAX))));
+ PLAY_SONG(clicky_song);
}
void clicky_freq_up(void) {
- float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR;
- if (new_freq < AUDIO_CLICKY_FREQ_MAX) {
- clicky_freq = new_freq;
- }
+ float new_freq = clicky_freq * AUDIO_CLICKY_FREQ_FACTOR;
+ if (new_freq < AUDIO_CLICKY_FREQ_MAX) {
+ clicky_freq = new_freq;
+ }
}
void clicky_freq_down(void) {
- float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR;
- if (new_freq > AUDIO_CLICKY_FREQ_MIN) {
- clicky_freq = new_freq;
- }
+ float new_freq = clicky_freq / AUDIO_CLICKY_FREQ_FACTOR;
+ if (new_freq > AUDIO_CLICKY_FREQ_MIN) {
+ clicky_freq = new_freq;
+ }
}
-void clicky_freq_reset(void) {
- clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
-}
+void clicky_freq_reset(void) { clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT; }
void clicky_toggle(void) {
- audio_config.clicky_enable ^= 1;
- eeconfig_update_audio(audio_config.raw);
+ audio_config.clicky_enable ^= 1;
+ eeconfig_update_audio(audio_config.raw);
}
void clicky_on(void) {
- audio_config.clicky_enable = 1;
- eeconfig_update_audio(audio_config.raw);
+ audio_config.clicky_enable = 1;
+ eeconfig_update_audio(audio_config.raw);
}
void clicky_off(void) {
- audio_config.clicky_enable = 0;
- eeconfig_update_audio(audio_config.raw);
+ audio_config.clicky_enable = 0;
+ eeconfig_update_audio(audio_config.raw);
}
-bool is_clicky_on(void) {
- return (audio_config.clicky_enable != 0);
-}
+bool is_clicky_on(void) { return (audio_config.clicky_enable != 0); }
bool process_clicky(uint16_t keycode, keyrecord_t *record) {
- if (keycode == CLICKY_TOGGLE && record->event.pressed) { clicky_toggle(); }
-
- if (keycode == CLICKY_ENABLE && record->event.pressed) { clicky_on(); }
- if (keycode == CLICKY_DISABLE && record->event.pressed) { clicky_off(); }
+ if (keycode == CLICKY_TOGGLE && record->event.pressed) {
+ clicky_toggle();
+ }
- if (keycode == CLICKY_RESET && record->event.pressed) { clicky_freq_reset(); }
+ if (keycode == CLICKY_ENABLE && record->event.pressed) {
+ clicky_on();
+ }
+ if (keycode == CLICKY_DISABLE && record->event.pressed) {
+ clicky_off();
+ }
- if (keycode == CLICKY_UP && record->event.pressed) { clicky_freq_up(); }
- if (keycode == CLICKY_DOWN && record->event.pressed) { clicky_freq_down(); }
+ if (keycode == CLICKY_RESET && record->event.pressed) {
+ clicky_freq_reset();
+ }
+ if (keycode == CLICKY_UP && record->event.pressed) {
+ clicky_freq_up();
+ }
+ if (keycode == CLICKY_DOWN && record->event.pressed) {
+ clicky_freq_down();
+ }
- if (audio_config.enable && audio_config.clicky_enable) {
- if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound
- if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM
- clicky_play();
- }
+ if (audio_config.enable && audio_config.clicky_enable) {
+ if (record->event.pressed) { // Leave this separate so it's easier to add upstroke sound
+ if (keycode != AU_OFF && keycode != AU_TOG) { // DO NOT PLAY if audio will be disabled, and causes issuse on ARM
+ clicky_play();
+ }
+ }
}
- }
- return true;
+ return true;
}
-#endif //AUDIO_CLICKY
+#endif // AUDIO_CLICKY
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 2c6c9d0d5f..f40ca74525 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -21,13 +21,13 @@ __attribute__((weak)) combo_t key_combos[COMBO_COUNT] = {
};
-__attribute__((weak)) void process_combo_event(uint8_t combo_index,
- bool pressed) {}
+__attribute__((weak)) void process_combo_event(uint8_t combo_index, bool pressed) {}
-static uint16_t timer = 0;
-static uint8_t current_combo_index = 0;
-static bool drop_buffer = false;
-static bool is_active = false;
+static uint16_t timer = 0;
+static uint8_t current_combo_index = 0;
+static bool drop_buffer = false;
+static bool is_active = false;
+static bool b_combo_enable = true; // defaults to enabled
static uint8_t buffer_size = 0;
#ifdef COMBO_ALLOW_ACTION_KEYS
@@ -37,141 +37,171 @@ static uint16_t key_buffer[MAX_COMBO_LENGTH];
#endif
static inline void send_combo(uint16_t action, bool pressed) {
- if (action) {
- if (pressed) {
- register_code16(action);
+ if (action) {
+ if (pressed) {
+ register_code16(action);
+ } else {
+ unregister_code16(action);
+ }
} else {
- unregister_code16(action);
+ process_combo_event(current_combo_index, pressed);
}
- } else {
- process_combo_event(current_combo_index, pressed);
- }
}
static inline void dump_key_buffer(bool emit) {
- if (buffer_size == 0) {
- return;
- }
+ if (buffer_size == 0) {
+ return;
+ }
- if (emit) {
- for (uint8_t i = 0; i < buffer_size; i++) {
+ if (emit) {
+ for (uint8_t i = 0; i < buffer_size; i++) {
#ifdef COMBO_ALLOW_ACTION_KEYS
- const action_t action = store_or_get_action(key_buffer[i].event.pressed,
- key_buffer[i].event.key);
- process_action(&(key_buffer[i]), action);
+ const action_t action = store_or_get_action(key_buffer[i].event.pressed, key_buffer[i].event.key);
+ process_action(&(key_buffer[i]), action);
#else
- register_code16(key_buffer[i]);
- send_keyboard_report();
+ register_code16(key_buffer[i]);
+ send_keyboard_report();
#endif
+ }
}
- }
- buffer_size = 0;
+ buffer_size = 0;
}
#define ALL_COMBO_KEYS_ARE_DOWN (((1 << count) - 1) == combo->state)
-#define KEY_STATE_DOWN(key) \
- do { \
- combo->state |= (1 << key); \
- } while (0)
-#define KEY_STATE_UP(key) \
- do { \
- combo->state &= ~(1 << key); \
- } while (0)
-
-static bool process_single_combo(combo_t *combo, uint16_t keycode,
- keyrecord_t *record) {
- uint8_t count = 0;
- uint8_t index = -1;
- /* Find index of keycode and number of combo keys */
- for (const uint16_t *keys = combo->keys;; ++count) {
- uint16_t key = pgm_read_word(&keys[count]);
- if (keycode == key)
- index = count;
- if (COMBO_END == key)
- break;
- }
-
- /* Continue processing if not a combo key */
- if (-1 == (int8_t)index)
- return false;
-
- bool is_combo_active = is_active;
-
- if (record->event.pressed) {
- KEY_STATE_DOWN(index);
-
- if (is_combo_active) {
- if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */
- send_combo(combo->keycode, true);
- drop_buffer = true;
- }
+#define KEY_STATE_DOWN(key) \
+ do { \
+ combo->state |= (1 << key); \
+ } while (0)
+#define KEY_STATE_UP(key) \
+ do { \
+ combo->state &= ~(1 << key); \
+ } while (0)
+
+static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record) {
+ uint8_t count = 0;
+ uint8_t index = -1;
+ /* Find index of keycode and number of combo keys */
+ for (const uint16_t *keys = combo->keys;; ++count) {
+ uint16_t key = pgm_read_word(&keys[count]);
+ if (keycode == key) index = count;
+ if (COMBO_END == key) break;
}
- } else {
- if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was released */
- send_combo(combo->keycode, false);
+
+ /* Continue processing if not a combo key */
+ if (-1 == (int8_t)index) return false;
+
+ bool is_combo_active = is_active;
+
+ if (record->event.pressed) {
+ KEY_STATE_DOWN(index);
+
+ if (is_combo_active) {
+ if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */
+ send_combo(combo->keycode, true);
+ drop_buffer = true;
+ }
+ }
} else {
- /* continue processing without immediately returning */
- is_combo_active = false;
+ if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was released */
+ send_combo(combo->keycode, false);
+ } else {
+ /* continue processing without immediately returning */
+ is_combo_active = false;
+ }
+
+ KEY_STATE_UP(index);
}
- KEY_STATE_UP(index);
- }
-
- return is_combo_active;
+ return is_combo_active;
}
#define NO_COMBO_KEYS_ARE_DOWN (0 == combo->state)
bool process_combo(uint16_t keycode, keyrecord_t *record) {
- bool is_combo_key = false;
- drop_buffer = false;
- bool no_combo_keys_pressed = true;
-
- for (current_combo_index = 0; current_combo_index < COMBO_COUNT;
- ++current_combo_index) {
- combo_t *combo = &key_combos[current_combo_index];
- is_combo_key |= process_single_combo(combo, keycode, record);
- no_combo_keys_pressed = no_combo_keys_pressed && NO_COMBO_KEYS_ARE_DOWN;
- }
-
- if (drop_buffer) {
- /* buffer is only dropped when we complete a combo, so we refresh the timer
- * here */
- timer = timer_read();
- dump_key_buffer(false);
- } else if (!is_combo_key) {
- /* if no combos claim the key we need to emit the keybuffer */
- dump_key_buffer(true);
+ bool is_combo_key = false;
+ drop_buffer = false;
+ bool no_combo_keys_pressed = true;
+
+ if (keycode == CMB_ON && record->event.pressed) {
+ combo_enable();
+ return true;
+ }
- // reset state if there are no combo keys pressed at all
- if (no_combo_keys_pressed) {
- timer = 0;
- is_active = true;
+ if (keycode == CMB_OFF && record->event.pressed) {
+ combo_disable();
+ return true;
}
- } else if (record->event.pressed && is_active) {
- /* otherwise the key is consumed and placed in the buffer */
- timer = timer_read();
- if (buffer_size < MAX_COMBO_LENGTH) {
+ if (keycode == CMB_TOG && record->event.pressed) {
+ combo_toggle();
+ return true;
+ }
+
+ if (!is_combo_enabled()) {
+ return true;
+ }
+
+ for (current_combo_index = 0; current_combo_index < COMBO_COUNT; ++current_combo_index) {
+ combo_t *combo = &key_combos[current_combo_index];
+ is_combo_key |= process_single_combo(combo, keycode, record);
+ no_combo_keys_pressed = no_combo_keys_pressed && NO_COMBO_KEYS_ARE_DOWN;
+ }
+
+ if (drop_buffer) {
+ /* buffer is only dropped when we complete a combo, so we refresh the timer
+ * here */
+ timer = timer_read();
+ dump_key_buffer(false);
+ } else if (!is_combo_key) {
+ /* if no combos claim the key we need to emit the keybuffer */
+ dump_key_buffer(true);
+
+ // reset state if there are no combo keys pressed at all
+ if (no_combo_keys_pressed) {
+ timer = 0;
+ is_active = true;
+ }
+ } else if (record->event.pressed && is_active) {
+ /* otherwise the key is consumed and placed in the buffer */
+ timer = timer_read();
+
+ if (buffer_size < MAX_COMBO_LENGTH) {
#ifdef COMBO_ALLOW_ACTION_KEYS
- key_buffer[buffer_size++] = *record;
+ key_buffer[buffer_size++] = *record;
#else
- key_buffer[buffer_size++] = keycode;
+ key_buffer[buffer_size++] = keycode;
#endif
+ }
}
- }
- return !is_combo_key;
+ return !is_combo_key;
}
void matrix_scan_combo(void) {
- if (is_active && timer && timer_elapsed(timer) > COMBO_TERM) {
+ if (b_combo_enable && is_active && timer && timer_elapsed(timer) > COMBO_TERM) {
+ /* This disables the combo, meaning key events for this
+ * combo will be handled by the next processors in the chain
+ */
+ is_active = false;
+ dump_key_buffer(true);
+ }
+}
+
+void combo_enable(void) { b_combo_enable = true; }
- /* This disables the combo, meaning key events for this
- * combo will be handled by the next processors in the chain
- */
- is_active = false;
+void combo_disable(void) {
+ b_combo_enable = is_active = false;
+ timer = 0;
dump_key_buffer(true);
- }
}
+
+void combo_toggle(void) {
+ if (b_combo_enable) {
+ combo_disable();
+ } else {
+ combo_enable();
+ }
+}
+
+bool is_combo_enabled(void) { return b_combo_enable; }
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index f06d2d3454..e21ee19609 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -22,40 +22,45 @@
#include <stdint.h>
#ifdef EXTRA_EXTRA_LONG_COMBOS
-#define MAX_COMBO_LENGTH 32
+# define MAX_COMBO_LENGTH 32
#elif EXTRA_LONG_COMBOS
-#define MAX_COMBO_LENGTH 16
+# define MAX_COMBO_LENGTH 16
#else
-#define MAX_COMBO_LENGTH 8
+# define MAX_COMBO_LENGTH 8
#endif
typedef struct {
- const uint16_t *keys;
- uint16_t keycode;
+ const uint16_t *keys;
+ uint16_t keycode;
#ifdef EXTRA_EXTRA_LONG_COMBOS
- uint32_t state;
+ uint32_t state;
#elif EXTRA_LONG_COMBOS
- uint16_t state;
+ uint16_t state;
#else
- uint8_t state;
+ uint8_t state;
#endif
} combo_t;
-#define COMBO(ck, ca) \
- { .keys = &(ck)[0], .keycode = (ca) }
-#define COMBO_ACTION(ck) \
- { .keys = &(ck)[0] }
+#define COMBO(ck, ca) \
+ { .keys = &(ck)[0], .keycode = (ca) }
+#define COMBO_ACTION(ck) \
+ { .keys = &(ck)[0] }
#define COMBO_END 0
#ifndef COMBO_COUNT
-#define COMBO_COUNT 0
+# define COMBO_COUNT 0
#endif
#ifndef COMBO_TERM
-#define COMBO_TERM TAPPING_TERM
+# define COMBO_TERM TAPPING_TERM
#endif
bool process_combo(uint16_t keycode, keyrecord_t *record);
void matrix_scan_combo(void);
void process_combo_event(uint8_t combo_index, bool pressed);
+void combo_enable(void);
+void combo_disable(void);
+void combo_toggle(void);
+bool is_combo_enabled(void);
+
#endif
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c
new file mode 100644
index 0000000000..2065f242db
--- /dev/null
+++ b/quantum/process_keycode/process_dynamic_macro.c
@@ -0,0 +1,257 @@
+/* Copyright 2016 Jack Humbert
+ * Copyright 2019 Drashna Jael're (@drashna, aka Christopher Courtney)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */
+#include "process_dynamic_macro.h"
+
+// default feedback method
+void dynamic_macro_led_blink(void) {
+#ifdef BACKLIGHT_ENABLE
+ backlight_toggle();
+ wait_ms(100);
+ backlight_toggle();
+#endif
+}
+
+/* User hooks for Dynamic Macros */
+
+__attribute__((weak)) void dynamic_macro_record_start_user(void) { dynamic_macro_led_blink(); }
+
+__attribute__((weak)) void dynamic_macro_play_user(int8_t direction) { dynamic_macro_led_blink(); }
+
+__attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) { dynamic_macro_led_blink(); }
+
+__attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) { dynamic_macro_led_blink(); }
+
+/* Convenience macros used for retrieving the debug info. All of them
+ * need a `direction` variable accessible at the call site.
+ */
+#define DYNAMIC_MACRO_CURRENT_SLOT() (direction > 0 ? 1 : 2)
+#define DYNAMIC_MACRO_CURRENT_LENGTH(BEGIN, POINTER) ((int)(direction * ((POINTER) - (BEGIN))))
+#define DYNAMIC_MACRO_CURRENT_CAPACITY(BEGIN, END2) ((int)(direction * ((END2) - (BEGIN)) + 1))
+
+/**
+ * Start recording of the dynamic macro.
+ *
+ * @param[out] macro_pointer The new macro buffer iterator.
+ * @param[in] macro_buffer The macro buffer used to initialize macro_pointer.
+ */
+void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer) {
+ dprintln("dynamic macro recording: started");
+
+ dynamic_macro_record_start_user();
+
+ clear_keyboard();
+ layer_clear();
+ *macro_pointer = macro_buffer;
+}
+
+/**
+ * Play the dynamic macro.
+ *
+ * @param macro_buffer[in] The beginning of the macro buffer being played.
+ * @param macro_end[in] The element after the last macro buffer element.
+ * @param direction[in] Either +1 or -1, which way to iterate the buffer.
+ */
+void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_t direction) {
+ dprintf("dynamic macro: slot %d playback\n", DYNAMIC_MACRO_CURRENT_SLOT());
+
+ layer_state_t saved_layer_state = layer_state;
+
+ clear_keyboard();
+ layer_clear();
+
+ while (macro_buffer != macro_end) {
+ process_record(macro_buffer);
+ macro_buffer += direction;
+ }
+
+ clear_keyboard();
+
+ layer_state = saved_layer_state;
+
+ dynamic_macro_play_user(direction);
+}
+
+/**
+ * Record a single key in a dynamic macro.
+ *
+ * @param macro_buffer[in] The start of the used macro buffer.
+ * @param macro_pointer[in,out] The current buffer position.
+ * @param macro2_end[in] The end of the other macro.
+ * @param direction[in] Either +1 or -1, which way to iterate the buffer.
+ * @param record[in] The current keypress.
+ */
+void dynamic_macro_record_key(keyrecord_t *macro_buffer, keyrecord_t **macro_pointer, keyrecord_t *macro2_end, int8_t direction, keyrecord_t *record) {
+ /* If we've just started recording, ignore all the key releases. */
+ if (!record->event.pressed && *macro_pointer == macro_buffer) {
+ dprintln("dynamic macro: ignoring a leading key-up event");
+ return;
+ }
+
+ /* The other end of the other macro is the last buffer element it
+ * is safe to use before overwriting the other macro.
+ */
+ if (*macro_pointer - direction != macro2_end) {
+ **macro_pointer = *record;
+ *macro_pointer += direction;
+ } else {
+ dynamic_macro_record_key_user(direction, record);
+ }
+
+ dprintf("dynamic macro: slot %d length: %d/%d\n", DYNAMIC_MACRO_CURRENT_SLOT(), DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, *macro_pointer), DYNAMIC_MACRO_CURRENT_CAPACITY(macro_buffer, macro2_end));
+}
+
+/**
+ * End recording of the dynamic macro. Essentially just update the
+ * pointer to the end of the macro.
+ */
+void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_pointer, int8_t direction, keyrecord_t **macro_end) {
+ dynamic_macro_record_end_user(direction);
+
+ /* Do not save the keys being held when stopping the recording,
+ * i.e. the keys used to access the layer DYN_REC_STOP is on.
+ */
+ while (macro_pointer != macro_buffer && (macro_pointer - direction)->event.pressed) {
+ dprintln("dynamic macro: trimming a trailing key-down event");
+ macro_pointer -= direction;
+ }
+
+ dprintf("dynamic macro: slot %d saved, length: %d\n", DYNAMIC_MACRO_CURRENT_SLOT(), DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, macro_pointer));
+
+ *macro_end = macro_pointer;
+}
+
+/* Handle the key events related to the dynamic macros. Should be
+ * called from process_record_user() like this:
+ *
+ * bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ * if (!process_record_dynamic_macro(keycode, record)) {
+ * return false;
+ * }
+ * <...THE REST OF THE FUNCTION...>
+ * }
+ */
+bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
+ /* Both macros use the same buffer but read/write on different
+ * ends of it.
+ *
+ * Macro1 is written left-to-right starting from the beginning of
+ * the buffer.
+ *
+ * Macro2 is written right-to-left starting from the end of the
+ * buffer.
+ *
+ * &macro_buffer macro_end
+ * v v
+ * +------------------------------------------------------------+
+ * |>>>>>> MACRO1 >>>>>> <<<<<<<<<<<<< MACRO2 <<<<<<<<<<<<<|
+ * +------------------------------------------------------------+
+ * ^ ^
+ * r_macro_end r_macro_buffer
+ *
+ * During the recording when one macro encounters the end of the
+ * other macro, the recording is stopped. Apart from this, there
+ * are no arbitrary limits for the macros' length in relation to
+ * each other: for example one can either have two medium sized
+ * macros or one long macro and one short macro. Or even one empty
+ * and one using the whole buffer.
+ */
+ static keyrecord_t macro_buffer[DYNAMIC_MACRO_SIZE];
+
+ /* Pointer to the first buffer element after the first macro.
+ * Initially points to the very beginning of the buffer since the
+ * macro is empty. */
+ static keyrecord_t *macro_end = macro_buffer;
+
+ /* The other end of the macro buffer. Serves as the beginning of
+ * the second macro. */
+ static keyrecord_t *const r_macro_buffer = macro_buffer + DYNAMIC_MACRO_SIZE - 1;
+
+ /* Like macro_end but for the second macro. */
+ static keyrecord_t *r_macro_end = r_macro_buffer;
+
+ /* A persistent pointer to the current macro position (iterator)
+ * used during the recording. */
+ static keyrecord_t *macro_pointer = NULL;
+
+ /* 0 - no macro is being recorded right now
+ * 1,2 - either macro 1 or 2 is being recorded */
+ static uint8_t macro_id = 0;
+
+ if (macro_id == 0) {
+ /* No macro recording in progress. */
+ if (!record->event.pressed) {
+ switch (keycode) {
+ case DYN_REC_START1:
+ dynamic_macro_record_start(&macro_pointer, macro_buffer);
+ macro_id = 1;
+ return false;
+ case DYN_REC_START2:
+ dynamic_macro_record_start(&macro_pointer, r_macro_buffer);
+ macro_id = 2;
+ return false;
+ case DYN_MACRO_PLAY1:
+ dynamic_macro_play(macro_buffer, macro_end, +1);
+ return false;
+ case DYN_MACRO_PLAY2:
+ dynamic_macro_play(r_macro_buffer, r_macro_end, -1);
+ return false;
+ }
+ }
+ } else {
+ /* A macro is being recorded right now. */
+ switch (keycode) {
+ case DYN_REC_STOP:
+ /* Stop the macro recording. */
+ if (record->event.pressed) { /* Ignore the initial release
+ * just after the recoding
+ * starts. */
+ switch (macro_id) {
+ case 1:
+ dynamic_macro_record_end(macro_buffer, macro_pointer, +1, &macro_end);
+ break;
+ case 2:
+ dynamic_macro_record_end(r_macro_buffer, macro_pointer, -1, &r_macro_end);
+ break;
+ }
+ macro_id = 0;
+ }
+ return false;
+#ifdef DYNAMIC_MACRO_NO_NESTING
+ case DYN_MACRO_PLAY1:
+ case DYN_MACRO_PLAY2:
+ dprintln("dynamic macro: ignoring macro play key while recording");
+ return false;
+#endif
+ default:
+ /* Store the key in the macro buffer and process it normally. */
+ switch (macro_id) {
+ case 1:
+ dynamic_macro_record_key(macro_buffer, &macro_pointer, r_macro_end, +1, record);
+ break;
+ case 2:
+ dynamic_macro_record_key(r_macro_buffer, &macro_pointer, macro_end, -1, record);
+ break;
+ }
+ return true;
+ break;
+ }
+ }
+
+ return true;
+}
diff --git a/quantum/process_keycode/process_dynamic_macro.h b/quantum/process_keycode/process_dynamic_macro.h
new file mode 100644
index 0000000000..39036541b8
--- /dev/null
+++ b/quantum/process_keycode/process_dynamic_macro.h
@@ -0,0 +1,41 @@
+/* Copyright 2016 Jack Humbert
+ * Copyright 2019 Drashna Jael're (@drashna, aka Christopher Courtney)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */
+#pragma once
+
+#include "quantum.h"
+
+/* May be overridden with a custom value. Be aware that the effective
+ * macro length is half of this value: each keypress is recorded twice
+ * because of the down-event and up-event. This is not a bug, it's the
+ * intended behavior.
+ *
+ * Usually it should be fine to set the macro size to at least 256 but
+ * there have been reports of it being too much in some users' cases,
+ * so 128 is considered a safe default.
+ */
+#ifndef DYNAMIC_MACRO_SIZE
+# define DYNAMIC_MACRO_SIZE 128
+#endif
+
+void dynamic_macro_led_blink(void);
+bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record);
+void dynamic_macro_record_start_user(void);
+void dynamic_macro_play_user(int8_t direction);
+void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record);
+void dynamic_macro_record_end_user(int8_t direction);
diff --git a/quantum/process_keycode/process_key_lock.c b/quantum/process_keycode/process_key_lock.c
index 50cc0a5ccb..602127a74b 100644
--- a/quantum/process_keycode/process_key_lock.c
+++ b/quantum/process_keycode/process_key_lock.c
@@ -19,36 +19,33 @@
#include "process_key_lock.h"
#define BV_64(shift) (((uint64_t)1) << (shift))
-#define GET_KEY_ARRAY(code) (((code) < 0x40) ? key_state[0] : \
- ((code) < 0x80) ? key_state[1] : \
- ((code) < 0xC0) ? key_state[2] : key_state[3])
-#define GET_CODE_INDEX(code) (((code) < 0x40) ? (code) : \
- ((code) < 0x80) ? (code) - 0x40 : \
- ((code) < 0xC0) ? (code) - 0x80 : (code) - 0xC0)
-#define KEY_STATE(code) (GET_KEY_ARRAY(code) & BV_64(GET_CODE_INDEX(code))) == BV_64(GET_CODE_INDEX(code))
-#define SET_KEY_ARRAY_STATE(code, val) do { \
- switch (code) { \
- case 0x00 ... 0x3F: \
- key_state[0] = (val); \
- break; \
- case 0x40 ... 0x7F: \
- key_state[1] = (val); \
- break; \
- case 0x80 ... 0xBF: \
- key_state[2] = (val); \
- break; \
- case 0xC0 ... 0xFF: \
- key_state[3] = (val); \
- break; \
- } \
-} while(0)
+#define GET_KEY_ARRAY(code) (((code) < 0x40) ? key_state[0] : ((code) < 0x80) ? key_state[1] : ((code) < 0xC0) ? key_state[2] : key_state[3])
+#define GET_CODE_INDEX(code) (((code) < 0x40) ? (code) : ((code) < 0x80) ? (code)-0x40 : ((code) < 0xC0) ? (code)-0x80 : (code)-0xC0)
+#define KEY_STATE(code) (GET_KEY_ARRAY(code) & BV_64(GET_CODE_INDEX(code))) == BV_64(GET_CODE_INDEX(code))
+#define SET_KEY_ARRAY_STATE(code, val) \
+ do { \
+ switch (code) { \
+ case 0x00 ... 0x3F: \
+ key_state[0] = (val); \
+ break; \
+ case 0x40 ... 0x7F: \
+ key_state[1] = (val); \
+ break; \
+ case 0x80 ... 0xBF: \
+ key_state[2] = (val); \
+ break; \
+ case 0xC0 ... 0xFF: \
+ key_state[3] = (val); \
+ break; \
+ } \
+ } while (0)
#define SET_KEY_STATE(code) SET_KEY_ARRAY_STATE(code, (GET_KEY_ARRAY(code) | BV_64(GET_CODE_INDEX(code))))
#define UNSET_KEY_STATE(code) SET_KEY_ARRAY_STATE(code, (GET_KEY_ARRAY(code)) & ~(BV_64(GET_CODE_INDEX(code))))
#define IS_STANDARD_KEYCODE(code) ((code) <= 0xFF)
// Locked key state. This is an array of 256 bits, one for each of the standard keys supported qmk.
-uint64_t key_state[4] = { 0x0, 0x0, 0x0, 0x0 };
-bool watching = false;
+uint64_t key_state[4] = {0x0, 0x0, 0x0, 0x0};
+bool watching = false;
// Translate any OSM keycodes back to their unmasked versions.
static inline uint16_t translate_keycode(uint16_t keycode) {
@@ -135,4 +132,3 @@ bool process_key_lock(uint16_t *keycode, keyrecord_t *record) {
return !(IS_STANDARD_KEYCODE(translated_keycode) && KEY_STATE(translated_keycode));
}
}
-
diff --git a/quantum/process_keycode/process_key_lock.h b/quantum/process_keycode/process_key_lock.h
index 876db4a324..a8e110a4bf 100644
--- a/quantum/process_keycode/process_key_lock.h
+++ b/quantum/process_keycode/process_key_lock.h
@@ -21,4 +21,4 @@
bool process_key_lock(uint16_t *keycode, keyrecord_t *record);
-#endif // PROCESS_KEY_LOCK_H
+#endif // PROCESS_KEY_LOCK_H
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index 897e9eabf6..58a615d85a 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -16,62 +16,64 @@
#ifdef LEADER_ENABLE
-#include "process_leader.h"
+# include "process_leader.h"
+# include <string.h>
-#ifndef LEADER_TIMEOUT
- #define LEADER_TIMEOUT 300
-#endif
+# ifndef LEADER_TIMEOUT
+# define LEADER_TIMEOUT 300
+# endif
-__attribute__ ((weak))
-void leader_start(void) {}
+__attribute__((weak)) void leader_start(void) {}
-__attribute__ ((weak))
-void leader_end(void) {}
+__attribute__((weak)) void leader_end(void) {}
// Leader key stuff
-bool leading = false;
+bool leading = false;
uint16_t leader_time = 0;
-uint16_t leader_sequence[5] = {0, 0, 0, 0, 0};
-uint8_t leader_sequence_size = 0;
+uint16_t leader_sequence[5] = {0, 0, 0, 0, 0};
+uint8_t leader_sequence_size = 0;
void qk_leader_start(void) {
- if (leading) { return; }
- leader_start();
- leading = true;
- leader_time = timer_read();
- leader_sequence_size = 0;
- leader_sequence[0] = 0;
- leader_sequence[1] = 0;
- leader_sequence[2] = 0;
- leader_sequence[3] = 0;
- leader_sequence[4] = 0;
+ if (leading) {
+ return;
+ }
+ leader_start();
+ leading = true;
+ leader_time = timer_read();
+ leader_sequence_size = 0;
+ memset(leader_sequence, 0, sizeof(leader_sequence));
}
bool process_leader(uint16_t keycode, keyrecord_t *record) {
- // Leader key set-up
- if (record->event.pressed) {
- if (leading) {
- if (timer_elapsed(leader_time) < LEADER_TIMEOUT) {
-#ifndef LEADER_KEY_STRICT_KEY_PROCESSING
- if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
- keycode = keycode & 0xFF;
+ // Leader key set-up
+ if (record->event.pressed) {
+ if (leading) {
+ if (timer_elapsed(leader_time) < LEADER_TIMEOUT) {
+# ifndef LEADER_KEY_STRICT_KEY_PROCESSING
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
+ keycode = keycode & 0xFF;
+ }
+# endif // LEADER_KEY_STRICT_KEY_PROCESSING
+ if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) {
+ leader_sequence[leader_sequence_size] = keycode;
+ leader_sequence_size++;
+ } else {
+ leading = false;
+ leader_end();
+ }
+# ifdef LEADER_PER_KEY_TIMING
+ leader_time = timer_read();
+# endif
+ return false;
+ }
+ } else {
+ if (keycode == KC_LEAD) {
+ qk_leader_start();
+ }
}
-#endif // LEADER_KEY_STRICT_KEY_PROCESSING
- leader_sequence[leader_sequence_size] = keycode;
- leader_sequence_size++;
-#ifdef LEADER_PER_KEY_TIMING
- leader_time = timer_read();
-#endif
- return false;
- }
- } else {
- if (keycode == KC_LEAD) {
- qk_leader_start();
- }
}
- }
- return true;
+ return true;
}
#endif
diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h
index 15bccc3f67..e0edf57b32 100644
--- a/quantum/process_keycode/process_leader.h
+++ b/quantum/process_keycode/process_leader.h
@@ -19,7 +19,6 @@
#include "quantum.h"
-
bool process_leader(uint16_t keycode, keyrecord_t *record);
void leader_start(void);
@@ -32,7 +31,11 @@ void qk_leader_start(void);
#define SEQ_FOUR_KEYS(key1, key2, key3, key4) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == 0)
#define SEQ_FIVE_KEYS(key1, key2, key3, key4, key5) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3) && leader_sequence[3] == (key4) && leader_sequence[4] == (key5))
-#define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[5]; extern uint8_t leader_sequence_size
+#define LEADER_EXTERNS() \
+ extern bool leading; \
+ extern uint16_t leader_time; \
+ extern uint16_t leader_sequence[5]; \
+ extern uint8_t leader_sequence_size
#define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
#endif
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index a67f736285..b2fb902eb4 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -16,86 +16,65 @@
#include "process_midi.h"
#ifdef MIDI_ENABLE
-#include <LUFA/Drivers/USB/USB.h>
-#include "midi.h"
-#include "qmk_midi.h"
+# include <LUFA/Drivers/USB/USB.h>
+# include "midi.h"
+# include "qmk_midi.h"
-#ifdef MIDI_BASIC
+# ifdef MIDI_BASIC
-void process_midi_basic_noteon(uint8_t note)
-{
- midi_send_noteon(&midi_device, 0, note, 128);
-}
+void process_midi_basic_noteon(uint8_t note) { midi_send_noteon(&midi_device, 0, note, 127); }
-void process_midi_basic_noteoff(uint8_t note)
-{
- midi_send_noteoff(&midi_device, 0, note, 0);
-}
+void process_midi_basic_noteoff(uint8_t note) { midi_send_noteoff(&midi_device, 0, note, 0); }
-void process_midi_all_notes_off(void)
-{
- midi_send_cc(&midi_device, 0, 0x7B, 0);
-}
+void process_midi_all_notes_off(void) { midi_send_cc(&midi_device, 0, 0x7B, 0); }
-#endif // MIDI_BASIC
+# endif // MIDI_BASIC
-#ifdef MIDI_ADVANCED
+# ifdef MIDI_ADVANCED
-#include "timer.h"
+# include "timer.h"
static uint8_t tone_status[MIDI_TONE_COUNT];
-static uint8_t midi_modulation;
-static int8_t midi_modulation_step;
+static uint8_t midi_modulation;
+static int8_t midi_modulation_step;
static uint16_t midi_modulation_timer;
-midi_config_t midi_config;
+midi_config_t midi_config;
-inline uint8_t compute_velocity(uint8_t setting)
-{
- return (setting + 1) * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN + 1));
-}
+inline uint8_t compute_velocity(uint8_t setting) { return (setting + 1) * (128 / (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN + 1)); }
-void midi_init(void)
-{
- midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN;
- midi_config.transpose = 0;
- midi_config.velocity = (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN);
- midi_config.channel = 0;
+void midi_init(void) {
+ midi_config.octave = MI_OCT_2 - MIDI_OCTAVE_MIN;
+ midi_config.transpose = 0;
+ midi_config.velocity = (MIDI_VELOCITY_MAX - MIDI_VELOCITY_MIN);
+ midi_config.channel = 0;
midi_config.modulation_interval = 8;
- for (uint8_t i = 0; i < MIDI_TONE_COUNT; i++)
- {
+ for (uint8_t i = 0; i < MIDI_TONE_COUNT; i++) {
tone_status[i] = MIDI_INVALID_NOTE;
}
- midi_modulation = 0;
- midi_modulation_step = 0;
+ midi_modulation = 0;
+ midi_modulation_step = 0;
midi_modulation_timer = 0;
}
-uint8_t midi_compute_note(uint16_t keycode)
-{
- return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose;
-}
+uint8_t midi_compute_note(uint16_t keycode) { return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose; }
-bool process_midi(uint16_t keycode, keyrecord_t *record)
-{
+bool process_midi(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
- case MIDI_TONE_MIN ... MIDI_TONE_MAX:
- {
- uint8_t channel = midi_config.channel;
- uint8_t tone = keycode - MIDI_TONE_MIN;
+ case MIDI_TONE_MIN ... MIDI_TONE_MAX: {
+ uint8_t channel = midi_config.channel;
+ uint8_t tone = keycode - MIDI_TONE_MIN;
uint8_t velocity = compute_velocity(midi_config.velocity);
if (record->event.pressed) {
uint8_t note = midi_compute_note(keycode);
midi_send_noteon(&midi_device, channel, note, velocity);
dprintf("midi noteon channel:%d note:%d velocity:%d\n", channel, note, velocity);
tone_status[tone] = note;
- }
- else {
+ } else {
uint8_t note = tone_status[tone];
- if (note != MIDI_INVALID_NOTE)
- {
+ if (note != MIDI_INVALID_NOTE) {
midi_send_noteoff(&midi_device, channel, note, velocity);
dprintf("midi noteoff channel:%d note:%d velocity:%d\n", channel, note, velocity);
}
@@ -137,8 +116,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
if (record->event.pressed && midi_config.transpose < (MIDI_TRANSPOSE_MAX - MI_TRNS_0)) {
const bool positive = midi_config.transpose > 0;
midi_config.transpose++;
- if (positive && midi_config.transpose < 0)
- midi_config.transpose--;
+ if (positive && midi_config.transpose < 0) midi_config.transpose--;
dprintf("midi transpose %d\n", midi_config.transpose);
}
return false;
@@ -211,8 +189,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
if (record->event.pressed) {
midi_config.modulation_interval++;
// prevent overflow
- if (midi_config.modulation_interval == 0)
- midi_config.modulation_interval--;
+ if (midi_config.modulation_interval == 0) midi_config.modulation_interval--;
dprintf("midi modulation interval %d\n", midi_config.modulation_interval);
}
return false;
@@ -226,8 +203,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
if (record->event.pressed) {
midi_send_pitchbend(&midi_device, midi_config.channel, -0x2000);
dprintf("midi pitchbend channel:%d amount:%d\n", midi_config.channel, -0x2000);
- }
- else {
+ } else {
midi_send_pitchbend(&midi_device, midi_config.channel, 0);
dprintf("midi pitchbend channel:%d amount:%d\n", midi_config.channel, 0);
}
@@ -236,8 +212,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
if (record->event.pressed) {
midi_send_pitchbend(&midi_device, midi_config.channel, 0x1fff);
dprintf("midi pitchbend channel:%d amount:%d\n", midi_config.channel, 0x1fff);
- }
- else {
+ } else {
midi_send_pitchbend(&midi_device, midi_config.channel, 0);
dprintf("midi pitchbend channel:%d amount:%d\n", midi_config.channel, 0);
}
@@ -247,35 +222,29 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
return true;
}
-#endif // MIDI_ADVANCED
+# endif // MIDI_ADVANCED
-void midi_task(void)
-{
+void midi_task(void) {
midi_device_process(&midi_device);
-#ifdef MIDI_ADVANCED
- if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval)
- return;
+# ifdef MIDI_ADVANCED
+ if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval) return;
midi_modulation_timer = timer_read();
- if (midi_modulation_step != 0)
- {
+ if (midi_modulation_step != 0) {
dprintf("midi modulation %d\n", midi_modulation);
midi_send_cc(&midi_device, midi_config.channel, 0x1, midi_modulation);
if (midi_modulation_step < 0 && midi_modulation < -midi_modulation_step) {
- midi_modulation = 0;
+ midi_modulation = 0;
midi_modulation_step = 0;
return;
}
midi_modulation += midi_modulation_step;
- if (midi_modulation > 127)
- midi_modulation = 127;
+ if (midi_modulation > 127) midi_modulation = 127;
}
-#endif
+# endif
}
-
-
-#endif // MIDI_ENABLE
+#endif // MIDI_ENABLE
diff --git a/quantum/process_keycode/process_midi.h b/quantum/process_keycode/process_midi.h
index 1968fbe3fa..0007b3ed25 100644
--- a/quantum/process_keycode/process_midi.h
+++ b/quantum/process_keycode/process_midi.h
@@ -21,24 +21,24 @@
#ifdef MIDI_ENABLE
-#ifdef MIDI_BASIC
+# ifdef MIDI_BASIC
void process_midi_basic_noteon(uint8_t note);
void process_midi_basic_noteoff(uint8_t note);
void process_midi_all_notes_off(void);
-#endif
+# endif
void midi_task(void);
-#ifdef MIDI_ADVANCED
+# ifdef MIDI_ADVANCED
typedef union {
- uint32_t raw;
- struct {
- uint8_t octave :4;
- int8_t transpose :4;
- uint8_t velocity :4;
- uint8_t channel :4;
- uint8_t modulation_interval :4;
- };
+ uint32_t raw;
+ struct {
+ uint8_t octave : 4;
+ int8_t transpose : 4;
+ uint8_t velocity : 4;
+ uint8_t channel : 4;
+ uint8_t modulation_interval : 4;
+ };
} midi_config_t;
extern midi_config_t midi_config;
@@ -46,12 +46,12 @@ extern midi_config_t midi_config;
void midi_init(void);
bool process_midi(uint16_t keycode, keyrecord_t *record);
-#define MIDI_INVALID_NOTE 0xFF
-#define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1)
+# define MIDI_INVALID_NOTE 0xFF
+# define MIDI_TONE_COUNT (MIDI_TONE_MAX - MIDI_TONE_MIN + 1)
uint8_t midi_compute_note(uint16_t keycode);
-#endif // MIDI_ADVANCED
+# endif // MIDI_ADVANCED
-#endif // MIDI_ENABLE
+#endif // MIDI_ENABLE
#endif
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c
index 697aa237fa..b61a16e878 100644
--- a/quantum/process_keycode/process_music.c
+++ b/quantum/process_keycode/process_music.c
@@ -16,103 +16,91 @@
#include "process_music.h"
#ifdef AUDIO_ENABLE
-#include "process_audio.h"
+# include "process_audio.h"
#endif
#if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
-#include "process_midi.h"
+# include "process_midi.h"
#endif
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
-bool music_activated = false;
-bool midi_activated = false;
+bool music_activated = false;
+bool midi_activated = false;
uint8_t music_starting_note = 0x0C;
-int music_offset = 7;
-uint8_t music_mode = MUSIC_MODE_MAJOR;
+int music_offset = 7;
+uint8_t music_mode = MUSIC_MODE_MAJOR;
// music sequencer
-static bool music_sequence_recording = false;
-static bool music_sequence_recorded = false;
-static bool music_sequence_playing = false;
-static uint8_t music_sequence[16] = {0};
-static uint8_t music_sequence_count = 0;
-static uint8_t music_sequence_position = 0;
-
-static uint16_t music_sequence_timer = 0;
+static bool music_sequence_recording = false;
+static bool music_sequence_recorded = false;
+static bool music_sequence_playing = false;
+static uint8_t music_sequence[16] = {0};
+static uint8_t music_sequence_count = 0;
+static uint8_t music_sequence_position = 0;
+
+static uint16_t music_sequence_timer = 0;
static uint16_t music_sequence_interval = 100;
-#ifdef AUDIO_ENABLE
- #ifndef MUSIC_ON_SONG
- #define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND)
- #endif
- #ifndef MUSIC_OFF_SONG
- #define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND)
- #endif
- #ifndef MIDI_ON_SONG
- #define MIDI_ON_SONG SONG(MUSIC_ON_SOUND)
- #endif
- #ifndef MIDI_OFF_SONG
- #define MIDI_OFF_SONG SONG(MUSIC_OFF_SOUND)
- #endif
- #ifndef CHROMATIC_SONG
- #define CHROMATIC_SONG SONG(CHROMATIC_SOUND)
- #endif
- #ifndef GUITAR_SONG
- #define GUITAR_SONG SONG(GUITAR_SOUND)
- #endif
- #ifndef VIOLIN_SONG
- #define VIOLIN_SONG SONG(VIOLIN_SOUND)
- #endif
- #ifndef MAJOR_SONG
- #define MAJOR_SONG SONG(MAJOR_SOUND)
- #endif
- float music_mode_songs[NUMBER_OF_MODES][5][2] = {
- CHROMATIC_SONG,
- GUITAR_SONG,
- VIOLIN_SONG,
- MAJOR_SONG
- };
- float music_on_song[][2] = MUSIC_ON_SONG;
- float music_off_song[][2] = MUSIC_OFF_SONG;
- float midi_on_song[][2] = MIDI_ON_SONG;
- float midi_off_song[][2] = MIDI_OFF_SONG;
-#endif
+# ifdef AUDIO_ENABLE
+# ifndef MUSIC_ON_SONG
+# define MUSIC_ON_SONG SONG(MUSIC_ON_SOUND)
+# endif
+# ifndef MUSIC_OFF_SONG
+# define MUSIC_OFF_SONG SONG(MUSIC_OFF_SOUND)
+# endif
+# ifndef MIDI_ON_SONG
+# define MIDI_ON_SONG SONG(MUSIC_ON_SOUND)
+# endif
+# ifndef MIDI_OFF_SONG
+# define MIDI_OFF_SONG SONG(MUSIC_OFF_SOUND)
+# endif
+# ifndef CHROMATIC_SONG
+# define CHROMATIC_SONG SONG(CHROMATIC_SOUND)
+# endif
+# ifndef GUITAR_SONG
+# define GUITAR_SONG SONG(GUITAR_SOUND)
+# endif
+# ifndef VIOLIN_SONG
+# define VIOLIN_SONG SONG(VIOLIN_SOUND)
+# endif
+# ifndef MAJOR_SONG
+# define MAJOR_SONG SONG(MAJOR_SOUND)
+# endif
+float music_mode_songs[NUMBER_OF_MODES][5][2] = {CHROMATIC_SONG, GUITAR_SONG, VIOLIN_SONG, MAJOR_SONG};
+float music_on_song[][2] = MUSIC_ON_SONG;
+float music_off_song[][2] = MUSIC_OFF_SONG;
+float midi_on_song[][2] = MIDI_ON_SONG;
+float midi_off_song[][2] = MIDI_OFF_SONG;
+# endif
static void music_noteon(uint8_t note) {
- #ifdef AUDIO_ENABLE
- if (music_activated)
- process_audio_noteon(note);
- #endif
- #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
- if (midi_activated)
- process_midi_basic_noteon(note);
- #endif
+# ifdef AUDIO_ENABLE
+ if (music_activated) process_audio_noteon(note);
+# endif
+# if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
+ if (midi_activated) process_midi_basic_noteon(note);
+# endif
}
static void music_noteoff(uint8_t note) {
- #ifdef AUDIO_ENABLE
- if (music_activated)
- process_audio_noteoff(note);
- #endif
- #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
- if (midi_activated)
- process_midi_basic_noteoff(note);
- #endif
+# ifdef AUDIO_ENABLE
+ if (music_activated) process_audio_noteoff(note);
+# endif
+# if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
+ if (midi_activated) process_midi_basic_noteoff(note);
+# endif
}
void music_all_notes_off(void) {
- #ifdef AUDIO_ENABLE
- if (music_activated)
- process_audio_all_notes_off();
- #endif
- #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
- if (midi_activated)
- process_midi_all_notes_off();
- #endif
+# ifdef AUDIO_ENABLE
+ if (music_activated) process_audio_all_notes_off();
+# endif
+# if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
+ if (midi_activated) process_midi_all_notes_off();
+# endif
}
bool process_music(uint16_t keycode, keyrecord_t *record) {
-
if (keycode == MU_ON && record->event.pressed) {
music_on();
return false;
@@ -152,110 +140,101 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
}
if (keycode == MU_MOD && record->event.pressed) {
- music_mode_cycle();
- return false;
+ music_mode_cycle();
+ return false;
}
if (music_activated || midi_activated) {
- if (record->event.pressed) {
- if (keycode == KC_LCTL) { // Start recording
- music_all_notes_off();
- music_sequence_recording = true;
- music_sequence_recorded = false;
- music_sequence_playing = false;
- music_sequence_count = 0;
- return false;
- }
-
- if (keycode == KC_LALT) { // Stop recording/playing
- music_all_notes_off();
- if (music_sequence_recording) { // was recording
- music_sequence_recorded = true;
- }
- music_sequence_recording = false;
- music_sequence_playing = false;
- return false;
- }
-
- if (keycode == KC_LGUI && music_sequence_recorded) { // Start playing
- music_all_notes_off();
- music_sequence_recording = false;
- music_sequence_playing = true;
- music_sequence_position = 0;
- music_sequence_timer = 0;
- return false;
- }
-
- if (keycode == KC_UP) {
- music_sequence_interval-=10;
- return false;
+ if (record->event.pressed) {
+ if (keycode == KC_LCTL) { // Start recording
+ music_all_notes_off();
+ music_sequence_recording = true;
+ music_sequence_recorded = false;
+ music_sequence_playing = false;
+ music_sequence_count = 0;
+ return false;
+ }
+
+ if (keycode == KC_LALT) { // Stop recording/playing
+ music_all_notes_off();
+ if (music_sequence_recording) { // was recording
+ music_sequence_recorded = true;
+ }
+ music_sequence_recording = false;
+ music_sequence_playing = false;
+ return false;
+ }
+
+ if (keycode == KC_LGUI && music_sequence_recorded) { // Start playing
+ music_all_notes_off();
+ music_sequence_recording = false;
+ music_sequence_playing = true;
+ music_sequence_position = 0;
+ music_sequence_timer = 0;
+ return false;
+ }
+
+ if (keycode == KC_UP) {
+ music_sequence_interval -= 10;
+ return false;
+ }
+
+ if (keycode == KC_DOWN) {
+ music_sequence_interval += 10;
+ return false;
+ }
}
- if (keycode == KC_DOWN) {
- music_sequence_interval+=10;
- return false;
- }
- }
-
- uint8_t note = 36;
- #ifdef MUSIC_MAP
+ uint8_t note = 36;
+# ifdef MUSIC_MAP
if (music_mode == MUSIC_MODE_CHROMATIC) {
- note = music_starting_note + music_offset + 36 + music_map[record->event.key.row][record->event.key.col];
+ note = music_starting_note + music_offset + 36 + music_map[record->event.key.row][record->event.key.col];
} else {
- uint8_t position = music_map[record->event.key.row][record->event.key.col];
- note = music_starting_note + music_offset + 36 + SCALE[position % 12] + (position / 12)*12;
+ uint8_t position = music_map[record->event.key.row][record->event.key.col];
+ note = music_starting_note + music_offset + 36 + SCALE[position % 12] + (position / 12) * 12;
}
- #else
+# else
if (music_mode == MUSIC_MODE_CHROMATIC)
- note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row);
+ note = (music_starting_note + record->event.key.col + music_offset - 3) + 12 * (MATRIX_ROWS - record->event.key.row);
else if (music_mode == MUSIC_MODE_GUITAR)
- note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row);
+ note = (music_starting_note + record->event.key.col + music_offset + 32) + 5 * (MATRIX_ROWS - record->event.key.row);
else if (music_mode == MUSIC_MODE_VIOLIN)
- note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row);
+ note = (music_starting_note + record->event.key.col + music_offset + 32) + 7 * (MATRIX_ROWS - record->event.key.row);
else if (music_mode == MUSIC_MODE_MAJOR)
- note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row);
+ note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3) + 12 * (MATRIX_ROWS - record->event.key.row);
else
- note = music_starting_note;
- #endif
-
- if (record->event.pressed) {
- music_noteon(note);
- if (music_sequence_recording) {
- music_sequence[music_sequence_count] = note;
- music_sequence_count++;
+ note = music_starting_note;
+# endif
+
+ if (record->event.pressed) {
+ music_noteon(note);
+ if (music_sequence_recording) {
+ music_sequence[music_sequence_count] = note;
+ music_sequence_count++;
+ }
+ } else {
+ music_noteoff(note);
}
- } else {
- music_noteoff(note);
- }
- if (music_mask(keycode))
- return false;
+ if (music_mask(keycode)) return false;
}
return true;
}
bool music_mask(uint16_t keycode) {
- #ifdef MUSIC_MASK
+# ifdef MUSIC_MASK
return MUSIC_MASK;
- #else
+# else
return music_mask_kb(keycode);
- #endif
+# endif
}
-__attribute__((weak))
-bool music_mask_kb(uint16_t keycode) {
- return music_mask_user(keycode);
-}
+__attribute__((weak)) bool music_mask_kb(uint16_t keycode) { return music_mask_user(keycode); }
-__attribute__((weak))
-bool music_mask_user(uint16_t keycode) {
- return keycode < 0xFF;
-}
+__attribute__((weak)) bool music_mask_user(uint16_t keycode) { return keycode < 0xFF; }
-bool is_music_on(void) {
- return (music_activated != 0);
-}
+bool is_music_on(void) { return (music_activated != 0); }
void music_toggle(void) {
if (!music_activated) {
@@ -267,23 +246,21 @@ void music_toggle(void) {
void music_on(void) {
music_activated = 1;
- #ifdef AUDIO_ENABLE
- PLAY_SONG(music_on_song);
- #endif
+# ifdef AUDIO_ENABLE
+ PLAY_SONG(music_on_song);
+# endif
music_on_user();
}
void music_off(void) {
music_all_notes_off();
music_activated = 0;
- #ifdef AUDIO_ENABLE
- PLAY_SONG(music_off_song);
- #endif
+# ifdef AUDIO_ENABLE
+ PLAY_SONG(music_off_song);
+# endif
}
-bool is_midi_on(void) {
- return (midi_activated != 0);
-}
+bool is_midi_on(void) { return (midi_activated != 0); }
void midi_toggle(void) {
if (!midi_activated) {
@@ -295,50 +272,47 @@ void midi_toggle(void) {
void midi_on(void) {
midi_activated = 1;
- #ifdef AUDIO_ENABLE
- PLAY_SONG(midi_on_song);
- #endif
+# ifdef AUDIO_ENABLE
+ PLAY_SONG(midi_on_song);
+# endif
midi_on_user();
}
void midi_off(void) {
- #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
- process_midi_all_notes_off();
- #endif
+# if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
+ process_midi_all_notes_off();
+# endif
midi_activated = 0;
- #ifdef AUDIO_ENABLE
- PLAY_SONG(midi_off_song);
- #endif
+# ifdef AUDIO_ENABLE
+ PLAY_SONG(midi_off_song);
+# endif
}
void music_mode_cycle(void) {
- music_all_notes_off();
- music_mode = (music_mode + 1) % NUMBER_OF_MODES;
- #ifdef AUDIO_ENABLE
+ music_all_notes_off();
+ music_mode = (music_mode + 1) % NUMBER_OF_MODES;
+# ifdef AUDIO_ENABLE
PLAY_SONG(music_mode_songs[music_mode]);
- #endif
+# endif
}
void matrix_scan_music(void) {
- if (music_sequence_playing) {
- if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) {
- music_sequence_timer = timer_read();
- uint8_t prev_note = music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)];
- uint8_t next_note = music_sequence[music_sequence_position];
- music_noteoff(prev_note);
- music_noteon(next_note);
- music_sequence_position = (music_sequence_position + 1) % music_sequence_count;
+ if (music_sequence_playing) {
+ if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) {
+ music_sequence_timer = timer_read();
+ uint8_t prev_note = music_sequence[(music_sequence_position - 1 < 0) ? (music_sequence_position - 1 + music_sequence_count) : (music_sequence_position - 1)];
+ uint8_t next_note = music_sequence[music_sequence_position];
+ music_noteoff(prev_note);
+ music_noteon(next_note);
+ music_sequence_position = (music_sequence_position + 1) % music_sequence_count;
+ }
}
- }
}
-__attribute__ ((weak))
-void music_on_user() {}
+__attribute__((weak)) void music_on_user() {}
-__attribute__ ((weak))
-void midi_on_user() {}
+__attribute__((weak)) void midi_on_user() {}
-__attribute__ ((weak))
-void music_scale_user() {}
+__attribute__((weak)) void music_scale_user() {}
-#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
+#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 f6753d4f24..292bc53742 100644
--- a/quantum/process_keycode/process_music.h
+++ b/quantum/process_keycode/process_music.h
@@ -21,18 +21,11 @@
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
-enum music_modes {
- MUSIC_MODE_CHROMATIC,
- MUSIC_MODE_GUITAR,
- MUSIC_MODE_VIOLIN,
- MUSIC_MODE_MAJOR,
- NUMBER_OF_MODES
-};
+enum music_modes { MUSIC_MODE_CHROMATIC, MUSIC_MODE_GUITAR, MUSIC_MODE_VIOLIN, MUSIC_MODE_MAJOR, NUMBER_OF_MODES };
-
-#ifdef MUSIC_MAP
- extern const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS];
-#endif
+# ifdef MUSIC_MAP
+extern const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS];
+# endif
bool process_music(uint16_t keycode, keyrecord_t *record);
@@ -58,14 +51,11 @@ bool music_mask(uint16_t keycode);
bool music_mask_kb(uint16_t keycode);
bool music_mask_user(uint16_t keycode);
-#ifndef SCALE
-#define SCALE (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), }
-#endif
+# ifndef SCALE
+# define SCALE \
+ (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), }
+# endif
-#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
+#endif // defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
#endif
diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c
index 613af70183..7c5e4169a6 100644
--- a/quantum/process_keycode/process_printer.c
+++ b/quantum/process_keycode/process_printer.c
@@ -17,17 +17,15 @@
#include "process_printer.h"
#include "action_util.h"
-bool printing_enabled = false;
-uint8_t character_shift = 0;
+bool printing_enabled = false;
+uint8_t character_shift = 0;
void enable_printing(void) {
- printing_enabled = true;
- serial_init();
+ printing_enabled = true;
+ serial_init();
}
-void disable_printing(void) {
- printing_enabled = false;
-}
+void disable_printing(void) { printing_enabled = false; }
uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29};
@@ -36,235 +34,232 @@ uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0
// keycode_to_ascii[KC_MINS] = {0x2D, 0x5F};
void print_char(char c) {
- USB_Disable();
- serial_send(c);
- USB_Init();
+ USB_Disable();
+ serial_send(c);
+ USB_Init();
}
void print_string(char c[]) {
- for(uint8_t i = 0; i < strlen(c); i++)
- print_char(c[i]);
+ for (uint8_t i = 0; i < strlen(c); i++) print_char(c[i]);
}
void print_box_string(const char text[]) {
- size_t len = strlen(text);
- char out[len * 3 + 8];
- out[0] = 0xDA;
- for (uint8_t i = 0; i < len; i++) {
- out[i+1] = 0xC4;
- }
- out[len + 1] = 0xBF;
- out[len + 2] = '\n';
-
- out[len + 3] = 0xB3;
- for (uint8_t i = 0; i < len; i++) {
- out[len + 4 + i] = text[i];
- }
- out[len * 2 + 4] = 0xB3;
- out[len * 2 + 5] = '\n';
+ size_t len = strlen(text);
+ char out[len * 3 + 8];
+ out[0] = 0xDA;
+ for (uint8_t i = 0; i < len; i++) {
+ out[i + 1] = 0xC4;
+ }
+ out[len + 1] = 0xBF;
+ out[len + 2] = '\n';
+ out[len + 3] = 0xB3;
+ for (uint8_t i = 0; i < len; i++) {
+ out[len + 4 + i] = text[i];
+ }
+ out[len * 2 + 4] = 0xB3;
+ out[len * 2 + 5] = '\n';
- out[len * 2 + 6] = 0xC0;
- for (uint8_t i = 0; i < len; i++) {
- out[len * 2 + 7 + i] = 0xC4;
- }
- out[len * 3 + 7] = 0xD9;
- out[len * 3 + 8] = '\n';
+ out[len * 2 + 6] = 0xC0;
+ for (uint8_t i = 0; i < len; i++) {
+ out[len * 2 + 7 + i] = 0xC4;
+ }
+ out[len * 3 + 7] = 0xD9;
+ out[len * 3 + 8] = '\n';
- print_string(out);
+ print_string(out);
}
bool process_printer(uint16_t keycode, keyrecord_t *record) {
- if (keycode == PRINT_ON) {
- enable_printing();
- return false;
- }
- if (keycode == PRINT_OFF) {
- disable_printing();
- return false;
- }
-
- if (printing_enabled) {
- switch(keycode) {
- case KC_EXLM ... KC_RPRN:
- case KC_UNDS:
- case KC_PLUS:
- case KC_LCBR:
- case KC_RCBR:
- case KC_PIPE:
- case KC_TILD:
- keycode &= 0xFF;
- case KC_LSFT:
- case KC_RSFT:
- if (record->event.pressed) {
- character_shift++;
- } else {
- character_shift--;
- }
- return false;
- break;
- }
+ if (keycode == PRINT_ON) {
+ enable_printing();
+ return false;
+ }
+ if (keycode == PRINT_OFF) {
+ disable_printing();
+ return false;
+ }
- switch(keycode) {
- case KC_F1:
- if (record->event.pressed) {
- print_box_string("This is a line of text!");
- }
- return false;
- case KC_ESC:
- if (record->event.pressed) {
- print_char(0x1B);
- }
- return false;
- break;
- case KC_SPC:
- if (record->event.pressed) {
- print_char(0x20);
- }
- return false;
- break;
- case KC_A ... KC_Z:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x41 + (keycode - KC_A));
- } else {
- print_char(0x61 + (keycode - KC_A));
- }
- }
- return false;
- break;
- case KC_1 ... KC_0:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(shifted_numbers[keycode - KC_1]);
- } else {
- print_char(0x30 + ((keycode - KC_1 + 1) % 10));
- }
- }
- return false;
- break;
- case KC_ENT:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x0C);
- } else {
- print_char(0x0A);
- }
- }
- return false;
- break;
- case KC_BSPC:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x18);
- } else {
- print_char(0x1A);
- }
- }
- return false;
- break;
- case KC_DOT:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x3E);
- } else {
- print_char(0x2E);
- }
- }
- return false;
- break;
- case KC_COMM:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x3C);
- } else {
- print_char(0x2C);
- }
- }
- return false;
- break;
- case KC_SLSH:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x3F);
- } else {
- print_char(0x2F);
- }
- }
- return false;
- break;
- case KC_QUOT:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x22);
- } else {
- print_char(0x27);
- }
- }
- return false;
- break;
- case KC_GRV:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7E);
- } else {
- print_char(0x60);
- }
- }
- return false;
- break;
- case KC_MINS:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x5F);
- } else {
- print_char(0x2D);
- }
- }
- return false;
- break;
- case KC_EQL:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x2B);
- } else {
- print_char(0x3D);
- }
- }
- return false;
- break;
- case KC_LBRC:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7B);
- } else {
- print_char(0x5B);
- }
- }
- return false;
- break;
- case KC_RBRC:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7D);
- } else {
- print_char(0x5D);
- }
- }
- return false;
- break;
- case KC_BSLS:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7C);
- } else {
- print_char(0x5C);
- }
- }
- return false;
- break;
- }
- }
- return true;
+ if (printing_enabled) {
+ switch (keycode) {
+ case KC_EXLM ... KC_RPRN:
+ case KC_UNDS:
+ case KC_PLUS:
+ case KC_LCBR:
+ case KC_RCBR:
+ case KC_PIPE:
+ case KC_TILD:
+ keycode &= 0xFF;
+ case KC_LSFT:
+ case KC_RSFT:
+ if (record->event.pressed) {
+ character_shift++;
+ } else {
+ character_shift--;
+ }
+ return false;
+ break;
+ }
+ switch (keycode) {
+ case KC_F1:
+ if (record->event.pressed) {
+ print_box_string("This is a line of text!");
+ }
+ return false;
+ case KC_ESC:
+ if (record->event.pressed) {
+ print_char(0x1B);
+ }
+ return false;
+ break;
+ case KC_SPC:
+ if (record->event.pressed) {
+ print_char(0x20);
+ }
+ return false;
+ break;
+ case KC_A ... KC_Z:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x41 + (keycode - KC_A));
+ } else {
+ print_char(0x61 + (keycode - KC_A));
+ }
+ }
+ return false;
+ break;
+ case KC_1 ... KC_0:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(shifted_numbers[keycode - KC_1]);
+ } else {
+ print_char(0x30 + ((keycode - KC_1 + 1) % 10));
+ }
+ }
+ return false;
+ break;
+ case KC_ENT:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x0C);
+ } else {
+ print_char(0x0A);
+ }
+ }
+ return false;
+ break;
+ case KC_BSPC:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x18);
+ } else {
+ print_char(0x1A);
+ }
+ }
+ return false;
+ break;
+ case KC_DOT:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x3E);
+ } else {
+ print_char(0x2E);
+ }
+ }
+ return false;
+ break;
+ case KC_COMM:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x3C);
+ } else {
+ print_char(0x2C);
+ }
+ }
+ return false;
+ break;
+ case KC_SLSH:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x3F);
+ } else {
+ print_char(0x2F);
+ }
+ }
+ return false;
+ break;
+ case KC_QUOT:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x22);
+ } else {
+ print_char(0x27);
+ }
+ }
+ return false;
+ break;
+ case KC_GRV:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7E);
+ } else {
+ print_char(0x60);
+ }
+ }
+ return false;
+ break;
+ case KC_MINS:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x5F);
+ } else {
+ print_char(0x2D);
+ }
+ }
+ return false;
+ break;
+ case KC_EQL:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x2B);
+ } else {
+ print_char(0x3D);
+ }
+ }
+ return false;
+ break;
+ case KC_LBRC:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7B);
+ } else {
+ print_char(0x5B);
+ }
+ }
+ return false;
+ break;
+ case KC_RBRC:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7D);
+ } else {
+ print_char(0x5D);
+ }
+ }
+ return false;
+ break;
+ case KC_BSLS:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7C);
+ } else {
+ print_char(0x5C);
+ }
+ }
+ return false;
+ break;
+ }
+ }
+ return true;
}
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c
index 3a00f169d8..e482d82591 100644
--- a/quantum/process_keycode/process_printer_bb.c
+++ b/quantum/process_keycode/process_printer_bb.c
@@ -17,44 +17,29 @@
#include "process_printer.h"
#include "action_util.h"
-bool printing_enabled = false;
-uint8_t character_shift = 0;
+bool printing_enabled = false;
+uint8_t character_shift = 0;
#define SERIAL_PIN_DDR DDRD
#define SERIAL_PIN_PORT PORTD
#define SERIAL_PIN_MASK _BV(PD3)
#define SERIAL_DELAY 52
-inline static
-void serial_delay(void) {
- _delay_us(SERIAL_DELAY);
-}
+inline static void serial_delay(void) { _delay_us(SERIAL_DELAY); }
-inline static
-void serial_high(void) {
- SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
-}
+inline static void serial_high(void) { SERIAL_PIN_PORT |= SERIAL_PIN_MASK; }
-inline static
-void serial_low(void) {
- SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
-}
-
-inline static
-void serial_output(void) {
- SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
-}
+inline static void serial_low(void) { SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; }
+inline static void serial_output(void) { SERIAL_PIN_DDR |= SERIAL_PIN_MASK; }
void enable_printing() {
- printing_enabled = true;
- serial_output();
- serial_high();
+ printing_enabled = true;
+ serial_output();
+ serial_high();
}
-void disable_printing() {
- printing_enabled = false;
-}
+void disable_printing() { printing_enabled = false; }
uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29};
@@ -63,214 +48,212 @@ uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0
// keycode_to_ascii[KC_MINS] = {0x2D, 0x5F};
void print_char(char c) {
- uint8_t b = 8;
- serial_output();
- while( b-- ) {
- if(c & (1 << b)) {
- serial_high();
- } else {
- serial_low();
+ uint8_t b = 8;
+ serial_output();
+ while (b--) {
+ if (c & (1 << b)) {
+ serial_high();
+ } else {
+ serial_low();
+ }
+ serial_delay();
}
- serial_delay();
- }
}
void print_string(char c[]) {
- for(uint8_t i = 0; i < strlen(c); i++)
- print_char(c[i]);
+ for (uint8_t i = 0; i < strlen(c); i++) print_char(c[i]);
}
bool process_printer(uint16_t keycode, keyrecord_t *record) {
- if (keycode == PRINT_ON) {
- enable_printing();
- return false;
- }
- if (keycode == PRINT_OFF) {
- disable_printing();
- return false;
- }
-
- if (printing_enabled) {
- switch(keycode) {
- case KC_EXLM ... KC_RPRN:
- case KC_UNDS:
- case KC_PLUS:
- case KC_LCBR:
- case KC_RCBR:
- case KC_PIPE:
- case KC_TILD:
- keycode &= 0xFF;
- case KC_LSFT:
- case KC_RSFT:
- if (record->event.pressed) {
- character_shift++;
- } else {
- character_shift--;
- }
- return false;
- break;
- }
+ if (keycode == PRINT_ON) {
+ enable_printing();
+ return false;
+ }
+ if (keycode == PRINT_OFF) {
+ disable_printing();
+ return false;
+ }
- switch(keycode) {
- case KC_F1:
- if (record->event.pressed) {
- print_string("This is a line of text!\n\n\n");
- }
- return false;
- case KC_ESC:
- if (record->event.pressed) {
- print_char(0x1B);
- }
- return false;
- break;
- case KC_SPC:
- if (record->event.pressed) {
- print_char(0x20);
- }
- return false;
- break;
- case KC_A ... KC_Z:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x41 + (keycode - KC_A));
- } else {
- print_char(0x61 + (keycode - KC_A));
- }
- }
- return false;
- break;
- case KC_1 ... KC_0:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(shifted_numbers[keycode - KC_1]);
- } else {
- print_char(0x30 + ((keycode - KC_1 + 1) % 10));
- }
- }
- return false;
- break;
- case KC_ENT:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x0C);
- } else {
- print_char(0x0A);
- }
- }
- return false;
- break;
- case KC_BSPC:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x18);
- } else {
- print_char(0x1A);
- }
- }
- return false;
- break;
- case KC_DOT:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x3E);
- } else {
- print_char(0x2E);
- }
- }
- return false;
- break;
- case KC_COMM:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x3C);
- } else {
- print_char(0x2C);
- }
- }
- return false;
- break;
- case KC_SLSH:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x3F);
- } else {
- print_char(0x2F);
- }
- }
- return false;
- break;
- case KC_QUOT:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x22);
- } else {
- print_char(0x27);
- }
- }
- return false;
- break;
- case KC_GRV:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7E);
- } else {
- print_char(0x60);
- }
- }
- return false;
- break;
- case KC_MINS:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x5F);
- } else {
- print_char(0x2D);
- }
- }
- return false;
- break;
- case KC_EQL:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x2B);
- } else {
- print_char(0x3D);
- }
- }
- return false;
- break;
- case KC_LBRC:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7B);
- } else {
- print_char(0x5B);
- }
- }
- return false;
- break;
- case KC_RBRC:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7D);
- } else {
- print_char(0x5D);
- }
- }
- return false;
- break;
- case KC_BSLS:
- if (record->event.pressed) {
- if (character_shift) {
- print_char(0x7C);
- } else {
- print_char(0x5C);
- }
- }
- return false;
- break;
- }
- }
- return true;
+ if (printing_enabled) {
+ switch (keycode) {
+ case KC_EXLM ... KC_RPRN:
+ case KC_UNDS:
+ case KC_PLUS:
+ case KC_LCBR:
+ case KC_RCBR:
+ case KC_PIPE:
+ case KC_TILD:
+ keycode &= 0xFF;
+ case KC_LSFT:
+ case KC_RSFT:
+ if (record->event.pressed) {
+ character_shift++;
+ } else {
+ character_shift--;
+ }
+ return false;
+ break;
+ }
+ switch (keycode) {
+ case KC_F1:
+ if (record->event.pressed) {
+ print_string("This is a line of text!\n\n\n");
+ }
+ return false;
+ case KC_ESC:
+ if (record->event.pressed) {
+ print_char(0x1B);
+ }
+ return false;
+ break;
+ case KC_SPC:
+ if (record->event.pressed) {
+ print_char(0x20);
+ }
+ return false;
+ break;
+ case KC_A ... KC_Z:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x41 + (keycode - KC_A));
+ } else {
+ print_char(0x61 + (keycode - KC_A));
+ }
+ }
+ return false;
+ break;
+ case KC_1 ... KC_0:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(shifted_numbers[keycode - KC_1]);
+ } else {
+ print_char(0x30 + ((keycode - KC_1 + 1) % 10));
+ }
+ }
+ return false;
+ break;
+ case KC_ENT:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x0C);
+ } else {
+ print_char(0x0A);
+ }
+ }
+ return false;
+ break;
+ case KC_BSPC:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x18);
+ } else {
+ print_char(0x1A);
+ }
+ }
+ return false;
+ break;
+ case KC_DOT:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x3E);
+ } else {
+ print_char(0x2E);
+ }
+ }
+ return false;
+ break;
+ case KC_COMM:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x3C);
+ } else {
+ print_char(0x2C);
+ }
+ }
+ return false;
+ break;
+ case KC_SLSH:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x3F);
+ } else {
+ print_char(0x2F);
+ }
+ }
+ return false;
+ break;
+ case KC_QUOT:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x22);
+ } else {
+ print_char(0x27);
+ }
+ }
+ return false;
+ break;
+ case KC_GRV:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7E);
+ } else {
+ print_char(0x60);
+ }
+ }
+ return false;
+ break;
+ case KC_MINS:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x5F);
+ } else {
+ print_char(0x2D);
+ }
+ }
+ return false;
+ break;
+ case KC_EQL:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x2B);
+ } else {
+ print_char(0x3D);
+ }
+ }
+ return false;
+ break;
+ case KC_LBRC:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7B);
+ } else {
+ print_char(0x5B);
+ }
+ }
+ return false;
+ break;
+ case KC_RBRC:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7D);
+ } else {
+ print_char(0x5D);
+ }
+ }
+ return false;
+ break;
+ case KC_BSLS:
+ if (record->event.pressed) {
+ if (character_shift) {
+ print_char(0x7C);
+ } else {
+ print_char(0x5C);
+ }
+ }
+ return false;
+ break;
+ }
+ }
+ return true;
}
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c
index c8721d446c..6833fdb9fb 100644
--- a/quantum/process_keycode/process_space_cadet.c
+++ b/quantum/process_keycode/process_space_cadet.c
@@ -16,150 +16,149 @@
#include "process_space_cadet.h"
#ifndef TAPPING_TERM
- #define TAPPING_TERM 200
+# define TAPPING_TERM 200
#endif
// ********** OBSOLETE DEFINES, STOP USING! (pls?) **********
// Shift / paren setup
#ifndef LSPO_KEY
- #define LSPO_KEY KC_9
+# define LSPO_KEY KC_9
#endif
#ifndef RSPC_KEY
- #define RSPC_KEY KC_0
+# define RSPC_KEY KC_0
#endif
// Shift / Enter setup
#ifndef SFTENT_KEY
- #define SFTENT_KEY KC_ENT
+# define SFTENT_KEY KC_ENT
#endif
#ifdef DISABLE_SPACE_CADET_MODIFIER
- #ifndef LSPO_MOD
- #define LSPO_MOD KC_TRNS
- #endif
- #ifndef RSPC_MOD
- #define RSPC_MOD KC_TRNS
- #endif
+# ifndef LSPO_MOD
+# define LSPO_MOD KC_TRNS
+# endif
+# ifndef RSPC_MOD
+# define RSPC_MOD KC_TRNS
+# endif
#else
- #ifndef LSPO_MOD
- #define LSPO_MOD KC_LSFT
- #endif
- #ifndef RSPC_MOD
- #define RSPC_MOD KC_RSFT
- #endif
+# ifndef LSPO_MOD
+# define LSPO_MOD KC_LSFT
+# endif
+# ifndef RSPC_MOD
+# define RSPC_MOD KC_RSFT
+# endif
#endif
// **********************************************************
// Shift / paren setup
#ifndef LSPO_KEYS
- #define LSPO_KEYS KC_LSFT, LSPO_MOD, LSPO_KEY
+# define LSPO_KEYS KC_LSFT, LSPO_MOD, LSPO_KEY
#endif
#ifndef RSPC_KEYS
- #define RSPC_KEYS KC_RSFT, RSPC_MOD, RSPC_KEY
+# define RSPC_KEYS KC_RSFT, RSPC_MOD, RSPC_KEY
#endif
// Control / paren setup
#ifndef LCPO_KEYS
- #define LCPO_KEYS KC_LCTL, KC_LSFT, KC_9
+# define LCPO_KEYS KC_LCTL, KC_LSFT, KC_9
#endif
#ifndef RCPC_KEYS
- #define RCPC_KEYS KC_RCTL, KC_RSFT, KC_0
+# define RCPC_KEYS KC_RCTL, KC_RSFT, KC_0
#endif
// Alt / paren setup
#ifndef LAPO_KEYS
- #define LAPO_KEYS KC_LALT, KC_LSFT, KC_9
+# define LAPO_KEYS KC_LALT, KC_LSFT, KC_9
#endif
#ifndef RAPC_KEYS
- #define RAPC_KEYS KC_RALT, KC_RSFT, KC_0
+# define RAPC_KEYS KC_RALT, KC_RSFT, KC_0
#endif
// Shift / Enter setup
#ifndef SFTENT_KEYS
- #define SFTENT_KEYS KC_RSFT, KC_TRNS, SFTENT_KEY
+# define SFTENT_KEYS KC_RSFT, KC_TRNS, SFTENT_KEY
#endif
-static uint8_t sc_last = 0;
+static uint8_t sc_last = 0;
static uint16_t sc_timer = 0;
#ifdef SPACE_CADET_MODIFIER_CARRYOVER
static uint8_t sc_mods = 0;
#endif
void perform_space_cadet(keyrecord_t *record, uint8_t holdMod, uint8_t tapMod, uint8_t keycode) {
- if (record->event.pressed) {
- sc_last = holdMod;
- sc_timer = timer_read ();
+ if (record->event.pressed) {
+ sc_last = holdMod;
+ sc_timer = timer_read();
#ifdef SPACE_CADET_MODIFIER_CARRYOVER
- sc_mods = get_mods();
+ sc_mods = get_mods();
#endif
- if (IS_MOD(holdMod)) {
- register_mods(MOD_BIT(holdMod));
- }
- }
- else {
- if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
- if (holdMod != tapMod) {
if (IS_MOD(holdMod)) {
- unregister_mods(MOD_BIT(holdMod));
- }
- if (IS_MOD(tapMod)) {
- register_mods(MOD_BIT(tapMod));
+ register_mods(MOD_BIT(holdMod));
}
- }
+ } else {
+ if (sc_last == holdMod && timer_elapsed(sc_timer) < TAPPING_TERM) {
+ if (holdMod != tapMod) {
+ if (IS_MOD(holdMod)) {
+ unregister_mods(MOD_BIT(holdMod));
+ }
+ if (IS_MOD(tapMod)) {
+ register_mods(MOD_BIT(tapMod));
+ }
+ }
#ifdef SPACE_CADET_MODIFIER_CARRYOVER
- set_weak_mods(sc_mods);
+ set_weak_mods(sc_mods);
#endif
- tap_code(keycode);
+ tap_code(keycode);
#ifdef SPACE_CADET_MODIFIER_CARRYOVER
- clear_weak_mods();
-#endif
- if (IS_MOD(tapMod)) {
- unregister_mods(MOD_BIT(tapMod));
- }
- } else {
- if (IS_MOD(holdMod)) {
- unregister_mods(MOD_BIT(holdMod));
- }
+ clear_weak_mods();
+#endif
+ if (IS_MOD(tapMod)) {
+ unregister_mods(MOD_BIT(tapMod));
+ }
+ } else {
+ if (IS_MOD(holdMod)) {
+ unregister_mods(MOD_BIT(holdMod));
+ }
+ }
}
- }
}
bool process_space_cadet(uint16_t keycode, keyrecord_t *record) {
- switch(keycode) {
- case KC_LSPO: {
- perform_space_cadet(record, LSPO_KEYS);
- return false;
- }
- case KC_RSPC: {
- perform_space_cadet(record, RSPC_KEYS);
- return false;
- }
- case KC_LCPO: {
- perform_space_cadet(record, LCPO_KEYS);
- return false;
- }
- case KC_RCPC: {
- perform_space_cadet(record, RCPC_KEYS);
- return false;
- }
- case KC_LAPO: {
- perform_space_cadet(record, LAPO_KEYS);
- return false;
- }
- case KC_RAPC: {
- perform_space_cadet(record, RAPC_KEYS);
- return false;
- }
- case KC_SFTENT: {
- perform_space_cadet(record, SFTENT_KEYS);
- return false;
- }
- default: {
- if (record->event.pressed) {
- sc_last = 0;
- }
- break;
+ switch (keycode) {
+ case KC_LSPO: {
+ perform_space_cadet(record, LSPO_KEYS);
+ return false;
+ }
+ case KC_RSPC: {
+ perform_space_cadet(record, RSPC_KEYS);
+ return false;
+ }
+ case KC_LCPO: {
+ perform_space_cadet(record, LCPO_KEYS);
+ return false;
+ }
+ case KC_RCPC: {
+ perform_space_cadet(record, RCPC_KEYS);
+ return false;
+ }
+ case KC_LAPO: {
+ perform_space_cadet(record, LAPO_KEYS);
+ return false;
+ }
+ case KC_RAPC: {
+ perform_space_cadet(record, RAPC_KEYS);
+ return false;
+ }
+ case KC_SFTENT: {
+ perform_space_cadet(record, SFTENT_KEYS);
+ return false;
+ }
+ default: {
+ if (record->event.pressed) {
+ sc_last = 0;
+ }
+ break;
+ }
}
- }
- return true;
+ return true;
}
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c
index 50a1ef2fcf..e0b33ec861 100644
--- a/quantum/process_keycode/process_steno.c
+++ b/quantum/process_keycode/process_steno.c
@@ -58,150 +58,136 @@
#define GEMINI_STATE_SIZE 6
#define MAX_STATE_SIZE GEMINI_STATE_SIZE
-static uint8_t state[MAX_STATE_SIZE] = {0};
-static uint8_t chord[MAX_STATE_SIZE] = {0};
-static int8_t pressed = 0;
+static uint8_t state[MAX_STATE_SIZE] = {0};
+static uint8_t chord[MAX_STATE_SIZE] = {0};
+static int8_t pressed = 0;
static steno_mode_t mode;
-static const uint8_t boltmap[64] PROGMEM = {
- TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM,
- TXB_S_L, TXB_S_L, TXB_T_L, TXB_K_L, TXB_P_L, TXB_W_L, TXB_H_L,
- TXB_R_L, TXB_A_L, TXB_O_L, TXB_STR, TXB_STR, TXB_NUL, TXB_NUL,
- TXB_NUL, TXB_STR, TXB_STR, TXB_E_R, TXB_U_R, TXB_F_R, TXB_R_R,
- TXB_P_R, TXB_B_R, TXB_L_R, TXB_G_R, TXB_T_R, TXB_S_R, TXB_D_R,
- TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_Z_R
-};
+static const uint8_t boltmap[64] PROGMEM = {TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_S_L, TXB_S_L, TXB_T_L, TXB_K_L, TXB_P_L, TXB_W_L, TXB_H_L, TXB_R_L, TXB_A_L, TXB_O_L, TXB_STR, TXB_STR, TXB_NUL, TXB_NUL, TXB_NUL, TXB_STR, TXB_STR, TXB_E_R, TXB_U_R, TXB_F_R, TXB_R_R, TXB_P_R, TXB_B_R, TXB_L_R, TXB_G_R, TXB_T_R, TXB_S_R, TXB_D_R, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_NUM, TXB_Z_R};
static void steno_clear_state(void) {
- memset(state, 0, sizeof(state));
- memset(chord, 0, sizeof(chord));
+ memset(state, 0, sizeof(state));
+ memset(chord, 0, sizeof(chord));
}
static void send_steno_state(uint8_t size, bool send_empty) {
- for (uint8_t i = 0; i < size; ++i) {
- if (chord[i] || send_empty) {
- virtser_send(chord[i]);
+ for (uint8_t i = 0; i < size; ++i) {
+ if (chord[i] || send_empty) {
+ virtser_send(chord[i]);
+ }
}
- }
}
void steno_init() {
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
- mode = eeprom_read_byte(EECONFIG_STENOMODE);
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+ mode = eeprom_read_byte(EECONFIG_STENOMODE);
}
void steno_set_mode(steno_mode_t new_mode) {
- steno_clear_state();
- mode = new_mode;
- eeprom_update_byte(EECONFIG_STENOMODE, mode);
+ steno_clear_state();
+ mode = new_mode;
+ eeprom_update_byte(EECONFIG_STENOMODE, mode);
}
/* override to intercept chords right before they get sent.
* return zero to suppress normal sending behavior.
*/
-__attribute__ ((weak))
-bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) { return true; }
+__attribute__((weak)) bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) { return true; }
-__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; }
+__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; }
-__attribute__ ((weak))
-bool process_steno_user(uint16_t keycode, keyrecord_t *record) { return true; }
+__attribute__((weak)) bool process_steno_user(uint16_t keycode, keyrecord_t *record) { return true; }
static void send_steno_chord(void) {
- if (send_steno_chord_user(mode, chord)) {
- switch(mode) {
- case STENO_MODE_BOLT:
- send_steno_state(BOLT_STATE_SIZE, false);
- virtser_send(0); // terminating byte
- break;
- case STENO_MODE_GEMINI:
- chord[0] |= 0x80; // Indicate start of packet
- send_steno_state(GEMINI_STATE_SIZE, true);
- break;
+ if (send_steno_chord_user(mode, chord)) {
+ switch (mode) {
+ case STENO_MODE_BOLT:
+ send_steno_state(BOLT_STATE_SIZE, false);
+ virtser_send(0); // terminating byte
+ break;
+ case STENO_MODE_GEMINI:
+ chord[0] |= 0x80; // Indicate start of packet
+ send_steno_state(GEMINI_STATE_SIZE, true);
+ break;
+ }
}
- }
- steno_clear_state();
+ steno_clear_state();
}
-uint8_t *steno_get_state(void) {
- return &state[0];
-}
+uint8_t *steno_get_state(void) { return &state[0]; }
-uint8_t *steno_get_chord(void) {
- return &chord[0];
-}
+uint8_t *steno_get_chord(void) { return &chord[0]; }
static bool update_state_bolt(uint8_t key, bool press) {
- uint8_t boltcode = pgm_read_byte(boltmap + key);
- if (press) {
- state[TXB_GET_GROUP(boltcode)] |= boltcode;
- chord[TXB_GET_GROUP(boltcode)] |= boltcode;
- } else {
- state[TXB_GET_GROUP(boltcode)] &= ~boltcode;
- }
- return false;
+ uint8_t boltcode = pgm_read_byte(boltmap + key);
+ if (press) {
+ state[TXB_GET_GROUP(boltcode)] |= boltcode;
+ chord[TXB_GET_GROUP(boltcode)] |= boltcode;
+ } else {
+ state[TXB_GET_GROUP(boltcode)] &= ~boltcode;
+ }
+ return false;
}
static bool update_state_gemini(uint8_t key, bool press) {
- int idx = key / 7;
- uint8_t bit = 1 << (6 - (key % 7));
- if (press) {
- state[idx] |= bit;
- chord[idx] |= bit;
- } else {
- state[idx] &= ~bit;
- }
- return false;
+ int idx = key / 7;
+ uint8_t bit = 1 << (6 - (key % 7));
+ if (press) {
+ state[idx] |= bit;
+ chord[idx] |= bit;
+ } else {
+ state[idx] &= ~bit;
+ }
+ return false;
}
bool process_steno(uint16_t keycode, keyrecord_t *record) {
- switch (keycode) {
- case QK_STENO_BOLT:
- if (!process_steno_user(keycode, record)) {
- return false;
- }
- if (IS_PRESSED(record->event)) {
- steno_set_mode(STENO_MODE_BOLT);
- }
- return false;
-
- case QK_STENO_GEMINI:
- if (!process_steno_user(keycode, record)) {
- return false;
- }
- if (IS_PRESSED(record->event)) {
- steno_set_mode(STENO_MODE_GEMINI);
- }
- return false;
-
- case STN__MIN...STN__MAX:
- if (!process_steno_user(keycode, record)) {
- return false;
- }
- switch(mode) {
- case STENO_MODE_BOLT:
- update_state_bolt(keycode - QK_STENO, IS_PRESSED(record->event));
- break;
- case STENO_MODE_GEMINI:
- update_state_gemini(keycode - QK_STENO, IS_PRESSED(record->event));
- break;
- }
- // allow postprocessing hooks
- if (postprocess_steno_user(keycode, record, mode, chord, pressed)) {
- if (IS_PRESSED(record->event)) {
- ++pressed;
- } else {
- --pressed;
- if (pressed <= 0) {
- pressed = 0;
- send_steno_chord();
- }
- }
- }
- return false;
- }
- return true;
+ switch (keycode) {
+ case QK_STENO_BOLT:
+ if (!process_steno_user(keycode, record)) {
+ return false;
+ }
+ if (IS_PRESSED(record->event)) {
+ steno_set_mode(STENO_MODE_BOLT);
+ }
+ return false;
+
+ case QK_STENO_GEMINI:
+ if (!process_steno_user(keycode, record)) {
+ return false;
+ }
+ if (IS_PRESSED(record->event)) {
+ steno_set_mode(STENO_MODE_GEMINI);
+ }
+ return false;
+
+ case STN__MIN ... STN__MAX:
+ if (!process_steno_user(keycode, record)) {
+ return false;
+ }
+ switch (mode) {
+ case STENO_MODE_BOLT:
+ update_state_bolt(keycode - QK_STENO, IS_PRESSED(record->event));
+ break;
+ case STENO_MODE_GEMINI:
+ update_state_gemini(keycode - QK_STENO, IS_PRESSED(record->event));
+ break;
+ }
+ // allow postprocessing hooks
+ if (postprocess_steno_user(keycode, record, mode, chord, pressed)) {
+ if (IS_PRESSED(record->event)) {
+ ++pressed;
+ } else {
+ --pressed;
+ if (pressed <= 0) {
+ pressed = 0;
+ send_steno_chord();
+ }
+ }
+ }
+ return false;
+ }
+ return true;
}
diff --git a/quantum/process_keycode/process_steno.h b/quantum/process_keycode/process_steno.h
index 71f9731224..3675423728 100644
--- a/quantum/process_keycode/process_steno.h
+++ b/quantum/process_keycode/process_steno.h
@@ -19,14 +19,14 @@
#include "quantum.h"
#if defined(STENO_ENABLE) && !defined(VIRTSER_ENABLE)
- #error "must have virtser enabled to use steno"
+# error "must have virtser enabled to use steno"
#endif
typedef enum { STENO_MODE_BOLT, STENO_MODE_GEMINI } steno_mode_t;
-bool process_steno(uint16_t keycode, keyrecord_t *record);
-void steno_init(void);
-void steno_set_mode(steno_mode_t mode);
+bool process_steno(uint16_t keycode, keyrecord_t *record);
+void steno_init(void);
+void steno_set_mode(steno_mode_t mode);
uint8_t *steno_get_state(void);
uint8_t *steno_get_chord(void);
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 16d33dddee..16756e59c2 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -17,7 +17,7 @@
#include "action_tapping.h"
#ifndef TAPPING_TERM
-#define TAPPING_TERM 200
+# define TAPPING_TERM 200
#endif
#ifndef NO_ACTION_ONESHOT
@@ -25,191 +25,173 @@ uint8_t get_oneshot_mods(void);
#endif
static uint16_t last_td;
-static int8_t highest_td = -1;
+static int8_t highest_td = -1;
-void qk_tap_dance_pair_on_each_tap (qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data) {
+ qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
- if (state->count == 2) {
- register_code16 (pair->kc2);
- state->finished = true;
- }
+ if (state->count == 2) {
+ register_code16(pair->kc2);
+ state->finished = true;
+ }
}
-void qk_tap_dance_pair_finished (qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data) {
+ qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
- if (state->count == 1) {
- register_code16 (pair->kc1);
- } else if (state->count == 2) {
- register_code16 (pair->kc2);
- }
+ if (state->count == 1) {
+ register_code16(pair->kc1);
+ } else if (state->count == 2) {
+ register_code16(pair->kc2);
+ }
}
-void qk_tap_dance_pair_reset (qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
+void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data) {
+ qk_tap_dance_pair_t *pair = (qk_tap_dance_pair_t *)user_data;
- if (state->count == 1) {
- unregister_code16 (pair->kc1);
- } else if (state->count == 2) {
- unregister_code16 (pair->kc2);
- }
+ if (state->count == 1) {
+ unregister_code16(pair->kc1);
+ } else if (state->count == 2) {
+ unregister_code16(pair->kc2);
+ }
}
-void qk_tap_dance_dual_role_on_each_tap (qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_data) {
+ qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
- if (state->count == 2) {
- layer_move (pair->layer);
- state->finished = true;
- }
+ if (state->count == 2) {
+ layer_move(pair->layer);
+ state->finished = true;
+ }
}
-void qk_tap_dance_dual_role_finished (qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_data) {
+ qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
- if (state->count == 1) {
- register_code16 (pair->kc);
- } else if (state->count == 2) {
- layer_move (pair->layer);
- }
+ if (state->count == 1) {
+ register_code16(pair->kc);
+ } else if (state->count == 2) {
+ pair->layer_function(pair->layer);
+ }
}
-void qk_tap_dance_dual_role_reset (qk_tap_dance_state_t *state, void *user_data) {
- qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
+void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data) {
+ qk_tap_dance_dual_role_t *pair = (qk_tap_dance_dual_role_t *)user_data;
- if (state->count == 1) {
- unregister_code16 (pair->kc);
- }
+ if (state->count == 1) {
+ unregister_code16(pair->kc);
+ }
}
-static inline void _process_tap_dance_action_fn (qk_tap_dance_state_t *state,
- void *user_data,
- qk_tap_dance_user_fn_t fn)
-{
- if (fn) {
- fn(state, user_data);
- }
+static inline void _process_tap_dance_action_fn(qk_tap_dance_state_t *state, void *user_data, qk_tap_dance_user_fn_t fn) {
+ if (fn) {
+ fn(state, user_data);
+ }
}
-static 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);
-}
+static 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); }
-static inline void process_tap_dance_action_on_dance_finished (qk_tap_dance_action_t *action)
-{
- if (action->state.finished)
- return;
- action->state.finished = true;
- add_mods(action->state.oneshot_mods);
- add_weak_mods(action->state.weak_mods);
- send_keyboard_report();
- _process_tap_dance_action_fn (&action->state, action->user_data, action->fn.on_dance_finished);
+static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) {
+ if (action->state.finished) return;
+ action->state.finished = true;
+ add_mods(action->state.oneshot_mods);
+ add_weak_mods(action->state.weak_mods);
+ send_keyboard_report();
+ _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_dance_finished);
}
-static inline void process_tap_dance_action_on_reset (qk_tap_dance_action_t *action)
-{
- _process_tap_dance_action_fn (&action->state, action->user_data, action->fn.on_reset);
- del_mods(action->state.oneshot_mods);
- del_weak_mods(action->state.weak_mods);
- send_keyboard_report();
+static inline void process_tap_dance_action_on_reset(qk_tap_dance_action_t *action) {
+ _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_reset);
+ del_mods(action->state.oneshot_mods);
+ del_weak_mods(action->state.weak_mods);
+ send_keyboard_report();
}
void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
- qk_tap_dance_action_t *action;
-
- if (!record->event.pressed)
- return;
-
- if (highest_td == -1)
- return;
-
- for (int i = 0; i <= highest_td; i++) {
- action = &tap_dance_actions[i];
- if (action->state.count) {
- if (keycode == action->state.keycode && keycode == last_td)
- continue;
- action->state.interrupted = true;
- action->state.interrupting_keycode = keycode;
- process_tap_dance_action_on_dance_finished (action);
- reset_tap_dance (&action->state);
+ qk_tap_dance_action_t *action;
+
+ if (!record->event.pressed) return;
+
+ if (highest_td == -1) return;
+
+ for (int i = 0; i <= highest_td; i++) {
+ action = &tap_dance_actions[i];
+ if (action->state.count) {
+ if (keycode == action->state.keycode && keycode == last_td) continue;
+ action->state.interrupted = true;
+ action->state.interrupting_keycode = keycode;
+ process_tap_dance_action_on_dance_finished(action);
+ reset_tap_dance(&action->state);
+ }
}
- }
}
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
- uint16_t idx = keycode - QK_TAP_DANCE;
- qk_tap_dance_action_t *action;
-
- switch(keycode) {
- case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
- if ((int16_t)idx > highest_td)
- highest_td = idx;
- action = &tap_dance_actions[idx];
-
- action->state.pressed = record->event.pressed;
- if (record->event.pressed) {
- action->state.keycode = keycode;
- action->state.count++;
- action->state.timer = timer_read();
+ uint16_t idx = keycode - QK_TAP_DANCE;
+ qk_tap_dance_action_t *action;
+
+ switch (keycode) {
+ case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
+ if ((int16_t)idx > highest_td) highest_td = idx;
+ action = &tap_dance_actions[idx];
+
+ action->state.pressed = record->event.pressed;
+ if (record->event.pressed) {
+ action->state.keycode = keycode;
+ action->state.count++;
+ action->state.timer = timer_read();
#ifndef NO_ACTION_ONESHOT
- action->state.oneshot_mods = get_oneshot_mods();
+ action->state.oneshot_mods = get_oneshot_mods();
#else
- action->state.oneshot_mods = 0;
+ action->state.oneshot_mods = 0;
#endif
- action->state.weak_mods = get_mods();
- action->state.weak_mods |= get_weak_mods();
- process_tap_dance_action_on_each_tap (action);
-
- last_td = keycode;
- } else {
- if (action->state.count && action->state.finished) {
- reset_tap_dance (&action->state);
- }
+ action->state.weak_mods = get_mods();
+ action->state.weak_mods |= get_weak_mods();
+ process_tap_dance_action_on_each_tap(action);
+
+ last_td = keycode;
+ } else {
+ if (action->state.count && action->state.finished) {
+ reset_tap_dance(&action->state);
+ }
+ }
+
+ break;
}
- break;
- }
-
- return true;
+ return true;
}
-
-
-void matrix_scan_tap_dance () {
- if (highest_td == -1)
- return;
- uint16_t tap_user_defined;
-
- for (uint8_t i = 0; i <= highest_td; i++) {
- qk_tap_dance_action_t *action = &tap_dance_actions[i];
- if(action->custom_tapping_term > 0 ) {
- tap_user_defined = action->custom_tapping_term;
- }
- else{
- tap_user_defined = TAPPING_TERM;
- }
- if (action->state.count && timer_elapsed (action->state.timer) > tap_user_defined) {
- process_tap_dance_action_on_dance_finished (action);
- reset_tap_dance (&action->state);
+void matrix_scan_tap_dance() {
+ if (highest_td == -1) return;
+ uint16_t tap_user_defined;
+
+ for (uint8_t i = 0; i <= highest_td; i++) {
+ qk_tap_dance_action_t *action = &tap_dance_actions[i];
+ if (action->custom_tapping_term > 0) {
+ tap_user_defined = action->custom_tapping_term;
+ } else {
+ tap_user_defined = TAPPING_TERM;
+ }
+ if (action->state.count && timer_elapsed(action->state.timer) > tap_user_defined) {
+ process_tap_dance_action_on_dance_finished(action);
+ reset_tap_dance(&action->state);
+ }
}
- }
}
-void reset_tap_dance (qk_tap_dance_state_t *state) {
- qk_tap_dance_action_t *action;
+void reset_tap_dance(qk_tap_dance_state_t *state) {
+ qk_tap_dance_action_t *action;
- if (state->pressed)
- return;
+ if (state->pressed) return;
- action = &tap_dance_actions[state->keycode - QK_TAP_DANCE];
+ action = &tap_dance_actions[state->keycode - QK_TAP_DANCE];
- process_tap_dance_action_on_reset (action);
+ process_tap_dance_action_on_reset(action);
- state->count = 0;
- state->interrupted = false;
- state->finished = false;
- state->interrupting_keycode = 0;
- last_td = 0;
+ state->count = 0;
+ state->interrupted = false;
+ state->finished = false;
+ state->interrupting_keycode = 0;
+ last_td = 0;
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index ca12f4746e..09ceef74d8 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -18,75 +18,66 @@
#ifdef TAP_DANCE_ENABLE
-#include <stdbool.h>
-#include <inttypes.h>
-
-typedef struct
-{
- uint8_t count;
- uint8_t oneshot_mods;
- uint8_t weak_mods;
- uint16_t keycode;
- uint16_t interrupting_keycode;
- uint16_t timer;
- bool interrupted;
- bool pressed;
- bool finished;
+# include <stdbool.h>
+# include <inttypes.h>
+
+typedef struct {
+ uint8_t count;
+ uint8_t oneshot_mods;
+ uint8_t weak_mods;
+ uint16_t keycode;
+ uint16_t interrupting_keycode;
+ uint16_t timer;
+ bool interrupted;
+ bool pressed;
+ bool finished;
} qk_tap_dance_state_t;
-#define TD(n) (QK_TAP_DANCE + n)
+# define TD(n) (QK_TAP_DANCE | ((n)&0xFF))
-typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state, void *user_data);
+typedef void (*qk_tap_dance_user_fn_t)(qk_tap_dance_state_t *state, void *user_data);
-typedef struct
-{
- struct {
- qk_tap_dance_user_fn_t on_each_tap;
- qk_tap_dance_user_fn_t on_dance_finished;
- qk_tap_dance_user_fn_t on_reset;
- } fn;
- qk_tap_dance_state_t state;
- uint16_t custom_tapping_term;
- void *user_data;
+typedef struct {
+ struct {
+ qk_tap_dance_user_fn_t on_each_tap;
+ qk_tap_dance_user_fn_t on_dance_finished;
+ qk_tap_dance_user_fn_t on_reset;
+ } fn;
+ qk_tap_dance_state_t state;
+ uint16_t custom_tapping_term;
+ void * user_data;
} qk_tap_dance_action_t;
-typedef struct
-{
- uint16_t kc1;
- uint16_t kc2;
+typedef struct {
+ uint16_t kc1;
+ uint16_t kc2;
} qk_tap_dance_pair_t;
-typedef struct
-{
- uint16_t kc;
- uint8_t layer;
+typedef struct {
+ uint16_t kc;
+ uint8_t layer;
+ void (*layer_function)(uint8_t);
} qk_tap_dance_dual_role_t;
-#define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \
- .fn = { qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset }, \
- .user_data = (void *)&((qk_tap_dance_pair_t) { kc1, kc2 }), \
- }
+# define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \
+ { .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), }
-#define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) { \
- .fn = { qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, \
- .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer }), \
- }
+# define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) \
+ { .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_move}), }
-#define ACTION_TAP_DANCE_FN(user_fn) { \
- .fn = { NULL, user_fn, NULL }, \
- .user_data = NULL, \
- }
+# define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \
+ { .fn = {NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_invert}), }
-#define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset) { \
- .fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset }, \
- .user_data = NULL, \
- }
+# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer)
-#define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) { \
- .fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset }, \
- .user_data = NULL, \
- .custom_tapping_term = tap_specific_tapping_term, \
- }
+# define ACTION_TAP_DANCE_FN(user_fn) \
+ { .fn = {NULL, user_fn, NULL}, .user_data = NULL, }
+
+# define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset) \
+ { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, }
+
+# define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \
+ { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, }
extern qk_tap_dance_action_t tap_dance_actions[];
@@ -94,20 +85,20 @@ extern qk_tap_dance_action_t tap_dance_actions[];
void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record);
bool process_tap_dance(uint16_t keycode, keyrecord_t *record);
-void matrix_scan_tap_dance (void);
-void reset_tap_dance (qk_tap_dance_state_t *state);
+void matrix_scan_tap_dance(void);
+void reset_tap_dance(qk_tap_dance_state_t *state);
-void qk_tap_dance_pair_on_each_tap (qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_pair_finished (qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_pair_reset (qk_tap_dance_state_t *state, void *user_data);
+void qk_tap_dance_pair_on_each_tap(qk_tap_dance_state_t *state, void *user_data);
+void qk_tap_dance_pair_finished(qk_tap_dance_state_t *state, void *user_data);
+void qk_tap_dance_pair_reset(qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_on_each_tap (qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_finished (qk_tap_dance_state_t *state, void *user_data);
-void qk_tap_dance_dual_role_reset (qk_tap_dance_state_t *state, void *user_data);
+void qk_tap_dance_dual_role_on_each_tap(qk_tap_dance_state_t *state, void *user_data);
+void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_data);
+void qk_tap_dance_dual_role_reset(qk_tap_dance_state_t *state, void *user_data);
#else
-#define TD(n) KC_NO
+# define TD(n) KC_NO
#endif
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c
index e791deffc1..f48f3d702d 100644
--- a/quantum/process_keycode/process_terminal.c
+++ b/quantum/process_keycode/process_terminal.c
@@ -21,62 +21,45 @@
#include <math.h>
#ifndef CMD_BUFF_SIZE
- #define CMD_BUFF_SIZE 5
+# define CMD_BUFF_SIZE 5
#endif
-
bool terminal_enabled = false;
-char buffer[80] = "";
+char buffer[80] = "";
char cmd_buffer[CMD_BUFF_SIZE][80];
-bool cmd_buffer_enabled = true; //replace with ifdef?
-char newline[2] = "\n";
+bool cmd_buffer_enabled = true; // replace with ifdef?
+char newline[2] = "\n";
char arguments[6][20];
bool firstTime = true;
-short int current_cmd_buffer_pos = 0; //used for up/down arrows - keeps track of where you are in the command buffer
+short int current_cmd_buffer_pos = 0; // used for up/down arrows - keeps track of where you are in the command buffer
-__attribute__ ((weak))
-const char terminal_prompt[8] = "> ";
+__attribute__((weak)) const char terminal_prompt[8] = "> ";
#ifdef AUDIO_ENABLE
- #ifndef TERMINAL_SONG
- #define TERMINAL_SONG SONG(TERMINAL_SOUND)
- #endif
- float terminal_song[][2] = TERMINAL_SONG;
- #define TERMINAL_BELL() PLAY_SONG(terminal_song)
+# ifndef TERMINAL_SONG
+# define TERMINAL_SONG SONG(TERMINAL_SOUND)
+# endif
+float terminal_song[][2] = TERMINAL_SONG;
+# define TERMINAL_BELL() PLAY_SONG(terminal_song)
#else
- #define TERMINAL_BELL()
+# define TERMINAL_BELL()
#endif
-__attribute__ ((weak))
-const char keycode_to_ascii_lut[58] = {
- 0, 0, 0, 0,
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t',
- ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/'
-};
-
-__attribute__ ((weak))
-const char shifted_keycode_to_ascii_lut[58] = {
- 0, 0, 0, 0,
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', 0, 0, 0, '\t',
- ' ', '_', '+', '{', '}', '|', 0, ':', '\'', '~', '<', '>', '?'
-};
+__attribute__((weak)) const char keycode_to_ascii_lut[58] = {0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t', ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/'};
+
+__attribute__((weak)) const char shifted_keycode_to_ascii_lut[58] = {0, 0, 0, 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', 0, 0, 0, '\t', ' ', '_', '+', '{', '}', '|', 0, ':', '\'', '~', '<', '>', '?'};
struct stringcase {
- char* string;
+ char *string;
void (*func)(void);
} typedef stringcase;
void enable_terminal(void) {
terminal_enabled = true;
strcpy(buffer, "");
- memset(cmd_buffer,0,CMD_BUFF_SIZE * 80);
- for (int i = 0; i < 6; i++)
- strcpy(arguments[i], "");
+ memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80);
+ for (int i = 0; i < 6; i++) strcpy(arguments[i], "");
// select all text to start over
// SEND_STRING(SS_LCTRL("a"));
send_string(terminal_prompt);
@@ -88,41 +71,41 @@ void disable_terminal(void) {
}
void push_to_cmd_buffer(void) {
-if (cmd_buffer_enabled) {
- if (cmd_buffer == NULL) {
- return;
- } else {
- if (firstTime) {
- firstTime = false;
- strcpy(cmd_buffer[0],buffer);
- return;
- }
+ if (cmd_buffer_enabled) {
+ if (cmd_buffer == NULL) {
+ return;
+ } else {
+ if (firstTime) {
+ firstTime = false;
+ strcpy(cmd_buffer[0], buffer);
+ return;
+ }
- for (int i= CMD_BUFF_SIZE - 1;i > 0 ;--i) {
- strncpy(cmd_buffer[i],cmd_buffer[i-1],80);
- }
+ for (int i = CMD_BUFF_SIZE - 1; i > 0; --i) {
+ strncpy(cmd_buffer[i], cmd_buffer[i - 1], 80);
+ }
- strcpy(cmd_buffer[0],buffer);
+ strcpy(cmd_buffer[0], buffer);
- return;
+ return;
+ }
}
- }
}
void terminal_about(void) {
SEND_STRING("QMK Firmware\n");
SEND_STRING(" v");
SEND_STRING(QMK_VERSION);
- SEND_STRING("\n"SS_TAP(X_HOME)" Built: ");
+ SEND_STRING("\n" SS_TAP(X_HOME) " Built: ");
SEND_STRING(QMK_BUILDDATE);
send_string(newline);
- #ifdef TERMINAL_HELP
- if (strlen(arguments[1]) != 0) {
- SEND_STRING("You entered: ");
- send_string(arguments[1]);
- send_string(newline);
- }
- #endif
+#ifdef TERMINAL_HELP
+ if (strlen(arguments[1]) != 0) {
+ SEND_STRING("You entered: ");
+ send_string(arguments[1]);
+ send_string(newline);
+ }
+#endif
}
void terminal_help(void);
@@ -131,11 +114,11 @@ extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
void terminal_keycode(void) {
if (strlen(arguments[1]) != 0 && strlen(arguments[2]) != 0 && strlen(arguments[3]) != 0) {
- char keycode_dec[5];
- char keycode_hex[5];
- uint16_t layer = strtol(arguments[1], (char **)NULL, 10);
- uint16_t row = strtol(arguments[2], (char **)NULL, 10);
- uint16_t col = strtol(arguments[3], (char **)NULL, 10);
+ char keycode_dec[5];
+ char keycode_hex[5];
+ uint16_t layer = strtol(arguments[1], (char **)NULL, 10);
+ uint16_t row = strtol(arguments[2], (char **)NULL, 10);
+ uint16_t col = strtol(arguments[3], (char **)NULL, 10);
uint16_t keycode = pgm_read_word(&keymaps[layer][row][col]);
itoa(keycode, keycode_dec, 10);
itoa(keycode, keycode_hex, 16);
@@ -145,9 +128,9 @@ void terminal_keycode(void) {
send_string(keycode_dec);
SEND_STRING(")\n");
} else {
- #ifdef TERMINAL_HELP
- SEND_STRING("usage: keycode <layer> <row> <col>\n");
- #endif
+#ifdef TERMINAL_HELP
+ SEND_STRING("usage: keycode <layer> <row> <col>\n");
+#endif
}
}
@@ -157,53 +140,44 @@ void terminal_keymap(void) {
for (int r = 0; r < MATRIX_ROWS; r++) {
for (int c = 0; c < MATRIX_COLS; c++) {
uint16_t keycode = pgm_read_word(&keymaps[layer][r][c]);
- char keycode_s[8];
+ char keycode_s[8];
sprintf(keycode_s, "0x%04x,", keycode);
send_string(keycode_s);
}
send_string(newline);
}
} else {
- #ifdef TERMINAL_HELP
- SEND_STRING("usage: keymap <layer>\n");
- #endif
+#ifdef TERMINAL_HELP
+ SEND_STRING("usage: keymap <layer>\n");
+#endif
}
}
void print_cmd_buff(void) {
- /* without the below wait, a race condition can occur wherein the
- buffer can be printed before it has been fully moved */
- wait_ms(250);
- for(int i=0;i<CMD_BUFF_SIZE;i++){
- char tmpChar = ' ';
- itoa(i ,&tmpChar,10);
- const char * tmpCnstCharStr = &tmpChar; //because sned_string wont take a normal char *
- send_string(tmpCnstCharStr);
- SEND_STRING(". ");
- send_string(cmd_buffer[i]);
- SEND_STRING("\n");
- }
+ /* without the below wait, a race condition can occur wherein the
+ buffer can be printed before it has been fully moved */
+ wait_ms(250);
+ for (int i = 0; i < CMD_BUFF_SIZE; i++) {
+ char tmpChar = ' ';
+ itoa(i, &tmpChar, 10);
+ const char *tmpCnstCharStr = &tmpChar; // because sned_string wont take a normal char *
+ send_string(tmpCnstCharStr);
+ SEND_STRING(". ");
+ send_string(cmd_buffer[i]);
+ SEND_STRING("\n");
+ }
}
-
void flush_cmd_buffer(void) {
- memset(cmd_buffer,0,CMD_BUFF_SIZE * 80);
- SEND_STRING("Buffer Cleared!\n");
+ memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80);
+ SEND_STRING("Buffer Cleared!\n");
}
-stringcase terminal_cases[] = {
- { "about", terminal_about },
- { "help", terminal_help },
- { "keycode", terminal_keycode },
- { "keymap", terminal_keymap },
- { "flush-buffer" , flush_cmd_buffer},
- { "print-buffer" , print_cmd_buff},
- { "exit", disable_terminal }
-};
+stringcase terminal_cases[] = {{"about", terminal_about}, {"help", terminal_help}, {"keycode", terminal_keycode}, {"keymap", terminal_keymap}, {"flush-buffer", flush_cmd_buffer}, {"print-buffer", print_cmd_buff}, {"exit", disable_terminal}};
void terminal_help(void) {
SEND_STRING("commands available:\n ");
- for( stringcase* case_p = terminal_cases; case_p != terminal_cases + sizeof( terminal_cases ) / sizeof( terminal_cases[0] ); case_p++ ) {
+ for (stringcase *case_p = terminal_cases; case_p != terminal_cases + sizeof(terminal_cases) / sizeof(terminal_cases[0]); case_p++) {
send_string(case_p->string);
SEND_STRING(" ");
}
@@ -211,7 +185,7 @@ void terminal_help(void) {
}
void command_not_found(void) {
- wait_ms(50); //sometimes buffer isnt grabbed quick enough
+ wait_ms(50); // sometimes buffer isnt grabbed quick enough
SEND_STRING("command \"");
send_string(buffer);
SEND_STRING("\" not found\n");
@@ -221,9 +195,9 @@ void process_terminal_command(void) {
// we capture return bc of the order of events, so we need to manually send a newline
send_string(newline);
- char * pch;
+ char * pch;
uint8_t i = 0;
- pch = strtok(buffer, " ");
+ pch = strtok(buffer, " ");
while (pch != NULL) {
strcpy(arguments[i], pch);
pch = strtok(NULL, " ");
@@ -231,38 +205,32 @@ void process_terminal_command(void) {
}
bool command_found = false;
- for( stringcase* case_p = terminal_cases; case_p != terminal_cases + sizeof( terminal_cases ) / sizeof( terminal_cases[0] ); case_p++ ) {
- if( 0 == strcmp( case_p->string, buffer ) ) {
+ for (stringcase *case_p = terminal_cases; case_p != terminal_cases + sizeof(terminal_cases) / sizeof(terminal_cases[0]); case_p++) {
+ if (0 == strcmp(case_p->string, buffer)) {
command_found = true;
(*case_p->func)();
break;
}
}
- if (!command_found)
- command_not_found();
+ if (!command_found) command_not_found();
if (terminal_enabled) {
strcpy(buffer, "");
- for (int i = 0; i < 6; i++)
- strcpy(arguments[i], "");
+ for (int i = 0; i < 6; i++) strcpy(arguments[i], "");
SEND_STRING(SS_TAP(X_HOME));
send_string(terminal_prompt);
}
}
void check_pos(void) {
- 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...
- current_cmd_buffer_pos = CMD_BUFF_SIZE - 1;
- } 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
- current_cmd_buffer_pos = 0;
- }
+ 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...
+ current_cmd_buffer_pos = CMD_BUFF_SIZE - 1;
+ } 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
+ current_cmd_buffer_pos = 0;
+ }
}
-
-
-
bool process_terminal(uint16_t keycode, keyrecord_t *record) {
-
if (keycode == TERM_ON && record->event.pressed) {
enable_terminal();
return false;
@@ -280,59 +248,66 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) {
if (keycode < 256) {
uint8_t str_len;
- char char_to_add;
+ char char_to_add;
switch (keycode) {
case KC_ENTER:
case KC_KP_ENTER:
push_to_cmd_buffer();
current_cmd_buffer_pos = 0;
process_terminal_command();
- return false; break;
+ return false;
+ break;
case KC_ESC:
SEND_STRING("\n");
enable_terminal();
- return false; break;
+ return false;
+ break;
case KC_BSPC:
str_len = strlen(buffer);
if (str_len > 0) {
- buffer[str_len-1] = 0;
+ buffer[str_len - 1] = 0;
return true;
} else {
TERMINAL_BELL();
return false;
- } break;
+ }
+ break;
case KC_LEFT:
- return false; break;
+ return false;
+ break;
case KC_RIGHT:
- return false; break;
- case KC_UP: // 0 = recent
- check_pos(); //check our current buffer position is valid
- if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { //once we get to the top, dont do anything
- str_len = strlen(buffer);
- for(int i= 0;i < str_len ;++i) {
- send_string(SS_TAP(X_BSPACE)); //clear w/e is on the line already
- //process_terminal(KC_BSPC,record);
- }
- strncpy(buffer,cmd_buffer[current_cmd_buffer_pos],80);
+ return false;
+ break;
+ case KC_UP: // 0 = recent
+ check_pos(); // check our current buffer position is valid
+ if (current_cmd_buffer_pos <= CMD_BUFF_SIZE - 1) { // once we get to the top, dont do anything
+ str_len = strlen(buffer);
+ for (int i = 0; i < str_len; ++i) {
+ send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already
+ // process_terminal(KC_BSPC,record);
+ }
+ strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80);
- send_string(buffer);
- ++current_cmd_buffer_pos; //get ready to access the above cmd if up/down is pressed again
- }
- return false; break;
+ send_string(buffer);
+ ++current_cmd_buffer_pos; // get ready to access the above cmd if up/down is pressed again
+ }
+ return false;
+ break;
case KC_DOWN:
- check_pos();
- if (current_cmd_buffer_pos >= 0) { //once we get to the bottom, dont do anything
- str_len = strlen(buffer);
- for(int i= 0;i < str_len ;++i) {
- send_string(SS_TAP(X_BSPACE)); //clear w/e is on the line already
- //process_terminal(KC_BSPC,record);
- }
- strncpy(buffer,cmd_buffer[current_cmd_buffer_pos],79);
-
- send_string(buffer);
- --current_cmd_buffer_pos; //get ready to access the above cmd if down/up is pressed again
+ check_pos();
+ if (current_cmd_buffer_pos >= 0) { // once we get to the bottom, dont do anything
+ str_len = strlen(buffer);
+ for (int i = 0; i < str_len; ++i) {
+ send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already
+ // process_terminal(KC_BSPC,record);
+ }
+ strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79);
+
+ send_string(buffer);
+ --current_cmd_buffer_pos; // get ready to access the above cmd if down/up is pressed again
}
- return false; break;
+ return false;
+ break;
default:
if (keycode <= 58) {
char_to_add = 0;
@@ -344,11 +319,9 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) {
if (char_to_add != 0) {
strncat(buffer, &char_to_add, 1);
}
- } break;
+ }
+ break;
}
-
-
-
}
}
return true;
diff --git a/quantum/process_keycode/process_terminal.h b/quantum/process_keycode/process_terminal.h
index d945949a41..8426f442b6 100644
--- a/quantum/process_keycode/process_terminal.h
+++ b/quantum/process_keycode/process_terminal.h
@@ -22,6 +22,6 @@
extern const char keycode_to_ascii_lut[58];
extern const char shifted_keycode_to_ascii_lut[58];
extern const char terminal_prompt[8];
-bool process_terminal(uint16_t keycode, keyrecord_t *record);
+bool process_terminal(uint16_t keycode, keyrecord_t *record);
#endif \ No newline at end of file
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c
index 5de2e41fc3..024077317f 100644
--- a/quantum/process_keycode/process_ucis.c
+++ b/quantum/process_keycode/process_ucis.c
@@ -19,139 +19,133 @@
qk_ucis_state_t qk_ucis_state;
void qk_ucis_start(void) {
- qk_ucis_state.count = 0;
- qk_ucis_state.in_progress = true;
+ qk_ucis_state.count = 0;
+ qk_ucis_state.in_progress = true;
- qk_ucis_start_user();
+ qk_ucis_start_user();
}
-__attribute__((weak))
-void qk_ucis_start_user(void) {
- unicode_input_start();
- register_hex(0x2328);
- unicode_input_finish();
+__attribute__((weak)) void qk_ucis_start_user(void) {
+ unicode_input_start();
+ register_hex(0x2328);
+ unicode_input_finish();
}
-__attribute__((weak))
-void qk_ucis_success(uint8_t symbol_index) {
-}
+__attribute__((weak)) void qk_ucis_success(uint8_t symbol_index) {}
static bool is_uni_seq(char *seq) {
- uint8_t i;
+ uint8_t i;
- for (i = 0; seq[i]; i++) {
- uint16_t code;
- if (('1' <= seq[i]) && (seq[i] <= '0'))
- code = seq[i] - '1' + KC_1;
- else
- code = seq[i] - 'a' + KC_A;
+ for (i = 0; seq[i]; i++) {
+ uint16_t code;
+ if (('1' <= seq[i]) && (seq[i] <= '0'))
+ code = seq[i] - '1' + KC_1;
+ else
+ code = seq[i] - 'a' + KC_A;
- if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != code)
- return false;
- }
+ if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != code) return false;
+ }
- return (qk_ucis_state.codes[i] == KC_ENT ||
- qk_ucis_state.codes[i] == KC_SPC);
+ return (qk_ucis_state.codes[i] == KC_ENT || qk_ucis_state.codes[i] == KC_SPC);
}
-__attribute__((weak))
-void qk_ucis_symbol_fallback (void) {
- for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
- uint8_t code = qk_ucis_state.codes[i];
- register_code(code);
- unregister_code(code);
- wait_ms(UNICODE_TYPE_DELAY);
- }
+__attribute__((weak)) void qk_ucis_symbol_fallback(void) {
+ for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
+ uint8_t code = qk_ucis_state.codes[i];
+ register_code(code);
+ unregister_code(code);
+ wait_ms(UNICODE_TYPE_DELAY);
+ }
}
-void register_ucis(const char *hex) {
- for(int i = 0; hex[i]; i++) {
- uint8_t kc = 0;
- char c = hex[i];
-
- switch (c) {
- case '0':
- kc = KC_0;
- break;
- case '1' ... '9':
- kc = c - '1' + KC_1;
- break;
- case 'a' ... 'f':
- kc = c - 'a' + KC_A;
- break;
- case 'A' ... 'F':
- kc = c - 'A' + KC_A;
- break;
- }
+__attribute__((weak)) void qk_ucis_cancel(void) {}
- if (kc) {
- register_code (kc);
- unregister_code (kc);
- wait_ms (UNICODE_TYPE_DELAY);
+void register_ucis(const char *hex) {
+ for (int i = 0; hex[i]; i++) {
+ uint8_t kc = 0;
+ char c = hex[i];
+
+ switch (c) {
+ case '0':
+ kc = KC_0;
+ break;
+ case '1' ... '9':
+ kc = c - '1' + KC_1;
+ break;
+ case 'a' ... 'f':
+ kc = c - 'a' + KC_A;
+ break;
+ case 'A' ... 'F':
+ kc = c - 'A' + KC_A;
+ break;
+ }
+
+ if (kc) {
+ register_code(kc);
+ unregister_code(kc);
+ wait_ms(UNICODE_TYPE_DELAY);
+ }
}
- }
}
-bool process_ucis (uint16_t keycode, keyrecord_t *record) {
- uint8_t i;
+bool process_ucis(uint16_t keycode, keyrecord_t *record) {
+ uint8_t i;
- if (!qk_ucis_state.in_progress)
- return true;
+ if (!qk_ucis_state.in_progress) return true;
- if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH &&
- !(keycode == KC_BSPC || keycode == KC_ESC || keycode == KC_SPC || keycode == KC_ENT)) {
- return false;
- }
-
- if (!record->event.pressed)
- return true;
-
- qk_ucis_state.codes[qk_ucis_state.count] = keycode;
- qk_ucis_state.count++;
-
- if (keycode == KC_BSPC) {
- if (qk_ucis_state.count >= 2) {
- qk_ucis_state.count -= 2;
- return true;
- } else {
- qk_ucis_state.count--;
- return false;
+ if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !(keycode == KC_BSPC || keycode == KC_ESC || keycode == KC_SPC || keycode == KC_ENT)) {
+ return false;
}
- }
- if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) {
- bool symbol_found = false;
+ if (!record->event.pressed) return true;
- for (i = qk_ucis_state.count; i > 0; i--) {
- register_code (KC_BSPC);
- unregister_code (KC_BSPC);
- wait_ms(UNICODE_TYPE_DELAY);
- }
-
- if (keycode == KC_ESC) {
- qk_ucis_state.in_progress = false;
- return false;
- }
+ qk_ucis_state.codes[qk_ucis_state.count] = keycode;
+ qk_ucis_state.count++;
- unicode_input_start();
- for (i = 0; ucis_symbol_table[i].symbol; i++) {
- if (is_uni_seq (ucis_symbol_table[i].symbol)) {
- symbol_found = true;
- register_ucis(ucis_symbol_table[i].code + 2);
- break;
- }
- }
- if (!symbol_found) {
- qk_ucis_symbol_fallback();
+ if (keycode == KC_BSPC) {
+ if (qk_ucis_state.count >= 2) {
+ qk_ucis_state.count -= 2;
+ return true;
+ } else {
+ qk_ucis_state.count--;
+ return false;
+ }
}
- unicode_input_finish();
- if (symbol_found) {
- qk_ucis_success(i);
+ if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) {
+ bool symbol_found = false;
+
+ for (i = qk_ucis_state.count; i > 0; i--) {
+ register_code(KC_BSPC);
+ unregister_code(KC_BSPC);
+ wait_ms(UNICODE_TYPE_DELAY);
+ }
+
+ if (keycode == KC_ESC) {
+ qk_ucis_state.in_progress = false;
+ qk_ucis_cancel();
+ return false;
+ }
+
+ unicode_input_start();
+ for (i = 0; ucis_symbol_table[i].symbol; i++) {
+ if (is_uni_seq(ucis_symbol_table[i].symbol)) {
+ symbol_found = true;
+ register_ucis(ucis_symbol_table[i].code + 2);
+ break;
+ }
+ }
+ if (!symbol_found) {
+ qk_ucis_symbol_fallback();
+ }
+ unicode_input_finish();
+
+ if (symbol_found) {
+ qk_ucis_success(i);
+ }
+
+ qk_ucis_state.in_progress = false;
+ return false;
}
-
- qk_ucis_state.in_progress = false;
- return false;
- }
- return true;
+ return true;
}
diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h
index b114d839ab..0f93a198bb 100644
--- a/quantum/process_keycode/process_ucis.h
+++ b/quantum/process_keycode/process_ucis.h
@@ -20,30 +20,34 @@
#include "process_unicode_common.h"
#ifndef UCIS_MAX_SYMBOL_LENGTH
-#define UCIS_MAX_SYMBOL_LENGTH 32
+# define UCIS_MAX_SYMBOL_LENGTH 32
#endif
typedef struct {
- char *symbol;
- char *code;
+ char *symbol;
+ char *code;
} qk_ucis_symbol_t;
typedef struct {
- uint8_t count;
- uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
- bool in_progress:1;
+ uint8_t count;
+ uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
+ bool in_progress : 1;
} qk_ucis_state_t;
extern qk_ucis_state_t qk_ucis_state;
-#define UCIS_TABLE(...) {__VA_ARGS__, {NULL, NULL}}
-#define UCIS_SYM(name, code) {name, #code}
+#define UCIS_TABLE(...) \
+ { \
+ __VA_ARGS__, { NULL, NULL } \
+ }
+#define UCIS_SYM(name, code) \
+ { name, #code }
extern const qk_ucis_symbol_t ucis_symbol_table[];
void qk_ucis_start(void);
void qk_ucis_start_user(void);
-void qk_ucis_symbol_fallback (void);
+void qk_ucis_symbol_fallback(void);
void qk_ucis_success(uint8_t symbol_index);
void register_ucis(const char *hex);
-bool process_ucis (uint16_t keycode, keyrecord_t *record);
+bool process_ucis(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c
index 2c914013ac..18a1d8bc1f 100644
--- a/quantum/process_keycode/process_unicode.c
+++ b/quantum/process_keycode/process_unicode.c
@@ -19,10 +19,10 @@
#include "eeprom.h"
bool process_unicode(uint16_t keycode, keyrecord_t *record) {
- if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX && record->event.pressed) {
- unicode_input_start();
- register_hex(keycode & 0x7FFF);
- unicode_input_finish();
- }
- return true;
+ if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX && record->event.pressed) {
+ unicode_input_start();
+ register_hex(keycode & 0x7FFF);
+ unicode_input_finish();
+ }
+ return true;
}
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 21ac2291db..94383f19b7 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -23,220 +23,215 @@ unicode_config_t unicode_config;
uint8_t unicode_saved_mods;
#if UNICODE_SELECTED_MODES != -1
-static uint8_t selected[] = { UNICODE_SELECTED_MODES };
+static uint8_t selected[] = {UNICODE_SELECTED_MODES};
static uint8_t selected_count = sizeof selected / sizeof *selected;
static uint8_t selected_index;
#endif
void unicode_input_mode_init(void) {
- unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE);
+ unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE);
#if UNICODE_SELECTED_MODES != -1
- #if UNICODE_CYCLE_PERSIST
- // Find input_mode in selected modes
- uint8_t i;
- for (i = 0; i < selected_count; i++) {
- if (selected[i] == unicode_config.input_mode) {
- selected_index = i;
- break;
+# if UNICODE_CYCLE_PERSIST
+ // Find input_mode in selected modes
+ uint8_t i;
+ for (i = 0; i < selected_count; i++) {
+ if (selected[i] == unicode_config.input_mode) {
+ selected_index = i;
+ break;
+ }
}
- }
- if (i == selected_count) {
- // Not found: input_mode isn't selected, change to one that is
+ if (i == selected_count) {
+ // Not found: input_mode isn't selected, change to one that is
+ unicode_config.input_mode = selected[selected_index = 0];
+ }
+# else
+ // Always change to the first selected input mode
unicode_config.input_mode = selected[selected_index = 0];
- }
- #else
- // Always change to the first selected input mode
- unicode_config.input_mode = selected[selected_index = 0];
- #endif
+# endif
#endif
- dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode);
+ dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode);
}
-uint8_t get_unicode_input_mode(void) {
- return unicode_config.input_mode;
-}
+uint8_t get_unicode_input_mode(void) { return unicode_config.input_mode; }
void set_unicode_input_mode(uint8_t mode) {
- unicode_config.input_mode = mode;
- persist_unicode_input_mode();
- dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode);
+ unicode_config.input_mode = mode;
+ persist_unicode_input_mode();
+ dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode);
}
void cycle_unicode_input_mode(uint8_t offset) {
#if UNICODE_SELECTED_MODES != -1
- selected_index = (selected_index + offset) % selected_count;
- unicode_config.input_mode = selected[selected_index];
- #if UNICODE_CYCLE_PERSIST
- persist_unicode_input_mode();
- #endif
- dprintf("Unicode input mode cycle to: %u\n", unicode_config.input_mode);
+ selected_index = (selected_index + offset) % selected_count;
+ unicode_config.input_mode = selected[selected_index];
+# if UNICODE_CYCLE_PERSIST
+ persist_unicode_input_mode();
+# endif
+ dprintf("Unicode input mode cycle to: %u\n", unicode_config.input_mode);
#endif
}
-void persist_unicode_input_mode(void) {
- eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode);
-}
+void persist_unicode_input_mode(void) { eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); }
+
+__attribute__((weak)) void unicode_input_start(void) {
+ unicode_saved_mods = get_mods(); // Save current mods
+ clear_mods(); // Unregister mods to start from a clean state
+
+ switch (unicode_config.input_mode) {
+ case UC_OSX:
+ register_code(UNICODE_KEY_OSX);
+ break;
+ case UC_LNX:
+ tap_code16(UNICODE_KEY_LNX);
+ break;
+ case UC_WIN:
+ register_code(KC_LALT);
+ tap_code(KC_PPLS);
+ break;
+ case UC_WINC:
+ tap_code(UNICODE_KEY_WINC);
+ tap_code(KC_U);
+ break;
+ }
-__attribute__((weak))
-void unicode_input_start(void) {
- unicode_saved_mods = get_mods(); // Save current mods
- clear_mods(); // Unregister mods to start from a clean state
-
- switch (unicode_config.input_mode) {
- case UC_OSX:
- register_code(UNICODE_KEY_OSX);
- break;
- case UC_LNX:
- tap_code16(UNICODE_KEY_LNX);
- break;
- case UC_WIN:
- register_code(KC_LALT);
- tap_code(KC_PPLS);
- break;
- case UC_WINC:
- tap_code(UNICODE_KEY_WINC);
- tap_code(KC_U);
- break;
- }
-
- wait_ms(UNICODE_TYPE_DELAY);
+ wait_ms(UNICODE_TYPE_DELAY);
}
-__attribute__((weak))
-void unicode_input_finish(void) {
- switch (unicode_config.input_mode) {
- case UC_OSX:
- unregister_code(UNICODE_KEY_OSX);
- break;
- case UC_LNX:
- tap_code(KC_SPC);
- break;
- case UC_WIN:
- unregister_code(KC_LALT);
- break;
- case UC_WINC:
- tap_code(KC_ENTER);
- break;
- }
-
- set_mods(unicode_saved_mods); // Reregister previously set mods
+__attribute__((weak)) void unicode_input_finish(void) {
+ switch (unicode_config.input_mode) {
+ case UC_OSX:
+ unregister_code(UNICODE_KEY_OSX);
+ break;
+ case UC_LNX:
+ tap_code(KC_SPC);
+ break;
+ case UC_WIN:
+ unregister_code(KC_LALT);
+ break;
+ case UC_WINC:
+ tap_code(KC_ENTER);
+ break;
+ }
+
+ set_mods(unicode_saved_mods); // Reregister previously set mods
}
-__attribute__((weak))
-void unicode_input_cancel(void) {
- switch (unicode_config.input_mode) {
- case UC_OSX:
- unregister_code(UNICODE_KEY_OSX);
- break;
- case UC_LNX:
- case UC_WINC:
- tap_code(KC_ESC);
- break;
- case UC_WIN:
- unregister_code(KC_LALT);
- break;
- }
-
- set_mods(unicode_saved_mods); // Reregister previously set mods
+__attribute__((weak)) void unicode_input_cancel(void) {
+ switch (unicode_config.input_mode) {
+ case UC_OSX:
+ unregister_code(UNICODE_KEY_OSX);
+ break;
+ case UC_LNX:
+ case UC_WINC:
+ tap_code(KC_ESC);
+ break;
+ case UC_WIN:
+ unregister_code(KC_LALT);
+ break;
+ }
+
+ set_mods(unicode_saved_mods); // Reregister previously set mods
}
-__attribute__((weak))
-uint16_t hex_to_keycode(uint8_t hex) {
- if (hex == 0x0) {
- return KC_0;
- } else if (hex < 0xA) {
- return KC_1 + (hex - 0x1);
- } else {
- return KC_A + (hex - 0xA);
- }
+__attribute__((weak)) uint16_t hex_to_keycode(uint8_t hex) {
+ if (hex == 0x0) {
+ return KC_0;
+ } else if (hex < 0xA) {
+ return KC_1 + (hex - 0x1);
+ } else {
+ return KC_A + (hex - 0xA);
+ }
}
void register_hex(uint16_t hex) {
- for(int i = 3; i >= 0; i--) {
- uint8_t digit = ((hex >> (i*4)) & 0xF);
- tap_code(hex_to_keycode(digit));
- }
+ for (int i = 3; i >= 0; i--) {
+ uint8_t digit = ((hex >> (i * 4)) & 0xF);
+ tap_code(hex_to_keycode(digit));
+ }
}
void send_unicode_hex_string(const char *str) {
- if (!str) { return; }
-
- while (*str) {
- // Find the next code point (token) in the string
- for (; *str == ' '; str++);
- size_t n = strcspn(str, " "); // Length of the current token
- char code_point[n+1];
- strncpy(code_point, str, n);
- code_point[n] = '\0'; // Make sure it's null-terminated
-
- // Normalize the code point: make all hex digits lowercase
- for (char *p = code_point; *p; p++) {
- *p = tolower((unsigned char)*p);
+ if (!str) {
+ return;
}
- // Send the code point as a Unicode input string
- unicode_input_start();
- send_string(code_point);
- unicode_input_finish();
-
- str += n; // Move to the first ' ' (or '\0') after the current token
- }
+ while (*str) {
+ // Find the next code point (token) in the string
+ for (; *str == ' '; str++)
+ ;
+ size_t n = strcspn(str, " "); // Length of the current token
+ char code_point[n + 1];
+ strncpy(code_point, str, n);
+ code_point[n] = '\0'; // Make sure it's null-terminated
+
+ // Normalize the code point: make all hex digits lowercase
+ for (char *p = code_point; *p; p++) {
+ *p = tolower((unsigned char)*p);
+ }
+
+ // Send the code point as a Unicode input string
+ unicode_input_start();
+ send_string(code_point);
+ unicode_input_finish();
+
+ str += n; // Move to the first ' ' (or '\0') after the current token
+ }
}
bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
- if (record->event.pressed) {
- switch (keycode) {
- case UNICODE_MODE_FORWARD:
- cycle_unicode_input_mode(+1);
- break;
- case UNICODE_MODE_REVERSE:
- cycle_unicode_input_mode(-1);
- break;
-
- case UNICODE_MODE_OSX:
- set_unicode_input_mode(UC_OSX);
+ if (record->event.pressed) {
+ switch (keycode) {
+ case UNICODE_MODE_FORWARD:
+ cycle_unicode_input_mode(+1);
+ break;
+ case UNICODE_MODE_REVERSE:
+ cycle_unicode_input_mode(-1);
+ break;
+
+ case UNICODE_MODE_OSX:
+ set_unicode_input_mode(UC_OSX);
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX)
- static float song_osx[][2] = UNICODE_SONG_OSX;
- PLAY_SONG(song_osx);
+ static float song_osx[][2] = UNICODE_SONG_OSX;
+ PLAY_SONG(song_osx);
#endif
- break;
- case UNICODE_MODE_LNX:
- set_unicode_input_mode(UC_LNX);
+ break;
+ case UNICODE_MODE_LNX:
+ set_unicode_input_mode(UC_LNX);
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX)
- static float song_lnx[][2] = UNICODE_SONG_LNX;
- PLAY_SONG(song_lnx);
+ static float song_lnx[][2] = UNICODE_SONG_LNX;
+ PLAY_SONG(song_lnx);
#endif
- break;
- case UNICODE_MODE_WIN:
- set_unicode_input_mode(UC_WIN);
+ break;
+ case UNICODE_MODE_WIN:
+ set_unicode_input_mode(UC_WIN);
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN)
- static float song_win[][2] = UNICODE_SONG_WIN;
- PLAY_SONG(song_win);
+ static float song_win[][2] = UNICODE_SONG_WIN;
+ PLAY_SONG(song_win);
#endif
- break;
- case UNICODE_MODE_BSD:
- set_unicode_input_mode(UC_BSD);
+ break;
+ case UNICODE_MODE_BSD:
+ set_unicode_input_mode(UC_BSD);
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD)
- static float song_bsd[][2] = UNICODE_SONG_BSD;
- PLAY_SONG(song_bsd);
+ static float song_bsd[][2] = UNICODE_SONG_BSD;
+ PLAY_SONG(song_bsd);
#endif
- break;
- case UNICODE_MODE_WINC:
- set_unicode_input_mode(UC_WINC);
+ break;
+ case UNICODE_MODE_WINC:
+ set_unicode_input_mode(UC_WINC);
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC)
- static float song_winc[][2] = UNICODE_SONG_WINC;
- PLAY_SONG(song_winc);
+ static float song_winc[][2] = UNICODE_SONG_WINC;
+ PLAY_SONG(song_winc);
#endif
- break;
+ break;
+ }
}
- }
-#if defined(UNICODE_ENABLE)
- return process_unicode(keycode, record);
+#if defined(UNICODE_ENABLE)
+ return process_unicode(keycode, record);
#elif defined(UNICODEMAP_ENABLE)
- return process_unicodemap(keycode, record);
+ return process_unicodemap(keycode, record);
#elif defined(UCIS_ENABLE)
- return process_ucis(keycode, record);
+ return process_ucis(keycode, record);
#else
- return true;
+ return true;
#endif
}
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h
index 7340800e56..cab6eea6ea 100644
--- a/quantum/process_keycode/process_unicode_common.h
+++ b/quantum/process_keycode/process_unicode_common.h
@@ -19,60 +19,60 @@
#include "quantum.h"
#if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1
- #error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time"
+# error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time"
#endif
// Keycodes used for starting Unicode input on different platforms
#ifndef UNICODE_KEY_OSX
- #define UNICODE_KEY_OSX KC_LALT
+# define UNICODE_KEY_OSX KC_LALT
#endif
#ifndef UNICODE_KEY_LNX
- #define UNICODE_KEY_LNX LCTL(LSFT(KC_U))
+# define UNICODE_KEY_LNX LCTL(LSFT(KC_U))
#endif
#ifndef UNICODE_KEY_WINC
- #define UNICODE_KEY_WINC KC_RALT
+# define UNICODE_KEY_WINC KC_RALT
#endif
// Comma-delimited, ordered list of input modes selected for use (e.g. in cycle)
// Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX
#ifndef UNICODE_SELECTED_MODES
- #define UNICODE_SELECTED_MODES -1
+# define UNICODE_SELECTED_MODES -1
#endif
// Whether input mode changes in cycle should be written to EEPROM
#ifndef UNICODE_CYCLE_PERSIST
- #define UNICODE_CYCLE_PERSIST true
+# define UNICODE_CYCLE_PERSIST true
#endif
// Delay between starting Unicode input and sending a sequence, in ms
#ifndef UNICODE_TYPE_DELAY
- #define UNICODE_TYPE_DELAY 10
+# define UNICODE_TYPE_DELAY 10
#endif
enum unicode_input_modes {
- UC_OSX, // Mac OS X using Unicode Hex Input
- UC_LNX, // Linux using IBus
- UC_WIN, // Windows using EnableHexNumpad
- UC_BSD, // BSD (not implemented)
- UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose)
- UC__COUNT // Number of available input modes (always leave at the end)
+ UC_OSX, // Mac OS X using Unicode Hex Input
+ UC_LNX, // Linux using IBus
+ UC_WIN, // Windows using EnableHexNumpad
+ UC_BSD, // BSD (not implemented)
+ UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose)
+ UC__COUNT // Number of available input modes (always leave at the end)
};
typedef union {
- uint32_t raw;
- struct {
- uint8_t input_mode : 8;
- };
+ uint32_t raw;
+ struct {
+ uint8_t input_mode : 8;
+ };
} unicode_config_t;
extern unicode_config_t unicode_config;
extern uint8_t unicode_saved_mods;
-void unicode_input_mode_init(void);
+void unicode_input_mode_init(void);
uint8_t get_unicode_input_mode(void);
-void set_unicode_input_mode(uint8_t mode);
-void cycle_unicode_input_mode(uint8_t offset);
-void persist_unicode_input_mode(void);
+void set_unicode_input_mode(uint8_t mode);
+void cycle_unicode_input_mode(uint8_t offset);
+void persist_unicode_input_mode(void);
void unicode_input_start(void);
void unicode_input_finish(void);
@@ -83,108 +83,108 @@ void send_unicode_hex_string(const char *str);
bool process_unicode_common(uint16_t keycode, keyrecord_t *record);
-#define UC_BSPC UC(0x0008)
-#define UC_SPC UC(0x0020)
-
-#define UC_EXLM UC(0x0021)
-#define UC_DQUT UC(0x0022)
-#define UC_HASH UC(0x0023)
-#define UC_DLR UC(0x0024)
-#define UC_PERC UC(0x0025)
-#define UC_AMPR UC(0x0026)
-#define UC_QUOT UC(0x0027)
-#define UC_LPRN UC(0x0028)
-#define UC_RPRN UC(0x0029)
-#define UC_ASTR UC(0x002A)
-#define UC_PLUS UC(0x002B)
-#define UC_COMM UC(0x002C)
-#define UC_DASH UC(0x002D)
-#define UC_DOT UC(0x002E)
-#define UC_SLSH UC(0x002F)
-
-#define UC_0 UC(0x0030)
-#define UC_1 UC(0x0031)
-#define UC_2 UC(0x0032)
-#define UC_3 UC(0x0033)
-#define UC_4 UC(0x0034)
-#define UC_5 UC(0x0035)
-#define UC_6 UC(0x0036)
-#define UC_7 UC(0x0037)
-#define UC_8 UC(0x0038)
-#define UC_9 UC(0x0039)
+#define UC_BSPC UC(0x0008)
+#define UC_SPC UC(0x0020)
+
+#define UC_EXLM UC(0x0021)
+#define UC_DQUT UC(0x0022)
+#define UC_HASH UC(0x0023)
+#define UC_DLR UC(0x0024)
+#define UC_PERC UC(0x0025)
+#define UC_AMPR UC(0x0026)
+#define UC_QUOT UC(0x0027)
+#define UC_LPRN UC(0x0028)
+#define UC_RPRN UC(0x0029)
+#define UC_ASTR UC(0x002A)
+#define UC_PLUS UC(0x002B)
+#define UC_COMM UC(0x002C)
+#define UC_DASH UC(0x002D)
+#define UC_DOT UC(0x002E)
+#define UC_SLSH UC(0x002F)
+
+#define UC_0 UC(0x0030)
+#define UC_1 UC(0x0031)
+#define UC_2 UC(0x0032)
+#define UC_3 UC(0x0033)
+#define UC_4 UC(0x0034)
+#define UC_5 UC(0x0035)
+#define UC_6 UC(0x0036)
+#define UC_7 UC(0x0037)
+#define UC_8 UC(0x0038)
+#define UC_9 UC(0x0039)
#define UC_COLN UC(0x003A)
#define UC_SCLN UC(0x003B)
-#define UC_LT UC(0x003C)
-#define UC_EQL UC(0x003D)
-#define UC_GT UC(0x003E)
-#define UC_QUES UC(0x003F)
-#define UC_AT UC(0x0040)
-
-#define UC_A UC(0x0041)
-#define UC_B UC(0x0042)
-#define UC_C UC(0x0043)
-#define UC_D UC(0x0044)
-#define UC_E UC(0x0045)
-#define UC_F UC(0x0046)
-#define UC_G UC(0x0047)
-#define UC_H UC(0x0048)
-#define UC_I UC(0x0049)
-#define UC_J UC(0x004A)
-#define UC_K UC(0x004B)
-#define UC_L UC(0x004C)
-#define UC_M UC(0x004D)
-#define UC_N UC(0x004E)
-#define UC_O UC(0x004F)
-#define UC_P UC(0x0050)
-#define UC_Q UC(0x0051)
-#define UC_R UC(0x0052)
-#define UC_S UC(0x0053)
-#define UC_T UC(0x0054)
-#define UC_U UC(0x0055)
-#define UC_V UC(0x0056)
-#define UC_W UC(0x0057)
-#define UC_X UC(0x0058)
-#define UC_Y UC(0x0059)
-#define UC_Z UC(0x005A)
-
-#define UC_LBRC UC(0x005B)
-#define UC_BSLS UC(0x005C)
-#define UC_RBRC UC(0x005D)
-#define UC_CIRM UC(0x005E)
-#define UC_UNDR UC(0x005F)
-
-#define UC_GRV UC(0x0060)
-
-#define UC_a UC(0x0061)
-#define UC_b UC(0x0062)
-#define UC_c UC(0x0063)
-#define UC_d UC(0x0064)
-#define UC_e UC(0x0065)
-#define UC_f UC(0x0066)
-#define UC_g UC(0x0067)
-#define UC_h UC(0x0068)
-#define UC_i UC(0x0069)
-#define UC_j UC(0x006A)
-#define UC_k UC(0x006B)
-#define UC_l UC(0x006C)
-#define UC_m UC(0x006D)
-#define UC_n UC(0x006E)
-#define UC_o UC(0x006F)
-#define UC_p UC(0x0070)
-#define UC_q UC(0x0071)
-#define UC_r UC(0x0072)
-#define UC_s UC(0x0073)
-#define UC_t UC(0x0074)
-#define UC_u UC(0x0075)
-#define UC_v UC(0x0076)
-#define UC_w UC(0x0077)
-#define UC_x UC(0x0078)
-#define UC_y UC(0x0079)
-#define UC_z UC(0x007A)
-
-#define UC_LCBR UC(0x007B)
-#define UC_PIPE UC(0x007C)
-#define UC_RCBR UC(0x007D)
-#define UC_TILD UC(0x007E)
-#define UC_DEL UC(0x007F)
+#define UC_LT UC(0x003C)
+#define UC_EQL UC(0x003D)
+#define UC_GT UC(0x003E)
+#define UC_QUES UC(0x003F)
+#define UC_AT UC(0x0040)
+
+#define UC_A UC(0x0041)
+#define UC_B UC(0x0042)
+#define UC_C UC(0x0043)
+#define UC_D UC(0x0044)
+#define UC_E UC(0x0045)
+#define UC_F UC(0x0046)
+#define UC_G UC(0x0047)
+#define UC_H UC(0x0048)
+#define UC_I UC(0x0049)
+#define UC_J UC(0x004A)
+#define UC_K UC(0x004B)
+#define UC_L UC(0x004C)
+#define UC_M UC(0x004D)
+#define UC_N UC(0x004E)
+#define UC_O UC(0x004F)
+#define UC_P UC(0x0050)
+#define UC_Q UC(0x0051)
+#define UC_R UC(0x0052)
+#define UC_S UC(0x0053)
+#define UC_T UC(0x0054)
+#define UC_U UC(0x0055)
+#define UC_V UC(0x0056)
+#define UC_W UC(0x0057)
+#define UC_X UC(0x0058)
+#define UC_Y UC(0x0059)
+#define UC_Z UC(0x005A)
+
+#define UC_LBRC UC(0x005B)
+#define UC_BSLS UC(0x005C)
+#define UC_RBRC UC(0x005D)
+#define UC_CIRM UC(0x005E)
+#define UC_UNDR UC(0x005F)
+
+#define UC_GRV UC(0x0060)
+
+#define UC_a UC(0x0061)
+#define UC_b UC(0x0062)
+#define UC_c UC(0x0063)
+#define UC_d UC(0x0064)
+#define UC_e UC(0x0065)
+#define UC_f UC(0x0066)
+#define UC_g UC(0x0067)
+#define UC_h UC(0x0068)
+#define UC_i UC(0x0069)
+#define UC_j UC(0x006A)
+#define UC_k UC(0x006B)
+#define UC_l UC(0x006C)
+#define UC_m UC(0x006D)
+#define UC_n UC(0x006E)
+#define UC_o UC(0x006F)
+#define UC_p UC(0x0070)
+#define UC_q UC(0x0071)
+#define UC_r UC(0x0072)
+#define UC_s UC(0x0073)
+#define UC_t UC(0x0074)
+#define UC_u UC(0x0075)
+#define UC_v UC(0x0076)
+#define UC_w UC(0x0077)
+#define UC_x UC(0x0078)
+#define UC_y UC(0x0079)
+#define UC_z UC(0x007A)
+
+#define UC_LCBR UC(0x007B)
+#define UC_PIPE UC(0x007C)
+#define UC_RCBR UC(0x007D)
+#define UC_TILD UC(0x007E)
+#define UC_DEL UC(0x007F)
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c
index b887879860..4364f156c4 100644
--- a/quantum/process_keycode/process_unicodemap.c
+++ b/quantum/process_keycode/process_unicodemap.c
@@ -17,62 +17,63 @@
#include "process_unicodemap.h"
void register_hex32(uint32_t hex) {
- bool onzerostart = true;
- for(int i = 7; i >= 0; i--) {
- if (i <= 3) {
- onzerostart = false;
+ bool onzerostart = true;
+ for (int i = 7; i >= 0; i--) {
+ if (i <= 3) {
+ onzerostart = false;
+ }
+ uint8_t digit = ((hex >> (i * 4)) & 0xF);
+ if (digit == 0) {
+ if (!onzerostart) {
+ register_code(hex_to_keycode(digit));
+ unregister_code(hex_to_keycode(digit));
+ }
+ } else {
+ register_code(hex_to_keycode(digit));
+ unregister_code(hex_to_keycode(digit));
+ onzerostart = false;
+ }
}
- uint8_t digit = ((hex >> (i*4)) & 0xF);
- if (digit == 0) {
- if (!onzerostart) {
- register_code(hex_to_keycode(digit));
- unregister_code(hex_to_keycode(digit));
- }
- } else {
- register_code(hex_to_keycode(digit));
- unregister_code(hex_to_keycode(digit));
- onzerostart = false;
- }
- }
}
-__attribute__((weak))
-uint16_t unicodemap_index(uint16_t keycode) {
- if (keycode >= QK_UNICODEMAP_PAIR) {
- // Keycode is a pair: extract index based on Shift / Caps Lock state
- uint16_t index = keycode - QK_UNICODEMAP_PAIR;
+__attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) {
+ if (keycode >= QK_UNICODEMAP_PAIR) {
+ // Keycode is a pair: extract index based on Shift / Caps Lock state
+ uint16_t index = keycode - QK_UNICODEMAP_PAIR;
- bool shift = unicode_saved_mods & MOD_MASK_SHIFT, caps = IS_HOST_LED_ON(USB_LED_CAPS_LOCK);
- if (shift ^ caps) { index >>= 7; }
+ bool shift = unicode_saved_mods & MOD_MASK_SHIFT, caps = IS_HOST_LED_ON(USB_LED_CAPS_LOCK);
+ if (shift ^ caps) {
+ index >>= 7;
+ }
- return index & 0x7F;
- } else {
- // Keycode is a regular index
- return keycode - QK_UNICODEMAP;
- }
+ return index & 0x7F;
+ } else {
+ // Keycode is a regular index
+ return keycode - QK_UNICODEMAP;
+ }
}
bool process_unicodemap(uint16_t keycode, keyrecord_t *record) {
- if (keycode >= QK_UNICODEMAP && keycode <= QK_UNICODEMAP_PAIR_MAX && record->event.pressed) {
- unicode_input_start();
+ if (keycode >= QK_UNICODEMAP && keycode <= QK_UNICODEMAP_PAIR_MAX && record->event.pressed) {
+ unicode_input_start();
- uint32_t code = pgm_read_dword(unicode_map + unicodemap_index(keycode));
- uint8_t input_mode = get_unicode_input_mode();
+ uint32_t code = pgm_read_dword(unicode_map + unicodemap_index(keycode));
+ uint8_t input_mode = get_unicode_input_mode();
- if (code > 0x10FFFF || (code > 0xFFFF && input_mode == UC_WIN)) {
- // Character is out of range supported by the platform
- unicode_input_cancel();
- } else if (code > 0xFFFF && input_mode == UC_OSX) {
- // Convert to UTF-16 surrogate pair on Mac
- code -= 0x10000;
- uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10;
- register_hex32(hi + 0xD800);
- register_hex32(lo + 0xDC00);
- unicode_input_finish();
- } else {
- register_hex32(code);
- unicode_input_finish();
+ if (code > 0x10FFFF || (code > 0xFFFF && input_mode == UC_WIN)) {
+ // Character is out of range supported by the platform
+ unicode_input_cancel();
+ } else if (code > 0xFFFF && input_mode == UC_OSX) {
+ // Convert to UTF-16 surrogate pair on Mac
+ code -= 0x10000;
+ uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10;
+ register_hex32(hi + 0xD800);
+ register_hex32(lo + 0xDC00);
+ unicode_input_finish();
+ } else {
+ register_hex32(code);
+ unicode_input_finish();
+ }
}
- }
- return true;
+ return true;
}
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h
index 51709c5dc8..a4b6d77f3a 100644
--- a/quantum/process_keycode/process_unicodemap.h
+++ b/quantum/process_keycode/process_unicodemap.h
@@ -20,6 +20,6 @@
extern const uint32_t PROGMEM unicode_map[];
-void register_hex32(uint32_t hex);
+void register_hex32(uint32_t hex);
uint16_t unicodemap_index(uint16_t keycode);
-bool process_unicodemap(uint16_t keycode, keyrecord_t *record);
+bool process_unicodemap(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 6530738b71..2e5e6376b7 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -17,179 +17,151 @@
#include "quantum.h"
#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
- #include "rgb.h"
+# include "rgb.h"
#endif
#ifdef PROTOCOL_LUFA
-#include "outputselect.h"
+# include "outputselect.h"
#endif
-#ifndef BREATHING_PERIOD
-#define BREATHING_PERIOD 6
-#endif
-
-#include "backlight.h"
+#ifdef BACKLIGHT_ENABLE
+# include "backlight.h"
extern backlight_config_t backlight_config;
+#endif
#ifdef FAUXCLICKY_ENABLE
-#include "fauxclicky.h"
+# include "fauxclicky.h"
#endif
#ifdef API_ENABLE
-#include "api.h"
+# include "api.h"
#endif
#ifdef MIDI_ENABLE
-#include "process_midi.h"
+# include "process_midi.h"
#endif
#ifdef VELOCIKEY_ENABLE
-#include "velocikey.h"
+# include "velocikey.h"
#endif
#ifdef HAPTIC_ENABLE
- #include "haptic.h"
+# include "haptic.h"
#endif
#ifdef ENCODER_ENABLE
-#include "encoder.h"
+# include "encoder.h"
#endif
#ifdef AUDIO_ENABLE
- #ifndef GOODBYE_SONG
- #define GOODBYE_SONG SONG(GOODBYE_SOUND)
- #endif
- #ifndef AG_NORM_SONG
- #define AG_NORM_SONG SONG(AG_NORM_SOUND)
- #endif
- #ifndef AG_SWAP_SONG
- #define AG_SWAP_SONG SONG(AG_SWAP_SOUND)
- #endif
- float goodbye_song[][2] = GOODBYE_SONG;
- float ag_norm_song[][2] = AG_NORM_SONG;
- float ag_swap_song[][2] = AG_SWAP_SONG;
- #ifdef DEFAULT_LAYER_SONGS
- float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
- #endif
-#endif
-
-static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
- switch (code) {
- case QK_MODS ... QK_MODS_MAX:
- break;
- default:
- return;
- }
-
- if (code & QK_LCTL)
- f(KC_LCTL);
- if (code & QK_LSFT)
- f(KC_LSFT);
- if (code & QK_LALT)
- f(KC_LALT);
- if (code & QK_LGUI)
- f(KC_LGUI);
-
- if (code < QK_RMODS_MIN) return;
-
- if (code & QK_RCTL)
- f(KC_RCTL);
- if (code & QK_RSFT)
- f(KC_RSFT);
- if (code & QK_RALT)
- f(KC_RALT);
- if (code & QK_RGUI)
- f(KC_RGUI);
-}
-
-static inline void qk_register_weak_mods(uint8_t kc) {
- add_weak_mods(MOD_BIT(kc));
- send_keyboard_report();
-}
+# ifndef GOODBYE_SONG
+# define GOODBYE_SONG SONG(GOODBYE_SOUND)
+# endif
+# ifndef AG_NORM_SONG
+# define AG_NORM_SONG SONG(AG_NORM_SOUND)
+# endif
+# ifndef AG_SWAP_SONG
+# define AG_SWAP_SONG SONG(AG_SWAP_SOUND)
+# endif
+# ifndef CG_NORM_SONG
+# define CG_NORM_SONG SONG(AG_NORM_SOUND)
+# endif
+# ifndef CG_SWAP_SONG
+# define CG_SWAP_SONG SONG(AG_SWAP_SOUND)
+# endif
+float goodbye_song[][2] = GOODBYE_SONG;
+float ag_norm_song[][2] = AG_NORM_SONG;
+float ag_swap_song[][2] = AG_SWAP_SONG;
+float cg_norm_song[][2] = CG_NORM_SONG;
+float cg_swap_song[][2] = CG_SWAP_SONG;
+# ifdef DEFAULT_LAYER_SONGS
+float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
+# endif
+#endif
-static inline void qk_unregister_weak_mods(uint8_t kc) {
- del_weak_mods(MOD_BIT(kc));
- send_keyboard_report();
-}
+static void do_code16(uint16_t code, void (*f)(uint8_t)) {
+ switch (code) {
+ case QK_MODS ... QK_MODS_MAX:
+ break;
+ default:
+ return;
+ }
-static inline void qk_register_mods(uint8_t kc) {
- add_weak_mods(MOD_BIT(kc));
- send_keyboard_report();
-}
+ uint8_t mods_to_send = 0;
+
+ if (code & QK_RMODS_MIN) { // Right mod flag is set
+ if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL);
+ if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT);
+ if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT);
+ if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI);
+ } else {
+ if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL);
+ if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT);
+ if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT);
+ if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI);
+ }
-static inline void qk_unregister_mods(uint8_t kc) {
- del_weak_mods(MOD_BIT(kc));
- send_keyboard_report();
+ f(mods_to_send);
}
-void register_code16 (uint16_t code) {
- if (IS_MOD(code) || code == KC_NO) {
- do_code16 (code, qk_register_mods);
- } else {
- do_code16 (code, qk_register_weak_mods);
- }
- register_code (code);
+void register_code16(uint16_t code) {
+ if (IS_MOD(code) || code == KC_NO) {
+ do_code16(code, register_mods);
+ } else {
+ do_code16(code, register_weak_mods);
+ }
+ register_code(code);
}
-void unregister_code16 (uint16_t code) {
- unregister_code (code);
- if (IS_MOD(code) || code == KC_NO) {
- do_code16 (code, qk_unregister_mods);
- } else {
- do_code16 (code, qk_unregister_weak_mods);
- }
+void unregister_code16(uint16_t code) {
+ unregister_code(code);
+ if (IS_MOD(code) || code == KC_NO) {
+ do_code16(code, unregister_mods);
+ } else {
+ do_code16(code, unregister_weak_mods);
+ }
}
void tap_code16(uint16_t code) {
- register_code16(code);
- #if TAP_CODE_DELAY > 0
+ register_code16(code);
+#if TAP_CODE_DELAY > 0
wait_ms(TAP_CODE_DELAY);
- #endif
- unregister_code16(code);
+#endif
+ unregister_code16(code);
}
-__attribute__ ((weak))
-bool process_action_kb(keyrecord_t *record) {
- return true;
-}
+__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; }
-__attribute__ ((weak))
-bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
- return process_record_user(keycode, record);
-}
+__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); }
-__attribute__ ((weak))
-bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- return true;
-}
+__attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; }
void reset_keyboard(void) {
- clear_keyboard();
+ clear_keyboard();
#if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
- process_midi_all_notes_off();
+ process_midi_all_notes_off();
#endif
#ifdef AUDIO_ENABLE
- #ifndef NO_MUSIC_MODE
+# ifndef NO_MUSIC_MODE
music_all_notes_off();
- #endif
- uint16_t timer_start = timer_read();
- PLAY_SONG(goodbye_song);
- shutdown_user();
- while(timer_elapsed(timer_start) < 250)
- wait_ms(1);
- stop_all_notes();
+# endif
+ uint16_t timer_start = timer_read();
+ PLAY_SONG(goodbye_song);
+ shutdown_user();
+ while (timer_elapsed(timer_start) < 250) wait_ms(1);
+ stop_all_notes();
#else
- shutdown_user();
- wait_ms(250);
+ shutdown_user();
+ wait_ms(250);
#endif
#ifdef HAPTIC_ENABLE
- haptic_shutdown();
+ haptic_shutdown();
#endif
// this is also done later in bootloader.c - not sure if it's neccesary here
#ifdef BOOTLOADER_CATERINA
- *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
+ *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
- bootloader_jump();
+ bootloader_jump();
}
/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
@@ -198,31 +170,27 @@ void reset_keyboard(void) {
static bool grave_esc_was_shifted = false;
/* Convert record into usable keycode via the contained event. */
-uint16_t get_record_keycode(keyrecord_t *record) {
- return get_event_keycode(record->event);
-}
-
+uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); }
/* Convert event into usable keycode. Checks the layer cache to ensure that it
* retains the correct keycode after a layer change, if the key is still pressed.
*/
uint16_t get_event_keycode(keyevent_t event) {
-
- #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
+#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
/* TODO: Use store_or_get_action() or a similar function. */
if (!disable_action_cache) {
- uint8_t layer;
-
- if (event.pressed) {
- layer = layer_switch_get_layer(event.key);
- update_source_layers_cache(event.key, layer);
- } else {
- layer = read_source_layers_cache(event.key);
- }
- return keymap_key_to_keycode(layer, event.key);
+ uint8_t layer;
+
+ if (event.pressed) {
+ layer = layer_switch_get_layer(event.key);
+ update_source_layers_cache(event.key, layer);
+ } else {
+ layer = read_source_layers_cache(event.key);
+ }
+ return keymap_key_to_keycode(layer, event.key);
} else
- #endif
- return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
+#endif
+ return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
}
/* Main keycode processing function. Hands off handling to other functions,
@@ -239,576 +207,595 @@ bool process_record_quantum(keyrecord_t *record) {
// return false;
// }
- #ifdef VELOCIKEY_ENABLE
- if (velocikey_enabled() && record->event.pressed) { velocikey_accelerate(); }
- #endif
+#ifdef VELOCIKEY_ENABLE
+ if (velocikey_enabled() && record->event.pressed) {
+ velocikey_accelerate();
+ }
+#endif
- #ifdef TAP_DANCE_ENABLE
+#ifdef TAP_DANCE_ENABLE
preprocess_tap_dance(keycode, record);
- #endif
-
- if (!(
- #if defined(KEY_LOCK_ENABLE)
- // Must run first to be able to mask key_up events.
- process_key_lock(&keycode, record) &&
- #endif
- #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
- process_clicky(keycode, record) &&
- #endif //AUDIO_CLICKY
- #ifdef HAPTIC_ENABLE
- process_haptic(keycode, record) &&
- #endif //HAPTIC_ENABLE
- #if defined(RGB_MATRIX_ENABLE)
- process_rgb_matrix(keycode, record) &&
- #endif
- process_record_kb(keycode, record) &&
- #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
- process_midi(keycode, record) &&
- #endif
- #ifdef AUDIO_ENABLE
- process_audio(keycode, record) &&
- #endif
- #ifdef STENO_ENABLE
- process_steno(keycode, record) &&
- #endif
- #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
- process_music(keycode, record) &&
- #endif
- #ifdef TAP_DANCE_ENABLE
- process_tap_dance(keycode, record) &&
- #endif
- #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
- process_unicode_common(keycode, record) &&
- #endif
- #ifdef LEADER_ENABLE
- process_leader(keycode, record) &&
- #endif
- #ifdef COMBO_ENABLE
- process_combo(keycode, record) &&
- #endif
- #ifdef PRINTING_ENABLE
- process_printer(keycode, record) &&
- #endif
- #ifdef AUTO_SHIFT_ENABLE
- process_auto_shift(keycode, record) &&
- #endif
- #ifdef TERMINAL_ENABLE
- process_terminal(keycode, record) &&
- #endif
- #ifdef SPACE_CADET_ENABLE
- process_space_cadet(keycode, record) &&
- #endif
- true)) {
- return false;
- }
-
- // Shift / paren setup
-
- switch(keycode) {
- case RESET:
- if (record->event.pressed) {
- reset_keyboard();
- }
- return false;
- case DEBUG:
- if (record->event.pressed) {
- debug_enable ^= 1;
- if (debug_enable) {
- print("DEBUG: enabled.\n");
- } else {
- print("DEBUG: disabled.\n");
- }
- }
- return false;
- case EEPROM_RESET:
- if (record->event.pressed) {
- eeconfig_init();
- }
- return false;
- #ifdef FAUXCLICKY_ENABLE
- case FC_TOG:
- if (record->event.pressed) {
- FAUXCLICKY_TOGGLE;
- }
- return false;
- case FC_ON:
- if (record->event.pressed) {
- FAUXCLICKY_ON;
- }
- return false;
- case FC_OFF:
- if (record->event.pressed) {
- FAUXCLICKY_OFF;
- }
- return false;
- #endif
- #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
- case RGB_TOG:
- // Split keyboards need to trigger on key-up for edge-case issue
- #ifndef SPLIT_KEYBOARD
- if (record->event.pressed) {
- #else
- if (!record->event.pressed) {
- #endif
- rgblight_toggle();
- }
- return false;
- case RGB_MODE_FORWARD:
- if (record->event.pressed) {
- uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT));
- if(shifted) {
- rgblight_step_reverse();
- }
- else {
- rgblight_step();
- }
- }
- return false;
- case RGB_MODE_REVERSE:
- if (record->event.pressed) {
- uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT));
- if(shifted) {
- rgblight_step();
- }
- else {
- rgblight_step_reverse();
- }
- }
- return false;
- case RGB_HUI:
- // Split keyboards need to trigger on key-up for edge-case issue
- #ifndef SPLIT_KEYBOARD
- if (record->event.pressed) {
- #else
- if (!record->event.pressed) {
- #endif
- rgblight_increase_hue();
- }
- return false;
- case RGB_HUD:
- // Split keyboards need to trigger on key-up for edge-case issue
- #ifndef SPLIT_KEYBOARD
- if (record->event.pressed) {
- #else
- if (!record->event.pressed) {
- #endif
- rgblight_decrease_hue();
- }
- return false;
- case RGB_SAI:
- // Split keyboards need to trigger on key-up for edge-case issue
- #ifndef SPLIT_KEYBOARD
- if (record->event.pressed) {
- #else
- if (!record->event.pressed) {
- #endif
- rgblight_increase_sat();
- }
- return false;
- case RGB_SAD:
- // Split keyboards need to trigger on key-up for edge-case issue
- #ifndef SPLIT_KEYBOARD
- if (record->event.pressed) {
- #else
- if (!record->event.pressed) {
- #endif
- rgblight_decrease_sat();
- }
- return false;
- case RGB_VAI:
- // Split keyboards need to trigger on key-up for edge-case issue
- #ifndef SPLIT_KEYBOARD
- if (record->event.pressed) {
- #else
- if (!record->event.pressed) {
- #endif
- rgblight_increase_val();
- }
- return false;
- case RGB_VAD:
- // Split keyboards need to trigger on key-up for edge-case issue
- #ifndef SPLIT_KEYBOARD
- if (record->event.pressed) {
- #else
- if (!record->event.pressed) {
- #endif
- rgblight_decrease_val();
- }
- return false;
- case RGB_SPI:
- if (record->event.pressed) {
- rgblight_increase_speed();
- }
- return false;
- case RGB_SPD:
- if (record->event.pressed) {
- rgblight_decrease_speed();
- }
- return false;
- case RGB_MODE_PLAIN:
- if (record->event.pressed) {
- rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
- }
- return false;
- case RGB_MODE_BREATHE:
- #ifdef RGBLIGHT_EFFECT_BREATHING
- if (record->event.pressed) {
- if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) &&
- (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) {
- rgblight_step();
- } else {
- rgblight_mode(RGBLIGHT_MODE_BREATHING);
- }
- }
- #endif
- return false;
- case RGB_MODE_RAINBOW:
- #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
- if (record->event.pressed) {
- if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) &&
- (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) {
- rgblight_step();
- } else {
- rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD);
- }
- }
- #endif
- return false;
- case RGB_MODE_SWIRL:
- #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
- if (record->event.pressed) {
- if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) &&
- (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) {
- rgblight_step();
- } else {
- rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
- }
- }
- #endif
- return false;
- case RGB_MODE_SNAKE:
- #ifdef RGBLIGHT_EFFECT_SNAKE
- if (record->event.pressed) {
- if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) &&
- (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) {
- rgblight_step();
- } else {
- rgblight_mode(RGBLIGHT_MODE_SNAKE);
- }
- }
- #endif
- return false;
- case RGB_MODE_KNIGHT:
- #ifdef RGBLIGHT_EFFECT_KNIGHT
- if (record->event.pressed) {
- if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) &&
- (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) {
- rgblight_step();
- } else {
- rgblight_mode(RGBLIGHT_MODE_KNIGHT);
- }
- }
- #endif
- return false;
- case RGB_MODE_XMAS:
- #ifdef RGBLIGHT_EFFECT_CHRISTMAS
- if (record->event.pressed) {
- rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
- }
- #endif
- return false;
- case RGB_MODE_GRADIENT:
- #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
- if (record->event.pressed) {
- if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) &&
- (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) {
- rgblight_step();
- } else {
- rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT);
- }
- }
- #endif
- return false;
- case RGB_MODE_RGBTEST:
- #ifdef RGBLIGHT_EFFECT_RGB_TEST
- if (record->event.pressed) {
- rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
- }
- #endif
- return false;
- #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
- #ifdef VELOCIKEY_ENABLE
- case VLK_TOG:
- if (record->event.pressed) {
- velocikey_toggle();
- }
- return false;
- #endif
- #ifdef PROTOCOL_LUFA
- case OUT_AUTO:
- if (record->event.pressed) {
- set_output(OUTPUT_AUTO);
- }
- return false;
- case OUT_USB:
- if (record->event.pressed) {
- set_output(OUTPUT_USB);
- }
- return false;
- #ifdef BLUETOOTH_ENABLE
- case OUT_BT:
- if (record->event.pressed) {
- set_output(OUTPUT_BLUETOOTH);
- }
- return false;
- #endif
- #endif
- case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO:
- if (record->event.pressed) {
- // MAGIC actions (BOOTMAGIC without the boot)
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
- /* keymap config */
- keymap_config.raw = eeconfig_read_keymap();
- switch (keycode)
- {
- case MAGIC_SWAP_CONTROL_CAPSLOCK:
- keymap_config.swap_control_capslock = true;
- break;
- case MAGIC_CAPSLOCK_TO_CONTROL:
- keymap_config.capslock_to_control = true;
- break;
- case MAGIC_SWAP_LALT_LGUI:
- keymap_config.swap_lalt_lgui = true;
- break;
- case MAGIC_SWAP_RALT_RGUI:
- keymap_config.swap_ralt_rgui = true;
- break;
- case MAGIC_NO_GUI:
- keymap_config.no_gui = true;
- break;
- case MAGIC_SWAP_GRAVE_ESC:
- keymap_config.swap_grave_esc = true;
- break;
- case MAGIC_SWAP_BACKSLASH_BACKSPACE:
- keymap_config.swap_backslash_backspace = true;
- break;
- case MAGIC_HOST_NKRO:
- keymap_config.nkro = true;
- break;
- case MAGIC_SWAP_ALT_GUI:
- keymap_config.swap_lalt_lgui = true;
- keymap_config.swap_ralt_rgui = true;
- #ifdef AUDIO_ENABLE
- PLAY_SONG(ag_swap_song);
- #endif
- break;
- case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
- keymap_config.swap_control_capslock = false;
- break;
- case MAGIC_UNCAPSLOCK_TO_CONTROL:
- keymap_config.capslock_to_control = false;
- break;
- case MAGIC_UNSWAP_LALT_LGUI:
- keymap_config.swap_lalt_lgui = false;
- break;
- case MAGIC_UNSWAP_RALT_RGUI:
- keymap_config.swap_ralt_rgui = false;
- break;
- case MAGIC_UNNO_GUI:
- keymap_config.no_gui = false;
- break;
- case MAGIC_UNSWAP_GRAVE_ESC:
- keymap_config.swap_grave_esc = false;
- break;
- case MAGIC_UNSWAP_BACKSLASH_BACKSPACE:
- keymap_config.swap_backslash_backspace = false;
- break;
- case MAGIC_UNHOST_NKRO:
- keymap_config.nkro = false;
- break;
- case MAGIC_UNSWAP_ALT_GUI:
- keymap_config.swap_lalt_lgui = false;
- keymap_config.swap_ralt_rgui = false;
- #ifdef AUDIO_ENABLE
- PLAY_SONG(ag_norm_song);
- #endif
- break;
- case MAGIC_TOGGLE_ALT_GUI:
- keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui;
- keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui;
- #ifdef AUDIO_ENABLE
- if (keymap_config.swap_ralt_rgui) {
- PLAY_SONG(ag_swap_song);
- } else {
- PLAY_SONG(ag_norm_song);
- }
- #endif
- break;
- case MAGIC_TOGGLE_NKRO:
- keymap_config.nkro = !keymap_config.nkro;
- break;
- default:
- break;
- }
- eeconfig_update_keymap(keymap_config.raw);
- clear_keyboard(); // clear to prevent stuck keys
+#endif
+ if (!(
+#if defined(KEY_LOCK_ENABLE)
+ // Must run first to be able to mask key_up events.
+ process_key_lock(&keycode, record) &&
+#endif
+#if defined(DYNAMIC_MACRO_ENABLE) && !defined(DYNAMIC_MACRO_USER_CALL)
+ // Must run asap to ensure all keypresses are recorded.
+ process_dynamic_macro(keycode, record) &&
+#endif
+#if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
+ process_clicky(keycode, record) &&
+#endif // AUDIO_CLICKY
+#ifdef HAPTIC_ENABLE
+ process_haptic(keycode, record) &&
+#endif // HAPTIC_ENABLE
+#if defined(RGB_MATRIX_ENABLE)
+ process_rgb_matrix(keycode, record) &&
+#endif
+ process_record_kb(keycode, record) &&
+#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
+ process_midi(keycode, record) &&
+#endif
+#ifdef AUDIO_ENABLE
+ process_audio(keycode, record) &&
+#endif
+#ifdef STENO_ENABLE
+ process_steno(keycode, record) &&
+#endif
+#if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
+ process_music(keycode, record) &&
+#endif
+#ifdef TAP_DANCE_ENABLE
+ process_tap_dance(keycode, record) &&
+#endif
+#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
+ process_unicode_common(keycode, record) &&
+#endif
+#ifdef LEADER_ENABLE
+ process_leader(keycode, record) &&
+#endif
+#ifdef COMBO_ENABLE
+ process_combo(keycode, record) &&
+#endif
+#ifdef PRINTING_ENABLE
+ process_printer(keycode, record) &&
+#endif
+#ifdef AUTO_SHIFT_ENABLE
+ process_auto_shift(keycode, record) &&
+#endif
+#ifdef TERMINAL_ENABLE
+ process_terminal(keycode, record) &&
+#endif
+#ifdef SPACE_CADET_ENABLE
+ process_space_cadet(keycode, record) &&
+#endif
+ true)) {
return false;
- }
- break;
+ }
+
+ // Shift / paren setup
+
+ switch (keycode) {
+ case RESET:
+ if (record->event.pressed) {
+ reset_keyboard();
+ }
+ return false;
+ case DEBUG:
+ if (record->event.pressed) {
+ debug_enable ^= 1;
+ if (debug_enable) {
+ print("DEBUG: enabled.\n");
+ } else {
+ print("DEBUG: disabled.\n");
+ }
+ }
+ return false;
+ case EEPROM_RESET:
+ if (record->event.pressed) {
+ eeconfig_init();
+ }
+ return false;
+#ifdef FAUXCLICKY_ENABLE
+ case FC_TOG:
+ if (record->event.pressed) {
+ FAUXCLICKY_TOGGLE;
+ }
+ return false;
+ case FC_ON:
+ if (record->event.pressed) {
+ FAUXCLICKY_ON;
+ }
+ return false;
+ case FC_OFF:
+ if (record->event.pressed) {
+ FAUXCLICKY_OFF;
+ }
+ return false;
+#endif
+#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
+ case RGB_TOG:
+// Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+ rgblight_toggle();
+ }
+ return false;
+ case RGB_MODE_FORWARD:
+ if (record->event.pressed) {
+ uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
+ if (shifted) {
+ rgblight_step_reverse();
+ } else {
+ rgblight_step();
+ }
+ }
+ return false;
+ case RGB_MODE_REVERSE:
+ if (record->event.pressed) {
+ uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
+ if (shifted) {
+ rgblight_step();
+ } else {
+ rgblight_step_reverse();
+ }
+ }
+ return false;
+ case RGB_HUI:
+// Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+ rgblight_increase_hue();
+ }
+ return false;
+ case RGB_HUD:
+// Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+ rgblight_decrease_hue();
+ }
+ return false;
+ case RGB_SAI:
+// Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+ rgblight_increase_sat();
+ }
+ return false;
+ case RGB_SAD:
+// Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+ rgblight_decrease_sat();
+ }
+ return false;
+ case RGB_VAI:
+// Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+ rgblight_increase_val();
+ }
+ return false;
+ case RGB_VAD:
+// Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+ rgblight_decrease_val();
+ }
+ return false;
+ case RGB_SPI:
+ if (record->event.pressed) {
+ rgblight_increase_speed();
+ }
+ return false;
+ case RGB_SPD:
+ if (record->event.pressed) {
+ rgblight_decrease_speed();
+ }
+ return false;
+ case RGB_MODE_PLAIN:
+ if (record->event.pressed) {
+ rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
+ }
+ return false;
+ case RGB_MODE_BREATHE:
+# ifdef RGBLIGHT_EFFECT_BREATHING
+ if (record->event.pressed) {
+ if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(RGBLIGHT_MODE_BREATHING);
+ }
+ }
+# endif
+ return false;
+ case RGB_MODE_RAINBOW:
+# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
+ if (record->event.pressed) {
+ if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD);
+ }
+ }
+# endif
+ return false;
+ case RGB_MODE_SWIRL:
+# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
+ if (record->event.pressed) {
+ if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
+ }
+ }
+# endif
+ return false;
+ case RGB_MODE_SNAKE:
+# ifdef RGBLIGHT_EFFECT_SNAKE
+ if (record->event.pressed) {
+ if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(RGBLIGHT_MODE_SNAKE);
+ }
+ }
+# endif
+ return false;
+ case RGB_MODE_KNIGHT:
+# ifdef RGBLIGHT_EFFECT_KNIGHT
+ if (record->event.pressed) {
+ if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(RGBLIGHT_MODE_KNIGHT);
+ }
+ }
+# endif
+ return false;
+ case RGB_MODE_XMAS:
+# ifdef RGBLIGHT_EFFECT_CHRISTMAS
+ if (record->event.pressed) {
+ rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
+ }
+# endif
+ return false;
+ case RGB_MODE_GRADIENT:
+# ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
+ if (record->event.pressed) {
+ if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT);
+ }
+ }
+# endif
+ return false;
+ case RGB_MODE_RGBTEST:
+# ifdef RGBLIGHT_EFFECT_RGB_TEST
+ if (record->event.pressed) {
+ rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
+ }
+# endif
+ return false;
+#endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
+#ifdef VELOCIKEY_ENABLE
+ case VLK_TOG:
+ if (record->event.pressed) {
+ velocikey_toggle();
+ }
+ return false;
+#endif
+#ifdef PROTOCOL_LUFA
+ case OUT_AUTO:
+ if (record->event.pressed) {
+ set_output(OUTPUT_AUTO);
+ }
+ return false;
+ case OUT_USB:
+ if (record->event.pressed) {
+ set_output(OUTPUT_USB);
+ }
+ return false;
+# ifdef BLUETOOTH_ENABLE
+ case OUT_BT:
+ if (record->event.pressed) {
+ set_output(OUTPUT_BLUETOOTH);
+ }
+ return false;
+# endif
+#endif
+ case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
+ case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
+ if (record->event.pressed) {
+ // MAGIC actions (BOOTMAGIC without the boot)
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+ /* keymap config */
+ keymap_config.raw = eeconfig_read_keymap();
+ switch (keycode) {
+ case MAGIC_SWAP_CONTROL_CAPSLOCK:
+ keymap_config.swap_control_capslock = true;
+ break;
+ case MAGIC_CAPSLOCK_TO_CONTROL:
+ keymap_config.capslock_to_control = true;
+ break;
+ case MAGIC_SWAP_LALT_LGUI:
+ keymap_config.swap_lalt_lgui = true;
+ break;
+ case MAGIC_SWAP_RALT_RGUI:
+ keymap_config.swap_ralt_rgui = true;
+ break;
+ case MAGIC_SWAP_LCTL_LGUI:
+ keymap_config.swap_lctl_lgui = true;
+ break;
+ case MAGIC_SWAP_RCTL_RGUI:
+ keymap_config.swap_rctl_rgui = true;
+ break;
+ case MAGIC_NO_GUI:
+ keymap_config.no_gui = true;
+ break;
+ case MAGIC_SWAP_GRAVE_ESC:
+ keymap_config.swap_grave_esc = true;
+ break;
+ case MAGIC_SWAP_BACKSLASH_BACKSPACE:
+ keymap_config.swap_backslash_backspace = true;
+ break;
+ case MAGIC_HOST_NKRO:
+ clear_keyboard(); // clear first buffer to prevent stuck keys
+ keymap_config.nkro = true;
+ break;
+ case MAGIC_SWAP_ALT_GUI:
+ keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true;
+#ifdef AUDIO_ENABLE
+ PLAY_SONG(ag_swap_song);
+#endif
+ break;
+ case MAGIC_SWAP_CTL_GUI:
+ keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true;
+#ifdef AUDIO_ENABLE
+ PLAY_SONG(cg_swap_song);
+#endif
+ break;
+ case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
+ keymap_config.swap_control_capslock = false;
+ break;
+ case MAGIC_UNCAPSLOCK_TO_CONTROL:
+ keymap_config.capslock_to_control = false;
+ break;
+ case MAGIC_UNSWAP_LALT_LGUI:
+ keymap_config.swap_lalt_lgui = false;
+ break;
+ case MAGIC_UNSWAP_RALT_RGUI:
+ keymap_config.swap_ralt_rgui = false;
+ break;
+ case MAGIC_UNSWAP_LCTL_LGUI:
+ keymap_config.swap_lctl_lgui = false;
+ break;
+ case MAGIC_UNSWAP_RCTL_RGUI:
+ keymap_config.swap_rctl_rgui = false;
+ break;
+ case MAGIC_UNNO_GUI:
+ keymap_config.no_gui = false;
+ break;
+ case MAGIC_UNSWAP_GRAVE_ESC:
+ keymap_config.swap_grave_esc = false;
+ break;
+ case MAGIC_UNSWAP_BACKSLASH_BACKSPACE:
+ keymap_config.swap_backslash_backspace = false;
+ break;
+ case MAGIC_UNHOST_NKRO:
+ clear_keyboard(); // clear first buffer to prevent stuck keys
+ keymap_config.nkro = false;
+ break;
+ case MAGIC_UNSWAP_ALT_GUI:
+ keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false;
+#ifdef AUDIO_ENABLE
+ PLAY_SONG(ag_norm_song);
+#endif
+ break;
+ case MAGIC_UNSWAP_CTL_GUI:
+ keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false;
+#ifdef AUDIO_ENABLE
+ PLAY_SONG(cg_norm_song);
+#endif
+ break;
+ case MAGIC_TOGGLE_ALT_GUI:
+ keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui;
+ keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui;
+#ifdef AUDIO_ENABLE
+ if (keymap_config.swap_ralt_rgui) {
+ PLAY_SONG(ag_swap_song);
+ } else {
+ PLAY_SONG(ag_norm_song);
+ }
+#endif
+ break;
+ case MAGIC_TOGGLE_CTL_GUI:
+ keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui;
+ keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui;
+#ifdef AUDIO_ENABLE
+ if (keymap_config.swap_rctl_rgui) {
+ PLAY_SONG(cg_swap_song);
+ } else {
+ PLAY_SONG(cg_norm_song);
+ }
+#endif
+ break;
+ case MAGIC_TOGGLE_NKRO:
+ clear_keyboard(); // clear first buffer to prevent stuck keys
+ keymap_config.nkro = !keymap_config.nkro;
+ break;
+ case MAGIC_EE_HANDS_LEFT:
+ eeconfig_update_handedness(true);
+ break;
+ case MAGIC_EE_HANDS_RIGHT:
+ eeconfig_update_handedness(false);
+ break;
+ default:
+ break;
+ }
+ eeconfig_update_keymap(keymap_config.raw);
+ clear_keyboard(); // clear to prevent stuck keys
+
+ return false;
+ }
+ break;
- case GRAVE_ESC: {
- uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)
- |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)));
+ case GRAVE_ESC: {
+ uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)));
#ifdef GRAVE_ESC_ALT_OVERRIDE
- // if ALT is pressed, ESC is always sent
- // this is handy for the cmd+opt+esc shortcut on macOS, among other things.
- if (get_mods() & (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT))) {
- shifted = 0;
- }
+ // if ALT is pressed, ESC is always sent
+ // this is handy for the cmd+opt+esc shortcut on macOS, among other things.
+ if (get_mods() & (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT))) {
+ shifted = 0;
+ }
#endif
#ifdef GRAVE_ESC_CTRL_OVERRIDE
- // if CTRL is pressed, ESC is always sent
- // this is handy for the ctrl+shift+esc shortcut on windows, among other things.
- if (get_mods() & (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL))) {
- shifted = 0;
- }
+ // if CTRL is pressed, ESC is always sent
+ // this is handy for the ctrl+shift+esc shortcut on windows, among other things.
+ if (get_mods() & (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL))) {
+ shifted = 0;
+ }
#endif
#ifdef GRAVE_ESC_GUI_OVERRIDE
- // if GUI is pressed, ESC is always sent
- if (get_mods() & (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))) {
- shifted = 0;
- }
+ // if GUI is pressed, ESC is always sent
+ if (get_mods() & (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))) {
+ shifted = 0;
+ }
#endif
#ifdef GRAVE_ESC_SHIFT_OVERRIDE
- // if SHIFT is pressed, ESC is always sent
- if (get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) {
- shifted = 0;
- }
-#endif
-
- if (record->event.pressed) {
- grave_esc_was_shifted = shifted;
- add_key(shifted ? KC_GRAVE : KC_ESCAPE);
- }
- else {
- del_key(grave_esc_was_shifted ? KC_GRAVE : KC_ESCAPE);
- }
-
- send_keyboard_report();
- return false;
- }
+ // if SHIFT is pressed, ESC is always sent
+ if (get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) {
+ shifted = 0;
+ }
+#endif
+
+ if (record->event.pressed) {
+ grave_esc_was_shifted = shifted;
+ add_key(shifted ? KC_GRAVE : KC_ESCAPE);
+ } else {
+ del_key(grave_esc_was_shifted ? KC_GRAVE : KC_ESCAPE);
+ }
+
+ send_keyboard_report();
+ return false;
+ }
#if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING)
- case BL_BRTG: {
- if (record->event.pressed) {
- breathing_toggle();
- }
- return false;
- }
+ case BL_BRTG: {
+ if (record->event.pressed) {
+ backlight_toggle_breathing();
+ }
+ return false;
+ }
#endif
- }
-
- return process_action_kb(record);
-}
+ }
-__attribute__ ((weak))
-const bool ascii_to_shift_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 0,
- 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 0, 1, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 0, 0, 0, 1, 1,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1, 0
-};
-
-__attribute__ ((weak))
-const bool ascii_to_altgr_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-__attribute__ ((weak))
-const uint8_t ascii_to_keycode_lut[0x80] PROGMEM = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, KC_ESC, 0, 0, 0, 0,
- KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
- KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
- KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
- KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
- KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
- KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
- KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
- KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
- KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
-};
-
-void send_string(const char *str) {
- send_string_with_delay(str, 0);
+ return process_action_kb(record);
}
-void send_string_P(const char *str) {
- send_string_with_delay_P(str, 0);
-}
+__attribute__((weak)) const bool ascii_to_shift_lut[128] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0};
+
+__attribute__((weak)) const bool ascii_to_altgr_lut[128] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {// NUL SOH STX ETX EOT ENQ ACK BEL
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // BS TAB LF VT FF CR SO SI
+ KC_BSPC, KC_TAB, KC_ENT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+ // CAN EM SUB ESC FS GS RS US
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
+
+ // ! " # $ % & '
+ KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
+ // ( ) * + , - . /
+ KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
+ // 0 1 2 3 4 5 6 7
+ KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ // 8 9 : ; < = > ?
+ KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
+ // @ A B C D E F G
+ KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // H I J K L M N O
+ KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
+ // P Q R S T U V W
+ KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
+ // X Y Z [ \ ] ^ _
+ KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
+ // ` a b c d e f g
+ KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
+ // h i j k l m n o
+ KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
+ // p q r s t u v w
+ KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
+ // x y z { | } ~ DEL
+ KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL};
+
+void send_string(const char *str) { send_string_with_delay(str, 0); }
+
+void send_string_P(const char *str) { send_string_with_delay_P(str, 0); }
void send_string_with_delay(const char *str, uint8_t interval) {
while (1) {
char ascii_code = *str;
if (!ascii_code) break;
if (ascii_code == SS_TAP_CODE) {
- // tap
- uint8_t keycode = *(++str);
- register_code(keycode);
- unregister_code(keycode);
+ // tap
+ uint8_t keycode = *(++str);
+ register_code(keycode);
+ unregister_code(keycode);
} else if (ascii_code == SS_DOWN_CODE) {
- // down
- uint8_t keycode = *(++str);
- register_code(keycode);
+ // down
+ uint8_t keycode = *(++str);
+ register_code(keycode);
} else if (ascii_code == SS_UP_CODE) {
- // up
- uint8_t keycode = *(++str);
- unregister_code(keycode);
+ // up
+ uint8_t keycode = *(++str);
+ unregister_code(keycode);
} else {
- send_char(ascii_code);
+ send_char(ascii_code);
}
++str;
// interval
- { uint8_t ms = interval; while (ms--) wait_ms(1); }
+ {
+ uint8_t ms = interval;
+ while (ms--) wait_ms(1);
+ }
}
}
@@ -817,695 +804,219 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
char ascii_code = pgm_read_byte(str);
if (!ascii_code) break;
if (ascii_code == SS_TAP_CODE) {
- // tap
- uint8_t keycode = pgm_read_byte(++str);
- register_code(keycode);
- unregister_code(keycode);
+ // tap
+ uint8_t keycode = pgm_read_byte(++str);
+ register_code(keycode);
+ unregister_code(keycode);
} else if (ascii_code == SS_DOWN_CODE) {
- // down
- uint8_t keycode = pgm_read_byte(++str);
- register_code(keycode);
+ // down
+ uint8_t keycode = pgm_read_byte(++str);
+ register_code(keycode);
} else if (ascii_code == SS_UP_CODE) {
- // up
- uint8_t keycode = pgm_read_byte(++str);
- unregister_code(keycode);
+ // up
+ uint8_t keycode = pgm_read_byte(++str);
+ unregister_code(keycode);
} else {
- send_char(ascii_code);
+ send_char(ascii_code);
}
++str;
// interval
- { uint8_t ms = interval; while (ms--) wait_ms(1); }
+ {
+ uint8_t ms = interval;
+ while (ms--) wait_ms(1);
+ }
}
}
void send_char(char ascii_code) {
- uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
- bool is_shifted = pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code]);
- bool is_altgred = pgm_read_byte(&ascii_to_altgr_lut[(uint8_t)ascii_code]);
-
- if (is_shifted) {
- register_code(KC_LSFT);
- }
- if (is_altgred) {
- register_code(KC_RALT);
- }
- tap_code(keycode);
- if (is_altgred) {
- unregister_code(KC_RALT);
- }
- if (is_shifted) {
- unregister_code(KC_LSFT);
- }
+ uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
+ bool is_shifted = pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code]);
+ bool is_altgred = pgm_read_byte(&ascii_to_altgr_lut[(uint8_t)ascii_code]);
+
+ if (is_shifted) {
+ register_code(KC_LSFT);
+ }
+ if (is_altgred) {
+ register_code(KC_RALT);
+ }
+ tap_code(keycode);
+ if (is_altgred) {
+ unregister_code(KC_RALT);
+ }
+ if (is_shifted) {
+ unregister_code(KC_LSFT);
+ }
}
void set_single_persistent_default_layer(uint8_t default_layer) {
- #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
+#if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
PLAY_SONG(default_layer_songs[default_layer]);
- #endif
- eeconfig_update_default_layer(1U<<default_layer);
- default_layer_set(1U<<default_layer);
+#endif
+ eeconfig_update_default_layer(1U << default_layer);
+ default_layer_set(1U << default_layer);
}
-uint32_t update_tri_layer_state(uint32_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) {
- uint32_t mask12 = (1UL << layer1) | (1UL << layer2);
- uint32_t mask3 = 1UL << layer3;
- return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3);
+layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) {
+ layer_state_t mask12 = (1UL << layer1) | (1UL << layer2);
+ layer_state_t mask3 = 1UL << layer3;
+ return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3);
}
-void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
- layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3));
-}
+void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); }
void tap_random_base64(void) {
- #if defined(__AVR_ATmega32U4__)
+#if defined(__AVR_ATmega32U4__)
uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
- #else
+#else
uint8_t key = rand() % 64;
- #endif
- switch (key) {
- case 0 ... 25:
- register_code(KC_LSFT);
- register_code(key + KC_A);
- unregister_code(key + KC_A);
- unregister_code(KC_LSFT);
- break;
- case 26 ... 51:
- register_code(key - 26 + KC_A);
- unregister_code(key - 26 + KC_A);
- break;
- case 52:
- register_code(KC_0);
- unregister_code(KC_0);
- break;
- case 53 ... 61:
- register_code(key - 53 + KC_1);
- unregister_code(key - 53 + KC_1);
- break;
- case 62:
- register_code(KC_LSFT);
- register_code(KC_EQL);
- unregister_code(KC_EQL);
- unregister_code(KC_LSFT);
- break;
- case 63:
- register_code(KC_SLSH);
- unregister_code(KC_SLSH);
- break;
- }
+#endif
+ switch (key) {
+ case 0 ... 25:
+ register_code(KC_LSFT);
+ register_code(key + KC_A);
+ unregister_code(key + KC_A);
+ unregister_code(KC_LSFT);
+ break;
+ case 26 ... 51:
+ register_code(key - 26 + KC_A);
+ unregister_code(key - 26 + KC_A);
+ break;
+ case 52:
+ register_code(KC_0);
+ unregister_code(KC_0);
+ break;
+ case 53 ... 61:
+ register_code(key - 53 + KC_1);
+ unregister_code(key - 53 + KC_1);
+ break;
+ case 62:
+ register_code(KC_LSFT);
+ register_code(KC_EQL);
+ unregister_code(KC_EQL);
+ unregister_code(KC_LSFT);
+ break;
+ case 63:
+ register_code(KC_SLSH);
+ unregister_code(KC_SLSH);
+ break;
+ }
}
-__attribute__((weak))
-void bootmagic_lite(void) {
- // The lite version of TMK's bootmagic based on Wilba.
- // 100% less potential for accidentally making the
- // keyboard do stupid things.
+__attribute__((weak)) void bootmagic_lite(void) {
+ // The lite version of TMK's bootmagic based on Wilba.
+ // 100% less potential for accidentally making the
+ // keyboard do stupid things.
- // We need multiple scans because debouncing can't be turned off.
- matrix_scan();
- #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0
+ // We need multiple scans because debouncing can't be turned off.
+ matrix_scan();
+#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0
wait_ms(DEBOUNCING_DELAY * 2);
- #elif defined(DEBOUNCE) && DEBOUNCE > 0
+#elif defined(DEBOUNCE) && DEBOUNCE > 0
wait_ms(DEBOUNCE * 2);
- #else
+#else
wait_ms(30);
- #endif
- matrix_scan();
-
- // If the Esc and space bar are held down on power up,
- // reset the EEPROM valid state and jump to bootloader.
- // Assumes Esc is at [0,0].
- // This isn't very generalized, but we need something that doesn't
- // rely on user's keymaps in firmware or EEPROM.
- if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
- eeconfig_disable();
- // Jump to bootloader.
- bootloader_jump();
- }
+#endif
+ matrix_scan();
+
+ // If the Esc and space bar are held down on power up,
+ // reset the EEPROM valid state and jump to bootloader.
+ // Assumes Esc is at [0,0].
+ // This isn't very generalized, but we need something that doesn't
+ // rely on user's keymaps in firmware or EEPROM.
+ if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
+ eeconfig_disable();
+ // Jump to bootloader.
+ bootloader_jump();
+ }
}
void matrix_init_quantum() {
- #ifdef BOOTMAGIC_LITE
+#ifdef BOOTMAGIC_LITE
bootmagic_lite();
- #endif
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
- #ifdef BACKLIGHT_ENABLE
- #ifdef LED_MATRIX_ENABLE
- led_matrix_init();
- #else
- backlight_init_ports();
- #endif
- #endif
- #ifdef AUDIO_ENABLE
+#endif
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+#ifdef BACKLIGHT_ENABLE
+# ifdef LED_MATRIX_ENABLE
+ led_matrix_init();
+# else
+ backlight_init_ports();
+# endif
+#endif
+#ifdef AUDIO_ENABLE
audio_init();
- #endif
- #ifdef RGB_MATRIX_ENABLE
+#endif
+#ifdef RGB_MATRIX_ENABLE
rgb_matrix_init();
- #endif
- #ifdef ENCODER_ENABLE
+#endif
+#ifdef ENCODER_ENABLE
encoder_init();
- #endif
- #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
+#endif
+#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
unicode_input_mode_init();
- #endif
- #ifdef HAPTIC_ENABLE
+#endif
+#ifdef HAPTIC_ENABLE
haptic_init();
- #endif
- #ifdef OUTPUT_AUTO_ENABLE
- set_output(OUTPUT_AUTO);
- #endif
- matrix_init_kb();
-}
-
-void matrix_scan_quantum() {
- #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
- matrix_scan_music();
- #endif
-
- #ifdef TAP_DANCE_ENABLE
- matrix_scan_tap_dance();
- #endif
-
- #ifdef COMBO_ENABLE
- matrix_scan_combo();
- #endif
-
- #if defined(BACKLIGHT_ENABLE)
- #if defined(LED_MATRIX_ENABLE)
- led_matrix_task();
- #elif defined(BACKLIGHT_PIN)
- backlight_task();
- #endif
- #endif
-
- #ifdef RGB_MATRIX_ENABLE
- rgb_matrix_task();
- #endif
-
- #ifdef ENCODER_ENABLE
- encoder_read();
- #endif
-
- #ifdef HAPTIC_ENABLE
- haptic_task();
- #endif
-
- matrix_scan_kb();
-}
-#if defined(BACKLIGHT_ENABLE) && (defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS))
-
-// The logic is a bit complex, we support 3 setups:
-// 1. hardware PWM when backlight is wired to a PWM pin
-// depending on this pin, we use a different output compare unit
-// 2. software PWM with hardware timers, but the used timer depends
-// on the audio setup (audio wins other backlight)
-// 3. full software PWM
-
-#if BACKLIGHT_PIN == B7
-# define HARDWARE_PWM
-# define TCCRxA TCCR1A
-# define TCCRxB TCCR1B
-# define COMxx1 COM1C1
-# define OCRxx OCR1C
-# define TIMERx_OVF_vect TIMER1_OVF_vect
-# define TOIEx TOIE1
-# define ICRx ICR1
-# define TIMSKx TIMSK1
-#elif BACKLIGHT_PIN == B6
-# define HARDWARE_PWM
-# define TCCRxA TCCR1A
-# define TCCRxB TCCR1B
-# define COMxx1 COM1B1
-# define OCRxx OCR1B
-# define TIMERx_OVF_vect TIMER1_OVF_vect
-# define TOIEx TOIE1
-# define ICRx ICR1
-# define TIMSKx TIMSK1
-#elif BACKLIGHT_PIN == B5
-# define HARDWARE_PWM
-# define TCCRxA TCCR1A
-# define TCCRxB TCCR1B
-# define COMxx1 COM1A1
-# define OCRxx OCR1A
-# define TIMERx_OVF_vect TIMER1_OVF_vect
-# define TOIEx TOIE1
-# define ICRx ICR1
-# define TIMSKx TIMSK1
-#elif BACKLIGHT_PIN == C6
-# define HARDWARE_PWM
-# define TCCRxA TCCR3A
-# define TCCRxB TCCR3B
-# define COMxx1 COM3A1
-# define OCRxx OCR3A
-# define TIMERx_OVF_vect TIMER3_OVF_vect
-# define TOIEx TOIE3
-# define ICRx ICR3
-# define TIMSKx TIMSK3
-#elif defined(__AVR_ATmega32A__) && BACKLIGHT_PIN == D4
-# define TCCRxA TCCR1A
-# define TCCRxB TCCR1B
-# define COMxx1 COM1B1
-# define OCRxx OCR1B
-# define TIMERx_OVF_vect TIMER1_OVF_vect
-# define TOIEx TOIE1
-# define ICRx ICR1
-# define TIMSKx TIMSK1
-#else
-# if !defined(BACKLIGHT_CUSTOM_DRIVER)
-# if !defined(B5_AUDIO) && !defined(B6_AUDIO) && !defined(B7_AUDIO)
- // timer 1 is not used by audio , backlight can use it
-#pragma message "Using hardware timer 1 with software PWM"
-# define HARDWARE_PWM
-# define BACKLIGHT_PWM_TIMER
-# define TCCRxA TCCR1A
-# define TCCRxB TCCR1B
-# define OCRxx OCR1A
-# define TIMERx_COMPA_vect TIMER1_COMPA_vect
-# define TIMERx_OVF_vect TIMER1_OVF_vect
-# define OCIExA OCIE1A
-# define TOIEx TOIE1
-# define ICRx ICR1
-# if defined(__AVR_ATmega32A__) // This MCU has only one TIMSK register
-# define TIMSKx TIMSK
-# else
-# define TIMSKx TIMSK1
-# endif
-# elif !defined(C6_AUDIO) && !defined(C5_AUDIO) && !defined(C4_AUDIO)
-#pragma message "Using hardware timer 3 with software PWM"
-// timer 3 is not used by audio, backlight can use it
-# define HARDWARE_PWM
-# define BACKLIGHT_PWM_TIMER
-# define TCCRxA TCCR3A
-# define TCCRxB TCCR3B
-# define OCRxx OCR3A
-# define TIMERx_COMPA_vect TIMER3_COMPA_vect
-# define TIMERx_OVF_vect TIMER3_OVF_vect
-# define OCIExA OCIE3A
-# define TOIEx TOIE3
-# define ICRx ICR1
-# define TIMSKx TIMSK3
-# else
-#pragma message "Audio in use - using pure software PWM"
-#define NO_HARDWARE_PWM
-# endif
-# else
-#pragma message "Custom driver defined - using pure software PWM"
-#define NO_HARDWARE_PWM
-# endif
#endif
-
-#ifndef BACKLIGHT_ON_STATE
-#define BACKLIGHT_ON_STATE 0
+#ifdef OUTPUT_AUTO_ENABLE
+ set_output(OUTPUT_AUTO);
#endif
-
-void backlight_on(uint8_t backlight_pin) {
-#if BACKLIGHT_ON_STATE == 0
- writePinLow(backlight_pin);
-#else
- writePinHigh(backlight_pin);
+#ifdef DIP_SWITCH_ENABLE
+ dip_switch_init();
#endif
-}
-void backlight_off(uint8_t backlight_pin) {
-#if BACKLIGHT_ON_STATE == 0
- writePinHigh(backlight_pin);
-#else
- writePinLow(backlight_pin);
-#endif
+ matrix_init_kb();
}
-
-#if defined(NO_HARDWARE_PWM) || defined(BACKLIGHT_PWM_TIMER) // pwm through software
-
-// we support multiple backlight pins
-#ifndef BACKLIGHT_LED_COUNT
-#define BACKLIGHT_LED_COUNT 1
+void matrix_scan_quantum() {
+#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
+ matrix_scan_music();
#endif
-#if BACKLIGHT_LED_COUNT == 1
-#define BACKLIGHT_PIN_INIT { BACKLIGHT_PIN }
-#else
-#define BACKLIGHT_PIN_INIT BACKLIGHT_PINS
+#ifdef TAP_DANCE_ENABLE
+ matrix_scan_tap_dance();
#endif
-#define FOR_EACH_LED(x) \
- for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) \
- { \
- uint8_t backlight_pin = backlight_pins[i]; \
- { \
- x \
- } \
- }
-
-static const uint8_t backlight_pins[BACKLIGHT_LED_COUNT] = BACKLIGHT_PIN_INIT;
-
-#else // full hardware PWM
-
-// we support only one backlight pin
-static const uint8_t backlight_pin = BACKLIGHT_PIN;
-#define FOR_EACH_LED(x) x
-
+#ifdef COMBO_ENABLE
+ matrix_scan_combo();
#endif
-#ifdef NO_HARDWARE_PWM
-__attribute__((weak))
-void backlight_init_ports(void)
-{
- // Setup backlight pin as output and output to on state.
- FOR_EACH_LED(
- setPinOutput(backlight_pin);
- backlight_on(backlight_pin);
- )
-}
-
-__attribute__ ((weak))
-void backlight_set(uint8_t level) {}
-
-uint8_t backlight_tick = 0;
-
-#ifndef BACKLIGHT_CUSTOM_DRIVER
-void backlight_task(void) {
- if ((0xFFFF >> ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) {
- FOR_EACH_LED(
- backlight_on(backlight_pin);
- )
- }
- else {
- FOR_EACH_LED(
- backlight_off(backlight_pin);
- )
- }
- backlight_tick = (backlight_tick + 1) % 16;
-}
+#if defined(BACKLIGHT_ENABLE)
+# if defined(LED_MATRIX_ENABLE)
+ led_matrix_task();
+# elif defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)
+ backlight_task();
+# endif
#endif
-#ifdef BACKLIGHT_BREATHING
- #ifndef BACKLIGHT_CUSTOM_DRIVER
- #error "Backlight breathing only available with hardware PWM. Please disable."
- #endif
+#ifdef RGB_MATRIX_ENABLE
+ rgb_matrix_task();
#endif
-#else // hardware pwm through timer
-
-#ifdef BACKLIGHT_PWM_TIMER
-
-// The idea of software PWM assisted by hardware timers is the following
-// we use the hardware timer in fast PWM mode like for hardware PWM, but
-// instead of letting the Output Match Comparator control the led pin
-// (which is not possible since the backlight is not wired to PWM pins on the
-// CPU), we do the LED on/off by oursleves.
-// The timer is setup to count up to 0xFFFF, and we set the Output Compare
-// register to the current 16bits backlight level (after CIE correction).
-// This means the CPU will trigger a compare match interrupt when the counter
-// reaches the backlight level, where we turn off the LEDs,
-// but also an overflow interrupt when the counter rolls back to 0,
-// in which we're going to turn on the LEDs.
-// The LED will then be on for OCRxx/0xFFFF time, adjusted every 244Hz.
-
-// Triggered when the counter reaches the OCRx value
-ISR(TIMERx_COMPA_vect) {
- FOR_EACH_LED(
- backlight_off(backlight_pin);
- )
-}
-
-// Triggered when the counter reaches the TOP value
-// this one triggers at F_CPU/65536 =~ 244 Hz
-ISR(TIMERx_OVF_vect) {
-#ifdef BACKLIGHT_BREATHING
- if(is_breathing()) {
- breathing_task();
- }
-#endif
- // for very small values of OCRxx (or backlight level)
- // we can't guarantee this whole code won't execute
- // at the same time as the compare match interrupt
- // which means that we might turn on the leds while
- // trying to turn them off, leading to flickering
- // artifacts (especially while breathing, because breathing_task
- // takes many computation cycles).
- // so better not turn them on while the counter TOP is very low.
- if (OCRxx > 256) {
- FOR_EACH_LED(
- backlight_on(backlight_pin);
- )
- }
-}
-
+#ifdef ENCODER_ENABLE
+ encoder_read();
#endif
-#define TIMER_TOP 0xFFFFU
-
-// See http://jared.geek.nz/2013/feb/linear-led-pwm
-static uint16_t cie_lightness(uint16_t v) {
- if (v <= 5243) // if below 8% of max
- return v / 9; // same as dividing by 900%
- else {
- uint32_t y = (((uint32_t) v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
- // to get a useful result with integer division, we shift left in the expression above
- // and revert what we've done again after squaring.
- y = y * y * y >> 8;
- if (y > 0xFFFFUL) // prevent overflow
- return 0xFFFFU;
- else
- return (uint16_t) y;
- }
-}
-
-// range for val is [0..TIMER_TOP]. PWM pin is high while the timer count is below val.
-static inline void set_pwm(uint16_t val) {
- OCRxx = val;
-}
-
-#ifndef BACKLIGHT_CUSTOM_DRIVER
-__attribute__ ((weak))
-void backlight_set(uint8_t level) {
- if (level > BACKLIGHT_LEVELS)
- level = BACKLIGHT_LEVELS;
-
- if (level == 0) {
- #ifdef BACKLIGHT_PWM_TIMER
- if (OCRxx) {
- TIMSKx &= ~(_BV(OCIExA));
- TIMSKx &= ~(_BV(TOIEx));
- FOR_EACH_LED(
- backlight_off(backlight_pin);
- )
- }
- #else
- // Turn off PWM control on backlight pin
- TCCRxA &= ~(_BV(COMxx1));
- #endif
- } else {
- #ifdef BACKLIGHT_PWM_TIMER
- if (!OCRxx) {
- TIMSKx |= _BV(OCIExA);
- TIMSKx |= _BV(TOIEx);
- }
- #else
- // Turn on PWM control of backlight pin
- TCCRxA |= _BV(COMxx1);
- #endif
- }
- // Set the brightness
- set_pwm(cie_lightness(TIMER_TOP * (uint32_t)level / BACKLIGHT_LEVELS));
-}
-
-void backlight_task(void) {}
-#endif // BACKLIGHT_CUSTOM_DRIVER
-
-#ifdef BACKLIGHT_BREATHING
-
-#define BREATHING_NO_HALT 0
-#define BREATHING_HALT_OFF 1
-#define BREATHING_HALT_ON 2
-#define BREATHING_STEPS 128
-
-static uint8_t breathing_period = BREATHING_PERIOD;
-static uint8_t breathing_halt = BREATHING_NO_HALT;
-static uint16_t breathing_counter = 0;
-
-#ifdef BACKLIGHT_PWM_TIMER
-static bool breathing = false;
-
-bool is_breathing(void) {
- return breathing;
-}
-
-#define breathing_interrupt_enable() do { breathing = true; } while (0)
-#define breathing_interrupt_disable() do { breathing = false; } while (0)
-#else
-
-bool is_breathing(void) {
- return !!(TIMSKx & _BV(TOIEx));
-}
-
-#define breathing_interrupt_enable() do {TIMSKx |= _BV(TOIEx);} while (0)
-#define breathing_interrupt_disable() do {TIMSKx &= ~_BV(TOIEx);} while (0)
+#ifdef HAPTIC_ENABLE
+ haptic_task();
#endif
-#define breathing_min() do {breathing_counter = 0;} while (0)
-#define breathing_max() do {breathing_counter = breathing_period * 244 / 2;} while (0)
-
-void breathing_enable(void)
-{
- breathing_counter = 0;
- breathing_halt = BREATHING_NO_HALT;
- breathing_interrupt_enable();
-}
-
-void breathing_pulse(void)
-{
- if (get_backlight_level() == 0)
- breathing_min();
- else
- breathing_max();
- breathing_halt = BREATHING_HALT_ON;
- breathing_interrupt_enable();
-}
-
-void breathing_disable(void)
-{
- breathing_interrupt_disable();
- // Restore backlight level
- backlight_set(get_backlight_level());
-}
-
-void breathing_self_disable(void)
-{
- if (get_backlight_level() == 0)
- breathing_halt = BREATHING_HALT_OFF;
- else
- breathing_halt = BREATHING_HALT_ON;
-}
-
-void breathing_toggle(void) {
- if (is_breathing())
- breathing_disable();
- else
- breathing_enable();
-}
-
-void breathing_period_set(uint8_t value)
-{
- if (!value)
- value = 1;
- breathing_period = value;
-}
-
-void breathing_period_default(void) {
- breathing_period_set(BREATHING_PERIOD);
-}
-
-void breathing_period_inc(void)
-{
- breathing_period_set(breathing_period+1);
-}
-
-void breathing_period_dec(void)
-{
- breathing_period_set(breathing_period-1);
-}
-
-/* To generate breathing curve in python:
- * from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
- */
-static 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};
-
-// Use this before the cie_lightness function.
-static inline uint16_t scale_backlight(uint16_t v) {
- return v / BACKLIGHT_LEVELS * get_backlight_level();
-}
-
-#ifdef BACKLIGHT_PWM_TIMER
-void breathing_task(void)
-#else
-/* Assuming a 16MHz CPU clock and a timer that resets at 64k (ICR1), the following interrupt handler will run
- * about 244 times per second.
- */
-ISR(TIMERx_OVF_vect)
+#ifdef DIP_SWITCH_ENABLE
+ dip_switch_read(false);
#endif
-{
- uint16_t interval = (uint16_t) breathing_period * 244 / BREATHING_STEPS;
- // resetting after one period to prevent ugly reset at overflow.
- breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
- uint8_t index = breathing_counter / interval % BREATHING_STEPS;
-
- if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) ||
- ((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1)))
- {
- breathing_interrupt_disable();
- }
-
- set_pwm(cie_lightness(scale_backlight((uint16_t) pgm_read_byte(&breathing_table[index]) * 0x0101U)));
-}
-#endif // BACKLIGHT_BREATHING
-
-__attribute__ ((weak))
-void backlight_init_ports(void)
-{
- // Setup backlight pin as output and output to on state.
- FOR_EACH_LED(
- setPinOutput(backlight_pin);
- backlight_on(backlight_pin);
- )
-
- // I could write a wall of text here to explain... but TL;DW
- // Go read the ATmega32u4 datasheet.
- // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
-
-#ifdef BACKLIGHT_PWM_TIMER
- // TimerX setup, Fast PWM mode count to TOP set in ICRx
- TCCRxA = _BV(WGM11); // = 0b00000010;
- // clock select clk/1
- TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-#else // hardware PWM
- // Pin PB7 = OCR1C (Timer 1, Channel C)
- // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
- // (i.e. start high, go low when counter matches.)
- // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
- // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
-
- /*
- 14.8.3:
- "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 [..]."
- "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)."
- */
- TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010;
- TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-#endif
- // Use full 16-bit resolution. Counter counts to ICR1 before reset to 0.
- ICRx = TIMER_TOP;
-
- backlight_init();
- #ifdef BACKLIGHT_BREATHING
- breathing_enable();
- #endif
+ matrix_scan_kb();
}
-#endif // hardware backlight
-
-#else // no backlight
-
-__attribute__ ((weak))
-void backlight_init_ports(void) {}
-
-__attribute__ ((weak))
-void backlight_set(uint8_t level) {}
-
-#endif // backlight
-
#ifdef HD44780_ENABLED
-#include "hd44780.h"
+# include "hd44780.h"
#endif
-
// Functions for spitting out values
//
-void send_dword(uint32_t number) { // this might not actually work
+void send_dword(uint32_t number) { // this might not actually work
uint16_t word = (number >> 16);
send_word(word);
send_word(number & 0xFFFFUL);
@@ -1540,18 +1051,15 @@ void send_nibble(uint8_t number) {
}
}
-
-__attribute__((weak))
-uint16_t hex_to_keycode(uint8_t hex)
-{
- hex = hex & 0xF;
- if (hex == 0x0) {
- return KC_0;
- } else if (hex < 0xA) {
- return KC_1 + (hex - 0x1);
- } else {
- return KC_A + (hex - 0xA);
- }
+__attribute__((weak)) uint16_t hex_to_keycode(uint8_t hex) {
+ hex = hex & 0xF;
+ if (hex == 0x0) {
+ return KC_0;
+ } else if (hex < 0xA) {
+ return KC_1 + (hex - 0x1);
+ } else {
+ return KC_A + (hex - 0xA);
+ }
}
void api_send_unicode(uint32_t unicode) {
@@ -1562,72 +1070,61 @@ void api_send_unicode(uint32_t unicode) {
#endif
}
-__attribute__ ((weak))
-void led_set_user(uint8_t usb_led) {
-
-}
+/** \brief Lock LED set callback - keymap/user level
+ *
+ * \deprecated Use led_update_user() instead.
+ */
+__attribute__((weak)) void led_set_user(uint8_t usb_led) {}
-__attribute__ ((weak))
-void led_set_kb(uint8_t usb_led) {
- led_set_user(usb_led);
-}
+/** \brief Lock LED set callback - keyboard level
+ *
+ * \deprecated Use led_update_kb() instead.
+ */
+__attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); }
-__attribute__ ((weak))
-void led_init_ports(void)
-{
+/** \brief Lock LED update callback - keymap/user level
+ *
+ * \return True if led_update_kb() should run its own code, false otherwise.
+ */
+__attribute__((weak)) bool led_update_user(led_t led_state) { return true; }
-}
+/** \brief Lock LED update callback - keyboard level
+ *
+ * \return Ignored for now.
+ */
+__attribute__((weak)) bool led_update_kb(led_t led_state) { return led_update_user(led_state); }
-__attribute__ ((weak))
-void led_set(uint8_t usb_led)
-{
-
- // Example LED Code
- //
- // // Using PE6 Caps Lock LED
- // if (usb_led & (1<<USB_LED_CAPS_LOCK))
- // {
- // // Output high.
- // DDRE |= (1<<6);
- // PORTE |= (1<<6);
- // }
- // else
- // {
- // // Output low.
- // DDRE &= ~(1<<6);
- // PORTE &= ~(1<<6);
- // }
+__attribute__((weak)) void led_init_ports(void) {}
+__attribute__((weak)) void led_set(uint8_t usb_led) {
#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
- // Use backlight as Caps Lock indicator
- uint8_t bl_toggle_lvl = 0;
-
- if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK) && !backlight_config.enable) {
- // Turning Caps Lock ON and backlight is disabled in config
- // Toggling backlight to the brightest level
- bl_toggle_lvl = BACKLIGHT_LEVELS;
- } else if (IS_LED_OFF(usb_led, USB_LED_CAPS_LOCK) && backlight_config.enable) {
- // Turning Caps Lock OFF and backlight is enabled in config
- // Toggling backlight and restoring config level
- bl_toggle_lvl = backlight_config.level;
- }
+ // Use backlight as Caps Lock indicator
+ uint8_t bl_toggle_lvl = 0;
+
+ if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK) && !backlight_config.enable) {
+ // Turning Caps Lock ON and backlight is disabled in config
+ // Toggling backlight to the brightest level
+ bl_toggle_lvl = BACKLIGHT_LEVELS;
+ } else if (IS_LED_OFF(usb_led, USB_LED_CAPS_LOCK) && backlight_config.enable) {
+ // Turning Caps Lock OFF and backlight is enabled in config
+ // Toggling backlight and restoring config level
+ bl_toggle_lvl = backlight_config.level;
+ }
- // Set level without modify backlight_config to keep ability to restore state
- backlight_set(bl_toggle_lvl);
+ // Set level without modify backlight_config to keep ability to restore state
+ backlight_set(bl_toggle_lvl);
#endif
- led_set_kb(usb_led);
+ led_set_kb(usb_led);
+ led_update_kb((led_t)usb_led);
}
-
//------------------------------------------------------------------------------
// Override these functions in your keymap file to play different tunes on
// different events such as startup and bootloader jump
-__attribute__ ((weak))
-void startup_user() {}
+__attribute__((weak)) void startup_user() {}
-__attribute__ ((weak))
-void shutdown_user() {}
+__attribute__((weak)) void shutdown_user() {}
//------------------------------------------------------------------------------
diff --git a/quantum/quantum.h b/quantum/quantum.h
index f089c6ef64..6beab65a32 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -16,12 +16,12 @@
#pragma once
#if defined(__AVR__)
- #include <avr/pgmspace.h>
- #include <avr/io.h>
- #include <avr/interrupt.h>
+# include <avr/pgmspace.h>
+# include <avr/io.h>
+# include <avr/interrupt.h>
#endif
#if defined(PROTOCOL_CHIBIOS)
- #include "hal.h"
+# include "hal.h"
#endif
#include "wait.h"
@@ -29,23 +29,23 @@
#include "keymap.h"
#ifdef BACKLIGHT_ENABLE
- #ifdef LED_MATRIX_ENABLE
- #include "ledmatrix.h"
- #else
- #include "backlight.h"
- #endif
+# ifdef LED_MATRIX_ENABLE
+# include "ledmatrix.h"
+# else
+# include "backlight.h"
+# endif
#endif
#if defined(RGBLIGHT_ENABLE)
- #include "rgblight.h"
+# include "rgblight.h"
#elif defined(RGB_MATRIX_ENABLE)
- // Dummy define RGBLIGHT_MODE_xxxx
- #define RGBLIGHT_H_DUMMY_DEFINE
- #include "rgblight.h"
+// Dummy define RGBLIGHT_MODE_xxxx
+# define RGBLIGHT_H_DUMMY_DEFINE
+# include "rgblight.h"
#endif
#ifdef RGB_MATRIX_ENABLE
- #include "rgb_matrix.h"
+# include "rgb_matrix.h"
#endif
#include "action_layer.h"
@@ -64,121 +64,127 @@
extern layer_state_t default_layer_state;
#ifndef NO_ACTION_LAYER
- extern layer_state_t layer_state;
+extern layer_state_t layer_state;
#endif
#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
- #include "process_midi.h"
+# include "process_midi.h"
#endif
#ifdef AUDIO_ENABLE
- #include "audio.h"
- #include "process_audio.h"
- #ifdef AUDIO_CLICKY
- #include "process_clicky.h"
- #endif
+# include "audio.h"
+# include "process_audio.h"
+# ifdef AUDIO_CLICKY
+# include "process_clicky.h"
+# endif
#endif
#ifdef STENO_ENABLE
- #include "process_steno.h"
+# include "process_steno.h"
#endif
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
- #include "process_music.h"
+# include "process_music.h"
#endif
#ifdef LEADER_ENABLE
- #include "process_leader.h"
+# include "process_leader.h"
#endif
#ifdef UNICODE_ENABLE
- #include "process_unicode.h"
+# include "process_unicode.h"
#endif
#ifdef UCIS_ENABLE
- #include "process_ucis.h"
+# include "process_ucis.h"
#endif
#ifdef UNICODEMAP_ENABLE
- #include "process_unicodemap.h"
+# include "process_unicodemap.h"
#endif
#ifdef TAP_DANCE_ENABLE
- #include "process_tap_dance.h"
+# include "process_tap_dance.h"
#endif
#ifdef PRINTING_ENABLE
- #include "process_printer.h"
+# include "process_printer.h"
#endif
#ifdef AUTO_SHIFT_ENABLE
- #include "process_auto_shift.h"
+# include "process_auto_shift.h"
#endif
#ifdef COMBO_ENABLE
- #include "process_combo.h"
+# include "process_combo.h"
#endif
#ifdef KEY_LOCK_ENABLE
- #include "process_key_lock.h"
+# include "process_key_lock.h"
#endif
#ifdef TERMINAL_ENABLE
- #include "process_terminal.h"
+# include "process_terminal.h"
#else
- #include "process_terminal_nop.h"
+# include "process_terminal_nop.h"
#endif
#ifdef SPACE_CADET_ENABLE
- #include "process_space_cadet.h"
+# include "process_space_cadet.h"
#endif
#ifdef HD44780_ENABLE
- #include "hd44780.h"
+# include "hd44780.h"
#endif
#ifdef HAPTIC_ENABLE
- #include "haptic.h"
+# include "haptic.h"
#endif
#ifdef OLED_DRIVER_ENABLE
- #include "oled_driver.h"
+# include "oled_driver.h"
+#endif
+
+#ifdef DIP_SWITCH_ENABLE
+# include "dip_switch.h"
+#endif
+
+#ifdef DYNAMIC_MACRO_ENABLE
+# include "process_dynamic_macro.h"
#endif
// Function substitutions to ease GPIO manipulation
#if defined(__AVR__)
- typedef uint8_t pin_t;
+typedef uint8_t pin_t;
- #define PIN_ADDRESS(p, offset) (_SFR_IO8(ADDRESS_BASE + ((p) >> PORT_SHIFTER) + (offset)))
- #define setPinInput(pin) (PIN_ADDRESS(pin, 1) &= ~_BV((pin) & 0xF))
- #define setPinInputHigh(pin) (PIN_ADDRESS(pin, 1) &= ~_BV((pin) & 0xF), \
- PIN_ADDRESS(pin, 2) |= _BV((pin) & 0xF))
- #define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
- #define setPinOutput(pin) (PIN_ADDRESS(pin, 1) |= _BV((pin) & 0xF))
+# define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF))
+# define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
+# define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
- #define writePinHigh(pin) (PIN_ADDRESS(pin, 2) |= _BV((pin) & 0xF))
- #define writePinLow(pin) (PIN_ADDRESS(pin, 2) &= ~_BV((pin) & 0xF))
- #define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
+# define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
+# define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
- #define readPin(pin) ((bool)(PIN_ADDRESS(pin, 0) & _BV((pin) & 0xF)))
+# define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
#elif defined(PROTOCOL_CHIBIOS)
- typedef ioline_t pin_t;
+typedef ioline_t pin_t;
- #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)
- #define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)
- #define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)
- #define setPinOutput(pin) palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)
+# define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)
+# define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)
+# define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)
+# define setPinOutput(pin) palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)
- #define writePinHigh(pin) palSetLine(pin)
- #define writePinLow(pin) palClearLine(pin)
- #define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
+# define writePinHigh(pin) palSetLine(pin)
+# define writePinLow(pin) palClearLine(pin)
+# define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
- #define readPin(pin) palReadLine(pin)
+# define readPin(pin) palReadLine(pin)
#endif
// Send string macros
#define STRINGIZE(z) #z
-#define ADD_SLASH_X(y) STRINGIZE(\x ## y)
+#define ADD_SLASH_X(y) STRINGIZE(\x##y)
#define SYMBOL_STR(x) ADD_SLASH_X(x)
#define SS_TAP_CODE 1
@@ -201,9 +207,9 @@ extern layer_state_t default_layer_state;
#define SEND_STRING(string) send_string_P(PSTR(string))
-extern const bool ascii_to_shift_lut[0x80];
-extern const bool ascii_to_altgr_lut[0x80];
-extern const uint8_t ascii_to_keycode_lut[0x80];
+extern const bool ascii_to_shift_lut[128];
+extern const bool ascii_to_altgr_lut[128];
+extern const uint8_t ascii_to_keycode_lut[128];
void send_string(const char *str);
void send_string_with_delay(const char *str, uint8_t interval);
@@ -212,31 +218,31 @@ void send_string_with_delay_P(const char *str, uint8_t interval);
void send_char(char ascii_code);
// For tri-layer
-void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
-uint32_t update_tri_layer_state(uint32_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
+void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
+layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3);
void set_single_persistent_default_layer(uint8_t default_layer);
void tap_random_base64(void);
-#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
+#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
#define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
-void matrix_init_kb(void);
-void matrix_scan_kb(void);
-void matrix_init_user(void);
-void matrix_scan_user(void);
+void matrix_init_kb(void);
+void matrix_scan_kb(void);
+void matrix_init_user(void);
+void matrix_scan_user(void);
uint16_t get_record_keycode(keyrecord_t *record);
uint16_t get_event_keycode(keyevent_t event);
-bool process_action_kb(keyrecord_t *record);
-bool process_record_kb(uint16_t keycode, keyrecord_t *record);
-bool process_record_user(uint16_t keycode, keyrecord_t *record);
+bool process_action_kb(keyrecord_t *record);
+bool process_record_kb(uint16_t keycode, keyrecord_t *record);
+bool process_record_user(uint16_t keycode, keyrecord_t *record);
#ifndef BOOTMAGIC_LITE_COLUMN
- #define BOOTMAGIC_LITE_COLUMN 0
+# define BOOTMAGIC_LITE_COLUMN 0
#endif
#ifndef BOOTMAGIC_LITE_ROW
- #define BOOTMAGIC_LITE_ROW 0
+# define BOOTMAGIC_LITE_ROW 0
#endif
void bootmagic_lite(void);
@@ -254,10 +260,10 @@ void tap_code16(uint16_t code);
void backlight_init_ports(void);
void backlight_task(void);
void backlight_task_internal(void);
-void backlight_on(uint8_t backlight_pin);
-void backlight_off(uint8_t backlight_pin);
+void backlight_on(pin_t backlight_pin);
+void backlight_off(pin_t backlight_pin);
- #ifdef BACKLIGHT_BREATHING
+# ifdef BACKLIGHT_BREATHING
void breathing_task(void);
void breathing_enable(void);
void breathing_pulse(void);
@@ -271,16 +277,18 @@ void breathing_period_default(void);
void breathing_period_set(uint8_t value);
void breathing_period_inc(void);
void breathing_period_dec(void);
- #endif
+# endif
#endif
-void send_dword(uint32_t number);
-void send_word(uint16_t number);
-void send_byte(uint8_t number);
-void send_nibble(uint8_t number);
+void send_dword(uint32_t number);
+void send_word(uint16_t number);
+void send_byte(uint8_t number);
+void send_nibble(uint8_t number);
uint16_t hex_to_keycode(uint8_t hex);
void led_set_user(uint8_t usb_led);
void led_set_kb(uint8_t usb_led);
+bool led_update_user(led_t led_state);
+bool led_update_kb(led_t led_state);
void api_send_unicode(uint32_t unicode);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 779c355efc..66a3c66e85 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -17,13 +17,13 @@
#define QUANTUM_KEYCODES_H
#ifndef MIDI_ENABLE_STRICT
-#define MIDI_ENABLE_STRICT 0
+# define MIDI_ENABLE_STRICT 0
#endif
#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
-#ifndef MIDI_TONE_KEYCODE_OCTAVES
-#define MIDI_TONE_KEYCODE_OCTAVES 3
-#endif
+# ifndef MIDI_TONE_KEYCODE_OCTAVES
+# define MIDI_TONE_KEYCODE_OCTAVES 3
+# endif
#endif
// Fillers to make layering more clear
@@ -31,64 +31,64 @@
#define XXXXXXX KC_NO
enum quantum_keycodes {
- // Ranges used in shortucuts - not to be used directly
- QK_TMK = 0x0000,
- QK_TMK_MAX = 0x00FF,
- QK_MODS = 0x0100,
- QK_LCTL = 0x0100,
- QK_LSFT = 0x0200,
- QK_LALT = 0x0400,
- QK_LGUI = 0x0800,
- QK_RMODS_MIN = 0x1000,
- QK_RCTL = 0x1100,
- QK_RSFT = 0x1200,
- QK_RALT = 0x1400,
- QK_RGUI = 0x1800,
- QK_MODS_MAX = 0x1FFF,
- QK_FUNCTION = 0x2000,
- QK_FUNCTION_MAX = 0x2FFF,
- QK_MACRO = 0x3000,
- QK_MACRO_MAX = 0x3FFF,
- QK_LAYER_TAP = 0x4000,
- QK_LAYER_TAP_MAX = 0x4FFF,
- QK_TO = 0x5000,
- QK_TO_MAX = 0x50FF,
- QK_MOMENTARY = 0x5100,
- QK_MOMENTARY_MAX = 0x51FF,
- QK_DEF_LAYER = 0x5200,
- QK_DEF_LAYER_MAX = 0x52FF,
- QK_TOGGLE_LAYER = 0x5300,
- QK_TOGGLE_LAYER_MAX = 0x53FF,
- QK_ONE_SHOT_LAYER = 0x5400,
- QK_ONE_SHOT_LAYER_MAX = 0x54FF,
- QK_ONE_SHOT_MOD = 0x5500,
- QK_ONE_SHOT_MOD_MAX = 0x55FF,
- QK_TAP_DANCE = 0x5700,
- QK_TAP_DANCE_MAX = 0x57FF,
- QK_LAYER_TAP_TOGGLE = 0x5800,
+ // Ranges used in shortcuts - not to be used directly
+ QK_BASIC = 0x0000,
+ QK_BASIC_MAX = 0x00FF,
+ QK_MODS = 0x0100,
+ QK_LCTL = 0x0100,
+ QK_LSFT = 0x0200,
+ QK_LALT = 0x0400,
+ QK_LGUI = 0x0800,
+ QK_RMODS_MIN = 0x1000,
+ QK_RCTL = 0x1100,
+ QK_RSFT = 0x1200,
+ QK_RALT = 0x1400,
+ QK_RGUI = 0x1800,
+ QK_MODS_MAX = 0x1FFF,
+ QK_FUNCTION = 0x2000,
+ QK_FUNCTION_MAX = 0x2FFF,
+ QK_MACRO = 0x3000,
+ QK_MACRO_MAX = 0x3FFF,
+ QK_LAYER_TAP = 0x4000,
+ QK_LAYER_TAP_MAX = 0x4FFF,
+ QK_TO = 0x5000,
+ QK_TO_MAX = 0x50FF,
+ QK_MOMENTARY = 0x5100,
+ QK_MOMENTARY_MAX = 0x51FF,
+ QK_DEF_LAYER = 0x5200,
+ QK_DEF_LAYER_MAX = 0x52FF,
+ QK_TOGGLE_LAYER = 0x5300,
+ QK_TOGGLE_LAYER_MAX = 0x53FF,
+ QK_ONE_SHOT_LAYER = 0x5400,
+ QK_ONE_SHOT_LAYER_MAX = 0x54FF,
+ QK_ONE_SHOT_MOD = 0x5500,
+ QK_ONE_SHOT_MOD_MAX = 0x55FF,
+ QK_TAP_DANCE = 0x5700,
+ QK_TAP_DANCE_MAX = 0x57FF,
+ QK_LAYER_TAP_TOGGLE = 0x5800,
QK_LAYER_TAP_TOGGLE_MAX = 0x58FF,
- QK_LAYER_MOD = 0x5900,
- QK_LAYER_MOD_MAX = 0x59FF,
+ QK_LAYER_MOD = 0x5900,
+ QK_LAYER_MOD_MAX = 0x59FF,
#ifdef STENO_ENABLE
- QK_STENO = 0x5A00,
- QK_STENO_BOLT = 0x5A30,
- QK_STENO_GEMINI = 0x5A31,
- QK_STENO_MAX = 0x5A3F,
+ QK_STENO = 0x5A00,
+ QK_STENO_BOLT = 0x5A30,
+ QK_STENO_GEMINI = 0x5A31,
+ QK_STENO_MAX = 0x5A3F,
#endif
#ifdef SWAP_HANDS_ENABLE
- QK_SWAP_HANDS = 0x5B00,
- QK_SWAP_HANDS_MAX = 0x5BFF,
+ QK_SWAP_HANDS = 0x5B00,
+ QK_SWAP_HANDS_MAX = 0x5BFF,
#endif
- QK_MOD_TAP = 0x6000,
- QK_MOD_TAP_MAX = 0x7FFF,
+ QK_MOD_TAP = 0x6000,
+ QK_MOD_TAP_MAX = 0x7FFF,
#ifdef UNICODE_ENABLE
- QK_UNICODE = 0x8000,
- QK_UNICODE_MAX = 0xFFFF,
+ QK_UNICODE = 0x8000,
+ QK_UNICODE_MAX = 0xFFFF,
#endif
#ifdef UNICODEMAP_ENABLE
- QK_UNICODEMAP = 0x8000,
- QK_UNICODEMAP_MAX = 0xBFFF,
- QK_UNICODEMAP_PAIR = 0xC000,
+ QK_UNICODEMAP = 0x8000,
+ QK_UNICODEMAP_MAX = 0xBFFF,
+ QK_UNICODEMAP_PAIR = 0xC000,
QK_UNICODEMAP_PAIR_MAX = 0xFFFF,
#endif
@@ -118,7 +118,7 @@ enum quantum_keycodes {
MAGIC_TOGGLE_ALT_GUI,
GRAVE_ESC,
- // Leader key
+// Leader key
#ifdef LEADER_ENABLE
KC_LEAD,
#endif
@@ -144,7 +144,6 @@ enum quantum_keycodes {
CLICKY_DOWN,
CLICKY_RESET,
-
#ifdef FAUXCLICKY_ENABLE
// Faux clicky
FC_ON,
@@ -164,7 +163,7 @@ enum quantum_keycodes {
MUV_IN,
MUV_DE,
- // Midi
+// Midi
#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
MI_ON,
MI_OFF,
@@ -174,7 +173,7 @@ enum quantum_keycodes {
#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
MIDI_TONE_MIN,
-#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 0
+# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 0
MI_C = MIDI_TONE_MIN,
MI_Cs,
MI_Db = MI_Cs,
@@ -192,9 +191,9 @@ enum quantum_keycodes {
MI_As,
MI_Bb = MI_As,
MI_B,
-#endif
+# endif
-#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 1
+# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 1
MI_C_1,
MI_Cs_1,
MI_Db_1 = MI_Cs_1,
@@ -212,9 +211,9 @@ enum quantum_keycodes {
MI_As_1,
MI_Bb_1 = MI_As_1,
MI_B_1,
-#endif
+# endif
-#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 2
+# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 2
MI_C_2,
MI_Cs_2,
MI_Db_2 = MI_Cs_2,
@@ -232,9 +231,9 @@ enum quantum_keycodes {
MI_As_2,
MI_Bb_2 = MI_As_2,
MI_B_2,
-#endif
+# endif
-#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 3
+# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 3
MI_C_3,
MI_Cs_3,
MI_Db_3 = MI_Cs_3,
@@ -252,9 +251,9 @@ enum quantum_keycodes {
MI_As_3,
MI_Bb_3 = MI_As_3,
MI_B_3,
-#endif
+# endif
-#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 4
+# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 4
MI_C_4,
MI_Cs_4,
MI_Db_4 = MI_Cs_4,
@@ -272,9 +271,9 @@ enum quantum_keycodes {
MI_As_4,
MI_Bb_4 = MI_As_4,
MI_B_4,
-#endif
+# endif
-#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
+# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
MI_C_5,
MI_Cs_5,
MI_Db_5 = MI_Cs_5,
@@ -292,21 +291,21 @@ enum quantum_keycodes {
MI_As_5,
MI_Bb_5 = MI_As_5,
MI_B_5,
-#endif
+# endif
-#if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
+# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
MIDI_TONE_MAX = MI_B_5,
-#elif MIDI_TONE_KEYCODE_OCTAVES > 4
+# elif MIDI_TONE_KEYCODE_OCTAVES > 4
MIDI_TONE_MAX = MI_B_4,
-#elif MIDI_TONE_KEYCODE_OCTAVES > 3
+# elif MIDI_TONE_KEYCODE_OCTAVES > 3
MIDI_TONE_MAX = MI_B_3,
-#elif MIDI_TONE_KEYCODE_OCTAVES > 2
+# elif MIDI_TONE_KEYCODE_OCTAVES > 2
MIDI_TONE_MAX = MI_B_2,
-#elif MIDI_TONE_KEYCODE_OCTAVES > 1
+# elif MIDI_TONE_KEYCODE_OCTAVES > 1
MIDI_TONE_MAX = MI_B_1,
-#elif MIDI_TONE_KEYCODE_OCTAVES > 0
+# elif MIDI_TONE_KEYCODE_OCTAVES > 0
MIDI_TONE_MAX = MI_B,
-#endif
+# endif
MIDI_OCTAVE_MIN,
MI_OCT_N2 = MIDI_OCTAVE_MIN,
@@ -320,8 +319,8 @@ enum quantum_keycodes {
MI_OCT_6,
MI_OCT_7,
MIDI_OCTAVE_MAX = MI_OCT_7,
- MI_OCTD, // octave down
- MI_OCTU, // octave up
+ MI_OCTD, // octave down
+ MI_OCTU, // octave up
MIDI_TRANSPOSE_MIN,
MI_TRNS_N6 = MIDI_TRANSPOSE_MIN,
@@ -338,8 +337,8 @@ enum quantum_keycodes {
MI_TRNS_5,
MI_TRNS_6,
MIDI_TRANSPOSE_MAX = MI_TRNS_6,
- MI_TRNSD, // transpose down
- MI_TRNSU, // transpose up
+ MI_TRNSD, // transpose down
+ MI_TRNSU, // transpose up
MIDI_VELOCITY_MIN,
MI_VEL_1 = MIDI_VELOCITY_MIN,
@@ -353,8 +352,8 @@ enum quantum_keycodes {
MI_VEL_9,
MI_VEL_10,
MIDI_VELOCITY_MAX = MI_VEL_10,
- MI_VELD, // velocity down
- MI_VELU, // velocity up
+ MI_VELD, // velocity down
+ MI_VELU, // velocity up
MIDI_CHANNEL_MIN,
MI_CH1 = MIDI_CHANNEL_MIN,
@@ -374,24 +373,24 @@ enum quantum_keycodes {
MI_CH15,
MI_CH16,
MIDI_CHANNEL_MAX = MI_CH16,
- MI_CHD, // previous channel
- MI_CHU, // next channel
+ MI_CHD, // previous channel
+ MI_CHU, // next channel
- MI_ALLOFF, // all notes off
+ MI_ALLOFF, // all notes off
- MI_SUS, // sustain
- MI_PORT, // portamento
- MI_SOST, // sostenuto
- MI_SOFT, // soft pedal
- MI_LEG, // legato
+ MI_SUS, // sustain
+ MI_PORT, // portamento
+ MI_SOST, // sostenuto
+ MI_SOFT, // soft pedal
+ MI_LEG, // legato
- MI_MOD, // modulation
- MI_MODSD, // decrease modulation speed
- MI_MODSU, // increase modulation speed
+ MI_MOD, // modulation
+ MI_MODSD, // decrease modulation speed
+ MI_MODSU, // increase modulation speed
- MI_BENDD, // Bend down
- MI_BENDU, // Bend up
-#endif // MIDI_ADVANCED
+ MI_BENDD, // Bend down
+ MI_BENDU, // Bend up
+#endif // MIDI_ADVANCED
// Backlight functionality
BL_ON,
@@ -424,7 +423,7 @@ enum quantum_keycodes {
RGB_MODE_GRADIENT,
RGB_MODE_RGBTEST,
- //Momentum matching toggle
+ // Momentum matching toggle
VLK_TOG,
// Left shift, open paren
@@ -474,6 +473,9 @@ enum quantum_keycodes {
HPT_BUZ,
HPT_MODI,
HPT_MODD,
+ HPT_CONT,
+ HPT_CONI,
+ HPT_COND,
HPT_DWLI,
HPT_DWLD,
@@ -489,6 +491,27 @@ enum quantum_keycodes {
// Right control, close paren
KC_RAPC,
+ CMB_ON,
+ CMB_OFF,
+ CMB_TOG,
+
+ MAGIC_SWAP_LCTL_LGUI,
+ MAGIC_SWAP_RCTL_RGUI,
+ MAGIC_UNSWAP_LCTL_LGUI,
+ MAGIC_UNSWAP_RCTL_RGUI,
+ MAGIC_SWAP_CTL_GUI,
+ MAGIC_UNSWAP_CTL_GUI,
+ MAGIC_TOGGLE_CTL_GUI,
+ MAGIC_EE_HANDS_LEFT,
+ MAGIC_EE_HANDS_RIGHT,
+
+ // Dynamic Macros
+ DYN_REC_START1,
+ DYN_REC_START2,
+ DYN_REC_STOP,
+ DYN_MACRO_PLAY1,
+ DYN_MACRO_PLAY2,
+
// always leave at the end
SAFE_RANGE
};
@@ -509,86 +532,86 @@ enum quantum_keycodes {
#define RWIN(kc) RGUI(kc)
#define HYPR(kc) (QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI | (kc))
-#define MEH(kc) (QK_LCTL | QK_LSFT | QK_LALT | (kc))
+#define MEH(kc) (QK_LCTL | QK_LSFT | QK_LALT | (kc))
#define LCAG(kc) (QK_LCTL | QK_LALT | QK_LGUI | (kc))
#define SGUI(kc) (QK_LGUI | QK_LSFT | (kc))
#define SCMD(kc) SGUI(kc)
#define SWIN(kc) SGUI(kc)
-#define LCA(kc) (QK_LCTL | QK_LALT | (kc))
+#define LCA(kc) (QK_LCTL | QK_LALT | (kc))
#define MOD_HYPR 0xF
-#define MOD_MEH 0x7
+#define MOD_MEH 0x7
// Aliases for shifted symbols
// Each key has a 4-letter code, and some have longer aliases too.
// While the long aliases are descriptive, the 4-letter codes
// make for nicer grid layouts (everything lines up), and are
// the preferred style for Quantum.
-#define KC_TILD LSFT(KC_GRV) // ~
-#define KC_TILDE KC_TILD
+#define KC_TILD LSFT(KC_GRV) // ~
+#define KC_TILDE KC_TILD
-#define KC_EXLM LSFT(KC_1) // !
-#define KC_EXCLAIM KC_EXLM
+#define KC_EXLM LSFT(KC_1) // !
+#define KC_EXCLAIM KC_EXLM
-#define KC_AT LSFT(KC_2) // @
+#define KC_AT LSFT(KC_2) // @
-#define KC_HASH LSFT(KC_3) // #
+#define KC_HASH LSFT(KC_3) // #
-#define KC_DLR LSFT(KC_4) // $
-#define KC_DOLLAR KC_DLR
+#define KC_DLR LSFT(KC_4) // $
+#define KC_DOLLAR KC_DLR
-#define KC_PERC LSFT(KC_5) // %
-#define KC_PERCENT KC_PERC
+#define KC_PERC LSFT(KC_5) // %
+#define KC_PERCENT KC_PERC
-#define KC_CIRC LSFT(KC_6) // ^
-#define KC_CIRCUMFLEX KC_CIRC
+#define KC_CIRC LSFT(KC_6) // ^
+#define KC_CIRCUMFLEX KC_CIRC
-#define KC_AMPR LSFT(KC_7) // &
-#define KC_AMPERSAND KC_AMPR
+#define KC_AMPR LSFT(KC_7) // &
+#define KC_AMPERSAND KC_AMPR
-#define KC_ASTR LSFT(KC_8) // *
+#define KC_ASTR LSFT(KC_8) // *
#define KC_ASTERISK KC_ASTR
-#define KC_LPRN LSFT(KC_9) // (
-#define KC_LEFT_PAREN KC_LPRN
+#define KC_LPRN LSFT(KC_9) // (
+#define KC_LEFT_PAREN KC_LPRN
-#define KC_RPRN LSFT(KC_0) // )
-#define KC_RIGHT_PAREN KC_RPRN
+#define KC_RPRN LSFT(KC_0) // )
+#define KC_RIGHT_PAREN KC_RPRN
-#define KC_UNDS LSFT(KC_MINS) // _
-#define KC_UNDERSCORE KC_UNDS
+#define KC_UNDS LSFT(KC_MINS) // _
+#define KC_UNDERSCORE KC_UNDS
-#define KC_PLUS LSFT(KC_EQL) // +
+#define KC_PLUS LSFT(KC_EQL) // +
-#define KC_LCBR LSFT(KC_LBRC) // {
+#define KC_LCBR LSFT(KC_LBRC) // {
#define KC_LEFT_CURLY_BRACE KC_LCBR
-#define KC_RCBR LSFT(KC_RBRC) // }
-#define KC_RIGHT_CURLY_BRACE KC_RCBR
+#define KC_RCBR LSFT(KC_RBRC) // }
+#define KC_RIGHT_CURLY_BRACE KC_RCBR
-#define KC_LABK LSFT(KC_COMM) // <
-#define KC_LEFT_ANGLE_BRACKET KC_LABK
+#define KC_LABK LSFT(KC_COMM) // <
+#define KC_LEFT_ANGLE_BRACKET KC_LABK
-#define KC_RABK LSFT(KC_DOT) // >
-#define KC_RIGHT_ANGLE_BRACKET KC_RABK
+#define KC_RABK LSFT(KC_DOT) // >
+#define KC_RIGHT_ANGLE_BRACKET KC_RABK
-#define KC_COLN LSFT(KC_SCLN) // :
-#define KC_COLON KC_COLN
+#define KC_COLN LSFT(KC_SCLN) // :
+#define KC_COLON KC_COLN
-#define KC_PIPE LSFT(KC_BSLS) // |
+#define KC_PIPE LSFT(KC_BSLS) // |
-#define KC_LT LSFT(KC_COMM) // <
+#define KC_LT LSFT(KC_COMM) // <
-#define KC_GT LSFT(KC_DOT) // >
+#define KC_GT LSFT(KC_DOT) // >
-#define KC_QUES LSFT(KC_SLSH) // ?
+#define KC_QUES LSFT(KC_SLSH) // ?
#define KC_QUESTION KC_QUES
-#define KC_DQT LSFT(KC_QUOT) // "
+#define KC_DQT LSFT(KC_QUOT) // "
#define KC_DOUBLE_QUOTE KC_DQT
#define KC_DQUO KC_DQT
-#define KC_DELT KC_DELETE // Del key (four letter code)
+#define KC_DELT KC_DELETE // Del key (four letter code)
// Alias for function layers than expand past FN31
#define FUNC(kc) (QK_FUNCTION | (kc))
@@ -630,12 +653,16 @@ enum quantum_keycodes {
#define RGB_M_T RGB_MODE_RGBTEST
// L-ayer, T-ap - 256 keycode max, 16 layer max
-#define LT(layer, kc) (QK_LAYER_TAP | (((layer) & 0xF) << 8) | ((kc) & 0xFF))
+#define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF))
#define AG_SWAP MAGIC_SWAP_ALT_GUI
#define AG_NORM MAGIC_UNSWAP_ALT_GUI
#define AG_TOGG MAGIC_TOGGLE_ALT_GUI
+#define CG_SWAP MAGIC_SWAP_CTL_GUI
+#define CG_NORM MAGIC_UNSWAP_CTL_GUI
+#define CG_TOGG MAGIC_TOGGLE_CTL_GUI
+
// GOTO layer - 16 layers max
// when:
// ON_PRESS = 1
@@ -644,43 +671,43 @@ enum quantum_keycodes {
// In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
// keycode modeled after the old version, kept below for this.
/* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */
-#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer) & 0xFF))
+#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer)&0xFF))
// Momentary switch layer - 256 layer max
-#define MO(layer) (QK_MOMENTARY | ((layer) & 0xFF))
+#define MO(layer) (QK_MOMENTARY | ((layer)&0xFF))
// Set default layer - 256 layer max
-#define DF(layer) (QK_DEF_LAYER | ((layer) & 0xFF))
+#define DF(layer) (QK_DEF_LAYER | ((layer)&0xFF))
// Toggle to layer - 256 layer max
-#define TG(layer) (QK_TOGGLE_LAYER | ((layer) & 0xFF))
+#define TG(layer) (QK_TOGGLE_LAYER | ((layer)&0xFF))
// One-shot layer - 256 layer max
-#define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer) & 0xFF))
+#define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer)&0xFF))
// L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only
-#define LM(layer, mod) (QK_LAYER_MOD | (((layer) & 0xF) << 4) | ((mod) & 0xF))
+#define LM(layer, mod) (QK_LAYER_MOD | (((layer)&0xF) << 4) | ((mod)&0xF))
// One-shot mod
-#define OSM(mod) (QK_ONE_SHOT_MOD | ((mod) & 0xFF))
+#define OSM(mod) (QK_ONE_SHOT_MOD | ((mod)&0xFF))
// Layer tap-toggle
-#define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer) & 0xFF))
+#define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer)&0xFF))
// M-od, T-ap - 256 keycode max
-#define MT(mod, kc) (QK_MOD_TAP | (((mod) & 0x1F) << 8) | ((kc) & 0xFF))
+#define MT(mod, kc) (QK_MOD_TAP | (((mod)&0x1F) << 8) | ((kc)&0xFF))
#define LCTL_T(kc) MT(MOD_LCTL, kc)
#define RCTL_T(kc) MT(MOD_RCTL, kc)
-#define CTL_T(kc) LCTL_T(kc)
+#define CTL_T(kc) LCTL_T(kc)
#define LSFT_T(kc) MT(MOD_LSFT, kc)
#define RSFT_T(kc) MT(MOD_RSFT, kc)
-#define SFT_T(kc) LSFT_T(kc)
+#define SFT_T(kc) LSFT_T(kc)
#define LALT_T(kc) MT(MOD_LALT, kc)
#define RALT_T(kc) MT(MOD_RALT, kc)
-#define ALT_T(kc) LALT_T(kc)
+#define ALT_T(kc) LALT_T(kc)
#define ALGR_T(kc) RALT_T(kc)
#define LGUI_T(kc) MT(MOD_LGUI, kc)
@@ -689,36 +716,36 @@ enum quantum_keycodes {
#define LWIN_T(kc) LGUI_T(kc)
#define RCMD_T(kc) RGUI_T(kc)
#define RWIN_T(kc) RGUI_T(kc)
-#define GUI_T(kc) LGUI_T(kc)
-#define CMD_T(kc) LCMD_T(kc)
-#define WIN_T(kc) LWIN_T(kc)
-
-#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
-#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
-#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
-#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
-#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/
-#define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI
+#define GUI_T(kc) LGUI_T(kc)
+#define CMD_T(kc) LCMD_T(kc)
+#define WIN_T(kc) LWIN_T(kc)
+
+#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
+#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
+#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
+#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
+#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/
+#define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI
#define SCMD_T(kc) SGUI_T(kc)
#define SWIN_T(kc) SGUI_T(kc)
-#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt
-#define ALL_T(kc) HYPR_T(kc)
+#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt
+#define ALL_T(kc) HYPR_T(kc)
// Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap
#define KC_HYPR HYPR(KC_NO)
-#define KC_MEH MEH(KC_NO)
+#define KC_MEH MEH(KC_NO)
#ifdef UNICODE_ENABLE
- // Allows Unicode input up to 0x7FFF
- #define UC(c) (QK_UNICODE | (c))
+// Allows Unicode input up to 0x7FFF
+# define UC(c) (QK_UNICODE | (c))
#endif
#ifdef UNICODEMAP_ENABLE
- // Allows Unicode input up to 0x10FFFF, requires unicode_map
- #define X(i) (QK_UNICODEMAP | (i))
- #define XP(i, j) (QK_UNICODEMAP_PAIR | ((i) & 0x7F) | (((j) & 0x7F) << 7)) // 127 max i and j
+// Allows Unicode input up to 0x10FFFF, requires unicode_map
+# define X(i) (QK_UNICODEMAP | (i))
+# define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j
#endif
-#define UC_MOD UNICODE_MODE_FORWARD
+#define UC_MOD UNICODE_MODE_FORWARD
#define UC_RMOD UNICODE_MODE_REVERSE
#define UC_M_OS UNICODE_MODE_OSX
@@ -728,13 +755,20 @@ enum quantum_keycodes {
#define UC_M_WC UNICODE_MODE_WINC
#ifdef SWAP_HANDS_ENABLE
- #define SH_T(kc) (QK_SWAP_HANDS | (kc))
- #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE)
- #define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE)
- #define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF)
- #define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON)
- #define SH_ON (QK_SWAP_HANDS | OP_SH_ON)
- #define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF)
+# define SH_T(kc) (QK_SWAP_HANDS | (kc))
+# define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE)
+# define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE)
+# define SH_MON (QK_SWAP_HANDS | OP_SH_ON_OFF)
+# define SH_MOFF (QK_SWAP_HANDS | OP_SH_OFF_ON)
+# define SH_ON (QK_SWAP_HANDS | OP_SH_ON)
+# define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF)
#endif
-#endif // QUANTUM_KEYCODES_H
+// Dynamic Macros aliases
+#define DM_REC1 DYN_REC_START1
+#define DM_REC2 DYN_REC_START2
+#define DM_RSTP DYN_REC_STOP
+#define DM_PLY1 DYN_MACRO_PLAY1
+#define DM_PLY2 DYN_MACRO_PLAY2
+
+#endif // QUANTUM_KEYCODES_H
diff --git a/quantum/rgb.h b/quantum/rgb.h
index ce674ce6bc..7b6ea0542f 100644
--- a/quantum/rgb.h
+++ b/quantum/rgb.h
@@ -17,37 +17,26 @@
#ifndef RGB_H
#define RGB_H
-__attribute__((weak))
-void rgblight_toggle(void) {};
+__attribute__((weak)) void rgblight_toggle(void){};
-__attribute__((weak))
-void rgblight_step(void) {};
+__attribute__((weak)) void rgblight_step(void){};
-__attribute__((weak))
-void rgblight_step_reverse(void) {};
+__attribute__((weak)) void rgblight_step_reverse(void){};
-__attribute__((weak))
-void rgblight_increase_hue(void) {};
+__attribute__((weak)) void rgblight_increase_hue(void){};
-__attribute__((weak))
-void rgblight_decrease_hue(void) {};
+__attribute__((weak)) void rgblight_decrease_hue(void){};
-__attribute__((weak))
-void rgblight_increase_sat(void) {};
+__attribute__((weak)) void rgblight_increase_sat(void){};
-__attribute__((weak))
-void rgblight_decrease_sat(void) {};
+__attribute__((weak)) void rgblight_decrease_sat(void){};
-__attribute__((weak))
-void rgblight_increase_val(void) {};
+__attribute__((weak)) void rgblight_increase_val(void){};
-__attribute__((weak))
-void rgblight_decrease_val(void) {};
+__attribute__((weak)) void rgblight_decrease_val(void){};
-__attribute__((weak))
-void rgblight_increase_speed(void) {};
+__attribute__((weak)) void rgblight_increase_speed(void){};
-__attribute__((weak))
-void rgblight_decrease_speed(void) {};
+__attribute__((weak)) void rgblight_decrease_speed(void){};
#endif \ No newline at end of file
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index d20daf5e45..55a6f74be7 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include "rgb_matrix.h"
#include "progmem.h"
#include "config.h"
@@ -27,9 +26,9 @@
#include "lib/lib8tion/lib8tion.h"
#ifndef RGB_MATRIX_CENTER
- const point_t k_rgb_matrix_center = { 112, 32 };
+const point_t k_rgb_matrix_center = {112, 32};
#else
- const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
+const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
#endif
// Generic effect runners
@@ -47,10 +46,10 @@
#include "rgb_matrix_animations/rgb_matrix_effects.inc"
#ifdef RGB_MATRIX_CUSTOM_KB
- #include "rgb_matrix_kb.inc"
+# include "rgb_matrix_kb.inc"
#endif
#ifdef RGB_MATRIX_CUSTOM_USER
- #include "rgb_matrix_user.inc"
+# include "rgb_matrix_user.inc"
#endif
#undef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
@@ -59,52 +58,48 @@
// ------------------------------------------
#ifndef RGB_DISABLE_AFTER_TIMEOUT
- #define RGB_DISABLE_AFTER_TIMEOUT 0
+# define RGB_DISABLE_AFTER_TIMEOUT 0
#endif
#ifndef RGB_DISABLE_WHEN_USB_SUSPENDED
- #define RGB_DISABLE_WHEN_USB_SUSPENDED false
-#endif
-
-#ifndef EECONFIG_RGB_MATRIX
- #define EECONFIG_RGB_MATRIX EECONFIG_RGBLIGHT
+# define RGB_DISABLE_WHEN_USB_SUSPENDED false
#endif
#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
- #undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
- #define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
+# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
+# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
#endif
#if !defined(RGB_MATRIX_HUE_STEP)
- #define RGB_MATRIX_HUE_STEP 8
+# define RGB_MATRIX_HUE_STEP 8
#endif
#if !defined(RGB_MATRIX_SAT_STEP)
- #define RGB_MATRIX_SAT_STEP 16
+# define RGB_MATRIX_SAT_STEP 16
#endif
#if !defined(RGB_MATRIX_VAL_STEP)
- #define RGB_MATRIX_VAL_STEP 16
+# define RGB_MATRIX_VAL_STEP 16
#endif
#if !defined(RGB_MATRIX_SPD_STEP)
- #define RGB_MATRIX_SPD_STEP 16
+# define RGB_MATRIX_SPD_STEP 16
#endif
#if !defined(RGB_MATRIX_STARTUP_MODE)
- #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
- #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
- #else
- // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
- #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR
- #endif
+# ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
+# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
+# else
+// fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
+# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR
+# endif
#endif
bool g_suspend_state = false;
rgb_config_t rgb_matrix_config;
-rgb_counters_t g_rgb_counters;
+rgb_counters_t g_rgb_counters;
static uint32_t rgb_counters_buffer;
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
@@ -112,456 +107,421 @@ uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
- last_hit_t g_last_hit_tracker;
- static last_hit_t last_hit_buffer;
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+last_hit_t g_last_hit_tracker;
+static last_hit_t last_hit_buffer;
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
-uint32_t eeconfig_read_rgb_matrix(void) {
- return eeprom_read_dword(EECONFIG_RGB_MATRIX);
-}
+void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); }
-void eeconfig_update_rgb_matrix(uint32_t val) {
- eeprom_update_dword(EECONFIG_RGB_MATRIX, val);
-}
+void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); }
void eeconfig_update_rgb_matrix_default(void) {
- dprintf("eeconfig_update_rgb_matrix_default\n");
- rgb_matrix_config.enable = 1;
- rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
- rgb_matrix_config.hsv = (HSV){ 0, UINT8_MAX, RGB_MATRIX_MAXIMUM_BRIGHTNESS };
- rgb_matrix_config.speed = UINT8_MAX / 2;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ dprintf("eeconfig_update_rgb_matrix_default\n");
+ rgb_matrix_config.enable = 1;
+ rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
+ rgb_matrix_config.hsv = (HSV){0, UINT8_MAX, RGB_MATRIX_MAXIMUM_BRIGHTNESS};
+ rgb_matrix_config.speed = UINT8_MAX / 2;
+ eeconfig_update_rgb_matrix();
}
void eeconfig_debug_rgb_matrix(void) {
- dprintf("rgb_matrix_config eprom\n");
- dprintf("rgb_matrix_config.enable = %d\n", rgb_matrix_config.enable);
- dprintf("rgb_matrix_config.mode = %d\n", rgb_matrix_config.mode);
- dprintf("rgb_matrix_config.hsv.h = %d\n", rgb_matrix_config.hsv.h);
- dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s);
- dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v);
- dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
+ dprintf("rgb_matrix_config eprom\n");
+ dprintf("rgb_matrix_config.enable = %d\n", rgb_matrix_config.enable);
+ dprintf("rgb_matrix_config.mode = %d\n", rgb_matrix_config.mode);
+ dprintf("rgb_matrix_config.hsv.h = %d\n", rgb_matrix_config.hsv.h);
+ dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s);
+ dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v);
+ dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
}
-__attribute__ ((weak))
-uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) {
- return 0;
-}
+__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; }
uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
- uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i);
- uint8_t led_index = g_led_config.matrix_co[row][column];
- if (led_index != NO_LED) {
- led_i[led_count] = led_index;
- led_count++;
- }
- return led_count;
+ uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i);
+ uint8_t led_index = g_led_config.matrix_co[row][column];
+ if (led_index != NO_LED) {
+ led_i[led_count] = led_index;
+ led_count++;
+ }
+ return led_count;
}
-void rgb_matrix_update_pwm_buffers(void) {
- rgb_matrix_driver.flush();
-}
+void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); }
-void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) {
- rgb_matrix_driver.set_color(index, red, green, blue);
-}
+void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); }
-void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) {
- rgb_matrix_driver.set_color_all(red, green, blue);
-}
+void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); }
bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
- uint8_t led[LED_HITS_TO_REMEMBER];
- uint8_t led_count = 0;
-
-#if defined(RGB_MATRIX_KEYRELEASES)
- if (!record->event.pressed) {
- led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
- g_rgb_counters.any_key_hit = 0;
- }
-#elif defined(RGB_MATRIX_KEYPRESSES)
- if (record->event.pressed) {
- led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
- g_rgb_counters.any_key_hit = 0;
- }
-#endif // defined(RGB_MATRIX_KEYRELEASES)
-
- if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
- memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count);
- memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count);
- memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit
- memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count);
- last_hit_buffer.count--;
- }
-
- for(uint8_t i = 0; i < led_count; i++) {
- uint8_t index = last_hit_buffer.count;
- last_hit_buffer.x[index] = g_led_config.point[led[i]].x;
- last_hit_buffer.y[index] = g_led_config.point[led[i]].y;
- last_hit_buffer.index[index] = led[i];
- last_hit_buffer.tick[index] = 0;
- last_hit_buffer.count++;
- }
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+ uint8_t led[LED_HITS_TO_REMEMBER];
+ uint8_t led_count = 0;
+
+# if defined(RGB_MATRIX_KEYRELEASES)
+ if (!record->event.pressed) {
+ led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
+ g_rgb_counters.any_key_hit = 0;
+ }
+# elif defined(RGB_MATRIX_KEYPRESSES)
+ if (record->event.pressed) {
+ led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
+ g_rgb_counters.any_key_hit = 0;
+ }
+# endif // defined(RGB_MATRIX_KEYRELEASES)
+
+ if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
+ memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count);
+ memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count);
+ memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit
+ memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count);
+ last_hit_buffer.count--;
+ }
+
+ for (uint8_t i = 0; i < led_count; i++) {
+ uint8_t index = last_hit_buffer.count;
+ last_hit_buffer.x[index] = g_led_config.point[led[i]].x;
+ last_hit_buffer.y[index] = g_led_config.point[led[i]].y;
+ last_hit_buffer.index[index] = led[i];
+ last_hit_buffer.tick[index] = 0;
+ last_hit_buffer.count++;
+ }
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
- if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) {
- process_rgb_matrix_typing_heatmap(record);
- }
-#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
+ if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) {
+ process_rgb_matrix_typing_heatmap(record);
+ }
+#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
- return true;
+ return true;
}
void rgb_matrix_test(void) {
- // Mask out bits 4 and 5
- // Increase the factor to make the test animation slower (and reduce to make it faster)
- uint8_t factor = 10;
- switch ( (g_rgb_counters.tick & (0b11 << factor)) >> factor )
- {
- case 0: {
- rgb_matrix_set_color_all( 20, 0, 0 );
- break;
+ // Mask out bits 4 and 5
+ // Increase the factor to make the test animation slower (and reduce to make it faster)
+ uint8_t factor = 10;
+ switch ((g_rgb_counters.tick & (0b11 << factor)) >> factor) {
+ case 0: {
+ rgb_matrix_set_color_all(20, 0, 0);
+ break;
+ }
+ case 1: {
+ rgb_matrix_set_color_all(0, 20, 0);
+ break;
+ }
+ case 2: {
+ rgb_matrix_set_color_all(0, 0, 20);
+ break;
+ }
+ case 3: {
+ rgb_matrix_set_color_all(20, 20, 20);
+ break;
+ }
}
- case 1: {
- rgb_matrix_set_color_all( 0, 20, 0 );
- break;
- }
- case 2: {
- rgb_matrix_set_color_all( 0, 0, 20 );
- break;
- }
- case 3: {
- rgb_matrix_set_color_all( 20, 20, 20 );
- break;
- }
- }
}
-static bool rgb_matrix_none(effect_params_t* params) {
- if (!params->init) {
- return false;
- }
+static bool rgb_matrix_none(effect_params_t *params) {
+ if (!params->init) {
+ return false;
+ }
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
- for (uint8_t i = led_min; i < led_max; i++) {
- rgb_matrix_set_color(i, 0, 0, 0);
- }
- return led_max < DRIVER_LED_TOTAL;
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ rgb_matrix_set_color(i, 0, 0, 0);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
-static uint8_t rgb_last_enable = UINT8_MAX;
-static uint8_t rgb_last_effect = UINT8_MAX;
-static effect_params_t rgb_effect_params = { 0, 0xFF };
-static rgb_task_states rgb_task_state = SYNCING;
+static uint8_t rgb_last_enable = UINT8_MAX;
+static uint8_t rgb_last_effect = UINT8_MAX;
+static effect_params_t rgb_effect_params = {0, 0xFF};
+static rgb_task_states rgb_task_state = SYNCING;
static void rgb_task_timers(void) {
- // Update double buffer timers
- uint16_t deltaTime = timer_elapsed32(rgb_counters_buffer);
- rgb_counters_buffer = timer_read32();
- if (g_rgb_counters.any_key_hit < UINT32_MAX) {
- if (UINT32_MAX - deltaTime < g_rgb_counters.any_key_hit) {
- g_rgb_counters.any_key_hit = UINT32_MAX;
- } else {
- g_rgb_counters.any_key_hit += deltaTime;
+ // Update double buffer timers
+ uint16_t deltaTime = timer_elapsed32(rgb_counters_buffer);
+ rgb_counters_buffer = timer_read32();
+ if (g_rgb_counters.any_key_hit < UINT32_MAX) {
+ if (UINT32_MAX - deltaTime < g_rgb_counters.any_key_hit) {
+ g_rgb_counters.any_key_hit = UINT32_MAX;
+ } else {
+ g_rgb_counters.any_key_hit += deltaTime;
+ }
}
- }
- // Update double buffer last hit timers
+ // Update double buffer last hit timers
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
- uint8_t count = last_hit_buffer.count;
- for (uint8_t i = 0; i < count; ++i) {
- if (UINT16_MAX - deltaTime < last_hit_buffer.tick[i]) {
- last_hit_buffer.count--;
- continue;
+ uint8_t count = last_hit_buffer.count;
+ for (uint8_t i = 0; i < count; ++i) {
+ if (UINT16_MAX - deltaTime < last_hit_buffer.tick[i]) {
+ last_hit_buffer.count--;
+ continue;
+ }
+ last_hit_buffer.tick[i] += deltaTime;
}
- last_hit_buffer.tick[i] += deltaTime;
- }
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
}
static void rgb_task_sync(void) {
- // next task
- if (timer_elapsed32(g_rgb_counters.tick) >= RGB_MATRIX_LED_FLUSH_LIMIT)
- rgb_task_state = STARTING;
+ // next task
+ if (timer_elapsed32(g_rgb_counters.tick) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING;
}
static void rgb_task_start(void) {
- // reset iter
- rgb_effect_params.iter = 0;
+ // reset iter
+ rgb_effect_params.iter = 0;
- // update double buffers
- g_rgb_counters.tick = rgb_counters_buffer;
+ // update double buffers
+ g_rgb_counters.tick = rgb_counters_buffer;
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
- g_last_hit_tracker = last_hit_buffer;
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+ g_last_hit_tracker = last_hit_buffer;
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
- // next task
- rgb_task_state = RENDERING;
+ // next task
+ rgb_task_state = RENDERING;
}
static void rgb_task_render(uint8_t effect) {
- bool rendering = false;
- rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable);
+ bool rendering = false;
+ rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable);
- // each effect can opt to do calculations
- // and/or request PWM buffer updates.
- switch (effect) {
- case RGB_MATRIX_NONE:
- rendering = rgb_matrix_none(&rgb_effect_params);
- break;
+ // each effect can opt to do calculations
+ // and/or request PWM buffer updates.
+ switch (effect) {
+ case RGB_MATRIX_NONE:
+ rendering = rgb_matrix_none(&rgb_effect_params);
+ break;
// ---------------------------------------------
// -----Begin rgb effect switch case macros-----
-#define RGB_MATRIX_EFFECT(name, ...) \
- case RGB_MATRIX_##name: \
- rendering = name(&rgb_effect_params); \
- break;
+#define RGB_MATRIX_EFFECT(name, ...) \
+ case RGB_MATRIX_##name: \
+ rendering = name(&rgb_effect_params); \
+ break;
#include "rgb_matrix_animations/rgb_matrix_effects.inc"
#undef RGB_MATRIX_EFFECT
#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER)
- #define RGB_MATRIX_EFFECT(name, ...) \
- case RGB_MATRIX_CUSTOM_##name: \
- rendering = name(&rgb_effect_params); \
- break;
- #ifdef RGB_MATRIX_CUSTOM_KB
- #include "rgb_matrix_kb.inc"
- #endif
- #ifdef RGB_MATRIX_CUSTOM_USER
- #include "rgb_matrix_user.inc"
- #endif
- #undef RGB_MATRIX_EFFECT
+# define RGB_MATRIX_EFFECT(name, ...) \
+ case RGB_MATRIX_CUSTOM_##name: \
+ rendering = name(&rgb_effect_params); \
+ break;
+# ifdef RGB_MATRIX_CUSTOM_KB
+# include "rgb_matrix_kb.inc"
+# endif
+# ifdef RGB_MATRIX_CUSTOM_USER
+# include "rgb_matrix_user.inc"
+# endif
+# undef RGB_MATRIX_EFFECT
#endif
-// -----End rgb effect switch case macros-------
-// ---------------------------------------------
+ // -----End rgb effect switch case macros-------
+ // ---------------------------------------------
+
+ // Factory default magic value
+ case UINT8_MAX: {
+ rgb_matrix_test();
+ rgb_task_state = FLUSHING;
+ }
+ return;
+ }
- // Factory default magic value
- case UINT8_MAX: {
- rgb_matrix_test();
+ rgb_effect_params.iter++;
+
+ // next task
+ if (!rendering) {
rgb_task_state = FLUSHING;
- }
- return;
- }
-
- rgb_effect_params.iter++;
-
- // next task
- if (!rendering) {
- rgb_task_state = FLUSHING;
- if (!rgb_effect_params.init && effect == RGB_MATRIX_NONE) {
- // We only need to flush once if we are RGB_MATRIX_NONE
- rgb_task_state = SYNCING;
+ if (!rgb_effect_params.init && effect == RGB_MATRIX_NONE) {
+ // We only need to flush once if we are RGB_MATRIX_NONE
+ rgb_task_state = SYNCING;
+ }
}
- }
}
static void rgb_task_flush(uint8_t effect) {
- // update last trackers after the first full render so we can init over several frames
- rgb_last_effect = effect;
- rgb_last_enable = rgb_matrix_config.enable;
+ // update last trackers after the first full render so we can init over several frames
+ rgb_last_effect = effect;
+ rgb_last_enable = rgb_matrix_config.enable;
- // update pwm buffers
- rgb_matrix_update_pwm_buffers();
+ // update pwm buffers
+ rgb_matrix_update_pwm_buffers();
- // next task
- rgb_task_state = SYNCING;
+ // next task
+ rgb_task_state = SYNCING;
}
void rgb_matrix_task(void) {
- rgb_task_timers();
-
- // Ideally we would also stop sending zeros to the LED driver PWM buffers
- // while suspended and just do a software shutdown. This is a cheap hack for now.
- bool suspend_backlight = ((g_suspend_state && RGB_DISABLE_WHEN_USB_SUSPENDED) || (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_rgb_counters.any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20));
- uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
-
- switch (rgb_task_state) {
- case STARTING:
- rgb_task_start();
- break;
- case RENDERING:
- rgb_task_render(effect);
- break;
- case FLUSHING:
- rgb_task_flush(effect);
- break;
- case SYNCING:
- rgb_task_sync();
- break;
- }
-
- if (!suspend_backlight) {
- rgb_matrix_indicators();
- }
+ rgb_task_timers();
+
+ // Ideally we would also stop sending zeros to the LED driver PWM buffers
+ // while suspended and just do a software shutdown. This is a cheap hack for now.
+ bool suspend_backlight = ((g_suspend_state && RGB_DISABLE_WHEN_USB_SUSPENDED) || (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_rgb_counters.any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20));
+ uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
+
+ switch (rgb_task_state) {
+ case STARTING:
+ rgb_task_start();
+ break;
+ case RENDERING:
+ rgb_task_render(effect);
+ break;
+ case FLUSHING:
+ rgb_task_flush(effect);
+ break;
+ case SYNCING:
+ rgb_task_sync();
+ break;
+ }
+
+ if (!suspend_backlight) {
+ rgb_matrix_indicators();
+ }
}
void rgb_matrix_indicators(void) {
- rgb_matrix_indicators_kb();
- rgb_matrix_indicators_user();
+ rgb_matrix_indicators_kb();
+ rgb_matrix_indicators_user();
}
-__attribute__((weak))
-void rgb_matrix_indicators_kb(void) {}
+__attribute__((weak)) void rgb_matrix_indicators_kb(void) {}
-__attribute__((weak))
-void rgb_matrix_indicators_user(void) {}
+__attribute__((weak)) void rgb_matrix_indicators_user(void) {}
void rgb_matrix_init(void) {
- rgb_matrix_driver.init();
+ rgb_matrix_driver.init();
- // TODO: put the 1 second startup delay here?
+ // TODO: put the 1 second startup delay here?
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
- g_last_hit_tracker.count = 0;
- for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
- g_last_hit_tracker.tick[i] = UINT16_MAX;
- }
+ g_last_hit_tracker.count = 0;
+ for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
+ g_last_hit_tracker.tick[i] = UINT16_MAX;
+ }
- last_hit_buffer.count = 0;
- for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
- last_hit_buffer.tick[i] = UINT16_MAX;
- }
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+ last_hit_buffer.count = 0;
+ for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
+ last_hit_buffer.tick[i] = UINT16_MAX;
+ }
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
- if (!eeconfig_is_enabled()) {
- dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n");
- eeconfig_init();
- eeconfig_update_rgb_matrix_default();
- }
+ if (!eeconfig_is_enabled()) {
+ dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n");
+ eeconfig_init();
+ eeconfig_update_rgb_matrix_default();
+ }
- rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
- rgb_matrix_config.speed = UINT8_MAX / 2; //EECONFIG needs to be increased to support this
- if (!rgb_matrix_config.mode) {
- dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n");
- eeconfig_update_rgb_matrix_default();
- rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
- }
- eeconfig_debug_rgb_matrix(); // display current eeprom values
+ eeconfig_read_rgb_matrix();
+ if (!rgb_matrix_config.mode) {
+ dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n");
+ eeconfig_update_rgb_matrix_default();
+ }
+ eeconfig_debug_rgb_matrix(); // display current eeprom values
}
-void rgb_matrix_set_suspend_state(bool state) {
- g_suspend_state = state;
-}
+void rgb_matrix_set_suspend_state(bool state) { g_suspend_state = state; }
void rgb_matrix_toggle(void) {
- rgb_matrix_config.enable ^= 1;
- rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.enable ^= 1;
+ rgb_task_state = STARTING;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_enable(void) {
- rgb_matrix_enable_noeeprom();
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_enable_noeeprom();
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_enable_noeeprom(void) {
- if (!rgb_matrix_config.enable)
- rgb_task_state = STARTING;
- rgb_matrix_config.enable = 1;
+ if (!rgb_matrix_config.enable) rgb_task_state = STARTING;
+ rgb_matrix_config.enable = 1;
}
void rgb_matrix_disable(void) {
- rgb_matrix_disable_noeeprom();
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_disable_noeeprom();
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_disable_noeeprom(void) {
- if (rgb_matrix_config.enable)
- rgb_task_state = STARTING;
- rgb_matrix_config.enable = 0;
+ if (rgb_matrix_config.enable) rgb_task_state = STARTING;
+ rgb_matrix_config.enable = 0;
}
void rgb_matrix_step(void) {
- rgb_matrix_config.mode++;
- if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX)
- rgb_matrix_config.mode = 1;
- rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.mode++;
+ if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1;
+ rgb_task_state = STARTING;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_step_reverse(void) {
- rgb_matrix_config.mode--;
- if (rgb_matrix_config.mode < 1)
- rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1;
- rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.mode--;
+ if (rgb_matrix_config.mode < 1) rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1;
+ rgb_task_state = STARTING;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_hue(void) {
- rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_hue(void) {
- rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_sat(void) {
- rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_sat(void) {
- rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_val(void) {
- rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
- if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
- rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
+ if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_val(void) {
- rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_speed(void) {
- rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this
+ rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_speed(void) {
- rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this
+ rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
+ eeconfig_update_rgb_matrix();
}
-led_flags_t rgb_matrix_get_flags(void) {
- return rgb_effect_params.flags;
-}
+led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; }
-void rgb_matrix_set_flags(led_flags_t flags) {
- rgb_effect_params.flags = flags;
-}
+void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; }
void rgb_matrix_mode(uint8_t mode) {
- rgb_matrix_config.mode = mode;
- rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.mode = mode;
+ rgb_task_state = STARTING;
+ eeconfig_update_rgb_matrix();
}
-void rgb_matrix_mode_noeeprom(uint8_t mode) {
- rgb_matrix_config.mode = mode;
-}
+void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_config.mode = mode; }
-uint8_t rgb_matrix_get_mode(void) {
- return rgb_matrix_config.mode;
-}
+uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; }
void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
- rgb_matrix_sethsv_noeeprom(hue, sat, val);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_sethsv_noeeprom(hue, sat, val);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
- rgb_matrix_config.hsv.h = hue;
- rgb_matrix_config.hsv.s = sat;
- rgb_matrix_config.hsv.v = val;
- if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
- rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
+ rgb_matrix_config.hsv.h = hue;
+ rgb_matrix_config.hsv.s = sat;
+ rgb_matrix_config.hsv.v = val;
+ if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
}
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index 96a8b76627..16ec96f036 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -27,43 +27,39 @@
#include "rgblight_list.h"
#ifdef IS31FL3731
- #include "is31fl3731.h"
-#elif defined (IS31FL3733)
- #include "is31fl3733.h"
-#elif defined (IS31FL3737)
- #include "is31fl3737.h"
-#elif defined (WS2812)
- #include "ws2812.h"
+# include "is31fl3731.h"
+#elif defined(IS31FL3733)
+# include "is31fl3733.h"
+#elif defined(IS31FL3737)
+# include "is31fl3737.h"
+#elif defined(WS2812)
+# include "ws2812.h"
#endif
#ifndef RGB_MATRIX_LED_FLUSH_LIMIT
- #define RGB_MATRIX_LED_FLUSH_LIMIT 16
+# define RGB_MATRIX_LED_FLUSH_LIMIT 16
#endif
#ifndef RGB_MATRIX_LED_PROCESS_LIMIT
- #define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5
+# define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5
#endif
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
-#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
- uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
- if (max > DRIVER_LED_TOTAL) \
- max = DRIVER_LED_TOTAL;
+# define RGB_MATRIX_USE_LIMITS(min, max) \
+ uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
+ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
+ if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
#else
-#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = 0; \
- uint8_t max = DRIVER_LED_TOTAL;
+# define RGB_MATRIX_USE_LIMITS(min, max) \
+ uint8_t min = 0; \
+ uint8_t max = DRIVER_LED_TOTAL;
#endif
-#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue
-
-typedef struct
-{
- HSV color;
- uint8_t index;
-} rgb_indicator;
+#define RGB_MATRIX_TEST_LED_FLAGS() \
+ if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue
enum rgb_matrix_effects {
- RGB_MATRIX_NONE = 0,
+ RGB_MATRIX_NONE = 0,
// --------------------------------------
// -----Begin rgb effect enum macros-----
@@ -72,25 +68,32 @@ enum rgb_matrix_effects {
#undef RGB_MATRIX_EFFECT
#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER)
- #define RGB_MATRIX_EFFECT(name, ...) RGB_MATRIX_CUSTOM_##name,
- #ifdef RGB_MATRIX_CUSTOM_KB
- #include "rgb_matrix_kb.inc"
- #endif
- #ifdef RGB_MATRIX_CUSTOM_USER
- #include "rgb_matrix_user.inc"
- #endif
- #undef RGB_MATRIX_EFFECT
+# define RGB_MATRIX_EFFECT(name, ...) RGB_MATRIX_CUSTOM_##name,
+# ifdef RGB_MATRIX_CUSTOM_KB
+# include "rgb_matrix_kb.inc"
+# endif
+# ifdef RGB_MATRIX_CUSTOM_USER
+# include "rgb_matrix_user.inc"
+# endif
+# undef RGB_MATRIX_EFFECT
#endif
-// --------------------------------------
-// -----End rgb effect enum macros-------
+ // --------------------------------------
+ // -----End rgb effect enum macros-------
- RGB_MATRIX_EFFECT_MAX
+ RGB_MATRIX_EFFECT_MAX
};
-uint8_t rgb_matrix_map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i);
+void eeconfig_update_rgb_matrix_default(void);
+
+uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i);
+uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i);
+
+void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
+void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
-void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
-void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
+
+void rgb_matrix_task(void);
// This runs after another backlight effect and replaces
// colors already set
@@ -99,74 +102,52 @@ void rgb_matrix_indicators_kb(void);
void rgb_matrix_indicators_user(void);
void rgb_matrix_init(void);
-void rgb_matrix_setup_drivers(void);
-
-void rgb_matrix_set_suspend_state(bool state);
-void rgb_matrix_set_indicator_state(uint8_t state);
-
-void rgb_matrix_task(void);
-
-// This should not be called from an interrupt
-// (eg. from a timer interrupt).
-// Call this while idle (in between matrix scans).
-// If the buffer is dirty, it will update the driver with the buffer.
-void rgb_matrix_update_pwm_buffers(void);
-
-bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
-
-void rgb_matrix_increase(void);
-void rgb_matrix_decrease(void);
-
-// void *backlight_get_key_color_eeprom_address(uint8_t led);
-// void backlight_get_key_color( uint8_t led, HSV *hsv );
-// void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
-
-void rgb_matrix_toggle(void);
-void rgb_matrix_enable(void);
-void rgb_matrix_enable_noeeprom(void);
-void rgb_matrix_disable(void);
-void rgb_matrix_disable_noeeprom(void);
-void rgb_matrix_step(void);
-void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
-void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
-void rgb_matrix_step_reverse(void);
-void rgb_matrix_increase_hue(void);
-void rgb_matrix_decrease_hue(void);
-void rgb_matrix_increase_sat(void);
-void rgb_matrix_decrease_sat(void);
-void rgb_matrix_increase_val(void);
-void rgb_matrix_decrease_val(void);
-void rgb_matrix_increase_speed(void);
-void rgb_matrix_decrease_speed(void);
+void rgb_matrix_set_suspend_state(bool state);
+void rgb_matrix_toggle(void);
+void rgb_matrix_enable(void);
+void rgb_matrix_enable_noeeprom(void);
+void rgb_matrix_disable(void);
+void rgb_matrix_disable_noeeprom(void);
+void rgb_matrix_step(void);
+void rgb_matrix_step_reverse(void);
+void rgb_matrix_increase_hue(void);
+void rgb_matrix_decrease_hue(void);
+void rgb_matrix_increase_sat(void);
+void rgb_matrix_decrease_sat(void);
+void rgb_matrix_increase_val(void);
+void rgb_matrix_decrease_val(void);
+void rgb_matrix_increase_speed(void);
+void rgb_matrix_decrease_speed(void);
led_flags_t rgb_matrix_get_flags(void);
-void rgb_matrix_set_flags(led_flags_t flags);
-void rgb_matrix_mode(uint8_t mode);
-void rgb_matrix_mode_noeeprom(uint8_t mode);
-uint8_t rgb_matrix_get_mode(void);
+void rgb_matrix_set_flags(led_flags_t flags);
+void rgb_matrix_mode(uint8_t mode);
+void rgb_matrix_mode_noeeprom(uint8_t mode);
+uint8_t rgb_matrix_get_mode(void);
+void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
+void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
#ifndef RGBLIGHT_ENABLE
-#define rgblight_toggle() rgb_matrix_toggle()
-#define rgblight_enable() rgb_matrix_enable()
-#define rgblight_enable_noeeprom() rgb_matrix_enable_noeeprom()
-#define rgblight_disable() rgb_matrix_disable()
-#define rgblight_disable_noeeprom() rgb_matrix_disable_noeeprom()
-#define rgblight_step() rgb_matrix_step()
-#define rgblight_sethsv(hue, sat, val) rgb_matrix_sethsv(hue, sat, val)
-#define rgblight_sethsv_noeeprom(hue, sat, val) rgb_matrix_sethsv_noeeprom(hue, sat, val)
-#define rgblight_step_reverse() rgb_matrix_step_reverse()
-#define rgblight_increase_hue() rgb_matrix_increase_hue()
-#define rgblight_decrease_hue() rgb_matrix_decrease_hue()
-#define rgblight_increase_sat() rgb_matrix_increase_sat()
-#define rgblight_decrease_sat() rgb_matrix_decrease_sat()
-#define rgblight_increase_val() rgb_matrix_increase_val()
-#define rgblight_decrease_val() rgb_matrix_decrease_val()
-#define rgblight_increase_speed() rgb_matrix_increase_speed()
-#define rgblight_decrease_speed() rgb_matrix_decrease_speed()
-#define rgblight_mode(mode) rgb_matrix_mode(mode)
-#define rgblight_mode_noeeprom(mode) rgb_matrix_mode_noeeprom(mode)
-#define rgblight_get_mode() rgb_matrix_get_mode()
-
+# define rgblight_toggle() rgb_matrix_toggle()
+# define rgblight_enable() rgb_matrix_enable()
+# define rgblight_enable_noeeprom() rgb_matrix_enable_noeeprom()
+# define rgblight_disable() rgb_matrix_disable()
+# define rgblight_disable_noeeprom() rgb_matrix_disable_noeeprom()
+# define rgblight_step() rgb_matrix_step()
+# define rgblight_sethsv(hue, sat, val) rgb_matrix_sethsv(hue, sat, val)
+# define rgblight_sethsv_noeeprom(hue, sat, val) rgb_matrix_sethsv_noeeprom(hue, sat, val)
+# define rgblight_step_reverse() rgb_matrix_step_reverse()
+# define rgblight_increase_hue() rgb_matrix_increase_hue()
+# define rgblight_decrease_hue() rgb_matrix_decrease_hue()
+# define rgblight_increase_sat() rgb_matrix_increase_sat()
+# define rgblight_decrease_sat() rgb_matrix_decrease_sat()
+# define rgblight_increase_val() rgb_matrix_increase_val()
+# define rgblight_decrease_val() rgb_matrix_decrease_val()
+# define rgblight_increase_speed() rgb_matrix_increase_speed()
+# define rgblight_decrease_speed() rgb_matrix_decrease_speed()
+# define rgblight_mode(mode) rgb_matrix_mode(mode)
+# define rgblight_mode_noeeprom(mode) rgb_matrix_mode_noeeprom(mode)
+# define rgblight_get_mode() rgb_matrix_get_mode()
#endif
typedef struct {
@@ -184,9 +165,9 @@ extern const rgb_matrix_driver_t rgb_matrix_driver;
extern rgb_config_t rgb_matrix_config;
-extern bool g_suspend_state;
+extern bool g_suspend_state;
extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
+extern led_config_t g_led_config;
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
extern last_hit_t g_last_hit_tracker;
#endif
diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h
index 8df3356f61..0778ab2098 100644
--- a/quantum/rgb_matrix_animations/alpha_mods_anim.h
+++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h
@@ -1,26 +1,26 @@
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
RGB_MATRIX_EFFECT(ALPHAS_MODS)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
// alphas = color1, mods = color2
bool ALPHAS_MODS(effect_params_t* params) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- HSV hsv = rgb_matrix_config.hsv;
- RGB rgb1 = hsv_to_rgb(hsv);
- hsv.h += rgb_matrix_config.speed;
- RGB rgb2 = hsv_to_rgb(hsv);
+ HSV hsv = rgb_matrix_config.hsv;
+ RGB rgb1 = hsv_to_rgb(hsv);
+ hsv.h += rgb_matrix_config.speed;
+ RGB rgb2 = hsv_to_rgb(hsv);
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
- rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b);
- } else {
- rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
+ rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b);
+ } else {
+ rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);
+ }
}
- }
- return led_max < DRIVER_LED_TOTAL;
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
diff --git a/quantum/rgb_matrix_animations/breathing_anim.h b/quantum/rgb_matrix_animations/breathing_anim.h
index 0af7b42cf3..92431555e7 100644
--- a/quantum/rgb_matrix_animations/breathing_anim.h
+++ b/quantum/rgb_matrix_animations/breathing_anim.h
@@ -1,20 +1,20 @@
#ifndef DISABLE_RGB_MATRIX_BREATHING
RGB_MATRIX_EFFECT(BREATHING)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
bool BREATHING(effect_params_t* params) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- HSV hsv = rgb_matrix_config.hsv;
- uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
- hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
- RGB rgb = hsv_to_rgb(hsv);
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ HSV hsv = rgb_matrix_config.hsv;
+ uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
+ hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
+ RGB rgb = hsv_to_rgb(hsv);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_BREATHING
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 4585c52716..3df3cfda7d 100644
--- a/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
hsv.s = scale8(hsv.s - time - atan2_8(dy, dx) * 3, hsv.s);
return hsv;
}
-bool BAND_PINWHEEL_SAT(effect_params_t* params) {
- return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math);
-}
+bool BAND_PINWHEEL_SAT(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 5cdb873489..7d80074fd5 100644
--- a/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
hsv.v = scale8(hsv.v - time - atan2_8(dy, dx) * 3, hsv.v);
return hsv;
}
-bool BAND_PINWHEEL_VAL(effect_params_t* params) {
- return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math);
-}
+bool BAND_PINWHEEL_VAL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 a5175f1cd9..35b830af6b 100644
--- a/quantum/rgb_matrix_animations/colorband_sat_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_sat_anim.h
@@ -1,16 +1,14 @@
#ifndef DISABLE_RGB_MATRIX_BAND_SAT
RGB_MATRIX_EFFECT(BAND_SAT)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) {
int16_t s = hsv.s - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
- hsv.s = scale8(s < 0 ? 0 : s, hsv.s);
+ hsv.s = scale8(s < 0 ? 0 : s, hsv.s);
return hsv;
}
-bool BAND_SAT(effect_params_t* params) {
- return effect_runner_i(params, &BAND_SAT_math);
-}
+bool BAND_SAT(effect_params_t* params) { return effect_runner_i(params, &BAND_SAT_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_BAND_SAT
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 096c675de8..048157aa1b 100644
--- a/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
hsv.s = scale8(hsv.s + dist - time - atan2_8(dy, dx), hsv.s);
return hsv;
}
-bool BAND_SPIRAL_SAT(effect_params_t* params) {
- return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math);
-}
+bool BAND_SPIRAL_SAT(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 1d4cc0c84f..bff2da1616 100644
--- a/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL
RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
hsv.v = scale8(hsv.v + dist - time - atan2_8(dy, dx), hsv.v);
return hsv;
}
-bool BAND_SPIRAL_VAL(effect_params_t* params) {
- return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math);
-}
+bool BAND_SPIRAL_VAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 de0bbb4715..f1aaf1d067 100644
--- a/quantum/rgb_matrix_animations/colorband_val_anim.h
+++ b/quantum/rgb_matrix_animations/colorband_val_anim.h
@@ -1,16 +1,14 @@
#ifndef DISABLE_RGB_MATRIX_BAND_VAL
RGB_MATRIX_EFFECT(BAND_VAL)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) {
int16_t v = hsv.v - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
- hsv.v = scale8(v < 0 ? 0 : v, hsv.v);
+ hsv.v = scale8(v < 0 ? 0 : v, hsv.v);
return hsv;
}
-bool BAND_VAL(effect_params_t* params) {
- return effect_runner_i(params, &BAND_VAL_math);
-}
+bool BAND_VAL(effect_params_t* params) { return effect_runner_i(params, &BAND_VAL_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_BAND_VAL
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 0c45aba8b1..faf8598a39 100644
--- a/quantum/rgb_matrix_animations/cycle_all_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_all_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
RGB_MATRIX_EFFECT(CYCLE_ALL)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time){
+static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time) {
hsv.h = time;
return hsv;
}
-bool CYCLE_ALL(effect_params_t* params) {
- return effect_runner_i(params, &CYCLE_ALL_math);
-}
+bool CYCLE_ALL(effect_params_t* params) { return effect_runner_i(params, &CYCLE_ALL_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_CYCLE_ALL
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 d2e5b4fbdf..cf911eb937 100644
--- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) {
+static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) {
hsv.h = g_led_config.point[i].x - time;
return hsv;
}
-bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
- return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math);
-}
+bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 fa7c3b09cf..d66acd4b2b 100644
--- a/quantum/rgb_matrix_animations/cycle_out_in_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_out_in_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_OUT_IN
RGB_MATRIX_EFFECT(CYCLE_OUT_IN)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
+static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
hsv.h = 3 * dist / 2 + time;
return hsv;
}
-bool CYCLE_OUT_IN(effect_params_t* params) {
- return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math);
-}
+bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 74a2c9aa58..fe8396140f 100644
--- a/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h
@@ -1,17 +1,15 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
- dx = (k_rgb_matrix_center.x / 2) - abs8(dx);
+static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
+ dx = (k_rgb_matrix_center.x / 2) - abs8(dx);
uint8_t dist = sqrt16(dx * dx + dy * dy);
- hsv.h = 3 * dist + time;
+ hsv.h = 3 * dist + time;
return hsv;
}
-bool CYCLE_OUT_IN_DUAL(effect_params_t* params) {
- return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math);
-}
+bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 54e222dc2e..7799887099 100644
--- a/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_PINWHEEL
RGB_MATRIX_EFFECT(CYCLE_PINWHEEL)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
+static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
hsv.h = atan2_8(dy, dx) + time;
return hsv;
}
-bool CYCLE_PINWHEEL(effect_params_t* params) {
- return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math);
-}
+bool CYCLE_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_CYCLE_PINWHEEL
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 b27d7a83c7..80cfb0dbc7 100644
--- a/quantum/rgb_matrix_animations/cycle_spiral_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_spiral_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_SPIRAL
RGB_MATRIX_EFFECT(CYCLE_SPIRAL)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
+static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
hsv.h = dist - time - atan2_8(dy, dx);
return hsv;
}
-bool CYCLE_SPIRAL(effect_params_t* params) {
- return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math);
-}
+bool CYCLE_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_CYCLE_SPIRAL
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 4bf8ef2ae4..5016f739d6 100644
--- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
RGB_MATRIX_EFFECT(CYCLE_UP_DOWN)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) {
+static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) {
hsv.h = g_led_config.point[i].y - time;
return hsv;
}
-bool CYCLE_UP_DOWN(effect_params_t* params) {
- return effect_runner_i(params, &CYCLE_UP_DOWN_math);
-}
+bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 982399cbde..7a4a52db1b 100644
--- a/quantum/rgb_matrix_animations/digital_rain_anim.h
+++ b/quantum/rgb_matrix_animations/digital_rain_anim.h
@@ -1,77 +1,75 @@
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN)
RGB_MATRIX_EFFECT(DIGITAL_RAIN)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#ifndef RGB_DIGITAL_RAIN_DROPS
- // lower the number for denser effect/wider keyboard
- #define RGB_DIGITAL_RAIN_DROPS 24
-#endif
+# ifndef RGB_DIGITAL_RAIN_DROPS
+// lower the number for denser effect/wider keyboard
+# define RGB_DIGITAL_RAIN_DROPS 24
+# endif
bool DIGITAL_RAIN(effect_params_t* params) {
- // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain
- const uint8_t drop_ticks = 28;
- const uint8_t pure_green_intensity = 0xd0;
- const uint8_t max_brightness_boost = 0xc0;
- const uint8_t max_intensity = 0xff;
+ // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain
+ const uint8_t drop_ticks = 28;
+ const uint8_t pure_green_intensity = 0xd0;
+ const uint8_t max_brightness_boost = 0xc0;
+ const uint8_t max_intensity = 0xff;
- static uint8_t drop = 0;
+ static uint8_t drop = 0;
- if (params->init) {
- rgb_matrix_set_color_all(0, 0, 0);
- memset(rgb_frame_buffer, 0, sizeof(rgb_frame_buffer));
- drop = 0;
- }
+ if (params->init) {
+ rgb_matrix_set_color_all(0, 0, 0);
+ memset(rgb_frame_buffer, 0, sizeof(rgb_frame_buffer));
+ drop = 0;
+ }
- for (uint8_t col = 0; col < MATRIX_COLS; col++) {
- for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) {
- // top row, pixels have just fallen and we're
- // making a new rain drop in this column
- rgb_frame_buffer[row][col] = max_intensity;
- }
- else if (rgb_frame_buffer[row][col] > 0 && rgb_frame_buffer[row][col] < max_intensity) {
- // neither fully bright nor dark, decay it
- rgb_frame_buffer[row][col]--;
- }
- // set the pixel colour
- uint8_t led[LED_HITS_TO_REMEMBER];
- uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) {
+ // top row, pixels have just fallen and we're
+ // making a new rain drop in this column
+ rgb_frame_buffer[row][col] = max_intensity;
+ } else if (rgb_frame_buffer[row][col] > 0 && rgb_frame_buffer[row][col] < max_intensity) {
+ // neither fully bright nor dark, decay it
+ rgb_frame_buffer[row][col]--;
+ }
+ // set the pixel colour
+ uint8_t led[LED_HITS_TO_REMEMBER];
+ uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);
- // TODO: multiple leds are supported mapped to the same row/column
- if (led_count > 0) {
- if (rgb_frame_buffer[row][col] > pure_green_intensity) {
- const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost * (rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity));
- rgb_matrix_set_color(led[0], boost, max_intensity, boost);
- }
- else {
- const uint8_t green = (uint8_t) ((uint16_t) max_intensity * rgb_frame_buffer[row][col] / pure_green_intensity);
- rgb_matrix_set_color(led[0], 0, green, 0);
+ // TODO: multiple leds are supported mapped to the same row/column
+ if (led_count > 0) {
+ if (rgb_frame_buffer[row][col] > pure_green_intensity) {
+ const uint8_t boost = (uint8_t)((uint16_t)max_brightness_boost * (rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity));
+ rgb_matrix_set_color(led[0], boost, max_intensity, boost);
+ } else {
+ const uint8_t green = (uint8_t)((uint16_t)max_intensity * rgb_frame_buffer[row][col] / pure_green_intensity);
+ rgb_matrix_set_color(led[0], 0, green, 0);
+ }
+ }
}
- }
}
- }
- if (++drop > drop_ticks) {
- // reset drop timer
- drop = 0;
- for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) {
- for (uint8_t col = 0; col < MATRIX_COLS; col++) {
- // if ths is on the bottom row and bright allow decay
- if (row == MATRIX_ROWS - 1 && rgb_frame_buffer[row][col] == max_intensity) {
- rgb_frame_buffer[row][col]--;
- }
- // check if the pixel above is bright
- if (rgb_frame_buffer[row - 1][col] == max_intensity) {
- // allow old bright pixel to decay
- rgb_frame_buffer[row - 1][col]--;
- // make this pixel bright
- rgb_frame_buffer[row][col] = max_intensity;
+ if (++drop > drop_ticks) {
+ // reset drop timer
+ drop = 0;
+ for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) {
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ // if ths is on the bottom row and bright allow decay
+ if (row == MATRIX_ROWS - 1 && rgb_frame_buffer[row][col] == max_intensity) {
+ rgb_frame_buffer[row][col]--;
+ }
+ // check if the pixel above is bright
+ if (rgb_frame_buffer[row - 1][col] == max_intensity) {
+ // allow old bright pixel to decay
+ rgb_frame_buffer[row - 1][col]--;
+ // make this pixel bright
+ rgb_frame_buffer[row][col] = max_intensity;
+ }
+ }
}
- }
}
- }
- return false;
+ return false;
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN)
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_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 336a41b2ce..ce94871681 100644
--- a/quantum/rgb_matrix_animations/dual_beacon_anim.h
+++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
RGB_MATRIX_EFFECT(DUAL_BEACON)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
+static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin) / 128;
return hsv;
}
-bool DUAL_BEACON(effect_params_t* params) {
- return effect_runner_sin_cos_i(params, &DUAL_BEACON_math);
-}
+bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_DUAL_BEACON
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_MATRIX_DUAL_BEACON
diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h
index 12848ab4cc..0f1f8e23cf 100644
--- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h
+++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h
@@ -1,22 +1,22 @@
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
RGB_MATRIX_EFFECT(GRADIENT_UP_DOWN)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
bool GRADIENT_UP_DOWN(effect_params_t* params) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- HSV hsv = rgb_matrix_config.hsv;
- uint8_t scale = scale8(64, rgb_matrix_config.speed);
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- // The y range will be 0..64, map this to 0..4
- // Relies on hue being 8-bit and wrapping
- hsv.h = rgb_matrix_config.hsv.h + scale * (g_led_config.point[i].y >> 4);
- RGB rgb = hsv_to_rgb(hsv);
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ HSV hsv = rgb_matrix_config.hsv;
+ uint8_t scale = scale8(64, rgb_matrix_config.speed);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ // The y range will be 0..64, map this to 0..4
+ // Relies on hue being 8-bit and wrapping
+ hsv.h = rgb_matrix_config.hsv.h + scale * (g_led_config.point[i].y >> 4);
+ RGB rgb = hsv_to_rgb(hsv);
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
index bffa0a42d7..5596146a38 100644
--- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
+++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
@@ -1,29 +1,29 @@
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
RGB_MATRIX_EFFECT(JELLYBEAN_RAINDROPS)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static void jellybean_raindrops_set_color(int i, effect_params_t* params) {
- if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
- HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.hsv.v };
- RGB rgb = hsv_to_rgb(hsv);
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
+ HSV hsv = {rand() & 0xFF, rand() & 0xFF, rgb_matrix_config.hsv.v};
+ RGB rgb = hsv_to_rgb(hsv);
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
bool JELLYBEAN_RAINDROPS(effect_params_t* params) {
- if (!params->init) {
- // Change one LED every tick, make sure speed is not 0
- if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
- jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, params);
+ if (!params->init) {
+ // Change one LED every tick, make sure speed is not 0
+ if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
+ jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, params);
+ }
+ return false;
}
- return false;
- }
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
- for (int i = led_min; i < led_max; i++) {
- jellybean_raindrops_set_color(i, params);
- }
- return led_max < DRIVER_LED_TOTAL;
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ for (int i = led_min; i < led_max; i++) {
+ jellybean_raindrops_set_color(i, params);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
index f53c819a9e..977261182f 100644
--- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
RGB_MATRIX_EFFECT(RAINBOW_BEACON)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
+static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128;
return hsv;
}
-bool RAINBOW_BEACON(effect_params_t* params) {
- return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math);
-}
+bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 e78c55e8dd..e51e7b2516 100644
--- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) {
+static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) {
hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time);
return hsv;
}
-bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) {
- return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math);
-}
+bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_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 8298fec468..1cd4ed2acf 100644
--- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
@@ -1,15 +1,13 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
-RGB_MATRIX_EFFECT(PINWHEELS)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+RGB_MATRIX_EFFECT(RAINBOW_PINWHEELS)
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
+static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128;
return hsv;
}
-bool PINWHEELS(effect_params_t* params) {
- return effect_runner_sin_cos_i(params, &PINWHEELS_math);
-}
+bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h
index a4fed51658..9f839a1bce 100644
--- a/quantum/rgb_matrix_animations/raindrops_anim.h
+++ b/quantum/rgb_matrix_animations/raindrops_anim.h
@@ -1,39 +1,39 @@
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
RGB_MATRIX_EFFECT(RAINDROPS)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static void raindrops_set_color(int i, effect_params_t* params) {
- if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
- HSV hsv = { 0 , rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v };
+ if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
+ HSV hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v};
- // Take the shortest path between hues
- int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4;
- if (deltaH > 127) {
- deltaH -= 256;
- } else if (deltaH < -127) {
- deltaH += 256;
- }
+ // Take the shortest path between hues
+ int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4;
+ if (deltaH > 127) {
+ deltaH -= 256;
+ } else if (deltaH < -127) {
+ deltaH += 256;
+ }
- hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03));
- RGB rgb = hsv_to_rgb(hsv);
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03));
+ RGB rgb = hsv_to_rgb(hsv);
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
bool RAINDROPS(effect_params_t* params) {
- if (!params->init) {
- // Change one LED every tick, make sure speed is not 0
- if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
- raindrops_set_color(rand() % DRIVER_LED_TOTAL, params);
+ if (!params->init) {
+ // Change one LED every tick, make sure speed is not 0
+ if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
+ raindrops_set_color(rand() % DRIVER_LED_TOTAL, params);
+ }
+ return false;
}
- return false;
- }
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
- for (int i = led_min; i < led_max; i++) {
- raindrops_set_color(i, params);
- }
- return led_max < DRIVER_LED_TOTAL;
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ for (int i = led_min; i < led_max; i++) {
+ raindrops_set_color(i, params);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_RAINDROPS
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_MATRIX_RAINDROPS
diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h
index 6e40638035..c8f5e70e7a 100644
--- a/quantum/rgb_matrix_animations/solid_color_anim.h
+++ b/quantum/rgb_matrix_animations/solid_color_anim.h
@@ -2,14 +2,14 @@ RGB_MATRIX_EFFECT(SOLID_COLOR)
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
bool SOLID_COLOR(effect_params_t* params) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- RGB rgb = hsv_to_rgb(rgb_matrix_config.hsv);
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ RGB rgb = hsv_to_rgb(rgb_matrix_config.hsv);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#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 dd49b6530e..d45bb961bc 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_anim.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h
@@ -1,17 +1,15 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
RGB_MATRIX_EFFECT(SOLID_REACTIVE)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) {
+static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) {
hsv.h += qsub8(130, offset);
return hsv;
}
-bool SOLID_REACTIVE(effect_params_t* params) {
- return effect_runner_reactive(params, &SOLID_REACTIVE_math);
-}
+bool SOLID_REACTIVE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE
+#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 5b9cfcbd52..f76c68e8c7 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_cross.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h
@@ -1,41 +1,36 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
-#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
+# if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
RGB_MATRIX_EFFECT(SOLID_REACTIVE_CROSS)
-#endif
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS)
-#endif
+# endif
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
uint16_t effect = tick + dist;
- dx = dx < 0 ? dx * -1 : dx;
- dy = dy < 0 ? dy * -1 : dy;
- dx = dx * 16 > 255 ? 255 : dx * 16;
- dy = dy * 16 > 255 ? 255 : dy * 16;
+ dx = dx < 0 ? dx * -1 : dx;
+ dy = dy < 0 ? dy * -1 : dy;
+ dx = dx * 16 > 255 ? 255 : dx * 16;
+ dy = dy * 16 > 255 ? 255 : dy * 16;
effect += dx > dy ? dy : dx;
- if (effect > 255)
- effect = 255;
+ if (effect > 255) effect = 255;
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;
}
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
-bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
- return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
+bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); }
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
-bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
- return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
+bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); }
+# endif
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
+#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 e90eaf4b28..17f94e3c18 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h
@@ -1,41 +1,34 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
-#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
+# if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
RGB_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS)
-#endif
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS)
-#endif
+# endif
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
uint16_t effect = tick - dist;
- if (effect > 255)
- effect = 255;
- if (dist > 72)
- effect = 255;
- if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8))
- effect = 255;
+ if (effect > 255) effect = 255;
+ if (dist > 72) effect = 255;
+ if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255;
hsv.v = qadd8(hsv.v, 255 - effect);
hsv.h = rgb_matrix_config.hsv.h + dy / 4;
return hsv;
}
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
-bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
- return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
+bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); }
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
-bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
- return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
+bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); }
+# endif
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
+#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 77c8ff6724..12eb248cc0 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
@@ -1,17 +1,15 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) {
+static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) {
hsv.v = scale8(255 - offset, hsv.v);
return hsv;
}
-bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) {
- return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math);
-}
+bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); }
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
+#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 73779dfa74..1cc4dca728 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_wide.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h
@@ -1,36 +1,31 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
-#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
+# if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
RGB_MATRIX_EFFECT(SOLID_REACTIVE_WIDE)
-#endif
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
-#endif
+# endif
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
uint16_t effect = tick + dist * 5;
- if (effect > 255)
- effect = 255;
+ if (effect > 255) effect = 255;
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;
}
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
-bool SOLID_REACTIVE_WIDE(effect_params_t* params) {
- return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
+bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); }
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
-bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) {
- return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
+bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); }
+# endif
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
+#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 441f35576b..99efb4996a 100644
--- a/quantum/rgb_matrix_animations/solid_splash_anim.h
+++ b/quantum/rgb_matrix_animations/solid_splash_anim.h
@@ -1,36 +1,31 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
-#if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH)
+# if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH)
-#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
+# ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
RGB_MATRIX_EFFECT(SOLID_SPLASH)
-#endif
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
+# ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
RGB_MATRIX_EFFECT(SOLID_MULTISPLASH)
-#endif
+# endif
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
uint16_t effect = tick - dist;
- if (effect > 255)
- effect = 255;
+ if (effect > 255) effect = 255;
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;
}
-#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
-bool SOLID_SPLASH(effect_params_t* params) {
- return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
+bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); }
+# endif
-#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
-bool SOLID_MULTISPLASH(effect_params_t* params) {
- return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
+bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); }
+# endif
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h
index 19ccb256e9..1415bcc0fa 100644
--- a/quantum/rgb_matrix_animations/splash_anim.h
+++ b/quantum/rgb_matrix_animations/splash_anim.h
@@ -1,37 +1,32 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
-#if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
+# if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
-#ifndef DISABLE_RGB_MATRIX_SPLASH
+# ifndef DISABLE_RGB_MATRIX_SPLASH
RGB_MATRIX_EFFECT(SPLASH)
-#endif
+# endif
-#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
+# ifndef DISABLE_RGB_MATRIX_MULTISPLASH
RGB_MATRIX_EFFECT(MULTISPLASH)
-#endif
+# endif
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
uint16_t effect = tick - dist;
- if (effect > 255)
- effect = 255;
+ if (effect > 255) effect = 255;
hsv.h += effect;
hsv.v = qadd8(hsv.v, 255 - effect);
return hsv;
}
-#ifndef DISABLE_RGB_MATRIX_SPLASH
-bool SPLASH(effect_params_t* params) {
- return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_SPLASH
+bool SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); }
+# endif
-#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
-bool MULTISPLASH(effect_params_t* params) {
- return effect_runner_reactive_splash(0, params, &SPLASH_math);
-}
-#endif
+# ifndef DISABLE_RGB_MATRIX_MULTISPLASH
+bool MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SPLASH_math); }
+# endif
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
+#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 374b7fea0c..dd313f16a5 100644
--- a/quantum/rgb_matrix_animations/typing_heatmap_anim.h
+++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h
@@ -1,74 +1,65 @@
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
RGB_MATRIX_EFFECT(TYPING_HEATMAP)
-#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-void process_rgb_matrix_typing_heatmap(keyrecord_t *record) {
- uint8_t row = record->event.key.row;
- uint8_t col = record->event.key.col;
+void process_rgb_matrix_typing_heatmap(keyrecord_t* record) {
+ uint8_t row = record->event.key.row;
+ uint8_t col = record->event.key.col;
uint8_t m_row = row - 1;
uint8_t p_row = row + 1;
uint8_t m_col = col - 1;
uint8_t p_col = col + 1;
- if (m_col < col)
- rgb_frame_buffer[row][m_col] = qadd8(rgb_frame_buffer[row][m_col], 16);
+ if (m_col < col) rgb_frame_buffer[row][m_col] = qadd8(rgb_frame_buffer[row][m_col], 16);
rgb_frame_buffer[row][col] = qadd8(rgb_frame_buffer[row][col], 32);
- if (p_col < MATRIX_COLS)
- rgb_frame_buffer[row][p_col] = qadd8(rgb_frame_buffer[row][p_col], 16);
+ if (p_col < MATRIX_COLS) rgb_frame_buffer[row][p_col] = qadd8(rgb_frame_buffer[row][p_col], 16);
if (p_row < MATRIX_ROWS) {
- if (m_col < col)
- rgb_frame_buffer[p_row][m_col] = qadd8(rgb_frame_buffer[p_row][m_col], 13);
- rgb_frame_buffer[p_row][col] = qadd8(rgb_frame_buffer[p_row][col], 16);
- if (p_col < MATRIX_COLS)
- rgb_frame_buffer[p_row][p_col] = qadd8(rgb_frame_buffer[p_row][p_col], 13);
+ if (m_col < col) rgb_frame_buffer[p_row][m_col] = qadd8(rgb_frame_buffer[p_row][m_col], 13);
+ rgb_frame_buffer[p_row][col] = qadd8(rgb_frame_buffer[p_row][col], 16);
+ if (p_col < MATRIX_COLS) rgb_frame_buffer[p_row][p_col] = qadd8(rgb_frame_buffer[p_row][p_col], 13);
}
if (m_row < row) {
- if (m_col < col)
- rgb_frame_buffer[m_row][m_col] = qadd8(rgb_frame_buffer[m_row][m_col], 13);
- rgb_frame_buffer[m_row][col] = qadd8(rgb_frame_buffer[m_row][col], 16);
- if (p_col < MATRIX_COLS)
- rgb_frame_buffer[m_row][p_col] = qadd8(rgb_frame_buffer[m_row][p_col], 13);
+ if (m_col < col) rgb_frame_buffer[m_row][m_col] = qadd8(rgb_frame_buffer[m_row][m_col], 13);
+ rgb_frame_buffer[m_row][col] = qadd8(rgb_frame_buffer[m_row][col], 16);
+ if (p_col < MATRIX_COLS) rgb_frame_buffer[m_row][p_col] = qadd8(rgb_frame_buffer[m_row][p_col], 13);
}
}
bool TYPING_HEATMAP(effect_params_t* params) {
- // Modified version of RGB_MATRIX_USE_LIMITS to work off of matrix row / col size
- uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter;
- uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT;
- if (led_max > sizeof(rgb_frame_buffer))
- led_max = sizeof(rgb_frame_buffer);
+ // Modified version of RGB_MATRIX_USE_LIMITS to work off of matrix row / col size
+ uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter;
+ uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT;
+ if (led_max > sizeof(rgb_frame_buffer)) led_max = sizeof(rgb_frame_buffer);
- if (params->init) {
- rgb_matrix_set_color_all(0, 0, 0);
- memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer);
- }
+ if (params->init) {
+ rgb_matrix_set_color_all(0, 0, 0);
+ memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer);
+ }
- // Render heatmap & decrease
- for (int i = led_min; i < led_max; i++) {
- uint8_t row = i % MATRIX_ROWS;
- uint8_t col = i / MATRIX_ROWS;
- uint8_t val = rgb_frame_buffer[row][col];
+ // Render heatmap & decrease
+ for (int i = led_min; i < led_max; i++) {
+ uint8_t row = i % MATRIX_ROWS;
+ uint8_t col = i / MATRIX_ROWS;
+ uint8_t val = rgb_frame_buffer[row][col];
- // set the pixel colour
- uint8_t led[LED_HITS_TO_REMEMBER];
- uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);
- for (uint8_t j = 0; j < led_count; ++j)
- {
- if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags))
- continue;
+ // set the pixel colour
+ uint8_t led[LED_HITS_TO_REMEMBER];
+ uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);
+ for (uint8_t j = 0; j < led_count; ++j) {
+ if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags)) continue;
- HSV hsv = { 170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v) };
- RGB rgb = hsv_to_rgb(hsv);
- rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b);
- }
+ HSV hsv = {170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v)};
+ RGB rgb = hsv_to_rgb(hsv);
+ rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b);
+ }
- rgb_frame_buffer[row][col] = qsub8(val, 1);
- }
+ rgb_frame_buffer[row][col] = qsub8(val, 1);
+ }
- return led_max < sizeof(rgb_frame_buffer);
+ return led_max < sizeof(rgb_frame_buffer);
}
-#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c
index 2a3aa9a5e0..9729a3064e 100644
--- a/quantum/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix_drivers.c
@@ -25,58 +25,57 @@
#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3737)
-#include "i2c_master.h"
+# include "i2c_master.h"
-static void init( void )
-{
+static void init(void) {
i2c_init();
-#ifdef IS31FL3731
- IS31FL3731_init( DRIVER_ADDR_1 );
- IS31FL3731_init( DRIVER_ADDR_2 );
-#elif defined(IS31FL3733)
- IS31FL3733_init( DRIVER_ADDR_1, 0 );
-#else
- IS31FL3737_init( DRIVER_ADDR_1 );
-#endif
- for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) {
+# ifdef IS31FL3731
+ IS31FL3731_init(DRIVER_ADDR_1);
+ IS31FL3731_init(DRIVER_ADDR_2);
+# elif defined(IS31FL3733)
+ IS31FL3733_init(DRIVER_ADDR_1, 0);
+# else
+ IS31FL3737_init(DRIVER_ADDR_1);
+# endif
+ for (int index = 0; index < DRIVER_LED_TOTAL; index++) {
bool enabled = true;
// This only caches it for later
-#ifdef IS31FL3731
- IS31FL3731_set_led_control_register( index, enabled, enabled, enabled );
-#elif defined(IS31FL3733)
- IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
-#else
- IS31FL3737_set_led_control_register( index, enabled, enabled, enabled );
-#endif
+# ifdef IS31FL3731
+ IS31FL3731_set_led_control_register(index, enabled, enabled, enabled);
+# elif defined(IS31FL3733)
+ IS31FL3733_set_led_control_register(index, enabled, enabled, enabled);
+# else
+ IS31FL3737_set_led_control_register(index, enabled, enabled, enabled);
+# endif
}
// This actually updates the LED drivers
-#ifdef IS31FL3731
- IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
-#elif defined(IS31FL3733)
- IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, 0 );
- IS31FL3733_update_led_control_registers( DRIVER_ADDR_2, 1 );
-#else
- IS31FL3737_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
-#endif
+# ifdef IS31FL3731
+ IS31FL3731_update_led_control_registers(DRIVER_ADDR_1, 0);
+ IS31FL3731_update_led_control_registers(DRIVER_ADDR_2, 1);
+# elif defined(IS31FL3733)
+ IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0);
+ IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1);
+# else
+ IS31FL3737_update_led_control_registers(DRIVER_ADDR_1, DRIVER_ADDR_2);
+# endif
}
-#ifdef IS31FL3731
-static void flush( void )
-{
- IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
+# ifdef IS31FL3731
+static void flush(void) {
+ IS31FL3731_update_pwm_buffers(DRIVER_ADDR_1, 0);
+ IS31FL3731_update_pwm_buffers(DRIVER_ADDR_2, 1);
}
const rgb_matrix_driver_t rgb_matrix_driver = {
- .init = init,
- .flush = flush,
- .set_color = IS31FL3731_set_color,
+ .init = init,
+ .flush = flush,
+ .set_color = IS31FL3731_set_color,
.set_color_all = IS31FL3731_set_color_all,
};
-#elif defined(IS31FL3733)
-static void flush( void )
-{
- IS31FL3733_update_pwm_buffers( DRIVER_ADDR_1, 0);
- IS31FL3733_update_pwm_buffers( DRIVER_ADDR_2, 1);
+# elif defined(IS31FL3733)
+static void flush(void) {
+ IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1, 0);
+ IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2, 1);
}
const rgb_matrix_driver_t rgb_matrix_driver = {
@@ -85,11 +84,8 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
.set_color = IS31FL3733_set_color,
.set_color_all = IS31FL3733_set_color_all,
};
-#else
-static void flush( void )
-{
- IS31FL3737_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
-}
+# else
+static void flush(void) { IS31FL3737_update_pwm_buffers(DRIVER_ADDR_1, DRIVER_ADDR_2); }
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
@@ -97,27 +93,40 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
.set_color = IS31FL3737_set_color,
.set_color_all = IS31FL3737_set_color_all,
};
-#endif
+# endif
#elif defined(WS2812)
-extern LED_TYPE led[DRIVER_LED_TOTAL];
+// LED color buffer
+LED_TYPE led[DRIVER_LED_TOTAL];
- static void flush( void )
- {
+static void init(void) {}
+
+static void flush(void) {
// Assumes use of RGB_DI_PIN
ws2812_setleds(led, DRIVER_LED_TOTAL);
- }
+}
- static void init( void )
- {
+// Set an led in the buffer to a color
+static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
+ led[i].r = r;
+ led[i].g = g;
+ led[i].b = b;
+# ifdef RGBW
+ led[i].w = 0;
+# endif
+}
- }
+static void setled_all(uint8_t r, uint8_t g, uint8_t b) {
+ for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) {
+ setled(i, r, g, b);
+ }
+}
- const rgb_matrix_driver_t rgb_matrix_driver = {
- .init = init,
- .flush = flush,
- .set_color = ws2812_setled,
- .set_color_all = ws2812_setled_all,
- };
+const rgb_matrix_driver_t rgb_matrix_driver = {
+ .init = init,
+ .flush = flush,
+ .set_color = setled,
+ .set_color_all = setled_all,
+};
#endif
diff --git a/quantum/rgb_matrix_runners/effect_runner_dx_dy.h b/quantum/rgb_matrix_runners/effect_runner_dx_dy.h
index 9650c9a131..3d312190a5 100644
--- a/quantum/rgb_matrix_runners/effect_runner_dx_dy.h
+++ b/quantum/rgb_matrix_runners/effect_runner_dx_dy.h
@@ -3,15 +3,15 @@
typedef HSV (*dx_dy_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t time);
bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2);
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x;
- int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
- RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time));
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x;
+ int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
+ RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
diff --git a/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h b/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h
index eb0c4d8dd3..1f4767e321 100644
--- a/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h
+++ b/quantum/rgb_matrix_runners/effect_runner_dx_dy_dist.h
@@ -3,16 +3,16 @@
typedef HSV (*dx_dy_dist_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time);
bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2);
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x;
- int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
- uint8_t dist = sqrt16(dx * dx + dy * dy);
- RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, dist, time));
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 2);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x;
+ int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y;
+ uint8_t dist = sqrt16(dx * dx + dy * dy);
+ RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, dist, time));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
diff --git a/quantum/rgb_matrix_runners/effect_runner_i.h b/quantum/rgb_matrix_runners/effect_runner_i.h
index d4a7ef392a..eebfb78c02 100644
--- a/quantum/rgb_matrix_runners/effect_runner_i.h
+++ b/quantum/rgb_matrix_runners/effect_runner_i.h
@@ -3,13 +3,13 @@
typedef HSV (*i_f)(HSV hsv, uint8_t i, uint8_t time);
bool effect_runner_i(effect_params_t* params, i_f effect_func) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
diff --git a/quantum/rgb_matrix_runners/effect_runner_reactive.h b/quantum/rgb_matrix_runners/effect_runner_reactive.h
index 9da2814ce8..53e77e3fb2 100644
--- a/quantum/rgb_matrix_runners/effect_runner_reactive.h
+++ b/quantum/rgb_matrix_runners/effect_runner_reactive.h
@@ -7,23 +7,23 @@ typedef HSV (*reactive_f)(HSV hsv, uint16_t offset);
bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
- uint16_t max_tick = 65535 / rgb_matrix_config.speed;
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- uint16_t tick = max_tick;
- // Reverse search to find most recent key hit
- for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
- if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
- tick = g_last_hit_tracker.tick[j];
- break;
- }
- }
+ uint16_t max_tick = 65535 / rgb_matrix_config.speed;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ uint16_t tick = max_tick;
+ // Reverse search to find most recent key hit
+ for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
+ if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
+ tick = g_last_hit_tracker.tick[j];
+ break;
+ }
+ }
- uint16_t offset = scale16by8(tick, rgb_matrix_config.speed);
- RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, offset));
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ uint16_t offset = scale16by8(tick, rgb_matrix_config.speed);
+ RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, offset));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix_runners/effect_runner_reactive_splash.h
index 4f2059c99c..b5d284a40f 100644
--- a/quantum/rgb_matrix_runners/effect_runner_reactive_splash.h
+++ b/quantum/rgb_matrix_runners/effect_runner_reactive_splash.h
@@ -5,25 +5,25 @@
typedef HSV (*reactive_splash_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick);
bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, reactive_splash_f effect_func) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- uint8_t count = g_last_hit_tracker.count;
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- HSV hsv = rgb_matrix_config.hsv;
- hsv.v = 0;
- for (uint8_t j = start; j < count; j++) {
- int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
- int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
- uint8_t dist = sqrt16(dx * dx + dy * dy);
- uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed);
- hsv = effect_func(hsv, dx, dy, dist, tick);
+ uint8_t count = g_last_hit_tracker.count;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ HSV hsv = rgb_matrix_config.hsv;
+ hsv.v = 0;
+ for (uint8_t j = start; j < count; j++) {
+ int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
+ int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
+ uint8_t dist = sqrt16(dx * dx + dy * dy);
+ uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed);
+ hsv = effect_func(hsv, dx, dy, dist, tick);
+ }
+ hsv.v = scale8(hsv.v, rgb_matrix_config.hsv.v);
+ RGB rgb = hsv_to_rgb(hsv);
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
- hsv.v = scale8(hsv.v, rgb_matrix_config.hsv.v);
- RGB rgb = hsv_to_rgb(hsv);
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ return led_max < DRIVER_LED_TOTAL;
}
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h b/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h
index e68a7a968c..c02352b86d 100644
--- a/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h
+++ b/quantum/rgb_matrix_runners/effect_runner_sin_cos_i.h
@@ -3,15 +3,15 @@
typedef HSV (*sin_cos_i_f)(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time);
bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) {
- RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
- uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
- int8_t cos_value = cos8(time) - 128;
- int8_t sin_value = sin8(time) - 128;
- for (uint8_t i = led_min; i < led_max; i++) {
- RGB_MATRIX_TEST_LED_FLAGS();
- RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time));
- rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
- }
- return led_max < DRIVER_LED_TOTAL;
+ uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
+ int8_t cos_value = cos8(time) - 128;
+ int8_t sin_value = sin8(time) - 128;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ RGB rgb = hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ return led_max < DRIVER_LED_TOTAL;
}
diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h
index 04a84f4ac7..fc23f55d0e 100644
--- a/quantum/rgb_matrix_types.h
+++ b/quantum/rgb_matrix_types.h
@@ -5,59 +5,54 @@
#include "color.h"
#if defined(__GNUC__)
-#define PACKED __attribute__ ((__packed__))
+# define PACKED __attribute__((__packed__))
#else
-#define PACKED
+# define PACKED
#endif
#if defined(_MSC_VER)
-#pragma pack( push, 1 )
+# pragma pack(push, 1)
#endif
#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
- #define RGB_MATRIX_KEYREACTIVE_ENABLED
+# define RGB_MATRIX_KEYREACTIVE_ENABLED
#endif
// Last led hit
#ifndef LED_HITS_TO_REMEMBER
- #define LED_HITS_TO_REMEMBER 8
-#endif // LED_HITS_TO_REMEMBER
+# define LED_HITS_TO_REMEMBER 8
+#endif // LED_HITS_TO_REMEMBER
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
typedef struct PACKED {
- uint8_t count;
- uint8_t x[LED_HITS_TO_REMEMBER];
- uint8_t y[LED_HITS_TO_REMEMBER];
- uint8_t index[LED_HITS_TO_REMEMBER];
- uint16_t tick[LED_HITS_TO_REMEMBER];
+ uint8_t count;
+ uint8_t x[LED_HITS_TO_REMEMBER];
+ uint8_t y[LED_HITS_TO_REMEMBER];
+ uint8_t index[LED_HITS_TO_REMEMBER];
+ uint16_t tick[LED_HITS_TO_REMEMBER];
} last_hit_t;
-#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
-typedef enum rgb_task_states {
- STARTING,
- RENDERING,
- FLUSHING,
- SYNCING
-} rgb_task_states;
+typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states;
typedef uint8_t led_flags_t;
typedef struct PACKED {
- uint8_t iter;
- led_flags_t flags;
- bool init;
+ uint8_t iter;
+ led_flags_t flags;
+ bool init;
} effect_params_t;
typedef struct PACKED {
- // Global tick at 20 Hz
- uint32_t tick;
- // Ticks since this key was last hit.
- uint32_t any_key_hit;
+ // Global tick at 20 Hz
+ uint32_t tick;
+ // Ticks since this key was last hit.
+ uint32_t any_key_hit;
} rgb_counters_t;
typedef struct PACKED {
- uint8_t x;
- uint8_t y;
+ uint8_t x;
+ uint8_t y;
} point_t;
#define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
@@ -72,21 +67,21 @@ typedef struct PACKED {
#define NO_LED 255
typedef struct PACKED {
- uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
- point_t point[DRIVER_LED_TOTAL];
- uint8_t flags[DRIVER_LED_TOTAL];
+ uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
+ point_t point[DRIVER_LED_TOTAL];
+ uint8_t flags[DRIVER_LED_TOTAL];
} led_config_t;
typedef union {
- uint32_t raw;
- struct PACKED {
- uint8_t enable :2;
- uint8_t mode :6;
- HSV hsv;
- uint8_t speed; //EECONFIG needs to be increased to support this
- };
+ uint32_t raw;
+ struct PACKED {
+ uint8_t enable : 2;
+ uint8_t mode : 6;
+ HSV hsv;
+ uint8_t speed; // EECONFIG needs to be increased to support this
+ };
} rgb_config_t;
#if defined(_MSC_VER)
-#pragma pack( pop )
+# pragma pack(pop)
#endif
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 75e4ef0d86..7949bb688e 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -16,13 +16,13 @@
#include <math.h>
#include <string.h>
#ifdef __AVR__
- #include <avr/eeprom.h>
- #include <avr/interrupt.h>
+# include <avr/eeprom.h>
+# include <avr/interrupt.h>
#endif
#ifdef STM32_EEPROM_ENABLE
- #include "hal.h"
- #include "eeprom.h"
- #include "eeprom_stm32.h"
+# include "hal.h"
+# include "eeprom.h"
+# include "eeprom_stm32.h"
#endif
#include "wait.h"
#include "progmem.h"
@@ -33,61 +33,58 @@
#include "led_tables.h"
#include "lib/lib8tion/lib8tion.h"
#ifdef VELOCIKEY_ENABLE
- #include "velocikey.h"
+# include "velocikey.h"
#endif
#ifdef RGBLIGHT_SPLIT
- /* for split keyboard */
- #define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE
- #define RGBLIGHT_SPLIT_SET_CHANGE_HSVS rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_HSVS
- #define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS rgblight_status.change_flags |= (RGBLIGHT_STATUS_CHANGE_MODE|RGBLIGHT_STATUS_CHANGE_HSVS)
- #define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_TIMER
- #define RGBLIGHT_SPLIT_ANIMATION_TICK rgblight_status.change_flags |= RGBLIGHT_STATUS_ANIMATION_TICK
+/* for split keyboard */
+# define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE
+# define RGBLIGHT_SPLIT_SET_CHANGE_HSVS rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_HSVS
+# define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS rgblight_status.change_flags |= (RGBLIGHT_STATUS_CHANGE_MODE | RGBLIGHT_STATUS_CHANGE_HSVS)
+# define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_TIMER
+# define RGBLIGHT_SPLIT_ANIMATION_TICK rgblight_status.change_flags |= RGBLIGHT_STATUS_ANIMATION_TICK
#else
- #define RGBLIGHT_SPLIT_SET_CHANGE_MODE
- #define RGBLIGHT_SPLIT_SET_CHANGE_HSVS
- #define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS
- #define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE
- #define RGBLIGHT_SPLIT_ANIMATION_TICK
+# define RGBLIGHT_SPLIT_SET_CHANGE_MODE
+# define RGBLIGHT_SPLIT_SET_CHANGE_HSVS
+# define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS
+# define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE
+# define RGBLIGHT_SPLIT_ANIMATION_TICK
#endif
-#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym,
+#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym,
#define _RGBM_SINGLE_DYNAMIC(sym)
-#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_ ## sym,
+#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym,
#define _RGBM_MULTI_DYNAMIC(sym)
-#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_ ## sym,
+#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##sym,
#define _RGBM_TMP_DYNAMIC(sym, msym)
-static uint8_t static_effect_table [] = {
+static uint8_t static_effect_table[] = {
#include "rgblight_modes.h"
};
-#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_ ## msym,
-#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_ ## msym,
-static uint8_t mode_base_table [] = {
- 0, // RGBLIGHT_MODE_zero
+#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##msym,
+#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##msym,
+static uint8_t mode_base_table[] = {
+ 0, // RGBLIGHT_MODE_zero
#include "rgblight_modes.h"
};
-static inline int is_static_effect(uint8_t mode) {
- return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL;
-}
+static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; }
#ifdef RGBLIGHT_LED_MAP
const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP;
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
-__attribute__ ((weak))
-const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64};
+__attribute__((weak)) const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64};
#endif
rgblight_config_t rgblight_config;
-rgblight_status_t rgblight_status = { .timer_enabled = false };
-bool is_rgblight_initialized = false;
+rgblight_status_t rgblight_status = {.timer_enabled = false};
+bool is_rgblight_initialized = false;
#ifdef RGBLIGHT_USE_TIMER
animation_status_t animation_status = {};
@@ -95,598 +92,543 @@ animation_status_t animation_status = {};
#ifndef LED_ARRAY
LED_TYPE led[RGBLED_NUM];
- #define LED_ARRAY led
+# define LED_ARRAY led
#endif
-
static uint8_t clipping_start_pos = 0;
-static uint8_t clipping_num_leds = RGBLED_NUM;
-static uint8_t effect_start_pos = 0;
-static uint8_t effect_end_pos = RGBLED_NUM;
-static uint8_t effect_num_leds = RGBLED_NUM;
+static uint8_t clipping_num_leds = RGBLED_NUM;
+static uint8_t effect_start_pos = 0;
+static uint8_t effect_end_pos = RGBLED_NUM;
+static uint8_t effect_num_leds = RGBLED_NUM;
void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) {
- clipping_start_pos = start_pos;
- clipping_num_leds = num_leds;
+ clipping_start_pos = start_pos;
+ clipping_num_leds = num_leds;
}
void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds) {
- if (start_pos >= RGBLED_NUM) return;
- if (start_pos + num_leds > RGBLED_NUM) return;
- effect_start_pos = start_pos;
- effect_end_pos = start_pos + num_leds;
- effect_num_leds = num_leds;
+ if (start_pos >= RGBLED_NUM) return;
+ if (start_pos + num_leds > RGBLED_NUM) return;
+ effect_start_pos = start_pos;
+ effect_end_pos = start_pos + num_leds;
+ effect_num_leds = num_leds;
}
void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
- HSV hsv = { hue, sat, val };
- RGB rgb = hsv_to_rgb(hsv);
- setrgb(rgb.r, rgb.g, rgb.b, led1);
+ HSV hsv = {hue, sat, val};
+ RGB rgb = hsv_to_rgb(hsv);
+ setrgb(rgb.r, rgb.g, rgb.b, led1);
}
-void 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);
-}
+void 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); }
void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
- (*led1).r = r;
- (*led1).g = g;
- (*led1).b = b;
+ (*led1).r = r;
+ (*led1).g = g;
+ (*led1).b = b;
+#ifdef RGBW
+ (*led1).w = 0;
+#endif
}
void rgblight_check_config(void) {
- /* Add some out of bound checks for RGB light config */
-
- if (rgblight_config.mode < RGBLIGHT_MODE_STATIC_LIGHT) {
- rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
- }
- else if (rgblight_config.mode > RGBLIGHT_MODES) {
- rgblight_config.mode = RGBLIGHT_MODES;
- }
-
- if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) {
- rgblight_config.val = RGBLIGHT_LIMIT_VAL;
- }
+ /* Add some out of bound checks for RGB light config */
+
+ if (rgblight_config.mode < RGBLIGHT_MODE_STATIC_LIGHT) {
+ rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
+ } else if (rgblight_config.mode > RGBLIGHT_MODES) {
+ rgblight_config.mode = RGBLIGHT_MODES;
+ }
+
+ if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) {
+ rgblight_config.val = RGBLIGHT_LIMIT_VAL;
+ }
}
uint32_t eeconfig_read_rgblight(void) {
- #if defined(__AVR__) || defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
+#if defined(__AVR__) || defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
return eeprom_read_dword(EECONFIG_RGBLIGHT);
- #else
+#else
return 0;
- #endif
+#endif
}
void eeconfig_update_rgblight(uint32_t val) {
- #if defined(__AVR__) || defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
+#if defined(__AVR__) || defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
rgblight_check_config();
eeprom_update_dword(EECONFIG_RGBLIGHT, val);
- #endif
+#endif
}
void eeconfig_update_rgblight_default(void) {
- //dprintf("eeconfig_update_rgblight_default\n");
- rgblight_config.enable = 1;
- rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
- rgblight_config.hue = 0;
- rgblight_config.sat = UINT8_MAX;
- rgblight_config.val = RGBLIGHT_LIMIT_VAL;
- rgblight_config.speed = 0;
- RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
- eeconfig_update_rgblight(rgblight_config.raw);
+ rgblight_config.enable = 1;
+ rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
+ rgblight_config.hue = 0;
+ rgblight_config.sat = UINT8_MAX;
+ rgblight_config.val = RGBLIGHT_LIMIT_VAL;
+ rgblight_config.speed = 0;
+ RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
+ eeconfig_update_rgblight(rgblight_config.raw);
}
void eeconfig_debug_rgblight(void) {
- dprintf("rgblight_config eprom\n");
- dprintf("rgblight_config.enable = %d\n", rgblight_config.enable);
- dprintf("rghlight_config.mode = %d\n", rgblight_config.mode);
- dprintf("rgblight_config.hue = %d\n", rgblight_config.hue);
- dprintf("rgblight_config.sat = %d\n", rgblight_config.sat);
- dprintf("rgblight_config.val = %d\n", rgblight_config.val);
- dprintf("rgblight_config.speed = %d\n", rgblight_config.speed);
+ dprintf("rgblight_config EEPROM:\n");
+ dprintf("rgblight_config.enable = %d\n", rgblight_config.enable);
+ dprintf("rghlight_config.mode = %d\n", rgblight_config.mode);
+ dprintf("rgblight_config.hue = %d\n", rgblight_config.hue);
+ dprintf("rgblight_config.sat = %d\n", rgblight_config.sat);
+ dprintf("rgblight_config.val = %d\n", rgblight_config.val);
+ dprintf("rgblight_config.speed = %d\n", rgblight_config.speed);
}
void rgblight_init(void) {
- /* if already initialized, don't do it again.
- If you must do it again, extern this and set to false, first.
- This is a dirty, dirty hack until proper hooks can be added for keyboard startup. */
- if (is_rgblight_initialized) { return; }
-
- debug_enable = 1; // Debug ON!
- dprintf("rgblight_init called.\n");
- dprintf("rgblight_init start!\n");
- if (!eeconfig_is_enabled()) {
- dprintf("rgblight_init eeconfig is not enabled.\n");
- eeconfig_init();
- eeconfig_update_rgblight_default();
- }
- rgblight_config.raw = eeconfig_read_rgblight();
- RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
- if (!rgblight_config.mode) {
- dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
- eeconfig_update_rgblight_default();
+ /* if already initialized, don't do it again.
+ If you must do it again, extern this and set to false, first.
+ This is a dirty, dirty hack until proper hooks can be added for keyboard startup. */
+ if (is_rgblight_initialized) {
+ return;
+ }
+
+ dprintf("rgblight_init called.\n");
+ dprintf("rgblight_init start!\n");
+ if (!eeconfig_is_enabled()) {
+ dprintf("rgblight_init eeconfig is not enabled.\n");
+ eeconfig_init();
+ eeconfig_update_rgblight_default();
+ }
rgblight_config.raw = eeconfig_read_rgblight();
- }
- rgblight_check_config();
+ RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
+ if (!rgblight_config.mode) {
+ dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
+ eeconfig_update_rgblight_default();
+ rgblight_config.raw = eeconfig_read_rgblight();
+ }
+ rgblight_check_config();
- eeconfig_debug_rgblight(); // display current eeprom values
+ eeconfig_debug_rgblight(); // display current eeprom values
#ifdef RGBLIGHT_USE_TIMER
- rgblight_timer_init(); // setup the timer
+ rgblight_timer_init(); // setup the timer
#endif
- if (rgblight_config.enable) {
- rgblight_mode_noeeprom(rgblight_config.mode);
- }
-
- is_rgblight_initialized = true;
+ if (rgblight_config.enable) {
+ rgblight_mode_noeeprom(rgblight_config.mode);
+ }
+ is_rgblight_initialized = true;
}
-uint32_t rgblight_read_dword(void) {
- return rgblight_config.raw;
-}
+uint32_t rgblight_read_dword(void) { return rgblight_config.raw; }
void rgblight_update_dword(uint32_t dword) {
- RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
- rgblight_config.raw = dword;
- if (rgblight_config.enable)
- rgblight_mode_noeeprom(rgblight_config.mode);
- else {
+ RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
+ rgblight_config.raw = dword;
+ if (rgblight_config.enable)
+ rgblight_mode_noeeprom(rgblight_config.mode);
+ else {
#ifdef RGBLIGHT_USE_TIMER
- rgblight_timer_disable();
+ rgblight_timer_disable();
#endif
- rgblight_set();
- }
+ rgblight_set();
+ }
}
void rgblight_increase(void) {
- uint8_t mode = 0;
- if (rgblight_config.mode < RGBLIGHT_MODES) {
- mode = rgblight_config.mode + 1;
- }
- rgblight_mode(mode);
+ uint8_t mode = 0;
+ if (rgblight_config.mode < RGBLIGHT_MODES) {
+ mode = rgblight_config.mode + 1;
+ }
+ rgblight_mode(mode);
}
void rgblight_decrease(void) {
- uint8_t mode = 0;
- // Mode will never be < 1. If it ever is, eeprom needs to be initialized.
- if (rgblight_config.mode > RGBLIGHT_MODE_STATIC_LIGHT) {
- mode = rgblight_config.mode - 1;
- }
- rgblight_mode(mode);
+ uint8_t mode = 0;
+ // Mode will never be < 1. If it ever is, eeprom needs to be initialized.
+ if (rgblight_config.mode > RGBLIGHT_MODE_STATIC_LIGHT) {
+ mode = rgblight_config.mode - 1;
+ }
+ rgblight_mode(mode);
}
void rgblight_step_helper(bool write_to_eeprom) {
- uint8_t mode = 0;
- mode = rgblight_config.mode + 1;
- if (mode > RGBLIGHT_MODES) {
- mode = 1;
- }
- rgblight_mode_eeprom_helper(mode, write_to_eeprom);
-}
-void rgblight_step_noeeprom(void) {
- rgblight_step_helper(false);
-}
-void rgblight_step(void) {
- rgblight_step_helper(true);
+ uint8_t mode = 0;
+ mode = rgblight_config.mode + 1;
+ if (mode > RGBLIGHT_MODES) {
+ mode = 1;
+ }
+ rgblight_mode_eeprom_helper(mode, write_to_eeprom);
}
+void rgblight_step_noeeprom(void) { rgblight_step_helper(false); }
+void rgblight_step(void) { rgblight_step_helper(true); }
void rgblight_step_reverse_helper(bool write_to_eeprom) {
- uint8_t mode = 0;
- mode = rgblight_config.mode - 1;
- if (mode < 1) {
- mode = RGBLIGHT_MODES;
- }
- rgblight_mode_eeprom_helper(mode, write_to_eeprom);
-}
-void rgblight_step_reverse_noeeprom(void) {
- rgblight_step_reverse_helper(false);
-}
-void rgblight_step_reverse(void) {
- rgblight_step_reverse_helper(true);
+ uint8_t mode = 0;
+ mode = rgblight_config.mode - 1;
+ if (mode < 1) {
+ mode = RGBLIGHT_MODES;
+ }
+ rgblight_mode_eeprom_helper(mode, write_to_eeprom);
}
+void rgblight_step_reverse_noeeprom(void) { rgblight_step_reverse_helper(false); }
+void rgblight_step_reverse(void) { rgblight_step_reverse_helper(true); }
uint8_t rgblight_get_mode(void) {
- if (!rgblight_config.enable) {
- return false;
- }
+ if (!rgblight_config.enable) {
+ return false;
+ }
- return rgblight_config.mode;
+ return rgblight_config.mode;
}
void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
- if (!rgblight_config.enable) {
- return;
- }
- if (mode < RGBLIGHT_MODE_STATIC_LIGHT) {
- rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
- } else if (mode > RGBLIGHT_MODES) {
- rgblight_config.mode = RGBLIGHT_MODES;
- } else {
- rgblight_config.mode = mode;
- }
- RGBLIGHT_SPLIT_SET_CHANGE_MODE;
- if (write_to_eeprom) {
- eeconfig_update_rgblight(rgblight_config.raw);
- xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode);
- } else {
- xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode);
- }
- if( is_static_effect(rgblight_config.mode) ) {
+ if (!rgblight_config.enable) {
+ return;
+ }
+ if (mode < RGBLIGHT_MODE_STATIC_LIGHT) {
+ rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
+ } else if (mode > RGBLIGHT_MODES) {
+ rgblight_config.mode = RGBLIGHT_MODES;
+ } else {
+ rgblight_config.mode = mode;
+ }
+ RGBLIGHT_SPLIT_SET_CHANGE_MODE;
+ if (write_to_eeprom) {
+ eeconfig_update_rgblight(rgblight_config.raw);
+ dprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode);
+ } else {
+ dprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode);
+ }
+ if (is_static_effect(rgblight_config.mode)) {
#ifdef RGBLIGHT_USE_TIMER
- rgblight_timer_disable();
+ rgblight_timer_disable();
#endif
- } else {
+ } else {
#ifdef RGBLIGHT_USE_TIMER
- rgblight_timer_enable();
+ rgblight_timer_enable();
#endif
- }
+ }
#ifdef RGBLIGHT_USE_TIMER
animation_status.restart = true;
#endif
- rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
+ rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
}
-void rgblight_mode(uint8_t mode) {
- rgblight_mode_eeprom_helper(mode, true);
-}
-
-void rgblight_mode_noeeprom(uint8_t mode) {
- rgblight_mode_eeprom_helper(mode, false);
-}
+void rgblight_mode(uint8_t mode) { rgblight_mode_eeprom_helper(mode, true); }
+void rgblight_mode_noeeprom(uint8_t mode) { rgblight_mode_eeprom_helper(mode, false); }
void rgblight_toggle(void) {
- xprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
- if (rgblight_config.enable) {
- rgblight_disable();
- }
- else {
- rgblight_enable();
- }
+ dprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
+ if (rgblight_config.enable) {
+ rgblight_disable();
+ } else {
+ rgblight_enable();
+ }
}
void rgblight_toggle_noeeprom(void) {
- xprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
- if (rgblight_config.enable) {
- rgblight_disable_noeeprom();
- }
- else {
- rgblight_enable_noeeprom();
- }
+ dprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
+ if (rgblight_config.enable) {
+ rgblight_disable_noeeprom();
+ } else {
+ rgblight_enable_noeeprom();
+ }
}
void rgblight_enable(void) {
- rgblight_config.enable = 1;
- // No need to update EEPROM here. rgblight_mode() will do that, actually
- //eeconfig_update_rgblight(rgblight_config.raw);
- xprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
- rgblight_mode(rgblight_config.mode);
+ rgblight_config.enable = 1;
+ // No need to update EEPROM here. rgblight_mode() will do that, actually
+ // eeconfig_update_rgblight(rgblight_config.raw);
+ dprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
+ rgblight_mode(rgblight_config.mode);
}
void rgblight_enable_noeeprom(void) {
- rgblight_config.enable = 1;
- xprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
- rgblight_mode_noeeprom(rgblight_config.mode);
+ rgblight_config.enable = 1;
+ dprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
+ rgblight_mode_noeeprom(rgblight_config.mode);
}
void rgblight_disable(void) {
- rgblight_config.enable = 0;
- eeconfig_update_rgblight(rgblight_config.raw);
- xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
+ rgblight_config.enable = 0;
+ eeconfig_update_rgblight(rgblight_config.raw);
+ dprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
#ifdef RGBLIGHT_USE_TIMER
- rgblight_timer_disable();
+ rgblight_timer_disable();
#endif
- RGBLIGHT_SPLIT_SET_CHANGE_MODE;
- wait_ms(50);
- rgblight_set();
+ RGBLIGHT_SPLIT_SET_CHANGE_MODE;
+ wait_ms(50);
+ rgblight_set();
}
void rgblight_disable_noeeprom(void) {
- rgblight_config.enable = 0;
- xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
+ rgblight_config.enable = 0;
+ dprintf("rgblight disable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
#ifdef RGBLIGHT_USE_TIMER
rgblight_timer_disable();
#endif
- RGBLIGHT_SPLIT_SET_CHANGE_MODE;
- wait_ms(50);
- rgblight_set();
+ RGBLIGHT_SPLIT_SET_CHANGE_MODE;
+ wait_ms(50);
+ rgblight_set();
}
void rgblight_increase_hue_helper(bool write_to_eeprom) {
- uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP;
- rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
-}
-void rgblight_increase_hue_noeeprom(void) {
- rgblight_increase_hue_helper(false);
-}
-void rgblight_increase_hue(void) {
- rgblight_increase_hue_helper(true);
+ uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP;
+ rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
}
+void rgblight_increase_hue_noeeprom(void) { rgblight_increase_hue_helper(false); }
+void rgblight_increase_hue(void) { rgblight_increase_hue_helper(true); }
void rgblight_decrease_hue_helper(bool write_to_eeprom) {
- uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP;
- rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
-}
-void rgblight_decrease_hue_noeeprom(void) {
- rgblight_decrease_hue_helper(false);
-}
-void rgblight_decrease_hue(void) {
- rgblight_decrease_hue_helper(true);
+ uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP;
+ rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
}
+void rgblight_decrease_hue_noeeprom(void) { rgblight_decrease_hue_helper(false); }
+void rgblight_decrease_hue(void) { rgblight_decrease_hue_helper(true); }
void rgblight_increase_sat_helper(bool write_to_eeprom) {
- uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
- rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
-}
-void rgblight_increase_sat_noeeprom(void) {
- rgblight_increase_sat_helper(false);
-}
-void rgblight_increase_sat(void) {
- rgblight_increase_sat_helper(true);
+ uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
}
+void rgblight_increase_sat_noeeprom(void) { rgblight_increase_sat_helper(false); }
+void rgblight_increase_sat(void) { rgblight_increase_sat_helper(true); }
void rgblight_decrease_sat_helper(bool write_to_eeprom) {
- uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
- rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
-}
-void rgblight_decrease_sat_noeeprom(void) {
- rgblight_decrease_sat_helper(false);
-}
-void rgblight_decrease_sat(void) {
- rgblight_decrease_sat_helper(true);
+ uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
}
+void rgblight_decrease_sat_noeeprom(void) { rgblight_decrease_sat_helper(false); }
+void rgblight_decrease_sat(void) { rgblight_decrease_sat_helper(true); }
void rgblight_increase_val_helper(bool write_to_eeprom) {
- uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP);
- rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
-}
-void rgblight_increase_val_noeeprom(void) {
- rgblight_increase_val_helper(false);
-}
-void rgblight_increase_val(void) {
- rgblight_increase_val_helper(true);
+ uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
}
+void rgblight_increase_val_noeeprom(void) { rgblight_increase_val_helper(false); }
+void rgblight_increase_val(void) { rgblight_increase_val_helper(true); }
void rgblight_decrease_val_helper(bool write_to_eeprom) {
- uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP);
- rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
-}
-void rgblight_decrease_val_noeeprom(void) {
- rgblight_decrease_val_helper(false);
-}
-void rgblight_decrease_val(void) {
- rgblight_decrease_val_helper(true);
+ uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
}
+void rgblight_decrease_val_noeeprom(void) { rgblight_decrease_val_helper(false); }
+void rgblight_decrease_val(void) { rgblight_decrease_val_helper(true); }
void rgblight_increase_speed(void) {
- if (rgblight_config.speed < 3)
- rgblight_config.speed++;
- //RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?
- eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
+ if (rgblight_config.speed < 3) rgblight_config.speed++;
+ // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?
+ eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
}
void rgblight_decrease_speed(void) {
- if (rgblight_config.speed > 0)
- rgblight_config.speed--;
- //RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED??
- eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
+ if (rgblight_config.speed > 0) rgblight_config.speed--;
+ // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED??
+ eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
}
void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
- if (rgblight_config.enable) {
- LED_TYPE tmp_led;
- sethsv(hue, sat, val, &tmp_led);
- // dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val);
- rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
- }
+ if (rgblight_config.enable) {
+ LED_TYPE tmp_led;
+ sethsv(hue, sat, val, &tmp_led);
+ rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
+ }
}
void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
- if (rgblight_config.enable) {
- rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
- if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
- // same static color
- LED_TYPE tmp_led;
- sethsv(hue, sat, val, &tmp_led);
- rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
- } else {
- // all LEDs in same color
- if ( 1 == 0 ) { //dummy
- }
+ if (rgblight_config.enable) {
+ rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
+ if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
+ // same static color
+ LED_TYPE tmp_led;
+ sethsv(hue, sat, val, &tmp_led);
+ rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
+ } else {
+ // all LEDs in same color
+ if (1 == 0) { // dummy
+ }
#ifdef RGBLIGHT_EFFECT_BREATHING
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING ) {
- // breathing mode, ignore the change of val, use in memory value instead
- val = rgblight_config.val;
- }
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) {
+ // breathing mode, ignore the change of val, use in memory value instead
+ val = rgblight_config.val;
+ }
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) {
- // rainbow mood, ignore the change of hue
- hue = rgblight_config.hue;
- }
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) {
+ // rainbow mood, ignore the change of hue
+ hue = rgblight_config.hue;
+ }
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) {
- // rainbow swirl, ignore the change of hue
- hue = rgblight_config.hue;
- }
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) {
+ // rainbow swirl, ignore the change of hue
+ hue = rgblight_config.hue;
+ }
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_STATIC_GRADIENT) {
- // static gradient
- uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
- bool direction = (delta % 2) == 0;
-#ifdef __AVR__
- // probably due to how pgm_read_word is defined for ARM, but the ARM compiler really hates this line
- uint8_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[delta / 2]);
-#else
- uint8_t range = RGBLED_GRADIENT_RANGES[delta / 2];
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_STATIC_GRADIENT) {
+ // static gradient
+ uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
+ bool direction = (delta % 2) == 0;
+# ifdef __AVR__
+ // probably due to how pgm_read_word is defined for ARM, but the ARM compiler really hates this line
+ uint8_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[delta / 2]);
+# else
+ uint8_t range = RGBLED_GRADIENT_RANGES[delta / 2];
+# endif
+ for (uint8_t i = 0; i < effect_num_leds; i++) {
+ uint8_t _hue = ((uint16_t)i * (uint16_t)range) / effect_num_leds;
+ if (direction) {
+ _hue = hue + _hue;
+ } else {
+ _hue = hue - _hue;
+ }
+ dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
+ sethsv(_hue, sat, val, (LED_TYPE *)&led[i + effect_start_pos]);
+ }
+ rgblight_set();
+ }
#endif
- for (uint8_t i = 0; i < effect_num_leds; i++) {
- uint8_t _hue = ((uint16_t)i * (uint16_t)range) / effect_num_leds;
- if (direction) {
- _hue = hue + _hue;
- } else {
- _hue = hue - _hue;
- }
- dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
- sethsv(_hue, sat, val, (LED_TYPE *)&led[i + effect_start_pos]);
}
- rgblight_set();
- }
-#endif
- }
#ifdef RGBLIGHT_SPLIT
- if( rgblight_config.hue != hue ||
- rgblight_config.sat != sat ||
- rgblight_config.val != val ) {
- RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
- }
+ if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) {
+ RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
+ }
#endif
- rgblight_config.hue = hue;
- rgblight_config.sat = sat;
- rgblight_config.val = val;
- if (write_to_eeprom) {
- eeconfig_update_rgblight(rgblight_config.raw);
- xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
- } else {
- xprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
+ rgblight_config.hue = hue;
+ rgblight_config.sat = sat;
+ rgblight_config.val = val;
+ if (write_to_eeprom) {
+ eeconfig_update_rgblight(rgblight_config.raw);
+ dprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
+ } else {
+ dprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
+ }
}
- }
}
-void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) {
- rgblight_sethsv_eeprom_helper(hue, sat, val, true);
-}
+void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, true); }
-void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) {
- rgblight_sethsv_eeprom_helper(hue, sat, val, false);
-}
+void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_eeprom_helper(hue, sat, val, false); }
-uint8_t rgblight_get_hue(void) {
- return rgblight_config.hue;
-}
+uint8_t rgblight_get_hue(void) { return rgblight_config.hue; }
-uint8_t rgblight_get_sat(void) {
- return rgblight_config.sat;
-}
+uint8_t rgblight_get_sat(void) { return rgblight_config.sat; }
-uint8_t rgblight_get_val(void) {
- return rgblight_config.val;
-}
+uint8_t rgblight_get_val(void) { return rgblight_config.val; }
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
- if (!rgblight_config.enable) { return; }
-
- for (uint8_t i = effect_start_pos; i < effect_end_pos; i++) {
- led[i].r = r;
- led[i].g = g;
- led[i].b = b;
- }
- rgblight_set();
+ if (!rgblight_config.enable) {
+ return;
+ }
+
+ for (uint8_t i = effect_start_pos; i < effect_end_pos; i++) {
+ led[i].r = r;
+ led[i].g = g;
+ led[i].b = b;
+#ifdef RGBW
+ led[i].w = 0;
+#endif
+ }
+ rgblight_set();
}
void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) {
- if (!rgblight_config.enable || index >= RGBLED_NUM) { return; }
+ if (!rgblight_config.enable || index >= RGBLED_NUM) {
+ return;
+ }
- led[index].r = r;
- led[index].g = g;
- led[index].b = b;
- rgblight_set();
+ led[index].r = r;
+ led[index].g = g;
+ led[index].b = b;
+#ifdef RGBW
+ led[index].w = 0;
+#endif
+ rgblight_set();
}
void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) {
- if (!rgblight_config.enable) { return; }
+ if (!rgblight_config.enable) {
+ return;
+ }
- LED_TYPE tmp_led;
- sethsv(hue, sat, val, &tmp_led);
- rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index);
+ LED_TYPE tmp_led;
+ sethsv(hue, sat, val, &tmp_led);
+ rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index);
}
-#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) \
- || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT)
+#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT)
-static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) {
- return
-#ifdef VELOCIKEY_ENABLE
- velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) :
-#endif
- pgm_read_byte(default_interval_address);
+static uint8_t get_interval_time(const uint8_t *default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) {
+ return
+# ifdef VELOCIKEY_ENABLE
+ velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) :
+# endif
+ pgm_read_byte(default_interval_address);
}
#endif
void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) {
- if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { return; }
-
- for (uint8_t i = start; i < end; i++) {
- led[i].r = r;
- led[i].g = g;
- led[i].b = b;
- }
- rgblight_set();
- wait_ms(1);
+ if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) {
+ return;
+ }
+
+ for (uint8_t i = start; i < end; i++) {
+ led[i].r = r;
+ led[i].g = g;
+ led[i].b = b;
+#ifdef RGBW
+ led[i].w = 0;
+#endif
+ }
+ rgblight_set();
+ wait_ms(1);
}
void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) {
- if (!rgblight_config.enable) { return; }
+ if (!rgblight_config.enable) {
+ return;
+ }
- LED_TYPE tmp_led;
- sethsv(hue, sat, val, &tmp_led);
- rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end);
+ LED_TYPE tmp_led;
+ sethsv(hue, sat, val, &tmp_led);
+ rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end);
}
#ifndef RGBLIGHT_SPLIT
-void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) {
- rgblight_setrgb_range(r, g, b, 0 , (uint8_t) RGBLED_NUM/2);
-}
+void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { rgblight_setrgb_range(r, g, b, 0, (uint8_t)RGBLED_NUM / 2); }
-void 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);
-}
+void 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); }
-void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) {
- rgblight_sethsv_range(hue, sat, val, 0, (uint8_t) RGBLED_NUM/2);
-}
+void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_sethsv_range(hue, sat, val, 0, (uint8_t)RGBLED_NUM / 2); }
-void 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);
-}
-#endif // ifndef RGBLIGHT_SPLIT
+void 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); }
+#endif // ifndef RGBLIGHT_SPLIT
#ifndef RGBLIGHT_CUSTOM_DRIVER
void rgblight_set(void) {
- LED_TYPE *start_led;
- uint16_t num_leds = clipping_num_leds;
-
- if (!rgblight_config.enable) {
- for (uint8_t i = effect_start_pos; i < effect_end_pos; i++) {
- led[i].r = 0;
- led[i].g = 0;
- led[i].b = 0;
+ LED_TYPE *start_led;
+ uint16_t num_leds = clipping_num_leds;
+
+ if (!rgblight_config.enable) {
+ for (uint8_t i = effect_start_pos; i < effect_end_pos; i++) {
+ led[i].r = 0;
+ led[i].g = 0;
+ led[i].b = 0;
+# ifdef RGBW
+ led[i].w = 0;
+# endif
+ }
}
- }
-#ifdef RGBLIGHT_LED_MAP
- LED_TYPE led0[RGBLED_NUM];
- for(uint8_t i = 0; i < RGBLED_NUM; i++) {
- led0[i] = led[pgm_read_byte(&led_map[i])];
- }
- start_led = led0 + clipping_start_pos;
-#else
- start_led = led + clipping_start_pos;
-#endif
-#ifdef RGBW
- ws2812_setleds_rgbw(start_led, num_leds);
-#else
- ws2812_setleds(start_led, num_leds);
-#endif
+# ifdef RGBLIGHT_LED_MAP
+ LED_TYPE led0[RGBLED_NUM];
+ for (uint8_t i = 0; i < RGBLED_NUM; i++) {
+ led0[i] = led[pgm_read_byte(&led_map[i])];
+ }
+ start_led = led0 + clipping_start_pos;
+# else
+ start_led = led + clipping_start_pos;
+# endif
+ ws2812_setleds(start_led, num_leds);
}
#endif
#ifdef RGBLIGHT_SPLIT
/* for split keyboard master side */
-uint8_t rgblight_get_change_flags(void) {
- return rgblight_status.change_flags;
-}
+uint8_t rgblight_get_change_flags(void) { return rgblight_status.change_flags; }
-void rgblight_clear_change_flags(void) {
- rgblight_status.change_flags = 0;
-}
+void rgblight_clear_change_flags(void) { rgblight_status.change_flags = 0; }
void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo) {
syncinfo->config = rgblight_config;
@@ -697,7 +639,7 @@ void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo) {
void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) {
if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_MODE) {
if (syncinfo->config.enable) {
- rgblight_config.enable = 1; // == rgblight_enable_noeeprom();
+ rgblight_config.enable = 1; // == rgblight_enable_noeeprom();
rgblight_mode_eeprom_helper(syncinfo->config.mode, write_to_eeprom);
} else {
rgblight_disable_noeeprom();
@@ -707,7 +649,7 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) {
rgblight_sethsv_eeprom_helper(syncinfo->config.hue, syncinfo->config.sat, syncinfo->config.val, write_to_eeprom);
// rgblight_config.speed = config->speed; // NEED???
}
- #ifdef RGBLIGHT_USE_TIMER
+# ifdef RGBLIGHT_USE_TIMER
if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_TIMER) {
if (syncinfo->status.timer_enabled) {
rgblight_timer_enable();
@@ -715,12 +657,12 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) {
rgblight_timer_disable();
}
}
- #ifndef RGBLIGHT_SPLIT_NO_ANIMATION_SYNC
+# ifndef RGBLIGHT_SPLIT_NO_ANIMATION_SYNC
if (syncinfo->status.change_flags & RGBLIGHT_STATUS_ANIMATION_TICK) {
animation_status.restart = true;
}
- #endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */
- #endif /* RGBLIGHT_USE_TIMER */
+# endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */
+# endif /* RGBLIGHT_USE_TIMER */
}
#endif /* RGBLIGHT_SPLIT */
@@ -730,51 +672,51 @@ typedef void (*effect_func_t)(animation_status_t *anim);
// Animation timer -- use system timer (AVR Timer0)
void rgblight_timer_init(void) {
- // OLD!!!! Animation timer -- AVR Timer3
- // static uint8_t rgblight_timer_is_init = 0;
- // if (rgblight_timer_is_init) {
- // return;
- // }
- // rgblight_timer_is_init = 1;
- // /* Timer 3 setup */
- // TCCR3B = _BV(WGM32) // CTC mode OCR3A as TOP
- // | _BV(CS30); // Clock selelct: clk/1
- // /* Set TOP value */
- // uint8_t sreg = SREG;
- // cli();
- // OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff;
- // OCR3AL = RGBLED_TIMER_TOP & 0xff;
- // SREG = sreg;
-
- rgblight_status.timer_enabled = false;
- RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
+ // OLD!!!! Animation timer -- AVR Timer3
+ // static uint8_t rgblight_timer_is_init = 0;
+ // if (rgblight_timer_is_init) {
+ // return;
+ // }
+ // rgblight_timer_is_init = 1;
+ // /* Timer 3 setup */
+ // TCCR3B = _BV(WGM32) // CTC mode OCR3A as TOP
+ // | _BV(CS30); // Clock selelct: clk/1
+ // /* Set TOP value */
+ // uint8_t sreg = SREG;
+ // cli();
+ // OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff;
+ // OCR3AL = RGBLED_TIMER_TOP & 0xff;
+ // SREG = sreg;
+
+ rgblight_status.timer_enabled = false;
+ RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
}
void rgblight_timer_enable(void) {
- if( !is_static_effect(rgblight_config.mode) ) {
- rgblight_status.timer_enabled = true;
- }
- animation_status.last_timer = timer_read();
- RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
- dprintf("rgblight timer enabled.\n");
+ if (!is_static_effect(rgblight_config.mode)) {
+ rgblight_status.timer_enabled = true;
+ }
+ animation_status.last_timer = timer_read();
+ RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
+ dprintf("rgblight timer enabled.\n");
}
void rgblight_timer_disable(void) {
- rgblight_status.timer_enabled = false;
- RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
- dprintf("rgblight timer disable.\n");
+ rgblight_status.timer_enabled = false;
+ RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
+ dprintf("rgblight timer disable.\n");
}
void rgblight_timer_toggle(void) {
- dprintf("rgblight timer toggle.\n");
- if(rgblight_status.timer_enabled) {
- rgblight_timer_disable();
- } else {
- rgblight_timer_enable();
- }
+ dprintf("rgblight timer toggle.\n");
+ if (rgblight_status.timer_enabled) {
+ rgblight_timer_disable();
+ } else {
+ rgblight_timer_enable();
+ }
}
void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) {
- rgblight_enable();
- rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
- rgblight_setrgb(r, g, b);
+ rgblight_enable();
+ rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
+ rgblight_setrgb(r, g, b);
}
static void rgblight_effect_dummy(animation_status_t *anim) {
@@ -790,104 +732,99 @@ static void rgblight_effect_dummy(animation_status_t *anim) {
}
void rgblight_task(void) {
- if (rgblight_status.timer_enabled) {
- effect_func_t effect_func = rgblight_effect_dummy;
- uint16_t interval_time = 2000; // dummy interval
- uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
- animation_status.delta = delta;
-
- // static light mode, do nothing here
- if ( 1 == 0 ) { //dummy
- }
-#ifdef RGBLIGHT_EFFECT_BREATHING
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) {
- // breathing mode
- interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[delta], 1, 100);
- effect_func = rgblight_effect_breathing;
- }
-#endif
-#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) {
- // rainbow mood mode
- interval_time = get_interval_time(&RGBLED_RAINBOW_MOOD_INTERVALS[delta], 5, 100);
- effect_func = rgblight_effect_rainbow_mood;
- }
-#endif
-#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) {
- // rainbow swirl mode
- interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[delta / 2], 1, 100);
- effect_func = rgblight_effect_rainbow_swirl;
- }
-#endif
-#ifdef RGBLIGHT_EFFECT_SNAKE
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_SNAKE) {
- // snake mode
- interval_time = get_interval_time(&RGBLED_SNAKE_INTERVALS[delta / 2], 1, 200);
- effect_func = rgblight_effect_snake;
- }
-#endif
-#ifdef RGBLIGHT_EFFECT_KNIGHT
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_KNIGHT) {
- // knight mode
- interval_time = get_interval_time(&RGBLED_KNIGHT_INTERVALS[delta], 5, 100);
- effect_func = rgblight_effect_knight;
- }
-#endif
-#ifdef RGBLIGHT_EFFECT_CHRISTMAS
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_CHRISTMAS) {
- // christmas mode
- interval_time = RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL;
- effect_func = (effect_func_t)rgblight_effect_christmas;
- }
-#endif
-#ifdef RGBLIGHT_EFFECT_RGB_TEST
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_RGB_TEST) {
- // RGB test mode
- interval_time = pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0]);
- effect_func = (effect_func_t)rgblight_effect_rgbtest;
- }
-#endif
-#ifdef RGBLIGHT_EFFECT_ALTERNATING
- else if (rgblight_status.base_mode == RGBLIGHT_MODE_ALTERNATING){
- interval_time = 500;
- effect_func = (effect_func_t)rgblight_effect_alternating;
- }
-#endif
- if (animation_status.restart) {
- animation_status.restart = false;
- animation_status.last_timer = timer_read() - interval_time - 1;
- animation_status.pos16 = 0; // restart signal to local each effect
- }
- if (timer_elapsed(animation_status.last_timer) >= interval_time) {
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- static uint16_t report_last_timer = 0;
- static bool tick_flag = false;
- uint16_t oldpos16;
- if (tick_flag) {
- tick_flag = false;
- //dprintf("rgblight animation tick\n");
- if (timer_elapsed(report_last_timer) >= 30000) {
- report_last_timer = timer_read();
- dprintf("rgblight animation tick report to slave\n");
- RGBLIGHT_SPLIT_ANIMATION_TICK;
+ if (rgblight_status.timer_enabled) {
+ effect_func_t effect_func = rgblight_effect_dummy;
+ uint16_t interval_time = 2000; // dummy interval
+ uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
+ animation_status.delta = delta;
+
+ // static light mode, do nothing here
+ if (1 == 0) { // dummy
+ }
+# ifdef RGBLIGHT_EFFECT_BREATHING
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) {
+ // breathing mode
+ interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[delta], 1, 100);
+ effect_func = rgblight_effect_breathing;
+ }
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) {
+ // rainbow mood mode
+ interval_time = get_interval_time(&RGBLED_RAINBOW_MOOD_INTERVALS[delta], 5, 100);
+ effect_func = rgblight_effect_rainbow_mood;
+ }
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) {
+ // rainbow swirl mode
+ interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[delta / 2], 1, 100);
+ effect_func = rgblight_effect_rainbow_swirl;
+ }
+# endif
+# ifdef RGBLIGHT_EFFECT_SNAKE
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_SNAKE) {
+ // snake mode
+ interval_time = get_interval_time(&RGBLED_SNAKE_INTERVALS[delta / 2], 1, 200);
+ effect_func = rgblight_effect_snake;
+ }
+# endif
+# ifdef RGBLIGHT_EFFECT_KNIGHT
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_KNIGHT) {
+ // knight mode
+ interval_time = get_interval_time(&RGBLED_KNIGHT_INTERVALS[delta], 5, 100);
+ effect_func = rgblight_effect_knight;
+ }
+# endif
+# ifdef RGBLIGHT_EFFECT_CHRISTMAS
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_CHRISTMAS) {
+ // christmas mode
+ interval_time = RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL;
+ effect_func = (effect_func_t)rgblight_effect_christmas;
+ }
+# endif
+# ifdef RGBLIGHT_EFFECT_RGB_TEST
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RGB_TEST) {
+ // RGB test mode
+ interval_time = pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0]);
+ effect_func = (effect_func_t)rgblight_effect_rgbtest;
+ }
+# endif
+# ifdef RGBLIGHT_EFFECT_ALTERNATING
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_ALTERNATING) {
+ interval_time = 500;
+ effect_func = (effect_func_t)rgblight_effect_alternating;
+ }
+# endif
+ if (animation_status.restart) {
+ animation_status.restart = false;
+ animation_status.last_timer = timer_read() - interval_time - 1;
+ animation_status.pos16 = 0; // restart signal to local each effect
+ }
+ if (timer_elapsed(animation_status.last_timer) >= interval_time) {
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ static uint16_t report_last_timer = 0;
+ static bool tick_flag = false;
+ uint16_t oldpos16;
+ if (tick_flag) {
+ tick_flag = false;
+ if (timer_elapsed(report_last_timer) >= 30000) {
+ report_last_timer = timer_read();
+ dprintf("rgblight animation tick report to slave\n");
+ RGBLIGHT_SPLIT_ANIMATION_TICK;
+ }
+ }
+ oldpos16 = animation_status.pos16;
+# endif
+ animation_status.last_timer += interval_time;
+ effect_func(&animation_status);
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ if (animation_status.pos16 == 0 && oldpos16 != 0) {
+ tick_flag = true;
+ }
+# endif
}
- }
- oldpos16 = animation_status.pos16;
- //dprintf("call effect function\n");
-#endif
- animation_status.last_timer += interval_time;
- effect_func(&animation_status);
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- //dprintf("pos16, oldpos16 = %d %d\n",
- // animation_status.pos16,oldpos16);
- if (animation_status.pos16 == 0 && oldpos16 != 0) {
- //dprintf("flag on\n");
- tick_flag = true;
- }
-#endif
}
- }
}
#endif /* RGBLIGHT_USE_TIMER */
@@ -895,237 +832,247 @@ void rgblight_task(void) {
// Effects
#ifdef RGBLIGHT_EFFECT_BREATHING
-#ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
- #ifndef RGBLIGHT_BREATHE_TABLE_SIZE
- #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64
- #endif
- #include <rgblight_breathe_table.h>
-#endif
+# ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
+# ifndef RGBLIGHT_BREATHE_TABLE_SIZE
+# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64
+# endif
+# include <rgblight_breathe_table.h>
+# endif
-__attribute__ ((weak))
-const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
+__attribute__((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
void rgblight_effect_breathing(animation_status_t *anim) {
- float val;
+ float val;
- // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
-#ifdef RGBLIGHT_EFFECT_BREATHE_TABLE
- val = pgm_read_byte(&rgblight_effect_breathe_table[anim->pos / table_scale]);
-#else
- val = (exp(sin((anim->pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E));
-#endif
- rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val);
- anim->pos = (anim->pos + 1);
+ // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
+# ifdef RGBLIGHT_EFFECT_BREATHE_TABLE
+ val = pgm_read_byte(&rgblight_effect_breathe_table[anim->pos / table_scale]);
+# else
+ val = (exp(sin((anim->pos / 255.0) * M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER / M_E) * (RGBLIGHT_EFFECT_BREATHE_MAX / (M_E - 1 / M_E));
+# endif
+ rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val);
+ anim->pos = (anim->pos + 1);
}
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
-__attribute__ ((weak))
-const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30};
+__attribute__((weak)) const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30};
void rgblight_effect_rainbow_mood(animation_status_t *anim) {
- rgblight_sethsv_noeeprom_old(anim->current_hue, rgblight_config.sat, rgblight_config.val);
- anim->current_hue++;
+ rgblight_sethsv_noeeprom_old(anim->current_hue, rgblight_config.sat, rgblight_config.val);
+ anim->current_hue++;
}
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
-#ifndef RGBLIGHT_RAINBOW_SWIRL_RANGE
- #define RGBLIGHT_RAINBOW_SWIRL_RANGE 255
-#endif
+# ifndef RGBLIGHT_RAINBOW_SWIRL_RANGE
+# define RGBLIGHT_RAINBOW_SWIRL_RANGE 255
+# endif
-__attribute__ ((weak))
-const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
+__attribute__((weak)) const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
void rgblight_effect_rainbow_swirl(animation_status_t *anim) {
- uint8_t hue;
- uint8_t i;
+ uint8_t hue;
+ uint8_t i;
- for (i = 0; i < effect_num_leds; i++) {
- hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / effect_num_leds * i + anim->current_hue);
- sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + effect_start_pos]);
- }
- rgblight_set();
+ for (i = 0; i < effect_num_leds; i++) {
+ hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / effect_num_leds * i + anim->current_hue);
+ sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + effect_start_pos]);
+ }
+ rgblight_set();
- if (anim->delta % 2) {
- anim->current_hue++;
- } else {
- anim->current_hue--;
- }
+ if (anim->delta % 2) {
+ anim->current_hue++;
+ } else {
+ anim->current_hue--;
+ }
}
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
-__attribute__ ((weak))
-const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
+__attribute__((weak)) const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
void rgblight_effect_snake(animation_status_t *anim) {
- static uint8_t pos = 0;
- uint8_t i, j;
- int8_t k;
- int8_t increment = 1;
-
- if (anim->delta % 2) {
- increment = -1;
- }
+ static uint8_t pos = 0;
+ uint8_t i, j;
+ int8_t k;
+ int8_t increment = 1;
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- if (anim->pos == 0) { // restart signal
- if (increment == 1) {
- pos = effect_num_leds - 1;
- } else {
- pos = 0;
+ if (anim->delta % 2) {
+ increment = -1;
}
- anim->pos = 1;
- }
-#endif
- for (i = 0; i < effect_num_leds; i++) {
- LED_TYPE *ledp = led + i + effect_start_pos;
- ledp->r = 0;
- ledp->g = 0;
- ledp->b = 0;
- for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) {
- k = pos + j * increment;
- if (k < 0) {
- k = k + effect_num_leds;
- }
- if (i == k) {
- sethsv(rgblight_config.hue, rgblight_config.sat,
- (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH),
- ledp);
- }
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ if (anim->pos == 0) { // restart signal
+ if (increment == 1) {
+ pos = effect_num_leds - 1;
+ } else {
+ pos = 0;
+ }
+ anim->pos = 1;
}
- }
- rgblight_set();
- if (increment == 1) {
- if (pos - 1 < 0) {
- pos = effect_num_leds - 1;
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- anim->pos = 0;
-#endif
+# endif
+
+ for (i = 0; i < effect_num_leds; i++) {
+ LED_TYPE *ledp = led + i + effect_start_pos;
+ ledp->r = 0;
+ ledp->g = 0;
+ ledp->b = 0;
+# ifdef RGBW
+ ledp->w = 0;
+# endif
+ for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) {
+ k = pos + j * increment;
+ if (k > RGBLED_NUM) {
+ k = k % RGBLED_NUM;
+ }
+ if (k < 0) {
+ k = k + effect_num_leds;
+ }
+ if (i == k) {
+ sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val * (RGBLIGHT_EFFECT_SNAKE_LENGTH - j) / RGBLIGHT_EFFECT_SNAKE_LENGTH), ledp);
+ }
+ }
+ }
+ rgblight_set();
+ if (increment == 1) {
+ if (pos - 1 < 0) {
+ pos = effect_num_leds - 1;
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ anim->pos = 0;
+# endif
+ } else {
+ pos -= 1;
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ anim->pos = 1;
+# endif
+ }
} else {
- pos -= 1;
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- anim->pos = 1;
-#endif
+ pos = (pos + 1) % effect_num_leds;
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ anim->pos = pos;
+# endif
}
- } else {
- pos = (pos + 1) % effect_num_leds;
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- anim->pos = pos;
-#endif
- }
}
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
-__attribute__ ((weak))
-const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
+__attribute__((weak)) const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
void rgblight_effect_knight(animation_status_t *anim) {
-
- static int8_t low_bound = 0;
- static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
- static int8_t increment = 1;
- uint8_t i, cur;
-
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- if (anim->pos == 0) { // restart signal
- anim->pos = 1;
- low_bound = 0;
- high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
- increment = 1;
- }
-#endif
- // Set all the LEDs to 0
- for (i = effect_start_pos; i < effect_end_pos; i++) {
- led[i].r = 0;
- led[i].g = 0;
- led[i].b = 0;
- }
- // Determine which LEDs should be lit up
- for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) {
- cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % effect_num_leds + effect_start_pos;
-
- if (i >= low_bound && i <= high_bound) {
- sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]);
- } else {
- led[cur].r = 0;
- led[cur].g = 0;
- led[cur].b = 0;
+ static int8_t low_bound = 0;
+ static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
+ static int8_t increment = 1;
+ uint8_t i, cur;
+
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ if (anim->pos == 0) { // restart signal
+ anim->pos = 1;
+ low_bound = 0;
+ high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
+ increment = 1;
}
- }
- rgblight_set();
-
- // Move from low_bound to high_bound changing the direction we increment each
- // time a boundary is hit.
- low_bound += increment;
- high_bound += increment;
+# endif
+ // Set all the LEDs to 0
+ for (i = effect_start_pos; i < effect_end_pos; i++) {
+ led[i].r = 0;
+ led[i].g = 0;
+ led[i].b = 0;
+# ifdef RGBW
+ led[i].w = 0;
+# endif
+ }
+ // Determine which LEDs should be lit up
+ for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) {
+ cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % effect_num_leds + effect_start_pos;
- if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) {
- increment = -increment;
-#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
- if (increment == 1) {
- anim->pos = 0;
+ if (i >= low_bound && i <= high_bound) {
+ sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]);
+ } else {
+ led[cur].r = 0;
+ led[cur].g = 0;
+ led[cur].b = 0;
+# ifdef RGBW
+ led[cur].w = 0;
+# endif
+ }
+ }
+ rgblight_set();
+
+ // Move from low_bound to high_bound changing the direction we increment each
+ // time a boundary is hit.
+ low_bound += increment;
+ high_bound += increment;
+
+ if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) {
+ increment = -increment;
+# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ if (increment == 1) {
+ anim->pos = 0;
+ }
+# endif
}
-#endif
- }
}
#endif
#ifdef RGBLIGHT_EFFECT_CHRISTMAS
void rgblight_effect_christmas(animation_status_t *anim) {
- uint8_t hue;
- uint8_t i;
-
- anim->current_offset = (anim->current_offset + 1) % 2;
- for (i = 0; i < effect_num_leds; i++) {
- hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 85;
- sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + effect_start_pos]);
- }
- rgblight_set();
+ uint8_t hue;
+ uint8_t i;
+
+ anim->current_offset = (anim->current_offset + 1) % 2;
+ for (i = 0; i < effect_num_leds; i++) {
+ hue = 0 + ((i / RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 85;
+ sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + effect_start_pos]);
+ }
+ rgblight_set();
}
#endif
#ifdef RGBLIGHT_EFFECT_RGB_TEST
-__attribute__ ((weak))
-const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024};
+__attribute__((weak)) const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024};
void rgblight_effect_rgbtest(animation_status_t *anim) {
- static uint8_t maxval = 0;
- uint8_t g; uint8_t r; uint8_t b;
-
- if( maxval == 0 ) {
- LED_TYPE tmp_led;
- sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led);
- maxval = tmp_led.r;
- }
- g = r = b = 0;
- switch( anim->pos ) {
- case 0: r = maxval; break;
- case 1: g = maxval; break;
- case 2: b = maxval; break;
- }
- rgblight_setrgb(r, g, b);
- anim->pos = (anim->pos + 1) % 3;
+ static uint8_t maxval = 0;
+ uint8_t g;
+ uint8_t r;
+ uint8_t b;
+
+ if (maxval == 0) {
+ LED_TYPE tmp_led;
+ sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led);
+ maxval = tmp_led.r;
+ }
+ g = r = b = 0;
+ switch (anim->pos) {
+ case 0:
+ r = maxval;
+ break;
+ case 1:
+ g = maxval;
+ break;
+ case 2:
+ b = maxval;
+ break;
+ }
+ rgblight_setrgb(r, g, b);
+ anim->pos = (anim->pos + 1) % 3;
}
#endif
#ifdef RGBLIGHT_EFFECT_ALTERNATING
void rgblight_effect_alternating(animation_status_t *anim) {
-
- for (int i = 0; i < effect_num_leds; i++) {
- LED_TYPE *ledp = led + i + effect_start_pos;
- if (i<effect_num_leds/2 && anim->pos) {
- sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp);
- } else if (i>=effect_num_leds/2 && !anim->pos) {
- sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp);
- } else {
- sethsv(rgblight_config.hue, rgblight_config.sat, 0, ledp);
- }
- }
- rgblight_set();
- anim->pos = (anim->pos + 1) % 2;
+ for (int i = 0; i < effect_num_leds; i++) {
+ LED_TYPE *ledp = led + i + effect_start_pos;
+ if (i < effect_num_leds / 2 && anim->pos) {
+ sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp);
+ } else if (i >= effect_num_leds / 2 && !anim->pos) {
+ sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp);
+ } else {
+ sethsv(rgblight_config.hue, rgblight_config.sat, 0, ledp);
+ }
+ }
+ rgblight_set();
+ anim->pos = (anim->pos + 1) % 2;
}
#endif
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index cba18ae729..e3aa098e4d 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -64,12 +64,12 @@
|-----------------|-----------------------------------|
*****/
-#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_ ## sym,
+#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_##sym,
+#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##sym,
+#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##sym,
enum RGBLIGHT_EFFECT_MODE {
RGBLIGHT_MODE_zero = 0,
#include "rgblight_modes.h"
@@ -78,101 +78,101 @@ enum RGBLIGHT_EFFECT_MODE {
#ifndef RGBLIGHT_H_DUMMY_DEFINE
-#define RGBLIGHT_MODES (RGBLIGHT_MODE_last-1)
+# define RGBLIGHT_MODES (RGBLIGHT_MODE_last - 1)
// sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85
-#ifndef RGBLIGHT_EFFECT_BREATHE_MAX
-#define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255
-#endif
-
-#ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH
-#define RGBLIGHT_EFFECT_SNAKE_LENGTH 4
-#endif
-
-#ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH
-#define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3
-#endif
-
-#ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET
-#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0
-#endif
-
-#ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM
-#define RGBLIGHT_EFFECT_KNIGHT_LED_NUM (effect_num_leds)
-#endif
-
-#ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL
-#define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000
-#endif
-
-#ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP
-#define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2
-#endif
-
-#ifndef RGBLIGHT_HUE_STEP
-#define RGBLIGHT_HUE_STEP 8
-#endif
-#ifndef RGBLIGHT_SAT_STEP
-#define RGBLIGHT_SAT_STEP 17
-#endif
-#ifndef RGBLIGHT_VAL_STEP
-#define RGBLIGHT_VAL_STEP 17
-#endif
-#ifndef RGBLIGHT_LIMIT_VAL
-#define RGBLIGHT_LIMIT_VAL 255
-#endif
-
-#define RGBLED_TIMER_TOP F_CPU/(256*64)
+# ifndef RGBLIGHT_EFFECT_BREATHE_MAX
+# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255
+# endif
+
+# ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH
+# define RGBLIGHT_EFFECT_SNAKE_LENGTH 4
+# endif
+
+# ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH
+# define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3
+# endif
+
+# ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET
+# define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0
+# endif
+
+# ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM
+# define RGBLIGHT_EFFECT_KNIGHT_LED_NUM (effect_num_leds)
+# endif
+
+# ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL
+# define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000
+# endif
+
+# ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP
+# define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2
+# endif
+
+# ifndef RGBLIGHT_HUE_STEP
+# define RGBLIGHT_HUE_STEP 8
+# endif
+# ifndef RGBLIGHT_SAT_STEP
+# define RGBLIGHT_SAT_STEP 17
+# endif
+# ifndef RGBLIGHT_VAL_STEP
+# define RGBLIGHT_VAL_STEP 17
+# endif
+# ifndef RGBLIGHT_LIMIT_VAL
+# define RGBLIGHT_LIMIT_VAL 255
+# endif
+
+# define RGBLED_TIMER_TOP F_CPU / (256 * 64)
// #define RGBLED_TIMER_TOP 0xFF10
-#include <stdint.h>
-#include <stdbool.h>
-#include "eeconfig.h"
-#ifndef RGBLIGHT_CUSTOM_DRIVER
-#include "ws2812.h"
-#endif
-#include "color.h"
-#include "rgblight_list.h"
+# include <stdint.h>
+# include <stdbool.h>
+# include "eeconfig.h"
+# ifndef RGBLIGHT_CUSTOM_DRIVER
+# include "ws2812.h"
+# endif
+# include "color.h"
+# include "rgblight_list.h"
-#if defined(__AVR__)
- #include <avr/pgmspace.h>
-#endif
+# if defined(__AVR__)
+# include <avr/pgmspace.h>
+# endif
extern LED_TYPE led[RGBLED_NUM];
-extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM;
-extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM;
-extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM;
-extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM;
-extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM;
+extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM;
+extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM;
+extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM;
+extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM;
+extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM;
extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM;
-extern bool is_rgblight_initialized;
+extern bool is_rgblight_initialized;
// Should stay in sycn with rgb matrix config as we reuse eeprom storage for both (for now)
typedef union {
- uint32_t raw;
- struct {
- bool enable :1;
- uint8_t mode :7;
- uint8_t hue :8;
- uint8_t sat :8;
- uint8_t val :8;
- uint8_t speed :8;//EECONFIG needs to be increased to support this
- };
+ uint32_t raw;
+ struct {
+ bool enable : 1;
+ uint8_t mode : 7;
+ uint8_t hue : 8;
+ uint8_t sat : 8;
+ uint8_t val : 8;
+ uint8_t speed : 8; // EECONFIG needs to be increased to support this
+ };
} rgblight_config_t;
typedef struct _rgblight_status_t {
- uint8_t base_mode;
- bool timer_enabled;
-#ifdef RGBLIGHT_SPLIT
+ uint8_t base_mode;
+ bool timer_enabled;
+# ifdef RGBLIGHT_SPLIT
uint8_t change_flags;
-#endif
+# endif
} rgblight_status_t;
/* === Utility Functions ===*/
void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1);
-void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check
+void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check
void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1);
/* === Low level Functions === */
@@ -190,12 +190,12 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8
void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end);
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b);
-#ifndef RGBLIGHT_SPLIT
+# ifndef RGBLIGHT_SPLIT
void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b);
void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b);
void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val);
void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val);
-#endif
+# endif
/* effect mode change */
void rgblight_mode(uint8_t mode);
@@ -240,13 +240,13 @@ uint8_t rgblight_get_sat(void);
uint8_t rgblight_get_val(void);
/* === qmk_firmware (core)internal Functions === */
-void rgblight_init(void);
+void rgblight_init(void);
uint32_t rgblight_read_dword(void);
-void rgblight_update_dword(uint32_t dword);
+void rgblight_update_dword(uint32_t dword);
uint32_t eeconfig_read_rgblight(void);
-void eeconfig_update_rgblight(uint32_t val);
-void eeconfig_update_rgblight_default(void);
-void eeconfig_debug_rgblight(void);
+void eeconfig_update_rgblight(uint32_t val);
+void eeconfig_update_rgblight_default(void);
+void eeconfig_debug_rgblight(void);
void rgb_matrix_increase(void);
void rgb_matrix_decrease(void);
@@ -254,7 +254,7 @@ void rgb_matrix_decrease(void);
void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom);
void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom);
-#define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF)
+# define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF)
void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b);
void rgblight_task(void);
@@ -264,26 +264,26 @@ void rgblight_timer_enable(void);
void rgblight_timer_disable(void);
void rgblight_timer_toggle(void);
-#ifdef RGBLIGHT_SPLIT
- #define RGBLIGHT_STATUS_CHANGE_MODE (1<<0)
- #define RGBLIGHT_STATUS_CHANGE_HSVS (1<<1)
- #define RGBLIGHT_STATUS_CHANGE_TIMER (1<<2)
- #define RGBLIGHT_STATUS_ANIMATION_TICK (1<<3)
+# ifdef RGBLIGHT_SPLIT
+# define RGBLIGHT_STATUS_CHANGE_MODE (1 << 0)
+# define RGBLIGHT_STATUS_CHANGE_HSVS (1 << 1)
+# define RGBLIGHT_STATUS_CHANGE_TIMER (1 << 2)
+# define RGBLIGHT_STATUS_ANIMATION_TICK (1 << 3)
- typedef struct _rgblight_syncinfo_t {
+typedef struct _rgblight_syncinfo_t {
rgblight_config_t config;
rgblight_status_t status;
- } rgblight_syncinfo_t;
+} rgblight_syncinfo_t;
- /* for split keyboard master side */
- uint8_t rgblight_get_change_flags(void);
- void rgblight_clear_change_flags(void);
- void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo);
- /* for split keyboard slave side */
- void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom);
-#endif
+/* for split keyboard master side */
+uint8_t rgblight_get_change_flags(void);
+void rgblight_clear_change_flags(void);
+void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo);
+/* for split keyboard slave side */
+void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom);
+# endif
-#ifdef RGBLIGHT_USE_TIMER
+# ifdef RGBLIGHT_USE_TIMER
typedef struct _animation_status_t {
uint16_t last_timer;
@@ -308,7 +308,7 @@ void rgblight_effect_christmas(animation_status_t *anim);
void rgblight_effect_rgbtest(animation_status_t *anim);
void rgblight_effect_alternating(animation_status_t *anim);
-#endif
+# endif
-#endif // #ifndef RGBLIGHT_H_DUMMY_DEFINE
-#endif // RGBLIGHT_H
+#endif // #ifndef RGBLIGHT_H_DUMMY_DEFINE
+#endif // RGBLIGHT_H
diff --git a/quantum/rgblight_breathe_table.h b/quantum/rgblight_breathe_table.h
index 7ab8cc9479..a438332bd3 100644
--- a/quantum/rgblight_breathe_table.h
+++ b/quantum/rgblight_breathe_table.h
@@ -2,115 +2,467 @@
#define RGBLIGHT_EFFECT_BREATHE_TABLE
const uint8_t rgblight_effect_breathe_table[] PROGMEM = {
- /* #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 */
- /* #define RGBLIGHT_EFFECT_BREATHE_MAX 255 */
+/* #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 */
+/* #define RGBLIGHT_EFFECT_BREATHE_MAX 255 */
- #if RGBLIGHT_BREATHE_TABLE_SIZE == 256
- 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2a, 0x2c,
- 0x2d, 0x2f, 0x30, 0x32, 0x33, 0x35, 0x36, 0x38,
- 0x3a, 0x3b, 0x3d, 0x3e, 0x40, 0x42, 0x43, 0x45,
- 0x47, 0x49, 0x4a, 0x4c, 0x4e, 0x50, 0x51, 0x53,
- 0x55, 0x57, 0x59, 0x5a, 0x5c, 0x5e, 0x60, 0x62,
- 0x64, 0x66, 0x68, 0x69, 0x6b, 0x6d, 0x6f, 0x71,
- 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d, 0x7f, 0x81,
- 0x83, 0x85, 0x87, 0x89, 0x8a, 0x8c, 0x8e, 0x90,
- 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0x9f,
- 0xa1, 0xa3, 0xa5, 0xa7, 0xa8, 0xaa, 0xac, 0xae,
- 0xaf, 0xb1, 0xb3, 0xb4, 0xb6, 0xb8, 0xb9, 0xbb,
- 0xbc, 0xbe, 0xbf, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6,
- 0xc7, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xd0,
- 0xd1, 0xd2, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd7, 0xd8, 0xd9, 0xd9, 0xda, 0xda, 0xdb, 0xdb,
- 0xdb, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdd, 0xdd,
- 0xdd, 0xdd, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdb,
- 0xdb, 0xdb, 0xda, 0xda, 0xd9, 0xd9, 0xd8, 0xd7,
- 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd2, 0xd1,
- 0xd0, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7,
- 0xc6, 0xc5, 0xc3, 0xc2, 0xc1, 0xbf, 0xbe, 0xbc,
- 0xbb, 0xb9, 0xb8, 0xb6, 0xb4, 0xb3, 0xb1, 0xaf,
- 0xae, 0xac, 0xaa, 0xa8, 0xa7, 0xa5, 0xa3, 0xa1,
- 0x9f, 0x9e, 0x9c, 0x9a, 0x98, 0x96, 0x94, 0x92,
- 0x90, 0x8e, 0x8c, 0x8a, 0x89, 0x87, 0x85, 0x83,
- 0x81, 0x7f, 0x7d, 0x7b, 0x79, 0x77, 0x75, 0x73,
- 0x71, 0x6f, 0x6d, 0x6b, 0x69, 0x68, 0x66, 0x64,
- 0x62, 0x60, 0x5e, 0x5c, 0x5a, 0x59, 0x57, 0x55,
- 0x53, 0x51, 0x50, 0x4e, 0x4c, 0x4a, 0x49, 0x47,
- 0x45, 0x43, 0x42, 0x40, 0x3e, 0x3d, 0x3b, 0x3a,
- 0x38, 0x36, 0x35, 0x33, 0x32, 0x30, 0x2f, 0x2d,
- 0x2c, 0x2a, 0x29, 0x28, 0x26, 0x25, 0x23, 0x22
- #endif /* 256 bytes table */
+#if RGBLIGHT_BREATHE_TABLE_SIZE == 256
+ 0x22,
+ 0x23,
+ 0x25,
+ 0x26,
+ 0x28,
+ 0x29,
+ 0x2a,
+ 0x2c,
+ 0x2d,
+ 0x2f,
+ 0x30,
+ 0x32,
+ 0x33,
+ 0x35,
+ 0x36,
+ 0x38,
+ 0x3a,
+ 0x3b,
+ 0x3d,
+ 0x3e,
+ 0x40,
+ 0x42,
+ 0x43,
+ 0x45,
+ 0x47,
+ 0x49,
+ 0x4a,
+ 0x4c,
+ 0x4e,
+ 0x50,
+ 0x51,
+ 0x53,
+ 0x55,
+ 0x57,
+ 0x59,
+ 0x5a,
+ 0x5c,
+ 0x5e,
+ 0x60,
+ 0x62,
+ 0x64,
+ 0x66,
+ 0x68,
+ 0x69,
+ 0x6b,
+ 0x6d,
+ 0x6f,
+ 0x71,
+ 0x73,
+ 0x75,
+ 0x77,
+ 0x79,
+ 0x7b,
+ 0x7d,
+ 0x7f,
+ 0x81,
+ 0x83,
+ 0x85,
+ 0x87,
+ 0x89,
+ 0x8a,
+ 0x8c,
+ 0x8e,
+ 0x90,
+ 0x92,
+ 0x94,
+ 0x96,
+ 0x98,
+ 0x9a,
+ 0x9c,
+ 0x9e,
+ 0x9f,
+ 0xa1,
+ 0xa3,
+ 0xa5,
+ 0xa7,
+ 0xa8,
+ 0xaa,
+ 0xac,
+ 0xae,
+ 0xaf,
+ 0xb1,
+ 0xb3,
+ 0xb4,
+ 0xb6,
+ 0xb8,
+ 0xb9,
+ 0xbb,
+ 0xbc,
+ 0xbe,
+ 0xbf,
+ 0xc1,
+ 0xc2,
+ 0xc3,
+ 0xc5,
+ 0xc6,
+ 0xc7,
+ 0xc9,
+ 0xca,
+ 0xcb,
+ 0xcc,
+ 0xcd,
+ 0xce,
+ 0xd0,
+ 0xd1,
+ 0xd2,
+ 0xd2,
+ 0xd3,
+ 0xd4,
+ 0xd5,
+ 0xd6,
+ 0xd7,
+ 0xd7,
+ 0xd8,
+ 0xd9,
+ 0xd9,
+ 0xda,
+ 0xda,
+ 0xdb,
+ 0xdb,
+ 0xdb,
+ 0xdc,
+ 0xdc,
+ 0xdc,
+ 0xdc,
+ 0xdc,
+ 0xdd,
+ 0xdd,
+ 0xdd,
+ 0xdd,
+ 0xdc,
+ 0xdc,
+ 0xdc,
+ 0xdc,
+ 0xdc,
+ 0xdb,
+ 0xdb,
+ 0xdb,
+ 0xda,
+ 0xda,
+ 0xd9,
+ 0xd9,
+ 0xd8,
+ 0xd7,
+ 0xd7,
+ 0xd6,
+ 0xd5,
+ 0xd4,
+ 0xd3,
+ 0xd2,
+ 0xd2,
+ 0xd1,
+ 0xd0,
+ 0xce,
+ 0xcd,
+ 0xcc,
+ 0xcb,
+ 0xca,
+ 0xc9,
+ 0xc7,
+ 0xc6,
+ 0xc5,
+ 0xc3,
+ 0xc2,
+ 0xc1,
+ 0xbf,
+ 0xbe,
+ 0xbc,
+ 0xbb,
+ 0xb9,
+ 0xb8,
+ 0xb6,
+ 0xb4,
+ 0xb3,
+ 0xb1,
+ 0xaf,
+ 0xae,
+ 0xac,
+ 0xaa,
+ 0xa8,
+ 0xa7,
+ 0xa5,
+ 0xa3,
+ 0xa1,
+ 0x9f,
+ 0x9e,
+ 0x9c,
+ 0x9a,
+ 0x98,
+ 0x96,
+ 0x94,
+ 0x92,
+ 0x90,
+ 0x8e,
+ 0x8c,
+ 0x8a,
+ 0x89,
+ 0x87,
+ 0x85,
+ 0x83,
+ 0x81,
+ 0x7f,
+ 0x7d,
+ 0x7b,
+ 0x79,
+ 0x77,
+ 0x75,
+ 0x73,
+ 0x71,
+ 0x6f,
+ 0x6d,
+ 0x6b,
+ 0x69,
+ 0x68,
+ 0x66,
+ 0x64,
+ 0x62,
+ 0x60,
+ 0x5e,
+ 0x5c,
+ 0x5a,
+ 0x59,
+ 0x57,
+ 0x55,
+ 0x53,
+ 0x51,
+ 0x50,
+ 0x4e,
+ 0x4c,
+ 0x4a,
+ 0x49,
+ 0x47,
+ 0x45,
+ 0x43,
+ 0x42,
+ 0x40,
+ 0x3e,
+ 0x3d,
+ 0x3b,
+ 0x3a,
+ 0x38,
+ 0x36,
+ 0x35,
+ 0x33,
+ 0x32,
+ 0x30,
+ 0x2f,
+ 0x2d,
+ 0x2c,
+ 0x2a,
+ 0x29,
+ 0x28,
+ 0x26,
+ 0x25,
+ 0x23,
+ 0x22
+#endif /* 256 bytes table */
- #if RGBLIGHT_BREATHE_TABLE_SIZE == 128
- 0x22, 0x25, 0x28, 0x2a,
- 0x2d, 0x30, 0x33, 0x36,
- 0x3a, 0x3d, 0x40, 0x43,
- 0x47, 0x4a, 0x4e, 0x51,
- 0x55, 0x59, 0x5c, 0x60,
- 0x64, 0x68, 0x6b, 0x6f,
- 0x73, 0x77, 0x7b, 0x7f,
- 0x83, 0x87, 0x8a, 0x8e,
- 0x92, 0x96, 0x9a, 0x9e,
- 0xa1, 0xa5, 0xa8, 0xac,
- 0xaf, 0xb3, 0xb6, 0xb9,
- 0xbc, 0xbf, 0xc2, 0xc5,
- 0xc7, 0xca, 0xcc, 0xce,
- 0xd1, 0xd2, 0xd4, 0xd6,
- 0xd7, 0xd9, 0xda, 0xdb,
- 0xdb, 0xdc, 0xdc, 0xdd,
- 0xdd, 0xdc, 0xdc, 0xdc,
- 0xdb, 0xda, 0xd9, 0xd8,
- 0xd7, 0xd5, 0xd3, 0xd2,
- 0xd0, 0xcd, 0xcb, 0xc9,
- 0xc6, 0xc3, 0xc1, 0xbe,
- 0xbb, 0xb8, 0xb4, 0xb1,
- 0xae, 0xaa, 0xa7, 0xa3,
- 0x9f, 0x9c, 0x98, 0x94,
- 0x90, 0x8c, 0x89, 0x85,
- 0x81, 0x7d, 0x79, 0x75,
- 0x71, 0x6d, 0x69, 0x66,
- 0x62, 0x5e, 0x5a, 0x57,
- 0x53, 0x50, 0x4c, 0x49,
- 0x45, 0x42, 0x3e, 0x3b,
- 0x38, 0x35, 0x32, 0x2f,
- 0x2c, 0x29, 0x26, 0x23
- #endif /* 128 bytes table */
+#if RGBLIGHT_BREATHE_TABLE_SIZE == 128
+ 0x22,
+ 0x25,
+ 0x28,
+ 0x2a,
+ 0x2d,
+ 0x30,
+ 0x33,
+ 0x36,
+ 0x3a,
+ 0x3d,
+ 0x40,
+ 0x43,
+ 0x47,
+ 0x4a,
+ 0x4e,
+ 0x51,
+ 0x55,
+ 0x59,
+ 0x5c,
+ 0x60,
+ 0x64,
+ 0x68,
+ 0x6b,
+ 0x6f,
+ 0x73,
+ 0x77,
+ 0x7b,
+ 0x7f,
+ 0x83,
+ 0x87,
+ 0x8a,
+ 0x8e,
+ 0x92,
+ 0x96,
+ 0x9a,
+ 0x9e,
+ 0xa1,
+ 0xa5,
+ 0xa8,
+ 0xac,
+ 0xaf,
+ 0xb3,
+ 0xb6,
+ 0xb9,
+ 0xbc,
+ 0xbf,
+ 0xc2,
+ 0xc5,
+ 0xc7,
+ 0xca,
+ 0xcc,
+ 0xce,
+ 0xd1,
+ 0xd2,
+ 0xd4,
+ 0xd6,
+ 0xd7,
+ 0xd9,
+ 0xda,
+ 0xdb,
+ 0xdb,
+ 0xdc,
+ 0xdc,
+ 0xdd,
+ 0xdd,
+ 0xdc,
+ 0xdc,
+ 0xdc,
+ 0xdb,
+ 0xda,
+ 0xd9,
+ 0xd8,
+ 0xd7,
+ 0xd5,
+ 0xd3,
+ 0xd2,
+ 0xd0,
+ 0xcd,
+ 0xcb,
+ 0xc9,
+ 0xc6,
+ 0xc3,
+ 0xc1,
+ 0xbe,
+ 0xbb,
+ 0xb8,
+ 0xb4,
+ 0xb1,
+ 0xae,
+ 0xaa,
+ 0xa7,
+ 0xa3,
+ 0x9f,
+ 0x9c,
+ 0x98,
+ 0x94,
+ 0x90,
+ 0x8c,
+ 0x89,
+ 0x85,
+ 0x81,
+ 0x7d,
+ 0x79,
+ 0x75,
+ 0x71,
+ 0x6d,
+ 0x69,
+ 0x66,
+ 0x62,
+ 0x5e,
+ 0x5a,
+ 0x57,
+ 0x53,
+ 0x50,
+ 0x4c,
+ 0x49,
+ 0x45,
+ 0x42,
+ 0x3e,
+ 0x3b,
+ 0x38,
+ 0x35,
+ 0x32,
+ 0x2f,
+ 0x2c,
+ 0x29,
+ 0x26,
+ 0x23
+#endif /* 128 bytes table */
- #if RGBLIGHT_BREATHE_TABLE_SIZE == 64
- 0x22, 0x28,
- 0x2d, 0x33,
- 0x3a, 0x40,
- 0x47, 0x4e,
- 0x55, 0x5c,
- 0x64, 0x6b,
- 0x73, 0x7b,
- 0x83, 0x8a,
- 0x92, 0x9a,
- 0xa1, 0xa8,
- 0xaf, 0xb6,
- 0xbc, 0xc2,
- 0xc7, 0xcc,
- 0xd1, 0xd4,
- 0xd7, 0xda,
- 0xdb, 0xdc,
- 0xdd, 0xdc,
- 0xdb, 0xd9,
- 0xd7, 0xd3,
- 0xd0, 0xcb,
- 0xc6, 0xc1,
- 0xbb, 0xb4,
- 0xae, 0xa7,
- 0x9f, 0x98,
- 0x90, 0x89,
- 0x81, 0x79,
- 0x71, 0x69,
- 0x62, 0x5a,
- 0x53, 0x4c,
- 0x45, 0x3e,
- 0x38, 0x32,
- 0x2c, 0x26
- #endif /* 64 bytes table */
+#if RGBLIGHT_BREATHE_TABLE_SIZE == 64
+ 0x22,
+ 0x28,
+ 0x2d,
+ 0x33,
+ 0x3a,
+ 0x40,
+ 0x47,
+ 0x4e,
+ 0x55,
+ 0x5c,
+ 0x64,
+ 0x6b,
+ 0x73,
+ 0x7b,
+ 0x83,
+ 0x8a,
+ 0x92,
+ 0x9a,
+ 0xa1,
+ 0xa8,
+ 0xaf,
+ 0xb6,
+ 0xbc,
+ 0xc2,
+ 0xc7,
+ 0xcc,
+ 0xd1,
+ 0xd4,
+ 0xd7,
+ 0xda,
+ 0xdb,
+ 0xdc,
+ 0xdd,
+ 0xdc,
+ 0xdb,
+ 0xd9,
+ 0xd7,
+ 0xd3,
+ 0xd0,
+ 0xcb,
+ 0xc6,
+ 0xc1,
+ 0xbb,
+ 0xb4,
+ 0xae,
+ 0xa7,
+ 0x9f,
+ 0x98,
+ 0x90,
+ 0x89,
+ 0x81,
+ 0x79,
+ 0x71,
+ 0x69,
+ 0x62,
+ 0x5a,
+ 0x53,
+ 0x4c,
+ 0x45,
+ 0x3e,
+ 0x38,
+ 0x32,
+ 0x2c,
+ 0x26
+#endif /* 64 bytes table */
};
-static const int table_scale = 256/sizeof(rgblight_effect_breathe_table);
+static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table);
#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */
diff --git a/quantum/rgblight_list.h b/quantum/rgblight_list.h
index 702e33e765..e30733baa6 100644
--- a/quantum/rgblight_list.h
+++ b/quantum/rgblight_list.h
@@ -16,45 +16,44 @@
#pragma once
/* RGB COLORS */
-#define RGB_WHITE 0xFF, 0xFF, 0xFF
-#define RGB_RED 0xFF, 0x00, 0x00
-#define RGB_CORAL 0xFF, 0x7C, 0x4D
-#define RGB_ORANGE 0xFF, 0x80, 0x00
-#define RGB_GOLDENROD 0xD9, 0xA5, 0x21
-#define RGB_GOLD 0xFF, 0xD9, 0x00
-#define RGB_YELLOW 0xFF, 0xFF, 0x00
-#define RGB_CHARTREUSE 0x80, 0xFF, 0x00
-#define RGB_GREEN 0x00, 0xFF, 0x00
-#define RGB_SPRINGGREEN 0x00, 0xFF, 0x80
-#define RGB_TURQUOISE 0x47, 0x6E, 0x6A
-#define RGB_TEAL 0x00, 0x80, 0x80
-#define RGB_CYAN 0x00, 0xFF, 0xFF
-#define RGB_AZURE 0x99, 0xf5, 0xFF
-#define RGB_BLUE 0x00, 0x00, 0xFF
-#define RGB_PURPLE 0x7A, 0x00, 0xFF
-#define RGB_MAGENTA 0xFF, 0x00, 0xFF
-#define RGB_PINK 0xFF, 0x80, 0xBF
+#define RGB_WHITE 0xFF, 0xFF, 0xFF
+#define RGB_RED 0xFF, 0x00, 0x00
+#define RGB_CORAL 0xFF, 0x7C, 0x4D
+#define RGB_ORANGE 0xFF, 0x80, 0x00
+#define RGB_GOLDENROD 0xD9, 0xA5, 0x21
+#define RGB_GOLD 0xFF, 0xD9, 0x00
+#define RGB_YELLOW 0xFF, 0xFF, 0x00
+#define RGB_CHARTREUSE 0x80, 0xFF, 0x00
+#define RGB_GREEN 0x00, 0xFF, 0x00
+#define RGB_SPRINGGREEN 0x00, 0xFF, 0x80
+#define RGB_TURQUOISE 0x47, 0x6E, 0x6A
+#define RGB_TEAL 0x00, 0x80, 0x80
+#define RGB_CYAN 0x00, 0xFF, 0xFF
+#define RGB_AZURE 0x99, 0xf5, 0xFF
+#define RGB_BLUE 0x00, 0x00, 0xFF
+#define RGB_PURPLE 0x7A, 0x00, 0xFF
+#define RGB_MAGENTA 0xFF, 0x00, 0xFF
+#define RGB_PINK 0xFF, 0x80, 0xBF
/* HSV COLORS */
-#define HSV_WHITE 0, 0, 255
-#define HSV_RED 0, 255, 255
-#define HSV_CORAL 11, 176, 255
-#define HSV_ORANGE 28, 255, 255
-#define HSV_GOLDENROD 30, 218, 218
-#define HSV_GOLD 36, 255, 255
-#define HSV_YELLOW 43, 255, 255
-#define HSV_CHARTREUSE 64, 255, 255
-#define HSV_GREEN 85, 255, 255
-#define HSV_SPRINGGREEN 106, 255, 255
-#define HSV_TURQUOISE 123, 90, 112
-#define HSV_TEAL 128, 255, 128
-#define HSV_CYAN 128, 255, 255
-#define HSV_AZURE 132, 102, 255
-#define HSV_BLUE 170, 255, 255
-#define HSV_PURPLE 191, 255, 255
-#define HSV_MAGENTA 213, 255, 255
-#define HSV_PINK 234, 128, 255
-
+#define HSV_WHITE 0, 0, 255
+#define HSV_RED 0, 255, 255
+#define HSV_CORAL 11, 176, 255
+#define HSV_ORANGE 28, 255, 255
+#define HSV_GOLDENROD 30, 218, 218
+#define HSV_GOLD 36, 255, 255
+#define HSV_YELLOW 43, 255, 255
+#define HSV_CHARTREUSE 64, 255, 255
+#define HSV_GREEN 85, 255, 255
+#define HSV_SPRINGGREEN 106, 255, 255
+#define HSV_TURQUOISE 123, 90, 112
+#define HSV_TEAL 128, 255, 128
+#define HSV_CYAN 128, 255, 255
+#define HSV_AZURE 132, 102, 255
+#define HSV_BLUE 170, 255, 255
+#define HSV_PURPLE 191, 255, 255
+#define HSV_MAGENTA 213, 255, 255
+#define HSV_PINK 234, 128, 255
/*
########################################################################################
@@ -71,105 +70,105 @@
*/
/* SET RGB List */
-#define rgblight_setrgb_white() rgblight_setrgb (RGB_WHITE)
-#define rgblight_setrgb_red() rgblight_setrgb (RGB_RED)
-#define rgblight_setrgb_coral() rgblight_setrgb (RGB_CORAL)
-#define rgblight_setrgb_orange() rgblight_setrgb (RGB_ORANGE)
-#define rgblight_setrgb_goldenrod() rgblight_setrgb (RGB_GOLDENROD)
-#define rgblight_setrgb_gold() rgblight_setrgb (RGB_GOLD)
-#define rgblight_setrgb_yellow() rgblight_setrgb (RGB_YELLOW)
-#define rgblight_setrgb_chartreuse() rgblight_setrgb (RGB_CHARTREUSE)
-#define rgblight_setrgb_green() rgblight_setrgb (RGB_GREEN)
-#define rgblight_setrgb_springgreen() rgblight_setrgb (RGB_SPRINGGREEN)
-#define rgblight_setrgb_turquoise() rgblight_setrgb (RGB_TURQUOISE)
-#define rgblight_setrgb_teal() rgblight_setrgb (RGB_TEAL)
-#define rgblight_setrgb_cyan() rgblight_setrgb (RGB_CYAN)
-#define rgblight_setrgb_azure() rgblight_setrgb (RGB_AZURE)
-#define rgblight_setrgb_blue() rgblight_setrgb (RGB_BLUE)
-#define rgblight_setrgb_purple() rgblight_setrgb (RGB_PURPLE)
-#define rgblight_setrgb_magenta() rgblight_setrgb (RGB_MAGENTA)
-#define rgblight_setrgb_pink() rgblight_setrgb (RGB_PINK)
+#define rgblight_setrgb_white() rgblight_setrgb(RGB_WHITE)
+#define rgblight_setrgb_red() rgblight_setrgb(RGB_RED)
+#define rgblight_setrgb_coral() rgblight_setrgb(RGB_CORAL)
+#define rgblight_setrgb_orange() rgblight_setrgb(RGB_ORANGE)
+#define rgblight_setrgb_goldenrod() rgblight_setrgb(RGB_GOLDENROD)
+#define rgblight_setrgb_gold() rgblight_setrgb(RGB_GOLD)
+#define rgblight_setrgb_yellow() rgblight_setrgb(RGB_YELLOW)
+#define rgblight_setrgb_chartreuse() rgblight_setrgb(RGB_CHARTREUSE)
+#define rgblight_setrgb_green() rgblight_setrgb(RGB_GREEN)
+#define rgblight_setrgb_springgreen() rgblight_setrgb(RGB_SPRINGGREEN)
+#define rgblight_setrgb_turquoise() rgblight_setrgb(RGB_TURQUOISE)
+#define rgblight_setrgb_teal() rgblight_setrgb(RGB_TEAL)
+#define rgblight_setrgb_cyan() rgblight_setrgb(RGB_CYAN)
+#define rgblight_setrgb_azure() rgblight_setrgb(RGB_AZURE)
+#define rgblight_setrgb_blue() rgblight_setrgb(RGB_BLUE)
+#define rgblight_setrgb_purple() rgblight_setrgb(RGB_PURPLE)
+#define rgblight_setrgb_magenta() rgblight_setrgb(RGB_MAGENTA)
+#define rgblight_setrgb_pink() rgblight_setrgb(RGB_PINK)
/* SET RGB List */
-#define rgblight_setrgb_white_at(at) rgblight_setrgb_at (RGB_WHITE, at)
-#define rgblight_setrgb_red_at(at) rgblight_setrgb_at (RGB_RED, at)
-#define rgblight_setrgb_coral_at(at) rgblight_setrgb_at (RGB_CORAL, at)
-#define rgblight_setrgb_orange_at(at) rgblight_setrgb_at (RGB_ORANGE at)
-#define rgblight_setrgb_goldenrod_at(at) rgblight_setrgb_at (RGB_GOLDENROD, at)
-#define rgblight_setrgb_gold_at(at) rgblight_setrgb_at (RGB_GOLD, at)
-#define rgblight_setrgb_yellow_at(at) rgblight_setrgb_at (RGB_YELLOW, at)
-#define rgblight_setrgb_chartreuse_at(at) rgblight_setrgb_at (RGB_CHARTREUSE, at)
-#define rgblight_setrgb_green_at(at) rgblight_setrgb_at (RGB_GREEN, at)
-#define rgblight_setrgb_springgreen_at(at) rgblight_setrgb_at (RGB_SPRINGGREEN, at)
-#define rgblight_setrgb_turquoise_at(at) rgblight_setrgb_at (RGB_TURQUOISE, at)
-#define rgblight_setrgb_teal_at(at) rgblight_setrgb_at (RGB_TEAL, at)
-#define rgblight_setrgb_cyan_at(at) rgblight_setrgb_at (RGB_CYAN, at)
-#define rgblight_setrgb_azure_at(at) rgblight_setrgb_at (RGB_AZURE, at)
-#define rgblight_setrgb_blue_at(at) rgblight_setrgb_at (RGB_BLUE, at)
-#define rgblight_setrgb_purple_at(at) rgblight_setrgb_at (RGB_PURPLE, at)
-#define rgblight_setrgb_magenta_at(at) rgblight_setrgb_at (RGB_MAGENTA, at)
-#define rgblight_setrgb_pink_at(at) rgblight_setrgb_at (RGB_PINK, at)
+#define rgblight_setrgb_white_at(at) rgblight_setrgb_at(RGB_WHITE, at)
+#define rgblight_setrgb_red_at(at) rgblight_setrgb_at(RGB_RED, at)
+#define rgblight_setrgb_coral_at(at) rgblight_setrgb_at(RGB_CORAL, at)
+#define rgblight_setrgb_orange_at(at) rgblight_setrgb_at(RGB_ORANGE at)
+#define rgblight_setrgb_goldenrod_at(at) rgblight_setrgb_at(RGB_GOLDENROD, at)
+#define rgblight_setrgb_gold_at(at) rgblight_setrgb_at(RGB_GOLD, at)
+#define rgblight_setrgb_yellow_at(at) rgblight_setrgb_at(RGB_YELLOW, at)
+#define rgblight_setrgb_chartreuse_at(at) rgblight_setrgb_at(RGB_CHARTREUSE, at)
+#define rgblight_setrgb_green_at(at) rgblight_setrgb_at(RGB_GREEN, at)
+#define rgblight_setrgb_springgreen_at(at) rgblight_setrgb_at(RGB_SPRINGGREEN, at)
+#define rgblight_setrgb_turquoise_at(at) rgblight_setrgb_at(RGB_TURQUOISE, at)
+#define rgblight_setrgb_teal_at(at) rgblight_setrgb_at(RGB_TEAL, at)
+#define rgblight_setrgb_cyan_at(at) rgblight_setrgb_at(RGB_CYAN, at)
+#define rgblight_setrgb_azure_at(at) rgblight_setrgb_at(RGB_AZURE, at)
+#define rgblight_setrgb_blue_at(at) rgblight_setrgb_at(RGB_BLUE, at)
+#define rgblight_setrgb_purple_at(at) rgblight_setrgb_at(RGB_PURPLE, at)
+#define rgblight_setrgb_magenta_at(at) rgblight_setrgb_at(RGB_MAGENTA, at)
+#define rgblight_setrgb_pink_at(at) rgblight_setrgb_at(RGB_PINK, at)
/* SET HSV List */
-#define rgblight_sethsv_white() rgblight_sethsv (HSV_WHITE)
-#define rgblight_sethsv_red() rgblight_sethsv (HSV_RED)
-#define rgblight_sethsv_coral() rgblight_sethsv (HSV_CORAL)
-#define rgblight_sethsv_orange() rgblight_sethsv (HSV_ORANGE)
-#define rgblight_sethsv_goldenrod() rgblight_sethsv (HSV_GOLDENROD)
-#define rgblight_sethsv_gold() rgblight_sethsv (HSV_GOLD)
-#define rgblight_sethsv_yellow() rgblight_sethsv (HSV_YELLOW)
-#define rgblight_sethsv_chartreuse() rgblight_sethsv (HSV_CHARTREUSE)
-#define rgblight_sethsv_green() rgblight_sethsv (HSV_GREEN)
-#define rgblight_sethsv_springgreen() rgblight_sethsv (HSV_SPRINGGREEN)
-#define rgblight_sethsv_turquoise() rgblight_sethsv (HSV_TURQUOISE)
-#define rgblight_sethsv_teal() rgblight_sethsv (HSV_TEAL)
-#define rgblight_sethsv_cyan() rgblight_sethsv (HSV_CYAN)
-#define rgblight_sethsv_azure() rgblight_sethsv (HSV_AZURE)
-#define rgblight_sethsv_blue() rgblight_sethsv (HSV_BLUE)
-#define rgblight_sethsv_purple() rgblight_sethsv (HSV_PURPLE)
-#define rgblight_sethsv_magenta() rgblight_sethsv (HSV_MAGENTA)
-#define rgblight_sethsv_pink() rgblight_sethsv (HSV_PINK)
+#define rgblight_sethsv_white() rgblight_sethsv(HSV_WHITE)
+#define rgblight_sethsv_red() rgblight_sethsv(HSV_RED)
+#define rgblight_sethsv_coral() rgblight_sethsv(HSV_CORAL)
+#define rgblight_sethsv_orange() rgblight_sethsv(HSV_ORANGE)
+#define rgblight_sethsv_goldenrod() rgblight_sethsv(HSV_GOLDENROD)
+#define rgblight_sethsv_gold() rgblight_sethsv(HSV_GOLD)
+#define rgblight_sethsv_yellow() rgblight_sethsv(HSV_YELLOW)
+#define rgblight_sethsv_chartreuse() rgblight_sethsv(HSV_CHARTREUSE)
+#define rgblight_sethsv_green() rgblight_sethsv(HSV_GREEN)
+#define rgblight_sethsv_springgreen() rgblight_sethsv(HSV_SPRINGGREEN)
+#define rgblight_sethsv_turquoise() rgblight_sethsv(HSV_TURQUOISE)
+#define rgblight_sethsv_teal() rgblight_sethsv(HSV_TEAL)
+#define rgblight_sethsv_cyan() rgblight_sethsv(HSV_CYAN)
+#define rgblight_sethsv_azure() rgblight_sethsv(HSV_AZURE)
+#define rgblight_sethsv_blue() rgblight_sethsv(HSV_BLUE)
+#define rgblight_sethsv_purple() rgblight_sethsv(HSV_PURPLE)
+#define rgblight_sethsv_magenta() rgblight_sethsv(HSV_MAGENTA)
+#define rgblight_sethsv_pink() rgblight_sethsv(HSV_PINK)
/* SET HSV List */
/* If you're doing layer indication, this is best, as it won't */
/* write to the eeprom, since it's limited (very high value). */
/* If you want to use modes with this (since you can), then you */
/* want to use rgblight_mode_noeeprom(x) instead. */
-#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom (HSV_WHITE)
-#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom (HSV_RED)
-#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom (HSV_CORAL)
-#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom (HSV_ORANGE)
-#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom (HSV_GOLDENROD)
-#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom (HSV_GOLD)
-#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom (HSV_YELLOW)
-#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom (HSV_CHARTREUSE)
-#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom (HSV_GREEN)
-#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom (HSV_SPRINGGREEN)
-#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom (HSV_TURQUOISE)
-#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom (HSV_TEAL)
-#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom (HSV_CYAN)
-#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom (HSV_AZURE)
-#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom (HSV_BLUE)
-#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom (HSV_PURPLE)
-#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom (HSV_MAGENTA)
-#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom (HSV_PINK)
+#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom(HSV_WHITE)
+#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom(HSV_RED)
+#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom(HSV_CORAL)
+#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom(HSV_ORANGE)
+#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom(HSV_GOLDENROD)
+#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom(HSV_GOLD)
+#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom(HSV_YELLOW)
+#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom(HSV_CHARTREUSE)
+#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom(HSV_GREEN)
+#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom(HSV_SPRINGGREEN)
+#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom(HSV_TURQUOISE)
+#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom(HSV_TEAL)
+#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom(HSV_CYAN)
+#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom(HSV_AZURE)
+#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom(HSV_BLUE)
+#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom(HSV_PURPLE)
+#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom(HSV_MAGENTA)
+#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom(HSV_PINK)
/* SET HSV List */
-#define rgblight_sethsv_white_at(at) rgblight_sethsv_at (HSV_WHITE, at)
-#define rgblight_sethsv_red_at(at) rgblight_sethsv_at (HSV_RED, at)
-#define rgblight_sethsv_coral_at(at) rgblight_sethsv_at (HSV_CORAL, at)
-#define rgblight_sethsv_orange_at(at) rgblight_sethsv_at (HSV_ORANGE, at)
-#define rgblight_sethsv_goldenrod_at(at) rgblight_sethsv_at (HSV_GOLDENROD, at)
-#define rgblight_sethsv_gold_at(at) rgblight_sethsv_at (HSV_GOLD, at)
-#define rgblight_sethsv_yellow_at(at) rgblight_sethsv_at (HSV_YELLOW, at)
-#define rgblight_sethsv_chartreuse_at(at) rgblight_sethsv_at (HSV_CHARTREUSE, at)
-#define rgblight_sethsv_green_at(at) rgblight_sethsv_at (HSV_GREEN, at)
-#define rgblight_sethsv_springgreen_at(at) rgblight_sethsv_at (HSV_SPRINGGREEN, at)
-#define rgblight_sethsv_turquoise_at(at) rgblight_sethsv_at (HSV_TURQUOISE, at)
-#define rgblight_sethsv_teal_at(at) rgblight_sethsv_at (HSV_TEAL, at)
-#define rgblight_sethsv_cyan_at(at) rgblight_sethsv_at (HSV_CYAN, at)
-#define rgblight_sethsv_azure_at(at) rgblight_sethsv_at (HSV_AZURE, at)
-#define rgblight_sethsv_blue_at(at) rgblight_sethsv_at (HSV_BLUE, at)
-#define rgblight_sethsv_purple_at(at) rgblight_sethsv_at (HSV_PURPLE, at)
-#define rgblight_sethsv_magenta_at(at) rgblight_sethsv_at (HSV_MAGENTA, at)
-#define rgblight_sethsv_pink_at(at) rgblight_sethsv_at (HSV_PINK, at)
+#define rgblight_sethsv_white_at(at) rgblight_sethsv_at(HSV_WHITE, at)
+#define rgblight_sethsv_red_at(at) rgblight_sethsv_at(HSV_RED, at)
+#define rgblight_sethsv_coral_at(at) rgblight_sethsv_at(HSV_CORAL, at)
+#define rgblight_sethsv_orange_at(at) rgblight_sethsv_at(HSV_ORANGE, at)
+#define rgblight_sethsv_goldenrod_at(at) rgblight_sethsv_at(HSV_GOLDENROD, at)
+#define rgblight_sethsv_gold_at(at) rgblight_sethsv_at(HSV_GOLD, at)
+#define rgblight_sethsv_yellow_at(at) rgblight_sethsv_at(HSV_YELLOW, at)
+#define rgblight_sethsv_chartreuse_at(at) rgblight_sethsv_at(HSV_CHARTREUSE, at)
+#define rgblight_sethsv_green_at(at) rgblight_sethsv_at(HSV_GREEN, at)
+#define rgblight_sethsv_springgreen_at(at) rgblight_sethsv_at(HSV_SPRINGGREEN, at)
+#define rgblight_sethsv_turquoise_at(at) rgblight_sethsv_at(HSV_TURQUOISE, at)
+#define rgblight_sethsv_teal_at(at) rgblight_sethsv_at(HSV_TEAL, at)
+#define rgblight_sethsv_cyan_at(at) rgblight_sethsv_at(HSV_CYAN, at)
+#define rgblight_sethsv_azure_at(at) rgblight_sethsv_at(HSV_AZURE, at)
+#define rgblight_sethsv_blue_at(at) rgblight_sethsv_at(HSV_BLUE, at)
+#define rgblight_sethsv_purple_at(at) rgblight_sethsv_at(HSV_PURPLE, at)
+#define rgblight_sethsv_magenta_at(at) rgblight_sethsv_at(HSV_MAGENTA, at)
+#define rgblight_sethsv_pink_at(at) rgblight_sethsv_at(HSV_PINK, at)
diff --git a/quantum/rgblight_modes.h b/quantum/rgblight_modes.h
index 8a8f9bdda9..40c9ce4980 100644
--- a/quantum/rgblight_modes.h
+++ b/quantum/rgblight_modes.h
@@ -1,62 +1,62 @@
#ifdef _RGBM_SINGLE_STATIC
- _RGBM_SINGLE_STATIC( STATIC_LIGHT )
- #ifdef RGBLIGHT_EFFECT_BREATHING
- _RGBM_MULTI_DYNAMIC( BREATHING )
- _RGBM_TMP_DYNAMIC( breathing_3, BREATHING )
- _RGBM_TMP_DYNAMIC( breathing_4, BREATHING )
- _RGBM_TMP_DYNAMIC( BREATHING_end, BREATHING )
- #endif
- #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
- _RGBM_MULTI_DYNAMIC( RAINBOW_MOOD )
- _RGBM_TMP_DYNAMIC( rainbow_mood_7, RAINBOW_MOOD )
- _RGBM_TMP_DYNAMIC( RAINBOW_MOOD_end, RAINBOW_MOOD )
- #endif
- #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
- _RGBM_MULTI_DYNAMIC( RAINBOW_SWIRL )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_10, RAINBOW_SWIRL )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_11, RAINBOW_SWIRL )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_12, RAINBOW_SWIRL )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_13, RAINBOW_SWIRL )
- _RGBM_TMP_DYNAMIC( RAINBOW_SWIRL_end, RAINBOW_SWIRL )
- #endif
- #ifdef RGBLIGHT_EFFECT_SNAKE
- _RGBM_MULTI_DYNAMIC( SNAKE )
- _RGBM_TMP_DYNAMIC( snake_16, SNAKE )
- _RGBM_TMP_DYNAMIC( snake_17, SNAKE )
- _RGBM_TMP_DYNAMIC( snake_18, SNAKE )
- _RGBM_TMP_DYNAMIC( snake_19, SNAKE )
- _RGBM_TMP_DYNAMIC( SNAKE_end, SNAKE )
- #endif
- #ifdef RGBLIGHT_EFFECT_KNIGHT
- _RGBM_MULTI_DYNAMIC( KNIGHT )
- _RGBM_TMP_DYNAMIC( knight_22, KNIGHT )
- _RGBM_TMP_DYNAMIC( KNIGHT_end, KNIGHT )
- #endif
- #ifdef RGBLIGHT_EFFECT_CHRISTMAS
- _RGBM_SINGLE_DYNAMIC( CHRISTMAS )
- #endif
- #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
- _RGBM_MULTI_STATIC( STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_26, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_27, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_28, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_29, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_30, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_31, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_32, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_33, STATIC_GRADIENT )
- _RGBM_TMP_STATIC( STATIC_GRADIENT_end, STATIC_GRADIENT )
- #endif
- #ifdef RGBLIGHT_EFFECT_RGB_TEST
- _RGBM_SINGLE_DYNAMIC( RGB_TEST )
- #endif
- #ifdef RGBLIGHT_EFFECT_ALTERNATING
- _RGBM_SINGLE_DYNAMIC( ALTERNATING )
- #endif
- //// Add a new mode here.
- // #ifdef RGBLIGHT_EFFECT_<name>
- // _RGBM_<SINGLE|MULTI>_<STATIC|DYNAMIC>( <name> )
- // #endif
+_RGBM_SINGLE_STATIC(STATIC_LIGHT)
+# ifdef RGBLIGHT_EFFECT_BREATHING
+_RGBM_MULTI_DYNAMIC(BREATHING)
+_RGBM_TMP_DYNAMIC(breathing_3, BREATHING)
+_RGBM_TMP_DYNAMIC(breathing_4, BREATHING)
+_RGBM_TMP_DYNAMIC(BREATHING_end, BREATHING)
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
+_RGBM_MULTI_DYNAMIC(RAINBOW_MOOD)
+_RGBM_TMP_DYNAMIC(rainbow_mood_7, RAINBOW_MOOD)
+_RGBM_TMP_DYNAMIC(RAINBOW_MOOD_end, RAINBOW_MOOD)
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
+_RGBM_MULTI_DYNAMIC(RAINBOW_SWIRL)
+_RGBM_TMP_DYNAMIC(rainbow_swirl_10, RAINBOW_SWIRL)
+_RGBM_TMP_DYNAMIC(rainbow_swirl_11, RAINBOW_SWIRL)
+_RGBM_TMP_DYNAMIC(rainbow_swirl_12, RAINBOW_SWIRL)
+_RGBM_TMP_DYNAMIC(rainbow_swirl_13, RAINBOW_SWIRL)
+_RGBM_TMP_DYNAMIC(RAINBOW_SWIRL_end, RAINBOW_SWIRL)
+# endif
+# ifdef RGBLIGHT_EFFECT_SNAKE
+_RGBM_MULTI_DYNAMIC(SNAKE)
+_RGBM_TMP_DYNAMIC(snake_16, SNAKE)
+_RGBM_TMP_DYNAMIC(snake_17, SNAKE)
+_RGBM_TMP_DYNAMIC(snake_18, SNAKE)
+_RGBM_TMP_DYNAMIC(snake_19, SNAKE)
+_RGBM_TMP_DYNAMIC(SNAKE_end, SNAKE)
+# endif
+# ifdef RGBLIGHT_EFFECT_KNIGHT
+_RGBM_MULTI_DYNAMIC(KNIGHT)
+_RGBM_TMP_DYNAMIC(knight_22, KNIGHT)
+_RGBM_TMP_DYNAMIC(KNIGHT_end, KNIGHT)
+# endif
+# ifdef RGBLIGHT_EFFECT_CHRISTMAS
+_RGBM_SINGLE_DYNAMIC(CHRISTMAS)
+# endif
+# ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
+_RGBM_MULTI_STATIC(STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_26, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_27, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_28, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_29, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_30, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_31, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_32, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(static_gradient_33, STATIC_GRADIENT)
+_RGBM_TMP_STATIC(STATIC_GRADIENT_end, STATIC_GRADIENT)
+# endif
+# ifdef RGBLIGHT_EFFECT_RGB_TEST
+_RGBM_SINGLE_DYNAMIC(RGB_TEST)
+# endif
+# ifdef RGBLIGHT_EFFECT_ALTERNATING
+_RGBM_SINGLE_DYNAMIC(ALTERNATING)
+# endif
+//// Add a new mode here.
+// #ifdef RGBLIGHT_EFFECT_<name>
+// _RGBM_<SINGLE|MULTI>_<STATIC|DYNAMIC>( <name> )
+// #endif
#endif
#undef _RGBM_SINGLE_STATIC
diff --git a/quantum/rgblight_post_config.h b/quantum/rgblight_post_config.h
index 048746c4b7..3c14cb6109 100644
--- a/quantum/rgblight_post_config.h
+++ b/quantum/rgblight_post_config.h
@@ -1,5 +1,5 @@
#if defined(RGBLED_SPLIT) && !defined(RGBLIGHT_SPLIT)
- // When RGBLED_SPLIT is defined,
- // it is considered that RGBLIGHT_SPLIT is defined implicitly.
- #define RGBLIGHT_SPLIT
+// When RGBLED_SPLIT is defined,
+// it is considered that RGBLIGHT_SPLIT is defined implicitly.
+# define RGBLIGHT_SPLIT
#endif
diff --git a/quantum/rgblight_reconfig.h b/quantum/rgblight_reconfig.h
index 11bd4fd118..4b9d6c4c2f 100644
--- a/quantum/rgblight_reconfig.h
+++ b/quantum/rgblight_reconfig.h
@@ -2,35 +2,28 @@
#define RGBLIGHT_RECONFIG_H
#ifdef RGBLIGHT_ANIMATIONS
- // for backward compatibility
- #define RGBLIGHT_EFFECT_BREATHING
- #define RGBLIGHT_EFFECT_RAINBOW_MOOD
- #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
- #define RGBLIGHT_EFFECT_SNAKE
- #define RGBLIGHT_EFFECT_KNIGHT
- #define RGBLIGHT_EFFECT_CHRISTMAS
- #define RGBLIGHT_EFFECT_STATIC_GRADIENT
- #define RGBLIGHT_EFFECT_RGB_TEST
- #define RGBLIGHT_EFFECT_ALTERNATING
+// for backward compatibility
+# define RGBLIGHT_EFFECT_BREATHING
+# define RGBLIGHT_EFFECT_RAINBOW_MOOD
+# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
+# define RGBLIGHT_EFFECT_SNAKE
+# define RGBLIGHT_EFFECT_KNIGHT
+# define RGBLIGHT_EFFECT_CHRISTMAS
+# define RGBLIGHT_EFFECT_STATIC_GRADIENT
+# define RGBLIGHT_EFFECT_RGB_TEST
+# define RGBLIGHT_EFFECT_ALTERNATING
#endif
#ifdef RGBLIGHT_STATIC_PATTERNS
- #define RGBLIGHT_EFFECT_STATIC_GRADIENT
+# define RGBLIGHT_EFFECT_STATIC_GRADIENT
#endif
// check dynamic animation effects chose ?
-#if defined(RGBLIGHT_EFFECT_BREATHING) || \
- defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || \
- defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || \
- defined(RGBLIGHT_EFFECT_SNAKE) || \
- defined(RGBLIGHT_EFFECT_KNIGHT) || \
- defined(RGBLIGHT_EFFECT_CHRISTMAS) || \
- defined(RGBLIGHT_EFFECT_RGB_TEST) || \
- defined(RGBLIGHT_EFFECT_ALTERNATING)
- #define RGBLIGHT_USE_TIMER
- #ifndef RGBLIGHT_ANIMATIONS
- #define RGBLIGHT_ANIMATIONS // for backward compatibility
- #endif
+#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) || defined(RGBLIGHT_EFFECT_CHRISTMAS) || defined(RGBLIGHT_EFFECT_RGB_TEST) || defined(RGBLIGHT_EFFECT_ALTERNATING)
+# define RGBLIGHT_USE_TIMER
+# ifndef RGBLIGHT_ANIMATIONS
+# define RGBLIGHT_ANIMATIONS // for backward compatibility
+# endif
#endif
-#endif // RGBLIGHT_RECONFIG_H
+#endif // RGBLIGHT_RECONFIG_H
diff --git a/quantum/send_string_keycodes.h b/quantum/send_string_keycodes.h
index 82195f6e55..e71790a1dc 100644
--- a/quantum/send_string_keycodes.h
+++ b/quantum/send_string_keycodes.h
@@ -1,207 +1,207 @@
#ifndef SEND_STRING_KEYCODES
#define SEND_STRING_KEYCODES
-#define X_NO 00
-#define X_ROLL_OVER 01
-#define X_POST_FAIL 02
-#define X_UNDEFINED 03
-#define X_A 04
-#define X_B 05
-#define X_C 06
-#define X_D 07
-#define X_E 08
-#define X_F 09
-#define X_G 0a
-#define X_H 0b
-#define X_I 0c
-#define X_J 0d
-#define X_K 0e
-#define X_L 0f
-#define X_M 10
-#define X_N 11
-#define X_O 12
-#define X_P 13
-#define X_Q 14
-#define X_R 15
-#define X_S 16
-#define X_T 17
-#define X_U 18
-#define X_V 19
-#define X_W 1a
-#define X_X 1b
-#define X_Y 1c
-#define X_Z 1d
-#define X_1 1e
-#define X_2 1f
-#define X_3 20
-#define X_4 21
-#define X_5 22
-#define X_6 23
-#define X_7 24
-#define X_8 25
-#define X_9 26
-#define X_0 27
-#define X_ENTER 28
-#define X_ESCAPE 29
-#define X_BSPACE 2a
-#define X_TAB 2b
-#define X_SPACE 2c
-#define X_MINUS 2d
-#define X_EQUAL 2e
-#define X_LBRACKET 2f
-#define X_RBRACKET 30
-#define X_BSLASH 31
-#define X_NONUS_HASH 32
-#define X_SCOLON 33
-#define X_QUOTE 34
-#define X_GRAVE 35
-#define X_COMMA 36
-#define X_DOT 37
-#define X_SLASH 38
-#define X_CAPSLOCK 39
-#define X_F1 3a
-#define X_F2 3b
-#define X_F3 3c
-#define X_F4 3d
-#define X_F5 3e
-#define X_F6 3f
-#define X_F7 40
-#define X_F8 41
-#define X_F9 42
-#define X_F10 43
-#define X_F11 44
-#define X_F12 45
-#define X_PSCREEN 46
-#define X_SCROLLLOCK 47
-#define X_PAUSE 48
-#define X_INSERT 49
-#define X_HOME 4a
-#define X_PGUP 4b
-#define X_DELETE 4c
-#define X_END 4d
-#define X_PGDOWN 4e
-#define X_RIGHT 4f
-#define X_LEFT 50
-#define X_DOWN 51
-#define X_UP 52
-#define X_NUMLOCK 53
-#define X_KP_SLASH 54
-#define X_KP_ASTERISK 55
-#define X_KP_MINUS 56
-#define X_KP_PLUS 57
-#define X_KP_ENTER 58
-#define X_KP_1 59
-#define X_KP_2 5a
-#define X_KP_3 5b
-#define X_KP_4 5c
-#define X_KP_5 5d
-#define X_KP_6 5e
-#define X_KP_7 5f
-#define X_KP_8 60
-#define X_KP_9 61
-#define X_KP_0 62
-#define X_KP_DOT 63
-#define X_NONUS_BSLASH 64
-#define X_APPLICATION 65
-#define X_POWER 66
-#define X_KP_EQUAL 67
-#define X_F13 68
-#define X_F14 69
-#define X_F15 6a
-#define X_F16 6b
-#define X_F17 6c
-#define X_F18 6d
-#define X_F19 6e
-#define X_F20 6f
-#define X_F21 70
-#define X_F22 71
-#define X_F23 72
-#define X_F24 73
-#define X_EXECUTE 74
-#define X_HELP 75
-#define X_MENU 76
-#define X_SELECT 77
-#define X_STOP 78
-#define X_AGAIN 79
-#define X_UNDO 7a
-#define X_CUT 7b
-#define X_COPY 7c
-#define X_PASTE 7d
-#define X_FIND 7e
-#define X__MUTE 7f
-#define X__VOLUP 80
-#define X__VOLDOWN 81
-#define X_LOCKING_CAPS 82
-#define X_LOCKING_NUM 83
-#define X_LOCKING_SCROLL 84
-#define X_KP_COMMA 85
-#define X_KP_EQUAL_AS400 86
-#define X_INT1 87
-#define X_INT2 88
-#define X_INT3 89
-#define X_INT4 8a
-#define X_INT5 8b
-#define X_INT6 8c
-#define X_INT7 8d
-#define X_INT8 8e
-#define X_INT9 8f
-#define X_LANG1 90
-#define X_LANG2 91
-#define X_LANG3 92
-#define X_LANG4 93
-#define X_LANG5 94
-#define X_LANG6 95
-#define X_LANG7 96
-#define X_LANG8 97
-#define X_LANG9 98
-#define X_ALT_ERASE 99
-#define X_SYSREQ 9a
-#define X_CANCEL 9b
-#define X_CLEAR 9c
-#define X_PRIOR 9d
-#define X_RETURN 9e
-#define X_SEPARATOR 9f
-#define X_OUT a0
-#define X_OPER a1
-#define X_CLEAR_AGAIN a2
-#define X_CRSEL a3
-#define X_EXSEL a4
+#define X_NO 00
+#define X_ROLL_OVER 01
+#define X_POST_FAIL 02
+#define X_UNDEFINED 03
+#define X_A 04
+#define X_B 05
+#define X_C 06
+#define X_D 07
+#define X_E 08
+#define X_F 09
+#define X_G 0a
+#define X_H 0b
+#define X_I 0c
+#define X_J 0d
+#define X_K 0e
+#define X_L 0f
+#define X_M 10
+#define X_N 11
+#define X_O 12
+#define X_P 13
+#define X_Q 14
+#define X_R 15
+#define X_S 16
+#define X_T 17
+#define X_U 18
+#define X_V 19
+#define X_W 1a
+#define X_X 1b
+#define X_Y 1c
+#define X_Z 1d
+#define X_1 1e
+#define X_2 1f
+#define X_3 20
+#define X_4 21
+#define X_5 22
+#define X_6 23
+#define X_7 24
+#define X_8 25
+#define X_9 26
+#define X_0 27
+#define X_ENTER 28
+#define X_ESCAPE 29
+#define X_BSPACE 2a
+#define X_TAB 2b
+#define X_SPACE 2c
+#define X_MINUS 2d
+#define X_EQUAL 2e
+#define X_LBRACKET 2f
+#define X_RBRACKET 30
+#define X_BSLASH 31
+#define X_NONUS_HASH 32
+#define X_SCOLON 33
+#define X_QUOTE 34
+#define X_GRAVE 35
+#define X_COMMA 36
+#define X_DOT 37
+#define X_SLASH 38
+#define X_CAPSLOCK 39
+#define X_F1 3a
+#define X_F2 3b
+#define X_F3 3c
+#define X_F4 3d
+#define X_F5 3e
+#define X_F6 3f
+#define X_F7 40
+#define X_F8 41
+#define X_F9 42
+#define X_F10 43
+#define X_F11 44
+#define X_F12 45
+#define X_PSCREEN 46
+#define X_SCROLLLOCK 47
+#define X_PAUSE 48
+#define X_INSERT 49
+#define X_HOME 4a
+#define X_PGUP 4b
+#define X_DELETE 4c
+#define X_END 4d
+#define X_PGDOWN 4e
+#define X_RIGHT 4f
+#define X_LEFT 50
+#define X_DOWN 51
+#define X_UP 52
+#define X_NUMLOCK 53
+#define X_KP_SLASH 54
+#define X_KP_ASTERISK 55
+#define X_KP_MINUS 56
+#define X_KP_PLUS 57
+#define X_KP_ENTER 58
+#define X_KP_1 59
+#define X_KP_2 5a
+#define X_KP_3 5b
+#define X_KP_4 5c
+#define X_KP_5 5d
+#define X_KP_6 5e
+#define X_KP_7 5f
+#define X_KP_8 60
+#define X_KP_9 61
+#define X_KP_0 62
+#define X_KP_DOT 63
+#define X_NONUS_BSLASH 64
+#define X_APPLICATION 65
+#define X_POWER 66
+#define X_KP_EQUAL 67
+#define X_F13 68
+#define X_F14 69
+#define X_F15 6a
+#define X_F16 6b
+#define X_F17 6c
+#define X_F18 6d
+#define X_F19 6e
+#define X_F20 6f
+#define X_F21 70
+#define X_F22 71
+#define X_F23 72
+#define X_F24 73
+#define X_EXECUTE 74
+#define X_HELP 75
+#define X_MENU 76
+#define X_SELECT 77
+#define X_STOP 78
+#define X_AGAIN 79
+#define X_UNDO 7a
+#define X_CUT 7b
+#define X_COPY 7c
+#define X_PASTE 7d
+#define X_FIND 7e
+#define X__MUTE 7f
+#define X__VOLUP 80
+#define X__VOLDOWN 81
+#define X_LOCKING_CAPS 82
+#define X_LOCKING_NUM 83
+#define X_LOCKING_SCROLL 84
+#define X_KP_COMMA 85
+#define X_KP_EQUAL_AS400 86
+#define X_INT1 87
+#define X_INT2 88
+#define X_INT3 89
+#define X_INT4 8a
+#define X_INT5 8b
+#define X_INT6 8c
+#define X_INT7 8d
+#define X_INT8 8e
+#define X_INT9 8f
+#define X_LANG1 90
+#define X_LANG2 91
+#define X_LANG3 92
+#define X_LANG4 93
+#define X_LANG5 94
+#define X_LANG6 95
+#define X_LANG7 96
+#define X_LANG8 97
+#define X_LANG9 98
+#define X_ALT_ERASE 99
+#define X_SYSREQ 9a
+#define X_CANCEL 9b
+#define X_CLEAR 9c
+#define X_PRIOR 9d
+#define X_RETURN 9e
+#define X_SEPARATOR 9f
+#define X_OUT a0
+#define X_OPER a1
+#define X_CLEAR_AGAIN a2
+#define X_CRSEL a3
+#define X_EXSEL a4
/* Modifiers */
-#define X_LCTRL e0
-#define X_LSHIFT e1
-#define X_LALT e2
-#define X_LGUI e3
-#define X_RCTRL e4
-#define X_RSHIFT e5
-#define X_RALT e6
-#define X_RGUI e7
+#define X_LCTRL e0
+#define X_LSHIFT e1
+#define X_LALT e2
+#define X_LGUI e3
+#define X_RCTRL e4
+#define X_RSHIFT e5
+#define X_RALT e6
+#define X_RGUI e7
/* System Control */
-#define X_SYSTEM_POWER a5
-#define X_SYSTEM_SLEEP a6
-#define X_SYSTEM_WAKE a7
+#define X_SYSTEM_POWER a5
+#define X_SYSTEM_SLEEP a6
+#define X_SYSTEM_WAKE a7
/* Media Control */
-#define X_AUDIO_MUTE a8
-#define X_AUDIO_VOL_UP a9
-#define X_AUDIO_VOL_DOWN aa
-#define X_MEDIA_NEXT_TRACK ab
-#define X_MEDIA_PREV_TRACK ac
-#define X_MEDIA_STOP ad
-#define X_MEDIA_PLAY_PAUSE ae
-#define X_MEDIA_SELECT af
-#define X_MEDIA_EJECT b0
-#define X_MAIL b1
-#define X_CALCULATOR b2
-#define X_MY_COMPUTER b3
-#define X_WWW_SEARCH b4
-#define X_WWW_HOME b5
-#define X_WWW_BACK b6
-#define X_WWW_FORWARD b7
-#define X_WWW_STOP b8
-#define X_WWW_REFRESH b9
-#define X_WWW_FAVORITES ba
+#define X_AUDIO_MUTE a8
+#define X_AUDIO_VOL_UP a9
+#define X_AUDIO_VOL_DOWN aa
+#define X_MEDIA_NEXT_TRACK ab
+#define X_MEDIA_PREV_TRACK ac
+#define X_MEDIA_STOP ad
+#define X_MEDIA_PLAY_PAUSE ae
+#define X_MEDIA_SELECT af
+#define X_MEDIA_EJECT b0
+#define X_MAIL b1
+#define X_CALCULATOR b2
+#define X_MY_COMPUTER b3
+#define X_WWW_SEARCH b4
+#define X_WWW_HOME b5
+#define X_WWW_BACK b6
+#define X_WWW_FORWARD b7
+#define X_WWW_STOP b8
+#define X_WWW_REFRESH b9
+#define X_WWW_FAVORITES ba
#define X_MEDIA_FAST_FORWARD bb
-#define X_MEDIA_REWIND bc
+#define X_MEDIA_REWIND bc
#endif
diff --git a/quantum/serial_link/protocol/byte_stuffer.c b/quantum/serial_link/protocol/byte_stuffer.c
index 2c87d64c29..d3a91d8286 100644
--- a/quantum/serial_link/protocol/byte_stuffer.c
+++ b/quantum/serial_link/protocol/byte_stuffer.c
@@ -34,21 +34,21 @@ SOFTWARE.
typedef struct byte_stuffer_state {
uint16_t next_zero;
uint16_t data_pos;
- bool long_frame;
- uint8_t data[MAX_FRAME_SIZE];
-}byte_stuffer_state_t;
+ bool long_frame;
+ uint8_t data[MAX_FRAME_SIZE];
+} byte_stuffer_state_t;
static byte_stuffer_state_t states[NUM_LINKS];
void init_byte_stuffer_state(byte_stuffer_state_t* state) {
- state->next_zero = 0;
- state->data_pos = 0;
+ state->next_zero = 0;
+ state->data_pos = 0;
state->long_frame = false;
}
void init_byte_stuffer(void) {
int i;
- for (i=0;i<NUM_LINKS;i++) {
+ for (i = 0; i < NUM_LINKS; i++) {
init_byte_stuffer_state(&states[i]);
}
}
@@ -57,9 +57,9 @@ void byte_stuffer_recv_byte(uint8_t link, uint8_t data) {
byte_stuffer_state_t* state = &states[link];
// Start of a new frame
if (state->next_zero == 0) {
- state->next_zero = data;
+ state->next_zero = data;
state->long_frame = data == 0xFF;
- state->data_pos = 0;
+ state->data_pos = 0;
return;
}
@@ -70,33 +70,28 @@ void byte_stuffer_recv_byte(uint8_t link, uint8_t data) {
if (state->data_pos > 0) {
validator_recv_frame(link, state->data, state->data_pos);
}
- }
- else {
+ } else {
// The frame is invalid, so reset
init_byte_stuffer_state(state);
}
- }
- else {
+ } else {
if (state->data_pos == MAX_FRAME_SIZE) {
// We exceeded our maximum frame size
// therefore there's nothing else to do than reset to a new frame
- state->next_zero = data;
+ state->next_zero = data;
state->long_frame = data == 0xFF;
- state->data_pos = 0;
- }
- else if (state->next_zero == 0) {
+ state->data_pos = 0;
+ } else if (state->next_zero == 0) {
if (state->long_frame) {
// This is part of a long frame, so continue
- state->next_zero = data;
+ state->next_zero = data;
state->long_frame = data == 0xFF;
- }
- else {
+ } else {
// Special case for zeroes
- state->next_zero = data;
+ state->next_zero = data;
state->data[state->data_pos++] = 0;
}
- }
- else {
+ } else {
state->data[state->data_pos++] = data;
}
}
@@ -105,7 +100,7 @@ void byte_stuffer_recv_byte(uint8_t link, uint8_t data) {
static void send_block(uint8_t link, uint8_t* start, uint8_t* end, uint8_t num_non_zero) {
send_data(link, &num_non_zero, 1);
if (end > start) {
- send_data(link, start, end-start);
+ send_data(link, start, end - start);
}
}
@@ -113,24 +108,22 @@ void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size) {
const uint8_t zero = 0;
if (size > 0) {
uint16_t num_non_zero = 1;
- uint8_t* end = data + size;
- uint8_t* start = data;
+ uint8_t* end = data + size;
+ uint8_t* start = data;
while (data < end) {
if (num_non_zero == 0xFF) {
// There's more data after big non-zero block
// So send it, and start a new block
send_block(link, start, data, num_non_zero);
- start = data;
+ start = data;
num_non_zero = 1;
- }
- else {
+ } else {
if (*data == 0) {
// A zero encountered, so send the block
send_block(link, start, data, num_non_zero);
- start = data + 1;
+ start = data + 1;
num_non_zero = 1;
- }
- else {
+ } else {
num_non_zero++;
}
++data;
diff --git a/quantum/serial_link/protocol/frame_router.c b/quantum/serial_link/protocol/frame_router.c
index 04b8c2e75c..5292673700 100644
--- a/quantum/serial_link/protocol/frame_router.c
+++ b/quantum/serial_link/protocol/frame_router.c
@@ -28,26 +28,22 @@ SOFTWARE.
static bool is_master;
-void router_set_master(bool master) {
- is_master = master;
-}
+void router_set_master(bool master) { is_master = master; }
-void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size){
+void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size) {
if (is_master) {
if (link == DOWN_LINK) {
- transport_recv_frame(data[size-1], data, size - 1);
+ transport_recv_frame(data[size - 1], data, size - 1);
}
- }
- else {
+ } else {
if (link == UP_LINK) {
- if (data[size-1] & 1) {
+ if (data[size - 1] & 1) {
transport_recv_frame(0, data, size - 1);
}
- data[size-1] >>= 1;
+ data[size - 1] >>= 1;
validator_send_frame(DOWN_LINK, data, size);
- }
- else {
- data[size-1]++;
+ } else {
+ data[size - 1]++;
validator_send_frame(UP_LINK, data, size);
}
}
@@ -59,8 +55,7 @@ void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) {
data[size] = 1;
validator_send_frame(UP_LINK, data, size + 1);
}
- }
- else {
+ } else {
if (is_master) {
data[size] = destination;
validator_send_frame(DOWN_LINK, data, size + 1);
diff --git a/quantum/serial_link/protocol/frame_validator.c b/quantum/serial_link/protocol/frame_validator.c
index 474f80ee8e..bc9136f70b 100644
--- a/quantum/serial_link/protocol/frame_validator.c
+++ b/quantum/serial_link/protocol/frame_validator.c
@@ -27,78 +27,14 @@ SOFTWARE.
#include "serial_link/protocol/byte_stuffer.h"
#include <string.h>
-const uint32_t poly8_lookup[256] =
-{
- 0, 0x77073096, 0xEE0E612C, 0x990951BA,
- 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
- 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
- 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
- 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
- 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
- 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
- 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
- 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
- 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
- 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
- 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
- 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
- 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
- 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
- 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
- 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
- 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
- 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
- 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
- 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
- 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
- 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
- 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
- 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
- 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
- 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
- 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
- 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
- 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
- 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
- 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
- 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
- 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
- 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
- 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
- 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
- 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
- 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
- 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
- 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
- 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
- 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
- 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
- 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
- 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
- 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
- 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
- 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
- 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
- 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
- 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
- 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
- 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
- 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
- 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
- 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
- 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
- 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
- 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
- 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
- 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
- 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
- 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
-};
+const uint32_t poly8_lookup[256] = {0, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
+ 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
+ 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
+ 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D};
-static uint32_t crc32_byte(uint8_t *p, uint32_t bytelength)
-{
+static uint32_t crc32_byte(uint8_t* p, uint32_t bytelength) {
uint32_t crc = 0xffffffff;
- while (bytelength-- !=0) crc = poly8_lookup[((uint8_t) crc ^ *(p++))] ^ (crc >> 8);
+ while (bytelength-- != 0) crc = poly8_lookup[((uint8_t)crc ^ *(p++))] ^ (crc >> 8);
// return (~crc); also works
return (crc ^ 0xffffffff);
}
@@ -106,10 +42,10 @@ static uint32_t crc32_byte(uint8_t *p, uint32_t bytelength)
void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size) {
if (size > 4) {
uint32_t frame_crc;
- memcpy(&frame_crc, data + size -4, 4);
+ memcpy(&frame_crc, data + size - 4, 4);
uint32_t expected_crc = crc32_byte(data, size - 4);
if (frame_crc == expected_crc) {
- route_incoming_frame(link, data, size-4);
+ route_incoming_frame(link, data, size - 4);
}
}
}
diff --git a/quantum/serial_link/protocol/transport.c b/quantum/serial_link/protocol/transport.c
index ff795fe201..73b8dc62e9 100644
--- a/quantum/serial_link/protocol/transport.c
+++ b/quantum/serial_link/protocol/transport.c
@@ -29,42 +29,38 @@ SOFTWARE.
#define MAX_REMOTE_OBJECTS 16
static remote_object_t* remote_objects[MAX_REMOTE_OBJECTS];
-static uint32_t num_remote_objects = 0;
+static uint32_t num_remote_objects = 0;
-void reinitialize_serial_link_transport(void) {
- num_remote_objects = 0;
-}
+void reinitialize_serial_link_transport(void) { num_remote_objects = 0; }
void add_remote_objects(remote_object_t** _remote_objects, uint32_t _num_remote_objects) {
unsigned int i;
- for(i=0;i<_num_remote_objects;i++) {
- remote_object_t* obj = _remote_objects[i];
+ for (i = 0; i < _num_remote_objects; i++) {
+ remote_object_t* obj = _remote_objects[i];
remote_objects[num_remote_objects++] = obj;
if (obj->object_type == MASTER_TO_ALL_SLAVES) {
triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer;
triple_buffer_init(tb);
uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);
- tb = (triple_buffer_object_t*)start;
+ tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
- }
- else if(obj->object_type == MASTER_TO_SINGLE_SLAVE) {
- uint8_t* start = obj->buffer;
+ } else if (obj->object_type == MASTER_TO_SINGLE_SLAVE) {
+ uint8_t* start = obj->buffer;
unsigned int j;
- for (j=0;j<NUM_SLAVES;j++) {
+ for (j = 0; j < NUM_SLAVES; j++) {
triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
start += LOCAL_OBJECT_SIZE(obj->object_size);
}
triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
- }
- else {
- uint8_t* start = obj->buffer;
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ } else {
+ uint8_t* start = obj->buffer;
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
start += LOCAL_OBJECT_SIZE(obj->object_size);
unsigned int j;
- for (j=0;j<NUM_SLAVES;j++) {
+ for (j = 0; j < NUM_SLAVES; j++) {
tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
start += REMOTE_OBJECT_SIZE(obj->object_size);
@@ -74,23 +70,21 @@ void add_remote_objects(remote_object_t** _remote_objects, uint32_t _num_remote_
}
void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size) {
- uint8_t id = data[size-1];
+ uint8_t id = data[size - 1];
if (id < num_remote_objects) {
remote_object_t* obj = remote_objects[id];
if (obj->object_size == size - 1) {
uint8_t* start;
if (obj->object_type == MASTER_TO_ALL_SLAVES) {
start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);
- }
- else if(obj->object_type == SLAVE_TO_MASTER) {
+ } else if (obj->object_type == SLAVE_TO_MASTER) {
start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);
start += (from - 1) * REMOTE_OBJECT_SIZE(obj->object_size);
- }
- else {
+ } else {
start = obj->buffer + NUM_SLAVES * LOCAL_OBJECT_SIZE(obj->object_size);
}
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
- void* ptr = triple_buffer_begin_write_internal(obj->object_size, tb);
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ void* ptr = triple_buffer_begin_write_internal(obj->object_size, tb);
memcpy(ptr, data, size - 1);
triple_buffer_end_write_internal(tb);
}
@@ -99,26 +93,25 @@ void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size) {
void update_transport(void) {
unsigned int i;
- for(i=0;i<num_remote_objects;i++) {
+ for (i = 0; i < num_remote_objects; i++) {
remote_object_t* obj = remote_objects[i];
if (obj->object_type == MASTER_TO_ALL_SLAVES || obj->object_type == SLAVE_TO_MASTER) {
- triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer;
- uint8_t* ptr = (uint8_t*)triple_buffer_read_internal(obj->object_size + LOCAL_OBJECT_EXTRA, tb);
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer;
+ uint8_t* ptr = (uint8_t*)triple_buffer_read_internal(obj->object_size + LOCAL_OBJECT_EXTRA, tb);
if (ptr) {
ptr[obj->object_size] = i;
- uint8_t dest = obj->object_type == MASTER_TO_ALL_SLAVES ? 0xFF : 0;
+ uint8_t dest = obj->object_type == MASTER_TO_ALL_SLAVES ? 0xFF : 0;
router_send_frame(dest, ptr, obj->object_size + 1);
}
- }
- else {
- uint8_t* start = obj->buffer;
+ } else {
+ uint8_t* start = obj->buffer;
unsigned int j;
- for (j=0;j<NUM_SLAVES;j++) {
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
- uint8_t* ptr = (uint8_t*)triple_buffer_read_internal(obj->object_size + LOCAL_OBJECT_EXTRA, tb);
+ for (j = 0; j < NUM_SLAVES; j++) {
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ uint8_t* ptr = (uint8_t*)triple_buffer_read_internal(obj->object_size + LOCAL_OBJECT_EXTRA, tb);
if (ptr) {
ptr[obj->object_size] = i;
- uint8_t dest = j + 1;
+ uint8_t dest = j + 1;
router_send_frame(dest, ptr, obj->object_size + 1);
}
start += LOCAL_OBJECT_SIZE(obj->object_size);
diff --git a/quantum/serial_link/protocol/transport.h b/quantum/serial_link/protocol/transport.h
index 2c5d890b21..309a56b000 100644
--- a/quantum/serial_link/protocol/transport.h
+++ b/quantum/serial_link/protocol/transport.h
@@ -42,104 +42,94 @@ typedef enum {
typedef struct {
remote_object_type object_type;
- uint16_t object_size;
- uint8_t buffer[] __attribute__((aligned(4)));
+ uint16_t object_size;
+ uint8_t buffer[] __attribute__((aligned(4)));
} remote_object_t;
-#define REMOTE_OBJECT_SIZE(objectsize) \
- (sizeof(triple_buffer_object_t) + objectsize * 3)
-#define LOCAL_OBJECT_SIZE(objectsize) \
- (sizeof(triple_buffer_object_t) + (objectsize + LOCAL_OBJECT_EXTRA) * 3)
-
-#define REMOTE_OBJECT_HELPER(name, type, num_local, num_remote) \
-typedef struct { \
- remote_object_t object; \
- uint8_t buffer[ \
- num_remote * REMOTE_OBJECT_SIZE(sizeof(type)) + \
- num_local * LOCAL_OBJECT_SIZE(sizeof(type))]; \
-} remote_object_##name##_t;
-
-#define MASTER_TO_ALL_SLAVES_OBJECT(name, type) \
- REMOTE_OBJECT_HELPER(name, type, 1, 1) \
- remote_object_##name##_t remote_object_##name = { \
- .object = { \
- .object_type = MASTER_TO_ALL_SLAVES, \
- .object_size = sizeof(type), \
- } \
- }; \
- type* begin_write_##name(void) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+#define REMOTE_OBJECT_SIZE(objectsize) (sizeof(triple_buffer_object_t) + objectsize * 3)
+#define LOCAL_OBJECT_SIZE(objectsize) (sizeof(triple_buffer_object_t) + (objectsize + LOCAL_OBJECT_EXTRA) * 3)
+
+#define REMOTE_OBJECT_HELPER(name, type, num_local, num_remote) \
+ typedef struct { \
+ remote_object_t object; \
+ uint8_t buffer[num_remote * REMOTE_OBJECT_SIZE(sizeof(type)) + num_local * LOCAL_OBJECT_SIZE(sizeof(type))]; \
+ } remote_object_##name##_t;
+
+#define MASTER_TO_ALL_SLAVES_OBJECT(name, type) \
+ REMOTE_OBJECT_HELPER(name, type, 1, 1) \
+ remote_object_##name##_t remote_object_##name = {.object = { \
+ .object_type = MASTER_TO_ALL_SLAVES, \
+ .object_size = sizeof(type), \
+ }}; \
+ type* begin_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
return (type*)triple_buffer_begin_write_internal(sizeof(type) + LOCAL_OBJECT_EXTRA, tb); \
- }\
- void end_write_##name(void) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
- triple_buffer_end_write_internal(tb); \
- signal_data_written(); \
- }\
- type* read_##name(void) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);\
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
- return (type*)triple_buffer_read_internal(obj->object_size, tb); \
+ } \
+ void end_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+ triple_buffer_end_write_internal(tb); \
+ signal_data_written(); \
+ } \
+ type* read_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ return (type*)triple_buffer_read_internal(obj->object_size, tb); \
}
-#define MASTER_TO_SINGLE_SLAVE_OBJECT(name, type) \
- REMOTE_OBJECT_HELPER(name, type, NUM_SLAVES, 1) \
- remote_object_##name##_t remote_object_##name = { \
- .object = { \
- .object_type = MASTER_TO_SINGLE_SLAVE, \
- .object_size = sizeof(type), \
- } \
- }; \
- type* begin_write_##name(uint8_t slave) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- uint8_t* start = obj->buffer;\
- start += slave * LOCAL_OBJECT_SIZE(obj->object_size); \
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+#define MASTER_TO_SINGLE_SLAVE_OBJECT(name, type) \
+ REMOTE_OBJECT_HELPER(name, type, NUM_SLAVES, 1) \
+ remote_object_##name##_t remote_object_##name = {.object = { \
+ .object_type = MASTER_TO_SINGLE_SLAVE, \
+ .object_size = sizeof(type), \
+ }}; \
+ type* begin_write_##name(uint8_t slave) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer; \
+ start += slave * LOCAL_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
return (type*)triple_buffer_begin_write_internal(sizeof(type) + LOCAL_OBJECT_EXTRA, tb); \
- }\
- void end_write_##name(uint8_t slave) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- uint8_t* start = obj->buffer;\
- start += slave * LOCAL_OBJECT_SIZE(obj->object_size); \
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
- triple_buffer_end_write_internal(tb); \
- signal_data_written(); \
- }\
- type* read_##name() { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- uint8_t* start = obj->buffer + NUM_SLAVES * LOCAL_OBJECT_SIZE(obj->object_size);\
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
- return (type*)triple_buffer_read_internal(obj->object_size, tb); \
+ } \
+ void end_write_##name(uint8_t slave) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer; \
+ start += slave * LOCAL_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ triple_buffer_end_write_internal(tb); \
+ signal_data_written(); \
+ } \
+ type* read_##name() { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer + NUM_SLAVES * LOCAL_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ return (type*)triple_buffer_read_internal(obj->object_size, tb); \
}
-#define SLAVE_TO_MASTER_OBJECT(name, type) \
- REMOTE_OBJECT_HELPER(name, type, 1, NUM_SLAVES) \
- remote_object_##name##_t remote_object_##name = { \
- .object = { \
- .object_type = SLAVE_TO_MASTER, \
- .object_size = sizeof(type), \
- } \
- }; \
- type* begin_write_##name(void) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+#define SLAVE_TO_MASTER_OBJECT(name, type) \
+ REMOTE_OBJECT_HELPER(name, type, 1, NUM_SLAVES) \
+ remote_object_##name##_t remote_object_##name = {.object = { \
+ .object_type = SLAVE_TO_MASTER, \
+ .object_size = sizeof(type), \
+ }}; \
+ type* begin_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
return (type*)triple_buffer_begin_write_internal(sizeof(type) + LOCAL_OBJECT_EXTRA, tb); \
- }\
- void end_write_##name(void) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
- triple_buffer_end_write_internal(tb); \
- signal_data_written(); \
- }\
- type* read_##name(uint8_t slave) { \
- remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
- uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);\
- start+=slave * REMOTE_OBJECT_SIZE(obj->object_size); \
- triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
- return (type*)triple_buffer_read_internal(obj->object_size, tb); \
+ } \
+ void end_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+ triple_buffer_end_write_internal(tb); \
+ signal_data_written(); \
+ } \
+ type* read_##name(uint8_t slave) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size); \
+ start += slave * REMOTE_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ return (type*)triple_buffer_read_internal(obj->object_size, tb); \
}
#define REMOTE_OBJECT(name) (remote_object_t*)&remote_object_##name
diff --git a/quantum/serial_link/protocol/triple_buffered_object.c b/quantum/serial_link/protocol/triple_buffered_object.c
index e3e8989d30..e0c6d702a5 100644
--- a/quantum/serial_link/protocol/triple_buffered_object.c
+++ b/quantum/serial_link/protocol/triple_buffered_object.c
@@ -49,14 +49,13 @@ void* triple_buffer_read_internal(uint16_t object_size, triple_buffer_object_t*
serial_link_lock();
if (GET_DATA_AVAILABLE()) {
uint8_t shared_index = GET_SHARED_INDEX();
- uint8_t read_index = GET_READ_INDEX();
+ uint8_t read_index = GET_READ_INDEX();
SET_READ_INDEX(shared_index);
SET_SHARED_INDEX(read_index);
SET_DATA_AVAILABLE(false);
serial_link_unlock();
return object->buffer + object_size * shared_index;
- }
- else {
+ } else {
serial_link_unlock();
return NULL;
}
@@ -70,7 +69,7 @@ void* triple_buffer_begin_write_internal(uint16_t object_size, triple_buffer_obj
void triple_buffer_end_write_internal(triple_buffer_object_t* object) {
serial_link_lock();
uint8_t shared_index = GET_SHARED_INDEX();
- uint8_t write_index = GET_WRITE_INDEX();
+ uint8_t write_index = GET_WRITE_INDEX();
SET_SHARED_INDEX(write_index);
SET_WRITE_INDEX(shared_index);
SET_DATA_AVAILABLE(true);
diff --git a/quantum/serial_link/protocol/triple_buffered_object.h b/quantum/serial_link/protocol/triple_buffered_object.h
index 2e57db3f50..6ec98d52bf 100644
--- a/quantum/serial_link/protocol/triple_buffered_object.h
+++ b/quantum/serial_link/protocol/triple_buffered_object.h
@@ -30,22 +30,18 @@ SOFTWARE.
typedef struct {
uint8_t state;
uint8_t buffer[] __attribute__((aligned(4)));
-}triple_buffer_object_t;
+} triple_buffer_object_t;
void triple_buffer_init(triple_buffer_object_t* object);
-#define triple_buffer_begin_write(object) \
- (typeof(*object.buffer[0])*)triple_buffer_begin_write_internal(sizeof(*object.buffer[0]), (triple_buffer_object_t*)object)
+#define triple_buffer_begin_write(object) (typeof(*object.buffer[0])*)triple_buffer_begin_write_internal(sizeof(*object.buffer[0]), (triple_buffer_object_t*)object)
-#define triple_buffer_end_write(object) \
- triple_buffer_end_write_internal((triple_buffer_object_t*)object)
+#define triple_buffer_end_write(object) triple_buffer_end_write_internal((triple_buffer_object_t*)object)
-#define triple_buffer_read(object) \
- (typeof(*object.buffer[0])*)triple_buffer_read_internal(sizeof(*object.buffer[0]), (triple_buffer_object_t*)object)
+#define triple_buffer_read(object) (typeof(*object.buffer[0])*)triple_buffer_read_internal(sizeof(*object.buffer[0]), (triple_buffer_object_t*)object)
void* triple_buffer_begin_write_internal(uint16_t object_size, triple_buffer_object_t* object);
-void triple_buffer_end_write_internal(triple_buffer_object_t* object);
+void triple_buffer_end_write_internal(triple_buffer_object_t* object);
void* triple_buffer_read_internal(uint16_t object_size, triple_buffer_object_t* object);
-
#endif
diff --git a/quantum/serial_link/system/serial_link.c b/quantum/serial_link/system/serial_link.c
index b3bee62a18..feac64e297 100644
--- a/quantum/serial_link/system/serial_link.c
+++ b/quantum/serial_link/system/serial_link.c
@@ -34,45 +34,37 @@ SOFTWARE.
#include "config.h"
static event_source_t new_data_event;
-static bool serial_link_connected;
-static bool is_master = false;
+static bool serial_link_connected;
+static bool is_master = false;
static uint8_t keyboard_leds(void);
-static void send_keyboard(report_keyboard_t *report);
-static void send_mouse(report_mouse_t *report);
-static void send_system(uint16_t data);
-static void send_consumer(uint16_t data);
-
-host_driver_t serial_driver = {
- keyboard_leds,
- send_keyboard,
- send_mouse,
- send_system,
- send_consumer
-};
+static void send_keyboard(report_keyboard_t* report);
+static void send_mouse(report_mouse_t* report);
+static void send_system(uint16_t data);
+static void send_consumer(uint16_t data);
+
+host_driver_t serial_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer};
// Define these in your Config.h file
#ifndef SERIAL_LINK_BAUD
-#error "Serial link baud is not set"
+# error "Serial link baud is not set"
#endif
#ifndef SERIAL_LINK_THREAD_PRIORITY
-#error "Serial link thread priority not set"
+# error "Serial link thread priority not set"
#endif
-static SerialConfig config = {
- .sc_speed = SERIAL_LINK_BAUD
-};
+static SerialConfig config = {.sc_speed = SERIAL_LINK_BAUD};
//#define DEBUG_LINK_ERRORS
static uint32_t read_from_serial(SerialDriver* driver, uint8_t link) {
const uint32_t buffer_size = 16;
- uint8_t buffer[buffer_size];
- uint32_t bytes_read = sdAsynchronousRead(driver, buffer, buffer_size);
- uint8_t* current = buffer;
- uint8_t* end = current + bytes_read;
- while(current < end) {
+ uint8_t buffer[buffer_size];
+ uint32_t bytes_read = sdAsynchronousRead(driver, buffer, buffer_size);
+ uint8_t* current = buffer;
+ uint8_t* end = current + bytes_read;
+ while (current < end) {
byte_stuffer_recv_byte(link, *current);
current++;
}
@@ -93,7 +85,6 @@ static void print_error(char* str, eventflags_t flags, SerialDriver* driver) {
print(str);
uint32_t size = qSpaceI(&(driver->iqueue));
xprintf(" Overrun error, queue size %d\n", size);
-
}
if (flags & SD_NOISE_ERROR) {
print(str);
@@ -110,9 +101,7 @@ static void print_error(char* str, eventflags_t flags, SerialDriver* driver) {
#endif
}
-bool is_serial_link_master(void) {
- return is_master;
-}
+bool is_serial_link_master(void) { return is_master; }
// TODO: Optimize the stack size, this is probably way too big
static THD_WORKING_AREA(serialThreadStack, 1024);
@@ -122,18 +111,11 @@ static THD_FUNCTION(serialThread, arg) {
event_listener_t sd1_listener;
event_listener_t sd2_listener;
chEvtRegister(&new_data_event, &new_data_listener, 0);
- eventflags_t events = CHN_INPUT_AVAILABLE
- | SD_PARITY_ERROR | SD_FRAMING_ERROR | SD_OVERRUN_ERROR | SD_NOISE_ERROR | SD_BREAK_DETECTED;
- chEvtRegisterMaskWithFlags(chnGetEventSource(&SD1),
- &sd1_listener,
- EVENT_MASK(1),
- events);
- chEvtRegisterMaskWithFlags(chnGetEventSource(&SD2),
- &sd2_listener,
- EVENT_MASK(2),
- events);
+ eventflags_t events = CHN_INPUT_AVAILABLE | SD_PARITY_ERROR | SD_FRAMING_ERROR | SD_OVERRUN_ERROR | SD_NOISE_ERROR | SD_BREAK_DETECTED;
+ chEvtRegisterMaskWithFlags(chnGetEventSource(&SD1), &sd1_listener, EVENT_MASK(1), events);
+ chEvtRegisterMaskWithFlags(chnGetEventSource(&SD2), &sd2_listener, EVENT_MASK(2), events);
bool need_wait = false;
- while(true) {
+ while (true) {
eventflags_t flags1 = 0;
eventflags_t flags2 = 0;
if (need_wait) {
@@ -162,8 +144,7 @@ static THD_FUNCTION(serialThread, arg) {
void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
if (link == DOWN_LINK) {
sdWrite(&SD1, data, size);
- }
- else {
+ } else {
sdWrite(&SD2, data, size);
}
}
@@ -187,13 +168,12 @@ static remote_object_t* remote_objects[] = {
void init_serial_link(void) {
serial_link_connected = false;
init_serial_link_hal();
- add_remote_objects(remote_objects, sizeof(remote_objects)/sizeof(remote_object_t*));
+ add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*));
init_byte_stuffer();
sdStart(&SD1, &config);
sdStart(&SD2, &config);
chEvtObjectInit(&new_data_event);
- (void)chThdCreateStatic(serialThreadStack, sizeof(serialThreadStack),
- SERIAL_LINK_THREAD_PRIORITY, serialThread, NULL);
+ (void)chThdCreateStatic(serialThreadStack, sizeof(serialThreadStack), SERIAL_LINK_THREAD_PRIORITY, serialThread, NULL);
}
void matrix_set_remote(matrix_row_t* rows, uint8_t index);
@@ -204,19 +184,19 @@ void serial_link_update(void) {
}
matrix_object_t matrix;
- bool changed = false;
- for(uint8_t i=0;i<MATRIX_ROWS;i++) {
+ bool changed = false;
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix.rows[i] = matrix_get_row(i);
changed |= matrix.rows[i] != last_matrix.rows[i];
}
systime_t current_time = chVTGetSystemTimeX();
- systime_t delta = current_time - last_update;
+ systime_t delta = current_time - last_update;
if (changed || delta > US2ST(5000)) {
- last_update = current_time;
- last_matrix = matrix;
+ last_update = current_time;
+ last_matrix = matrix;
matrix_object_t* m = begin_write_keyboard_matrix();
- for(uint8_t i=0;i<MATRIX_ROWS;i++) {
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
m->rows[i] = matrix.rows[i];
}
end_write_keyboard_matrix();
@@ -230,36 +210,19 @@ void serial_link_update(void) {
}
}
-void signal_data_written(void) {
- chEvtBroadcast(&new_data_event);
-}
+void signal_data_written(void) { chEvtBroadcast(&new_data_event); }
-bool is_serial_link_connected(void) {
- return serial_link_connected;
-}
+bool is_serial_link_connected(void) { return serial_link_connected; }
-host_driver_t* get_serial_link_driver(void) {
- return &serial_driver;
-}
+host_driver_t* get_serial_link_driver(void) { return &serial_driver; }
// NOTE: The driver does nothing, because the master handles everything
-uint8_t keyboard_leds(void) {
- return 0;
-}
+uint8_t keyboard_leds(void) { return 0; }
-void send_keyboard(report_keyboard_t *report) {
- (void)report;
-}
+void send_keyboard(report_keyboard_t* report) { (void)report; }
-void send_mouse(report_mouse_t *report) {
- (void)report;
-}
+void send_mouse(report_mouse_t* report) { (void)report; }
-void send_system(uint16_t data) {
- (void)data;
-}
-
-void send_consumer(uint16_t data) {
- (void)data;
-}
+void send_system(uint16_t data) { (void)data; }
+void send_consumer(uint16_t data) { (void)data; }
diff --git a/quantum/serial_link/system/serial_link.h b/quantum/serial_link/system/serial_link.h
index 351e03877b..f48fbe9ea7 100644
--- a/quantum/serial_link/system/serial_link.h
+++ b/quantum/serial_link/system/serial_link.h
@@ -28,33 +28,27 @@ SOFTWARE.
#include "host_driver.h"
#include <stdbool.h>
-void init_serial_link(void);
-void init_serial_link_hal(void);
-bool is_serial_link_connected(void);
-bool is_serial_link_master(void);
+void init_serial_link(void);
+void init_serial_link_hal(void);
+bool is_serial_link_connected(void);
+bool is_serial_link_master(void);
host_driver_t* get_serial_link_driver(void);
-void serial_link_update(void);
+void serial_link_update(void);
#if defined(PROTOCOL_CHIBIOS)
-#include "ch.h"
+# include "ch.h"
-static inline void serial_link_lock(void) {
- chSysLock();
-}
+static inline void serial_link_lock(void) { chSysLock(); }
-static inline void serial_link_unlock(void) {
- chSysUnlock();
-}
+static inline void serial_link_unlock(void) { chSysUnlock(); }
void signal_data_written(void);
#else
-inline void serial_link_lock(void) {
-}
+inline void serial_link_lock(void) {}
-inline void serial_link_unlock(void) {
-}
+inline void serial_link_unlock(void) {}
void signal_data_written(void);
diff --git a/quantum/serial_link/tests/byte_stuffer_tests.cpp b/quantum/serial_link/tests/byte_stuffer_tests.cpp
index ff49d727bb..9e4e1768f4 100644
--- a/quantum/serial_link/tests/byte_stuffer_tests.cpp
+++ b/quantum/serial_link/tests/byte_stuffer_tests.cpp
@@ -33,25 +33,21 @@ extern "C" {
}
using testing::_;
-using testing::ElementsAreArray;
using testing::Args;
+using testing::ElementsAreArray;
-class ByteStuffer : public ::testing::Test{
-public:
+class ByteStuffer : public ::testing::Test {
+ public:
ByteStuffer() {
Instance = this;
init_byte_stuffer();
}
- ~ByteStuffer() {
- Instance = nullptr;
- }
+ ~ByteStuffer() { Instance = nullptr; }
- MOCK_METHOD3(validator_recv_frame, void (uint8_t link, uint8_t* data, uint16_t size));
+ MOCK_METHOD3(validator_recv_frame, void(uint8_t link, uint8_t* data, uint16_t size));
- void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
- std::copy(data, data + size, std::back_inserter(sent_data));
- }
+ void send_data(uint8_t link, const uint8_t* data, uint16_t size) { std::copy(data, data + size, std::back_inserter(sent_data)); }
std::vector<uint8_t> sent_data;
static ByteStuffer* Instance;
@@ -60,52 +56,42 @@ public:
ByteStuffer* ByteStuffer::Instance = nullptr;
extern "C" {
- void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size) {
- ByteStuffer::Instance->validator_recv_frame(link, data, size);
- }
+void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size) { ByteStuffer::Instance->validator_recv_frame(link, data, size); }
- void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
- ByteStuffer::Instance->send_data(link, data, size);
- }
+void send_data(uint8_t link, const uint8_t* data, uint16_t size) { ByteStuffer::Instance->send_data(link, data, size); }
}
TEST_F(ByteStuffer, receives_no_frame_for_a_single_zero_byte) {
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).Times(0);
byte_stuffer_recv_byte(0, 0);
}
TEST_F(ByteStuffer, receives_no_frame_for_a_single_FF_byte) {
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).Times(0);
byte_stuffer_recv_byte(0, 0xFF);
}
TEST_F(ByteStuffer, receives_no_frame_for_a_single_random_byte) {
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).Times(0);
byte_stuffer_recv_byte(0, 0x4A);
}
TEST_F(ByteStuffer, receives_no_frame_for_a_zero_length_frame) {
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).Times(0);
byte_stuffer_recv_byte(0, 1);
byte_stuffer_recv_byte(0, 0);
}
TEST_F(ByteStuffer, receives_single_byte_valid_frame) {
uint8_t expected[] = {0x37};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 2);
byte_stuffer_recv_byte(0, 0x37);
byte_stuffer_recv_byte(0, 0);
}
TEST_F(ByteStuffer, receives_three_bytes_valid_frame) {
uint8_t expected[] = {0x37, 0x99, 0xFF};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 4);
byte_stuffer_recv_byte(0, 0x37);
byte_stuffer_recv_byte(0, 0x99);
@@ -115,8 +101,7 @@ TEST_F(ByteStuffer, receives_three_bytes_valid_frame) {
TEST_F(ByteStuffer, receives_single_zero_valid_frame) {
uint8_t expected[] = {0};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 1);
byte_stuffer_recv_byte(0, 1);
byte_stuffer_recv_byte(0, 0);
@@ -124,8 +109,7 @@ TEST_F(ByteStuffer, receives_single_zero_valid_frame) {
TEST_F(ByteStuffer, receives_valid_frame_with_zeroes) {
uint8_t expected[] = {5, 0, 3, 0};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 2);
byte_stuffer_recv_byte(0, 5);
byte_stuffer_recv_byte(0, 2);
@@ -134,14 +118,11 @@ TEST_F(ByteStuffer, receives_valid_frame_with_zeroes) {
byte_stuffer_recv_byte(0, 0);
}
-
TEST_F(ByteStuffer, receives_two_valid_frames) {
uint8_t expected1[] = {5, 0};
uint8_t expected2[] = {3};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected1)));
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected2)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected1)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected2)));
byte_stuffer_recv_byte(1, 2);
byte_stuffer_recv_byte(1, 5);
byte_stuffer_recv_byte(1, 1);
@@ -153,8 +134,7 @@ TEST_F(ByteStuffer, receives_two_valid_frames) {
TEST_F(ByteStuffer, receives_valid_frame_after_unexpected_zero) {
uint8_t expected[] = {5, 7};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(1, 3);
byte_stuffer_recv_byte(1, 1);
byte_stuffer_recv_byte(1, 0);
@@ -166,11 +146,10 @@ TEST_F(ByteStuffer, receives_valid_frame_after_unexpected_zero) {
TEST_F(ByteStuffer, receives_valid_frame_after_unexpected_non_zero) {
uint8_t expected[] = {5, 7};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 2);
byte_stuffer_recv_byte(0, 9);
- byte_stuffer_recv_byte(0, 4); // This should have been zero
+ byte_stuffer_recv_byte(0, 4); // This should have been zero
byte_stuffer_recv_byte(0, 0);
byte_stuffer_recv_byte(0, 3);
byte_stuffer_recv_byte(0, 5);
@@ -180,31 +159,29 @@ TEST_F(ByteStuffer, receives_valid_frame_after_unexpected_non_zero) {
TEST_F(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_and_then_end_of_frame) {
uint8_t expected[254];
- int i;
- for (i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
expected[i] = i + 1;
}
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 0xFF);
- for (i=0;i<254;i++) {
- byte_stuffer_recv_byte(0, i+1);
+ for (i = 0; i < 254; i++) {
+ byte_stuffer_recv_byte(0, i + 1);
}
byte_stuffer_recv_byte(0, 0);
}
TEST_F(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_next_byte_is_non_zero) {
uint8_t expected[255];
- int i;
- for (i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
expected[i] = i + 1;
}
expected[254] = 7;
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 0xFF);
- for (i=0;i<254;i++) {
- byte_stuffer_recv_byte(0, i+1);
+ for (i = 0; i < 254; i++) {
+ byte_stuffer_recv_byte(0, i + 1);
}
byte_stuffer_recv_byte(0, 2);
byte_stuffer_recv_byte(0, 7);
@@ -213,16 +190,15 @@ TEST_F(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_next_byte_is_
TEST_F(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_next_byte_is_zero) {
uint8_t expected[255];
- int i;
- for (i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
expected[i] = i + 1;
}
expected[254] = 0;
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 0xFF);
- for (i=0;i<254;i++) {
- byte_stuffer_recv_byte(0, i+1);
+ for (i = 0; i < 254; i++) {
+ byte_stuffer_recv_byte(0, i + 1);
}
byte_stuffer_recv_byte(0, 1);
byte_stuffer_recv_byte(0, 1);
@@ -231,25 +207,24 @@ TEST_F(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_next_byte_is_
TEST_F(ByteStuffer, receives_two_long_frames_and_some_more) {
uint8_t expected[515];
- int i;
- int j;
- for (j=0;j<2;j++) {
- for (i=0;i<254;i++) {
- expected[i+254*j] = i + 1;
+ int i;
+ int j;
+ for (j = 0; j < 2; j++) {
+ for (i = 0; i < 254; i++) {
+ expected[i + 254 * j] = i + 1;
}
}
- for (i=0;i<7;i++) {
- expected[254*2+i] = i + 1;
+ for (i = 0; i < 7; i++) {
+ expected[254 * 2 + i] = i + 1;
}
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
byte_stuffer_recv_byte(0, 0xFF);
- for (i=0;i<254;i++) {
- byte_stuffer_recv_byte(0, i+1);
+ for (i = 0; i < 254; i++) {
+ byte_stuffer_recv_byte(0, i + 1);
}
byte_stuffer_recv_byte(0, 0xFF);
- for (i=0;i<254;i++) {
- byte_stuffer_recv_byte(0, i+1);
+ for (i = 0; i < 254; i++) {
+ byte_stuffer_recv_byte(0, i + 1);
}
byte_stuffer_recv_byte(0, 8);
byte_stuffer_recv_byte(0, 1);
@@ -264,24 +239,22 @@ TEST_F(ByteStuffer, receives_two_long_frames_and_some_more) {
TEST_F(ByteStuffer, receives_an_all_zeros_frame_that_is_maximum_size) {
uint8_t expected[MAX_FRAME_SIZE] = {};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
int i;
byte_stuffer_recv_byte(0, 1);
- for(i=0;i<MAX_FRAME_SIZE;i++) {
- byte_stuffer_recv_byte(0, 1);
+ for (i = 0; i < MAX_FRAME_SIZE; i++) {
+ byte_stuffer_recv_byte(0, 1);
}
byte_stuffer_recv_byte(0, 0);
}
TEST_F(ByteStuffer, doesnt_recv_a_frame_thats_too_long_all_zeroes) {
uint8_t expected[1] = {0};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).Times(0);
int i;
byte_stuffer_recv_byte(0, 1);
- for(i=0;i<MAX_FRAME_SIZE;i++) {
- byte_stuffer_recv_byte(0, 1);
+ for (i = 0; i < MAX_FRAME_SIZE; i++) {
+ byte_stuffer_recv_byte(0, 1);
}
byte_stuffer_recv_byte(0, 1);
byte_stuffer_recv_byte(0, 0);
@@ -289,12 +262,11 @@ TEST_F(ByteStuffer, doesnt_recv_a_frame_thats_too_long_all_zeroes) {
TEST_F(ByteStuffer, received_frame_is_aborted_when_its_too_long) {
uint8_t expected[1] = {1};
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
int i;
byte_stuffer_recv_byte(0, 1);
- for(i=0;i<MAX_FRAME_SIZE;i++) {
- byte_stuffer_recv_byte(0, 1);
+ for (i = 0; i < MAX_FRAME_SIZE; i++) {
+ byte_stuffer_recv_byte(0, 1);
}
byte_stuffer_recv_byte(0, 2);
byte_stuffer_recv_byte(0, 1);
@@ -364,14 +336,14 @@ TEST_F(ByteStuffer, sends_three_byte_frame_with_all_zeroes) {
TEST_F(ByteStuffer, sends_frame_with_254_non_zeroes) {
uint8_t data[254];
- int i;
- for(i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
data[i] = i + 1;
}
byte_stuffer_send_frame(0, data, 254);
uint8_t expected[256];
expected[0] = 0xFF;
- for(i=1;i<255;i++) {
+ for (i = 1; i < 255; i++) {
expected[i] = i;
}
expected[255] = 0;
@@ -380,14 +352,14 @@ TEST_F(ByteStuffer, sends_frame_with_254_non_zeroes) {
TEST_F(ByteStuffer, sends_frame_with_255_non_zeroes) {
uint8_t data[255];
- int i;
- for(i=0;i<255;i++) {
+ int i;
+ for (i = 0; i < 255; i++) {
data[i] = i + 1;
}
byte_stuffer_send_frame(0, data, 255);
uint8_t expected[258];
expected[0] = 0xFF;
- for(i=1;i<255;i++) {
+ for (i = 1; i < 255; i++) {
expected[i] = i;
}
expected[255] = 2;
@@ -398,15 +370,15 @@ TEST_F(ByteStuffer, sends_frame_with_255_non_zeroes) {
TEST_F(ByteStuffer, sends_frame_with_254_non_zeroes_followed_by_zero) {
uint8_t data[255];
- int i;
- for(i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
data[i] = i + 1;
}
data[254] = 0;
byte_stuffer_send_frame(0, data, 255);
uint8_t expected[258];
expected[0] = 0xFF;
- for(i=1;i<255;i++) {
+ for (i = 1; i < 255; i++) {
expected[i] = i;
}
expected[255] = 1;
@@ -416,68 +388,63 @@ TEST_F(ByteStuffer, sends_frame_with_254_non_zeroes_followed_by_zero) {
}
TEST_F(ByteStuffer, sends_and_receives_full_roundtrip_small_packet) {
- uint8_t original_data[] = { 1, 2, 3};
+ uint8_t original_data[] = {1, 2, 3};
byte_stuffer_send_frame(0, original_data, sizeof(original_data));
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(original_data)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(original_data)));
int i;
- for(auto& d : sent_data) {
- byte_stuffer_recv_byte(1, d);
+ for (auto& d : sent_data) {
+ byte_stuffer_recv_byte(1, d);
}
}
TEST_F(ByteStuffer, sends_and_receives_full_roundtrip_small_packet_with_zeros) {
- uint8_t original_data[] = { 1, 0, 3, 0, 0, 9};
+ uint8_t original_data[] = {1, 0, 3, 0, 0, 9};
byte_stuffer_send_frame(1, original_data, sizeof(original_data));
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(original_data)));
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(original_data)));
int i;
- for(auto& d : sent_data) {
- byte_stuffer_recv_byte(1, d);
+ for (auto& d : sent_data) {
+ byte_stuffer_recv_byte(1, d);
}
}
TEST_F(ByteStuffer, sends_and_receives_full_roundtrip_254_bytes) {
uint8_t original_data[254];
- int i;
- for(i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
original_data[i] = i + 1;
}
byte_stuffer_send_frame(0, original_data, sizeof(original_data));
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(original_data)));
- for(auto& d : sent_data) {
- byte_stuffer_recv_byte(1, d);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(original_data)));
+ for (auto& d : sent_data) {
+ byte_stuffer_recv_byte(1, d);
}
}
TEST_F(ByteStuffer, sends_and_receives_full_roundtrip_256_bytes) {
uint8_t original_data[256];
- int i;
- for(i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
original_data[i] = i + 1;
}
original_data[254] = 22;
original_data[255] = 23;
byte_stuffer_send_frame(0, original_data, sizeof(original_data));
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(original_data)));
- for(auto& d : sent_data) {
- byte_stuffer_recv_byte(1, d);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(original_data)));
+ for (auto& d : sent_data) {
+ byte_stuffer_recv_byte(1, d);
}
}
TEST_F(ByteStuffer, sends_and_receives_full_roundtrip_254_bytes_and_then_zero) {
uint8_t original_data[255];
- int i;
- for(i=0;i<254;i++) {
+ int i;
+ for (i = 0; i < 254; i++) {
original_data[i] = i + 1;
}
original_data[254] = 0;
byte_stuffer_send_frame(0, original_data, sizeof(original_data));
- EXPECT_CALL(*this, validator_recv_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(original_data)));
- for(auto& d : sent_data) {
- byte_stuffer_recv_byte(1, d);
+ EXPECT_CALL(*this, validator_recv_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(original_data)));
+ for (auto& d : sent_data) {
+ byte_stuffer_recv_byte(1, d);
}
}
diff --git a/quantum/serial_link/tests/frame_router_tests.cpp b/quantum/serial_link/tests/frame_router_tests.cpp
index 2bd5bf830d..f76dfb33d6 100644
--- a/quantum/serial_link/tests/frame_router_tests.cpp
+++ b/quantum/serial_link/tests/frame_router_tests.cpp
@@ -26,27 +26,23 @@ SOFTWARE.
#include "gmock/gmock.h"
#include <array>
extern "C" {
- #include "serial_link/protocol/transport.h"
- #include "serial_link/protocol/byte_stuffer.h"
- #include "serial_link/protocol/frame_router.h"
+#include "serial_link/protocol/transport.h"
+#include "serial_link/protocol/byte_stuffer.h"
+#include "serial_link/protocol/frame_router.h"
}
using testing::_;
-using testing::ElementsAreArray;
using testing::Args;
+using testing::ElementsAreArray;
class FrameRouter : public testing::Test {
-public:
- FrameRouter() :
- current_router_buffer(nullptr)
- {
+ public:
+ FrameRouter() : current_router_buffer(nullptr) {
Instance = this;
init_byte_stuffer();
}
- ~FrameRouter() {
- Instance = nullptr;
- }
+ ~FrameRouter() { Instance = nullptr; }
void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
auto& buffer = current_router_buffer->send_buffers[link];
@@ -55,31 +51,26 @@ public:
void receive_data(uint8_t link, uint8_t* data, uint16_t size) {
int i;
- for(i=0;i<size;i++) {
+ for (i = 0; i < size; i++) {
byte_stuffer_recv_byte(link, data[i]);
}
}
void activate_router(uint8_t num) {
current_router_buffer = router_buffers + num;
- router_set_master(num==0);
+ router_set_master(num == 0);
}
void simulate_transport(uint8_t from, uint8_t to) {
- activate_router(to);
- if (from > to) {
- receive_data(DOWN_LINK,
- router_buffers[from].send_buffers[UP_LINK].data(),
- router_buffers[from].send_buffers[UP_LINK].size());
- }
- else if(to > from) {
- receive_data(UP_LINK,
- router_buffers[from].send_buffers[DOWN_LINK].data(),
- router_buffers[from].send_buffers[DOWN_LINK].size());
- }
+ activate_router(to);
+ if (from > to) {
+ receive_data(DOWN_LINK, router_buffers[from].send_buffers[UP_LINK].data(), router_buffers[from].send_buffers[UP_LINK].size());
+ } else if (to > from) {
+ receive_data(UP_LINK, router_buffers[from].send_buffers[DOWN_LINK].data(), router_buffers[from].send_buffers[DOWN_LINK].size());
+ }
}
- MOCK_METHOD3(transport_recv_frame, void (uint8_t from, uint8_t* data, uint16_t size));
+ MOCK_METHOD3(transport_recv_frame, void(uint8_t from, uint8_t* data, uint16_t size));
std::vector<uint8_t> received_data;
@@ -87,7 +78,7 @@ public:
std::vector<uint8_t> send_buffers[2];
};
- router_buffer router_buffers[8];
+ router_buffer router_buffers[8];
router_buffer* current_router_buffer;
static FrameRouter* Instance;
@@ -95,22 +86,15 @@ public:
FrameRouter* FrameRouter::Instance = nullptr;
-
typedef struct {
std::array<uint8_t, 4> data;
- uint8_t extra[16];
+ uint8_t extra[16];
} frame_buffer_t;
-
extern "C" {
- void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
- FrameRouter::Instance->send_data(link, data, size);
- }
+void send_data(uint8_t link, const uint8_t* data, uint16_t size) { FrameRouter::Instance->send_data(link, data, size); }
-
- void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size) {
- FrameRouter::Instance->transport_recv_frame(from, data, size);
- }
+void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size) { FrameRouter::Instance->transport_recv_frame(from, data, size); }
}
TEST_F(FrameRouter, master_broadcast_is_received_by_everyone) {
@@ -120,14 +104,12 @@ TEST_F(FrameRouter, master_broadcast_is_received_by_everyone) {
router_send_frame(0xFF, (uint8_t*)&data, 4);
EXPECT_GT(router_buffers[0].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[0].send_buffers[UP_LINK].size(), 0);
- EXPECT_CALL(*this, transport_recv_frame(0, _, _))
- .With(Args<1, 2>(ElementsAreArray(data.data)));
+ EXPECT_CALL(*this, transport_recv_frame(0, _, _)).With(Args<1, 2>(ElementsAreArray(data.data)));
simulate_transport(0, 1);
EXPECT_GT(router_buffers[1].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[1].send_buffers[UP_LINK].size(), 0);
- EXPECT_CALL(*this, transport_recv_frame(0, _, _))
- .With(Args<1, 2>(ElementsAreArray(data.data)));
+ EXPECT_CALL(*this, transport_recv_frame(0, _, _)).With(Args<1, 2>(ElementsAreArray(data.data)));
simulate_transport(1, 2);
EXPECT_GT(router_buffers[2].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[2].send_buffers[UP_LINK].size(), 0);
@@ -145,14 +127,12 @@ TEST_F(FrameRouter, master_send_is_received_by_targets) {
EXPECT_GT(router_buffers[1].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[1].send_buffers[UP_LINK].size(), 0);
- EXPECT_CALL(*this, transport_recv_frame(0, _, _))
- .With(Args<1, 2>(ElementsAreArray(data.data)));
+ EXPECT_CALL(*this, transport_recv_frame(0, _, _)).With(Args<1, 2>(ElementsAreArray(data.data)));
simulate_transport(1, 2);
EXPECT_GT(router_buffers[2].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[2].send_buffers[UP_LINK].size(), 0);
- EXPECT_CALL(*this, transport_recv_frame(0, _, _))
- .With(Args<1, 2>(ElementsAreArray(data.data)));
+ EXPECT_CALL(*this, transport_recv_frame(0, _, _)).With(Args<1, 2>(ElementsAreArray(data.data)));
simulate_transport(2, 3);
EXPECT_GT(router_buffers[3].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[3].send_buffers[UP_LINK].size(), 0);
@@ -166,8 +146,7 @@ TEST_F(FrameRouter, first_link_sends_to_master) {
EXPECT_GT(router_buffers[1].send_buffers[UP_LINK].size(), 0);
EXPECT_EQ(router_buffers[1].send_buffers[DOWN_LINK].size(), 0);
- EXPECT_CALL(*this, transport_recv_frame(1, _, _))
- .With(Args<1, 2>(ElementsAreArray(data.data)));
+ EXPECT_CALL(*this, transport_recv_frame(1, _, _)).With(Args<1, 2>(ElementsAreArray(data.data)));
simulate_transport(1, 0);
EXPECT_EQ(router_buffers[0].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[0].send_buffers[UP_LINK].size(), 0);
@@ -185,8 +164,7 @@ TEST_F(FrameRouter, second_link_sends_to_master) {
EXPECT_GT(router_buffers[1].send_buffers[UP_LINK].size(), 0);
EXPECT_EQ(router_buffers[1].send_buffers[DOWN_LINK].size(), 0);
- EXPECT_CALL(*this, transport_recv_frame(2, _, _))
- .With(Args<1, 2>(ElementsAreArray(data.data)));
+ EXPECT_CALL(*this, transport_recv_frame(2, _, _)).With(Args<1, 2>(ElementsAreArray(data.data)));
simulate_transport(1, 0);
EXPECT_EQ(router_buffers[0].send_buffers[DOWN_LINK].size(), 0);
EXPECT_EQ(router_buffers[0].send_buffers[UP_LINK].size(), 0);
@@ -218,12 +196,9 @@ TEST_F(FrameRouter, master_receives_on_uplink_does_nothing) {
EXPECT_GT(router_buffers[1].send_buffers[UP_LINK].size(), 0);
EXPECT_EQ(router_buffers[1].send_buffers[DOWN_LINK].size(), 0);
- EXPECT_CALL(*this, transport_recv_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, transport_recv_frame(_, _, _)).Times(0);
activate_router(0);
- receive_data(UP_LINK,
- router_buffers[1].send_buffers[UP_LINK].data(),
- router_buffers[1].send_buffers[UP_LINK].size());
+ receive_data(UP_LINK, router_buffers[1].send_buffers[UP_LINK].data(), router_buffers[1].send_buffers[UP_LINK].size());
EXPECT_EQ(router_buffers[0].send_buffers[UP_LINK].size(), 0);
EXPECT_EQ(router_buffers[0].send_buffers[DOWN_LINK].size(), 0);
}
diff --git a/quantum/serial_link/tests/frame_validator_tests.cpp b/quantum/serial_link/tests/frame_validator_tests.cpp
index 9223af83b0..43dc57b633 100644
--- a/quantum/serial_link/tests/frame_validator_tests.cpp
+++ b/quantum/serial_link/tests/frame_validator_tests.cpp
@@ -29,21 +29,17 @@ extern "C" {
}
using testing::_;
-using testing::ElementsAreArray;
using testing::Args;
+using testing::ElementsAreArray;
class FrameValidator : public testing::Test {
-public:
- FrameValidator() {
- Instance = this;
- }
+ public:
+ FrameValidator() { Instance = this; }
- ~FrameValidator() {
- Instance = nullptr;
- }
+ ~FrameValidator() { Instance = nullptr; }
- MOCK_METHOD3(route_incoming_frame, void (uint8_t link, uint8_t* data, uint16_t size));
- MOCK_METHOD3(byte_stuffer_send_frame, void (uint8_t link, uint8_t* data, uint16_t size));
+ MOCK_METHOD3(route_incoming_frame, void(uint8_t link, uint8_t* data, uint16_t size));
+ MOCK_METHOD3(byte_stuffer_send_frame, void(uint8_t link, uint8_t* data, uint16_t size));
static FrameValidator* Instance;
};
@@ -51,18 +47,13 @@ public:
FrameValidator* FrameValidator::Instance = nullptr;
extern "C" {
-void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size) {
- FrameValidator::Instance->route_incoming_frame(link, data, size);
-}
+void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size) { FrameValidator::Instance->route_incoming_frame(link, data, size); }
-void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size) {
- FrameValidator::Instance->byte_stuffer_send_frame(link, data, size);
-}
+void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size) { FrameValidator::Instance->byte_stuffer_send_frame(link, data, size); }
}
TEST_F(FrameValidator, doesnt_validate_frames_under_5_bytes) {
- EXPECT_CALL(*this, route_incoming_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, route_incoming_frame(_, _, _)).Times(0);
uint8_t data[] = {1, 2};
validator_recv_frame(0, 0, 1);
validator_recv_frame(0, data, 2);
@@ -72,44 +63,38 @@ TEST_F(FrameValidator, doesnt_validate_frames_under_5_bytes) {
TEST_F(FrameValidator, validates_one_byte_frame_with_correct_crc) {
uint8_t data[] = {0x44, 0x04, 0x6A, 0xB3, 0xA3};
- EXPECT_CALL(*this, route_incoming_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(data, 1)));
+ EXPECT_CALL(*this, route_incoming_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(data, 1)));
validator_recv_frame(0, data, 5);
}
TEST_F(FrameValidator, does_not_validate_one_byte_frame_with_incorrect_crc) {
uint8_t data[] = {0x44, 0, 0, 0, 0};
- EXPECT_CALL(*this, route_incoming_frame(_, _, _))
- .Times(0);
+ EXPECT_CALL(*this, route_incoming_frame(_, _, _)).Times(0);
validator_recv_frame(1, data, 5);
}
TEST_F(FrameValidator, validates_four_byte_frame_with_correct_crc) {
uint8_t data[] = {0x44, 0x10, 0xFF, 0x00, 0x74, 0x4E, 0x30, 0xBA};
- EXPECT_CALL(*this, route_incoming_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(data, 4)));
+ EXPECT_CALL(*this, route_incoming_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(data, 4)));
validator_recv_frame(1, data, 8);
}
TEST_F(FrameValidator, validates_five_byte_frame_with_correct_crc) {
uint8_t data[] = {1, 2, 3, 4, 5, 0xF4, 0x99, 0x0B, 0x47};
- EXPECT_CALL(*this, route_incoming_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(data, 5)));
+ EXPECT_CALL(*this, route_incoming_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(data, 5)));
validator_recv_frame(0, data, 9);
}
TEST_F(FrameValidator, sends_one_byte_with_correct_crc) {
uint8_t original[] = {0x44, 0, 0, 0, 0};
uint8_t expected[] = {0x44, 0x04, 0x6A, 0xB3, 0xA3};
- EXPECT_CALL(*this, byte_stuffer_send_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, byte_stuffer_send_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
validator_send_frame(0, original, 1);
}
TEST_F(FrameValidator, sends_five_bytes_with_correct_crc) {
uint8_t original[] = {1, 2, 3, 4, 5, 0, 0, 0, 0};
uint8_t expected[] = {1, 2, 3, 4, 5, 0xF4, 0x99, 0x0B, 0x47};
- EXPECT_CALL(*this, byte_stuffer_send_frame(_, _, _))
- .With(Args<1, 2>(ElementsAreArray(expected)));
+ EXPECT_CALL(*this, byte_stuffer_send_frame(_, _, _)).With(Args<1, 2>(ElementsAreArray(expected)));
validator_send_frame(0, original, 5);
}
diff --git a/quantum/serial_link/tests/transport_tests.cpp b/quantum/serial_link/tests/transport_tests.cpp
index 21b7b165f6..cfd1110460 100644
--- a/quantum/serial_link/tests/transport_tests.cpp
+++ b/quantum/serial_link/tests/transport_tests.cpp
@@ -26,8 +26,8 @@ SOFTWARE.
#include "gmock/gmock.h"
using testing::_;
-using testing::ElementsAreArray;
using testing::Args;
+using testing::ElementsAreArray;
extern "C" {
#include "serial_link/protocol/transport.h"
@@ -53,7 +53,7 @@ static remote_object_t* test_remote_objects[] = {
};
class Transport : public testing::Test {
-public:
+ public:
Transport() {
Instance = this;
add_remote_objects(test_remote_objects, sizeof(test_remote_objects) / sizeof(remote_object_t*));
@@ -64,8 +64,8 @@ public:
reinitialize_serial_link_transport();
}
- MOCK_METHOD0(signal_data_written, void ());
- MOCK_METHOD1(router_send_frame, void (uint8_t destination));
+ MOCK_METHOD0(signal_data_written, void());
+ MOCK_METHOD1(router_send_frame, void(uint8_t destination));
void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) {
router_send_frame(destination);
@@ -80,13 +80,9 @@ public:
Transport* Transport::Instance = nullptr;
extern "C" {
-void signal_data_written(void) {
- Transport::Instance->signal_data_written();
-}
+void signal_data_written(void) { Transport::Instance->signal_data_written(); }
-void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) {
- Transport::Instance->router_send_frame(destination, data, size);
-}
+void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) { Transport::Instance->router_send_frame(destination, data, size); }
}
TEST_F(Transport, write_to_local_signals_an_event) {
@@ -104,7 +100,7 @@ TEST_F(Transport, write_to_local_signals_an_event) {
TEST_F(Transport, writes_from_master_to_all_slaves) {
update_transport();
test_object1* obj = begin_write_master_to_slave();
- obj->test = 5;
+ obj->test = 5;
EXPECT_CALL(*this, signal_data_written());
end_write_master_to_slave();
EXPECT_CALL(*this, router_send_frame(0xFF));
@@ -118,7 +114,7 @@ TEST_F(Transport, writes_from_master_to_all_slaves) {
TEST_F(Transport, writes_from_slave_to_master) {
update_transport();
test_object1* obj = begin_write_slave_to_master();
- obj->test = 7;
+ obj->test = 7;
EXPECT_CALL(*this, signal_data_written());
end_write_slave_to_master();
EXPECT_CALL(*this, router_send_frame(0));
@@ -133,7 +129,7 @@ TEST_F(Transport, writes_from_slave_to_master) {
TEST_F(Transport, writes_from_master_to_single_slave) {
update_transport();
test_object1* obj = begin_write_master_to_single_slave(3);
- obj->test = 7;
+ obj->test = 7;
EXPECT_CALL(*this, signal_data_written());
end_write_master_to_single_slave(3);
EXPECT_CALL(*this, router_send_frame(4));
@@ -147,7 +143,7 @@ TEST_F(Transport, writes_from_master_to_single_slave) {
TEST_F(Transport, ignores_object_with_invalid_id) {
update_transport();
test_object1* obj = begin_write_master_to_single_slave(3);
- obj->test = 7;
+ obj->test = 7;
EXPECT_CALL(*this, signal_data_written());
end_write_master_to_single_slave(3);
EXPECT_CALL(*this, router_send_frame(4));
@@ -161,7 +157,7 @@ TEST_F(Transport, ignores_object_with_invalid_id) {
TEST_F(Transport, ignores_object_with_size_too_small) {
update_transport();
test_object1* obj = begin_write_master_to_slave();
- obj->test = 7;
+ obj->test = 7;
EXPECT_CALL(*this, signal_data_written());
end_write_master_to_slave();
EXPECT_CALL(*this, router_send_frame(_));
@@ -175,7 +171,7 @@ TEST_F(Transport, ignores_object_with_size_too_small) {
TEST_F(Transport, ignores_object_with_size_too_big) {
update_transport();
test_object1* obj = begin_write_master_to_slave();
- obj->test = 7;
+ obj->test = 7;
EXPECT_CALL(*this, signal_data_written());
end_write_master_to_slave();
EXPECT_CALL(*this, router_send_frame(_));
diff --git a/quantum/serial_link/tests/triple_buffered_object_tests.cpp b/quantum/serial_link/tests/triple_buffered_object_tests.cpp
index 7724bbee9c..8de9bfdebf 100644
--- a/quantum/serial_link/tests/triple_buffered_object_tests.cpp
+++ b/quantum/serial_link/tests/triple_buffered_object_tests.cpp
@@ -27,18 +27,16 @@ extern "C" {
#include "serial_link/protocol/triple_buffered_object.h"
}
-struct test_object{
- uint8_t state;
+struct test_object {
+ uint8_t state;
uint32_t buffer[3];
};
test_object test_object;
class TripleBufferedObject : public testing::Test {
-public:
- TripleBufferedObject() {
- triple_buffer_init((triple_buffer_object_t*)&test_object);
- }
+ public:
+ TripleBufferedObject() { triple_buffer_init((triple_buffer_object_t*)&test_object); }
};
TEST_F(TripleBufferedObject, writes_and_reads_object) {
@@ -47,9 +45,7 @@ TEST_F(TripleBufferedObject, writes_and_reads_object) {
EXPECT_EQ(*triple_buffer_read(&test_object), 0x3456ABCC);
}
-TEST_F(TripleBufferedObject, does_not_read_empty) {
- EXPECT_EQ(triple_buffer_read(&test_object), nullptr);
-}
+TEST_F(TripleBufferedObject, does_not_read_empty) { EXPECT_EQ(triple_buffer_read(&test_object), nullptr); }
TEST_F(TripleBufferedObject, writes_twice_and_reads_object) {
*triple_buffer_begin_write(&test_object) = 0x3456ABCC;
@@ -62,7 +58,7 @@ TEST_F(TripleBufferedObject, writes_twice_and_reads_object) {
TEST_F(TripleBufferedObject, performs_another_write_in_the_middle_of_read) {
*triple_buffer_begin_write(&test_object) = 1;
triple_buffer_end_write(&test_object);
- uint32_t* read = triple_buffer_read(&test_object);
+ uint32_t* read = triple_buffer_read(&test_object);
*triple_buffer_begin_write(&test_object) = 2;
triple_buffer_end_write(&test_object);
EXPECT_EQ(*read, 1);
@@ -73,7 +69,7 @@ TEST_F(TripleBufferedObject, performs_another_write_in_the_middle_of_read) {
TEST_F(TripleBufferedObject, performs_two_writes_in_the_middle_of_read) {
*triple_buffer_begin_write(&test_object) = 1;
triple_buffer_end_write(&test_object);
- uint32_t* read = triple_buffer_read(&test_object);
+ uint32_t* read = triple_buffer_read(&test_object);
*triple_buffer_begin_write(&test_object) = 2;
triple_buffer_end_write(&test_object);
*triple_buffer_begin_write(&test_object) = 3;
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index 3c3daf3d3b..7176d0cc4f 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -30,24 +30,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "transport.h"
#ifdef ENCODER_ENABLE
- #include "encoder.h"
+# include "encoder.h"
#endif
#if (MATRIX_COLS <= 8)
-# define print_matrix_header() print("\nr/c 01234567\n")
-# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
-# define matrix_bitpop(i) bitpop(matrix[i])
-# define ROW_SHIFTER ((uint8_t)1)
+# define print_matrix_header() print("\nr/c 01234567\n")
+# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
+# define matrix_bitpop(i) bitpop(matrix[i])
+# define ROW_SHIFTER ((uint8_t)1)
#elif (MATRIX_COLS <= 16)
-# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
-# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
-# define matrix_bitpop(i) bitpop16(matrix[i])
-# define ROW_SHIFTER ((uint16_t)1)
+# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
+# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
+# define matrix_bitpop(i) bitpop16(matrix[i])
+# define ROW_SHIFTER ((uint16_t)1)
#elif (MATRIX_COLS <= 32)
-# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
-# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
-# define matrix_bitpop(i) bitpop32(matrix[i])
-# define ROW_SHIFTER ((uint32_t)1)
+# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
+# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
+# define matrix_bitpop(i) bitpop32(matrix[i])
+# define ROW_SHIFTER ((uint32_t)1)
#endif
#define ERROR_DISCONNECT_COUNT 5
@@ -87,8 +87,8 @@ inline uint8_t matrix_rows(void) { return MATRIX_ROWS; }
inline uint8_t matrix_cols(void) { return MATRIX_COLS; }
bool matrix_is_modified(void) {
- if (debounce_active()) return false;
- return true;
+ if (debounce_active()) return false;
+ return true;
}
inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); }
@@ -96,22 +96,22 @@ inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((mat
inline matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; }
void matrix_print(void) {
- print_matrix_header();
-
- for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- phex(row);
- print(": ");
- print_matrix_row(row);
- print("\n");
- }
+ print_matrix_header();
+
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ phex(row);
+ print(": ");
+ print_matrix_row(row);
+ print("\n");
+ }
}
uint8_t matrix_key_count(void) {
- uint8_t count = 0;
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- count += matrix_bitpop(i);
- }
- return count;
+ uint8_t count = 0;
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ count += matrix_bitpop(i);
+ }
+ return count;
}
// matrix code
@@ -119,216 +119,222 @@ uint8_t matrix_key_count(void) {
#ifdef DIRECT_PINS
static void init_pins(void) {
- for (int row = 0; row < MATRIX_ROWS; row++) {
- for (int col = 0; col < MATRIX_COLS; col++) {
- pin_t pin = direct_pins[row][col];
- if (pin != NO_PIN) {
- setPinInputHigh(pin);
- }
+ for (int row = 0; row < MATRIX_ROWS; row++) {
+ for (int col = 0; col < MATRIX_COLS; col++) {
+ pin_t pin = direct_pins[row][col];
+ if (pin != NO_PIN) {
+ setPinInputHigh(pin);
+ }
+ }
}
- }
}
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
- matrix_row_t last_row_value = current_matrix[current_row];
- current_matrix[current_row] = 0;
+ matrix_row_t last_row_value = current_matrix[current_row];
+ current_matrix[current_row] = 0;
- for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
- pin_t pin = direct_pins[current_row][col_index];
- if (pin != NO_PIN) {
- current_matrix[current_row] |= readPin(pin) ? 0 : (ROW_SHIFTER << col_index);
+ for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
+ pin_t pin = direct_pins[current_row][col_index];
+ if (pin != NO_PIN) {
+ current_matrix[current_row] |= readPin(pin) ? 0 : (ROW_SHIFTER << col_index);
+ }
}
- }
- return (last_row_value != current_matrix[current_row]);
+ return (last_row_value != current_matrix[current_row]);
}
#elif (DIODE_DIRECTION == COL2ROW)
static void select_row(uint8_t row) {
- setPinOutput(row_pins[row]);
- writePinLow(row_pins[row]);
+ setPinOutput(row_pins[row]);
+ writePinLow(row_pins[row]);
}
static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); }
static void unselect_rows(void) {
- for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
- setPinInputHigh(row_pins[x]);
- }
+ for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
+ setPinInputHigh(row_pins[x]);
+ }
}
static void init_pins(void) {
- unselect_rows();
- for (uint8_t x = 0; x < MATRIX_COLS; x++) {
- setPinInputHigh(col_pins[x]);
- }
+ unselect_rows();
+ for (uint8_t x = 0; x < MATRIX_COLS; x++) {
+ setPinInputHigh(col_pins[x]);
+ }
}
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
- // Store last value of row prior to reading
- matrix_row_t last_row_value = current_matrix[current_row];
+ // Store last value of row prior to reading
+ matrix_row_t last_row_value = current_matrix[current_row];
- // Clear data in matrix row
- current_matrix[current_row] = 0;
+ // Clear data in matrix row
+ current_matrix[current_row] = 0;
- // Select row and wait for row selecton to stabilize
- select_row(current_row);
- wait_us(30);
+ // Select row and wait for row selecton to stabilize
+ select_row(current_row);
+ wait_us(30);
- // For each col...
- for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
- // Populate the matrix row with the state of the col pin
- current_matrix[current_row] |= readPin(col_pins[col_index]) ? 0 : (ROW_SHIFTER << col_index);
- }
+ // For each col...
+ for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
+ // Populate the matrix row with the state of the col pin
+ current_matrix[current_row] |= readPin(col_pins[col_index]) ? 0 : (ROW_SHIFTER << col_index);
+ }
- // Unselect row
- unselect_row(current_row);
+ // Unselect row
+ unselect_row(current_row);
- return (last_row_value != current_matrix[current_row]);
+ return (last_row_value != current_matrix[current_row]);
}
#elif (DIODE_DIRECTION == ROW2COL)
static void select_col(uint8_t col) {
- setPinOutput(col_pins[col]);
- writePinLow(col_pins[col]);
+ setPinOutput(col_pins[col]);
+ writePinLow(col_pins[col]);
}
static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); }
static void unselect_cols(void) {
- for (uint8_t x = 0; x < MATRIX_COLS; x++) {
- setPinInputHigh(col_pins[x]);
- }
+ for (uint8_t x = 0; x < MATRIX_COLS; x++) {
+ setPinInputHigh(col_pins[x]);
+ }
}
static void init_pins(void) {
- unselect_cols();
- for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
- setPinInputHigh(row_pins[x]);
- }
+ unselect_cols();
+ for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
+ setPinInputHigh(row_pins[x]);
+ }
}
static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
- bool matrix_changed = false;
-
- // Select col and wait for col selecton to stabilize
- select_col(current_col);
- wait_us(30);
-
- // For each row...
- for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
- // Store last value of row prior to reading
- matrix_row_t last_row_value = current_matrix[row_index];
-
- // Check row pin state
- if (readPin(row_pins[row_index])) {
- // Pin HI, clear col bit
- current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
- } else {
- // Pin LO, set col bit
- current_matrix[row_index] |= (ROW_SHIFTER << current_col);
- }
+ bool matrix_changed = false;
+
+ // Select col and wait for col selecton to stabilize
+ select_col(current_col);
+ wait_us(30);
+
+ // For each row...
+ for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
+ // Store last value of row prior to reading
+ matrix_row_t last_row_value = current_matrix[row_index];
+
+ // Check row pin state
+ if (readPin(row_pins[row_index])) {
+ // Pin HI, clear col bit
+ current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
+ } else {
+ // Pin LO, set col bit
+ current_matrix[row_index] |= (ROW_SHIFTER << current_col);
+ }
- // Determine if the matrix changed state
- if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
- matrix_changed = true;
+ // Determine if the matrix changed state
+ if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
+ matrix_changed = true;
+ }
}
- }
- // Unselect col
- unselect_col(current_col);
+ // Unselect col
+ unselect_col(current_col);
- return matrix_changed;
+ return matrix_changed;
}
#endif
void matrix_init(void) {
- debug_enable = true;
- debug_matrix = true;
- debug_mouse = true;
-
- // Set pinout for right half if pinout for that half is defined
- if (!isLeftHand) {
+ keyboard_split_setup();
+
+ // Set pinout for right half if pinout for that half is defined
+ if (!isLeftHand) {
+#ifdef DIRECT_PINS_RIGHT
+ const pin_t direct_pins_right[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS_RIGHT;
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ for (uint8_t j = 0; j < MATRIX_COLS; j++) {
+ direct_pins[i][j] = direct_pins_right[i][j];
+ }
+ }
+#endif
#ifdef MATRIX_ROW_PINS_RIGHT
- const uint8_t row_pins_right[MATRIX_ROWS] = MATRIX_ROW_PINS_RIGHT;
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- row_pins[i] = row_pins_right[i];
- }
+ const pin_t row_pins_right[MATRIX_ROWS] = MATRIX_ROW_PINS_RIGHT;
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ row_pins[i] = row_pins_right[i];
+ }
#endif
#ifdef MATRIX_COL_PINS_RIGHT
- const uint8_t col_pins_right[MATRIX_COLS] = MATRIX_COL_PINS_RIGHT;
- for (uint8_t i = 0; i < MATRIX_COLS; i++) {
- col_pins[i] = col_pins_right[i];
- }
+ const pin_t col_pins_right[MATRIX_COLS] = MATRIX_COL_PINS_RIGHT;
+ for (uint8_t i = 0; i < MATRIX_COLS; i++) {
+ col_pins[i] = col_pins_right[i];
+ }
#endif
- }
+ }
- thisHand = isLeftHand ? 0 : (ROWS_PER_HAND);
- thatHand = ROWS_PER_HAND - thisHand;
+ thisHand = isLeftHand ? 0 : (ROWS_PER_HAND);
+ thatHand = ROWS_PER_HAND - thisHand;
- // initialize key pins
- init_pins();
+ // initialize key pins
+ init_pins();
- // initialize matrix state: all keys off
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- matrix[i] = 0;
- }
+ // initialize matrix state: all keys off
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ matrix[i] = 0;
+ }
- debounce_init(ROWS_PER_HAND);
+ debounce_init(ROWS_PER_HAND);
- matrix_init_quantum();
+ matrix_init_quantum();
}
uint8_t _matrix_scan(void) {
- bool changed = false;
+ bool changed = false;
#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
- // Set row, read cols
- for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) {
- changed |= read_cols_on_row(raw_matrix, current_row);
- }
+ // Set row, read cols
+ for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) {
+ changed |= read_cols_on_row(raw_matrix, current_row);
+ }
#elif (DIODE_DIRECTION == ROW2COL)
- // Set col, read rows
- for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
- changed |= read_rows_on_col(raw_matrix, current_col);
- }
+ // Set col, read rows
+ for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
+ changed |= read_rows_on_col(raw_matrix, current_col);
+ }
#endif
- debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed);
+ debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed);
- return (uint8_t)changed;
+ return (uint8_t)changed;
}
uint8_t matrix_scan(void) {
- uint8_t ret = _matrix_scan();
-
- if (is_keyboard_master()) {
- static uint8_t error_count;
-
- if (!transport_master(matrix + thatHand)) {
- error_count++;
-
- if (error_count > ERROR_DISCONNECT_COUNT) {
- // reset other half if disconnected
- for (int i = 0; i < ROWS_PER_HAND; ++i) {
- matrix[thatHand + i] = 0;
+ uint8_t ret = _matrix_scan();
+
+ if (is_keyboard_master()) {
+ static uint8_t error_count;
+
+ if (!transport_master(matrix + thatHand)) {
+ error_count++;
+
+ if (error_count > ERROR_DISCONNECT_COUNT) {
+ // reset other half if disconnected
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ matrix[thatHand + i] = 0;
+ }
+ }
+ } else {
+ error_count = 0;
}
- }
- } else {
- error_count = 0;
- }
- matrix_scan_quantum();
- } else {
- transport_slave(matrix + thisHand);
+ matrix_scan_quantum();
+ } else {
+ transport_slave(matrix + thisHand);
#ifdef ENCODER_ENABLE
- encoder_read();
+ encoder_read();
#endif
- matrix_slave_scan_user();
- }
+ matrix_slave_scan_user();
+ }
- return ret;
+ return ret;
}
diff --git a/quantum/split_common/post_config.h b/quantum/split_common/post_config.h
index ff0fc5e193..5c0b414fb3 100644
--- a/quantum/split_common/post_config.h
+++ b/quantum/split_common/post_config.h
@@ -1,19 +1,19 @@
#if defined(USE_I2C) || defined(EH)
- // When using I2C, using rgblight implicitly involves split support.
- #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_SPLIT)
- #define RGBLIGHT_SPLIT
- #endif
+// When using I2C, using rgblight implicitly involves split support.
+# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_SPLIT)
+# define RGBLIGHT_SPLIT
+# endif
- #ifndef F_SCL
- #define F_SCL 100000UL // SCL frequency
- #endif
+# ifndef F_SCL
+# define F_SCL 100000UL // SCL frequency
+# endif
#else // use serial
- // When using serial, the user must define RGBLIGHT_SPLIT explicitly
- // in config.h as needed.
- // see quantum/rgblight_post_config.h
- #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
- // When using serial and RGBLIGHT_SPLIT need separate transaction
- #define SERIAL_USE_MULTI_TRANSACTION
- #endif
+// When using serial, the user must define RGBLIGHT_SPLIT explicitly
+// in config.h as needed.
+// see quantum/rgblight_post_config.h
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+// When using serial and RGBLIGHT_SPLIT need separate transaction
+# define SERIAL_USE_MULTI_TRANSACTION
+# endif
#endif
diff --git a/quantum/split_common/serial.c b/quantum/split_common/serial.c
index 1315377a34..c27cbfdd0a 100644
--- a/quantum/split_common/serial.c
+++ b/quantum/split_common/serial.c
@@ -8,7 +8,7 @@
*/
#ifndef F_CPU
-#define F_CPU 16000000
+# define F_CPU 16000000
#endif
#include <avr/io.h>
@@ -17,261 +17,227 @@
#include <stddef.h>
#include <stdbool.h>
#include "serial.h"
-//#include <pro_micro.h>
#ifdef SOFT_SERIAL_PIN
-#ifdef __AVR_ATmega32U4__
- // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
- #ifdef USE_AVR_I2C
- #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
- #error Using ATmega32U4 I2C, so can not use PD0, PD1
- #endif
- #endif
-
- #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3
- #define SERIAL_PIN_DDR DDRD
- #define SERIAL_PIN_PORT PORTD
- #define SERIAL_PIN_INPUT PIND
- #if SOFT_SERIAL_PIN == D0
- #define SERIAL_PIN_MASK _BV(PD0)
- #define EIMSK_BIT _BV(INT0)
- #define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01)))
- #define SERIAL_PIN_INTERRUPT INT0_vect
- #elif SOFT_SERIAL_PIN == D1
- #define SERIAL_PIN_MASK _BV(PD1)
- #define EIMSK_BIT _BV(INT1)
- #define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11)))
- #define SERIAL_PIN_INTERRUPT INT1_vect
- #elif SOFT_SERIAL_PIN == D2
- #define SERIAL_PIN_MASK _BV(PD2)
- #define EIMSK_BIT _BV(INT2)
- #define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21)))
- #define SERIAL_PIN_INTERRUPT INT2_vect
- #elif SOFT_SERIAL_PIN == D3
- #define SERIAL_PIN_MASK _BV(PD3)
- #define EIMSK_BIT _BV(INT3)
- #define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
- #define SERIAL_PIN_INTERRUPT INT3_vect
- #endif
- #elif SOFT_SERIAL_PIN == E6
- #define SERIAL_PIN_DDR DDRE
- #define SERIAL_PIN_PORT PORTE
- #define SERIAL_PIN_INPUT PINE
- #define SERIAL_PIN_MASK _BV(PE6)
- #define EIMSK_BIT _BV(INT6)
- #define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
- #define SERIAL_PIN_INTERRUPT INT6_vect
- #else
- #error invalid SOFT_SERIAL_PIN value
- #endif
-
-#else
- #error serial.c now support ATmega32U4 only
-#endif
-
-#define ALWAYS_INLINE __attribute__((always_inline))
-#define NO_INLINE __attribute__((noinline))
-#define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
+# ifdef __AVR_ATmega32U4__
+// if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
+# ifdef USE_AVR_I2C
+# if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
+# error Using ATmega32U4 I2C, so can not use PD0, PD1
+# endif
+# endif
+
+# define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
+# define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
+# define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
+
+# if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3
+# if SOFT_SERIAL_PIN == D0
+# define EIMSK_BIT _BV(INT0)
+# define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01)))
+# define SERIAL_PIN_INTERRUPT INT0_vect
+# elif SOFT_SERIAL_PIN == D1
+# define EIMSK_BIT _BV(INT1)
+# define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11)))
+# define SERIAL_PIN_INTERRUPT INT1_vect
+# elif SOFT_SERIAL_PIN == D2
+# define EIMSK_BIT _BV(INT2)
+# define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21)))
+# define SERIAL_PIN_INTERRUPT INT2_vect
+# elif SOFT_SERIAL_PIN == D3
+# define EIMSK_BIT _BV(INT3)
+# define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
+# define SERIAL_PIN_INTERRUPT INT3_vect
+# endif
+# elif SOFT_SERIAL_PIN == E6
+# define EIMSK_BIT _BV(INT6)
+# define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
+# define SERIAL_PIN_INTERRUPT INT6_vect
+# else
+# error invalid SOFT_SERIAL_PIN value
+# endif
+
+# else
+# error serial.c now support ATmega32U4 only
+# endif
+
+# define ALWAYS_INLINE __attribute__((always_inline))
+# define NO_INLINE __attribute__((noinline))
+# define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
// parity check
-#define ODD_PARITY 1
-#define EVEN_PARITY 0
-#define PARITY EVEN_PARITY
-
-#ifdef SERIAL_DELAY
- // custom setup in config.h
- // #define TID_SEND_ADJUST 2
- // #define SERIAL_DELAY 6 // micro sec
- // #define READ_WRITE_START_ADJUST 30 // cycles
- // #define READ_WRITE_WIDTH_ADJUST 8 // cycles
-#else
+# define ODD_PARITY 1
+# define EVEN_PARITY 0
+# define PARITY EVEN_PARITY
+
+# ifdef SERIAL_DELAY
+// custom setup in config.h
+// #define TID_SEND_ADJUST 2
+// #define SERIAL_DELAY 6 // micro sec
+// #define READ_WRITE_START_ADJUST 30 // cycles
+// #define READ_WRITE_WIDTH_ADJUST 8 // cycles
+# else
// ============ Standard setups ============
-#ifndef SELECT_SOFT_SERIAL_SPEED
-#define SELECT_SOFT_SERIAL_SPEED 1
+# ifndef SELECT_SOFT_SERIAL_SPEED
+# define SELECT_SOFT_SERIAL_SPEED 1
// 0: about 189kbps (Experimental only)
// 1: about 137kbps (default)
// 2: about 75kbps
// 3: about 39kbps
// 4: about 26kbps
// 5: about 20kbps
-#endif
-
-#if __GNUC__ < 6
- #define TID_SEND_ADJUST 14
-#else
- #define TID_SEND_ADJUST 2
-#endif
-
-#if SELECT_SOFT_SERIAL_SPEED == 0
- // Very High speed
- #define SERIAL_DELAY 4 // micro sec
- #if __GNUC__ < 6
- #define READ_WRITE_START_ADJUST 33 // cycles
- #define READ_WRITE_WIDTH_ADJUST 3 // cycles
- #else
- #define READ_WRITE_START_ADJUST 34 // cycles
- #define READ_WRITE_WIDTH_ADJUST 7 // cycles
- #endif
-#elif SELECT_SOFT_SERIAL_SPEED == 1
- // High speed
- #define SERIAL_DELAY 6 // micro sec
- #if __GNUC__ < 6
- #define READ_WRITE_START_ADJUST 30 // cycles
- #define READ_WRITE_WIDTH_ADJUST 3 // cycles
- #else
- #define READ_WRITE_START_ADJUST 33 // cycles
- #define READ_WRITE_WIDTH_ADJUST 7 // cycles
- #endif
-#elif SELECT_SOFT_SERIAL_SPEED == 2
- // Middle speed
- #define SERIAL_DELAY 12 // micro sec
- #define READ_WRITE_START_ADJUST 30 // cycles
- #if __GNUC__ < 6
- #define READ_WRITE_WIDTH_ADJUST 3 // cycles
- #else
- #define READ_WRITE_WIDTH_ADJUST 7 // cycles
- #endif
-#elif SELECT_SOFT_SERIAL_SPEED == 3
- // Low speed
- #define SERIAL_DELAY 24 // micro sec
- #define READ_WRITE_START_ADJUST 30 // cycles
- #if __GNUC__ < 6
- #define READ_WRITE_WIDTH_ADJUST 3 // cycles
- #else
- #define READ_WRITE_WIDTH_ADJUST 7 // cycles
- #endif
-#elif SELECT_SOFT_SERIAL_SPEED == 4
- // Very Low speed
- #define SERIAL_DELAY 36 // micro sec
- #define READ_WRITE_START_ADJUST 30 // cycles
- #if __GNUC__ < 6
- #define READ_WRITE_WIDTH_ADJUST 3 // cycles
- #else
- #define READ_WRITE_WIDTH_ADJUST 7 // cycles
- #endif
-#elif SELECT_SOFT_SERIAL_SPEED == 5
- // Ultra Low speed
- #define SERIAL_DELAY 48 // micro sec
- #define READ_WRITE_START_ADJUST 30 // cycles
- #if __GNUC__ < 6
- #define READ_WRITE_WIDTH_ADJUST 3 // cycles
- #else
- #define READ_WRITE_WIDTH_ADJUST 7 // cycles
- #endif
-#else
-#error invalid SELECT_SOFT_SERIAL_SPEED value
-#endif /* SELECT_SOFT_SERIAL_SPEED */
-#endif /* SERIAL_DELAY */
-
-#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2)
-#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2)
-
-#define SLAVE_INT_WIDTH_US 1
-#ifndef SERIAL_USE_MULTI_TRANSACTION
- #define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY
-#else
- #define SLAVE_INT_ACK_WIDTH_UNIT 2
- #define SLAVE_INT_ACK_WIDTH 4
-#endif
-
-static SSTD_t *Transaction_table = NULL;
+# endif
+
+# if __GNUC__ < 6
+# define TID_SEND_ADJUST 14
+# else
+# define TID_SEND_ADJUST 2
+# endif
+
+# if SELECT_SOFT_SERIAL_SPEED == 0
+// Very High speed
+# define SERIAL_DELAY 4 // micro sec
+# if __GNUC__ < 6
+# define READ_WRITE_START_ADJUST 33 // cycles
+# define READ_WRITE_WIDTH_ADJUST 3 // cycles
+# else
+# define READ_WRITE_START_ADJUST 34 // cycles
+# define READ_WRITE_WIDTH_ADJUST 7 // cycles
+# endif
+# elif SELECT_SOFT_SERIAL_SPEED == 1
+// High speed
+# define SERIAL_DELAY 6 // micro sec
+# if __GNUC__ < 6
+# define READ_WRITE_START_ADJUST 30 // cycles
+# define READ_WRITE_WIDTH_ADJUST 3 // cycles
+# else
+# define READ_WRITE_START_ADJUST 33 // cycles
+# define READ_WRITE_WIDTH_ADJUST 7 // cycles
+# endif
+# elif SELECT_SOFT_SERIAL_SPEED == 2
+// Middle speed
+# define SERIAL_DELAY 12 // micro sec
+# define READ_WRITE_START_ADJUST 30 // cycles
+# if __GNUC__ < 6
+# define READ_WRITE_WIDTH_ADJUST 3 // cycles
+# else
+# define READ_WRITE_WIDTH_ADJUST 7 // cycles
+# endif
+# elif SELECT_SOFT_SERIAL_SPEED == 3
+// Low speed
+# define SERIAL_DELAY 24 // micro sec
+# define READ_WRITE_START_ADJUST 30 // cycles
+# if __GNUC__ < 6
+# define READ_WRITE_WIDTH_ADJUST 3 // cycles
+# else
+# define READ_WRITE_WIDTH_ADJUST 7 // cycles
+# endif
+# elif SELECT_SOFT_SERIAL_SPEED == 4
+// Very Low speed
+# define SERIAL_DELAY 36 // micro sec
+# define READ_WRITE_START_ADJUST 30 // cycles
+# if __GNUC__ < 6
+# define READ_WRITE_WIDTH_ADJUST 3 // cycles
+# else
+# define READ_WRITE_WIDTH_ADJUST 7 // cycles
+# endif
+# elif SELECT_SOFT_SERIAL_SPEED == 5
+// Ultra Low speed
+# define SERIAL_DELAY 48 // micro sec
+# define READ_WRITE_START_ADJUST 30 // cycles
+# if __GNUC__ < 6
+# define READ_WRITE_WIDTH_ADJUST 3 // cycles
+# else
+# define READ_WRITE_WIDTH_ADJUST 7 // cycles
+# endif
+# else
+# error invalid SELECT_SOFT_SERIAL_SPEED value
+# endif /* SELECT_SOFT_SERIAL_SPEED */
+# endif /* SERIAL_DELAY */
+
+# define SERIAL_DELAY_HALF1 (SERIAL_DELAY / 2)
+# define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY / 2)
+
+# define SLAVE_INT_WIDTH_US 1
+# ifndef SERIAL_USE_MULTI_TRANSACTION
+# define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY
+# else
+# define SLAVE_INT_ACK_WIDTH_UNIT 2
+# define SLAVE_INT_ACK_WIDTH 4
+# endif
+
+static SSTD_t *Transaction_table = NULL;
static uint8_t Transaction_table_size = 0;
inline static void serial_delay(void) ALWAYS_INLINE;
-inline static
-void serial_delay(void) {
- _delay_us(SERIAL_DELAY);
-}
+inline static void serial_delay(void) { _delay_us(SERIAL_DELAY); }
inline static void serial_delay_half1(void) ALWAYS_INLINE;
-inline static
-void serial_delay_half1(void) {
- _delay_us(SERIAL_DELAY_HALF1);
-}
+inline static void serial_delay_half1(void) { _delay_us(SERIAL_DELAY_HALF1); }
inline static void serial_delay_half2(void) ALWAYS_INLINE;
-inline static
-void serial_delay_half2(void) {
- _delay_us(SERIAL_DELAY_HALF2);
-}
+inline static void serial_delay_half2(void) { _delay_us(SERIAL_DELAY_HALF2); }
inline static void serial_output(void) ALWAYS_INLINE;
-inline static
-void serial_output(void) {
- SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
-}
+inline static void serial_output(void) { setPinOutput(SOFT_SERIAL_PIN); }
// make the serial pin an input with pull-up resistor
inline static void serial_input_with_pullup(void) ALWAYS_INLINE;
-inline static
-void serial_input_with_pullup(void) {
- SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
- SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
-}
+inline static void serial_input_with_pullup(void) { setPinInputHigh(SOFT_SERIAL_PIN); }
inline static uint8_t serial_read_pin(void) ALWAYS_INLINE;
-inline static
-uint8_t serial_read_pin(void) {
- return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
-}
+inline static uint8_t serial_read_pin(void) { return !!readPin(SOFT_SERIAL_PIN); }
inline static void serial_low(void) ALWAYS_INLINE;
-inline static
-void serial_low(void) {
- SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
-}
+inline static void serial_low(void) { writePinLow(SOFT_SERIAL_PIN); }
inline static void serial_high(void) ALWAYS_INLINE;
-inline static
-void serial_high(void) {
- SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
-}
+inline static void serial_high(void) { writePinHigh(SOFT_SERIAL_PIN); }
-void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size)
-{
- Transaction_table = sstd_table;
+void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size) {
+ Transaction_table = sstd_table;
Transaction_table_size = (uint8_t)sstd_table_size;
serial_output();
serial_high();
}
-void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size)
-{
- Transaction_table = sstd_table;
+void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size) {
+ Transaction_table = sstd_table;
Transaction_table_size = (uint8_t)sstd_table_size;
serial_input_with_pullup();
// Enable INT0-INT3,INT6
EIMSK |= EIMSK_BIT;
-#if SERIAL_PIN_MASK == _BV(PE6)
+# if SOFT_SERIAL_PIN == E6
// Trigger on falling edge of INT6
EICRB &= EICRx_BIT;
-#else
+# else
// Trigger on falling edge of INT0-INT3
EICRA &= EICRx_BIT;
-#endif
+# endif
}
// Used by the sender to synchronize timing with the reciver.
static void sync_recv(void) NO_INLINE;
-static
-void sync_recv(void) {
- for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) {
- }
- // This shouldn't hang if the target disconnects because the
- // serial line will float to high if the target does disconnect.
- while (!serial_read_pin());
+static void sync_recv(void) {
+ for (uint8_t i = 0; i < SERIAL_DELAY * 5 && serial_read_pin(); i++) {
+ }
+ // This shouldn't hang if the target disconnects because the
+ // serial line will float to high if the target does disconnect.
+ while (!serial_read_pin())
+ ;
}
// Used by the reciver to send a synchronization signal to the sender.
static void sync_send(void) NO_INLINE;
-static
-void sync_send(void) {
- serial_low();
- serial_delay();
- serial_high();
+static void sync_send(void) {
+ serial_low();
+ serial_delay();
+ serial_high();
}
// Reads a byte from the serial line
@@ -279,92 +245,94 @@ static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE;
static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) {
uint8_t byte, i, p, pb;
- _delay_sub_us(READ_WRITE_START_ADJUST);
- for( i = 0, byte = 0, p = PARITY; i < bit; i++ ) {
- serial_delay_half1(); // read the middle of pulses
- if( serial_read_pin() ) {
- byte = (byte << 1) | 1; p ^= 1;
- } else {
- byte = (byte << 1) | 0; p ^= 0;
- }
- _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
- serial_delay_half2();
- }
- /* recive parity bit */
- serial_delay_half1(); // read the middle of pulses
- pb = serial_read_pin();
- _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
- serial_delay_half2();
-
- *pterrcount += (p != pb)? 1 : 0;
-
- return byte;
+ _delay_sub_us(READ_WRITE_START_ADJUST);
+ for (i = 0, byte = 0, p = PARITY; i < bit; i++) {
+ serial_delay_half1(); // read the middle of pulses
+ if (serial_read_pin()) {
+ byte = (byte << 1) | 1;
+ p ^= 1;
+ } else {
+ byte = (byte << 1) | 0;
+ p ^= 0;
+ }
+ _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
+ serial_delay_half2();
+ }
+ /* recive parity bit */
+ serial_delay_half1(); // read the middle of pulses
+ pb = serial_read_pin();
+ _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
+ serial_delay_half2();
+
+ *pterrcount += (p != pb) ? 1 : 0;
+
+ return byte;
}
// Sends a byte with MSB ordering
void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE;
void serial_write_chunk(uint8_t data, uint8_t bit) {
uint8_t b, p;
- for( p = PARITY, b = 1<<(bit-1); b ; b >>= 1) {
- if(data & b) {
- serial_high(); p ^= 1;
+ for (p = PARITY, b = 1 << (bit - 1); b; b >>= 1) {
+ if (data & b) {
+ serial_high();
+ p ^= 1;
} else {
- serial_low(); p ^= 0;
+ serial_low();
+ p ^= 0;
}
serial_delay();
}
/* send parity bit */
- if(p & 1) { serial_high(); }
- else { serial_low(); }
+ if (p & 1) {
+ serial_high();
+ } else {
+ serial_low();
+ }
serial_delay();
- serial_low(); // sync_send() / senc_recv() need raise edge
+ serial_low(); // sync_send() / senc_recv() need raise edge
}
static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
-static
-void serial_send_packet(uint8_t *buffer, uint8_t size) {
- for (uint8_t i = 0; i < size; ++i) {
- uint8_t data;
- data = buffer[i];
- sync_send();
- serial_write_chunk(data,8);
- }
+static void serial_send_packet(uint8_t *buffer, uint8_t size) {
+ for (uint8_t i = 0; i < size; ++i) {
+ uint8_t data;
+ data = buffer[i];
+ sync_send();
+ serial_write_chunk(data, 8);
+ }
}
static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
-static
-uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) {
- uint8_t pecount = 0;
- for (uint8_t i = 0; i < size; ++i) {
- uint8_t data;
- sync_recv();
- data = serial_read_chunk(&pecount, 8);
- buffer[i] = data;
- }
- return pecount == 0;
+static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) {
+ uint8_t pecount = 0;
+ for (uint8_t i = 0; i < size; ++i) {
+ uint8_t data;
+ sync_recv();
+ data = serial_read_chunk(&pecount, 8);
+ buffer[i] = data;
+ }
+ return pecount == 0;
}
-inline static
-void change_sender2reciver(void) {
- sync_send(); //0
- serial_delay_half1(); //1
- serial_low(); //2
- serial_input_with_pullup(); //2
- serial_delay_half1(); //3
+inline static void change_sender2reciver(void) {
+ sync_send(); // 0
+ serial_delay_half1(); // 1
+ serial_low(); // 2
+ serial_input_with_pullup(); // 2
+ serial_delay_half1(); // 3
}
-inline static
-void change_reciver2sender(void) {
- sync_recv(); //0
- serial_delay(); //1
- serial_low(); //3
- serial_output(); //3
- serial_delay_half1(); //4
+inline static void change_reciver2sender(void) {
+ sync_recv(); // 0
+ serial_delay(); // 1
+ serial_low(); // 3
+ serial_output(); // 3
+ serial_delay_half1(); // 4
}
-static inline uint8_t nibble_bits_count(uint8_t bits)
-{
+static inline uint8_t nibble_bits_count(uint8_t bits) {
bits = (bits & 0x5) + (bits >> 1 & 0x5);
bits = (bits & 0x3) + (bits >> 2 & 0x3);
return bits;
@@ -372,51 +340,47 @@ static inline uint8_t nibble_bits_count(uint8_t bits)
// interrupt handle to be used by the target device
ISR(SERIAL_PIN_INTERRUPT) {
+# ifndef SERIAL_USE_MULTI_TRANSACTION
+ serial_low();
+ serial_output();
+ SSTD_t *trans = Transaction_table;
+# else
+ // recive transaction table index
+ uint8_t tid, bits;
+ uint8_t pecount = 0;
+ sync_recv();
+ bits = serial_read_chunk(&pecount, 7);
+ tid = bits >> 3;
+ bits = (bits & 7) != nibble_bits_count(tid);
+ if (bits || pecount > 0 || tid > Transaction_table_size) {
+ return;
+ }
+ serial_delay_half1();
-#ifndef SERIAL_USE_MULTI_TRANSACTION
- serial_low();
- serial_output();
- SSTD_t *trans = Transaction_table;
-#else
- // recive transaction table index
- uint8_t tid, bits;
- uint8_t pecount = 0;
- sync_recv();
- bits = serial_read_chunk(&pecount,7);
- tid = bits>>3;
- bits = (bits&7) != nibble_bits_count(tid);
- if( bits || pecount> 0 || tid > Transaction_table_size ) {
- return;
- }
- serial_delay_half1();
-
- serial_high(); // response step1 low->high
- serial_output();
- _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH);
- SSTD_t *trans = &Transaction_table[tid];
- serial_low(); // response step2 ack high->low
-#endif
+ serial_high(); // response step1 low->high
+ serial_output();
+ _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT * SLAVE_INT_ACK_WIDTH);
+ SSTD_t *trans = &Transaction_table[tid];
+ serial_low(); // response step2 ack high->low
+# endif
+
+ // target send phase
+ if (trans->target2initiator_buffer_size > 0) serial_send_packet((uint8_t *)trans->target2initiator_buffer, trans->target2initiator_buffer_size);
+ // target switch to input
+ change_sender2reciver();
+
+ // target recive phase
+ if (trans->initiator2target_buffer_size > 0) {
+ if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer, trans->initiator2target_buffer_size)) {
+ *trans->status = TRANSACTION_ACCEPTED;
+ } else {
+ *trans->status = TRANSACTION_DATA_ERROR;
+ }
+ } else {
+ *trans->status = TRANSACTION_ACCEPTED;
+ }
- // target send phase
- if( trans->target2initiator_buffer_size > 0 )
- serial_send_packet((uint8_t *)trans->target2initiator_buffer,
- trans->target2initiator_buffer_size);
- // target switch to input
- change_sender2reciver();
-
- // target recive phase
- if( trans->initiator2target_buffer_size > 0 ) {
- if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer,
- trans->initiator2target_buffer_size) ) {
- *trans->status = TRANSACTION_ACCEPTED;
- } else {
- *trans->status = TRANSACTION_DATA_ERROR;
- }
- } else {
- *trans->status = TRANSACTION_ACCEPTED;
- }
-
- sync_recv(); //weit initiator output to high
+ sync_recv(); // weit initiator output to high
}
/////////
@@ -429,105 +393,103 @@ ISR(SERIAL_PIN_INTERRUPT) {
// TRANSACTION_NO_RESPONSE
// TRANSACTION_DATA_ERROR
// this code is very time dependent, so we need to disable interrupts
-#ifndef SERIAL_USE_MULTI_TRANSACTION
-int soft_serial_transaction(void) {
- SSTD_t *trans = Transaction_table;
-#else
-int soft_serial_transaction(int sstd_index) {
- if( sstd_index > Transaction_table_size )
- return TRANSACTION_TYPE_ERROR;
- SSTD_t *trans = &Transaction_table[sstd_index];
-#endif
- cli();
+# ifndef SERIAL_USE_MULTI_TRANSACTION
+int soft_serial_transaction(void) {
+ SSTD_t *trans = Transaction_table;
+# else
+int soft_serial_transaction(int sstd_index) {
+ if (sstd_index > Transaction_table_size) return TRANSACTION_TYPE_ERROR;
+ SSTD_t *trans = &Transaction_table[sstd_index];
+# endif
+ cli();
- // signal to the target that we want to start a transaction
- serial_output();
- serial_low();
- _delay_us(SLAVE_INT_WIDTH_US);
+ // signal to the target that we want to start a transaction
+ serial_output();
+ serial_low();
+ _delay_us(SLAVE_INT_WIDTH_US);
-#ifndef SERIAL_USE_MULTI_TRANSACTION
- // wait for the target response
- serial_input_with_pullup();
- _delay_us(SLAVE_INT_RESPONSE_TIME);
+# ifndef SERIAL_USE_MULTI_TRANSACTION
+ // wait for the target response
+ serial_input_with_pullup();
+ _delay_us(SLAVE_INT_RESPONSE_TIME);
+
+ // check if the target is present
+ if (serial_read_pin()) {
+ // target failed to pull the line low, assume not present
+ serial_output();
+ serial_high();
+ *trans->status = TRANSACTION_NO_RESPONSE;
+ sei();
+ return TRANSACTION_NO_RESPONSE;
+ }
- // check if the target is present
- if (serial_read_pin()) {
- // target failed to pull the line low, assume not present
- serial_output();
- serial_high();
- *trans->status = TRANSACTION_NO_RESPONSE;
- sei();
- return TRANSACTION_NO_RESPONSE;
- }
-
-#else
- // send transaction table index
- int tid = (sstd_index<<3) | (7 & nibble_bits_count(sstd_index));
- sync_send();
- _delay_sub_us(TID_SEND_ADJUST);
- serial_write_chunk(tid, 7);
- serial_delay_half1();
-
- // wait for the target response (step1 low->high)
- serial_input_with_pullup();
- while( !serial_read_pin() ) {
- _delay_sub_us(2);
- }
-
- // check if the target is present (step2 high->low)
- for( int i = 0; serial_read_pin(); i++ ) {
- if (i > SLAVE_INT_ACK_WIDTH + 1) {
- // slave failed to pull the line low, assume not present
- serial_output();
- serial_high();
- *trans->status = TRANSACTION_NO_RESPONSE;
- sei();
- return TRANSACTION_NO_RESPONSE;
- }
- _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT);
- }
-#endif
+# else
+ // send transaction table index
+ int tid = (sstd_index << 3) | (7 & nibble_bits_count(sstd_index));
+ sync_send();
+ _delay_sub_us(TID_SEND_ADJUST);
+ serial_write_chunk(tid, 7);
+ serial_delay_half1();
+
+ // wait for the target response (step1 low->high)
+ serial_input_with_pullup();
+ while (!serial_read_pin()) {
+ _delay_sub_us(2);
+ }
+
+ // check if the target is present (step2 high->low)
+ for (int i = 0; serial_read_pin(); i++) {
+ if (i > SLAVE_INT_ACK_WIDTH + 1) {
+ // slave failed to pull the line low, assume not present
+ serial_output();
+ serial_high();
+ *trans->status = TRANSACTION_NO_RESPONSE;
+ sei();
+ return TRANSACTION_NO_RESPONSE;
+ }
+ _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT);
+ }
+# endif
+
+ // initiator recive phase
+ // if the target is present syncronize with it
+ if (trans->target2initiator_buffer_size > 0) {
+ if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer, trans->target2initiator_buffer_size)) {
+ serial_output();
+ serial_high();
+ *trans->status = TRANSACTION_DATA_ERROR;
+ sei();
+ return TRANSACTION_DATA_ERROR;
+ }
+ }
+
+ // initiator switch to output
+ change_reciver2sender();
+
+ // initiator send phase
+ if (trans->initiator2target_buffer_size > 0) {
+ serial_send_packet((uint8_t *)trans->initiator2target_buffer, trans->initiator2target_buffer_size);
+ }
- // initiator recive phase
- // if the target is present syncronize with it
- if( trans->target2initiator_buffer_size > 0 ) {
- if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer,
- trans->target2initiator_buffer_size) ) {
- serial_output();
- serial_high();
- *trans->status = TRANSACTION_DATA_ERROR;
- sei();
- return TRANSACTION_DATA_ERROR;
- }
- }
-
- // initiator switch to output
- change_reciver2sender();
-
- // initiator send phase
- if( trans->initiator2target_buffer_size > 0 ) {
- serial_send_packet((uint8_t *)trans->initiator2target_buffer,
- trans->initiator2target_buffer_size);
- }
-
- // always, release the line when not in use
- sync_send();
-
- *trans->status = TRANSACTION_END;
- sei();
- return TRANSACTION_END;
+ // always, release the line when not in use
+ sync_send();
+
+ *trans->status = TRANSACTION_END;
+ sei();
+ return TRANSACTION_END;
}
-#ifdef SERIAL_USE_MULTI_TRANSACTION
+# ifdef SERIAL_USE_MULTI_TRANSACTION
int soft_serial_get_and_clean_status(int sstd_index) {
SSTD_t *trans = &Transaction_table[sstd_index];
cli();
- int retval = *trans->status;
- *trans->status = 0;;
+ int retval = *trans->status;
+ *trans->status = 0;
+ ;
sei();
return retval;
}
-#endif
+# endif
#endif
diff --git a/quantum/split_common/serial.h b/quantum/split_common/serial.h
index 1c1e640069..53e66cf905 100644
--- a/quantum/split_common/serial.h
+++ b/quantum/split_common/serial.h
@@ -22,14 +22,14 @@
// /////////////////////////////////////////////////////////////////
// Soft Serial Transaction Descriptor
-typedef struct _SSTD_t {
+typedef struct _SSTD_t {
uint8_t *status;
- uint8_t initiator2target_buffer_size;
+ uint8_t initiator2target_buffer_size;
uint8_t *initiator2target_buffer;
- uint8_t target2initiator_buffer_size;
+ uint8_t target2initiator_buffer_size;
uint8_t *target2initiator_buffer;
} SSTD_t;
-#define TID_LIMIT( table ) (sizeof(table) / sizeof(SSTD_t))
+#define TID_LIMIT(table) (sizeof(table) / sizeof(SSTD_t))
// initiator is transaction start side
void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size);
@@ -39,12 +39,12 @@ void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size);
// initiator resullt
#define TRANSACTION_END 0
#define TRANSACTION_NO_RESPONSE 0x1
-#define TRANSACTION_DATA_ERROR 0x2
-#define TRANSACTION_TYPE_ERROR 0x4
+#define TRANSACTION_DATA_ERROR 0x2
+#define TRANSACTION_TYPE_ERROR 0x4
#ifndef SERIAL_USE_MULTI_TRANSACTION
-int soft_serial_transaction(void);
+int soft_serial_transaction(void);
#else
-int soft_serial_transaction(int sstd_index);
+int soft_serial_transaction(int sstd_index);
#endif
// target status
@@ -58,5 +58,5 @@ int soft_serial_transaction(int sstd_index);
// or TRANSACTION_ACCEPTED
#define TRANSACTION_ACCEPTED 0x8
#ifdef SERIAL_USE_MULTI_TRANSACTION
-int soft_serial_get_and_clean_status(int sstd_index);
+int soft_serial_get_and_clean_status(int sstd_index);
#endif
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index 09a307b8ed..5c548de059 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -7,86 +7,101 @@
#include "quantum.h"
#ifdef EE_HANDS
-# include "tmk_core/common/eeprom.h"
-# include "eeconfig.h"
+# include "eeconfig.h"
#endif
#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
-#include "rgblight.h"
+# include "rgblight.h"
+#endif
+
+#ifndef SPLIT_USB_TIMEOUT
+# define SPLIT_USB_TIMEOUT 2500
#endif
volatile bool isLeftHand = true;
-__attribute__((weak))
-bool is_keyboard_left(void) {
- #if defined(SPLIT_HAND_PIN)
+bool waitForUsb(void) {
+ for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / 100); i++) {
+ // This will return true of a USB connection has been established
+#if defined(__AVR__)
+ if (UDADDR & _BV(ADDEN)) {
+#else
+ if (usbGetDriverStateI(&USBD1) == USB_ACTIVE) {
+#endif
+ return true;
+ }
+ wait_ms(100);
+ }
+
+#if defined(__AVR__)
+ // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow
+ (USBCON &= ~(_BV(USBE) | _BV(OTGPADE)));
+#endif
+
+ return false;
+}
+
+__attribute__((weak)) bool is_keyboard_left(void) {
+#if defined(SPLIT_HAND_PIN)
// Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
setPinInput(SPLIT_HAND_PIN);
return readPin(SPLIT_HAND_PIN);
- #elif defined(EE_HANDS)
- return eeprom_read_byte(EECONFIG_HANDEDNESS);
- #elif defined(MASTER_RIGHT)
+#elif defined(EE_HANDS)
+ return eeconfig_read_handedness();
+#elif defined(MASTER_RIGHT)
return !is_keyboard_master();
- #endif
+#endif
- return is_keyboard_master();
+ return is_keyboard_master();
}
-bool is_keyboard_master(void)
-{
-#ifdef __AVR__
- static enum { UNKNOWN, MASTER, SLAVE } usbstate = UNKNOWN;
+__attribute__((weak)) bool is_keyboard_master(void) {
+ static enum { UNKNOWN, MASTER, SLAVE } usbstate = UNKNOWN;
- // only check once, as this is called often
- if (usbstate == UNKNOWN)
- {
- USBCON |= (1 << OTGPADE); // enables VBUS pad
- wait_us(5);
+ // only check once, as this is called often
+ if (usbstate == UNKNOWN) {
+#if defined(SPLIT_USB_DETECT) || defined(PROTOCOL_CHIBIOS)
+ usbstate = waitForUsb() ? MASTER : SLAVE;
+#elif defined(__AVR__)
+ USBCON |= (1 << OTGPADE); // enables VBUS pad
+ wait_us(5);
- usbstate = (USBSTA & (1 << VBUS)) ? MASTER : SLAVE; // checks state of VBUS
- }
-
- return (usbstate == MASTER);
+ usbstate = (USBSTA & (1 << VBUS)) ? MASTER : SLAVE; // checks state of VBUS
#else
- return true;
+ usbstate = MASTER;
#endif
+ }
+
+ return (usbstate == MASTER);
}
static void keyboard_master_setup(void) {
#if defined(USE_I2C) || defined(EH)
- #ifdef SSD1306OLED
- matrix_master_OLED_init ();
- #endif
+# ifdef SSD1306OLED
+ matrix_master_OLED_init();
+# endif
#endif
- transport_master_init();
+ transport_master_init();
}
-static void keyboard_slave_setup(void)
-{
- transport_slave_init();
-}
+static void keyboard_slave_setup(void) { transport_slave_init(); }
-// this code runs before the usb and keyboard is initialized
-void matrix_setup(void)
-{
- isLeftHand = is_keyboard_left();
+// this code runs before the keyboard is fully initialized
+void keyboard_split_setup(void) {
+ isLeftHand = is_keyboard_left();
#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
- uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT;
- if (isLeftHand) {
- rgblight_set_clipping_range(0, num_rgb_leds_split[0]);
- }
- else {
- rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]);
- }
+ uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT;
+ if (isLeftHand) {
+ rgblight_set_clipping_range(0, num_rgb_leds_split[0]);
+ } else {
+ rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]);
+ }
#endif
- if (is_keyboard_master())
- {
- keyboard_master_setup();
- }
- else
- {
- keyboard_slave_setup();
- }
+ if (is_keyboard_master()) {
+ keyboard_master_setup();
+ } else {
+ keyboard_slave_setup();
+ }
}
diff --git a/quantum/split_common/split_util.h b/quantum/split_common/split_util.h
index 20f7535bf4..5d9c523400 100644
--- a/quantum/split_common/split_util.h
+++ b/quantum/split_common/split_util.h
@@ -7,4 +7,5 @@
extern volatile bool isLeftHand;
-void matrix_master_OLED_init (void);
+void matrix_master_OLED_init(void);
+void keyboard_split_setup(void);
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index b32d48eb88..3c783dc568 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -8,99 +8,100 @@
#define ROWS_PER_HAND (MATRIX_ROWS / 2)
#ifdef RGBLIGHT_ENABLE
-# include "rgblight.h"
+# include "rgblight.h"
#endif
#ifdef BACKLIGHT_ENABLE
-# include "backlight.h"
+# include "backlight.h"
#endif
#ifdef ENCODER_ENABLE
-# include "encoder.h"
+# include "encoder.h"
+static pin_t encoders_pad[] = ENCODERS_PAD_A;
+# define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t))
#endif
#if defined(USE_I2C) || defined(EH)
-# include "i2c_master.h"
-# include "i2c_slave.h"
+# include "i2c_master.h"
+# include "i2c_slave.h"
typedef struct _I2C_slave_buffer_t {
matrix_row_t smatrix[ROWS_PER_HAND];
uint8_t backlight_level;
-#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
rgblight_syncinfo_t rgblight_sync;
-#endif
-#ifdef ENCODER_ENABLE
+# endif
+# ifdef ENCODER_ENABLE
uint8_t encoder_state[NUMBER_OF_ENCODERS];
-#endif
+# endif
} I2C_slave_buffer_t;
-static I2C_slave_buffer_t * const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
+static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
-# define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level)
-# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
-# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
-# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
+# define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level)
+# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
+# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
+# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
-# define TIMEOUT 100
+# define TIMEOUT 100
-# ifndef SLAVE_I2C_ADDRESS
-# define SLAVE_I2C_ADDRESS 0x32
-# endif
+# ifndef SLAVE_I2C_ADDRESS
+# define SLAVE_I2C_ADDRESS 0x32
+# endif
// Get rows from other half over i2c
bool transport_master(matrix_row_t matrix[]) {
- i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
-
- // write backlight info
-# ifdef BACKLIGHT_ENABLE
- uint8_t level = is_backlight_enabled() ? get_backlight_level() : 0;
- if (level != i2c_buffer->backlight_level) {
- if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIGHT_START, (void *)&level, sizeof(level), TIMEOUT) >= 0) {
- i2c_buffer->backlight_level = level;
+ i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
+
+ // write backlight info
+# ifdef BACKLIGHT_ENABLE
+ uint8_t level = is_backlight_enabled() ? get_backlight_level() : 0;
+ if (level != i2c_buffer->backlight_level) {
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIGHT_START, (void *)&level, sizeof(level), TIMEOUT) >= 0) {
+ i2c_buffer->backlight_level = level;
+ }
}
- }
-# endif
-
-# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
- if (rgblight_get_change_flags()) {
- rgblight_syncinfo_t rgblight_sync;
- rgblight_get_syncinfo(&rgblight_sync);
- if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START,
- (void *)&rgblight_sync, sizeof(rgblight_sync), TIMEOUT) >= 0) {
- rgblight_clear_change_flags();
+# endif
+
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+ if (rgblight_get_change_flags()) {
+ rgblight_syncinfo_t rgblight_sync;
+ rgblight_get_syncinfo(&rgblight_sync);
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START, (void *)&rgblight_sync, sizeof(rgblight_sync), TIMEOUT) >= 0) {
+ rgblight_clear_change_flags();
+ }
}
- }
-# endif
+# endif
-# ifdef ENCODER_ENABLE
- i2c_readReg(SLAVE_I2C_ADDRESS, I2C_ENCODER_START, (void *)i2c_buffer->encoder_state, sizeof(i2c_buffer->encoder_state), TIMEOUT);
- encoder_update_raw(i2c_buffer->encoder_state);
-# endif
+# ifdef ENCODER_ENABLE
+ i2c_readReg(SLAVE_I2C_ADDRESS, I2C_ENCODER_START, (void *)i2c_buffer->encoder_state, sizeof(i2c_buffer->encoder_state), TIMEOUT);
+ encoder_update_raw(i2c_buffer->encoder_state);
+# endif
- return true;
+ return true;
}
void transport_slave(matrix_row_t matrix[]) {
- // Copy matrix to I2C buffer
- memcpy((void*)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix));
+ // Copy matrix to I2C buffer
+ memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix));
// Read Backlight Info
-# ifdef BACKLIGHT_ENABLE
- backlight_set(i2c_buffer->backlight_level);
-# endif
-
-# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
- // Update the RGB with the new data
- if (i2c_buffer->rgblight_sync.status.change_flags != 0) {
- rgblight_update_sync(&i2c_buffer->rgblight_sync, false);
- i2c_buffer->rgblight_sync.status.change_flags = 0;
- }
-# endif
-
-# ifdef ENCODER_ENABLE
- encoder_state_raw(i2c_buffer->encoder_state);
-# endif
+# ifdef BACKLIGHT_ENABLE
+ backlight_set(i2c_buffer->backlight_level);
+# endif
+
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+ // Update the RGB with the new data
+ if (i2c_buffer->rgblight_sync.status.change_flags != 0) {
+ rgblight_update_sync(&i2c_buffer->rgblight_sync, false);
+ i2c_buffer->rgblight_sync.status.change_flags = 0;
+ }
+# endif
+
+# ifdef ENCODER_ENABLE
+ encoder_state_raw(i2c_buffer->encoder_state);
+# endif
}
void transport_master_init(void) { i2c_init(); }
@@ -109,25 +110,25 @@ void transport_slave_init(void) { i2c_slave_init(SLAVE_I2C_ADDRESS); }
#else // USE_SERIAL
-# include "serial.h"
+# include "serial.h"
typedef struct _Serial_s2m_buffer_t {
- // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack
- matrix_row_t smatrix[ROWS_PER_HAND];
+ // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack
+ matrix_row_t smatrix[ROWS_PER_HAND];
-# ifdef ENCODER_ENABLE
- uint8_t encoder_state[NUMBER_OF_ENCODERS];
-# endif
+# ifdef ENCODER_ENABLE
+ uint8_t encoder_state[NUMBER_OF_ENCODERS];
+# endif
} Serial_s2m_buffer_t;
typedef struct _Serial_m2s_buffer_t {
-# ifdef BACKLIGHT_ENABLE
- uint8_t backlight_level;
-# endif
+# ifdef BACKLIGHT_ENABLE
+ uint8_t backlight_level;
+# endif
} Serial_m2s_buffer_t;
-#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
// When MCUs on both sides drive their respective RGB LED chains,
// it is necessary to synchronize, so it is necessary to communicate RGB
// information. In that case, define RGBLIGHT_SPLIT with info on the number
@@ -142,7 +143,7 @@ typedef struct _Serial_rgblight_t {
volatile Serial_rgblight_t serial_rgblight = {};
uint8_t volatile status_rgblight = 0;
-#endif
+# endif
volatile Serial_s2m_buffer_t serial_s2m_buffer = {};
volatile Serial_m2s_buffer_t serial_m2s_buffer = {};
@@ -150,102 +151,99 @@ uint8_t volatile status0 = 0;
enum serial_transaction_id {
GET_SLAVE_MATRIX = 0,
-#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
PUT_RGBLIGHT,
-#endif
+# endif
};
SSTD_t transactions[] = {
- [GET_SLAVE_MATRIX] = {
- (uint8_t *)&status0,
- sizeof(serial_m2s_buffer),
- (uint8_t *)&serial_m2s_buffer,
- sizeof(serial_s2m_buffer),
- (uint8_t *)&serial_s2m_buffer,
- },
-#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
- [PUT_RGBLIGHT] = {
- (uint8_t *)&status_rgblight,
- sizeof(serial_rgblight),
- (uint8_t *)&serial_rgblight,
- 0, NULL // no slave to master transfer
- },
-#endif
+ [GET_SLAVE_MATRIX] =
+ {
+ (uint8_t *)&status0,
+ sizeof(serial_m2s_buffer),
+ (uint8_t *)&serial_m2s_buffer,
+ sizeof(serial_s2m_buffer),
+ (uint8_t *)&serial_s2m_buffer,
+ },
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+ [PUT_RGBLIGHT] =
+ {
+ (uint8_t *)&status_rgblight, sizeof(serial_rgblight), (uint8_t *)&serial_rgblight, 0, NULL // no slave to master transfer
+ },
+# endif
};
void transport_master_init(void) { soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); }
void transport_slave_init(void) { soft_serial_target_init(transactions, TID_LIMIT(transactions)); }
-#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
// rgblight synchronization information communication.
void transport_rgblight_master(void) {
- if (rgblight_get_change_flags()) {
- rgblight_get_syncinfo((rgblight_syncinfo_t *)&serial_rgblight.rgblight_sync);
- if (soft_serial_transaction(PUT_RGBLIGHT) == TRANSACTION_END) {
- rgblight_clear_change_flags();
+ if (rgblight_get_change_flags()) {
+ rgblight_get_syncinfo((rgblight_syncinfo_t *)&serial_rgblight.rgblight_sync);
+ if (soft_serial_transaction(PUT_RGBLIGHT) == TRANSACTION_END) {
+ rgblight_clear_change_flags();
+ }
}
- }
}
void transport_rgblight_slave(void) {
- if (status_rgblight == TRANSACTION_ACCEPTED) {
- rgblight_update_sync((rgblight_syncinfo_t *)&serial_rgblight.rgblight_sync,
- false);
- status_rgblight = TRANSACTION_END;
- }
+ if (status_rgblight == TRANSACTION_ACCEPTED) {
+ rgblight_update_sync((rgblight_syncinfo_t *)&serial_rgblight.rgblight_sync, false);
+ status_rgblight = TRANSACTION_END;
+ }
}
-#else
-#define transport_rgblight_master()
-#define transport_rgblight_slave()
-#endif
+# else
+# define transport_rgblight_master()
+# define transport_rgblight_slave()
+# endif
bool transport_master(matrix_row_t matrix[]) {
-#ifndef SERIAL_USE_MULTI_TRANSACTION
- if (soft_serial_transaction() != TRANSACTION_END) {
- return false;
- }
-#else
- transport_rgblight_master();
- if (soft_serial_transaction(GET_SLAVE_MATRIX) != TRANSACTION_END) {
- return false;
- }
-#endif
+# ifndef SERIAL_USE_MULTI_TRANSACTION
+ if (soft_serial_transaction() != TRANSACTION_END) {
+ return false;
+ }
+# else
+ transport_rgblight_master();
+ if (soft_serial_transaction(GET_SLAVE_MATRIX) != TRANSACTION_END) {
+ return false;
+ }
+# endif
- // TODO: if MATRIX_COLS > 8 change to unpack()
- for (int i = 0; i < ROWS_PER_HAND; ++i) {
- matrix[i] = serial_s2m_buffer.smatrix[i];
- }
+ // TODO: if MATRIX_COLS > 8 change to unpack()
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ matrix[i] = serial_s2m_buffer.smatrix[i];
+ }
-# ifdef BACKLIGHT_ENABLE
- // Write backlight level for slave to read
- serial_m2s_buffer.backlight_level = is_backlight_enabled() ? get_backlight_level() : 0;
-# endif
+# ifdef BACKLIGHT_ENABLE
+ // Write backlight level for slave to read
+ serial_m2s_buffer.backlight_level = is_backlight_enabled() ? get_backlight_level() : 0;
+# endif
-# ifdef ENCODER_ENABLE
- encoder_update_raw((uint8_t *)serial_s2m_buffer.encoder_state);
-# endif
+# ifdef ENCODER_ENABLE
+ encoder_update_raw((uint8_t *)serial_s2m_buffer.encoder_state);
+# endif
- return true;
+ return true;
}
void transport_slave(matrix_row_t matrix[]) {
- transport_rgblight_slave();
- // TODO: if MATRIX_COLS > 8 change to pack()
- for (int i = 0; i < ROWS_PER_HAND; ++i) {
- serial_s2m_buffer.smatrix[i] = matrix[i];
- }
-# ifdef BACKLIGHT_ENABLE
- backlight_set(serial_m2s_buffer.backlight_level);
-# endif
-
-# ifdef ENCODER_ENABLE
- encoder_state_raw((uint8_t *)serial_s2m_buffer.encoder_state);
-# endif
+ transport_rgblight_slave();
+ // TODO: if MATRIX_COLS > 8 change to pack()
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ serial_s2m_buffer.smatrix[i] = matrix[i];
+ }
+# ifdef BACKLIGHT_ENABLE
+ backlight_set(serial_m2s_buffer.backlight_level);
+# endif
+# ifdef ENCODER_ENABLE
+ encoder_state_raw((uint8_t *)serial_s2m_buffer.encoder_state);
+# endif
}
#endif
diff --git a/quantum/stm32/chconf.h b/quantum/stm32/chconf.h
index 1d9f12ff1f..6b691950a6 100644
--- a/quantum/stm32/chconf.h
+++ b/quantum/stm32/chconf.h
@@ -26,9 +26,9 @@
*/
#ifndef CHCONF_H
-#define CHCONF_H
+# define CHCONF_H
-#define _CHIBIOS_RT_CONF_
+# define _CHIBIOS_RT_CONF_
/*===========================================================================*/
/**
@@ -41,14 +41,14 @@
* @brief System time counter resolution.
* @note Allowed values are 16 or 32 bits.
*/
-#define CH_CFG_ST_RESOLUTION 32
+# define CH_CFG_ST_RESOLUTION 32
/**
* @brief System tick frequency.
* @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
-#define CH_CFG_ST_FREQUENCY 100000
+# define CH_CFG_ST_FREQUENCY 100000
/**
* @brief Time delta constant for the tick-less mode.
@@ -58,7 +58,7 @@
* The value one is not valid, timeouts are rounded up to
* this value.
*/
-#define CH_CFG_ST_TIMEDELTA 2
+# define CH_CFG_ST_TIMEDELTA 2
/** @} */
@@ -81,7 +81,7 @@
* @note The round robin preemption is not supported in tickless mode and
* must be set to zero in that case.
*/
-#define CH_CFG_TIME_QUANTUM 0
+# define CH_CFG_TIME_QUANTUM 0
/**
* @brief Managed RAM size.
@@ -94,7 +94,7 @@
* provide the @p __heap_base__ and @p __heap_end__ symbols.
* @note Requires @p CH_CFG_USE_MEMCORE.
*/
-#define CH_CFG_MEMCORE_SIZE 0
+# define CH_CFG_MEMCORE_SIZE 0
/**
* @brief Idle thread automatic spawn suppression.
@@ -103,7 +103,7 @@
* function becomes the idle thread and must implement an
* infinite loop.
*/
-#define CH_CFG_NO_IDLE_THREAD FALSE
+# define CH_CFG_NO_IDLE_THREAD FALSE
/** @} */
@@ -122,7 +122,7 @@
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
*/
-#define CH_CFG_OPTIMIZE_SPEED TRUE
+# define CH_CFG_OPTIMIZE_SPEED TRUE
/** @} */
@@ -140,7 +140,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_TM TRUE
+# define CH_CFG_USE_TM TRUE
/**
* @brief Threads registry APIs.
@@ -148,7 +148,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_REGISTRY TRUE
+# define CH_CFG_USE_REGISTRY TRUE
/**
* @brief Threads synchronization APIs.
@@ -157,7 +157,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_WAITEXIT TRUE
+# define CH_CFG_USE_WAITEXIT TRUE
/**
* @brief Semaphores APIs.
@@ -165,7 +165,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_SEMAPHORES TRUE
+# define CH_CFG_USE_SEMAPHORES TRUE
/**
* @brief Semaphores queuing mode.
@@ -176,7 +176,7 @@
* requirements.
* @note Requires @p CH_CFG_USE_SEMAPHORES.
*/
-#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
+# define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
/**
* @brief Mutexes APIs.
@@ -184,7 +184,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_MUTEXES TRUE
+# define CH_CFG_USE_MUTEXES TRUE
/**
* @brief Enables recursive behavior on mutexes.
@@ -194,7 +194,7 @@
* @note The default is @p FALSE.
* @note Requires @p CH_CFG_USE_MUTEXES.
*/
-#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
+# define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
/**
* @brief Conditional Variables APIs.
@@ -204,7 +204,7 @@
* @note The default is @p TRUE.
* @note Requires @p CH_CFG_USE_MUTEXES.
*/
-#define CH_CFG_USE_CONDVARS TRUE
+# define CH_CFG_USE_CONDVARS TRUE
/**
* @brief Conditional Variables APIs with timeout.
@@ -214,7 +214,7 @@
* @note The default is @p TRUE.
* @note Requires @p CH_CFG_USE_CONDVARS.
*/
-#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
+# define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
/**
* @brief Events Flags APIs.
@@ -222,7 +222,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_EVENTS TRUE
+# define CH_CFG_USE_EVENTS TRUE
/**
* @brief Events Flags APIs with timeout.
@@ -232,7 +232,7 @@
* @note The default is @p TRUE.
* @note Requires @p CH_CFG_USE_EVENTS.
*/
-#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
+# define CH_CFG_USE_EVENTS_TIMEOUT TRUE
/**
* @brief Synchronous Messages APIs.
@@ -241,7 +241,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_MESSAGES TRUE
+# define CH_CFG_USE_MESSAGES TRUE
/**
* @brief Synchronous Messages queuing mode.
@@ -252,7 +252,7 @@
* requirements.
* @note Requires @p CH_CFG_USE_MESSAGES.
*/
-#define CH_CFG_USE_MESSAGES_PRIORITY TRUE
+# define CH_CFG_USE_MESSAGES_PRIORITY TRUE
/**
* @brief Mailboxes APIs.
@@ -262,7 +262,7 @@
* @note The default is @p TRUE.
* @note Requires @p CH_CFG_USE_SEMAPHORES.
*/
-#define CH_CFG_USE_MAILBOXES TRUE
+# define CH_CFG_USE_MAILBOXES TRUE
/**
* @brief Core Memory Manager APIs.
@@ -271,7 +271,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_MEMCORE TRUE
+# define CH_CFG_USE_MEMCORE TRUE
/**
* @brief Heap Allocator APIs.
@@ -283,7 +283,7 @@
* @p CH_CFG_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
-#define CH_CFG_USE_HEAP TRUE
+# define CH_CFG_USE_HEAP TRUE
/**
* @brief Memory Pools Allocator APIs.
@@ -292,7 +292,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_MEMPOOLS TRUE
+# define CH_CFG_USE_MEMPOOLS TRUE
/**
* @brief Dynamic Threads APIs.
@@ -303,7 +303,7 @@
* @note Requires @p CH_CFG_USE_WAITEXIT.
* @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
*/
-#define CH_CFG_USE_DYNAMIC TRUE
+# define CH_CFG_USE_DYNAMIC TRUE
/** @} */
@@ -319,7 +319,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_STATISTICS FALSE
+# define CH_DBG_STATISTICS FALSE
/**
* @brief Debug option, system state check.
@@ -328,7 +328,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_SYSTEM_STATE_CHECK FALSE
+# define CH_DBG_SYSTEM_STATE_CHECK FALSE
/**
* @brief Debug option, parameters checks.
@@ -337,7 +337,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_ENABLE_CHECKS FALSE
+# define CH_DBG_ENABLE_CHECKS FALSE
/**
* @brief Debug option, consistency checks.
@@ -347,7 +347,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_ENABLE_ASSERTS FALSE
+# define CH_DBG_ENABLE_ASSERTS FALSE
/**
* @brief Debug option, trace buffer.
@@ -355,14 +355,14 @@
*
* @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
*/
-#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
+# define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
/**
* @brief Trace buffer entries.
* @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
* different from @p CH_DBG_TRACE_MASK_DISABLED.
*/
-#define CH_DBG_TRACE_BUFFER_SIZE 128
+# define CH_DBG_TRACE_BUFFER_SIZE 128
/**
* @brief Debug option, stack checks.
@@ -374,7 +374,7 @@
* @note The default failure mode is to halt the system with the global
* @p panic_msg variable set to @p NULL.
*/
-#define CH_DBG_ENABLE_STACK_CHECK TRUE
+# define CH_DBG_ENABLE_STACK_CHECK TRUE
/**
* @brief Debug option, stacks initialization.
@@ -384,7 +384,7 @@
*
* @note The default is @p FALSE.
*/
-#define CH_DBG_FILL_THREADS FALSE
+# define CH_DBG_FILL_THREADS FALSE
/**
* @brief Debug option, threads profiling.
@@ -395,7 +395,7 @@
* @note This debug option is not currently compatible with the
* tickless mode.
*/
-#define CH_DBG_THREADS_PROFILING FALSE
+# define CH_DBG_THREADS_PROFILING FALSE
/** @} */
@@ -410,8 +410,7 @@
* @brief Threads descriptor structure extension.
* @details User fields added to the end of the @p thread_t structure.
*/
-#define CH_CFG_THREAD_EXTRA_FIELDS \
- /* Add threads custom fields here.*/
+# define CH_CFG_THREAD_EXTRA_FIELDS /* Add threads custom fields here.*/
/**
* @brief Threads initialization hook.
@@ -420,39 +419,39 @@
* @note It is invoked from within @p chThdInit() and implicitly from all
* the threads creation APIs.
*/
-#define CH_CFG_THREAD_INIT_HOOK(tp) { \
- /* Add threads initialization code here.*/ \
-}
+# define CH_CFG_THREAD_INIT_HOOK(tp) \
+ { /* Add threads initialization code here.*/ \
+ }
/**
* @brief Threads finalization hook.
* @details User finalization code added to the @p chThdExit() API.
*/
-#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
- /* Add threads finalization code here.*/ \
-}
+# define CH_CFG_THREAD_EXIT_HOOK(tp) \
+ { /* Add threads finalization code here.*/ \
+ }
/**
* @brief Context switch hook.
* @details This hook is invoked just before switching between threads.
*/
-#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
- /* Context switch code here.*/ \
-}
+# define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) \
+ { /* Context switch code here.*/ \
+ }
/**
* @brief ISR enter hook.
*/
-#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
- /* IRQ prologue code here.*/ \
-}
+# define CH_CFG_IRQ_PROLOGUE_HOOK() \
+ { /* IRQ prologue code here.*/ \
+ }
/**
* @brief ISR exit hook.
*/
-#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
- /* IRQ epilogue code here.*/ \
-}
+# define CH_CFG_IRQ_EPILOGUE_HOOK() \
+ { /* IRQ epilogue code here.*/ \
+ }
/**
* @brief Idle thread enter hook.
@@ -460,9 +459,9 @@
* should be invoked from here.
* @note This macro can be used to activate a power saving mode.
*/
-#define CH_CFG_IDLE_ENTER_HOOK() { \
- /* Idle-enter code here.*/ \
-}
+# define CH_CFG_IDLE_ENTER_HOOK() \
+ { /* Idle-enter code here.*/ \
+ }
/**
* @brief Idle thread leave hook.
@@ -470,44 +469,44 @@
* should be invoked from here.
* @note This macro can be used to deactivate a power saving mode.
*/
-#define CH_CFG_IDLE_LEAVE_HOOK() { \
- /* Idle-leave code here.*/ \
-}
+# define CH_CFG_IDLE_LEAVE_HOOK() \
+ { /* Idle-leave code here.*/ \
+ }
/**
* @brief Idle Loop hook.
* @details This hook is continuously invoked by the idle thread loop.
*/
-#define CH_CFG_IDLE_LOOP_HOOK() { \
- /* Idle loop code here.*/ \
-}
+# define CH_CFG_IDLE_LOOP_HOOK() \
+ { /* Idle loop code here.*/ \
+ }
/**
* @brief System tick event hook.
* @details This hook is invoked in the system tick handler immediately
* after processing the virtual timers queue.
*/
-#define CH_CFG_SYSTEM_TICK_HOOK() { \
- /* System tick event code here.*/ \
-}
+# define CH_CFG_SYSTEM_TICK_HOOK() \
+ { /* System tick event code here.*/ \
+ }
/**
* @brief System halt hook.
* @details This hook is invoked in case to a system halting error before
* the system is halted.
*/
-#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
- /* System halt code here.*/ \
-}
+# define CH_CFG_SYSTEM_HALT_HOOK(reason) \
+ { /* System halt code here.*/ \
+ }
/**
* @brief Trace hook.
* @details This hook is invoked each time a new record is written in the
* trace buffer.
*/
-#define CH_CFG_TRACE_HOOK(tep) { \
- /* Trace code here.*/ \
-}
+# define CH_CFG_TRACE_HOOK(tep) \
+ { /* Trace code here.*/ \
+ }
/** @} */
@@ -515,6 +514,6 @@
/* Port-specific settings (override port settings defaulted in chcore.h). */
/*===========================================================================*/
-#endif /* CHCONF_H */
+#endif /* CHCONF_H */
/** @} */
diff --git a/quantum/stm32/halconf.h b/quantum/stm32/halconf.h
index c3e0cbb728..72e011d3dc 100644
--- a/quantum/stm32/halconf.h
+++ b/quantum/stm32/halconf.h
@@ -26,156 +26,156 @@
*/
#ifndef HALCONF_H
-#define HALCONF_H
+# define HALCONF_H
-#include "mcuconf.h"
+# include "mcuconf.h"
/**
* @brief Enables the PAL subsystem.
*/
-#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL TRUE
-#endif
+# if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
+# define HAL_USE_PAL TRUE
+# endif
/**
* @brief Enables the ADC subsystem.
*/
-#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
-#define HAL_USE_ADC FALSE
-#endif
+# if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
+# define HAL_USE_ADC FALSE
+# endif
/**
* @brief Enables the CAN subsystem.
*/
-#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
-#define HAL_USE_CAN FALSE
-#endif
+# if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
+# define HAL_USE_CAN FALSE
+# endif
/**
* @brief Enables the DAC subsystem.
*/
-#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
-#define HAL_USE_DAC TRUE
-#endif
+# if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
+# define HAL_USE_DAC TRUE
+# endif
/**
* @brief Enables the EXT subsystem.
*/
-#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
-#define HAL_USE_EXT FALSE
-#endif
+# if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
+# define HAL_USE_EXT FALSE
+# endif
/**
* @brief Enables the GPT subsystem.
*/
-#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT TRUE
-#endif
+# if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
+# define HAL_USE_GPT TRUE
+# endif
/**
* @brief Enables the I2C subsystem.
*/
-#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C TRUE
-#endif
+# if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
+# define HAL_USE_I2C TRUE
+# endif
/**
* @brief Enables the I2S subsystem.
*/
-#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
-#define HAL_USE_I2S FALSE
-#endif
+# if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
+# define HAL_USE_I2S FALSE
+# endif
/**
* @brief Enables the ICU subsystem.
*/
-#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
-#define HAL_USE_ICU FALSE
-#endif
+# if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
+# define HAL_USE_ICU FALSE
+# endif
/**
* @brief Enables the MAC subsystem.
*/
-#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
-#define HAL_USE_MAC FALSE
-#endif
+# if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
+# define HAL_USE_MAC FALSE
+# endif
/**
* @brief Enables the MMC_SPI subsystem.
*/
-#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_MMC_SPI FALSE
-#endif
+# if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
+# define HAL_USE_MMC_SPI FALSE
+# endif
/**
* @brief Enables the PWM subsystem.
*/
-#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM FALSE
-#endif
+# if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
+# define HAL_USE_PWM TRUE
+# endif
/**
* @brief Enables the QSPI subsystem.
*/
-#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
-#define HAL_USE_QSPI FALSE
-#endif
+# if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
+# define HAL_USE_QSPI FALSE
+# endif
/**
* @brief Enables the RTC subsystem.
*/
-#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
-#define HAL_USE_RTC FALSE
-#endif
+# if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
+# define HAL_USE_RTC FALSE
+# endif
/**
* @brief Enables the SDC subsystem.
*/
-#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
-#define HAL_USE_SDC FALSE
-#endif
+# if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
+# define HAL_USE_SDC FALSE
+# endif
/**
* @brief Enables the SERIAL subsystem.
*/
-#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL FALSE
-#endif
+# if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
+# define HAL_USE_SERIAL FALSE
+# endif
/**
* @brief Enables the SERIAL over USB subsystem.
*/
-#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL_USB TRUE
-#endif
+# if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
+# define HAL_USE_SERIAL_USB TRUE
+# endif
/**
* @brief Enables the SPI subsystem.
*/
-#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI FALSE
-#endif
+# if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
+# define HAL_USE_SPI FALSE
+# endif
/**
* @brief Enables the UART subsystem.
*/
-#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
-#define HAL_USE_UART FALSE
-#endif
+# if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
+# define HAL_USE_UART FALSE
+# endif
/**
* @brief Enables the USB subsystem.
*/
-#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
-#define HAL_USE_USB TRUE
-#endif
+# if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
+# define HAL_USE_USB TRUE
+# endif
/**
* @brief Enables the WDG subsystem.
*/
-#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
-#define HAL_USE_WDG FALSE
-#endif
+# if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
+# define HAL_USE_WDG FALSE
+# endif
/*===========================================================================*/
/* ADC driver related settings. */
@@ -185,17 +185,17 @@
* @brief Enables synchronous APIs.
* @note Disabling this option saves both code and data space.
*/
-#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
-#define ADC_USE_WAIT TRUE
-#endif
+# if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
+# define ADC_USE_WAIT TRUE
+# endif
/**
* @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
* @note Disabling this option saves both code and data space.
*/
-#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define ADC_USE_MUTUAL_EXCLUSION TRUE
-#endif
+# if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+# define ADC_USE_MUTUAL_EXCLUSION TRUE
+# endif
/*===========================================================================*/
/* CAN driver related settings. */
@@ -204,9 +204,9 @@
/**
* @brief Sleep mode related APIs inclusion switch.
*/
-#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
-#define CAN_USE_SLEEP_MODE TRUE
-#endif
+# if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
+# define CAN_USE_SLEEP_MODE TRUE
+# endif
/*===========================================================================*/
/* I2C driver related settings. */
@@ -215,9 +215,9 @@
/**
* @brief Enables the mutual exclusion APIs on the I2C bus.
*/
-#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define I2C_USE_MUTUAL_EXCLUSION TRUE
-#endif
+# if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+# define I2C_USE_MUTUAL_EXCLUSION TRUE
+# endif
/*===========================================================================*/
/* MAC driver related settings. */
@@ -226,16 +226,16 @@
/**
* @brief Enables an event sources for incoming packets.
*/
-#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
-#define MAC_USE_ZERO_COPY FALSE
-#endif
+# if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
+# define MAC_USE_ZERO_COPY FALSE
+# endif
/**
* @brief Enables an event sources for incoming packets.
*/
-#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
-#define MAC_USE_EVENTS TRUE
-#endif
+# if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
+# define MAC_USE_EVENTS TRUE
+# endif
/*===========================================================================*/
/* MMC_SPI driver related settings. */
@@ -249,9 +249,9 @@
* This option is recommended also if the SPI driver does not
* use a DMA channel and heavily loads the CPU.
*/
-#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
-#define MMC_NICE_WAITING TRUE
-#endif
+# if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
+# define MMC_NICE_WAITING TRUE
+# endif
/*===========================================================================*/
/* SDC driver related settings. */
@@ -261,18 +261,18 @@
* @brief Number of initialization attempts before rejecting the card.
* @note Attempts are performed at 10mS intervals.
*/
-#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
-#define SDC_INIT_RETRY 100
-#endif
+# if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
+# define SDC_INIT_RETRY 100
+# endif
/**
* @brief Include support for MMC cards.
* @note MMC support is not yet implemented so this option must be kept
* at @p FALSE.
*/
-#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
-#define SDC_MMC_SUPPORT FALSE
-#endif
+# if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
+# define SDC_MMC_SUPPORT FALSE
+# endif
/**
* @brief Delays insertions.
@@ -280,9 +280,9 @@
* routines releasing some extra CPU time for the threads with
* lower priority, this may slow down the driver a bit however.
*/
-#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
-#define SDC_NICE_WAITING TRUE
-#endif
+# if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
+# define SDC_NICE_WAITING TRUE
+# endif
/*===========================================================================*/
/* SERIAL driver related settings. */
@@ -293,9 +293,9 @@
* @details Configuration parameter, this is the baud rate selected for the
* default configuration.
*/
-#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
-#define SERIAL_DEFAULT_BITRATE 38400
-#endif
+# if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
+# define SERIAL_DEFAULT_BITRATE 38400
+# endif
/**
* @brief Serial buffers size.
@@ -304,9 +304,9 @@
* @note The default is 16 bytes for both the transmission and receive
* buffers.
*/
-#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_BUFFERS_SIZE 16
-#endif
+# if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
+# define SERIAL_BUFFERS_SIZE 16
+# endif
/*===========================================================================*/
/* SERIAL_USB driver related setting. */
@@ -319,17 +319,17 @@
* @note The default is 256 bytes for both the transmission and receive
* buffers.
*/
-#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_SIZE 1
-#endif
+# if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
+# define SERIAL_USB_BUFFERS_SIZE 1
+# endif
/**
* @brief Serial over USB number of buffers.
* @note The default is 2 buffers.
*/
-#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_NUMBER 2
-#endif
+# if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
+# define SERIAL_USB_BUFFERS_NUMBER 2
+# endif
/*===========================================================================*/
/* SPI driver related settings. */
@@ -339,17 +339,17 @@
* @brief Enables synchronous APIs.
* @note Disabling this option saves both code and data space.
*/
-#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
-#define SPI_USE_WAIT TRUE
-#endif
+# if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
+# define SPI_USE_WAIT TRUE
+# endif
/**
* @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
* @note Disabling this option saves both code and data space.
*/
-#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define SPI_USE_MUTUAL_EXCLUSION TRUE
-#endif
+# if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+# define SPI_USE_MUTUAL_EXCLUSION TRUE
+# endif
/*===========================================================================*/
/* UART driver related settings. */
@@ -359,17 +359,17 @@
* @brief Enables synchronous APIs.
* @note Disabling this option saves both code and data space.
*/
-#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
-#define UART_USE_WAIT FALSE
-#endif
+# if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
+# define UART_USE_WAIT FALSE
+# endif
/**
* @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
* @note Disabling this option saves both code and data space.
*/
-#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define UART_USE_MUTUAL_EXCLUSION FALSE
-#endif
+# if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+# define UART_USE_MUTUAL_EXCLUSION FALSE
+# endif
/*===========================================================================*/
/* USB driver related settings. */
@@ -379,9 +379,9 @@
* @brief Enables synchronous APIs.
* @note Disabling this option saves both code and data space.
*/
-#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
-#define USB_USE_WAIT TRUE
-#endif
+# if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
+# define USB_USE_WAIT TRUE
+# endif
#endif /* HALCONF_H */
diff --git a/quantum/stm32/mcuconf.h b/quantum/stm32/mcuconf.h
index 36f8ca2252..4490dfed7e 100644
--- a/quantum/stm32/mcuconf.h
+++ b/quantum/stm32/mcuconf.h
@@ -36,35 +36,35 @@
/*
* HAL driver system settings.
*/
-#define STM32_NO_INIT FALSE
-#define STM32_PVD_ENABLE FALSE
-#define STM32_PLS STM32_PLS_LEV0
-#define STM32_HSI_ENABLED TRUE
-#define STM32_LSI_ENABLED TRUE
-#define STM32_HSE_ENABLED TRUE
-#define STM32_LSE_ENABLED FALSE
-#define STM32_SW STM32_SW_PLL
-#define STM32_PLLSRC STM32_PLLSRC_HSE
-#define STM32_PREDIV_VALUE 1
-#define STM32_PLLMUL_VALUE 9
-#define STM32_HPRE STM32_HPRE_DIV1
-#define STM32_PPRE1 STM32_PPRE1_DIV2
-#define STM32_PPRE2 STM32_PPRE2_DIV2
-#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
-#define STM32_ADC12PRES STM32_ADC12PRES_DIV1
-#define STM32_ADC34PRES STM32_ADC34PRES_DIV1
-#define STM32_USART1SW STM32_USART1SW_PCLK
-#define STM32_USART2SW STM32_USART2SW_PCLK
-#define STM32_USART3SW STM32_USART3SW_PCLK
-#define STM32_UART4SW STM32_UART4SW_PCLK
-#define STM32_UART5SW STM32_UART5SW_PCLK
-#define STM32_I2C1SW STM32_I2C1SW_SYSCLK
-#define STM32_I2C2SW STM32_I2C2SW_SYSCLK
-#define STM32_TIM1SW STM32_TIM1SW_PCLK2
-#define STM32_TIM8SW STM32_TIM8SW_PCLK2
-#define STM32_RTCSEL STM32_RTCSEL_LSI
-#define STM32_USB_CLOCK_REQUIRED TRUE
-#define STM32_USBPRE STM32_USBPRE_DIV1P5
+#define STM32_NO_INIT FALSE
+#define STM32_PVD_ENABLE FALSE
+#define STM32_PLS STM32_PLS_LEV0
+#define STM32_HSI_ENABLED TRUE
+#define STM32_LSI_ENABLED TRUE
+#define STM32_HSE_ENABLED TRUE
+#define STM32_LSE_ENABLED FALSE
+#define STM32_SW STM32_SW_PLL
+#define STM32_PLLSRC STM32_PLLSRC_HSE
+#define STM32_PREDIV_VALUE 1
+#define STM32_PLLMUL_VALUE 9
+#define STM32_HPRE STM32_HPRE_DIV1
+#define STM32_PPRE1 STM32_PPRE1_DIV2
+#define STM32_PPRE2 STM32_PPRE2_DIV2
+#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
+#define STM32_ADC12PRES STM32_ADC12PRES_DIV1
+#define STM32_ADC34PRES STM32_ADC34PRES_DIV1
+#define STM32_USART1SW STM32_USART1SW_PCLK
+#define STM32_USART2SW STM32_USART2SW_PCLK
+#define STM32_USART3SW STM32_USART3SW_PCLK
+#define STM32_UART4SW STM32_UART4SW_PCLK
+#define STM32_UART5SW STM32_UART5SW_PCLK
+#define STM32_I2C1SW STM32_I2C1SW_SYSCLK
+#define STM32_I2C2SW STM32_I2C2SW_SYSCLK
+#define STM32_TIM1SW STM32_TIM1SW_PCLK2
+#define STM32_TIM8SW STM32_TIM8SW_PCLK2
+#define STM32_RTCSEL STM32_RTCSEL_LSI
+#define STM32_USB_CLOCK_REQUIRED TRUE
+#define STM32_USBPRE STM32_USBPRE_DIV1P5
#undef STM32_HSE_BYPASS
// #error "oh no"
@@ -73,185 +73,185 @@
/*
* ADC driver system settings.
*/
-#define STM32_ADC_DUAL_MODE FALSE
-#define STM32_ADC_COMPACT_SAMPLES FALSE
-#define STM32_ADC_USE_ADC1 FALSE
-#define STM32_ADC_USE_ADC2 FALSE
-#define STM32_ADC_USE_ADC3 FALSE
-#define STM32_ADC_USE_ADC4 FALSE
-#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
-#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
-#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
-#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
-#define STM32_ADC_ADC1_DMA_PRIORITY 2
-#define STM32_ADC_ADC2_DMA_PRIORITY 2
-#define STM32_ADC_ADC3_DMA_PRIORITY 2
-#define STM32_ADC_ADC4_DMA_PRIORITY 2
-#define STM32_ADC_ADC12_IRQ_PRIORITY 5
-#define STM32_ADC_ADC3_IRQ_PRIORITY 5
-#define STM32_ADC_ADC4_IRQ_PRIORITY 5
-#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
-#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5
-#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5
-#define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5
-#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
-#define STM32_ADC_ADC34_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
+#define STM32_ADC_DUAL_MODE FALSE
+#define STM32_ADC_COMPACT_SAMPLES FALSE
+#define STM32_ADC_USE_ADC1 FALSE
+#define STM32_ADC_USE_ADC2 FALSE
+#define STM32_ADC_USE_ADC3 FALSE
+#define STM32_ADC_USE_ADC4 FALSE
+#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
+#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
+#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
+#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
+#define STM32_ADC_ADC1_DMA_PRIORITY 2
+#define STM32_ADC_ADC2_DMA_PRIORITY 2
+#define STM32_ADC_ADC3_DMA_PRIORITY 2
+#define STM32_ADC_ADC4_DMA_PRIORITY 2
+#define STM32_ADC_ADC12_IRQ_PRIORITY 5
+#define STM32_ADC_ADC3_IRQ_PRIORITY 5
+#define STM32_ADC_ADC4_IRQ_PRIORITY 5
+#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
+#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5
+#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5
+#define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5
+#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
+#define STM32_ADC_ADC34_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
/*
* CAN driver system settings.
*/
-#define STM32_CAN_USE_CAN1 FALSE
-#define STM32_CAN_CAN1_IRQ_PRIORITY 11
+#define STM32_CAN_USE_CAN1 FALSE
+#define STM32_CAN_CAN1_IRQ_PRIORITY 11
/*
* DAC driver system settings.
*/
-#define STM32_DAC_DUAL_MODE FALSE
-#define STM32_DAC_USE_DAC1_CH1 TRUE
-#define STM32_DAC_USE_DAC1_CH2 TRUE
-#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
-#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
-#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
-#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DUAL_MODE FALSE
+#define STM32_DAC_USE_DAC1_CH1 TRUE
+#define STM32_DAC_USE_DAC1_CH2 TRUE
+#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
/*
* EXT driver system settings.
*/
-#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI3_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI4_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI16_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI17_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI20_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI3_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI4_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI16_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI17_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI20_IRQ_PRIORITY 6
#define STM32_EXT_EXTI21_22_29_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI30_32_IRQ_PRIORITY 6
-#define STM32_EXT_EXTI33_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI30_32_IRQ_PRIORITY 6
+#define STM32_EXT_EXTI33_IRQ_PRIORITY 6
/*
* GPT driver system settings.
*/
-#define STM32_GPT_USE_TIM1 FALSE
-#define STM32_GPT_USE_TIM2 FALSE
-#define STM32_GPT_USE_TIM3 FALSE
-#define STM32_GPT_USE_TIM4 FALSE
-#define STM32_GPT_USE_TIM6 TRUE
-#define STM32_GPT_USE_TIM7 TRUE
-#define STM32_GPT_USE_TIM8 TRUE
-#define STM32_GPT_TIM1_IRQ_PRIORITY 7
-#define STM32_GPT_TIM2_IRQ_PRIORITY 7
-#define STM32_GPT_TIM3_IRQ_PRIORITY 7
-#define STM32_GPT_TIM4_IRQ_PRIORITY 7
-#define STM32_GPT_TIM6_IRQ_PRIORITY 7
-#define STM32_GPT_TIM7_IRQ_PRIORITY 7
-#define STM32_GPT_TIM8_IRQ_PRIORITY 7
+#define STM32_GPT_USE_TIM1 FALSE
+#define STM32_GPT_USE_TIM2 FALSE
+#define STM32_GPT_USE_TIM3 FALSE
+#define STM32_GPT_USE_TIM4 FALSE
+#define STM32_GPT_USE_TIM6 TRUE
+#define STM32_GPT_USE_TIM7 TRUE
+#define STM32_GPT_USE_TIM8 TRUE
+#define STM32_GPT_TIM1_IRQ_PRIORITY 7
+#define STM32_GPT_TIM2_IRQ_PRIORITY 7
+#define STM32_GPT_TIM3_IRQ_PRIORITY 7
+#define STM32_GPT_TIM4_IRQ_PRIORITY 7
+#define STM32_GPT_TIM6_IRQ_PRIORITY 7
+#define STM32_GPT_TIM7_IRQ_PRIORITY 7
+#define STM32_GPT_TIM8_IRQ_PRIORITY 7
/*
* I2C driver system settings.
*/
-#define STM32_I2C_USE_I2C1 TRUE
-#define STM32_I2C_USE_I2C2 FALSE
-#define STM32_I2C_BUSY_TIMEOUT 50
-#define STM32_I2C_I2C1_IRQ_PRIORITY 10
-#define STM32_I2C_I2C2_IRQ_PRIORITY 10
-#define STM32_I2C_USE_DMA TRUE
-#define STM32_I2C_I2C1_DMA_PRIORITY 1
-#define STM32_I2C_I2C2_DMA_PRIORITY 1
-#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
+#define STM32_I2C_USE_I2C1 TRUE
+#define STM32_I2C_USE_I2C2 FALSE
+#define STM32_I2C_BUSY_TIMEOUT 50
+#define STM32_I2C_I2C1_IRQ_PRIORITY 10
+#define STM32_I2C_I2C2_IRQ_PRIORITY 10
+#define STM32_I2C_USE_DMA TRUE
+#define STM32_I2C_I2C1_DMA_PRIORITY 1
+#define STM32_I2C_I2C2_DMA_PRIORITY 1
+#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
/*
* ICU driver system settings.
*/
-#define STM32_ICU_USE_TIM1 FALSE
-#define STM32_ICU_USE_TIM2 FALSE
-#define STM32_ICU_USE_TIM3 FALSE
-#define STM32_ICU_USE_TIM4 FALSE
-#define STM32_ICU_USE_TIM8 FALSE
-#define STM32_ICU_TIM1_IRQ_PRIORITY 7
-#define STM32_ICU_TIM2_IRQ_PRIORITY 7
-#define STM32_ICU_TIM3_IRQ_PRIORITY 7
-#define STM32_ICU_TIM4_IRQ_PRIORITY 7
-#define STM32_ICU_TIM8_IRQ_PRIORITY 7
+#define STM32_ICU_USE_TIM1 FALSE
+#define STM32_ICU_USE_TIM2 FALSE
+#define STM32_ICU_USE_TIM3 FALSE
+#define STM32_ICU_USE_TIM4 FALSE
+#define STM32_ICU_USE_TIM8 FALSE
+#define STM32_ICU_TIM1_IRQ_PRIORITY 7
+#define STM32_ICU_TIM2_IRQ_PRIORITY 7
+#define STM32_ICU_TIM3_IRQ_PRIORITY 7
+#define STM32_ICU_TIM4_IRQ_PRIORITY 7
+#define STM32_ICU_TIM8_IRQ_PRIORITY 7
/*
* PWM driver system settings.
*/
-#define STM32_PWM_USE_ADVANCED FALSE
-#define STM32_PWM_USE_TIM1 FALSE
-#define STM32_PWM_USE_TIM2 TRUE
-#define STM32_PWM_USE_TIM3 TRUE
-#define STM32_PWM_USE_TIM4 FALSE
-#define STM32_PWM_USE_TIM8 FALSE
-#define STM32_PWM_TIM1_IRQ_PRIORITY 7
-#define STM32_PWM_TIM2_IRQ_PRIORITY 7
-#define STM32_PWM_TIM3_IRQ_PRIORITY 7
-#define STM32_PWM_TIM4_IRQ_PRIORITY 7
-#define STM32_PWM_TIM8_IRQ_PRIORITY 7
+#define STM32_PWM_USE_ADVANCED FALSE
+#define STM32_PWM_USE_TIM1 FALSE
+#define STM32_PWM_USE_TIM2 FALSE
+#define STM32_PWM_USE_TIM3 TRUE
+#define STM32_PWM_USE_TIM4 TRUE
+#define STM32_PWM_USE_TIM8 FALSE
+#define STM32_PWM_TIM1_IRQ_PRIORITY 7
+#define STM32_PWM_TIM2_IRQ_PRIORITY 7
+#define STM32_PWM_TIM3_IRQ_PRIORITY 7
+#define STM32_PWM_TIM4_IRQ_PRIORITY 7
+#define STM32_PWM_TIM8_IRQ_PRIORITY 7
/*
* SERIAL driver system settings.
*/
-#define STM32_SERIAL_USE_USART1 FALSE
-#define STM32_SERIAL_USE_USART2 TRUE
-#define STM32_SERIAL_USE_USART3 FALSE
-#define STM32_SERIAL_USE_UART4 FALSE
-#define STM32_SERIAL_USE_UART5 FALSE
-#define STM32_SERIAL_USART1_PRIORITY 12
-#define STM32_SERIAL_USART2_PRIORITY 12
-#define STM32_SERIAL_USART3_PRIORITY 12
-#define STM32_SERIAL_UART4_PRIORITY 12
-#define STM32_SERIAL_UART5_PRIORITY 12
+#define STM32_SERIAL_USE_USART1 FALSE
+#define STM32_SERIAL_USE_USART2 TRUE
+#define STM32_SERIAL_USE_USART3 FALSE
+#define STM32_SERIAL_USE_UART4 FALSE
+#define STM32_SERIAL_USE_UART5 FALSE
+#define STM32_SERIAL_USART1_PRIORITY 12
+#define STM32_SERIAL_USART2_PRIORITY 12
+#define STM32_SERIAL_USART3_PRIORITY 12
+#define STM32_SERIAL_UART4_PRIORITY 12
+#define STM32_SERIAL_UART5_PRIORITY 12
/*
* SPI driver system settings.
*/
-#define STM32_SPI_USE_SPI1 FALSE
-#define STM32_SPI_USE_SPI2 FALSE
-#define STM32_SPI_USE_SPI3 FALSE
-#define STM32_SPI_SPI1_DMA_PRIORITY 1
-#define STM32_SPI_SPI2_DMA_PRIORITY 1
-#define STM32_SPI_SPI3_DMA_PRIORITY 1
-#define STM32_SPI_SPI1_IRQ_PRIORITY 10
-#define STM32_SPI_SPI2_IRQ_PRIORITY 10
-#define STM32_SPI_SPI3_IRQ_PRIORITY 10
-#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
+#define STM32_SPI_USE_SPI1 FALSE
+#define STM32_SPI_USE_SPI2 FALSE
+#define STM32_SPI_USE_SPI3 FALSE
+#define STM32_SPI_SPI1_DMA_PRIORITY 1
+#define STM32_SPI_SPI2_DMA_PRIORITY 1
+#define STM32_SPI_SPI3_DMA_PRIORITY 1
+#define STM32_SPI_SPI1_IRQ_PRIORITY 10
+#define STM32_SPI_SPI2_IRQ_PRIORITY 10
+#define STM32_SPI_SPI3_IRQ_PRIORITY 10
+#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
/*
* ST driver system settings.
*/
-#define STM32_ST_IRQ_PRIORITY 8
-#define STM32_ST_USE_TIMER 2
+#define STM32_ST_IRQ_PRIORITY 8
+#define STM32_ST_USE_TIMER 2
/*
* UART driver system settings.
*/
-#define STM32_UART_USE_USART1 FALSE
-#define STM32_UART_USE_USART2 FALSE
-#define STM32_UART_USE_USART3 FALSE
-#define STM32_UART_USART1_IRQ_PRIORITY 12
-#define STM32_UART_USART2_IRQ_PRIORITY 12
-#define STM32_UART_USART3_IRQ_PRIORITY 12
-#define STM32_UART_USART1_DMA_PRIORITY 0
-#define STM32_UART_USART2_DMA_PRIORITY 0
-#define STM32_UART_USART3_DMA_PRIORITY 0
-#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
+#define STM32_UART_USE_USART1 FALSE
+#define STM32_UART_USE_USART2 FALSE
+#define STM32_UART_USE_USART3 FALSE
+#define STM32_UART_USART1_IRQ_PRIORITY 12
+#define STM32_UART_USART2_IRQ_PRIORITY 12
+#define STM32_UART_USART3_IRQ_PRIORITY 12
+#define STM32_UART_USART1_DMA_PRIORITY 0
+#define STM32_UART_USART2_DMA_PRIORITY 0
+#define STM32_UART_USART3_DMA_PRIORITY 0
+#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
/*
* USB driver system settings.
*/
-#define STM32_USB_USE_USB1 TRUE
-#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
-#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
-#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
+#define STM32_USB_USE_USB1 TRUE
+#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
+#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
/*
* WDG driver system settings.
*/
-#define STM32_WDG_USE_IWDG FALSE
+#define STM32_WDG_USE_IWDG FALSE
#endif /* MCUCONF_H */
diff --git a/quantum/stm32/proton_c.mk b/quantum/stm32/proton_c.mk
index a65e283d3f..ff28a4cb5d 100644
--- a/quantum/stm32/proton_c.mk
+++ b/quantum/stm32/proton_c.mk
@@ -2,8 +2,12 @@
# These are defaults based on what has been implemented for ARM boards
AUDIO_ENABLE = yes
-RGBLIGHT_ENABLE = no
-BACKLIGHT_ENABLE = no
+WS2812_DRIVER = bitbang
+
+# Force task driven PWM until ARM can provide automatic configuration
+ifneq ($(strip $(BACKLIGHT_ENABLE)), no)
+ BACKLIGHT_ENABLE = software
+endif
# The rest of these settings shouldn't change
diff --git a/quantum/template/avr/config.h b/quantum/template/avr/config.h
index 1e41a2d31d..7e4a014495 100644
--- a/quantum/template/avr/config.h
+++ b/quantum/template/avr/config.h
@@ -20,12 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config_common.h"
/* USB Device descriptor parameter */
-#define VENDOR_ID 0xFEED
-#define PRODUCT_ID 0x0000
-#define DEVICE_VER 0x0001
-#define MANUFACTURER %YOUR_NAME%
-#define PRODUCT %KEYBOARD%
-#define DESCRIPTION A custom keyboard
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x0000
+#define DEVICE_VER 0x0001
+#define MANUFACTURER %YOUR_NAME%
+#define PRODUCT %KEYBOARD%
+#define DESCRIPTION A custom keyboard
/* key matrix size */
#define MATRIX_ROWS 2
@@ -40,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
*
-*/
+ */
#define MATRIX_ROW_PINS { D0, D5 }
#define MATRIX_COL_PINS { F1, F0, B0 }
#define UNUSED_PINS
@@ -51,7 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
*/
-#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
+#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
// #define BACKLIGHT_PIN B7
// #define BACKLIGHT_BREATHING
@@ -91,8 +91,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* define if matrix has ghost (lacks anti-ghosting diodes) */
//#define MATRIX_HAS_GHOST
-/* number of backlight levels */
-
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
@@ -138,7 +136,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* key combination for magic key command */
/* defined by default; to change, uncomment and set to the combination you want */
-// #define IS_COMMAND() (get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
+// #define IS_COMMAND() (get_mods() == MOD_MASK_SHIFT)
/* control how magic key switches layers */
//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
@@ -192,9 +190,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
-//#define NO_ACTION_MACRO
-//#define NO_ACTION_FUNCTION
+/* disable these deprecated features by default */
+#ifndef LINK_TIME_OPTIMIZATION_ENABLE
+ #define NO_ACTION_MACRO
+ #define NO_ACTION_FUNCTION
+#endif
/*
* MIDI options
*/
diff --git a/quantum/template/avr/readme.md b/quantum/template/avr/readme.md
index 719222d377..0430dd0fc9 100644
--- a/quantum/template/avr/readme.md
+++ b/quantum/template/avr/readme.md
@@ -4,9 +4,9 @@
A short description of the keyboard/project
-Keyboard Maintainer: [%YOUR_NAME%](https://github.com/yourusername)
-Hardware Supported: The PCBs, controllers supported
-Hardware Availability: links to where you can find this hardware
+* Keyboard Maintainer: [%YOUR_NAME%](https://github.com/yourusername)
+* Hardware Supported: The PCBs, controllers supported
+* Hardware Availability: Links to where you can find this hardware
Make example for this keyboard (after setting up your build environment):
diff --git a/quantum/template/avr/rules.mk b/quantum/template/avr/rules.mk
index 383a3594b4..ea0c83c68a 100644
--- a/quantum/template/avr/rules.mk
+++ b/quantum/template/avr/rules.mk
@@ -1,56 +1,19 @@
# MCU name
-#MCU = at90usb1286
MCU = atmega32u4
-# Processor frequency.
-# This will define a symbol, F_CPU, in all source code files equal to the
-# processor frequency in Hz. You can then use this symbol in your source code to
-# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-# automatically to create a 32-bit value in your source code.
-#
-# This will be an integer division of F_USB below, as it is sourced by
-# F_USB after it has run through any CPU prescalers. Note that this value
-# does not *change* the processor frequency - it should merely be updated to
-# reflect the processor speed set externally so that the code can use accurate
-# software delays.
-F_CPU = 16000000
-
-
-#
-# LUFA specific
-#
-# Target architecture (see library "Board Types" documentation).
-ARCH = AVR8
-
-# Input clock frequency.
-# This will define a symbol, F_USB, in all source code files equal to the
-# input clock frequency (before any prescaling is performed) in Hz. This value may
-# differ from F_CPU if prescaling is used on the latter, and is required as the
-# raw input clock is fed directly to the PLL sections of the AVR for high speed
-# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
-# at the end, this will be done automatically to create a 32-bit value in your
-# source code.
-#
-# If no clock division is performed on the input clock inside the AVR (via the
-# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
-F_USB = $(F_CPU)
-
-# Interrupt driven control endpoint task(+60)
-OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
-
-
# Bootloader selection
# Teensy halfkay
# Pro Micro caterina
# Atmel DFU atmel-dfu
# LUFA DFU lufa-dfu
# QMK DFU qmk-dfu
-# atmega32a bootloadHID
+# ATmega32A bootloadHID
+# ATmega328P USBasp
BOOTLOADER = atmel-dfu
-
# If you don't know the bootloader type, then you can specify the
# Boot Section Size in *bytes* by uncommenting out the OPT_DEFS line
+# Otherwise, delete this section
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
@@ -58,24 +21,22 @@ BOOTLOADER = atmel-dfu
# USBaspLoader 2048
# OPT_DEFS += -DBOOTLOADER_SIZE=4096
-
# Build Options
# change yes to no to disable
#
-BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = yes # Console for debug(+400)
+BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = yes # Mouse keys
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = no # USB Nkey Rollover
-BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
-MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
-UNICODE_ENABLE = no # Unicode
+MIDI_ENABLE = no # MIDI support
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE = no # Audio output on port C6
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
-HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
+HD44780_ENABLE = no # Enable support for HD44780 based LCDs
diff --git a/quantum/template/base/info.json b/quantum/template/base/info.json
index e69de29bb2..b8e8f1f2db 100644
--- a/quantum/template/base/info.json
+++ b/quantum/template/base/info.json
@@ -0,0 +1,18 @@
+{
+ "keyboard_name": "%KEYBOARD%",
+ "url": "",
+ "maintainer": "%YOUR_NAME%",
+ "width": 3,
+ "height": 2,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [
+ {"label":"k00", "x":0, "y":0},
+ {"label":"k01", "x":1, "y":0},
+ {"label":"k02", "x":2, "y":0},
+ {"label":"k10", "x":0, "y":1, "w":1.5},
+ {"label":"k12", "x":1.5, "y":1, "w":1.5}
+ ]
+ }
+ }
+}
diff --git a/quantum/template/avr/template.c b/quantum/template/base/keyboard.c
index e852a42c40..fc31c294a2 100644
--- a/quantum/template/avr/template.c
+++ b/quantum/template/base/keyboard.c
@@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include "%KEYBOARD%.h"
// Optional override functions below.
@@ -20,32 +21,30 @@
// These are only required if you want to perform custom actions.
/*
-
void matrix_init_kb(void) {
- // put your keyboard start-up code here
- // runs once when the firmware starts up
+ // put your keyboard start-up code here
+ // runs once when the firmware starts up
- matrix_init_user();
+ matrix_init_user();
}
void matrix_scan_kb(void) {
- // put your looping keyboard code here
- // runs every cycle (a lot)
+ // put your looping keyboard code here
+ // runs every cycle (a lot)
- matrix_scan_user();
+ matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
- // put your per-action keyboard code here
- // runs for every action, just before processing by the firmware
+ // put your per-action keyboard code here
+ // runs for every action, just before processing by the firmware
- return process_record_user(keycode, record);
+ return process_record_user(keycode, record);
}
-void led_set_kb(uint8_t usb_led) {
- // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
+bool led_update_kb(led_t led_state) {
+ // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
- led_set_user(usb_led);
+ return led_update_user(led_state);
}
-
*/
diff --git a/quantum/template/base/template.h b/quantum/template/base/keyboard.h
index 2e531b1fd4..8a21d92578 100644
--- a/quantum/template/base/template.h
+++ b/quantum/template/base/keyboard.h
@@ -13,11 +13,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#pragma once
#include "quantum.h"
-/* This a shortcut to help you visually see your layout.
+/* This is a shortcut to help you visually see your layout.
*
* The first section contains all of the arguments representing the physical
* layout of the board and position of the keys.
@@ -27,9 +28,9 @@
*/
#define LAYOUT( \
k00, k01, k02, \
- k10, k11 \
+ k10, k12 \
) \
{ \
{ k00, k01, k02 }, \
- { k10, KC_NO, k11 }, \
+ { k10, KC_NO, k12 } \
}
diff --git a/quantum/template/base/keymaps/default/keymap.c b/quantum/template/base/keymaps/default/keymap.c
index 0e9fad357f..3a68f5487c 100644
--- a/quantum/template/base/keymaps/default/keymap.c
+++ b/quantum/template/base/keymaps/default/keymap.c
@@ -15,41 +15,53 @@
*/
#include QMK_KEYBOARD_H
+// Defines names for use in layer keycodes and the keymap
+enum layer_names {
+ _BASE,
+ _FN
+};
+
// Defines the keycodes used by our macros in process_record_user
enum custom_keycodes {
- QMKBEST = SAFE_RANGE,
- QMKURL
+ QMKBEST = SAFE_RANGE,
+ QMKURL
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- [0] = LAYOUT( /* Base */
- KC_A, KC_1, KC_H, \
- KC_TAB, KC_SPC \
- ),
+ /* Base */
+ [_BASE] = LAYOUT(
+ KC_A, KC_1, MO(_FN),
+ KC_TAB, KC_SPC
+ ),
+ [_FN] = LAYOUT(
+ QMKBEST, QMKURL, _______,
+ RESET, XXXXXXX
+ )
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- switch (keycode) {
- case QMKBEST:
- if (record->event.pressed) {
- // when keycode QMKBEST is pressed
- SEND_STRING("QMK is the best thing ever!");
- } else {
- // when keycode QMKBEST is released
- }
- break;
- case QMKURL:
- if (record->event.pressed) {
- // when keycode QMKURL is pressed
- SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
- } else {
- // when keycode QMKURL is released
- }
- break;
- }
- return true;
+ switch (keycode) {
+ case QMKBEST:
+ if (record->event.pressed) {
+ // when keycode QMKBEST is pressed
+ SEND_STRING("QMK is the best thing ever!");
+ } else {
+ // when keycode QMKBEST is released
+ }
+ break;
+ case QMKURL:
+ if (record->event.pressed) {
+ // when keycode QMKURL is pressed
+ SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
+ } else {
+ // when keycode QMKURL is released
+ }
+ break;
+ }
+ return true;
}
+/*
void matrix_init_user(void) {
}
@@ -58,6 +70,7 @@ void matrix_scan_user(void) {
}
-void led_set_user(uint8_t usb_led) {
-
+bool led_update_user(led_t led_state) {
+ return true;
}
+*/
diff --git a/quantum/template/base/keymaps/default/readme.md b/quantum/template/base/keymaps/default/readme.md
index 21aa663d55..e052ed80f1 100644
--- a/quantum/template/base/keymaps/default/readme.md
+++ b/quantum/template/base/keymaps/default/readme.md
@@ -1 +1 @@
-# The default keymap for %KEYBOARD% \ No newline at end of file
+# The default keymap for %KEYBOARD%
diff --git a/quantum/template/ps2avrgb/config.h b/quantum/template/ps2avrgb/config.h
index 320d71fcbc..d93512bca6 100644
--- a/quantum/template/ps2avrgb/config.h
+++ b/quantum/template/ps2avrgb/config.h
@@ -19,12 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config_common.h"
-#define VENDOR_ID 0x20A0
-#define PRODUCT_ID 0x422D
-#define DEVICE_VER 0x0001
-#define MANUFACTURER You
-#define PRODUCT %KEYBOARD%
-#define DESCRIPTION A custom keyboard
+#define VENDOR_ID 0x20A0
+#define PRODUCT_ID 0x422D
+#define DEVICE_VER 0x0001
+#define MANUFACTURER %YOUR_NAME%
+#define PRODUCT %KEYBOARD%
+#define DESCRIPTION A custom keyboard
#define RGBLED_NUM 16
@@ -34,20 +34,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5 }
// #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, C1, C0, D7 }
-#define UNUSED_PINS {}
+#define UNUSED_PINS {}
#define DIODE_DIRECTION COL2ROW
#define DEBOUNCE 5
-#define NO_BACKLIGHT_CLOCK
#define BACKLIGHT_LEVELS 1
#define RGBLIGHT_ANIMATIONS
#define NO_UART 1
+/* disable these deprecated features by default */
+#ifndef LINK_TIME_OPTIMIZATION_ENABLE
+ #define NO_ACTION_MACRO
+ #define NO_ACTION_FUNCTION
+#endif
+
/* key combination for magic key command */
/* defined by default; to change, uncomment and set to the combination you want */
-// #define IS_COMMAND() (get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
+// #define IS_COMMAND() (get_mods() == MOD_MASK_SHIFT)
/* Bootmagic Lite key configuration */
// #define BOOTMAGIC_LITE_ROW 0
diff --git a/quantum/template/ps2avrgb/readme.md b/quantum/template/ps2avrgb/readme.md
index 1449b278cd..b45ef91c9d 100644
--- a/quantum/template/ps2avrgb/readme.md
+++ b/quantum/template/ps2avrgb/readme.md
@@ -4,43 +4,18 @@
A short description of the keyboard/project
-Keyboard Maintainer: [%YOUR_NAME%](https://github.com/yourusername)
-Hardware Supported: The PCBs, controllers supported
-Hardware Availability: links to where you can find this hardware
+* Keyboard Maintainer: [%YOUR_NAME%](https://github.com/yourusername)
+* Hardware Supported: The PCBs, controllers supported
+* Hardware Availability: links to where you can find this hardware
Make example for this keyboard (after setting up your build environment):
make %KEYBOARD%:default
-Flashing
-
-ps2avr(GB) boards use an atmega32a microcontroller and a different bootloader. It is not flashable using the regular QMK methods.
-
-**Reset Key:** Hold down the key located at `K00`, commonly programmed as `Esc` while plugging in the keyboard.
-
-Windows:
-1. Download [HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash).
-2. Place your keyboard into reset.
-3. Press the `Find Device` button and ensure that your keyboard is found.
-4. Press the `Open .hex File` button and locate the `.hex` file you created.
-5. Press the `Flash Device` button and wait for the process to complete.
-
-macOS:
-1. Install homebrew by typing the following:
- ```
- /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- ```
-2. Install `crosspack-avr`.
- ```
- brew cask install crosspack-avr
- ```
-3. Install the following packages:
- ```
- brew install python3
- pip3 install pyusb
- brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb
- ```
-4. Place your keyboard into reset.
-5. Flash the board by typing `bootloadHID -r` followed by the path to your `.hex` file.
+Flashing example for this keyboard ([after setting up the bootloadHID flashing environment](https://docs.qmk.fm/#/flashing_bootloadhid))
+
+ make %KEYBOARD%:default:flash
+
+**Reset Key**: Hold down the key located at *LOCATION*, commonly programmed as *KEY* while plugging in the keyboard.
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/quantum/template/ps2avrgb/rules.mk b/quantum/template/ps2avrgb/rules.mk
index 98a920e182..b9b81a6750 100644
--- a/quantum/template/ps2avrgb/rules.mk
+++ b/quantum/template/ps2avrgb/rules.mk
@@ -1,33 +1,26 @@
# MCU name
MCU = atmega32a
-PROTOCOL = VUSB
-# unsupported features for now
-NO_UART = yes
-NO_SUSPEND_POWER_DOWN = yes
-
-# processor frequency
-F_CPU = 12000000
-
-# Bootloader
-# This definition is optional, and if your keyboard supports multiple bootloaders of
-# different sizes, comment this out, and the correct address will be loaded
-# automatically (+60). See bootloader.mk for all options.
+# Bootloader selection
+# Teensy halfkay
+# Pro Micro caterina
+# Atmel DFU atmel-dfu
+# LUFA DFU lufa-dfu
+# QMK DFU qmk-dfu
+# ATmega32A bootloadHID
+# ATmega328P USBasp
BOOTLOADER = bootloadHID
-# build options
-BOOTMAGIC_ENABLE = no
-MOUSEKEY_ENABLE = no
-EXTRAKEY_ENABLE = yes
-CONSOLE_ENABLE = yes
-COMMAND_ENABLE = yes
-BACKLIGHT_ENABLE = no
-RGBLIGHT_ENABLE = yes
-RGBLIGHT_CUSTOM_DRIVER = yes
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = no # Mouse keys
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = yes # Console for debug
+COMMAND_ENABLE = yes # Commands for debug and configuration
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
+WS2812_DRIVER = i2c
OPT_DEFS = -DDEBUG_LEVEL=0
-
-SRC += i2c_master.c
-
-# programming options
-PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex
diff --git a/quantum/template/ps2avrgb/template.c b/quantum/template/ps2avrgb/template.c
deleted file mode 100644
index 07f27bbb22..0000000000
--- a/quantum/template/ps2avrgb/template.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright %YEAR% %YOUR_NAME%
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "%KEYBOARD%.h"
-
-#ifdef RGBLIGHT_ENABLE
-
-#include <string.h>
-#include "i2c_master.h"
-#include "rgblight.h"
-
-extern rgblight_config_t rgblight_config;
-
-void matrix_init_kb(void) {
- i2c_init();
- // call user level keymaps, if any
- matrix_init_user();
-}
-
-// custom RGB driver
-void rgblight_set(void) {
- if (!rgblight_config.enable) {
- memset(led, 0, 3 * RGBLED_NUM);
- }
-
- i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
- // if LEDs were previously on before poweroff, turn them back on
- if (rgb_init == false && rgblight_config.enable) {
- i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
- rgb_init = true;
- }
-
- rgblight_task();
- matrix_scan_user();
-}
-
-#endif
-
-// Optional override functions below.
-// You can leave any or all of these undefined.
-// These are only required if you want to perform custom actions.
-
-/*
-
-void matrix_init_kb(void) {
- // put your keyboard start-up code here
- // runs once when the firmware starts up
-
- matrix_init_user();
-}
-
-void matrix_scan_kb(void) {
- // put your looping keyboard code here
- // runs every cycle (a lot)
-
- matrix_scan_user();
-}
-
-bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
- // put your per-action keyboard code here
- // runs for every action, just before processing by the firmware
-
- return process_record_user(keycode, record);
-}
-
-void led_set_kb(uint8_t usb_led) {
- // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
-
- led_set_user(usb_led);
-}
-
-*/
diff --git a/quantum/template/ps2avrgb/usbconfig.h b/quantum/template/ps2avrgb/usbconfig.h
index 465db3a134..83ad06544d 100644
--- a/quantum/template/ps2avrgb/usbconfig.h
+++ b/quantum/template/ps2avrgb/usbconfig.h
@@ -14,15 +14,15 @@ section at the end of this file).
/* ---------------------------- Hardware Config ---------------------------- */
-#define USB_CFG_IOPORTNAME D
+#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
-#define USB_CFG_DMINUS_BIT 3
+#define USB_CFG_DMINUS_BIT 3
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
-#define USB_CFG_DPLUS_BIT 2
+#define USB_CFG_DPLUS_BIT 2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0! [You can also use other interrupts, see section
@@ -31,7 +31,7 @@ section at the end of this file).
* interrupt, the USB interrupt will also be triggered at Start-Of-Frame
* markers every millisecond.]
*/
-#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
+#define USB_CFG_CLOCK_KHZ (F_CPU / 1000)
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
* 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
* require no crystal, they tolerate +/- 1% deviation from the nominal
@@ -40,7 +40,7 @@ section at the end of this file).
* Since F_CPU should be defined to your actual clock rate anyway, you should
* not need to modify this setting.
*/
-#define USB_CFG_CHECK_CRC 0
+#define USB_CFG_CHECK_CRC 0
/* Define this to 1 if you want that the driver checks integrity of incoming
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
* currently only available for 18 MHz crystal clock. You must choose
@@ -63,18 +63,18 @@ section at the end of this file).
/* --------------------------- Functional Range ---------------------------- */
-#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
+#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
/* Define this to 1 if you want to compile a version with two endpoints: The
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
* number).
*/
-#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
+#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
/* Define this to 1 if you want to compile a version with three endpoints: The
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
* configured below) and a catch-all default interrupt-in endpoint as above.
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
*/
-#define USB_CFG_EP3_NUMBER 3
+#define USB_CFG_EP3_NUMBER 3
/* If the so-called endpoint 3 is used, it can now be configured to any other
* endpoint number (except 0) with this macro. Default if undefined is 3.
*/
@@ -84,13 +84,13 @@ section at the end of this file).
* Since the token is toggled BEFORE sending any data, the first packet is
* sent with the oposite value of this configuration!
*/
-#define USB_CFG_IMPLEMENT_HALT 0
+#define USB_CFG_IMPLEMENT_HALT 0
/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
* for endpoint 1 (interrupt endpoint). Although you may not need this feature,
* it is required by the standard. We have made it a config option because it
* bloats the code considerably.
*/
-#define USB_CFG_SUPPRESS_INTR_CODE 0
+#define USB_CFG_SUPPRESS_INTR_CODE 0
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
* want to send any data over them. If this macro is defined to 1, functions
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
@@ -98,48 +98,38 @@ section at the end of this file).
* (e.g. HID), but never want to send any data. This option saves a couple
* of bytes in flash memory and the transmit buffers in RAM.
*/
-#define USB_CFG_INTR_POLL_INTERVAL 1
-/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
- * interval. The value is in milliseconds and must not be less than 10 ms for
- * low speed devices.
- */
-#define USB_CFG_IS_SELF_POWERED 0
+#define USB_CFG_IS_SELF_POWERED 0
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
* device is powered from the USB bus.
*/
-#define USB_CFG_MAX_BUS_POWER 500
-/* Set this variable to the maximum USB bus power consumption of your device.
- * The value is in milliamperes. [It will be divided by two since USB
- * communicates power requirements in units of 2 mA.]
- */
-#define USB_CFG_IMPLEMENT_FN_WRITE 1
+#define USB_CFG_IMPLEMENT_FN_WRITE 1
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
* transfers. Set it to 0 if you don't need it and want to save a couple of
* bytes.
*/
-#define USB_CFG_IMPLEMENT_FN_READ 0
+#define USB_CFG_IMPLEMENT_FN_READ 0
/* Set this to 1 if you need to send control replies which are generated
* "on the fly" when usbFunctionRead() is called. If you only want to send
* data from a static buffer, set it to 0 and return the data from
* usbFunctionSetup(). This saves a couple of bytes.
*/
-#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
+#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
* You must implement the function usbFunctionWriteOut() which receives all
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
* can be found in 'usbRxToken'.
*/
-#define USB_CFG_HAVE_FLOWCONTROL 0
+#define USB_CFG_HAVE_FLOWCONTROL 0
/* Define this to 1 if you want flowcontrol over USB data. See the definition
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
* usbdrv.h.
*/
-#define USB_CFG_DRIVER_FLASH_PAGE 0
+#define USB_CFG_DRIVER_FLASH_PAGE 0
/* If the device has more than 64 kBytes of flash, define this to the 64 k page
* where the driver's constants (descriptors) are located. Or in other words:
* Define this to 1 for boot loaders on the ATMega128.
*/
-#define USB_CFG_LONG_TRANSFERS 0
+#define USB_CFG_LONG_TRANSFERS 0
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
* in a single control-in or control-out transfer. Note that the capability
* for long transfers increases the driver size.
@@ -160,7 +150,7 @@ section at the end of this file).
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
* received.
*/
-#define USB_COUNT_SOF 1
+#define USB_COUNT_SOF 1
/* define this macro to 1 if you need the global variable "usbSofCount" which
* counts SOF packets. This feature requires that the hardware interrupt is
* connected to D- instead of D+.
@@ -184,7 +174,7 @@ section at the end of this file).
* Please note that Start Of Frame detection works only if D- is wired to the
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
*/
-#define USB_CFG_CHECK_DATA_TOGGLING 0
+#define USB_CFG_CHECK_DATA_TOGGLING 0
/* define this macro to 1 if you want to filter out duplicate data packets
* sent by the host. Duplicates occur only as a consequence of communication
* errors, when the host does not receive an ACK. Please note that you need to
@@ -192,11 +182,11 @@ section at the end of this file).
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
* for each control- and out-endpoint to check for duplicate packets.
*/
-#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
+#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
/* define this macro to 1 if you want the function usbMeasureFrameLength()
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
*/
-#define USB_USE_FAST_CRC 0
+#define USB_USE_FAST_CRC 0
/* The assembler module has two implementations for the CRC algorithm. One is
* faster, the other is smaller. This CRC routine is only used for transmitted
* messages where timing is not critical. The faster routine needs 31 cycles
@@ -207,7 +197,7 @@ section at the end of this file).
/* -------------------------- Device Description --------------------------- */
-#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF)
+#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF)
/* USB vendor ID for the device, low byte first. If you have registered your
* own Vendor ID, define it here. Otherwise you may use one of obdev's free
* shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
@@ -216,7 +206,7 @@ section at the end of this file).
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
* the implications!
*/
-#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF)
+#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF)
/* This is the ID of the product, low byte first. It is interpreted in the
* scope of the vendor ID. If you have registered your own VID with usb.org
* or if you have licensed a PID from somebody else, define it here. Otherwise
@@ -227,10 +217,10 @@ section at the end of this file).
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
* the implications!
*/
-#define USB_CFG_DEVICE_VERSION 0x00, 0x02
+#define USB_CFG_DEVICE_VERSION (DEVICE_VER & 0xFF), ((DEVICE_VER >> 8) & 0xFF)
/* Version number of the device: Minor number first, then major number.
*/
-#define USB_CFG_VENDOR_NAME 'w', 'i', 'n', 'k', 'e', 'y', 'l', 'e', 's', 's', '.', 'k', 'r'
+#define USB_CFG_VENDOR_NAME 'w', 'i', 'n', 'k', 'e', 'y', 'l', 'e', 's', 's', '.', 'k', 'r'
#define USB_CFG_VENDOR_NAME_LEN 13
/* These two values define the vendor name returned by the USB device. The name
* must be given as a list of characters under single quotes. The characters
@@ -240,7 +230,7 @@ section at the end of this file).
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
* details.
*/
-#define USB_CFG_DEVICE_NAME 'p', 's', '2', 'a', 'v', 'r', 'G', 'B'
+#define USB_CFG_DEVICE_NAME 'p', 's', '2', 'a', 'v', 'r', 'G', 'B'
#define USB_CFG_DEVICE_NAME_LEN 8
/* Same as above for the device name. If you don't want a device name, undefine
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
@@ -255,20 +245,20 @@ section at the end of this file).
* to fine tune control over USB descriptors such as the string descriptor
* for the serial number.
*/
-#define USB_CFG_DEVICE_CLASS 0
-#define USB_CFG_DEVICE_SUBCLASS 0
+#define USB_CFG_DEVICE_CLASS 0
+#define USB_CFG_DEVICE_SUBCLASS 0
/* See USB specification if you want to conform to an existing device class.
* Class 0xff is "vendor specific".
*/
-#define USB_CFG_INTERFACE_CLASS 3 /* HID */
-#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */
-#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */
+#define USB_CFG_INTERFACE_CLASS 3 /* HID */
+#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */
+#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */
/* See USB specification if you want to conform to an existing device class or
* protocol. The following classes must be set at interface level:
* HID class is 3, no subclass and protocol required (but may be useful!)
* CDC class is 2, use subclass 2 and protocol 1 for ACM
*/
-#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
+#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
/* Define this to the length of the HID report descriptor, if you implement
* an HID device. Otherwise don't define it or define it to 0.
* If you use this define, you must add a PROGMEM character array named
@@ -333,19 +323,19 @@ section at the end of this file).
* };
*/
-#define USB_CFG_DESCR_PROPS_DEVICE 0
-#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_DEVICE 0
+#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
-#define USB_CFG_DESCR_PROPS_STRINGS 0
-#define USB_CFG_DESCR_PROPS_STRING_0 0
-#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
-#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
-#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
-#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_STRINGS 0
+#define USB_CFG_DESCR_PROPS_STRING_0 0
+#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
+#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
+#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
+#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
//#define USB_CFG_DESCR_PROPS_HID 0
-#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
//#define USB_CFG_DESCR_PROPS_HID_REPORT 0
-#define USB_CFG_DESCR_PROPS_UNKNOWN 0
+#define USB_CFG_DESCR_PROPS_UNKNOWN 0
#define usbMsgPtr_t unsigned short
/* If usbMsgPtr_t is not defined, it defaults to 'uchar *'. We define it to
@@ -374,10 +364,10 @@ section at the end of this file).
/* Set INT1 for D- falling edge to count SOF */
/* #define USB_INTR_CFG EICRA */
-#define USB_INTR_CFG_SET ((1 << ISC11) | (0 << ISC10))
+#define USB_INTR_CFG_SET ((1 << ISC11) | (0 << ISC10))
/* #define USB_INTR_CFG_CLR 0 */
/* #define USB_INTR_ENABLE EIMSK */
-#define USB_INTR_ENABLE_BIT INT1
+#define USB_INTR_ENABLE_BIT INT1
/* #define USB_INTR_PENDING EIFR */
-#define USB_INTR_PENDING_BIT INTF1
-#define USB_INTR_VECTOR INT1_vect
+#define USB_INTR_PENDING_BIT INTF1
+#define USB_INTR_VECTOR INT1_vect
diff --git a/quantum/variable_trace.c b/quantum/variable_trace.c
index 713747cfc2..00562bc920 100644
--- a/quantum/variable_trace.c
+++ b/quantum/variable_trace.c
@@ -19,26 +19,25 @@
#include <string.h>
#ifdef NO_PRINT
-#error "You need undef NO_PRINT to use the variable trace feature"
+# error "You need undef NO_PRINT to use the variable trace feature"
#endif
#ifndef CONSOLE_ENABLE
-#error "The console needs to be enabled in the makefile to use the variable trace feature"
+# error "The console needs to be enabled in the makefile to use the variable trace feature"
#endif
-
#define NUM_TRACED_VARIABLES 1
#ifndef MAX_VARIABLE_TRACE_SIZE
- #define MAX_VARIABLE_TRACE_SIZE 4
+# define MAX_VARIABLE_TRACE_SIZE 4
#endif
typedef struct {
const char* name;
- void* addr;
- unsigned size;
+ void* addr;
+ unsigned size;
const char* func;
- int line;
- uint8_t last_value[MAX_VARIABLE_TRACE_SIZE];
+ int line;
+ uint8_t last_value[MAX_VARIABLE_TRACE_SIZE];
} traced_variable_t;
@@ -48,18 +47,17 @@ void add_traced_variable(const char* name, void* addr, unsigned size, const char
verify_traced_variables(func, line);
if (size > MAX_VARIABLE_TRACE_SIZE) {
#if defined(__AVR__)
- xprintf("Traced variable \"%S\" exceeds the maximum size %d\n", name, size);
+ xprintf("Traced variable \"%S\" exceeds the maximum size %d\n", name, size);
#else
- xprintf("Traced variable \"%s\" exceeds the maximum size %d\n", name, size);
+ xprintf("Traced variable \"%s\" exceeds the maximum size %d\n", name, size);
#endif
- size = MAX_VARIABLE_TRACE_SIZE;
+ size = MAX_VARIABLE_TRACE_SIZE;
}
int index = -1;
for (int i = 0; i < NUM_TRACED_VARIABLES; i++) {
- if (index == -1 && traced_variables[i].addr == NULL){
+ if (index == -1 && traced_variables[i].addr == NULL) {
index = i;
- }
- else if (strcmp_P(name, traced_variables[i].name)==0) {
+ } else if (strcmp_P(name, traced_variables[i].name) == 0) {
index = i;
break;
}
@@ -71,19 +69,18 @@ void add_traced_variable(const char* name, void* addr, unsigned size, const char
}
traced_variable_t* t = &traced_variables[index];
- t->name = name;
- t->addr = addr;
- t->size = size;
- t->func = func;
- t->line = line;
+ t->name = name;
+ t->addr = addr;
+ t->size = size;
+ t->func = func;
+ t->line = line;
memcpy(&t->last_value[0], addr, size);
-
}
void remove_traced_variable(const char* name, const char* func, int line) {
verify_traced_variables(func, line);
for (int i = 0; i < NUM_TRACED_VARIABLES; i++) {
- if (strcmp_P(name, traced_variables[i].name)==0) {
+ if (strcmp_P(name, traced_variables[i].name) == 0) {
traced_variables[i].name = 0;
traced_variables[i].addr = NULL;
break;
@@ -95,29 +92,29 @@ void verify_traced_variables(const char* func, int line) {
for (int i = 0; i < NUM_TRACED_VARIABLES; i++) {
traced_variable_t* t = &traced_variables[i];
if (t->addr != NULL && t->name != NULL) {
- if (memcmp(t->last_value, t->addr, t->size)!=0){
+ if (memcmp(t->last_value, t->addr, t->size) != 0) {
#if defined(__AVR__)
- xprintf("Traced variable \"%S\" has been modified\n", t->name);
- xprintf("Between %S:%d\n", t->func, t->line);
- xprintf("And %S:%d\n", func, line);
+ xprintf("Traced variable \"%S\" has been modified\n", t->name);
+ xprintf("Between %S:%d\n", t->func, t->line);
+ xprintf("And %S:%d\n", func, line);
#else
- xprintf("Traced variable \"%s\" has been modified\n", t->name);
- xprintf("Between %s:%d\n", t->func, t->line);
- xprintf("And %s:%d\n", func, line);
+ xprintf("Traced variable \"%s\" has been modified\n", t->name);
+ xprintf("Between %s:%d\n", t->func, t->line);
+ xprintf("And %s:%d\n", func, line);
#endif
- xprintf("Previous value ");
- for (int j=0; j<t->size;j++) {
- print_hex8(t->last_value[j]);
- }
- xprintf("\nNew value ");
- uint8_t* addr = (uint8_t*)(t->addr);
- for (int j=0; j<t->size;j++) {
- print_hex8(addr[j]);
- }
- xprintf("\n");
- memcpy(t->last_value, addr, t->size);
- }
+ xprintf("Previous value ");
+ for (int j = 0; j < t->size; j++) {
+ print_hex8(t->last_value[j]);
+ }
+ xprintf("\nNew value ");
+ uint8_t* addr = (uint8_t*)(t->addr);
+ for (int j = 0; j < t->size; j++) {
+ print_hex8(addr[j]);
+ }
+ xprintf("\n");
+ memcpy(t->last_value, addr, t->size);
+ }
}
t->func = func;
diff --git a/quantum/variable_trace.h b/quantum/variable_trace.h
index dacc13858d..26b810d3cd 100644
--- a/quantum/variable_trace.h
+++ b/quantum/variable_trace.h
@@ -26,20 +26,19 @@
// Start tracing a variable at the memory address addr
// The name can be anything and is used only for reporting
// The size should usually be the same size as the variable you are interested in
-#define ADD_TRACED_VARIABLE(name, addr, size) \
- add_traced_variable(PSTR(name), (void*)addr, size, PSTR(__FILE__), __LINE__)
+# define ADD_TRACED_VARIABLE(name, addr, size) add_traced_variable(PSTR(name), (void*)addr, size, PSTR(__FILE__), __LINE__)
// Stop tracing the variable with the given name
-#define REMOVE_TRACED_VARIABLE(name) remove_traced_variable(PSTR(name), PSTR(__FILE__), __LINE__)
+# define REMOVE_TRACED_VARIABLE(name) remove_traced_variable(PSTR(name), PSTR(__FILE__), __LINE__)
// Call to get messages when the variable has been changed
-#define VERIFY_TRACED_VARIABLES() verify_traced_variables(PSTR(__FILE__), __LINE__)
+# define VERIFY_TRACED_VARIABLES() verify_traced_variables(PSTR(__FILE__), __LINE__)
#else
-#define ADD_TRACED_VARIABLE(name, addr, size)
-#define REMOVE_TRACED_VARIABLE(name)
-#define VERIFY_TRACED_VARIABLES()
+# define ADD_TRACED_VARIABLE(name, addr, size)
+# define REMOVE_TRACED_VARIABLE(name)
+# define VERIFY_TRACED_VARIABLES()
#endif
diff --git a/quantum/velocikey.c b/quantum/velocikey.c
index 550c3b70a6..6b7f82d950 100644
--- a/quantum/velocikey.c
+++ b/quantum/velocikey.c
@@ -4,23 +4,21 @@
#include "eeprom.h"
#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
-#define MAX(a,b) (((a)>(b))?(a):(b))
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#define TYPING_SPEED_MAX_VALUE 200
uint8_t typing_speed = 0;
-bool velocikey_enabled(void) {
- return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1;
-}
+bool velocikey_enabled(void) { return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1; }
void velocikey_toggle(void) {
- if (velocikey_enabled())
+ if (velocikey_enabled())
eeprom_update_byte(EECONFIG_VELOCIKEY, 0);
- else
+ else
eeprom_update_byte(EECONFIG_VELOCIKEY, 1);
}
@@ -29,18 +27,16 @@ void velocikey_accelerate(void) {
}
void velocikey_decelerate(void) {
- static uint16_t decay_timer = 0;
-
- if (timer_elapsed(decay_timer) > 500 || decay_timer == 0) {
- if (typing_speed > 0) typing_speed -= 1;
- //Decay a little faster at half of max speed
- if (typing_speed > TYPING_SPEED_MAX_VALUE / 2) typing_speed -= 1;
- //Decay even faster at 3/4 of max speed
- if (typing_speed > TYPING_SPEED_MAX_VALUE / 4 * 3) typing_speed -= 2;
- decay_timer = timer_read();
- }
+ static uint16_t decay_timer = 0;
+
+ if (timer_elapsed(decay_timer) > 500 || decay_timer == 0) {
+ if (typing_speed > 0) typing_speed -= 1;
+ // Decay a little faster at half of max speed
+ if (typing_speed > TYPING_SPEED_MAX_VALUE / 2) typing_speed -= 1;
+ // Decay even faster at 3/4 of max speed
+ if (typing_speed > TYPING_SPEED_MAX_VALUE / 4 * 3) typing_speed -= 2;
+ decay_timer = timer_read();
+ }
}
-uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) {
- return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE));
-}
+uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); }
diff --git a/quantum/velocikey.h b/quantum/velocikey.h
index 1910f0f4e9..b977606c5d 100644
--- a/quantum/velocikey.h
+++ b/quantum/velocikey.h
@@ -4,10 +4,10 @@
#include <stdint.h>
#include <stdbool.h>
-bool velocikey_enabled(void);
-void velocikey_toggle(void);
-void velocikey_accelerate(void);
-void velocikey_decelerate(void);
+bool velocikey_enabled(void);
+void velocikey_toggle(void);
+void velocikey_accelerate(void);
+void velocikey_decelerate(void);
uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue);
#endif \ No newline at end of file
diff --git a/quantum/visualizer/common_gfxconf.h b/quantum/visualizer/common_gfxconf.h
index eb705b1881..865e588693 100644
--- a/quantum/visualizer/common_gfxconf.h
+++ b/quantum/visualizer/common_gfxconf.h
@@ -22,7 +22,6 @@
#ifndef COMMON_GFXCONF_H
#define COMMON_GFXCONF_H
-
///////////////////////////////////////////////////////////////////////////
// GOS - One of these must be defined, preferably in your Makefile //
///////////////////////////////////////////////////////////////////////////
@@ -41,11 +40,11 @@
// #define INTERRUPTS_OFF() optional_code
// #define INTERRUPTS_ON() optional_code
// These are not defined by default for some reason
-#define GOS_NEED_X_THREADS FALSE
-#define GOS_NEED_X_HEAP FALSE
+#define GOS_NEED_X_THREADS FALSE
+#define GOS_NEED_X_HEAP FALSE
// Options that (should where relevant) apply to all operating systems
- #define GFX_NO_INLINE FALSE
+#define GFX_NO_INLINE FALSE
// #define GFX_COMPILER GFX_COMPILER_UNKNOWN
// #define GFX_CPU GFX_CPU_UNKNOWN
// #define GFX_OS_HEAP_SIZE 0
@@ -55,32 +54,31 @@
// #define GFX_OS_EXTRA_INIT_FUNCTION myOSInitRoutine
// #define GFX_OS_EXTRA_DEINIT_FUNCTION myOSDeInitRoutine
-
///////////////////////////////////////////////////////////////////////////
// GDISP //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GDISP TRUE
+#define GFX_USE_GDISP TRUE
//#define GDISP_NEED_AUTOFLUSH FALSE
//#define GDISP_NEED_TIMERFLUSH FALSE
//#define GDISP_NEED_VALIDATION TRUE
//#define GDISP_NEED_CLIP TRUE
-#define GDISP_NEED_CIRCLE TRUE
-#define GDISP_NEED_ELLIPSE TRUE
-#define GDISP_NEED_ARC TRUE
-#define GDISP_NEED_ARCSECTORS TRUE
-#define GDISP_NEED_CONVEX_POLYGON TRUE
+#define GDISP_NEED_CIRCLE TRUE
+#define GDISP_NEED_ELLIPSE TRUE
+#define GDISP_NEED_ARC TRUE
+#define GDISP_NEED_ARCSECTORS TRUE
+#define GDISP_NEED_CONVEX_POLYGON TRUE
//#define GDISP_NEED_SCROLL FALSE
-#define GDISP_NEED_PIXELREAD TRUE
-#define GDISP_NEED_CONTROL TRUE
+#define GDISP_NEED_PIXELREAD TRUE
+#define GDISP_NEED_CONTROL TRUE
//#define GDISP_NEED_QUERY FALSE
//#define GDISP_NEED_MULTITHREAD FALSE
//#define GDISP_NEED_STREAMING FALSE
-#define GDISP_NEED_TEXT TRUE
+#define GDISP_NEED_TEXT TRUE
// #define GDISP_NEED_TEXT_WORDWRAP FALSE
// #define GDISP_NEED_ANTIALIAS FALSE
// #define GDISP_NEED_UTF8 FALSE
- #define GDISP_NEED_TEXT_KERNING TRUE
+#define GDISP_NEED_TEXT_KERNING TRUE
// #define GDISP_INCLUDE_FONT_UI1 FALSE
// #define GDISP_INCLUDE_FONT_UI2 FALSE // The smallest preferred font.
// #define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE
@@ -90,10 +88,10 @@
// #define GDISP_INCLUDE_FONT_DEJAVUSANS20 FALSE
// #define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE
// #define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE
- #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 TRUE
+#define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 TRUE
// #define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE
// #define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE
- #define GDISP_INCLUDE_FONT_FIXED_5X8 TRUE
+#define GDISP_INCLUDE_FONT_FIXED_5X8 TRUE
// #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE
// #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE
// #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA FALSE
@@ -118,50 +116,49 @@
// #define GDISP_NEED_IMAGE_PNG FALSE
// #define GDISP_NEED_IMAGE_ACCOUNTING FALSE
#ifdef EMULATOR
-#define GDISP_NEED_PIXMAP TRUE
+# define GDISP_NEED_PIXMAP TRUE
#endif
// #define GDISP_NEED_PIXMAP_IMAGE FALSE
//#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE // If not defined the native hardware orientation is used.
//#define GDISP_LINEBUF_SIZE 128
//#define GDISP_STARTUP_COLOR Black
-#define GDISP_NEED_STARTUP_LOGO FALSE
+#define GDISP_NEED_STARTUP_LOGO FALSE
//#define GDISP_TOTAL_DISPLAYS 2
- #ifdef GDISP_DRIVER_LIST
- // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
- #define GDISP_HARDWARE_STREAM_WRITE FALSE
- #define GDISP_HARDWARE_STREAM_READ FALSE
- #define GDISP_HARDWARE_STREAM_POS FALSE
- #define GDISP_HARDWARE_DRAWPIXEL TRUE
- #define GDISP_HARDWARE_CLEARS FALSE
- #define GDISP_HARDWARE_FILLS FALSE
- //#define GDISP_HARDWARE_BITFILLS FALSE
- #define GDISP_HARDWARE_SCROLL FALSE
- #define GDISP_HARDWARE_PIXELREAD TRUE
- #define GDISP_HARDWARE_CONTROL TRUE
- #define GDISP_HARDWARE_QUERY FALSE
- #define GDISP_HARDWARE_CLIP FALSE
-
- #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
- #endif
+#ifdef GDISP_DRIVER_LIST
+// For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
+# define GDISP_HARDWARE_STREAM_WRITE FALSE
+# define GDISP_HARDWARE_STREAM_READ FALSE
+# define GDISP_HARDWARE_STREAM_POS FALSE
+# define GDISP_HARDWARE_DRAWPIXEL TRUE
+# define GDISP_HARDWARE_CLEARS FALSE
+# define GDISP_HARDWARE_FILLS FALSE
+//#define GDISP_HARDWARE_BITFILLS FALSE
+# define GDISP_HARDWARE_SCROLL FALSE
+# define GDISP_HARDWARE_PIXELREAD TRUE
+# define GDISP_HARDWARE_CONTROL TRUE
+# define GDISP_HARDWARE_QUERY FALSE
+# define GDISP_HARDWARE_CLIP FALSE
+
+# define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
+#endif
// The custom format is not defined for some reason, so define it as error
// so we don't get compiler warnings
#define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR
-#define GDISP_USE_GFXNET FALSE
+#define GDISP_USE_GFXNET FALSE
// #define GDISP_GFXNET_PORT 13001
// #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
// #define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
// #define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
-
///////////////////////////////////////////////////////////////////////////
// GWIN //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GWIN FALSE
+#define GFX_USE_GWIN FALSE
//#define GWIN_NEED_WINDOWMANAGER FALSE
// #define GWIN_REDRAW_IMMEDIATE FALSE
@@ -210,30 +207,27 @@
// #define GWIN_NEED_TABSET FALSE
// #define GWIN_TABSET_TABHEIGHT 18
-
///////////////////////////////////////////////////////////////////////////
// GEVENT //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GEVENT TRUE
+#define GFX_USE_GEVENT TRUE
//#define GEVENT_ASSERT_NO_RESOURCE FALSE
//#define GEVENT_MAXIMUM_SIZE 32
//#define GEVENT_MAX_SOURCE_LISTENERS 32
-
///////////////////////////////////////////////////////////////////////////
// GTIMER //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GTIMER FALSE
+#define GFX_USE_GTIMER FALSE
//#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
//#define GTIMER_THREAD_WORKAREA_SIZE 2048
-
///////////////////////////////////////////////////////////////////////////
// GQUEUE //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GQUEUE FALSE
+#define GFX_USE_GQUEUE FALSE
//#define GQUEUE_NEED_ASYNC FALSE
//#define GQUEUE_NEED_GSYNC FALSE
@@ -243,7 +237,7 @@
///////////////////////////////////////////////////////////////////////////
// GINPUT //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GINPUT FALSE
+#define GFX_USE_GINPUT FALSE
//#define GINPUT_NEED_MOUSE FALSE
// #define GINPUT_TOUCH_STARTRAW FALSE
@@ -264,11 +258,10 @@
//#define GINPUT_NEED_TOGGLE FALSE
//#define GINPUT_NEED_DIAL FALSE
-
///////////////////////////////////////////////////////////////////////////
// GFILE //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GFILE FALSE
+#define GFX_USE_GFILE FALSE
//#define GFILE_NEED_PRINTG FALSE
//#define GFILE_NEED_SCANG FALSE
@@ -292,26 +285,24 @@
///////////////////////////////////////////////////////////////////////////
// GADC //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GADC FALSE
+#define GFX_USE_GADC FALSE
//#define GADC_MAX_LOWSPEED_DEVICES 4
-
///////////////////////////////////////////////////////////////////////////
// GAUDIO //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GAUDIO FALSE
+#define GFX_USE_GAUDIO FALSE
// There seems to be a bug in the ugfx code, the wrong define is used
// So define it in order to avoid warnings
-#define GFX_USE_GAUDIN GFX_USE_GAUDIO
+#define GFX_USE_GAUDIN GFX_USE_GAUDIO
// #define GAUDIO_NEED_PLAY FALSE
// #define GAUDIO_NEED_RECORD FALSE
-
///////////////////////////////////////////////////////////////////////////
// GMISC //
///////////////////////////////////////////////////////////////////////////
-#define GFX_USE_GMISC TRUE
+#define GFX_USE_GMISC TRUE
//#define GMISC_NEED_ARRAYOPS FALSE
//#define GMISC_NEED_FASTTRIG FALSE
@@ -319,7 +310,7 @@
//#define GMISC_NEED_INVSQRT FALSE
// #define GMISC_INVSQRT_MIXED_ENDIAN FALSE
// #define GMISC_INVSQRT_REAL_SLOW FALSE
-#define GMISC_NEED_MATRIXFLOAT2D TRUE
-#define GMISC_NEED_MATRIXFIXED2D FALSE
+#define GMISC_NEED_MATRIXFLOAT2D TRUE
+#define GMISC_NEED_MATRIXFIXED2D FALSE
#endif /* COMMON_GFXCONF_H */
diff --git a/quantum/visualizer/default_animations.c b/quantum/visualizer/default_animations.c
index 2d03273720..2f43c67cc8 100644
--- a/quantum/visualizer/default_animations.c
+++ b/quantum/visualizer/default_animations.c
@@ -16,161 +16,162 @@
#if defined(VISUALIZER_ENABLE)
-#include "default_animations.h"
-#include "visualizer.h"
-#ifdef LCD_ENABLE
-#include "lcd_keyframes.h"
-#endif
-#ifdef LCD_BACKLIGHT_ENABLE
-#include "lcd_backlight_keyframes.h"
-#endif
-
-#ifdef BACKLIGHT_ENABLE
-#include "led_backlight_keyframes.h"
-#endif
+# include "default_animations.h"
+# include "visualizer.h"
+# ifdef LCD_ENABLE
+# include "lcd_keyframes.h"
+# endif
+# ifdef LCD_BACKLIGHT_ENABLE
+# include "lcd_backlight_keyframes.h"
+# endif
-#include "visualizer_keyframes.h"
+# ifdef BACKLIGHT_ENABLE
+# include "led_backlight_keyframes.h"
+# endif
+# include "visualizer_keyframes.h"
-#if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
+# if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
-#ifdef LCD_ENABLE
+# ifdef LCD_ENABLE
lcd_keyframe_enable(animation, state);
-#endif
-#ifdef LCD_BACKLIGHT_ENABLE
+# endif
+# ifdef LCD_BACKLIGHT_ENABLE
lcd_backlight_keyframe_enable(animation, state);
-#endif
-#ifdef BACKLIGHT_ENABLE
+# endif
+# ifdef BACKLIGHT_ENABLE
led_backlight_keyframe_enable(animation, state);
-#endif
+# endif
return false;
}
static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
-#ifdef LCD_ENABLE
+# ifdef LCD_ENABLE
lcd_keyframe_disable(animation, state);
-#endif
-#ifdef LCD_BACKLIGHT_ENABLE
+# endif
+# ifdef LCD_BACKLIGHT_ENABLE
lcd_backlight_keyframe_disable(animation, state);
-#endif
-#ifdef BACKLIGHT_ENABLE
+# endif
+# ifdef BACKLIGHT_ENABLE
led_backlight_keyframe_disable(animation, state);
-#endif
+# endif
return false;
}
static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) {
bool ret = false;
-#ifdef LCD_BACKLIGHT_ENABLE
+# ifdef LCD_BACKLIGHT_ENABLE
ret |= lcd_backlight_keyframe_animate_color(animation, state);
-#endif
-#ifdef BACKLIGHT_ENABLE
+# endif
+# ifdef BACKLIGHT_ENABLE
ret |= led_backlight_keyframe_fade_in_all(animation, state);
-#endif
+# endif
return ret;
}
static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) {
bool ret = false;
-#ifdef LCD_BACKLIGHT_ENABLE
+# ifdef LCD_BACKLIGHT_ENABLE
ret |= lcd_backlight_keyframe_animate_color(animation, state);
-#endif
-#ifdef BACKLIGHT_ENABLE
+# endif
+# ifdef BACKLIGHT_ENABLE
ret |= led_backlight_keyframe_fade_out_all(animation, state);
-#endif
+# endif
return ret;
}
-
// Don't worry, if the startup animation is long, you can use the keyboard like normal
// during that time
keyframe_animation_t default_startup_animation = {
-#if LCD_ENABLE
+# if LCD_ENABLE
.num_frames = 3,
-#else
+# else
.num_frames = 2,
-#endif
- .loop = false,
- .frame_lengths = {
- 0,
-#if LCD_ENABLE
- 0,
-#endif
- gfxMillisecondsToTicks(5000)},
- .frame_functions = {
+# endif
+ .loop = false,
+ .frame_lengths = {0,
+# if LCD_ENABLE
+ 0,
+# endif
+ gfxMillisecondsToTicks(5000)},
+ .frame_functions =
+ {
keyframe_enable,
-#if LCD_ENABLE
+# if LCD_ENABLE
lcd_keyframe_draw_logo,
-#endif
+# endif
keyframe_fade_in,
- },
+ },
};
keyframe_animation_t default_suspend_animation = {
-#if LCD_ENABLE
+# if LCD_ENABLE
.num_frames = 3,
-#else
+# else
.num_frames = 2,
-#endif
+# endif
.loop = false,
- .frame_lengths = {
-#if LCD_ENABLE
- 0,
-#endif
- gfxMillisecondsToTicks(1000),
- 0},
- .frame_functions = {
-#if LCD_ENABLE
+ .frame_lengths =
+ {
+# if LCD_ENABLE
+ 0,
+# endif
+ gfxMillisecondsToTicks(1000), 0},
+ .frame_functions =
+ {
+# if LCD_ENABLE
lcd_keyframe_display_layer_text,
-#endif
+# endif
keyframe_fade_out,
keyframe_disable,
- },
+ },
};
-#endif
+# endif
-#if defined(BACKLIGHT_ENABLE)
-#define CROSSFADE_TIME 1000
-#define GRADIENT_TIME 3000
+# if defined(BACKLIGHT_ENABLE)
+# define CROSSFADE_TIME 1000
+# define GRADIENT_TIME 3000
keyframe_animation_t led_test_animation = {
.num_frames = 14,
- .loop = true,
- .frame_lengths = {
- gfxMillisecondsToTicks(1000), // fade in
- gfxMillisecondsToTicks(1000), // no op (leds on)
- gfxMillisecondsToTicks(1000), // fade out
- gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
- gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
- gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
- gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
- 0, // mirror leds
- gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
- gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
- gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
- gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
- 0, // normal leds
- gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
-
- },
- .frame_functions = {
- led_backlight_keyframe_fade_in_all,
- keyframe_no_operation,
- led_backlight_keyframe_fade_out_all,
- led_backlight_keyframe_crossfade,
- led_backlight_keyframe_left_to_right_gradient,
- led_backlight_keyframe_crossfade,
- led_backlight_keyframe_top_to_bottom_gradient,
- led_backlight_keyframe_mirror_orientation,
- led_backlight_keyframe_crossfade,
- led_backlight_keyframe_left_to_right_gradient,
- led_backlight_keyframe_crossfade,
- led_backlight_keyframe_top_to_bottom_gradient,
- led_backlight_keyframe_normal_orientation,
- led_backlight_keyframe_crossfade,
- },
+ .loop = true,
+ .frame_lengths =
+ {
+ gfxMillisecondsToTicks(1000), // fade in
+ gfxMillisecondsToTicks(1000), // no op (leds on)
+ gfxMillisecondsToTicks(1000), // fade out
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
+ 0, // mirror leds
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
+ 0, // normal leds
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+
+ },
+ .frame_functions =
+ {
+ led_backlight_keyframe_fade_in_all,
+ keyframe_no_operation,
+ led_backlight_keyframe_fade_out_all,
+ led_backlight_keyframe_crossfade,
+ led_backlight_keyframe_left_to_right_gradient,
+ led_backlight_keyframe_crossfade,
+ led_backlight_keyframe_top_to_bottom_gradient,
+ led_backlight_keyframe_mirror_orientation,
+ led_backlight_keyframe_crossfade,
+ led_backlight_keyframe_left_to_right_gradient,
+ led_backlight_keyframe_crossfade,
+ led_backlight_keyframe_top_to_bottom_gradient,
+ led_backlight_keyframe_normal_orientation,
+ led_backlight_keyframe_crossfade,
+ },
};
-#endif
+# endif
#endif
diff --git a/quantum/visualizer/lcd_backlight.c b/quantum/visualizer/lcd_backlight.c
index 6cd996f75e..23978974e3 100644
--- a/quantum/visualizer/lcd_backlight.c
+++ b/quantum/visualizer/lcd_backlight.c
@@ -25,9 +25,9 @@ SOFTWARE.
#include "lcd_backlight.h"
#include <math.h>
-static uint8_t current_hue = 0;
+static uint8_t current_hue = 0;
static uint8_t current_saturation = 0;
-static uint8_t current_intensity = 0;
+static uint8_t current_intensity = 0;
static uint8_t current_brightness = 0;
void lcd_backlight_init(void) {
@@ -40,26 +40,26 @@ void lcd_backlight_init(void) {
// http://blog.saikoled.com/post/43693602826/why-every-led-light-should-be-using-hsi
static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_out, uint16_t* b_out) {
unsigned int r, g, b;
- h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees
- h = 3.14159f * h / 180.0f; // Convert to radians.
- s = s > 0.0f ? (s < 1.0f ? s : 1.0f) : 0.0f; // clamp s and i to interval [0,1]
+ h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees
+ h = 3.14159f * h / 180.0f; // Convert to radians.
+ s = s > 0.0f ? (s < 1.0f ? s : 1.0f) : 0.0f; // clamp s and i to interval [0,1]
i = i > 0.0f ? (i < 1.0f ? i : 1.0f) : 0.0f;
// Math! Thanks in part to Kyle Miller.
- if(h < 2.09439f) {
- r = 65535.0f * i/3.0f *(1.0f + s * cos(h) / cosf(1.047196667f - h));
- g = 65535.0f * i/3.0f *(1.0f + s *(1.0f - cosf(h) / cos(1.047196667f - h)));
- b = 65535.0f * i/3.0f *(1.0f - s);
- } else if(h < 4.188787) {
+ if (h < 2.09439f) {
+ r = 65535.0f * i / 3.0f * (1.0f + s * cos(h) / cosf(1.047196667f - h));
+ g = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cos(1.047196667f - h)));
+ b = 65535.0f * i / 3.0f * (1.0f - s);
+ } else if (h < 4.188787) {
h = h - 2.09439;
- g = 65535.0f * i/3.0f *(1.0f + s * cosf(h) / cosf(1.047196667f - h));
- b = 65535.0f * i/3.0f *(1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h)));
- r = 65535.0f * i/3.0f *(1.0f - s);
+ g = 65535.0f * i / 3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h));
+ b = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h)));
+ r = 65535.0f * i / 3.0f * (1.0f - s);
} else {
h = h - 4.188787;
- b = 65535.0f*i/3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h));
- r = 65535.0f*i/3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h)));
- g = 65535.0f*i/3.0f * (1.0f - s);
+ b = 65535.0f * i / 3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h));
+ r = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h)));
+ g = 65535.0f * i / 3.0f * (1.0f - s);
}
*r_out = r > 65535 ? 65535 : r;
*g_out = g > 65535 ? 65535 : g;
@@ -68,15 +68,15 @@ static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_o
void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity) {
uint16_t r, g, b;
- float hue_f = 360.0f * (float)hue / 255.0f;
- float saturation_f = (float)saturation / 255.0f;
- float intensity_f = (float)intensity / 255.0f;
+ float hue_f = 360.0f * (float)hue / 255.0f;
+ float saturation_f = (float)saturation / 255.0f;
+ float intensity_f = (float)intensity / 255.0f;
intensity_f *= (float)current_brightness / 255.0f;
hsi_to_rgb(hue_f, saturation_f, intensity_f, &r, &g, &b);
- current_hue = hue;
- current_saturation = saturation;
- current_intensity = intensity;
- lcd_backlight_hal_color(r, g, b);
+ current_hue = hue;
+ current_saturation = saturation;
+ current_intensity = intensity;
+ lcd_backlight_hal_color(r, g, b);
}
void lcd_backlight_brightness(uint8_t b) {
@@ -84,6 +84,4 @@ void lcd_backlight_brightness(uint8_t b) {
lcd_backlight_color(current_hue, current_saturation, current_intensity);
}
-uint8_t lcd_get_backlight_brightness(void) {
- return current_brightness;
-}
+uint8_t lcd_get_backlight_brightness(void) { return current_brightness; }
diff --git a/quantum/visualizer/lcd_backlight.h b/quantum/visualizer/lcd_backlight.h
index 95d7a07b46..7b0b6a9fd5 100644
--- a/quantum/visualizer/lcd_backlight.h
+++ b/quantum/visualizer/lcd_backlight.h
@@ -32,13 +32,11 @@ SOFTWARE.
#define LCD_SAT(color) ((color >> 8) & 0xFF)
#define LCD_INT(color) (color & 0xFF)
-static inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity) {
- return (color & 0xFFFFFF00) | new_intensity;
-}
+static inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity) { return (color & 0xFFFFFF00) | new_intensity; }
-void lcd_backlight_init(void);
-void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity);
-void lcd_backlight_brightness(uint8_t b);
+void lcd_backlight_init(void);
+void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity);
+void lcd_backlight_brightness(uint8_t b);
uint8_t lcd_get_backlight_brightness(void);
void lcd_backlight_hal_init(void);
diff --git a/quantum/visualizer/lcd_backlight_keyframes.c b/quantum/visualizer/lcd_backlight_keyframes.c
index 8c402baf6c..c13cce311d 100644
--- a/quantum/visualizer/lcd_backlight_keyframes.c
+++ b/quantum/visualizer/lcd_backlight_keyframes.c
@@ -17,46 +17,40 @@
#include "lcd_backlight_keyframes.h"
bool lcd_backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state) {
- int frame_length = animation->frame_lengths[animation->current_frame];
- int current_pos = frame_length - animation->time_left_in_frame;
- uint8_t t_h = LCD_HUE(state->target_lcd_color);
- uint8_t t_s = LCD_SAT(state->target_lcd_color);
- uint8_t t_i = LCD_INT(state->target_lcd_color);
- uint8_t p_h = LCD_HUE(state->prev_lcd_color);
- uint8_t p_s = LCD_SAT(state->prev_lcd_color);
- uint8_t p_i = LCD_INT(state->prev_lcd_color);
+ int frame_length = animation->frame_lengths[animation->current_frame];
+ int current_pos = frame_length - animation->time_left_in_frame;
+ uint8_t t_h = LCD_HUE(state->target_lcd_color);
+ uint8_t t_s = LCD_SAT(state->target_lcd_color);
+ uint8_t t_i = LCD_INT(state->target_lcd_color);
+ uint8_t p_h = LCD_HUE(state->prev_lcd_color);
+ uint8_t p_s = LCD_SAT(state->prev_lcd_color);
+ uint8_t p_i = LCD_INT(state->prev_lcd_color);
- uint8_t d_h1 = t_h - p_h; //Modulo arithmetic since we want to wrap around
- int d_h2 = t_h - p_h;
+ uint8_t d_h1 = t_h - p_h; // Modulo arithmetic since we want to wrap around
+ int d_h2 = t_h - p_h;
// Chose the shortest way around
int d_h = abs(d_h2) < d_h1 ? d_h2 : d_h1;
int d_s = t_s - p_s;
int d_i = t_i - p_i;
- int hue = (d_h * current_pos) / frame_length;
- int sat = (d_s * current_pos) / frame_length;
+ int hue = (d_h * current_pos) / frame_length;
+ int sat = (d_s * current_pos) / frame_length;
int intensity = (d_i * current_pos) / frame_length;
- //dprintf("%X -> %X = %X\n", p_h, t_h, hue);
+ // dprintf("%X -> %X = %X\n", p_h, t_h, hue);
hue += p_h;
sat += p_s;
intensity += p_i;
state->current_lcd_color = LCD_COLOR(hue, sat, intensity);
- lcd_backlight_color(
- LCD_HUE(state->current_lcd_color),
- LCD_SAT(state->current_lcd_color),
- LCD_INT(state->current_lcd_color));
+ lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color));
return true;
}
bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)animation;
- state->prev_lcd_color = state->target_lcd_color;
+ state->prev_lcd_color = state->target_lcd_color;
state->current_lcd_color = state->target_lcd_color;
- lcd_backlight_color(
- LCD_HUE(state->current_lcd_color),
- LCD_SAT(state->current_lcd_color),
- LCD_INT(state->current_lcd_color));
+ lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color));
return false;
}
@@ -70,8 +64,6 @@ bool lcd_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_
bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)animation;
(void)state;
- lcd_backlight_color(LCD_HUE(state->current_lcd_color),
- LCD_SAT(state->current_lcd_color),
- LCD_INT(state->current_lcd_color));
+ lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color));
return false;
}
diff --git a/quantum/visualizer/lcd_keyframes.c b/quantum/visualizer/lcd_keyframes.c
index 75eb457001..c7d9841df3 100644
--- a/quantum/visualizer/lcd_keyframes.c
+++ b/quantum/visualizer/lcd_keyframes.c
@@ -28,8 +28,7 @@ bool lcd_keyframe_display_layer_text(keyframe_animation_t* animation, visualizer
}
static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, char* buffer) {
- for (int i=0; i<16;i++)
- {
+ for (int i = 0; i < 16; i++) {
uint32_t mask = (1u << i);
if (default_layer & mask) {
if (layer & mask) {
@@ -44,7 +43,7 @@ static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, c
}
++buffer;
- if (i==3 || i==7 || i==11) {
+ if (i == 3 || i == 7 || i == 11) {
*buffer = ' ';
++buffer;
}
@@ -55,7 +54,7 @@ static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, c
bool lcd_keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)animation;
const char* layer_help = "1=On D=Default B=Both";
- char layer_buffer[16 + 4]; // 3 spaces and one null terminator
+ char layer_buffer[16 + 4]; // 3 spaces and one null terminator
gdispClear(White);
gdispDrawString(0, 0, layer_help, state->font_fixed5x8, Black);
format_layer_bitmap_string(state->status.default_layer, state->status.layer, layer_buffer);
@@ -69,8 +68,7 @@ static void format_mods_bitmap_string(uint8_t mods, char* buffer) {
*buffer = ' ';
++buffer;
- for (int i = 0; i<8; i++)
- {
+ for (int i = 0; i < 8; i++) {
uint32_t mask = (1u << i);
if (mods & mask) {
*buffer = '1';
@@ -79,7 +77,7 @@ static void format_mods_bitmap_string(uint8_t mods, char* buffer) {
}
++buffer;
- if (i==3) {
+ if (i == 3) {
*buffer = ' ';
++buffer;
}
@@ -90,9 +88,9 @@ static void format_mods_bitmap_string(uint8_t mods, char* buffer) {
bool lcd_keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)animation;
- const char* title = "Modifier states";
+ const char* title = "Modifier states";
const char* mods_header = " CSAG CSAG ";
- char status_buffer[12];
+ char status_buffer[12];
gdispClear(White);
gdispDrawString(0, 0, title, state->font_fixed5x8, Black);
@@ -109,30 +107,29 @@ static void get_led_state_string(char* output, visualizer_state_t* state) {
uint8_t pos = 0;
if (state->status.leds & (1u << USB_LED_NUM_LOCK)) {
- memcpy(output + pos, "NUM ", 4);
- pos += 4;
+ memcpy(output + pos, "NUM ", 4);
+ pos += 4;
}
if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
- memcpy(output + pos, "CAPS ", 5);
- pos += 5;
+ memcpy(output + pos, "CAPS ", 5);
+ pos += 5;
}
if (state->status.leds & (1u << USB_LED_SCROLL_LOCK)) {
- memcpy(output + pos, "SCRL ", 5);
- pos += 5;
+ memcpy(output + pos, "SCRL ", 5);
+ pos += 5;
}
if (state->status.leds & (1u << USB_LED_COMPOSE)) {
- memcpy(output + pos, "COMP ", 5);
- pos += 5;
+ memcpy(output + pos, "COMP ", 5);
+ pos += 5;
}
if (state->status.leds & (1u << USB_LED_KANA)) {
- memcpy(output + pos, "KANA", 4);
- pos += 4;
+ memcpy(output + pos, "KANA", 4);
+ pos += 4;
}
output[pos] = 0;
}
-bool lcd_keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state)
-{
+bool lcd_keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)animation;
char output[LED_STATE_STRING_SIZE];
get_led_state_string(output, state);
@@ -165,14 +162,13 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t*
// You can use static variables for things that can't be found in the animation
// or state structs, here we use the image
- //gdispGBlitArea is a tricky function to use since it supports blitting part of the image
+ // gdispGBlitArea is a tricky function to use since it supports blitting part of the image
// if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions
gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo);
return false;
}
-
bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)animation;
(void)state;
diff --git a/quantum/visualizer/lcd_keyframes.h b/quantum/visualizer/lcd_keyframes.h
index 2e912b4c73..6346c8643b 100644
--- a/quantum/visualizer/lcd_keyframes.h
+++ b/quantum/visualizer/lcd_keyframes.h
@@ -35,5 +35,4 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t*
bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state);
bool lcd_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state);
-
#endif /* QUANTUM_VISUALIZER_LCD_KEYFRAMES_H_ */
diff --git a/quantum/visualizer/led_backlight_keyframes.c b/quantum/visualizer/led_backlight_keyframes.c
index eb3f5561d8..d81117d2be 100644
--- a/quantum/visualizer/led_backlight_keyframes.c
+++ b/quantum/visualizer/led_backlight_keyframes.c
@@ -27,15 +27,15 @@ SOFTWARE.
static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) {
int frame_length = animation->frame_lengths[animation->current_frame];
- int current_pos = frame_length - animation->time_left_in_frame;
- int delta = to - from;
- int luma = (delta * current_pos) / frame_length;
+ int current_pos = frame_length - animation->time_left_in_frame;
+ int delta = to - from;
+ int luma = (delta * current_pos) / frame_length;
luma += from;
return luma;
}
static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) {
- uint8_t luma = fade_led_color(animation, from, to);
+ uint8_t luma = fade_led_color(animation, from, to);
color_t color = LUMA2COLOR(luma);
gdispGClear(LED_DISPLAY, color);
}
@@ -48,10 +48,10 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
static uint8_t compute_gradient_color(float t, float index, float num) {
- const float two_pi = M_PI * 2.0f;
- float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi;
- float x = t * two_pi + normalized_index;
- float v = 0.5 * (cosf(x) + 1.0f);
+ const float two_pi = M_PI * 2.0f;
+ float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi;
+ float x = t * two_pi + normalized_index;
+ float v = 0.5 * (cosf(x) + 1.0f);
return (uint8_t)(255.0f * v);
}
@@ -70,9 +70,9 @@ bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visual
bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state;
float frame_length = animation->frame_lengths[animation->current_frame];
- float current_pos = frame_length - animation->time_left_in_frame;
- float t = current_pos / frame_length;
- for (int i=0; i< NUM_COLS; i++) {
+ float current_pos = frame_length - animation->time_left_in_frame;
+ float t = current_pos / frame_length;
+ for (int i = 0; i < NUM_COLS; i++) {
uint8_t color = compute_gradient_color(t, i, NUM_COLS);
gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color));
}
@@ -82,9 +82,9 @@ bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animati
bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
(void)state;
float frame_length = animation->frame_lengths[animation->current_frame];
- float current_pos = frame_length - animation->time_left_in_frame;
- float t = current_pos / frame_length;
- for (int i=0; i< NUM_ROWS; i++) {
+ float current_pos = frame_length - animation->time_left_in_frame;
+ float t = current_pos / frame_length;
+ for (int i = 0; i < NUM_ROWS; i++) {
uint8_t color = compute_gradient_color(t, i, NUM_ROWS);
gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color));
}
@@ -92,9 +92,9 @@ bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animati
}
static void copy_current_led_state(uint8_t* dest) {
- for (int i=0;i<NUM_ROWS;i++) {
- for (int j=0;j<NUM_COLS;j++) {
- dest[i*NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i);
+ for (int i = 0; i < NUM_ROWS; i++) {
+ for (int j = 0; j < NUM_COLS; j++) {
+ dest[i * NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i);
}
}
}
@@ -105,9 +105,9 @@ bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualize
run_next_keyframe(animation, state);
copy_current_led_state(&crossfade_end_frame[0][0]);
}
- for (int i=0;i<NUM_ROWS;i++) {
- for (int j=0;j<NUM_COLS;j++) {
- color_t color = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j]));
+ for (int i = 0; i < NUM_ROWS; i++) {
+ for (int j = 0; j < NUM_COLS; j++) {
+ color_t color = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j]));
gdispGDrawPixel(LED_DISPLAY, j, i, color);
}
}
diff --git a/quantum/visualizer/led_backlight_keyframes.h b/quantum/visualizer/led_backlight_keyframes.h
index 487151013a..648f92b915 100644
--- a/quantum/visualizer/led_backlight_keyframes.h
+++ b/quantum/visualizer/led_backlight_keyframes.h
@@ -40,5 +40,4 @@ bool led_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_s
extern keyframe_animation_t led_test_animation;
-
#endif /* LED_KEYFRAMES_H */
diff --git a/quantum/visualizer/resources/lcd_logo.c b/quantum/visualizer/resources/lcd_logo.c
index 314776c0b2..165e6d1f53 100644
--- a/quantum/visualizer/resources/lcd_logo.c
+++ b/quantum/visualizer/resources/lcd_logo.c
@@ -16,7 +16,6 @@
#include "resources.h"
-
// To generate an image array like this
// Ensure the image is 128 x 32 or smaller
// Convert the bitmap to a C array using a program like http://www.riuson.com/lcd-image-converter/
@@ -24,39 +23,7 @@
// Update array in the source code with the C array produced by the conversion program
// The image below is generated from lcd_logo.png
-__attribute__((weak))
-const uint8_t resource_lcd_logo[512] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xf8, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x38, 0x38, 0x06, 0x29, 0x41, 0x24, 0x52, 0x24, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x42, 0xaa, 0xaa, 0xaa, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x82, 0x28, 0xaa, 0xae, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x43, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x38, 0x38, 0x0a, 0x55, 0x42, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x38, 0x38, 0x38, 0x05, 0x45, 0x42, 0x28, 0x89, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x18, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1c, 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x03, 0xff, 0x80, 0x04, 0x45, 0x14, 0xa4, 0x92, 0x83, 0x52, 0x22, 0x22, 0x36, 0x00, 0x00,
- 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0xba, 0x84, 0x55, 0x55, 0x57, 0x45, 0x00, 0x00,
- 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0xb2, 0x55, 0x55, 0x42, 0x65, 0x00, 0x00,
- 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x56, 0x65, 0x42, 0x45, 0x00, 0x00,
- 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x54, 0x45, 0x42, 0x45, 0x00, 0x00,
- 0x00, 0x00, 0x38, 0x00, 0x04, 0x48, 0xa2, 0x4a, 0x89, 0x06, 0x24, 0x42, 0x41, 0x36, 0x00, 0x00,
- 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
+__attribute__((weak)) const uint8_t resource_lcd_logo[512] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x38, 0x38, 0x06, 0x29, 0x41, 0x24, 0x52, 0x24, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x42, 0xaa, 0xaa, 0xaa, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x82, 0x28, 0xaa, 0xae, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x43, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x0a, 0x55, 0x42, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x05, 0x45, 0x42, 0x28, 0x89, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x80, 0x04, 0x45, 0x14, 0xa4, 0x92, 0x83, 0x52, 0x22, 0x22, 0x36, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0xba, 0x84, 0x55, 0x55, 0x57, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0xb2, 0x55, 0x55, 0x42, 0x65, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x56, 0x65, 0x42, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x54, 0x45, 0x42, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x04, 0x48, 0xa2, 0x4a, 0x89, 0x06, 0x24, 0x42, 0x41, 0x36, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/quantum/visualizer/resources/resources.h b/quantum/visualizer/resources/resources.h
index 1ea27a5364..74fd8d2f65 100644
--- a/quantum/visualizer/resources/resources.h
+++ b/quantum/visualizer/resources/resources.h
@@ -23,5 +23,4 @@
extern const uint8_t resource_lcd_logo[];
#endif
-
#endif /* QUANTUM_VISUALIZER_RESOURCES_RESOURCES_H_ */
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index 5b4d8d603e..3f182e74d8 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -26,26 +26,26 @@ SOFTWARE.
#include "visualizer.h"
#include <string.h>
#ifdef PROTOCOL_CHIBIOS
-#include "ch.h"
+# include "ch.h"
#endif
#include "gfx.h"
#ifdef LCD_BACKLIGHT_ENABLE
-#include "lcd_backlight.h"
+# include "lcd_backlight.h"
#endif
//#define DEBUG_VISUALIZER
#ifdef DEBUG_VISUALIZER
-#include "debug.h"
+# include "debug.h"
#else
-#include "nodebug.h"
+# include "nodebug.h"
#endif
#ifdef SERIAL_LINK_ENABLE
-#include "serial_link/protocol/transport.h"
-#include "serial_link/system/serial_link.h"
+# include "serial_link/protocol/transport.h"
+# include "serial_link/system/serial_link.h"
#endif
#include "action_util.h"
@@ -53,36 +53,31 @@ SOFTWARE.
// Define this in config.h
#ifndef VISUALIZER_THREAD_PRIORITY
// The visualizer needs gfx thread priorities
-#define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2)
+# define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2)
#endif
-static visualizer_keyboard_status_t current_status = {
- .layer = 0xFFFFFFFF,
- .default_layer = 0xFFFFFFFF,
- .leds = 0xFFFFFFFF,
+static visualizer_keyboard_status_t current_status = {.layer = 0xFFFFFFFF,
+ .default_layer = 0xFFFFFFFF,
+ .leds = 0xFFFFFFFF,
#ifdef BACKLIGHT_ENABLE
- .backlight_level = 0,
+ .backlight_level = 0,
#endif
- .mods = 0xFF,
- .suspended = false,
+ .mods = 0xFF,
+ .suspended = false,
#ifdef VISUALIZER_USER_DATA_SIZE
- .user_data = {0}
+ .user_data = {0}
#endif
};
static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) {
- return status1->layer == status2->layer &&
- status1->default_layer == status2->default_layer &&
- status1->mods == status2->mods &&
- status1->leds == status2->leds &&
- status1->suspended == status2->suspended
+ return status1->layer == status2->layer && status1->default_layer == status2->default_layer && status1->mods == status2->mods && status1->leds == status2->leds && status1->suspended == status2->suspended
#ifdef BACKLIGHT_ENABLE
- && status1->backlight_level == status2->backlight_level
+ && status1->backlight_level == status2->backlight_level
#endif
#ifdef VISUALIZER_USER_DATA_SIZE
- && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0
+ && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0
#endif
- ;
+ ;
}
static bool visualizer_enabled = false;
@@ -107,44 +102,38 @@ GDisplay* LCD_DISPLAY = 0;
GDisplay* LED_DISPLAY = 0;
#ifdef LCD_DISPLAY_NUMBER
-__attribute__((weak))
-GDisplay* get_lcd_display(void) {
- return gdispGetDisplay(LCD_DISPLAY_NUMBER);
-}
+__attribute__((weak)) GDisplay* get_lcd_display(void) { return gdispGetDisplay(LCD_DISPLAY_NUMBER); }
#endif
#ifdef LED_DISPLAY_NUMBER
-__attribute__((weak))
-GDisplay* get_led_display(void) {
- return gdispGetDisplay(LED_DISPLAY_NUMBER);
-}
+__attribute__((weak)) GDisplay* get_led_display(void) { return gdispGetDisplay(LED_DISPLAY_NUMBER); }
#endif
void start_keyframe_animation(keyframe_animation_t* animation) {
- animation->current_frame = -1;
+ animation->current_frame = -1;
animation->time_left_in_frame = 0;
- animation->need_update = true;
- int free_index = -1;
- for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ animation->need_update = true;
+ int free_index = -1;
+ for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) {
if (animations[i] == animation) {
return;
}
if (free_index == -1 && animations[i] == NULL) {
- free_index=i;
+ free_index = i;
}
}
- if (free_index!=-1) {
+ if (free_index != -1) {
animations[free_index] = animation;
}
}
void stop_keyframe_animation(keyframe_animation_t* animation) {
- animation->current_frame = animation->num_frames;
- animation->time_left_in_frame = 0;
- animation->need_update = true;
+ animation->current_frame = animation->num_frames;
+ animation->time_left_in_frame = 0;
+ animation->need_update = true;
animation->first_update_of_frame = false;
- animation->last_update_of_frame = false;
- for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ animation->last_update_of_frame = false;
+ for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) {
if (animations[i] == animation) {
animations[i] = NULL;
return;
@@ -153,21 +142,21 @@ void stop_keyframe_animation(keyframe_animation_t* animation) {
}
void stop_all_keyframe_animations(void) {
- for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) {
if (animations[i]) {
- animations[i]->current_frame = animations[i]->num_frames;
- animations[i]->time_left_in_frame = 0;
- animations[i]->need_update = true;
+ animations[i]->current_frame = animations[i]->num_frames;
+ animations[i]->time_left_in_frame = 0;
+ animations[i]->need_update = true;
animations[i]->first_update_of_frame = false;
- animations[i]->last_update_of_frame = false;
- animations[i] = NULL;
+ animations[i]->last_update_of_frame = false;
+ animations[i] = NULL;
}
}
}
static uint8_t get_num_running_animations(void) {
uint8_t count = 0;
- for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) {
count += animations[i] ? 1 : 0;
}
return count;
@@ -175,46 +164,44 @@ static uint8_t get_num_running_animations(void) {
static bool update_keyframe_animation(keyframe_animation_t* animation, visualizer_state_t* state, systemticks_t delta, systemticks_t* sleep_time) {
// TODO: Clean up this messy code
- dprintf("Animation frame%d, left %d, delta %d\n", animation->current_frame,
- animation->time_left_in_frame, delta);
+ dprintf("Animation frame%d, left %d, delta %d\n", animation->current_frame, animation->time_left_in_frame, delta);
if (animation->current_frame == animation->num_frames) {
animation->need_update = false;
return false;
}
if (animation->current_frame == -1) {
- animation->current_frame = 0;
- animation->time_left_in_frame = animation->frame_lengths[0];
- animation->need_update = true;
- animation->first_update_of_frame = true;
+ animation->current_frame = 0;
+ animation->time_left_in_frame = animation->frame_lengths[0];
+ animation->need_update = true;
+ animation->first_update_of_frame = true;
} else {
animation->time_left_in_frame -= delta;
while (animation->time_left_in_frame <= 0) {
int left = animation->time_left_in_frame;
if (animation->need_update) {
- animation->time_left_in_frame = 0;
+ animation->time_left_in_frame = 0;
animation->last_update_of_frame = true;
(*animation->frame_functions[animation->current_frame])(animation, state);
animation->last_update_of_frame = false;
}
animation->current_frame++;
- animation->need_update = true;
+ animation->need_update = true;
animation->first_update_of_frame = true;
if (animation->current_frame == animation->num_frames) {
if (animation->loop) {
animation->current_frame = 0;
- }
- else {
+ } else {
stop_keyframe_animation(animation);
return false;
}
}
- delta = -left;
+ delta = -left;
animation->time_left_in_frame = animation->frame_lengths[animation->current_frame];
animation->time_left_in_frame -= delta;
}
}
if (animation->need_update) {
- animation->need_update = (*animation->frame_functions[animation->current_frame])(animation, state);
+ animation->need_update = (*animation->frame_functions[animation->current_frame])(animation, state);
animation->first_update_of_frame = false;
}
@@ -231,13 +218,13 @@ void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* stat
if (next_frame == animation->num_frames) {
next_frame = 0;
}
- keyframe_animation_t temp_animation = *animation;
- temp_animation.current_frame = next_frame;
- temp_animation.time_left_in_frame = animation->frame_lengths[next_frame];
+ keyframe_animation_t temp_animation = *animation;
+ temp_animation.current_frame = next_frame;
+ temp_animation.time_left_in_frame = animation->frame_lengths[next_frame];
temp_animation.first_update_of_frame = true;
- temp_animation.last_update_of_frame = false;
- temp_animation.need_update = false;
- visualizer_state_t temp_state = *state;
+ temp_animation.last_update_of_frame = false;
+ temp_animation.need_update = false;
+ visualizer_state_t temp_state = *state;
(*temp_animation.frame_functions[next_frame])(&temp_animation, &temp_state);
}
@@ -252,70 +239,64 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
visualizer_keyboard_status_t initial_status = {
.default_layer = 0xFFFFFFFF,
- .layer = 0xFFFFFFFF,
- .mods = 0xFF,
- .leds = 0xFFFFFFFF,
- .suspended = false,
- #ifdef BACKLIGHT_ENABLE
+ .layer = 0xFFFFFFFF,
+ .mods = 0xFF,
+ .leds = 0xFFFFFFFF,
+ .suspended = false,
+#ifdef BACKLIGHT_ENABLE
.backlight_level = 0,
- #endif
- #ifdef VISUALIZER_USER_DATA_SIZE
+#endif
+#ifdef VISUALIZER_USER_DATA_SIZE
.user_data = {0},
- #endif
+#endif
};
- visualizer_state_t state = {
- .status = initial_status,
- .current_lcd_color = 0,
+ visualizer_state_t state = {.status = initial_status,
+ .current_lcd_color = 0,
#ifdef LCD_ENABLE
- .font_fixed5x8 = gdispOpenFont("fixed_5x8"),
- .font_dejavusansbold12 = gdispOpenFont("DejaVuSansBold12")
+ .font_fixed5x8 = gdispOpenFont("fixed_5x8"),
+ .font_dejavusansbold12 = gdispOpenFont("DejaVuSansBold12")
#endif
};
initialize_user_visualizer(&state);
state.prev_lcd_color = state.current_lcd_color;
#ifdef LCD_BACKLIGHT_ENABLE
- lcd_backlight_color(
- LCD_HUE(state.current_lcd_color),
- LCD_SAT(state.current_lcd_color),
- LCD_INT(state.current_lcd_color));
+ lcd_backlight_color(LCD_HUE(state.current_lcd_color), LCD_SAT(state.current_lcd_color), LCD_INT(state.current_lcd_color));
#endif
- systemticks_t sleep_time = TIME_INFINITE;
+ systemticks_t sleep_time = TIME_INFINITE;
systemticks_t current_time = gfxSystemTicks();
- bool force_update = true;
+ bool force_update = true;
- while(true) {
+ while (true) {
systemticks_t new_time = gfxSystemTicks();
- systemticks_t delta = new_time - current_time;
- current_time = new_time;
- bool enabled = visualizer_enabled;
+ systemticks_t delta = new_time - current_time;
+ current_time = new_time;
+ bool enabled = visualizer_enabled;
if (force_update || !same_status(&state.status, &current_status)) {
force_update = false;
- #if BACKLIGHT_ENABLE
- if(current_status.backlight_level != state.status.backlight_level) {
+#if BACKLIGHT_ENABLE
+ if (current_status.backlight_level != state.status.backlight_level) {
if (current_status.backlight_level != 0) {
gdispGSetPowerMode(LED_DISPLAY, powerOn);
uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS;
gdispGSetBacklight(LED_DISPLAY, percent);
- }
- else {
+ } else {
gdispGSetPowerMode(LED_DISPLAY, powerOff);
}
state.status.backlight_level = current_status.backlight_level;
}
- #endif
+#endif
if (visualizer_enabled) {
if (current_status.suspended) {
stop_all_keyframe_animations();
visualizer_enabled = false;
- state.status = current_status;
+ state.status = current_status;
user_visualizer_suspend(&state);
- }
- else {
+ } else {
visualizer_keyboard_status_t prev_status = state.status;
- state.status = current_status;
+ state.status = current_status;
update_user_visualizer_state(&state, &prev_status);
}
state.prev_lcd_color = state.current_lcd_color;
@@ -324,14 +305,14 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
if (!enabled && state.status.suspended && current_status.suspended == false) {
// Setting the status to the initial status will force an update
// when the visualizer is enabled again
- state.status = initial_status;
+ state.status = initial_status;
state.status.suspended = false;
stop_all_keyframe_animations();
user_visualizer_resume(&state);
state.prev_lcd_color = state.current_lcd_color;
}
sleep_time = TIME_INFINITE;
- for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) {
if (animations[i]) {
update_keyframe_animation(animations[i], &state, delta, &sleep_time);
}
@@ -350,17 +331,16 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
// Enable the visualizer when the startup or the suspend animation has finished
if (!visualizer_enabled && state.status.suspended == false && get_num_running_animations() == 0) {
visualizer_enabled = true;
- force_update = true;
- sleep_time = 0;
+ force_update = true;
+ sleep_time = 0;
}
systemticks_t after_update = gfxSystemTicks();
- unsigned update_delta = after_update - current_time;
+ unsigned update_delta = after_update - current_time;
if (sleep_time != TIME_INFINITE) {
if (sleep_time > update_delta) {
sleep_time -= update_delta;
- }
- else {
+ } else {
sleep_time = 0;
}
}
@@ -388,26 +368,25 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
void visualizer_init(void) {
gfxInit();
- #ifdef LCD_BACKLIGHT_ENABLE
+#ifdef LCD_BACKLIGHT_ENABLE
lcd_backlight_init();
- #endif
+#endif
- #ifdef SERIAL_LINK_ENABLE
- add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) );
- #endif
+#ifdef SERIAL_LINK_ENABLE
+ add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*));
+#endif
- #ifdef LCD_ENABLE
+#ifdef LCD_ENABLE
LCD_DISPLAY = get_lcd_display();
- #endif
+#endif
- #ifdef BACKLIGHT_ENABLE
+#ifdef BACKLIGHT_ENABLE
LED_DISPLAY = get_led_display();
- #endif
+#endif
// We are using a low priority thread, the idea is to have it run only
// when the main thread is sleeping during the matrix scanning
- gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack),
- VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL);
+ gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack), VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL);
}
void update_status(bool changed) {
@@ -418,36 +397,34 @@ void update_status(bool changed) {
}
}
#ifdef SERIAL_LINK_ENABLE
- static systime_t last_update = 0;
- systime_t current_update = chVTGetSystemTimeX();
- systime_t delta = current_update - last_update;
+ static systime_t last_update = 0;
+ systime_t current_update = chVTGetSystemTimeX();
+ systime_t delta = current_update - last_update;
if (changed || delta > MS2ST(10)) {
- last_update = current_update;
+ last_update = current_update;
visualizer_keyboard_status_t* r = begin_write_current_status();
- *r = current_status;
+ *r = current_status;
end_write_current_status();
}
#endif
}
uint8_t visualizer_get_mods() {
- uint8_t mods = get_mods();
+ uint8_t mods = get_mods();
#ifndef NO_ACTION_ONESHOT
- if (!has_oneshot_mods_timed_out()) {
- mods |= get_oneshot_mods();
- }
-#endif
- return mods;
+ if (!has_oneshot_mods_timed_out()) {
+ mods |= get_oneshot_mods();
+ }
+#endif
+ return mods;
}
#ifdef VISUALIZER_USER_DATA_SIZE
-void visualizer_set_user_data(void* u) {
- memcpy(user_data, u, VISUALIZER_USER_DATA_SIZE);
-}
+void visualizer_set_user_data(void* u) { memcpy(user_data, u, VISUALIZER_USER_DATA_SIZE); }
#endif
-void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds) {
+void visualizer_update(layer_state_t default_state, layer_state_t state, uint8_t mods, uint32_t leds) {
// Note that there's a small race condition here, the thread could read
// a state where one of these are set but not the other. But this should
// not really matter as it will be fixed during the next loop step.
@@ -455,34 +432,33 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uin
bool changed = false;
#ifdef SERIAL_LINK_ENABLE
- if (is_serial_link_connected ()) {
+ if (is_serial_link_connected()) {
visualizer_keyboard_status_t* new_status = read_current_status();
if (new_status) {
if (!same_status(&current_status, new_status)) {
- changed = true;
+ changed = true;
current_status = *new_status;
}
}
- }
- else {
+ } else {
#else
- {
+ {
#endif
visualizer_keyboard_status_t new_status = {
- .layer = state,
+ .layer = state,
.default_layer = default_state,
- .mods = mods,
- .leds = leds,
+ .mods = mods,
+ .leds = leds,
#ifdef BACKLIGHT_ENABLE
.backlight_level = current_status.backlight_level,
#endif
.suspended = current_status.suspended,
};
#ifdef VISUALIZER_USER_DATA_SIZE
- memcpy(new_status.user_data, user_data, VISUALIZER_USER_DATA_SIZE);
+ memcpy(new_status.user_data, user_data, VISUALIZER_USER_DATA_SIZE);
#endif
if (!same_status(&current_status, &new_status)) {
- changed = true;
+ changed = true;
current_status = new_status;
}
}
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h
index 90ecdcbaea..7ca6837ce6 100644
--- a/quantum/visualizer/visualizer.h
+++ b/quantum/visualizer/visualizer.h
@@ -30,13 +30,14 @@ SOFTWARE.
#include "config.h"
#include "gfx.h"
+#include "action_layer.h"
#ifdef LCD_BACKLIGHT_ENABLE
-#include "lcd_backlight.h"
+# include "lcd_backlight.h"
#endif
#ifdef BACKLIGHT_ENABLE
-#include "backlight.h"
+# include "backlight.h"
#endif
// use this function to merge both real_mods and oneshot_mods in a uint16_t
@@ -45,7 +46,7 @@ uint8_t visualizer_get_mods(void);
// This need to be called once at the start
void visualizer_init(void);
// This should be called at every matrix scan
-void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds);
+void visualizer_update(layer_state_t default_state, layer_state_t state, uint8_t mods, uint32_t leds);
// This should be called when the keyboard goes to suspend state
void visualizer_suspend(void);
@@ -68,11 +69,11 @@ void draw_emulator(void);
struct keyframe_animation_t;
typedef struct {
- uint32_t layer;
- uint32_t default_layer;
- uint32_t leds; // See led.h for available statuses
- uint8_t mods;
- bool suspended;
+ layer_state_t layer;
+ layer_state_t default_layer;
+ uint32_t leds; // See led.h for available statuses
+ uint8_t mods;
+ bool suspended;
#ifdef BACKLIGHT_ENABLE
uint8_t backlight_level;
#endif
@@ -86,7 +87,7 @@ typedef struct {
// from the user customized code
typedef struct visualizer_state_t {
// The user code should primarily be modifying these
- uint32_t target_lcd_color;
+ uint32_t target_lcd_color;
const char* layer_text;
// The user visualizer(and animation functions) can read these
@@ -110,15 +111,15 @@ typedef bool (*frame_func)(struct keyframe_animation_t*, visualizer_state_t*);
// while others are meant to be initialized by the user code
typedef struct keyframe_animation_t {
// These should be initialized
- int num_frames;
- bool loop;
- int frame_lengths[MAX_VISUALIZER_KEY_FRAMES];
+ int num_frames;
+ bool loop;
+ int frame_lengths[MAX_VISUALIZER_KEY_FRAMES];
frame_func frame_functions[MAX_VISUALIZER_KEY_FRAMES];
// Used internally by the system, and can also be read by
// keyframe update functions
- int current_frame;
- int time_left_in_frame;
+ int current_frame;
+ int time_left_in_frame;
bool first_update_of_frame;
bool last_update_of_frame;
bool need_update;