summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2021-06-29 12:23:03 -0700
committerDrashna Jael're <drashna@live.com>2021-06-29 12:24:07 -0700
commitacf2c323e2927f6007b17ded577cf49fd86fec6c (patch)
tree8334dc5c71e6ab9bf33c76143eac7bb0e60159b0
parentec7a7beeed3046e9144d4c4ce0ef3b2c4f9e4341 (diff)
parentf55e39e8a2246f6f96fd5d4a84a866e2615cde7b (diff)
Merge upstream QMK Firmware at '0.12.52~1'
-rw-r--r--.clang-format2
-rw-r--r--.gitattributes1
-rw-r--r--.github/ISSUE_TEMPLATE/blank.md5
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md7
-rw-r--r--.github/ISSUE_TEMPLATE/config.yml8
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.md7
-rw-r--r--.github/ISSUE_TEMPLATE/other_issues.md7
-rw-r--r--.github/ISSUE_TEMPLATE/zzz_blank.md11
-rw-r--r--.github/labeler.yml42
-rw-r--r--.github/stale.yml58
-rw-r--r--.github/workflows/api.yml37
-rw-r--r--.github/workflows/auto_tag.yaml33
-rw-r--r--.github/workflows/cli.yml28
-rw-r--r--.github/workflows/develop_api.yml37
-rw-r--r--.github/workflows/develop_update.yml37
-rw-r--r--.github/workflows/docs.yml43
-rw-r--r--.github/workflows/format.yaml42
-rw-r--r--.github/workflows/labeler.yml14
-rw-r--r--.github/workflows/lint.yml55
-rw-r--r--.gitignore6
-rw-r--r--.travis.yml4
-rw-r--r--CODE_OF_CONDUCT.md11
-rw-r--r--Makefile21
-rw-r--r--Vagrantfile2
-rw-r--r--api_data/_config.yml1
-rw-r--r--api_data/readme.md5
-rwxr-xr-xbin/qmk43
-rw-r--r--bootloader.mk13
-rw-r--r--build_keyboard.mk59
-rw-r--r--common_features.mk180
-rw-r--r--data/mappings/info_config.json46
-rw-r--r--data/mappings/info_rules.json15
-rw-r--r--data/mappings/keyboard_aliases.json443
-rw-r--r--data/schemas/api_keyboard.jsonschema35
-rw-r--r--data/schemas/false.jsonschema1
-rw-r--r--data/schemas/keyboard.jsonschema326
-rw-r--r--data/schemas/true.jsonschema1
-rw-r--r--disable_features.mk31
-rw-r--r--drivers/apa102/apa102.c151
-rw-r--r--drivers/apa102/apa102.h (renamed from drivers/avr/apa102.h)32
-rw-r--r--drivers/avr/serial.c8
-rw-r--r--drivers/avr/spi_master.c2
-rw-r--r--drivers/avr/spi_master.h2
-rw-r--r--drivers/avr/ssd1306.c2
-rw-r--r--drivers/avr/ssd1306.h2
-rw-r--r--drivers/avr/uart.c (renamed from tmk_core/common/uart.c)42
-rw-r--r--drivers/avr/uart.h35
-rw-r--r--drivers/avr/ws2812.c38
-rw-r--r--drivers/chibios/i2c_master.h5
-rw-r--r--drivers/chibios/serial_usart.c24
-rw-r--r--drivers/chibios/uart.c50
-rw-r--r--drivers/chibios/uart.h77
-rw-r--r--drivers/chibios/usbpd_stm32g4.c76
-rw-r--r--drivers/chibios/ws2812.c2
-rw-r--r--drivers/chibios/wt_rgb_backlight.c3125
-rw-r--r--drivers/chibios/wt_rgb_backlight.h115
-rw-r--r--drivers/chibios/wt_rgb_backlight_api.h43
-rw-r--r--drivers/chibios/wt_rgb_backlight_keycodes.h34
-rw-r--r--drivers/gpio/pca9555.c17
-rw-r--r--drivers/gpio/pca9555.h2
-rw-r--r--drivers/haptic/haptic.c89
-rw-r--r--drivers/haptic/haptic.h16
-rw-r--r--drivers/issi/is31fl3731-simple.c4
-rw-r--r--drivers/issi/is31fl3731-simple.h2
-rw-r--r--drivers/oled/licenses.txt45
-rw-r--r--drivers/oled/oled_driver.h6
-rw-r--r--drivers/qwiic/micro_oled.c2
-rw-r--r--drivers/qwiic/qwiic.mk9
-rw-r--r--drivers/usbpd.h29
-rw-r--r--keyboards/ergodox_ez/config.h11
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.c27
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.h6
-rw-r--r--keyboards/ergodox_ez/glow/glow.h3
-rw-r--r--keyboards/ergodox_ez/glow/rules.mk2
-rw-r--r--keyboards/ergodox_ez/info.json2
-rw-r--r--keyboards/ergodox_ez/keymaps/default/keymap.c108
-rw-r--r--keyboards/ergodox_ez/matrix.c1
-rw-r--r--keyboards/ergodox_ez/rules.mk5
-rw-r--r--keyboards/ergodox_ez/shine/config.h3
-rw-r--r--keyboards/ergodox_ez/shine/shine.h3
-rwxr-xr-x[-rw-r--r--]keyboards/ergodox_ez/util/compile_keymap.py0
-rw-r--r--keyboards/ergodox_ez/util/readme.md8
-rw-r--r--keyboards/moonlander/config.h62
-rw-r--r--keyboards/moonlander/info.json30
-rw-r--r--keyboards/moonlander/keymaps/default/config.h18
-rw-r--r--keyboards/moonlander/matrix.c41
-rw-r--r--keyboards/moonlander/moonlander.c80
-rw-r--r--keyboards/moonlander/moonlander.h37
-rw-r--r--keyboards/moonlander/readme.md28
-rw-r--r--keyboards/moonlander/rules.mk43
-rw-r--r--keyboards/planck/config.h8
-rw-r--r--keyboards/planck/ez/chconf.h (renamed from quantum/template/base/template.h)24
-rw-r--r--keyboards/planck/ez/config.h26
-rw-r--r--keyboards/planck/ez/ez.c46
-rw-r--r--keyboards/planck/ez/ez.h22
-rw-r--r--keyboards/planck/ez/glow/glow.c1
-rw-r--r--keyboards/planck/ez/glow/keymaps/glow/config.h36
-rw-r--r--keyboards/planck/ez/info.json224
-rw-r--r--keyboards/planck/ez/mcuconf.h30
-rwxr-xr-x[-rw-r--r--]keyboards/planck/ez/rules.mk30
-rw-r--r--keyboards/planck/info.json113
-rw-r--r--keyboards/planck/keymaps/default/config.h3
-rw-r--r--keyboards/planck/keymaps/default/keymap.c129
-rw-r--r--keyboards/planck/keymaps/oryx/config.h2
-rw-r--r--keyboards/planck/keymaps/oryx/keymap.c293
-rw-r--r--keyboards/planck/keymaps/webusb/config.h3
-rw-r--r--keyboards/planck/planck.c12
-rw-r--r--keyboards/planck/readme.md5
-rw-r--r--keyboards/planck/rules.mk32
m---------lib/chibios0
m---------lib/chibios-contrib0
m---------lib/lufa0
-rw-r--r--lib/python/qmk/c_parse.py41
-rw-r--r--lib/python/qmk/cli/__init__.py178
-rwxr-xr-xlib/python/qmk/cli/bux.py49
-rw-r--r--lib/python/qmk/cli/c2json.py20
-rw-r--r--lib/python/qmk/cli/cformat.py134
-rw-r--r--lib/python/qmk/cli/chibios/confmigrate.py21
-rw-r--r--lib/python/qmk/cli/clean.py10
-rwxr-xr-xlib/python/qmk/cli/compile.py15
-rwxr-xr-xlib/python/qmk/cli/doctor.py33
-rw-r--r--lib/python/qmk/cli/flash.py12
-rw-r--r--lib/python/qmk/cli/format/__init__.py1
-rwxr-xr-xlib/python/qmk/cli/format/json.py66
-rw-r--r--lib/python/qmk/cli/generate/__init__.py6
-rwxr-xr-xlib/python/qmk/cli/generate/api.py71
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py154
-rw-r--r--lib/python/qmk/cli/generate/dfu_header.py60
-rw-r--r--lib/python/qmk/cli/generate/docs.py14
-rwxr-xr-xlib/python/qmk/cli/generate/info_json.py67
-rwxr-xr-xlib/python/qmk/cli/generate/keyboard_h.py60
-rwxr-xr-xlib/python/qmk/cli/generate/layouts.py103
-rw-r--r--lib/python/qmk/cli/generate/rgb_breathe_table.py2
-rwxr-xr-xlib/python/qmk/cli/generate/rules_mk.py97
-rwxr-xr-xlib/python/qmk/cli/info.py36
-rwxr-xr-xlib/python/qmk/cli/json2c.py21
-rwxr-xr-xlib/python/qmk/cli/kle2json.py56
-rw-r--r--lib/python/qmk/cli/lint.py3
-rw-r--r--lib/python/qmk/cli/list/keymaps.py8
-rwxr-xr-xlib/python/qmk/cli/multibuild.py79
-rw-r--r--lib/python/qmk/cli/new/__init__.py1
-rw-r--r--lib/python/qmk/cli/new/keyboard.py11
-rwxr-xr-xlib/python/qmk/cli/new/keymap.py3
-rwxr-xr-xlib/python/qmk/cli/pyformat.py21
-rw-r--r--lib/python/qmk/cli/pytest.py7
-rw-r--r--lib/python/qmk/commands.py67
-rw-r--r--lib/python/qmk/constants.py15
-rw-r--r--lib/python/qmk/decorators.py60
-rw-r--r--lib/python/qmk/errors.py7
-rw-r--r--lib/python/qmk/info.py441
-rwxr-xr-xlib/python/qmk/json_encoders.py192
-rw-r--r--lib/python/qmk/json_schema.py68
-rw-r--r--lib/python/qmk/keyboard.py80
-rw-r--r--lib/python/qmk/keymap.py75
-rw-r--r--lib/python/qmk/os_helpers/__init__.py5
-rw-r--r--lib/python/qmk/os_helpers/linux/__init__.py13
-rw-r--r--lib/python/qmk/path.py10
-rw-r--r--lib/python/qmk/submodules.py17
-rw-r--r--lib/python/qmk/tests/minimal_info.json13
-rw-r--r--lib/python/qmk/tests/minimal_keymap.json7
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py158
-rw-r--r--lib/python/qmk/tests/test_qmk_keymap.py32
-rw-r--r--lib/python/qmk/tests/test_qmk_path.py6
-rw-r--r--message.mk3
-rw-r--r--nix/poetry.lock369
-rw-r--r--nix/pyproject.toml30
-rw-r--r--nix/sources.json26
-rw-r--r--nix/sources.nix174
-rw-r--r--platforms/chibios/BLACKPILL_STM32_F401/configs/config.h9
-rw-r--r--platforms/chibios/BLACKPILL_STM32_F411/configs/chconf.h714
-rw-r--r--platforms/chibios/BLACKPILL_STM32_F411/configs/config.h9
-rw-r--r--platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h525
-rw-r--r--platforms/chibios/GENERIC_STM32_F042X6/board/board.c4
-rw-r--r--platforms/chibios/GENERIC_STM32_F072XB/configs/mcuconf.h6
-rw-r--r--platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h22
-rw-r--r--platforms/chibios/GENERIC_STM32_G431XB/board/board.mk9
-rw-r--r--platforms/chibios/GENERIC_STM32_G431XB/configs/config.h23
-rw-r--r--platforms/chibios/GENERIC_STM32_G431XB/configs/mcuconf.h307
-rw-r--r--platforms/chibios/GENERIC_STM32_G474XE/board/board.mk9
-rw-r--r--platforms/chibios/GENERIC_STM32_G474XE/configs/config.h30
-rw-r--r--platforms/chibios/GENERIC_STM32_G474XE/configs/mcuconf.h372
-rw-r--r--platforms/chibios/QMK_PROTON_C/board/board.mk9
-rw-r--r--platforms/chibios/QMK_PROTON_C/configs/board.h37
-rw-r--r--platforms/chibios/QMK_PROTON_C/configs/bootloader_defs.h7
-rw-r--r--platforms/chibios/QMK_PROTON_C/configs/chconf.h (renamed from platforms/chibios/BLACKPILL_STM32_F401/configs/chconf.h)94
-rw-r--r--platforms/chibios/QMK_PROTON_C/configs/config.h20
-rw-r--r--platforms/chibios/QMK_PROTON_C/configs/halconf.h (renamed from platforms/chibios/BLACKPILL_STM32_F401/configs/halconf.h)30
-rw-r--r--platforms/chibios/QMK_PROTON_C/configs/mcuconf.h273
-rw-r--r--platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk12
-rw-r--r--platforms/chibios/common/configs/chconf.h124
-rw-r--r--platforms/chibios/common/configs/halconf.h28
-rw-r--r--quantum/api/api_sysex.h2
-rw-r--r--quantum/audio/audio.c539
-rw-r--r--quantum/audio/audio.h281
-rw-r--r--quantum/audio/audio_pwm.c606
-rw-r--r--quantum/audio/driver_avr_pwm.h17
-rw-r--r--quantum/audio/driver_avr_pwm_hardware.c332
-rw-r--r--quantum/audio/driver_chibios_dac.h126
-rw-r--r--quantum/audio/driver_chibios_dac_additive.c335
-rw-r--r--quantum/audio/driver_chibios_dac_basic.c245
-rw-r--r--quantum/audio/driver_chibios_pwm.h40
-rw-r--r--quantum/audio/driver_chibios_pwm_hardware.c144
-rw-r--r--quantum/audio/driver_chibios_pwm_software.c164
-rw-r--r--quantum/audio/musical_notes.h76
-rw-r--r--quantum/audio/song_list.h4
-rw-r--r--quantum/audio/voices.c171
-rw-r--r--quantum/audio/voices.h20
-rw-r--r--quantum/audio/wave.h36
-rw-r--r--quantum/backlight/backlight_avr.c6
-rw-r--r--quantum/bitwise.c (renamed from tmk_core/common/util.c)0
-rw-r--r--quantum/bitwise.h (renamed from tmk_core/common/util.h)7
-rw-r--r--quantum/color.c1
-rw-r--r--quantum/command.c (renamed from tmk_core/common/command.c)13
-rw-r--r--quantum/command.h (renamed from tmk_core/common/command.h)0
-rw-r--r--quantum/config_common.h398
-rw-r--r--quantum/debounce/sym_defer_pk.c6
-rw-r--r--quantum/debounce/sym_eager_pk.c6
-rw-r--r--quantum/debounce/sym_eager_pr.c6
-rw-r--r--quantum/dip_switch.c17
-rw-r--r--quantum/dynamic_keymap.c38
-rw-r--r--quantum/encoder.c22
-rw-r--r--quantum/encoder.h2
-rw-r--r--quantum/fauxclicky.c59
-rw-r--r--quantum/fauxclicky.h97
-rw-r--r--quantum/keymap.h4
-rw-r--r--quantum/keymap_extras/keymap_canadian_multilingual.h60
-rw-r--r--quantum/keymap_extras/keymap_croatian.h163
-rw-r--r--quantum/keymap_extras/keymap_french_afnor.h253
-rw-r--r--quantum/keymap_extras/keymap_neo2.h180
-rw-r--r--quantum/keymap_extras/keymap_nordic.h5
-rw-r--r--quantum/keymap_extras/keymap_norwegian.h197
-rw-r--r--quantum/keymap_extras/keymap_spanish_dvorak.h6
-rw-r--r--quantum/keymap_extras/keymap_us_extended.h227
-rw-r--r--quantum/keymap_extras/keymap_us_international.h20
-rw-r--r--quantum/keymap_extras/keymap_us_international_linux.h224
-rw-r--r--quantum/keymap_extras/sendstring_belgian.h8
-rw-r--r--quantum/keymap_extras/sendstring_bepo.h10
-rw-r--r--quantum/keymap_extras/sendstring_canadian_multilingual.h100
-rw-r--r--quantum/keymap_extras/sendstring_colemak.h14
-rw-r--r--quantum/keymap_extras/sendstring_croatian.h100
-rw-r--r--quantum/keymap_extras/sendstring_dvorak.h39
-rw-r--r--quantum/keymap_extras/sendstring_french.h12
-rw-r--r--quantum/keymap_extras/sendstring_french_afnor.h100
-rw-r--r--quantum/keymap_extras/sendstring_german.h26
-rw-r--r--quantum/keymap_extras/sendstring_jis.h31
-rw-r--r--quantum/keymap_extras/sendstring_norman.h14
-rw-r--r--quantum/keymap_extras/sendstring_spanish.h6
-rw-r--r--quantum/keymap_extras/sendstring_uk.h29
-rw-r--r--quantum/keymap_extras/sendstring_us_international.h100
-rw-r--r--quantum/keymap_extras/sendstring_workman.h14
-rw-r--r--quantum/led.h (renamed from tmk_core/common/led.h)10
-rw-r--r--quantum/led_matrix.c140
-rw-r--r--quantum/led_matrix.h42
-rw-r--r--quantum/led_matrix_drivers.c2
-rw-r--r--quantum/led_matrix_types.h69
-rw-r--r--quantum/matrix.c14
-rw-r--r--quantum/matrix.h (renamed from tmk_core/common/matrix.h)3
-rw-r--r--quantum/matrix_common.c7
-rw-r--r--quantum/mcu_selection.mk93
-rw-r--r--quantum/mousekey.c (renamed from tmk_core/common/mousekey.c)130
-rw-r--r--quantum/mousekey.h (renamed from tmk_core/common/mousekey.h)45
-rw-r--r--quantum/pointing_device.c9
-rw-r--r--quantum/pointing_device.h1
-rw-r--r--quantum/process_keycode/process_combo.c6
-rwxr-xr-x[-rw-r--r--]quantum/process_keycode/process_grave_esc.h0
-rw-r--r--quantum/process_keycode/process_magic.c5
-rw-r--r--quantum/process_keycode/process_midi.c23
-rw-r--r--quantum/process_keycode/process_rgb.c14
-rw-r--r--quantum/process_keycode/process_tap_dance.c4
-rw-r--r--quantum/process_keycode/process_tap_dance.h8
-rw-r--r--quantum/process_keycode/process_unicode_common.c6
-rw-r--r--quantum/quantum.c307
-rw-r--r--quantum/quantum.h143
-rw-r--r--quantum/quantum_keycodes.h83
-rw-r--r--quantum/rgb_matrix.c26
-rw-r--r--quantum/rgb_matrix.h2
-rw-r--r--quantum/rgb_matrix_animations/hue_breathing_anim.h22
-rw-r--r--quantum/rgb_matrix_animations/hue_pendulum_anim.h17
-rw-r--r--quantum/rgb_matrix_animations/hue_wave_anim.h17
-rw-r--r--quantum/rgb_matrix_animations/rgb_matrix_effects.inc3
-rw-r--r--quantum/rgb_matrix_animations/typing_heatmap_anim.h4
-rw-r--r--quantum/rgb_matrix_types.h16
-rw-r--r--quantum/rgblight.c152
-rw-r--r--quantum/rgblight.h5
-rw-r--r--quantum/ring_buffer.h (renamed from tmk_core/ring_buffer.h)11
-rw-r--r--quantum/send_string.c306
-rw-r--r--quantum/send_string.h54
-rw-r--r--quantum/send_string_keycodes.h18
-rw-r--r--quantum/split_common/matrix.c46
-rw-r--r--quantum/split_common/post_config.h2
-rw-r--r--quantum/split_common/split_util.c5
-rw-r--r--quantum/split_common/transport.c142
-rw-r--r--quantum/split_common/transport.h6
-rw-r--r--quantum/template/avr/config.h9
-rw-r--r--quantum/template/avr/rules.mk2
-rw-r--r--quantum/template/avr/template.c43
-rw-r--r--quantum/template/base/keymaps/default/keymap.c6
-rw-r--r--quantum/template/base/keymaps/default/readme.md2
-rw-r--r--quantum/template/ps2avrgb/config.h1
-rw-r--r--quantum/template/ps2avrgb/i2c.c106
-rw-r--r--quantum/template/ps2avrgb/matrix.c112
-rw-r--r--quantum/template/ps2avrgb/readme.md2
-rw-r--r--quantum/template/ps2avrgb/rules.mk2
-rw-r--r--quantum/template/ps2avrgb/template.c44
-rw-r--r--quantum/util.h (renamed from quantum/template/ps2avrgb/i2c.h)19
-rw-r--r--quantum/via.c18
-rw-r--r--quantum/via.h8
-rw-r--r--quantum/via_ensure_keycode.h366
-rw-r--r--quantum/wpm.c39
-rw-r--r--quantum/wpm.h4
-rw-r--r--readme.md30
-rw-r--r--requirements.txt4
-rw-r--r--setup.cfg2
-rw-r--r--shell.nix63
-rw-r--r--show_options.mk4
-rw-r--r--tmk_core/avr.mk72
-rw-r--r--tmk_core/chibios.mk4
-rw-r--r--tmk_core/common.mk38
-rw-r--r--tmk_core/common/action.c108
-rw-r--r--tmk_core/common/action.h1
-rw-r--r--tmk_core/common/action_tapping.c15
-rw-r--r--tmk_core/common/arm_atsam/_print.h (renamed from tmk_core/common/print.c)33
-rw-r--r--tmk_core/common/arm_atsam/printf.c9
-rw-r--r--tmk_core/common/arm_atsam/printf.mk1
-rw-r--r--tmk_core/common/arm_atsam/suspend.c3
-rw-r--r--tmk_core/common/atomic_util.h32
-rw-r--r--tmk_core/common/avr/_print.h33
-rw-r--r--tmk_core/common/avr/atomic_util.h22
-rw-r--r--tmk_core/common/avr/bootloader.c2
-rw-r--r--tmk_core/common/avr/gpio.h34
-rw-r--r--tmk_core/common/avr/pin_defs.h128
-rw-r--r--tmk_core/common/avr/printf.c20
-rw-r--r--tmk_core/common/avr/printf.mk2
-rw-r--r--tmk_core/common/avr/sleep_led.c2
-rw-r--r--tmk_core/common/avr/suspend.c92
-rw-r--r--tmk_core/common/avr/suspend_avr.h25
-rw-r--r--tmk_core/common/chibios/atomic_util.h37
-rw-r--r--tmk_core/common/chibios/eeprom_teensy.c2
-rw-r--r--tmk_core/common/chibios/gpio.h34
-rw-r--r--tmk_core/common/chibios/pin_defs.h242
-rw-r--r--tmk_core/common/debug.c41
-rw-r--r--tmk_core/common/eeconfig.c12
-rw-r--r--tmk_core/common/eeconfig.h2
-rw-r--r--tmk_core/common/gpio.h22
-rw-r--r--tmk_core/common/host.c2
-rw-r--r--tmk_core/common/keyboard.c122
-rw-r--r--tmk_core/common/keyboard.h11
-rw-r--r--tmk_core/common/keycode.h24
-rw-r--r--tmk_core/common/lib_printf.mk9
-rw-r--r--tmk_core/common/pin_defs.h23
-rw-r--r--tmk_core/common/print.h301
-rw-r--r--tmk_core/common/printf.c (renamed from tmk_core/protocol/usb_hid/test/config.h)19
-rw-r--r--tmk_core/common/progmem.h1
-rw-r--r--tmk_core/common/report.h37
-rw-r--r--tmk_core/common/sendchar.h2
-rw-r--r--tmk_core/common/suspend.h2
-rw-r--r--tmk_core/common/sync_timer.c58
-rw-r--r--tmk_core/common/sync_timer.h54
-rw-r--r--tmk_core/common/uart.h8
-rw-r--r--tmk_core/common/wait.h79
-rwxr-xr-xtmk_core/make_dfu_header.sh14
-rw-r--r--tmk_core/protocol/adb.c256
-rw-r--r--tmk_core/protocol/adb.h58
-rw-r--r--tmk_core/protocol/arm_atsam/i2c_master.c3
-rw-r--r--tmk_core/protocol/arm_atsam/i2c_master.h4
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c6
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.c94
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c8
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c42
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h7
-rw-r--r--tmk_core/protocol/chibios/main.c3
-rw-r--r--tmk_core/protocol/chibios/usb_main.c117
-rw-r--r--tmk_core/protocol/chibios/usb_main.h11
-rw-r--r--tmk_core/protocol/lufa/lufa.c35
-rw-r--r--tmk_core/protocol/lufa/outputselect.h14
-rw-r--r--tmk_core/protocol/m0110.c8
-rw-r--r--tmk_core/protocol/midi/qmk_midi.c2
-rw-r--r--tmk_core/protocol/ps2_mouse.c2
-rw-r--r--tmk_core/protocol/serial.h2
-rw-r--r--tmk_core/protocol/serial_uart.c25
-rw-r--r--tmk_core/protocol/usb_descriptor.c17
-rw-r--r--tmk_core/protocol/usb_descriptor.h3
-rw-r--r--tmk_core/protocol/usb_hid/test/Makefile126
-rw-r--r--tmk_core/protocol/usb_hid/test/test.cpp92
-rw-r--r--tmk_core/protocol/vusb/main.c66
-rw-r--r--tmk_core/protocol/vusb/usbconfig.h (renamed from quantum/template/ps2avrgb/usbconfig.h)60
-rw-r--r--tmk_core/protocol/vusb/vusb.c22
-rw-r--r--tmk_core/protocol/vusb/vusb.h3
-rw-r--r--tmk_core/protocol/xt.h41
-rw-r--r--tmk_core/protocol/xt_interrupt.c13
-rw-r--r--tmk_core/readme.md1
-rw-r--r--tmk_core/rules.mk5
-rwxr-xr-xutil/atmega32a_program.py105
-rwxr-xr-xutil/audio_generate_dac_lut.py67
-rwxr-xr-xutil/chibios_conf_updater.sh184
-rwxr-xr-xutil/docker_build.sh42
-rw-r--r--util/drivers.txt3
-rwxr-xr-xutil/install/debian.sh2
-rwxr-xr-xutil/install/fedora.sh2
-rwxr-xr-xutil/install/freebsd.sh2
-rwxr-xr-xutil/install/gentoo.sh2
-rwxr-xr-xutil/install/msys2.sh2
-rwxr-xr-xutil/install/void.sh2
-rwxr-xr-xutil/linux_install.sh245
-rwxr-xr-xutil/list_keyboards.sh12
-rwxr-xr-xutil/macos_install.sh30
-rwxr-xr-xutil/new_keyboard.sh13
-rwxr-xr-xutil/new_project.sh70
-rwxr-xr-xutil/qmk_install.sh15
-rw-r--r--util/qmk_tab_complete.sh2
-rwxr-xr-xutil/rules_cleaner.sh40
-rwxr-xr-xutil/sample_parser.py39
-rwxr-xr-xutil/travis_utils.sh25
-rw-r--r--util/udev/50-qmk.rules2
-rwxr-xr-xutil/wavetable_parser.py40
415 files changed, 18670 insertions, 7279 deletions
diff --git a/.clang-format b/.clang-format
index 2eb49559b7..b4f7967831 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,4 +1,4 @@
----
+---
BasedOnStyle: Google
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
diff --git a/.gitattributes b/.gitattributes
index 92dfc3c617..a0fd4fed62 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -92,3 +92,4 @@ GRAPHICS
# hex files
*.hex binary
*.eep binary
+nix/sources.nix linguist-generated=true
diff --git a/.github/ISSUE_TEMPLATE/blank.md b/.github/ISSUE_TEMPLATE/blank.md
deleted file mode 100644
index 50a32034d6..0000000000
--- a/.github/ISSUE_TEMPLATE/blank.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-name: Blank issue
-about: If you're 100% sure that you don't need one of the other issue templates, use this one instead.
-
----
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 3c35416e04..57b415f7b3 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,7 +1,12 @@
---
name: Bug report
-about: Create a report to help us improve the QMK Firmware
+about: Create a report to help us improve QMK Firmware.
+title: "[Bug] "
+labels: bug, help wanted
+assignees: ''
+
---
+
<!-- Provide a general summary of the bug in the title above. -->
<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000..0d4ca035c8
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,8 @@
+blank_issues_enabled: false
+contact_links:
+ - name: QMK Discord
+ url: https://discord.gg/Uq7gcHh
+ about: Ask questions, discuss issues and features. Chill.
+ - name: OLKB Subreddit
+ url: https://www.reddit.com/r/olkb
+ about: All things OLKB and QMK.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 01aeb26cec..1876834247 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,7 +1,12 @@
---
name: Feature request
-about: Suggest a new feature or changes to existing features
+about: Suggest a new feature or changes to existing features.
+title: "[Feature Request] "
+labels: enhancement, help wanted
+assignees: ''
+
---
+
<!--- Provide a general summary of the changes you want in the title above. -->
<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
diff --git a/.github/ISSUE_TEMPLATE/other_issues.md b/.github/ISSUE_TEMPLATE/other_issues.md
index 7c4891ac31..befeeb165a 100644
--- a/.github/ISSUE_TEMPLATE/other_issues.md
+++ b/.github/ISSUE_TEMPLATE/other_issues.md
@@ -1,7 +1,12 @@
---
name: Other issues
-about: Anything else that doesn't fall into the above categories.
+about: Anything else that doesn't fall into the above categories.
+title: ''
+labels: help wanted, question
+assignees: ''
+
---
+
<!--- Provide a general summary of the changes you want in the title above. -->
<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->
diff --git a/.github/ISSUE_TEMPLATE/zzz_blank.md b/.github/ISSUE_TEMPLATE/zzz_blank.md
new file mode 100644
index 0000000000..5644802ef5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/zzz_blank.md
@@ -0,0 +1,11 @@
+---
+name: Blank issue
+about: If you're 100% sure that you don't need one of the other issue templates, use
+ this one instead.
+title: ''
+labels: help wanted, question
+assignees: ''
+
+---
+
+
diff --git a/.github/labeler.yml b/.github/labeler.yml
new file mode 100644
index 0000000000..53921f7f95
--- /dev/null
+++ b/.github/labeler.yml
@@ -0,0 +1,42 @@
+core:
+ - quantum/**/*
+ - tmk_core/**/*
+ - drivers/**/*
+ - tests/**/*
+ - util/**/*
+ - platforms/**/*
+ - Makefile
+ - '*.mk'
+dependencies:
+ - any:
+ - 'lib/**/*'
+ - '!lib/python/**/*'
+keyboard:
+ - any:
+ - 'keyboards/**/*'
+ - '!keyboards/**/keymaps/**/*'
+keymap:
+ - users/**/*
+ - layouts/**/*
+ - keyboards/**/keymaps/**/*
+via:
+ - keyboards/**/keymaps/via/*
+cli:
+ - bin/qmk
+ - requirements.txt
+ - lib/python/**/*
+python:
+ - '**/*.py'
+documentation:
+ - docs/**/*
+translation:
+ - docs/fr-fr/**/*
+ - docs/es/**/*
+ - docs/ja/**/*
+ - docs/he-il/**/*
+ - docs/pt-br/**/*
+ - docs/zh-cn/**/*
+ - docs/de/**/*
+ - docs/ru-ru/**/*
+CI:
+ - .github/**/*
diff --git a/.github/stale.yml b/.github/stale.yml
new file mode 100644
index 0000000000..eb49888191
--- /dev/null
+++ b/.github/stale.yml
@@ -0,0 +1,58 @@
+# Configuration for probot-stale - https://github.com/probot/stale
+
+# General configuration
+
+# Pull request specific configuration
+pulls:
+ staleLabel: awaiting changes
+ # Number of days of inactivity before an Issue or Pull Request becomes stale
+ daysUntilStale: 45
+ # Number of days of inactivity before a stale Issue or Pull Request is closed.
+ # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
+ daysUntilClose: 30
+ # Comment to post when marking as stale. Set to `false` to disable
+ markComment: >
+ Thank you for your contribution!
+
+ This pull request has been automatically marked as stale because it has not had
+ activity in the last 45 days. It will be closed in 30 days if no further activity occurs.
+ Please feel free to give a status update now, or re-open when it's ready.
+
+ For maintainers: Please label with `awaiting review`, `breaking_change`, `in progress`, or `on hold` to prevent
+ the issue from being re-flagged.
+ # Comment to post when closing a stale Issue or Pull Request.
+ closeComment: >
+ Thank you for your contribution!
+
+ This pull request has been automatically closed because it has not had activity in the last 30 days.
+ Please feel free to give a status update now, ping for review, or re-open when it's ready.
+ # Limit the number of actions per hour, from 1-30. Default is 30
+ limitPerRun: 30
+ exemptLabels:
+ - awaiting review
+ - breaking_change
+ - in progress
+ - on hold
+
+# Issue specific configuration
+issues:
+ staleLabel: stale
+ limitPerRun: 10
+ daysUntilStale: 90
+ daysUntilClose: 30
+ markComment: >
+ This issue has been automatically marked as stale because it has not had activity in the
+ last 90 days. It will be closed in the next 30 days unless it is tagged properly or other activity
+ occurs.
+
+ For maintainers: Please label with `bug`, `in progress`, `on hold`, `discussion` or `to do` to prevent
+ the issue from being re-flagged.
+ closeComment: >
+ This issue has been automatically closed because it has not had activity in the last 30 days.
+ If this issue is still valid, re-open the issue and let us know.
+ exemptLabels:
+ - bug
+ - in progress
+ - on hold
+ - discussion
+ - to do
diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml
new file mode 100644
index 0000000000..c8d988d0f0
--- /dev/null
+++ b/.github/workflows/api.yml
@@ -0,0 +1,37 @@
+name: Update API Data
+
+on:
+ push:
+ branches:
+ - master
+ paths:
+ - 'keyboards/**'
+ - 'layouts/community/**'
+
+jobs:
+ api_data:
+ runs-on: ubuntu-latest
+ container: qmkfm/base_container
+
+ # protect against those who develop with their fork on master
+ if: github.repository == 'qmk/qmk_firmware'
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 1
+ persist-credentials: false
+
+ - name: Generate API Data
+ run: qmk generate-api
+
+ - name: Upload API Data
+ uses: jakejarvis/s3-sync-action@master
+ with:
+ args: --acl public-read --follow-symlinks --delete
+ env:
+ AWS_S3_BUCKET: ${{ secrets.API_SPACE_MASTER }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }}
+ AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com
+ SOURCE_DIR: 'api_data'
diff --git a/.github/workflows/auto_tag.yaml b/.github/workflows/auto_tag.yaml
new file mode 100644
index 0000000000..29e85c41ca
--- /dev/null
+++ b/.github/workflows/auto_tag.yaml
@@ -0,0 +1,33 @@
+name: Essential files modified
+
+on:
+ push:
+ branches:
+ - master
+ paths:
+ - quantum/**/*
+ - tmk_core/**/*
+ - drivers/**/*
+ - tests/**/*
+ - util/**/*
+ - platforms/**/*
+ - Makefile
+ - '*.mk'
+
+jobs:
+ tag:
+ runs-on: ubuntu-latest
+
+ # protect against those who develop with their fork on master
+ if: github.repository == 'qmk/qmk_firmware'
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Bump version and push tag
+ uses: anothrNick/github-tag-action@1.26.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ DEFAULT_BUMP: 'patch'
diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml
new file mode 100644
index 0000000000..28c6bb3679
--- /dev/null
+++ b/.github/workflows/cli.yml
@@ -0,0 +1,28 @@
+name: CLI CI
+
+on:
+ push:
+ branches:
+ - master
+ - future
+ pull_request:
+ paths:
+ - 'lib/python/**'
+ - 'bin/qmk'
+ - 'requirements.txt'
+ - '.github/workflows/cli.yml'
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ container: qmkfm/base_container
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: recursive
+ - name: Install dependencies
+ run: pip3 install -r requirements.txt
+ - name: Run tests
+ run: bin/qmk pytest
diff --git a/.github/workflows/develop_api.yml b/.github/workflows/develop_api.yml
new file mode 100644
index 0000000000..4e64cbcf8c
--- /dev/null
+++ b/.github/workflows/develop_api.yml
@@ -0,0 +1,37 @@
+name: Update Develop API Data
+
+on:
+ push:
+ branches:
+ - develop
+ paths:
+ - 'keyboards/**'
+ - 'layouts/community/**'
+
+jobs:
+ api_data:
+ runs-on: ubuntu-latest
+ container: qmkfm/base_container
+
+ # protect against those who work in their fork on develop
+ if: github.repository == 'qmk/qmk_firmware'
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 1
+ persist-credentials: false
+
+ - name: Generate API Data
+ run: qmk generate-api
+
+ - name: Upload API Data
+ uses: jakejarvis/s3-sync-action@master
+ with:
+ args: --acl public-read --follow-symlinks --delete
+ env:
+ AWS_S3_BUCKET: ${{ secrets.API_SPACE_DEVELOP }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }}
+ AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com
+ SOURCE_DIR: 'api_data'
diff --git a/.github/workflows/develop_update.yml b/.github/workflows/develop_update.yml
new file mode 100644
index 0000000000..285720fefe
--- /dev/null
+++ b/.github/workflows/develop_update.yml
@@ -0,0 +1,37 @@
+name: Update develop after master merge
+
+on:
+ push:
+ branches:
+ - master
+
+
+jobs:
+ develop_update:
+ runs-on: ubuntu-latest
+
+ if: github.repository == 'qmk/qmk_firmware'
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Checkout develop
+ run: |
+ git fetch origin master develop
+ git checkout develop
+
+ - name: Check if branch locked
+ id: check_locked
+ uses: andstor/file-existence-action@v1
+ with:
+ files: ".locked"
+
+ - name: Update develop from master
+ if: steps.check_locked.outputs.files_exists == 'false'
+ run: |
+ git config --global user.name "QMK Bot"
+ git config --global user.email "hello@qmk.fm"
+ git merge origin/master
+ git push origin develop
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000000..8855d1107f
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,43 @@
+name: Generate Docs
+
+on:
+ push:
+ branches:
+ - master
+ paths:
+ - 'tmk_core/**'
+ - 'quantum/**'
+ - 'platforms/**'
+ - 'docs/**'
+ - '.github/workflows/docs.yml'
+
+jobs:
+ generate:
+ runs-on: ubuntu-latest
+ container: qmkfm/base_container
+
+ # protect against those who develop with their fork on master
+ if: github.repository == 'qmk/qmk_firmware'
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 1
+
+ - name: Install dependencies
+ run: |
+ apt-get update && apt-get install -y rsync nodejs npm doxygen
+ npm install -g moxygen
+
+ - name: Build docs
+ run: |
+ qmk --verbose generate-docs
+
+ - name: Deploy
+ uses: JamesIves/github-pages-deploy-action@3.7.1
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ BASE_BRANCH: master
+ BRANCH: gh-pages
+ FOLDER: .build/docs
+ GIT_CONFIG_EMAIL: hello@qmk.fm
diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml
new file mode 100644
index 0000000000..c17a04a542
--- /dev/null
+++ b/.github/workflows/format.yaml
@@ -0,0 +1,42 @@
+name: PR Lint Format
+
+on:
+ pull_request:
+ paths:
+ - 'drivers/**'
+ - 'lib/arm_atsam/**'
+ - 'lib/lib8tion/**'
+ - 'lib/python/**'
+ - 'platforms/**'
+ - 'quantum/**'
+ - 'tests/**'
+ - 'tmk_core/**'
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+
+ container: qmkfm/base_container
+
+ steps:
+ - uses: rlespinasse/github-slug-action@v3.x
+
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - uses: trilom/file-changes-action@v1.2.4
+ id: file_changes
+ with:
+ output: ' '
+ fileOutput: ' '
+
+ - name: Run qmk cformat and qmk pyformat
+ shell: 'bash {0}'
+ run: |
+ qmk cformat --core-only -n $(< ~/files.txt)
+ cformat_exit=$?
+ qmk pyformat -n
+ pyformat_exit=$?
+
+ exit $((cformat_exit + pyformat_exit))
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
new file mode 100644
index 0000000000..3b99a8f43e
--- /dev/null
+++ b/.github/workflows/labeler.yml
@@ -0,0 +1,14 @@
+name: "Pull Request Labeler"
+
+on:
+ pull_request_target:
+ types: [opened, synchronize, reopened, ready_for_review, locked]
+
+jobs:
+ triage:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/labeler@main
+ with:
+ repo-token: "${{ secrets.GITHUB_TOKEN }}"
+ configuration-path: '.github/labeler.yml'
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000000..cd67de9d8b
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,55 @@
+name: PR Lint keyboards
+
+on:
+ pull_request:
+ paths:
+ - 'keyboards/**'
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+
+ container: qmkfm/base_container
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - uses: trilom/file-changes-action@v1.2.4
+ id: file_changes
+ with:
+ output: '\n'
+
+ - name: Print info
+ run: |
+ git rev-parse --short HEAD
+ echo ${{ github.event.pull_request.base.sha }}
+ echo '${{ steps.file_changes.outputs.files}}'
+
+ - name: Run qmk lint
+ shell: 'bash {0}'
+ run: |
+ QMK_CHANGES=$(echo -e '${{ steps.file_changes.outputs.files}}')
+ QMK_KEYBOARDS=$(qmk list-keyboards)
+
+ exit_code=0
+ for KB in $QMK_KEYBOARDS; do
+ KEYBOARD_CHANGES=$(echo "$QMK_CHANGES" | grep -E '^(keyboards/'${KB}'/)')
+ if [[ -z "$KEYBOARD_CHANGES" ]]; then
+ # skip as no changes for this keyboard
+ continue
+ fi
+
+ KEYMAP_ONLY=$(echo "$KEYBOARD_CHANGES" | grep -cv /keymaps/)
+ if [[ $KEYMAP_ONLY -gt 0 ]]; then
+ echo "linting ${KB}"
+
+ qmk lint --keyboard ${KB} && qmk info -l --keyboard ${KB}
+ exit_code=$(($exit_code + $?))
+ fi
+ done
+ if [[ $exit_code -gt 255 ]]; then
+ exit 255
+ fi
+ exit $exit_code
diff --git a/.gitignore b/.gitignore
index d9f3c30d3d..ec04818547 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@
*.swp
tags
*~
+api_data/v1
build/
.build/
*.bak
@@ -44,18 +45,20 @@ doxygen/
.browse.VC.db*
*.stackdump
# Let these ones be user specific, since we have so many different configurations
+*.code-workspace
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/tasks.json
.vscode/last.sql
.vscode/temp.sql
+.vscode/ipch/
.stfolder
.tags
# ignore image files
*.png
-*.jpg
*.gif
+*.jpg
# things travis sees
secrets.tar
@@ -64,6 +67,7 @@ id_rsa_*
# python things
__pycache__
+.python-version
# prerequisites for updating ChibiOS
/util/fmpp*
diff --git a/.travis.yml b/.travis.yml
index 0b2f46dd7a..5641a74316 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
os: linux
dist: trusty
-sudo: required
group: edge
language: c
branches:
@@ -21,6 +20,9 @@ script:
- bash util/travis_build.sh
addons:
apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-trusty-7
packages:
- pandoc
- diffutils
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index d5d8b01de5..c9e3e0586a 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -8,8 +8,17 @@ Our users, contributors, and collaborators are expected to treat each other with
* The use of sexualized language or imagery
* Unwelcome advances, sexual or otherwise
+* Deliberate intimidation, stalking, or following
* Insults or derogatory comments, or personal or political attacks
* Publishing others’ private information without explicit permission
+* Sustained disruption of talks or other events
* Other conduct which could reasonably be considered inappropriate in a professional setting
+* Advocating for, or encouraging, any of the above behaviour
-If someone is violating this Code of Conduct you may email hello@qmk.fm to bring your concern to the Members. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
+# Reporting
+
+If someone is violating this Code of Conduct, please email hello@qmk.fm or reach out to one of the Collaborators to bring it to our attention. All complaints will be reviewed and investigated.
+
+QMK will seek to use the least punitive means available to resolve an issue. If the circumstances require asking an offender to leave, we will do that.
+
+Reports will be taken and kept in strict confidence. You will not be required to confront an offender directly.
diff --git a/Makefile b/Makefile
index 580de27266..63730ccf66 100644
--- a/Makefile
+++ b/Makefile
@@ -217,6 +217,19 @@ define PARSE_RULE
# If the rule starts with all, then continue the parsing from
# PARSE_ALL_KEYBOARDS
ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
+ KEYBOARD_RULE=all
+ $$(eval $$(call PARSE_ALL_KEYBOARDS))
+ else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-avr),true)
+ KEYBOARD_RULE=all
+ REQUIRE_PLATFORM_KEY := avr
+ $$(eval $$(call PARSE_ALL_KEYBOARDS))
+ else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-chibios),true)
+ KEYBOARD_RULE=all
+ REQUIRE_PLATFORM_KEY := chibios
+ $$(eval $$(call PARSE_ALL_KEYBOARDS))
+ else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-arm_atsam),true)
+ KEYBOARD_RULE=all
+ REQUIRE_PLATFORM_KEY := arm_atsam
$$(eval $$(call PARSE_ALL_KEYBOARDS))
else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-avr),true)
KEYBOARD_RULE=all
@@ -234,7 +247,6 @@ define PARSE_RULE
$$(eval $$(call PARSE_TEST))
# If the rule starts with the name of a known keyboard, then continue
# the parsing from PARSE_KEYBOARD
-
else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(shell util/list_keyboards.sh | sort -u)),true)
KEYBOARD_RULE=$$(MATCHED_ITEM)
$$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
@@ -339,6 +351,9 @@ define PARSE_KEYBOARD
# Otherwise try to match the keymap from the current folder, or arguments to the make command
else ifneq ($$(KEYMAP),)
$$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
+ # Otherwise if we are running make all:<user> just skip
+ else ifeq ($$(KEYBOARD_RULE),all)
+ # $$(info Skipping: No user keymap for $$(CURRENT_KB))
# Otherwise, make all keymaps, again this is consistent with how it works without
# any arguments
else
@@ -498,8 +513,8 @@ endef
%:
# Check if we have the CMP tool installed
cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
- # Ensure that bin/qmk works. This will be a failing check after the next develop merge
- if ! bin/qmk hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; fi
+ # Ensure that bin/qmk works.
+ if ! bin/qmk hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
# Check if the submodules are dirty, and display a warning if they are
ifndef SKIP_GIT
if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
diff --git a/Vagrantfile b/Vagrantfile
index f956fd745e..a0137a599c 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -8,6 +8,8 @@ Vagrant.configure(2) do |config|
# VMware/Virtualbox ( and also Hyperv/Parallels) 64 bit
config.vm.box = "generic/debian9"
+ config.vm.synced_folder '.', '/vagrant'
+
# This section allows you to customize the Virtualbox VM
# settings, ie showing the GUI or upping the memory
# or cores if desired
diff --git a/api_data/_config.yml b/api_data/_config.yml
new file mode 100644
index 0000000000..277f1f2c51
--- /dev/null
+++ b/api_data/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-cayman
diff --git a/api_data/readme.md b/api_data/readme.md
new file mode 100644
index 0000000000..a4b2c6bce7
--- /dev/null
+++ b/api_data/readme.md
@@ -0,0 +1,5 @@
+# QMK Keyboard Metadata
+
+This directory contains machine parsable data about keyboards supported by QMK. The latest version is always available online at <https://keyboards.qmk.fm>.
+
+Do not edit anything here by hand. It is generated with the `qmk generate-api` command.
diff --git a/bin/qmk b/bin/qmk
index 801852d4e8..47b50f83b3 100755
--- a/bin/qmk
+++ b/bin/qmk
@@ -3,7 +3,6 @@
"""
import os
import sys
-from importlib.util import find_spec
from pathlib import Path
# Add the QMK python libs to our path
@@ -12,51 +11,9 @@ qmk_dir = script_dir.parent
python_lib_dir = Path(qmk_dir / 'lib' / 'python').resolve()
sys.path.append(str(python_lib_dir))
-
-def _check_modules(requirements):
- """ Check if the modules in the given requirements.txt are available.
- """
- with Path(qmk_dir / requirements).open() as fd:
- for line in fd.readlines():
- line = line.strip().replace('<', '=').replace('>', '=')
-
- if len(line) == 0 or line[0] == '#' or line.startswith('-r'):
- continue
-
- if '#' in line:
- line = line.split('#')[0]
-
- module = dict()
- module['name'] = module['import'] = line.split('=')[0] if '=' in line else line
-
- # Not every module is importable by its own name.
- if module['name'] == "pep8-naming":
- module['import'] = "pep8ext_naming"
-
- if not find_spec(module['import']):
- print('Could not find module %s!' % module['name'])
- print('Please run `python3 -m pip install -r %s` to install required python dependencies.' % (qmk_dir / requirements,))
- if developer:
- print('You can also turn off developer mode: qmk config user.developer=None')
- print()
- exit(255)
-
-
-developer = False
-# Make sure our modules have been setup
-_check_modules('requirements.txt')
-
# Setup the CLI
import milc # noqa
-# For developers additional modules are needed
-if milc.cli.config.user.developer:
- # Do not run the check for 'config',
- # so users can turn off developer mode
- if len(sys.argv) == 1 or (len(sys.argv) > 1 and 'config' != sys.argv[1]):
- developer = True
- _check_modules('requirements-dev.txt')
-
milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}'
diff --git a/bootloader.mk b/bootloader.mk
index 299639043e..fd76446e99 100644
--- a/bootloader.mk
+++ b/bootloader.mk
@@ -20,7 +20,6 @@
# Sets the bootloader defined in the keyboard's/keymap's rules.mk
# Current options:
#
-
# AVR:
# halfkay PJRC Teensy
# caterina Pro Micro (Sparkfun/generic)
@@ -41,30 +40,30 @@
ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
OPT_DEFS += -DBOOTLOADER_DFU
- ifneq (,$(filter $(MCU), at90usb646 atmega16u2 atmega16u4 atmega32u2 atmega32u4))
+ ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
BOOTLOADER_SIZE = 4096
endif
- ifeq ($(strip $(MCU)), at90usb1286)
+ ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
BOOTLOADER_SIZE = 8192
endif
endif
ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
OPT_DEFS += -DBOOTLOADER_LUFA_DFU
OPT_DEFS += -DBOOTLOADER_DFU
- ifneq (,$(filter $(MCU), at90usb646 atmega16u2 atmega16u4 atmega32u2 atmega32u4))
+ ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
BOOTLOADER_SIZE = 4096
endif
- ifeq ($(strip $(MCU)), at90usb1286)
+ ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
BOOTLOADER_SIZE = 8192
endif
endif
ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
OPT_DEFS += -DBOOTLOADER_QMK_DFU
OPT_DEFS += -DBOOTLOADER_DFU
- ifneq (,$(filter $(MCU), at90usb646 atmega16u2 atmega16u4 atmega32u2 atmega32u4))
+ ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
BOOTLOADER_SIZE = 4096
endif
- ifeq ($(strip $(MCU)), at90usb1286)
+ ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
BOOTLOADER_SIZE = 8192
endif
endif
diff --git a/build_keyboard.mk b/build_keyboard.mk
index 323ce57ae7..ec6b026c50 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -90,13 +90,16 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_1)/rules.mk)","")
include $(KEYBOARD_PATH_1)/rules.mk
endif
-
MAIN_KEYMAP_PATH_1 := $(KEYBOARD_PATH_1)/keymaps/$(KEYMAP)
MAIN_KEYMAP_PATH_2 := $(KEYBOARD_PATH_2)/keymaps/$(KEYMAP)
MAIN_KEYMAP_PATH_3 := $(KEYBOARD_PATH_3)/keymaps/$(KEYMAP)
MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
+# Pull in rules from info.json
+INFO_RULES_MK = $(shell bin/qmk generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/rules.mk)
+include $(INFO_RULES_MK)
+
# Check for keymap.json first, so we can regenerate keymap.c
include build_json.mk
@@ -136,9 +139,7 @@ ifeq ($(strip $(CTPC)), yes)
endif
ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
- TARGET := $(TARGET)_proton_c
- include platforms/chibios/GENERIC_STM32_F303XC/configs/proton_c.mk
- OPT_DEFS += -DCONVERT_TO_PROTON_C
+ include platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk
endif
ifneq ($(FORCE_LAYOUT),)
@@ -204,6 +205,7 @@ endif
#
# https://docs.qmk.fm/#/feature_layouts?id=tips-for-making-layouts-keyboard-agnostic
#
+QMK_KEYBOARD_H = $(KEYBOARD_OUTPUT)/src/default_keyboard.h
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/$(KEYBOARD_FOLDER_1).h)","")
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_1).h
endif
@@ -272,6 +274,39 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_config.h)","")
POST_CONFIG_H += $(KEYBOARD_PATH_5)/post_config.h
endif
+# Pull in stuff from info.json
+INFO_JSON_FILES :=
+ifneq ("$(wildcard $(KEYBOARD_PATH_1)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_1)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_2)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_2)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_3)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_3)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_4)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_4)/info.json
+endif
+ifneq ("$(wildcard $(KEYBOARD_PATH_5)/info.json)","")
+ INFO_JSON_FILES += $(KEYBOARD_PATH_5)/info.json
+endif
+
+CONFIG_H += $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/layouts.h
+
+$(KEYBOARD_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES)
+ bin/qmk generate-config-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_config.h
+
+$(KEYBOARD_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES)
+ bin/qmk generate-keyboard-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h
+
+$(KEYBOARD_OUTPUT)/src/layouts.h: $(INFO_JSON_FILES)
+ bin/qmk generate-layouts --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/layouts.h
+
+generated-files: $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/default_keyboard.h $(KEYBOARD_OUTPUT)/src/layouts.h
+
+.INTERMEDIATE : generated-files
+
# Userspace setup and definitions
ifeq ("$(USER_NAME)","")
USER_NAME := $(KEYMAP)
@@ -282,6 +317,12 @@ USER_PATH := users/$(USER_NAME)
ifneq ("$(wildcard $(USER_PATH)/config.h)","")
CONFIG_H += $(USER_PATH)/config.h
endif
+ifneq ("$(wildcard $(USER_PATH)/post_config.h)","")
+ POST_CONFIG_H += $(USER_PATH)/post_config.h
+endif
+
+# Disable features that a keyboard doesn't support
+-include disable_features.mk
# Object files directory
# To put object files in current directory, use a dot (.), do NOT make
@@ -302,9 +343,9 @@ SRC += $(KEYBOARD_SRC) \
# Search Path
VPATH += $(KEYMAP_PATH)
+VPATH += $(USER_PATH)
VPATH += $(KEYBOARD_PATHS)
VPATH += $(COMMON_VPATH)
-VPATH += $(USER_PATH)
include common_features.mk
include $(TMK_PATH)/protocol.mk
@@ -348,7 +389,7 @@ ALL_CONFIGS := $(PROJECT_CONFIG) $(CONFIG_H)
OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
$(KEYMAP_OUTPUT)_SRC := $(SRC)
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) $(GFXDEFS) \
--DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(QMK_KEYBOARD_H)\" -DQMK_KEYBOARD_CONFIG_H=\"$(KEYBOARD_PATH_1)/config.h\" \
+-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(QMK_KEYBOARD_H)\" \
-DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\" \
-DQMK_SUBPROJECT -DQMK_SUBPROJECT_H -DQMK_SUBPROJECT_CONFIG_H
$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
@@ -373,3 +414,9 @@ objs-size: build
include show_options.mk
include $(TMK_PATH)/rules.mk
+
+# Ensure we have generated files available for each of the objects
+define GEN_FILES
+$1: generated-files
+endef
+$(foreach O,$(OBJ),$(eval $(call GEN_FILES,$(patsubst %.a,%.o,$(O)))))
diff --git a/common_features.mk b/common_features.mk
index 0518adc9e5..8b51a60fb9 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -17,6 +17,8 @@ SERIAL_PATH := $(QUANTUM_PATH)/serial_link
QUANTUM_SRC += \
$(QUANTUM_DIR)/quantum.c \
+ $(QUANTUM_DIR)/send_string.c \
+ $(QUANTUM_DIR)/bitwise.c \
$(QUANTUM_DIR)/led.c \
$(QUANTUM_DIR)/keymap_common.c \
$(QUANTUM_DIR)/keycode_config.c
@@ -36,12 +38,36 @@ ifeq ($(strip $(API_SYSEX_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/api.c
endif
+ifeq ($(strip $(COMMAND_ENABLE)), yes)
+ SRC += $(QUANTUM_DIR)/command.c
+ OPT_DEFS += -DCOMMAND_ENABLE
+endif
+
+AUDIO_ENABLE ?= no
ifeq ($(strip $(AUDIO_ENABLE)), yes)
+ ifeq ($(PLATFORM),CHIBIOS)
+ AUDIO_DRIVER ?= dac_basic
+ ifeq ($(strip $(AUDIO_DRIVER)), dac_basic)
+ OPT_DEFS += -DAUDIO_DRIVER_DAC
+ else ifeq ($(strip $(AUDIO_DRIVER)), dac_additive)
+ OPT_DEFS += -DAUDIO_DRIVER_DAC
+ ## stm32f2 and above have a usable DAC unit, f1 do not, and need to use pwm instead
+ else ifeq ($(strip $(AUDIO_DRIVER)), pwm_software)
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ else ifeq ($(strip $(AUDIO_DRIVER)), pwm_hardware)
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ endif
+ else
+ # fallback for all other platforms is pwm
+ AUDIO_DRIVER ?= pwm_hardware
+ OPT_DEFS += -DAUDIO_DRIVER_PWM
+ endif
OPT_DEFS += -DAUDIO_ENABLE
MUSIC_ENABLE = yes
SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
- SRC += $(QUANTUM_DIR)/audio/audio_$(PLATFORM_KEY).c
+ SRC += $(QUANTUM_DIR)/audio/audio.c ## common audio code, hardware agnostic
+ SRC += $(QUANTUM_DIR)/audio/driver_$(PLATFORM_KEY)_$(strip $(AUDIO_DRIVER)).c
SRC += $(QUANTUM_DIR)/audio/voices.c
SRC += $(QUANTUM_DIR)/audio/luts.c
endif
@@ -74,9 +100,10 @@ ifeq ($(strip $(VIRTSER_ENABLE)), yes)
OPT_DEFS += -DVIRTSER_ENABLE
endif
-ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
- OPT_DEFS += -DFAUXCLICKY_ENABLE
- SRC += $(QUANTUM_DIR)/fauxclicky.c
+ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
+ OPT_DEFS += -DMOUSEKEY_ENABLE
+ OPT_DEFS += -DMOUSE_ENABLE
+ SRC += $(QUANTUM_DIR)/mousekey.c
endif
ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
@@ -135,7 +162,6 @@ else
# This ensures that the EEPROM page buffer fits into RAM
USE_PROCESS_STACKSIZE = 0x600
USE_EXCEPTIONS_STACKSIZE = 0x300
-
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
OPT_DEFS += -DEEPROM_EMU_STM32F042x6
@@ -156,20 +182,39 @@ else
endif
endif
+RGBLIGHT_ENABLE ?= no
+VALID_RGBLIGHT_TYPES := WS2812 APA102 custom
+
+ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
+ RGBLIGHT_DRIVER ?= custom
+endif
+
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
- POST_CONFIG_H += $(QUANTUM_DIR)/rgblight_post_config.h
- OPT_DEFS += -DRGBLIGHT_ENABLE
- SRC += $(QUANTUM_DIR)/color.c
- SRC += $(QUANTUM_DIR)/rgblight.c
- CIE1931_CURVE := yes
- RGB_KEYCODES_ENABLE := yes
- ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
- OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
+ RGBLIGHT_DRIVER ?= WS2812
+
+ ifeq ($(filter $(RGBLIGHT_DRIVER),$(VALID_RGBLIGHT_TYPES)),)
+ $(error RGBLIGHT_DRIVER="$(RGBLIGHT_DRIVER)" is not a valid RGB type)
else
+ POST_CONFIG_H += $(QUANTUM_DIR)/rgblight_post_config.h
+ OPT_DEFS += -DRGBLIGHT_ENABLE
+ SRC += $(QUANTUM_DIR)/color.c
+ SRC += $(QUANTUM_DIR)/rgblight.c
+ CIE1931_CURVE := yes
+ RGB_KEYCODES_ENABLE := yes
+ endif
+
+ ifeq ($(strip $(RGBLIGHT_DRIVER)), WS2812)
WS2812_DRIVER_REQUIRED := yes
endif
-endif
+ ifeq ($(strip $(RGBLIGHT_DRIVER)), APA102)
+ APA102_DRIVER_REQUIRED := yes
+ endif
+
+ ifeq ($(strip $(RGBLIGHT_DRIVER)), custom)
+ OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
+ endif
+endif
LED_MATRIX_ENABLE ?= no
VALID_LED_MATRIX_TYPES := IS31FL3731 custom
@@ -202,7 +247,7 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
$(error "$(RGB_MATRIX_DRIVER)" is not a valid matrix type)
endif
OPT_DEFS += -DRGB_MATRIX_ENABLE
-ifneq (,$(filter $(MCU), atmega16u2 atmega32u2))
+ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
# ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
OPT_DEFS += -DLIB8_ATTINY
endif
@@ -245,6 +290,11 @@ endif
WS2812_DRIVER_REQUIRED := yes
endif
+ ifeq ($(strip $(RGB_MATRIX_DRIVER)), APA102)
+ OPT_DEFS += -DAPA102
+ APA102_DRIVER_REQUIRED := yes
+ endif
+
ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB
endif
@@ -275,12 +325,13 @@ ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
VAPTH += $(SERIAL_PATH)
endif
-ifneq ($(strip $(VARIABLE_TRACE)),)
+VARIABLE_TRACE ?= no
+ifneq ($(strip $(VARIABLE_TRACE)),no)
SRC += $(QUANTUM_DIR)/variable_trace.c
OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
-ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
- OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
-endif
+ ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
+ OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
+ endif
endif
ifeq ($(strip $(LCD_ENABLE)), yes)
@@ -301,10 +352,6 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
$(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
endif
- ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
- CIE1931_CURVE := yes
- endif
-
COMMON_VPATH += $(QUANTUM_DIR)/backlight
SRC += $(QUANTUM_DIR)/backlight/backlight.c
SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
@@ -350,6 +397,11 @@ ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
endif
endif
+ifeq ($(strip $(APA102_DRIVER_REQUIRED)), yes)
+ COMMON_VPATH += $(DRIVER_PATH)/apa102
+ SRC += apa102.c
+endif
+
ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
CIE1931_CURVE := yes
endif
@@ -462,7 +514,7 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
# Determine which (if any) transport files are required
ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
- QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c
+ QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/transport.c
# Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
# Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
ifeq ($(PLATFORM),AVR)
@@ -549,62 +601,6 @@ ifeq ($(strip $(MAGIC_ENABLE)), yes)
OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
endif
-ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
- SRC += $(QUANTUM_DIR)/dip_switch.c
- OPT_DEFS += -DDIP_SWITCH_ENABLE
-endif
-
-VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c
-EEPROM_DRIVER ?= vendor
-ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),)
- $(error EEPROM_DRIVER="$(EEPROM_DRIVER)" is not a valid EEPROM driver)
-else
- OPT_DEFS += -DEEPROM_ENABLE
- ifeq ($(strip $(EEPROM_DRIVER)), custom)
- OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_CUSTOM
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
- SRC += eeprom_driver.c
- else ifeq ($(strip $(EEPROM_DRIVER)), i2c)
- OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_I2C
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
- QUANTUM_LIB_SRC += i2c_master.c
- SRC += eeprom_driver.c eeprom_i2c.c
- else ifeq ($(strip $(EEPROM_DRIVER)), transient)
- OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
- COMMON_VPATH += $(DRIVER_PATH)/eeprom
- SRC += eeprom_driver.c eeprom_transient.c
- else ifeq ($(strip $(EEPROM_DRIVER)), vendor)
- OPT_DEFS += -DEEPROM_VENDOR
- ifeq ($(PLATFORM),AVR)
- # Automatically provided by avr-libc, nothing required
- else ifeq ($(PLATFORM),CHIBIOS)
- ifeq ($(MCU_SERIES), STM32F3xx)
- SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
- SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
- OPT_DEFS += -DEEPROM_EMU_STM32F303xC
- OPT_DEFS += -DSTM32_EEPROM_ENABLE
- else ifeq ($(MCU_SERIES), STM32F1xx)
- SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
- SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
- OPT_DEFS += -DEEPROM_EMU_STM32F103xB
- OPT_DEFS += -DSTM32_EEPROM_ENABLE
- else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F072xB)
- SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
- SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
- OPT_DEFS += -DEEPROM_EMU_STM32F072xB
- OPT_DEFS += -DSTM32_EEPROM_ENABLE
- else
- # This will effectively work the same as "transient" if not supported by the chip
- SRC += $(PLATFORM_COMMON_DIR)/eeprom_teensy.c
- endif
- else ifeq ($(PLATFORM),ARM_ATSAM)
- SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
- else ifeq ($(PLATFORM),TEST)
- SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
- endif
- endif
-endif
-
GRAVE_ESC_ENABLE ?= yes
ifeq ($(strip $(GRAVE_ESC_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_grave_esc.c
@@ -659,3 +655,27 @@ endif
ifeq ($(strip $(JOYSTICK_ENABLE)), digital)
OPT_DEFS += -DDIGITAL_JOYSTICK_ENABLE
endif
+
+USBPD_ENABLE ?= no
+VALID_USBPD_DRIVER_TYPES = custom vendor
+USBPD_DRIVER ?= vendor
+ifeq ($(strip $(USBPD_ENABLE)), yes)
+ ifeq ($(filter $(strip $(USBPD_DRIVER)),$(VALID_USBPD_DRIVER_TYPES)),)
+ $(error USBPD_DRIVER="$(USBPD_DRIVER)" is not a valid USBPD driver)
+ else
+ OPT_DEFS += -DUSBPD_ENABLE
+ ifeq ($(strip $(USBPD_DRIVER)), vendor)
+ # Vendor-specific implementations
+ OPT_DEFS += -DUSBPD_VENDOR
+ ifeq ($(strip $(MCU_SERIES)), STM32G4xx)
+ OPT_DEFS += -DUSBPD_STM32G4
+ SRC += usbpd_stm32g4.c
+ else
+ $(error There is no vendor-provided USBPD driver available)
+ endif
+ else ifeq ($(strip $(USBPD_DRIVER)), custom)
+ OPT_DEFS += -DUSBPD_CUSTOM
+ # Board designers can add their own driver to $(SRC)
+ endif
+ endif
+endif
diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json
new file mode 100644
index 0000000000..b949b13320
--- /dev/null
+++ b/data/mappings/info_config.json
@@ -0,0 +1,46 @@
+# This file maps keys between `config.h` and `info.json`. It is used by QMK
+# to correctly and consistently map back and forth between the two systems.
+{
+ # Format:
+ # <config.h key>: {"info_key": <info.json key>, ["value_type": <value_type>], ["to_json": <true/false>], ["to_c": <true/false>]}
+ # value_type: one of "array", "array.int", "int", "hex", "list", "mapping"
+ # to_json: Default `true`. Set to `false` to exclude this mapping from info.json
+ # to_c: Default `true`. Set to `false` to exclude this mapping from config.h
+ # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places
+ "DEBOUNCE": {"info_key": "debounce", "value_type": "int"}
+ "DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"},
+ "DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false},
+ "DIODE_DIRECTION": {"info_key": "diode_direction"},
+ "LAYOUTS": {"info_key": "layout_aliases", "value_type": "mapping"},
+ "LED_CAPS_LOCK_PIN": {"info_key": "indicators.caps_lock"},
+ "LED_NUM_LOCK_PIN": {"info_key": "indicators.num_lock"},
+ "LED_SCROLL_LOCK_PIN": {"info_key": "indicators.scroll_lock"},
+ "MANUFACTURER": {"info_key": "manufacturer"},
+ "RGB_DI_PIN": {"info_key": "rgblight.pin"},
+ "RGBLED_NUM": {"info_key": "rgblight.led_count", "value_type": "int"},
+ "RGBLED_SPLIT": {"info_key": "rgblight.split_count", "value_type": "array.int"},
+ "RGBLIGHT_ANIMATIONS": {"info_key": "rgblight.animations.all", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_ALTERNATING": {"info_key": "rgblight.animations.alternating", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_BREATHING": {"info_key": "rgblight.animations.breathing", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_CHRISTMAS": {"info_key": "rgblight.animations.christmas", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_KNIGHT": {"info_key": "rgblight.animations.knight", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_RAINBOW_MOOD": {"info_key": "rgblight.animations.rainbow_mood", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_RAINBOW_SWIRL": {"info_key": "rgblight.animations.rainbow_swirl", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_RGB_TEST": {"info_key": "rgblight.animations.rgb_test", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_SNAKE": {"info_key": "rgblight.animations.snake", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_STATIC_GRADIENT": {"info_key": "rgblight.animations.static_gradient", "value_type": "bool"},
+ "RGBLIGHT_EFFECT_TWINKLE": {"info_key": "rgblight.animations.twinkle"},
+ "RGBLIGHT_LIMIT_VAL": {"info_key": "rgblight.max_brightness", "value_type": "int"},
+ "RGBLIGHT_HUE_STEP": {"info_key": "rgblight.hue_steps", "value_type": "int"},
+ "RGBLIGHT_SAT_STEP": {"info_key": "rgblight.saturation_steps", "value_type": "int"},
+ "RGBLIGHT_VAL_STEP": {"info_key": "rgblight.brightness_steps", "value_type": "int"},
+ "RGBLIGHT_SLEEP": {"info_key": "rgblight.sleep", "value_type": "bool"},
+ "RGBLIGHT_SPLIT": {"info_key": "rgblight.split", "value_type": "bool"},
+ "PRODUCT": {"info_key": "keyboard_folder", "to_json": false},
+ "PRODUCT_ID": {"info_key": "usb.pid", "value_type": "hex"},
+ "VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex"},
+ "QMK_ESC_OUTPUT": {"info_key": "qmk_lufa_bootloader.esc_output"},
+ "QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"},
+ "QMK_LED": {"info_key": "qmk_lufa_bootloader.led"},
+ "QMK_SPEAKER": {"info_key": "qmk_lufa_bootloader.speaker"}
+}
diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json
new file mode 100644
index 0000000000..97f772c4d5
--- /dev/null
+++ b/data/mappings/info_rules.json
@@ -0,0 +1,15 @@
+# This file maps keys between `rules.mk` and `info.json`. It is used by QMK
+# to correctly and consistently map back and forth between the two systems.
+{
+ # Format:
+ # <rules.mk key>: {"info_key": <info.json key>, ["value_type": <value_type>], ["to_json": <true/false>], ["to_c": <true/false>]}
+ # value_type: one of "array", "array.int", "int", "list", "hex", "mapping"
+ # to_json: Default `true`. Set to `false` to exclude this mapping from info.json
+ # to_c: Default `true`. Set to `false` to exclude this mapping from rules.mk
+ # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places
+ "BOARD": {"info_key": "board"},
+ "BOOTLOADER": {"info_key": "bootloader", "warn_duplicate": false},
+ "LAYOUTS": {"info_key": "community_layouts", "value_type": "list"},
+ "LED_MATRIX_DRIVER": {"info_key": "led_matrix.driver"},
+ "MCU": {"info_key": "processor", "warn_duplicate": false},
+}
diff --git a/data/mappings/keyboard_aliases.json b/data/mappings/keyboard_aliases.json
new file mode 100644
index 0000000000..5a2f7e3ae8
--- /dev/null
+++ b/data/mappings/keyboard_aliases.json
@@ -0,0 +1,443 @@
+{
+ # Format for each entry:
+ # <alias>: {
+ # target: <keyboard_folder>,
+ # layouts: {
+ # <layout_alias>: <layout_target>
+ # }
+ # }
+ #
+ # Both target and layouts are optional.
+ '2_milk': {
+ target: 'spaceman/2_milk'
+ },
+ 'aeboards/ext65': {
+ target: 'aeboards/ext65/rev1'
+ },
+ 'ai03/equinox': {
+ target: 'ai03/equinox/rev1'
+ },
+ aleth42: {
+ target: 'aleth42/rev1'
+ },
+ alice: {
+ target: 'tgr/alice'
+ },
+ angel17: {
+ target: 'angel17/alpha'
+ },
+ angel64: {
+ target: 'angel64/alpha'
+ },
+ at101_blackheart: {
+ target: 'at101_bh'
+ },
+ 'atom47/rev2': {
+ target: 'maartenwut/atom47/rev2'
+ },
+ 'atom47/rev3': {
+ target: 'maartenwut/atom47/rev3'
+ },
+ bear_face: {
+ target: 'bear_face/v1'
+ },
+ 'bpiphany/pegasushoof': {
+ target: 'bpiphany/pegasushoof/2013'
+ },
+ chavdai40: {
+ target: 'chavdai40/rev1'
+ },
+ 'candybar/lefty': {
+ target: 'tkc/candybar/lefty'
+ },
+ 'candybar/righty': {
+ target: 'tkc/candybar/righty'
+ },
+ canoe: {
+ target: 'percent/canoe'
+ },
+ 'cmm_studio/saka68': {
+ target: 'cmm_studio/saka68/solder'
+ },
+ 'crkbd/rev1': {
+ target: 'crkbd/rev1/legacy'
+ },
+ 'doro67/multi': {
+ layouts: {
+ LAYOUT_ansi: 'LAYOUT_65_ansi_blocker'
+ }
+ },
+ 'doro67/regular': {
+ layouts: {
+ LAYOUT: 'LAYOUT_65_ansi_blocker'
+ }
+ },
+ 'doro67/rgb': {
+ layouts: {
+ LAYOUT: 'LAYOUT_65_ansi_blocker'
+ }
+ },
+ drakon: {
+ target: 'jagdpietr/drakon'
+ },
+ 'dztech/dz60rgb': {
+ target: 'dztech/dz60rgb/v1'
+ },
+ 'dztech/dz60rgb_ansi': {
+ target: 'dztech/dz60rgb_ansi/v1'
+ },
+ 'dztech/dz60rgb_wkl': {
+ target: 'dztech/dz60rgb_wkl/v1'
+ },
+ 'dztech/dz65rgb': {
+ target: 'dztech/dz65rgb/v1'
+ },
+ eek: {
+ target: 'eek/silk_down'
+ },
+ ergoinu: {
+ target: 'dm9records/ergoinu'
+ },
+ 'exclusive/e85': {
+ target: 'exclusive/e85/hotswap'
+ },
+ gh60: {
+ target: 'gh60/revc'
+ },
+ 'handwired/ferris': {
+ target: 'ferris/0_1'
+ },
+ 'helix/pico/sc/back': {
+ target: 'helix/pico/sc'
+ },
+ 'helix/pico/sc/under': {
+ target: 'helix/pico/sc'
+ },
+ 'helix/rev2/back/oled': {
+ target: 'helix/rev2/back'
+ },
+ 'helix/rev2/oled': {
+ target: 'helix/rev2'
+ },
+ 'helix/rev2/oled/back': {
+ target: 'helix/rev2/back'
+ },
+ 'helix/rev2/oled/under': {
+ target: 'helix/rev2/under'
+ },
+ 'helix/rev2/sc/back': {
+ target: 'helix/rev2/sc'
+ },
+ 'helix/rev2/sc/oled': {
+ target: 'helix/rev2/sc'
+ },
+ 'helix/rev2/sc/oledback': {
+ target: 'helix/rev2/sc'
+ },
+ 'helix/rev2/sc/oledunder': {
+ target: 'helix/rev2/sc'
+ },
+ 'helix/rev2/sc/under': {
+ target: 'helix/rev2/sc'
+ },
+ 'helix/rev2/under': {
+ target: 'helix/rev2/sc'
+ },
+ 'helix/rev2/under/oled': {
+ target: 'helix/rev2/under'
+ },
+ id80: {
+ target: 'id80/ansi'
+ },
+ idb_60: {
+ target: 'idb/idb_60',
+ layouts: {
+ LAYOUT: 'LAYOUT_all'
+ }
+ },
+ jones: {
+ target: 'jones/v03_1'
+ },
+ katana60: {
+ target: 'rominronin/katana60/rev1'
+ },
+ 'kbdfans/kbd67mkiirgb': {
+ target: 'kbdfans/kbd67/mkiirgb',
+ layouts: {
+ LAYOUT: 'LAYOUT_65_ansi_blocker'
+ }
+ },
+ 'kbdfans/kbd67/mkiirgb': {
+ target: 'kbdfans/kbd67/mkiirgb/v1'
+ },
+ 'keebio/dsp40': {
+ target: 'keebio/dsp40/rev1'
+ },
+ 'keycapsss/plaid_pad': {
+ target: 'keycapsss/plaid_pad/rev1'
+ },
+ kudox: {
+ target: 'kudox/rev1'
+ },
+ 'lfkeyboards/lfk78': {
+ target: 'lfkeyboards/lfk78/revj'
+ },
+ 'lfkeyboards/smk65': {
+ target: 'lfkeyboards/smk65/revb'
+ },
+ 'maartenwut/atom47/rev2': {
+ target: 'evyd13/atom47/rev2'
+ },
+ 'maartenwut/atom47/rev3': {
+ target: 'evyd13/atom47/rev3'
+ },
+ 'maartenwut/eon40': {
+ target: 'evyd13/eon40'
+ },
+ 'maartenwut/eon65': {
+ target: 'evyd13/eon65'
+ },
+ 'maartenwut/eon75': {
+ target: 'evyd13/eon75'
+ },
+ 'maartenwut/eon87': {
+ target: 'evyd13/eon87'
+ },
+ 'maartenwut/eon95': {
+ target: 'evyd13/eon95'
+ },
+ 'maartenwut/gh80_1800': {
+ target: 'evyd13/gh80_1800'
+ },
+ 'maartenwut/gh80_3700': {
+ target: 'evyd13/gh80_3700'
+ },
+ 'maartenwut/minitomic': {
+ target: 'evyd13/minitomic'
+ },
+ 'maartenwut/mx5160': {
+ target: 'evyd13/mx5160'
+ },
+ 'maartenwut/nt660': {
+ target: 'evyd13/nt660'
+ },
+ 'maartenwut/omrontkl': {
+ target: 'evyd13/omrontkl'
+ },
+ 'maartenwut/plain60': {
+ target: 'evyd13/plain60'
+ },
+ 'maartenwut/pockettype': {
+ target: 'evyd13/pockettype'
+ },
+ 'maartenwut/quackfire': {
+ target: 'evyd13/quackfire'
+ },
+ 'maartenwut/solheim68': {
+ target: 'evyd13/solheim68'
+ },
+ 'maartenwut/ta65': {
+ target: 'evyd13/ta65'
+ },
+ 'maartenwut/wasdat': {
+ target: 'evyd13/wasdat'
+ },
+ 'maartenwut/wasdat_code': {
+ target: 'evyd13/wasdat_code'
+ },
+ 'maartenwut/wonderland': {
+ target: 'evyd13/wonderland'
+ },
+ 'mechlovin/hannah910': {
+ target: 'mechlovin/hannah910/rev1'
+ },
+ 'mechlovin/adelais/rgb_led': {
+ target: 'mechlovin/adelais/rgb_led/rev1'
+ },
+ 'mechlovin/adelais/standard_led': {
+ target: 'mechlovin/adelais/standard_led/rev2'
+ },
+ 'mechlovin/delphine': {
+ target: 'mechlovin/delphine/mono_led'
+ },
+ 'mechlovin/hannah60rgb': {
+ target: 'mechlovin/hannah60rgb/rev1'
+ },
+ 'melgeek/z70ultra': {
+ target: 'melgeek/z70ultra/rev1'
+ },
+ 'mechlovin/hannah65': {
+ target: 'mechlovin/hannah65/rev1'
+ },
+ model01: {
+ target: 'keyboardio/model01'
+ },
+ m0lly: {
+ target: 'tkc/m0lly'
+ },
+ 'montsinger/rebound': {
+ target: 'montsinger/rebound/rev1'
+ },
+ nomu30: {
+ target: 'nomu30/rev1'
+ },
+ 'noxary/268_2': {
+ layouts: {
+ LAYOUT: 'LAYOUT_65_ansi_blocker'
+ }
+ },
+ oddball: {
+ target: 'oddball/v1'
+ },
+ omnikey_blackheart: {
+ target: 'omnikey_bh'
+ },
+ 'pabile/p20': {
+ target: 'pabile/p20/ver1'
+ },
+ 'pancake/feather': {
+ target: 'spaceman/pancake/feather'
+ },
+ 'pancake/promicro': {
+ target: 'spaceman/pancake/promicro'
+ },
+ 'percent/canoe': {
+ layouts: {
+ LAYOUT_iso: 'LAYOUT_65_iso_blocker'
+ }
+ },
+ plaid: {
+ target: 'dm9records/plaid'
+ },
+ plain60: {
+ target: 'maartenwut/plain60'
+ },
+ 'ploopyco/trackball': {
+ target: 'ploopyco/trackball/rev1_005'
+ },
+ polilla: {
+ target: 'polilla/rev1'
+ },
+ 'preonic/rev1': {
+ layouts: {
+ LAYOUT_preonic_grid: 'LAYOUT_ortho_5x12'
+ }
+ },
+ 'preonic/rev2': {
+ layouts: {
+ LAYOUT_preonic_grid: 'LAYOUT_ortho_5x12'
+ }
+ },
+ 'preonic/rev3': {
+ layouts: {
+ LAYOUT_preonic_grid: 'LAYOUT_ortho_5x12'
+ }
+ },
+ 'primekb/prime_l': {
+ target: 'primekb/prime_l/v1'
+ },
+ 'primekb/prime_l_v2': {
+ target: 'primekb/prime_l/v2'
+ },
+ 'projectkb/alice': {
+ target: 'projectkb/alice/rev1'
+ },
+ 'rama/koyu': {
+ target: 'wilba_tech/rama_works_koyu'
+ },
+ 'rama/m6_a': {
+ target: 'wilba_tech/rama_works_m6_a'
+ },
+ 'rama/m6_b': {
+ target: 'wilba_tech/rama_works_m6_b'
+ },
+ 'rama/m10_b': {
+ target: 'wilba_tech/rama_works_m10_b'
+ },
+ 'rama/m60_a': {
+ target: 'wilba_tech/rama_works_m60_a'
+ },
+ 'rama/u80_a': {
+ target: 'wilba_tech/rama_works_u80_a'
+ },
+ 'ramonimbao/herringbone': {
+ target: 'ramonimbao/herringbone/v1'
+ },
+ 'rgbkb/pan': {
+ target: 'rgbkb/pan/rev1/32a'
+ },
+ 'rgbkb/pan/rev1': {
+ target: 'rgbkb/pan/rev1/32a'
+ },
+ romac: {
+ target: 'kingly_keys/romac'
+ },
+ ropro: {
+ target: 'kingly_keys/ropro'
+ },
+ satan: {
+ target: 'gh60/satan'
+ },
+ skog: {
+ target: 'percent/skog'
+ },
+ speedo: {
+ target: 'cozykeys/speedo/v2'
+ },
+ stoutgat: {
+ target: 'tkw/stoutgat/v1'
+ },
+ suihankey: {
+ target: 'suihankey/split/alpha'
+ },
+ ta65: {
+ target: 'maartenwut/ta65'
+ },
+ tartan: {
+ target: 'dm9records/tartan'
+ },
+ tkc1800: {
+ target: 'tkc/tkc1800'
+ },
+ 'tkw/stoutgat/v2': {
+ target: 'tkw/stoutgat/v2/f411'
+ },
+ underscore33: {
+ target: 'underscore33/rev1'
+ },
+ vinta: {
+ layouts: {
+ LAYOUT_67_ansi: 'LAYOUT_65_ansi_blocker'
+ }
+ },
+ wasdat: {
+ target: 'maartenwut/wasdat'
+ },
+ 'westfoxtrot/cypher': {
+ target: 'westfoxtrot/cypher/rev1'
+ },
+ 'whale/sk': {
+ target: 'whale/sk/v3'
+ },
+ 'xelus/dawn60': {
+ target: 'xelus/dawn60/rev1'
+ },
+ 'xelus/valor': {
+ target: 'xelus/valor/rev1'
+ },
+ yd60mq: {
+ target: 'yd60mq/12led'
+ },
+ ymd75: {
+ target: 'ymd75/rev1'
+ },
+ z150_blackheart: {
+ target: 'z150_bh'
+ },
+ zeal60: {
+ target: 'wilba_tech/zeal60'
+ },
+ zeal65: {
+ target: 'wilba_tech/zeal65'
+ }
+}
diff --git a/data/schemas/api_keyboard.jsonschema b/data/schemas/api_keyboard.jsonschema
new file mode 100644
index 0000000000..d570ee9990
--- /dev/null
+++ b/data/schemas/api_keyboard.jsonschema
@@ -0,0 +1,35 @@
+{
+ "allOf": [
+ { "$ref": "qmk.keyboard.v1" },
+ {
+ "$id": "qmk.api.keyboard.v1",
+ "keymaps": {
+ "type": "string"
+ },
+ "parse_errors": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "parse_warnings": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "processor_type": {
+ "type": "string"
+ },
+ "protocol": {
+ "type": "string"
+ },
+ "keyboard_folder": {
+ "type": "string"
+ },
+ "platform": {
+ "type": "string"
+ }
+ }
+ ]
+}
diff --git a/data/schemas/false.jsonschema b/data/schemas/false.jsonschema
new file mode 100644
index 0000000000..c508d5366f
--- /dev/null
+++ b/data/schemas/false.jsonschema
@@ -0,0 +1 @@
+false
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema
new file mode 100644
index 0000000000..ec03a8828b
--- /dev/null
+++ b/data/schemas/keyboard.jsonschema
@@ -0,0 +1,326 @@
+{
+ "$schema": "http://json-schema.org/schema#",
+ "$id": "qmk.keyboard.v1",
+ "title": "Keyboard Information",
+ "type": "object",
+ "properties": {
+ "keyboard_name": {
+ "type": "string",
+ "minLength": 2,
+ "maxLength": 250
+ },
+ "maintainer": {
+ "type": "string",
+ "minLength": 2,
+ "maxLength": 250
+ },
+ "manufacturer": {
+ "type": "string",
+ "minLength": 2,
+ "maxLength": 250
+ },
+ "url": {
+ "type": "string",
+ "format": "uri"
+ },
+ "processor": {
+ "type": "string",
+ "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F411", "STM32G431", "STM32G474", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
+ },
+ "board": {
+ "type": "string",
+ "minLength": 2,
+ "pattern": "^[a-zA-Z_][0-9a-zA-Z_]*$"
+ },
+ "bootloader": {
+ "type": "string",
+ "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "stm32-dfu", "stm32duino", "unknown", "USBasp"]
+ },
+ "diode_direction": {
+ "type": "string",
+ "enum": ["COL2ROW", "ROW2COL"]
+ },
+ "debounce": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ },
+ "height": {
+ "type": "number",
+ "min": 0.25
+ },
+ "width": {
+ "type": "number",
+ "min": 0.25
+ },
+ "community_layouts": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 2,
+ "pattern": "^[0-9a-z_]*$"
+ }
+ },
+ "features": {
+ "type": "object",
+ "additionalProperties": {"type": "boolean"}
+ },
+ "indicators": {
+ "type": "object",
+ "properties": {
+ "caps_lock": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ "num_lock": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ "scroll_lock": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ }
+ }
+ },
+ "layout_aliases": {
+ "type": "object",
+ "additionalProperties": {
+ "oneOf": [
+ {
+ "type": "string",
+ "enum": ["LAYOUT", "LAYOUT_planck_1x2uC"]
+ },
+ {
+ "type": "string",
+ "pattern": "^LAYOUT_[0-9a-z_]*$"
+ }
+ ]
+ }
+ },
+ "layouts": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "filename": {
+ "type": "string"
+ },
+ "c_macro": {
+ "type": "boolean"
+ },
+ "key_count": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ },
+ "layout": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "label": {"type": "string"},
+ "matrix": {
+ "type": "array",
+ "minItems": 2,
+ "maxItems": 2,
+ "items": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ }
+ },
+ "h": {
+ "type": "number",
+ "min": 0.25
+ },
+ "r": {
+ "type": "number",
+ "min": 0
+ },
+ "rx": {
+ "type": "number",
+ "min": 0
+ },
+ "ry": {
+ "type": "number",
+ "min": 0
+ },
+ "w": {
+ "type": "number",
+ "min": 0.25
+ },
+ "x": {
+ "type": "number",
+ "min": 0
+ },
+ "y": {
+ "type": "number",
+ "min": 0
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "matrix_pins": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "direct": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "oneOf": [
+ {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ {
+ "type": "number",
+ "multipleOf": 1
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ }
+ },
+ "cols": {
+ "type": "array",
+ "items": {
+ "oneOf": [
+ {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ {
+ "type": "number",
+ "multipleOf": 1
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "rows": {
+ "type": "array",
+ "items": {
+ "oneOf": [
+ {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ {
+ "type": "number",
+ "multipleOf": 1
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "rgblight": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "animations": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "boolean"
+ }
+ },
+ "brightness_steps": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ },
+ "hue_steps": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ },
+ "led_count": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ },
+ "max_brightness": {
+ "type": "number",
+ "min": 0,
+ "max": 255,
+ "multipleOf": 1
+ },
+ "pin": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ "saturation_steps": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ },
+ "sleep": {"type": "boolean"},
+ "split": {"type": "boolean"},
+ "split_count": {
+ "type": "array",
+ "minLength": 2,
+ "maxLength": 2,
+ "items": {
+ "type": "number",
+ "min": 0,
+ "multipleOf": 1
+ }
+ }
+ }
+ },
+ "usb": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "device_ver": {
+ "type": "string",
+ "pattern": "^[0-9A-F]x[0-9A-F][0-9A-F][0-9A-F][0-9A-F]"
+ },
+ "pid": {
+ "type": "string",
+ "pattern": "^[0-9A-F]x[0-9A-F][0-9A-F][0-9A-F][0-9A-F]"
+ },
+ "vid": {
+ "type": "string",
+ "pattern": "^[0-9A-F]x[0-9A-F][0-9A-F][0-9A-F][0-9A-F]"
+ }
+ }
+ },
+ "qmk_lufa_bootloader": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "esc_output": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ "esc_input": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ "led": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ },
+ "speaker": {
+ "type": "string",
+ "pattern": "^[A-K]\\d{1,2}$"
+ }
+ }
+ }
+ }
+}
diff --git a/data/schemas/true.jsonschema b/data/schemas/true.jsonschema
new file mode 100644
index 0000000000..27ba77ddaf
--- /dev/null
+++ b/data/schemas/true.jsonschema
@@ -0,0 +1 @@
+true
diff --git a/disable_features.mk b/disable_features.mk
new file mode 100644
index 0000000000..84d8316eac
--- /dev/null
+++ b/disable_features.mk
@@ -0,0 +1,31 @@
+# Unconditionally disable features that a keyboard advertises it doesn't support
+
+FEATURE_NAMES :=
+FEATURE_NAMES += ADAFRUIT_BLE
+FEATURE_NAMES += AUDIO
+FEATURE_NAMES += BACKLIGHT
+FEATURE_NAMES += BLUETOOTH
+FEATURE_NAMES += DIP_SWITCH
+FEATURE_NAMES += DYNAMIC_KEYMAP
+FEATURE_NAMES += ENCODER
+FEATURE_NAMES += HAPTIC
+FEATURE_NAMES += HD44780
+FEATURE_NAMES += IOS_DEVICE
+FEATURE_NAMES += LCD_BACKLIGHT
+FEATURE_NAMES += LCD
+FEATURE_NAMES += OLED
+FEATURE_NAMES += POINTING_DEVICE
+FEATURE_NAMES += PRINTING
+FEATURE_NAMES += PS2_MOUSE
+FEATURE_NAMES += RGBLIGHT
+FEATURE_NAMES += RGB_MATRIX
+FEATURE_NAMES += SLEEP_LED
+FEATURE_NAMES += SERIAL_LINK
+FEATURE_NAMES += STENO
+FEATURE_NAMES += SWAP_HANDS
+FEATURE_NAMES += VISUALIZER
+FEATURE_NAMES += WATCHDOG
+FEATURE_NAMES += XT
+
+$(foreach AFEATURE,$(FEATURE_NAMES),\
+ $(if $(filter $($(AFEATURE)_SUPPORTED),no),$(eval $(AFEATURE)_ENABLE=no)))
diff --git a/drivers/apa102/apa102.c b/drivers/apa102/apa102.c
new file mode 100644
index 0000000000..7396dc3c55
--- /dev/null
+++ b/drivers/apa102/apa102.c
@@ -0,0 +1,151 @@
+/* Copyright 2020 Aldehir Rojas
+ * Copyright 2017 Mikkel (Duckle29)
+ *
+ * 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 "apa102.h"
+#include "quantum.h"
+
+#ifndef APA102_NOPS
+# if defined(__AVR__)
+# define APA102_NOPS 0 // AVR at 16 MHz already spends 62.5 ns per clock, so no extra delay is needed
+# elif defined(PROTOCOL_CHIBIOS)
+
+# include "hal.h"
+# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX)
+# define APA102_NOPS (100 / (1000000000L / (STM32_SYSCLK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns
+# else
+# error("APA102_NOPS configuration required")
+# define APA102_NOPS 0 // this just pleases the compile so the above error is easier to spot
+# endif
+# endif
+#endif
+
+#define io_wait \
+ do { \
+ for (int i = 0; i < APA102_NOPS; i++) { \
+ __asm__ volatile("nop\n\t" \
+ "nop\n\t" \
+ "nop\n\t" \
+ "nop\n\t"); \
+ } \
+ } while (0)
+
+#define APA102_SEND_BIT(byte, bit) \
+ do { \
+ writePin(RGB_DI_PIN, (byte >> bit) & 1); \
+ io_wait; \
+ writePinHigh(RGB_CI_PIN); \
+ io_wait; \
+ writePinLow(RGB_CI_PIN); \
+ io_wait; \
+ } while (0)
+
+uint8_t apa102_led_brightness = APA102_DEFAULT_BRIGHTNESS;
+
+void static apa102_start_frame(void);
+void static apa102_end_frame(uint16_t num_leds);
+
+void static apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness);
+void static apa102_send_byte(uint8_t byte);
+
+void apa102_setleds(LED_TYPE *start_led, uint16_t num_leds) {
+ LED_TYPE *end = start_led + num_leds;
+
+ apa102_start_frame();
+ for (LED_TYPE *led = start_led; led < end; led++) {
+ apa102_send_frame(led->r, led->g, led->b, apa102_led_brightness);
+ }
+ apa102_end_frame(num_leds);
+}
+
+// Overwrite the default rgblight_call_driver to use apa102 driver
+void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { apa102_setleds(start_led, num_leds); }
+
+void static apa102_init(void) {
+ setPinOutput(RGB_DI_PIN);
+ setPinOutput(RGB_CI_PIN);
+
+ writePinLow(RGB_DI_PIN);
+ writePinLow(RGB_CI_PIN);
+}
+
+void apa102_set_brightness(uint8_t brightness) {
+ if (brightness > APA102_MAX_BRIGHTNESS) {
+ apa102_led_brightness = APA102_MAX_BRIGHTNESS;
+ } else if (brightness < 0) {
+ apa102_led_brightness = 0;
+ } else {
+ apa102_led_brightness = brightness;
+ }
+}
+
+void static apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) {
+ apa102_send_byte(0b11100000 | brightness);
+ apa102_send_byte(blue);
+ apa102_send_byte(green);
+ apa102_send_byte(red);
+}
+
+void static apa102_start_frame(void) {
+ apa102_init();
+ for (uint16_t i = 0; i < 4; i++) {
+ apa102_send_byte(0);
+ }
+}
+
+void static apa102_end_frame(uint16_t num_leds) {
+ // This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h
+ // and adapted. The code is MIT licensed. I think thats compatible?
+ //
+ // The data stream seen by the last LED in the chain will be delayed by
+ // (count - 1) clock edges, because each LED before it inverts the clock
+ // line and delays the data by one clock edge. Therefore, to make sure
+ // the last LED actually receives the data we wrote, the number of extra
+ // edges we send at the end of the frame must be at least (count - 1).
+ //
+ // Assuming we only want to send these edges in groups of size K, the
+ // C/C++ expression for the minimum number of groups to send is:
+ //
+ // ((count - 1) + (K - 1)) / K
+ //
+ // The C/C++ expression above is just (count - 1) divided by K,
+ // rounded up to the nearest whole number if there is a remainder.
+ //
+ // We set K to 16 and use the formula above as the number of frame-end
+ // bytes to transfer. Each byte has 16 clock edges.
+ //
+ // We are ignoring the specification for the end frame in the APA102
+ // datasheet, which says to send 0xFF four times, because it does not work
+ // when you have 66 LEDs or more, and also it results in unwanted white
+ // pixels if you try to update fewer LEDs than are on your LED strip.
+ uint16_t iterations = (num_leds + 14) / 16;
+ for (uint16_t i = 0; i < iterations; i++) {
+ apa102_send_byte(0);
+ }
+
+ apa102_init();
+}
+
+void static apa102_send_byte(uint8_t byte) {
+ APA102_SEND_BIT(byte, 7);
+ APA102_SEND_BIT(byte, 6);
+ APA102_SEND_BIT(byte, 5);
+ APA102_SEND_BIT(byte, 4);
+ APA102_SEND_BIT(byte, 3);
+ APA102_SEND_BIT(byte, 2);
+ APA102_SEND_BIT(byte, 1);
+ APA102_SEND_BIT(byte, 0);
+}
diff --git a/drivers/avr/apa102.h b/drivers/apa102/apa102.h
index d4c1e18ee1..58cf020c1e 100644
--- a/drivers/avr/apa102.h
+++ b/drivers/apa102/apa102.h
@@ -1,10 +1,5 @@
-/*
- * light weight WS2812 lib include
- *
- * Version 2.3 - Nev 29th 2015
- * Author: Tim (cpldcpu@gmail.com)
- *
- * Please do not change this file! All configuration is handled in "ws2812_config.h"
+/* Copyright 2020 Aldehir Rojas
+ * Copyright 2017 Mikkel (Duckle29)
*
* 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
@@ -22,24 +17,25 @@
#pragma once
-#include <avr/io.h>
-#include <avr/interrupt.h>
-
#include "color.h"
+#ifndef APA102_DEFAULT_BRIGHTNESS
+# define APA102_DEFAULT_BRIGHTNESS 31
+#endif
+
+#define APA102_MAX_BRIGHTNESS 31
+
+extern uint8_t apa102_led_brightness;
+
/* User Interface
*
* Input:
- * ledarray: An array of GRB data describing the LED colors
- * number_of_leds: The number of LEDs to write
- * pinmask (optional): Bitmask describing the output bin. e.g. _BV(PB0)
+ * start_led: An array of GRB data describing the LED colors
+ * num_leds: The number of LEDs to write
*
* The functions will perform the following actions:
* - Set the data-out pin as output
* - Send out the LED data
- * - Wait 50�s to reset the LEDs
*/
-
-void apa102_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
-void apa102_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
-void apa102_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
+void apa102_setleds(LED_TYPE *start_led, uint16_t num_leds);
+void apa102_set_brightness(uint8_t brightness);
diff --git a/drivers/avr/serial.c b/drivers/avr/serial.c
index d161b249cc..84365fe8f4 100644
--- a/drivers/avr/serial.c
+++ b/drivers/avr/serial.c
@@ -17,11 +17,10 @@
#include <stddef.h>
#include <stdbool.h>
#include "serial.h"
-//#include <pro_micro.h>
#ifdef SOFT_SERIAL_PIN
-# if !(defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+# if !(defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
# error serial.c is not supported for the currently selected MCU
# endif
// if using ATmega32U4/2, AT90USBxxx I2C, can not use PD0 and PD1 in soft serial.
@@ -53,8 +52,13 @@
# define EICRx EICRA
# endif
+<<<<<<< HEAD
// ATmegaxxU2 specific config
# if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)
+=======
+// ATmegaxxU2/AT90USB162 specific config
+# if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_AT90USB162__)
+>>>>>>> 0.12.52~1
// PD4(INT5), PD6(INT6), PD7(INT7), PC7(INT4)
# if SOFT_SERIAL_PIN == D4
# define EIMSK_BIT _BV(INT5)
diff --git a/drivers/avr/spi_master.c b/drivers/avr/spi_master.c
index cbec9f36e1..19ca0ced44 100644
--- a/drivers/avr/spi_master.c
+++ b/drivers/avr/spi_master.c
@@ -20,7 +20,7 @@
#include "quantum.h"
#include "timer.h"
-#if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
# define SPI_SCK_PIN B1
# define SPI_MOSI_PIN B2
# define SPI_MISO_PIN B3
diff --git a/drivers/avr/spi_master.h b/drivers/avr/spi_master.h
index e36a7c21c0..9203698dd5 100644
--- a/drivers/avr/spi_master.h
+++ b/drivers/avr/spi_master.h
@@ -21,7 +21,7 @@
typedef int16_t spi_status_t;
// Hardware SS pin is defined in the header so that user code can refer to it
-#if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
# define SPI_SS_PIN B0
#elif defined(__AVR_ATmega32A__)
# define SPI_SS_PIN B4
diff --git a/drivers/avr/ssd1306.c b/drivers/avr/ssd1306.c
index 205f749502..1a09a2bcb7 100644
--- a/drivers/avr/ssd1306.c
+++ b/drivers/avr/ssd1306.c
@@ -11,6 +11,8 @@
# include "sendchar.h"
# include "timer.h"
+struct CharacterMatrix display;
+
// Set this to 1 to help diagnose early startup problems
// when testing power-on with ble. Turn it off otherwise,
// as the latency of printing most of the debug info messes
diff --git a/drivers/avr/ssd1306.h b/drivers/avr/ssd1306.h
index dd5957c111..6eecdcfaa4 100644
--- a/drivers/avr/ssd1306.h
+++ b/drivers/avr/ssd1306.h
@@ -65,7 +65,7 @@ struct CharacterMatrix {
bool dirty;
};
-struct CharacterMatrix display;
+extern struct CharacterMatrix display;
bool iota_gfx_init(void);
void iota_gfx_task(void);
diff --git a/tmk_core/common/uart.c b/drivers/avr/uart.c
index 150e256c8f..c6abcb6fe0 100644
--- a/tmk_core/common/uart.c
+++ b/drivers/avr/uart.c
@@ -1,5 +1,3 @@
-// TODO: Teensy support(ATMega32u4/AT90USB128)
-// Fixed for Arduino Duemilanove ATmega168p by Jun Wako
/* UART Example for Teensy USB Development Board
* http://www.pjrc.com/teensy/
* Copyright (c) 2009 PJRC.COM, LLC
@@ -31,22 +29,7 @@
#include "uart.h"
-#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
-# define UDRn UDR0
-# define UBRRnL UBRR0L
-# define UCSRnA UCSR0A
-# define UCSRnB UCSR0B
-# define UCSRnC UCSR0C
-# define U2Xn U2X0
-# define RXENn RXEN0
-# define TXENn TXEN0
-# define RXCIEn RXCIE0
-# define UCSZn1 UCSZ01
-# define UCSZn0 UCSZ00
-# define UDRIEn UDRIE0
-# define USARTn_UDRE_vect USART_UDRE_vect
-# define USARTn_RX_vect USART_RX_vect
-#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
# define UDRn UDR1
# define UBRRnL UBRR1L
# define UCSRnA UCSR1A
@@ -76,6 +59,21 @@
# define UDRIEn UDRIE
# define USARTn_UDRE_vect USART_UDRE_vect
# define USARTn_RX_vect USART_RX_vect
+#elif defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
+# define UDRn UDR0
+# define UBRRnL UBRR0L
+# define UCSRnA UCSR0A
+# define UCSRnB UCSR0B
+# define UCSRnC UCSR0C
+# define U2Xn U2X0
+# define RXENn RXEN0
+# define TXENn TXEN0
+# define RXCIEn RXCIE0
+# define UCSZn1 UCSZ01
+# define UCSZn0 UCSZ00
+# define UDRIEn UDRIE0
+# define USARTn_UDRE_vect USART_UDRE_vect
+# define USARTn_RX_vect USART_RX_vect
#endif
// These buffers may be any size from 2 to 256 bytes.
@@ -131,16 +129,16 @@ uint8_t uart_getchar(void) {
return c;
}
-// Return the number of bytes waiting in the receive buffer.
+// Return whether the number of bytes waiting in the receive buffer is nonzero.
// Call this before uart_getchar() to check if it will need
// to wait for a byte to arrive.
-uint8_t uart_available(void) {
+bool uart_available(void) {
uint8_t head, tail;
head = rx_buffer_head;
tail = rx_buffer_tail;
- if (head >= tail) return head - tail;
- return RX_BUFFER_SIZE + head - tail;
+ if (head >= tail) return (head - tail) > 0;
+ return (RX_BUFFER_SIZE + head - tail) > 0;
}
// Transmit Interrupt
diff --git a/drivers/avr/uart.h b/drivers/avr/uart.h
new file mode 100644
index 0000000000..602eb3d8b0
--- /dev/null
+++ b/drivers/avr/uart.h
@@ -0,0 +1,35 @@
+/* UART Example for Teensy USB Development Board
+ * http://www.pjrc.com/teensy/
+ * Copyright (c) 2009 PJRC.COM, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+void uart_init(uint32_t baud);
+
+void uart_putchar(uint8_t c);
+
+uint8_t uart_getchar(void);
+
+bool uart_available(void);
diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c
index dd2ef89912..77c492cd4c 100644
--- a/drivers/avr/ws2812.c
+++ b/drivers/avr/ws2812.c
@@ -67,19 +67,27 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) {
#define w_onecycles (((F_CPU / 1000) * w_onepulse + 500000) / 1000000)
#define w_totalcycles (((F_CPU / 1000) * w_totalperiod + 500000) / 1000000)
-// w1 - nops between rising edge and falling edge - low
-#define w1 (w_zerocycles - w_fixedlow)
-// w2 nops between fe low and fe high
-#define w2 (w_onecycles - w_fixedhigh - w1)
-// w3 nops to complete loop
-#define w3 (w_totalcycles - w_fixedtotal - w1 - w2)
-
-#if w1 > 0
-# define w1_nops w1
+// w1_nops - nops between rising edge and falling edge - low
+#if w_zerocycles >= w_fixedlow
+# define w1_nops (w_zerocycles - w_fixedlow)
#else
# define w1_nops 0
#endif
+// w2_nops - nops between fe low and fe high
+#if w_onecycles >= (w_fixedhigh + w1_nops)
+# define w2_nops (w_onecycles - w_fixedhigh - w1_nops)
+#else
+# define w2_nops 0
+#endif
+
+// w3_nops - nops to complete loop
+#if w_totalcycles >= (w_fixedtotal + w1_nops + w2_nops)
+# define w3_nops (w_totalcycles - w_fixedtotal - w1_nops - w2_nops)
+#else
+# define w3_nops 0
+#endif
+
// The only critical timing parameter is the minimum pulse length of the "0"
// Warn or throw error if this timing can not be met with current F_CPU settings.
#define w_lowtime ((w1_nops + w_fixedlow) * 1000000) / (F_CPU / 1000)
@@ -90,18 +98,6 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) {
# warning "Please consider a higher clockspeed, if possible"
#endif
-#if w2 > 0
-# define w2_nops w2
-#else
-# define w2_nops 0
-#endif
-
-#if w3 > 0
-# define w3_nops w3
-#else
-# define w3_nops 0
-#endif
-
#define w_nop1 "nop \n\t"
#define w_nop2 "rjmp .+0 \n\t"
#define w_nop4 w_nop2 w_nop2
diff --git a/drivers/chibios/i2c_master.h b/drivers/chibios/i2c_master.h
index 5743c82d18..c68109acbd 100644
--- a/drivers/chibios/i2c_master.h
+++ b/drivers/chibios/i2c_master.h
@@ -1,9 +1,9 @@
/* Copyright 2018 Jack Humbert
* Copyright 2018 Yiancar
*
- * This program is free sofare: you can redistribute it and/or modify
+ * 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 Sofare Foundation, either version 2 of the License, or
+ * 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,
@@ -108,7 +108,6 @@ void i2c_init(void);
i2c_status_t i2c_start(uint8_t address);
i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout);
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
-i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t* tx_body, uint16_t tx_length, uint8_t* rx_body, uint16_t rx_length);
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout);
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
void i2c_stop(void);
diff --git a/drivers/chibios/serial_usart.c b/drivers/chibios/serial_usart.c
index a3e21f90bc..fb95ec56bd 100644
--- a/drivers/chibios/serial_usart.c
+++ b/drivers/chibios/serial_usart.c
@@ -58,7 +58,10 @@
# error invalid SELECT_SOFT_SERIAL_SPEED value
#endif
-#define TIMEOUT 100
+#ifndef SERIAL_USART_TIMEOUT
+# define SERIAL_USART_TIMEOUT 100
+#endif
+
#define HANDSHAKE_MAGIC 7
static inline msg_t sdWriteHalfDuplex(SerialDriver* driver, uint8_t* data, uint8_t size) {
@@ -201,21 +204,28 @@ int soft_serial_transaction(int index) {
sdClear(&SERIAL_USART_DRIVER);
// First chunk is always transaction id
+<<<<<<< HEAD
sdWriteTimeout(&SERIAL_USART_DRIVER, &sstd_index, sizeof(sstd_index), TIME_MS2I(TIMEOUT));
-
- uint8_t sstd_index_shake = 0xFF;
-
- // Which we always read back first so that we can error out correctly
+=======
+ sdWriteTimeout(&SERIAL_USART_DRIVER, &sstd_index, sizeof(sstd_index), TIME_MS2I(SERIAL_USART_TIMEOUT));
// - due to the half duplex limitations on return codes, we always have to read *something*
// - without the read, write only transactions *always* succeed, even during the boot process where the slave is not ready
+<<<<<<< HEAD
res = sdReadTimeout(&SERIAL_USART_DRIVER, &sstd_index_shake, sizeof(sstd_index_shake), TIME_MS2I(TIMEOUT));
+=======
+ res = sdReadTimeout(&SERIAL_USART_DRIVER, &sstd_index_shake, sizeof(sstd_index_shake), TIME_MS2I(SERIAL_USART_TIMEOUT));
+>>>>>>> 0.12.52~1
if (res < 0 || (sstd_index_shake != (sstd_index ^ HANDSHAKE_MAGIC))) {
dprintf("serial::usart_shake NO_RESPONSE\n");
return TRANSACTION_NO_RESPONSE;
}
if (trans->initiator2target_buffer_size) {
+<<<<<<< HEAD
res = sdWriteTimeout(&SERIAL_USART_DRIVER, trans->initiator2target_buffer, trans->initiator2target_buffer_size, TIME_MS2I(TIMEOUT));
+=======
+ res = sdWriteTimeout(&SERIAL_USART_DRIVER, trans->initiator2target_buffer, trans->initiator2target_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT));
+>>>>>>> 0.12.52~1
if (res < 0) {
dprintf("serial::usart_transmit NO_RESPONSE\n");
return TRANSACTION_NO_RESPONSE;
@@ -223,7 +233,11 @@ int soft_serial_transaction(int index) {
}
if (trans->target2initiator_buffer_size) {
+<<<<<<< HEAD
res = sdReadTimeout(&SERIAL_USART_DRIVER, trans->target2initiator_buffer, trans->target2initiator_buffer_size, TIME_MS2I(TIMEOUT));
+=======
+ res = sdReadTimeout(&SERIAL_USART_DRIVER, trans->target2initiator_buffer, trans->target2initiator_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT));
+>>>>>>> 0.12.52~1
if (res < 0) {
dprintf("serial::usart_receive NO_RESPONSE\n");
return TRANSACTION_NO_RESPONSE;
diff --git a/drivers/chibios/uart.c b/drivers/chibios/uart.c
new file mode 100644
index 0000000000..030335b342
--- /dev/null
+++ b/drivers/chibios/uart.c
@@ -0,0 +1,50 @@
+/* Copyright 2021
+ *
+ * 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 3 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 <https://www.gnu.org/licenses/>.
+ */
+
+#include "uart.h"
+
+#include "quantum.h"
+
+static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_CR1, SD1_CR2, SD1_CR3};
+
+void uart_init(uint32_t baud) {
+ static bool is_initialised = false;
+
+ if (!is_initialised) {
+ is_initialised = true;
+
+ serialConfig.speed = baud;
+
+#if defined(USE_GPIOV1)
+ palSetLineMode(SD1_TX_PIN, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
+ palSetLineMode(SD1_RX_PIN, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
+#else
+ palSetLineMode(SD1_TX_PIN, PAL_MODE_ALTERNATE(SD1_TX_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
+ palSetLineMode(SD1_RX_PIN, PAL_MODE_ALTERNATE(SD1_RX_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
+#endif
+ sdStart(&SERIAL_DRIVER, &serialConfig);
+ }
+}
+
+void uart_putchar(uint8_t c) { sdPut(&SERIAL_DRIVER, c); }
+
+uint8_t uart_getchar(void) {
+ msg_t res = sdGet(&SERIAL_DRIVER);
+
+ return (uint8_t)res;
+}
+
+bool uart_available(void) { return !sdGetWouldBlock(&SERIAL_DRIVER); }
diff --git a/drivers/chibios/uart.h b/drivers/chibios/uart.h
new file mode 100644
index 0000000000..b4e20e9fd3
--- /dev/null
+++ b/drivers/chibios/uart.h
@@ -0,0 +1,77 @@
+/* Copyright 2021
+ *
+ * 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 3 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 <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+#include <hal.h>
+
+#ifndef SERIAL_DRIVER
+# define SERIAL_DRIVER SD1
+#endif
+
+#ifndef SD1_TX_PIN
+# define SD1_TX_PIN A9
+#endif
+
+#ifndef SD1_TX_PAL_MODE
+# define SD1_TX_PAL_MODE 7
+#endif
+
+#ifndef SD1_RX_PIN
+# define SD1_RX_PIN A10
+#endif
+
+#ifndef SD1_RX_PAL_MODE
+# define SD1_RX_PAL_MODE 7
+#endif
+
+#ifndef SD1_CTS_PIN
+# define SD1_CTS_PIN A11
+#endif
+
+#ifndef SD1_CTS_PAL_MODE
+# define SD1_CTS_PAL_MODE 7
+#endif
+
+#ifndef SD1_RTS_PIN
+# define SD1_RTS_PIN A12
+#endif
+
+#ifndef SD1_RTS_PAL_MODE
+# define SD1_RTS_PAL_MODE 7
+#endif
+
+#ifndef SD1_CR1
+# define SD1_CR1 0
+#endif
+
+#ifndef SD1_CR2
+# define SD1_CR2 0
+#endif
+
+#ifndef SD1_CR3
+# define SD1_CR3 0
+#endif
+
+void uart_init(uint32_t baud);
+
+void uart_putchar(uint8_t c);
+
+uint8_t uart_getchar(void);
+
+bool uart_available(void);
diff --git a/drivers/chibios/usbpd_stm32g4.c b/drivers/chibios/usbpd_stm32g4.c
new file mode 100644
index 0000000000..f16ca8aeae
--- /dev/null
+++ b/drivers/chibios/usbpd_stm32g4.c
@@ -0,0 +1,76 @@
+/* Copyright 2021 Nick Brassel (@tzarc)
+ *
+ * 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 <quantum.h>
+
+#ifndef USBPD_UCPD1_CFG1
+# define USBPD_UCPD1_CFG1 (UCPD_CFG1_PSC_UCPDCLK_0 | UCPD_CFG1_TRANSWIN_3 | UCPD_CFG1_IFRGAP_4 | UCPD_CFG1_HBITCLKDIV_4)
+#endif // USBPD_UCPD1_CFG1
+
+// Initialises the USBPD subsystem
+__attribute__((weak)) void usbpd_init(void) {
+ // Disable dead-battery signals
+ PWR->CR3 |= PWR_CR3_UCPD_DBDIS;
+ // Enable the clock for the UCPD1 peripheral
+ RCC->APB1ENR2 |= RCC_APB1ENR2_UCPD1EN;
+
+ // Copy the existing value
+ uint32_t CFG1 = UCPD1->CFG1;
+ // Force-disable UCPD1 before configuring
+ CFG1 &= ~UCPD_CFG1_UCPDEN;
+ // Configure UCPD1
+ CFG1 = USBPD_UCPD1_CFG1;
+ // Apply the changes
+ UCPD1->CFG1 = CFG1;
+ // Enable UCPD1
+ UCPD1->CFG1 |= UCPD_CFG1_UCPDEN;
+
+ // Copy the existing value
+ uint32_t CR = UCPD1->CR;
+ // Clear out ANASUBMODE (irrelevant as a sink device)
+ CR &= ~UCPD_CR_ANASUBMODE_Msk;
+ // Advertise our capabilities as a sink, with both CC lines enabled
+ CR |= UCPD_CR_ANAMODE | UCPD_CR_CCENABLE_Msk;
+ // Apply the changes
+ UCPD1->CR = CR;
+}
+
+// Gets the current state of the USBPD allowance
+__attribute__((weak)) usbpd_allowance_t usbpd_get_allowance(void) {
+ uint32_t CR = UCPD1->CR;
+
+ int ucpd_enabled = (UCPD1->CFG1 & UCPD_CFG1_UCPDEN_Msk) >> UCPD_CFG1_UCPDEN_Pos;
+ int anamode = (CR & UCPD_CR_ANAMODE_Msk) >> UCPD_CR_ANAMODE_Pos;
+ int cc_enabled = (CR & UCPD_CR_CCENABLE_Msk) >> UCPD_CR_CCENABLE_Pos;
+
+ if (ucpd_enabled && anamode && cc_enabled) {
+ uint32_t SR = UCPD1->SR;
+ int vstate_cc1 = (SR & UCPD_SR_TYPEC_VSTATE_CC1_Msk) >> UCPD_SR_TYPEC_VSTATE_CC1_Pos;
+ int vstate_cc2 = (SR & UCPD_SR_TYPEC_VSTATE_CC2_Msk) >> UCPD_SR_TYPEC_VSTATE_CC2_Pos;
+ int vstate_max = vstate_cc1 > vstate_cc2 ? vstate_cc1 : vstate_cc2;
+ switch (vstate_max) {
+ case 0:
+ case 1:
+ return USBPD_500MA; // Note that this is 500mA (i.e. max USB 2.0), not 900mA, as we're not using USB 3.1 as a sink device.
+ case 2:
+ return USBPD_1500MA;
+ case 3:
+ return USBPD_3000MA;
+ }
+ }
+
+ return USBPD_500MA;
+} \ No newline at end of file
diff --git a/drivers/chibios/ws2812.c b/drivers/chibios/ws2812.c
index 876ed46eac..0d12e2fb79 100644
--- a/drivers/chibios/ws2812.c
+++ b/drivers/chibios/ws2812.c
@@ -6,7 +6,7 @@
/* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */
#ifndef NOP_FUDGE
-# if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F0XX) || defined(STM32F0xx) || defined(STM32F3XX) || defined(STM32F3xx) || defined(STM32L0XX) || defined(STM32L0xx)
+# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX)
# define NOP_FUDGE 0.4
# else
# error("NOP_FUDGE configuration required")
diff --git a/drivers/chibios/wt_rgb_backlight.c b/drivers/chibios/wt_rgb_backlight.c
new file mode 100644
index 0000000000..306f8186e0
--- /dev/null
+++ b/drivers/chibios/wt_rgb_backlight.c
@@ -0,0 +1,3125 @@
+/* Copyright 2017 Jason Williams (Wilba)
+ *
+ * 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/>.
+ */
+
+#if defined(RGB_BACKLIGHT_ZEAL60) || \
+ defined(RGB_BACKLIGHT_ZEAL65) || \
+ defined(RGB_BACKLIGHT_M60_A) || \
+ defined(RGB_BACKLIGHT_M6_B) || \
+ defined(RGB_BACKLIGHT_M10_C) || \
+ defined(RGB_BACKLIGHT_KOYU) || \
+ defined(RGB_BACKLIGHT_M65_B) || \
+ defined(RGB_BACKLIGHT_M65_BX) || \
+ defined(RGB_BACKLIGHT_HS60) || \
+ defined(RGB_BACKLIGHT_NK65) || \
+ defined(RGB_BACKLIGHT_NK87) || \
+ defined(RGB_BACKLIGHT_KW_MEGA) || \
+ defined(RGB_BACKLIGHT_NEBULA12) || \
+ defined(RGB_BACKLIGHT_NEBULA68) || \
+ defined(RGB_BACKLIGHT_U80_A) || \
+ defined(RGB_BACKLIGHT_DAWN60) || \
+ defined(RGB_BACKLIGHT_WT60_B) || \
+ defined(RGB_BACKLIGHT_WT60_BX) || \
+ defined(RGB_BACKLIGHT_WT60_C) || \
+ defined(RGB_BACKLIGHT_M50_A)
+#else
+#error wt_rgb_backlight.c compiled without setting configuration symbol
+#endif
+
+#ifndef MAX
+ #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+#endif
+
+#ifndef MIN
+ #define MIN(a,b) ((a) < (b)? (a): (b))
+#endif
+
+#include "quantum.h"
+#include "wt_rgb_backlight.h"
+#include "wt_rgb_backlight_api.h"
+#include "wt_rgb_backlight_keycodes.h"
+
+#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NK87) && !defined(RGB_BACKLIGHT_NEBULA68) && !defined(RGB_BACKLIGHT_NEBULA12) && !defined (RGB_BACKLIGHT_KW_MEGA)
+#include <avr/interrupt.h>
+#include "drivers/avr/i2c_master.h"
+#else
+#include <ch.h>
+#include <hal.h>
+#include "drivers/chibios/i2c_master.h"
+#endif
+
+#if defined(RGB_BACKLIGHT_DAWN60)
+#include "ws2812.h"
+LED_TYPE g_ws2812_leds[WS2812_LED_TOTAL];
+#endif
+
+#include "progmem.h"
+#include "quantum/color.h"
+#include "tmk_core/common/eeprom.h"
+
+#include "via.h" // uses EEPROM address, lighting value IDs
+#define RGB_BACKLIGHT_CONFIG_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
+
+#if VIA_EEPROM_CUSTOM_CONFIG_SIZE == 0
+#error VIA_EEPROM_CUSTOM_CONFIG_SIZE was not defined to store backlight_config struct
+#endif
+
+#if defined(RGB_BACKLIGHT_M6_B)
+#include "drivers/issi/is31fl3218.h"
+#define BACKLIGHT_LED_COUNT 6
+#elif defined(RGB_BACKLIGHT_HS60)
+#include "drivers/issi/is31fl3733.h"
+#define BACKLIGHT_LED_COUNT 64
+#elif defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA68) || defined(RGB_BACKLIGHT_KW_MEGA)
+#include "drivers/issi/is31fl3733.h"
+#define BACKLIGHT_LED_COUNT 69
+#elif defined(RGB_BACKLIGHT_NK87)
+#include "drivers/issi/is31fl3733.h"
+#define BACKLIGHT_LED_COUNT 128
+#else
+#include "drivers/issi/is31fl3731.h"
+#if defined(RGB_BACKLIGHT_U80_A)
+#define BACKLIGHT_LED_COUNT 108
+#elif defined(RGB_BACKLIGHT_DAWN60)
+#define BACKLIGHT_LED_COUNT 84 //64 + 20
+#elif defined(RGB_BACKLIGHT_NEBULA12)
+#define BACKLIGHT_LED_COUNT 16
+#elif defined(RGB_BACKLIGHT_M10_C)
+#define BACKLIGHT_LED_COUNT 12
+#else
+#define BACKLIGHT_LED_COUNT 72
+#endif
+#endif
+
+#define BACKLIGHT_EFFECT_MAX 10
+
+backlight_config g_config = {
+ .use_split_backspace = RGB_BACKLIGHT_USE_SPLIT_BACKSPACE,
+ .use_split_left_shift = RGB_BACKLIGHT_USE_SPLIT_LEFT_SHIFT,
+ .use_split_right_shift = RGB_BACKLIGHT_USE_SPLIT_RIGHT_SHIFT,
+ .use_7u_spacebar = RGB_BACKLIGHT_USE_7U_SPACEBAR,
+ .use_iso_enter = RGB_BACKLIGHT_USE_ISO_ENTER,
+ .disable_hhkb_blocker_leds = RGB_BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS,
+ .disable_when_usb_suspended = RGB_BACKLIGHT_DISABLE_WHEN_USB_SUSPENDED,
+ .disable_after_timeout = RGB_BACKLIGHT_DISABLE_AFTER_TIMEOUT,
+ .brightness = RGB_BACKLIGHT_BRIGHTNESS,
+ .effect = RGB_BACKLIGHT_EFFECT,
+ .effect_speed = RGB_BACKLIGHT_EFFECT_SPEED,
+ .color_1 = RGB_BACKLIGHT_COLOR_1,
+ .color_2 = RGB_BACKLIGHT_COLOR_2,
+ .caps_lock_indicator = RGB_BACKLIGHT_CAPS_LOCK_INDICATOR,
+ .layer_1_indicator = RGB_BACKLIGHT_LAYER_1_INDICATOR,
+ .layer_2_indicator = RGB_BACKLIGHT_LAYER_2_INDICATOR,
+ .layer_3_indicator = RGB_BACKLIGHT_LAYER_3_INDICATOR,
+ .alphas_mods = {
+ RGB_BACKLIGHT_ALPHAS_MODS_ROW_0,
+ RGB_BACKLIGHT_ALPHAS_MODS_ROW_1,
+ RGB_BACKLIGHT_ALPHAS_MODS_ROW_2,
+ RGB_BACKLIGHT_ALPHAS_MODS_ROW_3,
+ RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 },
+#if defined(RGB_BACKLIGHT_M6_B)
+ .custom_color = { { 0, 255 }, { 43, 255 }, { 85, 255 }, { 128, 255 }, { 171, 255 }, { 213, 255 } }
+#elif defined(RGB_BACKLIGHT_M10_C)
+ .custom_color = { { 0, 255 }, { 43, 255 }, { 85, 255 }, { 128, 255 }, { 171, 255 }, { 213, 255 }, { 0, 255 }, { 43, 255 }, { 85, 255 }, { 128, 255 } }
+#endif
+};
+
+bool g_suspend_state = false;
+uint8_t g_indicator_state = 0;
+
+// Global tick at 20 Hz
+uint32_t g_tick = 0;
+
+// Ticks since this key was last hit.
+uint8_t g_key_hit[BACKLIGHT_LED_COUNT];
+
+// Ticks since any key was last hit.
+uint32_t g_any_key_hit = 0;
+
+#if defined(RGB_BACKLIGHT_HS60)
+
+// This is a 7-bit address, that gets left-shifted and bit 0
+// set to 0 for write, 1 for read (as per I2C protocol)
+// ADDR_2 is not needed. it is here as a dummy
+#define ISSI_ADDR_1 0x50
+
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, B_1, A_1, C_1}, //LA1
+ {0, E_1, D_1, F_1}, //LA2
+ {0, H_1, G_1, I_1}, //LA3
+ {0, K_1, J_1, L_1}, //LA4
+ {0, B_2, A_2, C_2}, //LA5
+ {0, E_2, D_2, F_2}, //LA6
+ {0, H_2, G_2, I_2}, //LA7
+ {0, K_2, J_2, L_2}, //LA8
+ {0, B_3, A_3, C_3}, //LA9
+ {0, E_3, D_3, F_3}, //LA10
+ {0, H_3, G_3, I_3}, //LA11
+ {0, K_3, J_3, L_3}, //LA12
+ {0, B_4, A_4, C_4}, //LA13
+ {0, E_4, D_4, F_4}, //LA14
+ {0, H_4, G_4, I_4}, //LA15
+ {0, K_4, J_4, L_4}, //LA16
+ {0, B_5, A_5, C_5}, //LA17
+ {0, E_5, D_5, F_5}, //LA18
+ {0, H_5, G_5, I_5}, //LA19
+ {0, K_5, J_5, L_5}, //LA20
+ {0, B_6, A_6, C_6}, //LA21
+ {0, E_6, D_6, F_6}, //LA22
+ {0, H_6, G_6, I_6}, //LA23
+ {0, K_6, J_6, L_6}, //LA24
+ {0, B_7, A_7, C_7}, //LA25
+ {0, E_7, D_7, F_7}, //LA26
+ {0, H_7, G_7, I_7}, //LA27
+ {0, K_7, J_7, L_7}, //LA28
+ {0, B_8, A_8, C_8}, //LA29
+ {0, E_8, D_8, F_8}, //LA30
+ {0, H_8, G_8, I_8}, //LA31
+ {0, K_8, J_8, L_8}, //LA32
+ {0, B_9, A_9, C_9}, //LA33
+ {0, E_9, D_9, F_9}, //LA34
+ {0, H_9, G_9, I_9}, //LA35
+ {0, K_9, J_9, L_9}, //LA36
+ {0, B_10, A_10, C_10}, //LA37
+ {0, E_10, D_10, F_10}, //LA38
+ {0, H_10, G_10, I_10}, //LA39
+ {0, K_10, J_10, L_10}, //LA40
+ {0, B_11, A_11, C_11}, //LA41
+ {0, E_11, D_11, F_11}, //LA42
+ {0, H_11, G_11, I_11}, //LA43
+ {0, K_11, J_11, L_11}, //LA44
+ {0, B_12, A_12, C_12}, //LA45
+ {0, E_12, D_12, F_12}, //LA46
+ {0, H_12, G_12, I_12}, //LA47
+ {0, K_12, J_12, L_12}, //LA48
+ {0, B_13, A_13, C_13}, //LA49
+ {0, E_13, D_13, F_13}, //LA50
+ {0, H_13, G_13, I_13}, //LA51
+ {0, K_13, J_13, L_13}, //LA52
+ {0, B_14, A_14, C_14}, //LA53
+ {0, E_14, D_14, F_14}, //LA54
+ {0, H_14, G_14, I_14}, //LA55
+ {0, K_14, J_14, L_14}, //LA56
+ {0, B_15, A_15, C_15}, //LA57
+ {0, E_15, D_15, F_15}, //LA58
+ {0, H_15, G_15, I_15}, //LA59
+ {0, K_15, J_15, L_15}, //LA60
+ {0, B_16, A_16, C_16}, //LA61
+ {0, E_16, D_16, F_16}, //LA62
+ {0, H_16, G_16, I_16}, //LA63
+ {0, K_16, J_16, L_16}, //LA64
+};
+
+#elif defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA68) || defined(RGB_BACKLIGHT_NK87) || defined(RGB_BACKLIGHT_KW_MEGA)
+
+// This is a 7-bit address, that gets left-shifted and bit 0
+// set to 0 for write, 1 for read (as per I2C protocol)
+// ADDR_2 is not needed. it is here as a dummy
+#define ISSI_ADDR_1 0x50
+#define ISSI_ADDR_2 0x52
+
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, B_1, A_1, C_1}, //LA1
+ {0, E_1, D_1, F_1}, //LA2
+ {0, H_1, G_1, I_1}, //LA3
+ {0, K_1, J_1, L_1}, //LA4
+ {0, B_2, A_2, C_2}, //LA5
+ {0, E_2, D_2, F_2}, //LA6
+ {0, H_2, G_2, I_2}, //LA7
+ {0, K_2, J_2, L_2}, //LA8
+ {0, B_3, A_3, C_3}, //LA9
+ {0, E_3, D_3, F_3}, //LA10
+ {0, H_3, G_3, I_3}, //LA11
+ {0, K_3, J_3, L_3}, //LA12
+ {0, B_4, A_4, C_4}, //LA13
+ {0, E_4, D_4, F_4}, //LA14
+ {0, H_4, G_4, I_4}, //LA15
+ {0, K_4, J_4, L_4}, //LA16
+ {0, B_5, A_5, C_5}, //LA17
+ {0, E_5, D_5, F_5}, //LA18
+ {0, H_5, G_5, I_5}, //LA19
+ {0, K_5, J_5, L_5}, //LA20
+ {0, B_6, A_6, C_6}, //LA21
+ {0, E_6, D_6, F_6}, //LA22
+ {0, H_6, G_6, I_6}, //LA23
+ {0, K_6, J_6, L_6}, //LA24
+ {0, B_7, A_7, C_7}, //LA25
+ {0, E_7, D_7, F_7}, //LA26
+ {0, H_7, G_7, I_7}, //LA27
+ {0, K_7, J_7, L_7}, //LA28
+ {0, B_8, A_8, C_8}, //LA29
+ {0, E_8, D_8, F_8}, //LA30
+ {0, H_8, G_8, I_8}, //LA31
+ {0, K_8, J_8, L_8}, //LA32
+ {0, B_9, A_9, C_9}, //LA33
+ {0, E_9, D_9, F_9}, //LA34
+ {0, H_9, G_9, I_9}, //LA35
+ {0, K_9, J_9, L_9}, //LA36
+ {0, B_10, A_10, C_10}, //LA37
+ {0, E_10, D_10, F_10}, //LA38
+ {0, H_10, G_10, I_10}, //LA39
+ {0, K_10, J_10, L_10}, //LA40
+ {0, B_11, A_11, C_11}, //LA41
+ {0, E_11, D_11, F_11}, //LA42
+ {0, H_11, G_11, I_11}, //LA43
+ {0, K_11, J_11, L_11}, //LA44
+ {0, B_12, A_12, C_12}, //LA45
+ {0, E_12, D_12, F_12}, //LA46
+ {0, H_12, G_12, I_12}, //LA47
+ {0, K_12, J_12, L_12}, //LA48
+ {0, B_13, A_13, C_13}, //LA49
+ {0, E_13, D_13, F_13}, //LA50
+ {0, H_13, G_13, I_13}, //LA51
+ {0, K_13, J_13, L_13}, //LA52
+ {0, B_14, A_14, C_14}, //LA53
+ {0, E_14, D_14, F_14}, //LA54
+ {0, H_14, G_14, I_14}, //LA55
+ {0, K_14, J_14, L_14}, //LA56
+ {0, B_15, A_15, C_15}, //LA57
+ {0, E_15, D_15, F_15}, //LA58
+ {0, H_15, G_15, I_15}, //LA59
+ {0, K_15, J_15, L_15}, //LA60
+ {0, B_16, A_16, C_16}, //LA61
+ {0, E_16, D_16, F_16}, //LA62
+ {0, H_16, G_16, I_16}, //LA63
+ {0, K_16, J_16, L_16}, //LA64
+
+ {1, B_1, A_1, C_1}, //LB1
+ {1, E_1, D_1, F_1}, //LB2
+ {1, H_1, G_1, I_1}, //LB3
+ {1, K_1, J_1, L_1}, //LB4
+ {1, B_2, A_2, C_2}, //LB5
+ {1, E_2, D_2, F_2}, //LB6
+ {1, H_2, G_2, I_2}, //LB7
+ {1, K_2, J_2, L_2}, //LB8
+ {1, B_3, A_3, C_3}, //LB9
+ {1, E_3, D_3, F_3}, //LB10
+ {1, H_3, G_3, I_3}, //LB11
+ {1, K_3, J_3, L_3}, //LB12
+ {1, B_4, A_4, C_4}, //LB13
+ {1, E_4, D_4, F_4}, //LB14
+ {1, H_4, G_4, I_4}, //LB15
+ {1, K_4, J_4, L_4}, //LB16
+ {1, B_5, A_5, C_5}, //LB17
+ {1, E_5, D_5, F_5}, //LB18
+ {1, H_5, G_5, I_5}, //LB19
+ {1, K_5, J_5, L_5}, //LB20
+ {1, B_6, A_6, C_6}, //LB21
+ {1, E_6, D_6, F_6}, //LB22
+ {1, H_6, G_6, I_6}, //LB23
+ {1, K_6, J_6, L_6}, //LB24
+ {1, B_7, A_7, C_7}, //LB25
+ {1, E_7, D_7, F_7}, //LB26
+ {1, H_7, G_7, I_7}, //LB27
+ {1, K_7, J_7, L_7}, //LB28
+ {1, B_8, A_8, C_8}, //LB29
+ {1, E_8, D_8, F_8}, //LB30
+ {1, H_8, G_8, I_8}, //LB31
+ {1, K_8, J_8, L_8}, //LB32
+ {1, B_9, A_9, C_9}, //LB33
+ {1, E_9, D_9, F_9}, //LB34
+ {1, H_9, G_9, I_9}, //LB35
+ {1, K_9, J_9, L_9}, //LB36
+ {1, B_10, A_10, C_10}, //LB37
+ {1, E_10, D_10, F_10}, //LB38
+ {1, H_10, G_10, I_10}, //LB39
+ {1, K_10, J_10, L_10}, //LB40
+ {1, B_11, A_11, C_11}, //LB41
+ {1, E_11, D_11, F_11}, //LB42
+ {1, H_11, G_11, I_11}, //LB43
+ {1, K_11, J_11, L_11}, //LB44
+ {1, B_12, A_12, C_12}, //LB45
+ {1, E_12, D_12, F_12}, //LB46
+ {1, H_12, G_12, I_12}, //LB47
+ {1, K_12, J_12, L_12}, //LB48
+ {1, B_13, A_13, C_13}, //LB49
+ {1, E_13, D_13, F_13}, //LB50
+ {1, H_13, G_13, I_13}, //LB51
+ {1, K_13, J_13, L_13}, //LB52
+ {1, B_14, A_14, C_14}, //LB53
+ {1, E_14, D_14, F_14}, //LB54
+ {1, H_14, G_14, I_14}, //LB55
+ {1, K_14, J_14, L_14}, //LB56
+ {1, B_15, A_15, C_15}, //LB57
+ {1, E_15, D_15, F_15}, //LB58
+ {1, H_15, G_15, I_15}, //LB59
+ {1, K_15, J_15, L_15}, //LB60
+ {1, B_16, A_16, C_16}, //LB61
+ {1, E_16, D_16, F_16}, //LB62
+ {1, H_16, G_16, I_16}, //LB63
+ {1, K_16, J_16, L_16}, //LB64
+};
+
+#elif defined(RGB_BACKLIGHT_NEBULA12)
+// This is a 7-bit address, that gets left-shifted and bit 0
+// set to 0 for write, 1 for read (as per I2C protocol)
+#define ISSI_ADDR_1 0x74
+
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, C1_1, C3_2, C4_2}, //A1
+ {0, C1_2, C2_2, C4_3}, //A2
+ {0, C1_3, C2_3, C3_3}, //A3
+ {0, C1_4, C2_4, C3_4}, //A4
+ {0, C1_5, C2_5, C3_5}, //A5
+ {0, C1_6, C2_6, C3_6}, //A6
+ {0, C1_7, C2_7, C3_7}, //A7
+ {0, C1_8, C2_8, C3_8}, //A8
+ {0, C9_1, C8_1, C7_1}, //A9
+ {0, C9_2, C8_2, C7_2}, //A10
+ {0, C9_3, C8_3, C7_3}, //A11
+ {0, C9_4, C8_4, C7_4}, //A12
+ {0, C9_5, C8_5, C7_5}, //A13
+ {0, C9_6, C8_6, C7_6}, //A14
+ {0, C9_7, C8_7, C6_6}, //A15
+ {0, C9_8, C7_7, C6_7}, //A16
+};
+
+#elif defined(RGB_BACKLIGHT_U80_A)
+
+// U80-A prototype uses 3 ISSI drivers
+#define ISSI_ADDR_1 0x74 // 11101[00] <- GND
+#define ISSI_ADDR_2 0x76 // 11101[10] <- SDA
+#define ISSI_ADDR_3 0x75 // 11101[01] <- SCL
+
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, C2_1, C3_1, C4_1}, // LA0
+ {0, C1_1, C3_2, C4_2}, // LA1
+ {0, C1_2, C2_2, C4_3}, // LA2
+ {0, C1_3, C2_3, C3_3}, // LA3
+ {0, C1_4, C2_4, C3_4}, // LA4
+ {0, C1_5, C2_5, C3_5}, // LA5
+ {0, C1_6, C2_6, C3_6}, // LA6
+ {0, C1_7, C2_7, C3_7}, // LA7
+ {0, C1_8, C2_8, C3_8}, // LA8
+ {0, C9_1, C8_1, C7_1}, // LA9
+ {0, C9_2, C8_2, C7_2}, // LA10
+ {0, C9_3, C8_3, C7_3}, // LA11
+ {0, C9_4, C8_4, C7_4}, // LA12
+ {0, C9_5, C8_5, C7_5}, // LA13
+ {0, C9_6, C8_6, C7_6}, // LA14
+ {0, C9_7, C8_7, C6_6}, // LA15
+ {0, C9_8, C7_7, C6_7}, // LA16
+ {0, C8_8, C7_8, C6_8}, // LA17
+
+ {0, C2_9, C3_9, C4_9}, // LB0
+ {0, C1_9, C3_10, C4_10}, // LB1
+ {0, C1_10, C2_10, C4_11}, // LB2
+ {0, C1_11, C2_11, C3_11}, // LB3
+ {0, C1_12, C2_12, C3_12}, // LB4
+ {0, C1_13, C2_13, C3_13}, // LB5
+ {0, C1_14, C2_14, C3_14}, // LB6
+ {0, C1_15, C2_15, C3_15}, // LB7
+ {0, C1_16, C2_16, C3_16}, // LB8
+ {0, C9_9, C8_9, C7_9}, // LB9
+ {0, C9_10, C8_10, C7_10}, // LB10
+ {0, C9_11, C8_11, C7_11}, // LB11
+ {0, C9_12, C8_12, C7_12}, // LB12
+ {0, C9_13, C8_13, C7_13}, // LB13
+ {0, C9_14, C8_14, C7_14}, // LB14
+ {0, C9_15, C8_15, C6_14}, // LB15
+ {0, C9_16, C7_15, C6_15}, // LB16
+ {0, C8_16, C7_16, C6_16}, // LB17
+
+ {1, C2_1, C3_1, C4_1}, // LC0
+ {1, C1_1, C3_2, C4_2}, // LC1
+ {1, C1_2, C2_2, C4_3}, // LC2
+ {1, C1_3, C2_3, C3_3}, // LC3
+ {1, C1_4, C2_4, C3_4}, // LC4
+ {1, C1_5, C2_5, C3_5}, // LC5
+ {1, C1_6, C2_6, C3_6}, // LC6
+ {1, C1_7, C2_7, C3_7}, // LC7
+ {1, C1_8, C2_8, C3_8}, // LC8
+ {1, C9_1, C8_1, C7_1}, // LC9
+ {1, C9_2, C8_2, C7_2}, // LC10
+ {1, C9_3, C8_3, C7_3}, // LC11
+ {1, C9_4, C8_4, C7_4}, // LC12
+ {1, C9_5, C8_5, C7_5}, // LC13
+ {1, C9_6, C8_6, C7_6}, // LC14
+ {1, C9_7, C8_7, C6_6}, // LC15
+ {1, C9_8, C7_7, C6_7}, // LC16
+ {1, C8_8, C7_8, C6_8}, // LC17
+
+ {1, C2_9, C3_9, C4_9}, // LD0
+ {1, C1_9, C3_10, C4_10}, // LD1
+ {1, C1_10, C2_10, C4_11}, // LD2
+ {1, C1_11, C2_11, C3_11}, // LD3
+ {1, C1_12, C2_12, C3_12}, // LD4
+ {1, C1_13, C2_13, C3_13}, // LD5
+ {1, C1_14, C2_14, C3_14}, // LD6
+ {1, C1_15, C2_15, C3_15}, // LD7
+ {1, C1_16, C2_16, C3_16}, // LD8
+ {1, C9_9, C8_9, C7_9}, // LD9
+ {1, C9_10, C8_10, C7_10}, // LD10
+ {1, C9_11, C8_11, C7_11}, // LD11
+ {1, C9_12, C8_12, C7_12}, // LD12
+ {1, C9_13, C8_13, C7_13}, // LD13
+ {1, C9_14, C8_14, C7_14}, // LD14
+ {1, C9_15, C8_15, C6_14}, // LD15
+ {1, C9_16, C7_15, C6_15}, // LD16
+ {1, C8_16, C7_16, C6_16}, // LD17
+
+ {2, C2_1, C3_1, C4_1}, // LE0
+ {2, C1_1, C3_2, C4_2}, // LE1
+ {2, C1_2, C2_2, C4_3}, // LE2
+ {2, C1_3, C2_3, C3_3}, // LE3
+ {2, C1_4, C2_4, C3_4}, // LE4
+ {2, C1_5, C2_5, C3_5}, // LE5
+ {2, C1_6, C2_6, C3_6}, // LE6
+ {2, C1_7, C2_7, C3_7}, // LE7
+ {2, C1_8, C2_8, C3_8}, // LE8
+ {2, C9_1, C8_1, C7_1}, // LE9
+ {2, C9_2, C8_2, C7_2}, // LE10
+ {2, C9_3, C8_3, C7_3}, // LE11
+ {2, C9_4, C8_4, C7_4}, // LE12
+ {2, C9_5, C8_5, C7_5}, // LE13
+ {2, C9_6, C8_6, C7_6}, // LE14
+ {2, C9_7, C8_7, C6_6}, // LE15
+ {2, C9_8, C7_7, C6_7}, // LE16
+ {2, C8_8, C7_8, C6_8}, // LE17
+
+ {2, C2_9, C3_9, C4_9}, // LF0
+ {2, C1_9, C3_10, C4_10}, // LF1
+ {2, C1_10, C2_10, C4_11}, // LF2
+ {2, C1_11, C2_11, C3_11}, // LF3
+ {2, C1_12, C2_12, C3_12}, // LF4
+ {2, C1_13, C2_13, C3_13}, // LF5
+ {2, C1_14, C2_14, C3_14}, // LF6
+ {2, C1_15, C2_15, C3_15}, // LF7
+ {2, C1_16, C2_16, C3_16}, // LF8
+ {2, C9_9, C8_9, C7_9}, // LF9
+ {2, C9_10, C8_10, C7_10}, // LF10
+ {2, C9_11, C8_11, C7_11}, // LF11
+ {2, C9_12, C8_12, C7_12}, // LF12
+ {2, C9_13, C8_13, C7_13}, // LF13
+ {2, C9_14, C8_14, C7_14}, // LF14
+ {2, C9_15, C8_15, C6_14}, // LF15
+ {2, C9_16, C7_15, C6_15}, // LF16
+ {2, C8_16, C7_16, C6_16}, // LF17
+};
+#elif defined(RGB_BACKLIGHT_DAWN60)
+// This is a 7-bit address, that gets left-shifted and bit 0
+// set to 0 for write, 1 for read (as per I2C protocol)
+#define ISSI_ADDR_1 0x74
+#define ISSI_ADDR_2 0x76
+
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, C1_1, C3_2, C4_2}, //A1
+ {0, C1_2, C2_2, C4_3}, //A2
+ {0, C1_3, C2_3, C3_3}, //A3
+ {0, C1_4, C2_4, C3_4}, //A4
+ {0, C1_5, C2_5, C3_5}, //A5
+ {0, C1_6, C2_6, C3_6}, //A6
+ {0, C1_7, C2_7, C3_7}, //A7
+ {0, C1_8, C2_8, C3_8}, //A8
+ {0, C9_1, C8_1, C7_1}, //A9
+ {0, C9_2, C8_2, C7_2}, //A10
+ {0, C9_3, C8_3, C7_3}, //A11
+ {0, C9_4, C8_4, C7_4}, //A12
+ {0, C9_5, C8_5, C7_5}, //A13
+ {0, C9_6, C8_6, C7_6}, //A14
+ {0, C9_7, C8_7, C6_6}, //A15
+ {0, C9_8, C7_7, C6_7}, //A16
+
+ {0, C1_9, C3_10, C4_10}, //B1
+ {0, C1_10, C2_10, C4_11}, //B2
+ {0, C1_11, C2_11, C3_11}, //B3
+ {0, C1_12, C2_12, C3_12}, //B4
+ {0, C1_13, C2_13, C3_13}, //B5
+ {0, C1_14, C2_14, C3_14}, //B6
+ {0, C1_15, C2_15, C3_15}, //B7
+ {0, C1_16, C2_16, C3_16}, //B8
+ {0, C9_9, C8_9, C7_9}, //B9
+ {0, C9_10, C8_10, C7_10}, //B10
+ {0, C9_11, C8_11, C7_11}, //B11
+ {0, C9_12, C8_12, C7_12}, //B12
+ {0, C9_13, C8_13, C7_13}, //B13
+ {0, C9_14, C8_14, C7_14}, //B14
+ {0, C9_15, C8_15, C6_14}, //B15
+ {0, C9_16, C7_15, C6_15}, //B16
+
+ {1, C1_1, C3_2, C4_2}, //C1
+ {1, C1_2, C2_2, C4_3}, //C2
+ {1, C1_3, C2_3, C3_3}, //C3
+ {1, C1_4, C2_4, C3_4}, //C4
+ {1, C1_5, C2_5, C3_5}, //C5
+ {1, C1_6, C2_6, C3_6}, //C6
+ {1, C1_7, C2_7, C3_7}, //C7
+ {1, C1_8, C2_8, C3_8}, //C8
+ {1, C9_1, C8_1, C7_1}, //C9
+ {1, C9_2, C8_2, C7_2}, //C10
+ {1, C9_3, C8_3, C7_3}, //C11
+ {1, C9_4, C8_4, C7_4}, //C12
+ {1, C9_5, C8_5, C7_5}, //C13
+ {1, C9_6, C8_6, C7_6}, //C14
+ {1, C9_7, C8_7, C6_6}, //C15
+ {1, C9_8, C7_7, C6_7}, //C16
+
+ {1, C1_9, C3_10, C4_10}, //D1
+ {1, C1_10, C2_10, C4_11}, //D2
+ {1, C1_11, C2_11, C3_11}, //D3
+ {1, C1_12, C2_12, C3_12}, //D4
+ {1, C1_13, C2_13, C3_13}, //D5
+ {1, C1_14, C2_14, C3_14}, //D6
+ {1, C1_15, C2_15, C3_15}, //D7
+ {1, C1_16, C2_16, C3_16}, //D8
+ {1, C9_9, C8_9, C7_9}, //D9
+ {1, C9_10, C8_10, C7_10}, //D10
+ {1, C9_11, C8_11, C7_11}, //D11
+ {1, C9_12, C8_12, C7_12}, //D12
+ {1, C9_13, C8_13, C7_13}, //D13
+ {1, C9_14, C8_14, C7_14}, //D14
+ {1, C9_15, C8_15, C6_14}, //D15
+ {1, C9_16, C7_15, C6_15} //D16
+};
+#elif defined(RGB_BACKLIGHT_M6_B)
+ // Driver has fixed mapping of index to the red, green and blue LEDs
+#elif defined(RGB_BACKLIGHT_M10_C)
+// This is a 7-bit address, that gets left-shifted and bit 0
+// set to 0 for write, 1 for read (as per I2C protocol)
+#define ISSI_ADDR_1 0x74
+#define ISSI_ADDR_2
+
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+ {0, C1_9, C3_10, C4_10}, // LB1
+ {0, C1_10, C2_10, C4_11}, // LB2
+ {0, C1_11, C2_11, C3_11}, // LB3
+ {0, C1_12, C2_12, C3_12}, // LB4
+ {0, C1_13, C2_13, C3_13}, // LB5
+ {0, C1_14, C2_14, C3_14}, // LB6
+ {0, C9_11, C8_11, C7_11}, // LB11
+ {0, C9_12, C8_12, C7_12}, // LB12
+ {0, C9_13, C8_13, C7_13}, // LB13
+ {0, C9_14, C8_14, C7_14}, // LB14
+ {0, C9_15, C8_15, C6_14}, // LB15
+ {0, C9_16, C7_15, C6_15} // LB16
+};
+#else
+// This is a 7-bit address, that gets left-shifted and bit 0
+// set to 0 for write, 1 for read (as per I2C protocol)
+#define ISSI_ADDR_1 0x74
+#define ISSI_ADDR_2 0x76
+
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, C2_1, C3_1, C4_1}, // LA0
+ {0, C1_1, C3_2, C4_2}, // LA1
+ {0, C1_2, C2_2, C4_3}, // LA2
+ {0, C1_3, C2_3, C3_3}, // LA3
+ {0, C1_4, C2_4, C3_4}, // LA4
+ {0, C1_5, C2_5, C3_5}, // LA5
+ {0, C1_6, C2_6, C3_6}, // LA6
+ {0, C1_7, C2_7, C3_7}, // LA7
+ {0, C1_8, C2_8, C3_8}, // LA8
+ {0, C9_1, C8_1, C7_1}, // LA9
+ {0, C9_2, C8_2, C7_2}, // LA10
+ {0, C9_3, C8_3, C7_3}, // LA11
+ {0, C9_4, C8_4, C7_4}, // LA12
+ {0, C9_5, C8_5, C7_5}, // LA13
+ {0, C9_6, C8_6, C7_6}, // LA14
+ {0, C9_7, C8_7, C6_6}, // LA15
+ {0, C9_8, C7_7, C6_7}, // LA16
+ {0, C8_8, C7_8, C6_8}, // LA17
+
+ {0, C2_9, C3_9, C4_9}, // LB0
+ {0, C1_9, C3_10, C4_10}, // LB1
+ {0, C1_10, C2_10, C4_11}, // LB2
+ {0, C1_11, C2_11, C3_11}, // LB3
+ {0, C1_12, C2_12, C3_12}, // LB4
+ {0, C1_13, C2_13, C3_13}, // LB5
+ {0, C1_14, C2_14, C3_14}, // LB6
+ {0, C1_15, C2_15, C3_15}, // LB7
+ {0, C1_16, C2_16, C3_16}, // LB8
+ {0, C9_9, C8_9, C7_9}, // LB9
+ {0, C9_10, C8_10, C7_10}, // LB10
+ {0, C9_11, C8_11, C7_11}, // LB11
+ {0, C9_12, C8_12, C7_12}, // LB12
+ {0, C9_13, C8_13, C7_13}, // LB13
+ {0, C9_14, C8_14, C7_14}, // LB14
+ {0, C9_15, C8_15, C6_14}, // LB15
+ {0, C9_16, C7_15, C6_15}, // LB16
+ {0, C8_16, C7_16, C6_16}, // LB17
+
+ {1, C2_1, C3_1, C4_1}, // LC0
+ {1, C1_1, C3_2, C4_2}, // LC1
+ {1, C1_2, C2_2, C4_3}, // LC2
+ {1, C1_3, C2_3, C3_3}, // LC3
+ {1, C1_4, C2_4, C3_4}, // LC4
+ {1, C1_5, C2_5, C3_5}, // LC5
+ {1, C1_6, C2_6, C3_6}, // LC6
+ {1, C1_7, C2_7, C3_7}, // LC7
+ {1, C1_8, C2_8, C3_8}, // LC8
+ {1, C9_1, C8_1, C7_1}, // LC9
+ {1, C9_2, C8_2, C7_2}, // LC10
+ {1, C9_3, C8_3, C7_3}, // LC11
+ {1, C9_4, C8_4, C7_4}, // LC12
+ {1, C9_5, C8_5, C7_5}, // LC13
+ {1, C9_6, C8_6, C7_6}, // LC14
+ {1, C9_7, C8_7, C6_6}, // LC15
+ {1, C9_8, C7_7, C6_7}, // LC16
+ {1, C8_8, C7_8, C6_8}, // LC17
+
+ {1, C2_9, C3_9, C4_9}, // LD0
+ {1, C1_9, C3_10, C4_10}, // LD1
+ {1, C1_10, C2_10, C4_11}, // LD2
+ {1, C1_11, C2_11, C3_11}, // LD3
+ {1, C1_12, C2_12, C3_12}, // LD4
+ {1, C1_13, C2_13, C3_13}, // LD5
+ {1, C1_14, C2_14, C3_14}, // LD6
+ {1, C1_15, C2_15, C3_15}, // LD7
+ {1, C1_16, C2_16, C3_16}, // LD8
+ {1, C9_9, C8_9, C7_9}, // LD9
+ {1, C9_10, C8_10, C7_10}, // LD10
+ {1, C9_11, C8_11, C7_11}, // LD11
+ {1, C9_12, C8_12, C7_12}, // LD12
+ {1, C9_13, C8_13, C7_13}, // LD13
+ {1, C9_14, C8_14, C7_14}, // LD14
+ {1, C9_15, C8_15, C6_14}, // LD15
+ {1, C9_16, C7_15, C6_15}, // LD16
+ {1, C8_16, C7_16, C6_16}, // LD17
+};
+#endif
+
+
+typedef struct Point {
+ uint8_t x;
+ uint8_t y;
+} Point;
+
+
+// index in range 0..71 (LA0..LA17, LB0..LB17, LC0..LC17, LD0..LD17)
+// point values in range x=0..224 y=0..64
+// origin is center of top-left key (i.e Esc)
+#if defined(RGB_BACKLIGHT_ZEAL65)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32},
+ {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0},
+ // LB0..LB17
+ {144,0}, {160,0}, {176,0}, {192,0}, {216,0}, {224,0}, {240,0}, {240,16}, {240,32},
+ {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {220,16}, {240,48}, {240,64}, {224,64},
+ // LC0..LC17
+ {96,64}, {100,48}, {84,48}, {68,48}, {52,48}, {36,48}, {255,255}, {48,60}, {28,64},
+ {108,32}, {92,32}, {76,32}, {60,32}, {44,32}, {28,32}, {20,44}, {10,48}, {4,64},
+ // LD0..LD17
+ {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48},
+ {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {144,60}, {164,64}, {188,64}, {208,64}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,243},
+ {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255},
+ // LB0..LB17
+ {56,255}, {51,255}, {46,255}, {42,255}, {37,255}, {35,255}, {32,255}, {19,255}, {0,255},
+ {53,132}, {44,145}, {37,164}, {31,187}, {26,213}, {22,249}, {237,255}, {224,255}, {221,255},
+ // LC0..LC17
+ {184,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {255,255}, {167,255}, {165,255},
+ {128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {145,233}, {148,255}, {161,255},
+ // LD0..LD17
+ {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {0,201}, {224,181}, {230,217}, {235,255},
+ {189,128}, {200,131}, {210,141}, {218,159}, {255,255}, {201,228}, {206,255}, {213,255}, {218,255}
+};
+#elif defined(RGB_BACKLIGHT_KOYU)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32},
+ {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0},
+ // LB0..LB17
+ {144,0}, {160,0}, {176,0}, {192,0}, {208,0}, {224,0}, {240,0}, {240,16}, {240,32},
+ {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {220,16}, {240,48}, {240,64}, {224,64},
+ // LC0..LC17
+ {112,64}, {100,48}, {84,48}, {68,48}, {52,48}, {36,48}, {64,60}, {44,60}, {24,64},
+ {108,32}, {92,32}, {76,32}, {60,32}, {44,32}, {28,32}, {255,255}, {10,48}, {4,64},
+ // LD0..LD17
+ {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48},
+ {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {160,60}, {180,64}, {208,64}, {255,255}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,243},
+ {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255},
+ // LB0..LB17
+ {56,255}, {51,255}, {46,255}, {42,255}, {38,255}, {35,255}, {32,255}, {19,255}, {0,255},
+ {53,132}, {44,145}, {37,164}, {31,187}, {26,213}, {22,249}, {237,255}, {224,255}, {221,255},
+ // LC0..LC17
+ {189,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {172,252}, {169,255}, {165,255},
+ {128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {255,255}, {148,255}, {161,255},
+ // LD0..LD17
+ {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {0,201}, {224,181}, {230,217}, {235,255},
+ {189,128}, {200,131}, {210,141}, {218,159}, {255,255}, {207,238}, {211,255}, {218,255}, {255,255}
+};
+#elif defined(RGB_BACKLIGHT_M65_B) || defined(RGB_BACKLIGHT_M65_BX)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32},
+ {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0},
+ // LB0..LB17
+ {144,0}, {160,0}, {176,0}, {192,0}, {208,0}, {224,0}, {216,0}, {240,0}, {240,16},
+ {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {220,16}, {240,32}, {240,48}, {240,64},
+ // LC0..LC17
+ {112,64}, {100,48}, {84,48}, {68,48}, {52,48}, {36,48}, {64,60}, {44,60}, {24,64},
+ {108,32}, {92,32}, {76,32}, {60,32}, {44,32}, {28,32}, {255,255}, {10,48}, {4,64},
+ // LD0..LD17
+ {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48},
+ {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {160,60}, {180,64}, {208,64}, {224,64}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {64,128}, {75,132}, {84,145}, {91,164}, {97,187}, {102,213}, {105,242}, {109,255}, {128,243},
+ {61,255}, {67,255}, {72,255}, {77,255}, {82,255}, {86,255}, {90,255}, {93,255}, {96,255},
+ // LB0..LB17
+ {56,255}, {51,255}, {46,255}, {42,255}, {38,255}, {35,255}, {37,255}, {32,255}, {19,255},
+ {53,132}, {44,145}, {37,164}, {31,187}, {26,213}, {22,249}, {0,255}, {237,255}, {224,255},
+ // LC0..LC17
+ {189,255}, {179,135}, {170,149}, {163,169}, {157,193}, {153,220}, {172,252}, {169,255}, {165,255},
+ {128,26}, {128,60}, {128,94}, {128,128}, {128,162}, {128,196}, {255,255}, {148,255}, {161,255},
+ // LD0..LD17
+ {0,9}, {0,43}, {0,77}, {0,111}, {0,145}, {0,201}, {224,181}, {230,217}, {235,255},
+ {189,128}, {200,131}, {210,141}, {218,159}, {255,255}, {207,238}, {211,255}, {218,255}, {221,255}
+};
+#elif defined(RGB_BACKLIGHT_ZEAL60) || defined(RGB_BACKLIGHT_M60_A)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32},
+ {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0},
+ // LB0..LB17
+ {144,0}, {160,0}, {176,0}, {192,0}, {216,0}, {224,0}, {255,255}, {255,255}, {255,255},
+ {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {220,16}, {255,255}, {255,255}, {255,255},
+ // LC0..LC17
+ {102,64}, {100,48}, {84,48}, {68,48}, {52,48}, {36,48}, {60,64}, {43,64}, {23,64},
+ {108,32}, {92,32}, {76,32}, {60,32}, {44,32}, {28,32}, {20,48}, {2,48}, {3,64},
+ // LD0..LD17
+ {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {210,48}, {224,48},
+ {116,48}, {132,48}, {148,48}, {164,48}, {144,64}, {161,64}, {181,64}, {201,64}, {221,64}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {58,129}, {70,129}, {80,139}, {89,157}, {96,181}, {101,208}, {105,238}, {109,255}, {128,247},
+ {58,255}, {64,255}, {70,255}, {75,255}, {80,255}, {85,255}, {89,255}, {93,255}, {96,255},
+ // LB0..LB17
+ {53,255}, {48,255}, {43,255}, {39,255}, {34,255}, {32,255}, {255,255}, {255,255}, {255,255},
+ {48,139}, {39,157}, {32,181}, {27,208}, {23,238}, {19,255}, {255,255}, {255,255}, {255,255},
+ // LC0..LC17
+ {188,255}, {183,131}, {173,143}, {165,163}, {159,188}, {154,216}, {172,252}, {170,255}, {165,255},
+ {128,9}, {128,46}, {128,82}, {128,119}, {128,155}, {128,192}, {150,244}, {147,255}, {161,255},
+ // LD0..LD17
+ {0,27}, {0,64}, {0,101}, {0,137}, {0,174}, {255,233}, {228,201}, {235,255}, {237,255},
+ {195,128}, {206,136}, {215,152}, {222,175}, {205,234}, {209,255}, {214,255}, {219,255}, {223,255}
+};
+#elif defined(RGB_BACKLIGHT_WT60_B) || defined(RGB_BACKLIGHT_WT60_BX) || defined(RGB_BACKLIGHT_WT60_C)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {120,16}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {4,16}, {4,32},
+ {128,0}, {112,0}, {96,0}, {80,0}, {64,0}, {48,0}, {32,0}, {16,0}, {0,0},
+ // LB0..LB17
+ {144,0}, {160,0}, {176,0}, {192,0}, {208,0}, {224,0}, {216,0}, {255,255}, {255,255},
+ {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {220,16}, {255,255}, {255,255}, {255,255},
+ // LC0..LC17
+ {112,64}, {100,48}, {84,48}, {68,48}, {52,48}, {36,48}, {64,60}, {44,64}, {24,64},
+ {108,32}, {92,32}, {76,32}, {60,32}, {44,32}, {28,32}, {255,255}, {10,48}, {4,64},
+ // LD0..LD17
+ {124,32}, {140,32}, {156,32}, {172,32}, {188,32}, {214,32}, {180,48}, {202,48}, {224,48},
+ {116,48}, {132,48}, {148,48}, {164,48}, {255,255}, {160,60}, {180,64}, {200,64}, {220,64}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {58,129}, {70,129}, {80,139}, {89,157}, {96,181}, {101,208}, {105,238}, {109,255}, {128,247},
+ {58,255}, {64,255}, {70,255}, {75,255}, {80,255}, {85,255}, {89,255}, {93,255}, {96,255},
+ // LB0..LB17
+ {53,255}, {48,255}, {43,255}, {39,255}, {35,255}, {32,255}, {34,255}, {255,255}, {255,255},
+ {48,139}, {39,157}, {32,181}, {27,208}, {23,238}, {19,255}, {255,255}, {255,255}, {255,255},
+ // LC0..LC17
+ {192,255}, {183,131}, {173,143}, {165,163}, {159,188}, {154,216}, {173,248}, {170,255}, {165,255},
+ {128,9}, {128,46}, {128,82}, {128,119}, {128,155}, {128,192}, {255,255}, {148,255}, {161,255},
+ // LD0..LD17
+ {0,27}, {0,64}, {0,101}, {0,137}, {0,174}, {0,233}, {228,201}, {235,242}, {237,255},
+ {195,128}, {206,136}, {215,152}, {222,175}, {255,255}, {211,248}, {214,255}, {219,255}, {223,255}
+};
+#elif defined(RGB_BACKLIGHT_U80_A)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // Thse are scaled by 14.5 per U
+ // LA0..LA17
+ {109,36}, {94,36}, {80,36}, {65,36}, {51,36}, {36,36}, {22,36}, {4,36}, {5,51},
+ {116,22}, {102,22}, {87,22}, {73,22}, {58,22}, {44,22}, {29,22}, {15,22}, {0,22},
+ // LB0..LB17
+ {131,22}, {145,22}, {160,22}, {174,22}, {196,22}, {0,0}, {0,0}, {0,0}, {0,0},
+ {123,36}, {138,36}, {152,36}, {167,36}, {181,36}, {199,36}, {0,0}, {0,0}, {0,0},
+ // LC0..LC17
+ {102,80}, {91,65}, {76,65}, {62,65}, {47,65}, {33,65}, {58,76}, {40,80}, {22,80},
+ {98,51}, {83,51}, {69,51}, {54,51}, {40,51}, {25,51}, {0,0}, {9,65}, {4,80},
+ // LD0..LD17
+ {112,51}, {127,51}, {141,51}, {156,51}, {170,51}, {194,51}, {163,65}, {190,65}, {0,0},
+ {105,65}, {120,65}, {134,65}, {149,65}, {0,0}, {145,76}, {163,80}, {181,80}, {199,80},
+ // LE0..LE17
+ {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
+ {73,0}, {94,0}, {109,0}, {123,0}, {138,0}, {58,0}, {44,0}, {29,0}, {0,0},
+ // LF0..LF17
+ {160,0}, {174,0}, {189,0}, {203,0}, {225,0}, {239,0}, {254,0}, {254,22}, {254,36},
+ {239,22}, {239,36}, {225,22}, {225,36}, {0,0}, {239,65}, {225,80}, {239,80}, {254,80}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {59,129}, {69,129}, {80,138}, {88,154}, {95,175}, {100,200}, {104,227}, {107,255}, {128,226},
+ {59,255}, {64,255}, {69,255}, {75,255}, {80,255}, {84,255}, {88,255}, {91,255}, {95,255},
+ // LB0..LB17
+ {53,255}, {48,255}, {44,255}, {40,255}, {35,255}, {255,255}, {255,255}, {255,255}, {255,255},
+ {48,138}, {40,154}, {33,175}, {28,200}, {24,227}, {21,255}, {255,255}, {255,255}, {255,255},
+ // LC0..LC17
+ {192,255}, {184,131}, {174,141}, {166,159}, {160,181}, {155,207}, {174,244}, {171,255}, {166,255},
+ {128,9}, {128,43}, {128,77}, {128,111}, {128,145}, {128,179}, {255,255}, {150,252}, {162,255},
+ // LD0..LD17
+ {0,26}, {0,60}, {0,94}, {0,128}, {0,162}, {0,218}, {227,193}, {234,245}, {255,255},
+ {195,128}, {205,135}, {214,149}, {221,169}, {255,255}, {210,244}, {213,255}, {218,255}, {222,255},
+ // LE0..LE17
+ {255,255}, {255,255}, {255,255}, {255,255}, {255,255}, {255,255}, {255,255}, {255,255}, {255,255},
+ {70,255}, {66,255}, {62,255}, {59,255}, {56,255}, {73,255}, {76,255}, {79,255}, {84,255},
+ // LF0..LF17
+ {52,255}, {49,255}, {47,255}, {44,255}, {41,255}, {38,255}, {37,255}, {25,255}, {14,255},
+ {27,255}, {15,255}, {29,255}, {17,255}, {255,255}, {241,255}, {227,255}, {229,255}, {231,255}
+};
+#elif defined(RGB_BACKLIGHT_HS60) && defined(HS60_ANSI)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA47
+ {0,0}, {4,16}, {6,32}, {10,48}, {16,0}, {24,16}, {28,32}, {36,48}, {32,0}, {40,16}, {44,32}, {52,48},
+ {48,0}, {56,16}, {60,32}, {68,48}, {64,0}, {72,16}, {76,32}, {84,48}, {80,0}, {88,16}, {92,32}, {100,48},
+ {96,0}, {104,16}, {108,32}, {116,48}, {112,0}, {120,16}, {124,32}, {132,48}, {128,0}, {136,16}, {140,32},
+ {148,48}, {144,0}, {152,16}, {156,32}, {164,48}, {160,0}, {168,16}, {172,32}, {180,48}, {176,0}, {184, 16}, {188,32},
+ {255,255},// LA48 does not exist, dummy
+ // LA49..LA50
+ {192,0}, {200,16},
+ {255,255},// LA51 does not exit, dummy
+ // LA52..LA60
+ {210,48}, {216,0}, {220,16}, {214,32}, {222,64}, {2,64}, {22,64}, {42,64}, {102,64},
+ {255,255},// LA61 does not exit, dummy
+ {162,64}, {182,64}, {202,64}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA47
+ {96,255}, {109,255}, {128,242}, {148,255}, {93,255}, {105,238}, {128,192}, {154,216}, {89,255}, {101,208}, {128,155}, {159,188},
+ {85,255}, {96,181}, {128,119}, {165,163}, {81,255}, {89,157}, {128,82}, {173,143}, {75,255}, {81,139}, {128,46}, {183,131},
+ {70,255}, {70,129}, {129,9}, {195,128}, {64,255}, {58,129}, {255,27}, {206,136}, {58,255}, {47,139}, {255,64}, {215,152},
+ {53,255}, {39,157}, {255,101}, {222,175}, {47,255}, {32,181}, {255,137}, {228,201}, {43,255}, {27,208}, {255, 174},
+ {255,255},// LA48 does not exist, dummy
+ // LA49..LA50
+ {39,255}, {23,238},
+ {255,255},// LA51 does not exit, dummy
+ // LA52..LA60
+ {235,255}, {33,255}, {19,255}, {255,233}, {224,255}, {160,255}, {164,255}, {169,255}, {188,255},
+ {255,255},// LA61 does not exit, dummy
+ {209,255}, {215,255}, {220,255}
+};
+#elif defined(RGB_BACKLIGHT_HS60) && defined(HS60_HHKB)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA60
+ {0,0}, {4,16}, {6,32}, {10,48}, {16,0}, {24,16}, {28,32}, {36,48}, {32,0}, {40,16}, {44,32}, {52,48},
+ {48,0}, {56,16}, {60,32}, {68,48}, {64,0}, {72,16}, {76,32}, {84,48}, {80,0}, {88,16}, {92,32}, {100,48},
+ {96,0}, {104,16}, {108,32}, {116,48}, {112,0}, {120,16}, {124,32}, {132,48}, {128,0}, {136,16}, {140,32},
+ {148,48}, {144,0}, {152,16}, {156,32}, {164,48}, {160,0}, {168,16}, {172,32}, {180,48}, {176,0}, {184, 16}, {188,32},
+ {224,0}, {192,0}, {200,16}, {202,48}, {224,48}, {208,0}, {220,16}, {214,32}, {220,64}, {4,64}, {24,64}, {44,64}, {112,64},
+ {255,255}, {255,255}, // LA61..LA62 does not exit, dummy
+ // LA63..LA64
+ {180,64}, {200,64}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA60
+ {96,255}, {109,255}, {128,242}, {148,255}, {93,255}, {105,238}, {128,192}, {154,216}, {89,255}, {101,208}, {128,155}, {159,188},
+ {85,255}, {96,181}, {128,119}, {165,163}, {81,255}, {89,157}, {128,82}, {173,143}, {75,255}, {81,139}, {128,46}, {183,131},
+ {70,255}, {70,129}, {129,9}, {195,128}, {64,255}, {58,129}, {255,27}, {206,136}, {58,255}, {47,139}, {255,64}, {215,152},
+ {53,255}, {39,157}, {255,101}, {222,175}, {47,255}, {32,181}, {255,137}, {228,201}, {43,255}, {27,208}, {255, 174}, {32,255},
+ {39,255}, {23,238}, {233,242}, {237,255}, {35,255}, {19,255}, {255,233}, {223,255}, {161,255}, {165,255}, {170,255}, {192,255},
+ {255,255}, {255,255}, // LA61..LA62 does not exit, dummy
+ // LA63..LA64
+ {214,255}, {219,255}
+};
+#elif defined(RGB_BACKLIGHT_HS60) //HS60_ISO
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA50
+ {0,0}, {4,16}, {6,32}, {2,48}, {16,0}, {24,16}, {28,32}, {36,48}, {32,0}, {40,16}, {44,32}, {52,48}, {48,0},
+ {56,16}, {60,32}, {68,48}, {64,0}, {72,16}, {76,32}, {84,48}, {80,0}, {88,16}, {92,32}, {100,48}, {96,0}, {104,16},
+ {108,32}, {116,48}, {112,0}, {120,16}, {124,32}, {132,48}, {128,0}, {136,16}, {140,32}, {148,48}, {144,0}, {152,16},
+ {156,32}, {164,48}, {160,0}, {168,16}, {172,32}, {180,48}, {176,0}, {184, 16}, {188,32}, {20,48}, {192,0}, {200,16},
+ {255,255},// LA51 does not exit, dummy
+ // LA52..LA60
+ {210,48}, {216,0}, {220,16}, {222,24}, {222,64}, {2,64}, {22,64}, {42,64}, {102,64},
+ {255,255},// LA61 does not exit, dummy
+ {162,64}, {182,64}, {202,64}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA50
+ {96,255}, {109,255}, {128,242}, {147,255}, {93,255}, {105,238}, {128,192}, {154,216}, {89,255}, {101,208}, {128,155}, {159,188}, {85,255},
+ {96,181}, {128,119}, {165,163}, {81,255}, {89,157}, {128,82}, {173,143}, {75,255}, {81,139}, {128,46}, {183,131}, {70,255}, {70,129},
+ {129,9}, {195,128}, {64,255}, {58,129}, {255,27}, {206,136}, {58,255}, {47,139}, {255,64}, {215,152}, {53,255}, {39,157}, {255,101},
+ {222,175}, {47,255}, {32,181}, {255,137}, {228,201}, {43,255}, {27,208}, {255, 174}, {150,246}, {39,255}, {23,238},
+ {255,255},// LA51 does not exit, dummy
+ // LA52..LA60
+ {235,255}, {33,255}, {19,255}, {10,255}, {224,255}, {160,255}, {164,255}, {169,255}, {188,255},
+ {255,255},// LA61 does not exit, dummy
+ {209,255}, {215,255}, {220,255}
+};
+#elif defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_KW_MEGA)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA60
+ {0,0}, {4,16}, {6,32}, {10,48}, {16,0}, {24,16}, {28,32}, {36,48}, {32,0}, {40,16}, {44,32}, {52,48},
+ {48,0}, {56,16}, {60,32}, {68,48}, {64,0}, {72,16}, {76,32}, {84,48}, {80,0}, {88,16}, {92,32}, {100,48},
+ {96,0}, {104,16}, {108,32}, {116,48}, {112,0}, {120,16}, {124,32}, {132,48}, {128,0}, {136,16}, {140,32},
+ {148,48}, {144,0}, {152,16}, {156,32}, {164,48}, {160,0}, {168,16}, {172,32}, {180,48}, {176,0}, {184, 16}, {188,32},
+ {160,64}, {192,0}, {200,16}, {210,48}, {224,48}, {216,0}, {220,16}, {214,32}, {224,64}, {2,64}, {22,64}, {42,64}, {102,64},
+ {255,255},// LA61 does not exit, dummy
+ //LA62..LB5
+ {176,64}, {192,64}, {208,64}, {240,0}, {240,16}, {240,48}, {240,64}, {240,32}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA60
+ {96,255}, {109,255}, {128,242}, {148,255}, {93,255}, {105,238}, {128,192}, {154,216}, {89,255}, {101,208}, {128,155}, {159,188},
+ {85,255}, {96,181}, {128,119}, {165,163}, {81,255}, {89,157}, {128,82}, {173,143}, {75,255}, {81,139}, {128,46}, {183,131},
+ {70,255}, {70,129}, {129,9}, {195,128}, {64,255}, {58,129}, {255,27}, {206,136}, {58,255}, {47,139}, {255,64}, {215,152},
+ {53,255}, {39,157}, {255,101}, {222,175}, {47,255}, {32,181}, {255,137}, {228,201}, {43,255}, {27,208}, {255, 174},
+ {208,255}, {39,255}, {23,238}, {235,255}, {235,255}, {33,255}, {19,255}, {255,233}, {224,255}, {160,255}, {164,255}, {169,255}, {188,255},
+ {255,255},// LA61 does not exit, dummy
+ //LA62..LB5
+ {221,255}, {225,255}, {229,255}, {22,255}, {12,255}, {244,255}, {234,255}, {255,255}
+};
+#elif defined(RGB_BACKLIGHT_NK87)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ {0,19}, {4,33}, {6,48}, {9,63}, {15,19}, {22,33}, {26,48}, {33,63}, {30,19}, {37,33}, {41,48}, {48,63}, {44,19}, {52,33}, {56,48}, {63,63},
+ {59,19}, {67,33}, {70,48}, {78,63}, {74,19}, {81,33}, {85,48}, {93,63}, {89,19}, {96,33}, {100,48}, {107,63}, {104,19}, {111,33}, {115,48},
+ {122,63}, {118,19}, {126,33}, {130,48}, {137,63}, {133,19}, {141,33}, {144,48}, {152,63}, {148,19}, {155,33}, {159,48}, {167,63}, {163,19},
+ {170,33}, {174,48}, {226,78}, {178,19}, {185,33}, {194,63}, {241,63}, {200,19}, {204,33}, {198,48}, {241,78}, {4,78}, {22,78}, {41,78}, {104,78},
+ {255,255}, {167,78}, {185,78}, {204,78}, {0,0}, {255,255}, {255,255}, {255,255}, {19,0}, {255,255}, {255,255}, {255,255}, {33,0}, {255,255},
+ {255,255}, {255,78}, {48,0}, {255,255}, {255,255}, {255,255}, {63,0}, {255,255}, {255,255}, {255,255}, {81,0}, {255,255}, {255,255}, {255,255},
+ {96,0}, {255,255}, {255,255}, {255,255}, {111,0}, {255,255}, {255,255}, {255,255}, {126,0}, {255,255}, {255,255}, {255,255}, {144,0}, {255,255},
+ {255,255}, {255,255}, {159,0}, {255,255}, {255,255}, {255,255}, {174,0}, {255,255}, {255,255}, {255,255}, {189,0}, {255,255}, {226,33}, {226,19},
+ {207,0}, {255,255}, {241,33}, {241,19}, {226,0}, {255,255}, {255,33}, {255,19}, {241,0}, {255,255}, {255,255}, {255,0}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ {104,255}, {120,242}, {141,246}, {157,255}, {101,255}, {119,208}, {143,210}, {162,255}, {99,251}, {118,180}, {145,183}, {165,248}, {95,230},
+ {116,153}, {148,158}, {169,232}, {91,212}, {113,126}, {152,133}, {173,218}, {87,195}, {109,100}, {158,111}, {178,207}, {81,182}, {102,75},
+ {167,92}, {184,200}, {75,172}, {89,55}, {179,79}, {190,196}, {68,167}, {67,45}, {194,75}, {196,197}, {61,166}, {43,52}, {208,82}, {201,201},
+ {55,170}, {29,70}, {220,97}, {207,210}, {48,179}, {21,93}, {227,116}, {214,255}, {43,191}, {16,119}, {216,234}, {226,255}, {36,216}, {12,153},
+ {235,155}, {216,255}, {166,255}, {169,255}, {172,255}, {186,255}, {255,255}, {201,255}, {206,255}, {210,255}, {91,255}, {255,255}, {255,255},
+ {255,255}, {88,255}, {255,255}, {255,255}, {255,255}, {85,255}, {255,255}, {255,255}, {219,255}, {82,255}, {255,255}, {255,255}, {255,255},
+ {79,255}, {255,255}, {255,255}, {255,255}, {75,255}, {255,255}, {255,255}, {255,255}, {72,255}, {255,255}, {255,255}, {255,255}, {68,255},
+ {255,255}, {255,255}, {255,255}, {64,255}, {255,255}, {255,255}, {255,255}, {60,255}, {255,255}, {255,255}, {255,255}, {56,255}, {255,255},
+ {255,255}, {255,255}, {53,255}, {255,255}, {255,255}, {255,255}, {50,255}, {255,255}, {10,194}, {29,251}, {46,255}, {255,255}, {8,222}, {27,255},
+ {42,255}, {255,255}, {7,249}, {24,255}, {40,255}, {255,255}, {255,255}, {37,255}
+};
+#elif defined(RGB_BACKLIGHT_NEBULA12)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // A1..A16
+ {0,0}, {16,0}, {32,0}, {0,16}, {16,16}, {32,16}, {0,32}, {16,32},
+ {255,255}, {255,255}, {255,255}, {255,255},
+ {32,48}, {16,48}, {0,48}, {32,32}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // A1..A16
+ {72,197}, {64,194}, {56,197}, {85,74}, {64,64}, {43,74}, {171,74}, {192,64},
+ {255,255}, {255,255}, {255,255}, {255,255},
+ {200,196}, {192,192}, {184,196}, {213,74}
+};
+#elif defined(RGB_BACKLIGHT_NEBULA68)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA60
+ {0,0}, {4,16}, {6,31}, {10,47}, {16,0}, {24,16}, {27,31}, {35,47}, {31,0}, {39,16}, {43,31}, {51,47},
+ {47,0}, {55,16}, {59,31}, {67,47}, {63,0}, {71,16}, {75,31}, {82,47}, {79,0}, {86,16}, {90,31}, {98,47},
+ {94,0}, {102,16}, {106,31}, {114,47}, {110,0}, {118,16}, {122,31}, {130,47}, {126,0}, {133,16}, {137,31},
+ {145,47}, {141,0}, {149,16}, {153,31}, {161,47}, {157,0}, {165,16}, {169,31}, {177,47}, {173,0}, {181, 16}, {184,31},
+ {159,63}, {188,0}, {196,16}, {206,47}, {220,47}, {212,0}, {216,16}, {210,31}, {220,63}, {2,63}, {22,63}, {41,63}, {100,63},
+ {255,255},// LA61 does not exit, dummy
+ //LA62..LB5
+ {179,63}, {198,63}, {224,63}, {239,0}, {239,16}, {255,16}, {255,63}, {255,0}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA60
+ {96,255}, {109,255}, {128,244}, {148,255}, {93,255}, {106,245}, {128,201}, {153,225}, {80,255}, {103,219}, {128,169}, {156,200},
+ {87,255}, {99,194}, {128,138}, {161,177}, {83,255}, {94,171}, {128,106}, {167,157}, {79,255}, {87,152}, {128,75}, {174,141}, {74,255},
+ {80,138}, {128,43}, {183,131}, {70,255}, {70,129}, {129,12}, {193,128}, {65,255}, {60,128}, {255,20}, {203,133}, {60,255},
+ {51,135}, {255,51}, {212,145}, {55,255}, {42,148}, {255,83}, {219,162}, {50,255}, {36,166}, {255,114},
+ {202,255}, {46,255}, {30,188}, {228,203}, {231,225}, {40,255}, {25,219}, {255,165}, {217,255}, {160,255}, {164,255}, {168,255}, {183,255},
+ {255,255},// LA61 does not exit, dummy
+ //LA62..LB5
+ {207,255}, {213,255}, {218,255}, {35,255}, {21,255}, {19,255}, {224,255}, {32,255}
+};
+#elif defined(RGB_BACKLIGHT_M6_B)
+// M6-B is really simple:
+// 0 3 5
+// 1 2 4
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ {0,0}, {0,16}, {16,16}, {16,0}, {32,16}, {32,0}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ {160,255}, {96,255}, {77,255}, {179,255}, {51,255}, {205,255}
+};
+#elif defined(RGB_BACKLIGHT_M10_C)
+// M10-C is really simple:
+// 0 1 2
+// 3 4 5
+// 8 7 6
+// 11 10 9
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ {0,0}, {16,0}, {32,0},
+ {0,16}, {16,16}, {32,16},
+ {32,32}, {16,32}, {0,32},
+ {32,48}, {24,48}, {16,48}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ {160,255}, {192,255}, {224,255},
+ {128,255}, {0,0}, {0,255},
+ {32,255}, {64,255}, {96,255},
+ {45,255}, {54,255}, {64,255}
+};
+#elif defined(RGB_BACKLIGHT_DAWN60)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA1..LA16
+ {104, 16}, {88 , 16}, {72 , 16}, {56 , 16}, {40 , 16}, {24 , 16}, {4 , 16}, {6 , 32},
+ {112, 0}, {96 , 0}, {80 , 0}, {64 , 0}, {48 , 0}, {32 , 0}, {16 , 0}, {0 , 0},
+
+ // LB1..LB16
+ {128, 0}, {144, 0}, {160, 0}, {176, 0}, {192, 0}, {208, 0}, {224, 0}, {214, 32},
+ {120, 16}, {136, 16}, {152, 16}, {168, 16}, {184, 16}, {200, 16}, {220, 16}, {224, 48},
+
+ // LC1..LC16
+ {100, 48}, {84 , 48}, {68 , 48}, {52 , 48}, {36 , 48}, {102, 64}, {42 , 64}, {22 , 64},
+ {108, 32}, {92 , 32}, {76 , 32}, {60 , 32}, {44 , 32}, {28 , 32}, {10 , 48}, {2 , 64},
+
+ // LD1..LD16
+ {124, 32}, {140, 32}, {156, 32}, {172, 32}, {188, 32}, {180, 48}, {202, 48}, {224, 64},
+ {116, 48}, {132, 48}, {148, 48}, {164, 48}, {160, 64}, {176, 64}, {192, 64}, {208, 64},
+
+ //RGB UNDERGLOW
+ {27 , 3}, {64 , 3}, {100, 3}, {137, 3}, {173, 3}, {209, 3}, {242, 4}, {255, 8}, {255,32}, {255,64},
+ {241,64}, {212,64}, {173,64}, {137,64}, {100,64}, {63 ,64}, {28 ,64}, {0 ,64}, {0 ,32}, {0 , 8}, //20
+};
+
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ //LA1..LA16
+ {70,129}, {80,139}, {89,157}, {96,181}, {101,208}, {105,238}, {109,255}, {128,247},
+ {64,255}, {70,255}, {75,255}, {80,255}, {85,255}, {89,255}, {93,255}, {96,255},
+ //LB1..LB16
+ {58,255}, {53,255}, {48,255}, {43,255}, {39,255}, {34,255}, {32,255}, {255,233},
+ {58,129}, {48,139}, {39,157}, {32,181}, {27,208}, {23,238}, {19,255}, {237,255},
+ //LC1..LC16
+ {183,131}, {173,143}, {165,163}, {159,188}, {154,216}, {188,255}, {170,255}, {165,255},
+ {128,9}, {128,46}, {128,82}, {128,119}, {128,155}, {128,192}, {147,255}, {161,255},
+ //LD1..LD16
+ {0,27}, {0,64}, {0,101}, {0,137}, {0,174}, {228,201}, {235,255}, {224,255},
+ {195,128}, {206,136}, {215,152}, {222,175}, {208,255}, {213,255}, {217, 255}, {222,225},
+
+ //UNDERGLOW, {A,D}
+ //1 - 10
+ {91,255}, {84,255}, {74,255}, {60,255}, {48,255}, {39,255}, {32,255}, {27,255}, {0,255}, {236,255},
+ //11 - 20
+ {234,255}, {222,255}, {213,255}, {197,255}, {180,255}, {167,255}, {152,255}, {147,255}, {128,255}, {101,255}
+};
+#elif defined(RGB_BACKLIGHT_M50_A)
+const Point g_map_led_to_point[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {255,255}, {104,16}, {88,16}, {72,16}, {56,16}, {40,16}, {24,16}, {255,255}, {255,255},
+ {104,0}, {88,0}, {72,0}, {56,0}, {40,0}, {24,0}, {0,0}, {0,16}, {255,255},
+ // LB0..LB17
+ {255,255}, {120,0}, {136,0}, {152,0}, {168,0}, {184,0}, {200,0}, {255,255}, {255,255},
+ {120,16}, {136,16}, {152,16}, {168,16}, {184,16}, {200,16}, {255,255}, {255,255}, {255,255},
+ // LC0..LC17
+ {255,255}, {112,48}, {88,48}, {72,48}, {56,48}, {40,48}, {24,48}, {0,48}, {255,255},
+ {104,32}, {88,32}, {72,32}, {56,32}, {40,32}, {24,32}, {0,32}, {255,255}, {255,255},
+ // LD0..LD17
+ {255,255}, {120,32}, {136,32}, {152,32}, {168,32}, {184,32}, {200,32}, {255,255}, {255,255},
+ {255,255}, {136,48}, {152,48}, {168,48}, {184,48}, {200,48}, {255,255}, {255,255}, {255,255}
+};
+const Point g_map_led_to_point_polar[BACKLIGHT_LED_COUNT] PROGMEM = {
+ // LA0..LA17
+ {255,255}, {73,88}, {89,104}, {99,130}, {105,162}, {110,197}, {113,233}, {255,255}, {255,255},
+ {67,255}, {73,255}, {79,255}, {84,255}, {89,255}, {93,255}, {98,255}, {116,255}, {255,255},
+ // LB0..LB17
+ {0,0}, {61,255}, {55,255}, {49,255}, {44,255}, {39,255}, {35,255}, {255,255}, {255,255},
+ {55,88}, {39,104}, {29,130}, {23,162}, {18,197}, {15,233}, {255,255}, {255,255}, {255,255},
+ // LC0..LC17
+ {255,255}, {192,255}, {183,255}, {177,255}, {172,255}, {167,255}, {163,255}, {158,255}, {255,255},
+ {183,88}, {167,104}, {157,130}, {151,162}, {146,197}, {143,233}, {140,255}, {255,255}, {255,255},
+ // LD0..LD17
+ {255,255}, {201,88}, {217,104}, {227,130}, {233,162}, {238,197}, {241,233}, {255,255}, {255,255},
+ {255,255}, {201,255}, {207,255}, {212,255}, {217,255}, {221,255}, {255,255}, {255,255}, {255,255}
+};
+#endif
+
+// This may seem counter-intuitive, but it's quite flexible.
+// For each LED, get it's position to decide what color to make it.
+// This solves the issue of LEDs (and switches) not aligning to a grid,
+// or having a large "bitmap" and sampling them.
+void map_led_to_point( uint8_t index, Point *point )
+{
+ // Slightly messy way to get Point structs out of progmem.
+ uint8_t *addr = (uint8_t*)&g_map_led_to_point[index];
+ point->x = pgm_read_byte(addr);
+ point->y = pgm_read_byte(addr+1);
+
+#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C) || defined(RGB_BACKLIGHT_HS60) || defined(RGB_BACKLIGHT_NK65) || \
+ defined(RGB_BACKLIGHT_NK87) || defined(RGB_BACKLIGHT_NEBULA68) || defined(RGB_BACKLIGHT_NEBULA12) || defined(RGB_BACKLIGHT_KW_MEGA)
+ return;
+#endif
+
+ switch (index)
+ {
+#if !defined(RGB_BACKLIGHT_DAWN60)
+ case 18+4: // LB4A
+ if ( g_config.use_split_backspace )
+ point->x -= 8;
+ break;
+#endif
+#if defined(RGB_BACKLIGHT_ZEAL60)
+ case 18+14: // LB14A
+ if ( g_config.use_iso_enter )
+ point->y += 8; // extremely pedantic
+ break;
+ case 54+5: // LD5A
+ if ( !g_config.use_iso_enter )
+ point->x -= 10;
+ break;
+ case 36+16: // LC16A
+ if ( !g_config.use_split_left_shift )
+ point->x += 8;
+ break;
+#endif
+#if defined(RGB_BACKLIGHT_ZEAL60) || defined(RGB_BACKLIGHT_M60_A)
+ case 36+0: // LC0A
+ if ( g_config.use_7u_spacebar )
+ point->x += 10;
+ break;
+ case 36+6: // LC6A
+ if ( g_config.use_7u_spacebar )
+ point->x += 4;
+ break;
+ case 54+7: // LD7A
+ if ( !g_config.use_split_right_shift )
+ point->x -= 8;
+ break;
+#endif
+#if defined(RGB_BACKLIGHT_DAWN60)
+ case 15+6: // LB6A
+ if ( !g_config.use_split_backspace )
+ point->x += 8;
+ break;
+ case 31+6: // LC6A
+ if ( g_config.use_7u_spacebar )
+ point->x = 112;
+ break;
+ case 47+16: // LD16A
+ if ( g_config.use_7u_spacebar )
+ point->x -= 8;
+ break;
+ case 47+6: // LD6A
+ if ( g_config.use_split_right_shift )
+ point->x += 6;
+ break;
+ case 47+7: // LD7A
+ if ( g_config.use_split_right_shift )
+ point->x += 6;
+ break;
+#endif
+ }
+}
+
+void map_led_to_point_polar( uint8_t index, Point *point )
+{
+ // Slightly messy way to get Point structs out of progmem.
+ uint8_t *addr = (uint8_t*)&g_map_led_to_point_polar[index];
+ point->x = pgm_read_byte(addr);
+ point->y = pgm_read_byte(addr+1);
+}
+
+//
+// Maps switch matrix coordinate (row,col) to LED index
+//
+
+
+#if defined(RGB_BACKLIGHT_ZEAL65)
+// Note: Left spacebar stab is at 4,2 (LC7)
+// Right spacebar stab is at 4,9 (D14)
+//
+// A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B6
+// A7, A6, A5, A4, A3, A2, A1, A0, B9, B10, B11, B12, B13, B14, B7
+// A8, C14, C13, C12, C11, C10, C9, D0, D1, D2, D3, D4, D5, B5, B8
+// C16, C15, C5, C4, C3, C2, C1, D9, D10, D11, D12, D6, D7, D8, B15
+// C17, C8, C7, ---, ---, ---, ---, C0, ---, D14, D15, D16, D17, B17, B16
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4, 18+6 },
+ { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14, 18+7 },
+ { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 18+5, 18+8 },
+ { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+15 },
+ { 36+17, 36+8, 36+7, 255, 255, 255, 255, 36+0, 255, 54+14, 54+15, 54+16, 54+17, 18+17, 18+16 }
+};
+#elif defined(RGB_BACKLIGHT_KOYU)
+// Note: Left spacebar stab is at 4,4 (LC6)
+// Right spacebar stab is at 4,10 (D14)
+//
+// A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B6
+// A7, A6, A5, A4, A3, A2, A1, A0, B9, B10, B11, B12, B13, B14, B7
+// A8, C14, C13, C12, C11, C10, C9, D0, D1, D2, D3, D4, D5, B5, B8
+// C16, C15, C5, C4, C3, C2, C1, D9, D10, D11, D12, D6, D7, D8, B15
+// C17, C8, C7, C6, ---, ---, ---, C0, ---, ---, D14, D15, D16, B17, B16
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4, 18+6 },
+ { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14, 18+7 },
+ { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 18+5, 18+8 },
+ { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+15 },
+ { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 255, 54+14, 54+15, 54+16, 18+17, 18+16 }
+};
+#elif defined(RGB_BACKLIGHT_M65_B) || defined(RGB_BACKLIGHT_M65_BX)
+// Note: Left spacebar stab is at 4,4 (LC6)
+// Right spacebar stab is at 4,10 (D14)
+// (B6)
+// A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4, B7
+// A7, A6, A5, A4, A3, A2, A1, A0, B9, B10, B11, B12, B13, B14, B8
+// A8, C14, C13, C12, C11, C10, C9, D0, D1, D2, D3, D4, D5, B5, B15
+// C16, C15, C5, C4, C3, C2, C1, D9, D10, D11, D12, D6, D7, D8, B16
+// C17, C8, C7, C6, ---, ---, ---, C0, ---, ---, D14, D15, D16, D17, B17
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4, 18+7 },
+ { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14, 18+8 },
+ { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 18+5, 18+15 },
+ { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8, 18+16 },
+ { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 255, 54+14, 54+15, 54+16, 54+17, 18+17 }
+};
+#elif defined(RGB_BACKLIGHT_ZEAL60) || defined(RGB_BACKLIGHT_M60_A)
+// Note: Left spacebar stab is at 4,3 (LC6)
+// Right spacebar stab is at 4,9 (LD13) or 4,10 (LD14)
+//
+// A17, A16, A15, A14, A13, A12, A11, A10, A9, B0, B1, B2, B3, B4,
+// A7, A6, A5, A4, A3, A2, A1, A0, B9, B10, B11, B12, B13, B14,
+// A8, C14, C13, C12, C11, C10, C9, D0, D1, D2, D3, D4, D5, B5,
+// C16, C15, C5, C4, C3, C2, C1, D9, D10, D11, D12, D6, D7, D8,
+// C17, C8, C7, C6, ---, ---, ---, C0, ---, D13, D14, D15, D16, D17,
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4 },
+ { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14 },
+ { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 18+5 },
+ { 36+16, 36+15, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8 },
+ { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 54+13, 54+14, 54+15, 54+16, 54+17 }
+};
+#elif defined(RGB_BACKLIGHT_WT60_B) || defined(RGB_BACKLIGHT_WT60_BX) || defined(RGB_BACKLIGHT_WT60_C)
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4 },
+ { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14 },
+ { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 18+5 },
+ { 36+16, 255, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 54+8 },
+ { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 255, 54+14, 54+15, 54+16, 54+17 }
+};
+#elif defined(RGB_BACKLIGHT_U80_A)
+// Note: Left spacebar stab is at 5,3 (LC6)
+// Right spacebar stab is at 5,10 (LD14)
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 72+17, 72+16, 72+15, 72+14, 72+9, 72+10, 72+11, 72+12, 72+13, 90+0, 90+1, 90+2, 90+3, 255, 90+4, 90+5, 90+6 },
+ { 0+17, 0+16, 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+0, 18+1, 18+2, 18+3, 18+4, 90+11, 90+9, 90+7 },
+ { 0+7, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 0+0, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14, 90+12, 90+10, 90+8 },
+ { 0+8, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+0, 54+1, 54+2, 54+3, 54+4, 54+5, 255, 255, 255, 255 },
+ { 36+16, 255, 36+5, 36+4, 36+3, 36+2, 36+1, 54+9, 54+10, 54+11, 54+12, 54+6, 54+7, 255, 255, 90+14, 255 },
+ { 36+17, 36+8, 36+7, 36+6, 255, 255, 255, 36+0, 255, 255, 54+14, 54+15, 54+16, 54+17, 90+15, 90+16, 90+17 }
+};
+#elif defined(RGB_BACKLIGHT_HS60) && defined(HS60_ANSI)
+//
+// LA1, LA5, LA9, LA13, LA17, LA21, LA25, LA29, LA33, LA37, LA41, LA45, LA49, LA53,
+// LA2, LA6, LA10, LA14, LA18, LA22, LA26, LA30, LA34, LA38, LA42, LA46, LA50, ---,
+// LA3, LA7, LA11, LA15, LA19, LA23, LA27, LA31, LA35, LA39, LA43, LA47, LA54, LA55,
+// LA4, ---, LA8, LA12, LA16, LA20, LA24, LA28, LA32, LA36, LA40, LA44, ---, LA52,
+// LA57, LA58, LA59, ---, ---, ---, LA60, ---, ---, ---, LA62, LA63, LA64, LA56
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 1-1, 5-1, 9-1, 13-1, 17-1, 21-1, 25-1, 29-1, 33-1, 37-1, 41-1, 45-1, 49-1, 53-1 },
+ { 2-1, 6-1, 10-1, 14-1, 18-1, 22-1, 26-1, 30-1, 34-1, 38-1, 42-1, 46-1, 50-1, 255 },
+ { 3-1, 7-1, 11-1, 15-1, 19-1, 23-1, 27-1, 31-1, 35-1, 39-1, 43-1, 47-1, 54-1, 55-1 },
+ { 4-1, 255, 8-1, 12-1, 16-1, 20-1, 24-1, 28-1, 32-1, 36-1, 40-1, 44-1, 255, 52-1 },
+ { 57-1, 58-1, 59-1, 255, 255, 255, 60-1, 255, 255, 255, 62-1, 63-1, 64-1, 56-1 }
+};
+#elif defined(RGB_BACKLIGHT_HS60) && defined(HS60_HHKB)
+//
+// LA1, LA5, LA9, LA13, LA17, LA21, LA25, LA29, LA33, LA37, LA41, LA45, LA49, LA53,
+// LA2, LA6, LA10, LA14, LA18, LA22, LA26, LA30, LA34, LA38, LA42, LA46, LA50, LA48,
+// LA3, LA7, LA11, LA15, LA19, LA23, LA27, LA31, LA35, LA39, LA43, LA47, LA54, LA55,
+// LA4, ---, LA8, LA12, LA16, LA20, LA24, LA28, LA32, LA36, LA40, LA44, LA51, LA52,
+// LA57, LA58, LA59, ---, ---, ---, LA60, ---, ---, ---, ---, LA63, LA64, LA56
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 1-1, 5-1, 9-1, 13-1, 17-1, 21-1, 25-1, 29-1, 33-1, 37-1, 41-1, 45-1, 49-1, 53-1 },
+ { 2-1, 6-1, 10-1, 14-1, 18-1, 22-1, 26-1, 30-1, 34-1, 38-1, 42-1, 46-1, 50-1, 48-1 },
+ { 3-1, 7-1, 11-1, 15-1, 19-1, 23-1, 27-1, 31-1, 35-1, 39-1, 43-1, 47-1, 54-1, 55-1 },
+ { 4-1, 255, 8-1, 12-1, 16-1, 20-1, 24-1, 28-1, 32-1, 36-1, 40-1, 44-1, 51-1, 52-1 },
+ { 57-1, 58-1, 59-1, 255, 255, 255, 60-1, 255, 255, 255, 255, 63-1, 64-1, 56-1 }
+};
+#elif defined(RGB_BACKLIGHT_HS60) //HS60_ISO
+//
+// LA1, LA5, LA9, LA13, LA17, LA21, LA25, LA29, LA33, LA37, LA41, LA45, LA49, LA53,
+// LA2, LA6, LA10, LA14, LA18, LA22, LA26, LA30, LA34, LA38, LA42, LA46, LA50, ---,
+// LA3, LA7, LA11, LA15, LA19, LA23, LA27, LA31, LA35, LA39, LA43, LA47, LA54, LA55,
+// LA4, LA48, LA8, LA12, LA16, LA20, LA24, LA28, LA32, LA36, LA40, LA44, ---, LA52,
+// LA57, LA58, LA59, ---, ---, ---, LA60, ---, ---, ---, LA62, LA63, LA64, LA56
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 1-1, 5-1, 9-1, 13-1, 17-1, 21-1, 25-1, 29-1, 33-1, 37-1, 41-1, 45-1, 49-1, 53-1 },
+ { 2-1, 6-1, 10-1, 14-1, 18-1, 22-1, 26-1, 30-1, 34-1, 38-1, 42-1, 46-1, 50-1, 255 },
+ { 3-1, 7-1, 11-1, 15-1, 19-1, 23-1, 27-1, 31-1, 35-1, 39-1, 43-1, 47-1, 54-1, 55-1 },
+ { 4-1, 48-1, 8-1, 12-1, 16-1, 20-1, 24-1, 28-1, 32-1, 36-1, 40-1, 44-1, 255, 52-1 },
+ { 57-1, 58-1, 59-1, 255, 255, 255, 60-1, 255, 255, 255, 62-1, 63-1, 64-1, 56-1 }
+};
+#elif defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA68) || defined(RGB_BACKLIGHT_KW_MEGA)
+//
+// LA1, LA5, LA9, LA13, LA17, LA21, LA25, LA29, LA33, LA37, LA41, LA45, LA49, LA53, LB1,
+// LA2, LA6, LA10, LA14, LA18, LA22, LA26, LA30, LA34, LA38, LA42, LA46, LA50, ---, LB2,
+// LA3, LA7, LA11, LA15, LA19, LA23, LA27, LA31, LA35, LA39, LA43, LA47, LA54, LA55, LB5,
+// LA4, ---, LA8, LA12, LA16, LA20, LA24, LA28, LA32, LA36, LA40, LA44, LA51, LA52, LB3,
+// LA57, LA58, LA59, ---, ---, ---, LA60, ---, ---, LA48, LA62, LA63, LA64, LA56, LB4
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 1-1, 5-1, 9-1, 13-1, 17-1, 21-1, 25-1, 29-1, 33-1, 37-1, 41-1, 45-1, 49-1, 53-1, 1+64-1 },
+ { 2-1, 6-1, 10-1, 14-1, 18-1, 22-1, 26-1, 30-1, 34-1, 38-1, 42-1, 46-1, 50-1, 255, 2+64-1 },
+ { 3-1, 7-1, 11-1, 15-1, 19-1, 23-1, 27-1, 31-1, 35-1, 39-1, 43-1, 47-1, 54-1, 55-1, 5+64-1 },
+ { 4-1, 255, 8-1, 12-1, 16-1, 20-1, 24-1, 28-1, 32-1, 36-1, 40-1, 44-1, 51-1, 52-1, 3+64-1 },
+ { 57-1, 58-1, 59-1, 255, 255, 255, 60-1, 255, 255, 48-1, 62-1, 63-1, 64-1, 56-1, 4+64-1 }
+};
+#elif defined(RGB_BACKLIGHT_NK87)
+//
+// LB1, LB5, LB9, LB13, LB17, LB21, LB25, LB29, LB33, LB37, LB41, LB45, LB49, LB53, LB57, LB61, LB64,
+// LA1, LA5, LA9, LA13, LA17, LA21, LA25, LA29, LA33, LA37, LA41, LA45, LA49, LA53, LB52, LB56, LB60,
+// LA2, LA6, LA10, LA14, LA18, LA22, LA26, LA30, LA34, LA38, LA42, LA46, LA50, ---, LB51, LB55, LB59,
+// LA3, LA7, LA11, LA15, LA19, LA23, LA27, LA31, LA35, LA39, LA43, LA47, LA54, LA55, ---, ---, ---,
+// LA4, ---, LA8, LA12, LA16, LA20, LA24, LA28, LA32, LA36, LA40, LA44, LA51, ---, ---, LA52, ---,
+// LA57, LA58, LA59, ---, ---, ---, LA60, ---, ---, ---, ---, LA62, LA63, LA64, LA48, LA56, LB12
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 1+64-1, 5+64-1, 9+64-1, 13+64-1, 17+64-1, 21+64-1, 25+64-1, 29+64-1, 33+64-1, 37+64-1, 41+64-1, 45+64-1, 49+64-1, 53+64-1, 57+64-1, 61+64-1, 64+64-1 },
+ { 1-1, 5-1, 9-1, 13-1, 17-1, 21-1, 25-1, 29-1, 33-1, 37-1, 41-1, 45-1, 49-1, 53-1, 52+64-1, 56+64-1, 60+64-1 },
+ { 2-1, 6-1, 10-1, 14-1, 18-1, 22-1, 26-1, 30-1, 34-1, 38-1, 42-1, 46-1, 50-1, 255, 51+64-1, 55+64-1, 59+64-1 },
+ { 3-1, 7-1, 11-1, 15-1, 19-1, 23-1, 27-1, 31-1, 35-1, 39-1, 43-1, 47-1, 54-1, 55-1, 255, 255, 255 },
+ { 4-1, 255, 8-1, 12-1, 16-1, 20-1, 24-1, 28-1, 32-1, 36-1, 40-1, 44-1, 51-1, 255, 255, 52-1, 255 },
+ { 57-1, 58-1, 59-1, 255, 255, 255, 60-1, 255, 255, 255, 255, 62-1, 63-1, 64-1, 48-1, 56-1, 12+64-1 }
+};
+#elif defined(RGB_BACKLIGHT_NEBULA12)
+//
+// A1, A2, A3,
+// A4, A5, A6,
+// A7, A8, A16,
+// A15, A14, A13,
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 1-1, 2-1, 3-1 },
+ { 4-1, 5-1, 6-1 },
+ { 7-1, 8-1, 16-1 },
+ { 15-1, 14-1, 13-1 }
+};
+#elif defined(RGB_BACKLIGHT_M6_B)
+// M6-B is really simple:
+// 0 3 5
+// 1 2 4
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0, 3, 5, 1, 2, 4 }
+};
+#elif defined(RGB_BACKLIGHT_M10_C)
+// M10-C is really simple:
+// 0 1 2
+// 3 4 5
+// 8 7 6
+// 11 10 9
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0, 1, 2, 3, 4, 5, 8, 7, 6, 10 }
+};
+#elif defined(RGB_BACKLIGHT_DAWN60)
+//Dawn60
+// A16, A15, A14, A13, A12, A11, A10, A9, B1, B2, B3, B4, B5, B6,
+// A7, A6, A5, A4, A3, A2, A1, B9, B10, B11, B12, B13, B14, B15,
+// A8, C14, C13, C12, C11, C10, C9, D1, D2, D3, D4, D5, B8, B7,
+// C15, C5, C4, C3, C2, C1, D9, D10, D11, D12, ---, D6, D7, B16,
+// C16, C8, C7, ---, ---, C6, ---, ---, ---, D13, D14, D15, D16, D8,
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { -1+16, -1+15, -1+14, -1+13, -1+12, -1+11, -1+10, -1+9 , 15+1 , 15+2 , 15+3 , 15+4 , 15+5 , 15+6 },
+ { -1+7 , -1+6 , -1+5 , -1+4 , -1+3 , -1+2 , -1 +1, 15+9 , 15+10, 15+11, 15+12, 15+13, 15+14, 15+15},
+ { -1+8 , 31+14, 31+13, 31+12, 31+11, 31+10, 31+9 , 47+1 , 47+2 , 47+3 , 47+4 , 47+5 , 15+8 , 15+7 },
+ { 31+15, 31+5 , 31+4 , 31+3 , 31+2 , 31+1 , 47+9 , 47+10, 47+11, 47+12, 255 ,47+6 , 47+7 , 15+16},
+ { 31+16, 31+8 , 31+7 , 255 , 255 , 31+6 , 255 , 255 , 255 , 47+13, 47+14, 47+15, 47+16, 47+8 }
+};
+#elif defined(RGB_BACKLIGHT_M50_A)
+// LA15, LA14, LA13, LA12, LA11, LA10, LA9, LB1, LB2, LB3, LB4, LB5, LB6
+// LA16, LA6, LA5, LA4, LA3, LA2, LA1, LB9, LB10, LB11, LB12, LB13, LB14
+// LC15, LC14, LC13, LC12, LC11, LC10, LC9, LD1, LD2, LD3, LD4, LD5, LD6
+// LC7, LC6, LC5, LC4, LC3, LC2, LC1, ----, LD10, LD11, LD12, LD13, LD14
+const uint8_t g_map_row_column_to_led[MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+ { 0+15, 0+14, 0+13, 0+12, 0+11, 0+10, 0+9, 18+1, 18+2, 18+3, 18+4, 18+5, 18+6 },
+ { 0+16, 0+6, 0+5, 0+4, 0+3, 0+2, 0+1, 18+9, 18+10, 18+11, 18+12, 18+13, 18+14 },
+ { 36+15, 36+14, 36+13, 36+12, 36+11, 36+10, 36+9, 54+1, 54+2, 54+3, 54+4, 54+5, 54+6 },
+ { 36+7, 36+6, 36+5, 36+4, 36+3, 36+2, 36+1, 255, 54+10, 54+11, 54+12, 54+13, 54+14 },
+};
+#endif
+
+void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led )
+{
+ *led = 255;
+ if ( row < MATRIX_ROWS && column < MATRIX_COLS )
+ {
+ *led = pgm_read_byte(&g_map_row_column_to_led[row][column]);
+ }
+}
+
+void backlight_update_pwm_buffers(void)
+{
+#if defined(RGB_BACKLIGHT_M6_B)
+ IS31FL3218_update_pwm_buffers();
+#elif defined(RGB_BACKLIGHT_M10_C)
+ IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, 0 );
+ IS31FL3731_update_led_control_registers( ISSI_ADDR_1, 0 );
+#elif defined(RGB_BACKLIGHT_HS60)
+ IS31FL3733_update_pwm_buffers( ISSI_ADDR_1, 0 );
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
+#elif defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA68) || defined(RGB_BACKLIGHT_NK87) || defined(RGB_BACKLIGHT_KW_MEGA)
+ IS31FL3733_update_pwm_buffers( ISSI_ADDR_1, 0 );
+ IS31FL3733_update_pwm_buffers( ISSI_ADDR_2, 1 );
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 );
+#elif defined(RGB_BACKLIGHT_NEBULA12)
+ IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, 0 );
+ IS31FL3731_update_led_control_registers( ISSI_ADDR_1, 0 );
+#elif defined(RGB_BACKLIGHT_U80_A)
+ static uint8_t driver = 0;
+ switch ( driver )
+ {
+ case 0:
+ IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, 0 );
+ break;
+ case 1:
+ IS31FL3731_update_pwm_buffers( ISSI_ADDR_2, 1 );
+ break;
+ case 2:
+ IS31FL3731_update_pwm_buffers( ISSI_ADDR_3, 2 );
+ break;
+ }
+ if ( ++driver > 2 )
+ {
+ driver = 0;
+ }
+#else
+ IS31FL3731_update_pwm_buffers( ISSI_ADDR_1, 0 );
+ IS31FL3731_update_pwm_buffers( ISSI_ADDR_2, 1 );
+ IS31FL3731_update_led_control_registers( ISSI_ADDR_1, 0 );
+ IS31FL3731_update_led_control_registers( ISSI_ADDR_2, 1 );
+#endif
+}
+
+void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
+{
+#if defined(RGB_BACKLIGHT_M6_B)
+ IS31FL3218_set_color( index, red, green, blue );
+#elif defined(RGB_BACKLIGHT_HS60) || defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA68) || defined(RGB_BACKLIGHT_KW_MEGA)
+ IS31FL3733_set_color( index, red, green, blue );
+#elif defined(RGB_BACKLIGHT_NK87)
+ // This is done to avoid indicator LEDs being set
+ if (( index != 63+64-1 ) && ( index != 48+64-1 )) {
+ IS31FL3733_set_color( index, red, green, blue );
+ }
+#elif defined(RGB_BACKLIGHT_DAWN60)
+ if( index < DRIVER_LED_TOTAL ) {
+ IS31FL3731_set_color( index, red, green, blue );
+ } else {
+ g_ws2812_leds[index - DRIVER_LED_TOTAL].r = red;
+ g_ws2812_leds[index - DRIVER_LED_TOTAL].g = green;
+ g_ws2812_leds[index - DRIVER_LED_TOTAL].b = blue;
+ ws2812_setleds(g_ws2812_leds, WS2812_LED_TOTAL);
+ }
+#else
+ IS31FL3731_set_color( index, red, green, blue );
+#endif
+}
+
+void backlight_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
+{
+#if defined(RGB_BACKLIGHT_M6_B)
+ IS31FL3218_set_color_all( red, green, blue );
+#elif defined(RGB_BACKLIGHT_HS60) || defined(RGB_BACKLIGHT_NK65) || defined(RGB_BACKLIGHT_NEBULA68) || defined(RGB_BACKLIGHT_KW_MEGA)
+ // This is done to avoid indicator LEDs being set
+ for (int i = 0; i < BACKLIGHT_LED_COUNT; i++) {
+ IS31FL3733_set_color(i, red, green, blue);
+ }
+#elif defined(RGB_BACKLIGHT_NK87)
+ // This is done to avoid indicator LEDs being set
+ for (int i = 0; i < BACKLIGHT_LED_COUNT; i++) {
+ if (( i != 63+64-1 ) && ( i != 48+64-1 )) {
+ IS31FL3733_set_color(i, red, green, blue);
+ }
+ }
+#elif defined(RGB_BACKLIGHT_DAWN60)
+ IS31FL3731_set_color_all( red, green, blue );
+ for (uint8_t i = 0; i < WS2812_LED_TOTAL; i++) {
+ g_ws2812_leds[i].r = red;
+ g_ws2812_leds[i].g = green;
+ g_ws2812_leds[i].b = blue;
+ }
+ ws2812_setleds(g_ws2812_leds, WS2812_LED_TOTAL);
+#else
+ IS31FL3731_set_color_all( red, green, blue );
+#endif
+}
+
+void backlight_set_key_hit(uint8_t row, uint8_t column)
+{
+ uint8_t led;
+ map_row_column_to_led(row,column,&led);
+ g_key_hit[led] = 0;
+
+ g_any_key_hit = 0;
+}
+
+#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA68) && !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_NK87) && !defined(RGB_BACKLIGHT_KW_MEGA)
+// This is (F_CPU/1024) / 20 Hz
+// = 15625 Hz / 20 Hz
+// = 781
+#define TIMER3_TOP 781
+
+void backlight_timer_init(void)
+{
+ static uint8_t backlight_timer_is_init = 0;
+ if ( backlight_timer_is_init )
+ {
+ return;
+ }
+ backlight_timer_is_init = 1;
+
+ // Timer 3 setup
+ TCCR3B = _BV(WGM32) | // CTC mode OCR3A as TOP
+ _BV(CS32) | _BV(CS30); // prescale by /1024
+ // Set TOP value
+ uint8_t sreg = SREG;
+ cli();
+
+ OCR3AH = (TIMER3_TOP >> 8) & 0xff;
+ OCR3AL = TIMER3_TOP & 0xff;
+ SREG = sreg;
+}
+
+void backlight_timer_enable(void)
+{
+ TIMSK3 |= _BV(OCIE3A);
+}
+
+void backlight_timer_disable(void)
+{
+ TIMSK3 &= ~_BV(OCIE3A);
+}
+#elif defined(RGB_BACKLIGHT_NEBULA12) //STM32, use GPT with TIM3. Enable in halconf.h
+static void gpt_backlight_timer_task(GPTDriver *gptp);
+// Timer setup at 200Khz, callback at 10k ticks = 20Hz
+static GPTConfig gpt3cfg1 = {
+ .frequency = 200000U,
+ .callback = gpt_backlight_timer_task
+};
+
+void backlight_timer_init(void)
+{
+ gptStart(&GPTD3, &gpt3cfg1);
+}
+
+void backlight_timer_enable(void)
+{
+ gptStartContinuous(&GPTD3, 10000);
+}
+
+void backlight_timer_disable(void)
+{
+ gptStopTimer(&GPTD3);
+}
+#else //STM32, use GPT with TIM4. Enable in halconf.h
+static void gpt_backlight_timer_task(GPTDriver *gptp);
+// Timer setup at 200Khz, callback at 10k ticks = 20Hz
+static GPTConfig gpt4cfg1 = {
+ .frequency = 200000U,
+ .callback = gpt_backlight_timer_task
+};
+
+void backlight_timer_init(void)
+{
+ gptStart(&GPTD4, &gpt4cfg1);
+}
+
+void backlight_timer_enable(void)
+{
+ gptStartContinuous(&GPTD4, 10000);
+}
+
+void backlight_timer_disable(void)
+{
+ gptStopTimer(&GPTD4);
+}
+#endif //!defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA68) && !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_NK87) && !defined(RGB_BACKLIGHT_KW_MEGA)
+
+void backlight_set_suspend_state(bool state)
+{
+ g_suspend_state = state;
+}
+
+void backlight_set_indicator_state(uint8_t state)
+{
+ g_indicator_state = state;
+}
+
+void backlight_effect_rgb_test(void)
+{
+ // Mask out bits 4 and 5
+ // This 2-bit value will stay the same for 16 ticks.
+ switch ( (g_tick & 0x30) >> 4 )
+ {
+ case 0:
+ {
+ backlight_set_color_all( 255, 0, 0 );
+ break;
+ }
+ case 1:
+ {
+ backlight_set_color_all( 0, 255, 0 );
+ break;
+ }
+ case 2:
+ {
+ backlight_set_color_all( 0, 0, 255 );
+ break;
+ }
+ case 3:
+ {
+ backlight_set_color_all( 255, 255, 255 );
+ break;
+ }
+ }
+}
+
+#if defined(RGB_DEBUGGING_ONLY)
+// This tests the LEDs
+// Note that it will change the LED control registers
+// in the LED drivers, and leave them in an invalid
+// state for other backlight effects.
+// ONLY USE THIS FOR TESTING LEDS!
+void backlight_effect_single_LED_test(void)
+{
+ static uint8_t color = 0; // 0,1,2 for R,G,B
+ static uint8_t row = 0;
+ static uint8_t column = 0;
+
+ static uint8_t tick = 0;
+ tick++;
+
+ if ( tick > 2 )
+ {
+ tick = 0;
+ column++;
+ }
+ if ( column > 14 )
+ {
+ column = 0;
+ row++;
+ }
+ if ( row > 4 )
+ {
+ row = 0;
+ color++;
+ }
+ if ( color > 2 )
+ {
+ color = 0;
+ }
+
+ uint8_t led;
+ map_row_column_to_led( row, column, &led );
+ backlight_set_color_all( 255, 255, 255 );
+ backlight_test_led( led, color==0, color==1, color==2 );
+}
+#endif // defined(RGB_DEBUGGING_ONLY)
+
+// All LEDs off
+void backlight_effect_all_off(void)
+{
+ backlight_set_color_all( 0, 0, 0 );
+}
+
+// Solid color
+void backlight_effect_solid_color(void)
+{
+ HSV hsv = { .h = g_config.color_1.h, .s = g_config.color_1.s, .v = g_config.brightness };
+ RGB rgb = hsv_to_rgb( hsv );
+ backlight_set_color_all( rgb.r, rgb.g, rgb.b );
+}
+
+// alphas = color1, mods = color2
+void backlight_effect_alphas_mods(void)
+{
+ RGB rgb1 = hsv_to_rgb( (HSV){ .h = g_config.color_1.h, .s = g_config.color_1.s, .v = g_config.brightness } );
+ RGB rgb2 = hsv_to_rgb( (HSV){ .h = g_config.color_2.h, .s = g_config.color_2.s, .v = g_config.brightness } );
+ bool is_alpha = false;
+ for ( int row = 0; row < MATRIX_ROWS; row++ )
+ {
+ for ( int column = 0; column < MATRIX_COLS; column++ )
+ {
+ uint8_t index;
+ map_row_column_to_led( row, column, &index );
+ if ( index < BACKLIGHT_LED_COUNT )
+ {
+#if defined(RGB_BACKLIGHT_U80_A)
+ if ( row == 0 )
+ {
+ is_alpha = ( column < 16 ) && (( 0b1110000111100001 & (1<<column) ) == 0);
+ }
+ else
+ {
+ is_alpha = ( column < 16 ) && (( g_config.alphas_mods[row-1] & (1<<column) ) == 0);
+ }
+#elif defined(RGB_BACKLIGHT_NK87)
+ if ( row == 0 )
+ {
+ is_alpha = ( ( 0b11100000111100001 & (1<<column) ) == 0);
+ }
+ else
+ {
+ is_alpha = ( column < 16 ) && (( g_config.alphas_mods[row-1] & (1<<column) ) == 0);
+ }
+#else
+ is_alpha = ( g_config.alphas_mods[row] & (1<<column) ) == 0;
+#endif
+ if ( is_alpha )
+ {
+ backlight_set_color( index, rgb1.r, rgb1.g, rgb1.b );
+ }
+ else
+ {
+ backlight_set_color( index, rgb2.r, rgb2.g, rgb2.b );
+ }
+ }
+ }
+ }
+#if defined(RGB_BACKLIGHT_DAWN60)
+ for (int i = 0; i < WS2812_LED_TOTAL; i++) {
+ if ((RGB_UNDERGLOW_ALPHA_TOP_START <= i && i <= RGB_UNDERGLOW_ALPHA_TOP_END) ||
+ (RGB_UNDERGLOW_ALPHA_BOT_START <= i && i <= RGB_UNDERGLOW_ALPHA_BOT_END)) {
+ backlight_set_color(i + DRIVER_LED_TOTAL, rgb1.r, rgb1.g, rgb1.b);
+ } else {
+ backlight_set_color(i + DRIVER_LED_TOTAL, rgb2.r, rgb2.g, rgb2.b);
+ }
+ }
+#endif
+}
+
+void backlight_effect_gradient_up_down(void)
+{
+ int16_t h1 = g_config.color_1.h;
+ int16_t h2 = g_config.color_2.h;
+ int16_t deltaH = h2 - h1;
+
+ // Take the shortest path between hues
+ if ( deltaH > 127 )
+ {
+ deltaH -= 256;
+ }
+ else if ( deltaH < -127 )
+ {
+ deltaH += 256;
+ }
+ // Divide delta by 4, this gives the delta per row
+ deltaH /= 4;
+
+ int16_t s1 = g_config.color_1.s;
+ int16_t s2 = g_config.color_2.s;
+ int16_t deltaS = ( s2 - s1 ) / 4;
+
+ HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
+ RGB rgb;
+ Point point;
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ map_led_to_point( i, &point );
+ // The y range will be 0..64, map this to 0..4
+ uint8_t y = (point.y>>4);
+ // Relies on hue being 8-bit and wrapping
+ hsv.h = g_config.color_1.h + ( deltaH * y );
+ hsv.s = g_config.color_1.s + ( deltaS * y );
+ rgb = hsv_to_rgb( hsv );
+
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+}
+
+void backlight_effect_raindrops(bool initialize)
+{
+ int16_t h1 = g_config.color_1.h;
+ int16_t h2 = g_config.color_2.h;
+ int16_t deltaH = h2 - h1;
+ deltaH /= 4;
+
+ // Take the shortest path between hues
+ if ( deltaH > 127 )
+ {
+ deltaH -= 256;
+ }
+ else if ( deltaH < -127 )
+ {
+ deltaH += 256;
+ }
+
+ int16_t s1 = g_config.color_1.s;
+ int16_t s2 = g_config.color_2.s;
+ int16_t deltaS = ( s2 - s1 ) / 4;
+
+ HSV hsv;
+ RGB rgb;
+
+ // Change one LED every tick
+ uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255;
+
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ // If initialize, all get set to random colors
+ // If not, all but one will stay the same as before.
+ if ( initialize || i == led_to_change )
+ {
+ hsv.h = h1 + ( deltaH * ( rand() & 0x03 ) );
+ hsv.s = s1 + ( deltaS * ( rand() & 0x03 ) );
+ // Override brightness with global brightness control
+ hsv.v = g_config.brightness;
+
+ rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+ }
+}
+
+void backlight_effect_cycle_all(void)
+{
+ uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF;
+
+ // Relies on hue being 8-bit and wrapping
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ uint16_t offset2 = g_key_hit[i]<<2;
+#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA68) && !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_NK87) && !defined(RGB_BACKLIGHT_KW_MEGA)
+ // stabilizer LEDs use spacebar hits
+ if ( i == 36+6 || i == 54+13 || // LC6, LD13
+ ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14
+ {
+ offset2 = g_key_hit[36+0]<<2;
+ }
+#endif
+ offset2 = (offset2<=63) ? (63-offset2) : 0;
+
+ HSV hsv = { .h = offset+offset2, .s = 255, .v = g_config.brightness };
+ RGB rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+}
+
+void backlight_effect_cycle_left_right(void)
+{
+ uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF;
+ HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
+ RGB rgb;
+ Point point;
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ uint16_t offset2 = g_key_hit[i]<<2;
+#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA68) && !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_NK87) && !defined(RGB_BACKLIGHT_KW_MEGA)
+ // stabilizer LEDs use spacebar hits
+ if ( i == 36+6 || i == 54+13 || // LC6, LD13
+ ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14
+ {
+ offset2 = g_key_hit[36+0]<<2;
+ }
+#endif
+ offset2 = (offset2<=63) ? (63-offset2) : 0;
+
+ map_led_to_point( i, &point );
+ // Relies on hue being 8-bit and wrapping
+ hsv.h = point.x + offset + offset2;
+ rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+}
+
+void backlight_effect_cycle_up_down(void)
+{
+ uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF;
+ HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
+ RGB rgb;
+ Point point;
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ uint16_t offset2 = g_key_hit[i]<<2;
+#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_DAWN60) && !defined(RGB_BACKLIGHT_NEBULA68) && !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_NK87) && !defined(RGB_BACKLIGHT_KW_MEGA)
+ // stabilizer LEDs use spacebar hits
+ if ( i == 36+6 || i == 54+13 || // LC6, LD13
+ ( g_config.use_7u_spacebar && i == 54+14 ) ) // LD14
+ {
+ offset2 = g_key_hit[36+0]<<2;
+ }
+#endif
+ offset2 = (offset2<=63) ? (63-offset2) : 0;
+
+ map_led_to_point( i, &point );
+ // Relies on hue being 8-bit and wrapping
+ hsv.h = point.y + offset + offset2;
+ rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+}
+
+void backlight_effect_jellybean_raindrops( bool initialize )
+{
+ HSV hsv;
+ RGB rgb;
+
+ // Change one LED every tick
+ uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255;
+
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ // If initialize, all get set to random colors
+ // If not, all but one will stay the same as before.
+ if ( initialize || i == led_to_change )
+ {
+ hsv.h = rand() & 0xFF;
+ hsv.s = rand() & 0xFF;
+ // Override brightness with global brightness control
+ hsv.v = g_config.brightness;;
+
+ rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+ }
+}
+
+void backlight_effect_cycle_radial1(void)
+{
+ uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF;
+ HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness };
+ RGB rgb;
+ Point point;
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ map_led_to_point_polar( i, &point );
+ // Relies on hue being 8-bit and wrapping
+ hsv.h = point.x + offset;
+ hsv.s = point.y;
+ rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+}
+
+void backlight_effect_cycle_radial2(void)
+{
+ uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF;
+
+ HSV hsv = { .h = 0, .s = g_config.color_1.s, .v = g_config.brightness };
+ RGB rgb;
+ Point point;
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ map_led_to_point_polar( i, &point );
+ uint8_t offset2 = offset + point.x;
+ if ( offset2 & 0x80 )
+ {
+ offset2 = ~offset2;
+ }
+ offset2 = offset2 >> 2;
+ hsv.h = g_config.color_1.h + offset2;
+ hsv.s = 127 + ( point.y >> 1 );
+ rgb = hsv_to_rgb( hsv );
+ backlight_set_color( i, rgb.r, rgb.g, rgb.b );
+ }
+}
+
+#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C)
+void backlight_effect_custom_colors(void)
+{
+ RGB rgb;
+ for ( uint8_t i = 0; i < RGB_BACKLIGHT_CUSTOM_COLORS_COUNT; i++ )
+ {
+ HSV hsv = { .h = g_config.custom_color[i].h, .s = g_config.custom_color[i].s, .v = g_config.brightness };
+ rgb = hsv_to_rgb( hsv );
+ uint8_t led;
+ map_row_column_to_led( 0, i, &led );
+ backlight_set_color( led, rgb.r, rgb.g, rgb.b );
+#if defined(RGB_BACKLIGHT_M10_C)
+ // Set stab LEDs with the same color
+ if ( led == 10 ) {
+ backlight_set_color( 9, rgb.r, rgb.g, rgb.b );
+ backlight_set_color( 11, rgb.r, rgb.g, rgb.b );
+ }
+#endif
+ }
+}
+#endif
+
+void backlight_effect_indicators_set_colors( uint8_t index, HS color )
+{
+ HSV hsv = { .h = color.h, .s = color.s, .v = g_config.brightness };
+ RGB rgb = hsv_to_rgb( hsv );
+ if ( index == 254 )
+ {
+ backlight_set_color_all( rgb.r, rgb.g, rgb.b );
+ }
+ else
+ {
+ backlight_set_color( index, rgb.r, rgb.g, rgb.b );
+
+ // If the spacebar LED is the indicator,
+ // do the same for the spacebar stabilizers
+ if ( index == 36+0 ) // LC0
+ {
+#if defined(RGB_BACKLIGHT_ZEAL65)
+ backlight_set_color( 36+7, rgb.r, rgb.g, rgb.b ); // LC7
+ backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14
+#elif defined(RGB_BACKLIGHT_KOYU) || defined(RGB_BACKLIGHT_M65_B) || defined(RGB_BACKLIGHT_M65_BX)
+ backlight_set_color( 36+6, rgb.r, rgb.g, rgb.b ); // LC6
+ backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14
+#elif defined(RGB_BACKLIGHT_ZEAL60) || defined(RGB_BACKLIGHT_M60_A)
+ backlight_set_color( 36+6, rgb.r, rgb.g, rgb.b ); // LC6
+ backlight_set_color( 54+13, rgb.r, rgb.g, rgb.b ); // LD13
+ if ( g_config.use_7u_spacebar )
+ {
+ backlight_set_color( 54+14, rgb.r, rgb.g, rgb.b ); // LD14
+ }
+#endif
+ }
+ }
+}
+
+// This runs after another backlight effect and replaces
+// colors already set
+void backlight_effect_indicators(void)
+{
+ if ( g_config.caps_lock_indicator.index != 255 &&
+ ( g_indicator_state & (1<<USB_LED_CAPS_LOCK) ) )
+ {
+ backlight_effect_indicators_set_colors( g_config.caps_lock_indicator.index, g_config.caps_lock_indicator.color );
+ }
+ // This if/else if structure allows higher layers to
+ // override lower ones. If we set layer 3's indicator
+ // to none, then it will NOT show layer 2 or layer 1
+ // indicators, even if those layers are on via the
+ // MO13/MO23 Fn combo magic.
+ //
+ // Basically we want to handle the case where layer 3 is
+ // still the backlight configuration layer and we don't
+ // want "all LEDs" indicators hiding the backlight effect,
+ // but still allow end users to do whatever they want.
+ if ( IS_LAYER_ON(3) )
+ {
+ if ( g_config.layer_3_indicator.index != 255 )
+ {
+ backlight_effect_indicators_set_colors( g_config.layer_3_indicator.index, g_config.layer_3_indicator.color );
+ }
+ }
+ else if ( IS_LAYER_ON(2) )
+ {
+ if ( g_config.layer_2_indicator.index != 255 )
+ {
+ backlight_effect_indicators_set_colors( g_config.layer_2_indicator.index, g_config.layer_2_indicator.color );
+ }
+ }
+ else if ( IS_LAYER_ON(1) )
+ {
+ if ( g_config.layer_1_indicator.index != 255 )
+ {
+ backlight_effect_indicators_set_colors( g_config.layer_1_indicator.index, g_config.layer_1_indicator.color );
+ }
+ }
+}
+
+#if !defined(RGB_BACKLIGHT_HS60) && !defined(RGB_BACKLIGHT_NK65) && !defined(RGB_BACKLIGHT_NEBULA68) && !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_NK87) && !defined(RGB_BACKLIGHT_KW_MEGA)
+ISR(TIMER3_COMPA_vect)
+#else //STM32 interrupt
+static void gpt_backlight_timer_task(GPTDriver *gptp)
+#endif
+{
+ // delay 1 second before driving LEDs or doing anything else
+ static uint8_t startup_tick = 0;
+ if ( startup_tick < 20 )
+ {
+ startup_tick++;
+ return;
+ }
+
+ g_tick++;
+
+ if ( g_any_key_hit < 0xFFFFFFFF )
+ {
+ g_any_key_hit++;
+ }
+
+ for ( int led = 0; led < BACKLIGHT_LED_COUNT; led++ )
+ {
+ if ( g_key_hit[led] < 255 )
+ {
+ g_key_hit[led]++;
+ }
+ }
+
+ // Factory default magic value
+ if ( g_config.effect == 255 )
+ {
+ backlight_effect_rgb_test();
+ return;
+ }
+
+ // 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 && g_config.disable_when_usb_suspended) ||
+ (g_config.disable_after_timeout > 0 && g_any_key_hit > g_config.disable_after_timeout * 60 * 20));
+ uint8_t effect = suspend_backlight ? 0 : g_config.effect;
+
+ // Keep track of the effect used last time,
+ // detect change in effect, so each effect can
+ // have an optional initialization.
+ static uint8_t effect_last = 255;
+ bool initialize = effect != effect_last;
+ effect_last = effect;
+
+ // this gets ticked at 20 Hz.
+ // each effect can opt to do calculations
+ // and/or request PWM buffer updates.
+ switch ( effect )
+ {
+ case 0:
+ backlight_effect_all_off();
+ break;
+ case 1:
+ backlight_effect_solid_color();
+ break;
+ case 2:
+#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C)
+ backlight_effect_custom_colors();
+#else
+ backlight_effect_alphas_mods();
+#endif
+ break;
+ case 3:
+ backlight_effect_gradient_up_down();
+ break;
+ case 4:
+ backlight_effect_raindrops( initialize );
+ break;
+ case 5:
+ backlight_effect_cycle_all();
+ break;
+ case 6:
+ backlight_effect_cycle_left_right();
+ break;
+ case 7:
+ backlight_effect_cycle_up_down();
+ break;
+ case 8:
+ backlight_effect_jellybean_raindrops( initialize );
+ break;
+ case 9:
+ backlight_effect_cycle_radial1();
+ break;
+ case 10:
+ backlight_effect_cycle_radial2();
+ break;
+ default:
+ backlight_effect_all_off();
+ break;
+ }
+
+ if ( ! suspend_backlight )
+ {
+#if !defined(RGB_BACKLIGHT_M6_B) && !defined(RGB_BACKLIGHT_M10_C)
+ backlight_effect_indicators();
+#endif
+ }
+}
+
+void backlight_set_indicator_index( uint8_t *index, uint8_t row, uint8_t column )
+{
+ if ( row >= MATRIX_ROWS )
+ {
+ // Special value, 255=none, 254=all
+ *index = row;
+ }
+ else
+ {
+ map_row_column_to_led( row, column, index );
+ }
+}
+
+void backlight_get_indicator_row_col( uint8_t index, uint8_t *row, uint8_t *column )
+{
+ if ( index == 255 || index == 254 )
+ {
+ // Special value, 255=none, 254=all
+ *row = index;
+ *column = 0;
+ return;
+ }
+ for ( uint8_t r = 0; r < MATRIX_ROWS; r++ )
+ {
+ for ( uint8_t c = 0; c < MATRIX_COLS; c++ )
+ {
+ uint8_t i = 255;
+ map_row_column_to_led( r, c, &i );
+ if ( i == index )
+ {
+ *row = r;
+ *column = c;
+ return;
+ }
+ }
+ }
+}
+
+// Some helpers for setting/getting HSV
+void _set_color( HS *color, uint8_t *data )
+{
+ color->h = data[0];
+ color->s = data[1];
+}
+
+void _get_color( HS *color, uint8_t *data )
+{
+ data[0] = color->h;
+ data[1] = color->s;
+}
+
+void backlight_config_set_value( uint8_t *data )
+{
+ bool reinitialize = false;
+ uint8_t *value_id = &(data[0]);
+ uint8_t *value_data = &(data[1]);
+ switch ( *value_id )
+ {
+#if defined (RGB_BACKLIGHT_ZEAL60) || defined(RGB_BACKLIGHT_ZEAL65)
+ case id_use_split_backspace:
+ {
+ g_config.use_split_backspace = (bool)*value_data;
+ reinitialize = true;
+ break;
+ }
+#endif
+#if defined (RGB_BACKLIGHT_ZEAL60)
+ case id_use_split_left_shift:
+ {
+ g_config.use_split_left_shift = (bool)*value_data;
+ reinitialize = true;
+ break;
+ }
+ case id_use_split_right_shift:
+ {
+ g_config.use_split_right_shift = (bool)*value_data;
+ reinitialize = true;
+ break;
+ }
+ case id_use_7u_spacebar:
+ {
+ g_config.use_7u_spacebar = (bool)*value_data;
+ reinitialize = true;
+ break;
+ }
+ case id_use_iso_enter:
+ {
+ g_config.use_iso_enter = (bool)*value_data;
+ reinitialize = true;
+ break;
+ }
+ case id_disable_hhkb_blocker_leds:
+ {
+ g_config.disable_hhkb_blocker_leds = (bool)*value_data;
+ reinitialize = true;
+ break;
+ }
+#endif
+ case id_disable_when_usb_suspended:
+ {
+ g_config.disable_when_usb_suspended = (bool)*value_data;
+ break;
+ }
+ case id_disable_after_timeout:
+ {
+ g_config.disable_after_timeout = *value_data;
+ break;
+ }
+ case id_brightness:
+ {
+ g_config.brightness = *value_data;
+ break;
+ }
+ case id_effect:
+ {
+ g_config.effect = *value_data;
+ break;
+ }
+ case id_effect_speed:
+ {
+ g_config.effect_speed = *value_data;
+ break;
+ }
+ case id_color_1:
+ {
+ _set_color( &(g_config.color_1), value_data );
+ break;
+ }
+ case id_color_2:
+ {
+ _set_color( &(g_config.color_2), value_data );
+ break;
+ }
+ case id_caps_lock_indicator_color:
+ {
+ _set_color( &(g_config.caps_lock_indicator.color), value_data );
+ break;
+ }
+ case id_caps_lock_indicator_row_col:
+ {
+ backlight_set_indicator_index( &(g_config.caps_lock_indicator.index), value_data[0], value_data[1] );
+ break;
+ }
+ case id_layer_1_indicator_color:
+ {
+ _set_color( &(g_config.layer_1_indicator.color), value_data );
+ break;
+ }
+ case id_layer_1_indicator_row_col:
+ {
+ backlight_set_indicator_index( &(g_config.layer_1_indicator.index), value_data[0], value_data[1] );
+ break;
+ }
+ case id_layer_2_indicator_color:
+ {
+ _set_color( &(g_config.layer_2_indicator.color), value_data );
+ break;
+ }
+ case id_layer_2_indicator_row_col:
+ {
+ backlight_set_indicator_index( &(g_config.layer_2_indicator.index), value_data[0], value_data[1] );
+ break;
+ }
+ case id_layer_3_indicator_color:
+ {
+ _set_color( &(g_config.layer_3_indicator.color), value_data );
+ break;
+ }
+ case id_layer_3_indicator_row_col:
+ {
+ backlight_set_indicator_index( &(g_config.layer_3_indicator.index), value_data[0], value_data[1] );
+ break;
+ }
+ case id_alphas_mods:
+ {
+ for ( int i=0; i<5; i++ )
+ {
+ g_config.alphas_mods[i] = ( *(value_data+i*2) << 8 ) | ( *(value_data+i*2+1) );
+ }
+ }
+#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C)
+ case id_custom_color:
+ {
+ uint8_t index = value_data[0];
+ if ( index >= 0 && index < RGB_BACKLIGHT_CUSTOM_COLORS_COUNT )
+ {
+ _set_color( &(g_config.custom_color[index]), &(value_data[1]) );
+ }
+ }
+#endif
+ }
+
+ if ( reinitialize )
+ {
+ backlight_init_drivers();
+ }
+}
+
+void backlight_config_get_value( uint8_t *data )
+{
+ uint8_t *value_id = &(data[0]);
+ uint8_t *value_data = &(data[1]);
+ switch ( *value_id )
+ {
+ case id_use_split_backspace:
+ {
+ *value_data = ( g_config.use_split_backspace ? 1 : 0 );
+ break;
+ }
+ case id_use_split_left_shift:
+ {
+ *value_data = ( g_config.use_split_left_shift ? 1 : 0 );
+ break;
+ }
+ case id_use_split_right_shift:
+ {
+ *value_data = ( g_config.use_split_right_shift ? 1 : 0 );
+ break;
+ }
+ case id_use_7u_spacebar:
+ {
+ *value_data = ( g_config.use_7u_spacebar ? 1 : 0 );
+ break;
+ }
+ case id_use_iso_enter:
+ {
+ *value_data = ( g_config.use_iso_enter ? 1 : 0 );
+ break;
+ }
+ case id_disable_when_usb_suspended:
+ {
+ *value_data = ( g_config.disable_when_usb_suspended ? 1 : 0 );
+ break;
+ }
+ case id_disable_hhkb_blocker_leds:
+ {
+ *value_data = ( g_config.disable_hhkb_blocker_leds ? 1 : 0 );
+ break;
+ }
+ case id_disable_after_timeout:
+ {
+ *value_data = g_config.disable_after_timeout;
+ break;
+ }
+ case id_brightness:
+ {
+ *value_data = g_config.brightness;
+ break;
+ }
+ case id_effect:
+ {
+ *value_data = g_config.effect;
+ break;
+ }
+ case id_effect_speed:
+ {
+ *value_data = g_config.effect_speed;
+ break;
+ }
+ case id_color_1:
+ {
+ _get_color( &(g_config.color_1), value_data );
+ break;
+ }
+ case id_color_2:
+ {
+ _get_color( &(g_config.color_2), value_data );
+ break;
+ }
+ case id_caps_lock_indicator_color:
+ {
+ _get_color( &(g_config.caps_lock_indicator.color), value_data );
+ break;
+ }
+ case id_caps_lock_indicator_row_col:
+ {
+ backlight_get_indicator_row_col( g_config.caps_lock_indicator.index, &(value_data[0]), &(value_data[1]) );
+ break;
+ }
+ case id_layer_1_indicator_color:
+ {
+ _get_color( &(g_config.layer_1_indicator.color), value_data );
+ break;
+ }
+ case id_layer_1_indicator_row_col:
+ {
+ backlight_get_indicator_row_col( g_config.layer_1_indicator.index, &(value_data[0]), &(value_data[1]) );
+ break;
+ }
+ case id_layer_2_indicator_color:
+ {
+ _get_color( &(g_config.layer_2_indicator.color), value_data );
+ break;
+ }
+ case id_layer_2_indicator_row_col:
+ {
+ backlight_get_indicator_row_col( g_config.layer_2_indicator.index, &(value_data[0]), &(value_data[1]) );
+ break;
+ }
+ case id_layer_3_indicator_color:
+ {
+ _get_color( &(g_config.layer_3_indicator.color), value_data );
+ break;
+ }
+ case id_layer_3_indicator_row_col:
+ {
+ backlight_get_indicator_row_col( g_config.layer_3_indicator.index, &(value_data[0]), &(value_data[1]) );
+ break;
+ }
+ case id_alphas_mods:
+ {
+ for ( int i=0; i<5; i++ )
+ {
+ *(value_data+i*2) = g_config.alphas_mods[i] >> 8;
+ *(value_data+i*2+1) = g_config.alphas_mods[i] & 0xFF;
+ }
+ }
+#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C)
+ case id_custom_color:
+ {
+ uint8_t index = value_data[0];
+ if ( index >= 0 && index < RGB_BACKLIGHT_CUSTOM_COLORS_COUNT )
+ {
+ _get_color( &(g_config.custom_color[index]), &(value_data[1]) );
+ }
+ }
+#endif
+ }
+}
+
+void backlight_config_set_alphas_mods( uint16_t *alphas_mods )
+{
+ for ( int i=0; i<5; i++ )
+ {
+ g_config.alphas_mods[i] = alphas_mods[i];
+ }
+
+ backlight_config_save();
+}
+
+void backlight_config_load(void)
+{
+ eeprom_read_block( &g_config, ((void*)RGB_BACKLIGHT_CONFIG_EEPROM_ADDR), sizeof(backlight_config) );
+}
+
+void backlight_config_save(void)
+{
+ eeprom_update_block( &g_config, ((void*)RGB_BACKLIGHT_CONFIG_EEPROM_ADDR), sizeof(backlight_config) );
+}
+
+void backlight_init_drivers(void)
+{
+ // Initialize I2C
+ i2c_init();
+
+#if defined(RGB_BACKLIGHT_M6_B)
+ IS31FL3218_init();
+#elif defined(RGB_BACKLIGHT_HS60)
+ IS31FL3733_init( ISSI_ADDR_1, 0 );
+
+ for ( int index = 0; index < DRIVER_LED_TOTAL; index++ )
+ {
+#if defined(HS60_ANSI)
+ bool enabled = !( ( index == 48-1 ) || //LA48
+ ( index == 51-1 ) || //LA51
+ ( index == 61-1 ) ); //LA61
+#elif defined(HS60_HHKB)
+ bool enabled = !( ( index == 61-1 ) || //LA61
+ ( index == 62-1 ) ); //LA62
+#else //HS60_ISO
+ bool enabled = !( ( index == 51-1 ) || //LA51
+ ( index == 61-1 ) ); //LA61
+#endif
+ // This only caches it for later
+ IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
+ }
+ // This actually updates the LED drivers
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
+#elif defined(RGB_BACKLIGHT_NK65)
+ IS31FL3733_init( ISSI_ADDR_1, 0 );
+ IS31FL3733_init( ISSI_ADDR_2, 0 );
+
+ for ( int index = 0; index < DRIVER_LED_TOTAL; index++ )
+ {
+ bool enabled = !( ( index == 61-1 ) || //LA61
+ ( index > 6+64-1 ) ); //LB7-LB64
+ // This only caches it for later
+ IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
+ }
+ IS31FL3733_set_led_control_register( 7+64-1, 0, 1, 0 ); //Enable LB7 green enable for indicators
+ // This actually updates the LED drivers
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 );
+#elif defined(RGB_BACKLIGHT_NK87)
+ IS31FL3733_init( ISSI_ADDR_1, 0 );
+ IS31FL3733_init( ISSI_ADDR_2, 0 );
+
+ for ( int index = 0; index < DRIVER_LED_TOTAL; index++ )
+ {
+ bool enabled = !( ( index == 61-1 ) || //LA61
+ ( (index >= 2+64-1) && (index <= 4+64-1) ) ||
+ ( (index >= 6+64-1) && (index <= 8+64-1) ) ||
+ ( index == 10+64-1 ) || ( index == 11+64-1 ) ||
+ ( (index >= 14+64-1) && (index <= 16+64-1) ) ||
+ ( (index >= 18+64-1) && (index <= 20+64-1) ) ||
+ ( (index >= 22+64-1) && (index <= 24+64-1) ) ||
+ ( (index >= 26+64-1) && (index <= 28+64-1) ) ||
+ ( (index >= 30+64-1) && (index <= 32+64-1) ) ||
+ ( (index >= 34+64-1) && (index <= 36+64-1) ) ||
+ ( (index >= 38+64-1) && (index <= 40+64-1) ) ||
+ ( (index >= 42+64-1) && (index <= 44+64-1) ) ||
+ ( (index >= 46+64-1) && (index <= 48+64-1) ) ||
+ ( index == 50+64-1 ) ||
+ ( index == 54+64-1 ) ||
+ ( index == 58+64-1 ) ||
+ ( index == 62+64-1 ) );
+ // This only caches it for later
+ IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
+ }
+ IS31FL3733_set_led_control_register( 48+64-1, 0, 0, 1 ); //Enable LB48 blue enable for indicators
+ // This actually updates the LED drivers
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 );
+#elif defined(RGB_BACKLIGHT_NEBULA68)
+ IS31FL3733_init( ISSI_ADDR_1, 0 );
+ IS31FL3733_init( ISSI_ADDR_2, 0 );
+
+ for ( int index = 0; index < DRIVER_LED_TOTAL; index++ )
+ {
+ bool enabled = !( ( index == 61-1 ) || //LA61
+ ( index > 5+64-1 ) ); //LB6-LB64
+ // This only caches it for later
+ IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
+ }
+ // This actually updates the LED drivers
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 );
+#elif defined(RGB_BACKLIGHT_KW_MEGA)
+ IS31FL3733_init( ISSI_ADDR_1, 0 );
+ IS31FL3733_init( ISSI_ADDR_2, 0 );
+
+ for ( int index = 0; index < DRIVER_LED_TOTAL; index++ )
+ {
+ bool enabled = !( ( index == 61-1 ) || //LA61
+ ( index > 6+64-1 ) ); //LB7-LB64
+ // This only caches it for later
+ IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
+ }
+ // This actually updates the LED drivers
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_1, 0 );
+ IS31FL3733_update_led_control_registers( ISSI_ADDR_2, 1 );
+#else
+ // Init the #1 driver
+ IS31FL3731_init( ISSI_ADDR_1 );
+ // Init the #2 driver (if used)
+#if !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_M10_C)
+ IS31FL3731_init( ISSI_ADDR_2 );
+#endif
+ // Init the #3 driver (if used)
+#if defined(RGB_BACKLIGHT_U80_A)
+ IS31FL3731_init( ISSI_ADDR_3 );
+#endif
+
+ // Experimental feature, not in configuration yet
+#if defined(RGB_BACKLIGHT_ZEAL60)
+ bool disable_spacebar_stab_leds = false;
+#endif
+
+ for ( int index = 0; index < DRIVER_LED_TOTAL; index++ )
+ {
+ // OR the possible "disabled" cases together, then NOT the result to get the enabled state
+ // LC6 LD13 not present on Zeal65
+#if defined(RGB_BACKLIGHT_ZEAL65)
+ bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5
+ ( index == 36+6 ) || // LC6
+ ( index == 54+13 ) ); // LD13
+#elif defined(RGB_BACKLIGHT_KOYU)
+ bool enabled = !( ( index == 36+15 ) || // LC15
+ ( index == 54+13 ) || // LD13
+ ( index == 54+17 ) ); // LD17
+#elif defined(RGB_BACKLIGHT_M65_B) || defined(RGB_BACKLIGHT_M65_BX)
+ bool enabled = !(
+ // LB6 not present on M65-B
+#if defined(RGB_BACKLIGHT_M65_B)
+ ( index == 18+6 ) || // LB6
+#endif
+ // LC15 LD13 not present on M65-B, M65-BX
+ ( index == 36+15 ) || // LC15
+ ( index == 54+13 ) ); // LD13
+#elif defined(RGB_BACKLIGHT_M60_A)
+ bool enabled = !(
+ // LB6 LB7 LB8 LB15 LB16 LB17 not present on M60-A
+ ( index == 18+6 ) || // LB6
+ ( index == 18+7 ) || // LB7
+ ( index == 18+8 ) || // LB8
+ ( index == 18+15 ) || // LB15
+ ( index == 18+16 ) || // LB16
+ ( index == 18+17 ) || // LB17
+ // HHKB blockers (LC17, LD17) and ISO extra keys (LC15,LD13) not present on M60-A
+ ( index == 36+17 ) || // LC17
+ ( index == 54+17 ) || // LD17
+ ( index == 36+15 ) || // LC15
+ ( index == 54+13 ) ); // LD13
+#elif defined(RGB_BACKLIGHT_WT60_B) || defined(RGB_BACKLIGHT_WT60_BX) || defined(RGB_BACKLIGHT_WT60_C)
+ bool enabled = !(
+ // LB6 not present on WT60-B
+#if defined(RGB_BACKLIGHT_WT60_B)
+ ( index == 18+6 ) || // LB6
+#endif
+ // LB7 LB8 LB15 LB16 LB17 LC15 LD13 not present on WT60-B, WT60-BX, WT60-C
+ ( index == 18+7 ) || // LB7
+ ( index == 18+8 ) || // LB8
+ ( index == 18+15 ) || // LB15
+ ( index == 18+16 ) || // LB16
+ ( index == 18+17 ) || // LB17
+ ( index == 36+15 ) || // LC15
+ ( index == 54+13 ) ); // LD13
+#elif defined(RGB_BACKLIGHT_ZEAL60)
+ // LB6 LB7 LB8 LB15 LB16 LB17 not present on Zeal60
+ bool enabled = !( ( index == 18+5 && !g_config.use_split_backspace ) || // LB5
+ ( index == 36+15 && !g_config.use_split_left_shift ) || // LC15
+ ( index == 54+8 && !g_config.use_split_right_shift ) || // LD8
+ ( index == 54+13 && g_config.use_7u_spacebar ) || // LD13
+ ( index == 36+17 && g_config.disable_hhkb_blocker_leds ) || // LC17
+ ( index == 54+17 && g_config.disable_hhkb_blocker_leds ) || // LD17
+ ( index == 18+6 ) || // LB6
+ ( index == 18+7 ) || // LB7
+ ( index == 18+8 ) || // LB8
+ ( index == 18+15 ) || // LB15
+ ( index == 18+16 ) || // LB16
+ ( index == 18+17 ) || // LB17
+ ( index == 36+6 && disable_spacebar_stab_leds ) || // LC6
+ ( index == 54+13 && disable_spacebar_stab_leds ) || // LD13
+ ( index == 54+14 && disable_spacebar_stab_leds && g_config.use_7u_spacebar ) ); // LD14
+#elif defined(RGB_BACKLIGHT_U80_A)
+// LB5, LB6, LB7, LB8, LB15, LB16, LB17, LC15, LD8, LD13, LE0-LE8, LF13
+ bool enabled = !(
+ ( index == 18+5 ) || // LB5
+ ( index == 18+6 ) || // LB6
+ ( index == 18+7 ) || // LB7
+ ( index == 18+8 ) || // LB8
+ ( index == 18+15 ) || // LB15
+ ( index == 18+16 ) || // LB16
+ ( index == 18+16 ) || // LB17
+ ( index == 36+15 ) || // LC15
+ ( index == 54+8 ) || // LD8
+ ( index == 54+13 ) || // LD13
+ ( index >= 72+0 && index <= 72+8 ) || // LE0-LE8
+ ( index == 90+13 ) ); // LF13
+#elif defined(RGB_BACKLIGHT_DAWN60)
+ bool enabled = !( ( index == 15+7 && !g_config.use_split_backspace ) || //other backspace
+ ( index == 47+13 && g_config.use_7u_spacebar ) || //LD13
+ ( index == 47+15 && g_config.use_7u_spacebar ) ); //LD15
+#elif defined(RGB_BACKLIGHT_NEBULA12)
+ bool enabled = !( ( index >= 9-1 && index <= 12-1 ) ); // A9-A12
+#elif defined(RGB_BACKLIGHT_M50_A)
+ bool enabled = !(
+ // LA0, LA7, LA8, LA17
+ ( index == 0+0 ) ||
+ ( index == 0+7 ) ||
+ ( index == 0+8 ) ||
+ ( index == 0+17 ) ||
+
+ // LB0, LB7, LB8, LB15, LB16, LB17,
+ ( index == 18+0 ) ||
+ ( index == 18+7 ) ||
+ ( index == 18+8 ) ||
+ ( index == 18+15 ) ||
+ ( index == 18+16 ) ||
+ ( index == 18+17 ) ||
+ // LC0, LC8, LC16, LC17
+ ( index == 36+0 ) ||
+ ( index == 36+8 ) ||
+ ( index == 36+16 ) ||
+ ( index == 36+17 ) ||
+ // LD0, LD7, LD8, LD9, LD15, LD16, LD17
+ ( index == 54+0 ) ||
+ ( index == 54+7 ) ||
+ ( index == 54+8 ) ||
+ ( index == 54+9 ) ||
+ ( index == 54+15 ) ||
+ ( index == 54+16 ) ||
+ ( index == 54+17 ) );
+#elif defined(RGB_BACKLIGHT_M10_C)
+ bool enabled = true;
+#endif
+ // This only caches it for later
+ IS31FL3731_set_led_control_register( index, enabled, enabled, enabled );
+ }
+ // This actually updates the LED drivers
+ // TODO: refactor this to use DRIVER_COUNT
+ IS31FL3731_update_led_control_registers( ISSI_ADDR_1, 0 );
+#if !defined(RGB_BACKLIGHT_NEBULA12) && !defined(RGB_BACKLIGHT_M10_C)
+ IS31FL3731_update_led_control_registers( ISSI_ADDR_2, 1 );
+#endif
+#if defined(RGB_BACKLIGHT_U80_A)
+ IS31FL3731_update_led_control_registers( ISSI_ADDR_3, 2 );
+#endif
+#endif
+
+ // TODO: put the 1 second startup delay here?
+
+ // clear the key hits
+ for ( int led=0; led<BACKLIGHT_LED_COUNT; led++ )
+ {
+ g_key_hit[led] = 255;
+ }
+}
+
+bool process_record_backlight(uint16_t keycode, keyrecord_t *record)
+{
+ // Record keypresses for backlight effects
+ if ( record->event.pressed )
+ {
+ backlight_set_key_hit( record->event.key.row, record->event.key.col );
+ }
+
+ switch(keycode)
+ {
+ case BR_INC:
+ if (record->event.pressed)
+ {
+ backlight_brightness_increase();
+ }
+ return false;
+ break;
+ case BR_DEC:
+ if (record->event.pressed)
+ {
+ backlight_brightness_decrease();
+ }
+ return false;
+ break;
+ case EF_INC:
+ if (record->event.pressed)
+ {
+ backlight_effect_increase();
+ }
+ return false;
+ break;
+ case EF_DEC:
+ if (record->event.pressed)
+ {
+ backlight_effect_decrease();
+ }
+ return false;
+ break;
+ case ES_INC:
+ if (record->event.pressed)
+ {
+ backlight_effect_speed_increase();
+ }
+ return false;
+ break;
+ case ES_DEC:
+ if (record->event.pressed)
+ {
+ backlight_effect_speed_decrease();
+ }
+ return false;
+ break;
+ case H1_INC:
+ if (record->event.pressed)
+ {
+ backlight_color_1_hue_increase();
+ }
+ return false;
+ break;
+ case H1_DEC:
+ if (record->event.pressed)
+ {
+ backlight_color_1_hue_decrease();
+ }
+ return false;
+ break;
+ case S1_INC:
+ if (record->event.pressed)
+ {
+ backlight_color_1_sat_increase();
+ }
+ return false;
+ break;
+ case S1_DEC:
+ if (record->event.pressed)
+ {
+ backlight_color_1_sat_decrease();
+ break;
+ }
+ return false;
+ break;
+ case H2_INC:
+ if (record->event.pressed)
+ {
+ backlight_color_2_hue_increase();
+ }
+ return false;
+ break;
+ case H2_DEC:
+ if (record->event.pressed)
+ {
+ backlight_color_2_hue_decrease();
+ }
+ return false;
+ break;
+ case S2_INC:
+ if (record->event.pressed)
+ {
+ backlight_color_2_sat_increase();
+ }
+ return false;
+ break;
+ case S2_DEC:
+ if (record->event.pressed)
+ {
+ backlight_color_2_sat_decrease();
+ break;
+ }
+ return false;
+ break;
+ }
+
+ return true;
+}
+
+// Deals with the messy details of incrementing an integer
+uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max )
+{
+ int16_t new_value = value;
+ new_value += step;
+ return MIN( MAX( new_value, min ), max );
+}
+
+uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max )
+{
+ int16_t new_value = value;
+ new_value -= step;
+ return MIN( MAX( new_value, min ), max );
+}
+
+void backlight_effect_increase(void)
+{
+ g_config.effect = increment( g_config.effect, 1, 0, BACKLIGHT_EFFECT_MAX );
+ backlight_config_save();
+}
+
+void backlight_effect_decrease(void)
+{
+ g_config.effect = decrement( g_config.effect, 1, 0, BACKLIGHT_EFFECT_MAX );
+ backlight_config_save();
+}
+
+void backlight_effect_speed_increase(void)
+{
+ g_config.effect_speed = increment( g_config.effect_speed, 1, 0, 3 );
+ backlight_config_save();
+}
+
+void backlight_effect_speed_decrease(void)
+{
+ g_config.effect_speed = decrement( g_config.effect_speed, 1, 0, 3 );
+ backlight_config_save();
+}
+
+void backlight_brightness_increase(void)
+{
+ g_config.brightness = increment( g_config.brightness, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_brightness_decrease(void)
+{
+ g_config.brightness = decrement( g_config.brightness, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_1_hue_increase(void)
+{
+ g_config.color_1.h = increment( g_config.color_1.h, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_1_hue_decrease(void)
+{
+ g_config.color_1.h = decrement( g_config.color_1.h, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_1_sat_increase(void)
+{
+ g_config.color_1.s = increment( g_config.color_1.s, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_1_sat_decrease(void)
+{
+ g_config.color_1.s = decrement( g_config.color_1.s, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_2_hue_increase(void)
+{
+ g_config.color_2.h = increment( g_config.color_2.h, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_2_hue_decrease(void)
+{
+ g_config.color_2.h = decrement( g_config.color_2.h, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_2_sat_increase(void)
+{
+ g_config.color_2.s = increment( g_config.color_2.s, 8, 0, 255 );
+ backlight_config_save();
+}
+
+void backlight_color_2_sat_decrease(void)
+{
+ g_config.color_2.s = decrement( g_config.color_2.s, 8, 0, 255 );
+ backlight_config_save();
+}
+
+#if defined(RGB_DEBUGGING_ONLY)
+void backlight_test_led( uint8_t index, bool red, bool green, bool blue )
+{
+ for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ )
+ {
+ if ( i == index )
+ {
+ IS31FL3731_set_led_control_register( i, red, green, blue );
+ }
+ else
+ {
+ IS31FL3731_set_led_control_register( i, false, false, false );
+ }
+ }
+}
+
+void backlight_debug_led( bool state )
+{
+ if (state)
+ {
+ // Output high.
+ DDRE |= (1<<6);
+ PORTE |= (1<<6);
+ }
+ else
+ {
+ // Output low.
+ DDRE &= ~(1<<6);
+ PORTE &= ~(1<<6);
+ }
+}
+#endif // defined(RGB_DEBUGGING_ONLY)
+
+
diff --git a/drivers/chibios/wt_rgb_backlight.h b/drivers/chibios/wt_rgb_backlight.h
new file mode 100644
index 0000000000..529f84636a
--- /dev/null
+++ b/drivers/chibios/wt_rgb_backlight.h
@@ -0,0 +1,115 @@
+/* Copyright 2017 Jason Williams (Wilba)
+ *
+ * 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
+
+#if RGB_BACKLIGHT_ENABLED
+#else
+#error rgb_backlight.h included when RGB_BACKLIGHT_ENABLED == 0
+#endif // RGB_BACKLIGHT_ENABLED
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "quantum/color.h"
+
+typedef struct PACKED
+{
+ uint8_t h;
+ uint8_t s;
+} HS;
+
+typedef struct
+{
+ HS color;
+ uint8_t index;
+} backlight_config_indicator;
+
+#if defined(RGB_BACKLIGHT_M6_B)
+#define RGB_BACKLIGHT_CUSTOM_COLORS_COUNT 6
+#elif defined(RGB_BACKLIGHT_M10_C)
+#define RGB_BACKLIGHT_CUSTOM_COLORS_COUNT 10
+#endif
+
+typedef struct
+{
+ bool use_split_backspace:1; // |
+ bool use_split_left_shift:1; // |
+ bool use_split_right_shift:1; // |
+ bool use_7u_spacebar:1; // |
+ bool use_iso_enter:1; // |
+ bool disable_when_usb_suspended:1; // |
+ bool disable_hhkb_blocker_leds:1; // |
+ bool __pad7:1; // 1 byte
+ uint8_t disable_after_timeout; // 1 byte
+ uint8_t brightness; // 1 byte
+ uint8_t effect; // 1 byte
+ uint8_t effect_speed; // 1 byte
+ HS color_1; // 2 bytes
+ HS color_2; // 2 bytes
+ backlight_config_indicator caps_lock_indicator; // 3 bytes
+ backlight_config_indicator layer_1_indicator; // 3 bytes
+ backlight_config_indicator layer_2_indicator; // 3 bytes
+ backlight_config_indicator layer_3_indicator; // 3 bytes
+ uint16_t alphas_mods[5]; // 10 bytes
+#if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C)
+ HS custom_color[RGB_BACKLIGHT_CUSTOM_COLORS_COUNT]; // 12 or 20 bytes
+#endif
+} backlight_config; // = 31 bytes (M6-B = 43 bytes, M10-C 51 bytes)
+
+void backlight_config_load(void);
+void backlight_config_save(void);
+void backlight_config_set_value( uint8_t *data );
+void backlight_config_get_value( uint8_t *data );
+
+void backlight_init_drivers(void);
+
+void backlight_timer_init(void);
+void backlight_timer_enable(void);
+void backlight_timer_disable(void);
+
+void backlight_set_suspend_state(bool state);
+void backlight_set_indicator_state(uint8_t state);
+
+// 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 backlight_update_pwm_buffers(void);
+
+// Handle backlight specific keycodes
+bool process_record_backlight(uint16_t keycode, keyrecord_t *record);
+
+void backlight_set_key_hit(uint8_t row, uint8_t col);
+
+void backlight_effect_increase(void);
+void backlight_effect_decrease(void);
+void backlight_effect_speed_increase(void);
+void backlight_effect_speed_decrease(void);
+
+void backlight_brightness_increase(void);
+void backlight_brightness_decrease(void);
+
+void backlight_color_1_hue_increase(void);
+void backlight_color_1_hue_decrease(void);
+void backlight_color_1_sat_increase(void);
+void backlight_color_1_sat_decrease(void);
+void backlight_color_2_hue_increase(void);
+void backlight_color_2_hue_decrease(void);
+void backlight_color_2_sat_increase(void);
+void backlight_color_2_sat_decrease(void);
+
+void backlight_test_led( uint8_t index, bool red, bool green, bool blue );
+void backlight_debug_led(bool state);
diff --git a/drivers/chibios/wt_rgb_backlight_api.h b/drivers/chibios/wt_rgb_backlight_api.h
new file mode 100644
index 0000000000..0cd6b85f07
--- /dev/null
+++ b/drivers/chibios/wt_rgb_backlight_api.h
@@ -0,0 +1,43 @@
+/* Copyright 2017 Jason Williams (Wilba)
+ *
+ * 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
+
+enum wt_rgb_backlight_config_value
+{
+ id_use_split_backspace = 0x01,
+ id_use_split_left_shift = 0x02,
+ id_use_split_right_shift = 0x03,
+ id_use_7u_spacebar = 0x04,
+ id_use_iso_enter = 0x05,
+ id_disable_hhkb_blocker_leds = 0x06,
+ id_disable_when_usb_suspended = 0x07,
+ id_disable_after_timeout = 0x08,
+ id_brightness = 0x09,
+ id_effect = 0x0A,
+ id_effect_speed = 0x0B,
+ id_color_1 = 0x0C,
+ id_color_2 = 0x0D,
+ id_caps_lock_indicator_color = 0x0E,
+ id_caps_lock_indicator_row_col = 0x0F,
+ id_layer_1_indicator_color = 0x10,
+ id_layer_1_indicator_row_col = 0x11,
+ id_layer_2_indicator_color = 0x12,
+ id_layer_2_indicator_row_col = 0x13,
+ id_layer_3_indicator_color = 0x14,
+ id_layer_3_indicator_row_col = 0x15,
+ id_alphas_mods = 0x16,
+ id_custom_color = 0x17
+};
diff --git a/drivers/chibios/wt_rgb_backlight_keycodes.h b/drivers/chibios/wt_rgb_backlight_keycodes.h
new file mode 100644
index 0000000000..5a43649535
--- /dev/null
+++ b/drivers/chibios/wt_rgb_backlight_keycodes.h
@@ -0,0 +1,34 @@
+/* Copyright 2017 Jason Williams (Wilba)
+ *
+ * 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
+
+// This is hardcoded at 0x5F00 so it's well after keycode value SAFE_RANGE
+enum wt_rgb_backlight_keycodes {
+ BR_INC = 0x5F00, // backlight brightness increase
+ BR_DEC, // backlight brightness decrease
+ EF_INC, // backlight effect increase
+ EF_DEC, // backlight effect decrease
+ ES_INC,
+ ES_DEC,
+ H1_INC,
+ H1_DEC,
+ S1_INC,
+ S1_DEC,
+ H2_INC,
+ H2_DEC,
+ S2_INC,
+ S2_DEC
+};
diff --git a/drivers/gpio/pca9555.c b/drivers/gpio/pca9555.c
index 496bbca04e..02b5abbdde 100644
--- a/drivers/gpio/pca9555.c
+++ b/drivers/gpio/pca9555.c
@@ -76,3 +76,20 @@ uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) {
}
return data;
}
+
+uint16_t pca9555_readAllPins(uint8_t slave_addr) {
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+
+ typedef union {
+ uint8_t u8[2];
+ uint16_t u16;
+ } data16;
+
+ data16 data;
+
+ i2c_status_t ret = i2c_readReg(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9555_readAllPins::FAILED\n");
+ }
+ return data.u16;
+}
diff --git a/drivers/gpio/pca9555.h b/drivers/gpio/pca9555.h
index ebb97e2f30..3341ec3eb5 100644
--- a/drivers/gpio/pca9555.h
+++ b/drivers/gpio/pca9555.h
@@ -53,3 +53,5 @@ void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf);
void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf);
uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port);
+
+uint16_t pca9555_readAllPins(uint8_t slave_addr);
diff --git a/drivers/haptic/haptic.c b/drivers/haptic/haptic.c
index 8fef1cb225..828c8fba71 100644
--- a/drivers/haptic/haptic.c
+++ b/drivers/haptic/haptic.c
@@ -194,12 +194,12 @@ void haptic_set_mode(uint8_t mode) {
}
void haptic_set_amplitude(uint8_t amp) {
- haptic_config.amplitude = amp;
- eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude);
- #ifdef DRV2605L
- DRV_amplitude(amp);
- #endif
+ haptic_config.amplitude = amp;
+ eeconfig_update_haptic(haptic_config.raw);
+ xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude);
+#ifdef DRV2605L
+ DRV_amplitude(amp);
+#endif
}
void haptic_set_buzz(uint8_t buzz) {
@@ -236,21 +236,59 @@ uint8_t haptic_get_dwell(void) {
}
void haptic_enable_continuous(void) {
- haptic_config.cont = 1;
- xprintf("haptic_config.cont = %u\n", haptic_config.cont);
- eeconfig_update_haptic(haptic_config.raw);
- #ifdef DRV2605L
- DRV_rtp_init();
- #endif
+ haptic_config.cont = 1;
+ xprintf("haptic_config.cont = %u\n", haptic_config.cont);
+ eeconfig_update_haptic(haptic_config.raw);
+#ifdef DRV2605L
+ DRV_rtp_init();
+#endif
}
void haptic_disable_continuous(void) {
- haptic_config.cont = 0;
- xprintf("haptic_config.cont = %u\n", haptic_config.cont);
- eeconfig_update_haptic(haptic_config.raw);
- #ifdef DRV2605L
- DRV_write(DRV_MODE,0x00);
- #endif
+ haptic_config.cont = 0;
+ xprintf("haptic_config.cont = %u\n", haptic_config.cont);
+ eeconfig_update_haptic(haptic_config.raw);
+#ifdef DRV2605L
+ DRV_write(DRV_MODE, 0x00);
+#endif
+}
+
+void haptic_toggle_continuous(void) {
+#ifdef DRV2605L
+ if (haptic_config.cont) {
+ haptic_disable_continuous();
+ } else {
+ haptic_enable_continuous();
+ }
+ eeconfig_update_haptic(haptic_config.raw);
+#endif
+}
+
+void haptic_cont_increase(void) {
+ uint8_t amp = haptic_config.amplitude + 10;
+ if (haptic_config.amplitude >= 120) {
+ amp = 120;
+ }
+ haptic_set_amplitude(amp);
+}
+
+void haptic_cont_decrease(void) {
+ uint8_t amp = haptic_config.amplitude - 10;
+ if (haptic_config.amplitude < 20) {
+ amp = 20;
+ }
+ haptic_set_amplitude(amp);
+}
+
+void haptic_play(void) {
+#ifdef DRV2605L
+ uint8_t play_eff = 0;
+ play_eff = haptic_config.mode;
+ DRV_pulse(play_eff);
+#endif
+#ifdef SOLENOID_ENABLE
+ solenoid_fire();
+#endif
}
void haptic_toggle_continuous(void) {
@@ -294,7 +332,6 @@ void haptic_play(void) {
}
bool process_haptic(uint16_t keycode, keyrecord_t *record) {
-
if (keycode == HPT_ON && record->event.pressed) {
haptic_enable();
}
@@ -325,16 +362,16 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) {
if (keycode == HPT_DWLD && record->event.pressed) {
haptic_dwell_decrease();
}
- if (keycode == HPT_CONT && record->event.pressed) {
- haptic_toggle_continuous();
+ if (keycode == HPT_CONT && record->event.pressed) {
+ haptic_toggle_continuous();
}
- if (keycode == HPT_CONI && record->event.pressed) {
- haptic_cont_increase();
+ if (keycode == HPT_CONI && record->event.pressed) {
+ haptic_cont_increase();
}
- if (keycode == HPT_COND && record->event.pressed) {
- haptic_cont_decrease();
+ if (keycode == HPT_COND && record->event.pressed) {
+ haptic_cont_decrease();
}
-
+
if (haptic_config.enable) {
if (record->event.pressed) {
// keypress
diff --git a/drivers/haptic/haptic.h b/drivers/haptic/haptic.h
index 2f6eb31fc2..ba8e0d20be 100644
--- a/drivers/haptic/haptic.h
+++ b/drivers/haptic/haptic.h
@@ -34,14 +34,14 @@
typedef union {
uint32_t raw;
struct {
- bool enable :1;
- uint8_t feedback :2;
- uint8_t mode :7;
- bool buzz :1;
- uint8_t dwell :7;
- bool cont :1;
- uint8_t amplitude :8;
- uint16_t reserved :7;
+ bool enable : 1;
+ uint8_t feedback : 2;
+ uint8_t mode : 7;
+ bool buzz : 1;
+ uint8_t dwell : 7;
+ bool cont : 1;
+ uint8_t amplitude : 8;
+ uint8_t reserved : 5;
};
} haptic_config_t;
diff --git a/drivers/issi/is31fl3731-simple.c b/drivers/issi/is31fl3731-simple.c
index 7c86841f1e..d295772f5e 100644
--- a/drivers/issi/is31fl3731-simple.c
+++ b/drivers/issi/is31fl3731-simple.c
@@ -186,7 +186,7 @@ void IS31FL3731_init(uint8_t addr) {
}
void IS31FL3731_set_value(int index, uint8_t value) {
- if (index >= 0 && index < LED_DRIVER_LED_COUNT) {
+ if (index >= 0 && index < DRIVER_LED_TOTAL) {
is31_led led = g_is31_leds[index];
// Subtract 0x24 to get the second index of g_pwm_buffer
@@ -196,7 +196,7 @@ void IS31FL3731_set_value(int index, uint8_t value) {
}
void IS31FL3731_set_value_all(uint8_t value) {
- for (int i = 0; i < LED_DRIVER_LED_COUNT; i++) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
IS31FL3731_set_value(i, value);
}
}
diff --git a/drivers/issi/is31fl3731-simple.h b/drivers/issi/is31fl3731-simple.h
index 85b458753c..9665d6ed35 100644
--- a/drivers/issi/is31fl3731-simple.h
+++ b/drivers/issi/is31fl3731-simple.h
@@ -26,7 +26,7 @@ typedef struct is31_led {
uint8_t v;
} __attribute__((packed)) is31_led;
-extern const is31_led g_is31_leds[LED_DRIVER_LED_COUNT];
+extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
void IS31FL3731_init(uint8_t addr);
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
diff --git a/drivers/oled/licenses.txt b/drivers/oled/licenses.txt
new file mode 100644
index 0000000000..111603ebf3
--- /dev/null
+++ b/drivers/oled/licenses.txt
@@ -0,0 +1,45 @@
+The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.
+
+
+This is the Linux-penguin again...
+
+Originally drewn by Larry Ewing (http://www.isc.tamu.edu/~lewing/)
+(with the GIMP) the Linux Logo has been vectorized by me (Simon Budig,
+http://www.home.unix-ag.org/simon/).
+
+This happened quite some time ago with Corel Draw 4. But luckily
+meanwhile there are tools available to handle vector graphics with
+Linux. Bernhard Herzog (bernhard@users.sourceforge.net) deserves kudos
+for creating Sketch (http://sketch.sourceforge.net), a powerful free
+tool for creating vector graphics. He converted the Corel Draw file to
+the Sketch native format. Since I am unable to maintain the Corel Draw
+file any longer, the Sketch version now is the "official" one.
+
+Anja Gerwinski (anja@gerwinski.de) has created an alternate version of
+the penguin (penguin-variant.sk) with a thinner mouth line and slightly
+altered gradients. It also features a nifty drop shadow.
+
+The third bird (penguin-flat.sk) is a version reduced to three colors
+(black/white/yellow) for e.g. silk screen printing. I made this version
+for a mug, available at the friendly folks at
+http://www.kernelconcepts.de/ - they do good stuff, mail Petra
+(pinguin@kernelconcepts.de) if you need something special or don't
+understand the german :-)
+
+These drawings are copyrighted by Larry Ewing and Simon Budig
+(penguin-variant.sk also by Anja Gerwinski), redistribution is free but
+has to include this README/Copyright notice.
+
+The use of these drawings is free. However I am happy about a sample of
+your mug/t-shirt/whatever with this penguin on it...
+
+Have fun
+ Simon Budig
+
+
+Simon.Budig@unix-ag.org
+http://www.home.unix-ag.org/simon/
+
+Simon Budig
+Am Hardtkoeppel 2
+D-61279 Graevenwiesbach
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 99acacd96e..72ab21247d 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -173,12 +173,12 @@ typedef enum {
// Initialize the oled display, rotating the rendered output based on the define passed in.
// Returns true if the OLED was initialized successfully
-bool oled_init(uint8_t rotation);
+bool oled_init(oled_rotation_t rotation);
// Called at the start of oled_init, weak function overridable by the user
// rotation - the value passed into oled_init
-// Return new uint8_t if you want to override default rotation
-uint8_t oled_init_user(uint8_t rotation);
+// Return new oled_rotation_t if you want to override default rotation
+oled_rotation_t oled_init_user(oled_rotation_t rotation);
// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering
void oled_clear(void);
diff --git a/drivers/qwiic/micro_oled.c b/drivers/qwiic/micro_oled.c
index c7a4ee081d..bbeb140cbe 100644
--- a/drivers/qwiic/micro_oled.c
+++ b/drivers/qwiic/micro_oled.c
@@ -206,6 +206,8 @@ void clear_screen(void) {
send_data(0);
}
}
+
+ memset(micro_oled_screen_current, 0, LCDWIDTH * LCDHEIGHT / 8);
}
/** \brief Clear SSD1306's memory.
diff --git a/drivers/qwiic/qwiic.mk b/drivers/qwiic/qwiic.mk
index b23c25657d..164bd72108 100644
--- a/drivers/qwiic/qwiic.mk
+++ b/drivers/qwiic/qwiic.mk
@@ -1,16 +1,17 @@
-ifneq ($(strip $(QWIIC_ENABLE)),)
+ifeq ($(strip $(QWIIC_ENABLE)),yes)
COMMON_VPATH += $(DRIVER_PATH)/qwiic
OPT_DEFS += -DQWIIC_ENABLE
SRC += qwiic.c
QUANTUM_LIB_SRC += i2c_master.c
-endif
-ifneq ($(filter JOYSTIIC, $(QWIIC_ENABLE)),)
+ifneq ($(filter JOYSTIIC, $(QWIIC_DRIVERS)),)
OPT_DEFS += -DQWIIC_JOYSTIIC_ENABLE
SRC += joystiic.c
endif
-ifneq ($(filter MICRO_OLED, $(QWIIC_ENABLE)),)
+ifneq ($(filter MICRO_OLED, $(QWIIC_DRIVERS)),)
OPT_DEFS += -DQWIIC_MICRO_OLED_ENABLE
SRC += micro_oled.c
endif
+
+endif
diff --git a/drivers/usbpd.h b/drivers/usbpd.h
new file mode 100644
index 0000000000..df4f29bb9d
--- /dev/null
+++ b/drivers/usbpd.h
@@ -0,0 +1,29 @@
+/* Copyright 2021 Nick Brassel (@tzarc)
+ *
+ * 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
+
+typedef enum {
+ USBPD_500MA,
+ USBPD_1500MA,
+ USBPD_3000MA,
+} usbpd_allowance_t;
+
+// Initialises the USBPD subsystem
+void usbpd_init(void);
+
+// Gets the current state of the USBPD allowance
+usbpd_allowance_t usbpd_get_allowance(void); \ No newline at end of file
diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h
index 65d307d28c..874ec795bd 100644
--- a/keyboards/ergodox_ez/config.h
+++ b/keyboards/ergodox_ez/config.h
@@ -24,11 +24,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* USB Device descriptor parameter */
#define VENDOR_ID 0x3297
-#define PRODUCT_ID 0x4974
#define DEVICE_VER 0x0001
-#define MANUFACTURER ZSA Technology Labs Inc
+#define MANUFACTURER ZSA Technology Labs
+#define PRODUCT_ID 0x4974
#define PRODUCT ErgoDox EZ
-#define WEBUSB_LANDING_PAGE_URL u8"configure.ergodox-ez.com"
/* key matrix size */
#define MATRIX_ROWS 14
@@ -44,7 +43,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_EXPANDER_COL_PINS { 5, 4, 3, 2, 1, 0 }
#define MATRIX_EXPANDER_ROW_PINS { 0, 1, 2, 3, 4, 5, 6 }
-
#define MOUSEKEY_INTERVAL 20
#define MOUSEKEY_DELAY 0
#define MOUSEKEY_TIME_TO_MAX 60
@@ -54,6 +52,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MOUSEKEY_WHEEL_MAX_SPEED MOUSEKEY_MAX_SPEED
#define MOUSEKEY_WHEEL_TIME_TO_MAX MOUSEKEY_TIME_TO_MAX
+#define DEBOUNCE 30
+
#define TAPPING_TOGGLE 1
/* define if matrix has ghost */
@@ -114,9 +114,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* manufacturer specs.
*/
-#define DEBOUNCE 30
-
-#define USB_MAX_POWER_CONSUMPTION 500
// RGB backlight
#define DRIVER_ADDR_1 0b1110100
diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c
index 6b76b1d8cb..315ed98b5e 100644
--- a/keyboards/ergodox_ez/ergodox_ez.c
+++ b/keyboards/ergodox_ez/ergodox_ez.c
@@ -43,6 +43,7 @@ extern inline void ergodox_right_led_set(uint8_t led, uint8_t n);
extern inline void ergodox_led_all_set(uint8_t n);
keyboard_config_t keyboard_config;
+
bool i2c_initialized = 0;
i2c_status_t mcp23018_status = 0x20;
@@ -243,16 +244,6 @@ const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
#ifdef RGB_MATRIX_ENABLE
-void suspend_power_down_kb(void) {
- rgb_matrix_set_suspend_state(true);
- suspend_power_down_user();
-}
-
-void suspend_wakeup_init_kb(void) {
- rgb_matrix_set_suspend_state(false);
- suspend_wakeup_init_user();
-}
-
const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
/* driver
* | R location
@@ -348,13 +339,26 @@ led_config_t g_led_config = { {
4, 4, 1, 1, 1, 1
} };
+void suspend_power_down_kb(void) {
+ rgb_matrix_set_color_all(0, 0, 0);
+ rgb_matrix_set_suspend_state(true);
+ suspend_power_down_user();
+}
+
+ void suspend_wakeup_init_kb(void) {
+ rgb_matrix_set_suspend_state(false);
+ suspend_wakeup_init_user();
+}
+
+# ifdef ORYX_CONFIGURATOR
void keyboard_post_init_kb(void) {
rgb_matrix_enable_noeeprom();
keyboard_post_init_user();
}
+# endif
#endif
-
+#ifdef ORYX_CONFIGURATOR
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LED_LEVEL:
@@ -399,6 +403,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
}
return process_record_user(keycode, record);
}
+#endif
void eeconfig_init_kb(void) { // EEPROM is getting reset!
keyboard_config.raw = 0;
diff --git a/keyboards/ergodox_ez/ergodox_ez.h b/keyboards/ergodox_ez/ergodox_ez.h
index a10e0fee63..eb04cb88c0 100644
--- a/keyboards/ergodox_ez/ergodox_ez.h
+++ b/keyboards/ergodox_ez/ergodox_ez.h
@@ -86,8 +86,7 @@ inline void ergodox_left_led_2_off(void) { ergodox_left_led_2 = 0; }
inline void ergodox_left_led_3_off(void) { ergodox_left_led_3 = 0; }
#endif // LEFT_LEDS
-inline void ergodox_led_all_on(void)
-{
+inline void ergodox_led_all_on(void) {
ergodox_board_led_on();
ergodox_right_led_1_on();
ergodox_right_led_2_on();
@@ -121,8 +120,7 @@ inline void ergodox_right_led_set(uint8_t led, uint8_t n) {
(OCR1C = n);
}
-inline void ergodox_led_all_set(uint8_t n)
-{
+inline void ergodox_led_all_set(uint8_t n) {
ergodox_right_led_1_set(n);
ergodox_right_led_2_set(n);
ergodox_right_led_3_set(n);
diff --git a/keyboards/ergodox_ez/glow/glow.h b/keyboards/ergodox_ez/glow/glow.h
index a504e4fdfb..da7a6073ef 100644
--- a/keyboards/ergodox_ez/glow/glow.h
+++ b/keyboards/ergodox_ez/glow/glow.h
@@ -3,14 +3,17 @@ Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
Copyright 2015 ZSA Technology Labs Inc (@zsa)
Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+
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/>.
*/
diff --git a/keyboards/ergodox_ez/glow/rules.mk b/keyboards/ergodox_ez/glow/rules.mk
index f1a5c8b0f2..aad92997d0 100644
--- a/keyboards/ergodox_ez/glow/rules.mk
+++ b/keyboards/ergodox_ez/glow/rules.mk
@@ -1,3 +1 @@
-RGB_MATRIX_ENABLE = IS31FL3731
RGB_MATRIX_ENABLE = yes
-RGB_MATRIX_DRIVER = IS31FL3731
diff --git a/keyboards/ergodox_ez/info.json b/keyboards/ergodox_ez/info.json
index 6f7a941574..6c5598b083 100644
--- a/keyboards/ergodox_ez/info.json
+++ b/keyboards/ergodox_ez/info.json
@@ -1,7 +1,7 @@
{
"keyboard_name": "ErgoDox EZ",
"url": "ergodox-ez.com",
- "maintainer": "erez",
+ "maintainer": "ZSA via Drashna",
"width": 17,
"height": 8,
diff --git a/keyboards/ergodox_ez/keymaps/default/keymap.c b/keyboards/ergodox_ez/keymaps/default/keymap.c
index 9550d6465c..83aed78d26 100644
--- a/keyboards/ergodox_ez/keymaps/default/keymap.c
+++ b/keyboards/ergodox_ez/keymaps/default/keymap.c
@@ -1,13 +1,18 @@
#include QMK_KEYBOARD_H
#include "version.h"
-#define BASE 0 // default layer
-#define SYMB 1 // symbols
-#define MDIA 2 // media keys
+enum layers {
+ BASE, // default layer
+ SYMB, // symbols
+ MDIA, // media keys
+};
enum custom_keycodes {
- EPRM = SAFE_RANGE,
- VRSN,
+#ifdef ORYX_CONFIGURATOR
+ VRSN = EZ_SAFE_RANGE,
+#else
+ VRSN = SAFE_RANGE,
+#endif
RGB_SLD
};
@@ -33,25 +38,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | |ace | End | | PgDn | | |
* `--------------------' `----------------------'
*/
-[BASE] = LAYOUT_ergodox(
+[BASE] = LAYOUT_ergodox_pretty(
// left hand
- KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
- KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
- KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G,
- KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO),
- LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT,
- ALT_T(KC_APP), KC_LGUI,
- KC_HOME,
- KC_SPC, KC_BSPC, KC_END,
- // right hand
- KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
- TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
- KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), GUI_T(KC_QUOT),
- MEH_T(KC_NO), KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
- KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, TT(SYMB),
- KC_LALT, CTL_T(KC_ESC),
- KC_PGUP,
- KC_PGDN, KC_TAB, KC_ENT
+ KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
+ KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
+ KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), GUI_T(KC_QUOT),
+ KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), MEH_T(KC_NO), KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
+ LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, TT(SYMB),
+ ALT_T(KC_APP), KC_LGUI, KC_LALT, CTL_T(KC_ESC),
+ KC_HOME, KC_PGUP,
+ KC_SPC, KC_BSPC, KC_END, KC_PGDN, KC_TAB, KC_ENT
),
/* Keymap 1: Symbol Layer
*
@@ -74,25 +70,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | | | |
* `--------------------' `--------------------'
*/
-[SYMB] = LAYOUT_ergodox(
+[SYMB] = LAYOUT_ergodox_pretty(
// left hand
- VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
- KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS,
- KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV,
- KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS,
- EPRM, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- RGB_MOD, KC_TRNS,
- KC_TRNS,
- RGB_VAD, RGB_VAI, KC_TRNS,
- // right hand
- KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
- KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
- KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS,
- KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS,
- KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS,
- RGB_TOG, RGB_SLD,
- KC_TRNS,
- KC_TRNS, RGB_HUD, RGB_HUI
+ VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
+ KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
+ KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS,
+ KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS,
+ EEP_RST, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS,
+ RGB_MOD, KC_TRNS, RGB_TOG, RGB_SLD,
+ KC_TRNS, KC_TRNS,
+ RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, RGB_HUD, RGB_HUI
),
/* Keymap 2: Media and mouse keys
*
@@ -115,34 +102,23 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | | | |
* `--------------------' `--------------------'
*/
-[MDIA] = LAYOUT_ergodox(
+[MDIA] = LAYOUT_ergodox_pretty(
// left hand
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2,
- KC_TRNS, KC_TRNS,
- KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS,
- // right hand
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
- KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS,
- KC_TRNS,
- KC_TRNS, KC_TRNS, KC_WBAK
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS,
+
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_WBAK
),
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
- case EPRM:
- eeconfig_init();
- return false;
case VRSN:
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
return false;
@@ -157,7 +133,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
// Runs just one time when the keyboard initializes.
-void matrix_init_user(void) {
+void keyboard_post_init_user(void) {
#ifdef RGBLIGHT_COLOR_LAYER_0
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
#endif
@@ -170,15 +146,11 @@ layer_state_t layer_state_set_user(layer_state_t state) {
ergodox_right_led_2_off();
ergodox_right_led_3_off();
- uint8_t layer = biton32(state);
+ uint8_t layer = get_highest_layer(state);
switch (layer) {
case 0:
#ifdef RGBLIGHT_COLOR_LAYER_0
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
- #else
- #ifdef RGBLIGHT_ENABLE
- rgblight_init();
- #endif
#endif
break;
case 1:
diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c
index 88aeb61722..41919a7000 100644
--- a/keyboards/ergodox_ez/matrix.c
+++ b/keyboards/ergodox_ez/matrix.c
@@ -24,6 +24,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/>.
*/
+
/*
* scan matrix
*/
diff --git a/keyboards/ergodox_ez/rules.mk b/keyboards/ergodox_ez/rules.mk
index bfd8355ad0..72781ff901 100644
--- a/keyboards/ergodox_ez/rules.mk
+++ b/keyboards/ergodox_ez/rules.mk
@@ -26,6 +26,7 @@ CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
CUSTOM_MATRIX = lite # Custom matrix file for the ErgoDox EZ
NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+
UNICODE_ENABLE = no # Unicode
SWAP_HANDS_ENABLE= no # Allow swapping hands of keyboard
SLEEP_LED_ENABLE = no
@@ -43,3 +44,7 @@ QUANTUM_LIB_SRC += i2c_master.c
LAYOUTS = ergodox
MOUSE_SHARED_EP = no
+
+# Disable unsupported hardware
+AUDIO_SUPPORTED = no
+BACKLIGHT_SUPPORTED = no
diff --git a/keyboards/ergodox_ez/shine/config.h b/keyboards/ergodox_ez/shine/config.h
index c2bc6b5342..cf4f59f3b8 100644
--- a/keyboards/ergodox_ez/shine/config.h
+++ b/keyboards/ergodox_ez/shine/config.h
@@ -3,14 +3,17 @@ Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
Copyright 2015 ZSA Technology Labs Inc (@zsa)
Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+
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/>.
*/
diff --git a/keyboards/ergodox_ez/shine/shine.h b/keyboards/ergodox_ez/shine/shine.h
index a504e4fdfb..da7a6073ef 100644
--- a/keyboards/ergodox_ez/shine/shine.h
+++ b/keyboards/ergodox_ez/shine/shine.h
@@ -3,14 +3,17 @@ Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
Copyright 2015 ZSA Technology Labs Inc (@zsa)
Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+
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/>.
*/
diff --git a/keyboards/ergodox_ez/util/compile_keymap.py b/keyboards/ergodox_ez/util/compile_keymap.py
index f427d6fd80..f427d6fd80 100644..100755
--- a/keyboards/ergodox_ez/util/compile_keymap.py
+++ b/keyboards/ergodox_ez/util/compile_keymap.py
diff --git a/keyboards/ergodox_ez/util/readme.md b/keyboards/ergodox_ez/util/readme.md
index 26c5e5d99c..deb0cad5db 100644
--- a/keyboards/ergodox_ez/util/readme.md
+++ b/keyboards/ergodox_ez/util/readme.md
@@ -1,3 +1,11 @@
# ErgoDox EZ Utilities
+## compile_keymap.py
+
The Python script in this directory, by [mbarkhau](https://github.com/mbarkhau) allows you to write out a basic ErgoDox EZ keymap using Markdown notation, and then transpile it to C, which you can then compile. It's experimental, but if you're not comfortable using C, it's a nice option.
+
+## keymap_beautifier.py
+
+This Python 3 script, by [Tsan-Kuang Lee](https://github.com/tsankuanglee) takes the keymap.c downloaded from [ErgoDox EZ Configurator](https://configure.ergodox-ez.com/) and beautifies it for easier customization, allowing one to quickly draft a layout to build upon.
+
+See [README.md](./keymap_beautifier/README.md) for this utility for more details.
diff --git a/keyboards/moonlander/config.h b/keyboards/moonlander/config.h
index d49c33de8c..18a7dacdb6 100644
--- a/keyboards/moonlander/config.h
+++ b/keyboards/moonlander/config.h
@@ -1,19 +1,20 @@
-/*
-Copyright 2018 Jack Humbert <jack.humb@gmail.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/>.
-*/
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+ *
+ * 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
@@ -23,9 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// clang-format off
#define VENDOR_ID 0x3297
#define PRODUCT_ID 0x1969
-#define MANUFACTURER ZSA
+#define MANUFACTURER ZSA Technology Labs
#define PRODUCT Moonlander Mark I
-#define DESCRIPTION A keyboard
#define DEVICE_VER 0x0001
#define WEBUSB_LANDING_PAGE_URL u8"configure.ergodox-ez.com"
@@ -35,9 +35,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_ROWS 12
#define MATRIX_COLS 7
-/* Planck PCB default pin-out */
+/* PCB default pin-out */
// #define MATRIX_ROW_PINS { B10, B11, B12, B13, B14, B15 }
-// #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6 }
+// #define MATRIX_COL_PINS { A0, A1, A2, A3, A6, A7, B0 }
// #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 }
// #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 }
@@ -46,9 +46,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define MCP23_LED_G GPB6
// #define MCP23_LED_B GPA7
-#define EEPROM_I2C_24LC128
-#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (1638-1)
-
// Not needed, is default address:
// #define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10100000
@@ -78,10 +75,8 @@ 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
-
-#define I2C1_CLOCK_SPEED 400000
+#define NO_ACTION_MACRO
+#define NO_ACTION_FUNCTION
#define DRIVER_ADDR_1 0b1110100
#define DRIVER_ADDR_2 0b1110111
@@ -90,9 +85,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DRIVER_1_LED_TOTAL 36
#define DRIVER_2_LED_TOTAL 36
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
-#define RGB_MATRIX_CENTER \
- { 125, 26 }
-#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
+#define RGB_MATRIX_CENTER { 125, 26 }
+#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
#define RGB_MATRIX_KEYPRESSES
#define RGB_DISABLE_WHEN_USB_SUSPENDED true
@@ -115,6 +109,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MUSIC_MAP
-
#define FIRMWARE_VERSION_SIZE 17
#define DYNAMIC_KEYMAP_EEPROM_ADDR (EECONFIG_SIZE + FIRMWARE_VERSION_SIZE)
+#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 16383
+#define DYNAMIC_KEYMAP_LAYER_COUNT 32
+#define EEPROM_I2C_24LC128
+
+#define AUDIO_PIN A5
+#define AUDIO_PIN_ALT A4
+#define AUDIO_PIN_ALT_AS_NEGATIVE
diff --git a/keyboards/moonlander/info.json b/keyboards/moonlander/info.json
new file mode 100644
index 0000000000..34f4e8a9ae
--- /dev/null
+++ b/keyboards/moonlander/info.json
@@ -0,0 +1,30 @@
+{
+ "keyboard_name": "Moonlander Mark I",
+ "url": "zsa.io/moonlander",
+ "maintainer": "ZSA via Drashna",
+ "width": 17,
+ "height": 8,
+
+ "layouts": {
+ "LAYOUT_moonlander": {
+ "layout": [
+ {"x":0, "y":0.375}, {"x":1, "y":0.375}, {"x":2, "y":0.125}, {"x":3, "y":0}, {"x":4, "y":0.125}, {"x":5, "y":0.25}, {"x":6, "y":0.25},
+ {"x":10, "y":0.25}, {"x":11, "y":0.25}, {"x":12, "y":0.125}, {"x":13, "y":0}, {"x":14, "y":0.125}, {"x":15, "y":0.375}, {"x":16, "y":0.375},
+
+ {"x":0, "y":1.375}, {"x":1, "y":1.375}, {"x":2, "y":1.125}, {"x":3, "y":1}, {"x":4, "y":1.125}, {"x":5, "y":1.25}, {"x":6, "y":1.25},
+ {"x":10, "y":1.25}, {"x":11, "y":1.25}, {"x":12, "y":1.125}, {"x":13, "y":1}, {"x":14, "y":1.125}, {"x":15, "y":1.375}, {"x":16, "y":1.375},
+
+ {"x":0, "y":2.375}, {"x":1, "y":2.375}, {"x":2, "y":2.125}, {"x":3, "y":2}, {"x":4, "y":2.125}, {"x":5, "y":2.25}, {"x":6, "y":2.25},
+ {"x":10, "y":2.25}, {"x":11, "y":2.25}, {"x":12, "y":2.125}, {"x":13, "y":2}, {"x":14, "y":2.125}, {"x":15, "y":2.375}, {"x":16, "y":2.375},
+
+ {"x":0, "y":3.375}, {"x":1, "y":3.375}, {"x":2, "y":3.125}, {"x":3, "y":3}, {"x":4, "y":3.125}, {"x":5, "y":3.25},
+ {"x":11, "y":3.25}, {"x":12, "y":3.125}, {"x":13, "y":3}, {"x":14, "y":3.125}, {"x":15, "y":3.375}, {"x":16, "y":3.375},
+
+ {"x":0, "y":4.375}, {"x":1, "y":4.375}, {"x":2, "y":4.125}, {"x":3, "y":4}, {"x":4, "y":4.125}, {"x":5, "y":4.5, "w":2},
+ {"x":10, "y":4.5, "w":2}, {"x":12, "y":4.125}, {"x":13, "y":4}, {"x":14, "y":4.125}, {"x":15, "y":4.375}, {"x":16, "y":4.375},
+
+ {"x":5, "y":5.5, "h":1.5}, {"x":6, "y":5.5, "h":1.5}, {"x":7, "y":5.5, "h":1.5}, {"x":9, "y":5.5, "h":1.5}, {"x":10, "y":5.5, "h":1.5}, {"x":11, "y":5.5, "h":1.5}
+ ]
+ }
+ }
+}
diff --git a/keyboards/moonlander/keymaps/default/config.h b/keyboards/moonlander/keymaps/default/config.h
index 8da226b0a6..576aae9f52 100644
--- a/keyboards/moonlander/keymaps/default/config.h
+++ b/keyboards/moonlander/keymaps/default/config.h
@@ -1,3 +1,21 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+ *
+ * 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
#define ORYX_CONFIGURATOR
diff --git a/keyboards/moonlander/matrix.c b/keyboards/moonlander/matrix.c
index 13009b7e40..6a24346180 100644
--- a/keyboards/moonlander/matrix.c
+++ b/keyboards/moonlander/matrix.c
@@ -1,18 +1,19 @@
-/*
-Copyright 2018 Jack Humbert <jack.humb@gmail.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/>.
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+ *
+ * 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 <stdint.h>
@@ -45,6 +46,10 @@ static uint16_t debouncing_time_right = 0;
#define ROWS_PER_HAND (MATRIX_ROWS / 2)
+#ifndef MATRIX_IO_DELAY
+# define MATRIX_IO_DELAY 20
+#endif
+
extern bool mcp23018_leds[3];
extern bool is_launching;
@@ -56,6 +61,8 @@ __attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); }
__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); }
+__attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); }
+
bool mcp23018_initd = false;
static uint8_t mcp23018_reset_loop;
@@ -134,7 +141,7 @@ uint8_t matrix_scan(void) {
}
// need wait to settle pin state
- wait_us(20);
+ matrix_io_delay();
// read col data
data = (
@@ -262,10 +269,8 @@ void matrix_print(void) {
// DO NOT REMOVE
// Needed for proper wake/sleep
-
void matrix_power_up(void) {
bool temp_launching = is_launching;
-
// outputs
setPinOutput(B10);
setPinOutput(B11);
diff --git a/keyboards/moonlander/moonlander.c b/keyboards/moonlander/moonlander.c
index 42c119c2d9..efc7de85bb 100644
--- a/keyboards/moonlander/moonlander.c
+++ b/keyboards/moonlander/moonlander.c
@@ -1,36 +1,37 @@
-/*
-Copyright 2018 Jack Humbert <jack.humb@gmail.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.
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+ *
+ * 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 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 "moonlander.h"
#ifdef WEBUSB_ENABLE
-#include "webusb.h"
+# include "webusb.h"
#endif
keyboard_config_t keyboard_config;
bool mcp23018_leds[3] = {0, 0, 0};
-bool is_launching = false;
+bool is_launching = false;
#ifdef DYNAMIC_MACRO_ENABLE
static bool is_dynamic_recording = false;
-void dynamic_macro_record_start_user(void) {
- is_dynamic_recording = true;
-}
+void dynamic_macro_record_start_user(void) { is_dynamic_recording = true; }
void dynamic_macro_record_end_user(int8_t direction) {
is_dynamic_recording = false;
@@ -163,8 +164,7 @@ void keyboard_pre_init_kb(void) {
writePinLow(B4);
writePinLow(B3);
-
- chThdCreateStatic(waLEDThread, sizeof(waLEDThread), NORMALPRIO-16, LEDThread, NULL);
+ chThdCreateStatic(waLEDThread, sizeof(waLEDThread), NORMALPRIO - 16, LEDThread, NULL);
/* the array is initialized to 0, no need to re-set it here */
// mcp23018_leds[0] = 0; // blue
@@ -176,7 +176,7 @@ void keyboard_pre_init_kb(void) {
#if !defined(MOONLANDER_USER_LEDS)
layer_state_t layer_state_set_kb(layer_state_t state) {
- state = layer_state_set_user(state);
+ state = layer_state_set_user(state);
if (is_launching || !keyboard_config.led_level) return state;
ML_LED_1(false);
@@ -361,7 +361,7 @@ void suspend_power_down_kb(void) {
suspend_power_down_user();
}
- void suspend_wakeup_init_kb(void) {
+void suspend_wakeup_init_kb(void) {
rgb_matrix_set_suspend_state(false);
suspend_wakeup_init_user();
}
@@ -423,13 +423,11 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_moonlander(
// clang-format on
#endif
-
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
#ifdef WEBUSB_ENABLE
case WEBUSB_PAIR:
- if (!record->event.pressed && !webusb_state.pairing)
- layer_state_set_kb(layer_state);
+ if (!record->event.pressed && !webusb_state.pairing) layer_state_set_kb(layer_state);
break;
#endif
#if !defined(MOONLANDER_USER_LEDS)
@@ -454,27 +452,24 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
case TOGGLE_LAYER_COLOR:
if (record->event.pressed) {
keyboard_config.disable_layer_led ^= 1;
- if (keyboard_config.disable_layer_led)
- rgb_matrix_set_color_all(0, 0, 0);
+ if (keyboard_config.disable_layer_led) rgb_matrix_set_color_all(0, 0, 0);
eeconfig_update_kb(keyboard_config.raw);
}
break;
case RGB_TOG:
if (record->event.pressed) {
- switch (rgb_matrix_get_flags()) {
- case LED_FLAG_ALL: {
- rgb_matrix_set_flags(LED_FLAG_NONE);
- keyboard_config.rgb_matrix_enable = false;
- rgb_matrix_set_color_all(0, 0, 0);
- }
- break;
- default: {
- rgb_matrix_set_flags(LED_FLAG_ALL);
- keyboard_config.rgb_matrix_enable = true;
- }
- break;
- }
- eeconfig_update_kb(keyboard_config.raw);
+ switch (rgb_matrix_get_flags()) {
+ case LED_FLAG_ALL: {
+ rgb_matrix_set_flags(LED_FLAG_NONE);
+ keyboard_config.rgb_matrix_enable = false;
+ rgb_matrix_set_color_all(0, 0, 0);
+ } break;
+ default: {
+ rgb_matrix_set_flags(LED_FLAG_ALL);
+ keyboard_config.rgb_matrix_enable = true;
+ } break;
+ }
+ eeconfig_update_kb(keyboard_config.raw);
}
return false;
#endif
@@ -490,7 +485,6 @@ void matrix_init_kb(void) {
keyboard_config.led_level_res = 0b11;
eeconfig_update_kb(keyboard_config.raw);
}
-
#ifdef RGB_MATRIX_ENABLE
if (keyboard_config.rgb_matrix_enable) {
rgb_matrix_set_flags(LED_FLAG_ALL);
diff --git a/keyboards/moonlander/moonlander.h b/keyboards/moonlander/moonlander.h
index 1fd1db8ad5..e81e168b96 100644
--- a/keyboards/moonlander/moonlander.h
+++ b/keyboards/moonlander/moonlander.h
@@ -1,22 +1,29 @@
-/*
-Copyright 2018 Jack Humbert <jack.humb@gmail.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.
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
+ *
+ * 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 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"
+
+extern bool mcp23018_leds[];
+
#define MCP23018_DEFAULT_ADDRESS 0b0100000
#define ML_LED_1(status) writePin(B5, (bool)status)
@@ -27,8 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ML_LED_5(status) mcp23018_leds[1] = (bool)status
#define ML_LED_6(status) mcp23018_leds[2] = (bool)status
-#include "quantum.h"
-
// clang-format off
#define LAYOUT_moonlander( \
k00, k01, k02, k03, k04, k05, k06, k60, k61, k62, k63, k64, k65, k66, \
diff --git a/keyboards/moonlander/readme.md b/keyboards/moonlander/readme.md
new file mode 100644
index 0000000000..7ddfdb84a7
--- /dev/null
+++ b/keyboards/moonlander/readme.md
@@ -0,0 +1,28 @@
+# Moonlander
+
+![Moonlander](https://zsa.io/static/gallery-white-case-7a2ef555f8f7f4ce1b9030477b16e517.png)
+
+A next-gen split, ergonomic keyboard with an active left side, USB type C, integrated wrist rest, and a thumb cluster that can move.
+
+
+* Keyboard Maintainer: [drashna](https://github.com/drashna), [ZSA](https://github.com/zsa/)
+* Hardware Supported: Moonlander MK 1 (STM32F303xC)
+* Hardware Availability: [ZSA Store](https://zsa.io/moonlander/)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make moonlander:default
+
+Flashing example for this keyboard:
+
+ make moonlander:default:flash
+
+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).
+
+## Oryx Configuation
+
+If you're using the Smart LED (layer indication) feature from the Oryx Configurator, you want to make sure that you enable these options by adding `#define ORYX_CONFIGURATOR` to your keymap's `config.h`.
+
+This changes the `RGB_TOG` keycode so that it will toggle the lights on and off, in a way that will allow the Smart LEDs to continue to work, even with the rest of the LEDs turned off.
+
+Additionally, a new keycode has been added to toggle the Smart LEDs. Use `TOGGLE_LAYER_COLOR`, if you aren't already.
diff --git a/keyboards/moonlander/rules.mk b/keyboards/moonlander/rules.mk
index f5a3859cca..ffd415d78d 100644
--- a/keyboards/moonlander/rules.mk
+++ b/keyboards/moonlander/rules.mk
@@ -1,27 +1,32 @@
-#Cortex version
-MCU = STM32F303
+# MCU name
+MCU = STM32F303
+BOARD = QMK_PROTON_C
-#Build Options
-#comment out to disable the options.
+# Build Options
+# change yes to no to disable
#
-BACKLIGHT_ENABLE = no
-BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
-MOUSEKEY_ENABLE = yes # Mouse keys
-EXTRAKEY_ENABLE = yes # Audio control and System control
-CONSOLE_ENABLE = no # Console for debug
-COMMAND_ENABLE = yes # Commands for debug and configuration
-#SLEEP_LED_ENABLE = yes #Breathing sleep LED during USB suspend
-NKRO_ENABLE = yes # USB Nkey Rollover
-CUSTOM_MATRIX = yes # Custom matrix file
-AUDIO_ENABLE = yes
-SWAP_HANDS_ENABLE = no
+BOOTMAGIC_ENABLE = lite # 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 = yes # USB Nkey Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
+BLUETOOTH_ENABLE = no # Enable Bluetooth
+AUDIO_ENABLE = yes # Audio output
+CUSTOM_MATRIX = yes
+DEBOUNCE_TYPE = custom
+SWAP_HANDS_ENABLE = yes
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = IS31FL3731
#SERIAL_LINK_ENABLE = yes
-EEPROM_DRIVER = i2c
+EEPROM_DRIVER = i2c
+MOUSE_SHARED_EP = no
#project specific files
-SRC = matrix.c
+SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
-
-MOUSE_SHARED_EP = no
diff --git a/keyboards/planck/config.h b/keyboards/planck/config.h
index 837311c769..71111eca21 100644
--- a/keyboards/planck/config.h
+++ b/keyboards/planck/config.h
@@ -21,11 +21,9 @@ 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 0x6060
+#define VENDOR_ID 0x03A8
#define MANUFACTURER OLKB
#define PRODUCT Planck
-#define DESCRIPTION A compact ortholinear keyboard
/* key matrix size */
#define MATRIX_ROWS 4
@@ -42,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define QMK_SPEAKER C6
#define AUDIO_VOICES
-#define C6_AUDIO
+#define AUDIO_PIN C6
#define BACKLIGHT_PIN B7
@@ -56,7 +54,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_LEVELS 3
/* Set 0 if debouncing isn't needed */
-#define DEBOUNCING_DELAY 5
+#define DEBOUNCE 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
diff --git a/quantum/template/base/template.h b/keyboards/planck/ez/chconf.h
index 595da73c60..e1243f23ec 100644
--- a/quantum/template/base/template.h
+++ b/keyboards/planck/ez/chconf.h
@@ -1,4 +1,4 @@
-/* Copyright %YEAR% %YOUR_NAME%
+/* Copyright 2020 QMK
*
* 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
@@ -13,17 +13,17 @@
* 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 file was auto-generated by:
+ * `qmk chibios-confmigrate -i keyboards/planck/rev6/chconf.h -r platforms/chibios/QMK_PROTON_C/configs/chconf.h`
+ */
+
#pragma once
-#include "quantum.h"
+#define CH_CFG_ST_RESOLUTION 16
+
+#define CH_CFG_ST_FREQUENCY 10000
+
+#include_next <chconf.h>
-/* This 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.
- *
- * The second converts the arguments into a two-dimensional array which
- * represents the switch matrix.
- */
-#define LAYOUT(k00, k01, k02, k10, k11) \
- { {k00, k01, k02}, {k10, KC_NO, k11}, }
diff --git a/keyboards/planck/ez/config.h b/keyboards/planck/ez/config.h
index e5071f7e0c..a3713a5d2b 100644
--- a/keyboards/planck/ez/config.h
+++ b/keyboards/planck/ez/config.h
@@ -17,7 +17,7 @@
#pragma once
-/* USB Device descriptor parameter */
+
#undef VENDOR_ID
#define VENDOR_ID 0x3297
#undef PRODUCT_ID
@@ -27,7 +27,7 @@
#undef PRODUCT
#define PRODUCT Planck EZ
#define DEVICE_VER 0x0000
-#define WEBUSB_LANDING_PAGE_URL u8"configure.ergodox-ez.com"
+
#undef MATRIX_ROWS
#undef MATRIX_COLS
@@ -57,10 +57,13 @@
#define MUSIC_MAP
#undef AUDIO_VOICES
-#undef C6_AUDIO
+#undef AUDIO_PIN
+#define AUDIO_PIN A5
+#define AUDIO_PIN_ALT A4
+#define AUDIO_PIN_ALT_AS_NEGATIVE
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
-#define DEBOUNCE 6
+// #define DEBOUNCE 6
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
//#define LOCKING_SUPPORT_ENABLE
@@ -110,9 +113,6 @@
* MIDI options
*/
-/* Prevent use of disabled MIDI features in the keymap */
-//#define MIDI_ENABLE_STRICT 1
-
/* enable basic MIDI features:
- MIDI notes can be sent when in Music mode is on
*/
@@ -129,16 +129,6 @@
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
//#define MIDI_TONE_KEYCODE_OCTAVES 1
-// #define WS2812_LED_N 2
-// #define RGBLED_NUM WS2812_LED_N
-// #define WS2812_TIM_N 2
-// #define WS2812_TIM_CH 2
-// #define PORT_WS2812 GPIOA
-// #define PIN_WS2812 1
-// #define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA stream for TIMx_UP (look up in reference manual under DMA Channel selection)
-//#define WS2812_DMA_CHANNEL 7 // DMA channel for TIMx_UP
-//#define WS2812_EXTERNAL_PULLUP
-
#define DRIVER_ADDR_1 0b1010000
#define DRIVER_ADDR_2 0b1010000 // this is here for compliancy reasons.
@@ -150,11 +140,9 @@
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
#define RGB_DISABLE_WHEN_USB_SUSPENDED true
-
#define RGB_MATRIX_LED_PROCESS_LIMIT 5
#define RGB_MATRIX_LED_FLUSH_LIMIT 26
-#define I2C1_CLOCK_SPEED 400000
#define IGNORE_MOD_TAP_INTERRUPT
diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c
index b4f3d811ef..87ee3f7238 100644
--- a/keyboards/planck/ez/ez.c
+++ b/keyboards/planck/ez/ez.c
@@ -18,18 +18,7 @@
#include <hal.h>
keyboard_config_t keyboard_config;
-
#ifdef RGB_MATRIX_ENABLE
-void suspend_power_down_kb(void) {
- rgb_matrix_set_suspend_state(true);
- suspend_power_down_user();
-}
-
-void suspend_wakeup_init_kb(void) {
- rgb_matrix_set_suspend_state(false);
- suspend_wakeup_init_user();
-}
-
const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
/* Refer to IS31 manual for these locations
* driver
@@ -114,8 +103,24 @@ led_config_t g_led_config = { {
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1
} };
+
+void suspend_power_down_kb(void) {
+ rgb_matrix_set_color_all(0, 0, 0);
+ rgb_matrix_set_suspend_state(true);
+ suspend_power_down_user();
+}
+
+ void suspend_wakeup_init_kb(void) {
+ rgb_matrix_set_suspend_state(false);
+ suspend_wakeup_init_user();
+}
+void keyboard_post_init_kb(void) {
+ rgb_matrix_enable_noeeprom();
+ keyboard_post_init_user();
+}
#endif
+/* Left B9 Right B8 */
// See http://jared.geek.nz/2013/feb/linear-led-pwm
static uint16_t cie_lightness(uint16_t v) {
@@ -133,7 +138,7 @@ static uint16_t cie_lightness(uint16_t v) {
}
}
- static PWMConfig pwmCFG = {
+static PWMConfig pwmCFG = {
0xFFFF,/* PWM clock frequency */
256,/* initial PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */
NULL,
@@ -218,29 +223,18 @@ void keyboard_pre_init_kb(void) {
rgb_matrix_set_flags(LED_FLAG_NONE);
}
#endif
-
- // initialize settings for front LEDs
led_initialize_hardware();
keyboard_pre_init_user();
}
-#ifdef RGB_MATRIX_ENABLE
-void keyboard_post_init_kb(void) {
- rgb_matrix_enable_noeeprom();
- keyboard_post_init_user();
-}
-#endif
-
void eeconfig_init_kb(void) { // EEPROM is getting reset!
keyboard_config.raw = 0;
keyboard_config.rgb_matrix_enable = true;
keyboard_config.led_level = 4;
-
eeconfig_update_kb(keyboard_config.raw);
eeconfig_init_user();
}
-
layer_state_t layer_state_set_kb(layer_state_t state) {
planck_ez_left_led_off();
planck_ez_right_led_off();
@@ -281,7 +275,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
case TOGGLE_LAYER_COLOR:
if (record->event.pressed) {
keyboard_config.disable_layer_led ^= 1;
- if (keyboard_config.disable_layer_led)
+ if (keyboard_config.disable_layer_led)
rgb_matrix_set_color_all(0, 0, 0);
eeconfig_update_kb(keyboard_config.raw);
}
@@ -306,9 +300,10 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return false;
#endif
}
- return process_record_user(keycode, record);
+ return process_record_user(keycode, record);
}
+
#ifdef AUDIO_ENABLE
bool music_mask_kb(uint16_t keycode) {
switch (keycode) {
@@ -324,6 +319,7 @@ bool music_mask_kb(uint16_t keycode) {
}
}
#endif
+
#ifdef ORYX_ENABLE
static uint16_t loops = 0;
static bool is_on = false;
diff --git a/keyboards/planck/ez/ez.h b/keyboards/planck/ez/ez.h
index 07182417fc..144734a885 100644
--- a/keyboards/planck/ez/ez.h
+++ b/keyboards/planck/ez/ez.h
@@ -39,17 +39,21 @@
}
#define LAYOUT_ortho_4x12( \
- k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
- k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
- k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \
- k30, k31, k32, k33, k34, k35, KC_NO, k37, k38, k39, k3a, k3b \
-) \
-LAYOUT_planck_1x2uC( \
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, \
- k30, k31, k32, k33, k34, k35, k37, k38, k39, k3a, k3b \
-)
+ k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b \
+) \
+{ \
+ { k00, k01, k02, k03, k04, k05 }, \
+ { k10, k11, k12, k13, k14, k15 }, \
+ { k20, k21, k22, k23, k24, k25 }, \
+ { k30, k31, k32, k3a, k3b, KC_NO }, \
+ { k06, k07, k08, k09, k0a, k0b }, \
+ { k16, k17, k18, k19, k1a, k1b }, \
+ { k26, k27, k28, k29, k2a, k2b }, \
+ { k37, k38, k39, k33, k34, k35 } \
+}
#define KEYMAP LAYOUT_ortho_4x12
#define LAYOUT_planck_mit LAYOUT_planck_1x2uC
@@ -71,7 +75,7 @@ enum planck_ez_keycodes {
typedef union {
uint32_t raw;
struct {
- uint8_t led_level :3;
+ uint8_t led_level :3;
bool disable_layer_led :1;
bool rgb_matrix_enable :1;
};
diff --git a/keyboards/planck/ez/glow/glow.c b/keyboards/planck/ez/glow/glow.c
new file mode 100644
index 0000000000..1813ccae09
--- /dev/null
+++ b/keyboards/planck/ez/glow/glow.c
@@ -0,0 +1 @@
+#include "glow.h"
diff --git a/keyboards/planck/ez/glow/keymaps/glow/config.h b/keyboards/planck/ez/glow/keymaps/glow/config.h
index 6fa31cc8a7..501d118632 100644
--- a/keyboards/planck/ez/glow/keymaps/glow/config.h
+++ b/keyboards/planck/ez/glow/keymaps/glow/config.h
@@ -1,39 +1,7 @@
#pragma once
#ifdef AUDIO_ENABLE
- #define STARTUP_SONG SONG(PLANCK_SOUND)
- // #define STARTUP_SONG SONG(NO_SOUND)
-
- #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
- SONG(COLEMAK_SOUND), \
- SONG(DVORAK_SOUND) \
- }
+ #define STARTUP_SONG SONG(DVORAK_SOUND)
#endif
-/*
- * MIDI options
- */
-
-/* Prevent use of disabled MIDI features in the keymap */
-//#define MIDI_ENABLE_STRICT 1
-
-/* enable basic MIDI features:
- - MIDI notes can be sent when in Music mode is on
-*/
-
-#define MIDI_BASIC
-
-/* enable advanced MIDI features:
- - MIDI notes can be added to the keymap
- - Octave shift and transpose
- - Virtual sustain, portamento, and modulation wheel
- - etc.
-*/
-//#define MIDI_ADVANCED
-
-/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
-//#define MIDI_TONE_KEYCODE_OCTAVES 2
-
-// Most tactile encoders have detents every 4 stages
-#define ENCODER_RESOLUTION 4
-
+#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 5
diff --git a/keyboards/planck/ez/info.json b/keyboards/planck/ez/info.json
index b8382bfe0a..e1573871b6 100644
--- a/keyboards/planck/ez/info.json
+++ b/keyboards/planck/ez/info.json
@@ -1,115 +1,115 @@
{
- "keyboard_name": "Planck EZ",
- "keyboard_folder": "planck/ez",
- "url": "https://ergodox-ez.com/pages/planck",
- "maintainer": "jackhumbert",
- "width": 12,
- "height": 4,
- "layouts": {
- "LAYOUT_planck_1x2uC": {
- "key_count": 47,
- "layout": [
- { "x": 0, "y": 0 },
- { "x": 1, "y": 0 },
- { "x": 2, "y": 0 },
- { "x": 3, "y": 0 },
- { "x": 4, "y": 0 },
- { "x": 5, "y": 0 },
- { "x": 6, "y": 0 },
- { "x": 7, "y": 0 },
- { "x": 8, "y": 0 },
- { "x": 9, "y": 0 },
- { "x": 10, "y": 0 },
- { "x": 11, "y": 0 },
- { "x": 0, "y": 1 },
- { "x": 1, "y": 1 },
- { "x": 2, "y": 1 },
- { "x": 3, "y": 1 },
- { "x": 4, "y": 1 },
- { "x": 5, "y": 1 },
- { "x": 6, "y": 1 },
- { "x": 7, "y": 1 },
- { "x": 8, "y": 1 },
- { "x": 9, "y": 1 },
- { "x": 10, "y": 1 },
- { "x": 11, "y": 1 },
- { "x": 0, "y": 2 },
- { "x": 1, "y": 2 },
- { "x": 2, "y": 2 },
- { "x": 3, "y": 2 },
- { "x": 4, "y": 2 },
- { "x": 5, "y": 2 },
- { "x": 6, "y": 2 },
- { "x": 7, "y": 2 },
- { "x": 8, "y": 2 },
- { "x": 9, "y": 2 },
- { "x": 10, "y": 2 },
- { "x": 11, "y": 2 },
- { "x": 0, "y": 3 },
- { "x": 1, "y": 3 },
- { "x": 2, "y": 3 },
- { "x": 3, "y": 3 },
- { "x": 4, "y": 3 },
- { "x": 5, "y": 3, "w": 2 },
- { "x": 7, "y": 3 },
- { "x": 8, "y": 3 },
- { "x": 9, "y": 3 },
- { "x": 10, "y": 3 },
- { "x": 11, "y": 3 }
- ]
- },
- "LAYOUT_ortho_4x12": {
- "key_count": 48,
- "layout": [
- { "x": 0, "y": 0 },
- { "x": 1, "y": 0 },
- { "x": 2, "y": 0 },
- { "x": 3, "y": 0 },
- { "x": 4, "y": 0 },
- { "x": 5, "y": 0 },
- { "x": 6, "y": 0 },
- { "x": 7, "y": 0 },
- { "x": 8, "y": 0 },
- { "x": 9, "y": 0 },
- { "x": 10, "y": 0 },
- { "x": 11, "y": 0 },
- { "x": 0, "y": 1 },
- { "x": 1, "y": 1 },
- { "x": 2, "y": 1 },
- { "x": 3, "y": 1 },
- { "x": 4, "y": 1 },
- { "x": 5, "y": 1 },
- { "x": 6, "y": 1 },
- { "x": 7, "y": 1 },
- { "x": 8, "y": 1 },
- { "x": 9, "y": 1 },
- { "x": 10, "y": 1 },
- { "x": 11, "y": 1 },
- { "x": 0, "y": 2 },
- { "x": 1, "y": 2 },
- { "x": 2, "y": 2 },
- { "x": 3, "y": 2 },
- { "x": 4, "y": 2 },
- { "x": 5, "y": 2 },
- { "x": 6, "y": 2 },
- { "x": 7, "y": 2 },
- { "x": 8, "y": 2 },
- { "x": 9, "y": 2 },
- { "x": 10, "y": 2 },
- { "x": 11, "y": 2 },
- { "x": 0, "y": 3 },
- { "x": 1, "y": 3 },
- { "x": 2, "y": 3 },
- { "x": 3, "y": 3 },
- { "x": 4, "y": 3 },
- { "x": 5, "y": 3 },
- { "x": 6, "y": 3 },
- { "x": 7, "y": 3 },
- { "x": 8, "y": 3 },
- { "x": 9, "y": 3 },
- { "x": 10, "y": 3 },
- { "x": 11, "y": 3 }
- ]
+ "keyboard_name": "Planck EZ",
+ "keyboard_folder": "planck/ez",
+ "url": "https://ergodox-ez.com/pages/planck",
+ "maintainer": "jackhumbert",
+ "width": 12,
+ "height": 4,
+ "layouts": {
+ "LAYOUT_planck_1x2uC": {
+ "key_count": 47,
+ "layout": [
+ { "x": 0, "y": 0 },
+ { "x": 1, "y": 0 },
+ { "x": 2, "y": 0 },
+ { "x": 3, "y": 0 },
+ { "x": 4, "y": 0 },
+ { "x": 5, "y": 0 },
+ { "x": 6, "y": 0 },
+ { "x": 7, "y": 0 },
+ { "x": 8, "y": 0 },
+ { "x": 9, "y": 0 },
+ { "x": 10, "y": 0 },
+ { "x": 11, "y": 0 },
+ { "x": 0, "y": 1 },
+ { "x": 1, "y": 1 },
+ { "x": 2, "y": 1 },
+ { "x": 3, "y": 1 },
+ { "x": 4, "y": 1 },
+ { "x": 5, "y": 1 },
+ { "x": 6, "y": 1 },
+ { "x": 7, "y": 1 },
+ { "x": 8, "y": 1 },
+ { "x": 9, "y": 1 },
+ { "x": 10, "y": 1 },
+ { "x": 11, "y": 1 },
+ { "x": 0, "y": 2 },
+ { "x": 1, "y": 2 },
+ { "x": 2, "y": 2 },
+ { "x": 3, "y": 2 },
+ { "x": 4, "y": 2 },
+ { "x": 5, "y": 2 },
+ { "x": 6, "y": 2 },
+ { "x": 7, "y": 2 },
+ { "x": 8, "y": 2 },
+ { "x": 9, "y": 2 },
+ { "x": 10, "y": 2 },
+ { "x": 11, "y": 2 },
+ { "x": 0, "y": 3 },
+ { "x": 1, "y": 3 },
+ { "x": 2, "y": 3 },
+ { "x": 3, "y": 3 },
+ { "x": 4, "y": 3 },
+ { "x": 5, "y": 3, "w": 2 },
+ { "x": 7, "y": 3 },
+ { "x": 8, "y": 3 },
+ { "x": 9, "y": 3 },
+ { "x": 10, "y": 3 },
+ { "x": 11, "y": 3 }
+ ]
+ },
+ "LAYOUT_ortho_4x12": {
+ "key_count": 48,
+ "layout": [
+ { "x": 0, "y": 0 },
+ { "x": 1, "y": 0 },
+ { "x": 2, "y": 0 },
+ { "x": 3, "y": 0 },
+ { "x": 4, "y": 0 },
+ { "x": 5, "y": 0 },
+ { "x": 6, "y": 0 },
+ { "x": 7, "y": 0 },
+ { "x": 8, "y": 0 },
+ { "x": 9, "y": 0 },
+ { "x": 10, "y": 0 },
+ { "x": 11, "y": 0 },
+ { "x": 0, "y": 1 },
+ { "x": 1, "y": 1 },
+ { "x": 2, "y": 1 },
+ { "x": 3, "y": 1 },
+ { "x": 4, "y": 1 },
+ { "x": 5, "y": 1 },
+ { "x": 6, "y": 1 },
+ { "x": 7, "y": 1 },
+ { "x": 8, "y": 1 },
+ { "x": 9, "y": 1 },
+ { "x": 10, "y": 1 },
+ { "x": 11, "y": 1 },
+ { "x": 0, "y": 2 },
+ { "x": 1, "y": 2 },
+ { "x": 2, "y": 2 },
+ { "x": 3, "y": 2 },
+ { "x": 4, "y": 2 },
+ { "x": 5, "y": 2 },
+ { "x": 6, "y": 2 },
+ { "x": 7, "y": 2 },
+ { "x": 8, "y": 2 },
+ { "x": 9, "y": 2 },
+ { "x": 10, "y": 2 },
+ { "x": 11, "y": 2 },
+ { "x": 0, "y": 3 },
+ { "x": 1, "y": 3 },
+ { "x": 2, "y": 3 },
+ { "x": 3, "y": 3 },
+ { "x": 4, "y": 3 },
+ { "x": 5, "y": 3 },
+ { "x": 6, "y": 3 },
+ { "x": 7, "y": 3 },
+ { "x": 8, "y": 3 },
+ { "x": 9, "y": 3 },
+ { "x": 10, "y": 3 },
+ { "x": 11, "y": 3 }
+ ]
+ }
}
}
-}
diff --git a/keyboards/planck/ez/mcuconf.h b/keyboards/planck/ez/mcuconf.h
new file mode 100644
index 0000000000..dde67871cd
--- /dev/null
+++ b/keyboards/planck/ez/mcuconf.h
@@ -0,0 +1,30 @@
+/* Copyright 2020 QMK Contributors
+ *
+ * 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 3 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_next "mcuconf.h"
+
+// The SysTick timer from the normal quantum/stm32 uses TIM2 -- the WS2812 pin used
+// on the Planck requires the use of TIM2 to run PWM -- rework which timers are
+// allocated for PWM usage.
+#undef STM32_PWM_USE_TIM2
+#undef STM32_PWM_USE_TIM3
+#define STM32_PWM_USE_TIM2 TRUE
+#define STM32_PWM_USE_TIM3 FALSE
+
+// As mentioned above, we need to reallocate the SysTick timer used from
+// TIM2 to TIM3.
+#undef STM32_ST_USE_TIMER
+#define STM32_ST_USE_TIMER 3
diff --git a/keyboards/planck/ez/rules.mk b/keyboards/planck/ez/rules.mk
index a146c65aa9..cf95578b65 100644..100755
--- a/keyboards/planck/ez/rules.mk
+++ b/keyboards/planck/ez/rules.mk
@@ -1,24 +1,32 @@
# MCU name
MCU = STM32F303
+BOARD = QMK_PROTON_C
# Build Options
-# comment out to disable the options.
+
+# change to "no" to disable the options, or define them in the Makefile in
+# the appropriate keymap folder that will get included automatically
#
-BACKLIGHT_ENABLE = no
-BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
-## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.)
-MOUSEKEY_ENABLE = yes # Mouse keys
-EXTRAKEY_ENABLE = yes # Audio control and System control
+BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = yes # Mouse keys
+EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
-#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
-NKRO_ENABLE = yes # USB Nkey Rollover
-AUDIO_ENABLE = yes
+NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+AUDIO_ENABLE = yes # Audio output on port C6
RGBLIGHT_ENABLE = no
+ENCODER_ENABLE = yes
+
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
+#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+
# SERIAL_LINK_ENABLE = yes
ENCODER_ENABLE = yes
RGB_MATRIX_DRIVER = IS31FL3737
-LAYOUTS += ortho_4x12
-
MOUSE_SHARED_EP = no
+
+LAYOUTS = ortho_4x12
+LAYOUTS_HAS_RGB = no
diff --git a/keyboards/planck/info.json b/keyboards/planck/info.json
deleted file mode 100644
index 765d7d06ad..0000000000
--- a/keyboards/planck/info.json
+++ /dev/null
@@ -1,113 +0,0 @@
-{
- "keyboard_name": "Planck",
- "keyboard_folder": "planck",
- "url": "https://olkb.com/planck",
- "maintainer": "jackhumbert",
- "width": 12,
- "height": 4,
- "layouts": {
- "LAYOUT_planck_mit": {
- "key_count": 47,
- "layout": [
- { "w": 1, "x": 0, "y": 0 },
- { "w": 1, "x": 1, "y": 0 },
- { "w": 1, "x": 2, "y": 0 },
- { "w": 1, "x": 3, "y": 0 },
- { "w": 1, "x": 4, "y": 0 },
- { "w": 1, "x": 5, "y": 0 },
- { "w": 1, "x": 6, "y": 0 },
- { "w": 1, "x": 7, "y": 0 },
- { "w": 1, "x": 8, "y": 0 },
- { "w": 1, "x": 9, "y": 0 },
- { "w": 1, "x": 10, "y": 0 },
- { "w": 1, "x": 11, "y": 0 },
- { "w": 1, "x": 0, "y": 1 },
- { "w": 1, "x": 1, "y": 1 },
- { "w": 1, "x": 2, "y": 1 },
- { "w": 1, "x": 3, "y": 1 },
- { "w": 1, "x": 4, "y": 1 },
- { "w": 1, "x": 5, "y": 1 },
- { "w": 1, "x": 6, "y": 1 },
- { "w": 1, "x": 7, "y": 1 },
- { "w": 1, "x": 8, "y": 1 },
- { "w": 1, "x": 9, "y": 1 },
- { "w": 1, "x": 10, "y": 1 },
- { "w": 1, "x": 11, "y": 1 },
- { "w": 1, "x": 0, "y": 2 },
- { "w": 1, "x": 1, "y": 2 },
- { "w": 1, "x": 2, "y": 2 },
- { "w": 1, "x": 3, "y": 2 },
- { "w": 1, "x": 4, "y": 2 },
- { "w": 1, "x": 5, "y": 2 },
- { "w": 1, "x": 6, "y": 2 },
- { "w": 1, "x": 7, "y": 2 },
- { "w": 1, "x": 8, "y": 2 },
- { "w": 1, "x": 9, "y": 2 },
- { "w": 1, "x": 10, "y": 2 },
- { "w": 1, "x": 11, "y": 2 },
- { "w": 1, "x": 0, "y": 3 },
- { "w": 1, "x": 1, "y": 3 },
- { "w": 1, "x": 2, "y": 3 },
- { "w": 1, "x": 3, "y": 3 },
- { "w": 1, "x": 4, "y": 3 },
- { "w": 2, "x": 5, "y": 3 },
- { "w": 1, "x": 7, "y": 3 },
- { "w": 1, "x": 8, "y": 3 },
- { "w": 1, "x": 9, "y": 3 },
- { "w": 1, "x": 10, "y": 3 },
- { "w": 1, "x": 11, "y": 3 } ]
- },
- "LAYOUT_planck_grid": {
- "key_count": 48,
- "layout": [
- { "w": 1, "x": 0, "y": 0 },
- { "w": 1, "x": 1, "y": 0 },
- { "w": 1, "x": 2, "y": 0 },
- { "w": 1, "x": 3, "y": 0 },
- { "w": 1, "x": 4, "y": 0 },
- { "w": 1, "x": 5, "y": 0 },
- { "w": 1, "x": 6, "y": 0 },
- { "w": 1, "x": 7, "y": 0 },
- { "w": 1, "x": 8, "y": 0 },
- { "w": 1, "x": 9, "y": 0 },
- { "w": 1, "x": 10, "y": 0 },
- { "w": 1, "x": 11, "y": 0 },
- { "w": 1, "x": 0, "y": 1 },
- { "w": 1, "x": 1, "y": 1 },
- { "w": 1, "x": 2, "y": 1 },
- { "w": 1, "x": 3, "y": 1 },
- { "w": 1, "x": 4, "y": 1 },
- { "w": 1, "x": 5, "y": 1 },
- { "w": 1, "x": 6, "y": 1 },
- { "w": 1, "x": 7, "y": 1 },
- { "w": 1, "x": 8, "y": 1 },
- { "w": 1, "x": 9, "y": 1 },
- { "w": 1, "x": 10, "y": 1 },
- { "w": 1, "x": 11, "y": 1 },
- { "w": 1, "x": 0, "y": 2 },
- { "w": 1, "x": 1, "y": 2 },
- { "w": 1, "x": 2, "y": 2 },
- { "w": 1, "x": 3, "y": 2 },
- { "w": 1, "x": 4, "y": 2 },
- { "w": 1, "x": 5, "y": 2 },
- { "w": 1, "x": 6, "y": 2 },
- { "w": 1, "x": 7, "y": 2 },
- { "w": 1, "x": 8, "y": 2 },
- { "w": 1, "x": 9, "y": 2 },
- { "w": 1, "x": 10, "y": 2 },
- { "w": 1, "x": 11, "y": 2 },
- { "w": 1, "x": 0, "y": 3 },
- { "w": 1, "x": 1, "y": 3 },
- { "w": 1, "x": 2, "y": 3 },
- { "w": 1, "x": 3, "y": 3 },
- { "w": 1, "x": 4, "y": 3 },
- { "w": 1, "x": 5, "y": 3 },
- { "w": 1, "x": 6, "y": 3 },
- { "w": 1, "x": 7, "y": 3 },
- { "w": 1, "x": 8, "y": 3 },
- { "w": 1, "x": 9, "y": 3 },
- { "w": 1, "x": 10, "y": 3 },
- { "w": 1, "x": 11, "y": 3 } ]
- }
- }
-}
diff --git a/keyboards/planck/keymaps/default/config.h b/keyboards/planck/keymaps/default/config.h
index 6fa31cc8a7..9020d2b9f8 100644
--- a/keyboards/planck/keymaps/default/config.h
+++ b/keyboards/planck/keymaps/default/config.h
@@ -14,9 +14,6 @@
* MIDI options
*/
-/* Prevent use of disabled MIDI features in the keymap */
-//#define MIDI_ENABLE_STRICT 1
-
/* enable basic MIDI features:
- MIDI notes can be sent when in Music mode is on
*/
diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c
index bc72e360ba..22ff24c92b 100644
--- a/keyboards/planck/keymaps/default/keymap.c
+++ b/keyboards/planck/keymaps/default/keymap.c
@@ -17,7 +17,6 @@
#include QMK_KEYBOARD_H
#include "muse.h"
-extern keymap_config_t keymap_config;
enum planck_layers {
_QWERTY,
@@ -46,9 +45,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Qwerty
* ,-----------------------------------------------------------------------------------.
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
- * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
- * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
@@ -64,9 +63,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Colemak
* ,-----------------------------------------------------------------------------------.
* | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
- * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Esc | A | R | S | T | D | H | N | E | I | O | " |
- * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
@@ -82,9 +81,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Dvorak
* ,-----------------------------------------------------------------------------------.
* | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
- * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Esc | A | O | E | U | I | D | H | T | N | S | / |
- * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
@@ -100,9 +99,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Lower
* ,-----------------------------------------------------------------------------------.
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
- * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
- * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | Home | End | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
@@ -118,9 +117,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Raise
* ,-----------------------------------------------------------------------------------.
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
- * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
- * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / |Pg Up |Pg Dn | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | Next | Vol- | Vol+ | Play |
@@ -136,9 +135,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Plover layer (http://opensteno.org)
* ,-----------------------------------------------------------------------------------.
* | # | # | # | # | # | # | # | # | # | # | # | # |
- * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | | S | T | P | H | * | * | F | P | L | T | D |
- * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
* | | S | K | W | R | * | * | R | B | G | S | Z |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Exit | | | A | O | | E | U | | | |
@@ -152,12 +151,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
/* Adjust (Lower + Raise)
+ * v------------------------RGB CONTROL--------------------v
* ,-----------------------------------------------------------------------------------.
- * | | Reset| | | | | | | | | | Del |
- * |------+------+------+------+------+-------------+------+------+------+------+------|
- * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
- * |------+------+------+------+------+------|------+------+------+------+------+------|
- * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | |
+ * | | Reset|Debug | RGB |RGBMOD| HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| Del |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | |MUSmod|Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof|TermOn|TermOf| | | |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | | | | | | | | | | | |
* `-----------------------------------------------------------------------------------'
@@ -208,12 +208,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
backlight_step();
#endif
#ifdef KEYBOARD_planck_rev5
- PORTE &= ~(1<<6);
+ writePinLow(E6);
#endif
} else {
unregister_code(KC_RSFT);
#ifdef KEYBOARD_planck_rev5
- PORTE |= (1<<6);
+ writePinHigh(E6);
#endif
}
return false;
@@ -274,65 +274,70 @@ void encoder_update(bool clockwise) {
} else {
if (clockwise) {
#ifdef MOUSEKEY_ENABLE
- register_code(KC_MS_WH_DOWN);
- unregister_code(KC_MS_WH_DOWN);
+ tap_code(KC_MS_WH_DOWN);
#else
- register_code(KC_PGDN);
- unregister_code(KC_PGDN);
+ tap_code(KC_PGDN);
#endif
} else {
#ifdef MOUSEKEY_ENABLE
- register_code(KC_MS_WH_UP);
- unregister_code(KC_MS_WH_UP);
+ tap_code(KC_MS_WH_UP);
#else
- register_code(KC_PGUP);
- unregister_code(KC_PGUP);
+ tap_code(KC_PGUP);
#endif
}
}
}
void dip_switch_update_user(uint8_t index, bool active) {
- switch (index) {
- case 0:
- if (active) {
- #ifdef AUDIO_ENABLE
- PLAY_SONG(plover_song);
- #endif
- layer_on(_ADJUST);
- } else {
- #ifdef AUDIO_ENABLE
- PLAY_SONG(plover_gb_song);
- #endif
- layer_off(_ADJUST);
- }
- break;
- case 1:
- if (active) {
- muse_mode = true;
- } else {
- muse_mode = false;
- #ifdef AUDIO_ENABLE
- stop_all_notes();
- #endif
- }
- }
+ switch (index) {
+ case 0: {
+#ifdef AUDIO_ENABLE
+ static bool play_sound = false;
+#endif
+ if (active) {
+#ifdef AUDIO_ENABLE
+ if (play_sound) { PLAY_SONG(plover_song); }
+#endif
+ layer_on(_ADJUST);
+ } else {
+#ifdef AUDIO_ENABLE
+ if (play_sound) { PLAY_SONG(plover_gb_song); }
+#endif
+ layer_off(_ADJUST);
+ }
+#ifdef AUDIO_ENABLE
+ play_sound = true;
+#endif
+ break;
+ }
+ case 1:
+ if (active) {
+ muse_mode = true;
+ } else {
+ muse_mode = false;
+ }
+ }
}
void matrix_scan_user(void) {
- #ifdef AUDIO_ENABLE
+#ifdef AUDIO_ENABLE
if (muse_mode) {
- if (muse_counter == 0) {
- uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
- if (muse_note != last_muse_note) {
- stop_note(compute_freq_for_midi_note(last_muse_note));
- play_note(compute_freq_for_midi_note(muse_note), 0xF);
- last_muse_note = muse_note;
+ if (muse_counter == 0) {
+ uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
+ if (muse_note != last_muse_note) {
+ stop_note(compute_freq_for_midi_note(last_muse_note));
+ play_note(compute_freq_for_midi_note(muse_note), 0xF);
+ last_muse_note = muse_note;
+ }
+ }
+ muse_counter = (muse_counter + 1) % muse_tempo;
+ } else {
+ if (muse_counter) {
+ stop_all_notes();
+ muse_counter = 0;
}
- }
- muse_counter = (muse_counter + 1) % muse_tempo;
}
- #endif
+#endif
}
bool music_mask_user(uint16_t keycode) {
diff --git a/keyboards/planck/keymaps/oryx/config.h b/keyboards/planck/keymaps/oryx/config.h
index d46cb36945..54a7918d36 100644
--- a/keyboards/planck/keymaps/oryx/config.h
+++ b/keyboards/planck/keymaps/oryx/config.h
@@ -8,6 +8,8 @@
#define ENCODER_RESOLUTION 4
+#define ORYX_CONFIGURATOR
+
/*
Set any config.h overrides for your specific keymap here.
See config.h options at https://docs.qmk.fm/#/config_options?id=the-configh-file
diff --git a/keyboards/planck/keymaps/oryx/keymap.c b/keyboards/planck/keymaps/oryx/keymap.c
index 55a9168dca..79cbf2f6c5 100644
--- a/keyboards/planck/keymaps/oryx/keymap.c
+++ b/keyboards/planck/keymaps/oryx/keymap.c
@@ -7,59 +7,311 @@
#include "keymap_spanish.h"
#include "keymap_hungarian.h"
#include "keymap_swedish.h"
+//#include "keymap_br_abnt2.h"
+#include "keymap_canadian_multilingual.h"
+#include "keymap_german_ch.h"
-#define KC_MAC_UNDO LGUI(KC_U)
+#define KC_MAC_UNDO LGUI(KC_Z)
#define KC_MAC_CUT LGUI(KC_X)
#define KC_MAC_COPY LGUI(KC_C)
#define KC_MAC_PASTE LGUI(KC_V)
-#define KC_PC_UNDO LCTL(KC_U)
+#define KC_PC_UNDO LCTL(KC_Z)
#define KC_PC_CUT LCTL(KC_X)
#define KC_PC_COPY LCTL(KC_C)
#define KC_PC_PASTE LCTL(KC_V)
-
-enum planck_keycodes {
- RGB_SLD = SAFE_RANGE,
- EPRM,
-};
+#define NO_TH ALGR(KC_T)
+#define NO_ETH ALGR(KC_D)
enum planck_layers {
- _BASE,
+ _QWERTY,
+ _COLEMAK,
+ _DVORAK,
_LOWER,
_RAISE,
- _ADJUST,
+ _PLOVER,
+ _ADJUST
};
+enum planck_keycodes {
+ QWERTY = EZ_SAFE_RANGE,
+ COLEMAK,
+ DVORAK,
+ PLOVER,
+ BACKLIT,
+ EXT_PLV,
+ RGB_SLD
+};
#define LOWER MO(_LOWER)
#define RAISE MO(_RAISE)
+
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- [_BASE] = LAYOUT_planck_grid(KC_TAB,KC_Q,KC_W,KC_E,KC_R,KC_T,KC_Y,KC_U,KC_I,KC_O,KC_P,KC_BSPACE,KC_ESCAPE,KC_A,KC_S,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,KC_SCOLON,KC_QUOTE,KC_LSHIFT,KC_Z,KC_X,KC_C,KC_V,KC_B,KC_N,KC_M,KC_COMMA,KC_DOT,KC_SLASH,KC_ENTER,KC_TRANSPARENT,KC_LCTRL,KC_LALT,KC_LGUI,LOWER,KC_SPACE,KC_NO,RAISE,KC_LEFT,KC_DOWN,KC_UP,KC_RIGHT),
- [_LOWER] = LAYOUT_planck_grid(KC_TILD,KC_EXLM,KC_AT,KC_HASH,KC_DLR,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_TRANSPARENT,KC_DELETE,KC_F1,KC_F2,KC_F3,KC_F4,KC_F5,KC_F6,KC_UNDS,KC_PLUS,KC_LCBR,KC_RCBR,KC_PIPE,KC_TRANSPARENT,KC_F7,KC_F8,KC_F9,KC_F10,KC_F11,KC_F12,KC_NONUS_HASH,KC_NONUS_BSLASH,KC_HOME,KC_END,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_NO,KC_TRANSPARENT,KC_MEDIA_NEXT_TRACK,KC_AUDIO_VOL_DOWN,KC_AUDIO_VOL_UP,KC_MEDIA_PLAY_PAUSE),
+/* Qwerty
+ * ,-----------------------------------------------------------------------------------.
+ * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_QWERTY] = LAYOUT_planck_grid(
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
+ KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
+ BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
+),
+
+/* Colemak
+ * ,-----------------------------------------------------------------------------------.
+ * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Esc | A | R | S | T | D | H | N | E | I | O | " |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_COLEMAK] = LAYOUT_planck_grid(
+ KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC,
+ KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT,
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
+ BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
+),
+
+/* Dvorak
+ * ,-----------------------------------------------------------------------------------.
+ * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Esc | A | O | E | U | I | D | H | T | N | S | / |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_DVORAK] = LAYOUT_planck_grid(
+ KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC,
+ KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH,
+ KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT ,
+ BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
+),
- [_RAISE] = LAYOUT_planck_grid(KC_GRAVE,KC_1,KC_2,KC_3,KC_4,KC_5,KC_6,KC_7,KC_8,KC_9,KC_0,KC_TRANSPARENT,KC_DELETE,KC_F1,KC_F2,KC_F3,KC_F4,KC_F5,KC_F6,KC_MINUS,KC_EQUAL,KC_LBRACKET,KC_RBRACKET,KC_BSLASH,KC_TRANSPARENT,KC_F7,KC_F8,KC_F9,KC_F10,KC_F11,KC_F12,KC_NONUS_HASH,KC_NONUS_BSLASH,KC_PGUP,KC_PGDOWN,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_NO,KC_TRANSPARENT,KC_MEDIA_NEXT_TRACK,KC_AUDIO_VOL_DOWN,KC_AUDIO_VOL_UP,KC_MEDIA_PLAY_PAUSE),
+/* Lower
+ * ,-----------------------------------------------------------------------------------.
+ * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | Home | End | |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | | | | | | | Next | Vol- | Vol+ | Play |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_LOWER] = LAYOUT_planck_grid(
+ KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
+ KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
+ _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), KC_HOME, KC_END, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
+),
- [_ADJUST] = LAYOUT_planck_grid(KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_DELETE,KC_TRANSPARENT,AU_ON,AU_OFF,AU_TOG,KC_TRANSPARENT,KC_TRANSPARENT,RGB_TOG,RGB_VAI,RGB_VAD,KC_TRANSPARENT,RESET,KC_TRANSPARENT,KC_TRANSPARENT,MU_ON,MU_OFF,MU_TOG,KC_TRANSPARENT,KC_TRANSPARENT,RGB_MOD,RGB_HUI,RGB_HUD,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_NO,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT),
+/* Raise
+ * ,-----------------------------------------------------------------------------------.
+ * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / |Pg Up |Pg Dn | |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | | | | | | | Next | Vol- | Vol+ | Play |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_RAISE] = LAYOUT_planck_grid(
+ KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
+ KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
+ _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
+),
+
+/* Plover layer (http://opensteno.org)
+ * ,-----------------------------------------------------------------------------------.
+ * | # | # | # | # | # | # | # | # | # | # | # | # |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | S | T | P | H | * | * | F | P | L | T | D |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | S | K | W | R | * | * | R | B | G | S | Z |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | Exit | | | A | O | | E | U | | | |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_PLOVER] = LAYOUT_planck_grid(
+ KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 ,
+ XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,
+ XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
+ EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX
+),
+
+/* Adjust (Lower + Raise)
+ * v------------------------RGB CONTROL--------------------v
+ * ,-----------------------------------------------------------------------------------
+ * | | Reset|Debug | RGB |RGBMOD| HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| Del |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | | | | | | | | | | |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_ADJUST] = LAYOUT_planck_grid(
+ _______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
+ _______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______,
+ _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF, TOGGLE_LAYER_COLOR, LED_LEVEL, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
+)
};
+#ifdef AUDIO_ENABLE
+ float plover_song[][2] = SONG(PLOVER_SOUND);
+ float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
+#endif
+
+layer_state_t layer_state_set_user(layer_state_t state) {
+ return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
+}
+
+#ifdef RGB_MATRIX_EANBLE
+const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = {
+ [0] = { {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255} },
+
+ [1] = { {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {32,255,234}, {32,255,234}, {32,255,234}, {32,255,234} },
+
+ [2] = { {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246} },
+
+ [3] = { {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {249,228,255}, {249,228,255}, {249,228,255}, {216,255,255}, {216,255,255}, {105,255,255}, {105,255,255}, {105,255,255}, {216,255,255}, {14,255,255}, {216,255,255}, {216,255,255}, {249,228,255}, {249,228,255}, {249,228,255}, {216,255,255}, {216,255,255}, {105,255,255}, {105,255,255}, {105,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255} },
+
+};
+
+void set_layer_color(int layer) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ HSV hsv = {
+ .h = pgm_read_byte(&ledmap[layer][i][0]),
+ .s = pgm_read_byte(&ledmap[layer][i][1]),
+ .v = pgm_read_byte(&ledmap[layer][i][2]),
+ };
+ if (!hsv.h && !hsv.s && !hsv.v) {
+ rgb_matrix_set_color( i, 0, 0, 0 );
+ } else {
+ RGB rgb = hsv_to_rgb( hsv );
+ float f = (float)rgb_matrix_config.hsv.v / UINT8_MAX;
+ rgb_matrix_set_color( i, f * rgb.r, f * rgb.g, f * rgb.b );
+ }
+ }
+}
+
+void rgb_matrix_indicators_user(void) {
+ if (g_suspend_state || keyboard_config.disable_layer_led) { return; }
+ switch (biton32(layer_state)) {
+ case 0:
+ set_layer_color(0);
+ break;
+ case 3:
+ set_layer_color(1);
+ break;
+ case 4:
+ set_layer_color(2);
+ break;
+ case 6:
+ set_layer_color(3);
+ break;
+ default:
+ if (rgb_matrix_get_flags() == LED_FLAG_NONE)
+ rgb_matrix_set_color_all(0, 0, 0);
+ break;
+ }
+}
+#endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
- case EPRM:
+ case RGB_SLD:
if (record->event.pressed) {
- eeconfig_init();
+#ifdef RGBLIGHT_ENABLE
+ rgblight_mode(1);
+#endif
}
return false;
-#ifdef RGBLIGHT_ENABLE
- case RGB_SLD:
+ case QWERTY:
if (record->event.pressed) {
- rgblight_mode(1);
+ print("mode just switched to qwerty and this is a huge string\n");
+ set_single_persistent_default_layer(_QWERTY);
}
return false;
-#endif
+ break;
+ case COLEMAK:
+ if (record->event.pressed) {
+ set_single_persistent_default_layer(_COLEMAK);
+ }
+ return false;
+ break;
+ case DVORAK:
+ if (record->event.pressed) {
+ set_single_persistent_default_layer(_DVORAK);
+ }
+ return false;
+ break;
+ case BACKLIT:
+ if (record->event.pressed) {
+ register_code(KC_RSFT);
+ #ifdef BACKLIGHT_ENABLE
+ backlight_step();
+ #endif
+ #ifdef KEYBOARD_planck_rev5
+ PORTE &= ~(1<<6);
+ #endif
+ } else {
+ unregister_code(KC_RSFT);
+ #ifdef KEYBOARD_planck_rev5
+ PORTE |= (1<<6);
+ #endif
+ }
+ return false;
+ break;
+ case PLOVER:
+ if (record->event.pressed) {
+ #ifdef AUDIO_ENABLE
+ stop_all_notes();
+ PLAY_SONG(plover_song);
+ #endif
+ layer_off(_RAISE);
+ layer_off(_LOWER);
+ layer_off(_ADJUST);
+ layer_on(_PLOVER);
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+ keymap_config.raw = eeconfig_read_keymap();
+ keymap_config.nkro = 1;
+ eeconfig_update_keymap(keymap_config.raw);
+ }
+ return false;
+ break;
+ case EXT_PLV:
+ if (record->event.pressed) {
+ #ifdef AUDIO_ENABLE
+ PLAY_SONG(plover_gb_song);
+ #endif
+ layer_off(_PLOVER);
+ }
+ return false;
+ break;
}
return true;
}
@@ -131,6 +383,3 @@ bool music_mask_user(uint16_t keycode) {
return true;
}
}
-layer_state_t layer_state_set_user(layer_state_t state) {
- return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
-}
diff --git a/keyboards/planck/keymaps/webusb/config.h b/keyboards/planck/keymaps/webusb/config.h
index 6fa31cc8a7..9020d2b9f8 100644
--- a/keyboards/planck/keymaps/webusb/config.h
+++ b/keyboards/planck/keymaps/webusb/config.h
@@ -14,9 +14,6 @@
* MIDI options
*/
-/* Prevent use of disabled MIDI features in the keymap */
-//#define MIDI_ENABLE_STRICT 1
-
/* enable basic MIDI features:
- MIDI notes can be sent when in Music mode is on
*/
diff --git a/keyboards/planck/planck.c b/keyboards/planck/planck.c
index d9e3f00f2b..a17036fcf1 100644
--- a/keyboards/planck/planck.c
+++ b/keyboards/planck/planck.c
@@ -2,7 +2,7 @@
#ifdef SWAP_HANDS_ENABLE
__attribute__ ((weak))
-const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
+const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
{{11, 0}, {10, 0}, {9, 0}, {8, 0}, {7, 0}, {6, 0}, {5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}},
{{11, 1}, {10, 1}, {9, 1}, {8, 1}, {7, 1}, {6, 1}, {5, 1}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}},
{{11, 2}, {10, 2}, {9, 2}, {8, 2}, {7, 2}, {6, 2}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}},
@@ -12,10 +12,10 @@ const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
__attribute__ ((weak))
void matrix_init_kb(void) {
- // Turn status LED on
- #ifdef __AVR__
- DDRE |= (1<<6);
- PORTE |= (1<<6);
+ // Turn status LED on, with the exception of THK
+ #if defined(__AVR_ATmega32U4__)
+ setPinOutput(E6);
+ writePinHigh(E6);
#endif
matrix_init_user();
@@ -26,4 +26,4 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_planck_grid(
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
-); \ No newline at end of file
+);
diff --git a/keyboards/planck/readme.md b/keyboards/planck/readme.md
index d8591953b4..748c251478 100644
--- a/keyboards/planck/readme.md
+++ b/keyboards/planck/readme.md
@@ -15,6 +15,7 @@ Make example for this keyboard (after setting up your build environment):
Install examples:
- make planck/rev6:default:dfu-util
+ make planck/rev5:default:dfu # For Planck rev5 or earlier and Planck Light
+ make planck/rev6:default:dfu-util # For Planck rev6
-See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information.
+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/keyboards/planck/rules.mk b/keyboards/planck/rules.mk
deleted file mode 100644
index 09d4a74ea6..0000000000
--- a/keyboards/planck/rules.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# MCU name
-MCU = atmega32u4
-
-
-# Interrupt driven control endpoint task(+60)
-OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
-
-# Build Options
-# change to "no" to disable the options, or define them in the Makefile in
-# the appropriate keymap folder that will get included automatically
-#
-BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = no # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = no # Console for debug(+400)
-COMMAND_ENABLE = no # Commands for debug and configuration
-NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
-MIDI_ENABLE = no # MIDI controls
-AUDIO_ENABLE = yes # Audio output on port C6
-UNICODE_ENABLE = no # Unicode
-BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
-RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
-API_SYSEX_ENABLE = no
-
-# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
-
-LAYOUTS = ortho_4x12 planck_mit planck_grid
-LAYOUTS_HAS_RGB = no
-
-DEFAULT_FOLDER = planck/ez
diff --git a/lib/chibios b/lib/chibios
-Subproject 313416b8fda90d9973a749a0a35970956852c28
+Subproject ffe54d63cb10a355add318f8e922e39f1c3d4bf
diff --git a/lib/chibios-contrib b/lib/chibios-contrib
-Subproject e3a3a24047717af33b098266e11c2e4e5102206
+Subproject 61baa6b036138c155f7cfc5646d833d9423f324
diff --git a/lib/lufa b/lib/lufa
-Subproject 94e43e49777eaf76ea984adc486752bcd663a89
+Subproject 06193868f05d8ac626b017ed786c0980171c9cb
diff --git a/lib/python/qmk/c_parse.py b/lib/python/qmk/c_parse.py
index e41e271a43..d4f39c8839 100644
--- a/lib/python/qmk/c_parse.py
+++ b/lib/python/qmk/c_parse.py
@@ -1,12 +1,27 @@
"""Functions for working with config.h files.
"""
from pathlib import Path
+import re
from milc import cli
from qmk.comment_remover import comment_remover
default_key_entry = {'x': -1, 'y': 0, 'w': 1}
+single_comment_regex = re.compile(r' */[/*].*$')
+multi_comment_regex = re.compile(r'/\*(.|\n)*?\*/', re.MULTILINE)
+
+
+def strip_line_comment(string):
+ """Removes comments from a single line string.
+ """
+ return single_comment_regex.sub('', string)
+
+
+def strip_multiline_comment(string):
+ """Removes comments from a single line string.
+ """
+ return multi_comment_regex.sub('', string)
def c_source_files(dir_names):
@@ -31,7 +46,7 @@ def find_layouts(file):
parsed_layouts = {}
# Search the file for LAYOUT macros and aliases
- file_contents = file.read_text()
+ file_contents = file.read_text(encoding='utf-8')
file_contents = comment_remover(file_contents)
file_contents = file_contents.replace('\\\n', '')
@@ -52,8 +67,11 @@ def find_layouts(file):
layout = layout.strip()
parsed_layout = [_default_key(key) for key in layout.split(',')]
- for key in parsed_layout:
- key['matrix'] = matrix_locations.get(key['label'])
+ for i, key in enumerate(parsed_layout):
+ if 'label' not in key:
+ cli.log.error('Invalid LAYOUT macro in %s: Empty parameter name in macro %s at pos %s.', file, macro_name, i)
+ elif key['label'] in matrix_locations:
+ key['matrix'] = matrix_locations[key['label']]
parsed_layouts[macro_name] = {
'key_count': len(parsed_layout),
@@ -69,12 +87,7 @@ def find_layouts(file):
except ValueError:
continue
- # Populate our aliases
- for alias, text in aliases.items():
- if text in parsed_layouts and 'KEYMAP' not in alias:
- parsed_layouts[alias] = parsed_layouts[text]
-
- return parsed_layouts
+ return parsed_layouts, aliases
def parse_config_h_file(config_h_file, config_h=None):
@@ -86,14 +99,12 @@ def parse_config_h_file(config_h_file, config_h=None):
config_h_file = Path(config_h_file)
if config_h_file.exists():
- config_h_text = config_h_file.read_text()
+ config_h_text = config_h_file.read_text(encoding='utf-8')
config_h_text = config_h_text.replace('\\\n', '')
+ config_h_text = strip_multiline_comment(config_h_text)
for linenum, line in enumerate(config_h_text.split('\n')):
- line = line.strip()
-
- if '//' in line:
- line = line[:line.index('//')].strip()
+ line = strip_line_comment(line).strip()
if not line:
continue
@@ -156,6 +167,6 @@ def _parse_matrix_locations(matrix, file, macro_name):
row = row.replace('{', '').replace('}', '')
for col_num, identifier in enumerate(row.split(',')):
if identifier != 'KC_NO':
- matrix_locations[identifier] = (row_num, col_num)
+ matrix_locations[identifier] = [row_num, col_num]
return matrix_locations
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index 10536bb230..d07790d118 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -2,31 +2,159 @@
We list each subcommand here explicitly because all the reliable ways of searching for modules are slow and delay startup.
"""
+import os
+import shlex
import sys
+from importlib.util import find_spec
+from pathlib import Path
+from subprocess import run
-from milc import cli
-
-from . import c2json
-from . import cformat
-from . import chibios
-from . import clean
-from . import compile
-from . import config
-from . import docs
-from . import doctor
-from . import flash
-from . import generate
-from . import hello
-from . import info
-from . import json
-from . import json2c
-from . import lint
-from . import list
-from . import kle2json
-from . import new
-from . import pyformat
-from . import pytest
-
-if sys.version_info[0] != 3 or sys.version_info[1] < 6:
- cli.log.error('Your Python is too old! Please upgrade to Python 3.6 or later.')
+from milc import cli, __VERSION__
+from milc.questions import yesno
+
+
+def _run_cmd(*command):
+ """Run a command in a subshell.
+ """
+ if 'windows' in cli.platform.lower():
+ safecmd = map(shlex.quote, command)
+ safecmd = ' '.join(safecmd)
+ command = [os.environ['SHELL'], '-c', safecmd]
+
+ return run(command)
+
+
+def _find_broken_requirements(requirements):
+ """ Check if the modules in the given requirements.txt are available.
+
+ Args:
+
+ requirements
+ The path to a requirements.txt file
+
+ Returns a list of modules that couldn't be imported
+ """
+ with Path(requirements).open() as fd:
+ broken_modules = []
+
+ for line in fd.readlines():
+ line = line.strip().replace('<', '=').replace('>', '=')
+
+ if len(line) == 0 or line[0] == '#' or line.startswith('-r'):
+ continue
+
+ if '#' in line:
+ line = line.split('#')[0]
+
+ module_name = line.split('=')[0] if '=' in line else line
+ module_import = module_name.replace('-', '_')
+
+ # Not every module is importable by its own name.
+ if module_name == "pep8-naming":
+ module_import = "pep8ext_naming"
+
+ if not find_spec(module_import):
+ broken_modules.append(module_name)
+
+ return broken_modules
+
+
+def _broken_module_imports(requirements):
+ """Make sure we can import all the python modules.
+ """
+ broken_modules = _find_broken_requirements(requirements)
+
+ for module in broken_modules:
+ print('Could not find module %s!' % module)
+
+ if broken_modules:
+ return True
+
+ return False
+
+
+# Make sure our python is new enough
+#
+# Supported version information
+#
+# Based on the OSes we support these are the minimum python version available by default.
+# Last update: 2021 Jan 02
+#
+# Arch: 3.9
+# Debian: 3.7
+# Fedora 31: 3.7
+# Fedora 32: 3.8
+# Fedora 33: 3.9
+# FreeBSD: 3.7
+# Gentoo: 3.7
+# macOS: 3.9 (from homebrew)
+# msys2: 3.8
+# Slackware: 3.7
+# solus: 3.7
+# void: 3.9
+
+if sys.version_info[0] != 3 or sys.version_info[1] < 7:
+ print('Error: Your Python is too old! Please upgrade to Python 3.7 or later.')
exit(127)
+
+milc_version = __VERSION__.split('.')
+
+if int(milc_version[0]) < 2 and int(milc_version[1]) < 3:
+ requirements = Path('requirements.txt').resolve()
+
+ print(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')
+ exit(127)
+
+# Check to make sure we have all our dependencies
+msg_install = 'Please run `python3 -m pip install -r %s` to install required python dependencies.'
+
+if _broken_module_imports('requirements.txt'):
+ if yesno('Would you like to install the required Python modules?'):
+ _run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt')
+ else:
+ print()
+ print(msg_install % (str(Path('requirements.txt').resolve()),))
+ print()
+ exit(1)
+
+if cli.config.user.developer:
+ args = sys.argv[1:]
+ while args and args[0][0] == '-':
+ del args[0]
+ if not args or args[0] != 'config':
+ if _broken_module_imports('requirements-dev.txt'):
+ if yesno('Would you like to install the required developer Python modules?'):
+ _run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements-dev.txt')
+ elif yesno('Would you like to disable developer mode?'):
+ _run_cmd(sys.argv[0], 'config', 'user.developer=None')
+ else:
+ print()
+ print(msg_install % (str(Path('requirements-dev.txt').resolve()),))
+ print('You can also turn off developer mode: qmk config user.developer=None')
+ print()
+ exit(1)
+
+# Import our subcommands
+from . import bux # noqa
+from . import c2json # noqa
+from . import cformat # noqa
+from . import chibios # noqa
+from . import clean # noqa
+from . import compile # noqa
+from milc.subcommand import config # noqa
+from . import docs # noqa
+from . import doctor # noqa
+from . import fileformat # noqa
+from . import flash # noqa
+from . import format # noqa
+from . import generate # noqa
+from . import hello # noqa
+from . import info # noqa
+from . import json2c # noqa
+from . import lint # noqa
+from . import list # noqa
+from . import kle2json # noqa
+from . import multibuild # noqa
+from . import new # noqa
+from . import pyformat # noqa
+from . import pytest # noqa
diff --git a/lib/python/qmk/cli/bux.py b/lib/python/qmk/cli/bux.py
new file mode 100755
index 0000000000..504ee35d6e
--- /dev/null
+++ b/lib/python/qmk/cli/bux.py
@@ -0,0 +1,49 @@
+"""QMK Bux
+
+World domination secret weapon.
+"""
+from milc import cli
+from milc.subcommand import config
+
+
+@cli.subcommand('QMK Bux miner.', hidden=True)
+def bux(cli):
+ """QMK bux
+ """
+ if not cli.config.user.bux:
+ bux = 0
+ else:
+ bux = cli.config.user.bux
+
+ cli.args.read_only = False
+ config.set_config('user', 'bux', bux + 1)
+ cli.save_config()
+
+ buck = """
+@@BBBBBBBBBBBBBBBBBBBBK `vP8#####BE2~ x###g_ `S###q n##} -j#Bl. vBBBBBBBBBBBBBBBBBBBB@@
+@B `:!: ^#@#]- `!t@@&. 7@@B@#^ _Q@Q@@R y@@l:P@#1' `!!_ B@
+@B r@@@B g@@| ` N@@u 7@@iv@@u *#@z"@@R y@@&@@Q- l@@@D B@
+@B !#@B ^#@#x- I@B@@&' 7@@i "B@Q@@r _@@R y@@l.k#@W: `:@@D B@
+@B B@B `v3g#####B0N#d. v##x 'ckk: -##A u##i `lB#I_ @@D B@
+@B B@B @@D B@
+@B B@B `._":!!!=~^*|)r^~:' @@D B@
+@B ~*~ `,=)]}y2tjIIfKfKfaPsffsWsUyx~. **! B@
+@B .*r***r= _*]yzKsqKUfz22IAA3HzzUjtktzHWsHsIz]. B@
+@B )v` , !1- -rysHHUzUzo2jzoI22ztzkyykt2zjzUzIa3qPsl' !r*****` B@
+@B :} @` .j `xzqdAfzKWsj2kkcycczqAsk2zHbg&ER5q55SNN5U~ !RBB#d`c#1 f#\BQ&v B@
+@B _y ]# ,c vUWNWWPsfsssN9WyccnckAfUfWb0DR0&R5RRRddq2_ `@D`jr@2U@#c3@1@Qc- B@
+@B !7! .r]` }AE0RdRqNd9dNR9fUIzzosPqqAddNNdER9EE9dPy! BQ!zy@iU@.Q@@y@8x- B@
+@B :****>. '7adddDdR&gRNdRbd&dNNbbRdNdd5NdRRD0RSf}- .k0&EW`xR .8Q=NRRx B@
+@B =**-rx*r}r~}" ;n2jkzsf3N3zsKsP5dddRddddRddNNqPzy\" '~****" B@
+@B :!!~!;=~r>:*_ `:^vxikylulKfHkyjzzozoIoklix|^!-` B@
+@B ```'-_""::::!:_-.`` B@
+@B `- .` B@
+@B r@= In source we trust @H B@
+@B r@= @H B@
+@B -g@= `}&###E7 W#g. :#Q n####~ R###8k ;#& `##.7#8-`R#z t@H B@
+@B r@= 8@R=-=R@g R@@#:!@@ 2@&!:` 8@1=@@!*@B `@@- v@#8@y @H B@
+@B r@= :@@- _@@_R@fB#}@@ 2@@@# 8@@#@Q.*@B `@@- y@@N @H B@
+@B `. g@9=_~D@g R@}`&@@@ 2@&__` 8@u_Q@2!@@^-x@@` Y@QD@z .` B@
+@@BBBBBBBBBBBBBBBBBBB_ `c8@@@81` S#] `N#B l####v D###BA. vg@@#0~ i#&' 5#K RBBBBBBBBBBBBBBBBBB@@
+""" # noqa: Do not care about the ASCII art
+ print(f"{buck}\nYou've been blessed by the QMK gods!\nYou have {cli.config.user.bux} QMK bux.")
diff --git a/lib/python/qmk/cli/c2json.py b/lib/python/qmk/cli/c2json.py
index 2b3bb774f7..43110a9387 100644
--- a/lib/python/qmk/cli/c2json.py
+++ b/lib/python/qmk/cli/c2json.py
@@ -2,18 +2,22 @@
"""
import json
+from argcomplete.completers import FilesCompleter
from milc import cli
import qmk.keymap
import qmk.path
+from qmk.json_encoders import InfoJSONEncoder
+from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.errors import CppError
@cli.argument('--no-cpp', arg_only=True, action='store_false', help='Do not use \'cpp\' on keymap.c')
@cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
-@cli.argument('-kb', '--keyboard', arg_only=True, required=True, help='The keyboard\'s name')
+@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, required=True, help='The keyboard\'s name')
@cli.argument('-km', '--keymap', arg_only=True, required=True, help='The keymap\'s name')
-@cli.argument('filename', arg_only=True, help='keymap.c file')
+@cli.argument('filename', arg_only=True, completer=FilesCompleter('.c'), help='keymap.c file')
@cli.subcommand('Creates a keymap.json from a keymap.c file.')
def c2json(cli):
"""Generate a keymap.json from a keymap.c file.
@@ -34,7 +38,13 @@ def c2json(cli):
cli.args.output = None
# Parse the keymap.c
- keymap_json = qmk.keymap.c2json(cli.args.keyboard, cli.args.keymap, cli.args.filename, use_cpp=cli.args.no_cpp)
+ try:
+ keymap_json = qmk.keymap.c2json(cli.args.keyboard, cli.args.keymap, cli.args.filename, use_cpp=cli.args.no_cpp)
+ except CppError as e:
+ if cli.config.general.verbose:
+ cli.log.debug('The C pre-processor ran into a fatal error: %s', e)
+ cli.log.error('Something went wrong. Try to use --no-cpp.\nUse the CLI in verbose mode to find out more.')
+ return False
# Generate the keymap.json
try:
@@ -46,8 +56,8 @@ def c2json(cli):
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
- cli.args.output.replace(cli.args.output.name + '.bak')
- cli.args.output.write_text(json.dumps(keymap_json))
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
+ cli.args.output.write_text(json.dumps(keymap_json, cls=InfoJSONEncoder))
if not cli.args.quiet:
cli.log.info('Wrote keymap to %s.', cli.args.output)
diff --git a/lib/python/qmk/cli/cformat.py b/lib/python/qmk/cli/cformat.py
index 5aab31843c..efeb459676 100644
--- a/lib/python/qmk/cli/cformat.py
+++ b/lib/python/qmk/cli/cformat.py
@@ -1,65 +1,137 @@
"""Format C code according to QMK's style.
"""
-import subprocess
+from os import path
from shutil import which
+from subprocess import CalledProcessError, DEVNULL, Popen, PIPE
+from argcomplete.completers import FilesCompleter
from milc import cli
from qmk.path import normpath
from qmk.c_parse import c_source_files
+c_file_suffixes = ('c', 'h', 'cpp')
+core_dirs = ('drivers', 'quantum', 'tests', 'tmk_core', 'platforms')
+ignored = ('tmk_core/protocol/usb_hid', 'quantum/template', 'platforms/chibios')
-def cformat_run(files, all_files):
+
+def find_clang_format():
+ """Returns the path to clang-format.
+ """
+ for clang_version in range(20, 6, -1):
+ binary = f'clang-format-{clang_version}'
+
+ if which(binary):
+ return binary
+
+ return 'clang-format'
+
+
+def find_diffs(files):
+ """Run clang-format and diff it against a file.
+ """
+ found_diffs = False
+
+ for file in files:
+ cli.log.debug('Checking for changes in %s', file)
+ clang_format = Popen([find_clang_format(), file], stdout=PIPE, stderr=PIPE, universal_newlines=True)
+ diff = cli.run(['diff', '-u', f'--label=a/{file}', f'--label=b/{file}', str(file), '-'], stdin=clang_format.stdout, capture_output=True)
+
+ if diff.returncode != 0:
+ print(diff.stdout)
+ found_diffs = True
+
+ return found_diffs
+
+
+def cformat_run(files):
"""Spawn clang-format subprocess with proper arguments
"""
# Determine which version of clang-format to use
- clang_format = ['clang-format', '-i']
- for clang_version in [10, 9, 8, 7]:
- binary = 'clang-format-%d' % clang_version
- if which(binary):
- clang_format[0] = binary
- break
+ clang_format = [find_clang_format(), '-i']
+
try:
- if not files:
- cli.log.warn('No changes detected. Use "qmk cformat -a" to format all files')
- return False
- subprocess.run(clang_format + [file for file in files], check=True)
+ cli.run([*clang_format, *map(str, files)], check=True, capture_output=False, stdin=DEVNULL)
cli.log.info('Successfully formatted the C code.')
+ return True
- except subprocess.CalledProcessError:
+ except CalledProcessError as e:
cli.log.error('Error formatting C code!')
+ cli.log.debug('%s exited with returncode %s', e.cmd, e.returncode)
+ cli.log.debug('STDOUT:')
+ cli.log.debug(e.stdout)
+ cli.log.debug('STDERR:')
+ cli.log.debug(e.stderr)
return False
-@cli.argument('-a', '--all-files', arg_only=True, action='store_true', help='Format all core files.')
+def filter_files(files, core_only=False):
+ """Yield only files to be formatted and skip the rest
+ """
+ if core_only:
+ # Filter non-core files
+ for index, file in enumerate(files):
+ # The following statement checks each file to see if the file path is
+ # - in the core directories
+ # - not in the ignored directories
+ if not any(i in str(file) for i in core_dirs) or any(i in str(file) for i in ignored):
+ files[index] = None
+ cli.log.debug("Skipping non-core file %s, as '--core-only' is used.", file)
+
+ for file in files:
+ if file and file.name.split('.')[-1] in c_file_suffixes:
+ yield file
+ else:
+ cli.log.debug('Skipping file %s', file)
+
+
+@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Flag only, don't automatically format.")
@cli.argument('-b', '--base-branch', default='origin/master', help='Branch to compare to diffs to.')
-@cli.argument('files', nargs='*', arg_only=True, help='Filename(s) to format.')
+@cli.argument('-a', '--all-files', arg_only=True, action='store_true', help='Format all core files.')
+@cli.argument('--core-only', arg_only=True, action='store_true', help='Format core files only.')
+@cli.argument('files', nargs='*', arg_only=True, type=normpath, completer=FilesCompleter('.c'), help='Filename(s) to format.')
@cli.subcommand("Format C code according to QMK's style.", hidden=False if cli.config.user.developer else True)
def cformat(cli):
"""Format C code according to QMK's style.
"""
- # Empty array for files
- files = []
- # Core directories for formatting
- core_dirs = ['drivers', 'quantum', 'tests', 'tmk_core', 'platforms']
- ignores = ['tmk_core/protocol/usb_hid', 'quantum/template', 'platforms/chibios']
# Find the list of files to format
if cli.args.files:
- files.extend(normpath(file) for file in cli.args.files)
+ files = list(filter_files(cli.args.files, cli.args.core_only))
+
+ if not files:
+ cli.log.error('No C files in filelist: %s', ', '.join(map(str, cli.args.files)))
+ exit(0)
+
if cli.args.all_files:
cli.log.warning('Filenames passed with -a, only formatting: %s', ','.join(map(str, files)))
- # If -a is specified
+
elif cli.args.all_files:
all_files = c_source_files(core_dirs)
- # The following statement checks each file to see if the file path is in the ignored directories.
- files.extend(file for file in all_files if not any(i in str(file) for i in ignores))
- # No files specified & no -a flag
+ files = list(filter_files(all_files, True))
+
else:
- base_args = ['git', 'diff', '--name-only', cli.args.base_branch]
- out = subprocess.run(base_args + core_dirs, check=True, stdout=subprocess.PIPE)
- changed_files = filter(None, out.stdout.decode('UTF-8').split('\n'))
- filtered_files = [normpath(file) for file in changed_files if not any(i in file for i in ignores)]
- files.extend(file for file in filtered_files if file.exists() and file.suffix in ['.c', '.h', '.cpp'])
+ git_diff_cmd = ['git', 'diff', '--name-only', cli.args.base_branch, *core_dirs]
+ git_diff = cli.run(git_diff_cmd, stdin=DEVNULL)
+
+ if git_diff.returncode != 0:
+ cli.log.error("Error running %s", git_diff_cmd)
+ print(git_diff.stderr)
+ return git_diff.returncode
+
+ files = []
+
+ for file in git_diff.stdout.strip().split('\n'):
+ if not any([file.startswith(ignore) for ignore in ignored]):
+ if path.exists(file) and file.split('.')[-1] in c_file_suffixes:
+ files.append(file)
+
+ # Sanity check
+ if not files:
+ cli.log.error('No changed files detected. Use "qmk cformat -a" to format all core files')
+ return False
# Run clang-format on the files we've found
- cformat_run(files, cli.args.all_files)
+ if cli.args.dry_run:
+ return not find_diffs(files)
+ else:
+ return cformat_run(files)
diff --git a/lib/python/qmk/cli/chibios/confmigrate.py b/lib/python/qmk/cli/chibios/confmigrate.py
index b9cfda9614..be1f2cd744 100644
--- a/lib/python/qmk/cli/chibios/confmigrate.py
+++ b/lib/python/qmk/cli/chibios/confmigrate.py
@@ -32,7 +32,7 @@ file_header = """\
/*
* This file was auto-generated by:
- * `qmk chibios-confupdate -i {0} -r {1}`
+ * `qmk chibios-confmigrate -i {0} -r {1}`
*/
#pragma once
@@ -40,7 +40,7 @@ file_header = """\
def collect_defines(filepath):
- with open(filepath, 'r') as f:
+ with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
define_search = re.compile(r'(?m)^#\s*define\s+(?:.*\\\r?\n)*.*$', re.MULTILINE)
value_search = re.compile(r'^#\s*define\s+(?P<name>[a-zA-Z0-9_]+(\([^\)]*\))?)\s*(?P<value>.*)', re.DOTALL)
@@ -107,10 +107,11 @@ def migrate_mcuconf_h(to_override, outfile):
print("", file=outfile)
-@cli.argument('-i', '--input', type=normpath, arg_only=True, help='Specify input config file.')
-@cli.argument('-r', '--reference', type=normpath, arg_only=True, help='Specify the reference file to compare against')
+@cli.argument('-i', '--input', type=normpath, arg_only=True, required=True, help='Specify input config file.')
+@cli.argument('-r', '--reference', type=normpath, arg_only=True, required=True, help='Specify the reference file to compare against')
@cli.argument('-o', '--overwrite', arg_only=True, action='store_true', help='Overwrites the input file during migration.')
@cli.argument('-d', '--delete', arg_only=True, action='store_true', help='If the file has no overrides, migration will delete the input file.')
+@cli.argument('-f', '--force', arg_only=True, action='store_true', help='Re-migrates an already migrated file, even if it doesn\'t detect a full ChibiOS config.')
@cli.subcommand('Generates a migrated ChibiOS configuration file, as a result of comparing the input against a reference')
def chibios_confmigrate(cli):
"""Generates a usable ChibiOS replacement configuration file, based on a fully-defined conf and a reference config.
@@ -142,20 +143,20 @@ def chibios_confmigrate(cli):
eprint('--------------------------------------')
- if "CHCONF_H" in input_defs["dict"] or "_CHCONF_H_" in input_defs["dict"]:
+ if cli.args.input.name == "chconf.h" and ("CHCONF_H" in input_defs["dict"] or "_CHCONF_H_" in input_defs["dict"] or cli.args.force):
migrate_chconf_h(to_override, outfile=sys.stdout)
if cli.args.overwrite:
- with open(cli.args.input, "w") as out_file:
+ with open(cli.args.input, "w", encoding='utf-8') as out_file:
migrate_chconf_h(to_override, outfile=out_file)
- elif "HALCONF_H" in input_defs["dict"] or "_HALCONF_H_" in input_defs["dict"]:
+ elif cli.args.input.name == "halconf.h" and ("HALCONF_H" in input_defs["dict"] or "_HALCONF_H_" in input_defs["dict"] or cli.args.force):
migrate_halconf_h(to_override, outfile=sys.stdout)
if cli.args.overwrite:
- with open(cli.args.input, "w") as out_file:
+ with open(cli.args.input, "w", encoding='utf-8') as out_file:
migrate_halconf_h(to_override, outfile=out_file)
- elif "MCUCONF_H" in input_defs["dict"] or "_MCUCONF_H_" in input_defs["dict"]:
+ elif cli.args.input.name == "mcuconf.h" and ("MCUCONF_H" in input_defs["dict"] or "_MCUCONF_H_" in input_defs["dict"] or cli.args.force):
migrate_mcuconf_h(to_override, outfile=sys.stdout)
if cli.args.overwrite:
- with open(cli.args.input, "w") as out_file:
+ with open(cli.args.input, "w", encoding='utf-8') as out_file:
migrate_mcuconf_h(to_override, outfile=out_file)
diff --git a/lib/python/qmk/cli/clean.py b/lib/python/qmk/cli/clean.py
index ec6501b760..72b7ffe810 100644
--- a/lib/python/qmk/cli/clean.py
+++ b/lib/python/qmk/cli/clean.py
@@ -1,9 +1,9 @@
"""Clean the QMK firmware folder of build artifacts.
"""
-from qmk.commands import run
-from milc import cli
+from subprocess import DEVNULL
-import shutil
+from qmk.commands import create_make_target
+from milc import cli
@cli.argument('-a', '--all', arg_only=True, action='store_true', help='Remove *.hex and *.bin files in the QMK root as well.')
@@ -11,6 +11,4 @@ import shutil
def clean(cli):
"""Runs `make clean` (or `make distclean` if --all is passed)
"""
- make_cmd = 'gmake' if shutil.which('gmake') else 'make'
-
- run([make_cmd, 'distclean' if cli.args.all else 'clean'])
+ cli.run(create_make_target('distclean' if cli.args.all else 'clean'), capture_output=False, stdin=DEVNULL)
diff --git a/lib/python/qmk/cli/compile.py b/lib/python/qmk/cli/compile.py
index 322ce6a257..7a45e77214 100755
--- a/lib/python/qmk/cli/compile.py
+++ b/lib/python/qmk/cli/compile.py
@@ -2,17 +2,21 @@
You can compile a keymap already in the repo or using a QMK Configurator export.
"""
-from argparse import FileType
+from subprocess import DEVNULL
+from argcomplete.completers import FilesCompleter
from milc import cli
+import qmk.path
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json
+from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.keymap import keymap_completer
-@cli.argument('filename', nargs='?', arg_only=True, type=FileType('r'), help='The configurator export to compile')
-@cli.argument('-kb', '--keyboard', help='The keyboard to build a firmware for. Ignored when a configurator export is supplied.')
-@cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Ignored when a configurator export is supplied.')
+@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export to compile')
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='The keyboard to build a firmware for. Ignored when a configurator export is supplied.')
+@cli.argument('-km', '--keymap', completer=keymap_completer, help='The keymap to build a firmware for. Ignored when a configurator export is supplied.')
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs to run.")
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
@@ -29,8 +33,7 @@ def compile(cli):
"""
if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
command = create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, 'clean')
- # FIXME(skullydazed/anyone): Remove text=False once milc 1.0.11 has had enough time to be installed everywhere.
- cli.run(command, capture_output=False, text=False)
+ cli.run(command, capture_output=False, stdin=DEVNULL)
# Build the environment vars
envs = {}
diff --git a/lib/python/qmk/cli/doctor.py b/lib/python/qmk/cli/doctor.py
index 70f32911a4..9e10570620 100755
--- a/lib/python/qmk/cli/doctor.py
+++ b/lib/python/qmk/cli/doctor.py
@@ -3,12 +3,12 @@
Check out the user's QMK environment and make sure it's ready to compile.
"""
import platform
+from subprocess import DEVNULL
from milc import cli
from milc.questions import yesno
from qmk import submodules
from qmk.constants import QMK_FIRMWARE
-from qmk.commands import run
from qmk.os_helpers import CheckStatus, check_binaries, check_binary_versions, check_submodules, check_git_repo
@@ -31,16 +31,27 @@ def os_tests():
def os_test_linux():
"""Run the Linux specific tests.
"""
- cli.log.info("Detected {fg_cyan}Linux.")
- from qmk.os_helpers.linux import check_udev_rules
+ # Don't bother with udev on WSL, for now
+ if 'microsoft' in platform.uname().release.lower():
+ cli.log.info("Detected {fg_cyan}Linux (WSL){fg_reset}.")
- return check_udev_rules()
+ # https://github.com/microsoft/WSL/issues/4197
+ if QMK_FIRMWARE.as_posix().startswith("/mnt"):
+ cli.log.warning("I/O performance on /mnt may be extremely slow.")
+ return CheckStatus.WARNING
+
+ return CheckStatus.OK
+ else:
+ cli.log.info("Detected {fg_cyan}Linux{fg_reset}.")
+ from qmk.os_helpers.linux import check_udev_rules
+
+ return check_udev_rules()
def os_test_macos():
"""Run the Mac specific tests.
"""
- cli.log.info("Detected {fg_cyan}macOS.")
+ cli.log.info("Detected {fg_cyan}macOS %s{fg_reset}.", platform.mac_ver()[0])
return CheckStatus.OK
@@ -48,7 +59,8 @@ def os_test_macos():
def os_test_windows():
"""Run the Windows specific tests.
"""
- cli.log.info("Detected {fg_cyan}Windows.")
+ win32_ver = platform.win32_ver()
+ cli.log.info("Detected {fg_cyan}Windows %s (%s){fg_reset}.", win32_ver[0], win32_ver[1])
return CheckStatus.OK
@@ -65,11 +77,10 @@ def doctor(cli):
* [ ] Compile a trivial program with each compiler
"""
cli.log.info('QMK Doctor is checking your environment.')
+ cli.log.info('QMK home: {fg_cyan}%s', QMK_FIRMWARE)
status = os_tests()
- cli.log.info('QMK home: {fg_cyan}%s', QMK_FIRMWARE)
-
# Make sure our QMK home is a Git repo
git_ok = check_git_repo()
@@ -82,7 +93,7 @@ def doctor(cli):
if not bin_ok:
if yesno('Would you like to install dependencies?', default=True):
- run(['util/qmk_install.sh'])
+ cli.run(['util/qmk_install.sh', '-y'], stdin=DEVNULL, capture_output=False)
bin_ok = check_binaries()
if bin_ok:
@@ -107,9 +118,9 @@ def doctor(cli):
submodules.update()
sub_ok = check_submodules()
- if CheckStatus.ERROR in sub_ok:
+ if sub_ok == CheckStatus.ERROR:
status = CheckStatus.ERROR
- elif CheckStatus.WARNING in sub_ok and status == CheckStatus.OK:
+ elif sub_ok == CheckStatus.WARNING and status == CheckStatus.OK:
status = CheckStatus.WARNING
# Report a summary of our findings to the user
diff --git a/lib/python/qmk/cli/flash.py b/lib/python/qmk/cli/flash.py
index a876290035..1b2932a5b2 100644
--- a/lib/python/qmk/cli/flash.py
+++ b/lib/python/qmk/cli/flash.py
@@ -3,13 +3,15 @@
You can compile a keymap already in the repo or using a QMK Configurator export.
A bootloader must be specified.
"""
-from argparse import FileType
+from subprocess import DEVNULL
+from argcomplete.completers import FilesCompleter
from milc import cli
import qmk.path
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json
+from qmk.keyboard import keyboard_completer, keyboard_folder
def print_bootloader_help():
@@ -30,11 +32,11 @@ def print_bootloader_help():
cli.echo('For more info, visit https://docs.qmk.fm/#/flashing')
-@cli.argument('filename', nargs='?', arg_only=True, type=FileType('r'), help='The configurator export JSON to compile.')
+@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export JSON to compile.')
@cli.argument('-b', '--bootloaders', action='store_true', help='List the available bootloaders.')
@cli.argument('-bl', '--bootloader', default='flash', help='The flash command, corresponding to qmk\'s make options of bootloaders.')
@cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
-@cli.argument('-kb', '--keyboard', help='The keyboard to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='The keyboard to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs to run.")
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
@@ -54,7 +56,7 @@ def flash(cli):
"""
if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, 'clean')
- cli.run(command, capture_output=False)
+ cli.run(command, capture_output=False, stdin=DEVNULL)
# Build the environment vars
envs = {}
@@ -97,7 +99,7 @@ def flash(cli):
cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(command))
if not cli.args.dry_run:
cli.echo('\n')
- compile = cli.run(command, capture_output=False, text=True)
+ compile = cli.run(command, capture_output=False, stdin=DEVNULL)
return compile.returncode
else:
diff --git a/lib/python/qmk/cli/format/__init__.py b/lib/python/qmk/cli/format/__init__.py
new file mode 100644
index 0000000000..741ec778b1
--- /dev/null
+++ b/lib/python/qmk/cli/format/__init__.py
@@ -0,0 +1 @@
+from . import json
diff --git a/lib/python/qmk/cli/format/json.py b/lib/python/qmk/cli/format/json.py
new file mode 100755
index 0000000000..1358c70e7a
--- /dev/null
+++ b/lib/python/qmk/cli/format/json.py
@@ -0,0 +1,66 @@
+"""JSON Formatting Script
+
+Spits out a JSON file formatted with one of QMK's formatters.
+"""
+import json
+
+from jsonschema import ValidationError
+from milc import cli
+
+from qmk.info import info_json
+from qmk.json_schema import json_load, keyboard_validate
+from qmk.json_encoders import InfoJSONEncoder, KeymapJSONEncoder
+from qmk.path import normpath
+
+
+@cli.argument('json_file', arg_only=True, type=normpath, help='JSON file to format')
+@cli.argument('-f', '--format', choices=['auto', 'keyboard', 'keymap'], default='auto', arg_only=True, help='JSON formatter to use (Default: autodetect)')
+@cli.subcommand('Generate an info.json file for a keyboard.', hidden=False if cli.config.user.developer else True)
+def format_json(cli):
+ """Format a json file.
+ """
+ json_file = json_load(cli.args.json_file)
+
+ if cli.args.format == 'auto':
+ try:
+ keyboard_validate(json_file)
+ json_encoder = InfoJSONEncoder
+
+ except ValidationError as e:
+ cli.log.warning('File %s did not validate as a keyboard:\n\t%s', cli.args.json_file, e)
+ cli.log.info('Treating %s as a keymap file.', cli.args.json_file)
+ json_encoder = KeymapJSONEncoder
+
+ elif cli.args.format == 'keyboard':
+ json_encoder = InfoJSONEncoder
+ elif cli.args.format == 'keymap':
+ json_encoder = KeymapJSONEncoder
+ else:
+ # This should be impossible
+ cli.log.error('Unknown format: %s', cli.args.format)
+ return False
+
+ if json_encoder == KeymapJSONEncoder and 'layout' in json_file:
+ # Attempt to format the keycodes.
+ layout = json_file['layout']
+ info_data = info_json(json_file['keyboard'])
+
+ if layout in info_data.get('layout_aliases', {}):
+ layout = json_file['layout'] = info_data['layout_aliases'][layout]
+
+ if layout in info_data.get('layouts'):
+ for layer_num, layer in enumerate(json_file['layers']):
+ current_layer = []
+ last_row = 0
+
+ for keymap_key, info_key in zip(layer, info_data['layouts'][layout]['layout']):
+ if last_row != info_key['y']:
+ current_layer.append('JSON_NEWLINE')
+ last_row = info_key['y']
+
+ current_layer.append(keymap_key)
+
+ json_file['layers'][layer_num] = current_layer
+
+ # Display the results
+ print(json.dumps(json_file, cls=json_encoder))
diff --git a/lib/python/qmk/cli/generate/__init__.py b/lib/python/qmk/cli/generate/__init__.py
index f9585bfb5c..0efca0022d 100644
--- a/lib/python/qmk/cli/generate/__init__.py
+++ b/lib/python/qmk/cli/generate/__init__.py
@@ -1,3 +1,9 @@
from . import api
+from . import config_h
+from . import dfu_header
from . import docs
+from . import info_json
+from . import keyboard_h
+from . import layouts
from . import rgb_breathe_table
+from . import rules_mk
diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py
index 66db37cb52..285bd90eb5 100755
--- a/lib/python/qmk/cli/generate/api.py
+++ b/lib/python/qmk/cli/generate/api.py
@@ -8,51 +8,80 @@ from milc import cli
from qmk.datetime import current_datetime
from qmk.info import info_json
-from qmk.keyboard import list_keyboards
+from qmk.json_encoders import InfoJSONEncoder
+from qmk.json_schema import json_load
+from qmk.keyboard import find_readme, list_keyboards
+@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't write the data to disk.")
@cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True)
def generate_api(cli):
"""Generates the QMK API data.
"""
api_data_dir = Path('api_data')
v1_dir = api_data_dir / 'v1'
- keyboard_list = v1_dir / 'keyboard_list.json'
- keyboard_all = v1_dir / 'keyboards.json'
- usb_file = v1_dir / 'usb.json'
+ keyboard_all_file = v1_dir / 'keyboards.json' # A massive JSON containing everything
+ keyboard_list_file = v1_dir / 'keyboard_list.json' # A simple list of keyboard targets
+ keyboard_aliases_file = v1_dir / 'keyboard_aliases.json' # A list of historical keyboard names and their new name
+ keyboard_metadata_file = v1_dir / 'keyboard_metadata.json' # All the data configurator/via needs for initialization
+ usb_file = v1_dir / 'usb.json' # A mapping of USB VID/PID -> keyboard target
if not api_data_dir.exists():
api_data_dir.mkdir()
- kb_all = {'last_updated': current_datetime(), 'keyboards': {}}
- usb_list = {'last_updated': current_datetime(), 'devices': {}}
+ kb_all = {}
+ usb_list = {}
# Generate and write keyboard specific JSON files
for keyboard_name in list_keyboards():
- kb_all['keyboards'][keyboard_name] = info_json(keyboard_name)
+ kb_all[keyboard_name] = info_json(keyboard_name)
keyboard_dir = v1_dir / 'keyboards' / keyboard_name
keyboard_info = keyboard_dir / 'info.json'
keyboard_readme = keyboard_dir / 'readme.md'
- keyboard_readme_src = Path('keyboards') / keyboard_name / 'readme.md'
+ keyboard_readme_src = find_readme(keyboard_name)
keyboard_dir.mkdir(parents=True, exist_ok=True)
- keyboard_info.write_text(json.dumps({'last_updated': current_datetime(), 'keyboards': {keyboard_name: kb_all['keyboards'][keyboard_name]}}))
+ keyboard_json = json.dumps({'last_updated': current_datetime(), 'keyboards': {keyboard_name: kb_all[keyboard_name]}})
+ if not cli.args.dry_run:
+ keyboard_info.write_text(keyboard_json)
+ cli.log.debug('Wrote file %s', keyboard_info)
- if keyboard_readme_src.exists():
- copyfile(keyboard_readme_src, keyboard_readme)
+ if keyboard_readme_src:
+ copyfile(keyboard_readme_src, keyboard_readme)
+ cli.log.debug('Copied %s -> %s', keyboard_readme_src, keyboard_readme)
- if 'usb' in kb_all['keyboards'][keyboard_name]:
- usb = kb_all['keyboards'][keyboard_name]['usb']
+ if 'usb' in kb_all[keyboard_name]:
+ usb = kb_all[keyboard_name]['usb']
- if usb['vid'] not in usb_list['devices']:
- usb_list['devices'][usb['vid']] = {}
+ if 'vid' in usb and usb['vid'] not in usb_list:
+ usb_list[usb['vid']] = {}
- if usb['pid'] not in usb_list['devices'][usb['vid']]:
- usb_list['devices'][usb['vid']][usb['pid']] = {}
+ if 'pid' in usb and usb['pid'] not in usb_list[usb['vid']]:
+ usb_list[usb['vid']][usb['pid']] = {}
- usb_list['devices'][usb['vid']][usb['pid']][keyboard_name] = usb
+ if 'vid' in usb and 'pid' in usb:
+ usb_list[usb['vid']][usb['pid']][keyboard_name] = usb
+
+ # Generate data for the global files
+ keyboard_list = sorted(kb_all)
+ keyboard_aliases = json_load(Path('data/mappings/keyboard_aliases.json'))
+ keyboard_metadata = {
+ 'last_updated': current_datetime(),
+ 'keyboards': keyboard_list,
+ 'keyboard_aliases': keyboard_aliases,
+ 'usb': usb_list,
+ }
# Write the global JSON files
- keyboard_list.write_text(json.dumps({'last_updated': current_datetime(), 'keyboards': sorted(kb_all['keyboards'])}))
- keyboard_all.write_text(json.dumps(kb_all))
- usb_file.write_text(json.dumps(usb_list))
+ keyboard_all_json = json.dumps({'last_updated': current_datetime(), 'keyboards': kb_all}, cls=InfoJSONEncoder)
+ usb_json = json.dumps({'last_updated': current_datetime(), 'usb': usb_list}, cls=InfoJSONEncoder)
+ keyboard_list_json = json.dumps({'last_updated': current_datetime(), 'keyboards': keyboard_list}, cls=InfoJSONEncoder)
+ keyboard_aliases_json = json.dumps({'last_updated': current_datetime(), 'keyboard_aliases': keyboard_aliases}, cls=InfoJSONEncoder)
+ keyboard_metadata_json = json.dumps(keyboard_metadata, cls=InfoJSONEncoder)
+
+ if not cli.args.dry_run:
+ keyboard_all_file.write_text(keyboard_all_json)
+ usb_file.write_text(usb_json)
+ keyboard_list_file.write_text(keyboard_list_json)
+ keyboard_aliases_file.write_text(keyboard_aliases_json)
+ keyboard_metadata_file.write_text(keyboard_metadata_json)
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
new file mode 100755
index 0000000000..54cd5b96a8
--- /dev/null
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -0,0 +1,154 @@
+"""Used by the make system to generate info_config.h from info.json.
+"""
+from pathlib import Path
+
+from dotty_dict import dotty
+from milc import cli
+
+from qmk.decorators import automagic_keyboard, automagic_keymap
+from qmk.info import info_json
+from qmk.json_schema import json_load
+from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.path import is_keyboard, normpath
+
+
+def direct_pins(direct_pins):
+ """Return the config.h lines that set the direct pins.
+ """
+ rows = []
+
+ for row in direct_pins:
+ cols = ','.join(map(str, [col or 'NO_PIN' for col in row]))
+ rows.append('{' + cols + '}')
+
+ col_count = len(direct_pins[0])
+ row_count = len(direct_pins)
+
+ return """
+#ifndef MATRIX_COLS
+# define MATRIX_COLS %s
+#endif // MATRIX_COLS
+
+#ifndef MATRIX_ROWS
+# define MATRIX_ROWS %s
+#endif // MATRIX_ROWS
+
+#ifndef DIRECT_PINS
+# define DIRECT_PINS {%s}
+#endif // DIRECT_PINS
+""" % (col_count, row_count, ','.join(rows))
+
+
+def pin_array(define, pins):
+ """Return the config.h lines that set a pin array.
+ """
+ pin_num = len(pins)
+ pin_array = ', '.join(map(str, [pin or 'NO_PIN' for pin in pins]))
+
+ return f"""
+#ifndef {define}S
+# define {define}S {pin_num}
+#endif // {define}S
+
+#ifndef {define}_PINS
+# define {define}_PINS {{ {pin_array} }}
+#endif // {define}_PINS
+"""
+
+
+def matrix_pins(matrix_pins):
+ """Add the matrix config to the config.h.
+ """
+ pins = []
+
+ if 'direct' in matrix_pins:
+ pins.append(direct_pins(matrix_pins['direct']))
+
+ if 'cols' in matrix_pins:
+ pins.append(pin_array('MATRIX_COL', matrix_pins['cols']))
+
+ if 'rows' in matrix_pins:
+ pins.append(pin_array('MATRIX_ROW', matrix_pins['rows']))
+
+ return '\n'.join(pins)
+
+
+@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
+@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate config.h for.')
+@cli.subcommand('Used by the make system to generate info_config.h from info.json', hidden=True)
+@automagic_keyboard
+@automagic_keymap
+def generate_config_h(cli):
+ """Generates the info_config.h file.
+ """
+ # Determine our keyboard(s)
+ if not cli.config.generate_config_h.keyboard:
+ cli.log.error('Missing parameter: --keyboard')
+ cli.subcommands['info'].print_help()
+ return False
+
+ if not is_keyboard(cli.config.generate_config_h.keyboard):
+ cli.log.error('Invalid keyboard: "%s"', cli.config.generate_config_h.keyboard)
+ return False
+
+ # Build the info_config.h file.
+ kb_info_json = dotty(info_json(cli.config.generate_config_h.keyboard))
+ info_config_map = json_load(Path('data/mappings/info_config.json'))
+
+ config_h_lines = ['/* This file was generated by `qmk generate-config-h`. Do not edit or copy.' ' */', '', '#pragma once']
+
+ # Iterate through the info_config map to generate basic things
+ for config_key, info_dict in info_config_map.items():
+ info_key = info_dict['info_key']
+ key_type = info_dict.get('value_type', 'str')
+ to_config = info_dict.get('to_config', True)
+
+ if not to_config:
+ continue
+
+ try:
+ config_value = kb_info_json[info_key]
+ except KeyError:
+ continue
+
+ if key_type.startswith('array'):
+ config_h_lines.append('')
+ config_h_lines.append(f'#ifndef {config_key}')
+ config_h_lines.append(f'# define {config_key} {{ {", ".join(map(str, config_value))} }}')
+ config_h_lines.append(f'#endif // {config_key}')
+ elif key_type == 'bool':
+ if config_value:
+ config_h_lines.append('')
+ config_h_lines.append(f'#ifndef {config_key}')
+ config_h_lines.append(f'# define {config_key}')
+ config_h_lines.append(f'#endif // {config_key}')
+ elif key_type == 'mapping':
+ for key, value in config_value.items():
+ config_h_lines.append('')
+ config_h_lines.append(f'#ifndef {key}')
+ config_h_lines.append(f'# define {key} {value}')
+ config_h_lines.append(f'#endif // {key}')
+ else:
+ config_h_lines.append('')
+ config_h_lines.append(f'#ifndef {config_key}')
+ config_h_lines.append(f'# define {config_key} {config_value}')
+ config_h_lines.append(f'#endif // {config_key}')
+
+ if 'matrix_pins' in kb_info_json:
+ config_h_lines.append(matrix_pins(kb_info_json['matrix_pins']))
+
+ # Show the results
+ config_h = '\n'.join(config_h_lines)
+
+ if cli.args.output:
+ cli.args.output.parent.mkdir(parents=True, exist_ok=True)
+ if cli.args.output.exists():
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
+ cli.args.output.write_text(config_h)
+
+ if not cli.args.quiet:
+ cli.log.info('Wrote info_config.h to %s.', cli.args.output)
+
+ else:
+ print(config_h)
diff --git a/lib/python/qmk/cli/generate/dfu_header.py b/lib/python/qmk/cli/generate/dfu_header.py
new file mode 100644
index 0000000000..211ed9991a
--- /dev/null
+++ b/lib/python/qmk/cli/generate/dfu_header.py
@@ -0,0 +1,60 @@
+"""Used by the make system to generate LUFA Keyboard.h from info.json
+"""
+from dotty_dict import dotty
+from milc import cli
+
+from qmk.decorators import automagic_keyboard
+from qmk.info import info_json
+from qmk.path import is_keyboard, normpath
+from qmk.keyboard import keyboard_completer
+
+
+@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
+@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
+@cli.argument('-kb', '--keyboard', completer=keyboard_completer, help='Keyboard to generate LUFA Keyboard.h for.')
+@cli.subcommand('Used by the make system to generate LUFA Keyboard.h from info.json', hidden=True)
+@automagic_keyboard
+def generate_dfu_header(cli):
+ """Generates the Keyboard.h file.
+ """
+ # Determine our keyboard(s)
+ if not cli.config.generate_dfu_header.keyboard:
+ cli.log.error('Missing parameter: --keyboard')
+ cli.subcommands['info'].print_help()
+ return False
+
+ if not is_keyboard(cli.config.generate_dfu_header.keyboard):
+ cli.log.error('Invalid keyboard: "%s"', cli.config.generate_dfu_header.keyboard)
+ return False
+
+ # Build the Keyboard.h file.
+ kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard))
+
+ keyboard_h_lines = ['/* This file was generated by `qmk generate-dfu-header`. Do not edit or copy.' ' */', '', '#pragma once']
+ keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}')
+ keyboard_h_lines.append(f'#define PRODUCT {cli.config.generate_dfu_header.keyboard} Bootloader')
+
+ # Optional
+ if 'qmk_lufa_bootloader.esc_output' in kb_info_json:
+ keyboard_h_lines.append(f'#define QMK_ESC_OUTPUT {kb_info_json["qmk_lufa_bootloader.esc_output"]}')
+ if 'qmk_lufa_bootloader.esc_input' in kb_info_json:
+ keyboard_h_lines.append(f'#define QMK_ESC_INPUT {kb_info_json["qmk_lufa_bootloader.esc_input"]}')
+ if 'qmk_lufa_bootloader.led' in kb_info_json:
+ keyboard_h_lines.append(f'#define QMK_LED {kb_info_json["qmk_lufa_bootloader.led"]}')
+ if 'qmk_lufa_bootloader.speaker' in kb_info_json:
+ keyboard_h_lines.append(f'#define QMK_SPEAKER {kb_info_json["qmk_lufa_bootloader.speaker"]}')
+
+ # Show the results
+ keyboard_h = '\n'.join(keyboard_h_lines)
+
+ if cli.args.output:
+ cli.args.output.parent.mkdir(parents=True, exist_ok=True)
+ if cli.args.output.exists():
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
+ cli.args.output.write_text(keyboard_h)
+
+ if not cli.args.quiet:
+ cli.log.info('Wrote Keyboard.h to %s.', cli.args.output)
+
+ else:
+ print(keyboard_h)
diff --git a/lib/python/qmk/cli/generate/docs.py b/lib/python/qmk/cli/generate/docs.py
index a59a24db50..749336fea5 100644
--- a/lib/python/qmk/cli/generate/docs.py
+++ b/lib/python/qmk/cli/generate/docs.py
@@ -1,8 +1,8 @@
"""Build QMK documentation locally
"""
import shutil
-import subprocess
from pathlib import Path
+from subprocess import DEVNULL
from milc import cli
@@ -24,14 +24,16 @@ def generate_docs(cli):
shutil.copytree(DOCS_PATH, BUILD_PATH)
# When not verbose we want to hide all output
- args = {'check': True}
- if not cli.args.verbose:
- args.update({'stdout': subprocess.DEVNULL, 'stderr': subprocess.STDOUT})
+ args = {
+ 'capture_output': False if cli.config.general.verbose else True,
+ 'check': True,
+ 'stdin': DEVNULL,
+ }
cli.log.info('Generating internal docs...')
# Generate internal docs
- subprocess.run(['doxygen', 'Doxyfile'], **args)
- subprocess.run(['moxygen', '-q', '-a', '-g', '-o', BUILD_PATH / 'internals_%s.md', 'doxygen/xml'], **args)
+ cli.run(['doxygen', 'Doxyfile'], **args)
+ cli.run(['moxygen', '-q', '-a', '-g', '-o', BUILD_PATH / 'internals_%s.md', 'doxygen/xml'], **args)
cli.log.info('Successfully generated internal docs to %s.', BUILD_PATH)
diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py
new file mode 100755
index 0000000000..8931b68b6f
--- /dev/null
+++ b/lib/python/qmk/cli/generate/info_json.py
@@ -0,0 +1,67 @@
+"""Keyboard information script.
+
+Compile an info.json for a particular keyboard and pretty-print it.
+"""
+import json
+
+from jsonschema import Draft7Validator, validators
+from milc import cli
+
+from qmk.decorators import automagic_keyboard, automagic_keymap
+from qmk.info import info_json
+from qmk.json_encoders import InfoJSONEncoder
+from qmk.json_schema import load_jsonschema
+from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.path import is_keyboard
+
+
+def pruning_validator(validator_class):
+ """Extends Draft7Validator to remove properties that aren't specified in the schema.
+ """
+ validate_properties = validator_class.VALIDATORS["properties"]
+
+ def remove_additional_properties(validator, properties, instance, schema):
+ for prop in list(instance.keys()):
+ if prop not in properties:
+ del instance[prop]
+
+ for error in validate_properties(validator, properties, instance, schema):
+ yield error
+
+ return validators.extend(validator_class, {"properties": remove_additional_properties})
+
+
+def strip_info_json(kb_info_json):
+ """Remove the API-only properties from the info.json.
+ """
+ pruning_draft_7_validator = pruning_validator(Draft7Validator)
+ schema = load_jsonschema('keyboard')
+ validator = pruning_draft_7_validator(schema).validate
+
+ return validator(kb_info_json)
+
+
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to show info for.')
+@cli.argument('-km', '--keymap', help='Show the layers for a JSON keymap too.')
+@cli.subcommand('Generate an info.json file for a keyboard.', hidden=False if cli.config.user.developer else True)
+@automagic_keyboard
+@automagic_keymap
+def generate_info_json(cli):
+ """Generate an info.json file for a keyboard
+ """
+ # Determine our keyboard(s)
+ if not cli.config.generate_info_json.keyboard:
+ cli.log.error('Missing parameter: --keyboard')
+ cli.subcommands['info'].print_help()
+ return False
+
+ if not is_keyboard(cli.config.generate_info_json.keyboard):
+ cli.log.error('Invalid keyboard: "%s"', cli.config.generate_info_json.keyboard)
+ return False
+
+ # Build the info.json file
+ kb_info_json = info_json(cli.config.generate_info_json.keyboard)
+ strip_info_json(kb_info_json)
+
+ # Display the results
+ print(json.dumps(kb_info_json, indent=2, cls=InfoJSONEncoder))
diff --git a/lib/python/qmk/cli/generate/keyboard_h.py b/lib/python/qmk/cli/generate/keyboard_h.py
new file mode 100755
index 0000000000..22500dbc91
--- /dev/null
+++ b/lib/python/qmk/cli/generate/keyboard_h.py
@@ -0,0 +1,60 @@
+"""Used by the make system to generate keyboard.h from info.json.
+"""
+from milc import cli
+
+from qmk.decorators import automagic_keyboard, automagic_keymap
+from qmk.info import info_json
+from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.path import normpath
+
+
+def would_populate_layout_h(keyboard):
+ """Detect if a given keyboard is doing data driven layouts
+ """
+ # Build the info.json file
+ kb_info_json = info_json(keyboard)
+
+ for layout_name in kb_info_json['layouts']:
+ if kb_info_json['layouts'][layout_name]['c_macro']:
+ continue
+
+ if 'matrix' not in kb_info_json['layouts'][layout_name]['layout'][0]:
+ cli.log.debug('%s/%s: No matrix data!', keyboard, layout_name)
+ continue
+
+ return True
+
+ return False
+
+
+@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
+@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, required=True, help='Keyboard to generate keyboard.h for.')
+@cli.subcommand('Used by the make system to generate keyboard.h from info.json', hidden=True)
+@automagic_keyboard
+@automagic_keymap
+def generate_keyboard_h(cli):
+ """Generates the keyboard.h file.
+ """
+ has_layout_h = would_populate_layout_h(cli.config.generate_keyboard_h.keyboard)
+
+ # Build the layouts.h file.
+ keyboard_h_lines = ['/* This file was generated by `qmk generate-keyboard-h`. Do not edit or copy.' ' */', '', '#pragma once', '#include "quantum.h"']
+
+ if not has_layout_h:
+ keyboard_h_lines.append('#pragma error("<keyboard>.h is only optional for data driven keyboards - kb.h == bad times")')
+
+ # Show the results
+ keyboard_h = '\n'.join(keyboard_h_lines) + '\n'
+
+ if cli.args.output:
+ cli.args.output.parent.mkdir(parents=True, exist_ok=True)
+ if cli.args.output.exists():
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
+ cli.args.output.write_text(keyboard_h)
+
+ if not cli.args.quiet:
+ cli.log.info('Wrote keyboard_h to %s.', cli.args.output)
+
+ else:
+ print(keyboard_h)
diff --git a/lib/python/qmk/cli/generate/layouts.py b/lib/python/qmk/cli/generate/layouts.py
new file mode 100755
index 0000000000..ad6946d6cf
--- /dev/null
+++ b/lib/python/qmk/cli/generate/layouts.py
@@ -0,0 +1,103 @@
+"""Used by the make system to generate layouts.h from info.json.
+"""
+from milc import cli
+
+from qmk.constants import COL_LETTERS, ROW_LETTERS
+from qmk.decorators import automagic_keyboard, automagic_keymap
+from qmk.info import info_json
+from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.path import is_keyboard, normpath
+
+usb_properties = {
+ 'vid': 'VENDOR_ID',
+ 'pid': 'PRODUCT_ID',
+ 'device_ver': 'DEVICE_VER',
+}
+
+
+@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
+@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate config.h for.')
+@cli.subcommand('Used by the make system to generate layouts.h from info.json', hidden=True)
+@automagic_keyboard
+@automagic_keymap
+def generate_layouts(cli):
+ """Generates the layouts.h file.
+ """
+ # Determine our keyboard(s)
+ if not cli.config.generate_layouts.keyboard:
+ cli.log.error('Missing parameter: --keyboard')
+ cli.subcommands['info'].print_help()
+ return False
+
+ if not is_keyboard(cli.config.generate_layouts.keyboard):
+ cli.log.error('Invalid keyboard: "%s"', cli.config.generate_layouts.keyboard)
+ return False
+
+ # Build the info.json file
+ kb_info_json = info_json(cli.config.generate_layouts.keyboard)
+
+ # Build the layouts.h file.
+ layouts_h_lines = ['/* This file was generated by `qmk generate-layouts`. Do not edit or copy.' ' */', '', '#pragma once']
+
+ if 'matrix_pins' in kb_info_json:
+ if 'direct' in kb_info_json['matrix_pins']:
+ col_num = len(kb_info_json['matrix_pins']['direct'][0])
+ row_num = len(kb_info_json['matrix_pins']['direct'])
+ elif 'cols' in kb_info_json['matrix_pins'] and 'rows' in kb_info_json['matrix_pins']:
+ col_num = len(kb_info_json['matrix_pins']['cols'])
+ row_num = len(kb_info_json['matrix_pins']['rows'])
+ else:
+ cli.log.error('%s: Invalid matrix config.', cli.config.generate_layouts.keyboard)
+ return False
+
+ for layout_name in kb_info_json['layouts']:
+ if kb_info_json['layouts'][layout_name]['c_macro']:
+ continue
+
+ if 'matrix' not in kb_info_json['layouts'][layout_name]['layout'][0]:
+ cli.log.debug('%s/%s: No matrix data!', cli.config.generate_layouts.keyboard, layout_name)
+ continue
+
+ layout_keys = []
+ layout_matrix = [['KC_NO' for i in range(col_num)] for i in range(row_num)]
+
+ for i, key in enumerate(kb_info_json['layouts'][layout_name]['layout']):
+ row = key['matrix'][0]
+ col = key['matrix'][1]
+ identifier = 'k%s%s' % (ROW_LETTERS[row], COL_LETTERS[col])
+
+ try:
+ layout_matrix[row][col] = identifier
+ layout_keys.append(identifier)
+ except IndexError:
+ key_name = key.get('label', identifier)
+ cli.log.error('Matrix data out of bounds for layout %s at index %s (%s): %s, %s', layout_name, i, key_name, row, col)
+ return False
+
+ layouts_h_lines.append('')
+ layouts_h_lines.append('#define %s(%s) {\\' % (layout_name, ', '.join(layout_keys)))
+
+ rows = ', \\\n'.join(['\t {' + ', '.join(row) + '}' for row in layout_matrix])
+ rows += ' \\'
+ layouts_h_lines.append(rows)
+ layouts_h_lines.append('}')
+
+ for alias, target in kb_info_json.get('layout_aliases', {}).items():
+ layouts_h_lines.append('')
+ layouts_h_lines.append('#define %s %s' % (alias, target))
+
+ # Show the results
+ layouts_h = '\n'.join(layouts_h_lines) + '\n'
+
+ if cli.args.output:
+ cli.args.output.parent.mkdir(parents=True, exist_ok=True)
+ if cli.args.output.exists():
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
+ cli.args.output.write_text(layouts_h)
+
+ if not cli.args.quiet:
+ cli.log.info('Wrote info_config.h to %s.', cli.args.output)
+
+ else:
+ print(layouts_h)
diff --git a/lib/python/qmk/cli/generate/rgb_breathe_table.py b/lib/python/qmk/cli/generate/rgb_breathe_table.py
index e1c5423ee5..7382abd68b 100644
--- a/lib/python/qmk/cli/generate/rgb_breathe_table.py
+++ b/lib/python/qmk/cli/generate/rgb_breathe_table.py
@@ -70,7 +70,7 @@ static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table);
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
- cli.args.output.replace(cli.args.output.name + '.bak')
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(table_template)
if not cli.args.quiet:
diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py
new file mode 100755
index 0000000000..41c94e16b5
--- /dev/null
+++ b/lib/python/qmk/cli/generate/rules_mk.py
@@ -0,0 +1,97 @@
+"""Used by the make system to generate a rules.mk
+"""
+from pathlib import Path
+
+from dotty_dict import dotty
+from milc import cli
+
+from qmk.decorators import automagic_keyboard, automagic_keymap
+from qmk.info import info_json
+from qmk.json_schema import json_load
+from qmk.keyboard import keyboard_completer, keyboard_folder
+from qmk.path import is_keyboard, normpath
+
+
+def process_mapping_rule(kb_info_json, rules_key, info_dict):
+ """Return the rules.mk line(s) for a mapping rule.
+ """
+ if not info_dict.get('to_c', True):
+ return None
+
+ info_key = info_dict['info_key']
+ key_type = info_dict.get('value_type', 'str')
+
+ try:
+ rules_value = kb_info_json[info_key]
+ except KeyError:
+ return None
+
+ if key_type == 'array':
+ return f'{rules_key} ?= {" ".join(rules_value)}'
+ elif key_type == 'bool':
+ return f'{rules_key} ?= {"on" if rules_value else "off"}'
+ elif key_type == 'mapping':
+ return '\n'.join([f'{key} ?= {value}' for key, value in rules_value.items()])
+
+ return f'{rules_key} ?= {rules_value}'
+
+
+@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
+@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
+@cli.argument('-e', '--escape', arg_only=True, action='store_true', help="Escape spaces in quiet mode")
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate config.h for.')
+@cli.subcommand('Used by the make system to generate info_config.h from info.json', hidden=True)
+@automagic_keyboard
+@automagic_keymap
+def generate_rules_mk(cli):
+ """Generates a rules.mk file from info.json.
+ """
+ if not cli.config.generate_rules_mk.keyboard:
+ cli.log.error('Missing parameter: --keyboard')
+ cli.subcommands['info'].print_help()
+ return False
+
+ if not is_keyboard(cli.config.generate_rules_mk.keyboard):
+ cli.log.error('Invalid keyboard: "%s"', cli.config.generate_rules_mk.keyboard)
+ return False
+
+ kb_info_json = dotty(info_json(cli.config.generate_rules_mk.keyboard))
+ info_rules_map = json_load(Path('data/mappings/info_rules.json'))
+ rules_mk_lines = ['# This file was generated by `qmk generate-rules-mk`. Do not edit or copy.', '']
+
+ # Iterate through the info_rules map to generate basic rules
+ for rules_key, info_dict in info_rules_map.items():
+ new_entry = process_mapping_rule(kb_info_json, rules_key, info_dict)
+
+ if new_entry:
+ rules_mk_lines.append(new_entry)
+
+ # Iterate through features to enable/disable them
+ if 'features' in kb_info_json:
+ for feature, enabled in kb_info_json['features'].items():
+ if feature == 'bootmagic_lite' and enabled:
+ rules_mk_lines.append('BOOTMAGIC_ENABLE ?= lite')
+ else:
+ feature = feature.upper()
+ enabled = 'yes' if enabled else 'no'
+ rules_mk_lines.append(f'{feature}_ENABLE ?= {enabled}')
+
+ # Show the results
+ rules_mk = '\n'.join(rules_mk_lines) + '\n'
+
+ if cli.args.output:
+ cli.args.output.parent.mkdir(parents=True, exist_ok=True)
+ if cli.args.output.exists():
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
+ cli.args.output.write_text(rules_mk)
+
+ if cli.args.quiet:
+ if cli.args.escape:
+ print(cli.args.output.as_posix().replace(' ', '\\ '))
+ else:
+ print(cli.args.output)
+ else:
+ cli.log.info('Wrote rules.mk to %s.', cli.args.output)
+
+ else:
+ print(rules_mk)
diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py
index 9ab299a21e..0d08d242cd 100755
--- a/lib/python/qmk/cli/info.py
+++ b/lib/python/qmk/cli/info.py
@@ -2,21 +2,20 @@
Compile an info.json for a particular keyboard and pretty-print it.
"""
+import sys
import json
-import platform
from milc import cli
+from qmk.json_encoders import InfoJSONEncoder
+from qmk.constants import COL_LETTERS, ROW_LETTERS
from qmk.decorators import automagic_keyboard, automagic_keymap
-from qmk.keyboard import render_layouts, render_layout
+from qmk.keyboard import keyboard_completer, keyboard_folder, render_layouts, render_layout, rules_mk
from qmk.keymap import locate_keymap
from qmk.info import info_json
from qmk.path import is_keyboard
-platform_id = platform.platform().lower()
-
-ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
-COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz'
+UNICODE_SUPPORT = sys.stdout.encoding.lower().startswith('utf')
def show_keymap(kb_info_json, title_caps=True):
@@ -30,7 +29,7 @@ def show_keymap(kb_info_json, title_caps=True):
else:
cli.echo('{fg_blue}keymap_%s{fg_reset}:', cli.config.info.keymap)
- keymap_data = json.load(keymap_path.open())
+ keymap_data = json.load(keymap_path.open(encoding='utf-8'))
layout_name = keymap_data['layout']
for layer_num, layer in enumerate(keymap_data['layers']):
@@ -58,7 +57,7 @@ def show_matrix(kb_info_json, title_caps=True):
# Build our label list
labels = []
for key in layout['layout']:
- if key['matrix']:
+ if 'matrix' in key:
row = ROW_LETTERS[key['matrix'][0]]
col = COL_LETTERS[key['matrix'][1]]
@@ -92,6 +91,9 @@ def print_friendly_output(kb_info_json):
cli.echo('{fg_blue}Size{fg_reset}: %s x %s' % (kb_info_json['width'], kb_info_json['height']))
cli.echo('{fg_blue}Processor{fg_reset}: %s', kb_info_json.get('processor', 'Unknown'))
cli.echo('{fg_blue}Bootloader{fg_reset}: %s', kb_info_json.get('bootloader', 'Unknown'))
+ if 'layout_aliases' in kb_info_json:
+ aliases = [f'{key}={value}' for key, value in kb_info_json['layout_aliases'].items()]
+ cli.echo('{fg_blue}Layout aliases:{fg_reset} %s' % (', '.join(aliases),))
if cli.config.info.layouts:
show_layouts(kb_info_json, True)
@@ -122,12 +124,20 @@ def print_text_output(kb_info_json):
show_keymap(kb_info_json, False)
-@cli.argument('-kb', '--keyboard', help='Keyboard to show info for.')
+def print_parsed_rules_mk(keyboard_name):
+ rules = rules_mk(keyboard_name)
+ for k in sorted(rules.keys()):
+ print('%s = %s' % (k, rules[k]))
+ return
+
+
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to show info for.')
@cli.argument('-km', '--keymap', help='Show the layers for a JSON keymap too.')
@cli.argument('-l', '--layouts', action='store_true', help='Render the layouts.')
@cli.argument('-m', '--matrix', action='store_true', help='Render the layouts with matrix information.')
@cli.argument('-f', '--format', default='friendly', arg_only=True, help='Format to display the data in (friendly, text, json) (Default: friendly).')
-@cli.argument('--ascii', action='store_true', default='windows' in platform_id, help='Render layout box drawings in ASCII only.')
+@cli.argument('--ascii', action='store_true', default=not UNICODE_SUPPORT, help='Render layout box drawings in ASCII only.')
+@cli.argument('-r', '--rules-mk', action='store_true', help='Render the parsed values of the keyboard\'s rules.mk file.')
@cli.subcommand('Keyboard information.')
@automagic_keyboard
@automagic_keymap
@@ -144,12 +154,16 @@ def info(cli):
cli.log.error('Invalid keyboard: "%s"', cli.config.info.keyboard)
return False
+ if bool(cli.args.rules_mk):
+ print_parsed_rules_mk(cli.config.info.keyboard)
+ return False
+
# Build the info.json file
kb_info_json = info_json(cli.config.info.keyboard)
# Output in the requested format
if cli.args.format == 'json':
- print(json.dumps(kb_info_json))
+ print(json.dumps(kb_info_json, cls=InfoJSONEncoder))
elif cli.args.format == 'text':
print_text_output(kb_info_json)
elif cli.args.format == 'friendly':
diff --git a/lib/python/qmk/cli/json2c.py b/lib/python/qmk/cli/json2c.py
index 97d8fb0c33..a90578c021 100755
--- a/lib/python/qmk/cli/json2c.py
+++ b/lib/python/qmk/cli/json2c.py
@@ -1,8 +1,8 @@
"""Generate a keymap.c from a configurator export.
"""
import json
-import sys
+from argcomplete.completers import FilesCompleter
from milc import cli
import qmk.keymap
@@ -11,7 +11,7 @@ import qmk.path
@cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
-@cli.argument('filename', type=qmk.path.normpath, arg_only=True, help='Configurator JSON file')
+@cli.argument('filename', type=qmk.path.FileType('r'), arg_only=True, completer=FilesCompleter('.json'), help='Configurator JSON file')
@cli.subcommand('Creates a keymap.c from a QMK Configurator export.')
def json2c(cli):
"""Generate a keymap.c from a configurator export.
@@ -20,19 +20,8 @@ def json2c(cli):
"""
try:
- # Parse the configurator from stdin
- if cli.args.filename and cli.args.filename.name == '-':
- user_keymap = json.load(sys.stdin)
-
- else:
- # Error checking
- if not cli.args.filename.exists():
- cli.log.error('JSON file does not exist!')
- return False
-
- # Parse the configurator json file
- else:
- user_keymap = json.loads(cli.args.filename.read_text())
+ # Parse the configurator from json file (or stdin)
+ user_keymap = json.load(cli.args.filename)
except json.decoder.JSONDecodeError as ex:
cli.log.error('The JSON input does not appear to be valid.')
@@ -49,7 +38,7 @@ def json2c(cli):
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
- cli.args.output.replace(cli.args.output.name + '.bak')
+ cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(keymap_c)
if not cli.args.quiet:
diff --git a/lib/python/qmk/cli/kle2json.py b/lib/python/qmk/cli/kle2json.py
index 3d1bb8c43c..acb75ef4fd 100755
--- a/lib/python/qmk/cli/kle2json.py
+++ b/lib/python/qmk/cli/kle2json.py
@@ -3,28 +3,16 @@
import json
import os
from pathlib import Path
-from decimal import Decimal
-from collections import OrderedDict
+from argcomplete.completers import FilesCompleter
from milc import cli
from kle2xy import KLE2xy
from qmk.converter import kle2qmk
+from qmk.json_encoders import InfoJSONEncoder
-class CustomJSONEncoder(json.JSONEncoder):
- def default(self, obj):
- try:
- if isinstance(obj, Decimal):
- if obj % 2 in (Decimal(0), Decimal(1)):
- return int(obj)
- return float(obj)
- except TypeError:
- pass
- return json.JSONEncoder.default(self, obj)
-
-
-@cli.argument('filename', help='The KLE raw txt to convert')
+@cli.argument('filename', completer=FilesCompleter('.json'), help='The KLE raw txt to convert')
@cli.argument('-f', '--force', action='store_true', help='Flag to overwrite current info.json')
@cli.subcommand('Convert a KLE layout to a Configurator JSON', hidden=False if cli.config.user.developer else True)
def kle2json(cli):
@@ -40,7 +28,7 @@ def kle2json(cli):
cli.log.error('File {fg_cyan}%s{style_reset_all} was not found.', file_path)
return False
out_path = file_path.parent
- raw_code = file_path.open().read()
+ raw_code = file_path.read_text(encoding='utf-8')
# Check if info.json exists, allow overwrite with force
if Path(out_path, "info.json").exists() and not cli.args.force:
cli.log.error('File {fg_cyan}%s/info.json{style_reset_all} already exists, use -f or --force to overwrite.', out_path)
@@ -52,24 +40,22 @@ def kle2json(cli):
cli.log.error('Could not parse KLE raw data: %s', raw_code)
cli.log.exception(e)
return False
- keyboard = OrderedDict(
- keyboard_name=kle.name,
- url='',
- maintainer='qmk',
- width=kle.columns,
- height=kle.rows,
- layouts={'LAYOUT': {
- 'layout': 'LAYOUT_JSON_HERE'
- }},
- )
- # Initialize keyboard with json encoded from ordered dict
- keyboard = json.dumps(keyboard, indent=4, separators=(', ', ': '), sort_keys=False, cls=CustomJSONEncoder)
- # Initialize layout with kle2qmk from converter module
- layout = json.dumps(kle2qmk(kle), separators=(', ', ':'), cls=CustomJSONEncoder)
- # Replace layout in keyboard json
- keyboard = keyboard.replace('"LAYOUT_JSON_HERE"', layout)
+ keyboard = {
+ 'keyboard_name': kle.name,
+ 'url': '',
+ 'maintainer': 'qmk',
+ 'width': kle.columns,
+ 'height': kle.rows,
+ 'layouts': {
+ 'LAYOUT': {
+ 'layout': kle2qmk(kle)
+ }
+ },
+ }
+
# Write our info.json
- file = open(out_path / "info.json", "w")
- file.write(keyboard)
- file.close()
+ keyboard = json.dumps(keyboard, indent=4, separators=(', ', ': '), sort_keys=False, cls=InfoJSONEncoder)
+ info_json_file = out_path / 'info.json'
+
+ info_json_file.write_text(keyboard)
cli.log.info('Wrote out {fg_cyan}%s/info.json', out_path)
diff --git a/lib/python/qmk/cli/lint.py b/lib/python/qmk/cli/lint.py
index 74467021e0..a164dba632 100644
--- a/lib/python/qmk/cli/lint.py
+++ b/lib/python/qmk/cli/lint.py
@@ -4,12 +4,13 @@ from milc import cli
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.info import info_json
+from qmk.keyboard import keyboard_completer
from qmk.keymap import locate_keymap
from qmk.path import is_keyboard, keyboard
@cli.argument('--strict', action='store_true', help='Treat warnings as errors.')
-@cli.argument('-kb', '--keyboard', help='The keyboard to check.')
+@cli.argument('-kb', '--keyboard', completer=keyboard_completer, help='The keyboard to check.')
@cli.argument('-km', '--keymap', help='The keymap to check.')
@cli.subcommand('Check keyboard and keymap for common mistakes.')
@automagic_keyboard
diff --git a/lib/python/qmk/cli/list/keymaps.py b/lib/python/qmk/cli/list/keymaps.py
index 49bc84b2ce..d79ab75b58 100644
--- a/lib/python/qmk/cli/list/keymaps.py
+++ b/lib/python/qmk/cli/list/keymaps.py
@@ -4,18 +4,14 @@ from milc import cli
import qmk.keymap
from qmk.decorators import automagic_keyboard
-from qmk.path import is_keyboard
+from qmk.keyboard import keyboard_completer, keyboard_folder
-@cli.argument("-kb", "--keyboard", help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
+@cli.argument("-kb", "--keyboard", type=keyboard_folder, completer=keyboard_completer, help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
@cli.subcommand("List the keymaps for a specific keyboard")
@automagic_keyboard
def list_keymaps(cli):
"""List the keymaps for a specific keyboard
"""
- if not is_keyboard(cli.config.list_keymaps.keyboard):
- cli.log.error('Keyboard %s does not exist!', cli.config.list_keymaps.keyboard)
- return False
-
for name in qmk.keymap.list_keymaps(cli.config.list_keymaps.keyboard):
print(name)
diff --git a/lib/python/qmk/cli/multibuild.py b/lib/python/qmk/cli/multibuild.py
new file mode 100755
index 0000000000..46594c0997
--- /dev/null
+++ b/lib/python/qmk/cli/multibuild.py
@@ -0,0 +1,79 @@
+"""Compile all keyboards.
+
+This will compile everything in parallel, for testing purposes.
+"""
+import re
+from pathlib import Path
+from subprocess import DEVNULL
+
+from milc import cli
+
+from qmk.constants import QMK_FIRMWARE
+from qmk.commands import _find_make
+import qmk.keyboard
+
+
+def _make_rules_mk_filter(key, value):
+ def _rules_mk_filter(keyboard_name):
+ rules_mk = qmk.keyboard.rules_mk(keyboard_name)
+ return True if key in rules_mk and rules_mk[key].lower() == str(value).lower() else False
+
+ return _rules_mk_filter
+
+
+def _is_split(keyboard_name):
+ rules_mk = qmk.keyboard.rules_mk(keyboard_name)
+ return True if 'SPLIT_KEYBOARD' in rules_mk and rules_mk['SPLIT_KEYBOARD'].lower() == 'yes' else False
+
+
+@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs to run.")
+@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
+@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on the supplied value in rules.mk. Supported format is 'SPLIT_KEYBOARD=yes'. May be passed multiple times.")
+@cli.subcommand('Compile QMK Firmware for all keyboards.', hidden=False if cli.config.user.developer else True)
+def multibuild(cli):
+ """Compile QMK Firmware against all keyboards.
+ """
+
+ make_cmd = _find_make()
+ if cli.args.clean:
+ cli.run([make_cmd, 'clean'], capture_output=False, stdin=DEVNULL)
+
+ builddir = Path(QMK_FIRMWARE) / '.build'
+ makefile = builddir / 'parallel_kb_builds.mk'
+
+ keyboard_list = qmk.keyboard.list_keyboards()
+
+ filter_re = re.compile(r'^(?P<key>[A-Z0-9_]+)\s*=\s*(?P<value>[^#]+)$')
+ for filter_txt in cli.args.filter:
+ f = filter_re.match(filter_txt)
+ if f is not None:
+ keyboard_list = filter(_make_rules_mk_filter(f.group('key'), f.group('value')), keyboard_list)
+
+ keyboard_list = list(sorted(keyboard_list))
+
+ if len(keyboard_list) == 0:
+ return
+
+ builddir.mkdir(parents=True, exist_ok=True)
+ with open(makefile, "w") as f:
+ for keyboard_name in keyboard_list:
+ keyboard_safe = keyboard_name.replace('/', '_')
+ # yapf: disable
+ f.write(
+ f"""\
+all: {keyboard_safe}_binary
+{keyboard_safe}_binary:
+ @rm -f "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}" || true
+ +@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="default" REQUIRE_PLATFORM_KEY= COLOR=true SILENT=false \\
+ >>"{QMK_FIRMWARE}/.build/build.log.{keyboard_safe}" 2>&1 \\
+ || cp "{QMK_FIRMWARE}/.build/build.log.{keyboard_safe}" "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}"
+ @{{ grep '\[ERRORS\]' "{QMK_FIRMWARE}/.build/build.log.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:default" ; }} \\
+ || {{ grep '\[WARNINGS\]' "{QMK_FIRMWARE}/.build/build.log.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;33m[WARNINGS]\e[0m\\n" "{keyboard_name}:default" ; }} \\
+ || printf "Build %-64s \e[1;32m[OK]\e[0m\\n" "{keyboard_name}:default"
+ @rm -f "{QMK_FIRMWARE}/.build/build.log.{keyboard_safe}" || true
+
+"""# noqa
+ )
+ # yapf: enable
+
+ cli.run([make_cmd, '-j', str(cli.args.parallel), '-f', makefile, 'all'], capture_output=False, stdin=DEVNULL)
diff --git a/lib/python/qmk/cli/new/__init__.py b/lib/python/qmk/cli/new/__init__.py
index c6a26939b8..fe5d6fe483 100644
--- a/lib/python/qmk/cli/new/__init__.py
+++ b/lib/python/qmk/cli/new/__init__.py
@@ -1 +1,2 @@
+from . import keyboard
from . import keymap
diff --git a/lib/python/qmk/cli/new/keyboard.py b/lib/python/qmk/cli/new/keyboard.py
new file mode 100644
index 0000000000..ae4445ca48
--- /dev/null
+++ b/lib/python/qmk/cli/new/keyboard.py
@@ -0,0 +1,11 @@
+"""This script automates the creation of keyboards.
+"""
+from milc import cli
+
+
+@cli.subcommand('Creates a new keyboard')
+def new_keyboard(cli):
+ """Creates a new keyboard
+ """
+ # TODO: replace this bodge to the existing script
+ cli.run(['util/new_keyboard.sh'], stdin=None, capture_output=False)
diff --git a/lib/python/qmk/cli/new/keymap.py b/lib/python/qmk/cli/new/keymap.py
index 52c564997b..60cb743cb6 100755
--- a/lib/python/qmk/cli/new/keymap.py
+++ b/lib/python/qmk/cli/new/keymap.py
@@ -5,10 +5,11 @@ from pathlib import Path
import qmk.path
from qmk.decorators import automagic_keyboard, automagic_keymap
+from qmk.keyboard import keyboard_completer, keyboard_folder
from milc import cli
-@cli.argument('-kb', '--keyboard', help='Specify keyboard name. Example: 1upkeyboards/1up60hse')
+@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Specify keyboard name. Example: 1upkeyboards/1up60hse')
@cli.argument('-km', '--keymap', help='Specify the name for the new keymap directory')
@cli.subcommand('Creates a new keymap for the keyboard of your choosing')
@automagic_keyboard
diff --git a/lib/python/qmk/cli/pyformat.py b/lib/python/qmk/cli/pyformat.py
index 1464443804..abe5f6de19 100755
--- a/lib/python/qmk/cli/pyformat.py
+++ b/lib/python/qmk/cli/pyformat.py
@@ -1,17 +1,26 @@
"""Format python code according to QMK's style.
"""
-from milc import cli
+from subprocess import CalledProcessError, DEVNULL
-import subprocess
+from milc import cli
+@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Flag only, don't automatically format.")
@cli.subcommand("Format python code according to QMK's style.", hidden=False if cli.config.user.developer else True)
def pyformat(cli):
"""Format python code according to QMK's style.
"""
+ edit = '--diff' if cli.args.dry_run else '--in-place'
+ yapf_cmd = ['yapf', '-vv', '--recursive', edit, 'bin/qmk', 'lib/python']
try:
- subprocess.run(['yapf', '-vv', '-ri', 'bin/qmk', 'lib/python'], check=True)
- cli.log.info('Successfully formatted the python code in `bin/qmk` and `lib/python`.')
+ cli.run(yapf_cmd, check=True, capture_output=False, stdin=DEVNULL)
+ cli.log.info('Python code in `bin/qmk` and `lib/python` is correctly formatted.')
+ return True
+
+ except CalledProcessError:
+ if cli.args.dry_run:
+ cli.log.error('Python code in `bin/qmk` and `lib/python` incorrectly formatted!')
+ else:
+ cli.log.error('Error formatting python code!')
- except subprocess.CalledProcessError:
- cli.log.error('Error formatting python code!')
+ return False
diff --git a/lib/python/qmk/cli/pytest.py b/lib/python/qmk/cli/pytest.py
index 5417a9cb34..bdb336b9a7 100644
--- a/lib/python/qmk/cli/pytest.py
+++ b/lib/python/qmk/cli/pytest.py
@@ -2,7 +2,7 @@
QMK script to run unit and integration tests against our python code.
"""
-import subprocess
+from subprocess import DEVNULL
from milc import cli
@@ -11,6 +11,7 @@ from milc import cli
def pytest(cli):
"""Run several linting/testing commands.
"""
- flake8 = subprocess.run(['flake8', 'lib/python', 'bin/qmk'])
- nose2 = subprocess.run(['nose2', '-v'])
+ nose2 = cli.run(['nose2', '-v'], capture_output=False, stdin=DEVNULL)
+ flake8 = cli.run(['flake8', 'lib/python', 'bin/qmk'], capture_output=False, stdin=DEVNULL)
+
return flake8.returncode | nose2.returncode
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py
index 3c6f0d001d..ee049e8af7 100644
--- a/lib/python/qmk/commands.py
+++ b/lib/python/qmk/commands.py
@@ -2,17 +2,16 @@
"""
import json
import os
-import platform
-import subprocess
-import shlex
import shutil
from pathlib import Path
+from subprocess import DEVNULL
from time import strftime
from milc import cli
import qmk.keymap
from qmk.constants import KEYBOARD_OUTPUT_PREFIX
+from qmk.json_schema import json_load
time_fmt = '%Y-%m-%d-%H:%M:%S'
@@ -28,6 +27,33 @@ def _find_make():
return make_cmd
+def create_make_target(target, parallel=1, **env_vars):
+ """Create a make command
+
+ Args:
+
+ target
+ Usually a make rule, such as 'clean' or 'all'.
+
+ parallel
+ The number of make jobs to run in parallel
+
+ **env_vars
+ Environment variables to be passed to make.
+
+ Returns:
+
+ A command that can be run to make the specified keyboard and keymap
+ """
+ env = []
+ make_cmd = _find_make()
+
+ for key, value in env_vars.items():
+ env.append(f'{key}={value}')
+
+ return [make_cmd, '-j', str(parallel), *env, target]
+
+
def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars):
"""Create a make compile command
@@ -52,17 +78,12 @@ def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars):
A command that can be run to make the specified keyboard and keymap
"""
- env = []
make_args = [keyboard, keymap]
- make_cmd = _find_make()
if target:
make_args.append(target)
- for key, value in env_vars.items():
- env.append(f'{key}={value}')
-
- return [make_cmd, '-j', str(parallel), *env, ':'.join(make_args)]
+ return create_make_target(':'.join(make_args), parallel, **env_vars)
def get_git_version(repo_dir='.', check_dir='.'):
@@ -71,13 +92,13 @@ def get_git_version(repo_dir='.', check_dir='.'):
git_describe_cmd = ['git', 'describe', '--abbrev=6', '--dirty', '--always', '--tags']
if Path(check_dir).exists():
- git_describe = cli.run(git_describe_cmd, cwd=repo_dir)
+ git_describe = cli.run(git_describe_cmd, stdin=DEVNULL, cwd=repo_dir)
if git_describe.returncode == 0:
return git_describe.stdout.strip()
else:
- cli.args.warn(f'"{" ".join(git_describe_cmd)}" returned error code {git_describe.returncode}')
+ cli.log.warn(f'"{" ".join(git_describe_cmd)}" returned error code {git_describe.returncode}')
print(git_describe.stderr)
return strftime(time_fmt)
@@ -190,22 +211,14 @@ def parse_configurator_json(configurator_file):
"""
# FIXME(skullydazed/anyone): Add validation here
user_keymap = json.load(configurator_file)
+ orig_keyboard = user_keymap['keyboard']
+ aliases = json_load(Path('data/mappings/keyboard_aliases.json'))
- return user_keymap
-
+ if orig_keyboard in aliases:
+ if 'target' in aliases[orig_keyboard]:
+ user_keymap['keyboard'] = aliases[orig_keyboard]['target']
-def run(command, *args, **kwargs):
- """Run a command with subprocess.run
- """
- platform_id = platform.platform().lower()
-
- if isinstance(command, str):
- raise TypeError('`command` must be a non-text sequence such as list or tuple.')
+ if 'layouts' in aliases[orig_keyboard] and user_keymap['layout'] in aliases[orig_keyboard]['layouts']:
+ user_keymap['layout'] = aliases[orig_keyboard]['layouts'][user_keymap['layout']]
- if 'windows' in platform_id:
- safecmd = map(str, command)
- safecmd = map(shlex.quote, safecmd)
- safecmd = ' '.join(safecmd)
- command = [os.environ['SHELL'], '-c', safecmd]
-
- return subprocess.run(command, *args, **kwargs)
+ return user_keymap
diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py
index 2ddaa568a2..3ed69f3bf9 100644
--- a/lib/python/qmk/constants.py
+++ b/lib/python/qmk/constants.py
@@ -10,8 +10,8 @@ QMK_FIRMWARE = Path.cwd()
MAX_KEYBOARD_SUBFOLDERS = 5
# Supported processor types
-CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F411'
-LUFA_PROCESSORS = 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
+CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F411', 'STM32G431', 'STM32G474'
+LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
# Common format strings
@@ -19,6 +19,17 @@ DATE_FORMAT = '%Y-%m-%d'
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
TIME_FORMAT = '%H:%M:%S'
+# Used when generating matrix locations
+COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz'
+ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
+
+# Mapping between info.json and config.h keys
+LED_INDICATORS = {
+ 'caps_lock': 'LED_CAPS_LOCK_PIN',
+ 'num_lock': 'LED_NUM_LOCK_PIN',
+ 'scroll_lock': 'LED_SCROLL_LOCK_PIN',
+}
+
# Constants that should match their counterparts in make
BUILD_DIR = environ.get('BUILD_DIR', '.build')
KEYBOARD_OUTPUT_PREFIX = f'{BUILD_DIR}/obj_'
diff --git a/lib/python/qmk/decorators.py b/lib/python/qmk/decorators.py
index 629402b095..8d43ae980f 100644
--- a/lib/python/qmk/decorators.py
+++ b/lib/python/qmk/decorators.py
@@ -1,13 +1,12 @@
"""Helpful decorators that subcommands can use.
"""
import functools
-from pathlib import Path
from time import monotonic
from milc import cli
-from qmk.keymap import is_keymap_dir
-from qmk.path import is_keyboard, under_qmk_firmware
+from qmk.keyboard import find_keyboard_from_dir
+from qmk.keymap import find_keymap_from_dir
def automagic_keyboard(func):
@@ -17,27 +16,13 @@ def automagic_keyboard(func):
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
- # Check to make sure their copy of MILC supports config_source
- if not hasattr(cli, 'config_source'):
- cli.log.error("This subcommand requires a newer version of the QMK CLI. Please upgrade using `pip3 install --upgrade qmk` or your package manager.")
- exit(1)
-
# Ensure that `--keyboard` was not passed and CWD is under `qmk_firmware/keyboards`
if cli.config_source[cli._entrypoint.__name__]['keyboard'] != 'argument':
- relative_cwd = under_qmk_firmware()
-
- if relative_cwd and len(relative_cwd.parts) > 1 and relative_cwd.parts[0] == 'keyboards':
- # Attempt to extract the keyboard name from the current directory
- current_path = Path('/'.join(relative_cwd.parts[1:]))
-
- if 'keymaps' in current_path.parts:
- # Strip current_path of anything after `keymaps`
- keymap_index = len(current_path.parts) - current_path.parts.index('keymaps') - 1
- current_path = current_path.parents[keymap_index]
+ keyboard = find_keyboard_from_dir()
- if is_keyboard(current_path):
- cli.config[cli._entrypoint.__name__]['keyboard'] = str(current_path)
- cli.config_source[cli._entrypoint.__name__]['keyboard'] = 'keyboard_directory'
+ if keyboard:
+ cli.config[cli._entrypoint.__name__]['keyboard'] = keyboard
+ cli.config_source[cli._entrypoint.__name__]['keyboard'] = 'keyboard_directory'
return func(*args, **kwargs)
@@ -51,36 +36,13 @@ def automagic_keymap(func):
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
- # Check to make sure their copy of MILC supports config_source
- if not hasattr(cli, 'config_source'):
- cli.log.error("This subcommand requires a newer version of the QMK CLI. Please upgrade using `pip3 install --upgrade qmk` or your package manager.")
- exit(1)
-
# Ensure that `--keymap` was not passed and that we're under `qmk_firmware`
if cli.config_source[cli._entrypoint.__name__]['keymap'] != 'argument':
- relative_cwd = under_qmk_firmware()
-
- if relative_cwd and len(relative_cwd.parts) > 1:
- # If we're in `qmk_firmware/keyboards` and `keymaps` is in our path, try to find the keyboard name.
- if relative_cwd.parts[0] == 'keyboards' and 'keymaps' in relative_cwd.parts:
- current_path = Path('/'.join(relative_cwd.parts[1:])) # Strip 'keyboards' from the front
-
- if 'keymaps' in current_path.parts and current_path.name != 'keymaps':
- while current_path.parent.name != 'keymaps':
- current_path = current_path.parent
- cli.config[cli._entrypoint.__name__]['keymap'] = current_path.name
- cli.config_source[cli._entrypoint.__name__]['keymap'] = 'keymap_directory'
-
- # If we're in `qmk_firmware/layouts` guess the name from the community keymap they're in
- elif relative_cwd.parts[0] == 'layouts' and is_keymap_dir(relative_cwd):
- cli.config[cli._entrypoint.__name__]['keymap'] = relative_cwd.name
- cli.config_source[cli._entrypoint.__name__]['keymap'] = 'layouts_directory'
-
- # If we're in `qmk_firmware/users` guess the name from the userspace they're in
- elif relative_cwd.parts[0] == 'users':
- # Guess the keymap name based on which userspace they're in
- cli.config[cli._entrypoint.__name__]['keymap'] = relative_cwd.parts[1]
- cli.config_source[cli._entrypoint.__name__]['keymap'] = 'users_directory'
+ keymap_name, keymap_type = find_keymap_from_dir()
+
+ if keymap_name:
+ cli.config[cli._entrypoint.__name__]['keymap'] = keymap_name
+ cli.config_source[cli._entrypoint.__name__]['keymap'] = keymap_type
return func(*args, **kwargs)
diff --git a/lib/python/qmk/errors.py b/lib/python/qmk/errors.py
index 4a8a91556b..1317687821 100644
--- a/lib/python/qmk/errors.py
+++ b/lib/python/qmk/errors.py
@@ -3,3 +3,10 @@ class NoSuchKeyboardError(Exception):
"""
def __init__(self, message):
self.message = message
+
+
+class CppError(Exception):
+ """Raised when 'cpp' cannot process a file.
+ """
+ def __init__(self, message):
+ self.message = message
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index f476dc666d..47c8bff7a8 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -1,18 +1,29 @@
"""Functions that help us generate and use info.json files.
"""
-import json
from glob import glob
from pathlib import Path
+import jsonschema
+from dotty_dict import dotty
from milc import cli
from qmk.constants import CHIBIOS_PROCESSORS, LUFA_PROCESSORS, VUSB_PROCESSORS
from qmk.c_parse import find_layouts
+from qmk.json_schema import deep_update, json_load, keyboard_validate, keyboard_api_validate
from qmk.keyboard import config_h, rules_mk
from qmk.keymap import list_keymaps
from qmk.makefile import parse_rules_mk_file
from qmk.math import compute
+true_values = ['1', 'on', 'yes']
+false_values = ['0', 'off', 'no']
+
+
+def _valid_community_layout(layout):
+ """Validate that a declared community list exists
+ """
+ return (Path('layouts/default') / layout).exists()
+
def info_json(keyboard):
"""Generate the info.json data for a specific keyboard.
@@ -38,8 +49,14 @@ def info_json(keyboard):
info_data['keymaps'][keymap.name] = {'url': f'https://raw.githubusercontent.com/qmk/qmk_firmware/master/{keymap}/keymap.json'}
# Populate layout data
- for layout_name, layout_json in _find_all_layouts(info_data, keyboard, rules).items():
+ layouts, aliases = _find_all_layouts(info_data, keyboard)
+
+ if aliases:
+ info_data['layout_aliases'] = aliases
+
+ for layout_name, layout_json in layouts.items():
if not layout_name.startswith('LAYOUT_kc'):
+ layout_json['c_macro'] = True
info_data['layouts'][layout_name] = layout_json
# Merge in the data from info.json, config.h, and rules.mk
@@ -47,54 +64,211 @@ def info_json(keyboard):
info_data = _extract_config_h(info_data)
info_data = _extract_rules_mk(info_data)
+ # Validate against the jsonschema
+ try:
+ keyboard_api_validate(info_data)
+
+ except jsonschema.ValidationError as e:
+ json_path = '.'.join([str(p) for p in e.absolute_path])
+ cli.log.error('Invalid API data: %s: %s: %s', keyboard, json_path, e.message)
+ exit()
+
+ # Make sure we have at least one layout
+ if not info_data.get('layouts'):
+ _log_error(info_data, 'No LAYOUTs defined! Need at least one layout defined in the keyboard.h or info.json.')
+
+ # Filter out any non-existing community layouts
+ for layout in info_data.get('community_layouts', []):
+ if not _valid_community_layout(layout):
+ # Ignore layout from future checks
+ info_data['community_layouts'].remove(layout)
+ _log_error(info_data, 'Claims to support a community layout that does not exist: %s' % (layout))
+
+ # Make sure we supply layout macros for the community layouts we claim to support
+ for layout in info_data.get('community_layouts', []):
+ layout_name = 'LAYOUT_' + layout
+ if layout_name not in info_data.get('layouts', {}) and layout_name not in info_data.get('layout_aliases', {}):
+ _log_error(info_data, 'Claims to support community layout %s but no %s() macro found' % (layout, layout_name))
+
return info_data
-def _extract_config_h(info_data):
- """Pull some keyboard information from existing rules.mk files
+def _extract_features(info_data, rules):
+ """Find all the features enabled in rules.mk.
+ """
+ # Special handling for bootmagic which also supports a "lite" mode.
+ if rules.get('BOOTMAGIC_ENABLE') == 'lite':
+ rules['BOOTMAGIC_LITE_ENABLE'] = 'on'
+ del rules['BOOTMAGIC_ENABLE']
+ if rules.get('BOOTMAGIC_ENABLE') == 'full':
+ rules['BOOTMAGIC_ENABLE'] = 'on'
+
+ # Skip non-boolean features we haven't implemented special handling for
+ for feature in 'HAPTIC_ENABLE', 'QWIIC_ENABLE':
+ if rules.get(feature):
+ del rules[feature]
+
+ # Process the rest of the rules as booleans
+ for key, value in rules.items():
+ if key.endswith('_ENABLE'):
+ key = '_'.join(key.split('_')[:-1]).lower()
+ value = True if value.lower() in true_values else False if value.lower() in false_values else value
+
+ if 'config_h_features' not in info_data:
+ info_data['config_h_features'] = {}
+
+ if 'features' not in info_data:
+ info_data['features'] = {}
+
+ if key in info_data['features']:
+ _log_warning(info_data, 'Feature %s is specified in both info.json and rules.mk, the rules.mk value wins.' % (key,))
+
+ info_data['features'][key] = value
+ info_data['config_h_features'][key] = value
+
+ return info_data
+
+
+def _pin_name(pin):
+ """Returns the proper representation for a pin.
+ """
+ pin = pin.strip()
+
+ if not pin:
+ return None
+
+ elif pin.isdigit():
+ return int(pin)
+
+ elif pin == 'NO_PIN':
+ return None
+
+ elif pin[0] in 'ABCDEFGHIJK' and pin[1].isdigit():
+ return pin
+
+ raise ValueError(f'Invalid pin: {pin}')
+
+
+def _extract_pins(pins):
+ """Returns a list of pins from a comma separated string of pins.
+ """
+ return [_pin_name(pin) for pin in pins.split(',')]
+
+
+def _extract_direct_matrix(info_data, direct_pins):
+ """
+ """
+ info_data['matrix_pins'] = {}
+ direct_pin_array = []
+
+ while direct_pins[-1] != '}':
+ direct_pins = direct_pins[:-1]
+
+ for row in direct_pins.split('},{'):
+ if row.startswith('{'):
+ row = row[1:]
+
+ if row.endswith('}'):
+ row = row[:-1]
+
+ direct_pin_array.append([])
+
+ for pin in row.split(','):
+ if pin == 'NO_PIN':
+ pin = None
+
+ direct_pin_array[-1].append(pin)
+
+ return direct_pin_array
+
+
+def _extract_matrix_info(info_data, config_c):
+ """Populate the matrix information.
"""
- config_c = config_h(info_data['keyboard_folder'])
row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip()
col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip()
direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1]
- info_data['diode_direction'] = config_c.get('DIODE_DIRECTION')
- info_data['matrix_size'] = {
- 'rows': compute(config_c.get('MATRIX_ROWS', '0')),
- 'cols': compute(config_c.get('MATRIX_COLS', '0')),
- }
- info_data['matrix_pins'] = {}
+ if 'MATRIX_ROWS' in config_c and 'MATRIX_COLS' in config_c:
+ if 'matrix_size' in info_data:
+ _log_warning(info_data, 'Matrix size is specified in both info.json and config.h, the config.h values win.')
+
+ info_data['matrix_size'] = {
+ 'cols': compute(config_c.get('MATRIX_COLS', '0')),
+ 'rows': compute(config_c.get('MATRIX_ROWS', '0')),
+ }
- if row_pins:
- info_data['matrix_pins']['rows'] = row_pins.split(',')
- if col_pins:
- info_data['matrix_pins']['cols'] = col_pins.split(',')
+ if row_pins and col_pins:
+ if 'matrix_pins' in info_data:
+ _log_warning(info_data, 'Matrix pins are specified in both info.json and config.h, the config.h values win.')
+
+ info_data['matrix_pins'] = {
+ 'cols': _extract_pins(col_pins),
+ 'rows': _extract_pins(row_pins),
+ }
if direct_pins:
- direct_pin_array = []
- for row in direct_pins.split('},{'):
- if row.startswith('{'):
- row = row[1:]
- if row.endswith('}'):
- row = row[:-1]
+ if 'matrix_pins' in info_data:
+ _log_warning(info_data, 'Direct pins are specified in both info.json and config.h, the config.h values win.')
- direct_pin_array.append([])
+ info_data['matrix_pins']['direct'] = _extract_direct_matrix(info_data, direct_pins)
- for pin in row.split(','):
- if pin == 'NO_PIN':
- pin = None
+ return info_data
- direct_pin_array[-1].append(pin)
- info_data['matrix_pins']['direct'] = direct_pin_array
+def _extract_config_h(info_data):
+ """Pull some keyboard information from existing config.h files
+ """
+ config_c = config_h(info_data['keyboard_folder'])
- info_data['usb'] = {
- 'vid': config_c.get('VENDOR_ID'),
- 'pid': config_c.get('PRODUCT_ID'),
- 'device_ver': config_c.get('DEVICE_VER'),
- 'manufacturer': config_c.get('MANUFACTURER'),
- 'product': config_c.get('PRODUCT'),
- }
+ # Pull in data from the json map
+ dotty_info = dotty(info_data)
+ info_config_map = json_load(Path('data/mappings/info_config.json'))
+
+ for config_key, info_dict in info_config_map.items():
+ info_key = info_dict['info_key']
+ key_type = info_dict.get('value_type', 'str')
+
+ try:
+ if config_key in config_c and info_dict.get('to_json', True):
+ if dotty_info.get(info_key) and info_dict.get('warn_duplicate', True):
+ _log_warning(info_data, '%s in config.h is overwriting %s in info.json' % (config_key, info_key))
+
+ if key_type.startswith('array'):
+ if '.' in key_type:
+ key_type, array_type = key_type.split('.', 1)
+ else:
+ array_type = None
+
+ config_value = config_c[config_key].replace('{', '').replace('}', '').strip()
+
+ if array_type == 'int':
+ dotty_info[info_key] = list(map(int, config_value.split(',')))
+ else:
+ dotty_info[info_key] = config_value.split(',')
+
+ elif key_type == 'bool':
+ dotty_info[info_key] = config_c[config_key] in true_values
+
+ elif key_type == 'hex':
+ dotty_info[info_key] = '0x' + config_c[config_key][2:].upper()
+
+ elif key_type == 'list':
+ dotty_info[info_key] = config_c[config_key].split()
+
+ elif key_type == 'int':
+ dotty_info[info_key] = int(config_c[config_key])
+
+ else:
+ dotty_info[info_key] = config_c[config_key]
+
+ except Exception as e:
+ _log_warning(info_data, f'{config_key}->{info_key}: {e}')
+
+ info_data.update(dotty_info)
+
+ # Pull data that easily can't be mapped in json
+ _extract_matrix_info(info_data, config_c)
return info_data
@@ -103,63 +277,144 @@ def _extract_rules_mk(info_data):
"""Pull some keyboard information from existing rules.mk files
"""
rules = rules_mk(info_data['keyboard_folder'])
- mcu = rules.get('MCU')
+ info_data['processor'] = rules.get('MCU', info_data.get('processor', 'atmega32u4'))
+
+ if info_data['processor'] in CHIBIOS_PROCESSORS:
+ arm_processor_rules(info_data, rules)
+
+ elif info_data['processor'] in LUFA_PROCESSORS + VUSB_PROCESSORS:
+ avr_processor_rules(info_data, rules)
+
+ else:
+ cli.log.warning("%s: Unknown MCU: %s" % (info_data['keyboard_folder'], info_data['processor']))
+ unknown_processor_rules(info_data, rules)
+
+ # Pull in data from the json map
+ dotty_info = dotty(info_data)
+ info_rules_map = json_load(Path('data/mappings/info_rules.json'))
+
+ for rules_key, info_dict in info_rules_map.items():
+ info_key = info_dict['info_key']
+ key_type = info_dict.get('value_type', 'str')
+
+ try:
+ if rules_key in rules and info_dict.get('to_json', True):
+ if dotty_info.get(info_key) and info_dict.get('warn_duplicate', True):
+ _log_warning(info_data, '%s in rules.mk is overwriting %s in info.json' % (rules_key, info_key))
+
+ if key_type.startswith('array'):
+ if '.' in key_type:
+ key_type, array_type = key_type.split('.', 1)
+ else:
+ array_type = None
+
+ rules_value = rules[rules_key].replace('{', '').replace('}', '').strip()
+
+ if array_type == 'int':
+ dotty_info[info_key] = list(map(int, rules_value.split(',')))
+ else:
+ dotty_info[info_key] = rules_value.split(',')
+
+ elif key_type == 'list':
+ dotty_info[info_key] = rules[rules_key].split()
- if mcu in CHIBIOS_PROCESSORS:
- return arm_processor_rules(info_data, rules)
+ elif key_type == 'bool':
+ dotty_info[info_key] = rules[rules_key] in true_values
- elif mcu in LUFA_PROCESSORS + VUSB_PROCESSORS:
- return avr_processor_rules(info_data, rules)
+ elif key_type == 'hex':
+ dotty_info[info_key] = '0x' + rules[rules_key][2:].upper()
- msg = "Unknown MCU: " + str(mcu)
+ elif key_type == 'int':
+ dotty_info[info_key] = int(rules[rules_key])
- _log_warning(info_data, msg)
+ else:
+ dotty_info[info_key] = rules[rules_key]
+
+ except Exception as e:
+ _log_warning(info_data, f'{rules_key}->{info_key}: {e}')
+
+ info_data.update(dotty_info)
+
+ # Merge in config values that can't be easily mapped
+ _extract_features(info_data, rules)
+
+ return info_data
- return unknown_processor_rules(info_data, rules)
+
+def _merge_layouts(info_data, new_info_data):
+ """Merge new_info_data into info_data in an intelligent way.
+ """
+ for layout_name, layout_json in new_info_data['layouts'].items():
+ if layout_name in info_data['layouts']:
+ # Pull in layouts we have a macro for
+ if len(info_data['layouts'][layout_name]['layout']) != len(layout_json['layout']):
+ msg = '%s: %s: Number of elements in info.json does not match! info.json:%s != %s:%s'
+ _log_error(info_data, msg % (info_data['keyboard_folder'], layout_name, len(layout_json['layout']), layout_name, len(info_data['layouts'][layout_name]['layout'])))
+ else:
+ for i, key in enumerate(info_data['layouts'][layout_name]['layout']):
+ key.update(layout_json['layout'][i])
+ else:
+ # Pull in layouts that have matrix data
+ missing_matrix = False
+ for key in layout_json.get('layout', {}):
+ if 'matrix' not in key:
+ missing_matrix = True
+
+ if not missing_matrix:
+ if layout_name in info_data['layouts']:
+ # Update an existing layout with new data
+ for i, key in enumerate(info_data['layouts'][layout_name]['layout']):
+ key.update(layout_json['layout'][i])
+
+ else:
+ # Copy in the new layout wholesale
+ layout_json['c_macro'] = False
+ info_data['layouts'][layout_name] = layout_json
+
+ return info_data
def _search_keyboard_h(path):
current_path = Path('keyboards/')
+ aliases = {}
layouts = {}
+
for directory in path.parts:
current_path = current_path / directory
keyboard_h = '%s.h' % (directory,)
keyboard_h_path = current_path / keyboard_h
if keyboard_h_path.exists():
- layouts.update(find_layouts(keyboard_h_path))
+ new_layouts, new_aliases = find_layouts(keyboard_h_path)
+ layouts.update(new_layouts)
+
+ for alias, alias_text in new_aliases.items():
+ if alias_text in layouts:
+ aliases[alias] = alias_text
- return layouts
+ return layouts, aliases
-def _find_all_layouts(info_data, keyboard, rules):
+def _find_all_layouts(info_data, keyboard):
"""Looks for layout macros associated with this keyboard.
"""
- layouts = _search_keyboard_h(Path(keyboard))
+ layouts, aliases = _search_keyboard_h(Path(keyboard))
if not layouts:
- # If we didn't find any layouts above we widen our search. This is error
- # prone which is why we want to encourage people to follow the standard above.
- _log_warning(info_data, 'Falling back to searching for KEYMAP/LAYOUT macros.')
+ # If we don't find any layouts from info.json or keyboard.h we widen our search. This is error prone which is why we want to encourage people to follow the standard above.
+ info_data['parse_warnings'].append('%s: Falling back to searching for KEYMAP/LAYOUT macros.' % (keyboard))
+
for file in glob('keyboards/%s/*.h' % keyboard):
if file.endswith('.h'):
- these_layouts = find_layouts(file)
+ these_layouts, these_aliases = find_layouts(file)
+
if these_layouts:
layouts.update(these_layouts)
- if 'LAYOUTS' in rules:
- # Match these up against the supplied layouts
- supported_layouts = rules['LAYOUTS'].strip().split()
- for layout_name in sorted(layouts):
- if not layout_name.startswith('LAYOUT_'):
- continue
- layout_name = layout_name[7:]
- if layout_name in supported_layouts:
- supported_layouts.remove(layout_name)
-
- if supported_layouts:
- _log_error(info_data, 'Missing LAYOUT() macro for %s' % (', '.join(supported_layouts)))
+ for alias, alias_text in these_aliases.items():
+ if alias_text in layouts:
+ aliases[alias] = alias_text
- return layouts
+ return layouts, aliases
def _log_error(info_data, message):
@@ -180,13 +435,13 @@ def arm_processor_rules(info_data, rules):
"""Setup the default info for an ARM board.
"""
info_data['processor_type'] = 'arm'
- info_data['bootloader'] = rules['BOOTLOADER'] if 'BOOTLOADER' in rules else 'unknown'
- info_data['processor'] = rules['MCU'] if 'MCU' in rules else 'unknown'
info_data['protocol'] = 'ChibiOS'
- if info_data['bootloader'] == 'unknown':
+ if 'bootloader' not in info_data:
if 'STM32' in info_data['processor']:
info_data['bootloader'] = 'stm32-dfu'
+ else:
+ info_data['bootloader'] = 'unknown'
if 'STM32' in info_data['processor']:
info_data['platform'] = 'STM32'
@@ -202,11 +457,12 @@ def avr_processor_rules(info_data, rules):
"""Setup the default info for an AVR board.
"""
info_data['processor_type'] = 'avr'
- info_data['bootloader'] = rules['BOOTLOADER'] if 'BOOTLOADER' in rules else 'atmel-dfu'
info_data['platform'] = rules['ARCH'] if 'ARCH' in rules else 'unknown'
- info_data['processor'] = rules['MCU'] if 'MCU' in rules else 'unknown'
info_data['protocol'] = 'V-USB' if rules.get('MCU') in VUSB_PROCESSORS else 'LUFA'
+ if 'bootloader' not in info_data:
+ info_data['bootloader'] = 'atmel-dfu'
+
# FIXME(fauxpark/anyone): Eventually we should detect the protocol by looking at PROTOCOL inherited from mcu_selection.mk:
# info_data['protocol'] = 'V-USB' if rules.get('PROTOCOL') == 'VUSB' else 'LUFA'
@@ -230,33 +486,42 @@ def merge_info_jsons(keyboard, info_data):
"""
for info_file in find_info_json(keyboard):
# Load and validate the JSON data
- try:
- with info_file.open('r') as info_fd:
- new_info_data = json.load(info_fd)
- except Exception as e:
- _log_error(info_data, "Invalid JSON in file %s: %s: %s" % (str(info_file), e.__class__.__name__, e))
- continue
+ new_info_data = json_load(info_file)
if not isinstance(new_info_data, dict):
_log_error(info_data, "Invalid file %s, root object should be a dictionary." % (str(info_file),))
continue
- # Copy whitelisted keys into `info_data`
- for key in ('keyboard_name', 'manufacturer', 'identifier', 'url', 'maintainer', 'processor', 'bootloader', 'width', 'height'):
- if key in new_info_data:
- info_data[key] = new_info_data[key]
+ try:
+ keyboard_validate(new_info_data)
+ except jsonschema.ValidationError as e:
+ json_path = '.'.join([str(p) for p in e.absolute_path])
+ cli.log.error('Not including data from file: %s', info_file)
+ cli.log.error('\t%s: %s', json_path, e.message)
+ continue
+
+ # Merge layout data in
+ if 'layout_aliases' in new_info_data:
+ info_data['layout_aliases'] = {**info_data.get('layout_aliases', {}), **new_info_data['layout_aliases']}
+ del new_info_data['layout_aliases']
+
+ for layout_name, layout in new_info_data.get('layouts', {}).items():
+ if layout_name in info_data.get('layout_aliases', {}):
+ _log_warning(info_data, f"info.json uses alias name {layout_name} instead of {info_data['layout_aliases'][layout_name]}")
+ layout_name = info_data['layout_aliases'][layout_name]
+
+ if layout_name in info_data['layouts']:
+ for new_key, existing_key in zip(layout['layout'], info_data['layouts'][layout_name]['layout']):
+ existing_key.update(new_key)
+ else:
+ layout['c_macro'] = False
+ info_data['layouts'][layout_name] = layout
- # Merge the layouts in
+ # Update info_data with the new data
if 'layouts' in new_info_data:
- for layout_name, json_layout in new_info_data['layouts'].items():
- # Only pull in layouts we have a macro for
- if layout_name in info_data['layouts']:
- if info_data['layouts'][layout_name]['key_count'] != len(json_layout['layout']):
- msg = '%s: Number of elements in info.json does not match! info.json:%s != %s:%s'
- _log_error(info_data, msg % (layout_name, len(json_layout['layout']), layout_name, len(info_data['layouts'][layout_name]['layout'])))
- else:
- for i, key in enumerate(info_data['layouts'][layout_name]['layout']):
- key.update(json_layout['layout'][i])
+ del new_info_data['layouts']
+
+ deep_update(info_data, new_info_data)
return info_data
diff --git a/lib/python/qmk/json_encoders.py b/lib/python/qmk/json_encoders.py
new file mode 100755
index 0000000000..9f3da022b4
--- /dev/null
+++ b/lib/python/qmk/json_encoders.py
@@ -0,0 +1,192 @@
+"""Class that pretty-prints QMK info.json files.
+"""
+import json
+from decimal import Decimal
+
+newline = '\n'
+
+
+class QMKJSONEncoder(json.JSONEncoder):
+ """Base class for all QMK JSON encoders.
+ """
+ container_types = (list, tuple, dict)
+ indentation_char = " "
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.indentation_level = 0
+
+ if not self.indent:
+ self.indent = 4
+
+ def encode_decimal(self, obj):
+ """Encode a decimal object.
+ """
+ if obj == int(obj): # I can't believe Decimal objects don't have .is_integer()
+ return int(obj)
+
+ return float(obj)
+
+ def encode_list(self, obj):
+ """Encode a list-like object.
+ """
+ if self.primitives_only(obj):
+ return "[" + ", ".join(self.encode(element) for element in obj) + "]"
+
+ else:
+ self.indentation_level += 1
+ output = [self.indent_str + self.encode(element) for element in obj]
+ self.indentation_level -= 1
+
+ return "[\n" + ",\n".join(output) + "\n" + self.indent_str + "]"
+
+ def encode(self, obj):
+ """Encode keymap.json objects for QMK.
+ """
+ if isinstance(obj, Decimal):
+ return self.encode_decimal(obj)
+
+ elif isinstance(obj, (list, tuple)):
+ return self.encode_list(obj)
+
+ elif isinstance(obj, dict):
+ return self.encode_dict(obj)
+
+ else:
+ return super().encode(obj)
+
+ def primitives_only(self, obj):
+ """Returns true if the object doesn't have any container type objects (list, tuple, dict).
+ """
+ if isinstance(obj, dict):
+ obj = obj.values()
+
+ return not any(isinstance(element, self.container_types) for element in obj)
+
+ @property
+ def indent_str(self):
+ return self.indentation_char * (self.indentation_level * self.indent)
+
+
+class InfoJSONEncoder(QMKJSONEncoder):
+ """Custom encoder to make info.json's a little nicer to work with.
+ """
+ def encode_dict(self, obj):
+ """Encode info.json dictionaries.
+ """
+ if obj:
+ if self.indentation_level == 4:
+ # These are part of a layout, put them on a single line.
+ return "{ " + ", ".join(f"{self.encode(key)}: {self.encode(element)}" for key, element in sorted(obj.items())) + " }"
+
+ else:
+ self.indentation_level += 1
+ output = [self.indent_str + f"{json.dumps(key)}: {self.encode(value)}" for key, value in sorted(obj.items(), key=self.sort_dict)]
+ self.indentation_level -= 1
+ return "{\n" + ",\n".join(output) + "\n" + self.indent_str + "}"
+ else:
+ return "{}"
+
+ def sort_dict(self, key):
+ """Forces layout to the back of the sort order.
+ """
+ key = key[0]
+
+ if self.indentation_level == 1:
+ if key == 'manufacturer':
+ return '10keyboard_name'
+
+ elif key == 'keyboard_name':
+ return '11keyboard_name'
+
+ elif key == 'maintainer':
+ return '12maintainer'
+
+ elif key in ('height', 'width'):
+ return '40' + str(key)
+
+ elif key == 'community_layouts':
+ return '97community_layouts'
+
+ elif key == 'layout_aliases':
+ return '98layout_aliases'
+
+ elif key == 'layouts':
+ return '99layouts'
+
+ else:
+ return '50' + str(key)
+
+ return key
+
+
+class KeymapJSONEncoder(QMKJSONEncoder):
+ """Custom encoder to make keymap.json's a little nicer to work with.
+ """
+ def encode_dict(self, obj):
+ """Encode dictionary objects for keymap.json.
+ """
+ if obj:
+ self.indentation_level += 1
+ output_lines = [f"{self.indent_str}{json.dumps(key)}: {self.encode(value)}" for key, value in sorted(obj.items(), key=self.sort_dict)]
+ output = ',\n'.join(output_lines)
+ self.indentation_level -= 1
+
+ return f"{{\n{output}\n{self.indent_str}}}"
+
+ else:
+ return "{}"
+
+ def encode_list(self, obj):
+ """Encode a list-like object.
+ """
+ if self.indentation_level == 2:
+ indent_level = self.indentation_level + 1
+ # We have a list of keycodes
+ layer = [[]]
+
+ for key in obj:
+ if key == 'JSON_NEWLINE':
+ layer.append([])
+ else:
+ layer[-1].append(f'"{key}"')
+
+ layer = [f"{self.indent_str*indent_level}{', '.join(row)}" for row in layer]
+
+ return f"{self.indent_str}[\n{newline.join(layer)}\n{self.indent_str*self.indentation_level}]"
+
+ elif self.primitives_only(obj):
+ return "[" + ", ".join(self.encode(element) for element in obj) + "]"
+
+ else:
+ self.indentation_level += 1
+ output = [self.indent_str + self.encode(element) for element in obj]
+ self.indentation_level -= 1
+
+ return "[\n" + ",\n".join(output) + "\n" + self.indent_str + "]"
+
+ def sort_dict(self, key):
+ """Sorts the hashes in a nice way.
+ """
+ key = key[0]
+
+ if self.indentation_level == 1:
+ if key == 'version':
+ return '00version'
+
+ elif key == 'author':
+ return '01author'
+
+ elif key == 'notes':
+ return '02notes'
+
+ elif key == 'layers':
+ return '98layers'
+
+ elif key == 'documentation':
+ return '99documentation'
+
+ else:
+ return '50' + str(key)
+
+ return key
diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py
new file mode 100644
index 0000000000..077dfcaa93
--- /dev/null
+++ b/lib/python/qmk/json_schema.py
@@ -0,0 +1,68 @@
+"""Functions that help us generate and use info.json files.
+"""
+import json
+from collections.abc import Mapping
+from pathlib import Path
+
+import hjson
+import jsonschema
+from milc import cli
+
+
+def json_load(json_file):
+ """Load a json file from disk.
+
+ Note: file must be a Path object.
+ """
+ try:
+ return hjson.load(json_file.open(encoding='utf-8'))
+
+ except json.decoder.JSONDecodeError as e:
+ cli.log.error('Invalid JSON encountered attempting to load {fg_cyan}%s{fg_reset}:\n\t{fg_red}%s', json_file, e)
+ exit(1)
+
+
+def load_jsonschema(schema_name):
+ """Read a jsonschema file from disk.
+
+ FIXME(skullydazed/anyone): Refactor to make this a public function.
+ """
+ schema_path = Path(f'data/schemas/{schema_name}.jsonschema')
+
+ if not schema_path.exists():
+ schema_path = Path('data/schemas/false.jsonschema')
+
+ return json_load(schema_path)
+
+
+def keyboard_validate(data):
+ """Validates data against the keyboard jsonschema.
+ """
+ schema = load_jsonschema('keyboard')
+ validator = jsonschema.Draft7Validator(schema).validate
+
+ return validator(data)
+
+
+def keyboard_api_validate(data):
+ """Validates data against the api_keyboard jsonschema.
+ """
+ base = load_jsonschema('keyboard')
+ relative = load_jsonschema('api_keyboard')
+ resolver = jsonschema.RefResolver.from_schema(base)
+ validator = jsonschema.Draft7Validator(relative, resolver=resolver).validate
+
+ return validator(data)
+
+
+def deep_update(origdict, newdict):
+ """Update a dictionary in place, recursing to do a deep copy.
+ """
+ for key, value in newdict.items():
+ if isinstance(value, Mapping):
+ origdict[key] = deep_update(origdict.get(key, {}), value)
+
+ else:
+ origdict[key] = value
+
+ return origdict
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py
index a4c2873757..06c9df874f 100644
--- a/lib/python/qmk/keyboard.py
+++ b/lib/python/qmk/keyboard.py
@@ -6,7 +6,9 @@ from pathlib import Path
import os
from glob import glob
+import qmk.path
from qmk.c_parse import parse_config_h_file
+from qmk.json_schema import json_load
from qmk.makefile import parse_rules_mk_file
BOX_DRAWING_CHARACTERS = {
@@ -31,12 +33,71 @@ BOX_DRAWING_CHARACTERS = {
base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep
+def find_keyboard_from_dir():
+ """Returns a keyboard name based on the user's current directory.
+ """
+ relative_cwd = qmk.path.under_qmk_firmware()
+
+ if relative_cwd and len(relative_cwd.parts) > 1 and relative_cwd.parts[0] == 'keyboards':
+ # Attempt to extract the keyboard name from the current directory
+ current_path = Path('/'.join(relative_cwd.parts[1:]))
+
+ if 'keymaps' in current_path.parts:
+ # Strip current_path of anything after `keymaps`
+ keymap_index = len(current_path.parts) - current_path.parts.index('keymaps') - 1
+ current_path = current_path.parents[keymap_index]
+
+ if qmk.path.is_keyboard(current_path):
+ return str(current_path)
+
+
+def find_readme(keyboard):
+ """Returns the readme for this keyboard.
+ """
+ cur_dir = qmk.path.keyboard(keyboard)
+ keyboards_dir = Path('keyboards')
+ while not (cur_dir / 'readme.md').exists():
+ if cur_dir == keyboards_dir:
+ return None
+ cur_dir = cur_dir.parent
+
+ return cur_dir / 'readme.md'
+
+
+def keyboard_folder(keyboard):
+ """Returns the actual keyboard folder.
+
+ This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard.
+ """
+ aliases = json_load(Path('data/mappings/keyboard_aliases.json'))
+
+ if keyboard in aliases:
+ keyboard = aliases[keyboard].get('target', keyboard)
+
+ rules_mk_file = Path(base_path, keyboard, 'rules.mk')
+
+ if rules_mk_file.exists():
+ rules_mk = parse_rules_mk_file(rules_mk_file)
+ keyboard = rules_mk.get('DEFAULT_FOLDER', keyboard)
+
+ if not qmk.path.is_keyboard(keyboard):
+ raise ValueError(f'Invalid keyboard: {keyboard}')
+
+ return keyboard
+
+
def _find_name(path):
"""Determine the keyboard name by stripping off the base_path and rules.mk.
"""
return path.replace(base_path, "").replace(os.path.sep + "rules.mk", "")
+def keyboard_completer(prefix, action, parser, parsed_args):
+ """Returns a list of keyboards for tab completion.
+ """
+ return list_keyboards()
+
+
def list_keyboards():
"""Returns a list of all keyboards.
"""
@@ -44,7 +105,16 @@ def list_keyboards():
kb_wildcard = os.path.join(base_path, "**", "rules.mk")
paths = [path for path in glob(kb_wildcard, recursive=True) if 'keymaps' not in path]
- return sorted(map(_find_name, paths))
+ return sorted(set(map(resolve_keyboard, map(_find_name, paths))))
+
+
+def resolve_keyboard(keyboard):
+ cur_dir = Path('keyboards')
+ rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
+ while 'DEFAULT_FOLDER' in rules and keyboard != rules['DEFAULT_FOLDER']:
+ keyboard = rules['DEFAULT_FOLDER']
+ rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
+ return keyboard
def config_h(keyboard):
@@ -58,8 +128,7 @@ def config_h(keyboard):
"""
config = {}
cur_dir = Path('keyboards')
- rules = rules_mk(keyboard)
- keyboard = Path(rules['DEFAULT_FOLDER'] if 'DEFAULT_FOLDER' in rules else keyboard)
+ keyboard = Path(resolve_keyboard(keyboard))
for dir in keyboard.parts:
cur_dir = cur_dir / dir
@@ -77,13 +146,10 @@ def rules_mk(keyboard):
Returns:
a dictionary representing the content of the entire rules.mk tree for a keyboard
"""
- keyboard = Path(keyboard)
cur_dir = Path('keyboards')
+ keyboard = Path(resolve_keyboard(keyboard))
rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
- if 'DEFAULT_FOLDER' in rules:
- keyboard = Path(rules['DEFAULT_FOLDER'])
-
for i, dir in enumerate(keyboard.parts):
cur_dir = cur_dir / dir
rules = parse_rules_mk_file(cur_dir / 'rules.mk', rules)
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py
index 266532f503..2d5921e7a8 100644
--- a/lib/python/qmk/keymap.py
+++ b/lib/python/qmk/keymap.py
@@ -1,19 +1,19 @@
"""Functions that help you work with QMK keymaps.
"""
-from pathlib import Path
import json
-import subprocess
import sys
+from pathlib import Path
+from subprocess import DEVNULL
+import argcomplete
+from milc import cli
from pygments.lexers.c_cpp import CLexer
from pygments.token import Token
from pygments import lex
-from milc import cli
-
-from qmk.keyboard import rules_mk
import qmk.path
-import qmk.commands
+from qmk.keyboard import find_keyboard_from_dir, rules_mk
+from qmk.errors import CppError
# The `keymap.c` template to use when a keyboard doesn't have its own
DEFAULT_KEYMAP_C = """#include QMK_KEYBOARD_H
@@ -42,7 +42,7 @@ def template_json(keyboard):
template_file = Path('keyboards/%s/templates/keymap.json' % keyboard)
template = {'keyboard': keyboard}
if template_file.exists():
- template.update(json.loads(template_file.read_text()))
+ template.update(json.load(template_file.open(encoding='utf-8')))
return template
@@ -58,7 +58,7 @@ def template_c(keyboard):
"""
template_file = Path('keyboards/%s/templates/keymap.c' % keyboard)
if template_file.exists():
- template = template_file.read_text()
+ template = template_file.read_text(encoding='utf-8')
else:
template = DEFAULT_KEYMAP_C
@@ -74,6 +74,54 @@ def _strip_any(keycode):
return keycode
+def find_keymap_from_dir():
+ """Returns `(keymap_name, source)` for the directory we're currently in.
+
+ """
+ relative_cwd = qmk.path.under_qmk_firmware()
+
+ if relative_cwd and len(relative_cwd.parts) > 1:
+ # If we're in `qmk_firmware/keyboards` and `keymaps` is in our path, try to find the keyboard name.
+ if relative_cwd.parts[0] == 'keyboards' and 'keymaps' in relative_cwd.parts:
+ current_path = Path('/'.join(relative_cwd.parts[1:])) # Strip 'keyboards' from the front
+
+ if 'keymaps' in current_path.parts and current_path.name != 'keymaps':
+ while current_path.parent.name != 'keymaps':
+ current_path = current_path.parent
+
+ return current_path.name, 'keymap_directory'
+
+ # If we're in `qmk_firmware/layouts` guess the name from the community keymap they're in
+ elif relative_cwd.parts[0] == 'layouts' and is_keymap_dir(relative_cwd):
+ return relative_cwd.name, 'layouts_directory'
+
+ # If we're in `qmk_firmware/users` guess the name from the userspace they're in
+ elif relative_cwd.parts[0] == 'users':
+ # Guess the keymap name based on which userspace they're in
+ return relative_cwd.parts[1], 'users_directory'
+
+ return None, None
+
+
+def keymap_completer(prefix, action, parser, parsed_args):
+ """Returns a list of keymaps for tab completion.
+ """
+ try:
+ if parsed_args.keyboard:
+ return list_keymaps(parsed_args.keyboard)
+
+ keyboard = find_keyboard_from_dir()
+
+ if keyboard:
+ return list_keymaps(keyboard)
+
+ except Exception as e:
+ argcomplete.warn(f'Error: {e.__class__.__name__}: {str(e)}')
+ return []
+
+ return []
+
+
def is_keymap_dir(keymap, c=True, json=True, additional_files=None):
"""Return True if Path object `keymap` has a keymap file inside.
@@ -313,7 +361,7 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
return sorted(names)
-def _c_preprocess(path, stdin=None):
+def _c_preprocess(path, stdin=DEVNULL):
""" Run a file through the C pre-processor
Args:
@@ -323,7 +371,12 @@ def _c_preprocess(path, stdin=None):
Returns:
the stdout of the pre-processor
"""
- pre_processed_keymap = qmk.commands.run(['cpp', path] if path else ['cpp'], stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+ cmd = ['cpp', str(path)] if path else ['cpp']
+ pre_processed_keymap = cli.run(cmd, stdin=stdin)
+ if 'fatal error' in pre_processed_keymap.stderr:
+ for line in pre_processed_keymap.stderr.split('\n'):
+ if 'fatal error' in line:
+ raise (CppError(line))
return pre_processed_keymap.stdout
@@ -469,7 +522,7 @@ def parse_keymap_c(keymap_file, use_cpp=True):
if use_cpp:
keymap_file = _c_preprocess(keymap_file)
else:
- keymap_file = keymap_file.read_text()
+ keymap_file = keymap_file.read_text(encoding='utf-8')
keymap = dict()
keymap['layers'] = _get_layers(keymap_file)
diff --git a/lib/python/qmk/os_helpers/__init__.py b/lib/python/qmk/os_helpers/__init__.py
index 3f64a63a3a..3e98db3c32 100644
--- a/lib/python/qmk/os_helpers/__init__.py
+++ b/lib/python/qmk/os_helpers/__init__.py
@@ -3,10 +3,9 @@
from enum import Enum
import re
import shutil
-import subprocess
+from subprocess import DEVNULL
from milc import cli
-from qmk.commands import run
from qmk import submodules
from qmk.constants import QMK_FIRMWARE
@@ -142,7 +141,7 @@ def is_executable(command):
# Make sure the command can be executed
version_arg = ESSENTIAL_BINARIES[command].get('version_arg', '--version')
- check = run([command, version_arg], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=5, universal_newlines=True)
+ check = cli.run([command, version_arg], combined_output=True, stdin=DEVNULL, timeout=5)
ESSENTIAL_BINARIES[command]['output'] = check.stdout
diff --git a/lib/python/qmk/os_helpers/linux/__init__.py b/lib/python/qmk/os_helpers/linux/__init__.py
index 86850bf284..de38f1d609 100644
--- a/lib/python/qmk/os_helpers/linux/__init__.py
+++ b/lib/python/qmk/os_helpers/linux/__init__.py
@@ -5,7 +5,6 @@ import shutil
from milc import cli
from qmk.constants import QMK_FIRMWARE
-from qmk.commands import run
from qmk.os_helpers import CheckStatus
@@ -48,6 +47,10 @@ def check_udev_rules():
_udev_rule("03eb", "2ff3"), # ATmega16U4
_udev_rule("03eb", "2ff4"), # ATmega32U4
_udev_rule("03eb", "2ff9"), # AT90USB64
+<<<<<<< HEAD
+=======
+ _udev_rule("03eb", "2ffa"), # AT90USB162
+>>>>>>> 0.12.52~1
_udev_rule("03eb", "2ffb") # AT90USB128
},
'kiibohd': {_udev_rule("1c11", "b007")},
@@ -94,7 +97,11 @@ def check_udev_rules():
# Collect all rules from the config files
for rule_file in udev_rules:
+<<<<<<< HEAD
for line in rule_file.read_text().split('\n'):
+=======
+ for line in rule_file.read_text(encoding='utf-8').split('\n'):
+>>>>>>> 0.12.52~1
line = line.strip()
if not line.startswith("#") and len(line):
current_rules.add(line)
@@ -131,7 +138,11 @@ def check_modem_manager():
"""
if check_systemd():
+<<<<<<< HEAD
mm_check = run(["systemctl", "--quiet", "is-active", "ModemManager.service"], timeout=10)
+=======
+ mm_check = cli.run(["systemctl", "--quiet", "is-active", "ModemManager.service"], timeout=10)
+>>>>>>> 0.12.52~1
if mm_check.returncode == 0:
return True
else:
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py
index 54def1d5d6..2aa1916f55 100644
--- a/lib/python/qmk/path.py
+++ b/lib/python/qmk/path.py
@@ -2,6 +2,7 @@
"""
import logging
import os
+import argparse
from pathlib import Path
from qmk.constants import MAX_KEYBOARD_SUBFOLDERS, QMK_FIRMWARE
@@ -65,3 +66,12 @@ def normpath(path):
return path
return Path(os.environ['ORIG_CWD']) / path
+
+
+class FileType(argparse.FileType):
+ def __call__(self, string):
+ """normalize and check exists
+ otherwise magic strings like '-' for stdin resolve to bad paths
+ """
+ norm = normpath(string)
+ return super().__call__(norm if norm.exists() else string)
diff --git a/lib/python/qmk/submodules.py b/lib/python/qmk/submodules.py
index be51a68043..6a272dae50 100644
--- a/lib/python/qmk/submodules.py
+++ b/lib/python/qmk/submodules.py
@@ -1,7 +1,6 @@
"""Functions for working with QMK's submodules.
"""
-
-import subprocess
+from milc import cli
def status():
@@ -18,7 +17,7 @@ def status():
status is None when the submodule doesn't exist, False when it's out of date, and True when it's current
"""
submodules = {}
- git_cmd = subprocess.run(['git', 'submodule', 'status'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30, universal_newlines=True)
+ git_cmd = cli.run(['git', 'submodule', 'status'], timeout=30)
for line in git_cmd.stdout.split('\n'):
if not line:
@@ -53,19 +52,19 @@ def update(submodules=None):
# Update everything
git_sync_cmd.append('--recursive')
git_update_cmd.append('--recursive')
- subprocess.run(git_sync_cmd, check=True)
- subprocess.run(git_update_cmd, check=True)
+ cli.run(git_sync_cmd, check=True)
+ cli.run(git_update_cmd, check=True)
else:
if isinstance(submodules, str):
# Update only a single submodule
git_sync_cmd.append(submodules)
git_update_cmd.append(submodules)
- subprocess.run(git_sync_cmd, check=True)
- subprocess.run(git_update_cmd, check=True)
+ cli.run(git_sync_cmd, check=True)
+ cli.run(git_update_cmd, check=True)
else:
# Update submodules in a list
for submodule in submodules:
- subprocess.run(git_sync_cmd + [submodule], check=True)
- subprocess.run(git_update_cmd + [submodule], check=True)
+ cli.run([*git_sync_cmd, submodule], check=True)
+ cli.run([*git_update_cmd, submodule], check=True)
diff --git a/lib/python/qmk/tests/minimal_info.json b/lib/python/qmk/tests/minimal_info.json
new file mode 100644
index 0000000000..b91c23bd3d
--- /dev/null
+++ b/lib/python/qmk/tests/minimal_info.json
@@ -0,0 +1,13 @@
+{
+ "keyboard_name": "tester",
+ "maintainer": "qmk",
+ "height": 5,
+ "width": 15,
+ "layouts": {
+ "LAYOUT": {
+ "layout": [
+ { "label": "KC_A", "x": 0, "y": 0, "matrix": [0, 0] }
+ ]
+ }
+ }
+}
diff --git a/lib/python/qmk/tests/minimal_keymap.json b/lib/python/qmk/tests/minimal_keymap.json
new file mode 100644
index 0000000000..258f9e8a9a
--- /dev/null
+++ b/lib/python/qmk/tests/minimal_keymap.json
@@ -0,0 +1,7 @@
+{
+ "keyboard": "handwired/pytest/basic",
+ "keymap": "test",
+ "layers": [["KC_A"]],
+ "layout": "LAYOUT_ortho_1x1",
+ "version": 1
+}
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index a8159c9c08..a7b70a7d99 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -1,24 +1,23 @@
import platform
+from subprocess import DEVNULL
-from subprocess import STDOUT, PIPE
-
-from qmk.commands import run
+from milc import cli
is_windows = 'windows' in platform.platform().lower()
def check_subcommand(command, *args):
cmd = ['bin/qmk', command, *args]
- result = run(cmd, stdout=PIPE, stderr=STDOUT, universal_newlines=True)
+ result = cli.run(cmd, stdin=DEVNULL, combined_output=True)
return result
def check_subcommand_stdin(file_to_read, command, *args):
"""Pipe content of a file to a command and return output.
"""
- with open(file_to_read) as my_file:
+ with open(file_to_read, encoding='utf-8') as my_file:
cmd = ['bin/qmk', command, *args]
- result = run(cmd, stdin=my_file, stdout=PIPE, stderr=STDOUT, universal_newlines=True)
+ result = cli.run(cmd, stdin=my_file, combined_output=True)
return result
@@ -33,22 +32,27 @@ def check_returncode(result, expected=[0]):
def test_cformat():
- result = check_subcommand('cformat', 'quantum/matrix.c')
+ result = check_subcommand('cformat', '-n', 'quantum/matrix.c')
check_returncode(result)
+def test_cformat_all():
+ result = check_subcommand('cformat', '-n', '-a')
+ check_returncode(result, [0, 1])
+
+
def test_compile():
- result = check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default', '-n')
+ result = check_subcommand('compile', '-kb', 'handwired/pytest/basic', '-km', 'default', '-n')
check_returncode(result)
def test_compile_json():
- result = check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default_json')
+ result = check_subcommand('compile', '-kb', 'handwired/pytest/basic', '-km', 'default_json', '-n')
check_returncode(result)
def test_flash():
- result = check_subcommand('flash', '-kb', 'handwired/onekey/pytest', '-km', 'default', '-n')
+ result = check_subcommand('flash', '-kb', 'handwired/pytest/basic', '-km', 'default', '-n')
check_returncode(result)
@@ -57,12 +61,6 @@ def test_flash_bootloaders():
check_returncode(result, [1])
-def test_config():
- result = check_subcommand('config')
- check_returncode(result)
- assert 'general.color' in result.stdout
-
-
def test_kle2json():
result = check_subcommand('kle2json', 'lib/python/qmk/tests/kle.txt', '-f')
check_returncode(result)
@@ -83,29 +81,35 @@ def test_hello():
def test_pyformat():
- result = check_subcommand('pyformat')
+ result = check_subcommand('pyformat', '--dry-run')
check_returncode(result)
- assert 'Successfully formatted the python code' in result.stdout
+ assert 'Python code in `bin/qmk` and `lib/python` is correctly formatted.' in result.stdout
def test_list_keyboards():
result = check_subcommand('list-keyboards')
check_returncode(result)
# check to see if a known keyboard is returned
- # this will fail if handwired/onekey/pytest is removed
- assert 'handwired/onekey/pytest' in result.stdout
+ # this will fail if handwired/pytest/basic is removed
+ assert 'handwired/pytest/basic' in result.stdout
def test_list_keymaps():
- result = check_subcommand('list-keymaps', '-kb', 'handwired/onekey/pytest')
+ result = check_subcommand('list-keymaps', '-kb', 'handwired/pytest/basic')
check_returncode(result)
- assert 'default' and 'test' in result.stdout
+ assert 'default' and 'default_json' in result.stdout
def test_list_keymaps_long():
- result = check_subcommand('list-keymaps', '--keyboard', 'handwired/onekey/pytest')
+ result = check_subcommand('list-keymaps', '--keyboard', 'handwired/pytest/basic')
check_returncode(result)
- assert 'default' and 'test' in result.stdout
+ assert 'default' and 'default_json' in result.stdout
+
+
+def test_list_keymaps_community():
+ result = check_subcommand('list-keymaps', '--keyboard', 'handwired/pytest/has_community')
+ check_returncode(result)
+ assert 'test' in result.stdout
def test_list_keymaps_kb_only():
@@ -128,45 +132,45 @@ def test_list_keymaps_vendor_kb_rev():
def test_list_keymaps_no_keyboard_found():
result = check_subcommand('list-keymaps', '-kb', 'asdfghjkl')
- check_returncode(result, [1])
- assert 'does not exist' in result.stdout
+ check_returncode(result, [2])
+ assert 'invalid keyboard_folder value' in result.stdout
def test_json2c():
- result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json')
+ result = check_subcommand('json2c', 'keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json')
check_returncode(result)
assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n'
def test_json2c_stdin():
- result = check_subcommand_stdin('keyboards/handwired/onekey/keymaps/default_json/keymap.json', 'json2c', '-')
+ result = check_subcommand_stdin('keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json', 'json2c', '-')
check_returncode(result)
assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n'
def test_info():
- result = check_subcommand('info', '-kb', 'handwired/onekey/pytest')
+ result = check_subcommand('info', '-kb', 'handwired/pytest/basic')
check_returncode(result)
- assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout
- assert 'Processor: STM32F303' in result.stdout
+ assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Processor: atmega32u4' in result.stdout
assert 'Layout:' not in result.stdout
assert 'k0' not in result.stdout
def test_info_keyboard_render():
- result = check_subcommand('info', '-kb', 'handwired/onekey/pytest', '-l')
+ result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-l')
check_returncode(result)
- assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout
- assert 'Processor: STM32F303' in result.stdout
+ assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Processor: atmega32u4' in result.stdout
assert 'Layouts:' in result.stdout
assert 'k0' in result.stdout
def test_info_keymap_render():
- result = check_subcommand('info', '-kb', 'handwired/onekey/pytest', '-km', 'default_json')
+ result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-km', 'default_json')
check_returncode(result)
- assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout
- assert 'Processor: STM32F303' in result.stdout
+ assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Processor: atmega32u4' in result.stdout
if is_windows:
assert '|A |' in result.stdout
@@ -175,10 +179,10 @@ def test_info_keymap_render():
def test_info_matrix_render():
- result = check_subcommand('info', '-kb', 'handwired/onekey/pytest', '-m')
+ result = check_subcommand('info', '-kb', 'handwired/pytest/basic', '-m')
check_returncode(result)
- assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout
- assert 'Processor: STM32F303' in result.stdout
+ assert 'Keyboard Name: handwired/pytest/basic' in result.stdout
+ assert 'Processor: atmega32u4' in result.stdout
assert 'LAYOUT_ortho_1x1' in result.stdout
if is_windows:
@@ -190,27 +194,27 @@ def test_info_matrix_render():
def test_c2json():
- result = check_subcommand("c2json", "-kb", "handwired/onekey/pytest", "-km", "default", "keyboards/handwired/onekey/keymaps/default/keymap.c")
+ result = check_subcommand("c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/default/keymap.c")
check_returncode(result)
- assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}'
+ assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}'
def test_c2json_nocpp():
- result = check_subcommand("c2json", "--no-cpp", "-kb", "handwired/onekey/pytest", "-km", "default", "keyboards/handwired/onekey/keymaps/pytest_nocpp/keymap.c")
+ result = check_subcommand("c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c")
check_returncode(result)
- assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}'
+ assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}'
def test_c2json_stdin():
- result = check_subcommand_stdin("keyboards/handwired/onekey/keymaps/default/keymap.c", "c2json", "-kb", "handwired/onekey/pytest", "-km", "default", "-")
+ result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/default/keymap.c", "c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "-")
check_returncode(result)
- assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}'
+ assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}'
def test_c2json_nocpp_stdin():
- result = check_subcommand_stdin("keyboards/handwired/onekey/keymaps/pytest_nocpp/keymap.c", "c2json", "--no-cpp", "-kb", "handwired/onekey/pytest", "-km", "default", "-")
+ result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c", "c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "-")
check_returncode(result)
- assert result.stdout.strip() == '{"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}'
+ assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}'
def test_clean():
@@ -219,8 +223,66 @@ def test_clean():
assert result.stdout.count('done') == 2
+def test_generate_api():
+ result = check_subcommand('generate-api', '--dry-run')
+ check_returncode(result)
+
+
def test_generate_rgb_breathe_table():
result = check_subcommand("generate-rgb-breathe-table", "-c", "1.2", "-m", "127")
check_returncode(result)
assert 'Breathing center: 1.2' in result.stdout
assert 'Breathing max: 127' in result.stdout
+
+
+def test_generate_config_h():
+ result = check_subcommand('generate-config-h', '-kb', 'handwired/pytest/basic')
+ check_returncode(result)
+ assert '# define DEVICE_VER 0x0001' in result.stdout
+ assert '# define DESCRIPTION handwired/pytest/basic' in result.stdout
+ assert '# define DIODE_DIRECTION COL2ROW' in result.stdout
+ assert '# define MANUFACTURER none' in result.stdout
+ assert '# define PRODUCT handwired/pytest/basic' in result.stdout
+ assert '# define PRODUCT_ID 0x6465' in result.stdout
+ assert '# define VENDOR_ID 0xFEED' in result.stdout
+ assert '# define MATRIX_COLS 1' in result.stdout
+ assert '# define MATRIX_COL_PINS { F4 }' in result.stdout
+ assert '# define MATRIX_ROWS 1' in result.stdout
+ assert '# define MATRIX_ROW_PINS { F5 }' in result.stdout
+
+
+def test_generate_rules_mk():
+ result = check_subcommand('generate-rules-mk', '-kb', 'handwired/pytest/basic')
+ check_returncode(result)
+ assert 'BOOTLOADER ?= atmel-dfu' in result.stdout
+ assert 'MCU ?= atmega32u4' in result.stdout
+
+
+def test_generate_layouts():
+ result = check_subcommand('generate-layouts', '-kb', 'handwired/pytest/basic')
+ check_returncode(result)
+ assert '#define LAYOUT_custom(k0A) {' in result.stdout
+
+
+def test_format_json_keyboard():
+ result = check_subcommand('format-json', '--format', 'keyboard', 'lib/python/qmk/tests/minimal_info.json')
+ check_returncode(result)
+ assert result.stdout == '{\n "keyboard_name": "tester",\n "maintainer": "qmk",\n "height": 5,\n "width": 15,\n "layouts": {\n "LAYOUT": {\n "layout": [\n { "label": "KC_A", "matrix": [0, 0], "x": 0, "y": 0 }\n ]\n }\n }\n}\n'
+
+
+def test_format_json_keymap():
+ result = check_subcommand('format-json', '--format', 'keymap', 'lib/python/qmk/tests/minimal_keymap.json')
+ check_returncode(result)
+ assert result.stdout == '{\n "version": 1,\n "keyboard": "handwired/pytest/basic",\n "keymap": "test",\n "layout": "LAYOUT_ortho_1x1",\n "layers": [\n [\n "KC_A"\n ]\n ]\n}\n'
+
+
+def test_format_json_keyboard_auto():
+ result = check_subcommand('format-json', '--format', 'auto', 'lib/python/qmk/tests/minimal_info.json')
+ check_returncode(result)
+ assert result.stdout == '{\n "keyboard_name": "tester",\n "maintainer": "qmk",\n "height": 5,\n "width": 15,\n "layouts": {\n "LAYOUT": {\n "layout": [\n { "label": "KC_A", "matrix": [0, 0], "x": 0, "y": 0 }\n ]\n }\n }\n}\n'
+
+
+def test_format_json_keymap_auto():
+ result = check_subcommand('format-json', '--format', 'auto', 'lib/python/qmk/tests/minimal_keymap.json')
+ check_returncode(result)
+ assert result.stdout == '{\n "keyboard": "handwired/pytest/basic",\n "keymap": "test",\n "layers": [\n ["KC_A"]\n ],\n "layout": "LAYOUT_ortho_1x1",\n "version": 1\n}\n'
diff --git a/lib/python/qmk/tests/test_qmk_keymap.py b/lib/python/qmk/tests/test_qmk_keymap.py
index f1ecf29378..b9e80df672 100644
--- a/lib/python/qmk/tests/test_qmk_keymap.py
+++ b/lib/python/qmk/tests/test_qmk_keymap.py
@@ -1,38 +1,38 @@
import qmk.keymap
-def test_template_c_onekey_proton_c():
- templ = qmk.keymap.template_c('handwired/onekey/proton_c')
+def test_template_c_pytest_basic():
+ templ = qmk.keymap.template_c('handwired/pytest/basic')
assert templ == qmk.keymap.DEFAULT_KEYMAP_C
-def test_template_json_onekey_proton_c():
- templ = qmk.keymap.template_json('handwired/onekey/proton_c')
- assert templ == {'keyboard': 'handwired/onekey/proton_c'}
+def test_template_json_pytest_basic():
+ templ = qmk.keymap.template_json('handwired/pytest/basic')
+ assert templ == {'keyboard': 'handwired/pytest/basic'}
-def test_template_c_onekey_pytest():
- templ = qmk.keymap.template_c('handwired/onekey/pytest')
+def test_template_c_pytest_has_template():
+ templ = qmk.keymap.template_c('handwired/pytest/has_template')
assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n'
-def test_template_json_onekey_pytest():
- templ = qmk.keymap.template_json('handwired/onekey/pytest')
- assert templ == {'keyboard': 'handwired/onekey/pytest', "documentation": "This file is a keymap.json file for handwired/onekey/pytest"}
+def test_template_json_pytest_has_template():
+ templ = qmk.keymap.template_json('handwired/pytest/has_template')
+ assert templ == {'keyboard': 'handwired/pytest/has_template', "documentation": "This file is a keymap.json file for handwired/pytest/has_template"}
-def test_generate_c_onekey_pytest():
- templ = qmk.keymap.generate_c('handwired/onekey/pytest', 'LAYOUT', [['KC_A']])
+def test_generate_c_pytest_has_template():
+ templ = qmk.keymap.generate_c('handwired/pytest/has_template', 'LAYOUT', [['KC_A']])
assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n'
-def test_generate_json_onekey_pytest():
- templ = qmk.keymap.generate_json('default', 'handwired/onekey/pytest', 'LAYOUT', [['KC_A']])
- assert templ == {"keyboard": "handwired/onekey/pytest", "documentation": "This file is a keymap.json file for handwired/onekey/pytest", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_A"]]}
+def test_generate_json_pytest_has_template():
+ templ = qmk.keymap.generate_json('default', 'handwired/pytest/has_template', 'LAYOUT', [['KC_A']])
+ assert templ == {"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_A"]]}
def test_parse_keymap_c():
- parsed_keymap_c = qmk.keymap.parse_keymap_c('keyboards/handwired/onekey/keymaps/default/keymap.c')
+ parsed_keymap_c = qmk.keymap.parse_keymap_c('keyboards/handwired/pytest/basic/keymaps/default/keymap.c')
assert parsed_keymap_c == {'layers': [{'name': '0', 'layout': 'LAYOUT_ortho_1x1', 'keycodes': ['KC_A']}]}
diff --git a/lib/python/qmk/tests/test_qmk_path.py b/lib/python/qmk/tests/test_qmk_path.py
index 74db7b3e26..4b5132f13d 100644
--- a/lib/python/qmk/tests/test_qmk_path.py
+++ b/lib/python/qmk/tests/test_qmk_path.py
@@ -4,9 +4,9 @@ from pathlib import Path
import qmk.path
-def test_keymap_onekey_pytest():
- path = qmk.path.keymap('handwired/onekey/pytest')
- assert path.samefile('keyboards/handwired/onekey/keymaps')
+def test_keymap_pytest_basic():
+ path = qmk.path.keymap('handwired/pytest/basic')
+ assert path.samefile('keyboards/handwired/pytest/basic/keymaps')
def test_normpath():
diff --git a/message.mk b/message.mk
index 84b23c1ba8..3240c041b9 100644
--- a/message.mk
+++ b/message.mk
@@ -86,8 +86,7 @@ MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT
MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
MSG_FILE_NEAR_LIMIT = The firmware size is approaching the maximum - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
-MSG_PYTHON_MISSING = $(WARN_COLOR)WARNING:$(NO_COLOR)\n \
- Can not run bin/qmk! This tool will be required when the develop branch is merged on 2020 Aug 29.\n\n\
+MSG_PYTHON_MISSING = $(ERROR_COLOR)ERROR:$(NO_COLOR) Can not run bin/qmk!\n\n\
Please run $(BOLD)util/qmk_install.sh$(NO_COLOR) to install all the dependencies QMK requires.\n\n
MSG_FLASH_BOOTLOADER = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's bootloader is not specified or is not supported by the \":flash\" target at this time.\n\n
MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n
diff --git a/nix/poetry.lock b/nix/poetry.lock
new file mode 100644
index 0000000000..74d6e7dd58
--- /dev/null
+++ b/nix/poetry.lock
@@ -0,0 +1,369 @@
+[[package]]
+name = "appdirs"
+version = "1.4.4"
+description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "argcomplete"
+version = "1.12.2"
+description = "Bash tab completion for argparse"
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.extras]
+test = ["coverage", "flake8", "pexpect", "wheel"]
+
+[[package]]
+name = "attrs"
+version = "20.3.0"
+description = "Classes Without Boilerplate"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+
+[package.extras]
+dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface", "furo", "sphinx", "pre-commit"]
+docs = ["furo", "sphinx", "zope.interface"]
+tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"]
+tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six"]
+
+[[package]]
+name = "colorama"
+version = "0.4.4"
+description = "Cross-platform colored terminal text."
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+
+[[package]]
+name = "coverage"
+version = "5.5"
+description = "Code coverage measurement for Python"
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
+
+[package.extras]
+toml = ["toml"]
+
+[[package]]
+name = "dotty-dict"
+version = "1.3.0"
+description = "Dictionary wrapper for quick access to deeply nested keys."
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+setuptools_scm = "*"
+
+[[package]]
+name = "flake8"
+version = "3.9.0"
+description = "the modular source code checker: pep8 pyflakes and co"
+category = "dev"
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
+
+[package.dependencies]
+mccabe = ">=0.6.0,<0.7.0"
+pycodestyle = ">=2.7.0,<2.8.0"
+pyflakes = ">=2.3.0,<2.4.0"
+
+[[package]]
+name = "flake8-polyfill"
+version = "1.0.2"
+description = "Polyfill package for Flake8 plugins"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+flake8 = "*"
+
+[[package]]
+name = "hjson"
+version = "3.0.2"
+description = "Hjson, a user interface for JSON."
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "jsonschema"
+version = "3.2.0"
+description = "An implementation of JSON Schema validation for Python"
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+attrs = ">=17.4.0"
+pyrsistent = ">=0.14.0"
+six = ">=1.11.0"
+
+[package.extras]
+format = ["idna", "jsonpointer (>1.13)", "rfc3987", "strict-rfc3339", "webcolors"]
+format_nongpl = ["idna", "jsonpointer (>1.13)", "webcolors", "rfc3986-validator (>0.1.0)", "rfc3339-validator"]
+
+[[package]]
+name = "mccabe"
+version = "0.6.1"
+description = "McCabe checker, plugin for flake8"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "milc"
+version = "1.3.0"
+description = "Opinionated Batteries-Included Python 3 CLI Framework."
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+appdirs = "*"
+argcomplete = "*"
+colorama = "*"
+
+[[package]]
+name = "nose2"
+version = "0.10.0"
+description = "unittest2 with plugins, the succesor to nose"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+coverage = ">=4.4.1"
+six = ">=1.7"
+
+[package.extras]
+coverage_plugin = ["coverage (>=4.4.1)"]
+dev = ["Sphinx (>=1.6.5)", "sphinx-rtd-theme", "mock", "coverage"]
+
+[[package]]
+name = "pep8-naming"
+version = "0.11.1"
+description = "Check PEP-8 naming conventions, plugin for flake8"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+flake8-polyfill = ">=1.0.2,<2"
+
+[[package]]
+name = "pycodestyle"
+version = "2.7.0"
+description = "Python style guide checker"
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+
+[[package]]
+name = "pyflakes"
+version = "2.3.1"
+description = "passive checker of Python programs"
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+
+[[package]]
+name = "pygments"
+version = "2.8.1"
+description = "Pygments is a syntax highlighting package written in Python."
+category = "main"
+optional = false
+python-versions = ">=3.5"
+
+[[package]]
+name = "pyrsistent"
+version = "0.17.3"
+description = "Persistent/Functional/Immutable data structures"
+category = "main"
+optional = false
+python-versions = ">=3.5"
+
+[[package]]
+name = "setuptools-scm"
+version = "6.0.1"
+description = "the blessed package to manage your versions by scm tags"
+category = "main"
+optional = false
+python-versions = ">=3.6"
+
+[package.extras]
+toml = ["toml"]
+
+[[package]]
+name = "six"
+version = "1.15.0"
+description = "Python 2 and 3 compatibility utilities"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
+
+[[package]]
+name = "wave"
+version = "0.0.2"
+description = "Whole Architecture Verification"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "yapf"
+version = "0.30.0"
+description = "A formatter for Python code."
+category = "dev"
+optional = false
+python-versions = "*"
+
+[metadata]
+lock-version = "1.1"
+python-versions = "^3.8"
+content-hash = "6adb87c61d9eacf55e4e80bc6c73325e4e4854a792e3881ff448b6ee1cb75091"
+
+[metadata.files]
+appdirs = [
+ {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"},
+ {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"},
+]
+argcomplete = [
+ {file = "argcomplete-1.12.2-py2.py3-none-any.whl", hash = "sha256:17f01a9b9b9ece3e6b07058eae737ad6e10de8b4e149105f84614783913aba71"},
+ {file = "argcomplete-1.12.2.tar.gz", hash = "sha256:de0e1282330940d52ea92a80fea2e4b9e0da1932aaa570f84d268939d1897b04"},
+]
+attrs = [
+ {file = "attrs-20.3.0-py2.py3-none-any.whl", hash = "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6"},
+ {file = "attrs-20.3.0.tar.gz", hash = "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700"},
+]
+colorama = [
+ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
+ {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
+]
+coverage = [
+ {file = "coverage-5.5-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:b6d534e4b2ab35c9f93f46229363e17f63c53ad01330df9f2d6bd1187e5eaacf"},
+ {file = "coverage-5.5-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:b7895207b4c843c76a25ab8c1e866261bcfe27bfaa20c192de5190121770672b"},
+ {file = "coverage-5.5-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:c2723d347ab06e7ddad1a58b2a821218239249a9e4365eaff6649d31180c1669"},
+ {file = "coverage-5.5-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:900fbf7759501bc7807fd6638c947d7a831fc9fdf742dc10f02956ff7220fa90"},
+ {file = "coverage-5.5-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:004d1880bed2d97151facef49f08e255a20ceb6f9432df75f4eef018fdd5a78c"},
+ {file = "coverage-5.5-cp27-cp27m-win32.whl", hash = "sha256:06191eb60f8d8a5bc046f3799f8a07a2d7aefb9504b0209aff0b47298333302a"},
+ {file = "coverage-5.5-cp27-cp27m-win_amd64.whl", hash = "sha256:7501140f755b725495941b43347ba8a2777407fc7f250d4f5a7d2a1050ba8e82"},
+ {file = "coverage-5.5-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:372da284cfd642d8e08ef606917846fa2ee350f64994bebfbd3afb0040436905"},
+ {file = "coverage-5.5-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:8963a499849a1fc54b35b1c9f162f4108017b2e6db2c46c1bed93a72262ed083"},
+ {file = "coverage-5.5-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:869a64f53488f40fa5b5b9dcb9e9b2962a66a87dab37790f3fcfb5144b996ef5"},
+ {file = "coverage-5.5-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:4a7697d8cb0f27399b0e393c0b90f0f1e40c82023ea4d45d22bce7032a5d7b81"},
+ {file = "coverage-5.5-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:8d0a0725ad7c1a0bcd8d1b437e191107d457e2ec1084b9f190630a4fb1af78e6"},
+ {file = "coverage-5.5-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:51cb9476a3987c8967ebab3f0fe144819781fca264f57f89760037a2ea191cb0"},
+ {file = "coverage-5.5-cp310-cp310-win_amd64.whl", hash = "sha256:c0891a6a97b09c1f3e073a890514d5012eb256845c451bd48f7968ef939bf4ae"},
+ {file = "coverage-5.5-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:3487286bc29a5aa4b93a072e9592f22254291ce96a9fbc5251f566b6b7343cdb"},
+ {file = "coverage-5.5-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:deee1077aae10d8fa88cb02c845cfba9b62c55e1183f52f6ae6a2df6a2187160"},
+ {file = "coverage-5.5-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:f11642dddbb0253cc8853254301b51390ba0081750a8ac03f20ea8103f0c56b6"},
+ {file = "coverage-5.5-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:6c90e11318f0d3c436a42409f2749ee1a115cd8b067d7f14c148f1ce5574d701"},
+ {file = "coverage-5.5-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:30c77c1dc9f253283e34c27935fded5015f7d1abe83bc7821680ac444eaf7793"},
+ {file = "coverage-5.5-cp35-cp35m-win32.whl", hash = "sha256:9a1ef3b66e38ef8618ce5fdc7bea3d9f45f3624e2a66295eea5e57966c85909e"},
+ {file = "coverage-5.5-cp35-cp35m-win_amd64.whl", hash = "sha256:972c85d205b51e30e59525694670de6a8a89691186012535f9d7dbaa230e42c3"},
+ {file = "coverage-5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:af0e781009aaf59e25c5a678122391cb0f345ac0ec272c7961dc5455e1c40066"},
+ {file = "coverage-5.5-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:74d881fc777ebb11c63736622b60cb9e4aee5cace591ce274fb69e582a12a61a"},
+ {file = "coverage-5.5-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:92b017ce34b68a7d67bd6d117e6d443a9bf63a2ecf8567bb3d8c6c7bc5014465"},
+ {file = "coverage-5.5-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:d636598c8305e1f90b439dbf4f66437de4a5e3c31fdf47ad29542478c8508bbb"},
+ {file = "coverage-5.5-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:41179b8a845742d1eb60449bdb2992196e211341818565abded11cfa90efb821"},
+ {file = "coverage-5.5-cp36-cp36m-win32.whl", hash = "sha256:040af6c32813fa3eae5305d53f18875bedd079960822ef8ec067a66dd8afcd45"},
+ {file = "coverage-5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:5fec2d43a2cc6965edc0bb9e83e1e4b557f76f843a77a2496cbe719583ce8184"},
+ {file = "coverage-5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:18ba8bbede96a2c3dde7b868de9dcbd55670690af0988713f0603f037848418a"},
+ {file = "coverage-5.5-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:2910f4d36a6a9b4214bb7038d537f015346f413a975d57ca6b43bf23d6563b53"},
+ {file = "coverage-5.5-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:f0b278ce10936db1a37e6954e15a3730bea96a0997c26d7fee88e6c396c2086d"},
+ {file = "coverage-5.5-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:796c9c3c79747146ebd278dbe1e5c5c05dd6b10cc3bcb8389dfdf844f3ead638"},
+ {file = "coverage-5.5-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:53194af30d5bad77fcba80e23a1441c71abfb3e01192034f8246e0d8f99528f3"},
+ {file = "coverage-5.5-cp37-cp37m-win32.whl", hash = "sha256:184a47bbe0aa6400ed2d41d8e9ed868b8205046518c52464fde713ea06e3a74a"},
+ {file = "coverage-5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:2949cad1c5208b8298d5686d5a85b66aae46d73eec2c3e08c817dd3513e5848a"},
+ {file = "coverage-5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:217658ec7187497e3f3ebd901afdca1af062b42cfe3e0dafea4cced3983739f6"},
+ {file = "coverage-5.5-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1aa846f56c3d49205c952d8318e76ccc2ae23303351d9270ab220004c580cfe2"},
+ {file = "coverage-5.5-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:24d4a7de75446be83244eabbff746d66b9240ae020ced65d060815fac3423759"},
+ {file = "coverage-5.5-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d1f8bf7b90ba55699b3a5e44930e93ff0189aa27186e96071fac7dd0d06a1873"},
+ {file = "coverage-5.5-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:970284a88b99673ccb2e4e334cfb38a10aab7cd44f7457564d11898a74b62d0a"},
+ {file = "coverage-5.5-cp38-cp38-win32.whl", hash = "sha256:01d84219b5cdbfc8122223b39a954820929497a1cb1422824bb86b07b74594b6"},
+ {file = "coverage-5.5-cp38-cp38-win_amd64.whl", hash = "sha256:2e0d881ad471768bf6e6c2bf905d183543f10098e3b3640fc029509530091502"},
+ {file = "coverage-5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d1f9ce122f83b2305592c11d64f181b87153fc2c2bbd3bb4a3dde8303cfb1a6b"},
+ {file = "coverage-5.5-cp39-cp39-manylinux1_i686.whl", hash = "sha256:13c4ee887eca0f4c5a247b75398d4114c37882658300e153113dafb1d76de529"},
+ {file = "coverage-5.5-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:52596d3d0e8bdf3af43db3e9ba8dcdaac724ba7b5ca3f6358529d56f7a166f8b"},
+ {file = "coverage-5.5-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:2cafbbb3af0733db200c9b5f798d18953b1a304d3f86a938367de1567f4b5bff"},
+ {file = "coverage-5.5-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:44d654437b8ddd9eee7d1eaee28b7219bec228520ff809af170488fd2fed3e2b"},
+ {file = "coverage-5.5-cp39-cp39-win32.whl", hash = "sha256:d314ed732c25d29775e84a960c3c60808b682c08d86602ec2c3008e1202e3bb6"},
+ {file = "coverage-5.5-cp39-cp39-win_amd64.whl", hash = "sha256:13034c4409db851670bc9acd836243aeee299949bd5673e11844befcb0149f03"},
+ {file = "coverage-5.5-pp36-none-any.whl", hash = "sha256:f030f8873312a16414c0d8e1a1ddff2d3235655a2174e3648b4fa66b3f2f1079"},
+ {file = "coverage-5.5-pp37-none-any.whl", hash = "sha256:2a3859cb82dcbda1cfd3e6f71c27081d18aa251d20a17d87d26d4cd216fb0af4"},
+ {file = "coverage-5.5.tar.gz", hash = "sha256:ebe78fe9a0e874362175b02371bdfbee64d8edc42a044253ddf4ee7d3c15212c"},
+]
+dotty-dict = [
+ {file = "dotty_dict-1.3.0.tar.gz", hash = "sha256:eb0035a3629ecd84397a68f1f42f1e94abd1c34577a19cd3eacad331ee7cbaf0"},
+]
+flake8 = [
+ {file = "flake8-3.9.0-py2.py3-none-any.whl", hash = "sha256:12d05ab02614b6aee8df7c36b97d1a3b2372761222b19b58621355e82acddcff"},
+ {file = "flake8-3.9.0.tar.gz", hash = "sha256:78873e372b12b093da7b5e5ed302e8ad9e988b38b063b61ad937f26ca58fc5f0"},
+]
+flake8-polyfill = [
+ {file = "flake8-polyfill-1.0.2.tar.gz", hash = "sha256:e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda"},
+ {file = "flake8_polyfill-1.0.2-py2.py3-none-any.whl", hash = "sha256:12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9"},
+]
+hjson = [
+ {file = "hjson-3.0.2-py3-none-any.whl", hash = "sha256:5546438bf4e1b52bc964c6a47c4ed10fa5fba8a1b264e22efa893e333baad2db"},
+ {file = "hjson-3.0.2.tar.gz", hash = "sha256:2838fd7200e5839ea4516ece953f3a19892c41089f0d933ba3f68e596aacfcd5"},
+]
+jsonschema = [
+ {file = "jsonschema-3.2.0-py2.py3-none-any.whl", hash = "sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163"},
+ {file = "jsonschema-3.2.0.tar.gz", hash = "sha256:c8a85b28d377cc7737e46e2d9f2b4f44ee3c0e1deac6bf46ddefc7187d30797a"},
+]
+mccabe = [
+ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
+ {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
+]
+milc = [
+ {file = "milc-1.3.0-py2.py3-none-any.whl", hash = "sha256:a4dd8ce77f1d4ac5e08311eecc6954c349d4032d7ed4e0335822e09740514f22"},
+ {file = "milc-1.3.0.tar.gz", hash = "sha256:a9d0299aaaef7a3f00010589c3c0d0669798467e397580620a68e9290b36cdda"},
+]
+nose2 = [
+ {file = "nose2-0.10.0-py2.py3-none-any.whl", hash = "sha256:aa620e759f2c5018d9ba041340391913e282ecebd3c392027f1575847b093ec6"},
+ {file = "nose2-0.10.0.tar.gz", hash = "sha256:886ba617a96de0130c54b24479bd5c2d74d5c940d40f3809c3a275511a0c4a60"},
+]
+pep8-naming = [
+ {file = "pep8-naming-0.11.1.tar.gz", hash = "sha256:a1dd47dd243adfe8a83616e27cf03164960b507530f155db94e10b36a6cd6724"},
+ {file = "pep8_naming-0.11.1-py2.py3-none-any.whl", hash = "sha256:f43bfe3eea7e0d73e8b5d07d6407ab47f2476ccaeff6937c84275cd30b016738"},
+]
+pycodestyle = [
+ {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"},
+ {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"},
+]
+pyflakes = [
+ {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"},
+ {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"},
+]
+pygments = [
+ {file = "Pygments-2.8.1-py3-none-any.whl", hash = "sha256:534ef71d539ae97d4c3a4cf7d6f110f214b0e687e92f9cb9d2a3b0d3101289c8"},
+ {file = "Pygments-2.8.1.tar.gz", hash = "sha256:2656e1a6edcdabf4275f9a3640db59fd5de107d88e8663c5d4e9a0fa62f77f94"},
+]
+pyrsistent = [
+ {file = "pyrsistent-0.17.3.tar.gz", hash = "sha256:2e636185d9eb976a18a8a8e96efce62f2905fea90041958d8cc2a189756ebf3e"},
+]
+setuptools-scm = [
+ {file = "setuptools_scm-6.0.1-py3-none-any.whl", hash = "sha256:c3bd5f701c8def44a5c0bfe8d407bef3f80342217ef3492b951f3777bd2d915c"},
+ {file = "setuptools_scm-6.0.1.tar.gz", hash = "sha256:d1925a69cb07e9b29416a275b9fadb009a23c148ace905b2fb220649a6c18e92"},
+]
+six = [
+ {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
+ {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
+]
+wave = [
+ {file = "Wave-0.0.2.tar.gz", hash = "sha256:5a895bb85e04e38c82dba90d66a5ae8f488b50c58f3fc4df868a5bcdcabb8632"},
+ {file = "Wave-0.0.2.zip", hash = "sha256:5187f49497287d218cc83d4cd1e5299dc31485ab3ed32abbaa9e95d8f73c4095"},
+]
+yapf = [
+ {file = "yapf-0.30.0-py2.py3-none-any.whl", hash = "sha256:3abf61ba67cf603069710d30acbc88cfe565d907e16ad81429ae90ce9651e0c9"},
+ {file = "yapf-0.30.0.tar.gz", hash = "sha256:3000abee4c28daebad55da6c85f3cd07b8062ce48e2e9943c8da1b9667d48427"},
+]
diff --git a/nix/pyproject.toml b/nix/pyproject.toml
new file mode 100644
index 0000000000..62d49fad59
--- /dev/null
+++ b/nix/pyproject.toml
@@ -0,0 +1,30 @@
+# This file should be kept in sync with requirements.txt and requirements-dev.txt
+# It is particularly required by the Nix environment (see shell.nix). To update versions,
+# normally one would run "poetry update --lock"
+[tool.poetry]
+name = "qmk"
+version = "0.1.0"
+description = ""
+authors = []
+
+[tool.poetry.dependencies]
+python = "^3.8"
+appdirs = "^1.4.4"
+argcomplete = "^1.12.2"
+colorama = "^0.4.4"
+hjson = "^3.0.2"
+milc = "^1.1.0"
+Pygments = "^2.8.0"
+dotty-dict = "^1.3.0"
+jsonschema = "^3.2.0"
+
+[tool.poetry.dev-dependencies]
+nose2 = "^0.10.0"
+flake8 = "^3.8.4"
+pep8-naming = "^0.11.1"
+yapf = "^0.30.0"
+Wave = "^0.0.2"
+
+[build-system]
+requires = ["poetry-core>=1.0.0"]
+build-backend = "poetry.core.masonry.api"
diff --git a/nix/sources.json b/nix/sources.json
new file mode 100644
index 0000000000..7afca37073
--- /dev/null
+++ b/nix/sources.json
@@ -0,0 +1,26 @@
+{
+ "niv": {
+ "branch": "master",
+ "description": "Easy dependency management for Nix projects",
+ "homepage": "https://github.com/nmattia/niv",
+ "owner": "nmattia",
+ "repo": "niv",
+ "rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e",
+ "sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n",
+ "type": "tarball",
+ "url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz",
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
+ },
+ "nixpkgs": {
+ "branch": "nixpkgs-unstable",
+ "description": "Nix Packages collection",
+ "homepage": "",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "c0e881852006b132236cbf0301bd1939bb50867e",
+ "sha256": "0fy7z7yxk5n7yslsvx5cyc6h21qwi4bhxf3awhirniszlbvaazy2",
+ "type": "tarball",
+ "url": "https://github.com/NixOS/nixpkgs/archive/c0e881852006b132236cbf0301bd1939bb50867e.tar.gz",
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
+ }
+}
diff --git a/nix/sources.nix b/nix/sources.nix
new file mode 100644
index 0000000000..1938409ddd
--- /dev/null
+++ b/nix/sources.nix
@@ -0,0 +1,174 @@
+# This file has been generated by Niv.
+
+let
+
+ #
+ # The fetchers. fetch_<type> fetches specs of type <type>.
+ #
+
+ fetch_file = pkgs: name: spec:
+ let
+ name' = sanitizeName name + "-src";
+ in
+ if spec.builtin or true then
+ builtins_fetchurl { inherit (spec) url sha256; name = name'; }
+ else
+ pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
+
+ fetch_tarball = pkgs: name: spec:
+ let
+ name' = sanitizeName name + "-src";
+ in
+ if spec.builtin or true then
+ builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
+ else
+ pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
+
+ fetch_git = name: spec:
+ let
+ ref =
+ if spec ? ref then spec.ref else
+ if spec ? branch then "refs/heads/${spec.branch}" else
+ if spec ? tag then "refs/tags/${spec.tag}" else
+ abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
+ in
+ builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
+
+ fetch_local = spec: spec.path;
+
+ fetch_builtin-tarball = name: throw
+ ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
+ $ niv modify ${name} -a type=tarball -a builtin=true'';
+
+ fetch_builtin-url = name: throw
+ ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
+ $ niv modify ${name} -a type=file -a builtin=true'';
+
+ #
+ # Various helpers
+ #
+
+ # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
+ sanitizeName = name:
+ (
+ concatMapStrings (s: if builtins.isList s then "-" else s)
+ (
+ builtins.split "[^[:alnum:]+._?=-]+"
+ ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
+ )
+ );
+
+ # The set of packages used when specs are fetched using non-builtins.
+ mkPkgs = sources: system:
+ let
+ sourcesNixpkgs =
+ import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
+ hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
+ hasThisAsNixpkgsPath = <nixpkgs> == ./.;
+ in
+ if builtins.hasAttr "nixpkgs" sources
+ then sourcesNixpkgs
+ else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
+ import <nixpkgs> {}
+ else
+ abort
+ ''
+ Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
+ add a package called "nixpkgs" to your sources.json.
+ '';
+
+ # The actual fetching function.
+ fetch = pkgs: name: spec:
+
+ if ! builtins.hasAttr "type" spec then
+ abort "ERROR: niv spec ${name} does not have a 'type' attribute"
+ else if spec.type == "file" then fetch_file pkgs name spec
+ else if spec.type == "tarball" then fetch_tarball pkgs name spec
+ else if spec.type == "git" then fetch_git name spec
+ else if spec.type == "local" then fetch_local spec
+ else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
+ else if spec.type == "builtin-url" then fetch_builtin-url name
+ else
+ abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
+
+ # If the environment variable NIV_OVERRIDE_${name} is set, then use
+ # the path directly as opposed to the fetched source.
+ replace = name: drv:
+ let
+ saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
+ ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
+ in
+ if ersatz == "" then drv else
+ # this turns the string into an actual Nix path (for both absolute and
+ # relative paths)
+ if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
+
+ # Ports of functions for older nix versions
+
+ # a Nix version of mapAttrs if the built-in doesn't exist
+ mapAttrs = builtins.mapAttrs or (
+ f: set: with builtins;
+ listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
+ );
+
+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
+ range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
+
+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
+ stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
+
+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
+ stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
+ concatMapStrings = f: list: concatStrings (map f list);
+ concatStrings = builtins.concatStringsSep "";
+
+ # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
+ optionalAttrs = cond: as: if cond then as else {};
+
+ # fetchTarball version that is compatible between all the versions of Nix
+ builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
+ let
+ inherit (builtins) lessThan nixVersion fetchTarball;
+ in
+ if lessThan nixVersion "1.12" then
+ fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
+ else
+ fetchTarball attrs;
+
+ # fetchurl version that is compatible between all the versions of Nix
+ builtins_fetchurl = { url, name ? null, sha256 }@attrs:
+ let
+ inherit (builtins) lessThan nixVersion fetchurl;
+ in
+ if lessThan nixVersion "1.12" then
+ fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
+ else
+ fetchurl attrs;
+
+ # Create the final "sources" from the config
+ mkSources = config:
+ mapAttrs (
+ name: spec:
+ if builtins.hasAttr "outPath" spec
+ then abort
+ "The values in sources.json should not have an 'outPath' attribute"
+ else
+ spec // { outPath = replace name (fetch config.pkgs name spec); }
+ ) config.sources;
+
+ # The "config" used by the fetchers
+ mkConfig =
+ { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
+ , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
+ , system ? builtins.currentSystem
+ , pkgs ? mkPkgs sources system
+ }: rec {
+ # The sources, i.e. the attribute set of spec name to spec
+ inherit sources;
+
+ # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
+ inherit pkgs;
+ };
+
+in
+mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
diff --git a/platforms/chibios/BLACKPILL_STM32_F401/configs/config.h b/platforms/chibios/BLACKPILL_STM32_F401/configs/config.h
index 1c9d9c6126..e181422eba 100644
--- a/platforms/chibios/BLACKPILL_STM32_F401/configs/config.h
+++ b/platforms/chibios/BLACKPILL_STM32_F401/configs/config.h
@@ -17,8 +17,13 @@
#define BOARD_OTG_NOVBUSSENS 1
-#define STM32_LSECLK 32768U
-#define STM32_HSECLK 25000000U
+#ifndef STM32_LSECLK
+# define STM32_LSECLK 32768U
+#endif // STM32_LSECLK
+
+#ifndef STM32_HSECLK
+# define STM32_HSECLK 25000000U
+#endif // STM32_HSECLK
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
diff --git a/platforms/chibios/BLACKPILL_STM32_F411/configs/chconf.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/chconf.h
deleted file mode 100644
index 7dc4f84a8a..0000000000
--- a/platforms/chibios/BLACKPILL_STM32_F411/configs/chconf.h
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/**
- * @file rt/templates/chconf.h
- * @brief Configuration file template.
- * @details A copy of this file must be placed in each project directory, it
- * contains the application specific kernel settings.
- *
- * @addtogroup config
- * @details Kernel related settings and hooks.
- * @{
- */
-
-#ifndef CHCONF_H
-#define CHCONF_H
-
-#define _CHIBIOS_RT_CONF_
-#define _CHIBIOS_RT_CONF_VER_6_0_
-
-/*===========================================================================*/
-/**
- * @name System timers settings
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief System time counter resolution.
- * @note Allowed values are 16 or 32 bits.
- */
-#if !defined(CH_CFG_ST_RESOLUTION)
-#define CH_CFG_ST_RESOLUTION 32
-#endif
-
-/**
- * @brief System tick frequency.
- * @details Frequency of the system timer that drives the system ticks. This
- * setting also defines the system tick time unit.
- */
-#if !defined(CH_CFG_ST_FREQUENCY)
-#define CH_CFG_ST_FREQUENCY 10000
-#endif
-
-/**
- * @brief Time intervals data size.
- * @note Allowed values are 16, 32 or 64 bits.
- */
-#if !defined(CH_CFG_INTERVALS_SIZE)
-#define CH_CFG_INTERVALS_SIZE 32
-#endif
-
-/**
- * @brief Time types data size.
- * @note Allowed values are 16 or 32 bits.
- */
-#if !defined(CH_CFG_TIME_TYPES_SIZE)
-#define CH_CFG_TIME_TYPES_SIZE 32
-#endif
-
-/**
- * @brief Time delta constant for the tick-less mode.
- * @note If this value is zero then the system uses the classic
- * periodic tick. This value represents the minimum number
- * of ticks that is safe to specify in a timeout directive.
- * The value one is not valid, timeouts are rounded up to
- * this value.
- */
-#if !defined(CH_CFG_ST_TIMEDELTA)
-#define CH_CFG_ST_TIMEDELTA 2
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Kernel parameters and options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief Round robin interval.
- * @details This constant is the number of system ticks allowed for the
- * threads before preemption occurs. Setting this value to zero
- * disables the preemption for threads with equal priority and the
- * round robin becomes cooperative. Note that higher priority
- * threads can still preempt, the kernel is always preemptive.
- * @note Disabling the round robin preemption makes the kernel more compact
- * and generally faster.
- * @note The round robin preemption is not supported in tickless mode and
- * must be set to zero in that case.
- */
-#if !defined(CH_CFG_TIME_QUANTUM)
-#define CH_CFG_TIME_QUANTUM 0
-#endif
-
-/**
- * @brief Managed RAM size.
- * @details Size of the RAM area to be managed by the OS. If set to zero
- * then the whole available RAM is used. The core memory is made
- * available to the heap allocator and/or can be used directly through
- * the simplified core memory allocator.
- *
- * @note In order to let the OS manage the whole RAM the linker script must
- * provide the @p __heap_base__ and @p __heap_end__ symbols.
- * @note Requires @p CH_CFG_USE_MEMCORE.
- */
-#if !defined(CH_CFG_MEMCORE_SIZE)
-#define CH_CFG_MEMCORE_SIZE 0
-#endif
-
-/**
- * @brief Idle thread automatic spawn suppression.
- * @details When this option is activated the function @p chSysInit()
- * does not spawn the idle thread. The application @p main()
- * function becomes the idle thread and must implement an
- * infinite loop.
- */
-#if !defined(CH_CFG_NO_IDLE_THREAD)
-#define CH_CFG_NO_IDLE_THREAD FALSE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Performance options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief OS optimization.
- * @details If enabled then time efficient rather than space efficient code
- * is used when two possible implementations exist.
- *
- * @note This is not related to the compiler optimization options.
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_OPTIMIZE_SPEED)
-#define CH_CFG_OPTIMIZE_SPEED TRUE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Subsystem options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief Time Measurement APIs.
- * @details If enabled then the time measurement APIs are included in
- * the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_TM)
-#define CH_CFG_USE_TM TRUE
-#endif
-
-/**
- * @brief Threads registry APIs.
- * @details If enabled then the registry APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_REGISTRY)
-#define CH_CFG_USE_REGISTRY TRUE
-#endif
-
-/**
- * @brief Threads synchronization APIs.
- * @details If enabled then the @p chThdWait() function is included in
- * the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_WAITEXIT)
-#define CH_CFG_USE_WAITEXIT TRUE
-#endif
-
-/**
- * @brief Semaphores APIs.
- * @details If enabled then the Semaphores APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES)
-#define CH_CFG_USE_SEMAPHORES TRUE
-#endif
-
-/**
- * @brief Semaphores queuing mode.
- * @details If enabled then the threads are enqueued on semaphores by
- * priority rather than in FIFO order.
- *
- * @note The default is @p FALSE. Enable this if you have special
- * requirements.
- * @note Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
-#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
-#endif
-
-/**
- * @brief Mutexes APIs.
- * @details If enabled then the mutexes APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MUTEXES)
-#define CH_CFG_USE_MUTEXES TRUE
-#endif
-
-/**
- * @brief Enables recursive behavior on mutexes.
- * @note Recursive mutexes are heavier and have an increased
- * memory footprint.
- *
- * @note The default is @p FALSE.
- * @note Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
-#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
-#endif
-
-/**
- * @brief Conditional Variables APIs.
- * @details If enabled then the conditional variables APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_CONDVARS)
-#define CH_CFG_USE_CONDVARS TRUE
-#endif
-
-/**
- * @brief Conditional Variables APIs with timeout.
- * @details If enabled then the conditional variables APIs with timeout
- * specification are included in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_CONDVARS.
- */
-#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
-#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
-#endif
-
-/**
- * @brief Events Flags APIs.
- * @details If enabled then the event flags APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_EVENTS)
-#define CH_CFG_USE_EVENTS TRUE
-#endif
-
-/**
- * @brief Events Flags APIs with timeout.
- * @details If enabled then the events APIs with timeout specification
- * are included in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_EVENTS.
- */
-#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
-#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
-#endif
-
-/**
- * @brief Synchronous Messages APIs.
- * @details If enabled then the synchronous messages APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MESSAGES)
-#define CH_CFG_USE_MESSAGES TRUE
-#endif
-
-/**
- * @brief Synchronous Messages queuing mode.
- * @details If enabled then messages are served by priority rather than in
- * FIFO order.
- *
- * @note The default is @p FALSE. Enable this if you have special
- * requirements.
- * @note Requires @p CH_CFG_USE_MESSAGES.
- */
-#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
-#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
-#endif
-
-/**
- * @brief Mailboxes APIs.
- * @details If enabled then the asynchronous messages (mailboxes) APIs are
- * included in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_MAILBOXES)
-#define CH_CFG_USE_MAILBOXES TRUE
-#endif
-
-/**
- * @brief Core Memory Manager APIs.
- * @details If enabled then the core memory manager APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMCORE)
-#define CH_CFG_USE_MEMCORE TRUE
-#endif
-
-/**
- * @brief Heap Allocator APIs.
- * @details If enabled then the memory heap allocator APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
- * @p CH_CFG_USE_SEMAPHORES.
- * @note Mutexes are recommended.
- */
-#if !defined(CH_CFG_USE_HEAP)
-#define CH_CFG_USE_HEAP TRUE
-#endif
-
-/**
- * @brief Memory Pools Allocator APIs.
- * @details If enabled then the memory pools allocator APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMPOOLS)
-#define CH_CFG_USE_MEMPOOLS TRUE
-#endif
-
-/**
- * @brief Objects FIFOs APIs.
- * @details If enabled then the objects FIFOs APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_OBJ_FIFOS)
-#define CH_CFG_USE_OBJ_FIFOS TRUE
-#endif
-
-/**
- * @brief Pipes APIs.
- * @details If enabled then the pipes APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_PIPES)
-#define CH_CFG_USE_PIPES TRUE
-#endif
-
-/**
- * @brief Dynamic Threads APIs.
- * @details If enabled then the dynamic threads creation APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_WAITEXIT.
- * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
- */
-#if !defined(CH_CFG_USE_DYNAMIC)
-#define CH_CFG_USE_DYNAMIC TRUE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Objects factory options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief Objects Factory APIs.
- * @details If enabled then the objects factory APIs are included in the
- * kernel.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_CFG_USE_FACTORY)
-#define CH_CFG_USE_FACTORY TRUE
-#endif
-
-/**
- * @brief Maximum length for object names.
- * @details If the specified length is zero then the name is stored by
- * pointer but this could have unintended side effects.
- */
-#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
-#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
-#endif
-
-/**
- * @brief Enables the registry of generic objects.
- */
-#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
-#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
-#endif
-
-/**
- * @brief Enables factory for generic buffers.
- */
-#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
-#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
-#endif
-
-/**
- * @brief Enables factory for semaphores.
- */
-#if !defined(CH_CFG_FACTORY_SEMAPHORES)
-#define CH_CFG_FACTORY_SEMAPHORES TRUE
-#endif
-
-/**
- * @brief Enables factory for mailboxes.
- */
-#if !defined(CH_CFG_FACTORY_MAILBOXES)
-#define CH_CFG_FACTORY_MAILBOXES TRUE
-#endif
-
-/**
- * @brief Enables factory for objects FIFOs.
- */
-#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
-#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
-#endif
-
-/**
- * @brief Enables factory for Pipes.
- */
-#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
-#define CH_CFG_FACTORY_PIPES TRUE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Debug options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief Debug option, kernel statistics.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_STATISTICS)
-#define CH_DBG_STATISTICS FALSE
-#endif
-
-/**
- * @brief Debug option, system state check.
- * @details If enabled the correct call protocol for system APIs is checked
- * at runtime.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
-#define CH_DBG_SYSTEM_STATE_CHECK FALSE
-#endif
-
-/**
- * @brief Debug option, parameters checks.
- * @details If enabled then the checks on the API functions input
- * parameters are activated.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_CHECKS)
-#define CH_DBG_ENABLE_CHECKS FALSE
-#endif
-
-/**
- * @brief Debug option, consistency checks.
- * @details If enabled then all the assertions in the kernel code are
- * activated. This includes consistency checks inside the kernel,
- * runtime anomalies and port-defined checks.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_ASSERTS)
-#define CH_DBG_ENABLE_ASSERTS FALSE
-#endif
-
-/**
- * @brief Debug option, trace buffer.
- * @details If enabled then the trace buffer is activated.
- *
- * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
- */
-#if !defined(CH_DBG_TRACE_MASK)
-#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
-#endif
-
-/**
- * @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.
- */
-#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
-#define CH_DBG_TRACE_BUFFER_SIZE 128
-#endif
-
-/**
- * @brief Debug option, stack checks.
- * @details If enabled then a runtime stack check is performed.
- *
- * @note The default is @p FALSE.
- * @note The stack check is performed in a architecture/port dependent way.
- * It may not be implemented or some ports.
- * @note The default failure mode is to halt the system with the global
- * @p panic_msg variable set to @p NULL.
- */
-#if !defined(CH_DBG_ENABLE_STACK_CHECK)
-#define CH_DBG_ENABLE_STACK_CHECK FALSE
-#endif
-
-/**
- * @brief Debug option, stacks initialization.
- * @details If enabled then the threads working area is filled with a byte
- * value when a thread is created. This can be useful for the
- * runtime measurement of the used stack.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_FILL_THREADS)
-#define CH_DBG_FILL_THREADS FALSE
-#endif
-
-/**
- * @brief Debug option, threads profiling.
- * @details If enabled then a field is added to the @p thread_t structure that
- * counts the system ticks occurred while executing the thread.
- *
- * @note The default is @p FALSE.
- * @note This debug option is not currently compatible with the
- * tickless mode.
- */
-#if !defined(CH_DBG_THREADS_PROFILING)
-#define CH_DBG_THREADS_PROFILING FALSE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Kernel hooks
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief System structure extension.
- * @details User fields added to the end of the @p ch_system_t structure.
- */
-#define CH_CFG_SYSTEM_EXTRA_FIELDS \
- /* Add threads custom fields here.*/
-
-/**
- * @brief System initialization hook.
- * @details User initialization code added to the @p chSysInit() function
- * just before interrupts are enabled globally.
- */
-#define CH_CFG_SYSTEM_INIT_HOOK() { \
- /* Add threads initialization code here.*/ \
-}
-
-/**
- * @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.*/
-
-/**
- * @brief Threads initialization hook.
- * @details User initialization code added to the @p _thread_init() function.
- *
- * @note It is invoked from within @p _thread_init() and implicitly from all
- * the threads creation APIs.
- */
-#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.*/ \
-}
-
-/**
- * @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.*/ \
-}
-
-/**
- * @brief ISR enter hook.
- */
-#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
- /* IRQ prologue code here.*/ \
-}
-
-/**
- * @brief ISR exit hook.
- */
-#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
- /* IRQ epilogue code here.*/ \
-}
-
-/**
- * @brief Idle thread enter hook.
- * @note This hook is invoked within a critical zone, no OS functions
- * 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.*/ \
-}
-
-/**
- * @brief Idle thread leave hook.
- * @note This hook is invoked within a critical zone, no OS functions
- * 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.*/ \
-}
-
-/**
- * @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.*/ \
-}
-
-/**
- * @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.*/ \
-}
-
-/**
- * @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.*/ \
-}
-
-/**
- * @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.*/ \
-}
-
-/** @} */
-
-/*===========================================================================*/
-/* Port-specific settings (override port settings defaulted in chcore.h). */
-/*===========================================================================*/
-
-#endif /* CHCONF_H */
-
-/** @} */
diff --git a/platforms/chibios/BLACKPILL_STM32_F411/configs/config.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/config.h
index 1c9d9c6126..e181422eba 100644
--- a/platforms/chibios/BLACKPILL_STM32_F411/configs/config.h
+++ b/platforms/chibios/BLACKPILL_STM32_F411/configs/config.h
@@ -17,8 +17,13 @@
#define BOARD_OTG_NOVBUSSENS 1
-#define STM32_LSECLK 32768U
-#define STM32_HSECLK 25000000U
+#ifndef STM32_LSECLK
+# define STM32_LSECLK 32768U
+#endif // STM32_LSECLK
+
+#ifndef STM32_HSECLK
+# define STM32_HSECLK 25000000U
+#endif // STM32_HSECLK
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
diff --git a/platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h b/platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h
deleted file mode 100644
index a8db392aaa..0000000000
--- a/platforms/chibios/BLACKPILL_STM32_F411/configs/halconf.h
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/**
- * @file templates/halconf.h
- * @brief HAL configuration header.
- * @details HAL configuration file, this file allows to enable or disable the
- * various device drivers from your application. You may also use
- * this file in order to override the device drivers default settings.
- *
- * @addtogroup HAL_CONF
- * @{
- */
-
-#ifndef HALCONF_H
-#define HALCONF_H
-
-#define _CHIBIOS_HAL_CONF_
-#define _CHIBIOS_HAL_CONF_VER_7_0_
-
-#include "mcuconf.h"
-
-/**
- * @brief Enables the PAL subsystem.
- */
-#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
-
-/**
- * @brief Enables the CAN subsystem.
- */
-#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
-#define HAL_USE_CAN FALSE
-#endif
-
-/**
- * @brief Enables the cryptographic subsystem.
- */
-#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
-#define HAL_USE_CRY FALSE
-#endif
-
-/**
- * @brief Enables the DAC subsystem.
- */
-#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
-#define HAL_USE_DAC FALSE
-#endif
-
-/**
- * @brief Enables the GPT subsystem.
- */
-#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT FALSE
-#endif
-
-/**
- * @brief Enables the I2C subsystem.
- */
-#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C FALSE
-#endif
-
-/**
- * @brief Enables the I2S subsystem.
- */
-#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
-
-/**
- * @brief Enables the MAC subsystem.
- */
-#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
-
-/**
- * @brief Enables the PWM subsystem.
- */
-#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM FALSE
-#endif
-
-/**
- * @brief Enables the RTC subsystem.
- */
-#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
-
-/**
- * @brief Enables the SERIAL subsystem.
- */
-#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 FALSE
-#endif
-
-/**
- * @brief Enables the SIO subsystem.
- */
-#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
-#define HAL_USE_SIO FALSE
-#endif
-
-/**
- * @brief Enables the SPI subsystem.
- */
-#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI FALSE
-#endif
-
-/**
- * @brief Enables the TRNG subsystem.
- */
-#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
-#define HAL_USE_TRNG FALSE
-#endif
-
-/**
- * @brief Enables the UART subsystem.
- */
-#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
-
-/**
- * @brief Enables the WDG subsystem.
- */
-#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
-#define HAL_USE_WDG FALSE
-#endif
-
-/**
- * @brief Enables the WSPI subsystem.
- */
-#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
-#define HAL_USE_WSPI FALSE
-#endif
-
-/*===========================================================================*/
-/* PAL driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables synchronous APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
-#define PAL_USE_CALLBACKS FALSE
-#endif
-
-/**
- * @brief Enables synchronous APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
-#define PAL_USE_WAIT FALSE
-#endif
-
-/*===========================================================================*/
-/* ADC driver related settings. */
-/*===========================================================================*/
-
-/**
- * @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
-
-/**
- * @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
-
-/*===========================================================================*/
-/* CAN driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Sleep mode related APIs inclusion switch.
- */
-#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
-#define CAN_USE_SLEEP_MODE TRUE
-#endif
-
-/**
- * @brief Enforces the driver to use direct callbacks rather than OSAL events.
- */
-#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
-#define CAN_ENFORCE_USE_CALLBACKS FALSE
-#endif
-
-/*===========================================================================*/
-/* CRY driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables the SW fall-back of the cryptographic driver.
- * @details When enabled, this option, activates a fall-back software
- * implementation for algorithms not supported by the underlying
- * hardware.
- * @note Fall-back implementations may not be present for all algorithms.
- */
-#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
-#define HAL_CRY_USE_FALLBACK FALSE
-#endif
-
-/**
- * @brief Makes the driver forcibly use the fall-back implementations.
- */
-#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
-#define HAL_CRY_ENFORCE_FALLBACK FALSE
-#endif
-
-/*===========================================================================*/
-/* DAC driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables synchronous APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
-#define DAC_USE_WAIT TRUE
-#endif
-
-/**
- * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define DAC_USE_MUTUAL_EXCLUSION TRUE
-#endif
-
-/*===========================================================================*/
-/* I2C driver related settings. */
-/*===========================================================================*/
-
-/**
- * @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
-
-/*===========================================================================*/
-/* MAC driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables the zero-copy API.
- */
-#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
-
-/*===========================================================================*/
-/* MMC_SPI driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Delays insertions.
- * @details If enabled this options inserts delays into the MMC waiting
- * routines releasing some extra CPU time for the threads with
- * lower priority, this may slow down the driver a bit however.
- * 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
-
-/*===========================================================================*/
-/* SDC driver related settings. */
-/*===========================================================================*/
-
-/**
- * @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
-
-/**
- * @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
-
-/**
- * @brief Delays insertions.
- * @details If enabled this options inserts delays into the MMC waiting
- * 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
-
-/**
- * @brief OCR initialization constant for V20 cards.
- */
-#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
-#define SDC_INIT_OCR_V20 0x50FF8000U
-#endif
-
-/**
- * @brief OCR initialization constant for non-V20 cards.
- */
-#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
-#define SDC_INIT_OCR 0x80100000U
-#endif
-
-/*===========================================================================*/
-/* SERIAL driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Default bit rate.
- * @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
-
-/**
- * @brief Serial buffers size.
- * @details Configuration parameter, you can change the depth of the queue
- * buffers depending on the requirements of your application.
- * @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
-
-/*===========================================================================*/
-/* SERIAL_USB driver related setting. */
-/*===========================================================================*/
-
-/**
- * @brief Serial over USB buffers size.
- * @details Configuration parameter, the buffer size must be a multiple of
- * the USB data endpoint maximum packet size.
- * @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 256
-#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
-
-/*===========================================================================*/
-/* SPI driver related settings. */
-/*===========================================================================*/
-
-/**
- * @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
-
-/**
- * @brief Enables circular transfers APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
-#define SPI_USE_CIRCULAR FALSE
-#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
-
-/**
- * @brief Handling method for SPI CS line.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
-#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
-#endif
-
-/*===========================================================================*/
-/* UART driver related settings. */
-/*===========================================================================*/
-
-/**
- * @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
-
-/**
- * @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
-
-/*===========================================================================*/
-/* USB driver related settings. */
-/*===========================================================================*/
-
-/**
- * @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
-
-/*===========================================================================*/
-/* WSPI driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables synchronous APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
-#define WSPI_USE_WAIT TRUE
-#endif
-
-/**
- * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define WSPI_USE_MUTUAL_EXCLUSION TRUE
-#endif
-
-#endif /* HALCONF_H */
-
-/** @} */
diff --git a/platforms/chibios/GENERIC_STM32_F042X6/board/board.c b/platforms/chibios/GENERIC_STM32_F042X6/board/board.c
index 3c6f54ef5e..0d7c88756a 100644
--- a/platforms/chibios/GENERIC_STM32_F042X6/board/board.c
+++ b/platforms/chibios/GENERIC_STM32_F042X6/board/board.c
@@ -202,16 +202,12 @@ static void stm32_gpio_init(void) {
/* Driver exported functions. */
/*===========================================================================*/
-__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {}
-
/**
* @brief Early initialization code.
* @details GPIO ports and system clocks are initialized before everything
* else.
*/
void __early_init(void) {
- enter_bootloader_mode_if_requested();
-
stm32_gpio_init();
stm32_clock_init();
}
diff --git a/platforms/chibios/GENERIC_STM32_F072XB/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_F072XB/configs/mcuconf.h
index 688350e9ce..32b2777a81 100644
--- a/platforms/chibios/GENERIC_STM32_F072XB/configs/mcuconf.h
+++ b/platforms/chibios/GENERIC_STM32_F072XB/configs/mcuconf.h
@@ -124,7 +124,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_TIM3 FALSE
#define STM32_PWM_TIM1_IRQ_PRIORITY 3
#define STM32_PWM_TIM2_IRQ_PRIORITY 3
#define STM32_PWM_TIM3_IRQ_PRIORITY 3
@@ -141,11 +141,13 @@
* SPI driver system settings.
*/
#define STM32_SPI_USE_SPI1 FALSE
-#define STM32_SPI_USE_SPI2 TRUE
+#define STM32_SPI_USE_SPI2 FALSE
#define STM32_SPI_SPI1_DMA_PRIORITY 1
#define STM32_SPI_SPI2_DMA_PRIORITY 1
#define STM32_SPI_SPI1_IRQ_PRIORITY 2
#define STM32_SPI_SPI2_IRQ_PRIORITY 2
+#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
diff --git a/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h
index ac2d9a1eed..c6f5a8ac52 100644
--- a/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h
+++ b/platforms/chibios/GENERIC_STM32_F303XC/configs/mcuconf.h
@@ -127,8 +127,8 @@
* 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_USE_DAC1_CH1 FALSE
+#define STM32_DAC_USE_DAC1_CH2 FALSE
#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
@@ -141,10 +141,10 @@
#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_USE_TIM15 TRUE
+#define STM32_GPT_USE_TIM6 FALSE
+#define STM32_GPT_USE_TIM7 FALSE
+#define STM32_GPT_USE_TIM8 FALSE
+#define STM32_GPT_USE_TIM15 FALSE
#define STM32_GPT_USE_TIM16 FALSE
#define STM32_GPT_USE_TIM17 FALSE
#define STM32_GPT_TIM1_IRQ_PRIORITY 7
@@ -158,7 +158,7 @@
/*
* I2C driver system settings.
*/
-#define STM32_I2C_USE_I2C1 TRUE
+#define STM32_I2C_USE_I2C1 FALSE
#define STM32_I2C_USE_I2C2 FALSE
#define STM32_I2C_BUSY_TIMEOUT 50
#define STM32_I2C_I2C1_IRQ_PRIORITY 10
@@ -189,8 +189,8 @@
#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_TIM3 FALSE
+#define STM32_PWM_USE_TIM4 FALSE
#define STM32_PWM_USE_TIM8 FALSE
#define STM32_PWM_USE_TIM15 FALSE
#define STM32_PWM_USE_TIM16 FALSE
@@ -213,7 +213,7 @@
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
-#define STM32_SERIAL_USE_USART2 TRUE
+#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE
@@ -227,7 +227,7 @@
* SPI driver system settings.
*/
#define STM32_SPI_USE_SPI1 FALSE
-#define STM32_SPI_USE_SPI2 TRUE
+#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
diff --git a/platforms/chibios/GENERIC_STM32_G431XB/board/board.mk b/platforms/chibios/GENERIC_STM32_G431XB/board/board.mk
new file mode 100644
index 0000000000..0acbcd83c7
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_G431XB/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G431RB/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G431RB
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/GENERIC_STM32_G431XB/configs/config.h b/platforms/chibios/GENERIC_STM32_G431XB/configs/config.h
new file mode 100644
index 0000000000..39ce627e77
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_G431XB/configs/config.h
@@ -0,0 +1,23 @@
+/* Copyright 2018-2020 Nick Brassel (@tzarc)
+ *
+ * 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/>.
+ */
+
+/* Address for jumping to bootloader on STM32 chips. */
+/* It is chip dependent, the correct number can be looked up here (page 175):
+ * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
+ * This also requires a patch to chibios:
+ * <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
+ */
+#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
diff --git a/platforms/chibios/GENERIC_STM32_G431XB/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_G431XB/configs/mcuconf.h
new file mode 100644
index 0000000000..182d4885d7
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_G431XB/configs/mcuconf.h
@@ -0,0 +1,307 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * STM32G4xx drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the whole
+ * driver is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 15...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...3 Lowest...Highest.
+ */
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+#define STM32G4xx_MCUCONF
+#define STM32G431_MCUCONF
+#define STM32G441_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define STM32_NO_INIT FALSE
+#define STM32_VOS STM32_VOS_RANGE1
+#define STM32_PWR_CR2 (PWR_CR2_PLS_LEV0)
+#define STM32_PWR_CR3 (PWR_CR3_EIWF)
+#define STM32_PWR_CR4 (0U)
+#define STM32_HSI16_ENABLED TRUE
+#define STM32_HSI48_ENABLED TRUE
+#define STM32_HSE_ENABLED FALSE
+#define STM32_LSI_ENABLED TRUE
+#define STM32_LSE_ENABLED FALSE
+#define STM32_SW STM32_SW_PLLRCLK
+#define STM32_PLLSRC STM32_PLLSRC_HSI16
+#define STM32_PLLM_VALUE 4
+#define STM32_PLLN_VALUE 80
+#define STM32_PLLPDIV_VALUE 0
+#define STM32_PLLP_VALUE 7
+#define STM32_PLLQ_VALUE 8
+#define STM32_PLLR_VALUE 2
+#define STM32_HPRE STM32_HPRE_DIV1
+#define STM32_PPRE1 STM32_PPRE1_DIV1
+#define STM32_PPRE2 STM32_PPRE2_DIV1
+#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
+#define STM32_MCOPRE STM32_MCOPRE_DIV1
+#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
+
+/*
+ * Peripherals clock sources.
+ */
+#define STM32_USART1SEL STM32_USART1SEL_SYSCLK
+#define STM32_USART2SEL STM32_USART2SEL_SYSCLK
+#define STM32_USART3SEL STM32_USART3SEL_SYSCLK
+#define STM32_UART4SEL STM32_UART4SEL_SYSCLK
+#define STM32_LPUART1SEL STM32_LPUART1SEL_PCLK1
+#define STM32_I2C1SEL STM32_I2C1SEL_PCLK1
+#define STM32_I2C2SEL STM32_I2C2SEL_PCLK1
+#define STM32_I2C3SEL STM32_I2C3SEL_PCLK1
+#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
+#define STM32_SAI1SEL STM32_SAI1SEL_SYSCLK
+#define STM32_I2S23SEL STM32_I2S23SEL_SYSCLK
+#define STM32_FDCANSEL STM32_FDCANSEL_PCLK1
+#define STM32_CLK48SEL STM32_CLK48SEL_HSI48
+#define STM32_ADC12SEL STM32_ADC12SEL_PLLPCLK
+#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK
+
+/*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY 6
+#define STM32_IRQ_EXTI1_PRIORITY 6
+#define STM32_IRQ_EXTI2_PRIORITY 6
+#define STM32_IRQ_EXTI3_PRIORITY 6
+#define STM32_IRQ_EXTI4_PRIORITY 6
+#define STM32_IRQ_EXTI5_9_PRIORITY 6
+#define STM32_IRQ_EXTI10_15_PRIORITY 6
+#define STM32_IRQ_EXTI164041_PRIORITY 6
+#define STM32_IRQ_EXTI17_PRIORITY 6
+#define STM32_IRQ_EXTI18_PRIORITY 6
+#define STM32_IRQ_EXTI19_PRIORITY 6
+#define STM32_IRQ_EXTI20_PRIORITY 6
+#define STM32_IRQ_EXTI212229_PRIORITY 6
+#define STM32_IRQ_EXTI30_32_PRIORITY 6
+#define STM32_IRQ_EXTI33_PRIORITY 6
+
+#define STM32_IRQ_FDCAN1_PRIORITY 10
+
+#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
+#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
+#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
+#define STM32_IRQ_TIM1_CC_PRIORITY 7
+#define STM32_IRQ_TIM2_PRIORITY 7
+#define STM32_IRQ_TIM3_PRIORITY 7
+#define STM32_IRQ_TIM4_PRIORITY 7
+#define STM32_IRQ_TIM6_PRIORITY 7
+#define STM32_IRQ_TIM7_PRIORITY 7
+#define STM32_IRQ_TIM8_UP_PRIORITY 7
+#define STM32_IRQ_TIM8_CC_PRIORITY 7
+
+#define STM32_IRQ_USART1_PRIORITY 12
+#define STM32_IRQ_USART2_PRIORITY 12
+#define STM32_IRQ_USART3_PRIORITY 12
+#define STM32_IRQ_UART4_PRIORITY 12
+#define STM32_IRQ_LPUART1_PRIORITY 12
+
+/*
+ * 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_ADC1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_ADC_ADC1_DMA_PRIORITY 2
+#define STM32_ADC_ADC2_DMA_PRIORITY 2
+#define STM32_ADC_ADC12_IRQ_PRIORITY 5
+#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
+#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5
+#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV4
+#define STM32_ADC_ADC12_PRESC ADC_CCR_PRESC_DIV2
+
+/*
+ * CAN driver system settings.
+ */
+#define STM32_CAN_USE_FDCAN1 FALSE
+
+/*
+ * DAC driver system settings.
+ */
+#define STM32_DAC_DUAL_MODE FALSE
+#define STM32_DAC_USE_DAC1_CH1 FALSE
+#define STM32_DAC_USE_DAC1_CH2 FALSE
+#define STM32_DAC_USE_DAC3_CH1 FALSE
+#define STM32_DAC_USE_DAC3_CH2 FALSE
+#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC3_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC3_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DAC3_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC3_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC3_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC3_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+
+/*
+ * 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 FALSE
+#define STM32_GPT_USE_TIM7 FALSE
+#define STM32_GPT_USE_TIM8 FALSE
+#define STM32_GPT_USE_TIM15 FALSE
+#define STM32_GPT_USE_TIM16 FALSE
+#define STM32_GPT_USE_TIM17 FALSE
+
+/*
+ * I2C driver system settings.
+ */
+#define STM32_I2C_USE_I2C1 FALSE
+#define STM32_I2C_USE_I2C2 FALSE
+#define STM32_I2C_USE_I2C3 FALSE
+#define STM32_I2C_BUSY_TIMEOUT 50
+#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C1_IRQ_PRIORITY 5
+#define STM32_I2C_I2C2_IRQ_PRIORITY 5
+#define STM32_I2C_I2C3_IRQ_PRIORITY 5
+#define STM32_I2C_I2C1_DMA_PRIORITY 3
+#define STM32_I2C_I2C2_DMA_PRIORITY 3
+#define STM32_I2C_I2C3_DMA_PRIORITY 3
+#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_USE_TIM15 FALSE
+
+/*
+ * PWM driver system settings.
+ */
+#define STM32_PWM_USE_ADVANCED FALSE
+#define STM32_PWM_USE_TIM1 FALSE
+#define STM32_PWM_USE_TIM2 FALSE
+#define STM32_PWM_USE_TIM3 FALSE
+#define STM32_PWM_USE_TIM4 FALSE
+#define STM32_PWM_USE_TIM8 FALSE
+#define STM32_PWM_USE_TIM15 FALSE
+#define STM32_PWM_USE_TIM16 FALSE
+#define STM32_PWM_USE_TIM17 FALSE
+
+/*
+ * RTC driver system settings.
+ */
+
+/*
+ * SDC driver system settings.
+ */
+
+/*
+ * SERIAL driver system settings.
+ */
+#define STM32_SERIAL_USE_USART1 FALSE
+#define STM32_SERIAL_USE_USART2 FALSE
+#define STM32_SERIAL_USE_USART3 FALSE
+#define STM32_SERIAL_USE_UART4 FALSE
+#define STM32_SERIAL_USE_LPUART1 FALSE
+
+/*
+ * 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_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#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
+
+/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
+ * 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_USE_UART4 FALSE
+#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART1_DMA_PRIORITY 0
+#define STM32_UART_USART2_DMA_PRIORITY 0
+#define STM32_UART_USART3_DMA_PRIORITY 0
+#define STM32_UART_UART4_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 5
+#define STM32_USB_USB1_LP_IRQ_PRIORITY 6
+
+/*
+ * WDG driver system settings.
+ */
+#define STM32_WDG_USE_IWDG FALSE
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/GENERIC_STM32_G474XE/board/board.mk b/platforms/chibios/GENERIC_STM32_G474XE/board/board.mk
new file mode 100644
index 0000000000..957adf509b
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_G474XE/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G474RE/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G474RE
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/GENERIC_STM32_G474XE/configs/config.h b/platforms/chibios/GENERIC_STM32_G474XE/configs/config.h
new file mode 100644
index 0000000000..eb74d68e85
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_G474XE/configs/config.h
@@ -0,0 +1,30 @@
+/* Copyright 2020 Nick Brassel (tzarc)
+ *
+ * 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 3 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 <https://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#ifndef STM32_BOOTLOADER_DUAL_BANK
+# define STM32_BOOTLOADER_DUAL_BANK FALSE
+#endif
+
+// To Enter bootloader from `RESET` keycode, you'll need to dedicate a GPIO to
+// charge an RC network on the BOOT0 pin.
+// See the QMK Discord's #hardware channel pins for an example circuit.
+// Insert these two lines into your keyboard's `config.h` file.
+// In the case below, PB7 is selected to charge.
+#if 0
+#define STM32_BOOTLOADER_DUAL_BANK TRUE
+#define STM32_BOOTLOADER_DUAL_BANK_GPIO B7
+#endif \ No newline at end of file
diff --git a/platforms/chibios/GENERIC_STM32_G474XE/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_G474XE/configs/mcuconf.h
new file mode 100644
index 0000000000..117e920e3b
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_G474XE/configs/mcuconf.h
@@ -0,0 +1,372 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * STM32G4xx drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the whole
+ * driver is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 15...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...3 Lowest...Highest.
+ */
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+#define STM32G4xx_MCUCONF
+#define STM32G473_MCUCONF
+#define STM32G483_MCUCONF
+#define STM32G474_MCUCONF
+#define STM32G484_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define STM32_NO_INIT FALSE
+#define STM32_VOS STM32_VOS_RANGE1
+#define STM32_PWR_CR2 (PWR_CR2_PLS_LEV0)
+#define STM32_PWR_CR3 (PWR_CR3_EIWF)
+#define STM32_PWR_CR4 (0U)
+#define STM32_HSI16_ENABLED TRUE
+#define STM32_HSI48_ENABLED TRUE
+#define STM32_HSE_ENABLED FALSE
+#define STM32_LSI_ENABLED FALSE
+#define STM32_LSE_ENABLED FALSE
+#define STM32_SW STM32_SW_PLLRCLK
+#define STM32_PLLSRC STM32_PLLSRC_HSI16
+#define STM32_PLLM_VALUE 2
+#define STM32_PLLN_VALUE 40
+#define STM32_PLLPDIV_VALUE 0
+#define STM32_PLLP_VALUE 7
+#define STM32_PLLQ_VALUE 2
+#define STM32_PLLR_VALUE 2
+#define STM32_HPRE STM32_HPRE_DIV1
+#define STM32_PPRE1 STM32_PPRE1_DIV1
+#define STM32_PPRE2 STM32_PPRE2_DIV1
+#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
+#define STM32_MCOPRE STM32_MCOPRE_DIV1
+#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
+
+/*
+ * Peripherals clock sources.
+ */
+#define STM32_USART1SEL STM32_USART1SEL_SYSCLK
+#define STM32_USART2SEL STM32_USART2SEL_SYSCLK
+#define STM32_USART3SEL STM32_USART3SEL_SYSCLK
+#define STM32_UART4SEL STM32_UART4SEL_SYSCLK
+#define STM32_UART5SEL STM32_UART5SEL_SYSCLK
+#define STM32_LPUART1SEL STM32_LPUART1SEL_PCLK1
+#define STM32_I2C1SEL STM32_I2C1SEL_PCLK1
+#define STM32_I2C2SEL STM32_I2C2SEL_PCLK1
+#define STM32_I2C3SEL STM32_I2C3SEL_PCLK1
+#define STM32_I2C4SEL STM32_I2C4SEL_PCLK1
+#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
+#define STM32_SAI1SEL STM32_SAI1SEL_SYSCLK
+#define STM32_I2S23SEL STM32_I2S23SEL_SYSCLK
+#define STM32_FDCANSEL STM32_FDCANSEL_HSE
+#define STM32_CLK48SEL STM32_CLK48SEL_HSI48
+#define STM32_ADC12SEL STM32_ADC12SEL_PLLPCLK
+#define STM32_ADC345SEL STM32_ADC345SEL_PLLPCLK
+#define STM32_QSPISEL STM32_QSPISEL_SYSCLK
+#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK
+
+/*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY 6
+#define STM32_IRQ_EXTI1_PRIORITY 6
+#define STM32_IRQ_EXTI2_PRIORITY 6
+#define STM32_IRQ_EXTI3_PRIORITY 6
+#define STM32_IRQ_EXTI4_PRIORITY 6
+#define STM32_IRQ_EXTI5_9_PRIORITY 6
+#define STM32_IRQ_EXTI10_15_PRIORITY 6
+#define STM32_IRQ_EXTI164041_PRIORITY 6
+#define STM32_IRQ_EXTI17_PRIORITY 6
+#define STM32_IRQ_EXTI18_PRIORITY 6
+#define STM32_IRQ_EXTI19_PRIORITY 6
+#define STM32_IRQ_EXTI20_PRIORITY 6
+#define STM32_IRQ_EXTI212229_PRIORITY 6
+#define STM32_IRQ_EXTI30_32_PRIORITY 6
+#define STM32_IRQ_EXTI33_PRIORITY 6
+
+#define STM32_IRQ_FDCAN1_PRIORITY 10
+#define STM32_IRQ_FDCAN2_PRIORITY 10
+#define STM32_IRQ_FDCAN3_PRIORITY 10
+
+#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
+#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
+#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
+#define STM32_IRQ_TIM1_CC_PRIORITY 7
+#define STM32_IRQ_TIM2_PRIORITY 7
+#define STM32_IRQ_TIM3_PRIORITY 7
+#define STM32_IRQ_TIM4_PRIORITY 7
+#define STM32_IRQ_TIM5_PRIORITY 7
+#define STM32_IRQ_TIM6_PRIORITY 7
+#define STM32_IRQ_TIM7_PRIORITY 7
+#define STM32_IRQ_TIM8_UP_PRIORITY 7
+#define STM32_IRQ_TIM8_CC_PRIORITY 7
+#define STM32_IRQ_TIM20_UP_PRIORITY 7
+#define STM32_IRQ_TIM20_CC_PRIORITY 7
+
+#define STM32_IRQ_USART1_PRIORITY 12
+#define STM32_IRQ_USART2_PRIORITY 12
+#define STM32_IRQ_USART3_PRIORITY 12
+#define STM32_IRQ_UART4_PRIORITY 12
+#define STM32_IRQ_UART5_PRIORITY 12
+#define STM32_IRQ_LPUART1_PRIORITY 12
+
+/*
+ * 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_ANY
+#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#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_DIV4
+#define STM32_ADC_ADC345_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV4
+#define STM32_ADC_ADC12_PRESC ADC_CCR_PRESC_DIV2
+#define STM32_ADC_ADC345_PRESC ADC_CCR_PRESC_DIV2
+
+/*
+ * CAN driver system settings.
+ */
+#define STM32_CAN_USE_FDCAN1 FALSE
+#define STM32_CAN_USE_FDCAN2 FALSE
+#define STM32_CAN_USE_FDCAN3 FALSE
+
+/*
+ * DAC driver system settings.
+ */
+#define STM32_DAC_DUAL_MODE FALSE
+#define STM32_DAC_USE_DAC1_CH1 FALSE
+#define STM32_DAC_USE_DAC1_CH2 FALSE
+#define STM32_DAC_USE_DAC2_CH1 FALSE
+#define STM32_DAC_USE_DAC3_CH1 FALSE
+#define STM32_DAC_USE_DAC3_CH2 FALSE
+#define STM32_DAC_USE_DAC4_CH1 FALSE
+#define STM32_DAC_USE_DAC4_CH2 FALSE
+#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC2_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC3_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC3_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC4_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC4_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DAC2_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC3_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC3_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DAC4_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC4_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC2_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC3_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC3_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC4_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_DAC_DAC4_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+
+/*
+ * 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_TIM5 FALSE
+#define STM32_GPT_USE_TIM6 FALSE
+#define STM32_GPT_USE_TIM7 FALSE
+#define STM32_GPT_USE_TIM8 FALSE
+#define STM32_GPT_USE_TIM15 FALSE
+#define STM32_GPT_USE_TIM16 FALSE
+#define STM32_GPT_USE_TIM17 FALSE
+
+/*
+ * I2C driver system settings.
+ */
+#define STM32_I2C_USE_I2C1 FALSE
+#define STM32_I2C_USE_I2C2 FALSE
+#define STM32_I2C_USE_I2C3 FALSE
+#define STM32_I2C_USE_I2C4 FALSE
+#define STM32_I2C_BUSY_TIMEOUT 50
+#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_I2C_I2C1_IRQ_PRIORITY 5
+#define STM32_I2C_I2C2_IRQ_PRIORITY 5
+#define STM32_I2C_I2C3_IRQ_PRIORITY 5
+#define STM32_I2C_I2C4_IRQ_PRIORITY 5
+#define STM32_I2C_I2C1_DMA_PRIORITY 3
+#define STM32_I2C_I2C2_DMA_PRIORITY 3
+#define STM32_I2C_I2C3_DMA_PRIORITY 3
+#define STM32_I2C_I2C4_DMA_PRIORITY 3
+#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_TIM5 FALSE
+#define STM32_ICU_USE_TIM8 FALSE
+#define STM32_ICU_USE_TIM15 FALSE
+#define STM32_ICU_USE_TIM16 FALSE
+#define STM32_ICU_USE_TIM17 FALSE
+
+/*
+ * PWM driver system settings.
+ */
+#define STM32_PWM_USE_ADVANCED FALSE
+#define STM32_PWM_USE_TIM1 FALSE
+#define STM32_PWM_USE_TIM2 FALSE
+#define STM32_PWM_USE_TIM3 FALSE
+#define STM32_PWM_USE_TIM4 FALSE
+#define STM32_PWM_USE_TIM5 FALSE
+#define STM32_PWM_USE_TIM8 FALSE
+#define STM32_PWM_USE_TIM15 FALSE
+#define STM32_PWM_USE_TIM16 FALSE
+#define STM32_PWM_USE_TIM17 FALSE
+#define STM32_PWM_USE_TIM20 FALSE
+
+/*
+ * RTC driver system settings.
+ */
+
+/*
+ * SDC driver system settings.
+ */
+
+/*
+ * SERIAL driver system settings.
+ */
+#define STM32_SERIAL_USE_USART1 FALSE
+#define STM32_SERIAL_USE_USART2 FALSE
+#define STM32_SERIAL_USE_USART3 FALSE
+#define STM32_SERIAL_USE_UART4 FALSE
+#define STM32_SERIAL_USE_UART5 FALSE
+#define STM32_SERIAL_USE_LPUART1 FALSE
+
+/*
+ * 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_USE_SPI4 FALSE
+#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_SPI_SPI1_DMA_PRIORITY 1
+#define STM32_SPI_SPI2_DMA_PRIORITY 1
+#define STM32_SPI_SPI3_DMA_PRIORITY 1
+#define STM32_SPI_SPI4_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_SPI4_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
+
+/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
+ * 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_USE_UART4 FALSE
+#define STM32_UART_USE_UART5 FALSE
+#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
+#define STM32_UART_USART1_DMA_PRIORITY 0
+#define STM32_UART_USART2_DMA_PRIORITY 0
+#define STM32_UART_USART3_DMA_PRIORITY 0
+#define STM32_UART_UART4_DMA_PRIORITY 0
+#define STM32_UART_UART5_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 5
+#define STM32_USB_USB1_LP_IRQ_PRIORITY 5
+
+/*
+ * WDG driver system settings.
+ */
+#define STM32_WDG_USE_IWDG FALSE
+
+/*
+ * WSPI driver system settings.
+ */
+#define STM32_WSPI_USE_QUADSPI1 FALSE
+#define STM32_WSPI_QUADSPI1_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/QMK_PROTON_C/board/board.mk b/platforms/chibios/QMK_PROTON_C/board/board.mk
new file mode 100644
index 0000000000..f891e65247
--- /dev/null
+++ b/platforms/chibios/QMK_PROTON_C/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/QMK_PROTON_C/configs/board.h b/platforms/chibios/QMK_PROTON_C/configs/board.h
new file mode 100644
index 0000000000..97159964d0
--- /dev/null
+++ b/platforms/chibios/QMK_PROTON_C/configs/board.h
@@ -0,0 +1,37 @@
+/* Copyright 2020 Nick Brassel (tzarc)
+ *
+ * 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 3 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 <https://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include_next "board.h"
+
+#undef STM32_HSE_BYPASS
+
+/*
+ * USB bus activation macro, required by the USB driver.
+ */
+#define usb_lld_connect_bus(usbp) \
+ do { \
+ palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_ALTERNATE(14)); \
+ } while (0)
+
+/*
+ * USB bus de-activation macro, required by the USB driver.
+ */
+#define usb_lld_disconnect_bus(usbp) \
+ do { \
+ palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL); \
+ palClearPad(GPIOA, GPIOA_USB_DP); \
+ } while (0)
diff --git a/platforms/chibios/QMK_PROTON_C/configs/bootloader_defs.h b/platforms/chibios/QMK_PROTON_C/configs/bootloader_defs.h
new file mode 100644
index 0000000000..3b0e9d20a6
--- /dev/null
+++ b/platforms/chibios/QMK_PROTON_C/configs/bootloader_defs.h
@@ -0,0 +1,7 @@
+/* Address for jumping to bootloader on STM32 chips. */
+/* It is chip dependent, the correct number can be looked up here:
+ * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
+ * This also requires a patch to chibios:
+ * <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
+ */
+#define STM32_BOOTLOADER_ADDRESS 0x1FFFD800
diff --git a/platforms/chibios/BLACKPILL_STM32_F401/configs/chconf.h b/platforms/chibios/QMK_PROTON_C/configs/chconf.h
index 7dc4f84a8a..a1cbf68086 100644
--- a/platforms/chibios/BLACKPILL_STM32_F401/configs/chconf.h
+++ b/platforms/chibios/QMK_PROTON_C/configs/chconf.h
@@ -29,7 +29,7 @@
#define CHCONF_H
#define _CHIBIOS_RT_CONF_
-#define _CHIBIOS_RT_CONF_VER_6_0_
+#define _CHIBIOS_RT_CONF_VER_6_1_
/*===========================================================================*/
/**
@@ -52,7 +52,7 @@
* setting also defines the system tick time unit.
*/
#if !defined(CH_CFG_ST_FREQUENCY)
-#define CH_CFG_ST_FREQUENCY 10000
+#define CH_CFG_ST_FREQUENCY 100000
#endif
/**
@@ -109,21 +109,6 @@
#endif
/**
- * @brief Managed RAM size.
- * @details Size of the RAM area to be managed by the OS. If set to zero
- * then the whole available RAM is used. The core memory is made
- * available to the heap allocator and/or can be used directly through
- * the simplified core memory allocator.
- *
- * @note In order to let the OS manage the whole RAM the linker script must
- * provide the @p __heap_base__ and @p __heap_end__ symbols.
- * @note Requires @p CH_CFG_USE_MEMCORE.
- */
-#if !defined(CH_CFG_MEMCORE_SIZE)
-#define CH_CFG_MEMCORE_SIZE 0
-#endif
-
-/**
* @brief Idle thread automatic spawn suppression.
* @details When this option is activated the function @p chSysInit()
* does not spawn the idle thread. The application @p main()
@@ -308,9 +293,31 @@
* @note Requires @p CH_CFG_USE_MESSAGES.
*/
#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
-#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
+#define CH_CFG_USE_MESSAGES_PRIORITY TRUE
+#endif
+
+/**
+ * @brief Dynamic Threads APIs.
+ * @details If enabled then the dynamic threads creation APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_CFG_USE_WAITEXIT.
+ * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
+ */
+#if !defined(CH_CFG_USE_DYNAMIC)
+#define CH_CFG_USE_DYNAMIC TRUE
#endif
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name OSLIB options
+ * @{
+ */
+/*===========================================================================*/
+
/**
* @brief Mailboxes APIs.
* @details If enabled then the asynchronous messages (mailboxes) APIs are
@@ -335,6 +342,21 @@
#endif
/**
+ * @brief Managed RAM size.
+ * @details Size of the RAM area to be managed by the OS. If set to zero
+ * then the whole available RAM is used. The core memory is made
+ * available to the heap allocator and/or can be used directly through
+ * the simplified core memory allocator.
+ *
+ * @note In order to let the OS manage the whole RAM the linker script must
+ * provide the @p __heap_base__ and @p __heap_end__ symbols.
+ * @note Requires @p CH_CFG_USE_MEMCORE.
+ */
+#if !defined(CH_CFG_MEMCORE_SIZE)
+#define CH_CFG_MEMCORE_SIZE 0
+#endif
+
+/**
* @brief Heap Allocator APIs.
* @details If enabled then the memory heap allocator APIs are included
* in the kernel.
@@ -382,16 +404,36 @@
#endif
/**
- * @brief Dynamic Threads APIs.
- * @details If enabled then the dynamic threads creation APIs are included
+ * @brief Objects Caches APIs.
+ * @details If enabled then the objects caches APIs are included
* in the kernel.
*
* @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_WAITEXIT.
- * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
*/
-#if !defined(CH_CFG_USE_DYNAMIC)
-#define CH_CFG_USE_DYNAMIC TRUE
+#if !defined(CH_CFG_USE_OBJ_CACHES)
+#define CH_CFG_USE_OBJ_CACHES FALSE
+#endif
+
+/**
+ * @brief Delegate threads APIs.
+ * @details If enabled then the delegate threads APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_CFG_USE_DELEGATES)
+#define CH_CFG_USE_DELEGATES FALSE
+#endif
+
+/**
+ * @brief Jobs Queues APIs.
+ * @details If enabled then the jobs queues APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_CFG_USE_JOBS)
+#define CH_CFG_USE_JOBS FALSE
#endif
/** @} */
@@ -411,7 +453,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_CFG_USE_FACTORY)
-#define CH_CFG_USE_FACTORY TRUE
+#define CH_CFG_USE_FACTORY FALSE
#endif
/**
@@ -547,7 +589,7 @@
* @p panic_msg variable set to @p NULL.
*/
#if !defined(CH_DBG_ENABLE_STACK_CHECK)
-#define CH_DBG_ENABLE_STACK_CHECK FALSE
+#define CH_DBG_ENABLE_STACK_CHECK TRUE
#endif
/**
diff --git a/platforms/chibios/QMK_PROTON_C/configs/config.h b/platforms/chibios/QMK_PROTON_C/configs/config.h
new file mode 100644
index 0000000000..a73f0c0b47
--- /dev/null
+++ b/platforms/chibios/QMK_PROTON_C/configs/config.h
@@ -0,0 +1,20 @@
+/* Copyright 2020 Nick Brassel (tzarc)
+ *
+ * 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 3 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 <https://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
+#endif
diff --git a/platforms/chibios/BLACKPILL_STM32_F401/configs/halconf.h b/platforms/chibios/QMK_PROTON_C/configs/halconf.h
index a8db392aaa..41fbac29e0 100644
--- a/platforms/chibios/BLACKPILL_STM32_F401/configs/halconf.h
+++ b/platforms/chibios/QMK_PROTON_C/configs/halconf.h
@@ -29,9 +29,9 @@
#define HALCONF_H
#define _CHIBIOS_HAL_CONF_
-#define _CHIBIOS_HAL_CONF_VER_7_0_
+#define _CHIBIOS_HAL_CONF_VER_7_1_
-#include "mcuconf.h"
+#include <mcuconf.h>
/**
* @brief Enables the PAL subsystem.
@@ -65,21 +65,28 @@
* @brief Enables the DAC subsystem.
*/
#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
-#define HAL_USE_DAC FALSE
+#define HAL_USE_DAC TRUE
+#endif
+
+/**
+ * @brief Enables the EFlash subsystem.
+ */
+#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
+#define HAL_USE_EFL FALSE
#endif
/**
* @brief Enables the GPT subsystem.
*/
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT FALSE
+#define HAL_USE_GPT TRUE
#endif
/**
* @brief Enables the I2C subsystem.
*/
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C FALSE
+#define HAL_USE_I2C TRUE
#endif
/**
@@ -114,7 +121,7 @@
* @brief Enables the PWM subsystem.
*/
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM FALSE
+#define HAL_USE_PWM TRUE
#endif
/**
@@ -142,7 +149,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL_USB FALSE
+#define HAL_USE_SERIAL_USB TRUE
#endif
/**
@@ -156,7 +163,7 @@
* @brief Enables the SPI subsystem.
*/
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI FALSE
+#define HAL_USE_SPI TRUE
#endif
/**
@@ -203,7 +210,7 @@
* @note Disabling this option saves both code and data space.
*/
#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
-#define PAL_USE_CALLBACKS FALSE
+#define PAL_USE_CALLBACKS TRUE
#endif
/**
@@ -211,7 +218,7 @@
* @note Disabling this option saves both code and data space.
*/
#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
-#define PAL_USE_WAIT FALSE
+#define PAL_USE_WAIT TRUE
#endif
/*===========================================================================*/
@@ -420,7 +427,7 @@
* buffers.
*/
#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_SIZE 256
+#define SERIAL_USB_BUFFERS_SIZE 1
#endif
/**
@@ -451,7 +458,6 @@
#define SPI_USE_CIRCULAR FALSE
#endif
-
/**
* @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
* @note Disabling this option saves both code and data space.
diff --git a/platforms/chibios/QMK_PROTON_C/configs/mcuconf.h b/platforms/chibios/QMK_PROTON_C/configs/mcuconf.h
new file mode 100644
index 0000000000..4d7b586c08
--- /dev/null
+++ b/platforms/chibios/QMK_PROTON_C/configs/mcuconf.h
@@ -0,0 +1,273 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+/*
+ * STM32F3xx drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the whole
+ * driver is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 15...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...3 Lowest...Highest.
+ */
+
+#define STM32F3xx_MCUCONF
+#define STM32F303_MCUCONF
+
+/*
+ * 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
+
+/*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY 6
+#define STM32_IRQ_EXTI1_PRIORITY 6
+#define STM32_IRQ_EXTI2_PRIORITY 6
+#define STM32_IRQ_EXTI3_PRIORITY 6
+#define STM32_IRQ_EXTI4_PRIORITY 6
+#define STM32_IRQ_EXTI5_9_PRIORITY 6
+#define STM32_IRQ_EXTI10_15_PRIORITY 6
+#define STM32_IRQ_EXTI16_PRIORITY 6
+#define STM32_IRQ_EXTI17_PRIORITY 15
+#define STM32_IRQ_EXTI18_PRIORITY 6
+#define STM32_IRQ_EXTI19_PRIORITY 15
+#define STM32_IRQ_EXTI20_PRIORITY 15
+#define STM32_IRQ_EXTI21_22_29_PRIORITY 6
+#define STM32_IRQ_EXTI30_32_PRIORITY 6
+#define STM32_IRQ_EXTI33_PRIORITY 6
+#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
+#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
+#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
+#define STM32_IRQ_TIM1_CC_PRIORITY 7
+
+/*
+ * 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
+
+/*
+ * CAN driver system settings.
+ */
+#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
+
+/*
+ * 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_USE_TIM15 TRUE
+#define STM32_GPT_USE_TIM16 FALSE
+#define STM32_GPT_USE_TIM17 FALSE
+#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")
+
+/*
+ * 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_USE_TIM15 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 FALSE
+#define STM32_PWM_USE_TIM3 TRUE
+#define STM32_PWM_USE_TIM4 TRUE
+#define STM32_PWM_USE_TIM8 FALSE
+#define STM32_PWM_USE_TIM15 FALSE
+#define STM32_PWM_USE_TIM16 FALSE
+#define STM32_PWM_USE_TIM17 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
+
+/*
+ * RTC driver system settings.
+ */
+#define STM32_RTC_PRESA_VALUE 32
+#define STM32_RTC_PRESS_VALUE 1024
+#define STM32_RTC_CR_INIT 0
+#define STM32_RTC_TAMPCR_INIT 0
+
+/*
+ * SERIAL driver system settings.
+ */
+#define STM32_SERIAL_USE_USART1 TRUE
+#define STM32_SERIAL_USE_USART2 FALSE
+#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 TRUE
+#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
+
+/*
+ * 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")
+
+/*
+ * 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
+
+/*
+ * WDG driver system settings.
+ */
+#define STM32_WDG_USE_IWDG FALSE
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk b/platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk
new file mode 100644
index 0000000000..3fa73a96e0
--- /dev/null
+++ b/platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk
@@ -0,0 +1,12 @@
+# Proton C MCU settings for converting AVR projects
+TARGET := $(TARGET)_proton_c
+MCU := STM32F303
+BOARD := QMK_PROTON_C
+OPT_DEFS += -DCONVERT_TO_PROTON_C
+
+# These are defaults based on what has been implemented for ARM boards
+AUDIO_ENABLE = yes
+WS2812_DRIVER = bitbang
+
+# Force task driven PWM until ARM can provide automatic configuration
+BACKLIGHT_DRIVER = software \ No newline at end of file
diff --git a/platforms/chibios/common/configs/chconf.h b/platforms/chibios/common/configs/chconf.h
index aac3303705..44327a82d7 100644
--- a/platforms/chibios/common/configs/chconf.h
+++ b/platforms/chibios/common/configs/chconf.h
@@ -29,7 +29,7 @@
#define CHCONF_H
#define _CHIBIOS_RT_CONF_
-#define _CHIBIOS_RT_CONF_VER_6_0_
+#define _CHIBIOS_RT_CONF_VER_6_1_
/*===========================================================================*/
/**
@@ -109,21 +109,6 @@
#endif
/**
- * @brief Managed RAM size.
- * @details Size of the RAM area to be managed by the OS. If set to zero
- * then the whole available RAM is used. The core memory is made
- * available to the heap allocator and/or can be used directly through
- * the simplified core memory allocator.
- *
- * @note In order to let the OS manage the whole RAM the linker script must
- * provide the @p __heap_base__ and @p __heap_end__ symbols.
- * @note Requires @p CH_CFG_USE_MEMCORE.
- */
-#if !defined(CH_CFG_MEMCORE_SIZE)
-#define CH_CFG_MEMCORE_SIZE 0
-#endif
-
-/**
* @brief Idle thread automatic spawn suppression.
* @details When this option is activated the function @p chSysInit()
* does not spawn the idle thread. The application @p main()
@@ -172,7 +157,7 @@
* @note The default is @p TRUE.
*/
#if !defined(CH_CFG_USE_TM)
-#define CH_CFG_USE_TM TRUE
+#define CH_CFG_USE_TM FALSE
#endif
/**
@@ -182,7 +167,7 @@
* @note The default is @p TRUE.
*/
#if !defined(CH_CFG_USE_REGISTRY)
-#define CH_CFG_USE_REGISTRY TRUE
+#define CH_CFG_USE_REGISTRY FALSE
#endif
/**
@@ -193,7 +178,7 @@
* @note The default is @p TRUE.
*/
#if !defined(CH_CFG_USE_WAITEXIT)
-#define CH_CFG_USE_WAITEXIT TRUE
+#define CH_CFG_USE_WAITEXIT FALSE
#endif
/**
@@ -250,7 +235,7 @@
* @note Requires @p CH_CFG_USE_MUTEXES.
*/
#if !defined(CH_CFG_USE_CONDVARS)
-#define CH_CFG_USE_CONDVARS TRUE
+#define CH_CFG_USE_CONDVARS FALSE
#endif
/**
@@ -295,7 +280,7 @@
* @note The default is @p TRUE.
*/
#if !defined(CH_CFG_USE_MESSAGES)
-#define CH_CFG_USE_MESSAGES TRUE
+#define CH_CFG_USE_MESSAGES FALSE
#endif
/**
@@ -308,10 +293,32 @@
* @note Requires @p CH_CFG_USE_MESSAGES.
*/
#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
-#define CH_CFG_USE_MESSAGES_PRIORITY TRUE
+#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
#endif
/**
+ * @brief Dynamic Threads APIs.
+ * @details If enabled then the dynamic threads creation APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_CFG_USE_WAITEXIT.
+ * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
+ */
+#if !defined(CH_CFG_USE_DYNAMIC)
+#define CH_CFG_USE_DYNAMIC FALSE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name OSLIB options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
* @brief Mailboxes APIs.
* @details If enabled then the asynchronous messages (mailboxes) APIs are
* included in the kernel.
@@ -320,7 +327,7 @@
* @note Requires @p CH_CFG_USE_SEMAPHORES.
*/
#if !defined(CH_CFG_USE_MAILBOXES)
-#define CH_CFG_USE_MAILBOXES TRUE
+#define CH_CFG_USE_MAILBOXES FALSE
#endif
/**
@@ -335,6 +342,21 @@
#endif
/**
+ * @brief Managed RAM size.
+ * @details Size of the RAM area to be managed by the OS. If set to zero
+ * then the whole available RAM is used. The core memory is made
+ * available to the heap allocator and/or can be used directly through
+ * the simplified core memory allocator.
+ *
+ * @note In order to let the OS manage the whole RAM the linker script must
+ * provide the @p __heap_base__ and @p __heap_end__ symbols.
+ * @note Requires @p CH_CFG_USE_MEMCORE.
+ */
+#if !defined(CH_CFG_MEMCORE_SIZE)
+#define CH_CFG_MEMCORE_SIZE 0
+#endif
+
+/**
* @brief Heap Allocator APIs.
* @details If enabled then the memory heap allocator APIs are included
* in the kernel.
@@ -345,7 +367,7 @@
* @note Mutexes are recommended.
*/
#if !defined(CH_CFG_USE_HEAP)
-#define CH_CFG_USE_HEAP TRUE
+#define CH_CFG_USE_HEAP FALSE
#endif
/**
@@ -356,7 +378,7 @@
* @note The default is @p TRUE.
*/
#if !defined(CH_CFG_USE_MEMPOOLS)
-#define CH_CFG_USE_MEMPOOLS TRUE
+#define CH_CFG_USE_MEMPOOLS FALSE
#endif
/**
@@ -367,7 +389,7 @@
* @note The default is @p TRUE.
*/
#if !defined(CH_CFG_USE_OBJ_FIFOS)
-#define CH_CFG_USE_OBJ_FIFOS TRUE
+#define CH_CFG_USE_OBJ_FIFOS FALSE
#endif
/**
@@ -378,20 +400,40 @@
* @note The default is @p TRUE.
*/
#if !defined(CH_CFG_USE_PIPES)
-#define CH_CFG_USE_PIPES TRUE
+#define CH_CFG_USE_PIPES FALSE
#endif
/**
- * @brief Dynamic Threads APIs.
- * @details If enabled then the dynamic threads creation APIs are included
+ * @brief Objects Caches APIs.
+ * @details If enabled then the objects caches APIs are included
* in the kernel.
*
* @note The default is @p TRUE.
- * @note Requires @p CH_CFG_USE_WAITEXIT.
- * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
*/
-#if !defined(CH_CFG_USE_DYNAMIC)
-#define CH_CFG_USE_DYNAMIC TRUE
+#if !defined(CH_CFG_USE_OBJ_CACHES)
+#define CH_CFG_USE_OBJ_CACHES FALSE
+#endif
+
+/**
+ * @brief Delegate threads APIs.
+ * @details If enabled then the delegate threads APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_CFG_USE_DELEGATES)
+#define CH_CFG_USE_DELEGATES FALSE
+#endif
+
+/**
+ * @brief Jobs Queues APIs.
+ * @details If enabled then the jobs queues APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_CFG_USE_JOBS)
+#define CH_CFG_USE_JOBS FALSE
#endif
/** @} */
@@ -411,7 +453,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_CFG_USE_FACTORY)
-#define CH_CFG_USE_FACTORY TRUE
+#define CH_CFG_USE_FACTORY FALSE
#endif
/**
@@ -427,42 +469,42 @@
* @brief Enables the registry of generic objects.
*/
#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
-#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
+#define CH_CFG_FACTORY_OBJECTS_REGISTRY FALSE
#endif
/**
* @brief Enables factory for generic buffers.
*/
#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
-#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
+#define CH_CFG_FACTORY_GENERIC_BUFFERS FALSE
#endif
/**
* @brief Enables factory for semaphores.
*/
#if !defined(CH_CFG_FACTORY_SEMAPHORES)
-#define CH_CFG_FACTORY_SEMAPHORES TRUE
+#define CH_CFG_FACTORY_SEMAPHORES FALSE
#endif
/**
* @brief Enables factory for mailboxes.
*/
#if !defined(CH_CFG_FACTORY_MAILBOXES)
-#define CH_CFG_FACTORY_MAILBOXES TRUE
+#define CH_CFG_FACTORY_MAILBOXES FALSE
#endif
/**
* @brief Enables factory for objects FIFOs.
*/
#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
-#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
+#define CH_CFG_FACTORY_OBJ_FIFOS FALSE
#endif
/**
* @brief Enables factory for Pipes.
*/
#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
-#define CH_CFG_FACTORY_PIPES TRUE
+#define CH_CFG_FACTORY_PIPES FALSE
#endif
/** @} */
@@ -547,7 +589,7 @@
* @p panic_msg variable set to @p NULL.
*/
#if !defined(CH_DBG_ENABLE_STACK_CHECK)
-#define CH_DBG_ENABLE_STACK_CHECK TRUE
+#define CH_DBG_ENABLE_STACK_CHECK FALSE
#endif
/**
diff --git a/platforms/chibios/common/configs/halconf.h b/platforms/chibios/common/configs/halconf.h
index 6b48e289f9..264ae4e6c1 100644
--- a/platforms/chibios/common/configs/halconf.h
+++ b/platforms/chibios/common/configs/halconf.h
@@ -29,9 +29,9 @@
#define HALCONF_H
#define _CHIBIOS_HAL_CONF_
-#define _CHIBIOS_HAL_CONF_VER_7_0_
+#define _CHIBIOS_HAL_CONF_VER_7_1_
-#include "mcuconf.h"
+#include <mcuconf.h>
/**
* @brief Enables the PAL subsystem.
@@ -65,21 +65,28 @@
* @brief Enables the DAC subsystem.
*/
#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
-#define HAL_USE_DAC TRUE
+#define HAL_USE_DAC FALSE
+#endif
+
+/**
+ * @brief Enables the EFlash subsystem.
+ */
+#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
+#define HAL_USE_EFL FALSE
#endif
/**
* @brief Enables the GPT subsystem.
*/
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT TRUE
+#define HAL_USE_GPT FALSE
#endif
/**
* @brief Enables the I2C subsystem.
*/
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C TRUE
+#define HAL_USE_I2C FALSE
#endif
/**
@@ -114,7 +121,7 @@
* @brief Enables the PWM subsystem.
*/
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM TRUE
+#define HAL_USE_PWM FALSE
#endif
/**
@@ -142,7 +149,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL_USB TRUE
+#define HAL_USE_SERIAL_USB FALSE
#endif
/**
@@ -156,7 +163,7 @@
* @brief Enables the SPI subsystem.
*/
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI TRUE
+#define HAL_USE_SPI FALSE
#endif
/**
@@ -203,7 +210,7 @@
* @note Disabling this option saves both code and data space.
*/
#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
-#define PAL_USE_CALLBACKS TRUE
+#define PAL_USE_CALLBACKS FALSE
#endif
/**
@@ -211,7 +218,7 @@
* @note Disabling this option saves both code and data space.
*/
#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
-#define PAL_USE_WAIT TRUE
+#define PAL_USE_WAIT FALSE
#endif
/*===========================================================================*/
@@ -451,7 +458,6 @@
#define SPI_USE_CIRCULAR FALSE
#endif
-
/**
* @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
* @note Disabling this option saves both code and data space.
diff --git a/quantum/api/api_sysex.h b/quantum/api/api_sysex.h
index 382f4bea44..eb0a18848d 100644
--- a/quantum/api/api_sysex.h
+++ b/quantum/api/api_sysex.h
@@ -18,6 +18,8 @@
#include "api.h"
+#define API_SYSEX_MAX_SIZE 32
+
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
new file mode 100644
index 0000000000..46277dd70b
--- /dev/null
+++ b/quantum/audio/audio.c
@@ -0,0 +1,539 @@
+/* Copyright 2016-2020 Jack Humbert
+ * Copyright 2020 JohSchneider
+
+ * 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 "audio.h"
+#include "eeconfig.h"
+#include "timer.h"
+#include "wait.h"
+
+/* audio system:
+ *
+ * audio.[ch] takes care of all overall state, tracking the actively playing
+ * notes/tones; the notes a SONG consists of;
+ * ...
+ * = everything audio-related that is platform agnostic
+ *
+ * driver_[avr|chibios]_[dac|pwm] take care of the lower hardware dependent parts,
+ * specific to each platform and the used subsystem/driver to drive
+ * the output pins/channels with the calculated frequencies for each
+ * active tone
+ * as part of this, the driver has to trigger regular state updates by
+ * calling 'audio_update_state' through some sort of timer - be it a
+ * dedicated one or piggybacking on for example the timer used to
+ * generate a pwm signal/clock.
+ *
+ *
+ * A Note on terminology:
+ * tone, pitch and frequency are used somewhat interchangeably, in a strict Wikipedia-sense:
+ * "(Musical) tone, a sound characterized by its duration, pitch (=frequency),
+ * intensity (=volume), and timbre"
+ * - intensity/volume is currently not handled at all, although the 'dac_additive' driver could do so
+ * - timbre is handled globally (TODO: only used with the pwm drivers at the moment)
+ *
+ * in musical_note.h a 'note' is the combination of a pitch and a duration
+ * these are used to create SONG arrays; during playback their frequencies
+ * are handled as single successive tones, while the durations are
+ * kept track of in 'audio_update_state'
+ *
+ * 'voice' as it is used here, equates to a sort of instrument with its own
+ * characteristics sound and effects
+ * the audio system as-is deals only with (possibly multiple) tones of one
+ * instrument/voice at a time (think: chords). since the number of tones that
+ * can be reproduced depends on the hardware/driver in use: pwm can only
+ * reproduce one tone per output/speaker; DACs can reproduce/mix multiple
+ * when doing additive synthesis.
+ *
+ * 'duration' can either be in the beats-per-minute related unit found in
+ * musical_notes.h, OR in ms; keyboards create SONGs with the former, while
+ * the internal state of the audio system does its calculations with the later - ms
+ */
+
+#ifndef AUDIO_TONE_STACKSIZE
+# define AUDIO_TONE_STACKSIZE 8
+#endif
+uint8_t active_tones = 0; // number of tones pushed onto the stack by audio_play_tone - might be more than the hardware is able to reproduce at any single time
+musical_tone_t tones[AUDIO_TONE_STACKSIZE]; // stack of currently active tones
+
+bool playing_melody = false; // playing a SONG?
+bool playing_note = false; // or (possibly multiple simultaneous) tones
+bool state_changed = false; // global flag, which is set if anything changes with the active_tones
+
+// melody/SONG related state variables
+float (*notes_pointer)[][2]; // SONG, an array of MUSICAL_NOTEs
+uint16_t notes_count; // length of the notes_pointer array
+bool notes_repeat; // PLAY_SONG or PLAY_LOOP?
+uint16_t melody_current_note_duration = 0; // duration of the currently playing note from the active melody, in ms
+uint8_t note_tempo = TEMPO_DEFAULT; // beats-per-minute
+uint16_t current_note = 0; // index into the array at notes_pointer
+bool note_resting = false; // if a short pause was introduced between two notes with the same frequency while playing a melody
+uint16_t last_timestamp = 0;
+
+#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
+# ifndef AUDIO_MAX_SIMULTANEOUS_TONES
+# define AUDIO_MAX_SIMULTANEOUS_TONES 3
+# endif
+uint16_t tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT;
+uint8_t tone_multiplexing_index_shift = 0; // offset used on active-tone array access
+#endif
+
+// provided and used by voices.c
+extern uint8_t note_timbre;
+extern bool glissando;
+extern bool vibrato;
+extern uint16_t voices_timer;
+
+#ifndef STARTUP_SONG
+# define STARTUP_SONG SONG(STARTUP_SOUND)
+#endif
+#ifndef AUDIO_ON_SONG
+# define AUDIO_ON_SONG SONG(AUDIO_ON_SOUND)
+#endif
+#ifndef AUDIO_OFF_SONG
+# define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
+#endif
+float startup_song[][2] = STARTUP_SONG;
+float audio_on_song[][2] = AUDIO_ON_SONG;
+float audio_off_song[][2] = AUDIO_OFF_SONG;
+
+static bool audio_initialized = false;
+static bool audio_driver_stopped = true;
+audio_config_t audio_config;
+
+void audio_init() {
+ if (audio_initialized) {
+ return;
+ }
+
+ // Check EEPROM
+#ifdef EEPROM_ENABLE
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+ audio_config.raw = eeconfig_read_audio();
+#else // EEPROM settings
+ audio_config.enable = true;
+# ifdef AUDIO_CLICKY_ON
+ audio_config.clicky_enable = true;
+# endif
+#endif // EEPROM settings
+
+ for (uint8_t i = 0; i < AUDIO_TONE_STACKSIZE; i++) {
+ tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0};
+ }
+
+ if (!audio_initialized) {
+ audio_driver_initialize();
+ audio_initialized = true;
+ }
+ stop_all_notes();
+}
+
+void audio_startup(void) {
+ if (audio_config.enable) {
+ PLAY_SONG(startup_song);
+ }
+
+ last_timestamp = timer_read();
+}
+
+void audio_toggle(void) {
+ if (audio_config.enable) {
+ stop_all_notes();
+ }
+ 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();
+ PLAY_SONG(audio_on_song);
+}
+
+void audio_off(void) {
+ PLAY_SONG(audio_off_song);
+ wait_ms(100);
+ audio_stop_all();
+ audio_config.enable = 0;
+ eeconfig_update_audio(audio_config.raw);
+}
+
+bool audio_is_on(void) { return (audio_config.enable != 0); }
+
+void audio_stop_all() {
+ if (audio_driver_stopped) {
+ return;
+ }
+
+ active_tones = 0;
+
+ audio_driver_stop();
+
+ playing_melody = false;
+ playing_note = false;
+
+ melody_current_note_duration = 0;
+
+ for (uint8_t i = 0; i < AUDIO_TONE_STACKSIZE; i++) {
+ tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0};
+ }
+
+ audio_driver_stopped = true;
+}
+
+void audio_stop_tone(float pitch) {
+ if (pitch < 0.0f) {
+ pitch = -1 * pitch;
+ }
+
+ if (playing_note) {
+ if (!audio_initialized) {
+ audio_init();
+ }
+ bool found = false;
+ for (int i = AUDIO_TONE_STACKSIZE - 1; i >= 0; i--) {
+ found = (tones[i].pitch == pitch);
+ if (found) {
+ tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0};
+ for (int j = i; (j < AUDIO_TONE_STACKSIZE - 1); j++) {
+ tones[j] = tones[j + 1];
+ tones[j + 1] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0};
+ }
+ break;
+ }
+ }
+ if (!found) {
+ return;
+ }
+
+ state_changed = true;
+ active_tones--;
+ if (active_tones < 0) active_tones = 0;
+#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
+ if (tone_multiplexing_index_shift >= active_tones) {
+ tone_multiplexing_index_shift = 0;
+ }
+#endif
+ if (active_tones == 0) {
+ audio_driver_stop();
+ audio_driver_stopped = true;
+ playing_note = false;
+ }
+ }
+}
+
+void audio_play_note(float pitch, uint16_t duration) {
+ if (!audio_config.enable) {
+ return;
+ }
+
+ if (!audio_initialized) {
+ audio_init();
+ }
+
+ if (pitch < 0.0f) {
+ pitch = -1 * pitch;
+ }
+
+ // round-robin: shifting out old tones, keeping only unique ones
+ // if the new frequency is already amongst the active tones, shift it to the top of the stack
+ bool found = false;
+ for (int i = active_tones - 1; i >= 0; i--) {
+ found = (tones[i].pitch == pitch);
+ if (found) {
+ for (int j = i; (j < active_tones - 1); j++) {
+ tones[j] = tones[j + 1];
+ tones[j + 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration};
+ }
+ return; // since this frequency played already, the hardware was already started
+ }
+ }
+
+ // frequency/tone is actually new, so we put it on the top of the stack
+ active_tones++;
+ if (active_tones > AUDIO_TONE_STACKSIZE) {
+ active_tones = AUDIO_TONE_STACKSIZE;
+ // shift out the oldest tone to make room
+ for (int i = 0; i < active_tones - 1; i++) {
+ tones[i] = tones[i + 1];
+ }
+ }
+ state_changed = true;
+ playing_note = true;
+ tones[active_tones - 1] = (musical_tone_t){.time_started = timer_read(), .pitch = pitch, .duration = duration};
+
+ // TODO: needs to be handled per note/tone -> use its timestamp instead?
+ voices_timer = timer_read(); // reset to zero, for the effects added by voices.c
+
+ if (audio_driver_stopped) {
+ audio_driver_start();
+ audio_driver_stopped = false;
+ }
+}
+
+void audio_play_tone(float pitch) { audio_play_note(pitch, 0xffff); }
+
+void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat) {
+ if (!audio_config.enable) {
+ audio_stop_all();
+ return;
+ }
+
+ if (!audio_initialized) {
+ audio_init();
+ }
+
+ // Cancel note if a note is playing
+ if (playing_note) audio_stop_all();
+
+ playing_melody = true;
+ note_resting = false;
+
+ notes_pointer = np;
+ notes_count = n_count;
+ notes_repeat = n_repeat;
+
+ current_note = 0; // note in the melody-array/list at note_pointer
+
+ // start first note manually, which also starts the audio_driver
+ // all following/remaining notes are played by 'audio_update_state'
+ audio_play_note((*notes_pointer)[current_note][0], audio_duration_to_ms((*notes_pointer)[current_note][1]));
+ last_timestamp = timer_read();
+ melody_current_note_duration = audio_duration_to_ms((*notes_pointer)[current_note][1]);
+}
+
+float click[2][2];
+void audio_play_click(uint16_t delay, float pitch, uint16_t duration) {
+ uint16_t duration_tone = audio_ms_to_duration(duration);
+ uint16_t duration_delay = audio_ms_to_duration(delay);
+
+ if (delay <= 0.0f) {
+ click[0][0] = pitch;
+ click[0][1] = duration_tone;
+ click[1][0] = 0.0f;
+ click[1][1] = 0.0f;
+ audio_play_melody(&click, 1, false);
+ } else {
+ // first note is a rest/pause
+ click[0][0] = 0.0f;
+ click[0][1] = duration_delay;
+ // second note is the actual click
+ click[1][0] = pitch;
+ click[1][1] = duration_tone;
+ audio_play_melody(&click, 2, false);
+ }
+}
+
+bool audio_is_playing_note(void) { return playing_note; }
+
+bool audio_is_playing_melody(void) { return playing_melody; }
+
+uint8_t audio_get_number_of_active_tones(void) { return active_tones; }
+
+float audio_get_frequency(uint8_t tone_index) {
+ if (tone_index >= active_tones) {
+ return 0.0f;
+ }
+ return tones[active_tones - tone_index - 1].pitch;
+}
+
+float audio_get_processed_frequency(uint8_t tone_index) {
+ if (tone_index >= active_tones) {
+ return 0.0f;
+ }
+
+ int8_t index = active_tones - tone_index - 1;
+ // new tones are stacked on top (= appended at the end), so the most recent/current is MAX-1
+
+#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
+ index = index - tone_multiplexing_index_shift;
+ if (index < 0) // wrap around
+ index += active_tones;
+#endif
+
+ if (tones[index].pitch <= 0.0f) {
+ return 0.0f;
+ }
+
+ return voice_envelope(tones[index].pitch);
+}
+
+bool audio_update_state(void) {
+ if (!playing_note && !playing_melody) {
+ return false;
+ }
+
+ bool goto_next_note = false;
+ uint16_t current_time = timer_read();
+
+ if (playing_melody) {
+ goto_next_note = timer_elapsed(last_timestamp) >= melody_current_note_duration;
+ if (goto_next_note) {
+ uint16_t delta = timer_elapsed(last_timestamp) - melody_current_note_duration;
+ last_timestamp = current_time;
+ uint16_t previous_note = current_note;
+ current_note++;
+ voices_timer = timer_read(); // reset to zero, for the effects added by voices.c
+
+ if (current_note >= notes_count) {
+ if (notes_repeat) {
+ current_note = 0;
+ } else {
+ audio_stop_all();
+ return false;
+ }
+ }
+
+ if (!note_resting && (*notes_pointer)[previous_note][0] == (*notes_pointer)[current_note][0]) {
+ note_resting = true;
+
+ // special handling for successive notes of the same frequency:
+ // insert a short pause to separate them audibly
+ audio_play_note(0.0f, audio_duration_to_ms(2));
+ current_note = previous_note;
+ melody_current_note_duration = audio_duration_to_ms(2);
+
+ } else {
+ note_resting = false;
+
+ // TODO: handle glissando here (or remember previous and current tone)
+ /* there would need to be a freq(here we are) -> freq(next note)
+ * and do slide/glissando in between problem here is to know which
+ * frequency on the stack relates to what other? e.g. a melody starts
+ * tones in a sequence, and stops expiring one, so the most recently
+ * stopped is the starting point for a glissando to the most recently started?
+ * how to detect and preserve this relation?
+ * and what about user input, chords, ...?
+ */
+
+ // '- delta': Skip forward in the next note's length if we've over shot
+ // the last, so the overall length of the song is the same
+ uint16_t duration = audio_duration_to_ms((*notes_pointer)[current_note][1]);
+
+ // Skip forward past any completely missed notes
+ while (delta > duration && current_note < notes_count - 1) {
+ delta -= duration;
+ current_note++;
+ duration = audio_duration_to_ms((*notes_pointer)[current_note][1]);
+ }
+
+ if (delta < duration) {
+ duration -= delta;
+ } else {
+ // Only way to get here is if it is the last note and
+ // we have completely missed it. Play it for 1ms...
+ duration = 1;
+ }
+
+ audio_play_note((*notes_pointer)[current_note][0], duration);
+ melody_current_note_duration = duration;
+ }
+ }
+ }
+
+ if (playing_note) {
+#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
+ tone_multiplexing_index_shift = (int)(current_time / tone_multiplexing_rate) % MIN(AUDIO_MAX_SIMULTANEOUS_TONES, active_tones);
+ goto_next_note = true;
+#endif
+ if (vibrato || glissando) {
+ // force update on each cycle, since vibrato shifts the frequency slightly
+ goto_next_note = true;
+ }
+
+ // housekeeping: stop notes that have no playtime left
+ for (int i = 0; i < active_tones; i++) {
+ if ((tones[i].duration != 0xffff) // indefinitely playing notes, started by 'audio_play_tone'
+ && (tones[i].duration != 0) // 'uninitialized'
+ ) {
+ if (timer_elapsed(tones[i].time_started) >= tones[i].duration) {
+ audio_stop_tone(tones[i].pitch); // also sets 'state_changed=true'
+ }
+ }
+ }
+ }
+
+ // state-changes have a higher priority, always triggering the hardware to update
+ if (state_changed) {
+ state_changed = false;
+ return true;
+ }
+
+ return goto_next_note;
+}
+
+// Tone-multiplexing functions
+#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
+void audio_set_tone_multiplexing_rate(uint16_t rate) { tone_multiplexing_rate = rate; }
+void audio_enable_tone_multiplexing(void) { tone_multiplexing_rate = AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT; }
+void audio_disable_tone_multiplexing(void) { tone_multiplexing_rate = 0; }
+void audio_increase_tone_multiplexing_rate(uint16_t change) {
+ if ((0xffff - change) > tone_multiplexing_rate) {
+ tone_multiplexing_rate += change;
+ }
+}
+void audio_decrease_tone_multiplexing_rate(uint16_t change) {
+ if (change <= tone_multiplexing_rate) {
+ tone_multiplexing_rate -= change;
+ }
+}
+#endif
+
+// Tempo functions
+
+void audio_set_tempo(uint8_t tempo) {
+ if (tempo < 10) note_tempo = 10;
+ // else if (tempo > 250)
+ // note_tempo = 250;
+ else
+ note_tempo = tempo;
+}
+
+void audio_increase_tempo(uint8_t tempo_change) {
+ if (tempo_change > 255 - note_tempo)
+ note_tempo = 255;
+ else
+ note_tempo += tempo_change;
+}
+
+void audio_decrease_tempo(uint8_t tempo_change) {
+ if (tempo_change >= note_tempo - 10)
+ note_tempo = 10;
+ else
+ note_tempo -= tempo_change;
+}
+
+// TODO in the int-math version are some bugs; songs sometimes abruptly end - maybe an issue with the timer/system-tick wrapping around?
+uint16_t audio_duration_to_ms(uint16_t duration_bpm) {
+#if defined(__AVR__)
+ // doing int-math saves us some bytes in the overall firmware size, but the intermediate result is less accurate before being cast to/returned as uint
+ return ((uint32_t)duration_bpm * 60 * 1000) / (64 * note_tempo);
+ // NOTE: beware of uint16_t overflows when note_tempo is low and/or the duration is long
+#else
+ return ((float)duration_bpm * 60) / (64 * note_tempo) * 1000;
+#endif
+}
+uint16_t audio_ms_to_duration(uint16_t duration_ms) {
+#if defined(__AVR__)
+ return ((uint32_t)duration_ms * 64 * note_tempo) / 60 / 1000;
+#else
+ return ((float)duration_ms * 64 * note_tempo) / 60 / 1000;
+#endif
+}
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index dccf03d5f6..56b9158a1a 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -1,4 +1,5 @@
-/* Copyright 2016 Jack Humbert
+/* Copyright 2016-2020 Jack Humbert
+ * Copyright 2020 JohSchneider
*
* 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
@@ -13,28 +14,30 @@
* 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>
-#if defined(__AVR__)
-# include <avr/io.h>
-#endif
-#include "wait.h"
#include "musical_notes.h"
#include "song_list.h"
#include "voices.h"
#include "quantum.h"
#include <math.h>
-// Largely untested PWM audio mode (doesn't sound as good)
-// #define PWM_AUDIO
-
-// #define VIBRATO_ENABLE
+#if defined(__AVR__)
+# include <avr/io.h>
+# if defined(AUDIO_DRIVER_PWM)
+# include "driver_avr_pwm.h"
+# endif
+#endif
-// Enable vibrato strength/amplitude - slows down ISR too much
-// #define VIBRATO_STRENGTH_ENABLE
+#if defined(PROTOCOL_CHIBIOS)
+# if defined(AUDIO_DRIVER_PWM)
+# include "driver_chibios_pwm.h"
+# elif defined(AUDIO_DRIVER_DAC)
+# include "driver_chibios_dac.h"
+# endif
+#endif
typedef union {
uint8_t raw;
@@ -45,62 +48,238 @@ typedef union {
};
} audio_config_t;
-bool is_audio_on(void);
+// AVR/LUFA has a MIN, arm/chibios does not
+#ifndef MIN
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+/*
+ * a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre
+ * https://en.wikipedia.org/wiki/Musical_tone
+ * "A musical tone is characterized by its duration, pitch, intensity (or loudness), and timbre (or quality)"
+ */
+typedef struct {
+ uint16_t time_started; // timestamp the tone/note was started, system time runs with 1ms resolution -> 16bit timer overflows every ~64 seconds, long enough under normal circumstances; but might be too soon for long-duration notes when the note_tempo is set to a very low value
+ float pitch; // aka frequency, in Hz
+ uint16_t duration; // in ms, converted from the musical_notes.h unit which has 64parts to a beat, factoring in the current tempo in beats-per-minute
+ // float intensity; // aka volume [0,1] TODO: not used at the moment; pwm drivers can't handle it
+ // uint8_t timbre; // range: [0,100] TODO: this currently kept track of globally, should we do this per tone instead?
+} musical_tone_t;
+
+// public interface
+
+/**
+ * @brief one-time initialization called by quantum/quantum.c
+ * @details usually done lazy, when some tones are to be played
+ *
+ * @post audio system (and hardware) initialized and ready to play tones
+ */
+void audio_init(void);
+void audio_startup(void);
+
+/**
+ * @brief en-/disable audio output, save this choice to the eeprom
+ */
void audio_toggle(void);
+/**
+ * @brief enable audio output, save this choice to the eeprom
+ */
void audio_on(void);
+/**
+ * @brief disable audio output, save this choice to the eeprom
+ */
void audio_off(void);
+/**
+ * @brief query the if audio output is enabled
+ */
+bool audio_is_on(void);
-// Vibrato rate functions
+/**
+ * @brief start playback of a tone with the given frequency and duration
+ *
+ * @details starts the playback of a given note, which is automatically stopped
+ * at the the end of its duration = fire&forget
+ *
+ * @param[in] pitch frequency of the tone be played
+ * @param[in] duration in milliseconds, use 'audio_duration_to_ms' to convert
+ * from the musical_notes.h unit to ms
+ */
+void audio_play_note(float pitch, uint16_t duration);
+// TODO: audio_play_note(float pitch, uint16_t duration, float intensity, float timbre);
+// audio_play_note_with_instrument ifdef AUDIO_ENABLE_VOICES
-#ifdef VIBRATO_ENABLE
+/**
+ * @brief start playback of a tone with the given frequency
+ *
+ * @details the 'frequency' is put on-top the internal stack of active tones,
+ * as a new tone with indefinite duration. this tone is played by
+ * the hardware until a call to 'audio_stop_tone'.
+ * should a tone with that frequency already be active, its entry
+ * is put on the top of said internal stack - so no duplicate
+ * entries are kept.
+ * 'hardware_start' is called upon the first note.
+ *
+ * @param[in] pitch frequency of the tone be played
+ */
+void audio_play_tone(float pitch);
-void set_vibrato_rate(float rate);
-void increase_vibrato_rate(float change);
-void decrease_vibrato_rate(float change);
+/**
+ * @brief stop a given tone/frequency
+ *
+ * @details removes a tone matching the given frequency from the internal
+ * playback stack
+ * the hardware is stopped in case this was the last/only frequency
+ * being played.
+ *
+ * @param[in] pitch tone/frequency to be stopped
+ */
+void audio_stop_tone(float pitch);
-# ifdef VIBRATO_STRENGTH_ENABLE
+/**
+ * @brief play a melody
+ *
+ * @details starts playback of a melody passed in from a SONG definition - an
+ * array of {pitch, duration} float-tuples
+ *
+ * @param[in] np note-pointer to the SONG array
+ * @param[in] n_count number of MUSICAL_NOTES of the SONG
+ * @param[in] n_repeat false for onetime, true for looped playback
+ */
+void audio_play_melody(float (*np)[][2], uint16_t n_count, bool n_repeat);
-void set_vibrato_strength(float strength);
-void increase_vibrato_strength(float change);
-void decrease_vibrato_strength(float change);
+/**
+ * @brief play a short tone of a specific frequency to emulate a 'click'
+ *
+ * @details constructs a two-note melody (one pause plus a note) and plays it through
+ * audio_play_melody. very short durations might not quite work due to
+ * hardware limitations (DAC: added pulses from zero-crossing feature;...)
+ *
+ * @param[in] delay in milliseconds, length for the pause before the pulses, can be zero
+ * @param[in] pitch
+ * @param[in] duration in milliseconds, length of the 'click'
+ */
+void audio_play_click(uint16_t delay, float pitch, uint16_t duration);
-# endif
+/**
+ * @brief stops all playback
+ *
+ * @details stops playback of both a melody as well as single tones, resetting
+ * the internal state
+ */
+void audio_stop_all(void);
-#endif
+/**
+ * @brief query if one/multiple tones are playing
+ */
+bool audio_is_playing_note(void);
-// Polyphony functions
+/**
+ * @brief query if a melody/SONG is playing
+ */
+bool audio_is_playing_melody(void);
-void set_polyphony_rate(float rate);
-void enable_polyphony(void);
-void disable_polyphony(void);
-void increase_polyphony_rate(float change);
-void decrease_polyphony_rate(float change);
+// These macros are used to allow audio_play_melody 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]))))
-void set_timbre(float timbre);
-void set_tempo(uint8_t tempo);
+/**
+ * @brief convenience macro, to play a melody/SONG once
+ */
+#define PLAY_SONG(note_array) audio_play_melody(&note_array, NOTE_ARRAY_SIZE((note_array)), false)
+// TODO: a 'song' is a melody plus singing/vocals -> PLAY_MELODY
+/**
+ * @brief convenience macro, to play a melody/SONG in a loop, until stopped by 'audio_stop_all'
+ */
+#define PLAY_LOOP(note_array) audio_play_melody(&note_array, NOTE_ARRAY_SIZE((note_array)), true)
-void increase_tempo(uint8_t tempo_change);
-void decrease_tempo(uint8_t tempo_change);
+// Tone-Multiplexing functions
+// this feature only makes sense for hardware setups which can't do proper
+// audio-wave synthesis = have no DAC and need to use PWM for tone generation
+#ifdef AUDIO_ENABLE_TONE_MULTIPLEXING
+# ifndef AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT
+# define AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT 0
+// 0=off, good starting value is 4; the lower the value the higher the cpu-load
+# endif
+void audio_set_tone_multiplexing_rate(uint16_t rate);
+void audio_enable_tone_multiplexing(void);
+void audio_disable_tone_multiplexing(void);
+void audio_increase_tone_multiplexing_rate(uint16_t change);
+void audio_decrease_tone_multiplexing_rate(uint16_t change);
+#endif
+
+// Tempo functions
+
+void audio_set_tempo(uint8_t tempo);
+void audio_increase_tempo(uint8_t tempo_change);
+void audio_decrease_tempo(uint8_t tempo_change);
+
+// conversion macros, from 64parts-to-a-beat to milliseconds and back
+uint16_t audio_duration_to_ms(uint16_t duration_bpm);
+uint16_t audio_ms_to_duration(uint16_t duration_ms);
-void audio_init(void);
void audio_startup(void);
-#ifdef PWM_AUDIO
-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);
+// hardware interface
-#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), }
+// implementation in the driver_avr/arm_* respective parts
+void audio_driver_initialize(void);
+void audio_driver_start(void);
+void audio_driver_stop(void);
-// 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_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)
+/**
+ * @brief get the number of currently active tones
+ * @return number, 0=none active
+ */
+uint8_t audio_get_number_of_active_tones(void);
+
+/**
+ * @brief access to the raw/unprocessed frequency for a specific tone
+ * @details each active tone has a frequency associated with it, which
+ * the internal state keeps track of, and is usually influenced
+ * by various effects
+ * @param[in] tone_index, ranging from 0 to number_of_active_tones-1, with the
+ * first being the most recent and each increment yielding the next
+ * older one
+ * @return a positive frequency, in Hz; or zero if the tone is a pause
+ */
+float audio_get_frequency(uint8_t tone_index);
+
+/**
+ * @brief calculate and return the frequency for the requested tone
+ * @details effects like glissando, vibrato, ... are post-processed onto the
+ * each active tones 'base'-frequency; this function returns the
+ * post-processed result.
+ * @param[in] tone_index, ranging from 0 to number_of_active_tones-1, with the
+ * first being the most recent and each increment yielding the next
+ * older one
+ * @return a positive frequency, in Hz; or zero if the tone is a pause
+ */
+float audio_get_processed_frequency(uint8_t tone_index);
+
+/**
+ * @brief update audio internal state: currently playing and active tones,...
+ * @details This function is intended to be called by the audio-hardware
+ * specific implementation on a somewhat regular basis while a SONG
+ * or notes (pitch+duration) are playing to 'advance' the internal
+ * state (current playing notes, position in the melody, ...)
+ *
+ * @return true if something changed in the currently active tones, which the
+ * hardware might need to react to
+ */
+bool audio_update_state(void);
+
+// legacy and back-warts compatibility stuff
+
+#define is_audio_on() audio_is_on()
+#define is_playing_notes() audio_is_playing_melody()
+#define is_playing_note() audio_is_playing_note()
+#define stop_all_notes() audio_stop_all()
+#define stop_note(f) audio_stop_tone(f)
+#define play_note(f, v) audio_play_tone(f)
-bool is_playing_notes(void);
+#define set_timbre(t) voice_set_timbre(t)
+#define set_tempo(t) audio_set_tempo(t)
+#define increase_tempo(t) audio_increase_tempo(t)
+#define decrease_tempo(t) audio_decrease_tempo(t)
+// vibrato functions are not used in any keyboards
diff --git a/quantum/audio/audio_pwm.c b/quantum/audio/audio_pwm.c
deleted file mode 100644
index d93ac4bb40..0000000000
--- a/quantum/audio/audio_pwm.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/* 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/>.
- */
-#include <stdio.h>
-#include <string.h>
-//#include <math.h>
-#include <avr/pgmspace.h>
-#include <avr/interrupt.h>
-#include <avr/io.h>
-#include "print.h"
-#include "audio.h"
-#include "keymap.h"
-
-#include "eeconfig.h"
-
-#define PI 3.14159265
-
-#define CPU_PRESCALER 8
-
-#ifndef STARTUP_SONG
-# define STARTUP_SONG SONG(STARTUP_SOUND)
-#endif
-float startup_song[][2] = STARTUP_SONG;
-
-// Timer Abstractions
-
-// TIMSK3 - Timer/Counter #3 Interrupt Mask Register
-// Turn on/off 3A interputs, stopping/enabling the ISR calls
-#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;
-#endif
-
-void delay_us(int count) {
- while (count--) {
- _delay_us(1);
- }
-}
-
-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;
-
-float place = 0;
-
-uint8_t* sample;
-uint16_t sample_length = 0;
-// float freq = 0;
-
-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];
-uint16_t notes_count;
-bool notes_repeat;
-float notes_rest;
-bool note_resting = false;
-
-uint16_t current_note = 0;
-uint8_t rest_counter = 0;
-
-#ifdef VIBRATO_ENABLE
-float vibrato_counter = 0;
-float vibrato_strength = .5;
-float vibrato_rate = 0.125;
-#endif
-
-float polyphony_rate = 0;
-
-static bool audio_initialized = false;
-
-audio_config_t audio_config;
-
-uint16_t envelope_index = 0;
-
-void audio_init() {
- // Check EEPROM
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
- audio_config.raw = eeconfig_read_audio();
-
-#ifdef PWM_AUDIO
-
- 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;
-
- /* Enable the OC4A output */
- DDRC |= _BV(PORTC6);
-
- 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
-
-#else
-
- // Set port PC6 (OC3A and /OC4A) as output
- DDRC |= _BV(PORTC6);
-
- 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);
-
-#endif
-
- audio_initialized = true;
-}
-
-void audio_startup() {
- if (audio_config.enable) {
- PLAY_SONG(startup_song);
- }
-}
-
-void stop_all_notes() {
- if (!audio_initialized) {
- audio_init();
- }
- voices = 0;
-#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;
-
- for (uint8_t i = 0; i < 8; i++) {
- frequencies[i] = 0;
- volumes[i] = 0;
- }
-}
-
-void stop_note(float freq) {
- if (playing_note) {
- if (!audio_initialized) {
- audio_init();
- }
-#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;
- 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) {
-#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;
- }
- }
-}
-
-#ifdef VIBRATO_ENABLE
-
-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);
- return vibrated_freq;
-}
-
-#endif
-
-ISR(TIMER3_COMPA_vect) {
- if (playing_note) {
-#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
- 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;
- }
-#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];
- }
- } 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;
- }
- }
-
- if (envelope_index < 65535) {
- envelope_index++;
- }
- 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
- // OCR4A = pgm_read_byte(&sample[(uint16_t)place_int]);
-
- // place_int++;
-
- // if (place_int >= sample_length)
- // if (repeat)
- // place_int -= sample_length;
- // 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;
- }
-
- 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;
- if (NOTE_PERIOD > 0)
- end_of_note = (note_position >= (note_length / NOTE_PERIOD * 0xFFFF));
- else
- end_of_note = (note_position >= (note_length * 0x7FF));
- if (end_of_note) {
- current_note++;
- if (current_note >= notes_count) {
- 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
- playing_notes = false;
- return;
- }
- }
- if (!note_resting && (notes_rest > 0)) {
- note_resting = true;
- note_frequency = 0;
- 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
- }
- note_position = 0;
- }
- }
-
- if (!audio_config.enable) {
- playing_notes = 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();
-
- playing_note = true;
-
- envelope_index = 0;
-
-#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) {
- 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;
-
- notes_pointer = np;
- notes_count = n_count;
- notes_repeat = n_repeat;
- notes_rest = n_rest;
-
- place = 0;
- current_note = 0;
-
-#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) {
- if (!audio_initialized) {
- audio_init();
- }
-
- if (audio_config.enable) {
- DISABLE_AUDIO_COUNTER_3_ISR;
- stop_all_notes();
- place_int = 0;
- sample = s;
- sample_length = l;
- repeat = r;
-
- ENABLE_AUDIO_COUNTER_3_ISR;
- }
-}
-#endif
-
-void audio_toggle(void) {
- audio_config.enable ^= 1;
- eeconfig_update_audio(audio_config.raw);
-}
-
-void audio_on(void) {
- audio_config.enable = 1;
- eeconfig_update_audio(audio_config.raw);
-}
-
-void audio_off(void) {
- 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 increase_vibrato_rate(float change) { vibrato_rate *= change; }
-
-void decrease_vibrato_rate(float change) { vibrato_rate /= change; }
-
-# ifdef VIBRATO_STRENGTH_ENABLE
-
-void set_vibrato_strength(float strength) { vibrato_strength = strength; }
-
-void increase_vibrato_strength(float change) { vibrato_strength *= change; }
-
-void decrease_vibrato_strength(float change) { vibrato_strength /= change; }
-
-# endif /* VIBRATO_STRENGTH_ENABLE */
-
-#endif /* VIBRATO_ENABLE */
-
-// Polyphony functions
-
-void set_polyphony_rate(float rate) { polyphony_rate = rate; }
-
-void enable_polyphony() { polyphony_rate = 5; }
-
-void disable_polyphony() { polyphony_rate = 0; }
-
-void increase_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; }
-
-// Tempo functions
-
-void set_tempo(uint8_t tempo) { note_tempo = tempo; }
-
-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;
- }
-}
-
-//------------------------------------------------------------------------------
-// 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_goodbye_tone() {}
-//------------------------------------------------------------------------------
diff --git a/quantum/audio/driver_avr_pwm.h b/quantum/audio/driver_avr_pwm.h
new file mode 100644
index 0000000000..d6eb3571da
--- /dev/null
+++ b/quantum/audio/driver_avr_pwm.h
@@ -0,0 +1,17 @@
+/* Copyright 2020 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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
diff --git a/quantum/audio/driver_avr_pwm_hardware.c b/quantum/audio/driver_avr_pwm_hardware.c
new file mode 100644
index 0000000000..df03a4558c
--- /dev/null
+++ b/quantum/audio/driver_avr_pwm_hardware.c
@@ -0,0 +1,332 @@
+/* Copyright 2016 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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/>.
+ */
+
+#if defined(__AVR__)
+# include <avr/pgmspace.h>
+# include <avr/interrupt.h>
+# include <avr/io.h>
+#endif
+
+#include "audio.h"
+
+extern bool playing_note;
+extern bool playing_melody;
+extern uint8_t note_timbre;
+
+#define CPU_PRESCALER 8
+
+/*
+ Audio Driver: PWM
+
+ drive up to two speakers through the AVR PWM hardware-peripheral, using timer1 and/or timer3 on Atmega32U4.
+
+ the primary channel_1 can be connected to either pin PC4 PC5 or PC6 (the later being used by most AVR based keyboards) with a PMW signal generated by timer3
+ and an optional secondary channel_2 on either pin PB5, PB6 or PB7, with a PWM signal from timer1
+
+ alternatively, the PWM pins on PORTB can be used as only/primary speaker
+*/
+
+#if defined(AUDIO_PIN) && (AUDIO_PIN != C4) && (AUDIO_PIN != C5) && (AUDIO_PIN != C6) && (AUDIO_PIN != B5) && (AUDIO_PIN != B6) && (AUDIO_PIN != B7) && (AUDIO_PIN != D5)
+# error "Audio feature enabled, but no suitable pin selected as AUDIO_PIN - see docs/feature_audio under the AVR settings for available options."
+#endif
+
+#if (AUDIO_PIN == C4) || (AUDIO_PIN == C5) || (AUDIO_PIN == C6)
+# define AUDIO1_PIN_SET
+# define AUDIO1_TIMSKx TIMSK3
+# define AUDIO1_TCCRxA TCCR3A
+# define AUDIO1_TCCRxB TCCR3B
+# define AUDIO1_ICRx ICR3
+# define AUDIO1_WGMx0 WGM30
+# define AUDIO1_WGMx1 WGM31
+# define AUDIO1_WGMx2 WGM32
+# define AUDIO1_WGMx3 WGM33
+# define AUDIO1_CSx0 CS30
+# define AUDIO1_CSx1 CS31
+# define AUDIO1_CSx2 CS32
+
+# if (AUDIO_PIN == C6)
+# define AUDIO1_COMxy0 COM3A0
+# define AUDIO1_COMxy1 COM3A1
+# define AUDIO1_OCIExy OCIE3A
+# define AUDIO1_OCRxy OCR3A
+# define AUDIO1_PIN C6
+# define AUDIO1_TIMERx_COMPy_vect TIMER3_COMPA_vect
+# elif (AUDIO_PIN == C5)
+# define AUDIO1_COMxy0 COM3B0
+# define AUDIO1_COMxy1 COM3B1
+# define AUDIO1_OCIExy OCIE3B
+# define AUDIO1_OCRxy OCR3B
+# define AUDIO1_PIN C5
+# define AUDIO1_TIMERx_COMPy_vect TIMER3_COMPB_vect
+# elif (AUDIO_PIN == C4)
+# define AUDIO1_COMxy0 COM3C0
+# define AUDIO1_COMxy1 COM3C1
+# define AUDIO1_OCIExy OCIE3C
+# define AUDIO1_OCRxy OCR3C
+# define AUDIO1_PIN C4
+# define AUDIO1_TIMERx_COMPy_vect TIMER3_COMPC_vect
+# endif
+#endif
+
+#if defined(AUDIO_PIN) && defined(AUDIO_PIN_ALT) && (AUDIO_PIN == AUDIO_PIN_ALT)
+# error "Audio feature: AUDIO_PIN and AUDIO_PIN_ALT on the same pin makes no sense."
+#endif
+
+#if ((AUDIO_PIN == B5) && ((AUDIO_PIN_ALT == B6) || (AUDIO_PIN_ALT == B7))) || ((AUDIO_PIN == B6) && ((AUDIO_PIN_ALT == B5) || (AUDIO_PIN_ALT == B7))) || ((AUDIO_PIN == B7) && ((AUDIO_PIN_ALT == B5) || (AUDIO_PIN_ALT == B6)))
+# error "Audio feature: PORTB as AUDIO_PIN and AUDIO_PIN_ALT at the same time is not supported."
+#endif
+
+#if defined(AUDIO_PIN_ALT) && (AUDIO_PIN_ALT != B5) && (AUDIO_PIN_ALT != B6) && (AUDIO_PIN_ALT != B7)
+# error "Audio feature: the pin selected as AUDIO_PIN_ALT is not supported."
+#endif
+
+#if (AUDIO_PIN == B5) || (AUDIO_PIN == B6) || (AUDIO_PIN == B7) || (AUDIO_PIN_ALT == B5) || (AUDIO_PIN_ALT == B6) || (AUDIO_PIN_ALT == B7) || (AUDIO_PIN == D5)
+# define AUDIO2_PIN_SET
+# define AUDIO2_TIMSKx TIMSK1
+# define AUDIO2_TCCRxA TCCR1A
+# define AUDIO2_TCCRxB TCCR1B
+# define AUDIO2_ICRx ICR1
+# define AUDIO2_WGMx0 WGM10
+# define AUDIO2_WGMx1 WGM11
+# define AUDIO2_WGMx2 WGM12
+# define AUDIO2_WGMx3 WGM13
+# define AUDIO2_CSx0 CS10
+# define AUDIO2_CSx1 CS11
+# define AUDIO2_CSx2 CS12
+
+# if (AUDIO_PIN == B5) || (AUDIO_PIN_ALT == B5)
+# define AUDIO2_COMxy0 COM1A0
+# define AUDIO2_COMxy1 COM1A1
+# define AUDIO2_OCIExy OCIE1A
+# define AUDIO2_OCRxy OCR1A
+# define AUDIO2_PIN B5
+# define AUDIO2_TIMERx_COMPy_vect TIMER1_COMPA_vect
+# elif (AUDIO_PIN == B6) || (AUDIO_PIN_ALT == B6)
+# define AUDIO2_COMxy0 COM1B0
+# define AUDIO2_COMxy1 COM1B1
+# define AUDIO2_OCIExy OCIE1B
+# define AUDIO2_OCRxy OCR1B
+# define AUDIO2_PIN B6
+# define AUDIO2_TIMERx_COMPy_vect TIMER1_COMPB_vect
+# elif (AUDIO_PIN == B7) || (AUDIO_PIN_ALT == B7)
+# define AUDIO2_COMxy0 COM1C0
+# define AUDIO2_COMxy1 COM1C1
+# define AUDIO2_OCIExy OCIE1C
+# define AUDIO2_OCRxy OCR1C
+# define AUDIO2_PIN B7
+# define AUDIO2_TIMERx_COMPy_vect TIMER1_COMPC_vect
+# elif (AUDIO_PIN == D5) && defined(__AVR_ATmega32A__)
+# pragma message "Audio support for ATmega32A is experimental and can cause crashes."
+# undef AUDIO2_TIMSKx
+# define AUDIO2_TIMSKx TIMSK
+# define AUDIO2_COMxy0 COM1A0
+# define AUDIO2_COMxy1 COM1A1
+# define AUDIO2_OCIExy OCIE1A
+# define AUDIO2_OCRxy OCR1A
+# define AUDIO2_PIN D5
+# define AUDIO2_TIMERx_COMPy_vect TIMER1_COMPA_vect
+# endif
+#endif
+
+// C6 seems to be the assumed default by many existing keyboard - but sill warn the user
+#if !defined(AUDIO1_PIN_SET) && !defined(AUDIO2_PIN_SET)
+# pragma message "Audio feature enabled, but no suitable pin selected - see docs/feature_audio under the AVR settings for available options. Don't expect to hear anything... :-)"
+// TODO: make this an error - go through the breaking-change-process and change all keyboards to the new define
+#endif
+// -----------------------------------------------------------------------------
+
+#ifdef AUDIO1_PIN_SET
+static float channel_1_frequency = 0.0f;
+void channel_1_set_frequency(float freq) {
+ if (freq == 0.0f) // a pause/rest is a valid "note" with freq=0
+ {
+ // disable the output, but keep the pwm-ISR going (with the previous
+ // frequency) so the audio-state keeps getting updated
+ // Note: setting the duty-cycle 0 is not possible on non-inverting PWM mode - see the AVR data-sheet
+ AUDIO1_TCCRxA &= ~(_BV(AUDIO1_COMxy1) | _BV(AUDIO1_COMxy0));
+ return;
+ } else {
+ AUDIO1_TCCRxA |= _BV(AUDIO1_COMxy1); // enable output, PWM mode
+ }
+
+ channel_1_frequency = freq;
+
+ // set pwm period
+ AUDIO1_ICRx = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
+ // and duty cycle
+ AUDIO1_OCRxy = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre / 100);
+}
+
+void channel_1_start(void) {
+ // enable timer-counter ISR
+ AUDIO1_TIMSKx |= _BV(AUDIO1_OCIExy);
+ // enable timer-counter output
+ AUDIO1_TCCRxA |= _BV(AUDIO1_COMxy1);
+}
+
+void channel_1_stop(void) {
+ // disable timer-counter ISR
+ AUDIO1_TIMSKx &= ~_BV(AUDIO1_OCIExy);
+ // disable timer-counter output
+ AUDIO1_TCCRxA &= ~(_BV(AUDIO1_COMxy1) | _BV(AUDIO1_COMxy0));
+}
+#endif
+
+#ifdef AUDIO2_PIN_SET
+static float channel_2_frequency = 0.0f;
+void channel_2_set_frequency(float freq) {
+ if (freq == 0.0f) {
+ AUDIO2_TCCRxA &= ~(_BV(AUDIO2_COMxy1) | _BV(AUDIO2_COMxy0));
+ return;
+ } else {
+ AUDIO2_TCCRxA |= _BV(AUDIO2_COMxy1);
+ }
+
+ channel_2_frequency = freq;
+
+ AUDIO2_ICRx = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
+ AUDIO2_OCRxy = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre / 100);
+}
+
+float channel_2_get_frequency(void) { return channel_2_frequency; }
+
+void channel_2_start(void) {
+ AUDIO2_TIMSKx |= _BV(AUDIO2_OCIExy);
+ AUDIO2_TCCRxA |= _BV(AUDIO2_COMxy1);
+}
+
+void channel_2_stop(void) {
+ AUDIO2_TIMSKx &= ~_BV(AUDIO2_OCIExy);
+ AUDIO2_TCCRxA &= ~(_BV(AUDIO2_COMxy1) | _BV(AUDIO2_COMxy0));
+}
+#endif
+
+void audio_driver_initialize() {
+#ifdef AUDIO1_PIN_SET
+ channel_1_stop();
+ setPinOutput(AUDIO1_PIN);
+#endif
+
+#ifdef AUDIO2_PIN_SET
+ channel_2_stop();
+ setPinOutput(AUDIO2_PIN);
+#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 AUDIO1_PIN_SET
+ // initialize timer-counter
+ AUDIO1_TCCRxA = (0 << AUDIO1_COMxy1) | (0 << AUDIO1_COMxy0) | (1 << AUDIO1_WGMx1) | (0 << AUDIO1_WGMx0);
+ AUDIO1_TCCRxB = (1 << AUDIO1_WGMx3) | (1 << AUDIO1_WGMx2) | (0 << AUDIO1_CSx2) | (1 << AUDIO1_CSx1) | (0 << AUDIO1_CSx0);
+#endif
+
+#ifdef AUDIO2_PIN_SET
+ AUDIO2_TCCRxA = (0 << AUDIO2_COMxy1) | (0 << AUDIO2_COMxy0) | (1 << AUDIO2_WGMx1) | (0 << AUDIO2_WGMx0);
+ AUDIO2_TCCRxB = (1 << AUDIO2_WGMx3) | (1 << AUDIO2_WGMx2) | (0 << AUDIO2_CSx2) | (1 << AUDIO2_CSx1) | (0 << AUDIO2_CSx0);
+#endif
+}
+
+void audio_driver_stop() {
+#ifdef AUDIO1_PIN_SET
+ channel_1_stop();
+#endif
+
+#ifdef AUDIO2_PIN_SET
+ channel_2_stop();
+#endif
+}
+
+void audio_driver_start(void) {
+#ifdef AUDIO1_PIN_SET
+ channel_1_start();
+ if (playing_note) {
+ channel_1_set_frequency(audio_get_processed_frequency(0));
+ }
+#endif
+
+#if !defined(AUDIO1_PIN_SET) && defined(AUDIO2_PIN_SET)
+ channel_2_start();
+ if (playing_note) {
+ channel_2_set_frequency(audio_get_processed_frequency(0));
+ }
+#endif
+}
+
+static volatile uint32_t isr_counter = 0;
+#ifdef AUDIO1_PIN_SET
+ISR(AUDIO1_TIMERx_COMPy_vect) {
+ isr_counter++;
+ if (isr_counter < channel_1_frequency / (CPU_PRESCALER * 8)) return;
+
+ isr_counter = 0;
+ bool state_changed = audio_update_state();
+
+ if (!playing_note && !playing_melody) {
+ channel_1_stop();
+# ifdef AUDIO2_PIN_SET
+ channel_2_stop();
+# endif
+ return;
+ }
+
+ if (state_changed) {
+ channel_1_set_frequency(audio_get_processed_frequency(0));
+# ifdef AUDIO2_PIN_SET
+ if (audio_get_number_of_active_tones() > 1) {
+ channel_2_set_frequency(audio_get_processed_frequency(1));
+ } else {
+ channel_2_stop();
+ }
+# endif
+ }
+}
+#endif
+
+#if !defined(AUDIO1_PIN_SET) && defined(AUDIO2_PIN_SET)
+ISR(AUDIO2_TIMERx_COMPy_vect) {
+ isr_counter++;
+ if (isr_counter < channel_2_frequency / (CPU_PRESCALER * 8)) return;
+
+ isr_counter = 0;
+ bool state_changed = audio_update_state();
+
+ if (!playing_note && !playing_melody) {
+ channel_2_stop();
+ return;
+ }
+
+ if (state_changed) {
+ channel_2_set_frequency(audio_get_processed_frequency(0));
+ }
+}
+#endif
diff --git a/quantum/audio/driver_chibios_dac.h b/quantum/audio/driver_chibios_dac.h
new file mode 100644
index 0000000000..07cd622ead
--- /dev/null
+++ b/quantum/audio/driver_chibios_dac.h
@@ -0,0 +1,126 @@
+/* Copyright 2019 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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
+
+#ifndef A4
+# define A4 PAL_LINE(GPIOA, 4)
+#endif
+#ifndef A5
+# define A5 PAL_LINE(GPIOA, 5)
+#endif
+
+/**
+ * Size of the dac_buffer arrays. All must be the same size.
+ */
+#define AUDIO_DAC_BUFFER_SIZE 256U
+
+/**
+ * Highest value allowed sample value.
+
+ * since the DAC is limited to 12 bit, the absolute max is 0xfff = 4095U;
+ * lower values adjust the peak-voltage aka volume down.
+ * adjusting this value has only an effect on a sample-buffer whose values are
+ * are NOT pregenerated - see square-wave
+ */
+#ifndef AUDIO_DAC_SAMPLE_MAX
+# define AUDIO_DAC_SAMPLE_MAX 4095U
+#endif
+
+#if !defined(AUDIO_DAC_SAMPLE_RATE) && !defined(AUDIO_MAX_SIMULTANEOUS_TONES) && !defined(AUDIO_DAC_QUALITY_VERY_LOW) && !defined(AUDIO_DAC_QUALITY_LOW) && !defined(AUDIO_DAC_QUALITY_HIGH) && !defined(AUDIO_DAC_QUALITY_VERY_HIGH)
+# define AUDIO_DAC_QUALITY_SANE_MINIMUM
+#endif
+
+/**
+ * These presets allow you to quickly switch between quality settings for
+ * the DAC. The sample rate and maximum number of simultaneous tones roughly
+ * has an inverse relationship - slightly higher sample rates may be possible.
+ *
+ * NOTE: a high sample-rate results in a higher cpu-load, which might lead to
+ * (audible) discontinuities and/or starve other processes of cpu-time
+ * (like RGB-led back-lighting, ...)
+ */
+#ifdef AUDIO_DAC_QUALITY_VERY_LOW
+# define AUDIO_DAC_SAMPLE_RATE 11025U
+# define AUDIO_MAX_SIMULTANEOUS_TONES 8
+#endif
+
+#ifdef AUDIO_DAC_QUALITY_LOW
+# define AUDIO_DAC_SAMPLE_RATE 22050U
+# define AUDIO_MAX_SIMULTANEOUS_TONES 4
+#endif
+
+#ifdef AUDIO_DAC_QUALITY_HIGH
+# define AUDIO_DAC_SAMPLE_RATE 44100U
+# define AUDIO_MAX_SIMULTANEOUS_TONES 2
+#endif
+
+#ifdef AUDIO_DAC_QUALITY_VERY_HIGH
+# define AUDIO_DAC_SAMPLE_RATE 88200U
+# define AUDIO_MAX_SIMULTANEOUS_TONES 1
+#endif
+
+#ifdef AUDIO_DAC_QUALITY_SANE_MINIMUM
+/* a sane-minimum config: with a trade-off between cpu-load and tone-range
+ *
+ * the (currently) highest defined note is NOTE_B8 with 7902Hz; if we now
+ * aim for an even even multiple of the buffer-size, we end up with:
+ * ( roundUptoPow2(highest note / AUDIO_DAC_BUFFER_SIZE) * nyquist-rate * AUDIO_DAC_BUFFER_SIZE)
+ * 7902/256 = 30.867 * 2 * 256 ~= 16384
+ * which works out (but the 'scope shows some sampling artifacts with lower harmonics :-P)
+ */
+# define AUDIO_DAC_SAMPLE_RATE 16384U
+# define AUDIO_MAX_SIMULTANEOUS_TONES 8
+#endif
+
+/**
+ * Effective bit-rate of the DAC. 44.1khz is the standard for most audio - any
+ * lower will sacrifice perceptible audio quality. Any higher will limit the
+ * number of simultaneous tones. In most situations, a tenth (1/10) of the
+ * sample rate is where notes become unbearable.
+ */
+#ifndef AUDIO_DAC_SAMPLE_RATE
+# define AUDIO_DAC_SAMPLE_RATE 44100U
+#endif
+
+/**
+ * The number of tones that can be played simultaneously. If too high a value
+ * is used here, the keyboard will freeze and glitch-out when that many tones
+ * are being played.
+ */
+#ifndef AUDIO_MAX_SIMULTANEOUS_TONES
+# define AUDIO_MAX_SIMULTANEOUS_TONES 2
+#endif
+
+/**
+ * The default value of the DAC when not playing anything. Certain hardware
+ * setups may require a high (AUDIO_DAC_SAMPLE_MAX) or low (0) value here.
+ * Since multiple added sine waves tend to oscillate around the midpoint,
+ * and possibly never/rarely reach either 0 of MAX, 1/2 MAX can be a
+ * reasonable default value.
+ */
+#ifndef AUDIO_DAC_OFF_VALUE
+# define AUDIO_DAC_OFF_VALUE AUDIO_DAC_SAMPLE_MAX / 2
+#endif
+
+#if AUDIO_DAC_OFF_VALUE > AUDIO_DAC_SAMPLE_MAX
+# error "AUDIO_DAC: OFF_VALUE may not be larger than SAMPLE_MAX"
+#endif
+
+/**
+ *user overridable sample generation/processing
+ */
+uint16_t dac_value_generate(void);
diff --git a/quantum/audio/driver_chibios_dac_additive.c b/quantum/audio/driver_chibios_dac_additive.c
new file mode 100644
index 0000000000..db304adb87
--- /dev/null
+++ b/quantum/audio/driver_chibios_dac_additive.c
@@ -0,0 +1,335 @@
+/* Copyright 2016-2019 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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 "audio.h"
+#include <ch.h>
+#include <hal.h>
+
+/*
+ Audio Driver: DAC
+
+ which utilizes the dac unit many STM32 are equipped with, to output a modulated waveform from samples stored in the dac_buffer_* array who are passed to the hardware through DMA
+
+ it is also possible to have a custom sample-LUT by implementing/overriding 'dac_value_generate'
+
+ this driver allows for multiple simultaneous tones to be played through one single channel by doing additive wave-synthesis
+*/
+
+#if !defined(AUDIO_PIN)
+# error "Audio feature enabled, but no suitable pin selected as AUDIO_PIN - see docs/feature_audio under 'ARM (DAC additive)' for available options."
+#endif
+#if defined(AUDIO_PIN_ALT) && !defined(AUDIO_PIN_ALT_AS_NEGATIVE)
+# pragma message "Audio feature: AUDIO_PIN_ALT set, but not AUDIO_PIN_ALT_AS_NEGATIVE - pin will be left unused; audio might still work though."
+#endif
+
+#if !defined(AUDIO_PIN_ALT)
+// no ALT pin defined is valid, but the c-ifs below need some value set
+# define AUDIO_PIN_ALT PAL_NOLINE
+#endif
+
+#if !defined(AUDIO_DAC_SAMPLE_WAVEFORM_SINE) && !defined(AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE) && !defined(AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE) && !defined(AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID)
+# define AUDIO_DAC_SAMPLE_WAVEFORM_SINE
+#endif
+
+#ifdef AUDIO_DAC_SAMPLE_WAVEFORM_SINE
+/* one full sine wave over [0,2*pi], but shifted up one amplitude and left pi/4; for the samples to start at 0
+ */
+static const dacsample_t dac_buffer_sine[AUDIO_DAC_BUFFER_SIZE] = {
+ // 256 values, max 4095
+ 0x0, 0x1, 0x2, 0x6, 0xa, 0xf, 0x16, 0x1e, 0x27, 0x32, 0x3d, 0x4a, 0x58, 0x67, 0x78, 0x89, 0x9c, 0xb0, 0xc5, 0xdb, 0xf2, 0x10a, 0x123, 0x13e, 0x159, 0x175, 0x193, 0x1b1, 0x1d1, 0x1f1, 0x212, 0x235, 0x258, 0x27c, 0x2a0, 0x2c6, 0x2ed, 0x314, 0x33c, 0x365, 0x38e, 0x3b8, 0x3e3, 0x40e, 0x43a, 0x467, 0x494, 0x4c2, 0x4f0, 0x51f, 0x54e, 0x57d, 0x5ad, 0x5dd, 0x60e, 0x63f, 0x670, 0x6a1, 0x6d3, 0x705, 0x737, 0x769, 0x79b, 0x7cd, 0x800, 0x832, 0x864, 0x896, 0x8c8, 0x8fa, 0x92c, 0x95e, 0x98f, 0x9c0, 0x9f1, 0xa22, 0xa52, 0xa82, 0xab1, 0xae0, 0xb0f, 0xb3d, 0xb6b, 0xb98, 0xbc5, 0xbf1, 0xc1c, 0xc47, 0xc71, 0xc9a, 0xcc3, 0xceb, 0xd12, 0xd39, 0xd5f, 0xd83, 0xda7, 0xdca, 0xded, 0xe0e, 0xe2e, 0xe4e, 0xe6c, 0xe8a, 0xea6, 0xec1, 0xedc, 0xef5, 0xf0d, 0xf24, 0xf3a, 0xf4f, 0xf63, 0xf76, 0xf87, 0xf98, 0xfa7, 0xfb5, 0xfc2, 0xfcd, 0xfd8, 0xfe1, 0xfe9, 0xff0, 0xff5, 0xff9, 0xffd, 0xffe,
+ 0xfff, 0xffe, 0xffd, 0xff9, 0xff5, 0xff0, 0xfe9, 0xfe1, 0xfd8, 0xfcd, 0xfc2, 0xfb5, 0xfa7, 0xf98, 0xf87, 0xf76, 0xf63, 0xf4f, 0xf3a, 0xf24, 0xf0d, 0xef5, 0xedc, 0xec1, 0xea6, 0xe8a, 0xe6c, 0xe4e, 0xe2e, 0xe0e, 0xded, 0xdca, 0xda7, 0xd83, 0xd5f, 0xd39, 0xd12, 0xceb, 0xcc3, 0xc9a, 0xc71, 0xc47, 0xc1c, 0xbf1, 0xbc5, 0xb98, 0xb6b, 0xb3d, 0xb0f, 0xae0, 0xab1, 0xa82, 0xa52, 0xa22, 0x9f1, 0x9c0, 0x98f, 0x95e, 0x92c, 0x8fa, 0x8c8, 0x896, 0x864, 0x832, 0x800, 0x7cd, 0x79b, 0x769, 0x737, 0x705, 0x6d3, 0x6a1, 0x670, 0x63f, 0x60e, 0x5dd, 0x5ad, 0x57d, 0x54e, 0x51f, 0x4f0, 0x4c2, 0x494, 0x467, 0x43a, 0x40e, 0x3e3, 0x3b8, 0x38e, 0x365, 0x33c, 0x314, 0x2ed, 0x2c6, 0x2a0, 0x27c, 0x258, 0x235, 0x212, 0x1f1, 0x1d1, 0x1b1, 0x193, 0x175, 0x159, 0x13e, 0x123, 0x10a, 0xf2, 0xdb, 0xc5, 0xb0, 0x9c, 0x89, 0x78, 0x67, 0x58, 0x4a, 0x3d, 0x32, 0x27, 0x1e, 0x16, 0xf, 0xa, 0x6, 0x2, 0x1};
+#endif // AUDIO_DAC_SAMPLE_WAVEFORM_SINE
+#ifdef AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE
+static const dacsample_t dac_buffer_triangle[AUDIO_DAC_BUFFER_SIZE] = {
+ // 256 values, max 4095
+ 0x0, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0, 0x100, 0x120, 0x140, 0x160, 0x180, 0x1a0, 0x1c0, 0x1e0, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0x3c0, 0x3e0, 0x400, 0x420, 0x440, 0x460, 0x480, 0x4a0, 0x4c0, 0x4e0, 0x500, 0x520, 0x540, 0x560, 0x580, 0x5a0, 0x5c0, 0x5e0, 0x600, 0x620, 0x640, 0x660, 0x680, 0x6a0, 0x6c0, 0x6e0, 0x700, 0x720, 0x740, 0x760, 0x780, 0x7a0, 0x7c0, 0x7e0, 0x800, 0x81f, 0x83f, 0x85f, 0x87f, 0x89f, 0x8bf, 0x8df, 0x8ff, 0x91f, 0x93f, 0x95f, 0x97f, 0x99f, 0x9bf, 0x9df, 0x9ff, 0xa1f, 0xa3f, 0xa5f, 0xa7f, 0xa9f, 0xabf, 0xadf, 0xaff, 0xb1f, 0xb3f, 0xb5f, 0xb7f, 0xb9f, 0xbbf, 0xbdf, 0xbff, 0xc1f, 0xc3f, 0xc5f, 0xc7f, 0xc9f, 0xcbf, 0xcdf, 0xcff, 0xd1f, 0xd3f, 0xd5f, 0xd7f, 0xd9f, 0xdbf, 0xddf, 0xdff, 0xe1f, 0xe3f, 0xe5f, 0xe7f, 0xe9f, 0xebf, 0xedf, 0xeff, 0xf1f, 0xf3f, 0xf5f, 0xf7f, 0xf9f, 0xfbf, 0xfdf,
+ 0xfff, 0xfdf, 0xfbf, 0xf9f, 0xf7f, 0xf5f, 0xf3f, 0xf1f, 0xeff, 0xedf, 0xebf, 0xe9f, 0xe7f, 0xe5f, 0xe3f, 0xe1f, 0xdff, 0xddf, 0xdbf, 0xd9f, 0xd7f, 0xd5f, 0xd3f, 0xd1f, 0xcff, 0xcdf, 0xcbf, 0xc9f, 0xc7f, 0xc5f, 0xc3f, 0xc1f, 0xbff, 0xbdf, 0xbbf, 0xb9f, 0xb7f, 0xb5f, 0xb3f, 0xb1f, 0xaff, 0xadf, 0xabf, 0xa9f, 0xa7f, 0xa5f, 0xa3f, 0xa1f, 0x9ff, 0x9df, 0x9bf, 0x99f, 0x97f, 0x95f, 0x93f, 0x91f, 0x8ff, 0x8df, 0x8bf, 0x89f, 0x87f, 0x85f, 0x83f, 0x81f, 0x800, 0x7e0, 0x7c0, 0x7a0, 0x780, 0x760, 0x740, 0x720, 0x700, 0x6e0, 0x6c0, 0x6a0, 0x680, 0x660, 0x640, 0x620, 0x600, 0x5e0, 0x5c0, 0x5a0, 0x580, 0x560, 0x540, 0x520, 0x500, 0x4e0, 0x4c0, 0x4a0, 0x480, 0x460, 0x440, 0x420, 0x400, 0x3e0, 0x3c0, 0x3a0, 0x380, 0x360, 0x340, 0x320, 0x300, 0x2e0, 0x2c0, 0x2a0, 0x280, 0x260, 0x240, 0x220, 0x200, 0x1e0, 0x1c0, 0x1a0, 0x180, 0x160, 0x140, 0x120, 0x100, 0xe0, 0xc0, 0xa0, 0x80, 0x60, 0x40, 0x20};
+#endif // AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE
+#ifdef AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE
+static const dacsample_t dac_buffer_square[AUDIO_DAC_BUFFER_SIZE] = {
+ [0 ... AUDIO_DAC_BUFFER_SIZE / 2 - 1] = 0, // first and
+ [AUDIO_DAC_BUFFER_SIZE / 2 ... AUDIO_DAC_BUFFER_SIZE - 1] = AUDIO_DAC_SAMPLE_MAX, // second half
+};
+#endif // AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE
+/*
+// four steps: 0, 1/3, 2/3 and 1
+static const dacsample_t dac_buffer_staircase[AUDIO_DAC_BUFFER_SIZE] = {
+ [0 ... AUDIO_DAC_BUFFER_SIZE/3 -1 ] = 0,
+ [AUDIO_DAC_BUFFER_SIZE / 4 ... AUDIO_DAC_BUFFER_SIZE / 2 -1 ] = AUDIO_DAC_SAMPLE_MAX / 3,
+ [AUDIO_DAC_BUFFER_SIZE / 2 ... 3 * AUDIO_DAC_BUFFER_SIZE / 4 -1 ] = 2 * AUDIO_DAC_SAMPLE_MAX / 3,
+ [3 * AUDIO_DAC_BUFFER_SIZE / 4 ... AUDIO_DAC_BUFFER_SIZE -1 ] = AUDIO_DAC_SAMPLE_MAX,
+}
+*/
+#ifdef AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID
+static const dacsample_t dac_buffer_trapezoid[AUDIO_DAC_BUFFER_SIZE] = {0x0, 0x1f, 0x7f, 0xdf, 0x13f, 0x19f, 0x1ff, 0x25f, 0x2bf, 0x31f, 0x37f, 0x3df, 0x43f, 0x49f, 0x4ff, 0x55f, 0x5bf, 0x61f, 0x67f, 0x6df, 0x73f, 0x79f, 0x7ff, 0x85f, 0x8bf, 0x91f, 0x97f, 0x9df, 0xa3f, 0xa9f, 0xaff, 0xb5f, 0xbbf, 0xc1f, 0xc7f, 0xcdf, 0xd3f, 0xd9f, 0xdff, 0xe5f, 0xebf, 0xf1f, 0xf7f, 0xfdf, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff,
+ 0xfff, 0xfdf, 0xf7f, 0xf1f, 0xebf, 0xe5f, 0xdff, 0xd9f, 0xd3f, 0xcdf, 0xc7f, 0xc1f, 0xbbf, 0xb5f, 0xaff, 0xa9f, 0xa3f, 0x9df, 0x97f, 0x91f, 0x8bf, 0x85f, 0x7ff, 0x79f, 0x73f, 0x6df, 0x67f, 0x61f, 0x5bf, 0x55f, 0x4ff, 0x49f, 0x43f, 0x3df, 0x37f, 0x31f, 0x2bf, 0x25f, 0x1ff, 0x19f, 0x13f, 0xdf, 0x7f, 0x1f, 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, 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};
+#endif // AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID
+
+static dacsample_t dac_buffer_empty[AUDIO_DAC_BUFFER_SIZE] = {AUDIO_DAC_OFF_VALUE};
+
+/* keep track of the sample position for for each frequency */
+static float dac_if[AUDIO_MAX_SIMULTANEOUS_TONES] = {0.0};
+
+static float active_tones_snapshot[AUDIO_MAX_SIMULTANEOUS_TONES] = {0, 0};
+static uint8_t active_tones_snapshot_length = 0;
+
+typedef enum {
+ OUTPUT_SHOULD_START,
+ OUTPUT_RUN_NORMALLY,
+ // path 1: wait for zero, then change/update active tones
+ OUTPUT_TONES_CHANGED,
+ OUTPUT_REACHED_ZERO_BEFORE_TONE_CHANGE,
+ // path 2: hardware should stop, wait for zero then turn output off = stop the timer
+ OUTPUT_SHOULD_STOP,
+ OUTPUT_REACHED_ZERO_BEFORE_OFF,
+ OUTPUT_OFF,
+ OUTPUT_OFF_1,
+ OUTPUT_OFF_2, // trailing off: giving the DAC two more conversion cycles until the AUDIO_DAC_OFF_VALUE reaches the output, then turn the timer off, which leaves the output at that level
+ number_of_output_states
+} output_states_t;
+output_states_t state = OUTPUT_OFF_2;
+
+/**
+ * Generation of the waveform being passed to the callback. Declared weak so users
+ * can override it with their own wave-forms/noises.
+ */
+__attribute__((weak)) uint16_t dac_value_generate(void) {
+ // DAC is running/asking for values but snapshot length is zero -> must be playing a pause
+ if (active_tones_snapshot_length == 0) {
+ return AUDIO_DAC_OFF_VALUE;
+ }
+
+ /* doing additive wave synthesis over all currently playing tones = adding up
+ * sine-wave-samples for each frequency, scaled by the number of active tones
+ */
+ uint16_t value = 0;
+ float frequency = 0.0f;
+
+ for (uint8_t i = 0; i < active_tones_snapshot_length; i++) {
+ /* Note: a user implementation does not have to rely on the active_tones_snapshot, but
+ * could directly query the active frequencies through audio_get_processed_frequency */
+ frequency = active_tones_snapshot[i];
+
+ dac_if[i] = dac_if[i] + ((frequency * AUDIO_DAC_BUFFER_SIZE) / AUDIO_DAC_SAMPLE_RATE) * 2 / 3;
+ /*Note: the 2/3 are necessary to get the correct frequencies on the
+ * DAC output (as measured with an oscilloscope), since the gpt
+ * timer runs with 3*AUDIO_DAC_SAMPLE_RATE; and the DAC callback
+ * is called twice per conversion.*/
+
+ dac_if[i] = fmod(dac_if[i], AUDIO_DAC_BUFFER_SIZE);
+
+ // Wavetable generation/lookup
+ uint16_t dac_i = (uint16_t)dac_if[i];
+
+#if defined(AUDIO_DAC_SAMPLE_WAVEFORM_SINE)
+ value += dac_buffer_sine[dac_i] / active_tones_snapshot_length;
+#elif defined(AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE)
+ value += dac_buffer_triangle[dac_i] / active_tones_snapshot_length;
+#elif defined(AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID)
+ value += dac_buffer_trapezoid[dac_i] / active_tones_snapshot_length;
+#elif defined(AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE)
+ value += dac_buffer_square[dac_i] / active_tones_snapshot_length;
+#endif
+ /*
+ // SINE
+ value += dac_buffer_sine[dac_i] / active_tones_snapshot_length / 3;
+ // TRIANGLE
+ value += dac_buffer_triangle[dac_i] / active_tones_snapshot_length / 3;
+ // SQUARE
+ value += dac_buffer_square[dac_i] / active_tones_snapshot_length / 3;
+ //NOTE: combination of these three wave-forms is more exemplary - and doesn't sound particularly good :-P
+ */
+
+ // STAIRS (mostly usefully as test-pattern)
+ // value_avg = dac_buffer_staircase[dac_i] / active_tones_snapshot_length;
+ }
+
+ return value;
+}
+
+/**
+ * DAC streaming callback. Does all of the main computing for playing songs.
+ *
+ * Note: chibios calls this CB twice: during the 'half buffer event', and the 'full buffer event'.
+ */
+static void dac_end(DACDriver *dacp) {
+ dacsample_t *sample_p = (dacp)->samples;
+
+ // work on the other half of the buffer
+ if (dacIsBufferComplete(dacp)) {
+ sample_p += AUDIO_DAC_BUFFER_SIZE / 2; // 'half_index'
+ }
+
+ for (uint8_t s = 0; s < AUDIO_DAC_BUFFER_SIZE / 2; s++) {
+ if (OUTPUT_OFF <= state) {
+ sample_p[s] = AUDIO_DAC_OFF_VALUE;
+ continue;
+ } else {
+ sample_p[s] = dac_value_generate();
+ }
+
+ /* zero crossing (or approach, whereas zero == DAC_OFF_VALUE, which can be configured to anything from 0 to DAC_SAMPLE_MAX)
+ * ============================*=*========================== AUDIO_DAC_SAMPLE_MAX
+ * * *
+ * * *
+ * ---------------------------------------------------------
+ * * * } AUDIO_DAC_SAMPLE_MAX/100
+ * --------------------------------------------------------- AUDIO_DAC_OFF_VALUE
+ * * * } AUDIO_DAC_SAMPLE_MAX/100
+ * ---------------------------------------------------------
+ * *
+ * * *
+ * * *
+ * =====*=*================================================= 0x0
+ */
+ if (((sample_p[s] + (AUDIO_DAC_SAMPLE_MAX / 100)) > AUDIO_DAC_OFF_VALUE) && // value approaches from below
+ (sample_p[s] < (AUDIO_DAC_OFF_VALUE + (AUDIO_DAC_SAMPLE_MAX / 100))) // or above
+ ) {
+ if ((OUTPUT_SHOULD_START == state) && (active_tones_snapshot_length > 0)) {
+ state = OUTPUT_RUN_NORMALLY;
+ } else if (OUTPUT_TONES_CHANGED == state) {
+ state = OUTPUT_REACHED_ZERO_BEFORE_TONE_CHANGE;
+ } else if (OUTPUT_SHOULD_STOP == state) {
+ state = OUTPUT_REACHED_ZERO_BEFORE_OFF;
+ }
+ }
+
+ // still 'ramping up', reset the output to OFF_VALUE until the generated values reach that value, to do a smooth handover
+ if (OUTPUT_SHOULD_START == state) {
+ sample_p[s] = AUDIO_DAC_OFF_VALUE;
+ }
+
+ if ((OUTPUT_SHOULD_START == state) || (OUTPUT_REACHED_ZERO_BEFORE_OFF == state) || (OUTPUT_REACHED_ZERO_BEFORE_TONE_CHANGE == state)) {
+ uint8_t active_tones = MIN(AUDIO_MAX_SIMULTANEOUS_TONES, audio_get_number_of_active_tones());
+ active_tones_snapshot_length = 0;
+ // update the snapshot - once, and only on occasion that something changed;
+ // -> saves cpu cycles (?)
+ for (uint8_t i = 0; i < active_tones; i++) {
+ float freq = audio_get_processed_frequency(i);
+ if (freq > 0) { // disregard 'rest' notes, with valid frequency 0.0f; which would only lower the resulting waveform volume during the additive synthesis step
+ active_tones_snapshot[active_tones_snapshot_length++] = freq;
+ }
+ }
+
+ if ((0 == active_tones_snapshot_length) && (OUTPUT_REACHED_ZERO_BEFORE_OFF == state)) {
+ state = OUTPUT_OFF;
+ }
+ if (OUTPUT_REACHED_ZERO_BEFORE_TONE_CHANGE == state) {
+ state = OUTPUT_RUN_NORMALLY;
+ }
+ }
+ }
+
+ // update audio internal state (note position, current_note, ...)
+ if (audio_update_state()) {
+ if (OUTPUT_SHOULD_STOP != state) {
+ state = OUTPUT_TONES_CHANGED;
+ }
+ }
+
+ if (OUTPUT_OFF <= state) {
+ if (OUTPUT_OFF_2 == state) {
+ // stopping timer6 = stopping the DAC at whatever value it is currently pushing to the output = AUDIO_DAC_OFF_VALUE
+ gptStopTimer(&GPTD6);
+ } else {
+ state++;
+ }
+ }
+}
+
+static void dac_error(DACDriver *dacp, dacerror_t err) {
+ (void)dacp;
+ (void)err;
+
+ chSysHalt("DAC failure. halp");
+}
+
+static const GPTConfig gpt6cfg1 = {.frequency = AUDIO_DAC_SAMPLE_RATE * 3,
+ .callback = NULL,
+ .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
+ .dier = 0U};
+
+static const DACConfig dac_conf = {.init = AUDIO_DAC_OFF_VALUE, .datamode = DAC_DHRM_12BIT_RIGHT};
+
+/**
+ * @note The DAC_TRG(0) here selects the Timer 6 TRGO event, which is triggered
+ * on the rising edge after 3 APB1 clock cycles, causing our gpt6cfg1.frequency
+ * to be a third of what we expect.
+ *
+ * Here are all the values for DAC_TRG (TSEL in the ref manual)
+ * TIM15_TRGO 0b011
+ * TIM2_TRGO 0b100
+ * TIM3_TRGO 0b001
+ * TIM6_TRGO 0b000
+ * TIM7_TRGO 0b010
+ * EXTI9 0b110
+ * SWTRIG 0b111
+ */
+static const DACConversionGroup dac_conv_cfg = {.num_channels = 1U, .end_cb = dac_end, .error_cb = dac_error, .trigger = DAC_TRG(0b000)};
+
+void audio_driver_initialize() {
+ if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
+ palSetLineMode(A4, PAL_MODE_INPUT_ANALOG);
+ dacStart(&DACD1, &dac_conf);
+ }
+ if ((AUDIO_PIN == A5) || (AUDIO_PIN_ALT == A5)) {
+ palSetLineMode(A5, PAL_MODE_INPUT_ANALOG);
+ dacStart(&DACD2, &dac_conf);
+ }
+
+ /* enable the output buffer, to directly drive external loads with no additional circuitry
+ *
+ * see: AN4566 Application note: Extending the DAC performance of STM32 microcontrollers
+ * Note: Buffer-Off bit -> has to be set 0 to enable the output buffer
+ * Note: enabling the output buffer imparts an additional dc-offset of a couple mV
+ *
+ * this is done here, reaching directly into the stm32 registers since chibios has not implemented BOFF handling yet
+ * (see: chibios/os/hal/ports/STM32/todo.txt '- BOFF handling in DACv1.'
+ */
+ DACD1.params->dac->CR &= ~DAC_CR_BOFF1;
+ DACD2.params->dac->CR &= ~DAC_CR_BOFF2;
+
+ if (AUDIO_PIN == A4) {
+ dacStartConversion(&DACD1, &dac_conv_cfg, dac_buffer_empty, AUDIO_DAC_BUFFER_SIZE);
+ } else if (AUDIO_PIN == A5) {
+ dacStartConversion(&DACD2, &dac_conv_cfg, dac_buffer_empty, AUDIO_DAC_BUFFER_SIZE);
+ }
+
+ // no inverted/out-of-phase waveform (yet?), only pulling AUDIO_PIN_ALT to AUDIO_DAC_OFF_VALUE
+#if defined(AUDIO_PIN_ALT_AS_NEGATIVE)
+ if (AUDIO_PIN_ALT == A4) {
+ dacPutChannelX(&DACD1, 0, AUDIO_DAC_OFF_VALUE);
+ } else if (AUDIO_PIN_ALT == A5) {
+ dacPutChannelX(&DACD2, 0, AUDIO_DAC_OFF_VALUE);
+ }
+#endif
+
+ gptStart(&GPTD6, &gpt6cfg1);
+}
+
+void audio_driver_stop(void) { state = OUTPUT_SHOULD_STOP; }
+
+void audio_driver_start(void) {
+ gptStartContinuous(&GPTD6, 2U);
+
+ for (uint8_t i = 0; i < AUDIO_MAX_SIMULTANEOUS_TONES; i++) {
+ dac_if[i] = 0.0f;
+ active_tones_snapshot[i] = 0.0f;
+ }
+ active_tones_snapshot_length = 0;
+ state = OUTPUT_SHOULD_START;
+}
diff --git a/quantum/audio/driver_chibios_dac_basic.c b/quantum/audio/driver_chibios_dac_basic.c
new file mode 100644
index 0000000000..fac6513506
--- /dev/null
+++ b/quantum/audio/driver_chibios_dac_basic.c
@@ -0,0 +1,245 @@
+/* Copyright 2016-2020 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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 "audio.h"
+#include "ch.h"
+#include "hal.h"
+
+/*
+ Audio Driver: DAC
+
+ which utilizes both channels of the DAC unit many STM32 are equipped with to output a modulated square-wave, from precomputed samples stored in a buffer, which is passed to the hardware through DMA
+
+ this driver can either be used to drive to separate speakers, wired to A4+Gnd and A5+Gnd, which allows two tones to be played simultaneously
+ OR
+ one speaker wired to A4+A5 with the AUDIO_PIN_ALT_AS_NEGATIVE define set - see docs/feature_audio
+
+*/
+
+#if !defined(AUDIO_PIN)
+# pragma message "Audio feature enabled, but no suitable pin selected as AUDIO_PIN - see docs/feature_audio under 'ARM (DAC basic)' for available options."
+// TODO: make this an 'error' instead; go through a breaking change, and add AUDIO_PIN A5 to all keyboards currently using AUDIO on STM32 based boards? - for now: set the define here
+# define AUDIO_PIN A5
+#endif
+// check configuration for ONE speaker, connected to both DAC pins
+#if defined(AUDIO_PIN_ALT_AS_NEGATIVE) && !defined(AUDIO_PIN_ALT)
+# error "Audio feature: AUDIO_PIN_ALT_AS_NEGATIVE set, but no pin configured as AUDIO_PIN_ALT"
+#endif
+
+#ifndef AUDIO_PIN_ALT
+// no ALT pin defined is valid, but the c-ifs below need some value set
+# define AUDIO_PIN_ALT -1
+#endif
+
+#if !defined(AUDIO_STATE_TIMER)
+# define AUDIO_STATE_TIMER GPTD8
+#endif
+
+// square-wave
+static const dacsample_t dac_buffer_1[AUDIO_DAC_BUFFER_SIZE] = {
+ // First half is max, second half is 0
+ [0 ... AUDIO_DAC_BUFFER_SIZE / 2 - 1] = AUDIO_DAC_SAMPLE_MAX,
+ [AUDIO_DAC_BUFFER_SIZE / 2 ... AUDIO_DAC_BUFFER_SIZE - 1] = 0,
+};
+
+// square-wave
+static const dacsample_t dac_buffer_2[AUDIO_DAC_BUFFER_SIZE] = {
+ // opposite of dac_buffer above
+ [0 ... AUDIO_DAC_BUFFER_SIZE / 2 - 1] = 0,
+ [AUDIO_DAC_BUFFER_SIZE / 2 ... AUDIO_DAC_BUFFER_SIZE - 1] = AUDIO_DAC_SAMPLE_MAX,
+};
+
+GPTConfig gpt6cfg1 = {.frequency = AUDIO_DAC_SAMPLE_RATE,
+ .callback = NULL,
+ .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
+ .dier = 0U};
+GPTConfig gpt7cfg1 = {.frequency = AUDIO_DAC_SAMPLE_RATE,
+ .callback = NULL,
+ .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
+ .dier = 0U};
+
+static void gpt_audio_state_cb(GPTDriver *gptp);
+GPTConfig gptStateUpdateCfg = {.frequency = 10,
+ .callback = gpt_audio_state_cb,
+ .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
+ .dier = 0U};
+
+static const DACConfig dac_conf_ch1 = {.init = AUDIO_DAC_OFF_VALUE, .datamode = DAC_DHRM_12BIT_RIGHT};
+static const DACConfig dac_conf_ch2 = {.init = AUDIO_DAC_OFF_VALUE, .datamode = DAC_DHRM_12BIT_RIGHT};
+
+/**
+ * @note The DAC_TRG(0) here selects the Timer 6 TRGO event, which is triggered
+ * on the rising edge after 3 APB1 clock cycles, causing our gpt6cfg1.frequency
+ * to be a third of what we expect.
+ *
+ * Here are all the values for DAC_TRG (TSEL in the ref manual)
+ * TIM15_TRGO 0b011
+ * TIM2_TRGO 0b100
+ * TIM3_TRGO 0b001
+ * TIM6_TRGO 0b000
+ * TIM7_TRGO 0b010
+ * EXTI9 0b110
+ * SWTRIG 0b111
+ */
+static const DACConversionGroup dac_conv_grp_ch1 = {.num_channels = 1U, .trigger = DAC_TRG(0b000)};
+static const DACConversionGroup dac_conv_grp_ch2 = {.num_channels = 1U, .trigger = DAC_TRG(0b010)};
+
+void channel_1_start(void) {
+ gptStart(&GPTD6, &gpt6cfg1);
+ gptStartContinuous(&GPTD6, 2U);
+ palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
+}
+
+void channel_1_stop(void) {
+ gptStopTimer(&GPTD6);
+ palSetPadMode(GPIOA, 4, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPad(GPIOA, 4);
+}
+
+static float channel_1_frequency = 0.0f;
+void channel_1_set_frequency(float freq) {
+ channel_1_frequency = freq;
+
+ channel_1_stop();
+ if (freq <= 0.0) // a pause/rest has freq=0
+ return;
+
+ gpt6cfg1.frequency = 2 * freq * AUDIO_DAC_BUFFER_SIZE;
+ channel_1_start();
+}
+float channel_1_get_frequency(void) { return channel_1_frequency; }
+
+void channel_2_start(void) {
+ gptStart(&GPTD7, &gpt7cfg1);
+ gptStartContinuous(&GPTD7, 2U);
+ palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG);
+}
+
+void channel_2_stop(void) {
+ gptStopTimer(&GPTD7);
+ palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPad(GPIOA, 5);
+}
+
+static float channel_2_frequency = 0.0f;
+void channel_2_set_frequency(float freq) {
+ channel_2_frequency = freq;
+
+ channel_2_stop();
+ if (freq <= 0.0) // a pause/rest has freq=0
+ return;
+
+ gpt7cfg1.frequency = 2 * freq * AUDIO_DAC_BUFFER_SIZE;
+ channel_2_start();
+}
+float channel_2_get_frequency(void) { return channel_2_frequency; }
+
+static void gpt_audio_state_cb(GPTDriver *gptp) {
+ if (audio_update_state()) {
+#if defined(AUDIO_PIN_ALT_AS_NEGATIVE)
+ // one piezo/speaker connected to both audio pins, the generated square-waves are inverted
+ channel_1_set_frequency(audio_get_processed_frequency(0));
+ channel_2_set_frequency(audio_get_processed_frequency(0));
+
+#else // two separate audio outputs/speakers
+ // primary speaker on A4, optional secondary on A5
+ if (AUDIO_PIN == A4) {
+ channel_1_set_frequency(audio_get_processed_frequency(0));
+ if (AUDIO_PIN_ALT == A5) {
+ if (audio_get_number_of_active_tones() > 1) {
+ channel_2_set_frequency(audio_get_processed_frequency(1));
+ } else {
+ channel_2_stop();
+ }
+ }
+ }
+
+ // primary speaker on A5, optional secondary on A4
+ if (AUDIO_PIN == A5) {
+ channel_2_set_frequency(audio_get_processed_frequency(0));
+ if (AUDIO_PIN_ALT == A4) {
+ if (audio_get_number_of_active_tones() > 1) {
+ channel_1_set_frequency(audio_get_processed_frequency(1));
+ } else {
+ channel_1_stop();
+ }
+ }
+ }
+#endif
+ }
+}
+
+void audio_driver_initialize() {
+ if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
+ palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
+ dacStart(&DACD1, &dac_conf_ch1);
+
+ // initial setup of the dac-triggering timer is still required, even
+ // though it gets reconfigured and restarted later on
+ gptStart(&GPTD6, &gpt6cfg1);
+ }
+
+ if ((AUDIO_PIN == A5) || (AUDIO_PIN_ALT == A5)) {
+ palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG);
+ dacStart(&DACD2, &dac_conf_ch2);
+
+ gptStart(&GPTD7, &gpt7cfg1);
+ }
+
+ /* enable the output buffer, to directly drive external loads with no additional circuitry
+ *
+ * see: AN4566 Application note: Extending the DAC performance of STM32 microcontrollers
+ * Note: Buffer-Off bit -> has to be set 0 to enable the output buffer
+ * Note: enabling the output buffer imparts an additional dc-offset of a couple mV
+ *
+ * this is done here, reaching directly into the stm32 registers since chibios has not implemented BOFF handling yet
+ * (see: chibios/os/hal/ports/STM32/todo.txt '- BOFF handling in DACv1.'
+ */
+ DACD1.params->dac->CR &= ~DAC_CR_BOFF1;
+ DACD2.params->dac->CR &= ~DAC_CR_BOFF2;
+
+ // start state-updater
+ gptStart(&AUDIO_STATE_TIMER, &gptStateUpdateCfg);
+}
+
+void audio_driver_stop(void) {
+ if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
+ gptStopTimer(&GPTD6);
+
+ // stop the ongoing conversion and put the output in a known state
+ dacStopConversion(&DACD1);
+ dacPutChannelX(&DACD1, 0, AUDIO_DAC_OFF_VALUE);
+ }
+
+ if ((AUDIO_PIN == A5) || (AUDIO_PIN_ALT == A5)) {
+ gptStopTimer(&GPTD7);
+
+ dacStopConversion(&DACD2);
+ dacPutChannelX(&DACD2, 0, AUDIO_DAC_OFF_VALUE);
+ }
+ gptStopTimer(&AUDIO_STATE_TIMER);
+}
+
+void audio_driver_start(void) {
+ if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
+ dacStartConversion(&DACD1, &dac_conv_grp_ch1, (dacsample_t *)dac_buffer_1, AUDIO_DAC_BUFFER_SIZE);
+ }
+ if ((AUDIO_PIN == A5) || (AUDIO_PIN_ALT == A5)) {
+ dacStartConversion(&DACD2, &dac_conv_grp_ch2, (dacsample_t *)dac_buffer_2, AUDIO_DAC_BUFFER_SIZE);
+ }
+ gptStartContinuous(&AUDIO_STATE_TIMER, 2U);
+}
diff --git a/quantum/audio/driver_chibios_pwm.h b/quantum/audio/driver_chibios_pwm.h
new file mode 100644
index 0000000000..86cab916e1
--- /dev/null
+++ b/quantum/audio/driver_chibios_pwm.h
@@ -0,0 +1,40 @@
+/* Copyright 2020 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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
+
+#if !defined(AUDIO_PWM_DRIVER)
+// NOTE: Timer2 seems to be used otherwise in QMK, otherwise we could default to A5 (= TIM2_CH1, with PWMD2 and alternate-function(1))
+# define AUDIO_PWM_DRIVER PWMD1
+#endif
+
+#if !defined(AUDIO_PWM_CHANNEL)
+// NOTE: sticking to the STM data-sheet numbering: TIMxCH1 to TIMxCH4
+// default: STM32F303CC PA8+TIM1_CH1 -> 1
+# define AUDIO_PWM_CHANNEL 1
+#endif
+
+#if !defined(AUDIO_PWM_PAL_MODE)
+// pin-alternate function: see the data-sheet for which pin needs what AF to connect to TIMx_CHy
+// default: STM32F303CC PA8+TIM1_CH1 -> 6
+# define AUDIO_PWM_PAL_MODE 6
+#endif
+
+#if !defined(AUDIO_STATE_TIMER)
+// timer used to trigger updates in the audio-system, configured/enabled in chibios mcuconf.
+// Tim6 is the default for "larger" STMs, smaller ones might not have this one (enabled) and need to switch to a different one (e.g.: STM32F103 has only Tim1-Tim4)
+# define AUDIO_STATE_TIMER GPTD6
+#endif
diff --git a/quantum/audio/driver_chibios_pwm_hardware.c b/quantum/audio/driver_chibios_pwm_hardware.c
new file mode 100644
index 0000000000..3c7d89b290
--- /dev/null
+++ b/quantum/audio/driver_chibios_pwm_hardware.c
@@ -0,0 +1,144 @@
+/* Copyright 2020 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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/>.
+ */
+
+/*
+Audio Driver: PWM
+
+the duty-cycle is always kept at 50%, and the pwm-period is adjusted to match the frequency of a note to be played back.
+
+this driver uses the chibios-PWM system to produce a square-wave on specific output pins that are connected to the PWM hardware.
+The hardware directly toggles the pin via its alternate function. see your MCUs data-sheet for which pin can be driven by what timer - looking for TIMx_CHy and the corresponding alternate function.
+
+ */
+
+#include "audio.h"
+#include "ch.h"
+#include "hal.h"
+
+#if !defined(AUDIO_PIN)
+# error "Audio feature enabled, but no pin selected - see docs/feature_audio under the ARM PWM settings"
+#endif
+
+extern bool playing_note;
+extern bool playing_melody;
+extern uint8_t note_timbre;
+
+static PWMConfig pwmCFG = {
+ .frequency = 100000, /* PWM clock frequency */
+ // CHIBIOS-BUG? can't set the initial period to <2, or the pwm (hard or software) takes ~130ms with .frequency=500000 for a pwmChangePeriod to take effect; with no output=silence in the meantime
+ .period = 2, /* initial PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */
+ .callback = NULL, /* no callback, the hardware directly toggles the pin */
+ .channels =
+ {
+#if AUDIO_PWM_CHANNEL == 4
+ {PWM_OUTPUT_DISABLED, NULL}, /* channel 0 -> TIMx_CH1 */
+ {PWM_OUTPUT_DISABLED, NULL}, /* channel 1 -> TIMx_CH2 */
+ {PWM_OUTPUT_DISABLED, NULL}, /* channel 2 -> TIMx_CH3 */
+ {PWM_OUTPUT_ACTIVE_HIGH, NULL} /* channel 3 -> TIMx_CH4 */
+#elif AUDIO_PWM_CHANNEL == 3
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_ACTIVE_HIGH, NULL}, /* TIMx_CH3 */
+ {PWM_OUTPUT_DISABLED, NULL}
+#elif AUDIO_PWM_CHANNEL == 2
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_ACTIVE_HIGH, NULL}, /* TIMx_CH2 */
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL}
+#else /*fallback to CH1 */
+ {PWM_OUTPUT_ACTIVE_HIGH, NULL}, /* TIMx_CH1 */
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL},
+ {PWM_OUTPUT_DISABLED, NULL}
+#endif
+ },
+};
+
+static float channel_1_frequency = 0.0f;
+void channel_1_set_frequency(float freq) {
+ channel_1_frequency = freq;
+
+ if (freq <= 0.0) // a pause/rest has freq=0
+ return;
+
+ pwmcnt_t period = (pwmCFG.frequency / freq);
+ pwmChangePeriod(&AUDIO_PWM_DRIVER, period);
+ pwmEnableChannel(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1,
+ // adjust the duty-cycle so that the output is for 'note_timbre' duration HIGH
+ PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100));
+}
+
+float channel_1_get_frequency(void) { return channel_1_frequency; }
+
+void channel_1_start(void) {
+ pwmStop(&AUDIO_PWM_DRIVER);
+ pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
+}
+
+void channel_1_stop(void) { pwmStop(&AUDIO_PWM_DRIVER); }
+
+static void gpt_callback(GPTDriver *gptp);
+GPTConfig gptCFG = {
+ /* a whole note is one beat, which is - per definition in musical_notes.h - set to 64
+ the longest note is BREAVE_DOT=128+64=192, the shortest SIXTEENTH=4
+ the tempo (which might vary!) is in bpm (beats per minute)
+ therefore: if the timer ticks away at .frequency = (60*64)Hz,
+ and the .interval counts from 64 downwards - audio_update_state is
+ called just often enough to not miss any notes
+ */
+ .frequency = 60 * 64,
+ .callback = gpt_callback,
+};
+
+void audio_driver_initialize(void) {
+ pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
+
+ // connect the AUDIO_PIN to the PWM hardware
+#if defined(USE_GPIOV1) // STM32F103C8
+ palSetLineMode(AUDIO_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
+#else // GPIOv2 (or GPIOv3 for f4xx, which is the same/compatible at this command)
+ palSetLineMode(AUDIO_PIN, PAL_STM32_MODE_ALTERNATE | PAL_STM32_ALTERNATE(AUDIO_PWM_PAL_MODE));
+#endif
+
+ gptStart(&AUDIO_STATE_TIMER, &gptCFG);
+}
+
+void audio_driver_start(void) {
+ channel_1_stop();
+ channel_1_start();
+
+ if (playing_note || playing_melody) {
+ gptStartContinuous(&AUDIO_STATE_TIMER, 64);
+ }
+}
+
+void audio_driver_stop(void) {
+ channel_1_stop();
+ gptStopTimer(&AUDIO_STATE_TIMER);
+}
+
+/* a regular timer task, that checks the note to be currently played
+ * and updates the pwm to output that frequency
+ */
+static void gpt_callback(GPTDriver *gptp) {
+ float freq; // TODO: freq_alt
+
+ if (audio_update_state()) {
+ freq = audio_get_processed_frequency(0); // freq_alt would be index=1
+ channel_1_set_frequency(freq);
+ }
+}
diff --git a/quantum/audio/driver_chibios_pwm_software.c b/quantum/audio/driver_chibios_pwm_software.c
new file mode 100644
index 0000000000..15c3e98b6a
--- /dev/null
+++ b/quantum/audio/driver_chibios_pwm_software.c
@@ -0,0 +1,164 @@
+/* Copyright 2020 Jack Humbert
+ * Copyright 2020 JohSchneider
+ *
+ * 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/>.
+ */
+
+/*
+Audio Driver: PWM
+
+the duty-cycle is always kept at 50%, and the pwm-period is adjusted to match the frequency of a note to be played back.
+
+this driver uses the chibios-PWM system to produce a square-wave on any given output pin in software
+- a pwm callback is used to set/clear the configured pin.
+
+ */
+#include "audio.h"
+#include "ch.h"
+#include "hal.h"
+
+#if !defined(AUDIO_PIN)
+# error "Audio feature enabled, but no pin selected - see docs/feature_audio under the ARM PWM settings"
+#endif
+extern bool playing_note;
+extern bool playing_melody;
+extern uint8_t note_timbre;
+
+static void pwm_audio_period_callback(PWMDriver *pwmp);
+static void pwm_audio_channel_interrupt_callback(PWMDriver *pwmp);
+
+static PWMConfig pwmCFG = {
+ .frequency = 100000, /* PWM clock frequency */
+ // CHIBIOS-BUG? can't set the initial period to <2, or the pwm (hard or software) takes ~130ms with .frequency=500000 for a pwmChangePeriod to take effect; with no output=silence in the meantime
+ .period = 2, /* initial PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */
+ .callback = pwm_audio_period_callback,
+ .channels =
+ {
+ // software-PWM just needs another callback on any channel
+ {PWM_OUTPUT_ACTIVE_HIGH, pwm_audio_channel_interrupt_callback}, /* channel 0 -> TIMx_CH1 */
+ {PWM_OUTPUT_DISABLED, NULL}, /* channel 1 -> TIMx_CH2 */
+ {PWM_OUTPUT_DISABLED, NULL}, /* channel 2 -> TIMx_CH3 */
+ {PWM_OUTPUT_DISABLED, NULL} /* channel 3 -> TIMx_CH4 */
+ },
+};
+
+static float channel_1_frequency = 0.0f;
+void channel_1_set_frequency(float freq) {
+ channel_1_frequency = freq;
+
+ if (freq <= 0.0) // a pause/rest has freq=0
+ return;
+
+ pwmcnt_t period = (pwmCFG.frequency / freq);
+ pwmChangePeriod(&AUDIO_PWM_DRIVER, period);
+
+ pwmEnableChannel(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1,
+ // adjust the duty-cycle so that the output is for 'note_timbre' duration HIGH
+ PWM_PERCENTAGE_TO_WIDTH(&AUDIO_PWM_DRIVER, (100 - note_timbre) * 100));
+}
+
+float channel_1_get_frequency(void) { return channel_1_frequency; }
+
+void channel_1_start(void) {
+ pwmStop(&AUDIO_PWM_DRIVER);
+ pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
+
+ pwmEnablePeriodicNotification(&AUDIO_PWM_DRIVER);
+ pwmEnableChannelNotification(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1);
+}
+
+void channel_1_stop(void) {
+ pwmStop(&AUDIO_PWM_DRIVER);
+
+ palClearLine(AUDIO_PIN); // leave the line low, after last note was played
+
+#if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE)
+ palClearLine(AUDIO_PIN_ALT); // leave the line low, after last note was played
+#endif
+}
+
+// generate a PWM signal on any pin, not necessarily the one connected to the timer
+static void pwm_audio_period_callback(PWMDriver *pwmp) {
+ (void)pwmp;
+ palClearLine(AUDIO_PIN);
+
+#if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE)
+ palSetLine(AUDIO_PIN_ALT);
+#endif
+}
+static void pwm_audio_channel_interrupt_callback(PWMDriver *pwmp) {
+ (void)pwmp;
+ if (channel_1_frequency > 0) {
+ palSetLine(AUDIO_PIN); // generate a PWM signal on any pin, not necessarily the one connected to the timer
+#if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE)
+ palClearLine(AUDIO_PIN_ALT);
+#endif
+ }
+}
+
+static void gpt_callback(GPTDriver *gptp);
+GPTConfig gptCFG = {
+ /* a whole note is one beat, which is - per definition in musical_notes.h - set to 64
+ the longest note is BREAVE_DOT=128+64=192, the shortest SIXTEENTH=4
+ the tempo (which might vary!) is in bpm (beats per minute)
+ therefore: if the timer ticks away at .frequency = (60*64)Hz,
+ and the .interval counts from 64 downwards - audio_update_state is
+ called just often enough to not miss anything
+ */
+ .frequency = 60 * 64,
+ .callback = gpt_callback,
+};
+
+void audio_driver_initialize(void) {
+ pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
+
+ palSetLineMode(AUDIO_PIN, PAL_MODE_OUTPUT_PUSHPULL);
+ palClearLine(AUDIO_PIN);
+
+#if defined(AUDIO_PIN_ALT) && defined(AUDIO_PIN_ALT_AS_NEGATIVE)
+ palSetLineMode(AUDIO_PIN_ALT, PAL_MODE_OUTPUT_PUSHPULL);
+ palClearLine(AUDIO_PIN_ALT);
+#endif
+
+ pwmEnablePeriodicNotification(&AUDIO_PWM_DRIVER); // enable pwm callbacks
+ pwmEnableChannelNotification(&AUDIO_PWM_DRIVER, AUDIO_PWM_CHANNEL - 1);
+
+ gptStart(&AUDIO_STATE_TIMER, &gptCFG);
+}
+
+void audio_driver_start(void) {
+ channel_1_stop();
+ channel_1_start();
+
+ if (playing_note || playing_melody) {
+ gptStartContinuous(&AUDIO_STATE_TIMER, 64);
+ }
+}
+
+void audio_driver_stop(void) {
+ channel_1_stop();
+ gptStopTimer(&AUDIO_STATE_TIMER);
+}
+
+/* a regular timer task, that checks the note to be currently played
+ * and updates the pwm to output that frequency
+ */
+static void gpt_callback(GPTDriver *gptp) {
+ float freq; // TODO: freq_alt
+
+ if (audio_update_state()) {
+ freq = audio_get_processed_frequency(0); // freq_alt would be index=1
+ channel_1_set_frequency(freq);
+ }
+}
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h
index 66aafd27c7..ddd7d374f5 100644
--- a/quantum/audio/musical_notes.h
+++ b/quantum/audio/musical_notes.h
@@ -1,4 +1,5 @@
/* Copyright 2016 Jack Humbert
+ * Copyright 2020 JohSchneider
*
* 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
@@ -13,12 +14,11 @@
* 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
-// Tempo Placeholder
#ifndef TEMPO_DEFAULT
-# define TEMPO_DEFAULT 100
+# define TEMPO_DEFAULT 120
+// in beats-per-minute
#endif
#define SONG(notes...) \
@@ -27,12 +27,14 @@
// 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 THIRTYSECOND_NOTE(note) MUSICAL_NOTE(note, 2)
#define BREVE_DOT_NOTE(note) MUSICAL_NOTE(note, 128 + 64)
#define WHOLE_DOT_NOTE(note) MUSICAL_NOTE(note, 64 + 32)
@@ -40,6 +42,9 @@
#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 THIRTYSECOND_DOT_NOTE(note) MUSICAL_NOTE(note, 2 + 1)
+// duration of 64 units == one beat == one whole note
+// with a tempo of 60bpm this comes to a length of one second
// Note Type Shortcuts
#define M__NOTE(note, duration) MUSICAL_NOTE(note, duration)
@@ -49,57 +54,52 @@
#define Q__NOTE(n) QUARTER_NOTE(n)
#define E__NOTE(n) EIGHTH_NOTE(n)
#define S__NOTE(n) SIXTEENTH_NOTE(n)
+#define T__NOTE(n) THIRTYSECOND_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 TD_NOTE(n) THIRTYSECOND_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_12 12
+#define TIMBRE_25 25
+#define TIMBRE_50 50
+#define TIMBRE_75 75
#ifndef TIMBRE_DEFAULT
# define TIMBRE_DEFAULT TIMBRE_50
#endif
// Notes - # = Octave
-#ifdef __arm__
-# define NOTE_REST 1.00f
-#else
-# define NOTE_REST 0.00f
-#endif
-
-/* These notes are currently bugged
-#define NOTE_C0 16.35f
-#define NOTE_CS0 17.32f
-#define NOTE_D0 18.35f
-#define NOTE_DS0 19.45f
-#define NOTE_E0 20.60f
-#define NOTE_F0 21.83f
-#define NOTE_FS0 23.12f
-#define NOTE_G0 24.50f
-#define NOTE_GS0 25.96f
-#define NOTE_A0 27.50f
-#define NOTE_AS0 29.14f
-#define NOTE_B0 30.87f
-#define NOTE_C1 32.70f
-#define NOTE_CS1 34.65f
-#define NOTE_D1 36.71f
-#define NOTE_DS1 38.89f
-#define NOTE_E1 41.20f
-#define NOTE_F1 43.65f
-#define NOTE_FS1 46.25f
-#define NOTE_G1 49.00f
-#define NOTE_GS1 51.91f
-#define NOTE_A1 55.00f
-#define NOTE_AS1 58.27f
-*/
+#define NOTE_REST 0.00f
+#define NOTE_C0 16.35f
+#define NOTE_CS0 17.32f
+#define NOTE_D0 18.35f
+#define NOTE_DS0 19.45f
+#define NOTE_E0 20.60f
+#define NOTE_F0 21.83f
+#define NOTE_FS0 23.12f
+#define NOTE_G0 24.50f
+#define NOTE_GS0 25.96f
+#define NOTE_A0 27.50f
+#define NOTE_AS0 29.14f
+#define NOTE_B0 30.87f
+#define NOTE_C1 32.70f
+#define NOTE_CS1 34.65f
+#define NOTE_D1 36.71f
+#define NOTE_DS1 38.89f
+#define NOTE_E1 41.20f
+#define NOTE_F1 43.65f
+#define NOTE_FS1 46.25f
+#define NOTE_G1 49.00f
+#define NOTE_GS1 51.91f
+#define NOTE_A1 55.00f
+#define NOTE_AS1 58.27f
#define NOTE_B1 61.74f
#define NOTE_C2 65.41f
#define NOTE_CS2 69.30f
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index d48c11b7d1..b54b397e1c 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -140,13 +140,11 @@
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),
-
/* Title: State Anthem of the Soviet Union
* Author/Composer: Alexander Alexandrov
* License: Public Domain
*/
-#define USSR_ANTHEM \
- B__NOTE(_G6), B__NOTE(_C7), W__NOTE(_G6), H__NOTE(_A6), B__NOTE(_B6), W__NOTE(_E6), W__NOTE(_E6), B__NOTE(_A6), W__NOTE(_G6), H__NOTE(_F6), B__NOTE(_G6), W__NOTE(_C6), W__NOTE(_C6), B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_E6), B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_G6), B__NOTE(_F6), W__NOTE(_G6), W__NOTE(_A6), B__NOTE(_B6),
+#define USSR_ANTHEM B__NOTE(_G6), B__NOTE(_C7), W__NOTE(_G6), H__NOTE(_A6), B__NOTE(_B6), W__NOTE(_E6), W__NOTE(_E6), B__NOTE(_A6), W__NOTE(_G6), H__NOTE(_F6), B__NOTE(_G6), W__NOTE(_C6), W__NOTE(_C6), B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_E6), B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_G6), B__NOTE(_F6), W__NOTE(_G6), W__NOTE(_A6), B__NOTE(_B6),
/* 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 1592618be4..d43fb8d169 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -1,4 +1,5 @@
/* Copyright 2016 Jack Humbert
+ * Copyright 2020 JohSchneider
*
* 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
@@ -17,36 +18,73 @@
#include "audio.h"
#include <stdlib.h>
-// these are imported from audio.c
-extern uint16_t envelope_index;
-extern float note_timbre;
-extern float polyphony_rate;
-extern bool glissando;
+uint8_t note_timbre = TIMBRE_DEFAULT;
+bool glissando = false;
+bool vibrato = false;
+float vibrato_strength = 0.5;
+float vibrato_rate = 0.125;
+uint16_t voices_timer = 0;
+
+#ifdef AUDIO_VOICE_DEFAULT
+voice_type voice = AUDIO_VOICE_DEFAULT;
+#else
voice_type voice = default_voice;
+#endif
void set_voice(voice_type v) { voice = v; }
void voice_iterate() { voice = (voice + 1) % number_of_voices; }
-
void voice_deiterate() { voice = (voice - 1 + number_of_voices) % number_of_voices; }
+#ifdef AUDIO_VOICES
+float mod(float a, int b) {
+ float r = fmod(a, b);
+ return r < 0 ? r + b : r;
+}
+
+// Effect: 'vibrate' a given target frequency slightly above/below its initial value
+float voice_add_vibrato(float average_freq) {
+ float vibrato_counter = mod(timer_read() / (100 * vibrato_rate), VIBRATO_LUT_LENGTH);
+
+ return average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength);
+}
+
+// Effect: 'slides' the 'frequency' from the starting-point, to the target frequency
+float voice_add_glissando(float from_freq, float to_freq) {
+ if (to_freq != 0 && from_freq < to_freq && from_freq < to_freq * pow(2, -440 / to_freq / 12 / 2)) {
+ return from_freq * pow(2, 440 / from_freq / 12 / 2);
+ } else if (to_freq != 0 && from_freq > to_freq && from_freq > to_freq * pow(2, 440 / to_freq / 12 / 2)) {
+ return from_freq * pow(2, -440 / from_freq / 12 / 2);
+ } else {
+ return to_freq;
+ }
+}
+#endif
+
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));
+#ifdef AUDIO_VOICES
+ uint16_t envelope_index = timer_elapsed(voices_timer); // TODO: multiply in some factor?
+ uint16_t compensated_index = envelope_index / 100; // TODO: correct factor would be?
+#endif
switch (voice) {
case default_voice:
- glissando = false;
- note_timbre = TIMBRE_50;
- polyphony_rate = 0;
+ glissando = false;
+ // note_timbre = TIMBRE_50; //Note: leave the user the possibility to adjust the timbre with 'audio_set_timbre'
break;
#ifdef AUDIO_VOICES
+ case vibrating:
+ glissando = false;
+ vibrato = true;
+ break;
+
case something:
- glissando = false;
- polyphony_rate = 0;
+ glissando = false;
switch (compensated_index) {
case 0 ... 9:
note_timbre = TIMBRE_12;
@@ -57,24 +95,23 @@ float voice_envelope(float frequency) {
break;
case 20 ... 200:
- note_timbre = .125 + .125;
+ note_timbre = 12 + 12;
break;
default:
- note_timbre = .125;
+ note_timbre = 12;
break;
}
break;
case drums:
- glissando = false;
- polyphony_rate = 0;
+ glissando = false;
// switch (compensated_index) {
// case 0 ... 10:
- // note_timbre = 0.5;
+ // note_timbre = 50;
// break;
// case 11 ... 20:
- // note_timbre = 0.5 * (21 - compensated_index) / 10;
+ // note_timbre = 50 * (21 - compensated_index) / 10;
// break;
// default:
// note_timbre = 0;
@@ -88,10 +125,10 @@ float voice_envelope(float frequency) {
frequency = (rand() % (int)(40)) + 60;
switch (envelope_index) {
case 0 ... 10:
- note_timbre = 0.5;
+ note_timbre = 50;
break;
case 11 ... 20:
- note_timbre = 0.5 * (21 - envelope_index) / 10;
+ note_timbre = 50 * (21 - envelope_index) / 10;
break;
default:
note_timbre = 0;
@@ -103,10 +140,10 @@ float voice_envelope(float frequency) {
frequency = (rand() % (int)(1000)) + 1000;
switch (envelope_index) {
case 0 ... 5:
- note_timbre = 0.5;
+ note_timbre = 50;
break;
case 6 ... 20:
- note_timbre = 0.5 * (21 - envelope_index) / 15;
+ note_timbre = 50 * (21 - envelope_index) / 15;
break;
default:
note_timbre = 0;
@@ -118,10 +155,10 @@ float voice_envelope(float frequency) {
frequency = (rand() % (int)(2000)) + 3000;
switch (envelope_index) {
case 0 ... 15:
- note_timbre = 0.5;
+ note_timbre = 50;
break;
case 16 ... 20:
- note_timbre = 0.5 * (21 - envelope_index) / 5;
+ note_timbre = 50 * (21 - envelope_index) / 5;
break;
default:
note_timbre = 0;
@@ -133,10 +170,10 @@ float voice_envelope(float frequency) {
frequency = (rand() % (int)(2000)) + 3000;
switch (envelope_index) {
case 0 ... 35:
- note_timbre = 0.5;
+ note_timbre = 50;
break;
case 36 ... 50:
- note_timbre = 0.5 * (51 - envelope_index) / 15;
+ note_timbre = 50 * (51 - envelope_index) / 15;
break;
default:
note_timbre = 0;
@@ -145,8 +182,7 @@ float voice_envelope(float frequency) {
}
break;
case butts_fader:
- glissando = true;
- polyphony_rate = 0;
+ glissando = true;
switch (compensated_index) {
case 0 ... 9:
frequency = frequency / 4;
@@ -159,7 +195,7 @@ float voice_envelope(float frequency) {
break;
case 20 ... 200:
- note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2) * .125;
+ note_timbre = 12 - (uint8_t)(pow(((float)compensated_index - 20) / (200 - 20), 2) * 12.5);
break;
default:
@@ -169,7 +205,6 @@ float voice_envelope(float frequency) {
break;
// case octave_crunch:
- // polyphony_rate = 0;
// switch (compensated_index) {
// case 0 ... 9:
// case 20 ... 24:
@@ -187,14 +222,13 @@ float voice_envelope(float frequency) {
// default:
// note_timbre = TIMBRE_12;
- // break;
+ // break;
// }
// break;
case duty_osc:
// This slows the loop down a substantial amount, so higher notes may freeze
- glissando = true;
- polyphony_rate = 0;
+ glissando = true;
switch (compensated_index) {
default:
# define OCS_SPEED 10
@@ -202,38 +236,36 @@ float voice_envelope(float frequency) {
// 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;
+ note_timbre = (uint8_t)abs((compensated_index * OCS_SPEED % 3000) - 1500) * (OCS_AMP / 1500) + (1 - OCS_AMP) / 2;
break;
}
break;
case duty_octave_down:
- glissando = true;
- polyphony_rate = 0;
- note_timbre = (envelope_index % 2) * .125 + .375 * 2;
- if ((envelope_index % 4) == 0) note_timbre = 0.5;
+ glissando = true;
+ note_timbre = (uint8_t)(100 * (envelope_index % 2) * .125 + .375 * 2);
+ if ((envelope_index % 4) == 0) note_timbre = 50;
if ((envelope_index % 8) == 0) note_timbre = 0;
break;
case delayed_vibrato:
- glissando = true;
- polyphony_rate = 0;
- note_timbre = TIMBRE_50;
+ glissando = true;
+ 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)];
break;
}
break;
// case delayed_vibrato_octave:
- // polyphony_rate = 0;
// if ((envelope_index % 2) == 1) {
- // note_timbre = 0.55;
+ // note_timbre = 55;
// } else {
- // note_timbre = 0.45;
+ // note_timbre = 45;
// }
// #define VOICE_VIBRATO_DELAY 150
// #define VOICE_VIBRATO_SPEED 50
@@ -246,35 +278,64 @@ float voice_envelope(float frequency) {
// }
// break;
// case duty_fifth_down:
- // note_timbre = 0.5;
+ // note_timbre = TIMBRE_50;
// if ((envelope_index % 3) == 0)
- // note_timbre = 0.75;
+ // note_timbre = TIMBRE_75;
// break;
// case duty_fourth_down:
- // note_timbre = 0.0;
+ // note_timbre = 0;
// if ((envelope_index % 12) == 0)
- // note_timbre = 0.75;
+ // note_timbre = TIMBRE_75;
// if (((envelope_index % 12) % 4) != 1)
- // note_timbre = 0.75;
+ // note_timbre = TIMBRE_75;
// break;
// case duty_third_down:
- // note_timbre = 0.5;
+ // note_timbre = TIMBRE_50;
// if ((envelope_index % 5) == 0)
- // note_timbre = 0.75;
+ // note_timbre = TIMBRE_75;
// break;
// case duty_fifth_third_down:
- // note_timbre = 0.5;
+ // note_timbre = TIMBRE_50;
// if ((envelope_index % 5) == 0)
- // note_timbre = 0.75;
+ // note_timbre = TIMBRE_75;
// if ((envelope_index % 3) == 0)
- // note_timbre = 0.25;
+ // note_timbre = TIMBRE_25;
// break;
-#endif
+#endif // AUDIO_VOICES
default:
break;
}
+#ifdef AUDIO_VOICES
+ if (vibrato && (vibrato_strength > 0)) {
+ frequency = voice_add_vibrato(frequency);
+ }
+
+ if (glissando) {
+ // TODO: where to keep track of the start-frequency?
+ // frequency = voice_add_glissando(??, frequency);
+ }
+#endif // AUDIO_VOICES
+
return frequency;
}
+
+// Vibrato functions
+
+void voice_set_vibrato_rate(float rate) { vibrato_rate = rate; }
+void voice_increase_vibrato_rate(float change) { vibrato_rate *= change; }
+void voice_decrease_vibrato_rate(float change) { vibrato_rate /= change; }
+void voice_set_vibrato_strength(float strength) { vibrato_strength = strength; }
+void voice_increase_vibrato_strength(float change) { vibrato_strength *= change; }
+void voice_decrease_vibrato_strength(float change) { vibrato_strength /= change; }
+
+// Timbre functions
+
+void voice_set_timbre(uint8_t timbre) {
+ if ((timbre > 0) && (timbre < 100)) {
+ note_timbre = timbre;
+ }
+}
+uint8_t voice_get_timbre(void) { return note_timbre; }
diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h
index abafa2b404..7bd26b461f 100644
--- a/quantum/audio/voices.h
+++ b/quantum/audio/voices.h
@@ -1,4 +1,5 @@
/* Copyright 2016 Jack Humbert
+ * Copyright 2020 JohSchneider
*
* 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
@@ -29,6 +30,7 @@ float voice_envelope(float frequency);
typedef enum {
default_voice,
#ifdef AUDIO_VOICES
+ vibrating,
something,
drums,
butts_fader,
@@ -48,3 +50,21 @@ typedef enum {
void set_voice(voice_type v);
void voice_iterate(void);
void voice_deiterate(void);
+
+// Vibrato functions
+void voice_set_vibrato_rate(float rate);
+void voice_increase_vibrato_rate(float change);
+void voice_decrease_vibrato_rate(float change);
+void voice_set_vibrato_strength(float strength);
+void voice_increase_vibrato_strength(float change);
+void voice_decrease_vibrato_strength(float change);
+
+// Timbre functions
+/**
+ * @brief set the global timbre for tones to be played
+ * @note: only applies to pwm implementations - where it adjusts the duty-cycle
+ * @note: using any instrument from voices.[ch] other than 'default' may override the set value
+ * @param[in]: timbre: valid range is (0,100)
+ */
+void voice_set_timbre(uint8_t timbre);
+uint8_t voice_get_timbre(void);
diff --git a/quantum/audio/wave.h b/quantum/audio/wave.h
deleted file mode 100644
index 48210a944e..0000000000
--- a/quantum/audio/wave.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* 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/>.
- */
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-
-#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};
diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c
index 4d66da80ba..e47192de34 100644
--- a/quantum/backlight/backlight_avr.c
+++ b/quantum/backlight/backlight_avr.c
@@ -68,7 +68,7 @@
# define COMxx1 COM3A1
# define OCRxx OCR3A
# endif
-#elif (defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)) && (BACKLIGHT_PIN == B7 || BACKLIGHT_PIN == C5 || BACKLIGHT_PIN == C6)
+#elif (defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)) && (BACKLIGHT_PIN == B7 || BACKLIGHT_PIN == C5 || BACKLIGHT_PIN == C6)
# define HARDWARE_PWM
# define ICRx ICR1
# define TCCRxA TCCR1A
@@ -126,7 +126,7 @@
# define COMxx1 COM1B1
# define OCRxx OCR1B
# endif
-#elif !defined(B5_AUDIO) && !defined(B6_AUDIO) && !defined(B7_AUDIO)
+#elif (AUDIO_PIN != B5) && (AUDIO_PIN != B6) && (AUDIO_PIN != B7) && (AUDIO_PIN_ALT != B5) && (AUDIO_PIN_ALT != B6) && (AUDIO_PIN_ALT != B7)
// 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
@@ -145,7 +145,7 @@
# define OCIExA OCIE1A
# define OCRxx OCR1A
-#elif !defined(C6_AUDIO) && !defined(C5_AUDIO) && !defined(C4_AUDIO)
+#elif (AUDIO_PIN != C4) && (AUDIO_PIN != C5) && (AUDIO_PIN != C6)
# 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
diff --git a/tmk_core/common/util.c b/quantum/bitwise.c
index 861cca0054..861cca0054 100644
--- a/tmk_core/common/util.c
+++ b/quantum/bitwise.c
diff --git a/tmk_core/common/util.h b/quantum/bitwise.h
index db57f268c3..276bc7437b 100644
--- a/tmk_core/common/util.h
+++ b/quantum/bitwise.h
@@ -19,13 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
-// convert to L string
-#define LSTR(s) XLSTR(s)
-#define XLSTR(s) L## #s
-// convert to string
-#define STR(s) XSTR(s)
-#define XSTR(s) #s
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/quantum/color.c b/quantum/color.c
index 3cb8a1a2ca..1c5128e4a2 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -96,7 +96,6 @@ RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) {
return rgb;
}
-
RGB hsv_to_rgb(HSV hsv) {
#ifdef USE_CIE1931_CURVE
return hsv_to_rgb_impl(hsv, true);
diff --git a/tmk_core/common/command.c b/quantum/command.c
index fb34ebb462..34c4b36b1c 100644
--- a/tmk_core/common/command.c
+++ b/quantum/command.c
@@ -141,7 +141,6 @@ static void command_common_help(void) {
static void print_version(void) {
// print version & information
print("\n\t- Version -\n");
- print("DESC: " STR(DESCRIPTION) "\n");
print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
"PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
"VER: " STR(DEVICE_VER) "\n");
@@ -551,22 +550,22 @@ static void mousekey_param_print(void) {
# if !defined(NO_PRINT) && !defined(USER_PRINT)
print("\n\t- Values -\n");
print("1: delay(*10ms): ");
- pdec(mk_delay);
+ print_dec(mk_delay);
print("\n");
print("2: interval(ms): ");
- pdec(mk_interval);
+ print_dec(mk_interval);
print("\n");
print("3: max_speed: ");
- pdec(mk_max_speed);
+ print_dec(mk_max_speed);
print("\n");
print("4: time_to_max: ");
- pdec(mk_time_to_max);
+ print_dec(mk_time_to_max);
print("\n");
print("5: wheel_max_speed: ");
- pdec(mk_wheel_max_speed);
+ print_dec(mk_wheel_max_speed);
print("\n");
print("6: wheel_time_to_max: ");
- pdec(mk_wheel_time_to_max);
+ print_dec(mk_wheel_time_to_max);
print("\n");
# endif /* !NO_PRINT */
}
diff --git a/tmk_core/common/command.h b/quantum/command.h
index 4f77be085c..4f77be085c 100644
--- a/tmk_core/common/command.h
+++ b/quantum/command.h
diff --git a/quantum/config_common.h b/quantum/config_common.h
index 53377f2b61..d93477b27e 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -16,402 +16,12 @@
#pragma once
+#ifndef __ASSEMBLER__
+# include "pin_defs.h"
+#endif
+
/* diode directions */
#define COL2ROW 0
#define ROW2COL 1
-#define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */
-
-// useful for direct pin mapping
-#define NO_PIN (pin_t)(~0)
-
-#ifdef __AVR__
-# 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 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__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
-# 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_ATtiny85__)
-# define ADDRESS_BASE 0x10
-# define PINB_ADDRESS 0x6
-# else
-# error "Pins are not defined"
-# endif
-
-/* 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
-
-# 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)
-
-// 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, 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 B18 PAL_LINE(GPIOB, 18)
-# define B19 PAL_LINE(GPIOB, 19)
-# 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)
-# define G0 PAL_LINE(GPIOG, 0)
-# define G1 PAL_LINE(GPIOG, 1)
-# define G2 PAL_LINE(GPIOG, 2)
-# define G3 PAL_LINE(GPIOG, 3)
-# define G4 PAL_LINE(GPIOG, 4)
-# define G5 PAL_LINE(GPIOG, 5)
-# define G6 PAL_LINE(GPIOG, 6)
-# define G7 PAL_LINE(GPIOG, 7)
-# define G8 PAL_LINE(GPIOG, 8)
-# define G9 PAL_LINE(GPIOG, 9)
-# define G10 PAL_LINE(GPIOG, 10)
-# define G11 PAL_LINE(GPIOG, 11)
-# define G12 PAL_LINE(GPIOG, 12)
-# define G13 PAL_LINE(GPIOG, 13)
-# define G14 PAL_LINE(GPIOG, 14)
-# define G15 PAL_LINE(GPIOG, 15)
-# define H0 PAL_LINE(GPIOH, 0)
-# define H1 PAL_LINE(GPIOH, 1)
-# define H2 PAL_LINE(GPIOH, 2)
-# define H3 PAL_LINE(GPIOH, 3)
-# define H4 PAL_LINE(GPIOH, 4)
-# define H5 PAL_LINE(GPIOH, 5)
-# define H6 PAL_LINE(GPIOH, 6)
-# define H7 PAL_LINE(GPIOH, 7)
-# define H8 PAL_LINE(GPIOH, 8)
-# define H9 PAL_LINE(GPIOH, 9)
-# define H10 PAL_LINE(GPIOH, 10)
-# define H11 PAL_LINE(GPIOH, 11)
-# define H12 PAL_LINE(GPIOH, 12)
-# define H13 PAL_LINE(GPIOH, 13)
-# define H14 PAL_LINE(GPIOH, 14)
-# define H15 PAL_LINE(GPIOH, 15)
-# define I0 PAL_LINE(GPIOI, 0)
-# define I1 PAL_LINE(GPIOI, 1)
-# define I2 PAL_LINE(GPIOI, 2)
-# define I3 PAL_LINE(GPIOI, 3)
-# define I4 PAL_LINE(GPIOI, 4)
-# define I5 PAL_LINE(GPIOI, 5)
-# define I6 PAL_LINE(GPIOI, 6)
-# define I7 PAL_LINE(GPIOI, 7)
-# define I8 PAL_LINE(GPIOI, 8)
-# define I9 PAL_LINE(GPIOI, 9)
-# define I10 PAL_LINE(GPIOI, 10)
-# define I11 PAL_LINE(GPIOI, 11)
-# define I12 PAL_LINE(GPIOI, 12)
-# define I13 PAL_LINE(GPIOI, 13)
-# define I14 PAL_LINE(GPIOI, 14)
-# define I15 PAL_LINE(GPIOI, 15)
-# define J0 PAL_LINE(GPIOJ, 0)
-# define J1 PAL_LINE(GPIOJ, 1)
-# define J2 PAL_LINE(GPIOJ, 2)
-# define J3 PAL_LINE(GPIOJ, 3)
-# define J4 PAL_LINE(GPIOJ, 4)
-# define J5 PAL_LINE(GPIOJ, 5)
-# define J6 PAL_LINE(GPIOJ, 6)
-# define J7 PAL_LINE(GPIOJ, 7)
-# define J8 PAL_LINE(GPIOJ, 8)
-# define J9 PAL_LINE(GPIOJ, 9)
-# define J10 PAL_LINE(GPIOJ, 10)
-# define J11 PAL_LINE(GPIOJ, 11)
-# define J12 PAL_LINE(GPIOJ, 12)
-# define J13 PAL_LINE(GPIOJ, 13)
-# define J14 PAL_LINE(GPIOJ, 14)
-# define J15 PAL_LINE(GPIOJ, 15)
-// Keyboards can `#define KEYBOARD_REQUIRES_GPIOK` if they need to access GPIO-K pins. These conflict with a whole
-// bunch of layout definitions, so it's intentionally left out unless absolutely required -- in that case, the
-// keyboard designer should use a different symbol when defining their layout macros.
-# ifdef KEYBOARD_REQUIRES_GPIOK
-# define K0 PAL_LINE(GPIOK, 0)
-# define K1 PAL_LINE(GPIOK, 1)
-# define K2 PAL_LINE(GPIOK, 2)
-# define K3 PAL_LINE(GPIOK, 3)
-# define K4 PAL_LINE(GPIOK, 4)
-# define K5 PAL_LINE(GPIOK, 5)
-# define K6 PAL_LINE(GPIOK, 6)
-# define K7 PAL_LINE(GPIOK, 7)
-# define K8 PAL_LINE(GPIOK, 8)
-# define K9 PAL_LINE(GPIOK, 9)
-# define K10 PAL_LINE(GPIOK, 10)
-# define K11 PAL_LINE(GPIOK, 11)
-# define K12 PAL_LINE(GPIOK, 12)
-# define K13 PAL_LINE(GPIOK, 13)
-# define K14 PAL_LINE(GPIOK, 14)
-# define K15 PAL_LINE(GPIOK, 15)
-# endif
-# 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)
-# 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
#include "song_list.h"
diff --git a/quantum/debounce/sym_defer_pk.c b/quantum/debounce/sym_defer_pk.c
index 6c0e3bb071..60513f98e1 100644
--- a/quantum/debounce/sym_defer_pk.c
+++ b/quantum/debounce/sym_defer_pk.c
@@ -23,6 +23,12 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
#include "quantum.h"
#include <stdlib.h>
+#ifdef PROTOCOL_CHIBIOS
+# if CH_CFG_USE_MEMCORE == FALSE
+# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm.
+# endif
+#endif
+
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c
index 93a40ad441..e66cf92d79 100644
--- a/quantum/debounce/sym_eager_pk.c
+++ b/quantum/debounce/sym_eager_pk.c
@@ -23,6 +23,12 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
#include "quantum.h"
#include <stdlib.h>
+#ifdef PROTOCOL_CHIBIOS
+# if CH_CFG_USE_MEMCORE == FALSE
+# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm.
+# endif
+#endif
+
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c
index d12931fddb..20ccb46f1d 100644
--- a/quantum/debounce/sym_eager_pr.c
+++ b/quantum/debounce/sym_eager_pr.c
@@ -23,6 +23,12 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
#include "quantum.h"
#include <stdlib.h>
+#ifdef PROTOCOL_CHIBIOS
+# if CH_CFG_USE_MEMCORE == FALSE
+# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm.
+# endif
+#endif
+
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c
index b1edd7d9cc..cda69bd0ef 100644
--- a/quantum/dip_switch.c
+++ b/quantum/dip_switch.c
@@ -49,17 +49,13 @@ static uint16_t scan_count;
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_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_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_user(uint32_t state) {}
-__attribute__((weak))
-void dip_switch_update_mask_kb(uint32_t state) { dip_switch_update_mask_user(state); }
+__attribute__((weak)) void dip_switch_update_mask_kb(uint32_t state) { dip_switch_update_mask_user(state); }
void dip_switch_init(void) {
#ifdef DIP_SWITCH_PINS
@@ -73,10 +69,9 @@ void dip_switch_init(void) {
#endif
}
-
void dip_switch_read(bool forced) {
- bool has_dip_state_changed = false;
- uint32_t dip_switch_mask = 0;
+ bool has_dip_state_changed = false;
+ uint32_t dip_switch_mask = 0;
#ifdef DIP_SWITCH_MATRIX_GRID
bool read_raw = false;
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 688379c9af..f76f37f997 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -14,16 +14,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "keymap.h" // to get keymaps[][][]
-#include "eeprom.h"
-#include "progmem.h" // to read default from flash
+
+#include "tmk_core/common/eeprom.h"
#include "quantum.h" // for send_string()
-#include "dynamic_keymap.h"
-#ifdef VIA_ENABLE
-# include "via.h" // for default VIA_EEPROM_ADDR_END
-#else
-# include "eeconfig.h"
-#endif
+#include "eeconfig.h"
#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
# define DYNAMIC_KEYMAP_LAYER_COUNT 4
@@ -35,10 +29,18 @@
// This is the default EEPROM max address to use for dynamic keymaps.
// The default is the ATmega32u4 EEPROM max address.
-// Explicitly override it if the keyboard uses a microcontroller with
+// Explicitly override it if the keyboard uses a microcontroller with
// more EEPROM *and* it makes sense to increase it.
#ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR
-# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023
+# if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__)
+# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
+# elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095
+# elif defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATtiny85__)
+# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 511
+# else
+# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023
+# endif
#endif
// Due to usage of uint16_t check for max 65535
@@ -222,9 +224,9 @@ void dynamic_keymap_macro_send(uint8_t 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};
+ // Send the macro string one or three chars at a time
+ // by making temporary 1 or 3 char strings
+ char data[4] = {0, 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) {
@@ -235,10 +237,12 @@ void dynamic_keymap_macro_send(uint8_t id) {
break;
}
// If the char is magic (tap, down, up),
- // add the next char (key to use) and send a 2 char string.
+ // add the next char (key to use) and send a 3 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) {
+ data[1] = data[0];
+ data[0] = SS_QMK_PREFIX;
+ data[2] = eeprom_read_byte(p++);
+ if (data[2] == 0) {
break;
}
}
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 7ca31afedc..2ed64c1e30 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -94,8 +94,9 @@ void encoder_init(void) {
#endif
}
-static void encoder_update(int8_t index, uint8_t state) {
- uint8_t i = index;
+static bool encoder_update(int8_t index, uint8_t state) {
+ bool changed = false;
+ uint8_t i = index;
#ifdef ENCODER_RESOLUTIONS
int8_t resolution = encoder_resolutions[i];
@@ -109,40 +110,53 @@ static void encoder_update(int8_t index, uint8_t state) {
encoder_pulses[i] += encoder_LUT[state & 0xF];
if (encoder_pulses[i] >= resolution) {
encoder_value[index]++;
+ changed = true;
encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE);
}
if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise
encoder_value[index]--;
+ changed = true;
encoder_update_kb(index, ENCODER_CLOCKWISE);
}
encoder_pulses[i] %= resolution;
+ return changed;
}
-void encoder_read(void) {
+bool encoder_read(void) {
+ bool changed = false;
for (uint8_t 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_update(i, encoder_state[i]);
+ changed |= encoder_update(i, encoder_state[i]);
}
+ return changed;
}
#ifdef SPLIT_KEYBOARD
+void last_encoder_activity_trigger(void);
+
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) {
+ bool changed = false;
for (uint8_t 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]++;
+ changed = true;
encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE);
}
while (delta < 0) {
delta++;
encoder_value[index]--;
+ changed = true;
encoder_update_kb(index, ENCODER_CLOCKWISE);
}
}
+
+ // Update the last encoder input time -- handled external to encoder_read() when we're running a split
+ if (changed) last_encoder_activity_trigger();
}
#endif
diff --git a/quantum/encoder.h b/quantum/encoder.h
index ec09a8cc47..db6f220da4 100644
--- a/quantum/encoder.h
+++ b/quantum/encoder.h
@@ -20,7 +20,7 @@
#include "quantum.h"
void encoder_init(void);
-void encoder_read(void);
+bool encoder_read(void);
void encoder_update_kb(int8_t index, bool clockwise);
void encoder_update_user(int8_t index, bool clockwise);
diff --git a/quantum/fauxclicky.c b/quantum/fauxclicky.c
deleted file mode 100644
index 53499c9c1e..0000000000
--- a/quantum/fauxclicky.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-Copyright 2017 Priyadi Iman Nurcahyo
-
-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 <avr/interrupt.h>
-#include <avr/io.h>
-#include "timer.h"
-#include "fauxclicky.h"
-#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;
-
-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);
-}
-
-void fauxclicky_stop() {
- FAUXCLICKY_DISABLE_OUTPUT;
- note_playing = false;
-}
-
-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_ENABLE_OUTPUT;
-}
-
-void fauxclicky_check() {
- if (!note_playing) return;
-
- if (timer_elapsed(note_start) > note_period) {
- fauxclicky_stop();
- }
-}
diff --git a/quantum/fauxclicky.h b/quantum/fauxclicky.h
deleted file mode 100644
index ed54d0edcf..0000000000
--- a/quantum/fauxclicky.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-Copyright 2017 Priyadi Iman Nurcahyo
-
-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/>.
-*/
-
-#ifdef AUDIO_ENABLE
-# 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);
-
-extern bool fauxclicky_enabled;
-
-//
-// tempo in BPM
-//
-
-#ifndef FAUXCLICKY_TEMPO
-# define FAUXCLICKY_TEMPO TEMPO_DEFAULT
-#endif
-
-// beep on press
-#define FAUXCLICKY_ACTION_PRESS fauxclicky_play(fauxclicky_pressed_note)
-
-// beep on release
-#define FAUXCLICKY_ACTION_RELEASE fauxclicky_play(fauxclicky_released_note)
-
-// general purpose beep
-#define FAUXCLICKY_BEEP fauxclicky_play(fauxclicky_beep_note)
-
-// enable
-#define FAUXCLICKY_ON fauxclicky_enabled = true
-
-// disable
-#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)
-
-//
-// pin configuration
-//
-
-#ifndef FAUXCLICKY_CPU_PRESCALER
-# define FAUXCLICKY_CPU_PRESCALER 8
-#endif
-
-#ifndef FAUXCLICKY_ENABLE_OUTPUT
-# define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1)
-#endif
-
-#ifndef FAUXCLICKY_DISABLE_OUTPUT
-# define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0))
-#endif
-
-#ifndef FAUXCLICKY_TIMER_PERIOD
-# define FAUXCLICKY_TIMER_PERIOD ICR3
-#endif
-
-#ifndef FAUXCLICKY_DUTY_CYCLE
-# define FAUXCLICKY_DUTY_CYCLE OCR3A
-#endif
-
-//
-// definitions
-//
-
-void fauxclicky_init(void);
-void fauxclicky_stop(void);
-void fauxclicky_play(float note[2]);
-void fauxclicky_check(void);
diff --git a/quantum/keymap.h b/quantum/keymap.h
index 00d21e084b..191e813977 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -39,6 +39,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if defined(PROTOCOL_CHIBIOS)
# define RESET QK_RESET
#endif
+// Gross hack, remove me and change RESET keycode to QK_BOOT
+#if defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)
+# undef RESET
+#endif
#include "quantum_keycodes.h"
diff --git a/quantum/keymap_extras/keymap_canadian_multilingual.h b/quantum/keymap_extras/keymap_canadian_multilingual.h
index d86a96086c..bb8e44d546 100644
--- a/quantum/keymap_extras/keymap_canadian_multilingual.h
+++ b/quantum/keymap_extras/keymap_canadian_multilingual.h
@@ -22,15 +22,15 @@
/*
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ / │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ │
+ * │ / │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ^ │ Ç │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ È │ À │ │
+ * │     │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ^ │ Ç │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ È │ À │    │
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ Ù │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ É │ │
+ * │    │ Ù │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ É │          │
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
+ * │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
@@ -88,15 +88,15 @@
/* Shifted symbols
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ \ │ ! │ @ │ # │ $ │ % │ ? │ & │ * │ ( │ ) │ _ │ + │ │
+ * │ \ │ ! │ @ │ # │ $ │ % │ ? │ & │ * │ ( │ ) │ _ │ + │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ │ │ │ │ │ │ │ │ ¨ │ │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ │ │ │ │ │ │ │ │ │ : │ │ │ │
+ * │     │   │   │   │   │   │   │   │   │   │   │ ¨ │   │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │   │   │   │   │   │   │   │   │   │ : │   │   │    │
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ │ │ │ │ │ │ │ │ ' │ " │ │ │
+ * │    │   │   │   │   │   │   │   │   │ ' │ " │   │          │
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
+ * │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
@@ -123,15 +123,15 @@
/* AltGr symbols
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ | │ │ │ │ ¤ │ │ │ { │ } │ [ │ ] │ │ ¬ │ │
+ * │ | │   │   │   │ ¤ │   │   │ { │ } │ [ │ ] │   │ ¬ │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ € │ │ │ │ │ │ │ │ ` │ ~ │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ │ │ │ │ │ │ │ │ │ ° │ │ │ │
+ * │     │   │   │ € │   │   │   │   │   │   │   │ ` │ ~ │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │   │   │   │   │   │   │   │   │   │ ° │   │   │    │
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ │ « │ » │ │ │ │ │ │ < │ > │ │ │
+ * │    │   │ « │ » │   │   │   │   │   │ < │ > │   │          │
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
+ * │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
@@ -156,15 +156,15 @@
/* Right Ctrl symbols
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ │ ¹ │ ² │ ³ │ ¼ │ ½ │ ¾ │ │ │ │ │ │ ¸ │ │
+ * │   │ ¹ │ ² │ ³ │ ¼ │ ½ │ ¾ │   │   │   │   │   │ ¸ │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ Ω │ Ł │ Œ │ ¶ │ Ŧ │ ← │ ↓ │ → │ Ø │ Þ │ │ ~ │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ Æ │ ß │ Ð │ │ Ŋ │ Ħ │ IJ │ ĸ │ Ŀ │ ´ │ │ │ │
+ * │     │ Ω │ Ł │ Œ │ ¶ │ Ŧ │ ← │ ↓ │ → │ Ø │ Þ │   │ ~ │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │ Æ │ ß │ Ð │   │ Ŋ │ Ħ │ IJ │ ĸ │ Ŀ │ ´ │   │   │    │
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ │ │ │ ¢ │ “ │ ” │ ʼn │ μ │ ― │ ˙ │ │ │
+ * │    │   │   │   │ ¢ │ “ │ ” │ ʼn │ μ │ ― │ ˙ │   │          │
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
+ * │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
@@ -208,15 +208,15 @@
/* Shift+Right Ctrl symbols
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
- * │ - │ ¡ │ │ £ │ │ ⅜ │ ⅝ │ ⅞ │ ™ │ ± │ │ ¿ │ ˛ │ │
+ * │ - │ ¡ │   │ £ │   │ ⅜ │ ⅝ │ ⅞ │ ™ │ ± │   │ ¿ │ ˛ │       │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
- * │ │ │ │ │ ® │ │ ¥ │ ↑ │ ı │ │ │ ° │ ¯ │ │
- * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
- * │ │ │ § │ │ ª │ │ │ │ │ │ ˝ │ ˇ │ ˘ │ │
+ * │     │   │   │   │ ® │   │ ¥ │ ↑ │ ı │   │   │ ° │ ¯ │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │   │ § │   │ ª │   │   │   │   │   │ ˝ │ ˇ │ ˘ │    │
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
- * │ │ ¦ │ │ │ © │ ‘ │ ’ │ ♪ │ º │ × │ ÷ │ │ │
+ * │    │ ¦ │   │   │ © │ ‘ │ ’ │ ♪ │ º │ × │ ÷ │   │          │
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
- * │ │ │ │ │ │ │ │ │
+ * │    │    │    │                        │    │    │    │    │
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
diff --git a/quantum/keymap_extras/keymap_croatian.h b/quantum/keymap_extras/keymap_croatian.h
new file mode 100644
index 0000000000..4af5dc5875
--- /dev/null
+++ b/quantum/keymap_extras/keymap_croatian.h
@@ -0,0 +1,163 @@
+/* Copyright 2020
+ *
+ * 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 "keymap.h"
+
+// clang-format off
+
+/*
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ¸ │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ ' │ + │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ Q │ W │ E │ R │ T │ Z │ U │ I │ O │ P │ Š │ Đ │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │ A │ S │ D │ F │ G │ H │ J │ K │ L │ Č │ Ć │ Ž │    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │ < │ Y │ X │ C │ V │ B │ N │ M │ , │ . │ - │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define HR_CEDL KC_GRV // ¸ (dead)
+#define HR_1 KC_1 // 1
+#define HR_2 KC_2 // 2
+#define HR_3 KC_3 // 3
+#define HR_4 KC_4 // 4
+#define HR_5 KC_5 // 5
+#define HR_6 KC_6 // 6
+#define HR_7 KC_7 // 7
+#define HR_8 KC_8 // 8
+#define HR_9 KC_9 // 9
+#define HR_0 KC_0 // 0
+#define HR_QUOT KC_MINS // '
+#define HR_PLUS KC_EQL // +
+// Row 2
+#define HR_Q KC_Q // Q
+#define HR_W KC_W // W
+#define HR_E KC_E // E
+#define HR_R KC_R // R
+#define HR_T KC_T // T
+#define HR_Z KC_Y // Z
+#define HR_U KC_U // U
+#define HR_I KC_I // I
+#define HR_O KC_O // O
+#define HR_P KC_P // P
+#define HR_SCAR KC_LBRC // Š
+#define HR_DSTR KC_RBRC // Đ
+// Row 3
+#define HR_A KC_A // A
+#define HR_S KC_S // S
+#define HR_D KC_D // D
+#define HR_F KC_F // F
+#define HR_G KC_G // G
+#define HR_H KC_H // H
+#define HR_J KC_J // J
+#define HR_K KC_K // K
+#define HR_L KC_L // L
+#define HR_CCAR KC_SCLN // Č
+#define HR_CACU KC_QUOT // Ć
+#define HR_ZCAR KC_NUHS // Ž
+// Row 4
+#define HR_LABK KC_NUBS // <
+#define HR_Y KC_Z // Y
+#define HR_X KC_X // X
+#define HR_C KC_C // C
+#define HR_V KC_V // V
+#define HR_B KC_B // B
+#define HR_N KC_N // N
+#define HR_M KC_M // M
+#define HR_COMM KC_COMM // ,
+#define HR_DOT KC_DOT // .
+#define HR_MINS KC_SLSH // -
+
+/* Shifted symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ¨ │ ! │ " │ # │ $ │ % │ & │ / │ ( │ ) │ = │ ? │ * │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │   │   │   │   │   │   │   │   │   │   │   │   │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │   │   │   │   │   │   │   │   │   │   │   │   │    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │ > │   │   │   │   │   │   │   │ ; │ : │ _ │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define HR_DIAE S(HR_CEDL) // ¨ (dead)
+#define HR_EXLM S(HR_1) // !
+#define HR_DQUO S(HR_2) // "
+#define HR_HASH S(HR_3) // #
+#define HR_DLR S(HR_4) // $
+#define HR_PERC S(HR_5) // %
+#define HR_AMPR S(HR_6) // &
+#define HR_SLSH S(HR_7) // /
+#define HR_LPRN S(HR_8) // (
+#define HR_RPRN S(HR_9) // )
+#define HR_EQL S(HR_0) // =
+#define HR_QUES S(HR_QUOT) // ?
+#define HR_ASTR S(HR_PLUS) // *
+// Row 4
+#define HR_RABK S(HR_LABK) // >
+#define HR_SCLN S(HR_COMM) // ;
+#define HR_COLN S(HR_DOT) // :
+#define HR_UNDS S(HR_MINS) // _
+
+/* AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │   │ ~ │ ˇ │ ^ │ ˘ │ ° │ ˛ │ ` │ ˙ │ ´ │ ˝ │   │   │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ \ │ | │ € │   │   │   │   │   │   │   │ ÷ │ × │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │   │   │   │ [ │ ] │   │   │ ł │ Ł │   │ ß │ ¤ │    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │   │   │   │   │ @ │ { │ } │ § │   │   │   │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define HR_TILD ALGR(HR_1) // ~
+#define HR_CARN ALGR(HR_2) // ˇ (dead)
+#define HR_CIRC ALGR(HR_3) // ^ (dead)
+#define HR_BREV ALGR(HR_4) // ˘ (dead)
+#define HR_RNGA ALGR(HR_5) // ° (dead)
+#define HR_OGON ALGR(HR_6) // ˛ (dead)
+#define HR_GRV ALGR(HR_7) // `
+#define HR_DOTA ALGR(HR_8) // ˙ (dead)
+#define HR_ACUT ALGR(HR_9) // ´ (dead)
+#define HR_DACU ALGR(HR_0) // ˝ (dead)
+// Row 2
+#define HR_BSLS ALGR(HR_Q) // (backslash)
+#define HR_PIPE ALGR(HR_W) // |
+#define HR_EURO ALGR(HR_E) // €
+#define HR_DIV ALGR(HR_SCAR) // ÷
+#define HR_MUL ALGR(HR_DSTR) // ×
+// Row 3
+#define HR_LBRC ALGR(HR_F) // [
+#define HR_RBRC ALGR(HR_G) // ]
+#define HR_LLST ALGR(HR_K) // ł
+#define HR_CLST ALGR(HR_L) // Ł
+#define HR_SS ALGR(HR_CACU) // ß
+#define HR_CURR ALGR(HR_ZCAR) // ¤
+// Row 4
+#define HR_AT ALGR(HR_V) // @
+#define HR_LCBR ALGR(HR_B) // {
+#define HR_RCBR ALGR(HR_N) // }
+#define HR_SECT ALGR(HR_M) // §
diff --git a/quantum/keymap_extras/keymap_french_afnor.h b/quantum/keymap_extras/keymap_french_afnor.h
new file mode 100644
index 0000000000..be67fdc952
--- /dev/null
+++ b/quantum/keymap_extras/keymap_french_afnor.h
@@ -0,0 +1,253 @@
+/* Copyright 2020 Guillaume Gérard
+ *
+ * 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/>.
+ */
+
+/* French AZERTY - AFNOR NF Z71-300
+ *
+ * A standard for the French keyboard
+ *
+ * The project was launched at the end of 2015 on the proposal of the General
+ * Delegation for the French language and the languages ​​of France (Ministry
+ * of Culture), starting from the observation that the current "azerty"
+ * keyboards constrain the writing of French, languages regional and European
+ * languages ​​with Latin alphabet.
+ *
+ * For the first time, a standard (NF Z71-300) defines the placement of
+ * characters on the French keyboard. It offers two layouts, one of which
+ * closely follows the QWERTY keyboard used by most people who write in French.
+ *
+ * However, it is in many ways superior to the old keyboard:
+ *
+ * - it contains all the characters required to enter text in French (for example É, œ and ")
+ * - it is designed to be more ergonomic and allow faster typing
+ * - it includes almost 60 additional characters for entering foreign languages, technical content, etc
+ * - however, the characters remain easy to locate thanks to intuitive groupings
+ *
+ * Source: https://norme-azerty.fr
+ */
+
+#pragma once
+
+#include "keymap.h"
+
+// clang-format off
+
+/*
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ @ │ à │ é │ è │ ê │ ( │ ) │ ‘ │ ’ │ « │ » │ ' │ ^ │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ A │ Z │ E │ R │ T │ Y │ U │ I │ O │ P │ - │ + │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │ Q │ S │ D │ F │ G │ H │ J │ K │ L │ M │ / │ * │    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │ < │ W │ X │ C │ V │ B │ N │ . │ , │ : │ ; │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define FR_AT KC_GRV // @
+#define FR_AGRV KC_1 // à
+#define FR_EACU KC_2 // é
+#define FR_EGRV KC_3 // è
+#define FR_ECIR KC_4 // ê
+#define FR_LPRN KC_5 // (
+#define FR_RPRN KC_6 // )
+#define FR_LSQU KC_7 // ‘
+#define FR_RSQU KC_8 // ’
+#define FR_LDAQ KC_9 // «
+#define FR_RDAQ KC_0 // »
+#define FR_QUOT KC_MINS // '
+#define FR_DCIR KC_EQL // ^ (dead)
+// Row 2
+#define FR_A KC_Q // A
+#define FR_Z KC_W // Z
+#define FR_E KC_E // E
+#define FR_R KC_R // R
+#define FR_T KC_T // T
+#define FR_Y KC_Y // Y
+#define FR_U KC_U // U
+#define FR_I KC_I // I
+#define FR_O KC_O // O
+#define FR_P KC_P // P
+#define FR_MINS KC_LBRC // -
+#define FR_PLUS KC_RBRC // +
+// Row 3
+#define FR_Q KC_A // Q
+#define FR_S KC_S // S
+#define FR_D KC_D // D
+#define FR_F KC_F // F
+#define FR_G KC_G // G
+#define FR_H KC_H // H
+#define FR_J KC_J // J
+#define FR_K KC_K // K
+#define FR_L KC_L // L
+#define FR_M KC_SCLN // M
+#define FR_SLSH KC_QUOT // /
+#define FR_ASTR KC_NUHS // *
+// Row 4
+#define FR_LABK KC_NUBS // <
+#define FR_W KC_Z // W
+#define FR_X KC_X // X
+#define FR_C KC_C // C
+#define FR_V KC_V // V
+#define FR_B KC_B // B
+#define FR_N KC_N // N
+#define FR_DOT KC_M // .
+#define FR_COMM KC_COMM // ,
+#define FR_COLN KC_DOT // :
+#define FR_SCLN KC_SLSH // ;
+
+/* Shifted symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ # │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ " │ ¨ │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │   │   │   │   │   │   │   │   │   │   │ – │ ± │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │   │   │   │   │   │   │   │   │   │   │ \ │ ½ │    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │ > │   │   │   │   │   │   │ ? │ ! │ … │ = │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define FR_HASH S(FR_AT) // #
+#define FR_1 S(FR_AGRV) // 1
+#define FR_2 S(FR_EACU) // 2
+#define FR_3 S(FR_EGRV) // 3
+#define FR_4 S(FR_ECIR) // 4
+#define FR_5 S(FR_LPRN) // 5
+#define FR_6 S(FR_RPRN) // 6
+#define FR_7 S(FR_LSQU) // 7
+#define FR_8 S(FR_RSQU) // 8
+#define FR_9 S(FR_LDAQ) // 9
+#define FR_0 S(FR_RDAQ) // 0
+#define FR_DQUO S(FR_QUOT) // "
+#define FR_DIAE S(FR_DCIR) // ¨ (dead)
+// Row 2
+#define FR_NDSH S(FR_MINS) // –
+#define FR_PLMN S(FR_PLUS) // ±
+// Row 3
+#define FR_BSLS S(FR_SLSH) // (backslash)
+#define FR_HALF S(FR_ASTR) // ½
+// Row 4
+#define FR_RABK S(FR_LABK) // >
+#define FR_QUES S(FR_DOT) // ?
+#define FR_EXLM S(FR_COMM) // !
+#define FR_ELLP S(FR_COLN) // …
+#define FR_EQL S(FR_SCLN) // =
+
+/* AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ˘ │ § │ ´ │ ` │ & │ [ │ ] │ ¯ │ _ │ “ │ ” │ ° │ ˇ │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ æ │ £ │ € │ ® │ { │ } │ ù │ ˙ │ œ │ % │ − │ † │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │ θ │ ß │ $ │ ¤ │ µ │ Eu│   │ ∕ │ | │ ∞ │ ÷ │ × │    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │ ≤ │ ʒ │ © │ ç │ ¸ │ − │ ~ │ ¿ │ ¡ │ · │ ≃ │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define FR_BREV ALGR(FR_AT) // ˘ (dead)
+#define FR_SECT ALGR(FR_AGRV) // §
+#define FR_ACUT ALGR(FR_EACU) // ´ (dead)
+#define FR_GRV ALGR(FR_EGRV) // ` (dead)
+#define FR_AMPR ALGR(FR_ECIR) // &
+#define FR_LBRC ALGR(FR_LPRN) // [
+#define FR_RBRC ALGR(FR_RPRN) // ]
+#define FR_MACR ALGR(FR_LSQU) // ¯ (dead)
+#define FR_UNDS ALGR(FR_RSQU) // _
+#define FR_LDQU ALGR(FR_LDAQ) // “
+#define FR_RDQU ALGR(FR_RDAQ) // ”
+#define FR_DEG ALGR(FR_QUOT) // °
+#define FR_CARN ALGR(FR_DCIR) // ˇ (dead)
+// Row 2
+#define FR_AE ALGR(FR_A) // æ
+#define FR_PND ALGR(FR_Z) // £
+#define FR_EURO ALGR(FR_E) // €
+#define FR_REGD ALGR(FR_R) // ®
+#define FR_LCBR ALGR(FR_T) // {
+#define FR_RCBR ALGR(FR_Y) // }
+#define FR_UGRV ALGR(FR_U) // ù
+#define FR_DOTA ALGR(FR_I) // ˙ (dead)
+#define FR_OE ALGR(FR_O) // œ
+#define FR_PERC ALGR(FR_P) // %
+#define FR_MMNS ALGR(FR_MINS) // −
+#define FR_DAGG ALGR(FR_PLUS) // †
+// Row 3
+#define FR_THET ALGR(FR_Q) // θ
+#define FR_SS ALGR(FR_S) // ß
+#define FR_DLR ALGR(FR_D) // $
+#define FR_CURR ALGR(FR_F) // ¤ (dead monetary key)
+#define FR_DGRK ALGR(FR_G) // µ (dead Greek key)
+#define FR_EU ALGR(FR_H) // Eu (dead European symbol key)
+#define FR_DSLS ALGR(FR_K) // ∕ (dead)
+#define FR_PIPE ALGR(FR_L) // |
+#define FR_INFN ALGR(FR_M) // ∞
+#define FR_DIV ALGR(FR_SLSH) // ÷
+#define FR_MUL ALGR(FR_ASTR) // ×
+// Row 4
+#define FR_LEQL ALGR(FR_LABK) // ≤
+#define FR_EZH ALGR(FR_W) // ʒ
+#define FR_COPY ALGR(FR_X) // ©
+#define FR_CCED ALGR(FR_C) // ç
+#define FR_CEDL ALGR(FR_V) // ¸ (dead)
+#define FR_DMNS ALGR(FR_B) // − (dead)
+#define FR_DTIL ALGR(FR_N) // ~ (dead)
+#define FR_IQUE ALGR(FR_DOT) // ¿
+#define FR_IEXL ALGR(FR_COMM) // ¡
+#define FR_MDDT ALGR(FR_COLN) // ·
+#define FR_AEQL ALGR(FR_SCLN) // ≃
+
+/* Shift+AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │  ̑ │   │   │   │   │ ˝ │  ̏ │   │ — │ ‹ │ › │ ˚ │   │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │   │   │   │   │ ™ │   │   │  ̣ │   │ ‰ │ ‑ │ ‡ │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │      │   │   │   │   │   │ ˍ │   │   │   │   │ √ │ ¼ │    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │ ≥ │   │   │   │ ˛ │   │   │   │  ̦ │   │ ≠ │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define FR_IBRV S(ALGR(FR_AT)) //  ̑ (dead)
+#define FR_DACU S(ALGR(FR_LPRN)) // ˝ (dead)
+#define FR_DGRV S(ALGR(FR_RPRN)) //  ̏ (dead)
+#define FR_MDSH S(ALGR(FR_RSQU)) // —
+#define FR_LSAQ S(ALGR(FR_LDAQ)) // ‹
+#define FR_RSAQ S(ALGR(FR_RDAQ)) // ›
+#define FR_RNGA S(ALGR(FR_QUOT)) // ˚ (dead)
+// Row 2
+#define FR_TM S(ALGR(FR_T)) // ™
+#define FR_DOTB S(ALGR(FR_I)) //  ̣ (dead)
+#define FR_PERM S(ALGR(FR_P)) // ‰
+#define FR_NBHY S(ALGR(FR_MINS)) // ‑ (non-breaking hyphen)
+#define FR_DDAG S(ALGR(FR_PLUS)) // ‡
+// Row 3
+#define FR_MACB S(ALGR(FR_H)) // ˍ (dead)
+#define FR_SQRT S(ALGR(FR_SLSH)) // √
+#define FR_QRTR S(ALGR(FR_ASTR)) // ¼
+// Row 4
+#define FR_GEQL S(ALGR(FR_LABK)) // ≥
+#define FR_OGON S(ALGR(FR_V)) // ˛ (dead)
+#define FR_DCMM S(ALGR(FR_COMM)) //  ̦ (dead)
+#define FR_NEQL S(ALGR(FR_SCLN)) // ≠
diff --git a/quantum/keymap_extras/keymap_neo2.h b/quantum/keymap_extras/keymap_neo2.h
index 818a739c76..c34e9116bb 100644
--- a/quantum/keymap_extras/keymap_neo2.h
+++ b/quantum/keymap_extras/keymap_neo2.h
@@ -13,66 +13,130 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef KEYMAP_NEO2
-#define KEYMAP_NEO2
-#include "keymap.h"
-#include "keymap_german.h"
-
-#define NEO_A KC_D
-#define NEO_B KC_N
-#define NEO_C KC_R
-#define NEO_D DE_OE
-#define NEO_E KC_F
-#define NEO_F KC_O
-#define NEO_G KC_I
-#define NEO_H KC_U
-#define NEO_I KC_S
-#define NEO_J DE_MINS
-#define NEO_K DE_Z
-#define NEO_L KC_E
-#define NEO_M KC_M
-#define NEO_N KC_J
-#define NEO_O KC_G
-#define NEO_P KC_V
-#define NEO_Q KC_P
-#define NEO_R KC_K
-#define NEO_S KC_H
-#define NEO_T KC_L
-#define NEO_U KC_A
-#define NEO_V KC_W
-#define NEO_W KC_T
-#define NEO_X KC_Q
-#define NEO_Y DE_AE
-#define NEO_Z KC_B
-#define NEO_AE KC_C
-#define NEO_OE KC_X
-#define NEO_UE DE_Y
-#define NEO_SS DE_UE
-
-#define NEO_DOT DE_DOT
-#define NEO_COMM DE_COMM
+#pragma once
-#define NEO_1 DE_1
-#define NEO_2 DE_2
-#define NEO_3 DE_3
-#define NEO_4 DE_4
-#define NEO_5 DE_5
-#define NEO_6 DE_6
-#define NEO_7 DE_7
-#define NEO_8 DE_8
-#define NEO_9 DE_9
-#define NEO_0 DE_0
-#define NEO_MINS DE_SS
-
-#define NEO_ACUT DE_PLUS
-#define NEO_GRV DE_ACUT
-#define NEO_CIRC DE_CIRC
+#include "keymap.h"
-#define NEO_L1_L KC_CAPS
-#define NEO_L1_R DE_HASH
+// clang-format off
-#define NEO_L2_L DE_LESS
-#define NEO_L2_R KC_ALGR
+/*
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ^ │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ ` │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ X │ V │ L │ C │ W │ K │ H │ G │ F │ Q │ ß │ ´ │     │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
+ * │  L3  │ U │ I │ A │ E │ O │ S │ N │ R │ T │ D │ Y │ L3│    │
+ * ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
+ * │    │L4 │ Ü │ Ö │ Ä │ P │ Z │ B │ M │ , │ . │ J │          │
+ * ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │ L4 │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define NE_CIRC KC_GRV // ^ (dead)
+#define NE_1 KC_1 // 1
+#define NE_2 KC_2 // 2
+#define NE_3 KC_3 // 3
+#define NE_4 KC_4 // 4
+#define NE_5 KC_5 // 5
+#define NE_6 KC_6 // 6
+#define NE_7 KC_7 // 7
+#define NE_8 KC_8 // 8
+#define NE_9 KC_9 // 9
+#define NE_0 KC_0 // 0
+#define NE_MINS KC_MINS // -
+#define NE_GRV KC_EQL // ` (dead)
+// Row 2
+#define NE_X KC_Q // X
+#define NE_V KC_W // V
+#define NE_L KC_E // L
+#define NE_C KC_R // C
+#define NE_W KC_T // W
+#define NE_K KC_Y // K
+#define NE_H KC_U // H
+#define NE_G KC_I // G
+#define NE_F KC_O // F
+#define NE_Q KC_P // Q
+#define NE_SS KC_LBRC // ß
+#define NE_ACUT KC_RBRC // ´ (dead)
+// Row 3
+#define NE_L3L KC_CAPS // (layer 3)
+#define NE_U KC_A // U
+#define NE_I KC_S // I
+#define NE_A KC_D // A
+#define NE_E KC_F // E
+#define NE_O KC_G // O
+#define NE_S KC_H // S
+#define NE_N KC_J // N
+#define NE_R KC_K // R
+#define NE_T KC_L // T
+#define NE_D KC_SCLN // D
+#define NE_Y KC_QUOT // Y
+#define NE_L3R KC_NUHS // (layer 3)
+// Row 4
+#define NE_L4L KC_NUBS // (layer 4)
+#define NE_UDIA KC_Z // Ü
+#define NE_ODIA KC_X // Ö
+#define NE_ADIA KC_C // Ä
+#define NE_P KC_V // P
+#define NE_Z KC_B // Z
+#define NE_B KC_N // B
+#define NE_M KC_M // M
+#define NE_COMM KC_COMM // ,
+#define NE_DOT KC_DOT // .
+#define NE_J KC_SLSH // J
+// Row 5
+#define NE_L4R KC_ALGR // (layer 4)
-#endif
+// DEPRECATED
+#define NEO_A NE_A
+#define NEO_B NE_B
+#define NEO_C NE_C
+#define NEO_D NE_D
+#define NEO_E NE_E
+#define NEO_F NE_F
+#define NEO_G NE_G
+#define NEO_H NE_H
+#define NEO_I NE_I
+#define NEO_J NE_J
+#define NEO_K NE_K
+#define NEO_L NE_L
+#define NEO_M NE_M
+#define NEO_N NE_N
+#define NEO_O NE_O
+#define NEO_P NE_P
+#define NEO_Q NE_Q
+#define NEO_R NE_R
+#define NEO_S NE_S
+#define NEO_T NE_T
+#define NEO_U NE_U
+#define NEO_V NE_V
+#define NEO_W NE_W
+#define NEO_X NE_X
+#define NEO_Y NE_Y
+#define NEO_Z NE_Z
+#define NEO_AE NE_ADIA
+#define NEO_OE NE_ODIA
+#define NEO_UE NE_UDIA
+#define NEO_SS NE_SS
+#define NEO_DOT NE_DOT
+#define NEO_COMM NE_COMM
+#define NEO_1 NE_1
+#define NEO_2 NE_2
+#define NEO_3 NE_3
+#define NEO_4 NE_4
+#define NEO_5 NE_5
+#define NEO_6 NE_6
+#define NEO_7 NE_7
+#define NEO_8 NE_8
+#define NEO_9 NE_9
+#define NEO_0 NE_0
+#define NEO_MINS NE_MINS
+#define NEO_ACUT NE_ACUT
+#define NEO_GRV NE_GRV
+#define NEO_CIRC NE_CIRC
+#define NEO_L1_L NE_L3L
+#define NEO_L1_R NE_L3R
+#define NEO_L2_L NE_L4L
+#define NEO_L2_R NE_L4R
diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h
index 7942533b31..76d2f4f6b0 100644
--- a/quantum/keymap_extras/keymap_nordic.h
+++ b/quantum/keymap_extras/keymap_nordic.h
@@ -66,8 +66,3 @@
#define NO_BSLS ALGR(KC_MINS)
#define NO_MU ALGR(KC_M)
-
-// Icelandic characters
-#define NO_TH KC_SLSH //Þ
-#define NO_ETH KC_LBRC //Ð
-#define NO_UMLT KC_MINS //Ö
diff --git a/quantum/keymap_extras/keymap_norwegian.h b/quantum/keymap_extras/keymap_norwegian.h
index b16339c8b3..8b6497f00f 100644
--- a/quantum/keymap_extras/keymap_norwegian.h
+++ b/quantum/keymap_extras/keymap_norwegian.h
@@ -34,57 +34,57 @@
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
-#define NRW_PIPE KC_GRV // |
-#define NRW_1 KC_1 // 1
-#define NRW_2 KC_2 // 2
-#define NRW_3 KC_3 // 3
-#define NRW_4 KC_4 // 4
-#define NRW_5 KC_5 // 5
-#define NRW_6 KC_6 // 6
-#define NRW_7 KC_7 // 7
-#define NRW_8 KC_8 // 8
-#define NRW_9 KC_9 // 9
-#define NRW_0 KC_0 // 0
-#define NRW_PLUS KC_MINS // +
-#define NRW_BSLS KC_EQL // (backslash)
+#define NWG_PIPE KC_GRV // |
+#define NWG_1 KC_1 // 1
+#define NWG_2 KC_2 // 2
+#define NWG_3 KC_3 // 3
+#define NWG_4 KC_4 // 4
+#define NWG_5 KC_5 // 5
+#define NWG_6 KC_6 // 6
+#define NWG_7 KC_7 // 7
+#define NWG_8 KC_8 // 8
+#define NWG_9 KC_9 // 9
+#define NWG_0 KC_0 // 0
+#define NWG_PLUS KC_MINS // +
+#define NWG_BSLS KC_EQL // (backslash)
// Row 2
-#define NRW_Q KC_Q // Q
-#define NRW_W KC_W // W
-#define NRW_E KC_E // E
-#define NRW_R KC_R // R
-#define NRW_T KC_T // T
-#define NRW_Y KC_Y // Y
-#define NRW_U KC_U // U
-#define NRW_I KC_I // I
-#define NRW_O KC_O // O
-#define NRW_P KC_P // P
-#define NRW_ARNG KC_LBRC // Å
-#define NRW_DIAE KC_RBRC // ¨ (dead)
+#define NWG_Q KC_Q // Q
+#define NWG_W KC_W // W
+#define NWG_E KC_E // E
+#define NWG_R KC_R // R
+#define NWG_T KC_T // T
+#define NWG_Y KC_Y // Y
+#define NWG_U KC_U // U
+#define NWG_I KC_I // I
+#define NWG_O KC_O // O
+#define NWG_P KC_P // P
+#define NWG_ARNG KC_LBRC // Å
+#define NWG_DIAE KC_RBRC // ¨ (dead)
// Row 3
-#define NRW_A KC_A // A
-#define NRW_S KC_S // S
-#define NRW_D KC_D // D
-#define NRW_F KC_F // F
-#define NRW_G KC_G // G
-#define NRW_H KC_H // H
-#define NRW_J KC_J // J
-#define NRW_K KC_K // K
-#define NRW_L KC_L // L
-#define NRW_OSTR KC_SCLN // Ø
-#define NRW_AE KC_QUOT // Æ
-#define NRW_QUOT KC_NUHS // '
+#define NWG_A KC_A // A
+#define NWG_S KC_S // S
+#define NWG_D KC_D // D
+#define NWG_F KC_F // F
+#define NWG_G KC_G // G
+#define NWG_H KC_H // H
+#define NWG_J KC_J // J
+#define NWG_K KC_K // K
+#define NWG_L KC_L // L
+#define NWG_OSTR KC_SCLN // Ø
+#define NWG_AE KC_QUOT // Æ
+#define NWG_QUOT KC_NUHS // '
// Row 4
-#define NRW_LABK KC_NUBS // <
-#define NRW_Z KC_Z // Z
-#define NRW_X KC_X // X
-#define NRW_C KC_C // C
-#define NRW_V KC_V // V
-#define NRW_B KC_B // B
-#define NRW_N KC_N // N
-#define NRW_M KC_M // M
-#define NRW_COMM KC_COMM // ,
-#define NRW_DOT KC_DOT // .
-#define NRW_MINS KC_SLSH // -
+#define NWG_LABK KC_NUBS // <
+#define NWG_Z KC_Z // Z
+#define NWG_X KC_X // X
+#define NWG_C KC_C // C
+#define NWG_V KC_V // V
+#define NWG_B KC_B // B
+#define NWG_N KC_N // N
+#define NWG_M KC_M // M
+#define NWG_COMM KC_COMM // ,
+#define NWG_DOT KC_DOT // .
+#define NWG_MINS KC_SLSH // -
/* Shifted symbols
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
@@ -100,28 +100,28 @@
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
-#define NRW_SECT S(NRW_PIPE) // §
-#define NRW_EXLM S(NRW_1) // !
-#define NRW_DQUO S(NRW_2) // "
-#define NRW_HASH S(NRW_3) // #
-#define NRW_CURR S(NRW_4) // ¤
-#define NRW_PERC S(NRW_5) // %
-#define NRW_AMPR S(NRW_6) // &
-#define NRW_SLSH S(NRW_7) // /
-#define NRW_LPRN S(NRW_8) // (
-#define NRW_RPRN S(NRW_9) // )
-#define NRW_EQL S(NRW_0) // =
-#define NRW_QUES S(NRW_PLUS) // ?
-#define NRW_GRV S(NRW_BSLS) // ` (dead)
+#define NWG_SECT S(NWG_PIPE) // §
+#define NWG_EXLM S(NWG_1) // !
+#define NWG_DQUO S(NWG_2) // "
+#define NWG_HASH S(NWG_3) // #
+#define NWG_CURR S(NWG_4) // ¤
+#define NWG_PERC S(NWG_5) // %
+#define NWG_AMPR S(NWG_6) // &
+#define NWG_SLSH S(NWG_7) // /
+#define NWG_LPRN S(NWG_8) // (
+#define NWG_RPRN S(NWG_9) // )
+#define NWG_EQL S(NWG_0) // =
+#define NWG_QUES S(NWG_PLUS) // ?
+#define NWG_GRV S(NWG_BSLS) // ` (dead)
// Row 2
-#define NRW_CIRC S(NRW_DIAE) // ^ (dead)
+#define NWG_CIRC S(NWG_DIAE) // ^ (dead)
// Row 3
-#define NRW_ASTR S(NRW_QUOT) // *
+#define NWG_ASTR S(NWG_QUOT) // *
// Row 4
-#define NRW_RABK S(NRW_LABK) // >
-#define NRW_SCLN S(NRW_COMM) // ;
-#define NRW_COLN S(NRW_DOT) // :
-#define NRW_UNDS S(NRW_MINS) // _
+#define NWG_RABK S(NWG_LABK) // >
+#define NWG_SCLN S(NWG_COMM) // ;
+#define NWG_COLN S(NWG_DOT) // :
+#define NWG_UNDS S(NWG_MINS) // _
/* AltGr symbols
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
@@ -137,39 +137,40 @@
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
-#define NRW_AT ALGR(NRW_2) // @
-#define NRW_PND ALGR(NRW_3) // £
-#define NRW_DLR ALGR(NRW_4) // $
-#define NRW_EURO ALGR(NRW_5) // €
-#define NRW_LCBR ALGR(NRW_7) // {
-#define NRW_LBRC ALGR(NRW_8) // [
-#define NRW_RBRC ALGR(NRW_9) // ]
-#define NRW_RCBR ALGR(NRW_0) // }
-#define NRW_ACUT ALGR(NRW_BSLS) // ´ (dead)
+
+#define NWG_AT ALGR(NWG_2) // @
+#define NWG_PND ALGR(NWG_3) // £
+#define NWG_DLR ALGR(NWG_4) // $
+#define NWG_EURO ALGR(NWG_5) // €
+#define NWG_LCBR ALGR(NWG_7) // {
+#define NWG_LBRC ALGR(NWG_8) // [
+#define NWG_RBRC ALGR(NWG_9) // ]
+#define NWG_RCBR ALGR(NWG_0) // }
+#define NWG_ACUT ALGR(NWG_BSLS) // ´ (dead)
// Row 2
-#define NRW_TILD ALGR(NRW_DIAE) // ~ (dead)
+#define NWG_TILD ALGR(NWG_DIAE) // ~ (dead)
// Row 4
-#define NRW_MICR ALGR(NRW_M) // µ
+#define NWG_MICR ALGR(NWG_M) // µ
// DEPRECATED
-#define NRW_AM NRW_ARNG
-#define NRW_AA NRW_ARNG
-#define NRW_OSLH NRW_OSTR
-#define NRW_APOS NRW_QUOT
-#define NRW_LESS NRW_LABK
-#define NRW_QUO2 NRW_DQUO
-#define NRW_BULT NRW_CURR
-#define NRW_GRTR NRW_RABK
-#define NRW_MU NRW_MICR
+#define NWG_AM NWG_ARNG
+#define NWG_AA NWG_ARNG
+#define NWG_OSLH NWG_OSTR
+#define NWG_APOS NWG_QUOT
+#define NWG_LESS NWG_LABK
+#define NWG_QUO2 NWG_DQUO
+#define NWG_BULT NWG_CURR
+#define NWG_GRTR NWG_RABK
+#define NWG_MU NWG_MICR
// Norwegian macOS symbols
-#define NRW_ACUT_MAC NRW_BSLS // ´
-#define NRW_APOS_MAC NRW_LABK // '
-#define NRW_AT_MAC NRW_QUOT // @
-#define NRW_BSLS_MAC S(ALGR(NRW_7)) // (backslash)
-#define NRW_DLR_MAC S(NRW_4) // $
-#define NRW_GRV_MAC ALGR(NRW_BSLS) // `
-#define NRW_GRTR_MAC S(NRW_PIPE) // >
-#define NRW_LCBR_MAC S(ALGR(NRW_8)) // {
-#define NRW_LESS_MAC NRW_PIPE // <
-#define NRW_PIPE_MAC ALGR(NRW_7) // |
-#define NRW_RCBR_MAC S(ALGR(NRW_9)) // }
+#define NWG_ACUT_MAC NWG_BSLS // ´
+#define NWG_APOS_MAC NWG_LABK // '
+#define NWG_AT_MAC NWG_QUOT // @
+#define NWG_BSLS_MAC S(ALGR(NWG_7)) // (backslash)
+#define NWG_DLR_MAC S(NWG_4) // $
+#define NWG_GRV_MAC ALGR(NWG_BSLS) // `
+#define NWG_GRTR_MAC S(NWG_PIPE) // >
+#define NWG_LCBR_MAC S(ALGR(NWG_8)) // {
+#define NWG_LESS_MAC NWG_PIPE // <
+#define NWG_PIPE_MAC ALGR(NWG_7) // |
+#define NWG_RCBR_MAC S(ALGR(NWG_9)) // }
diff --git a/quantum/keymap_extras/keymap_spanish_dvorak.h b/quantum/keymap_extras/keymap_spanish_dvorak.h
index b6bc734c37..8fd6214728 100644
--- a/quantum/keymap_extras/keymap_spanish_dvorak.h
+++ b/quantum/keymap_extras/keymap_spanish_dvorak.h
@@ -26,7 +26,7 @@
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
* │     │ . │ , │ Ñ │ P │ Y │ F │ G │ C │ H │ L │ ` │ + │     │
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐    │
- * │      │ A │ O │ E │ U │ I │ D │ R │ T │ N │ S │ ' │ Ç │    │
+ * │      │ A │ O │ E │ U │ I │ D │ R │ T │ N │ S │ ´ │ Ç │    │
* ├────┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴────┤
* │    │ < │ - │ Q │ J │ K │ X │ B │ M │ W │ V │ Z │          │
* ├────┼───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
@@ -119,7 +119,11 @@
#define DV_CIRC S(DV_GRV) // ^ (dead)
#define DV_ASTR S(DV_PLUS) // *
// Row 3
+<<<<<<< HEAD
#define DV_DIAE S(DV_GRV) // ¨ (dead)
+=======
+#define DV_DIAE S(DV_ACUT) // ¨ (dead)
+>>>>>>> 0.12.52~1
// Row 4
#define DV_RABK S(DV_LABK) // >
#define DV_UNDS S(DV_MINS) // _
diff --git a/quantum/keymap_extras/keymap_us_extended.h b/quantum/keymap_extras/keymap_us_extended.h
new file mode 100644
index 0000000000..b2b3a734c9
--- /dev/null
+++ b/quantum/keymap_extras/keymap_us_extended.h
@@ -0,0 +1,227 @@
+/* Copyright 2020
+ *
+ * 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 "keymap.h"
+
+// clang-format off
+
+/*
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │  \  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define US_GRV KC_GRV // `
+#define US_1 KC_1 // 1
+#define US_2 KC_2 // 2
+#define US_3 KC_3 // 3
+#define US_4 KC_4 // 4
+#define US_5 KC_5 // 5
+#define US_6 KC_6 // 6
+#define US_7 KC_7 // 7
+#define US_8 KC_8 // 8
+#define US_9 KC_9 // 9
+#define US_0 KC_0 // 0
+#define US_MINS KC_MINS // -
+#define US_EQL KC_EQL // =
+// Row 2
+#define US_Q KC_Q // Q
+#define US_W KC_W // W
+#define US_E KC_E // E
+#define US_R KC_R // R
+#define US_T KC_T // T
+#define US_Y KC_Y // Y
+#define US_U KC_U // U
+#define US_I KC_I // I
+#define US_O KC_O // O
+#define US_P KC_P // P
+#define US_LBRC KC_LBRC // [
+#define US_RBRC KC_RBRC // ]
+#define US_BSLS KC_BSLS // (backslash)
+// Row 3
+#define US_A KC_A // A
+#define US_S KC_S // S
+#define US_D KC_D // D
+#define US_F KC_F // F
+#define US_G KC_G // G
+#define US_H KC_H // H
+#define US_J KC_J // J
+#define US_K KC_K // K
+#define US_L KC_L // L
+#define US_SCLN KC_SCLN // ;
+#define US_QUOT KC_QUOT // '
+// Row 4
+#define US_Z KC_Z // Z
+#define US_X KC_X // X
+#define US_C KC_C // C
+#define US_V KC_V // V
+#define US_B KC_B // B
+#define US_N KC_N // N
+#define US_M KC_M // M
+#define US_COMM KC_COMM // ,
+#define US_DOT KC_DOT // .
+#define US_SLSH KC_SLSH // /
+
+/* Shifted symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │   │   │   │   │   │   │   │   │   │   │ { │ } │  |  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │   │   │   │   │   │   │   │   │   │ : │ " │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │   │   │   │   │   │   │   │ < │ > │ ? │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define US_TILD S(US_GRV) // ~
+#define US_EXLM S(US_1) // !
+#define US_AT S(US_2) // @
+#define US_HASH S(US_3) // #
+#define US_DLR S(US_4) // $
+#define US_PERC S(US_5) // %
+#define US_CIRC S(US_6) // ^
+#define US_AMPR S(US_7) // &
+#define US_ASTR S(US_8) // *
+#define US_LPRN S(US_9) // (
+#define US_RPRN S(US_0) // )
+#define US_UNDS S(US_MINS) // _
+#define US_PLUS S(US_EQL) // +
+// Row 2
+#define US_LCBR S(US_LBRC) // {
+#define US_RCBR S(US_RBRC) // }
+#define US_PIPE S(US_BSLS) // |
+// Row 3
+#define US_COLN S(US_SCLN) // :
+#define US_DQUO S(US_QUOT) // "
+// Row 4
+#define US_LABK S(US_COMM) // <
+#define US_RABK S(US_DOT) // >
+#define US_QUES S(US_SLSH) // ?
+
+/* AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ` │ ¹ │ ² │ ³ │ ¤ │ € │ ^ │ ̛  │ ¾ │ ‘ │ ’ │ ¥ │ × │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ Ä │ Å │ É │ ® │ Þ │ Ü │ Ú │ Í │ Ó │ Ö │ « │ » │  ¬  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │ Á │ ß │ Ð │   │   │   │ Ï │ Œ │ Ø │ ¶ │ ' │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │ Æ │   │ © │   │   │ Ñ │ µ │ Ç │ ˙ │ ¿ │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define US_DGRV ALGR(US_GRV) // ` (dead)
+#define US_SUP1 ALGR(US_1) // ¹
+#define US_SUP2 ALGR(US_2) // ²
+#define US_SUP3 ALGR(US_3) // ³
+#define US_CURR ALGR(US_4) // ¤
+#define US_EURO ALGR(US_5) // €
+#define US_DCIR ALGR(US_6) // ^ (dead)
+#define US_HORN ALGR(US_7) // ̛̛ (dead)
+#define US_OGON ALGR(US_8) // ˛ (dead)
+#define US_LSQU ALGR(US_9) // ‘
+#define US_RSQU ALGR(US_0) // ’
+#define US_YEN ALGR(US_MINS) // ¥
+#define US_MUL ALGR(US_EQL) // ×
+// Row 2
+#define US_ADIA ALGR(US_Q) // Ä
+#define US_ARNG ALGR(US_W) // Å
+#define US_EACU ALGR(US_E) // É
+#define US_EDIA ALGR(US_R) // Ë
+#define US_THRN ALGR(US_T) // Þ
+#define US_UDIA ALGR(US_Y) // Ü
+#define US_UACU ALGR(US_U) // Ú
+#define US_IACU ALGR(US_I) // Í
+#define US_OACU ALGR(US_O) // Ó
+#define US_ODIA ALGR(US_P) // Ö
+#define US_LDAQ ALGR(US_LBRC) // «
+#define US_RDAQ ALGR(US_RBRC) // »
+#define US_NOT ALGR(US_BSLS) // ¬
+// Row 3
+#define US_AACU ALGR(US_A) // Á
+#define US_SS ALGR(US_S) // ß
+#define US_ETH ALGR(US_D) // Ð
+#define US_IDIA ALGR(US_J) // Ï
+#define US_OE ALGR(US_K) // Œ
+#define US_OSTR ALGR(US_L) // Ø
+#define US_PILC ALGR(US_SCLN) // ¶
+#define US_ACUT ALGR(US_QUOT) // ´ (dead)
+// Row 4
+#define US_AE ALGR(US_Z) // Æ
+#define US_OE_2 ALGR(US_X) // Œ
+#define US_COPY ALGR(US_C) // ©
+#define US_REGD ALGR(US_V) // ®
+#define US_NTIL ALGR(US_N) // Ñ
+#define US_MICR ALGR(US_M) // µ
+#define US_CCED ALGR(US_COMM) // Ç
+#define US_DOTA ALGR(US_DOT) // ˙ (dead)
+#define US_IQUE ALGR(US_SLSH) // ¿
+
+/* Shift+AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ~ │ ¡ │ ˝ │ ¯ │ £ │ ¸ │ ¼ │ ½ │ ¾ │ ˘ │ ° │  ̣ │ ÷ │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │   │   │   │   │   │   │   │   │   │   │ “ │ ” │  ¦  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │   │ § │   │   │   │   │   │   │   │ ° │ " │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │   │   │ ¢ │   │   │   │   │   │ ˇ │  ̉ │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define US_DTIL S(ALGR(US_GRV)) // ~ (dead)
+#define US_IEXL S(ALGR(US_1)) // ¡
+#define US_DACU S(ALGR(US_2)) // ˝ (dead)
+#define US_MACR S(ALGR(US_3)) // ¯ (dead)
+#define US_PND S(ALGR(US_4)) // £
+#define US_CEDL S(ALGR(US_5)) // ¸ (dead)
+#define US_QRTR S(ALGR(US_6)) // ¼
+#define US_HALF S(ALGR(US_7)) // ½
+#define US_TQTR S(ALGR(US_8)) // ¾
+#define US_BREV S(ALGR(US_9)) // ˘ (dead)
+#define US_RNGA S(ALGR(US_0)) // ° (dead)
+#define US_DOTB S(ALGR(US_MINS)) // ̣ (dead)
+#define US_DIV S(ALGR(US_EQL)) // ÷
+// Row 2
+#define US_LDQU S(ALGR(US_LBRC)) // “
+#define US_RDQU S(ALGR(US_LBRC)) // ”
+#define US_BRKP S(ALGR(US_BSLS)) // ¦
+// Row 3
+#define US_SECT S(ALGR(US_S)) // §
+#define US_DEG S(ALGR(US_SCLN)) // °
+#define US_DIAE S(ALGR(US_QUOT)) // ¨ (dead)
+// Row 4
+#define US_CENT S(ALGR(US_C)) // ¢
+#define US_CARN S(ALGR(US_DOT)) // ˇ (dead)
+#define US_HOKA S(ALGR(US_SLSH)) // ̉ (dead)
+
diff --git a/quantum/keymap_extras/keymap_us_international.h b/quantum/keymap_extras/keymap_us_international.h
index a3bc465971..49afcc4fb2 100644
--- a/quantum/keymap_extras/keymap_us_international.h
+++ b/quantum/keymap_extras/keymap_us_international.h
@@ -26,7 +26,7 @@
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
* │     │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │  \  │
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
- * │      │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │        │
+ * │      │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ´ │        │
* ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
* │        │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │          │
* ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
@@ -34,7 +34,7 @@
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
-#define US_GRV KC_GRV // ` (dead)
+#define US_DGRV KC_GRV // ` (dead)
#define US_1 KC_1 // 1
#define US_2 KC_2 // 2
#define US_3 KC_3 // 3
@@ -72,7 +72,7 @@
#define US_K KC_K // K
#define US_L KC_L // L
#define US_SCLN KC_SCLN // ;
-#define US_QUOT KC_QUOT // ' (dead)
+#define US_ACUT KC_QUOT // ´ (dead)
// Row 4
#define US_Z KC_Z // Z
#define US_X KC_X // X
@@ -91,7 +91,7 @@
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
* │     │   │   │   │   │   │   │   │   │   │   │ { │ } │  |  │
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
- * │      │   │   │   │   │   │   │   │   │   │ : │ " │        │
+ * │      │   │   │   │   │   │   │   │   │   │ : │ ¨ │        │
* ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
* │        │   │   │   │   │   │   │   │ < │ > │ ? │          │
* ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
@@ -99,13 +99,13 @@
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
*/
// Row 1
-#define US_TILD S(US_GRV) // ~ (dead)
+#define US_DTIL S(US_DGRV) // ~ (dead)
#define US_EXLM S(US_1) // !
-#define US_AT S(US_2) // "
+#define US_AT S(US_2) // @
#define US_HASH S(US_3) // #
#define US_DLR S(US_4) // $
#define US_PERC S(US_5) // %
-#define US_CIRC S(US_6) // ^
+#define US_DCIR S(US_6) // ^ (dead)
#define US_AMPR S(US_7) // &
#define US_ASTR S(US_8) // *
#define US_LPRN S(US_9) // (
@@ -118,7 +118,7 @@
#define US_PIPE S(US_BSLS) // |
// Row 3
#define US_COLN S(US_SCLN) // :
-#define US_DQUO S(US_QUOT) // " (dead)
+#define US_DIAE S(US_ACUT) // ¨ (dead)
// Row 4
#define US_LABK S(US_COMM) // <
#define US_RABK S(US_DOT) // >
@@ -170,7 +170,7 @@
#define US_ETH ALGR(US_D) // Ð
#define US_OSTR ALGR(US_L) // Ø
#define US_PILC ALGR(US_SCLN) // ¶
-#define US_ACUT ALGR(US_QUOT) // ´
+#define US_NDAC ALGR(US_ACUT) // ´
// Row 4
#define US_AE ALGR(US_Z) // Æ
#define US_COPY ALGR(US_C) // ©
@@ -201,6 +201,6 @@
// Row 3
#define US_SECT S(ALGR(US_S)) // §
#define US_DEG S(ALGR(US_SCLN)) // °
-#define US_DIAE S(ALGR(US_QUOT)) // ¨
+#define US_NDDR S(ALGR(US_ACUT)) // ¨
// Row 4
#define US_CENT S(ALGR(US_C)) // ¢
diff --git a/quantum/keymap_extras/keymap_us_international_linux.h b/quantum/keymap_extras/keymap_us_international_linux.h
new file mode 100644
index 0000000000..2c3e230393
--- /dev/null
+++ b/quantum/keymap_extras/keymap_us_international_linux.h
@@ -0,0 +1,224 @@
+/* Copyright 2020
+ *
+ * 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 "keymap.h"
+
+// clang-format off
+
+/*
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │  \  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ´ │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define US_DGRV KC_GRV // ` (dead)
+#define US_1 KC_1 // 1
+#define US_2 KC_2 // 2
+#define US_3 KC_3 // 3
+#define US_4 KC_4 // 4
+#define US_5 KC_5 // 5
+#define US_6 KC_6 // 6
+#define US_7 KC_7 // 7
+#define US_8 KC_8 // 8
+#define US_9 KC_9 // 9
+#define US_0 KC_0 // 0
+#define US_MINS KC_MINS // -
+#define US_EQL KC_EQL // =
+// Row 2
+#define US_Q KC_Q // Q
+#define US_W KC_W // W
+#define US_E KC_E // E
+#define US_R KC_R // R
+#define US_T KC_T // T
+#define US_Y KC_Y // Y
+#define US_U KC_U // U
+#define US_I KC_I // I
+#define US_O KC_O // O
+#define US_P KC_P // P
+#define US_LBRC KC_LBRC // [
+#define US_RBRC KC_RBRC // ]
+#define US_BSLS KC_BSLS // (backslash)
+// Row 3
+#define US_A KC_A // A
+#define US_S KC_S // S
+#define US_D KC_D // D
+#define US_F KC_F // F
+#define US_G KC_G // G
+#define US_H KC_H // H
+#define US_J KC_J // J
+#define US_K KC_K // K
+#define US_L KC_L // L
+#define US_SCLN KC_SCLN // ;
+#define US_ACUT KC_QUOT // ´ (dead)
+// Row 4
+#define US_Z KC_Z // Z
+#define US_X KC_X // X
+#define US_C KC_C // C
+#define US_V KC_V // V
+#define US_B KC_B // B
+#define US_N KC_N // N
+#define US_M KC_M // M
+#define US_COMM KC_COMM // ,
+#define US_DOT KC_DOT // .
+#define US_SLSH KC_SLSH // /
+
+/* Shifted symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │   │   │   │   │   │   │   │   │   │   │ { │ } │  |  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │   │   │   │   │   │   │   │   │   │ : │ ¨ │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │   │   │   │   │   │   │   │ < │ > │ ? │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define US_DTIL S(US_DGRV) // ~ (dead)
+#define US_EXLM S(US_1) // !
+#define US_AT S(US_2) // @
+#define US_HASH S(US_3) // #
+#define US_DLR S(US_4) // $
+#define US_PERC S(US_5) // %
+#define US_DCIR S(US_6) // ^ (dead)
+#define US_AMPR S(US_7) // &
+#define US_ASTR S(US_8) // *
+#define US_LPRN S(US_9) // (
+#define US_RPRN S(US_0) // )
+#define US_UNDS S(US_MINS) // _
+#define US_PLUS S(US_EQL) // +
+// Row 2
+#define US_LCBR S(US_LBRC) // {
+#define US_RCBR S(US_RBRC) // }
+#define US_PIPE S(US_BSLS) // |
+// Row 3
+#define US_COLN S(US_SCLN) // :
+#define US_DIAE S(US_ACUT) // ¨ (dead)
+// Row 4
+#define US_LABK S(US_COMM) // <
+#define US_RABK S(US_DOT) // >
+#define US_QUES S(US_SLSH) // ?
+
+/* AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ` │ ¡ │ ² │ ³ │ ¤ │ € │ ¼ │ ½ │ ¾ │ ‘ │ ’ │ ¥ │ × │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │ Ä │ Å │ É │ ® │ Þ │ Ü │ Ú │ Í │ Ó │ Ö │ « │ » │  ¬  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │ Á │ ß │ Ð │   │   │   │   │ Œ │ Ø │ ¶ │ ' │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │ Æ │   │ © │   │   │ Ñ │ µ │ Ç │ ˙ │ ¿ │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+
+// Row 1
+#define US_GRV ALGR(US_DGRV) // `
+#define US_IEXL ALGR(US_1) // ¡
+#define US_SUP2 ALGR(US_2) // ²
+#define US_SUP3 ALGR(US_3) // ³
+#define US_CURR ALGR(US_4) // ¤
+#define US_EURO ALGR(US_5) // €
+#define US_QRTR ALGR(US_6) // ¼
+#define US_HALF ALGR(US_7) // ½
+#define US_TQTR ALGR(US_8) // ¾
+#define US_LSQU ALGR(US_9) // ‘
+#define US_RSQU ALGR(US_0) // ’
+#define US_YEN ALGR(US_MINS) // ¥
+#define US_MUL ALGR(US_EQL) // ×
+// Row 2
+#define US_ADIA ALGR(US_Q) // Ä
+#define US_ARNG ALGR(US_W) // Å
+#define US_EACU ALGR(US_E) // É
+#define US_REGD ALGR(US_R) // ®
+#define US_THRN ALGR(US_T) // Þ
+#define US_UDIA ALGR(US_Y) // Ü
+#define US_UACU ALGR(US_U) // Ú
+#define US_IACU ALGR(US_I) // Í
+#define US_OACU ALGR(US_O) // Ó
+#define US_ODIA ALGR(US_P) // Ö
+#define US_LDAQ ALGR(US_LBRC) // «
+#define US_RDAQ ALGR(US_RBRC) // »
+#define US_NOT ALGR(US_BSLS) // ¬
+// Row 3
+#define US_AACU ALGR(US_A) // Á
+#define US_SS ALGR(US_S) // ß
+#define US_ETH ALGR(US_D) // Ð
+#define US_OE ALGR(US_K) // Œ
+#define US_OSTR ALGR(US_L) // Ø
+#define US_PILC ALGR(US_SCLN) // ¶
+#define US_QUOT ALGR(US_ACUT) // '
+// Row 4
+#define US_AE ALGR(US_Z) // Æ
+#define US_COPY ALGR(US_C) // ©
+#define US_NTIL ALGR(US_N) // Ñ
+#define US_MICR ALGR(US_M) // µ
+#define US_CCED ALGR(US_COMM) // Ç
+#define US_DOTA ALGR(US_DOT) // ˙ (dead)
+#define US_IQUE ALGR(US_SLSH) // ¿
+
+/* Shift+AltGr symbols
+ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
+ * │ ~ │ ¹ │ ˝ │ ¯ │ £ │ ¸ │ ^ │ ̛  │ ˛ │ ˘ │ ° │  ̣ │ ÷ │       │
+ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
+ * │     │   │   │   │   │   │   │   │   │   │   │ “ │ ” │  ¦  │
+ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤
+ * │      │   │ § │   │   │   │   │   │   │   │ ° │ " │        │
+ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤
+ * │        │   │   │ ¢ │   │   │   │   │   │ ˇ │  ̉ │          │
+ * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤
+ * │    │    │    │                        │    │    │    │    │
+ * └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
+ */
+// Row 1
+#define US_TILD S(ALGR(US_DGRV)) // ~
+#define US_SUP1 S(ALGR(US_1)) // ¹
+#define US_DACU S(ALGR(US_2)) // ˝ (dead)
+#define US_MACR S(ALGR(US_3)) // ¯ (dead)
+#define US_PND S(ALGR(US_4)) // £
+#define US_CEDL S(ALGR(US_5)) // ¸ (dead)
+#define US_CIRC S(ALGR(US_6)) // ^
+#define US_HORN S(ALGR(US_7)) // ̛ (dead)
+#define US_OGON S(ALGR(US_8)) // ˛ (dead)
+#define US_BREV S(ALGR(US_9)) // ˘ (dead)
+#define US_RNGA S(ALGR(US_0)) // ° (dead)
+#define US_DOTB S(ALGR(US_MINS)) // ̣ (dead)
+#define US_DIV S(ALGR(US_EQL)) // ÷
+// Row 2
+#define US_LDQU S(ALGR(US_LBRC)) // “
+#define US_RDQU S(ALGR(US_LBRC)) // ”
+#define US_BRKP S(ALGR(US_BSLS)) // ¦
+// Row 3
+#define US_SECT S(ALGR(US_S)) // §
+#define US_DEG S(ALGR(US_SCLN)) // °
+#define US_DQUO S(ALGR(US_ACUT)) // "
+// Row 4
+#define US_CENT S(ALGR(US_C)) // ¢
+#define US_CARN S(ALGR(US_DOT)) // ˇ (dead)
+#define US_HOKA S(ALGR(US_SLSH)) // ̉ (dead)
diff --git a/quantum/keymap_extras/sendstring_belgian.h b/quantum/keymap_extras/sendstring_belgian.h
index 9ff92f010d..5e7218a2fa 100644
--- a/quantum/keymap_extras/sendstring_belgian.h
+++ b/quantum/keymap_extras/sendstring_belgian.h
@@ -21,6 +21,8 @@
#include "keymap_belgian.h"
#include "quantum.h"
+// clang-format off
+
const uint8_t ascii_to_shift_lut[16] PROGMEM = {
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
@@ -65,16 +67,16 @@ 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
KC_SPC, BE_EXLM, BE_DQUO, BE_DQUO, BE_DLR, BE_UGRV, BE_AMPR, BE_QUOT,
// ( ) * + , - . /
- BE_LPRN, BE_RPRN, BE_DLR, BE_EQL, BE_COMM, BE_MINS, BE_SCLN, BE_COLN,
+ 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_AMPR, BE_EACU, BE_DQUO, BE_QUOT, BE_LPRN, BE_SECT, BE_EGRV,
// 8 9 : ; < = > ?
diff --git a/quantum/keymap_extras/sendstring_bepo.h b/quantum/keymap_extras/sendstring_bepo.h
index be442070dc..8119cd9f54 100644
--- a/quantum/keymap_extras/sendstring_bepo.h
+++ b/quantum/keymap_extras/sendstring_bepo.h
@@ -21,6 +21,7 @@
#include "keymap_bepo.h"
#include "quantum.h"
+// clang-format off
const uint8_t ascii_to_shift_lut[16] PROGMEM = {
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
@@ -66,16 +67,16 @@ 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
KC_SPC, BP_DCIR, BP_DQUO, BP_DLR, BP_DLR, BP_PERC, BP_P, BP_QUOT,
// ( ) * + , - . /
- BP_LPRN, BP_RPRN, BP_ASTR, BP_PLUS, BP_COMM, BP_MINS, BP_DOT, BP_SLSH,
+ 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_DQUO, BP_LDAQ, BP_RDAQ, BP_LPRN, BP_RPRN, BP_AT, BP_PLUS,
// 8 9 : ; < = > ?
@@ -95,4 +96,5 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
// 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};
+ BP_X, BP_Y, BP_Z, BP_Y, BP_B, BP_X, BP_K, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_canadian_multilingual.h b/quantum/keymap_extras/sendstring_canadian_multilingual.h
new file mode 100644
index 0000000000..c3fcc62c37
--- /dev/null
+++ b/quantum/keymap_extras/sendstring_canadian_multilingual.h
@@ -0,0 +1,100 @@
+/* Copyright 2020
+ *
+ * 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 Canadian Multilingual layouts
+
+#pragma once
+
+#include "keymap_canadian_multilingual.h"
+#include "quantum.h"
+
+// clang-format off
+
+const uint8_t ascii_to_shift_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 1, 0, 0, 0, 0, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 0, 1, 0, 0, 1),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0)
+};
+
+const uint8_t ascii_to_altgr_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 1, 0, 1, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 1, 0, 1, 0, 0),
+ KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(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, CA_1, CA_DOT, CA_3, CA_4, CA_5, CA_7, CA_COMM,
+ // ( ) * + , - . /
+ CA_9, CA_0, CA_8, CA_EQL, CA_COMM, CA_MINS, CA_DOT, CA_SLSH,
+ // 0 1 2 3 4 5 6 7
+ CA_0, CA_1, CA_2, CA_3, CA_4, CA_5, CA_6, CA_7,
+ // 8 9 : ; < = > ?
+ CA_8, CA_9, CA_SCLN, CA_SCLN, CA_DOT, CA_EQL, CA_COMM, CA_6,
+ // @ A B C D E F G
+ CA_2, CA_A, CA_B, CA_C, CA_D, CA_E, CA_F, CA_G,
+ // H I J K L M N O
+ CA_H, CA_I, CA_J, CA_K, CA_L, CA_M, CA_N, CA_O,
+ // P Q R S T U V W
+ CA_P, CA_Q, CA_R, CA_S, CA_T, CA_U, CA_V, CA_W,
+ // X Y Z [ \ ] ^ _
+ CA_X, CA_Y, CA_Z, CA_9, CA_SLSH, CA_0, CA_CIRC, CA_MINS,
+ // ` a b c d e f g
+ CA_CIRC, CA_A, CA_B, CA_C, CA_D, CA_E, CA_F, CA_G,
+ // h i j k l m n o
+ CA_H, CA_I, CA_J, CA_K, CA_L, CA_M, CA_N, CA_O,
+ // p q r s t u v w
+ CA_P, CA_Q, CA_R, CA_S, CA_T, CA_U, CA_V, CA_W,
+ // x y z { | } ~ DEL
+ CA_X, CA_Y, CA_Z, CA_7, CA_SLSH, CA_8, CA_CCED, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_colemak.h b/quantum/keymap_extras/sendstring_colemak.h
index 8564ec1dea..3aef96b24a 100644
--- a/quantum/keymap_extras/sendstring_colemak.h
+++ b/quantum/keymap_extras/sendstring_colemak.h
@@ -20,15 +20,17 @@
#include "keymap_colemak.h"
+// 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
KC_SPC, CM_1, CM_QUOT, CM_3, CM_4, CM_5, CM_7, CM_QUOT,
@@ -41,17 +43,17 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
// @ A B C D E F G
CM_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,
+ 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,
+ 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, CM_LBRC, CM_BSLS, CM_RBRC, CM_6, CM_MINS,
// ` a b c d e f g
CM_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,
+ 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,
+ 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, CM_LBRC, CM_BSLS, CM_RBRC, CM_GRV, KC_DEL
};
diff --git a/quantum/keymap_extras/sendstring_croatian.h b/quantum/keymap_extras/sendstring_croatian.h
new file mode 100644
index 0000000000..67f75992ae
--- /dev/null
+++ b/quantum/keymap_extras/sendstring_croatian.h
@@ -0,0 +1,100 @@
+/* Copyright 2020
+ *
+ * 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 Croatian layouts
+
+#pragma once
+
+#include "keymap_croatian.h"
+#include "quantum.h"
+
+// clang-format off
+
+const uint8_t ascii_to_shift_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 0),
+ KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 0, 1),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 1, 1, 0, 1, 1, 1),
+ KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 0, 1),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0)
+};
+
+const uint8_t ascii_to_altgr_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 1, 0),
+ KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(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, HR_1, HR_2, HR_3, HR_4, HR_5, HR_6, HR_QUOT,
+ // ( ) * + , - . /
+ HR_8, HR_9, HR_PLUS, HR_PLUS, HR_COMM, HR_MINS, HR_DOT, HR_7,
+ // 0 1 2 3 4 5 6 7
+ HR_0, HR_1, HR_2, HR_3, HR_4, HR_5, HR_6, HR_7,
+ // 8 9 : ; < = > ?
+ HR_8, HR_9, HR_DOT, HR_COMM, HR_LABK, HR_0, HR_LABK, HR_QUOT,
+ // @ A B C D E F G
+ HR_V, HR_A, HR_B, HR_C, HR_D, HR_E, HR_F, HR_G,
+ // H I J K L M N O
+ HR_H, HR_I, HR_J, HR_K, HR_L, HR_M, HR_N, HR_O,
+ // P Q R S T U V W
+ HR_P, HR_Q, HR_R, HR_S, HR_T, HR_U, HR_V, HR_W,
+ // X Y Z [ \ ] ^ _
+ HR_X, HR_Y, HR_Z, HR_F, HR_Q, HR_G, HR_3, HR_MINS,
+ // ` a b c d e f g
+ HR_7, HR_A, HR_B, HR_C, HR_D, HR_E, HR_F, HR_G,
+ // h i j k l m n o
+ HR_H, HR_I, HR_J, HR_K, HR_L, HR_M, HR_N, HR_O,
+ // p q r s t u v w
+ HR_P, HR_Q, HR_R, HR_S, HR_T, HR_U, HR_V, HR_W,
+ // x y z { | } ~ DEL
+ HR_X, HR_Y, HR_Z, HR_B, HR_W, HR_N, HR_1, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_dvorak.h b/quantum/keymap_extras/sendstring_dvorak.h
index 3ddb00b112..9bad0dc13a 100644
--- a/quantum/keymap_extras/sendstring_dvorak.h
+++ b/quantum/keymap_extras/sendstring_dvorak.h
@@ -20,10 +20,16 @@
#include "keymap_dvorak.h"
+<<<<<<< HEAD
+=======
+// clang-format off
+
+>>>>>>> 0.12.52~1
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
+<<<<<<< HEAD
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,
@@ -54,3 +60,36 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
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};
+=======
+ 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
+};
+>>>>>>> 0.12.52~1
diff --git a/quantum/keymap_extras/sendstring_french.h b/quantum/keymap_extras/sendstring_french.h
index 9b7f5e8ed7..ab65f28eb7 100644
--- a/quantum/keymap_extras/sendstring_french.h
+++ b/quantum/keymap_extras/sendstring_french.h
@@ -21,6 +21,8 @@
#include "keymap_french.h"
#include "quantum.h"
+// clang-format off
+
const uint8_t ascii_to_shift_lut[16] PROGMEM = {
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
@@ -65,20 +67,20 @@ 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
- KC_SPC, FR_EXLM, FR_QUOT, FR_DQUO, FR_DLR, FR_UGRV, FR_AMPR, FR_QUOT,
+ KC_SPC, FR_EXLM, FR_DQUO, FR_DQUO, FR_DLR, FR_UGRV, FR_AMPR, FR_QUOT,
// ( ) * + , - . /
- FR_LPRN, FR_RPRN, FR_ASTR, FR_EQL, FR_COMM, FR_MINS, FR_SCLN, FR_COLN,
+ 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_AMPR, FR_EACU, FR_DQUO, FR_QUOT, FR_LPRN, FR_MINS, FR_EGRV,
// 8 9 : ; < = > ?
- FR_CCED, FR_AGRV, FR_COLN, FR_SCLN, FR_LABK, FR_EQL, FR_LABK, FR_COMM,
+ FR_UNDS, FR_CCED, FR_COLN, FR_SCLN, FR_LABK, FR_EQL, FR_LABK, FR_COMM,
// @ A B C D E F G
FR_AGRV, FR_A, FR_B, FR_C, FR_D, FR_E, FR_F, FR_G,
// H I J K L M N O
diff --git a/quantum/keymap_extras/sendstring_french_afnor.h b/quantum/keymap_extras/sendstring_french_afnor.h
new file mode 100644
index 0000000000..690daaaf02
--- /dev/null
+++ b/quantum/keymap_extras/sendstring_french_afnor.h
@@ -0,0 +1,100 @@
+/* Copyright 2020 Guillaume Gérard
+ *
+ * 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 - AFNOR NF Z71-300) layouts
+
+#pragma once
+
+#include "keymap_french_afnor.h"
+#include "quantum.h"
+
+// clang-format off
+
+const uint8_t ascii_to_shift_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 1, 1, 1, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 0, 0, 0, 1, 1, 1),
+ KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 0, 1, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0)
+};
+
+const uint8_t ascii_to_altgr_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 0, 0, 0, 1, 1, 1, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 1, 0, 1, 0, 1),
+ KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(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_COMM, FR_QUOT, FR_AT, FR_D, FR_P, FR_ECIR, FR_QUOT,
+ // ( ) * + , - . /
+ FR_LPRN, FR_RPRN, FR_ASTR, FR_PLUS, FR_COMM, FR_MINS, FR_DOT, FR_SLSH,
+ // 0 1 2 3 4 5 6 7
+ FR_RDAQ, FR_AGRV, FR_EACU, FR_EGRV, FR_ECIR, FR_LPRN, FR_RPRN, FR_LSQU,
+ // 8 9 : ; < = > ?
+ FR_RSQU, FR_LDAQ, FR_COLN, FR_SCLN, FR_LABK, FR_SCLN, FR_LABK, FR_DOT,
+ // @ A B C D E F G
+ FR_AT, FR_A, FR_B, FR_C, FR_D, FR_E, FR_F, FR_G,
+ // H I J K L M N O
+ FR_H, FR_I, FR_J, FR_K, FR_L, FR_M, FR_N, FR_O,
+ // P Q R S T U V W
+ FR_P, FR_Q, FR_R, FR_S, FR_T, FR_U, FR_V, FR_W,
+ // X Y Z [ \ ] ^ _
+ FR_X, FR_Y, FR_Z, FR_LPRN, FR_SLSH, FR_RPRN, FR_DCIR, FR_RSQU,
+ // ` a b c d e f g
+ FR_EGRV, FR_A, FR_B, FR_C, FR_D, FR_E, FR_F, FR_G,
+ // h i j k l m n o
+ FR_H, FR_I, FR_J, FR_K, FR_L, FR_M, FR_N, FR_O,
+ // p q r s t u v w
+ FR_P, FR_Q, FR_R, FR_S, FR_T, FR_U, FR_V, FR_W,
+ // x y z { | } ~ DEL
+ FR_X, FR_Y, FR_Z, FR_T, FR_L, FR_Y, FR_N, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_german.h b/quantum/keymap_extras/sendstring_german.h
index 639c22b3a7..3445a0e5fb 100644
--- a/quantum/keymap_extras/sendstring_german.h
+++ b/quantum/keymap_extras/sendstring_german.h
@@ -21,6 +21,8 @@
#include "keymap_german.h"
#include "quantum.h"
+// clang-format off
+
const uint8_t ascii_to_shift_lut[16] PROGMEM = {
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
@@ -65,34 +67,34 @@ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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_LABK, DE_0, DE_LABK, 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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_LABK, DE_0, DE_PLUS, KC_DEL
};
diff --git a/quantum/keymap_extras/sendstring_jis.h b/quantum/keymap_extras/sendstring_jis.h
index f9c574560b..58335ad41d 100644
--- a/quantum/keymap_extras/sendstring_jis.h
+++ b/quantum/keymap_extras/sendstring_jis.h
@@ -21,6 +21,8 @@
#include "keymap_jp.h"
#include "quantum.h"
+// clang-format off
+
const uint8_t ascii_to_shift_lut[16] PROGMEM = {
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
@@ -45,33 +47,34 @@ 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
- KC_SPC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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};
+ 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 e52afc2a6a..21dbbdd705 100644
--- a/quantum/keymap_extras/sendstring_norman.h
+++ b/quantum/keymap_extras/sendstring_norman.h
@@ -20,15 +20,17 @@
#include "keymap_norman.h"
+// 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
KC_SPC, NM_1, NM_QUOT, NM_3, NM_4, NM_5, NM_7, NM_QUOT,
@@ -41,17 +43,17 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
// @ A B C D E F G
NM_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,
+ 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,
+ 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, NM_LBRC, NM_BSLS, NM_RBRC, NM_6, NM_MINS,
// ` a b c d e f g
NM_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,
+ 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,
+ 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, NM_LBRC, NM_BSLS, NM_RBRC, NM_GRV, KC_DEL
};
diff --git a/quantum/keymap_extras/sendstring_spanish.h b/quantum/keymap_extras/sendstring_spanish.h
index 03c8fe7483..b984a6f463 100644
--- a/quantum/keymap_extras/sendstring_spanish.h
+++ b/quantum/keymap_extras/sendstring_spanish.h
@@ -21,6 +21,8 @@
#include "keymap_spanish.h"
#include "quantum.h"
+// clang-format off
+
const uint8_t ascii_to_shift_lut[16] PROGMEM = {
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
@@ -65,11 +67,11 @@ 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
KC_SPC, ES_1, ES_2, ES_3, ES_4, ES_5, ES_6, ES_QUOT,
diff --git a/quantum/keymap_extras/sendstring_uk.h b/quantum/keymap_extras/sendstring_uk.h
index 1319c8164d..bbd30769b0 100644
--- a/quantum/keymap_extras/sendstring_uk.h
+++ b/quantum/keymap_extras/sendstring_uk.h
@@ -21,6 +21,8 @@
#include "keymap_uk.h"
#include "quantum.h"
+// clang-format off
+
const uint8_t ascii_to_shift_lut[16] PROGMEM = {
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
@@ -45,33 +47,34 @@ 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
KC_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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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};
+ UK_X, UK_Y, UK_Z, UK_LBRC, UK_BSLS, UK_RBRC, UK_HASH, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_us_international.h b/quantum/keymap_extras/sendstring_us_international.h
new file mode 100644
index 0000000000..53a5891fb1
--- /dev/null
+++ b/quantum/keymap_extras/sendstring_us_international.h
@@ -0,0 +1,100 @@
+/* Copyright 2019 Rys Sommefeldt
+ *
+ * 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 UK layouts
+
+#pragma once
+
+#include "keymap_us_international.h"
+#include "quantum.h"
+
+// clang-format off
+
+const uint8_t ascii_to_shift_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 0),
+ KCLUT_ENTRY(1, 1, 1, 1, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 1, 0, 1, 0, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 1, 1),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 1, 0),
+};
+
+__attribute__((weak)) const uint8_t ascii_to_dead_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 0, 1, 0, 0, 0, 0, 1),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 1, 0),
+ KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 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, US_1, US_ACUT, US_3, US_4, US_5, US_7, US_ACUT,
+ // ( ) * + , - . /
+ US_9, US_0, US_8, US_EQL, US_COMM, US_MINS, US_DOT, US_SLSH,
+ // 0 1 2 3 4 5 6 7
+ US_0, US_1, US_2, US_3, US_4, US_5, US_6, US_7,
+ // 8 9 : ; < = > ?
+ US_8, US_9, US_SCLN, US_SCLN, US_COMM, US_EQL, US_DOT, US_SLSH,
+ // @ A B C D E F G
+ US_2, US_A, US_B, US_C, US_D, US_E, US_F, US_G,
+ // H I J K L M N O
+ US_H, US_I, US_J, US_K, US_L, US_M, US_N, US_O,
+ // P Q R S T U V W
+ US_P, US_Q, US_R, US_S, US_T, US_U, US_V, US_W,
+ // X Y Z [ \ ] ^ _
+ US_X, US_Y, US_Z, US_LBRC, US_BSLS, US_RBRC, US_6, US_MINS,
+ // ` a b c d e f g
+ US_DGRV, US_A, US_B, US_C, US_D, US_E, US_F, US_G,
+ // h i j k l m n o
+ US_H, US_I, US_J, US_K, US_L, US_M, US_N, US_O,
+ // p q r s t u v w
+ US_P, US_Q, US_R, US_S, US_T, US_U, US_V, US_W,
+ // x y z { | } ~ DEL
+ US_X, US_Y, US_Z, US_LBRC, US_BSLS, US_RBRC, US_DGRV, KC_DEL
+};
diff --git a/quantum/keymap_extras/sendstring_workman.h b/quantum/keymap_extras/sendstring_workman.h
index 6e7f17b965..04f8e3908a 100644
--- a/quantum/keymap_extras/sendstring_workman.h
+++ b/quantum/keymap_extras/sendstring_workman.h
@@ -20,15 +20,17 @@
#include "keymap_workman.h"
+// 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,
+ 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,
+ XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
// ! " # $ % & '
KC_SPC, WK_1, WK_QUOT, WK_3, WK_4, WK_5, WK_7, WK_QUOT,
@@ -41,17 +43,17 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
// @ A B C D E F G
WK_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,
+ 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,
+ 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, WK_LBRC, WK_BSLS, WK_RBRC, WK_6, WK_MINS,
// ` a b c d e f g
WK_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,
+ 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,
+ 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, WK_LBRC, WK_BSLS, WK_RBRC, WK_GRV, KC_DEL
};
diff --git a/tmk_core/common/led.h b/quantum/led.h
index f9b2229c36..0fe38ea035 100644
--- a/tmk_core/common/led.h
+++ b/quantum/led.h
@@ -36,11 +36,11 @@ extern "C" {
typedef union {
uint8_t raw;
struct {
- bool num_lock : 1;
- bool caps_lock : 1;
- bool scroll_lock : 1;
- bool compose : 1;
- bool kana : 1;
+ bool num_lock : 1;
+ bool caps_lock : 1;
+ bool scroll_lock : 1;
+ bool compose : 1;
+ bool kana : 1;
uint8_t reserved : 3;
};
} led_t;
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index eb523990a6..4f1f06c7ac 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -27,7 +27,7 @@
#include <string.h>
#include <math.h>
-led_config_t led_matrix_config;
+led_eeconfig_t led_matrix_eeconfig;
#ifndef MAX
# define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
@@ -59,7 +59,7 @@ bool g_suspend_state = false;
uint32_t g_tick = 0;
// Ticks since this key was last hit.
-uint8_t g_key_hit[LED_DRIVER_LED_COUNT];
+uint8_t g_key_hit[DRIVER_LED_TOTAL];
// Ticks since any key was last hit.
uint32_t g_any_key_hit = 0;
@@ -70,40 +70,32 @@ void eeconfig_update_led_matrix(uint32_t config_value) { eeprom_update_dword(EEC
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);
+ led_matrix_eeconfig.enable = 1;
+ led_matrix_eeconfig.mode = LED_MATRIX_UNIFORM_BRIGHTNESS;
+ led_matrix_eeconfig.val = 128;
+ led_matrix_eeconfig.speed = 0;
+ eeconfig_update_led_matrix(led_matrix_eeconfig.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_eeconfig eeprom\n");
+ dprintf("led_matrix_eeconfig.enable = %d\n", led_matrix_eeconfig.enable);
+ dprintf("led_matrix_eeconfig.mode = %d\n", led_matrix_eeconfig.mode);
+ dprintf("led_matrix_eeconfig.val = %d\n", led_matrix_eeconfig.val);
+ dprintf("led_matrix_eeconfig.speed = %d\n", led_matrix_eeconfig.speed);
}
-// Last led hit
-#ifndef LED_HITS_TO_REMEMBER
-# 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;
-void map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i, uint8_t *led_count) {
- led_matrix led;
- *led_count = 0;
-
- for (uint8_t i = 0; i < LED_DRIVER_LED_COUNT; i++) {
- // map_index_to_led(i, &led);
- led = g_leds[i];
- if (row == led.matrix_co.row && column == led.matrix_co.col) {
- led_i[*led_count] = i;
- (*led_count)++;
- }
+uint8_t map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
+ uint8_t led_count = 0;
+ 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 led_matrix_update_pwm_buffers(void) { led_matrix_driver.flush(); }
@@ -114,8 +106,8 @@ void led_matrix_set_index_value_all(uint8_t value) { led_matrix_driver.set_value
bool process_led_matrix(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
- uint8_t led[8], led_count;
- map_row_column_to_led(record->event.key.row, record->event.key.col, led, &led_count);
+ uint8_t led[8];
+ uint8_t led_count = map_row_column_to_led(record->event.key.row, record->event.key.col, led);
if (led_count > 0) {
for (uint8_t i = LED_HITS_TO_REMEMBER; i > 1; i--) {
g_last_led_hit[i - 1] = g_last_led_hit[i - 2];
@@ -127,8 +119,8 @@ bool process_led_matrix(uint16_t keycode, keyrecord_t *record) {
g_any_key_hit = 0;
} else {
#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);
+ uint8_t led[8];
+ uint8_t led_count = map_row_column_to_led(record->event.key.row, record->event.key.col, led);
for (uint8_t i = 0; i < led_count; i++) g_key_hit[led[i]] = 255;
g_any_key_hit = 255;
@@ -143,12 +135,12 @@ void led_matrix_set_suspend_state(bool state) { g_suspend_state = state; }
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_eeconfig.val); }
void led_matrix_custom(void) {}
void led_matrix_task(void) {
- if (!led_matrix_config.enable) {
+ if (!led_matrix_eeconfig.enable) {
led_matrix_all_off();
led_matrix_indicators();
return;
@@ -160,7 +152,7 @@ void led_matrix_task(void) {
g_any_key_hit++;
}
- for (int led = 0; led < LED_DRIVER_LED_COUNT; led++) {
+ for (int led = 0; led < DRIVER_LED_TOTAL; led++) {
if (g_key_hit[led] < 255) {
if (g_key_hit[led] == 254) g_last_led_count = MAX(g_last_led_count - 1, 0);
g_key_hit[led]++;
@@ -170,7 +162,7 @@ void led_matrix_task(void) {
// 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;
+ uint8_t effect = suspend_backlight ? 0 : led_matrix_eeconfig.mode;
// this gets ticked at 20 Hz.
// each effect can opt to do calculations
@@ -211,8 +203,8 @@ __attribute__((weak)) void led_matrix_indicators_user(void) {}
// else
// {
// // This needs updated to something like
-// // uint8_t led[8], led_count;
-// // map_row_column_to_led(row,column,led,&led_count);
+// // uint8_t led[8];
+// // uint8_t led_count = map_row_column_to_led(row, column, led);
// // for(uint8_t i = 0; i < led_count; i++)
// map_row_column_to_led(row, column, index);
// }
@@ -225,7 +217,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 < DRIVER_LED_TOTAL; led++) {
g_key_hit[led] = 255;
}
@@ -235,12 +227,12 @@ void led_matrix_init(void) {
eeconfig_update_led_matrix_default();
}
- led_matrix_config.raw = eeconfig_read_led_matrix();
+ led_matrix_eeconfig.raw = eeconfig_read_led_matrix();
- if (!led_matrix_config.mode) {
- dprintf("led_matrix_init_drivers led_matrix_config.mode = 0. Write default values to EEPROM.\n");
+ if (!led_matrix_eeconfig.mode) {
+ dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n");
eeconfig_update_led_matrix_default();
- led_matrix_config.raw = eeconfig_read_led_matrix();
+ led_matrix_eeconfig.raw = eeconfig_read_led_matrix();
}
eeconfig_debug_led_matrix(); // display current eeprom values
@@ -270,10 +262,10 @@ static uint8_t decrement(uint8_t value, uint8_t step, uint8_t min, uint8_t max)
// }
// void backlight_set_key_value(uint8_t row, uint8_t column, uint8_t value) {
-// uint8_t led[8], led_count;
-// map_row_column_to_led(row,column,led,&led_count);
+// uint8_t led[8];
+// uint8_t led_count = map_row_column_to_led(row, column, led);
// for(uint8_t i = 0; i < led_count; i++) {
-// if (led[i] < LED_DRIVER_LED_COUNT) {
+// if (led[i] < DRIVER_LED_TOTAL) {
// void *address = backlight_get_custom_key_value_eeprom_address(led[i]);
// eeprom_update_byte(address, value);
// }
@@ -283,74 +275,74 @@ 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; }
void led_matrix_toggle(void) {
- led_matrix_config.enable ^= 1;
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ led_matrix_eeconfig.enable ^= 1;
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
void led_matrix_enable(void) {
- led_matrix_config.enable = 1;
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ led_matrix_eeconfig.enable = 1;
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
-void led_matrix_enable_noeeprom(void) { led_matrix_config.enable = 1; }
+void led_matrix_enable_noeeprom(void) { led_matrix_eeconfig.enable = 1; }
void led_matrix_disable(void) {
- led_matrix_config.enable = 0;
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ led_matrix_eeconfig.enable = 0;
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
-void led_matrix_disable_noeeprom(void) { led_matrix_config.enable = 0; }
+void led_matrix_disable_noeeprom(void) { led_matrix_eeconfig.enable = 0; }
void led_matrix_step(void) {
- led_matrix_config.mode++;
- if (led_matrix_config.mode >= LED_MATRIX_EFFECT_MAX) {
- led_matrix_config.mode = 1;
+ led_matrix_eeconfig.mode++;
+ if (led_matrix_eeconfig.mode >= LED_MATRIX_EFFECT_MAX) {
+ led_matrix_eeconfig.mode = 1;
}
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
void led_matrix_step_reverse(void) {
- led_matrix_config.mode--;
- if (led_matrix_config.mode < 1) {
- led_matrix_config.mode = LED_MATRIX_EFFECT_MAX - 1;
+ led_matrix_eeconfig.mode--;
+ if (led_matrix_eeconfig.mode < 1) {
+ led_matrix_eeconfig.mode = LED_MATRIX_EFFECT_MAX - 1;
}
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
void led_matrix_increase_val(void) {
- led_matrix_config.val = increment(led_matrix_config.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS);
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ led_matrix_eeconfig.val = increment(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
void led_matrix_decrease_val(void) {
- led_matrix_config.val = decrement(led_matrix_config.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS);
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ led_matrix_eeconfig.val = decrement(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
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
+ led_matrix_eeconfig.speed = increment(led_matrix_eeconfig.speed, 1, 0, 3);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.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
+ led_matrix_eeconfig.speed = decrement(led_matrix_eeconfig.speed, 1, 0, 3);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw); // EECONFIG needs to be increased to support this
}
void led_matrix_mode(uint8_t mode, bool eeprom_write) {
- led_matrix_config.mode = mode;
+ led_matrix_eeconfig.mode = mode;
if (eeprom_write) {
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
}
-uint8_t led_matrix_get_mode(void) { return led_matrix_config.mode; }
+uint8_t led_matrix_get_mode(void) { return led_matrix_eeconfig.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_eeconfig.val = val; }
void led_matrix_set_value(uint8_t val) {
led_matrix_set_value_noeeprom(val);
- eeconfig_update_led_matrix(led_matrix_config.raw);
+ eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
void backlight_set(uint8_t val) { led_matrix_set_value(val); }
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h
index 7dcdf1d482..85bae43c15 100644
--- a/quantum/led_matrix.h
+++ b/quantum/led_matrix.h
@@ -19,46 +19,12 @@
#pragma once
+#include "led_matrix_types.h"
+
#ifndef BACKLIGHT_ENABLE
# error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE
#endif
-typedef struct Point {
- 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;
-} __attribute__((packed)) led_matrix;
-
-extern const led_matrix g_leds[LED_DRIVER_LED_COUNT];
-
-typedef struct {
- 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
- };
-} led_config_t;
-
enum led_matrix_effects {
LED_MATRIX_UNIFORM_BRIGHTNESS = 1,
// All new effects go above this line
@@ -122,3 +88,7 @@ typedef struct {
} led_matrix_driver_t;
extern const led_matrix_driver_t led_matrix_driver;
+
+extern led_eeconfig_t led_matrix_eeconfig;
+
+extern led_config_t g_led_config;
diff --git a/quantum/led_matrix_drivers.c b/quantum/led_matrix_drivers.c
index 9decaa33c2..eddf3f2863 100644
--- a/quantum/led_matrix_drivers.c
+++ b/quantum/led_matrix_drivers.c
@@ -66,7 +66,7 @@ static void init(void) {
# endif
# endif
- for (int index = 0; index < LED_DRIVER_LED_COUNT; index++) {
+ for (int index = 0; index < DRIVER_LED_TOTAL; index++) {
# ifdef IS31FL3731
IS31FL3731_set_led_control_register(index, true);
# else
diff --git a/quantum/led_matrix_types.h b/quantum/led_matrix_types.h
new file mode 100644
index 0000000000..669b67042b
--- /dev/null
+++ b/quantum/led_matrix_types.h
@@ -0,0 +1,69 @@
+/* Copyright 2021
+ *
+ * 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>
+
+#if defined(__GNUC__)
+# define PACKED __attribute__((__packed__))
+#else
+# define PACKED
+#endif
+
+#if defined(_MSC_VER)
+# pragma pack(push, 1)
+#endif
+
+// Last led hit
+#ifndef LED_HITS_TO_REMEMBER
+# define LED_HITS_TO_REMEMBER 8
+#endif // LED_HITS_TO_REMEMBER
+
+typedef struct PACKED {
+ uint8_t x;
+ uint8_t y;
+} point_t;
+
+#define LED_FLAG_ALL 0xFF
+#define LED_FLAG_NONE 0x00
+#define LED_FLAG_MODIFIER 0x01
+#define LED_FLAG_KEYLIGHT 0x04
+#define LED_FLAG_INDICATOR 0x08
+
+#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];
+} led_config_t;
+
+typedef union {
+ uint32_t raw;
+ struct PACKED {
+ uint8_t enable : 2;
+ uint8_t mode : 6;
+ uint16_t reserved;
+ uint8_t val;
+ uint8_t speed; // EECONFIG needs to be increased to support this
+ };
+} led_eeconfig_t;
+
+#if defined(_MSC_VER)
+# pragma pack(pop)
+#endif
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 9083ff3861..c027b7bf27 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -101,9 +101,9 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Start with a clear matrix row
matrix_row_t current_row_value = 0;
- // Select row and wait for row selecton to stabilize
+ // Select row
select_row(current_row);
- matrix_io_delay();
+ matrix_output_select_delay();
// For each col...
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
@@ -116,6 +116,9 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Unselect row
unselect_row(current_row);
+ if (current_row + 1 < MATRIX_ROWS) {
+ matrix_output_unselect_delay(); // wait for row signal to go HIGH
+ }
// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
@@ -147,9 +150,9 @@ static void init_pins(void) {
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
select_col(current_col);
- matrix_io_delay();
+ matrix_output_select_delay();
// For each row...
for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
@@ -175,6 +178,9 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
// Unselect col
unselect_col(current_col);
+ if (current_col + 1 < MATRIX_COLS) {
+ matrix_output_unselect_delay(); // wait for col signal to go HIGH
+ }
return matrix_changed;
}
diff --git a/tmk_core/common/matrix.h b/quantum/matrix.h
index b570227a31..ce57010a47 100644
--- a/tmk_core/common/matrix.h
+++ b/quantum/matrix.h
@@ -55,6 +55,9 @@ matrix_row_t matrix_get_row(uint8_t row);
/* print matrix for debug */
void matrix_print(void);
/* delay between changing matrix pin state and reading values */
+void matrix_output_select_delay(void);
+void matrix_output_unselect_delay(void);
+/* only for backwards compatibility. delay between changing matrix pin state and reading values */
void matrix_io_delay(void);
/* power control */
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c
index 15f1e0e82e..efbad6a5fd 100644
--- a/quantum/matrix_common.c
+++ b/quantum/matrix_common.c
@@ -1,3 +1,4 @@
+#include "quantum.h"
#include "matrix.h"
#include "debounce.h"
#include "wait.h"
@@ -68,7 +69,7 @@ void matrix_print(void) {
print_matrix_header();
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- phex(row);
+ print_hex8(row);
print(": ");
print_matrix_row(row);
print("\n");
@@ -83,8 +84,12 @@ uint8_t matrix_key_count(void) {
return count;
}
+/* `matrix_io_delay ()` exists for backwards compatibility. From now on, use matrix_output_unselect_delay(). */
__attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); }
+__attribute__((weak)) void matrix_output_select_delay(void) { waitInputPinDelay(); }
+__attribute__((weak)) void matrix_output_unselect_delay(void) { matrix_io_delay(); }
+
// CUSTOM MATRIX 'LITE'
__attribute__((weak)) void matrix_init_custom(void) {}
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk
index ea88d9ab9e..f7329fc4d9 100644
--- a/quantum/mcu_selection.mk
+++ b/quantum/mcu_selection.mk
@@ -16,7 +16,6 @@ ifneq ($(findstring MKL26Z64, $(MCU)),)
# Linker script to use
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
# or <keyboard_dir>/ld/
- # - NOTE: a custom ld script is needed for EEPROM on Teensy LC
MCU_LDSCRIPT ?= MKL26Z64
# Startup code to use
@@ -280,7 +279,73 @@ ifneq ($(findstring STM32F411, $(MCU)),)
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
endif
-ifneq (,$(filter $(MCU),atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb1286))
+ifneq ($(findstring STM32G431, $(MCU)),)
+ # Cortex version
+ MCU = cortex-m4
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV = 7
+
+ ## chip/board settings
+ # - the next two should match the directories in
+ # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = STM32
+ MCU_SERIES = STM32G4xx
+
+ # Linker script to use
+ # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or <keyboard_dir>/ld/
+ MCU_LDSCRIPT ?= STM32G431xB
+
+ # Startup code to use
+ # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= stm32g4xx
+
+ # Board: it should exist either in <chibios>/os/hal/boards/,
+ # <keyboard_dir>/boards/, or drivers/boards/
+ BOARD ?= GENERIC_STM32_G431XB
+
+ USE_FPU ?= yes
+
+ # Options to pass to dfu-util when flashing
+ DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
+ DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+endif
+
+ifneq ($(findstring STM32G474, $(MCU)),)
+ # Cortex version
+ MCU = cortex-m4
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV = 7
+
+ ## chip/board settings
+ # - the next two should match the directories in
+ # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = STM32
+ MCU_SERIES = STM32G4xx
+
+ # Linker script to use
+ # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or <keyboard_dir>/ld/
+ MCU_LDSCRIPT ?= STM32G474xE
+
+ # Startup code to use
+ # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= stm32g4xx
+
+ # Board: it should exist either in <chibios>/os/hal/boards/,
+ # <keyboard_dir>/boards/, or drivers/boards/
+ BOARD ?= GENERIC_STM32_G474XE
+
+ USE_FPU ?= yes
+
+ # Options to pass to dfu-util when flashing
+ DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
+ DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+endif
+
+ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287))
PROTOCOL = LUFA
# Processor frequency.
@@ -318,12 +383,15 @@ ifneq (,$(filter $(MCU),atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 a
ifeq (,$(filter $(NO_INTERRUPT_CONTROL_ENDPOINT),yes))
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
endif
- ifneq (,$(filter $(MCU),atmega16u2 atmega32u2))
+ ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2))
NO_I2C = yes
endif
endif
ifneq (,$(filter $(MCU),atmega32a))
+ # MCU name for avrdude
+ AVRDUDE_MCU = m32
+
PROTOCOL = VUSB
# Processor frequency.
@@ -332,15 +400,12 @@ ifneq (,$(filter $(MCU),atmega32a))
# 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_SUSPEND_POWER_DOWN ?= yes
-
- # Programming options
- PROGRAM_CMD ?= ./util/atmega32a_program.py $(TARGET).hex
endif
ifneq (,$(filter $(MCU),atmega328p))
+ # MCU name for avrdude
+ AVRDUDE_MCU = m328p
+
PROTOCOL = VUSB
# Processor frequency.
@@ -349,9 +414,6 @@ ifneq (,$(filter $(MCU),atmega328p))
# 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_SUSPEND_POWER_DOWN ?= yes
endif
ifneq (,$(filter $(MCU),atmega328))
@@ -366,10 +428,6 @@ ifneq (,$(filter $(MCU),atmega328))
# 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
ifneq (,$(filter $(MCU),attiny85))
@@ -381,7 +439,4 @@ ifneq (,$(filter $(MCU),attiny85))
# 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 ?= 16500000
-
- # unsupported features for now
- NO_SUSPEND_POWER_DOWN ?= yes
endif
diff --git a/tmk_core/common/mousekey.c b/quantum/mousekey.c
index ef18bcf1a8..99bfd6b96f 100644
--- a/tmk_core/common/mousekey.c
+++ b/quantum/mousekey.c
@@ -36,6 +36,9 @@ static void mousekey_debug(void);
static uint8_t mousekey_accel = 0;
static uint8_t mousekey_repeat = 0;
static uint8_t mousekey_wheel_repeat = 0;
+#ifdef MK_KINETIC_SPEED
+static uint16_t mouse_timer = 0;
+#endif
#ifndef MK_3_SPEED
@@ -43,7 +46,7 @@ static uint16_t last_timer_c = 0;
static uint16_t last_timer_w = 0;
/*
- * Mouse keys acceleration algorithm
+ * Mouse keys acceleration algorithm
* http://en.wikipedia.org/wiki/Mouse_keys
*
* speed = delta * max_speed * (repeat / time_to_max)**((1000+curve)/1000)
@@ -105,6 +108,65 @@ static uint8_t wheel_unit(void) {
}
# else /* #ifndef MK_COMBINED */
+# ifdef MK_KINETIC_SPEED
+
+/*
+ * Kinetic movement acceleration algorithm
+ *
+ * current speed = I + A * T/50 + A * 0.5 * T^2 | maximum B
+ *
+ * T: time since the mouse movement started
+ * E: mouse events per second (set through MOUSEKEY_INTERVAL, UHK sends 250, the
+ * pro micro on my Signum 3.0 sends only 125!)
+ * I: initial speed at time 0
+ * A: acceleration
+ * B: base mouse travel speed
+ */
+const uint16_t mk_accelerated_speed = MOUSEKEY_ACCELERATED_SPEED;
+const uint16_t mk_base_speed = MOUSEKEY_BASE_SPEED;
+const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED;
+const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED;
+
+static uint8_t move_unit(void) {
+ float speed = mk_initial_speed;
+
+ if (mousekey_accel & ((1 << 0) | (1 << 2))) {
+ speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed;
+ } else if (mousekey_repeat && mouse_timer) {
+ const float time_elapsed = timer_elapsed(mouse_timer) / 50;
+ speed = mk_initial_speed + MOUSEKEY_MOVE_DELTA * time_elapsed + MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
+
+ speed = speed > mk_base_speed ? mk_base_speed : speed;
+ }
+
+ /* convert speed to USB mouse speed 1 to 127 */
+ speed = (uint8_t)(speed / (1000.0f / mk_interval));
+ speed = speed < 1 ? 1 : speed;
+
+ return speed > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : speed;
+}
+
+float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
+
+static uint8_t wheel_unit(void) {
+ float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
+
+ if (mousekey_accel & ((1 << 0) | (1 << 2))) {
+ speed = mousekey_accel & (1 << 2) ? MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS : MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS;
+ } else if (mousekey_repeat && mouse_timer) {
+ if (mk_wheel_interval != MOUSEKEY_WHEEL_BASE_MOVEMENTS) {
+ const float time_elapsed = timer_elapsed(mouse_timer) / 50;
+ speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + 1 * time_elapsed + 1 * 0.5 * time_elapsed * time_elapsed;
+ }
+ speed = speed > MOUSEKEY_WHEEL_BASE_MOVEMENTS ? MOUSEKEY_WHEEL_BASE_MOVEMENTS : speed;
+ }
+
+ mk_wheel_interval = 1000.0f / speed;
+
+ return 1;
+}
+
+# else /* #ifndef MK_KINETIC_SPEED */
static uint8_t move_unit(void) {
uint16_t unit;
@@ -142,7 +204,8 @@ static uint8_t wheel_unit(void) {
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
}
-# endif /* #ifndef MK_COMBINED */
+# endif /* #ifndef MK_KINETIC_SPEED */
+# endif /* #ifndef MK_COMBINED */
void mousekey_task(void) {
// report cursor and scroll movement independently
@@ -193,6 +256,12 @@ void mousekey_task(void) {
}
void mousekey_on(uint8_t code) {
+# ifdef MK_KINETIC_SPEED
+ if (mouse_timer == 0) {
+ mouse_timer = timer_read();
+ }
+# endif /* #ifdef MK_KINETIC_SPEED */
+
if (code == KC_MS_UP)
mouse_report.y = move_unit() * -1;
else if (code == KC_MS_DOWN)
@@ -209,16 +278,8 @@ void mousekey_on(uint8_t code) {
mouse_report.h = wheel_unit() * -1;
else if (code == KC_MS_WH_RIGHT)
mouse_report.h = wheel_unit();
- else if (code == KC_MS_BTN1)
- mouse_report.buttons |= MOUSE_BTN1;
- else if (code == KC_MS_BTN2)
- mouse_report.buttons |= MOUSE_BTN2;
- else if (code == KC_MS_BTN3)
- mouse_report.buttons |= MOUSE_BTN3;
- else if (code == KC_MS_BTN4)
- mouse_report.buttons |= MOUSE_BTN4;
- else if (code == KC_MS_BTN5)
- mouse_report.buttons |= MOUSE_BTN5;
+ else if (IS_MOUSEKEY_BUTTON(code))
+ mouse_report.buttons |= 1 << (code - KC_MS_BTN1);
else if (code == KC_MS_ACCEL0)
mousekey_accel |= (1 << 0);
else if (code == KC_MS_ACCEL1)
@@ -244,23 +305,20 @@ void mousekey_off(uint8_t code) {
mouse_report.h = 0;
else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0)
mouse_report.h = 0;
- else if (code == KC_MS_BTN1)
- mouse_report.buttons &= ~MOUSE_BTN1;
- else if (code == KC_MS_BTN2)
- mouse_report.buttons &= ~MOUSE_BTN2;
- else if (code == KC_MS_BTN3)
- mouse_report.buttons &= ~MOUSE_BTN3;
- else if (code == KC_MS_BTN4)
- mouse_report.buttons &= ~MOUSE_BTN4;
- else if (code == KC_MS_BTN5)
- mouse_report.buttons &= ~MOUSE_BTN5;
+ else if (IS_MOUSEKEY_BUTTON(code))
+ mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1));
else if (code == KC_MS_ACCEL0)
mousekey_accel &= ~(1 << 0);
else if (code == KC_MS_ACCEL1)
mousekey_accel &= ~(1 << 1);
else if (code == KC_MS_ACCEL2)
mousekey_accel &= ~(1 << 2);
- if (mouse_report.x == 0 && mouse_report.y == 0) mousekey_repeat = 0;
+ if (mouse_report.x == 0 && mouse_report.y == 0) {
+ mousekey_repeat = 0;
+# ifdef MK_KINETIC_SPEED
+ mouse_timer = 0;
+# endif /* #ifdef MK_KINETIC_SPEED */
+ }
if (mouse_report.v == 0 && mouse_report.h == 0) mousekey_wheel_repeat = 0;
}
@@ -349,16 +407,8 @@ void mousekey_on(uint8_t code) {
mouse_report.h = w_offset * -1;
else if (code == KC_MS_WH_RIGHT)
mouse_report.h = w_offset;
- else if (code == KC_MS_BTN1)
- mouse_report.buttons |= MOUSE_BTN1;
- else if (code == KC_MS_BTN2)
- mouse_report.buttons |= MOUSE_BTN2;
- else if (code == KC_MS_BTN3)
- mouse_report.buttons |= MOUSE_BTN3;
- else if (code == KC_MS_BTN4)
- mouse_report.buttons |= MOUSE_BTN4;
- else if (code == KC_MS_BTN5)
- mouse_report.buttons |= MOUSE_BTN5;
+ else if (IS_MOUSEKEY_BUTTON(code))
+ mouse_report.buttons |= 1 << (code - KC_MS_BTN1);
else if (code == KC_MS_ACCEL0)
mk_speed = mkspd_0;
else if (code == KC_MS_ACCEL1)
@@ -388,16 +438,8 @@ void mousekey_off(uint8_t code) {
mouse_report.h = 0;
else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0)
mouse_report.h = 0;
- else if (code == KC_MS_BTN1)
- mouse_report.buttons &= ~MOUSE_BTN1;
- else if (code == KC_MS_BTN2)
- mouse_report.buttons &= ~MOUSE_BTN2;
- else if (code == KC_MS_BTN3)
- mouse_report.buttons &= ~MOUSE_BTN3;
- else if (code == KC_MS_BTN4)
- mouse_report.buttons &= ~MOUSE_BTN4;
- else if (code == KC_MS_BTN5)
- mouse_report.buttons &= ~MOUSE_BTN5;
+ else if (IS_MOUSEKEY_BUTTON(code))
+ mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1));
# ifdef MK_MOMENTARY_ACCEL
else if (code == KC_MS_ACCEL0)
mk_speed = mkspd_DEFAULT;
@@ -429,7 +471,7 @@ void mousekey_clear(void) {
static void mousekey_debug(void) {
if (!debug_mouse) return;
print("mousekey [btn|x y v h](rep/acl): [");
- phex(mouse_report.buttons);
+ print_hex8(mouse_report.buttons);
print("|");
print_decs(mouse_report.x);
print(" ");
diff --git a/tmk_core/common/mousekey.h b/quantum/mousekey.h
index 300d262f5d..70dc4bb5c5 100644
--- a/tmk_core/common/mousekey.h
+++ b/quantum/mousekey.h
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-#include <stdbool.h>
+#include <stdint.h>
#include "host.h"
#ifndef MK_3_SPEED
@@ -36,16 +36,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# endif
# ifndef MOUSEKEY_MOVE_DELTA
-# define MOUSEKEY_MOVE_DELTA 5
+# ifndef MK_KINETIC_SPEED
+# define MOUSEKEY_MOVE_DELTA 5
+# else
+# define MOUSEKEY_MOVE_DELTA 25
+# endif
# endif
# ifndef MOUSEKEY_WHEEL_DELTA
# define MOUSEKEY_WHEEL_DELTA 1
# endif
# ifndef MOUSEKEY_DELAY
-# define MOUSEKEY_DELAY 300
+# ifndef MK_KINETIC_SPEED
+# define MOUSEKEY_DELAY 300
+# else
+# define MOUSEKEY_DELAY 8
+# endif
# endif
# ifndef MOUSEKEY_INTERVAL
-# define MOUSEKEY_INTERVAL 50
+# ifndef MK_KINETIC_SPEED
+# define MOUSEKEY_INTERVAL 50
+# else
+# define MOUSEKEY_INTERVAL 8
+# endif
# endif
# ifndef MOUSEKEY_MAX_SPEED
# define MOUSEKEY_MAX_SPEED 10
@@ -66,6 +78,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define MOUSEKEY_WHEEL_TIME_TO_MAX 40
# endif
+# ifndef MOUSEKEY_INITIAL_SPEED
+# define MOUSEKEY_INITIAL_SPEED 100
+# endif
+# ifndef MOUSEKEY_BASE_SPEED
+# define MOUSEKEY_BASE_SPEED 1000
+# endif
+# ifndef MOUSEKEY_DECELERATED_SPEED
+# define MOUSEKEY_DECELERATED_SPEED 400
+# endif
+# ifndef MOUSEKEY_ACCELERATED_SPEED
+# define MOUSEKEY_ACCELERATED_SPEED 3000
+# endif
+# ifndef MOUSEKEY_WHEEL_INITIAL_MOVEMENTS
+# define MOUSEKEY_WHEEL_INITIAL_MOVEMENTS 16
+# endif
+# ifndef MOUSEKEY_WHEEL_BASE_MOVEMENTS
+# define MOUSEKEY_WHEEL_BASE_MOVEMENTS 32
+# endif
+# ifndef MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS
+# define MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS 48
+# endif
+# ifndef MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS
+# define MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS 8
+# endif
+
#else /* #ifndef MK_3_SPEED */
# ifndef MK_C_OFFSET_UNMOD
diff --git a/quantum/pointing_device.c b/quantum/pointing_device.c
index 9b7629f307..09d889f697 100644
--- a/quantum/pointing_device.c
+++ b/quantum/pointing_device.c
@@ -25,18 +25,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static report_mouse_t mouseReport = {};
+__attribute__((weak)) bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old) { return (new.buttons != old.buttons) || (new.x&& new.x != old.x) || (new.y&& new.y != old.y) || (new.h&& new.h != old.h) || (new.v&& new.v != old.v); }
+
__attribute__((weak)) void pointing_device_init(void) {
// initialize device, if that needs to be done.
}
__attribute__((weak)) void pointing_device_send(void) {
+ static report_mouse_t old_report = {};
+
// If you need to do other things, like debugging, this is the place to do it.
- host_mouse_send(&mouseReport);
+ if (has_mouse_report_changed(mouseReport, old_report)) {
+ 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;
+ old_report = mouseReport;
}
__attribute__((weak)) void pointing_device_task(void) {
diff --git a/quantum/pointing_device.h b/quantum/pointing_device.h
index aa074bb37d..56a542d545 100644
--- a/quantum/pointing_device.h
+++ b/quantum/pointing_device.h
@@ -26,3 +26,4 @@ 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);
+bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old);
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 0f1257e396..f38d7d47a0 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -20,8 +20,8 @@
#ifndef COMBO_VARIABLE_LEN
__attribute__((weak)) combo_t key_combos[COMBO_COUNT] = {};
#else
-extern combo_t key_combos[];
-extern int COMBO_LEN;
+extern combo_t key_combos[];
+extern int COMBO_LEN;
#endif
__attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {}
@@ -146,7 +146,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
}
#ifndef COMBO_VARIABLE_LEN
for (current_combo_index = 0; current_combo_index < COMBO_COUNT; ++current_combo_index) {
-#else
+#else
for (current_combo_index = 0; current_combo_index < COMBO_LEN; ++current_combo_index) {
#endif
combo_t *combo = &key_combos[current_combo_index];
diff --git a/quantum/process_keycode/process_grave_esc.h b/quantum/process_keycode/process_grave_esc.h
index bbf4483763..bbf4483763 100644..100755
--- a/quantum/process_keycode/process_grave_esc.h
+++ b/quantum/process_keycode/process_grave_esc.h
diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c
index c70764dea1..44dd5f0579 100644
--- a/quantum/process_keycode/process_magic.c
+++ b/quantum/process_keycode/process_magic.c
@@ -42,7 +42,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
- case MAGIC_SWAP_LCTL_LGUI ... MAGIC_TOGGLE_CTL_GUI:
+ case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
switch (keycode) {
@@ -158,15 +158,14 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) {
clear_keyboard(); // clear first buffer to prevent stuck keys
keymap_config.nkro = !keymap_config.nkro;
break;
-#if 0
case MAGIC_EE_HANDS_LEFT:
eeconfig_update_handedness(true);
break;
case MAGIC_EE_HANDS_RIGHT:
eeconfig_update_handedness(false);
break;
-#endif
}
+
eeconfig_update_keymap(keymap_config.raw);
clear_keyboard(); // clear to prevent stuck keys
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index 8e2fb955e7..9632d2b757 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -34,7 +34,7 @@ void process_midi_all_notes_off(void) { midi_send_cc(&midi_device, 0, 0x7B, 0);
# include "timer.h"
-static uint8_t tone_status[MIDI_TONE_COUNT];
+static uint8_t tone_status[2][MIDI_TONE_COUNT];
static uint8_t midi_modulation;
static int8_t midi_modulation_step;
@@ -51,7 +51,8 @@ void midi_init(void) {
midi_config.modulation_interval = 8;
for (uint8_t i = 0; i < MIDI_TONE_COUNT; i++) {
- tone_status[i] = MIDI_INVALID_NOTE;
+ tone_status[0][i] = MIDI_INVALID_NOTE;
+ tone_status[1][i] = 0;
}
midi_modulation = 0;
@@ -68,19 +69,21 @@ bool process_midi(uint16_t keycode, keyrecord_t *record) {
uint8_t tone = keycode - MIDI_TONE_MIN;
uint8_t velocity = midi_config.velocity;
if (record->event.pressed) {
- if (tone_status[tone] == MIDI_INVALID_NOTE) {
- 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;
+ 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[1][tone] += 1;
+ if (tone_status[0][tone] == MIDI_INVALID_NOTE) {
+ tone_status[0][tone] = note;
}
} else {
- uint8_t note = tone_status[tone];
- if (note != MIDI_INVALID_NOTE) {
+ uint8_t note = tone_status[0][tone];
+ tone_status[1][tone] -= 1;
+ if (tone_status[1][tone] == 0) {
midi_send_noteoff(&midi_device, channel, note, velocity);
dprintf("midi noteoff channel:%d note:%d velocity:%d\n", channel, note, velocity);
+ tone_status[0][tone] = MIDI_INVALID_NOTE;
}
- tone_status[tone] = MIDI_INVALID_NOTE;
}
return false;
}
diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c
index db31011d98..5dd8e7809d 100644
--- a/quantum/process_keycode/process_rgb.c
+++ b/quantum/process_keycode/process_rgb.c
@@ -167,7 +167,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_RAINBOW:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_MOOD)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_MOOD)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT)
@@ -175,7 +175,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_SWIRL:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_SWIRL)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL)
handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end);
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_PINWHEEL)
@@ -183,27 +183,27 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
#endif
return false;
case RGB_MODE_SNAKE:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_SNAKE)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_SNAKE)
handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end);
#endif
return false;
case RGB_MODE_KNIGHT:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_KNIGHT)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_KNIGHT)
handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
#endif
return false;
case RGB_MODE_XMAS:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_CHRISTMAS)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_CHRISTMAS)
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
#endif
return false;
case RGB_MODE_GRADIENT:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_STATIC_GRADIENT)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_STATIC_GRADIENT)
handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end);
#endif
return false;
case RGB_MODE_RGBTEST:
-#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RGB_TEST)
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RGB_TEST)
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
#endif
return false;
diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c
index 138de0eba2..17dc540a64 100644
--- a/quantum/process_keycode/process_tap_dance.c
+++ b/quantum/process_keycode/process_tap_dance.c
@@ -117,6 +117,10 @@ void preprocess_tap_dance(uint16_t keycode, keyrecord_t *record) {
action->state.interrupting_keycode = keycode;
process_tap_dance_action_on_dance_finished(action);
reset_tap_dance(&action->state);
+
+ // Tap dance actions can leave some weak mods active (e.g., if the tap dance is mapped to a keycode with
+ // modifiers), but these weak mods should not affect the keypress which interrupted the tap dance.
+ clear_weak_mods();
}
}
}
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
index b04767ca65..a013c5cabf 100644
--- a/quantum/process_keycode/process_tap_dance.h
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -63,10 +63,10 @@ typedef struct {
{ .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, layer_move }), }
+ { .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_TOGGLE_LAYER(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_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_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer)
@@ -79,8 +79,6 @@ typedef struct {
# 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[];
/* To be used internally */
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index bac9fbcc0f..46fcaaa86b 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -158,7 +158,7 @@ __attribute__((weak)) void unicode_input_cancel(void) {
void register_hex(uint16_t hex) {
for (int i = 3; i >= 0; i--) {
uint8_t digit = ((hex >> (i * 4)) & 0xF);
- tap_code16(hex_to_keycode(digit));
+ send_nibble(digit);
}
}
@@ -171,10 +171,10 @@ void register_hex32(uint32_t hex) {
uint8_t digit = ((hex >> (i * 4)) & 0xF);
if (digit == 0) {
if (!onzerostart) {
- tap_code16(hex_to_keycode(digit));
+ send_nibble(digit);
}
} else {
- tap_code16(hex_to_keycode(digit));
+ send_nibble(digit);
onzerostart = false;
}
}
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 3c98e9c459..d5d97f3242 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -25,10 +25,6 @@
# include "backlight.h"
#endif
-#ifdef FAUXCLICKY_ENABLE
-# include "fauxclicky.h"
-#endif
-
#ifdef API_ENABLE
# include "api.h"
#endif
@@ -53,6 +49,9 @@ float goodbye_song[][2] = GOODBYE_SONG;
# ifdef DEFAULT_LAYER_SONGS
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
# endif
+# ifdef SENDSTRING_BELL
+float bell_song[][2] = SONG(TERMINAL_SOUND);
+# endif
#endif
#ifdef AUTO_SHIFT_ENABLE
@@ -146,7 +145,6 @@ void reset_keyboard(void) {
/* Convert record into usable keycode via the contained event. */
uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { return get_event_keycode(record->event, update_layer_cache); }
-
/* 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.
* "update_layer_cache" is to ensure that it only updates the layer cache when
@@ -222,9 +220,6 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef HAPTIC_ENABLE
process_haptic(keycode, record) &&
#endif // HAPTIC_ENABLE
-#if defined(RGB_MATRIX_ENABLE)
- process_rgb_matrix(keycode, record) &&
-#endif
#ifdef ORYX_ENABLE
process_record_oryx(keycode, record) &&
#endif
@@ -310,17 +305,6 @@ bool process_record_quantum(keyrecord_t *record) {
case EEPROM_RESET:
eeconfig_init();
return false;
-#ifdef FAUXCLICKY_ENABLE
- case FC_TOG:
- FAUXCLICKY_TOGGLE;
- return false;
- case FC_ON:
- FAUXCLICKY_ON;
- return false;
- case FC_OFF:
- FAUXCLICKY_OFF;
- return false;
-#endif
#ifdef VELOCIKEY_ENABLE
case VLK_TOG:
velocikey_toggle();
@@ -337,224 +321,11 @@ bool process_record_quantum(keyrecord_t *record) {
set_output(OUTPUT_BLUETOOTH);
return false;
#endif
-#if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING)
- case BL_BRTG:
- backlight_toggle_breathing();
- return false;
-#endif
-#ifdef WEBUSB_ENABLE
- case WEBUSB_PAIR:
- webusb_state.pairing ^= true;
- return false;
-#endif
- }
- }
-
- return process_action_kb(record);
-}
-
-// clang-format off
-
-/* Bit-Packed look-up table to convert an ASCII character to whether
- * [Shift] needs to be sent with the keycode.
- */
-__attribute__((weak)) const uint8_t ascii_to_shift_lut[16] PROGMEM = {
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
-
- KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 0),
- KCLUT_ENTRY(1, 1, 1, 1, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 1, 0, 1, 0, 1, 1),
- KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
- KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
- KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
- KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 1, 1),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 1, 0),
-};
-
-/* Bit-Packed look-up table to convert an ASCII character to whether
- * [AltGr] needs to be sent with the keycode.
- */
-__attribute__((weak)) const uint8_t ascii_to_altgr_lut[16] PROGMEM = {
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
-
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
- KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
-};
-
-/* Look-up table to convert an ASCII character to a keycode.
- */
-__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
-};
-
-// clang-format on
-
-// Note: we bit-pack in "reverse" order to optimize loading
-#define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01)
-
-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_QMK_PREFIX) {
- ascii_code = *(++str);
- if (ascii_code == SS_TAP_CODE) {
- // tap
- uint8_t keycode = *(++str);
- tap_code(keycode);
- } else if (ascii_code == SS_DOWN_CODE) {
- // down
- uint8_t keycode = *(++str);
- register_code(keycode);
- } else if (ascii_code == SS_UP_CODE) {
- // up
- uint8_t keycode = *(++str);
- unregister_code(keycode);
- } else if (ascii_code == SS_DELAY_CODE) {
- // delay
- int ms = 0;
- uint8_t keycode = *(++str);
- while (isdigit(keycode)) {
- ms *= 10;
- ms += keycode - '0';
- keycode = *(++str);
- }
- while (ms--) wait_ms(1);
- }
- } else {
- send_char(ascii_code);
- }
- ++str;
- // interval
- {
- uint8_t ms = interval;
- while (ms--) wait_ms(1);
}
}
-}
-
-void send_string_with_delay_P(const char *str, uint8_t interval) {
- while (1) {
- char ascii_code = pgm_read_byte(str);
- if (!ascii_code) break;
- if (ascii_code == SS_QMK_PREFIX) {
- ascii_code = pgm_read_byte(++str);
- if (ascii_code == SS_TAP_CODE) {
- // tap
- uint8_t keycode = pgm_read_byte(++str);
- tap_code(keycode);
- } else if (ascii_code == SS_DOWN_CODE) {
- // 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);
- } else if (ascii_code == SS_DELAY_CODE) {
- // delay
- int ms = 0;
- uint8_t keycode = pgm_read_byte(++str);
- while (isdigit(keycode)) {
- ms *= 10;
- ms += keycode - '0';
- keycode = pgm_read_byte(++str);
- }
- while (ms--) wait_ms(1);
- }
- } else {
- send_char(ascii_code);
- }
- ++str;
- // interval
- {
- uint8_t ms = interval;
- while (ms--) wait_ms(1);
- }
- }
-}
-
-void send_char(char ascii_code) {
-#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL)
- if (ascii_code == '\a') { // BEL
- PLAY_SONG(bell_song);
- return;
- }
-#endif
- uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
- bool is_shifted = PGM_LOADBIT(ascii_to_shift_lut, (uint8_t)ascii_code);
- bool is_altgred = PGM_LOADBIT(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);
- }
+ return process_action_kb(record);
}
void set_single_persistent_default_layer(uint8_t default_layer) {
@@ -573,34 +344,6 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_
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__)
- uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
-#else
- uint8_t key = rand() % 64;
-#endif
- switch (key) {
- case 0 ... 25:
- send_char(key + 'A');
- break;
- case 26 ... 51:
- send_char(key - 26 + 'a');
- break;
- case 52:
- send_char('0');
- break;
- case 53 ... 61:
- send_char(key - 53 + '1');
- break;
- case 62:
- send_char('+');
- break;
- case 63:
- send_char('/');
- break;
- }
-}
-
void matrix_init_quantum() {
#ifdef BOOTMAGIC_LITE
bootmagic_lite();
@@ -682,10 +425,6 @@ void matrix_scan_quantum() {
led_matrix_task();
#endif
-#ifdef RGB_MATRIX_ENABLE
- rgb_matrix_task();
-#endif
-
#ifdef WPM_ENABLE
decay_wpm();
#endif
@@ -709,42 +448,6 @@ void matrix_scan_quantum() {
# include "hd44780.h"
#endif
-// Functions for spitting out values
-//
-
-void send_dword(uint32_t number) {
- uint16_t word = (number >> 16);
- send_word(word);
- send_word(number & 0xFFFFUL);
-}
-
-void send_word(uint16_t number) {
- uint8_t byte = number >> 8;
- send_byte(byte);
- send_byte(number & 0xFF);
-}
-
-void send_byte(uint8_t number) {
- uint8_t nibble = number >> 4;
- send_nibble(nibble);
- send_nibble(number & 0xF);
-}
-
-void send_nibble(uint8_t number) {
- tap_code16(hex_to_keycode(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);
- }
-}
-
void api_send_unicode(uint32_t unicode) {
#ifdef API_ENABLE
uint8_t chunk[4];
@@ -761,8 +464,6 @@ __attribute__((weak)) void startup_user() {}
__attribute__((weak)) void shutdown_user() {}
-//------------------------------------------------------------------------------
-
#ifdef WEBUSB_ENABLE
__attribute__((weak)) bool webusb_receive_user(uint8_t *data, uint8_t length) { return false; }
__attribute__((weak)) bool webusb_receive_kb(uint8_t *data, uint8_t length) { return webusb_receive_user(data, length); }
diff --git a/quantum/quantum.h b/quantum/quantum.h
index b105c66664..a5ed1b66bd 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -53,12 +53,15 @@
#include "eeconfig.h"
#include "bootloader.h"
#include "timer.h"
+#include "sync_timer.h"
#include "config_common.h"
+#include "gpio.h"
+#include "atomic_util.h"
#include "led.h"
#include "action_util.h"
#include "action_tapping.h"
#include "print.h"
-#include "send_string_keycodes.h"
+#include "send_string.h"
#include "suspend.h"
#include <stddef.h>
#include <stdlib.h>
@@ -201,128 +204,50 @@ extern layer_state_t layer_state;
# include "wpm.h"
#endif
-// Function substitutions to ease GPIO manipulation
-#if defined(__AVR__)
-typedef uint8_t pin_t;
-
-# define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_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) (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)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
-
-# define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF))
-
-#elif defined(PROTOCOL_CHIBIOS)
-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 writePinHigh(pin) palSetLine(pin)
-# define writePinLow(pin) palClearLine(pin)
-# define writePin(pin, level) ((level) ? (writePinHigh(pin)) : (writePinLow(pin)))
-
-# define readPin(pin) palReadLine(pin)
-
-# define togglePin(pin) palToggleLine(pin)
+#ifdef USBPD_ENABLE
+# include "usbpd.h"
#endif
-// Atomic macro to help make GPIO and other controls atomic.
-#ifdef IGNORE_ATOMIC_BLOCK
-/* do nothing atomic macro */
-# define ATOMIC_BLOCK for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0)
-# define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK
-# define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK
-
-#elif defined(__AVR__)
-/* atomic macro for AVR */
-# include <util/atomic.h>
-
-# define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
-# define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON)
+// Function substitutions to ease GPIO manipulation
+#if defined(__AVR__)
-#elif defined(PROTOCOL_CHIBIOS) || defined(PROTOCOL_ARM_ATSAM)
-/* atomic macro for ChibiOS / ARM ATSAM */
-# if defined(PROTOCOL_ARM_ATSAM)
-# include "arm_atsam_protocol.h"
+/* The AVR series GPIOs have a one clock read delay for changes in the digital input signal.
+ * But here's more margin to make it two clocks. */
+# if !defined(GPIO_INPUT_PIN_DELAY)
+# define GPIO_INPUT_PIN_DELAY 2
# endif
+# define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
-static __inline__ uint8_t __interrupt_disable__(void) {
-# if defined(PROTOCOL_CHIBIOS)
- chSysLock();
-# endif
-# if defined(PROTOCOL_ARM_ATSAM)
- __disable_irq();
-# endif
- return 1;
-}
+#elif defined(__ARMEL__) || defined(__ARMEB__)
-static __inline__ void __interrupt_enable__(const uint8_t *__s) {
-# if defined(PROTOCOL_CHIBIOS)
- chSysUnlock();
-# endif
-# if defined(PROTOCOL_ARM_ATSAM)
- __enable_irq();
+/* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus
+ * to which the GPIO is connected.
+ * The connected buses differ depending on the various series of MCUs.
+ * And since the instruction execution clock of the CPU and the bus clock of GPIO are different,
+ * there is a delay of several clocks to read the change of the input signal.
+ *
+ * Define this delay with the GPIO_INPUT_PIN_DELAY macro.
+ * If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used.
+ * (A fairly large value of 0.25 microseconds is set.)
+ */
+# if !defined(GPIO_INPUT_PIN_DELAY)
+# if defined(STM32_SYSCLK)
+# define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4)
+# elif defined(KINETIS_SYSCLK_FREQUENCY)
+# define GPIO_INPUT_PIN_DELAY (KINETIS_SYSCLK_FREQUENCY / 1000000L / 4)
+# endif
# endif
- __asm__ volatile("" ::: "memory");
- (void)__s;
-}
-
-# define ATOMIC_BLOCK(type) for (type, __ToDo = __interrupt_disable__(); __ToDo; __ToDo = 0)
-# define ATOMIC_FORCEON uint8_t sreg_save __attribute__((__cleanup__(__interrupt_enable__))) = 0
-
-# define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE dose not implement")
-# define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON)
-
-/* Other platform */
-#else
-
-# define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE dose not implement")
-# define ATOMIC_BLOCK_FORCEON _Static_assert(0, "ATOMIC_BLOCK_FORCEON dose not implement")
+# define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
#endif
-#define SEND_STRING(string) send_string_P(PSTR(string))
-#define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval)
-
-// Look-Up Tables (LUTs) to convert ASCII character to keycode sequence.
-extern const uint8_t ascii_to_keycode_lut[128];
-extern const uint8_t ascii_to_shift_lut[16];
-extern const uint8_t ascii_to_altgr_lut[16];
-// clang-format off
-#define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \
- ( ((a) ? 1 : 0) << 0 \
- | ((b) ? 1 : 0) << 1 \
- | ((c) ? 1 : 0) << 2 \
- | ((d) ? 1 : 0) << 3 \
- | ((e) ? 1 : 0) << 4 \
- | ((f) ? 1 : 0) << 5 \
- | ((g) ? 1 : 0) << 6 \
- | ((h) ? 1 : 0) << 7 )
-// clang-format on
-
-void send_string(const char *str);
-void send_string_with_delay(const char *str, uint8_t interval);
-void send_string_P(const char *str);
-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);
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_is(layer)
#define IS_LAYER_OFF(layer) !layer_state_is(layer)
@@ -359,12 +284,6 @@ void register_code16(uint16_t code);
void unregister_code16(uint16_t code);
void tap_code16(uint16_t code);
-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);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 37e01751a7..97d200c8cf 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -73,31 +73,22 @@ enum quantum_keycodes {
QK_LAYER_TAP_TOGGLE_MAX = 0x58FF,
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,
-#endif
-#ifdef SWAP_HANDS_ENABLE
- QK_SWAP_HANDS = 0x5B00,
- QK_SWAP_HANDS_MAX = 0x5BFF,
-#endif
- QK_MOD_TAP = 0x6000,
- QK_MOD_TAP_MAX = 0x7FFF,
-#ifdef UNICODE_ENABLE
- QK_UNICODE = 0x8000,
- QK_UNICODE_MAX = 0xFFFF,
-#endif
-#ifdef UNICODEMAP_ENABLE
- QK_UNICODEMAP = 0x8000,
- QK_UNICODEMAP_MAX = 0xBFFF,
- QK_UNICODEMAP_PAIR = 0xC000,
- QK_UNICODEMAP_PAIR_MAX = 0xFFFF,
-#endif
+ QK_STENO = 0x5A00,
+ QK_STENO_BOLT = 0x5A30,
+ QK_STENO_GEMINI = 0x5A31,
+ QK_STENO_MAX = 0x5A3F,
+ QK_SWAP_HANDS = 0x5B00,
+ QK_SWAP_HANDS_MAX = 0x5BFF,
+ QK_MOD_TAP = 0x6000,
+ QK_MOD_TAP_MAX = 0x7FFF,
+ QK_UNICODE = 0x8000,
+ QK_UNICODE_MAX = 0xFFFF,
+ QK_UNICODEMAP = 0x8000,
+ QK_UNICODEMAP_MAX = 0xBFFF,
+ QK_UNICODEMAP_PAIR = 0xC000,
+ QK_UNICODEMAP_PAIR_MAX = 0xFFFF,
// Loose keycodes - to be used directly
-
RESET = 0x5C00,
DEBUG,
MAGIC_SWAP_CONTROL_CAPSLOCK,
@@ -150,13 +141,6 @@ enum quantum_keycodes {
CLICKY_DOWN,
CLICKY_RESET,
-#ifdef FAUXCLICKY_ENABLE
- // Faux clicky
- FC_ON,
- FC_OFF,
- FC_TOG,
-#endif
-
// Music mode on/off/toggle
MU_ON,
MU_OFF,
@@ -348,7 +332,11 @@ enum quantum_keycodes {
MIDI_VELOCITY_MIN,
MI_VEL_0 = MIDI_VELOCITY_MIN,
+# ifdef VIA_ENABLE
+ MI_VEL_1 = MIDI_VELOCITY_MIN,
+# else
MI_VEL_1,
+# endif
MI_VEL_2,
MI_VEL_3,
MI_VEL_4,
@@ -719,6 +707,9 @@ enum quantum_keycodes {
#define CK_DOWN CLICKY_DOWN
#define CK_ON CLICKY_ENABLE
#define CK_OFF CLICKY_DISABLE
+#define FC_ON CLICKY_ENABLE
+#define FC_OFF CLICKY_DISABLE
+#define FC_TOGG CLICKY_TOGGLE
#define RGB_MOD RGB_MODE_FORWARD
#define RGB_RMOD RGB_MODE_REVERSE
@@ -853,15 +844,11 @@ enum quantum_keycodes {
#define KC_HYPR HYPR(KC_NO)
#define KC_MEH MEH(KC_NO)
-#ifdef UNICODE_ENABLE
-// 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
-#endif
+// UNICODE_ENABLE - Allows Unicode input up to 0x7FFF
+#define UC(c) (QK_UNICODE | (c))
+// 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
#define UC_MOD UNICODE_MODE_FORWARD
#define UC_RMOD UNICODE_MODE_REVERSE
@@ -874,16 +861,14 @@ enum quantum_keycodes {
#define UC_M_BS UNICODE_MODE_BSD
#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_OS (QK_SWAP_HANDS | OP_SH_ONESHOT)
-# 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
+#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_OS (QK_SWAP_HANDS | OP_SH_ONESHOT)
+#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)
// Dynamic Macros aliases
#define DM_REC1 DYN_REC_START1
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index a5c2229d72..ec17b4d72c 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -117,7 +117,6 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv
# define RGB_MATRIX_STARTUP_SPD UINT8_MAX / 2
#endif
-
// globals
bool g_suspend_state = false;
rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
@@ -185,11 +184,12 @@ 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) { rgb_matrix_driver.set_color_all(red, green, blue); }
-bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
+void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
+#ifndef RGB_MATRIX_SPLIT
+ if (!is_keyboard_master()) return;
+#endif
#if RGB_DISABLE_TIMEOUT > 0
- if (record->event.pressed) {
- rgb_anykey_timer = 0;
- }
+ rgb_anykey_timer = 0;
#endif // RGB_DISABLE_TIMEOUT > 0
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
@@ -197,12 +197,12 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
uint8_t led_count = 0;
# if defined(RGB_MATRIX_KEYRELEASES)
- if (!record->event.pressed)
+ if (!pressed)
# elif defined(RGB_MATRIX_KEYPRESSES)
- if (record->event.pressed)
+ if (pressed)
# endif // defined(RGB_MATRIX_KEYRELEASES)
{
- led_count = rgb_matrix_map_row_column_to_led(record->event.key.row, record->event.key.col, led);
+ led_count = rgb_matrix_map_row_column_to_led(row, col, led);
}
if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
@@ -225,11 +225,9 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#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);
+ process_rgb_matrix_typing_heatmap(row, col);
}
#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
-
- return true;
}
void rgb_matrix_test(void) {
@@ -267,9 +265,9 @@ static bool rgb_matrix_none(effect_params_t *params) {
static void rgb_task_timers(void) {
#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
- uint32_t deltaTime = timer_elapsed32(rgb_timer_buffer);
+ uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer);
#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
- rgb_timer_buffer = timer_read32();
+ rgb_timer_buffer = sync_timer_read32();
// Update double buffer timers
#if RGB_DISABLE_TIMEOUT > 0
@@ -297,7 +295,7 @@ static void rgb_task_timers(void) {
static void rgb_task_sync(void) {
// next task
- if (timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING;
+ if (sync_timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING;
}
static void rgb_task_start(void) {
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index 8c80c1bff0..bb8bcfab68 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -98,7 +98,7 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
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 process_rgb_matrix(uint8_t row, uint8_t col, bool pressed);
void rgb_matrix_task(void);
diff --git a/quantum/rgb_matrix_animations/hue_breathing_anim.h b/quantum/rgb_matrix_animations/hue_breathing_anim.h
new file mode 100644
index 0000000000..54dea958af
--- /dev/null
+++ b/quantum/rgb_matrix_animations/hue_breathing_anim.h
@@ -0,0 +1,22 @@
+#ifndef DISABLE_RGB_MATRIX_HUE_BREATHING
+RGB_MATRIX_EFFECT(HUE_BREATHING)
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
+// Change huedelta to adjust range of hue change. 0-255.
+// Hue Breathing - All LED's light up
+bool HUE_BREATHING(effect_params_t* params) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ uint8_t huedelta = 12;
+ HSV hsv = rgb_matrix_config.hsv;
+ uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
+ hsv.h = hsv.h + scale8(abs8(sin8(time) - 128) * 2, huedelta);
+ 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_HUE_BREATHING
diff --git a/quantum/rgb_matrix_animations/hue_pendulum_anim.h b/quantum/rgb_matrix_animations/hue_pendulum_anim.h
new file mode 100644
index 0000000000..2d8d36174f
--- /dev/null
+++ b/quantum/rgb_matrix_animations/hue_pendulum_anim.h
@@ -0,0 +1,17 @@
+#ifndef DISABLE_RGB_MATRIX_HUE_PENDULUM
+RGB_MATRIX_EFFECT(HUE_PENDULUM)
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
+// Change huedelta to adjust range of hue change. 0-255.
+// Looks better with a low value and slow speed for subtle change.
+// Hue Pendulum - color changes in a wave to the right before reversing direction
+static HSV HUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) {
+ uint8_t huedelta = 12;
+ hsv.h = hsv.h + scale8(abs8(sin8(time) + (g_led_config.point[i].x) - 128) * 2, huedelta);
+ return hsv;
+}
+
+bool HUE_PENDULUM(effect_params_t* params) { return effect_runner_i(params, &HUE_PENDULUM_math); }
+
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_HUE_PENDULUM
diff --git a/quantum/rgb_matrix_animations/hue_wave_anim.h b/quantum/rgb_matrix_animations/hue_wave_anim.h
new file mode 100644
index 0000000000..fd9026fc90
--- /dev/null
+++ b/quantum/rgb_matrix_animations/hue_wave_anim.h
@@ -0,0 +1,17 @@
+#ifndef DISABLE_RGB_MATRIX_HUE_WAVE
+RGB_MATRIX_EFFECT(HUE_WAVE)
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
+// Change huedelta to adjust range of hue change. 0-255.
+// Looks better with a low value and slow speed for subtle change.
+// Hue Wave - color changes in a wave to the right
+static HSV HUE_WAVE_math(HSV hsv, uint8_t i, uint8_t time) {
+ uint8_t huedelta = 24;
+ hsv.h = hsv.h + scale8(abs8(g_led_config.point[i].x - time), huedelta);
+ return hsv;
+}
+
+bool HUE_WAVE(effect_params_t* params) { return effect_runner_i(params, &HUE_WAVE_math); }
+
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_RGB_HUE_WAVE
diff --git a/quantum/rgb_matrix_animations/rgb_matrix_effects.inc b/quantum/rgb_matrix_animations/rgb_matrix_effects.inc
index 4c1723d933..053d441506 100644
--- a/quantum/rgb_matrix_animations/rgb_matrix_effects.inc
+++ b/quantum/rgb_matrix_animations/rgb_matrix_effects.inc
@@ -23,6 +23,9 @@
#include "rgb_matrix_animations/rainbow_pinwheels_anim.h"
#include "rgb_matrix_animations/raindrops_anim.h"
#include "rgb_matrix_animations/jellybean_raindrops_anim.h"
+#include "rgb_matrix_animations/hue_breathing_anim.h"
+#include "rgb_matrix_animations/hue_pendulum_anim.h"
+#include "rgb_matrix_animations/hue_wave_anim.h"
#include "rgb_matrix_animations/typing_heatmap_anim.h"
#include "rgb_matrix_animations/digital_rain_anim.h"
#include "rgb_matrix_animations/solid_reactive_simple_anim.h"
diff --git a/quantum/rgb_matrix_animations/typing_heatmap_anim.h b/quantum/rgb_matrix_animations/typing_heatmap_anim.h
index e06437bf76..e7dda11a2f 100644
--- a/quantum/rgb_matrix_animations/typing_heatmap_anim.h
+++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h
@@ -6,9 +6,7 @@ RGB_MATRIX_EFFECT(TYPING_HEATMAP)
# define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 25
# endif
-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(uint8_t row, uint8_t col) {
uint8_t m_row = row - 1;
uint8_t p_row = row + 1;
uint8_t m_col = col - 1;
diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h
index f7ebec1d5d..7b8171fb23 100644
--- a/quantum/rgb_matrix_types.h
+++ b/quantum/rgb_matrix_types.h
@@ -1,3 +1,19 @@
+/* Copyright 2021
+ *
+ * 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>
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 3842c9130b..119d3eab21 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -29,7 +29,7 @@
#endif
#include "wait.h"
#include "progmem.h"
-#include "timer.h"
+#include "sync_timer.h"
#include "rgblight.h"
#include "color.h"
#include "debug.h"
@@ -42,6 +42,9 @@
#ifndef MIN
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
+#ifndef MAX
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
#ifdef RGBLIGHT_SPLIT
/* for split keyboard */
@@ -81,6 +84,26 @@ static uint8_t mode_base_table[] = {
#include "rgblight_modes.h"
};
+#if !defined(RGBLIGHT_DEFAULT_MODE)
+# define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT
+#endif
+
+#if !defined(RGBLIGHT_DEFAULT_HUE)
+# define RGBLIGHT_DEFAULT_HUE 0
+#endif
+
+#if !defined(RGBLIGHT_DEFAULT_SAT)
+# define RGBLIGHT_DEFAULT_SAT UINT8_MAX
+#endif
+
+#if !defined(RGBLIGHT_DEFAULT_VAL)
+# define RGBLIGHT_DEFAULT_VAL RGBLIGHT_LIMIT_VAL
+#endif
+
+#if !defined(RGBLIGHT_DEFAULT_SPD)
+# define RGBLIGHT_DEFAULT_SPD 0
+#endif
+
static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; }
#ifdef RGBLIGHT_LED_MAP
@@ -180,11 +203,11 @@ void eeconfig_update_rgblight_current(void) { eeconfig_update_rgblight(rgblight_
void eeconfig_update_rgblight_default(void) {
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_config.mode = RGBLIGHT_DEFAULT_MODE;
+ rgblight_config.hue = RGBLIGHT_DEFAULT_HUE;
+ rgblight_config.sat = RGBLIGHT_DEFAULT_SAT;
+ rgblight_config.val = RGBLIGHT_DEFAULT_VAL;
+ rgblight_config.speed = RGBLIGHT_DEFAULT_SPD;
RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
eeconfig_update_rgblight(rgblight_config.raw);
}
@@ -551,9 +574,7 @@ uint8_t rgblight_get_sat(void) { return rgblight_config.sat; }
uint8_t rgblight_get_val(void) { return rgblight_config.val; }
-HSV rgblight_get_hsv(void) {
- return (HSV){ rgblight_config.hue, rgblight_config.sat, rgblight_config.val };
-}
+HSV rgblight_get_hsv(void) { return (HSV){rgblight_config.hue, rgblight_config.sat, rgblight_config.val}; }
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
if (!rgblight_config.enable) {
@@ -702,18 +723,16 @@ static void rgblight_layers_write(void) {
# ifdef RGBLIGHT_LAYER_BLINK
rgblight_layer_mask_t _blinked_layer_mask = 0;
-uint16_t _blink_duration = 0;
static uint16_t _blink_timer;
void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) {
rgblight_set_layer_state(layer, true);
_blinked_layer_mask |= (rgblight_layer_mask_t)1 << layer;
- _blink_timer = timer_read();
- _blink_duration = duration_ms;
+ _blink_timer = sync_timer_read() + duration_ms;
}
void rgblight_unblink_layers(void) {
- if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) {
+ if (_blinked_layer_mask != 0 && timer_expired(sync_timer_read(), _blink_timer)) {
for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) {
if ((_blinked_layer_mask & (rgblight_layer_mask_t)1 << layer) != 0) {
rgblight_set_layer_state(layer, false);
@@ -865,22 +884,6 @@ 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;
}
@@ -888,7 +891,7 @@ void rgblight_timer_enable(void) {
if (!is_static_effect(rgblight_config.mode)) {
rgblight_status.timer_enabled = true;
}
- animation_status.last_timer = timer_read();
+ animation_status.last_timer = sync_timer_read();
RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
dprintf("rgblight timer enabled.\n");
}
@@ -991,24 +994,25 @@ void rgblight_task(void) {
# endif
# ifdef RGBLIGHT_EFFECT_TWINKLE
else if (rgblight_status.base_mode == RGBLIGHT_MODE_TWINKLE) {
- interval_time = get_interval_time(&RGBLED_TWINKLE_INTERVALS[delta % 3], 5, 50);
+ interval_time = get_interval_time(&RGBLED_TWINKLE_INTERVALS[delta % 3], 5, 30);
effect_func = (effect_func_t)rgblight_effect_twinkle;
}
# endif
if (animation_status.restart) {
animation_status.restart = false;
- animation_status.last_timer = timer_read() - interval_time - 1;
+ animation_status.last_timer = sync_timer_read();
animation_status.pos16 = 0; // restart signal to local each effect
}
- if (timer_elapsed(animation_status.last_timer) >= interval_time) {
+ uint16_t now = sync_timer_read();
+ if (timer_expired(now, animation_status.last_timer)) {
# 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();
+ if (timer_expired(now, report_last_timer)) {
+ report_last_timer += 30000;
dprintf("rgblight animation tick report to slave\n");
RGBLIGHT_SPLIT_ANIMATION_TICK;
}
@@ -1032,8 +1036,7 @@ void rgblight_task(void) {
#endif /* RGBLIGHT_USE_TIMER */
-// Effects
-#ifdef RGBLIGHT_EFFECT_BREATHING
+#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_TWINKLE)
# ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
# ifndef RGBLIGHT_BREATHE_TABLE_SIZE
@@ -1042,17 +1045,24 @@ void rgblight_task(void) {
# include <rgblight_breathe_table.h>
# endif
-__attribute__((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
-
-void rgblight_effect_breathing(animation_status_t *anim) {
- float val;
-
+static uint8_t breathe_calc(uint8_t pos) {
// 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]);
+ return pgm_read_byte(&rgblight_effect_breathe_table[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));
+ return (exp(sin((pos / 255.0) * M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER / M_E) * (RGBLIGHT_EFFECT_BREATHE_MAX / (M_E - 1 / M_E));
# endif
+}
+
+#endif
+
+// Effects
+#ifdef RGBLIGHT_EFFECT_BREATHING
+
+__attribute__((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
+
+void rgblight_effect_breathing(animation_status_t *anim) {
+ uint8_t val = breathe_calc(anim->pos);
rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val);
anim->pos = (anim->pos + 1);
}
@@ -1122,7 +1132,7 @@ void rgblight_effect_snake(animation_status_t *anim) {
ledp->g = 0;
ledp->b = 0;
# ifdef RGBW
- ledp->w = 0;
+ ledp->w = 0;
# endif
for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) {
k = pos + j * increment;
@@ -1304,48 +1314,54 @@ void rgblight_effect_alternating(animation_status_t *anim) {
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
-__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {50, 25, 10};
+__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {30, 15, 5};
typedef struct PACKED {
HSV hsv;
uint8_t life;
- bool up;
+ uint8_t max_life;
} TwinkleState;
static TwinkleState led_twinkle_state[RGBLED_NUM];
void rgblight_effect_twinkle(animation_status_t *anim) {
- bool random_color = anim->delta / 3;
- bool restart = anim->pos == 0;
- anim->pos = 1;
+ const bool random_color = anim->delta / 3;
+ const bool restart = anim->pos == 0;
+ anim->pos = 1;
+
+ const uint8_t bottom = breathe_calc(0);
+ const uint8_t top = breathe_calc(127);
+
+ uint8_t frac(uint8_t n, uint8_t d) { return (uint16_t)255 * n / d; }
+ uint8_t scale(uint16_t v, uint8_t scale) { return (v * scale) >> 8; }
for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) {
TwinkleState *t = &(led_twinkle_state[i]);
HSV * c = &(t->hsv);
+
+ if (!random_color) {
+ c->h = rgblight_config.hue;
+ c->s = rgblight_config.sat;
+ }
+
if (restart) {
// Restart
- t->life = 0;
- t->hsv.v = 0;
+ t->life = 0;
+ c->v = 0;
} else if (t->life) {
// This LED is already on, either brightening or dimming
t->life--;
- uint8_t on = t->up ? RGBLIGHT_EFFECT_TWINKLE_LIFE - t->life : t->life;
- c->v = (uint16_t)rgblight_config.val * on / RGBLIGHT_EFFECT_TWINKLE_LIFE;
- if (t->life == 0 && t->up) {
- t->up = false;
- t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE;
- }
- if (!random_color) {
- c->h = rgblight_config.hue;
- c->s = rgblight_config.sat;
- }
- } else if (rand() < RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY) {
+ uint8_t unscaled = frac(breathe_calc(frac(t->life, t->max_life)) - bottom, top - bottom);
+ c->v = scale(rgblight_config.val, unscaled);
+ } else if (rand() < scale((uint16_t)RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY, 127 + rgblight_config.val / 2)) {
// This LED is off, but was randomly selected to start brightening
- c->h = random_color ? rand() % 0xFF : rgblight_config.hue;
- c->s = random_color ? (rand() % (rgblight_config.sat / 2)) + (rgblight_config.sat / 2) : rgblight_config.sat;
- c->v = 0;
- t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE;
- t->up = true;
+ if (random_color) {
+ c->h = rand() % 0xFF;
+ c->s = (rand() % (rgblight_config.sat / 2)) + (rgblight_config.sat / 2);
+ }
+ c->v = 0;
+ t->max_life = MAX(20, MIN(RGBLIGHT_EFFECT_TWINKLE_LIFE, rgblight_config.val));
+ t->life = t->max_life;
} else {
// This LED is off, and was NOT selected to start brightening
}
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 1854fee999..6fb3ab9380 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -150,7 +150,7 @@ enum RGBLIGHT_EFFECT_MODE {
# endif
# ifndef RGBLIGHT_EFFECT_TWINKLE_LIFE
-# define RGBLIGHT_EFFECT_TWINKLE_LIFE 75
+# define RGBLIGHT_EFFECT_TWINKLE_LIFE 200
# endif
# ifndef RGBLIGHT_EFFECT_TWINKLE_PROBABILITY
@@ -170,9 +170,6 @@ enum RGBLIGHT_EFFECT_MODE {
# 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"
diff --git a/tmk_core/ring_buffer.h b/quantum/ring_buffer.h
index 8f887c8f74..284745ca8e 100644
--- a/tmk_core/ring_buffer.h
+++ b/quantum/ring_buffer.h
@@ -1,14 +1,13 @@
#pragma once
-/*--------------------------------------------------------------------
- * Ring buffer to store scan codes from keyboard
- *------------------------------------------------------------------*/
-#ifndef RBUF_SIZE
-# define RBUF_SIZE 32
-#endif
#include <util/atomic.h>
#include <stdint.h>
#include <stdbool.h>
+
+#ifndef RBUF_SIZE
+# define RBUF_SIZE 32
+#endif
+
static uint8_t rbuf[RBUF_SIZE];
static uint8_t rbuf_head = 0;
static uint8_t rbuf_tail = 0;
diff --git a/quantum/send_string.c b/quantum/send_string.c
new file mode 100644
index 0000000000..7d096b4273
--- /dev/null
+++ b/quantum/send_string.c
@@ -0,0 +1,306 @@
+/* Copyright 2021
+ *
+ * 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 <ctype.h>
+
+#include "quantum.h"
+
+#include "send_string.h"
+
+// clang-format off
+
+/* Bit-Packed look-up table to convert an ASCII character to whether
+ * [Shift] needs to be sent with the keycode.
+ */
+__attribute__((weak)) const uint8_t ascii_to_shift_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 0),
+ KCLUT_ENTRY(1, 1, 1, 1, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 1, 0, 1, 0, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
+ KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 1, 1),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 1, 0)
+};
+
+/* Bit-Packed look-up table to convert an ASCII character to whether
+ * [AltGr] needs to be sent with the keycode.
+ */
+__attribute__((weak)) const uint8_t ascii_to_altgr_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0)
+};
+
+/* Bit-Packed look-up table to convert an ASCII character to whether
+ * [Space] needs to be sent after the keycode
+ */
+__attribute__((weak)) const uint8_t ascii_to_dead_lut[16] PROGMEM = {
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
+ KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0)
+};
+
+/* Look-up table to convert an ASCII character to a keycode.
+ */
+__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
+};
+
+// clang-format on
+
+// Note: we bit-pack in "reverse" order to optimize loading
+#define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01)
+
+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_QMK_PREFIX) {
+ ascii_code = *(++str);
+ if (ascii_code == SS_TAP_CODE) {
+ // tap
+ uint8_t keycode = *(++str);
+ tap_code(keycode);
+ } else if (ascii_code == SS_DOWN_CODE) {
+ // down
+ uint8_t keycode = *(++str);
+ register_code(keycode);
+ } else if (ascii_code == SS_UP_CODE) {
+ // up
+ uint8_t keycode = *(++str);
+ unregister_code(keycode);
+ } else if (ascii_code == SS_DELAY_CODE) {
+ // delay
+ int ms = 0;
+ uint8_t keycode = *(++str);
+ while (isdigit(keycode)) {
+ ms *= 10;
+ ms += keycode - '0';
+ keycode = *(++str);
+ }
+ while (ms--) wait_ms(1);
+ }
+ } else {
+ send_char(ascii_code);
+ }
+ ++str;
+ // interval
+ {
+ uint8_t ms = interval;
+ while (ms--) wait_ms(1);
+ }
+ }
+}
+
+void send_string_with_delay_P(const char *str, uint8_t interval) {
+ while (1) {
+ char ascii_code = pgm_read_byte(str);
+ if (!ascii_code) break;
+ if (ascii_code == SS_QMK_PREFIX) {
+ ascii_code = pgm_read_byte(++str);
+ if (ascii_code == SS_TAP_CODE) {
+ // tap
+ uint8_t keycode = pgm_read_byte(++str);
+ tap_code(keycode);
+ } else if (ascii_code == SS_DOWN_CODE) {
+ // 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);
+ } else if (ascii_code == SS_DELAY_CODE) {
+ // delay
+ int ms = 0;
+ uint8_t keycode = pgm_read_byte(++str);
+ while (isdigit(keycode)) {
+ ms *= 10;
+ ms += keycode - '0';
+ keycode = pgm_read_byte(++str);
+ }
+ while (ms--) wait_ms(1);
+ }
+ } else {
+ send_char(ascii_code);
+ }
+ ++str;
+ // interval
+ {
+ uint8_t ms = interval;
+ while (ms--) wait_ms(1);
+ }
+ }
+}
+
+void send_char(char ascii_code) {
+#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL)
+ if (ascii_code == '\a') { // BEL
+ PLAY_SONG(bell_song);
+ return;
+ }
+#endif
+
+ uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
+ bool is_shifted = PGM_LOADBIT(ascii_to_shift_lut, (uint8_t)ascii_code);
+ bool is_altgred = PGM_LOADBIT(ascii_to_altgr_lut, (uint8_t)ascii_code);
+ bool is_dead = PGM_LOADBIT(ascii_to_dead_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);
+ }
+ if (is_dead) {
+ tap_code(KC_SPACE);
+ }
+}
+
+void send_dword(uint32_t number) {
+ send_word(number >> 16);
+ send_word(number & 0xFFFFUL);
+}
+
+void send_word(uint16_t number) {
+ send_byte(number >> 8);
+ send_byte(number & 0xFF);
+}
+
+void send_byte(uint8_t number) {
+ send_nibble(number >> 4);
+ send_nibble(number & 0xF);
+}
+
+void send_nibble(uint8_t number) {
+ switch (number & 0xF) {
+ case 0 ... 9:
+ send_char(number + '0');
+ break;
+ case 10 ... 15:
+ send_char(number - 10 + 'a');
+ break;
+ }
+}
+
+void tap_random_base64(void) {
+#if defined(__AVR_ATmega32U4__)
+ uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
+#else
+ uint8_t key = rand() % 64;
+#endif
+ switch (key) {
+ case 0 ... 25:
+ send_char(key + 'A');
+ break;
+ case 26 ... 51:
+ send_char(key - 26 + 'a');
+ break;
+ case 52:
+ send_char('0');
+ break;
+ case 53 ... 61:
+ send_char(key - 53 + '1');
+ break;
+ case 62:
+ send_char('+');
+ break;
+ case 63:
+ send_char('/');
+ break;
+ }
+}
diff --git a/quantum/send_string.h b/quantum/send_string.h
new file mode 100644
index 0000000000..b90e6f6890
--- /dev/null
+++ b/quantum/send_string.h
@@ -0,0 +1,54 @@
+/* Copyright 2021
+ *
+ * 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 <stdint.h>
+
+#include "progmem.h"
+#include "send_string_keycodes.h"
+
+#define SEND_STRING(string) send_string_P(PSTR(string))
+#define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval)
+
+// Look-Up Tables (LUTs) to convert ASCII character to keycode sequence.
+extern const uint8_t ascii_to_shift_lut[16];
+extern const uint8_t ascii_to_altgr_lut[16];
+extern const uint8_t ascii_to_dead_lut[16];
+extern const uint8_t ascii_to_keycode_lut[128];
+
+// clang-format off
+#define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \
+ ( ((a) ? 1 : 0) << 0 \
+ | ((b) ? 1 : 0) << 1 \
+ | ((c) ? 1 : 0) << 2 \
+ | ((d) ? 1 : 0) << 3 \
+ | ((e) ? 1 : 0) << 4 \
+ | ((f) ? 1 : 0) << 5 \
+ | ((g) ? 1 : 0) << 6 \
+ | ((h) ? 1 : 0) << 7 )
+// clang-format on
+
+void send_string(const char *str);
+void send_string_with_delay(const char *str, uint8_t interval);
+void send_string_P(const char *str);
+void send_string_with_delay_P(const char *str, uint8_t interval);
+void send_char(char ascii_code);
+
+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 tap_random_base64(void);
diff --git a/quantum/send_string_keycodes.h b/quantum/send_string_keycodes.h
index 1e8a8e9ff5..7017e03d5a 100644
--- a/quantum/send_string_keycodes.h
+++ b/quantum/send_string_keycodes.h
@@ -362,6 +362,7 @@
#define X_BRIGHTNESS_DOWN be
/* Mouse Buttons (unallocated range in HID spec) */
+#ifdef VIA_ENABLE
#define X_MS_UP f0
#define X_MS_DOWN f1
#define X_MS_LEFT f2
@@ -371,6 +372,23 @@
#define X_MS_BTN3 f6
#define X_MS_BTN4 f7
#define X_MS_BTN5 f8
+#define X_MS_BTN6 f8
+#define X_MS_BTN7 f8
+#define X_MS_BTN8 f8
+#else
+#define X_MS_UP ed
+#define X_MS_DOWN ee
+#define X_MS_LEFT ef
+#define X_MS_RIGHT f0
+#define X_MS_BTN1 f1
+#define X_MS_BTN2 f2
+#define X_MS_BTN3 f3
+#define X_MS_BTN4 f4
+#define X_MS_BTN5 f5
+#define X_MS_BTN6 f6
+#define X_MS_BTN7 f7
+#define X_MS_BTN8 f8
+#endif
#define X_MS_WH_UP f9
#define X_MS_WH_DOWN fa
#define X_MS_WH_LEFT fb
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index 51bf8b1095..d6636b886a 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -114,9 +114,9 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Start with a clear matrix row
matrix_row_t current_row_value = 0;
- // Select row and wait for row selecton to stabilize
+ // Select row
select_row(current_row);
- matrix_io_delay();
+ matrix_output_select_delay();
// For each col...
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
@@ -129,6 +129,9 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Unselect row
unselect_row(current_row);
+ if (current_row + 1 < MATRIX_ROWS) {
+ matrix_output_unselect_delay(); // wait for row signal to go HIGH
+ }
// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
@@ -160,9 +163,9 @@ static void init_pins(void) {
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
select_col(current_col);
- matrix_io_delay();
+ matrix_output_select_delay();
// For each row...
for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
@@ -188,6 +191,9 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
// Unselect col
unselect_col(current_col);
+ if (current_col + 1 < MATRIX_COLS) {
+ matrix_output_unselect_delay(); // wait for col signal to go HIGH
+ }
return matrix_changed;
}
@@ -245,48 +251,62 @@ void matrix_init(void) {
split_post_init();
}
-void matrix_post_scan(void) {
+bool matrix_post_scan(void) {
+ bool changed = false;
if (is_keyboard_master()) {
static uint8_t error_count;
- if (!transport_master(matrix + thatHand)) {
+ matrix_row_t slave_matrix[ROWS_PER_HAND] = {0};
+ if (!transport_master(matrix + thisHand, slave_matrix)) {
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;
+ slave_matrix[i] = 0;
}
+
+ changed = true;
}
} else {
error_count = 0;
+
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ if (matrix[thatHand + i] != slave_matrix[i]) {
+ matrix[thatHand + i] = slave_matrix[i];
+ changed = true;
+ }
+ }
}
matrix_scan_quantum();
} else {
- transport_slave(matrix + thisHand);
+ transport_slave(matrix + thatHand, matrix + thisHand);
matrix_slave_scan_user();
}
+
+ return changed;
}
uint8_t matrix_scan(void) {
- bool changed = false;
+ bool local_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);
+ local_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);
+ local_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, local_changed);
- matrix_post_scan();
- return (uint8_t)changed;
+ bool remote_changed = matrix_post_scan();
+ return (uint8_t)(local_changed || remote_changed);
}
diff --git a/quantum/split_common/post_config.h b/quantum/split_common/post_config.h
index 5c0b414fb3..4ae1d52732 100644
--- a/quantum/split_common/post_config.h
+++ b/quantum/split_common/post_config.h
@@ -1,4 +1,4 @@
-#if defined(USE_I2C) || defined(EH)
+#if defined(USE_I2C)
// When using I2C, using rgblight implicitly involves split support.
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_SPLIT)
# define RGBLIGHT_SPLIT
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index 575bdc0fdc..2ae44e6e15 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -40,7 +40,10 @@ volatile bool isLeftHand = true;
#if defined(SPLIT_USB_DETECT)
# if defined(PROTOCOL_LUFA)
static inline bool usbHasActiveConnection(void) { return USB_Device_IsAddressSet(); }
-static inline void usbDisable(void) { USB_Disable(); }
+static inline void usbDisable(void) {
+ USB_Disable();
+ USB_DeviceState = DEVICE_STATE_Unattached;
+}
# elif defined(PROTOCOL_CHIBIOS)
static inline bool usbHasActiveConnection(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; }
static inline void usbDisable(void) { usbStop(&USBD1); }
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index 487dbcae64..61b61ea08c 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -6,6 +6,7 @@
#include "quantum.h"
#define ROWS_PER_HAND (MATRIX_ROWS / 2)
+#define SYNC_TIMER_OFFSET 2
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
@@ -21,14 +22,29 @@ 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)
+#if defined(USE_I2C)
# include "i2c_master.h"
# include "i2c_slave.h"
typedef struct _I2C_slave_buffer_t {
+# ifndef DISABLE_SYNC_TIMER
+ uint32_t sync_timer;
+# endif
+# ifdef SPLIT_TRANSPORT_MIRROR
+ matrix_row_t mmatrix[ROWS_PER_HAND];
+# endif
matrix_row_t smatrix[ROWS_PER_HAND];
- uint8_t backlight_level;
+# ifdef SPLIT_MODS_ENABLE
+ uint8_t real_mods;
+ uint8_t weak_mods;
+# ifndef NO_ACTION_ONESHOT
+ uint8_t oneshot_mods;
+# endif
+# endif
+# ifdef BACKLIGHT_ENABLE
+ uint8_t backlight_level;
+# endif
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
rgblight_syncinfo_t rgblight_sync;
# endif
@@ -42,9 +58,14 @@ typedef struct _I2C_slave_buffer_t {
static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
+# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer)
+# define I2C_KEYMAP_MASTER_START offsetof(I2C_slave_buffer_t, mmatrix)
+# define I2C_KEYMAP_SLAVE_START offsetof(I2C_slave_buffer_t, smatrix)
+# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods)
+# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods)
+# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods)
# 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_WPM_START offsetof(I2C_slave_buffer_t, current_wpm)
@@ -55,8 +76,11 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# 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);
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+ i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_SLAVE_START, (void *)slave_matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
+# ifdef SPLIT_TRANSPORT_MIRROR
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_MASTER_START, (void *)master_matrix, sizeof(i2c_buffer->mmatrix), TIMEOUT);
+# endif
// write backlight info
# ifdef BACKLIGHT_ENABLE
@@ -85,18 +109,54 @@ bool transport_master(matrix_row_t matrix[]) {
# ifdef WPM_ENABLE
uint8_t current_wpm = get_current_wpm();
- if(current_wpm != i2c_buffer->current_wpm) {
+ if (current_wpm != i2c_buffer->current_wpm) {
if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WPM_START, (void *)&current_wpm, sizeof(current_wpm), TIMEOUT) >= 0) {
i2c_buffer->current_wpm = current_wpm;
}
}
# endif
+
+# ifdef SPLIT_MODS_ENABLE
+ uint8_t real_mods = get_mods();
+ if (real_mods != i2c_buffer->real_mods) {
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_REAL_MODS_START, (void *)&real_mods, sizeof(real_mods), TIMEOUT) >= 0) {
+ i2c_buffer->real_mods = real_mods;
+ }
+ }
+
+ uint8_t weak_mods = get_weak_mods();
+ if (weak_mods != i2c_buffer->weak_mods) {
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WEAK_MODS_START, (void *)&weak_mods, sizeof(weak_mods), TIMEOUT) >= 0) {
+ i2c_buffer->weak_mods = weak_mods;
+ }
+ }
+
+# ifndef NO_ACTION_ONESHOT
+ uint8_t oneshot_mods = get_oneshot_mods();
+ if (oneshot_mods != i2c_buffer->oneshot_mods) {
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_ONESHOT_MODS_START, (void *)&oneshot_mods, sizeof(oneshot_mods), TIMEOUT) >= 0) {
+ i2c_buffer->oneshot_mods = oneshot_mods;
+ }
+ }
+# endif
+# endif
+
+# ifndef DISABLE_SYNC_TIMER
+ i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT);
+# endif
return true;
}
-void transport_slave(matrix_row_t matrix[]) {
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+# ifndef DISABLE_SYNC_TIMER
+ sync_timer_update(i2c_buffer->sync_timer);
+# endif
// Copy matrix to I2C buffer
- memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix));
+ memcpy((void *)i2c_buffer->smatrix, (void *)slave_matrix, sizeof(i2c_buffer->smatrix));
+# ifdef SPLIT_TRANSPORT_MIRROR
+ memcpy((void *)master_matrix, (void *)i2c_buffer->mmatrix, sizeof(i2c_buffer->mmatrix));
+# endif
// Read Backlight Info
# ifdef BACKLIGHT_ENABLE
@@ -118,6 +178,14 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef WPM_ENABLE
set_current_wpm(i2c_buffer->current_wpm);
# endif
+
+# ifdef SPLIT_MODS_ENABLE
+ set_mods(i2c_buffer->real_mods);
+ set_weak_mods(i2c_buffer->weak_mods);
+# ifndef NO_ACTION_ONESHOT
+ set_oneshot_mods(i2c_buffer->oneshot_mods);
+# endif
+# endif
}
void transport_master_init(void) { i2c_init(); }
@@ -139,11 +207,24 @@ typedef struct _Serial_s2m_buffer_t {
} Serial_s2m_buffer_t;
typedef struct _Serial_m2s_buffer_t {
+# ifdef SPLIT_MODS_ENABLE
+ uint8_t real_mods;
+ uint8_t weak_mods;
+# ifndef NO_ACTION_ONESHOT
+ uint8_t oneshot_mods;
+# endif
+# endif
+# ifndef DISABLE_SYNC_TIMER
+ uint32_t sync_timer;
+# endif
+# ifdef SPLIT_TRANSPORT_MIRROR
+ matrix_row_t mmatrix[ROWS_PER_HAND];
+# endif
# ifdef BACKLIGHT_ENABLE
- uint8_t backlight_level;
+ uint8_t backlight_level;
# endif
# ifdef WPM_ENABLE
- uint8_t current_wpm;
+ uint8_t current_wpm;
# endif
} Serial_m2s_buffer_t;
@@ -221,7 +302,7 @@ void transport_rgblight_slave(void) {
# define transport_rgblight_slave()
# endif
-bool transport_master(matrix_row_t matrix[]) {
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
# ifndef SERIAL_USE_MULTI_TRANSACTION
if (soft_serial_transaction() != TRANSACTION_END) {
return false;
@@ -235,7 +316,10 @@ bool transport_master(matrix_row_t matrix[]) {
// TODO: if MATRIX_COLS > 8 change to unpack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- matrix[i] = serial_s2m_buffer.smatrix[i];
+ slave_matrix[i] = serial_s2m_buffer.smatrix[i];
+# ifdef SPLIT_TRANSPORT_MIRROR
+ serial_m2s_buffer.mmatrix[i] = master_matrix[i];
+# endif
}
# ifdef BACKLIGHT_ENABLE
@@ -249,16 +333,34 @@ bool transport_master(matrix_row_t matrix[]) {
# ifdef WPM_ENABLE
// Write wpm to slave
- serial_m2s_buffer.current_wpm = get_current_wpm();
+ serial_m2s_buffer.current_wpm = get_current_wpm();
+# endif
+
+# ifdef SPLIT_MODS_ENABLE
+ serial_m2s_buffer.real_mods = get_mods();
+ serial_m2s_buffer.weak_mods = get_weak_mods();
+# ifndef NO_ACTION_ONESHOT
+ serial_m2s_buffer.oneshot_mods = get_oneshot_mods();
+# endif
+# endif
+# ifndef DISABLE_SYNC_TIMER
+ serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
# endif
return true;
}
-void transport_slave(matrix_row_t matrix[]) {
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
transport_rgblight_slave();
+# ifndef DISABLE_SYNC_TIMER
+ sync_timer_update(serial_m2s_buffer.sync_timer);
+# endif
+
// TODO: if MATRIX_COLS > 8 change to pack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- serial_s2m_buffer.smatrix[i] = matrix[i];
+ serial_s2m_buffer.smatrix[i] = slave_matrix[i];
+# ifdef SPLIT_TRANSPORT_MIRROR
+ master_matrix[i] = serial_m2s_buffer.mmatrix[i];
+# endif
}
# ifdef BACKLIGHT_ENABLE
backlight_set(serial_m2s_buffer.backlight_level);
@@ -269,7 +371,15 @@ void transport_slave(matrix_row_t matrix[]) {
# endif
# ifdef WPM_ENABLE
- set_current_wpm(serial_m2s_buffer.current_wpm);
+ set_current_wpm(serial_m2s_buffer.current_wpm);
+# endif
+
+# ifdef SPLIT_MODS_ENABLE
+ set_mods(serial_m2s_buffer.real_mods);
+ set_weak_mods(serial_m2s_buffer.weak_mods);
+# ifndef NO_ACTION_ONESHOT
+ set_oneshot_mods(serial_m2s_buffer.oneshot_mods);
+# endif
# endif
}
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h
index f3e752bf9b..a9f66301bf 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -1,10 +1,10 @@
#pragma once
-#include "common/matrix.h"
+#include "matrix.h"
void transport_master_init(void);
void transport_slave_init(void);
// returns false if valid data not received from slave
-bool transport_master(matrix_row_t matrix[]);
-void transport_slave(matrix_row_t matrix[]);
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
diff --git a/quantum/template/avr/config.h b/quantum/template/avr/config.h
index 82c6d3bec9..4192bbcfa2 100644
--- a/quantum/template/avr/config.h
+++ b/quantum/template/avr/config.h
@@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001
#define MANUFACTURER %YOUR_NAME%
#define PRODUCT %KEYBOARD%
-#define DESCRIPTION A custom keyboard
/* key matrix size */
#define MATRIX_ROWS 2
@@ -41,10 +40,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
*
*/
-#define MATRIX_ROW_PINS \
- { D0, D5 }
-#define MATRIX_COL_PINS \
- { F1, F0, B0 }
+#define MATRIX_ROW_PINS { D0, D5 }
+#define MATRIX_COL_PINS { F1, F0, B0 }
#define UNUSED_PINS
/* COL2ROW, ROW2COL */
@@ -145,8 +142,6 @@ 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 */
#define NO_ACTION_MACRO
diff --git a/quantum/template/avr/rules.mk b/quantum/template/avr/rules.mk
index ed6357c39f..5c0d8f307c 100644
--- a/quantum/template/avr/rules.mk
+++ b/quantum/template/avr/rules.mk
@@ -1,8 +1,6 @@
# MCU name
-#MCU = at90usb1286
MCU = atmega32u4
-
# Bootloader selection
BOOTLOADER = atmel-dfu
diff --git a/quantum/template/avr/template.c b/quantum/template/avr/template.c
deleted file mode 100644
index 7a5434f30e..0000000000
--- a/quantum/template/avr/template.c
+++ /dev/null
@@ -1,43 +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"
-
-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/base/keymaps/default/keymap.c b/quantum/template/base/keymaps/default/keymap.c
index fad132d159..b8ffb0156c 100644
--- a/quantum/template/base/keymaps/default/keymap.c
+++ b/quantum/template/base/keymaps/default/keymap.c
@@ -22,6 +22,12 @@ enum layer_names {
};
// Defines the keycodes used by our macros in process_record_user
+enum custom_keycodes {
+ QMKBEST = SAFE_RANGE,
+ QMKURL
+};
+
+// Defines the keycodes used by our macros in process_record_user
enum custom_keycodes { QMKBEST = SAFE_RANGE, QMKURL };
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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 2701d53c43..6150bcce6d 100644
--- a/quantum/template/ps2avrgb/config.h
+++ b/quantum/template/ps2avrgb/config.h
@@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001
#define MANUFACTURER %YOUR_NAME%
#define PRODUCT %KEYBOARD%
-#define DESCRIPTION A custom keyboard
/* key matrix size */
#define MATRIX_ROWS 8
diff --git a/quantum/template/ps2avrgb/i2c.c b/quantum/template/ps2avrgb/i2c.c
deleted file mode 100644
index e8c4455ad1..0000000000
--- a/quantum/template/ps2avrgb/i2c.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.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/>.
-*/
-
-// Please do not modify this file
-
-#include <avr/io.h>
-#include <util/twi.h>
-
-#include "i2c.h"
-
-void i2c_set_bitrate(uint16_t bitrate_khz) {
- uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz);
- if (bitrate_div >= 16) {
- bitrate_div = (bitrate_div - 16) / 2;
- }
- TWBR = bitrate_div;
-}
-
-void i2c_init(void) {
- // set pull-up resistors on I2C bus pins
- PORTC |= 0b11;
-
- i2c_set_bitrate(400);
-
- // enable TWI (two-wire interface)
- TWCR |= (1 << TWEN);
-
- // enable TWI interrupt and slave address ACK
- TWCR |= (1 << TWIE);
- TWCR |= (1 << TWEA);
-}
-
-uint8_t i2c_start(uint8_t address) {
- // reset TWI control register
- TWCR = 0;
-
- // begin transmission and wait for it to end
- TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
- while (!(TWCR & (1<<TWINT)));
-
- // check if the start condition was successfully transmitted
- if ((TWSR & 0xF8) != TW_START) {
- return 1;
- }
-
- // transmit address and wait
- TWDR = address;
- TWCR = (1<<TWINT) | (1<<TWEN);
- while (!(TWCR & (1<<TWINT)));
-
- // check if the device has acknowledged the READ / WRITE mode
- uint8_t twst = TW_STATUS & 0xF8;
- if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
- return 1;
- }
-
- return 0;
-}
-
-void i2c_stop(void) {
- TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-}
-
-uint8_t i2c_write(uint8_t data) {
- TWDR = data;
-
- // transmit data and wait
- TWCR = (1<<TWINT) | (1<<TWEN);
- while (!(TWCR & (1<<TWINT)));
-
- if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
- return 1;
- }
-
- return 0;
-}
-
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) {
- if (i2c_start(address)) {
- return 1;
- }
-
- for (uint16_t i = 0; i < length; i++) {
- if (i2c_write(data[i])) {
- return 1;
- }
- }
-
- i2c_stop();
-
- return 0;
-}
diff --git a/quantum/template/ps2avrgb/matrix.c b/quantum/template/ps2avrgb/matrix.c
deleted file mode 100644
index 245813dfd2..0000000000
--- a/quantum/template/ps2avrgb/matrix.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.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 <avr/io.h>
-#include <util/delay.h>
-
-#include "matrix.h"
-
-#ifndef DEBOUNCE
-# define DEBOUNCE 5
-#endif
-
-static uint8_t debouncing = DEBOUNCE;
-
-static matrix_row_t matrix[MATRIX_ROWS];
-static matrix_row_t matrix_debouncing[MATRIX_ROWS];
-
-void matrix_set_row_status(uint8_t row);
-uint8_t bit_reverse(uint8_t x);
-
-void matrix_init(void) {
- // all outputs for rows high
- DDRB = 0xFF;
- PORTB = 0xFF;
- // all inputs for columns
- DDRA = 0x00;
- DDRC &= ~(0x111111<<2);
- DDRD &= ~(1<<PIND7);
- // all columns are pulled-up
- PORTA = 0xFF;
- PORTC |= (0b111111<<2);
- PORTD |= (1<<PIND7);
-
- // initialize matrix state: all keys off
- for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- matrix[row] = 0x00;
- matrix_debouncing[row] = 0x00;
- }
-
- matrix_init_quantum();
-}
-
-uint8_t matrix_scan(void) {
- for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- matrix_set_row_status(row);
- _delay_us(5);
-
- matrix_row_t cols = (
- // cols 0..7, PORTA 0 -> 7
- (~PINA) & 0xFF
- ) | (
- // cols 8..13, PORTC 7 -> 0
- bit_reverse((~PINC) & 0xFF) << 8
- ) | (
- // col 14, PORTD 7
- ((~PIND) & (1 << PIND7)) << 7
- );
-
- if (matrix_debouncing[row] != cols) {
- matrix_debouncing[row] = cols;
- debouncing = DEBOUNCE;
- }
- }
-
- if (debouncing) {
- if (--debouncing) {
- _delay_ms(1);
- } else {
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- matrix[i] = matrix_debouncing[i];
- }
- }
- }
-
- matrix_scan_quantum();
-
- return 1;
-}
-
-// declarations
-void matrix_set_row_status(uint8_t row) {
- DDRB = (1 << row);
- PORTB = ~(1 << row);
-}
-
-uint8_t bit_reverse(uint8_t x) {
- x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
- x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
- x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
- return x;
-}
-
-inline matrix_row_t matrix_get_row(uint8_t row) {
- return matrix[row];
-}
-
-void matrix_print(void) {
-}
diff --git a/quantum/template/ps2avrgb/readme.md b/quantum/template/ps2avrgb/readme.md
index a1322535bd..f19743a163 100644
--- a/quantum/template/ps2avrgb/readme.md
+++ b/quantum/template/ps2avrgb/readme.md
@@ -12,7 +12,7 @@ Make example for this keyboard (after setting up your build environment):
make %KEYBOARD%:default
-Flashing example for this keyboard ([after setting up the bootloadHID flashing environment](flashing_bootloadhid.md))
+Flashing example for this keyboard ([after setting up the bootloadHID flashing environment](https://docs.qmk.fm/#/flashing_bootloadhid))
make %KEYBOARD%:default:flash
diff --git a/quantum/template/ps2avrgb/rules.mk b/quantum/template/ps2avrgb/rules.mk
index 7c73d2c232..1b61e9534d 100644
--- a/quantum/template/ps2avrgb/rules.mk
+++ b/quantum/template/ps2avrgb/rules.mk
@@ -17,5 +17,3 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
WS2812_DRIVER = i2c
-
-OPT_DEFS = -DDEBUG_LEVEL=0
diff --git a/quantum/template/ps2avrgb/template.c b/quantum/template/ps2avrgb/template.c
deleted file mode 100644
index 503da7ca71..0000000000
--- a/quantum/template/ps2avrgb/template.c
+++ /dev/null
@@ -1,44 +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"
-
-
-// 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);
-}
diff --git a/quantum/template/ps2avrgb/i2c.h b/quantum/util.h
index 7ce50cdb57..bef3b9abe3 100644
--- a/quantum/template/ps2avrgb/i2c.h
+++ b/quantum/util.h
@@ -1,5 +1,5 @@
/*
-Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.com>
+Copyright 2011 Jun Wako <wakojun@gmail.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
@@ -14,14 +14,13 @@ 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
-// Please do not modify this file
+#include "bitwise.h"
-#ifndef __I2C_H__
-#define __I2C_H__
-
-void i2c_init(void);
-void i2c_set_bitrate(uint16_t bitrate_khz);
-uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length);
-
-#endif
+// convert to L string
+#define LSTR(s) XLSTR(s)
+#define XLSTR(s) L## #s
+// convert to string
+#define STR(s) XSTR(s)
+#define XSTR(s) #s
diff --git a/quantum/via.c b/quantum/via.c
index 288299ada8..c89b663b9b 100644
--- a/quantum/via.c
+++ b/quantum/via.c
@@ -46,6 +46,7 @@
#include "dynamic_keymap.h"
#include "tmk_core/common/eeprom.h"
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
+#include "via_ensure_keycode.h"
// Forward declare some helpers.
#if defined(VIA_QMK_BACKLIGHT_ENABLE)
@@ -111,7 +112,7 @@ void via_init(void) {
if (via_eeprom_is_valid()) {
} else {
// This resets the layout options
- via_set_layout_options(0);
+ via_set_layout_options(VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT);
// This resets the keymaps in EEPROM to what is in flash.
dynamic_keymap_reset();
// This resets the macros in EEPROM to nothing.
@@ -186,7 +187,7 @@ bool process_record_via(uint16_t keycode, keyrecord_t *record) {
// Keyboard level code can override this to handle custom messages from VIA.
// See raw_hid_receive() implementation.
-// DO NOT call raw_hid_send() in the overide function.
+// DO NOT call raw_hid_send() in the override function.
__attribute__((weak)) void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
uint8_t *command_id = &(data[0]);
*command_id = id_unhandled;
@@ -370,19 +371,6 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
dynamic_keymap_set_buffer(offset, size, &command_data[3]);
break;
}
- case id_eeprom_reset: {
- via_eeprom_reset();
- break;
- }
- case id_bootloader_jump: {
- // Need to send data back before the jump
- // Informs host that the command is handled
- raw_hid_send(data, length);
- // Give host time to read it
- wait_ms(100);
- bootloader_jump();
- break;
- }
default: {
// The command ID is not known
// Return the unhandled state
diff --git a/quantum/via.h b/quantum/via.h
index 8c2d545e9d..d0510fcabd 100644
--- a/quantum/via.h
+++ b/quantum/via.h
@@ -37,6 +37,14 @@
# define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 1
#endif
+// Allow override of the layout options default value.
+// This requires advanced knowledge of how VIA stores layout options
+// and is only really useful for setting a boolean layout option
+// state to true by default.
+#ifndef VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT
+# define VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT 0x00000000
+#endif
+
// The end of the EEPROM memory used by VIA
// By default, dynamic keymaps will start at this if there is no
// custom config
diff --git a/quantum/via_ensure_keycode.h b/quantum/via_ensure_keycode.h
new file mode 100644
index 0000000000..a9c1b8ba5d
--- /dev/null
+++ b/quantum/via_ensure_keycode.h
@@ -0,0 +1,366 @@
+#pragma once
+
+#include "quantum.h"
+#include "via.h"
+
+#ifndef VIA_HAS_BROKEN_KEYCODES
+
+_Static_assert(KC_NO == 0, "");
+_Static_assert(KC_TRNS == 1, "");
+
+_Static_assert(KC_A == 0x04, "");
+_Static_assert(KC_B == 0x05, "");
+_Static_assert(KC_C == 0x06, "");
+_Static_assert(KC_D == 0x07, "");
+_Static_assert(KC_E == 0x08, "");
+_Static_assert(KC_F == 0x09, "");
+_Static_assert(KC_G == 0x0A, "");
+_Static_assert(KC_H == 0x0B, "");
+_Static_assert(KC_I == 0x0C, "");
+_Static_assert(KC_J == 0x0D, "");
+_Static_assert(KC_K == 0x0E, "");
+_Static_assert(KC_L == 0x0F, "");
+_Static_assert(KC_M == 0x10, "");
+_Static_assert(KC_N == 0x11, "");
+_Static_assert(KC_O == 0x12, "");
+_Static_assert(KC_P == 0x13, "");
+_Static_assert(KC_Q == 0x14, "");
+_Static_assert(KC_R == 0x15, "");
+_Static_assert(KC_S == 0x16, "");
+_Static_assert(KC_T == 0x17, "");
+_Static_assert(KC_U == 0x18, "");
+_Static_assert(KC_V == 0x19, "");
+_Static_assert(KC_W == 0x1A, "");
+_Static_assert(KC_X == 0x1B, "");
+_Static_assert(KC_Y == 0x1C, "");
+_Static_assert(KC_Z == 0x1D, "");
+_Static_assert(KC_1 == 0x1E, "");
+_Static_assert(KC_2 == 0x1F, "");
+_Static_assert(KC_3 == 0x20, "");
+_Static_assert(KC_4 == 0x21, "");
+_Static_assert(KC_5 == 0x22, "");
+_Static_assert(KC_6 == 0x23, "");
+_Static_assert(KC_7 == 0x24, "");
+_Static_assert(KC_8 == 0x25, "");
+_Static_assert(KC_9 == 0x26, "");
+_Static_assert(KC_0 == 0x27, "");
+_Static_assert(KC_ENTER == 0x28, "");
+_Static_assert(KC_ESCAPE == 0x29, "");
+_Static_assert(KC_BSPACE == 0x2A, "");
+_Static_assert(KC_TAB == 0x2B, "");
+_Static_assert(KC_SPACE == 0x2C, "");
+_Static_assert(KC_MINUS == 0x2D, "");
+_Static_assert(KC_EQUAL == 0x2E, "");
+_Static_assert(KC_LBRACKET == 0x2F, "");
+_Static_assert(KC_RBRACKET == 0x30, "");
+_Static_assert(KC_BSLASH == 0x31, "");
+_Static_assert(KC_SCOLON == 0x33, "");
+_Static_assert(KC_QUOTE == 0x34, "");
+_Static_assert(KC_GRAVE == 0x35, "");
+_Static_assert(KC_COMMA == 0x36, "");
+_Static_assert(KC_DOT == 0x37, "");
+_Static_assert(KC_SLASH == 0x38, "");
+_Static_assert(KC_CAPSLOCK == 0x39, "");
+_Static_assert(KC_F1 == 0x3A, "");
+_Static_assert(KC_F2 == 0x3B, "");
+_Static_assert(KC_F3 == 0x3C, "");
+_Static_assert(KC_F4 == 0x3D, "");
+_Static_assert(KC_F5 == 0x3E, "");
+_Static_assert(KC_F6 == 0x3F, "");
+_Static_assert(KC_F7 == 0x40, "");
+_Static_assert(KC_F8 == 0x41, "");
+_Static_assert(KC_F9 == 0x42, "");
+_Static_assert(KC_F10 == 0x43, "");
+_Static_assert(KC_F11 == 0x44, "");
+_Static_assert(KC_F12 == 0x45, "");
+_Static_assert(KC_PSCREEN == 0x46, "");
+_Static_assert(KC_SCROLLLOCK == 0x47, "");
+_Static_assert(KC_PAUSE == 0x48, "");
+_Static_assert(KC_INSERT == 0x49, "");
+_Static_assert(KC_HOME == 0x4A, "");
+_Static_assert(KC_PGUP == 0x4B, "");
+_Static_assert(KC_DELETE == 0x4C, "");
+_Static_assert(KC_END == 0x4D, "");
+_Static_assert(KC_PGDOWN == 0x4E, "");
+_Static_assert(KC_RIGHT == 0x4F, "");
+_Static_assert(KC_LEFT == 0x50, "");
+_Static_assert(KC_DOWN == 0x51, "");
+_Static_assert(KC_UP == 0x52, "");
+_Static_assert(KC_NUMLOCK == 0x53, "");
+_Static_assert(KC_KP_SLASH == 0x54, "");
+_Static_assert(KC_KP_ASTERISK == 0x55, "");
+_Static_assert(KC_KP_MINUS == 0x56, "");
+_Static_assert(KC_KP_PLUS == 0x57, "");
+_Static_assert(KC_KP_ENTER == 0x58, "");
+_Static_assert(KC_KP_1 == 0x59, "");
+_Static_assert(KC_KP_2 == 0x5A, "");
+_Static_assert(KC_KP_3 == 0x5B, "");
+_Static_assert(KC_KP_4 == 0x5C, "");
+_Static_assert(KC_KP_5 == 0x5D, "");
+_Static_assert(KC_KP_6 == 0x5E, "");
+_Static_assert(KC_KP_7 == 0x5F, "");
+_Static_assert(KC_KP_8 == 0x60, "");
+_Static_assert(KC_KP_9 == 0x61, "");
+_Static_assert(KC_KP_0 == 0x62, "");
+_Static_assert(KC_KP_DOT == 0x63, "");
+_Static_assert(KC_APPLICATION == 0x65, "");
+_Static_assert(KC_KP_EQUAL == 0x67, "");
+_Static_assert(KC_KP_COMMA == 0x85, "");
+_Static_assert(KC_LCTRL == 0xE0, "");
+_Static_assert(KC_LSHIFT == 0xE1, "");
+_Static_assert(KC_LALT == 0xE2, "");
+_Static_assert(KC_LGUI == 0xE3, "");
+_Static_assert(KC_RCTRL == 0xE4, "");
+_Static_assert(KC_RSHIFT == 0xE5, "");
+_Static_assert(KC_RALT == 0xE6, "");
+_Static_assert(KC_RGUI == 0xE7, "");
+
+_Static_assert(KC_TILD == 0x235, "");
+_Static_assert(KC_EXLM == 0x21E, "");
+_Static_assert(KC_AT == 0x21F, "");
+_Static_assert(KC_HASH == 0x220, "");
+_Static_assert(KC_DLR == 0x221, "");
+_Static_assert(KC_PERC == 0x222, "");
+_Static_assert(KC_CIRC == 0x223, "");
+_Static_assert(KC_AMPR == 0x224, "");
+_Static_assert(KC_ASTR == 0x225, "");
+_Static_assert(KC_LPRN == 0x226, "");
+_Static_assert(KC_RPRN == 0x227, "");
+_Static_assert(KC_UNDS == 0x22D, "");
+_Static_assert(KC_PLUS == 0x22E, "");
+_Static_assert(KC_LCBR == 0x22F, "");
+_Static_assert(KC_RCBR == 0x230, "");
+_Static_assert(KC_LT == 0x236, "");
+_Static_assert(KC_GT == 0x237, "");
+_Static_assert(KC_COLN == 0x233, "");
+_Static_assert(KC_PIPE == 0x231, "");
+_Static_assert(KC_QUES == 0x238, "");
+_Static_assert(KC_DQUO == 0x234, "");
+
+_Static_assert(KC_NONUS_HASH == 0x32, "");
+_Static_assert(KC_NONUS_BSLASH == 0x64, "");
+_Static_assert(KC_RO == 0x87, "");
+_Static_assert(KC_KANA == 0x88, "");
+_Static_assert(KC_JYEN == 0x89, "");
+_Static_assert(KC_HENK == 0x8A, "");
+_Static_assert(KC_MHEN == 0x8B, "");
+_Static_assert(KC_LANG1 == 0x90, "");
+_Static_assert(KC_LANG2 == 0x91, "");
+
+_Static_assert(KC_GESC == 0x5C16, "");
+_Static_assert(KC_LSPO == 0x5CD7, "");
+_Static_assert(KC_RSPC == 0x5CD8, "");
+_Static_assert(KC_LCPO == 0x5CF3, "");
+_Static_assert(KC_RCPC == 0x5CF4, "");
+_Static_assert(KC_LAPO == 0x5CF5, "");
+_Static_assert(KC_RAPC == 0x5CF6, "");
+_Static_assert(KC_SFTENT == 0x5CD9, "");
+
+_Static_assert(BL_TOGG == 23743, "");
+_Static_assert(BL_STEP == 23744, "");
+_Static_assert(BL_BRTG == 23745, "");
+_Static_assert(BL_ON == 23739, "");
+_Static_assert(BL_OFF == 23740, "");
+_Static_assert(BL_INC == 23742, "");
+_Static_assert(BL_DEC == 23741, "");
+_Static_assert(RGB_TOG == 23746, "");
+_Static_assert(RGB_MOD == 23747, "");
+_Static_assert(RGB_RMOD == 23748, "");
+_Static_assert(RGB_HUI == 23749, "");
+_Static_assert(RGB_HUD == 23750, "");
+_Static_assert(RGB_SAI == 23751, "");
+_Static_assert(RGB_SAD == 23752, "");
+_Static_assert(RGB_VAI == 23753, "");
+_Static_assert(RGB_VAD == 23754, "");
+_Static_assert(RGB_SPI == 23755, "");
+_Static_assert(RGB_SPD == 23756, "");
+_Static_assert(RGB_M_P == 23757, "");
+_Static_assert(RGB_M_B == 23758, "");
+_Static_assert(RGB_M_R == 23759, "");
+_Static_assert(RGB_M_SW == 23760, "");
+_Static_assert(RGB_M_SN == 23761, "");
+_Static_assert(RGB_M_K == 23762, "");
+_Static_assert(RGB_M_X == 23763, "");
+_Static_assert(RGB_M_G == 23764, "");
+_Static_assert(RGB_M_T == 23765, "");
+
+_Static_assert(KC_F13 == 104, "");
+_Static_assert(KC_F14 == 105, "");
+_Static_assert(KC_F15 == 106, "");
+_Static_assert(KC_F16 == 107, "");
+_Static_assert(KC_F17 == 108, "");
+_Static_assert(KC_F18 == 109, "");
+_Static_assert(KC_F19 == 110, "");
+_Static_assert(KC_F20 == 111, "");
+_Static_assert(KC_F21 == 112, "");
+_Static_assert(KC_F22 == 113, "");
+_Static_assert(KC_F23 == 114, "");
+_Static_assert(KC_F24 == 115, "");
+_Static_assert(KC_PWR == 165, "");
+_Static_assert(KC_SLEP == 166, "");
+_Static_assert(KC_WAKE == 167, "");
+_Static_assert(KC_EXEC == 116, "");
+_Static_assert(KC_HELP == 117, "");
+_Static_assert(KC_SLCT == 119, "");
+_Static_assert(KC_STOP == 120, "");
+_Static_assert(KC_AGIN == 121, "");
+_Static_assert(KC_UNDO == 122, "");
+_Static_assert(KC_CUT == 123, "");
+_Static_assert(KC_COPY == 124, "");
+_Static_assert(KC_PSTE == 125, "");
+_Static_assert(KC_FIND == 126, "");
+_Static_assert(KC_CALC == 178, "");
+_Static_assert(KC_MAIL == 177, "");
+_Static_assert(KC_MSEL == 175, "");
+_Static_assert(KC_MYCM == 179, "");
+_Static_assert(KC_WSCH == 180, "");
+_Static_assert(KC_WHOM == 181, "");
+_Static_assert(KC_WBAK == 182, "");
+_Static_assert(KC_WFWD == 183, "");
+_Static_assert(KC_WSTP == 184, "");
+_Static_assert(KC_WREF == 185, "");
+_Static_assert(KC_WFAV == 186, "");
+_Static_assert(KC_BRIU == 189, "");
+_Static_assert(KC_BRID == 190, "");
+_Static_assert(KC_MPRV == 172, "");
+_Static_assert(KC_MNXT == 171, "");
+_Static_assert(KC_MUTE == 168, "");
+_Static_assert(KC_VOLD == 170, "");
+_Static_assert(KC_VOLU == 169, "");
+_Static_assert(KC_MSTP == 173, "");
+_Static_assert(KC_MPLY == 174, "");
+_Static_assert(KC_MRWD == 188, "");
+_Static_assert(KC_MFFD == 187, "");
+_Static_assert(KC_EJCT == 176, "");
+_Static_assert(KC_MS_U == 240, "");
+_Static_assert(KC_MS_D == 241, "");
+_Static_assert(KC_MS_L == 242, "");
+_Static_assert(KC_MS_R == 243, "");
+_Static_assert(KC_BTN1 == 244, "");
+_Static_assert(KC_BTN2 == 245, "");
+_Static_assert(KC_BTN3 == 246, "");
+_Static_assert(KC_BTN4 == 247, "");
+_Static_assert(KC_BTN5 == 248, "");
+_Static_assert(KC_WH_U == 249, "");
+_Static_assert(KC_WH_D == 250, "");
+_Static_assert(KC_WH_L == 251, "");
+_Static_assert(KC_WH_R == 252, "");
+_Static_assert(KC_ACL0 == 253, "");
+_Static_assert(KC_ACL1 == 254, "");
+_Static_assert(KC_ACL2 == 255, "");
+_Static_assert(KC_LCAP == 130, "");
+_Static_assert(KC_LNUM == 131, "");
+_Static_assert(KC_LSCR == 132, "");
+
+_Static_assert(FN_MO13 == 0x5F10, "");
+_Static_assert(FN_MO23 == 0x5F11, "");
+
+_Static_assert(MACRO00 == 0x5F12, "");
+_Static_assert(MACRO01 == 0x5F13, "");
+_Static_assert(MACRO02 == 0x5F14, "");
+_Static_assert(MACRO03 == 0x5F15, "");
+_Static_assert(MACRO04 == 0x5F16, "");
+_Static_assert(MACRO05 == 0x5F17, "");
+_Static_assert(MACRO06 == 0x5F18, "");
+_Static_assert(MACRO07 == 0x5F19, "");
+_Static_assert(MACRO08 == 0x5F1A, "");
+_Static_assert(MACRO09 == 0x5F1B, "");
+_Static_assert(MACRO10 == 0x5F1C, "");
+_Static_assert(MACRO11 == 0x5F1D, "");
+_Static_assert(MACRO12 == 0x5F1E, "");
+_Static_assert(MACRO13 == 0x5F1F, "");
+_Static_assert(MACRO14 == 0x5F20, "");
+_Static_assert(MACRO15 == 0x5F21, "");
+
+_Static_assert(USER00 == 0x5F80, "");
+_Static_assert(USER01 == 0x5F81, "");
+_Static_assert(USER02 == 0x5F82, "");
+_Static_assert(USER03 == 0x5F83, "");
+_Static_assert(USER04 == 0x5F84, "");
+_Static_assert(USER05 == 0x5F85, "");
+_Static_assert(USER06 == 0x5F86, "");
+_Static_assert(USER07 == 0x5F87, "");
+_Static_assert(USER08 == 0x5F88, "");
+_Static_assert(USER09 == 0x5F89, "");
+_Static_assert(USER10 == 0x5F8A, "");
+_Static_assert(USER11 == 0x5F8B, "");
+_Static_assert(USER12 == 0x5F8C, "");
+_Static_assert(USER13 == 0x5F8D, "");
+_Static_assert(USER14 == 0x5F8E, "");
+_Static_assert(USER15 == 0x5F8F, "");
+
+_Static_assert(KC_POWER == 102, "");
+_Static_assert(KC_MENU == 118, "");
+_Static_assert(KC_KP_EQUAL_AS400 == 134, "");
+_Static_assert(KC_INT6 == 140, "");
+_Static_assert(KC_INT7 == 141, "");
+_Static_assert(KC_INT8 == 142, "");
+_Static_assert(KC_INT9 == 143, "");
+_Static_assert(KC_LANG3 == 146, "");
+_Static_assert(KC_LANG4 == 147, "");
+_Static_assert(KC_LANG5 == 148, "");
+_Static_assert(KC_LANG6 == 149, "");
+_Static_assert(KC_LANG7 == 150, "");
+_Static_assert(KC_LANG8 == 151, "");
+_Static_assert(KC_LANG9 == 152, "");
+_Static_assert(KC_ERAS == 153, "");
+_Static_assert(KC_SYSREQ == 154, "");
+_Static_assert(KC_CANCEL == 155, "");
+_Static_assert(KC_CLEAR == 156, "");
+_Static_assert(KC_CLR == 156, "");
+_Static_assert(KC_PRIOR == 157, "");
+_Static_assert(KC_OUT == 160, "");
+_Static_assert(KC_OPER == 161, "");
+_Static_assert(KC_CLEAR_AGAIN == 162, "");
+_Static_assert(KC_CRSEL == 163, "");
+_Static_assert(KC_EXSEL == 164, "");
+_Static_assert(KC_FN0 == 192, "");
+_Static_assert(KC_FN1 == 193, "");
+_Static_assert(KC_FN2 == 194, "");
+_Static_assert(KC_FN3 == 195, "");
+_Static_assert(KC_FN4 == 196, "");
+_Static_assert(KC_FN5 == 197, "");
+_Static_assert(KC_FN6 == 198, "");
+_Static_assert(KC_FN7 == 199, "");
+_Static_assert(KC_FN8 == 200, "");
+_Static_assert(KC_FN9 == 201, "");
+_Static_assert(KC_FN10 == 202, "");
+_Static_assert(KC_FN11 == 203, "");
+_Static_assert(KC_FN12 == 204, "");
+_Static_assert(KC_FN13 == 205, "");
+_Static_assert(KC_FN14 == 206, "");
+_Static_assert(KC_FN15 == 207, "");
+_Static_assert(KC_FN16 == 208, "");
+_Static_assert(KC_FN17 == 209, "");
+_Static_assert(KC_FN18 == 210, "");
+_Static_assert(KC_FN19 == 211, "");
+_Static_assert(KC_FN20 == 212, "");
+_Static_assert(KC_FN21 == 213, "");
+_Static_assert(KC_FN22 == 214, "");
+_Static_assert(KC_FN23 == 215, "");
+_Static_assert(KC_FN24 == 216, "");
+_Static_assert(KC_FN25 == 217, "");
+_Static_assert(KC_FN26 == 218, "");
+_Static_assert(KC_FN27 == 219, "");
+_Static_assert(KC_FN28 == 220, "");
+_Static_assert(KC_FN29 == 221, "");
+_Static_assert(KC_FN30 == 222, "");
+_Static_assert(KC_FN31 == 223, "");
+_Static_assert(RESET == 23552, "");
+_Static_assert(DEBUG == 23553, "");
+_Static_assert(MAGIC_TOGGLE_NKRO == 23572, "");
+_Static_assert(AU_ON == 23581, "");
+_Static_assert(AU_OFF == 23582, "");
+_Static_assert(AU_TOG == 23583, "");
+_Static_assert(CLICKY_TOGGLE == 23584, "");
+_Static_assert(CLICKY_ENABLE == 23585, "");
+_Static_assert(CLICKY_DISABLE == 23586, "");
+_Static_assert(CLICKY_UP == 23587, "");
+_Static_assert(CLICKY_DOWN == 23588, "");
+_Static_assert(CLICKY_RESET == 23589, "");
+_Static_assert(MU_ON == 23590, "");
+_Static_assert(MU_OFF == 23591, "");
+_Static_assert(MU_TOG == 23592, "");
+_Static_assert(MU_MOD == 23593, "");
+
+#endif
diff --git a/quantum/wpm.c b/quantum/wpm.c
index d4c971f313..da30bd252c 100644
--- a/quantum/wpm.c
+++ b/quantum/wpm.c
@@ -17,12 +17,12 @@
#include "wpm.h"
-//WPM Stuff
-static uint8_t current_wpm = 0;
-static uint8_t latest_wpm = 0;
-static uint16_t wpm_timer = 0;
+// WPM Stuff
+static uint8_t current_wpm = 0;
+static uint8_t latest_wpm = 0;
+static uint16_t wpm_timer = 0;
-//This smoothing is 40 keystrokes
+// This smoothing is 40 keystrokes
static const float wpm_smoothing = 0.0487;
void set_current_wpm(uint8_t new_wpm) { current_wpm = new_wpm; }
@@ -34,34 +34,31 @@ bool wpm_keycode(uint16_t keycode) { return wpm_keycode_kb(keycode); }
__attribute__((weak)) bool wpm_keycode_kb(uint16_t keycode) { return wpm_keycode_user(keycode); }
__attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) {
-
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
keycode = keycode & 0xFF;
} else if (keycode > 0xFF) {
- keycode = 0;
+ keycode = 0;
}
- if((keycode >= KC_A && keycode <= KC_0) || (keycode >= KC_TAB && keycode <= KC_SLASH)) {
- return true;
+ if ((keycode >= KC_A && keycode <= KC_0) || (keycode >= KC_TAB && keycode <= KC_SLASH)) {
+ return true;
}
return false;
}
-
void update_wpm(uint16_t keycode) {
- if(wpm_keycode(keycode)) {
- if(wpm_timer > 0) {
- latest_wpm = 60000 / timer_elapsed(wpm_timer) / 5;
- current_wpm = (latest_wpm - current_wpm) * wpm_smoothing + current_wpm;
- }
- wpm_timer = timer_read();
+ if (wpm_keycode(keycode)) {
+ if (wpm_timer > 0) {
+ latest_wpm = 60000 / timer_elapsed(wpm_timer) / 5;
+ current_wpm = (latest_wpm - current_wpm) * wpm_smoothing + current_wpm;
+ }
+ wpm_timer = timer_read();
}
}
void decay_wpm(void) {
- if (timer_elapsed(wpm_timer) > 1000) {
- current_wpm = (0 - current_wpm) * wpm_smoothing +
- current_wpm;
- wpm_timer = timer_read();
- }
+ if (timer_elapsed(wpm_timer) > 1000) {
+ current_wpm = (0 - current_wpm) * wpm_smoothing + current_wpm;
+ wpm_timer = timer_read();
+ }
}
diff --git a/quantum/wpm.h b/quantum/wpm.h
index fa0b6d1288..15ab4ffcd1 100644
--- a/quantum/wpm.h
+++ b/quantum/wpm.h
@@ -23,8 +23,8 @@ bool wpm_keycode(uint16_t keycode);
bool wpm_keycode_kb(uint16_t keycode);
bool wpm_keycode_user(uint16_t keycode);
-void set_current_wpm(uint8_t);
+void set_current_wpm(uint8_t);
uint8_t get_current_wpm(void);
-void update_wpm(uint16_t);
+void update_wpm(uint16_t);
void decay_wpm(void);
diff --git a/readme.md b/readme.md
index b9639565e4..dd1aab5536 100644
--- a/readme.md
+++ b/readme.md
@@ -6,6 +6,14 @@
[![GitHub forks](https://img.shields.io/github/forks/ErgoDox-EZ/qmk_firmware.svg?style=social&label=Fork)](https://github.com/ErgoDox-EZ/qmk_firmware/)
This purpose of this fork is maintain a clean repo that only contains the keyboard code that we need, and as little else as possible. This is to keep it lightweight, since we only need a couple of keyboards. This is the repo that the EZ Configurator will pull from.
+## Documentation
+
+* [See the official documentation on docs.qmk.fm](https://docs.qmk.fm)
+
+The docs are powered by [Docsify](https://docsify.js.org/) and hosted on [GitHub](/docs/). They are also viewable offline; see [Previewing the Documentation](https://docs.qmk.fm/#/contributing?id=previewing-the-documentation) for more details.
+
+You can request changes by making a fork and opening a [pull request](https://github.com/qmk/qmk_firmware/pulls), or by clicking the "Edit this page" link at the bottom of any page.
+
## Supported Keyboards
@@ -24,8 +32,7 @@ qmk setup zsa/qmk_firmware -b firmware20
## Maintainers
-QMK is developed and maintained by Jack Humbert of OLKB with contributions from the community, and of course, [Hasu](https://github.com/tmk). The ZSA branch is maintained by Drashna, ZSA's official QMK Liaison, and by Florian Didron, ZSA's lead developer, with input from Erez Zukerman (ZSA CEO).
-
+QMK is developed and maintained by Jack Humbert of OLKB with contributions from the community, and of course, [Hasu](https://github.com/tmk). The OLKB product firmwares are maintained by [Jack Humbert](https://github.com/jackhumbert), the Ergodox EZ by [ZSA Technology Labs](https://github.com/zsa), the Clueboard by [Zach White](https://github.com/skullydazed), and the Atreus by [Phil Hagelberg](https://github.com/technomancy).
# Update Process
@@ -41,8 +48,19 @@ QMK is developed and maintained by Jack Humbert of OLKB with contributions from
- [https://github.com/qmk/qmk_firmware/commits/master/drivers](https://github.com/qmk/qmk_firmware/commits/master/drivers)
- [https://github.com/qmk/qmk_firmware/commits/master/lib](https://github.com/qmk/qmk_firmware/commits/master/lib)
- These folders are the important ones for maintaining the repo and keeping it properly up to date. Most, but not all, changes on this list should be pulled into our repo.
-3. `git cherry-pick` the commits we want
- - `git rm docs/* -r` to remove the document updates when cherry picking. Repeat for any keyboard/keymap/etc that have changes that we aren't interested in
+4. `git merge (hash|tag)`
+ - `git rm -rf docs users layouts .vscode` to remove the docs and user code that we don't want.
+ - To remove all of the keyboard exept the ones we want:
+ ```sh
+ find ./keyboards -mindepth 1 -maxdepth 1 -type d -not -name ergodox_ez -not -name planck -not -name moonlander -exec git rm -rf '{}' \;`
+ find ./keyboards/planck -mindepth 1 -maxdepth 1 -type d -not -name ez -not -name keymaps -exec git rm -rf '{}' \;
+ ```
+ - To remove all of the keymaps from folder that we don't want:
+ ```sh
+ find ./keyboards/ -mindepth 3 -maxdepth 3 -type d -not -name default -not -name oryx -not -name webusb -not -name glow -not -name reactive -not -name shine -not -name keymaps -exec git rm -rf '{}' \;
+ ```
+ - Resolve merge conflicts, and commit.
+
4. Commit update
* Include commit info in `[changelog.md](http://changelog.md)`
5. Open Pull request, and include information about the commit
@@ -50,7 +68,3 @@ QMK is developed and maintained by Jack Humbert of OLKB with contributions from
## Strategy
To keep PRs small and easier to test, they should ideally be 1:1 with commits from QMK Firmware master. They should only group commits if/when it makes sense. Such as multiple commits for a specific feature (split RGB support, for instance)
-
-## Merging
-
-Pull Requests should be merged/rebased, not squashed, so we can maintain a commit history that is close to QMK Firmware's, for ease of reference.
diff --git a/requirements.txt b/requirements.txt
index 6e907cf8e8..8553e2c3f0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,8 @@
appdirs
argcomplete
colorama
+dotty-dict
hjson
-milc
+jsonschema>=3
+milc>=1.3.0
pygments
diff --git a/setup.cfg b/setup.cfg
index 5ef2f9ba09..baa6a03967 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -3,6 +3,8 @@
ignore =
# QMK is ok with long lines.
E501
+ # Conflicts with our yapf config
+ E231
per_file_ignores =
**/__init__.py:F401
diff --git a/shell.nix b/shell.nix
index 82505d5d27..e82436ae11 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,57 +1,16 @@
{ avr ? true, arm ? true, teensy ? true }:
-
let
- nixpkgs = builtins.fetchTarball {
- url = "https://github.com/NixOS/nixpkgs/archive/c4b26e702044dbf40f8236136c099d8ab6778514.tar.gz";
- sha256 = "0w6hgs01qzni3a7cvgadjlmcdlb6vay3w910vh4k9fc949ii7s60";
- };
-
- pkgs = import nixpkgs { };
-
- hjson = with pkgs.python3Packages; buildPythonPackage rec {
- pname = "hjson";
- version = "3.0.1";
-
- src = fetchPypi {
- inherit pname version;
- sha256 = "1yaimcgz8w0ps1wk28wk9g9zdidp79d14xqqj9rjkvxalvx2f5qx";
- };
-
- doCheck = false;
+ # We specify sources via Niv: use "niv update nixpkgs" to update nixpkgs, for example.
+ sources = import ./nix/sources.nix {};
+ pkgs = import sources.nixpkgs {};
+
+ # Builds the python env based on nix/pyproject.toml and
+ # nix/poetry.lock Use the "poetry update --lock", "poetry add
+ # --lock" etc. in the nix folder to adjust the contents of those
+ # files if the requirements*.txt files change
+ pythonEnv = pkgs.poetry2nix.mkPoetryEnv {
+ projectDir = ./nix;
};
-
- milc = with pkgs.python3Packages; buildPythonPackage rec {
- pname = "milc";
- version = "1.0.10";
-
- src = fetchPypi {
- inherit pname version;
- sha256 = "1q1p7qrqk78mw67nhv04zgxaq8himmdxmy2vp4fmi7chwgcbpi32";
- };
-
- propagatedBuildInputs = [
- appdirs
- argcomplete
- colorama
- ];
-
- doCheck = false;
- };
-
- pythonEnv = pkgs.python3.withPackages (p: with p; [
- # requirements.txt
- appdirs
- argcomplete
- colorama
- hjson
- milc
- pygments
- # requirements-dev.txt
- nose2
- flake8
- pep8-naming
- yapf
- ]);
in
with pkgs;
@@ -71,7 +30,7 @@ in
mkShell {
name = "qmk-firmware";
- buildInputs = [ clang-tools dfu-programmer dfu-util diffutils git pythonEnv ]
+ buildInputs = [ clang-tools dfu-programmer dfu-util diffutils git pythonEnv poetry niv ]
++ lib.optional avr [
pkgsCross.avr.buildPackages.binutils
pkgsCross.avr.buildPackages.gcc8
diff --git a/show_options.mk b/show_options.mk
index 15407dfd2a..cd04f6a0d7 100644
--- a/show_options.mk
+++ b/show_options.mk
@@ -26,7 +26,6 @@ HARDWARE_OPTION_NAMES = \
MIDI_ENABLE \
BLUETOOTH_ENABLE \
AUDIO_ENABLE \
- FAUXCLICKY_ENABLE \
HD44780_ENABLE \
ENCODER_ENABLE \
LCD_ENABLE \
@@ -50,6 +49,7 @@ OTHER_OPTION_NAMES = \
STENO_ENABLE \
TAP_DANCE_ENABLE \
VIRTSER_ENABLE \
+ OLED_DRIVER_ENABLE \
OLED_ENABLE \
LED_BACK_ENABLE \
LED_UNDERGLOW_ENABLE \
@@ -58,10 +58,8 @@ OTHER_OPTION_NAMES = \
HELIX ZINC \
ADAFRUIT_BLE_ENABLE \
AUTOLOG_ENABLE \
- BREATHING_LED_ENABLE \
DEBUG_ENABLE \
ENCODER_ENABLE_CUSTOM \
- FADING_LED_ENABLE \
GERMAN_ENABLE \
HAPTIC_ENABLE \
HHKB_RN42_ENABLE \
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index dcdb6a449a..2bc7cc9553 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -154,38 +154,45 @@ dfu-split-left: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size
dfu-split-right: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size
$(call EXEC_DFU,eeprom-righthand.eep)
+AVRDUDE_PROGRAMMER ?= avrdude
+
define EXEC_AVRDUDE
- USB= ;\
- if $(GREP) -q -s Microsoft /proc/version; then \
- echo 'ERROR: AVR flashing cannot be automated within the Windows Subsystem for Linux (WSL) currently. Instead, take the .hex file generated and flash it using QMK Toolbox, AVRDUDE, AVRDUDESS, or XLoader.'; \
- else \
- printf "Detecting USB port, reset your controller now."; \
- TMP1=`mktemp`; \
- TMP2=`mktemp`; \
- ls /dev/tty* > $$TMP1; \
- while [ -z $$USB ]; do \
- sleep 0.5; \
- printf "."; \
- ls /dev/tty* > $$TMP2; \
- USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
- mv $$TMP2 $$TMP1; \
- done; \
- rm $$TMP1; \
- echo ""; \
- echo "Device $$USB has appeared; assuming it is the controller."; \
- if $(GREP) -q -s 'MINGW\|MSYS' /proc/version; then \
- USB=`echo "$$USB" | perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e'`; \
- echo "Remapped MSYS2 USB port to $$USB"; \
- sleep 1; \
+ list_devices() { \
+ if $(GREP) -q -s icrosoft /proc/version; then \
+ wmic.exe path Win32_SerialPort get DeviceID 2>/dev/null | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | xargs echo -n | sort; \
+ elif [ "`uname`" = "FreeBSD" ]; then \
+ ls /dev/tty* | grep -v '\.lock$$' | grep -v '\.init$$'; \
else \
- printf "Waiting for $$USB to become writable."; \
- while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \
+ ls /dev/tty*; \
fi; \
- if [ -z "$(1)" ]; then \
- avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
- else \
- avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex -U eeprom:w:$(QUANTUM_PATH)/split_common/$(1); \
- fi \
+ }; \
+ USB= ;\
+ printf "Detecting USB port, reset your controller now."; \
+ TMP1=`mktemp`; \
+ TMP2=`mktemp`; \
+ list_devices > $$TMP1; \
+ while [ -z "$$USB" ]; do \
+ sleep 0.5; \
+ printf "."; \
+ list_devices > $$TMP2; \
+ USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
+ mv $$TMP2 $$TMP1; \
+ done; \
+ rm $$TMP1; \
+ echo ""; \
+ echo "Device $$USB has appeared; assuming it is the controller."; \
+ if $(GREP) -q -s 'MINGW\|MSYS\|icrosoft' /proc/version; then \
+ USB=`echo "$$USB" | LANG=C perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e'`; \
+ echo "Remapped USB port to $$USB"; \
+ sleep 1; \
+ else \
+ printf "Waiting for $$USB to become writable."; \
+ while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \
+ fi; \
+ if [ -z "$(1)" ]; then \
+ $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
+ else \
+ $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex -U eeprom:w:$(QUANTUM_PATH)/split_common/$(1); \
fi
endef
@@ -204,7 +211,7 @@ avrdude-split-right: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
$(call EXEC_AVRDUDE,eeprom-righthand.eep)
define EXEC_USBASP
- avrdude -p $(MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex
+ $(AVRDUDE_PROGRAMMER) -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex
endef
usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
@@ -283,8 +290,11 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
$(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof
bootloader:
+ifneq ($(strip $(BOOTLOADER)), qmk-dfu)
+ $(error Please set BOOTLOADER = qmk-dfu first!)
+endif
make -C lib/lufa/Bootloaders/DFU/ clean
- $(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS)
+ bin/qmk generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index e94e935ebb..40595a1e3b 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -71,6 +71,9 @@ else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/board/board.mk)","
BOARD_PATH = $(TOP_DIR)/platforms/chibios/$(BOARD)
BOARD_MK += $(TOP_DIR)/platforms/chibios/$(BOARD)/board/board.mk
KEYBOARD_PATHS += $(BOARD_PATH)/configs
+ ifneq ("$(wildcard $(BOARD_PATH)/rules.mk)","")
+ include $(BOARD_PATH)/rules.mk
+ endif
endif
ifeq ("$(wildcard $(BOARD_MK))","")
@@ -309,6 +312,7 @@ LDFLAGS += -mno-thumb-interwork -mthumb
LDSYMBOLS =,--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE)
LDSYMBOLS :=$(LDSYMBOLS),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE)
LDFLAGS += -Wl,--script=$(LDSCRIPT)$(LDSYMBOLS)
+LDFLAGS += --specs=nano.specs
OPT_DEFS += -DPROTOCOL_CHIBIOS
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index 5ead3c090f..bcc44a63e6 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -10,27 +10,20 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/action_macro.c \
$(COMMON_DIR)/action_layer.c \
$(COMMON_DIR)/action_util.c \
- $(COMMON_DIR)/print.c \
$(COMMON_DIR)/debug.c \
$(COMMON_DIR)/sendchar_null.c \
- $(COMMON_DIR)/util.c \
$(COMMON_DIR)/eeconfig.c \
$(COMMON_DIR)/report.c \
$(PLATFORM_COMMON_DIR)/suspend.c \
$(PLATFORM_COMMON_DIR)/timer.c \
+ $(COMMON_DIR)/sync_timer.c \
$(PLATFORM_COMMON_DIR)/bootloader.c \
-ifeq ($(PLATFORM),AVR)
- TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/xprintf.S
-else ifeq ($(PLATFORM),CHIBIOS)
- TMK_COMMON_SRC += $(PRINTF_PATH)/printf.c
- TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT
- TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL
- TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG
- TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T
- VPATH += $(PRINTF_PATH)
-else ifeq ($(PLATFORM),ARM_ATSAM)
- TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/printf.c
+# Use platform provided print - fall back to lib/printf
+ifneq ("$(wildcard $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk)","")
+ include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk
+else
+ include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk
endif
# Option modules
@@ -67,10 +60,6 @@ ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes)
endif
ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
- TMK_COMMON_SRC += $(COMMON_DIR)/mousekey.c
- TMK_COMMON_DEFS += -DMOUSEKEY_ENABLE
- TMK_COMMON_DEFS += -DMOUSE_ENABLE
-
ifeq ($(strip $(MOUSE_SHARED_EP)), yes)
TMK_COMMON_DEFS += -DMOUSE_SHARED_EP
SHARED_EP_ENABLE = yes
@@ -98,17 +87,16 @@ else
TMK_COMMON_DEFS += -DNO_DEBUG
endif
-ifeq ($(strip $(COMMAND_ENABLE)), yes)
- TMK_COMMON_SRC += $(COMMON_DIR)/command.c
- TMK_COMMON_DEFS += -DCOMMAND_ENABLE
-endif
-
ifeq ($(strip $(NKRO_ENABLE)), yes)
- ifneq ($(PROTOCOL),VUSB)
+ ifeq ($(PROTOCOL), VUSB)
+ $(info NKRO is not currently supported on V-USB, and has been disabled.)
+ else ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
+ $(info NKRO is not currently supported with Bluetooth, and has been disabled.)
+ else ifneq ($(BLUETOOTH),)
+ $(info NKRO is not currently supported with Bluetooth, and has been disabled.)
+ else
TMK_COMMON_DEFS += -DNKRO_ENABLE
SHARED_EP_ENABLE = yes
- else
- $(info NKRO is not currently supported on V-USB, and has been disabled.)
endif
endif
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index b87b9e7282..055bd91de0 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -47,10 +47,6 @@ int tp_buttons;
int retro_tapping_counter = 0;
#endif
-#ifdef FAUXCLICKY_ENABLE
-# include "fauxclicky.h"
-#endif
-
#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { return false; }
#endif
@@ -80,15 +76,10 @@ void action_exec(keyevent_t event) {
#endif
}
-#ifdef FAUXCLICKY_ENABLE
- if (IS_PRESSED(event)) {
- FAUXCLICKY_ACTION_PRESS;
- }
- if (IS_RELEASED(event)) {
- FAUXCLICKY_ACTION_RELEASE;
+ if (event.pressed) {
+ // clear the potential weak mods left by previously pressed keys
+ clear_weak_mods();
}
- fauxclicky_check();
-#endif
#ifdef SWAP_HANDS_ENABLE
if (!IS_NOEVENT(event)) {
@@ -251,11 +242,6 @@ void process_action(keyrecord_t *record, action_t action) {
uint8_t tap_count = record->tap.count;
#endif
- if (event.pressed) {
- // clear the potential weak mods left by previously pressed keys
- clear_weak_mods();
- }
-
#ifndef NO_ACTION_ONESHOT
bool do_release_oneshot = false;
// notice we only clear the one shot layer if the pressed key is not a modifier.
@@ -424,56 +410,22 @@ void process_action(keyrecord_t *record, action_t action) {
case ACT_MOUSEKEY:
if (event.pressed) {
mousekey_on(action.key.code);
- switch (action.key.code) {
-# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
- case KC_MS_BTN1:
- register_button(true, MOUSE_BTN1);
- break;
- case KC_MS_BTN2:
- register_button(true, MOUSE_BTN2);
- break;
- case KC_MS_BTN3:
- register_button(true, MOUSE_BTN3);
- break;
-# endif
-# ifdef POINTING_DEVICE_ENABLE
- case KC_MS_BTN4:
- register_button(true, MOUSE_BTN4);
- break;
- case KC_MS_BTN5:
- register_button(true, MOUSE_BTN5);
- break;
-# endif
- default:
- mousekey_send();
- break;
- }
} else {
mousekey_off(action.key.code);
- switch (action.key.code) {
+ }
+ switch (action.key.code) {
# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
- case KC_MS_BTN1:
- register_button(false, MOUSE_BTN1);
- break;
- case KC_MS_BTN2:
- register_button(false, MOUSE_BTN2);
- break;
- case KC_MS_BTN3:
- register_button(false, MOUSE_BTN3);
- break;
-# endif
-# ifdef POINTING_DEVICE_ENABLE
- case KC_MS_BTN4:
- register_button(false, MOUSE_BTN4);
- break;
- case KC_MS_BTN5:
- register_button(false, MOUSE_BTN5);
- break;
+# ifdef POINTING_DEVICE_ENABLE
+ case KC_MS_BTN1 ... KC_MS_BTN8:
+# else
+ case KC_MS_BTN1 ... KC_MS_BTN3:
+# endif
+ register_button(event.pressed, MOUSE_BTN_MASK(action.key.code - KC_MS_BTN1));
+ break;
# endif
- default:
- mousekey_send();
- break;
- }
+ default:
+ mousekey_send();
+ break;
}
break;
#endif
@@ -936,23 +888,28 @@ void unregister_code(uint8_t code) {
#endif
}
-/** \brief Utilities for actions. (FIXME: Needs better description)
+/** \brief Tap a keycode with a delay.
*
- * FIXME: Needs documentation.
+ * \param code The basic keycode to tap.
+ * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
*/
-void tap_code(uint8_t code) {
+void tap_code_delay(uint8_t code, uint16_t delay) {
register_code(code);
- if (code == KC_CAPS) {
- wait_ms(TAP_HOLD_CAPS_DELAY);
- } else {
- wait_ms(TAP_CODE_DELAY);
+ for (uint16_t i = delay; i > 0; i--) {
+ wait_ms(1);
}
unregister_code(code);
}
+/** \brief Tap a keycode with the default delay.
+ *
+ * \param code The basic keycode to tap. If `code` is `KC_CAPS`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
+ */
+void tap_code(uint8_t code) { tap_code_delay(code, code == KC_CAPS ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); }
+
/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
*
- * \param mods A bitfield of modifiers to unregister.
+ * \param mods A bitfield of modifiers to register.
*/
void register_mods(uint8_t mods) {
if (mods) {
@@ -972,6 +929,7 @@ void unregister_mods(uint8_t mods) {
}
}
+
/** \brief Adds the given weak modifiers and sends a keyboard report immediately.
*
* \param mods A bitfield of modifiers to register.
@@ -1017,6 +975,10 @@ void clear_keyboard_but_mods(void) {
* FIXME: Needs documentation.
*/
void clear_keyboard_but_mods_and_keys() {
+#ifdef EXTRAKEY_ENABLE
+ host_system_send(0);
+ host_consumer_send(0);
+#endif
clear_weak_mods();
clear_macro_mods();
send_keyboard_report();
@@ -1024,10 +986,6 @@ void clear_keyboard_but_mods_and_keys() {
mousekey_clear();
mousekey_send();
#endif
-#ifdef EXTRAKEY_ENABLE
- host_system_send(0);
- host_consumer_send(0);
-#endif
}
/** \brief Utilities for actions. (FIXME: Needs better description)
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 81cd54369c..9a991de1c2 100644
--- a/tmk_core/common/action.h
+++ b/tmk_core/common/action.h
@@ -100,6 +100,7 @@ void process_action(keyrecord_t *record, action_t action);
void register_code(uint8_t code);
void unregister_code(uint8_t code);
void tap_code(uint8_t code);
+void tap_code_delay(uint8_t code, uint16_t delay);
void register_mods(uint8_t mods);
void unregister_mods(uint8_t mods);
void register_weak_mods(uint8_t mods);
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c
index fe545c79a0..56044e096d 100644
--- a/tmk_core/common/action_tapping.c
+++ b/tmk_core/common/action_tapping.c
@@ -120,14 +120,21 @@ bool process_tapping(keyrecord_t *keyp) {
* useful for long TAPPING_TERM but may prevent fast typing.
*/
# if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY)
- else if (
+ else if (((
# ifdef TAPPING_TERM_PER_KEY
- (get_tapping_term(get_event_keycode(tapping_key.event, false), keyp) >= 500) &&
+ get_tapping_term(get_event_keycode(tapping_key.event, false), keyp)
+# else
+ TAPPING_TERM
# endif
+ >= 500)
+
# ifdef PERMISSIVE_HOLD_PER_KEY
- !get_permissive_hold(get_event_keycode(tapping_key.event, false), keyp) &&
+ || get_permissive_hold(get_event_keycode(tapping_key.event, false), keyp)
+# elif defined(PERMISSIVE_HOLD)
+ || true
# endif
- IS_RELEASED(event) && waiting_buffer_typed(event)) {
+ ) &&
+ IS_RELEASED(event) && waiting_buffer_typed(event)) {
debug("Tapping: End. No tap. Interfered by typing key\n");
process_record(&tapping_key);
tapping_key = (keyrecord_t){};
diff --git a/tmk_core/common/print.c b/tmk_core/common/arm_atsam/_print.h
index 07aef0b0eb..04320ee38b 100644
--- a/tmk_core/common/print.c
+++ b/tmk_core/common/arm_atsam/_print.h
@@ -1,4 +1,4 @@
-/* Copyright 2012,2013 Jun Wako <wakojun@gmail.com> */
+/* Copyright 2012 Jun Wako <wakojun@gmail.com> */
/* Very basic print functions, intended to be used with usb_debug_only.c
* http://www.pjrc.com/teensy/
* Copyright (c) 2008 PJRC.COM, LLC
@@ -21,27 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#pragma once
-#include <stdint.h>
-#include "print.h"
+#include "arm_atsam/printf.h"
-#ifndef NO_PRINT
-
-# if defined(__AVR__)
-
-# define sendchar(c) xputc(c)
-
-void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) { xdev_out(sendchar_func); }
-
-# elif defined(PROTOCOL_CHIBIOS) /* __AVR__ */
-
-// don't need anything extra
-
-# elif defined(__arm__) /* __AVR__ */
-
-// TODO
-// void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) { }
-
-# endif /* __AVR__ */
-
-#endif
+// Create user & normal print defines
+#define xprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
+#define print(s) __xprintf(s)
+#define println(s) __xprintf(s "\r\n")
+#define uprint(s) __xprintf(s)
+#define uprintln(s) __xprintf(s "\r\n")
+#define uprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
diff --git a/tmk_core/common/arm_atsam/printf.c b/tmk_core/common/arm_atsam/printf.c
index cd7cdb52e6..6f7e8d343f 100644
--- a/tmk_core/common/arm_atsam/printf.c
+++ b/tmk_core/common/arm_atsam/printf.c
@@ -15,11 +15,13 @@ 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 "printf.h"
+#include "sendchar.h"
+
#ifdef CONSOLE_ENABLE
# include "samd51j18a.h"
# include "arm_atsam_protocol.h"
-# include "printf.h"
# include <string.h>
# include <stdarg.h>
@@ -66,3 +68,8 @@ void console_printf(char *fmt, ...) {
}
#endif // CONSOLE_ENABLE
+<<<<<<< HEAD
+=======
+
+void print_set_sendchar(sendchar_func_t send) {}
+>>>>>>> 0.12.52~1
diff --git a/tmk_core/common/arm_atsam/printf.mk b/tmk_core/common/arm_atsam/printf.mk
new file mode 100644
index 0000000000..f70e02731f
--- /dev/null
+++ b/tmk_core/common/arm_atsam/printf.mk
@@ -0,0 +1 @@
+TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/printf.c
diff --git a/tmk_core/common/arm_atsam/suspend.c b/tmk_core/common/arm_atsam/suspend.c
index 6a36740658..e51426128d 100644
--- a/tmk_core/common/arm_atsam/suspend.c
+++ b/tmk_core/common/arm_atsam/suspend.c
@@ -7,7 +7,8 @@
*
* FIXME: needs doc
*/
-void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */ }
+void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */
+}
/** \brief Run user level Power down
*
diff --git a/tmk_core/common/atomic_util.h b/tmk_core/common/atomic_util.h
new file mode 100644
index 0000000000..2c95302a13
--- /dev/null
+++ b/tmk_core/common/atomic_util.h
@@ -0,0 +1,32 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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
+
+// Macro to help make GPIO and other controls atomic.
+
+#ifndef IGNORE_ATOMIC_BLOCK
+# if __has_include_next("atomic_util.h")
+# include_next "atomic_util.h" /* Include the platforms atomic.h */
+# else
+# define ATOMIC_BLOCK _Static_assert(0, "ATOMIC_BLOCK not implemented")
+# define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented")
+# define ATOMIC_BLOCK_FORCEON _Static_assert(0, "ATOMIC_BLOCK_FORCEON not implemented")
+# endif
+#else /* do nothing atomic macro */
+# define ATOMIC_BLOCK for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0)
+# define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK
+# define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK
+#endif
diff --git a/tmk_core/common/avr/_print.h b/tmk_core/common/avr/_print.h
new file mode 100644
index 0000000000..5c1fdd26d8
--- /dev/null
+++ b/tmk_core/common/avr/_print.h
@@ -0,0 +1,33 @@
+/* Copyright 2012 Jun Wako <wakojun@gmail.com> */
+/* Very basic print functions, intended to be used with usb_debug_only.c
+ * http://www.pjrc.com/teensy/
+ * Copyright (c) 2008 PJRC.COM, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#pragma once
+
+#include "avr/xprintf.h"
+
+// Create user & normal print defines
+#define print(s) xputs(PSTR(s))
+#define println(s) xputs(PSTR(s "\r\n"))
+#define uprint(s) xputs(PSTR(s))
+#define uprintln(s) xputs(PSTR(s "\r\n"))
+#define uprintf(fmt, ...) __xprintf(PSTR(fmt), ##__VA_ARGS__) \ No newline at end of file
diff --git a/tmk_core/common/avr/atomic_util.h b/tmk_core/common/avr/atomic_util.h
new file mode 100644
index 0000000000..7c5d2e7dcc
--- /dev/null
+++ b/tmk_core/common/avr/atomic_util.h
@@ -0,0 +1,22 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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
+
+/* atomic macro for AVR */
+#include <util/atomic.h>
+
+#define ATOMIC_BLOCK_RESTORESTATE ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+#define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON)
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c
index a1db55da93..c0272903b8 100644
--- a/tmk_core/common/avr/bootloader.c
+++ b/tmk_core/common/avr/bootloader.c
@@ -77,7 +77,7 @@ uint32_t reset_key __attribute__((section(".noinit,\"aw\",@nobits;")));
*
* FIXME: needs doc
*/
-void bootloader_jump(void) {
+__attribute__((weak)) void bootloader_jump(void) {
#if !defined(BOOTLOADER_SIZE)
uint8_t high_fuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
diff --git a/tmk_core/common/avr/gpio.h b/tmk_core/common/avr/gpio.h
new file mode 100644
index 0000000000..231556c29c
--- /dev/null
+++ b/tmk_core/common/avr/gpio.h
@@ -0,0 +1,34 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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 <avr/io.h>
+#include "pin_defs.h"
+
+typedef uint8_t pin_t;
+
+#define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_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) (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)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
+
+#define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF))
diff --git a/tmk_core/common/avr/pin_defs.h b/tmk_core/common/avr/pin_defs.h
new file mode 100644
index 0000000000..23d948041d
--- /dev/null
+++ b/tmk_core/common/avr/pin_defs.h
@@ -0,0 +1,128 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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 <avr/io.h>
+
+#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 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_AT90USB162__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
+# define ADDRESS_BASE 0x00
+# define PINB_ADDRESS 0x3
+# define PINC_ADDRESS 0x6
+# define PIND_ADDRESS 0x9
+#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+# 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_ATtiny85__)
+# define ADDRESS_BASE 0x10
+# define PINB_ADDRESS 0x6
+#else
+# error "Pins are not defined"
+#endif
+
+#define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin)
+
+#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)
+
+/* I/O pins */
+#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
diff --git a/tmk_core/common/avr/printf.c b/tmk_core/common/avr/printf.c
new file mode 100644
index 0000000000..9ad7a38693
--- /dev/null
+++ b/tmk_core/common/avr/printf.c
@@ -0,0 +1,20 @@
+/*
+Copyright 2011 Jun Wako <wakojun@gmail.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 "xprintf.h"
+#include "sendchar.h"
+
+void print_set_sendchar(sendchar_func_t func) { xdev_out(func); }
diff --git a/tmk_core/common/avr/printf.mk b/tmk_core/common/avr/printf.mk
new file mode 100644
index 0000000000..060ad88c57
--- /dev/null
+++ b/tmk_core/common/avr/printf.mk
@@ -0,0 +1,2 @@
+TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/xprintf.S
+TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/printf.c
diff --git a/tmk_core/common/avr/sleep_led.c b/tmk_core/common/avr/sleep_led.c
index 63dcc2afd9..9a3b52abe5 100644
--- a/tmk_core/common/avr/sleep_led.c
+++ b/tmk_core/common/avr/sleep_led.c
@@ -90,7 +90,7 @@ void sleep_led_toggle(void) {
*
* (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle
*
- * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63
+ * https://www.wolframalpha.com/input/?i=sin%28x%2F64*pi%29**8+*+255%2C+x%3D0+to+63
* (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i }
*/
static const uint8_t breathing_table[64] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, 255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index b784a0835d..47a82a2eec 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -4,7 +4,6 @@
#include <avr/interrupt.h>
#include "matrix.h"
#include "action.h"
-#include "suspend_avr.h"
#include "suspend.h"
#include "timer.h"
#include "led.h"
@@ -13,6 +12,9 @@
#ifdef PROTOCOL_LUFA
# include "lufa.h"
#endif
+#ifdef PROTOCOL_VUSB
+# include "vusb.h"
+#endif
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
@@ -52,7 +54,25 @@ __attribute__((weak)) void suspend_power_down_user(void) {}
*/
__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
-#ifndef NO_SUSPEND_POWER_DOWN
+#if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect)
+
+// clang-format off
+#define wdt_intr_enable(value) \
+__asm__ __volatile__ ( \
+ "in __tmp_reg__,__SREG__" "\n\t" \
+ "cli" "\n\t" \
+ "wdr" "\n\t" \
+ "sts %0,%1" "\n\t" \
+ "out __SREG__,__tmp_reg__" "\n\t" \
+ "sts %0,%2" "\n\t" \
+ : /* no outputs */ \
+ : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
+ "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
+ "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | _BV(WDIE) | (value & 0x07))) \
+ : "r0" \
+)
+// clang-format on
+
/** \brief Power down MCU with watchdog timer
*
* wdto: watchdog timer timeout defined in <avr/wdt.h>
@@ -74,35 +94,11 @@ static uint8_t wdt_timeout = 0;
* FIXME: needs doc
*/
static void power_down(uint8_t wdto) {
-# ifdef PROTOCOL_LUFA
- if (USB_DeviceState == DEVICE_STATE_Configured) return;
-# endif
wdt_timeout = wdto;
// Watchdog Interrupt Mode
wdt_intr_enable(wdto);
-# ifdef BACKLIGHT_ENABLE
- backlight_set(0);
-# endif
-
- // Turn off LED indicators
- uint8_t leds_off = 0;
-# if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
- if (is_backlight_enabled()) {
- // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
- leds_off |= (1 << USB_LED_CAPS_LOCK);
- }
-# endif
- led_set(leds_off);
-
-# ifdef AUDIO_ENABLE
- stop_all_notes();
-# endif /* AUDIO_ENABLE */
-# if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
- rgblight_suspend();
-# endif
-
// TODO: more power saving
// See PicoPower application note
// - I/O port input with pullup
@@ -125,10 +121,45 @@ static void power_down(uint8_t wdto) {
* FIXME: needs doc
*/
void suspend_power_down(void) {
+#ifdef PROTOCOL_LUFA
+ if (USB_DeviceState == DEVICE_STATE_Configured) return;
+#endif
+#ifdef PROTOCOL_VUSB
+ if (!vusb_suspended) return;
+#endif
+
suspend_power_down_kb();
#ifndef NO_SUSPEND_POWER_DOWN
+ // Turn off backlight
+# ifdef BACKLIGHT_ENABLE
+ backlight_set(0);
+# endif
+
+ // Turn off LED indicators
+ uint8_t leds_off = 0;
+# if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
+ if (is_backlight_enabled()) {
+ // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
+ leds_off |= (1 << USB_LED_CAPS_LOCK);
+ }
+# endif
+ led_set(leds_off);
+
+ // Turn off audio
+# ifdef AUDIO_ENABLE
+ stop_all_notes();
+# endif
+
+ // Turn off underglow
+# if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
+ rgblight_suspend();
+# endif
+
+ // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt)
+# if defined(WDT_vect)
power_down(WDTO_15MS);
+# endif
#endif
}
@@ -163,17 +194,24 @@ __attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_us
void suspend_wakeup_init(void) {
// clear keyboard state
clear_keyboard();
+
+ // Turn on backlight
#ifdef BACKLIGHT_ENABLE
backlight_init();
#endif
+
+ // Restore LED indicators
led_set(host_keyboard_leds());
+
+ // Wake up underglow
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
rgblight_wakeup();
#endif
+
suspend_wakeup_init_kb();
}
-#ifndef NO_SUSPEND_POWER_DOWN
+#if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect)
/* watchdog timeout */
ISR(WDT_vect) {
// compensate timer for sleep
diff --git a/tmk_core/common/avr/suspend_avr.h b/tmk_core/common/avr/suspend_avr.h
deleted file mode 100644
index 6df048f3bb..0000000000
--- a/tmk_core/common/avr/suspend_avr.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <avr/sleep.h>
-#include <avr/wdt.h>
-#include <avr/interrupt.h>
-
-// clang-format off
-#define wdt_intr_enable(value) \
-__asm__ __volatile__ ( \
- "in __tmp_reg__,__SREG__" "\n\t" \
- "cli" "\n\t" \
- "wdr" "\n\t" \
- "sts %0,%1" "\n\t" \
- "out __SREG__,__tmp_reg__" "\n\t" \
- "sts %0,%2" "\n\t" \
- : /* no outputs */ \
- : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
- "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
- "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \
- _BV(WDIE) | (value & 0x07)) ) \
- : "r0" \
-)
-// clang-format on
diff --git a/tmk_core/common/chibios/atomic_util.h b/tmk_core/common/chibios/atomic_util.h
new file mode 100644
index 0000000000..8975045153
--- /dev/null
+++ b/tmk_core/common/chibios/atomic_util.h
@@ -0,0 +1,37 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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 <ch.h>
+
+static __inline__ uint8_t __interrupt_disable__(void) {
+ chSysLock();
+
+ return 1;
+}
+
+static __inline__ void __interrupt_enable__(const uint8_t *__s) {
+ chSysUnlock();
+
+ __asm__ volatile("" ::: "memory");
+ (void)__s;
+}
+
+#define ATOMIC_BLOCK(type) for (type, __ToDo = __interrupt_disable__(); __ToDo; __ToDo = 0)
+#define ATOMIC_FORCEON uint8_t sreg_save __attribute__((__cleanup__(__interrupt_enable__))) = 0
+
+#define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented")
+#define ATOMIC_BLOCK_FORCEON ATOMIC_BLOCK(ATOMIC_FORCEON)
diff --git a/tmk_core/common/chibios/eeprom_teensy.c b/tmk_core/common/chibios/eeprom_teensy.c
index e135e19a21..4aaf665269 100644
--- a/tmk_core/common/chibios/eeprom_teensy.c
+++ b/tmk_core/common/chibios/eeprom_teensy.c
@@ -363,7 +363,7 @@ void eeprom_initialize(void) {
return;
}
} while (p < (uint16_t *)SYMVAL(__eeprom_workarea_end__));
- flashend = (uint32_t)((uint16_t *)SYMVAL(__eeprom_workarea_end__) - 1);
+ flashend = (uint32_t)(p - 1);
}
uint8_t eeprom_read_byte(const uint8_t *addr) {
diff --git a/tmk_core/common/chibios/gpio.h b/tmk_core/common/chibios/gpio.h
new file mode 100644
index 0000000000..5d0e142abc
--- /dev/null
+++ b/tmk_core/common/chibios/gpio.h
@@ -0,0 +1,34 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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 <hal.h>
+#include "pin_defs.h"
+
+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 writePinHigh(pin) palSetLine(pin)
+#define writePinLow(pin) palClearLine(pin)
+#define writePin(pin, level) ((level) ? (writePinHigh(pin)) : (writePinLow(pin)))
+
+#define readPin(pin) palReadLine(pin)
+
+#define togglePin(pin) palToggleLine(pin)
diff --git a/tmk_core/common/chibios/pin_defs.h b/tmk_core/common/chibios/pin_defs.h
new file mode 100644
index 0000000000..86bc1076e8
--- /dev/null
+++ b/tmk_core/common/chibios/pin_defs.h
@@ -0,0 +1,242 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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
+
+// 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)
+
+// 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 B18 PAL_LINE(GPIOB, 18)
+# define B19 PAL_LINE(GPIOB, 19)
+# 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)
+# define G0 PAL_LINE(GPIOG, 0)
+# define G1 PAL_LINE(GPIOG, 1)
+# define G2 PAL_LINE(GPIOG, 2)
+# define G3 PAL_LINE(GPIOG, 3)
+# define G4 PAL_LINE(GPIOG, 4)
+# define G5 PAL_LINE(GPIOG, 5)
+# define G6 PAL_LINE(GPIOG, 6)
+# define G7 PAL_LINE(GPIOG, 7)
+# define G8 PAL_LINE(GPIOG, 8)
+# define G9 PAL_LINE(GPIOG, 9)
+# define G10 PAL_LINE(GPIOG, 10)
+# define G11 PAL_LINE(GPIOG, 11)
+# define G12 PAL_LINE(GPIOG, 12)
+# define G13 PAL_LINE(GPIOG, 13)
+# define G14 PAL_LINE(GPIOG, 14)
+# define G15 PAL_LINE(GPIOG, 15)
+# define H0 PAL_LINE(GPIOH, 0)
+# define H1 PAL_LINE(GPIOH, 1)
+# define H2 PAL_LINE(GPIOH, 2)
+# define H3 PAL_LINE(GPIOH, 3)
+# define H4 PAL_LINE(GPIOH, 4)
+# define H5 PAL_LINE(GPIOH, 5)
+# define H6 PAL_LINE(GPIOH, 6)
+# define H7 PAL_LINE(GPIOH, 7)
+# define H8 PAL_LINE(GPIOH, 8)
+# define H9 PAL_LINE(GPIOH, 9)
+# define H10 PAL_LINE(GPIOH, 10)
+# define H11 PAL_LINE(GPIOH, 11)
+# define H12 PAL_LINE(GPIOH, 12)
+# define H13 PAL_LINE(GPIOH, 13)
+# define H14 PAL_LINE(GPIOH, 14)
+# define H15 PAL_LINE(GPIOH, 15)
+# define I0 PAL_LINE(GPIOI, 0)
+# define I1 PAL_LINE(GPIOI, 1)
+# define I2 PAL_LINE(GPIOI, 2)
+# define I3 PAL_LINE(GPIOI, 3)
+# define I4 PAL_LINE(GPIOI, 4)
+# define I5 PAL_LINE(GPIOI, 5)
+# define I6 PAL_LINE(GPIOI, 6)
+# define I7 PAL_LINE(GPIOI, 7)
+# define I8 PAL_LINE(GPIOI, 8)
+# define I9 PAL_LINE(GPIOI, 9)
+# define I10 PAL_LINE(GPIOI, 10)
+# define I11 PAL_LINE(GPIOI, 11)
+# define I12 PAL_LINE(GPIOI, 12)
+# define I13 PAL_LINE(GPIOI, 13)
+# define I14 PAL_LINE(GPIOI, 14)
+# define I15 PAL_LINE(GPIOI, 15)
+# define J0 PAL_LINE(GPIOJ, 0)
+# define J1 PAL_LINE(GPIOJ, 1)
+# define J2 PAL_LINE(GPIOJ, 2)
+# define J3 PAL_LINE(GPIOJ, 3)
+# define J4 PAL_LINE(GPIOJ, 4)
+# define J5 PAL_LINE(GPIOJ, 5)
+# define J6 PAL_LINE(GPIOJ, 6)
+# define J7 PAL_LINE(GPIOJ, 7)
+# define J8 PAL_LINE(GPIOJ, 8)
+# define J9 PAL_LINE(GPIOJ, 9)
+# define J10 PAL_LINE(GPIOJ, 10)
+# define J11 PAL_LINE(GPIOJ, 11)
+# define J12 PAL_LINE(GPIOJ, 12)
+# define J13 PAL_LINE(GPIOJ, 13)
+# define J14 PAL_LINE(GPIOJ, 14)
+# define J15 PAL_LINE(GPIOJ, 15)
+// Keyboards can `#define KEYBOARD_REQUIRES_GPIOK` if they need to access GPIO-K pins. These conflict with a whole
+// bunch of layout definitions, so it's intentionally left out unless absolutely required -- in that case, the
+// keyboard designer should use a different symbol when defining their layout macros.
+# ifdef KEYBOARD_REQUIRES_GPIOK
+# define K0 PAL_LINE(GPIOK, 0)
+# define K1 PAL_LINE(GPIOK, 1)
+# define K2 PAL_LINE(GPIOK, 2)
+# define K3 PAL_LINE(GPIOK, 3)
+# define K4 PAL_LINE(GPIOK, 4)
+# define K5 PAL_LINE(GPIOK, 5)
+# define K6 PAL_LINE(GPIOK, 6)
+# define K7 PAL_LINE(GPIOK, 7)
+# define K8 PAL_LINE(GPIOK, 8)
+# define K9 PAL_LINE(GPIOK, 9)
+# define K10 PAL_LINE(GPIOK, 10)
+# define K11 PAL_LINE(GPIOK, 11)
+# define K12 PAL_LINE(GPIOK, 12)
+# define K13 PAL_LINE(GPIOK, 13)
+# define K14 PAL_LINE(GPIOK, 14)
+# define K15 PAL_LINE(GPIOK, 15)
+# endif
+#endif
diff --git a/tmk_core/common/debug.c b/tmk_core/common/debug.c
index bea96dfc14..ea62deaa8c 100644
--- a/tmk_core/common/debug.c
+++ b/tmk_core/common/debug.c
@@ -1,24 +1,25 @@
-#include <stdbool.h>
-#include "debug.h"
+/*
+Copyright 2011 Jun Wako <wakojun@gmail.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.
-#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+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 "debug.h"
debug_config_t debug_config = {
-/* GCC Bug 10676 - Using unnamed fields in initializers
- * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676 */
-#if GCC_VERSION >= 40600
- .enable = false,
- .matrix = false,
- .keyboard = false,
- .mouse = false,
- .reserved = 0
-#else
- {
- false, // .enable
- false, // .matrix
- false, // .keyboard
- false, // .mouse
- 0 // .reserved
- }
-#endif
+ .enable = false, //
+ .matrix = false, //
+ .keyboard = false, //
+ .mouse = false, //
+ .reserved = 0 //
};
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index 9bdf926a5a..60b2dcb7e7 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -6,6 +6,7 @@
#ifdef ORYX_ENABLE
# include "oryx.h"
#endif
+
#ifdef STM32_EEPROM_ENABLE
# include <hal.h>
# include "eeprom_stm32.h"
@@ -60,19 +61,18 @@ void eeconfig_init_quantum(void) {
eeprom_update_byte(EECONFIG_VELOCIKEY, 0);
eeprom_update_dword(EECONFIG_RGB_MATRIX, 0);
eeprom_update_byte(EECONFIG_RGB_MATRIX_SPEED, 0);
-
+#ifdef ORYX_ENABLE
+ eeconfig_init_oryx();
+#endif
// TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
// within the emulated eeprom via dfu-util or another tool
#if defined INIT_EE_HANDS_LEFT
- #pragma message "Faking EE_HANDS for left hand"
+# pragma message "Faking EE_HANDS for left hand"
eeprom_update_byte(EECONFIG_HANDEDNESS, 1);
#elif defined INIT_EE_HANDS_RIGHT
- #pragma message "Faking EE_HANDS for right hand"
+# pragma message "Faking EE_HANDS for right hand"
eeprom_update_byte(EECONFIG_HANDEDNESS, 0);
#endif
-#ifdef ORYX_ENABLE
- eeconfig_init_oryx();
-#endif
#if defined(HAPTIC_ENABLE)
haptic_reset();
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 95e9523662..86b9e6f99b 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#ifndef EECONFIG_MAGIC_NUMBER
-# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEF
+# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEB // When changing, decrement this value to avoid future re-init issues
#endif
#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
diff --git a/tmk_core/common/gpio.h b/tmk_core/common/gpio.h
new file mode 100644
index 0000000000..b47f6f8e43
--- /dev/null
+++ b/tmk_core/common/gpio.h
@@ -0,0 +1,22 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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 "pin_defs.h"
+
+#if __has_include_next("gpio.h")
+# include_next "gpio.h" /* Include the platforms gpio.h */
+#endif \ No newline at end of file
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c
index 713b0d9456..e7d92cfac6 100644
--- a/tmk_core/common/host.c
+++ b/tmk_core/common/host.c
@@ -41,7 +41,7 @@ uint8_t host_keyboard_leds(void) {
}
led_t host_keyboard_led_state(void) {
- if (!driver) return (led_t) {0};
+ if (!driver) return (led_t){0};
return (led_t)((*driver->keyboard_leds)());
}
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 0932a1d21b..ce3255c069 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "led.h"
#include "keycode.h"
#include "timer.h"
+#include "sync_timer.h"
#include "print.h"
#include "debug.h"
#include "command.h"
@@ -53,15 +54,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
#endif
+#ifdef RGB_MATRIX_ENABLE
+# include "rgb_matrix.h"
+#endif
#ifdef ENCODER_ENABLE
# include "encoder.h"
#endif
#ifdef STENO_ENABLE
# include "process_steno.h"
#endif
-#ifdef FAUXCLICKY_ENABLE
-# include "fauxclicky.h"
-#endif
#ifdef SERIAL_LINK_ENABLE
# include "serial_link/system/serial_link.h"
#endif
@@ -96,10 +97,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "dip_switch.h"
#endif
+static uint32_t last_input_modification_time = 0;
+uint32_t last_input_activity_time(void) { return last_input_modification_time; }
+uint32_t last_input_activity_elapsed(void) { return timer_elapsed32(last_input_modification_time); }
+
+static uint32_t last_matrix_modification_time = 0;
+uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; }
+uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); }
+void last_matrix_activity_trigger(void) { last_matrix_modification_time = last_input_modification_time = timer_read32(); }
+
+static uint32_t last_encoder_modification_time = 0;
+uint32_t last_encoder_activity_time(void) { return last_encoder_modification_time; }
+uint32_t last_encoder_activity_elapsed(void) { return timer_elapsed32(last_encoder_modification_time); }
+void last_encoder_activity_trigger(void) { last_encoder_modification_time = last_input_modification_time = timer_read32(); }
+
// Only enable this if console is enabled to print to
#if defined(DEBUG_MATRIX_SCAN_RATE)
-static uint32_t matrix_timer = 0;
-static uint32_t matrix_scan_count = 0;
+static uint32_t matrix_timer = 0;
+static uint32_t matrix_scan_count = 0;
static uint32_t last_matrix_scan_count = 0;
void matrix_scan_perf_task(void) {
@@ -108,17 +123,15 @@ void matrix_scan_perf_task(void) {
uint32_t timer_now = timer_read32();
if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) {
# if defined(CONSOLE_ENABLE)
- dprintf("matrix scan frequency: %d\n", matrix_scan_count);
+ dprintf("matrix scan frequency: %lu\n", matrix_scan_count);
# endif
last_matrix_scan_count = matrix_scan_count;
- matrix_timer = timer_now;
- matrix_scan_count = 0;
+ matrix_timer = timer_now;
+ matrix_scan_count = 0;
}
}
-uint32_t get_matrix_scan_rate(void) {
- return last_matrix_scan_count;
-}
+uint32_t get_matrix_scan_rate(void) { return last_matrix_scan_count; }
#else
# define matrix_scan_perf_task()
#endif
@@ -173,6 +186,9 @@ void disable_jtag(void) {
#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
MCUCR |= _BV(JTD);
MCUCR |= _BV(JTD);
+#elif defined(__AVR_ATmega32A__)
+ MCUCSR |= _BV(JTD);
+ MCUCSR |= _BV(JTD);
#endif
}
@@ -213,7 +229,10 @@ __attribute__((weak)) void keyboard_post_init_kb(void) { keyboard_post_init_user
* FIXME: needs doc
*/
void keyboard_setup(void) {
+#ifndef NO_JTAG_DISABLE
disable_jtag();
+#endif
+ print_set_sendchar(sendchar);
matrix_setup();
keyboard_pre_init_kb();
}
@@ -257,6 +276,7 @@ __attribute__((weak)) void housekeeping_task_user(void) {}
*/
void keyboard_init(void) {
timer_init();
+ sync_timer_init();
matrix_init();
#ifdef VIA_ENABLE
via_init();
@@ -293,9 +313,6 @@ void keyboard_init(void) {
#ifdef STENO_ENABLE
steno_init();
#endif
-#ifdef FAUXCLICKY_ENABLE
- fauxclicky_init();
-#endif
#ifdef POINTING_DEVICE_ENABLE
pointing_device_init();
#endif
@@ -314,6 +331,17 @@ void keyboard_init(void) {
keyboard_post_init_kb(); /* Always keep this last */
}
+/** \brief key_event_task
+ *
+ * This function is responsible for calling into other systems when they need to respond to electrical switch press events.
+ * This is differnet than keycode events as no layer processing, or filtering occurs.
+ */
+void switch_events(uint8_t row, uint8_t col, bool pressed) {
+#if defined(RGB_MATRIX_ENABLE)
+ process_rgb_matrix(row, col, pressed);
+#endif
+}
+
/** \brief Keyboard task: Do keyboard routine jobs
*
* Do routine keyboard jobs:
@@ -334,42 +362,45 @@ void keyboard_task(void) {
#ifdef QMK_KEYS_PER_SCAN
uint8_t keys_processed = 0;
#endif
+#ifdef ENCODER_ENABLE
+ bool encoders_changed = false;
+#endif
housekeeping_task_kb();
housekeeping_task_user();
-#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT)
- uint8_t ret = matrix_scan();
-#else
- matrix_scan();
-#endif
+ uint8_t matrix_changed = matrix_scan();
+ if (matrix_changed) last_matrix_activity_trigger();
- if (should_process_keypress()) {
- for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
- matrix_row = matrix_get_row(r);
- matrix_change = matrix_row ^ matrix_prev[r];
- if (matrix_change) {
+ for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
+ matrix_row = matrix_get_row(r);
+ matrix_change = matrix_row ^ matrix_prev[r];
+ if (matrix_change) {
#ifdef MATRIX_HAS_GHOST
- if (has_ghost_in_row(r, matrix_row)) {
- continue;
- }
+ if (has_ghost_in_row(r, matrix_row)) {
+ continue;
+ }
#endif
- if (debug_matrix) matrix_print();
- matrix_row_t col_mask = 1;
- for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) {
- if (matrix_change & col_mask) {
+ if (debug_matrix) matrix_print();
+ matrix_row_t col_mask = 1;
+ for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) {
+ if (matrix_change & col_mask) {
+ if (should_process_keypress()) {
action_exec((keyevent_t){
.key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */
});
- // record a processed key
- matrix_prev[r] ^= col_mask;
+ }
+ // record a processed key
+ matrix_prev[r] ^= col_mask;
+
+ switch_events(r, c, (matrix_row & col_mask));
+
#ifdef QMK_KEYS_PER_SCAN
- // only jump out if we have processed "enough" keys.
- if (++keys_processed >= QMK_KEYS_PER_SCAN)
+ // only jump out if we have processed "enough" keys.
+ if (++keys_processed >= QMK_KEYS_PER_SCAN)
#endif
- // process a key per task call
- goto MATRIX_LOOP_END;
- }
+ // process a key per task call
+ goto MATRIX_LOOP_END;
}
}
}
@@ -391,6 +422,10 @@ MATRIX_LOOP_END:
rgblight_task();
#endif
+#ifdef RGB_MATRIX_ENABLE
+ rgb_matrix_task();
+#endif
+
#if defined(BACKLIGHT_ENABLE)
# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)
backlight_task();
@@ -398,7 +433,8 @@ MATRIX_LOOP_END:
#endif
#ifdef ENCODER_ENABLE
- encoder_read();
+ encoders_changed = encoder_read();
+ if (encoders_changed) last_encoder_activity_trigger();
#endif
#ifdef QWIIC_ENABLE
@@ -408,8 +444,12 @@ MATRIX_LOOP_END:
#ifdef OLED_DRIVER_ENABLE
oled_task();
# ifndef OLED_DISABLE_TIMEOUT
- // Wake up oled if user is using those fabulous keys!
- if (ret) oled_on();
+ // Wake up oled if user is using those fabulous keys or spinning those encoders!
+# ifdef ENCODER_ENABLE
+ if (matrix_changed || encoders_changed) oled_on();
+# else
+ if (matrix_changed) oled_on();
+# endif
# endif
#endif
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h
index f330854fba..eaf74bac58 100644
--- a/tmk_core/common/keyboard.h
+++ b/tmk_core/common/keyboard.h
@@ -52,8 +52,6 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) &&
#define TICK \
(keyevent_t) { .key = (keypos_t){.row = 255, .col = 255}, .pressed = false, .time = (timer_read() | 1) }
-void disable_jtag(void);
-
/* it runs once at early stage of startup before keyboard_init. */
void keyboard_setup(void);
/* it runs once after initializing host side protocol, debug and MCU peripherals. */
@@ -75,6 +73,15 @@ void keyboard_post_init_user(void);
void housekeeping_task_kb(void);
void housekeeping_task_user(void);
+uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity
+uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity
+
+uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity
+uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity
+
+uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity
+uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity
+
uint32_t get_matrix_scan_rate(void);
#ifdef __cplusplus
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h
index d35e44d8dc..8facabd818 100644
--- a/tmk_core/common/keycode.h
+++ b/tmk_core/common/keycode.h
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
-#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN5)
+#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN8)
#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
@@ -205,6 +205,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_BTN3 KC_MS_BTN3
#define KC_BTN4 KC_MS_BTN4
#define KC_BTN5 KC_MS_BTN5
+#define KC_BTN6 KC_MS_BTN6
+#define KC_BTN7 KC_MS_BTN7
+#define KC_BTN8 KC_MS_BTN8
#define KC_WH_U KC_MS_WH_UP
#define KC_WH_D KC_MS_WH_DOWN
#define KC_WH_L KC_MS_WH_LEFT
@@ -520,16 +523,29 @@ enum internal_special_keycodes {
};
enum mouse_keys {
- /* Mouse Buttons */
+/* Mouse Buttons */
+#ifdef VIA_ENABLE
KC_MS_UP = 0xF0,
+#else
+ KC_MS_UP = 0xED,
+#endif
KC_MS_DOWN,
KC_MS_LEFT,
- KC_MS_RIGHT,
+ KC_MS_RIGHT, // 0xF0
KC_MS_BTN1,
KC_MS_BTN2,
KC_MS_BTN3,
KC_MS_BTN4,
KC_MS_BTN5,
+#ifdef VIA_ENABLE
+ KC_MS_BTN6 = KC_MS_BTN5,
+ KC_MS_BTN7 = KC_MS_BTN5,
+ KC_MS_BTN8 = KC_MS_BTN5,
+#else
+ KC_MS_BTN6,
+ KC_MS_BTN7,
+ KC_MS_BTN8,
+#endif
/* Mouse Wheel */
KC_MS_WH_UP,
@@ -540,5 +556,5 @@ enum mouse_keys {
/* Acceleration */
KC_MS_ACCEL0,
KC_MS_ACCEL1,
- KC_MS_ACCEL2
+ KC_MS_ACCEL2 // 0xFF
};
diff --git a/tmk_core/common/lib_printf.mk b/tmk_core/common/lib_printf.mk
new file mode 100644
index 0000000000..10d2d8468d
--- /dev/null
+++ b/tmk_core/common/lib_printf.mk
@@ -0,0 +1,9 @@
+PRINTF_PATH = $(LIB_PATH)/printf
+
+TMK_COMMON_SRC += $(PRINTF_PATH)/printf.c
+TMK_COMMON_SRC += $(COMMON_DIR)/printf.c
+TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT
+TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL
+TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG
+TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T
+VPATH += $(PRINTF_PATH)
diff --git a/tmk_core/common/pin_defs.h b/tmk_core/common/pin_defs.h
new file mode 100644
index 0000000000..ea730138f2
--- /dev/null
+++ b/tmk_core/common/pin_defs.h
@@ -0,0 +1,23 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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
+
+// useful for direct pin mapping
+#define NO_PIN (pin_t)(~0)
+
+#if __has_include_next("pin_defs.h")
+# include_next "pin_defs.h" /* Include the platforms pin_defs.h */
+#endif
diff --git a/tmk_core/common/print.h b/tmk_core/common/print.h
index 647a5aa053..48f91e6342 100644
--- a/tmk_core/common/print.h
+++ b/tmk_core/common/print.h
@@ -27,104 +27,76 @@
#include <stdint.h>
#include <stdbool.h>
#include "util.h"
+#include "sendchar.h"
+#include "progmem.h"
-#if defined(PROTOCOL_CHIBIOS) || defined(PROTOCOL_ARM_ATSAM)
-# define PSTR(x) x
-#endif
+void print_set_sendchar(sendchar_func_t func);
#ifndef NO_PRINT
-
-# if defined(__AVR__) /* __AVR__ */
-
-# include "avr/xprintf.h"
-
-# ifdef USER_PRINT /* USER_PRINT */
-
-// Remove normal print defines
-# define print(s)
-# define println(s)
-# undef xprintf
-# define xprintf(fmt, ...)
-
-// Create user print defines
-# define uprint(s) xputs(PSTR(s))
-# define uprintln(s) xputs(PSTR(s "\r\n"))
-# define uprintf(fmt, ...) __xprintf(PSTR(fmt), ##__VA_ARGS__)
-
-# else /* NORMAL PRINT */
-
-// Create user & normal print defines
-# define print(s) xputs(PSTR(s))
-# define println(s) xputs(PSTR(s "\r\n"))
-# define uprint(s) print(s)
-# define uprintln(s) println(s)
-# define uprintf(fmt, ...) xprintf(fmt, ##__VA_ARGS__)
-
-# endif /* USER_PRINT / NORMAL PRINT */
-
-# ifdef __cplusplus
-extern "C"
-# endif
-
- /* function pointer of sendchar to be used by print utility */
- void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
-
-# elif defined(PROTOCOL_CHIBIOS) /* PROTOCOL_CHIBIOS */
-
+# if __has_include_next("_print.h")
+# include_next "_print.h" /* Include the platforms print.h */
+# else
+// Fall back to lib/printf
# include "printf.h" // lib/printf/printf.h
-# ifdef USER_PRINT /* USER_PRINT */
-
-// Remove normal print defines
-# define print(s)
-# define println(s)
-# define xprintf(fmt, ...)
-
-// Create user print defines
-# define uprint(s) printf(s)
-# define uprintln(s) printf(s "\r\n")
-# define uprintf printf
-
-# else /* NORMAL PRINT */
// Create user & normal print defines
-# define print(s) printf(s)
-# define println(s) printf(s "\r\n")
-# define xprintf printf
-# define uprint(s) printf(s)
-# define uprintln(s) printf(s "\r\n")
-# define uprintf printf
+# define print(s) printf(s)
+# define println(s) printf(s "\r\n")
+# define xprintf printf
+# define uprint(s) printf(s)
+# define uprintln(s) printf(s "\r\n")
+# define uprintf printf
-# endif /* USER_PRINT / NORMAL PRINT */
-
-# elif defined(PROTOCOL_ARM_ATSAM) /* PROTOCOL_ARM_ATSAM */
-
-# include "arm_atsam/printf.h"
+# endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM */
+#else /* NO_PRINT */
+# undef xprintf
+// Remove print defines
+# define print(s)
+# define println(s)
+# define xprintf(fmt, ...)
+# define uprintf(fmt, ...)
+# define uprint(s)
+# define uprintln(s)
-# ifdef USER_PRINT /* USER_PRINT */
+#endif /* NO_PRINT */
+#ifdef USER_PRINT
// Remove normal print defines
-# define print(s)
-# define println(s)
-# define xprintf(fmt, ...)
-
-// Create user print defines
-# define uprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
-# define uprint(s) xprintf(s)
-# define uprintln(s) xprintf(s "\r\n")
-
-# else /* NORMAL PRINT */
-
-// Create user & normal print defines
-# define xprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
-# define print(s) xprintf(s)
-# define println(s) xprintf(s "\r\n")
-# define uprint(s) print(s)
-# define uprintln(s) println(s)
-# define uprintf(fmt, ...) xprintf(fmt, ##__VA_ARGS__)
-
-# endif /* USER_PRINT / NORMAL PRINT */
+# undef print
+# undef println
+# undef xprintf
+# define print(s)
+# define println(s)
+# define xprintf(fmt, ...)
+#endif
-# endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM */
+#define print_dec(i) xprintf("%u", i)
+#define print_decs(i) xprintf("%d", i)
+/* hex */
+#define print_hex4(i) xprintf("%X", i)
+#define print_hex8(i) xprintf("%02X", i)
+#define print_hex16(i) xprintf("%04X", i)
+#define print_hex32(i) xprintf("%08lX", i)
+/* binary */
+#define print_bin4(i) xprintf("%04b", i)
+#define print_bin8(i) xprintf("%08b", i)
+#define print_bin16(i) xprintf("%016b", i)
+#define print_bin32(i) xprintf("%032lb", i)
+#define print_bin_reverse8(i) xprintf("%08b", bitrev(i))
+#define print_bin_reverse16(i) xprintf("%016b", bitrev16(i))
+#define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i))
+/* print value utility */
+#define print_val_dec(v) xprintf(#v ": %u\n", v)
+#define print_val_decs(v) xprintf(#v ": %d\n", v)
+#define print_val_hex8(v) xprintf(#v ": %X\n", v)
+#define print_val_hex16(v) xprintf(#v ": %02X\n", v)
+#define print_val_hex32(v) xprintf(#v ": %04lX\n", v)
+#define print_val_bin8(v) xprintf(#v ": %08b\n", v)
+#define print_val_bin16(v) xprintf(#v ": %016b\n", v)
+#define print_val_bin32(v) xprintf(#v ": %032lb\n", v)
+#define print_val_bin_reverse8(v) xprintf(#v ": %08b\n", bitrev(v))
+#define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v))
+#define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v))
// User print disables the normal print messages in the body of QMK/TMK code and
// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do
@@ -132,139 +104,32 @@ extern "C"
// print (and store their wasteful strings).
//
// !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!!
-//
-# ifdef USER_PRINT
-
-// Disable normal print
-# define print_dec(data)
-# define print_decs(data)
-# define print_hex4(data)
-# define print_hex8(data)
-# define print_hex16(data)
-# define print_hex32(data)
-# define print_bin4(data)
-# define print_bin8(data)
-# define print_bin16(data)
-# define print_bin32(data)
-# define print_bin_reverse8(data)
-# define print_bin_reverse16(data)
-# define print_bin_reverse32(data)
-# define print_val_dec(v)
-# define print_val_decs(v)
-# define print_val_hex8(v)
-# define print_val_hex16(v)
-# define print_val_hex32(v)
-# define print_val_bin8(v)
-# define print_val_bin16(v)
-# define print_val_bin32(v)
-# define print_val_bin_reverse8(v)
-# define print_val_bin_reverse16(v)
-# define print_val_bin_reverse32(v)
-
-# else /* NORMAL_PRINT */
-
-// Enable normal print
-/* decimal */
-# define print_dec(i) xprintf("%u", i)
-# define print_decs(i) xprintf("%d", i)
-/* hex */
-# define print_hex4(i) xprintf("%X", i)
-# define print_hex8(i) xprintf("%02X", i)
-# define print_hex16(i) xprintf("%04X", i)
-# define print_hex32(i) xprintf("%08lX", i)
-/* binary */
-# define print_bin4(i) xprintf("%04b", i)
-# define print_bin8(i) xprintf("%08b", i)
-# define print_bin16(i) xprintf("%016b", i)
-# define print_bin32(i) xprintf("%032lb", i)
-# define print_bin_reverse8(i) xprintf("%08b", bitrev(i))
-# define print_bin_reverse16(i) xprintf("%016b", bitrev16(i))
-# define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i))
-/* print value utility */
-# define print_val_dec(v) xprintf(# v ": %u\n", v)
-# define print_val_decs(v) xprintf(# v ": %d\n", v)
-# define print_val_hex8(v) xprintf(# v ": %X\n", v)
-# define print_val_hex16(v) xprintf(# v ": %02X\n", v)
-# define print_val_hex32(v) xprintf(# v ": %04lX\n", v)
-# define print_val_bin8(v) xprintf(# v ": %08b\n", v)
-# define print_val_bin16(v) xprintf(# v ": %016b\n", v)
-# define print_val_bin32(v) xprintf(# v ": %032lb\n", v)
-# define print_val_bin_reverse8(v) xprintf(# v ": %08b\n", bitrev(v))
-# define print_val_bin_reverse16(v) xprintf(# v ": %016b\n", bitrev16(v))
-# define print_val_bin_reverse32(v) xprintf(# v ": %032lb\n", bitrev32(v))
-
-# endif /* USER_PRINT / NORMAL_PRINT */
-
-// User Print
/* decimal */
-# define uprint_dec(i) uprintf("%u", i)
-# define uprint_decs(i) uprintf("%d", i)
+#define uprint_dec(i) uprintf("%u", i)
+#define uprint_decs(i) uprintf("%d", i)
/* hex */
-# define uprint_hex4(i) uprintf("%X", i)
-# define uprint_hex8(i) uprintf("%02X", i)
-# define uprint_hex16(i) uprintf("%04X", i)
-# define uprint_hex32(i) uprintf("%08lX", i)
+#define uprint_hex4(i) uprintf("%X", i)
+#define uprint_hex8(i) uprintf("%02X", i)
+#define uprint_hex16(i) uprintf("%04X", i)
+#define uprint_hex32(i) uprintf("%08lX", i)
/* binary */
-# define uprint_bin4(i) uprintf("%04b", i)
-# define uprint_bin8(i) uprintf("%08b", i)
-# define uprint_bin16(i) uprintf("%016b", i)
-# define uprint_bin32(i) uprintf("%032lb", i)
-# define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i))
-# define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i))
-# define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i))
+#define uprint_bin4(i) uprintf("%04b", i)
+#define uprint_bin8(i) uprintf("%08b", i)
+#define uprint_bin16(i) uprintf("%016b", i)
+#define uprint_bin32(i) uprintf("%032lb", i)
+#define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i))
+#define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i))
+#define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i))
/* print value utility */
-# define uprint_val_dec(v) uprintf(# v ": %u\n", v)
-# define uprint_val_decs(v) uprintf(# v ": %d\n", v)
-# define uprint_val_hex8(v) uprintf(# v ": %X\n", v)
-# define uprint_val_hex16(v) uprintf(# v ": %02X\n", v)
-# define uprint_val_hex32(v) uprintf(# v ": %04lX\n", v)
-# define uprint_val_bin8(v) uprintf(# v ": %08b\n", v)
-# define uprint_val_bin16(v) uprintf(# v ": %016b\n", v)
-# define uprint_val_bin32(v) uprintf(# v ": %032lb\n", v)
-# define uprint_val_bin_reverse8(v) uprintf(# v ": %08b\n", bitrev(v))
-# define uprint_val_bin_reverse16(v) uprintf(# v ": %016b\n", bitrev16(v))
-# define uprint_val_bin_reverse32(v) uprintf(# v ": %032lb\n", bitrev32(v))
-
-#else /* NO_PRINT */
-
-# define xprintf(fmt, ...)
-# define print(s)
-# define println(s)
-# define print_set_sendchar(func)
-# define print_dec(data)
-# define print_decs(data)
-# define print_hex4(data)
-# define print_hex8(data)
-# define print_hex16(data)
-# define print_hex32(data)
-# define print_bin4(data)
-# define print_bin8(data)
-# define print_bin16(data)
-# define print_bin32(data)
-# define print_bin_reverse8(data)
-# define print_bin_reverse16(data)
-# define print_bin_reverse32(data)
-# define print_val_dec(v)
-# define print_val_decs(v)
-# define print_val_hex8(v)
-# define print_val_hex16(v)
-# define print_val_hex32(v)
-# define print_val_bin8(v)
-# define print_val_bin16(v)
-# define print_val_bin32(v)
-# define print_val_bin_reverse8(v)
-# define print_val_bin_reverse16(v)
-# define print_val_bin_reverse32(v)
-
-#endif /* NO_PRINT */
-
-/* Backward compatiblitly for old name */
-#define pdec(data) print_dec(data)
-#define pdec16(data) print_dec(data)
-#define phex(data) print_hex8(data)
-#define phex16(data) print_hex16(data)
-#define pbin(data) print_bin8(data)
-#define pbin16(data) print_bin16(data)
-#define pbin_reverse(data) print_bin_reverse8(data)
-#define pbin_reverse16(data) print_bin_reverse16(data)
+#define uprint_val_dec(v) uprintf(#v ": %u\n", v)
+#define uprint_val_decs(v) uprintf(#v ": %d\n", v)
+#define uprint_val_hex8(v) uprintf(#v ": %X\n", v)
+#define uprint_val_hex16(v) uprintf(#v ": %02X\n", v)
+#define uprint_val_hex32(v) uprintf(#v ": %04lX\n", v)
+#define uprint_val_bin8(v) uprintf(#v ": %08b\n", v)
+#define uprint_val_bin16(v) uprintf(#v ": %016b\n", v)
+#define uprint_val_bin32(v) uprintf(#v ": %032lb\n", v)
+#define uprint_val_bin_reverse8(v) uprintf(#v ": %08b\n", bitrev(v))
+#define uprint_val_bin_reverse16(v) uprintf(#v ": %016b\n", bitrev16(v))
+#define uprint_val_bin_reverse32(v) uprintf(#v ": %032lb\n", bitrev32(v))
diff --git a/tmk_core/protocol/usb_hid/test/config.h b/tmk_core/common/printf.c
index 71a6814fd1..e8440e55ee 100644
--- a/tmk_core/protocol/usb_hid/test/config.h
+++ b/tmk_core/common/printf.c
@@ -1,5 +1,5 @@
/*
-Copyright 2012 Jun Wako <wakojun@gmail.com>
+Copyright 2011 Jun Wako <wakojun@gmail.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
@@ -14,17 +14,14 @@ 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 <stddef.h>
+#include "sendchar.h"
-#pragma once
+// bind lib/printf to console interface - sendchar
-#define VENDOR_ID 0xFEED
-#define PRODUCT_ID 0xCAFE
-#define DEVICE_VER 0x0814
-#define MANUFACTURER t.m.k.
-#define PRODUCT USB to USB keyboard converter
+static int8_t null_sendchar_func(uint8_t c) { return 0; }
+static sendchar_func_t func = null_sendchar_func;
-#define DESCRIPTION Product from t.m.k. keyboard firmware project
+void print_set_sendchar(sendchar_func_t send) { func = send; }
-/* matrix size */
-#define MATRIX_ROWS 32
-#define MATRIX_COLS 8
+void _putchar(char character) { func(character); }
diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h
index c8863d3ad2..4e4771e523 100644
--- a/tmk_core/common/progmem.h
+++ b/tmk_core/common/progmem.h
@@ -4,6 +4,7 @@
# include <avr/pgmspace.h>
#else
# define PROGMEM
+# define PSTR(x) x
# define PGM_P const char*
# define memcpy_P(dest, src, n) memcpy(dest, src, n)
# define pgm_read_byte(address_short) *((uint8_t*)(address_short))
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 5d7c5b3b28..db6370657d 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -34,12 +34,16 @@ enum hid_report_ids {
};
/* Mouse buttons */
+#define MOUSE_BTN_MASK(n) (1 << (n))
enum mouse_buttons {
- MOUSE_BTN1 = (1 << 0),
- MOUSE_BTN2 = (1 << 1),
- MOUSE_BTN3 = (1 << 2),
- MOUSE_BTN4 = (1 << 3),
- MOUSE_BTN5 = (1 << 4)
+ MOUSE_BTN1 = MOUSE_BTN_MASK(0),
+ MOUSE_BTN2 = MOUSE_BTN_MASK(1),
+ MOUSE_BTN3 = MOUSE_BTN_MASK(2),
+ MOUSE_BTN4 = MOUSE_BTN_MASK(3),
+ MOUSE_BTN5 = MOUSE_BTN_MASK(4),
+ MOUSE_BTN6 = MOUSE_BTN_MASK(5),
+ MOUSE_BTN7 = MOUSE_BTN_MASK(6),
+ MOUSE_BTN8 = MOUSE_BTN_MASK(7)
};
/* Consumer Page (0x0C)
@@ -76,7 +80,21 @@ enum consumer_usages {
AL_ASSISTANT = 0x1CB,
AL_KEYBOARD_LAYOUT = 0x1AE,
// 15.16 Generic GUI Application Controls
+ AC_NEW = 0x201,
+ AC_OPEN = 0x202,
+ AC_CLOSE = 0x203,
+ AC_EXIT = 0x204,
+ AC_MAXIMIZE = 0x205,
AC_MINIMIZE = 0x206,
+ AC_SAVE = 0x207,
+ AC_PRINT = 0x208,
+ AC_PROPERTIES = 0x209,
+ AC_UNDO = 0x21A,
+ AC_COPY = 0x21B,
+ AC_CUT = 0x21C,
+ AC_PASTE = 0x21D,
+ AC_SELECT_ALL = 0x21E,
+ AC_FIND = 0x21F,
AC_SEARCH = 0x221,
AC_HOME = 0x223,
AC_BACK = 0x224,
@@ -92,9 +110,12 @@ enum consumer_usages {
*/
enum desktop_usages {
// 4.5.1 System Controls - Power Controls
- SYSTEM_POWER_DOWN = 0x81,
- SYSTEM_SLEEP = 0x82,
- SYSTEM_WAKE_UP = 0x83
+ SYSTEM_POWER_DOWN = 0x81,
+ SYSTEM_SLEEP = 0x82,
+ SYSTEM_WAKE_UP = 0x83,
+ SYSTEM_RESTART = 0x8F,
+ // 4.10 System Display Controls
+ SYSTEM_DISPLAY_TOGGLE_INT_EXT = 0xB5
};
// clang-format on
diff --git a/tmk_core/common/sendchar.h b/tmk_core/common/sendchar.h
index b150dd464e..edcddaa6bb 100644
--- a/tmk_core/common/sendchar.h
+++ b/tmk_core/common/sendchar.h
@@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern "C" {
#endif
+typedef int8_t (*sendchar_func_t)(uint8_t c);
+
/* transmit a character. return 0 on success, -1 on error. */
int8_t sendchar(uint8_t c);
diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h
index 9d17d984ed..95845e4b63 100644
--- a/tmk_core/common/suspend.h
+++ b/tmk_core/common/suspend.h
@@ -14,5 +14,5 @@ void suspend_power_down_user(void);
void suspend_power_down_kb(void);
#ifndef USB_SUSPEND_WAKEUP_DELAY
-# define USB_SUSPEND_WAKEUP_DELAY 200
+# define USB_SUSPEND_WAKEUP_DELAY 0
#endif
diff --git a/tmk_core/common/sync_timer.c b/tmk_core/common/sync_timer.c
new file mode 100644
index 0000000000..de24b463b6
--- /dev/null
+++ b/tmk_core/common/sync_timer.c
@@ -0,0 +1,58 @@
+/*
+Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+If you happen to meet one of the copyright holders in a bar you are obligated
+to buy them one pint of beer.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+#include "sync_timer.h"
+#include "keyboard.h"
+
+#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER)
+volatile int32_t sync_timer_ms;
+
+void sync_timer_init(void) { sync_timer_ms = 0; }
+
+void sync_timer_update(uint32_t time) {
+ if (is_keyboard_master()) return;
+ sync_timer_ms = time - timer_read32();
+}
+
+uint16_t sync_timer_read(void) {
+ if (is_keyboard_master()) return timer_read();
+ return sync_timer_read32();
+}
+
+uint32_t sync_timer_read32(void) {
+ if (is_keyboard_master()) return timer_read32();
+ return sync_timer_ms + timer_read32();
+}
+
+uint16_t sync_timer_elapsed(uint16_t last) {
+ if (is_keyboard_master()) return timer_elapsed(last);
+ return TIMER_DIFF_16(sync_timer_read(), last);
+}
+
+uint32_t sync_timer_elapsed32(uint32_t last) {
+ if (is_keyboard_master()) return timer_elapsed32(last);
+ return TIMER_DIFF_32(sync_timer_read32(), last);
+}
+#endif
diff --git a/tmk_core/common/sync_timer.h b/tmk_core/common/sync_timer.h
new file mode 100644
index 0000000000..9ddef45bb2
--- /dev/null
+++ b/tmk_core/common/sync_timer.h
@@ -0,0 +1,54 @@
+/*
+Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+If you happen to meet one of the copyright holders in a bar you are obligated
+to buy them one pint of beer.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+#pragma once
+
+#include <stdint.h>
+#include "timer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER)
+void sync_timer_init(void);
+void sync_timer_update(uint32_t time);
+uint16_t sync_timer_read(void);
+uint32_t sync_timer_read32(void);
+uint16_t sync_timer_elapsed(uint16_t last);
+uint32_t sync_timer_elapsed32(uint32_t last);
+#else
+# define sync_timer_init()
+# define sync_timer_clear()
+# define sync_timer_update(t)
+# define sync_timer_read() timer_read()
+# define sync_timer_read32() timer_read32()
+# define sync_timer_elapsed(t) timer_elapsed(t)
+# define sync_timer_elapsed32(t) timer_elapsed32(t)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tmk_core/common/uart.h b/tmk_core/common/uart.h
deleted file mode 100644
index ea247b17b8..0000000000
--- a/tmk_core/common/uart.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-
-void uart_init(uint32_t baud);
-void uart_putchar(uint8_t c);
-uint8_t uart_getchar(void);
-uint8_t uart_available(void);
diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h
index 89128e9daf..28224fe3aa 100644
--- a/tmk_core/common/wait.h
+++ b/tmk_core/common/wait.h
@@ -6,10 +6,89 @@
extern "C" {
#endif
+#if defined(__ARMEL__) || defined(__ARMEB__)
+# ifndef __OPTIMIZE__
+# pragma message "Compiler optimizations disabled; wait_cpuclock() won't work as designed"
+# endif
+
+# define wait_cpuclock(x) wait_cpuclock_allnop(x)
+
+# define CLOCK_DELAY_NOP8 "nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t"
+
+__attribute__((always_inline)) static inline void wait_cpuclock_allnop(unsigned int n) { /* n: 1..135 */
+ /* The argument n must be a constant expression.
+ * That way, compiler optimization will remove unnecessary code. */
+ if (n < 1) {
+ return;
+ }
+ if (n > 8) {
+ unsigned int n8 = n / 8;
+ n = n - n8 * 8;
+ switch (n8) {
+ case 16:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 15:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 14:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 13:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 12:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 11:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 10:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 9:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 8:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 7:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 6:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 5:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 4:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 3:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 2:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 1:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 0:
+ break;
+ }
+ }
+ switch (n) {
+ case 8:
+ asm volatile("nop" ::: "memory");
+ case 7:
+ asm volatile("nop" ::: "memory");
+ case 6:
+ asm volatile("nop" ::: "memory");
+ case 5:
+ asm volatile("nop" ::: "memory");
+ case 4:
+ asm volatile("nop" ::: "memory");
+ case 3:
+ asm volatile("nop" ::: "memory");
+ case 2:
+ asm volatile("nop" ::: "memory");
+ case 1:
+ asm volatile("nop" ::: "memory");
+ case 0:
+ break;
+ }
+}
+#endif
+
#if defined(__AVR__)
# include <util/delay.h>
# define wait_ms(ms) _delay_ms(ms)
# define wait_us(us) _delay_us(us)
+# define wait_cpuclock(x) __builtin_avr_delay_cycles(x)
#elif defined PROTOCOL_CHIBIOS
# include <ch.h>
# define wait_ms(ms) \
diff --git a/tmk_core/make_dfu_header.sh b/tmk_core/make_dfu_header.sh
deleted file mode 100755
index 7e2283dd70..0000000000
--- a/tmk_core/make_dfu_header.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-ALL_CONFIGS=$*
-GREP="grep"
-
-cat <<- EOF > lib/lufa/Bootloaders/DFU/Keyboard.h
-#pragma once
-
-$($GREP "MANUFACTURER[ \t]" $ALL_CONFIGS -h | tail -1)
-$($GREP "PRODUCT[ \t]" $ALL_CONFIGS -h | tail -1 | tr -d '\r') Bootloader
-$($GREP "QMK_ESC_OUTPUT[ \t]" $ALL_CONFIGS -h | tail -1)
-$($GREP "QMK_ESC_INPUT[ \t]" $ALL_CONFIGS -h | tail -1)
-$($GREP "QMK_LED[ \t]" $ALL_CONFIGS -h | tail -1)
-$($GREP "QMK_SPEAKER[ \t]" $ALL_CONFIGS -h | tail -1)
-EOF
diff --git a/tmk_core/protocol/adb.c b/tmk_core/protocol/adb.c
index a23c919619..367f1b09fa 100644
--- a/tmk_core/protocol/adb.c
+++ b/tmk_core/protocol/adb.c
@@ -1,5 +1,5 @@
/*
-Copyright 2011 Jun WAKO <wakojun@gmail.com>
+Copyright 2011-19 Jun WAKO <wakojun@gmail.com>
Copyright 2013 Shay Green <gblargg@gmail.com>
This software is licensed with a Modified BSD License.
@@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <avr/io.h>
#include <avr/interrupt.h>
#include "adb.h"
+#include "print.h"
// GCC doesn't inline functions normally
#define data_lo() (ADB_DDR |= (1 << ADB_DATA_BIT))
@@ -59,7 +60,6 @@ static inline void place_bit1(void);
static inline void send_byte(uint8_t data);
static inline uint16_t wait_data_lo(uint16_t us);
static inline uint16_t wait_data_hi(uint16_t us);
-static inline uint16_t adb_host_dev_recv(uint8_t device);
void adb_host_init(void) {
ADB_PORT &= ~(1 << ADB_DATA_BIT);
@@ -81,119 +81,164 @@ bool adb_host_psw(void) { return psw_in(); }
* <http://geekhack.org/index.php?topic=14290.msg1068919#msg1068919>
* <http://geekhack.org/index.php?topic=14290.msg1070139#msg1070139>
*/
-
-// ADB Bit Cells
-//
-// bit cell time: 70-130us
-// low part of bit0: 60-70% of bit cell
-// low part of bit1: 30-40% of bit cell
-//
-// bit cell time 70us 130us
-// --------------------------------------------
-// low part of bit0 42-49 78-91
-// high part of bit0 21-28 39-52
-// low part of bit1 21-28 39-52
-// high part of bit1 42-49 78-91
-//
-//
-// bit0:
-// 70us bit cell:
-// ____________~~~~~~
-// 42-49 21-28
-//
-// 130us bit cell:
-// ____________~~~~~~
-// 78-91 39-52
-//
-// bit1:
-// 70us bit cell:
-// ______~~~~~~~~~~~~
-// 21-28 42-49
-//
-// 130us bit cell:
-// ______~~~~~~~~~~~~
-// 39-52 78-91
-//
-// [from Apple IIgs Hardware Reference Second Edition]
-
-enum { ADDR_KEYB = 0x20, ADDR_MOUSE = 0x30 };
-
-uint16_t adb_host_kbd_recv(void) { return adb_host_dev_recv(ADDR_KEYB); }
+uint16_t adb_host_kbd_recv(void) { return adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_0); }
#ifdef ADB_MOUSE_ENABLE
-void adb_mouse_init(void) { return; }
+__attribute__((weak)) void adb_mouse_init(void) { return; }
+
+__attribute__((weak)) void adb_mouse_task(void) { return; }
-uint16_t adb_host_mouse_recv(void) { return adb_host_dev_recv(ADDR_MOUSE); }
+uint16_t adb_host_mouse_recv(void) { return adb_host_talk(ADB_ADDR_MOUSE, ADB_REG_0); }
#endif
-static inline uint16_t adb_host_dev_recv(uint8_t device) {
- uint16_t data = 0;
+// This sends Talk command to read data from register and returns length of the data.
+uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) {
+ for (int8_t i = 0; i < len; i++) buf[i] = 0;
+
cli();
attention();
- send_byte(device | 0x0C); // Addr:Keyboard(0010)/Mouse(0011), Cmd:Talk(11), Register0(00)
- place_bit0(); // Stopbit(0)
+ send_byte((addr << 4) | ADB_CMD_TALK | reg);
+ place_bit0(); // Stopbit(0)
+ // TODO: Service Request(Srq):
+ // Device holds low part of comannd stopbit for 140-260us
+ //
+ // Command:
+ // ......._ ______________________ ___ ............_ -------
+ // | | | | | | |
+ // Command | | | | | Data bytes | |
+ // ........|___| | 140-260 |__| |_............|___|
+ // |stop0 | Tlt Stop-to-Start |start1| |stop0 |
+ //
+ // Command without data:
+ // ......._ __________________________
+ // | |
+ // Command | |
+ // ........|___| | 140-260 |
+ // |stop0 | Tlt Stop-to-Start |
+ //
+ // Service Request:
+ // ......._ ______ ___ ............_ -------
+ // | 140-260 | | | | | |
+ // Command | Service Request | | | | Data bytes | |
+ // ........|___________________| |__| |_............|___|
+ // |stop0 | |start1| |stop0 |
+ // ......._ __________
+ // | 140-260 |
+ // Command | Service Request |
+ // ........|___________________|
+ // |stop0 |
+ // This can be happened?
+ // ......._ ______________________ ___ ............_ -----
+ // | | | | | | 140-260 |
+ // Command | | | | | Data bytes | Service Request |
+ // ........|___| | 140-260 |__| |_............|_________________|
+ // |stop0 | Tlt Stop-to-Start |start1| |stop0 |
+ //
+ // "Service requests are issued by the devices during a very specific time at the
+ // end of the reception of the command packet.
+ // If a device in need of service issues a service request, it must do so within
+ // the 65 µs of the Stop Bit’s low time and maintain the line low for a total of 300 µs."
+ //
+ // "A device sends a Service Request signal by holding the bus low during the low
+ // portion of the stop bit of any command or data transaction. The device must lengthen
+ // the stop by a minimum of 140 J.lS beyond its normal duration, as shown in Figure 8-15."
+ // http://ww1.microchip.com/downloads/en/AppNotes/00591b.pdf
if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored
+ xprintf("R");
sei();
- return -30; // something wrong
+ return 0;
}
if (!wait_data_lo(500)) { // Tlt/Stop to Start(140-260us)
sei();
- return 0; // No data to send
+ return 0; // No data from device(not error);
+ }
+
+ // start bit(1)
+ if (!wait_data_hi(40)) {
+ xprintf("S");
+ sei();
+ return 0;
+ }
+ if (!wait_data_lo(100)) {
+ xprintf("s");
+ sei();
+ return 0;
}
- uint8_t n = 17; // start bit + 16 data bits
+ uint8_t n = 0; // bit count
do {
+ //
+ // |<- bit_cell_max(130) ->|
+ // | |<- lo ->|
+ // | | |<-hi->|
+ // _______
+ // | | |
+ // | 130-lo | lo-hi |
+ // |________| |
+ //
uint8_t lo = (uint8_t)wait_data_hi(130);
- if (!lo) goto error;
+ if (!lo) goto error; // no more bit or after stop bit
uint8_t hi = (uint8_t)wait_data_lo(lo);
- if (!hi) goto error;
+ if (!hi) goto error; // stop bit extedned by Srq?
- hi = lo - hi;
- lo = 130 - lo;
+ if (n / 8 >= len) continue; // can't store in buf
- data <<= 1;
- if (lo < hi) {
- data |= 1;
- } else if (n == 17) {
- sei();
- return -20;
+ buf[n / 8] <<= 1;
+ if ((130 - lo) < (lo - hi)) {
+ buf[n / 8] |= 1;
}
- } while (--n);
-
- // Stop bit can't be checked normally since it could have service request lenghtening
- // and its high state never goes low.
- if (!wait_data_hi(351) || wait_data_lo(91)) {
- sei();
- return -21;
- }
- sei();
- return data;
+ } while (++n);
error:
sei();
- return -n;
+ return n / 8;
}
-void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l) {
+uint16_t adb_host_talk(uint8_t addr, uint8_t reg) {
+ uint8_t len;
+ uint8_t buf[8];
+ len = adb_host_talk_buf(addr, reg, buf, 8);
+ if (len != 2) return 0;
+ return (buf[0] << 8 | buf[1]);
+}
+
+void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) {
cli();
attention();
- send_byte(cmd);
- place_bit0(); // Stopbit(0)
+ send_byte((addr << 4) | ADB_CMD_LISTEN | reg);
+ place_bit0(); // Stopbit(0)
+ // TODO: Service Request
_delay_us(200); // Tlt/Stop to Start
place_bit1(); // Startbit(1)
- send_byte(data_h);
- send_byte(data_l);
+ for (int8_t i = 0; i < len; i++) {
+ send_byte(buf[i]);
+ // xprintf("%02X ", buf[i]);
+ }
place_bit0(); // Stopbit(0);
sei();
}
+void adb_host_listen(uint8_t addr, uint8_t reg, uint8_t data_h, uint8_t data_l) {
+ uint8_t buf[2] = {data_h, data_l};
+ adb_host_listen_buf(addr, reg, buf, 2);
+}
+
+void adb_host_flush(uint8_t addr) {
+ cli();
+ attention();
+ send_byte((addr << 4) | ADB_CMD_FLUSH);
+ place_bit0(); // Stopbit(0)
+ _delay_us(200); // Tlt/Stop to Start
+ sei();
+}
+
// send state of LEDs
void adb_host_kbd_led(uint8_t led) {
- // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10)
- // send upper byte (not used)
- // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0:
- adb_host_listen(0x2A, 0, led & 0x07);
+ // Listen Register2
+ // upper byte: not used
+ // lower byte: bit2=ScrollLock, bit1=CapsLock, bit0=NumLock
+ adb_host_listen(ADB_ADDR_KEYBOARD, ADB_REG_2, 0, led & 0x07);
}
#ifdef ADB_PSW_BIT
@@ -327,7 +372,7 @@ Commands
bits commands
------------------------------------------------------
- - - - - 0 0 0 0 Send Request(reset all devices)
+ - - - - 0 0 0 0 Send Reset(reset all devices)
A A A A 0 0 0 1 Flush(reset a device)
- - - - 0 0 1 0 Reserved
- - - - 0 0 1 1 Reserved
@@ -435,5 +480,56 @@ Keyboard LEDs & state of keys(Register2)
| +----------------------------- Delete
+------------------------------- Reserved
+Address, Handler ID and bits(Register3)
+ 1514131211 . . 8 7 . . . . . . 0
+ | | | | | | | | | | | | | | | |
+ | | | | | | | | +-+-+-+-+-+-+-+- Handler ID
+ | | | | +-+-+-+----------------- Address
+ | | | +------------------------- 0
+ | | +--------------------------- Service request enable(1 = enabled)
+ | +----------------------------- Exceptional event(alwyas 1 if not used)
+ +------------------------------- 0
+
+ADB Bit Cells
+ bit cell time: 70-130us
+ low part of bit0: 60-70% of bit cell
+ low part of bit1: 30-40% of bit cell
+
+ bit cell time 70us 130us
+ --------------------------------------------
+ low part of bit0 42-49 78-91
+ high part of bit0 21-28 39-52
+ low part of bit1 21-28 39-52
+ high part of bit1 42-49 78-91
+
+
+ bit0:
+ 70us bit cell:
+ ____________~~~~~~
+ 42-49 21-28
+
+ 130us bit cell:
+ ____________~~~~~~
+ 78-91 39-52
+
+ bit1:
+ 70us bit cell:
+ ______~~~~~~~~~~~~
+ 21-28 42-49
+
+ 130us bit cell:
+ ______~~~~~~~~~~~~
+ 39-52 78-91
+
+ [from Apple IIgs Hardware Reference Second Edition]
+
+Keyboard Handle ID
+ Apple Standard Keyboard M0116: 0x01
+ Apple Extended Keyboard M0115: 0x02
+ Apple Extended Keyboard II M3501: 0x02
+ Apple Adjustable Keybaord: 0x10
+
+ http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L802
+
END_OF_ADB
*/
diff --git a/tmk_core/protocol/adb.h b/tmk_core/protocol/adb.h
index 34cbcf7691..fe8becc2d5 100644
--- a/tmk_core/protocol/adb.h
+++ b/tmk_core/protocol/adb.h
@@ -1,5 +1,5 @@
/*
-Copyright 2011 Jun WAKO <wakojun@gmail.com>
+Copyright 2011-19 Jun WAKO <wakojun@gmail.com>
This software is licensed with a Modified BSD License.
All of this is supposed to be Free Software, Open Source, DFSG-free,
@@ -47,12 +47,60 @@ POSSIBILITY OF SUCH DAMAGE.
#define ADB_POWER 0x7F
#define ADB_CAPS 0x39
+/* ADB commands */
+// Default Address
+#define ADB_ADDR_0 0
+#define ADB_ADDR_DONGLE 1
+#define ADB_ADDR_KEYBOARD 2
+#define ADB_ADDR_MOUSE 3
+#define ADB_ADDR_TABLET 4
+#define ADB_ADDR_APPLIANCE 7
+#define ADB_ADDR_8 8
+#define ADB_ADDR_9 9
+#define ADB_ADDR_10 10
+#define ADB_ADDR_11 11
+#define ADB_ADDR_12 12
+#define ADB_ADDR_13 13
+#define ADB_ADDR_14 14
+#define ADB_ADDR_15 15
+// for temporary purpose, do not use for polling
+#define ADB_ADDR_TMP 15
+#define ADB_ADDR_MOUSE_POLL 10
+// Command Type
+#define ADB_CMD_RESET 0
+#define ADB_CMD_FLUSH 1
+#define ADB_CMD_LISTEN 8
+#define ADB_CMD_TALK 12
+// Register
+#define ADB_REG_0 0
+#define ADB_REG_1 1
+#define ADB_REG_2 2
+#define ADB_REG_3 3
+
+/* ADB keyboard handler id */
+#define ADB_HANDLER_STD 0x01 /* IIGS, M0116 */
+#define ADB_HANDLER_AEK 0x02 /* M0115, M3501 */
+#define ADB_HANDLER_AEK_RMOD 0x03 /* M0115, M3501, alternate mode enableing right modifiers */
+#define ADB_HANDLER_STD_ISO 0x04 /* M0118, ISO swapping keys */
+#define ADB_HANDLER_AEK_ISO 0x05 /* M0115, M3501, ISO swapping keys */
+#define ADB_HANDLER_M1242_ANSI 0x10 /* Adjustable keyboard */
+#define ADB_HANDLER_CLASSIC1_MOUSE 0x01
+#define ADB_HANDLER_CLASSIC2_MOUSE 0x02
+#define ADB_HANDLER_EXTENDED_MOUSE 0x04
+#define ADB_HANDLER_TURBO_MOUSE 0x32
+
// ADB host
void adb_host_init(void);
bool adb_host_psw(void);
+uint16_t adb_host_talk(uint8_t addr, uint8_t reg);
+uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len);
+void adb_host_listen(uint8_t addr, uint8_t reg, uint8_t data_h, uint8_t data_l);
+void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len);
+void adb_host_flush(uint8_t addr);
+void adb_host_kbd_led(uint8_t led);
uint16_t adb_host_kbd_recv(void);
uint16_t adb_host_mouse_recv(void);
-void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l);
-void adb_host_kbd_led(uint8_t led);
-void adb_mouse_task(void);
-void adb_mouse_init(void);
+
+// ADB Mouse
+void adb_mouse_task(void);
+void adb_mouse_init(void);
diff --git a/tmk_core/protocol/arm_atsam/i2c_master.c b/tmk_core/protocol/arm_atsam/i2c_master.c
index d3319ab447..dda2f85b00 100644
--- a/tmk_core/protocol/arm_atsam/i2c_master.c
+++ b/tmk_core/protocol/arm_atsam/i2c_master.c
@@ -28,6 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define I2C_LED_USE_DMA 1 // Set 1 to use background DMA transfers for leds, Set 0 to use inline software transfers
+DmacDescriptor dmac_desc;
+DmacDescriptor dmac_desc_wb;
+
static uint8_t i2c_led_q[I2C_Q_SIZE]; // I2C queue circular buffer
static uint8_t i2c_led_q_s; // Start of circular buffer
static uint8_t i2c_led_q_e; // End of circular buffer
diff --git a/tmk_core/protocol/arm_atsam/i2c_master.h b/tmk_core/protocol/arm_atsam/i2c_master.h
index 44dbdfbffa..68773f213f 100644
--- a/tmk_core/protocol/arm_atsam/i2c_master.h
+++ b/tmk_core/protocol/arm_atsam/i2c_master.h
@@ -24,8 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "issi3733_driver.h"
# include "config.h"
-__attribute__((__aligned__(16))) DmacDescriptor dmac_desc;
-__attribute__((__aligned__(16))) DmacDescriptor dmac_desc_wb;
+extern __attribute__((__aligned__(16))) DmacDescriptor dmac_desc;
+extern __attribute__((__aligned__(16))) DmacDescriptor dmac_desc_wb;
uint8_t I2C3733_Init_Control(void);
uint8_t I2C3733_Init_Drivers(void);
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index e10be52fb8..ab5e9a9852 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -305,11 +305,5 @@ int main(void) {
// dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired);
}
#endif // CONSOLE_ENABLE
-
- // Run housekeeping
- housekeeping_task_kb();
- housekeeping_task_user();
- }
-
return 1;
}
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
index b337df7627..2b0805dc86 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
@@ -15,16 +15,17 @@ 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 "arm_atsam_protocol.h"
-#include "tmk_core/common/led.h"
-#include "rgb_matrix.h"
-#include <string.h>
-#include <math.h>
-
-#ifdef USE_MASSDROP_CONFIGURATOR
+#ifdef RGB_MATRIX_ENABLE
+# include "arm_atsam_protocol.h"
+# include "led.h"
+# include "rgb_matrix.h"
+# include <string.h>
+# include <math.h>
+
+# ifdef USE_MASSDROP_CONFIGURATOR
__attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}};
static void md_rgb_matrix_config_override(int i);
-#endif // USE_MASSDROP_CONFIGURATOR
+# endif // USE_MASSDROP_CONFIGURATOR
void SERCOM1_0_Handler(void) {
if (SERCOM1->I2CM.INTFLAG.bit.ERROR) {
@@ -58,17 +59,17 @@ RGB led_buffer[ISSI3733_LED_COUNT];
uint8_t gcr_desired;
uint8_t gcr_actual;
uint8_t gcr_actual_last;
-#ifdef USE_MASSDROP_CONFIGURATOR
+# ifdef USE_MASSDROP_CONFIGURATOR
uint8_t gcr_breathe;
float breathe_mult;
float pomod;
-#endif
+# endif
-#define ACT_GCR_NONE 0
-#define ACT_GCR_INC 1
-#define ACT_GCR_DEC 2
+# define ACT_GCR_NONE 0
+# define ACT_GCR_INC 1
+# define ACT_GCR_DEC 2
-#define LED_GCR_STEP_AUTO 2
+# define LED_GCR_STEP_AUTO 2
static uint8_t gcr_min_counter;
static uint8_t v_5v_cat_hit;
@@ -78,11 +79,11 @@ void gcr_compute(void) {
uint8_t action = ACT_GCR_NONE;
uint8_t gcr_use = gcr_desired;
-#ifdef USE_MASSDROP_CONFIGURATOR
+# ifdef USE_MASSDROP_CONFIGURATOR
if (led_animation_breathing) {
gcr_use = gcr_breathe;
}
-#endif
+# endif
// If the 5v takes a catastrophic hit, disable the LED drivers briefly, assert auto gcr mode, min gcr and let the auto take over
if (v_5v < V5_CAT) {
@@ -150,7 +151,7 @@ void gcr_compute(void) {
gcr_actual -= LED_GCR_STEP_AUTO;
gcr_min_counter = 0;
-#ifdef USE_MASSDROP_CONFIGURATOR
+# ifdef USE_MASSDROP_CONFIGURATOR
// If breathe mode is active, the top end can fluctuate if the host can not supply enough current
// So set the breathe GCR to where it becomes stable
if (led_animation_breathing == 1) {
@@ -159,7 +160,7 @@ void gcr_compute(void) {
// and the same would happen maybe one or two more times. Therefore I'm favoring
// powering through one full breathe and letting gcr settle completely
}
-#endif
+# endif
}
}
}
@@ -196,25 +197,25 @@ void md_rgb_matrix_prepare(void) {
}
}
-void led_set_one(int i, uint8_t r, uint8_t g, uint8_t b) {
+static void led_set_one(int i, uint8_t r, uint8_t g, uint8_t b) {
if (i < ISSI3733_LED_COUNT) {
-#ifdef USE_MASSDROP_CONFIGURATOR
+# ifdef USE_MASSDROP_CONFIGURATOR
md_rgb_matrix_config_override(i);
-#else
+# else
led_buffer[i].r = r;
led_buffer[i].g = g;
led_buffer[i].b = b;
-#endif
+# endif
}
}
-void led_set_all(uint8_t r, uint8_t g, uint8_t b) {
+static void led_set_all(uint8_t r, uint8_t g, uint8_t b) {
for (uint8_t i = 0; i < ISSI3733_LED_COUNT; i++) {
led_set_one(i, r, g, b);
}
}
-void init(void) {
+static void init(void) {
DBGC(DC_LED_MATRIX_INIT_BEGIN);
issi3733_prepare_arrays();
@@ -227,16 +228,16 @@ void init(void) {
DBGC(DC_LED_MATRIX_INIT_COMPLETE);
}
-void flush(void) {
-#ifdef USE_MASSDROP_CONFIGURATOR
+static void flush(void) {
+# ifdef USE_MASSDROP_CONFIGURATOR
if (!led_enabled) {
return;
} // Prevent calculations and I2C traffic if LED drivers are not enabled
-#else
+# else
if (!sr_exp_data.bit.SDB_N) {
return;
} // Prevent calculations and I2C traffic if LED drivers are not enabled
-#endif
+# endif
// Wait for previous transfer to complete
while (i2c_led_q_running) {
@@ -249,7 +250,7 @@ void flush(void) {
*led_map[i].rgb.b = led_buffer[i].b;
}
-#ifdef USE_MASSDROP_CONFIGURATOR
+# ifdef USE_MASSDROP_CONFIGURATOR
breathe_mult = 1;
if (led_animation_breathing) {
@@ -275,7 +276,7 @@ void flush(void) {
pomod = (uint32_t)pomod % 10000;
pomod /= 100.0f;
-#endif // USE_MASSDROP_CONFIGURATOR
+# endif // USE_MASSDROP_CONFIGURATOR
uint8_t drvid;
@@ -295,25 +296,27 @@ void md_rgb_matrix_indicators(void) {
if (kbled && rgb_matrix_config.enable) {
for (uint8_t i = 0; i < ISSI3733_LED_COUNT; i++) {
if (
-#if USB_LED_NUM_LOCK_SCANCODE != 255
+# if USB_LED_NUM_LOCK_SCANCODE != 255
(led_map[i].scan == USB_LED_NUM_LOCK_SCANCODE && (kbled & (1 << USB_LED_NUM_LOCK))) ||
-#endif // NUM LOCK
-#if USB_LED_CAPS_LOCK_SCANCODE != 255
+# endif // NUM LOCK
+# if USB_LED_CAPS_LOCK_SCANCODE != 255
(led_map[i].scan == USB_LED_CAPS_LOCK_SCANCODE && (kbled & (1 << USB_LED_CAPS_LOCK))) ||
-#endif // CAPS LOCK
-#if USB_LED_SCROLL_LOCK_SCANCODE != 255
+# endif // CAPS LOCK
+# if USB_LED_SCROLL_LOCK_SCANCODE != 255
(led_map[i].scan == USB_LED_SCROLL_LOCK_SCANCODE && (kbled & (1 << USB_LED_SCROLL_LOCK))) ||
-#endif // SCROLL LOCK
-#if USB_LED_COMPOSE_SCANCODE != 255
+# endif // SCROLL LOCK
+# if USB_LED_COMPOSE_SCANCODE != 255
(led_map[i].scan == USB_LED_COMPOSE_SCANCODE && (kbled & (1 << USB_LED_COMPOSE))) ||
-#endif // COMPOSE
-#if USB_LED_KANA_SCANCODE != 255
+# endif // COMPOSE
+# if USB_LED_KANA_SCANCODE != 255
(led_map[i].scan == USB_LED_KANA_SCANCODE && (kbled & (1 << USB_LED_KANA))) ||
-#endif // KANA
+# endif // KANA
(0)) {
- led_buffer[i].r = 255 - led_buffer[i].r;
- led_buffer[i].g = 255 - led_buffer[i].g;
- led_buffer[i].b = 255 - led_buffer[i].b;
+ if (rgb_matrix_get_flags() & LED_FLAG_INDICATOR) {
+ led_buffer[i].r = 255 - led_buffer[i].r;
+ led_buffer[i].g = 255 - led_buffer[i].g;
+ led_buffer[i].b = 255 - led_buffer[i].b;
+ }
}
}
}
@@ -325,7 +328,7 @@ const rgb_matrix_driver_t rgb_matrix_driver = {.init = init, .flush = flush, .se
= Legacy Lighting Support =
==============================================================================*/
-#ifdef USE_MASSDROP_CONFIGURATOR
+# ifdef USE_MASSDROP_CONFIGURATOR
// Ported from Massdrop QMK GitHub Repo
// TODO?: wire these up to keymap.c
@@ -467,4 +470,5 @@ static void md_rgb_matrix_config_override(int i) {
led_buffer[i].b = (uint8_t)bo;
}
-#endif // USE_MASSDROP_CONFIGURATOR
+# endif // USE_MASSDROP_CONFIGURATOR
+#endif // RGB_MATRIX_ENABLE
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
index b43008cc5b..fce225a6c4 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
@@ -15,9 +15,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef USE_MASSDROP_CONFIGURATOR
+#ifdef RGB_MATRIX_ENABLE
+# ifdef USE_MASSDROP_CONFIGURATOR
-# include "md_rgb_matrix.h"
+# include "md_rgb_matrix.h"
// Teal <-> Salmon
led_setup_t leds_teal_salmon[] = {
@@ -96,4 +97,5 @@ void *led_setups[] = {leds_rainbow_s, leds_rainbow_ns, leds_teal_salmon, leds_ye
const uint8_t led_setups_count = sizeof(led_setups) / sizeof(led_setups[0]);
-#endif
+# endif // USE_MASSDROP_CONFIGURATOR
+#endif // RGB_MATRIX_ENABLE
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
index e3fa65574e..9ea4addcfc 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
@@ -374,39 +374,33 @@ static uint8_t udi_hid_exk_report_trans[UDI_HID_EXK_REPORT_SIZE];
COMPILER_WORD_ALIGNED
UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{
+ // clang-format off
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x80, // Usage (System Control)
0xA1, 0x01, // Collection (Application)
0x85, REPORT_ID_SYSTEM, // Report ID
- 0x1A, 0x81,
- 0x00, // Usage Minimum (81) (System Power Down)
- 0x2A, 0x83,
- 0x00, // Usage Maximum (83) (System Wake Up)
- 0x16, 0x01,
- 0x00, // Logical Minimum (1)
- 0x26, 0x03,
- 0x00, // Logical Maximum (3)
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x10, // Report Size (16)
- 0x81, 0x00, // Input (Data, Array, Absolute)
- 0xC0, // End Collection
+ 0x19, 0x01, // Usage Minimum (Pointer)
+ 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xB7, 0x00, // Logical Maximum
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x10, // Report Size (16)
+ 0x81, 0x00, // Input (Data, Array, Absolute)
+ 0xC0, // End Collection
0x05, 0x0C, // Usage Page (Consumer)
0x09, 0x01, // Usage (Consumer Control)
0xA1, 0x01, // Collection (Application)
0x85, REPORT_ID_CONSUMER, // Report ID
- 0x1A, 0x01,
- 0x00, // Usage Minimum (Consumer Control)
- 0x2A, 0x9C,
- 0x02, // Usage Maximum (AC Distribute Vertically)
- 0x16, 0x01,
- 0x00, // Logical Minimum
- 0x26, 0x9C,
- 0x02, // Logical Maximum
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x10, // Report Size (16)
- 0x81, 0x00, // Input (Data, Array, Absolute)
- 0xC0 // End Collection
+ 0x19, 0x01, // Usage Minimum (Consumer Control)
+ 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xA0, 0x02, // Logical Maximum
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x10, // Report Size (16)
+ 0x81, 0x00, // Input (Data, Array, Absolute)
+ 0xC0 // End Collection
+ //clang-format on
}};
static bool udi_hid_exk_setreport(void);
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
index 2f8a39bdd8..fb97f63cef 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
@@ -186,9 +186,10 @@ COMPILER_PACK_RESET()
#define USB_HID_COUNTRY_UK 32 // UK
#define USB_HID_COUNTRY_US 33 // US
#define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia
-#define USB_HID_COUNTRY_TURKISH_F 35 // Turkish-F
- //! @}
- //! @}
+#define USB_HID_COUNTRY_TURKISH_F \
+ 35 // Turkish-F
+ //! @}
+ //! @}
//! @}
//! \name HID KEYS values
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index 5c27a8c6a0..6cd88be577 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -167,6 +167,7 @@ int main(void) {
keyboard_setup();
/* Init USB */
+ usb_event_queue_init();
init_usb_driver(&USB_DRIVER);
#ifdef MIDI_ENABLE
@@ -225,6 +226,8 @@ int main(void) {
/* Main loop */
while (true) {
+ usb_event_queue_task();
+
#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
print("[s]");
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 67ae8520fd..990dc1b91c 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -27,6 +27,7 @@
#include <ch.h>
#include <hal.h>
+#include <string.h>
#include "usb_main.h"
@@ -50,6 +51,7 @@ extern keymap_config_t keymap_config;
#ifdef WEBUSB_ENABLE
# include "webusb.h"
#endif
+
#ifdef JOYSTICK_ENABLE
# include "joystick.h"
#endif
@@ -168,6 +170,7 @@ static const USBEndpointConfig shared_ep_config = {
};
#endif
+
#ifdef WEBUSB_ENABLE
/** Microsoft OS 2.0 Descriptor. This is used by Windows to select the USB driver for the device.
*
@@ -397,6 +400,69 @@ static usb_driver_configs_t drivers = {
* ---------------------------------------------------------
*/
+#define USB_EVENT_QUEUE_SIZE 16
+usbevent_t event_queue[USB_EVENT_QUEUE_SIZE];
+uint8_t event_queue_head;
+uint8_t event_queue_tail;
+
+void usb_event_queue_init(void) {
+ // Initialise the event queue
+ memset(&event_queue, 0, sizeof(event_queue));
+ event_queue_head = 0;
+ event_queue_tail = 0;
+}
+
+static inline bool usb_event_queue_enqueue(usbevent_t event) {
+ uint8_t next = (event_queue_head + 1) % USB_EVENT_QUEUE_SIZE;
+ if (next == event_queue_tail) {
+ return false;
+ }
+ event_queue[event_queue_head] = event;
+ event_queue_head = next;
+ return true;
+}
+
+static inline bool usb_event_queue_dequeue(usbevent_t *event) {
+ if (event_queue_head == event_queue_tail) {
+ return false;
+ }
+ *event = event_queue[event_queue_tail];
+ event_queue_tail = (event_queue_tail + 1) % USB_EVENT_QUEUE_SIZE;
+ return true;
+}
+
+static inline void usb_event_suspend_handler(void) {
+#ifdef SLEEP_LED_ENABLE
+ sleep_led_enable();
+#endif /* SLEEP_LED_ENABLE */
+}
+
+static inline void usb_event_wakeup_handler(void) {
+ suspend_wakeup_init();
+#ifdef SLEEP_LED_ENABLE
+ sleep_led_disable();
+ // NOTE: converters may not accept this
+ led_set(host_keyboard_leds());
+#endif /* SLEEP_LED_ENABLE */
+}
+
+void usb_event_queue_task(void) {
+ usbevent_t event;
+ while (usb_event_queue_dequeue(&event)) {
+ switch (event) {
+ case USB_EVENT_SUSPEND:
+ usb_event_suspend_handler();
+ break;
+ case USB_EVENT_WAKEUP:
+ usb_event_wakeup_handler();
+ break;
+ default:
+ // Nothing to do, we don't handle it.
+ break;
+ }
+ }
+}
+
/* Handles the USB driver global events
* TODO: maybe disable some things when connection is lost? */
static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
@@ -431,9 +497,7 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
osalSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
-#ifdef SLEEP_LED_ENABLE
- sleep_led_enable();
-#endif /* SLEEP_LED_ENABLE */
+ usb_event_queue_enqueue(USB_EVENT_SUSPEND);
/* Falls into.*/
case USB_EVENT_UNCONFIGURED:
/* Falls into.*/
@@ -454,12 +518,7 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
qmkusbWakeupHookI(&drivers.array[i].driver);
chSysUnlockFromISR();
}
- suspend_wakeup_init();
-#ifdef SLEEP_LED_ENABLE
- sleep_led_disable();
- // NOTE: converters may not accept this
- led_set(host_keyboard_leds());
-#endif /* SLEEP_LED_ENABLE */
+ usb_event_queue_enqueue(USB_EVENT_WAKEUP);
return;
case USB_EVENT_STALLED:
@@ -575,7 +634,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
if (!keymap_config.nkro && keyboard_idle) {
#else /* NKRO_ENABLE */
if (keyboard_idle) {
-#endif /* NKRO_ENABLE */
+#endif /* NKRO_ENABLE */
/* arm the idle timer if boot protocol & idle */
osalSysLockFromISR();
chVTSetI(&keyboard_idle_timer, 4 * TIME_MS2I(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp);
@@ -867,7 +926,7 @@ void send_mouse(report_mouse_t *report) {
}
#else /* MOUSE_ENABLE */
-void send_mouse(report_mouse_t *report) { (void)report; }
+void send_mouse(report_mouse_t *report) { (void)report; }
#endif /* MOUSE_ENABLE */
/* ---------------------------------------------------------
@@ -923,9 +982,32 @@ void send_consumer(uint16_t data) {
#ifdef CONSOLE_ENABLE
int8_t sendchar(uint8_t c) {
- // The previous implmentation had timeouts, but I think it's better to just slow down
- // and make sure that everything is transferred, rather than dropping stuff
- return chnWrite(&drivers.console_driver.driver, &c, 1);
+ static bool timed_out = false;
+ /* The `timed_out` state is an approximation of the ideal `is_listener_disconnected?` state.
+ *
+ * When a 5ms timeout write has timed out, hid_listen is most likely not running, or not
+ * listening to this keyboard, so we go into the timed_out state. In this state we assume
+ * that hid_listen is most likely not gonna be connected to us any time soon, so it would
+ * be wasteful to write follow-up characters with a 5ms timeout, it would all add up and
+ * unncecessarily slow down the firmware. However instead of just dropping the characters,
+ * we write them with a TIME_IMMEDIATE timeout, which is a zero timeout,
+ * and this will succeed only if hid_listen gets connected again. When a write with
+ * TIME_IMMEDIATE timeout succeeds, we know that hid_listen is listening to us again, and
+ * we can go back to the timed_out = false state, and following writes will be executed
+ * with a 5ms timeout. The reason we don't just send all characters with the TIME_IMMEDIATE
+ * timeout is that this could cause bytes to be lost even if hid_listen is running, if there
+ * is a lot of data being sent over the console.
+ *
+ * This logic will work correctly as long as hid_listen is able to receive at least 200
+ * bytes per second. On a heavily overloaded machine that's so overloaded that it's
+ * unusable, and constantly swapping, hid_listen might have trouble receiving 200 bytes per
+ * second, so some bytes might be lost on the console.
+ */
+
+ const sysinterval_t timeout = timed_out ? TIME_IMMEDIATE : TIME_MS2I(5);
+ const size_t result = chnWriteTimeout(&drivers.console_driver.driver, &c, 1, timeout);
+ timed_out = (result == 0);
+ return result;
}
// Just a dummy function for now, this could be exposed as a weak function
@@ -946,15 +1028,8 @@ void console_task(void) {
} while (size > 0);
}
-#else /* CONSOLE_ENABLE */
-int8_t sendchar(uint8_t c) {
- (void)c;
- return 0;
-}
#endif /* CONSOLE_ENABLE */
-void _putchar(char character) { sendchar(character); }
-
#ifdef RAW_ENABLE
void raw_hid_send(uint8_t *data, uint8_t length) {
// TODO: implement variable size packet
diff --git a/tmk_core/protocol/chibios/usb_main.h b/tmk_core/protocol/chibios/usb_main.h
index eaa08d8f79..fb33c8cd0f 100644
--- a/tmk_core/protocol/chibios/usb_main.h
+++ b/tmk_core/protocol/chibios/usb_main.h
@@ -38,6 +38,17 @@ void init_usb_driver(USBDriver *usbp);
void restart_usb_driver(USBDriver *usbp);
/* ---------------
+ * USB Event queue
+ * ---------------
+ */
+
+/* Initialisation of the FIFO */
+void usb_event_queue_init(void);
+
+/* Task to dequeue and execute any handlers for the USB events on the main thread */
+void usb_event_queue_task(void);
+
+/* ---------------
* Keyboard header
* ---------------
*/
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 1d019d1695..b1af36d113 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -782,9 +782,7 @@ static void send_keyboard(report_keyboard_t *report) {
uint8_t timeout = 255;
#ifdef BLUETOOTH_ENABLE
- uint8_t where = where_to_send();
-
- if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
+ if (where_to_send() == OUTPUT_BLUETOOTH) {
# ifdef MODULE_ADAFRUIT_BLE
adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys));
# elif MODULE_RN42
@@ -797,9 +795,6 @@ static void send_keyboard(report_keyboard_t *report) {
serial_send(report->keys[i]);
}
# endif
- }
-
- if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) {
return;
}
#endif
@@ -840,9 +835,7 @@ static void send_mouse(report_mouse_t *report) {
uint8_t timeout = 255;
# ifdef BLUETOOTH_ENABLE
- uint8_t where = where_to_send();
-
- if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
+ if (where_to_send() == OUTPUT_BLUETOOTH) {
# ifdef MODULE_ADAFRUIT_BLE
// FIXME: mouse buttons
adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons);
@@ -857,9 +850,6 @@ static void send_mouse(report_mouse_t *report) {
serial_send(report->h); // should try sending the wheel h here
serial_send(0x00);
# endif
- }
-
- if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) {
return;
}
# endif
@@ -918,9 +908,13 @@ static void send_system(uint16_t data) {
static void send_consumer(uint16_t data) {
#ifdef EXTRAKEY_ENABLE
# ifdef BLUETOOTH_ENABLE
+<<<<<<< HEAD
uint8_t where = where_to_send();
if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
+=======
+ if (where_to_send() == OUTPUT_BLUETOOTH) {
+>>>>>>> 0.12.52~1
# ifdef MODULE_ADAFRUIT_BLE
adafruit_ble_send_consumer_key(data);
# elif MODULE_RN42
@@ -934,9 +928,12 @@ static void send_consumer(uint16_t data) {
serial_send(bitmap & 0xFF);
serial_send((bitmap >> 8) & 0xFF);
# endif
+<<<<<<< HEAD
}
if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) {
+=======
+>>>>>>> 0.12.52~1
return;
}
# endif
@@ -955,9 +952,14 @@ static void send_consumer(uint16_t data) {
* FIXME: Needs doc
*/
int8_t sendchar(uint8_t c) {
+<<<<<<< HEAD
// Not wait once timeouted.
+=======
+ // Do not wait if the previous write has timed_out.
+>>>>>>> 0.12.52~1
// Because sendchar() is called so many times, waiting each call causes big lag.
- static bool timeouted = false;
+ // The `timed_out` state is an approximation of the ideal `is_listener_disconnected?` state.
+ static bool timed_out = false;
// prevents Console_Task() from running during sendchar() runs.
// or char will be lost. These two function is mutually exclusive.
@@ -971,11 +973,11 @@ int8_t sendchar(uint8_t c) {
goto ERROR_EXIT;
}
- if (timeouted && !Endpoint_IsReadWriteAllowed()) {
+ if (timed_out && !Endpoint_IsReadWriteAllowed()) {
goto ERROR_EXIT;
}
- timeouted = false;
+ timed_out = false;
uint8_t timeout = SEND_TIMEOUT;
while (!Endpoint_IsReadWriteAllowed()) {
@@ -986,7 +988,7 @@ int8_t sendchar(uint8_t c) {
goto ERROR_EXIT;
}
if (!(timeout--)) {
- timeouted = true;
+ timed_out = true;
goto ERROR_EXIT;
}
_delay_ms(1);
@@ -1136,7 +1138,6 @@ static void setup_usb(void) {
// for Console_Task
USB_Device_EnableSOFEvents();
- print_set_sendchar(sendchar);
}
/** \brief Main
diff --git a/tmk_core/protocol/lufa/outputselect.h b/tmk_core/protocol/lufa/outputselect.h
index 7f7ed00b95..c4548e1122 100644
--- a/tmk_core/protocol/lufa/outputselect.h
+++ b/tmk_core/protocol/lufa/outputselect.h
@@ -21,21 +21,11 @@ enum outputs {
OUTPUT_NONE,
OUTPUT_USB,
- OUTPUT_BLUETOOTH,
-
- // backward compatibility
- OUTPUT_USB_AND_BT
+ OUTPUT_BLUETOOTH
};
-/**
- * backward compatibility for BLUETOOTH_ENABLE, send to BT and USB by default
- */
#ifndef OUTPUT_DEFAULT
-# ifdef BLUETOOTH_ENABLE
-# define OUTPUT_DEFAULT OUTPUT_USB_AND_BT
-# else
-# define OUTPUT_DEFAULT OUTPUT_AUTO
-# endif
+# define OUTPUT_DEFAULT OUTPUT_AUTO
#endif
void set_output(uint8_t output);
diff --git a/tmk_core/protocol/m0110.c b/tmk_core/protocol/m0110.c
index b02a6933d2..64f2fa50ab 100644
--- a/tmk_core/protocol/m0110.c
+++ b/tmk_core/protocol/m0110.c
@@ -95,11 +95,11 @@ void m0110_init(void) {
uint8_t data;
m0110_send(M0110_MODEL);
data = m0110_recv();
- print("m0110_init model: "); phex(data); print("\n");
+ print("m0110_init model: "); print_hex8(data); print("\n");
m0110_send(M0110_TEST);
data = m0110_recv();
- print("m0110_init test: "); phex(data); print("\n");
+ print("m0110_init test: "); print_hex8(data); print("\n");
*/
}
@@ -122,7 +122,7 @@ uint8_t m0110_send(uint8_t data) {
return 1;
ERROR:
print("m0110_send err: ");
- phex(m0110_error);
+ print_hex8(m0110_error);
print("\n");
_delay_ms(500);
idle();
@@ -146,7 +146,7 @@ uint8_t m0110_recv(void) {
return data;
ERROR:
print("m0110_recv err: ");
- phex(m0110_error);
+ print_hex8(m0110_error);
print("\n");
_delay_ms(500);
idle();
diff --git a/tmk_core/protocol/midi/qmk_midi.c b/tmk_core/protocol/midi/qmk_midi.c
index 6f6aced725..c18dbf9930 100644
--- a/tmk_core/protocol/midi/qmk_midi.c
+++ b/tmk_core/protocol/midi/qmk_midi.c
@@ -5,7 +5,7 @@
#include "usb_descriptor.h"
#include "process_midi.h"
#if API_SYSEX_ENABLE
-# include "api.h"
+# include "api_sysex.h"
#endif
/*******************************************************************************
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c
index 8df465026b..5415453a05 100644
--- a/tmk_core/protocol/ps2_mouse.c
+++ b/tmk_core/protocol/ps2_mouse.c
@@ -190,7 +190,7 @@ static inline void ps2_mouse_clear_report(report_mouse_t *mouse_report) {
static inline void ps2_mouse_print_report(report_mouse_t *mouse_report) {
if (!debug_mouse) return;
print("ps2_mouse: [");
- phex(mouse_report->buttons);
+ print_hex8(mouse_report->buttons);
print("|");
print_hex8((uint8_t)mouse_report->x);
print(" ");
diff --git a/tmk_core/protocol/serial.h b/tmk_core/protocol/serial.h
index b70d117d7c..0204b84a92 100644
--- a/tmk_core/protocol/serial.h
+++ b/tmk_core/protocol/serial.h
@@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma once
+#define SERIAL_UART_DATA UDR1
+
/* host role */
void serial_init(void);
uint8_t serial_recv(void);
diff --git a/tmk_core/protocol/serial_uart.c b/tmk_core/protocol/serial_uart.c
index a15124193a..d5b5657095 100644
--- a/tmk_core/protocol/serial_uart.c
+++ b/tmk_core/protocol/serial_uart.c
@@ -40,6 +40,22 @@ POSSIBILITY OF SUCH DAMAGE.
#include <avr/interrupt.h>
#include "serial.h"
+#ifndef SERIAL_UART_BAUD
+# define SERIAL_UART_BAUD 9600
+#endif
+
+#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
+#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
+#define SERIAL_UART_RXD_VECT USART1_RX_vect
+
+#ifndef SERIAL_UART_INIT_CUSTOM
+# define SERIAL_UART_INIT_CUSTOM \
+ /* enable TX */ \
+ UCSR1B = _BV(TXEN1); \
+ /* 8-bit data */ \
+ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
+#endif
+
#if defined(SERIAL_UART_RTS_LO) && defined(SERIAL_UART_RTS_HI)
// Buffer state
// Empty: RBUF_SPACE == RBUF_SIZE(head==tail)
@@ -61,7 +77,14 @@ POSSIBILITY OF SUCH DAMAGE.
# define rbuf_check_rts_hi()
#endif
-void serial_init(void) { SERIAL_UART_INIT(); }
+void serial_init(void) {
+ do {
+ // Set baud rate
+ UBRR1L = SERIAL_UART_UBRR;
+ UBRR1L = SERIAL_UART_UBRR >> 8;
+ SERIAL_UART_INIT_CUSTOM;
+ } while (0);
+}
// RX ring buffer
#define RBUF_SIZE 256
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index 4a5edb1907..9277554856 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -40,7 +40,7 @@
#include "report.h"
#include "usb_descriptor.h"
#ifdef WEBUSB_ENABLE
-#include "webusb_descriptor.h"
+# include "webusb_descriptor.h"
#endif
#include "usb_descriptor_common.h"
@@ -119,19 +119,15 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
# endif
HID_RI_USAGE(8, 0x01), // Pointer
HID_RI_COLLECTION(8, 0x00), // Physical
- // Buttons (5 bits)
+ // Buttons (8 bits)
HID_RI_USAGE_PAGE(8, 0x09), // Button
HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1
- HID_RI_USAGE_MAXIMUM(8, 0x05), // Button 5
+ HID_RI_USAGE_MAXIMUM(8, 0x08), // Button 8
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
- HID_RI_REPORT_COUNT(8, 0x05),
+ HID_RI_REPORT_COUNT(8, 0x08),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
- // Button padding (3 bits)
- HID_RI_REPORT_COUNT(8, 0x01),
- HID_RI_REPORT_SIZE(8, 0x03),
- HID_RI_INPUT(8, HID_IOF_CONSTANT),
// X/Y position (2 bytes)
HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
@@ -288,8 +284,8 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = {
#ifdef WEBUSB_ENABLE
const USB_Descriptor_BOS_t PROGMEM BOSDescriptor = BOS_DESCRIPTOR(
- (MS_OS_20_PLATFORM_DESCRIPTOR(MS_OS_20_VENDOR_CODE, MS_OS_20_DESCRIPTOR_SET_TOTAL_LENGTH))
- (WEBUSB_PLATFORM_DESCRIPTOR(WEBUSB_VENDOR_CODE, WEBUSB_LANDING_PAGE_INDEX))
+ (MS_OS_20_PLATFORM_DESCRIPTOR(MS_OS_20_VENDOR_CODE, MS_OS_20_DESCRIPTOR_SET_TOTAL_LENGTH))
+ (WEBUSB_PLATFORM_DESCRIPTOR(WEBUSB_VENDOR_CODE, WEBUSB_LANDING_PAGE_INDEX))
);
#endif
#ifdef JOYSTICK_ENABLE
@@ -369,6 +365,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
#else
.USBSpecification = VERSION_BCD(1, 1, 0),
#endif
+
#if VIRTSER_ENABLE
.Class = USB_CSCP_IADDeviceClass,
.SubClass = USB_CSCP_IADDeviceSubclass,
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h
index e4d5435110..2ea4861f36 100644
--- a/tmk_core/protocol/usb_descriptor.h
+++ b/tmk_core/protocol/usb_descriptor.h
@@ -49,7 +49,7 @@
# include <hal.h>
#endif
#ifdef WEBUSB_ENABLE
-#include "webusb_descriptor.h"
+# include "webusb_descriptor.h"
#endif
/*
@@ -271,6 +271,7 @@ enum usb_endpoints {
# define WEBUSB_IN_EPADDR (ENDPOINT_DIR_IN | WEBUSB_IN_EPNUM)
# define WEBUSB_OUT_EPADDR (ENDPOINT_DIR_OUT | WEBUSB_OUT_EPNUM)
#endif
+
#ifdef JOYSTICK_ENABLE
JOYSTICK_IN_EPNUM = NEXT_EPNUM,
# if STM32_USB_USE_OTG1
diff --git a/tmk_core/protocol/usb_hid/test/Makefile b/tmk_core/protocol/usb_hid/test/Makefile
deleted file mode 100644
index 83bf2aed67..0000000000
--- a/tmk_core/protocol/usb_hid/test/Makefile
+++ /dev/null
@@ -1,126 +0,0 @@
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device.
-# Please customize your programmer settings(PROGRAM_CMD)
-#
-# make teensy = Download the hex file to the device, using teensy_loader_cli.
-# (must have teensy_loader_cli installed).
-#
-# make dfu = Download the hex file to the device, using dfu-programmer (must
-# have dfu-programmer installed).
-#
-# make flip = Download the hex file to the device, using Atmel FLIP (must
-# have Atmel FLIP installed).
-#
-# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
-# (must have dfu-programmer installed).
-#
-# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
-# (must have Atmel FLIP installed).
-#
-# make debug = Start either simulavr or avarice as specified for debugging,
-# with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-# bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-# Target file name (without extension).
-TARGET = usb_hid_test
-
-TMK_DIR = ../../..
-
-# Directory keyboard dependent files exist
-TARGET_DIR = .
-
-# MCU name
-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
-OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
-
-
-
-# Build Options
-# comment out to disable the options.
-#
-# Console for debug
-OPT_DEFS += -DCONSOLE_ENABLE
-
-# Boot Section Size in bytes
-# Teensy halfKay 512
-# Atmel DFU loader 4096
-# LUFA bootloader 4096
-#OPT_DEFS += -DBOOT_SIZE=4096
-
-
-
-SRC = test.cpp
-SRC += common/debug.c
-SRC += common/print.c
-
-CONFIG_H = config.h
-
-
-
-# Search Path
-VPATH += $(TARGET_DIR)
-VPATH += $(TMK_DIR)
-VPATH += $(TMK_DIR)/common
-
-
-
-# program Leonardo
-PROGRAM_CMD = avrdude -p$(MCU) -cavr109 -P$(DEV) -b57600 -Uflash:w:$(TARGET).hex
-
-
-
-include $(TMK_DIR)/protocol/usb_hid.mk
-include $(TMK_DIR)/protocol/lufa.mk
-include $(TMK_DIR)/rules.mk
diff --git a/tmk_core/protocol/usb_hid/test/test.cpp b/tmk_core/protocol/usb_hid/test/test.cpp
deleted file mode 100644
index 4958f0c619..0000000000
--- a/tmk_core/protocol/usb_hid/test/test.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <avr/io.h>
-#include <avr/wdt.h>
-#include <avr/power.h>
-#include <util/delay.h>
-#include <Arduino.h>
-
-// USB HID host
-#include "Usb.h"
-#include "hid.h"
-#include "hidboot.h"
-#include "parser.h"
-
-// LUFA
-#include "lufa.h"
-
-#include "debug.h"
-
-#include "leonardo_led.h"
-
-
-static USB usb_host;
-static HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host);
-static KBDReportParser kbd_parser;
-
-static void LUFA_setup(void)
-{
- /* Disable watchdog if enabled by bootloader/fuses */
- MCUSR &= ~(1 << WDRF);
- wdt_disable();
-
- /* Disable clock division */
- clock_prescale_set(clock_div_1);
-
- // Leonardo needs. Without this USB device is not recognized.
- USB_Disable();
-
- USB_Init();
-
- // for Console_Task
- USB_Device_EnableSOFEvents();
-}
-
-static void HID_setup()
-{
- // Arduino Timer startup: wiring.c
- init();
-
- if (usb_host.Init() == -1) {
- debug("HID init: failed\n");
- LED_TX_OFF;
- }
-
- _delay_ms(200);
-
- kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
-}
-
-int main(void)
-{
- // LED for debug
- LED_TX_INIT;
- LED_TX_ON;
-
- print_enable = true;
- debug_enable = true;
- debug_matrix = true;
- debug_keyboard = true;
- debug_mouse = true;
-
- LUFA_setup();
- sei();
-
- // wait for startup of sendchar routine
- while (USB_DeviceState != DEVICE_STATE_Configured) ;
- if (debug_enable) {
- _delay_ms(1000);
- }
-
- HID_setup();
-
- debug("init: done\n");
- for (;;) {
- usb_host.Task();
-
-#if !defined(INTERRUPT_CONTROL_ENDPOINT)
- // LUFA Task for control request
- USB_USBTask();
-#endif
- }
-
- return 0;
-}
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c
index 2e8bb2fbbc..53926a7493 100644
--- a/tmk_core/protocol/vusb/main.c
+++ b/tmk_core/protocol/vusb/main.c
@@ -53,10 +53,10 @@ static void initForUsbConnectivity(void) {
usbDeviceConnect();
}
-static void usb_remote_wakeup(void) {
+static void vusb_send_remote_wakeup(void) {
cli();
- int8_t ddr_orig = USBDDR;
+ uint8_t ddr_orig = USBDDR;
USBOUT |= (1 << USBMINUS);
USBDDR = ddr_orig | USBMASK;
USBOUT ^= USBMASK;
@@ -70,16 +70,34 @@ static void usb_remote_wakeup(void) {
sei();
}
+bool vusb_suspended = false;
+
+static void vusb_suspend(void) {
+ vusb_suspended = true;
+
+#ifdef SLEEP_LED_ENABLE
+ sleep_led_enable();
+#endif
+
+ suspend_power_down();
+}
+
+#if USB_COUNT_SOF
+static void vusb_wakeup(void) {
+ vusb_suspended = false;
+ suspend_wakeup_init();
+
+# ifdef SLEEP_LED_ENABLE
+ sleep_led_disable();
+# endif
+}
+#endif
+
/** \brief Setup USB
*
* FIXME: Needs doc
*/
-static void setup_usb(void) {
- initForUsbConnectivity();
-
- // for Console_Task
- print_set_sendchar(sendchar);
-}
+static void setup_usb(void) { initForUsbConnectivity(); }
/** \brief Main
*
@@ -87,9 +105,8 @@ static void setup_usb(void) {
*/
int main(void) __attribute__((weak));
int main(void) {
- bool suspended = false;
#if USB_COUNT_SOF
- uint16_t last_timer = timer_read();
+ uint16_t sof_timer = timer_read();
#endif
#ifdef CLKPR
@@ -112,23 +129,24 @@ int main(void) {
while (1) {
#if USB_COUNT_SOF
if (usbSofCount != 0) {
- suspended = false;
usbSofCount = 0;
- last_timer = timer_read();
-# ifdef SLEEP_LED_ENABLE
- sleep_led_disable();
-# endif
+ sof_timer = timer_read();
+ if (vusb_suspended) {
+ vusb_wakeup();
+ }
} else {
// Suspend when no SOF in 3ms-10ms(7.1.7.4 Suspending of USB1.1)
- if (timer_elapsed(last_timer) > 5) {
- suspended = true;
-# ifdef SLEEP_LED_ENABLE
- sleep_led_enable();
-# endif
+ if (!vusb_suspended && timer_elapsed(sof_timer) > 5) {
+ vusb_suspend();
}
}
#endif
- if (!suspended) {
+ if (vusb_suspended) {
+ vusb_suspend();
+ if (suspend_wakeup_condition()) {
+ vusb_send_remote_wakeup();
+ }
+ } else {
usbPoll();
// TODO: configuration process is inconsistent. it sometime fails.
@@ -145,6 +163,7 @@ int main(void) {
raw_hid_task();
}
#endif
+
#ifdef CONSOLE_ENABLE
usbPoll();
@@ -154,10 +173,7 @@ int main(void) {
#endif
// Run housekeeping
- housekeeping_task_kb();
- housekeeping_task_user();
- } else if (suspend_wakeup_condition()) {
- usb_remote_wakeup();
+ housekeeping_task();
}
}
}
diff --git a/quantum/template/ps2avrgb/usbconfig.h b/tmk_core/protocol/vusb/usbconfig.h
index da078545fc..041f7bd095 100644
--- a/quantum/template/ps2avrgb/usbconfig.h
+++ b/tmk_core/protocol/vusb/usbconfig.h
@@ -1,6 +1,16 @@
+/* Name: usbconfig.h
+ * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
+ * Author: Christian Starkjohann
+ * Creation Date: 2005-04-01
+ * Tabsize: 4
+ * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
+ * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
+ * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
+ */
+
#pragma once
-#include "config.h"
+// clang-format off
/*
General Description:
@@ -60,18 +70,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.
*/
@@ -91,13 +101,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(), usbSetInterrupt3() and usbSetInterrupt4() are omitted.
@@ -105,16 +115,16 @@ section at the end of this file).
* to an interface (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_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_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
@@ -126,17 +136,17 @@ section at the end of this file).
* 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.
@@ -183,7 +193,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
@@ -191,11 +201,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
@@ -291,16 +301,16 @@ section at the end of this file).
* };
*/
-#define USB_CFG_DESCR_PROPS_DEVICE USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_STRINGS USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_STRING_0 USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_STRING_VENDOR USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_STRING_PRODUCT USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
-#define USB_CFG_DESCR_PROPS_UNKNOWN 0
+#define USB_CFG_DESCR_PROPS_DEVICE USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_STRINGS USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_STRING_0 USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_STRING_VENDOR USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_STRING_PRODUCT USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
+#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
+#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
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 4a13ca5847..9362fbde78 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -296,7 +296,7 @@ static void send_consumer(uint16_t data) {
*------------------------------------------------------------------*/
static struct {
uint16_t len;
- enum { NONE, BOOTLOADER, SET_LED } kind;
+ enum { NONE, SET_LED } kind;
} last_req;
usbMsgLen_t usbFunctionSetup(uchar data[8]) {
@@ -323,11 +323,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) {
dprint("SET_LED:");
last_req.kind = SET_LED;
last_req.len = rq->wLength.word;
-#ifdef BOOTLOADER_SIZE
- } else if (rq->wValue.word == 0x0301) {
- last_req.kind = BOOTLOADER;
- last_req.len = rq->wLength.word;
-#endif
}
return USB_NO_MSG; // to get data in usbFunctionWrite
} else {
@@ -352,11 +347,6 @@ uchar usbFunctionWrite(uchar *data, uchar len) {
last_req.len = 0;
return 1;
break;
- case BOOTLOADER:
- usbDeviceDisconnect();
- bootloader_jump();
- return 1;
- break;
case NONE:
default:
return -1;
@@ -454,19 +444,15 @@ const PROGMEM uchar shared_hid_report[] = {
0x85, REPORT_ID_MOUSE, // Report ID
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
- // Buttons (5 bits)
+ // Buttons (8 bits)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button 1)
- 0x29, 0x05, // Usage Maximum (Button 5)
+ 0x29, 0x08, // Usage Maximum (Button 8)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
- 0x95, 0x05, // Report Count (5)
+ 0x95, 0x08, // Report Count (8)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
- // Button padding (3 bits)
- 0x95, 0x01, // Report Count (1)
- 0x75, 0x03, // Report Size (3)
- 0x81, 0x03, // Input (Constant)
// X/Y position (2 bytes)
0x05, 0x01, // Usage Page (Generic Desktop)
diff --git a/tmk_core/protocol/vusb/vusb.h b/tmk_core/protocol/vusb/vusb.h
index b4c73aabae..b1ecc98f37 100644
--- a/tmk_core/protocol/vusb/vusb.h
+++ b/tmk_core/protocol/vusb/vusb.h
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "host_driver.h"
+#include <usbdrv/usbdrv.h>
typedef struct usbDescriptorHeader {
uchar bLength;
@@ -119,5 +120,7 @@ typedef struct usbConfigurationDescriptor {
#define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1))
+extern bool vusb_suspended;
+
host_driver_t *vusb_driver(void);
void vusb_transfer_keyboard(void);
diff --git a/tmk_core/protocol/xt.h b/tmk_core/protocol/xt.h
index 6dc5f19d00..538ff0e459 100644
--- a/tmk_core/protocol/xt.h
+++ b/tmk_core/protocol/xt.h
@@ -38,33 +38,36 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma once
-#define XT_DATA_IN() \
- do { \
- XT_DATA_DDR &= ~(1 << XT_DATA_BIT); \
- XT_DATA_PORT |= (1 << XT_DATA_BIT); \
+#include "quantum.h"
+
+#define XT_DATA_IN() \
+ do { \
+ setPinInput(XT_DATA_PIN); \
+ writePinHigh(XT_DATA_PIN); \
} while (0)
-#define XT_DATA_READ() (XT_DATA_PIN & (1 << XT_DATA_BIT))
+#define XT_DATA_READ() readPin(XT_DATA_PIN)
-#define XT_DATA_LO() \
- do { \
- XT_DATA_PORT &= ~(1 << XT_DATA_BIT); \
- XT_DATA_DDR |= (1 << XT_DATA_BIT); \
+#define XT_DATA_LO() \
+ do { \
+ writePinLow(XT_DATA_PIN); \
+ setPinOutput(XT_DATA_PIN); \
} while (0)
-#define XT_CLOCK_IN() \
- do { \
- XT_CLOCK_DDR &= ~(1 << XT_CLOCK_BIT); \
- XT_CLOCK_PORT |= (1 << XT_CLOCK_BIT); \
+#define XT_CLOCK_IN() \
+ do { \
+ setPinInput(XT_CLOCK_PIN); \
+ writePinHigh(XT_CLOCK_PIN); \
} while (0)
-#define XT_CLOCK_READ() (XT_CLOCK_PIN & (1 << XT_CLOCK_BIT))
+#define XT_CLOCK_READ() readPin(XT_CLOCK_PIN)
-#define XT_CLOCK_LO() \
- do { \
- XT_CLOCK_PORT &= ~(1 << XT_CLOCK_BIT); \
- XT_CLOCK_DDR |= (1 << XT_CLOCK_BIT); \
+#define XT_CLOCK_LO() \
+ do { \
+ writePinLow(XT_CLOCK_PIN); \
+ setPinOutput(XT_CLOCK_PIN); \
} while (0)
-void xt_host_init(void);
+void xt_host_init(void);
+
uint8_t xt_host_recv(void);
diff --git a/tmk_core/protocol/xt_interrupt.c b/tmk_core/protocol/xt_interrupt.c
index 51e52243fd..ba9d71848f 100644
--- a/tmk_core/protocol/xt_interrupt.c
+++ b/tmk_core/protocol/xt_interrupt.c
@@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <avr/interrupt.h>
-#include <util/delay.h>
#include "xt.h"
#include "wait.h"
#include "debug.h"
@@ -60,7 +59,7 @@ void xt_host_init(void) {
/* soft reset: pull clock line down for 20ms */
XT_DATA_LO();
XT_CLOCK_LO();
- _delay_ms(20);
+ wait_ms(20);
/* input mode with pullup */
XT_CLOCK_IN();
@@ -120,9 +119,10 @@ ISR(XT_INT_VECT) {
* Ring buffer to store scan codes from keyboard
*------------------------------------------------------------------*/
#define PBUF_SIZE 32
-static uint8_t pbuf[PBUF_SIZE];
-static uint8_t pbuf_head = 0;
-static uint8_t pbuf_tail = 0;
+static uint8_t pbuf[PBUF_SIZE];
+static uint8_t pbuf_head = 0;
+static uint8_t pbuf_tail = 0;
+
static inline void pbuf_enqueue(uint8_t data) {
uint8_t sreg = SREG;
cli();
@@ -135,6 +135,7 @@ static inline void pbuf_enqueue(uint8_t data) {
}
SREG = sreg;
}
+
static inline uint8_t pbuf_dequeue(void) {
uint8_t val = 0;
@@ -148,6 +149,7 @@ static inline uint8_t pbuf_dequeue(void) {
return val;
}
+
static inline bool pbuf_has_data(void) {
uint8_t sreg = SREG;
cli();
@@ -155,6 +157,7 @@ static inline bool pbuf_has_data(void) {
SREG = sreg;
return has_data;
}
+
static inline void pbuf_clear(void) {
uint8_t sreg = SREG;
cli();
diff --git a/tmk_core/readme.md b/tmk_core/readme.md
index 69a4f75e06..a754cfee42 100644
--- a/tmk_core/readme.md
+++ b/tmk_core/readme.md
@@ -67,7 +67,6 @@ Start Your Own Project
#define PRODUCT_ID 0xBEEF
#define MANUFACTURER t.m.k.
#define PRODUCT Macway mod
- #define DESCRIPTION t.m.k. keyboard firmware for Macway mod
#### 2. Keyboard matrix configuration
#define MATRIX_ROWS 8
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index f5f758943e..bbcfc1e4d1 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -108,6 +108,10 @@ endif
CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
CFLAGS += $(CSTANDARD)
+# This fixes lots of keyboards linking errors but SHOULDN'T BE A FINAL SOLUTION
+# Fixing of multiple variable definitions must be made.
+CFLAGS += -fcommon
+
#---------------- Compiler Options C++ ----------------
# -g*: generate debugging information
# -O*: optimization level
@@ -124,6 +128,7 @@ CXXFLAGS += -O$(OPT)
CXXFLAGS += -w
CXXFLAGS += -Wall
CXXFLAGS += -Wundef
+
ifneq ($(strip $(ALLOW_WARNINGS)), yes)
CXXFLAGS += -Werror
endif
diff --git a/util/atmega32a_program.py b/util/atmega32a_program.py
deleted file mode 100755
index b777b91106..0000000000
--- a/util/atmega32a_program.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, Sebastian Kaim <sebb@sebb767.de>
-#
-# 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/>.
-
-from __future__ import print_function
-
-import os
-import sys
-import time
-import usb
-
-
-def checkForKeyboardInNormalMode():
- """Returns a device if a ps2avrGB device in normal made (that is in keyboard mode) or None if it is not found."""
- return usb.core.find(idVendor=0x20A0, idProduct=0x422D)
-
-def checkForKeyboardInBootloaderMode():
- """Returns True if a ps2avrGB device in bootloader (flashable) mode is found and False otherwise."""
- return (usb.core.find(idVendor=0x16c0, idProduct=0x05df) is not None)
-
-def flashKeyboard(firmware_file):
- """Calls bootloadHID to flash the given file to the device."""
- print('Flashing firmware to device ...')
- if os.system('bootloadHID -r "%s"' % firmware_file) == 0:
- print('\nDone!')
- else:
- print('\nbootloadHID returned an error.')
-
-def printDeviceInfo(dev):
- """Prints all infos for a given USB device"""
- print('Device Information:')
- print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor))
- print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct))
- print('Manufacturer: %s' % (dev.iManufacturer))
- print('Serial: %s' % (dev.iSerialNumber))
- print('Product: %s' % (dev.iProduct), end='\n\n')
-
-def sendDeviceToBootloaderMode(dev):
- """Tries to send a given ps2avrGB keyboard to bootloader mode to allow flashing."""
- try:
- dev.set_configuration()
-
- request_type = usb.util.build_request_type(
- usb.util.CTRL_OUT,
- usb.util.CTRL_TYPE_CLASS,
- usb.util.CTRL_RECIPIENT_DEVICE)
-
- USBRQ_HID_SET_REPORT = 0x09
- HID_REPORT_OPTION = 0x0301
-
- dev.ctrl_transfer(request_type, USBRQ_HID_SET_REPORT, HID_REPORT_OPTION, 0, [0, 0, 0xFF] + [0] * 5)
- except usb.core.USBError:
- # for some reason I keep getting USBError, but it works!
- pass
-
-
-if len(sys.argv) < 2:
- print('Usage: %s <firmware.hex>' % sys.argv[0])
- sys.exit(1)
-
-kb = checkForKeyboardInNormalMode()
-
-if kb is not None:
- print('Found a keyboard in normal mode. Attempting to send it to bootloader mode ...', end='')
- sendDeviceToBootloaderMode(kb)
- print(' done.')
- print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.")
- print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode")
-
-attempts = 12 # 60 seconds
-found = False
-for attempt in range(1, attempts + 1):
- print("Searching for keyboard in bootloader mode (%i/%i) ... " % (attempt, attempts), end='')
-
- if checkForKeyboardInBootloaderMode():
- print('Found', end='\n\n')
- flashKeyboard(sys.argv[1])
- found = True
- break
- else:
- print('Nothing.', end='')
-
- if attempt != attempts: # no need to wait on the last attempt
- print(' Sleeping 5 seconds.', end='')
- time.sleep(5)
-
- # print a newline
- print()
-
-if not found:
- print("Couldn't find a flashable keyboard. Aborting.")
- sys.exit(2)
-
diff --git a/util/audio_generate_dac_lut.py b/util/audio_generate_dac_lut.py
new file mode 100755
index 0000000000..c31ba3d7ee
--- /dev/null
+++ b/util/audio_generate_dac_lut.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+#
+# Copyright 2020 JohSchneider
+#
+# 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/>.
+#
+
+AUDIO_DAC_BUFFER_SIZE=256
+AUDIO_DAC_SAMPLE_MAX=4095
+
+def plot(values):
+ for v in values:
+ print('0'* int(v * 80/AUDIO_DAC_SAMPLE_MAX))
+
+def to_lut(values):
+ for v in values:
+ print(hex(int(v)), end=", ")
+
+
+from math import sin, tau, pi
+
+samples=[]
+
+def sampleSine():
+ for s in range(AUDIO_DAC_BUFFER_SIZE):
+ samples.append((sin((s/AUDIO_DAC_BUFFER_SIZE)*tau - pi/2) + 1 )/2* AUDIO_DAC_SAMPLE_MAX)
+
+def sampleTriangle():
+ for s in range(AUDIO_DAC_BUFFER_SIZE):
+ if s < AUDIO_DAC_BUFFER_SIZE/2:
+ samples.append(s/(AUDIO_DAC_BUFFER_SIZE/2) * AUDIO_DAC_SAMPLE_MAX)
+ else:
+ samples.append(AUDIO_DAC_SAMPLE_MAX - (s-AUDIO_DAC_BUFFER_SIZE/2)/(AUDIO_DAC_BUFFER_SIZE/2) * AUDIO_DAC_SAMPLE_MAX)
+
+#compromise between square and triangle wave,
+def sampleTrapezoidal():
+ for i in range(AUDIO_DAC_BUFFER_SIZE):
+ a=3 #slope/inclination
+ if (i < AUDIO_DAC_BUFFER_SIZE/2):
+ s = a * (i * AUDIO_DAC_SAMPLE_MAX/(AUDIO_DAC_BUFFER_SIZE/2)) + (1-a)*AUDIO_DAC_SAMPLE_MAX/2
+ else:
+ i = i - AUDIO_DAC_BUFFER_SIZE/2
+ s = AUDIO_DAC_SAMPLE_MAX - a * (i * AUDIO_DAC_SAMPLE_MAX/(AUDIO_DAC_BUFFER_SIZE/2)) - (1-a)*AUDIO_DAC_SAMPLE_MAX/2
+
+ if s < 0:
+ s=0
+ if s> AUDIO_DAC_SAMPLE_MAX:
+ s=AUDIO_DAC_SAMPLE_MAX
+ samples.append(s)
+
+
+#sampleSine()
+sampleTrapezoidal()
+#print(samples)
+plot(samples)
+to_lut(samples)
diff --git a/util/chibios_conf_updater.sh b/util/chibios_conf_updater.sh
new file mode 100755
index 0000000000..70bd80da1e
--- /dev/null
+++ b/util/chibios_conf_updater.sh
@@ -0,0 +1,184 @@
+#!/bin/bash
+
+set -eEuo pipefail
+umask 022
+
+sinfo() { echo "$@" >&2 ; }
+shead() { sinfo "" ; sinfo "---------------------------------" ; sinfo "-- $@" ; sinfo "---------------------------------" ; }
+havecmd() { command command type "${1}" >/dev/null 2>&1 || return 1 ; }
+
+this_script="$(realpath "${BASH_SOURCE[0]}")"
+script_dir="$(realpath "$(dirname "$this_script")")"
+qmk_firmware_dir="$(realpath "$script_dir/../")"
+
+declare -A file_hashes
+
+export PATH="$PATH:$script_dir/fmpp/bin"
+
+build_fmpp() {
+ [ -f "$script_dir/fmpp.tar.gz" ] \
+ || wget -O"$script_dir/fmpp.tar.gz" https://github.com/freemarker/fmpp/archive/v0.9.16.tar.gz
+ [ -d "$script_dir/fmpp" ] \
+ || { mkdir "$script_dir/fmpp" && tar xf "$script_dir/fmpp.tar.gz" -C "$script_dir/fmpp" --strip-components=1 ; }
+ pushd "$script_dir/fmpp" >/dev/null 2>&1
+ sed -e "s#bootclasspath.path=.*#bootclasspath.path=$(find /usr/lib/jvm -name 'rt.jar' | sort | tail -n1)#g" \
+ -e "s#ant.jar.path=.*#ant.jar.path=$(find /usr/share/java -name 'ant-1*.jar' | sort | tail -n1)#g" \
+ build.properties.sample > build.properties
+ sed -e 's#source="1.5"#source="1.8"#g' \
+ -e 's#target="1.5"#target="1.8"#g' \
+ build.xml > build.xml.new
+ mv build.xml.new build.xml
+ ant clean
+ ant
+ chmod +x "$script_dir/fmpp/bin/fmpp"
+ popd >/dev/null 2>&1
+}
+
+find_chibi_files() {
+ local search_path="$1"
+ shift
+ local conditions=( "$@" )
+ for file in $(find -L "$search_path" -not -path '*/lib/chibios*' -and -not -path '*/lib/ugfx*' -and -not -path '*/util/*' -and \( "${conditions[@]}" \) | sort) ; do
+ if [ -z "$(grep 'include_next' "$file")" ] ; then
+ echo $file
+ fi
+ done
+}
+
+revert_chibi_files() {
+ local search_path="$1"
+ shead "Reverting ChibiOS config/board files..."
+ for file in $(find_chibi_files "$search_path" -name chconf.h -or -name halconf.h -or -name mcuconf.h -or -name board.c -or -name board.h -or -name board.mk -or -name board.chcfg) ; do
+ pushd "$search_path" >/dev/null 2>&1
+ local relpath=$(realpath --relative-to="$search_path" "$file")
+ git checkout upstream/develop -- "$relpath" || git checkout origin/develop -- "$relpath" || true
+ popd >/dev/null 2>&1
+ done
+}
+
+populate_file_hashes() {
+ local search_path="$1"
+ shead "Determining duplicate config/board files..."
+ for file in $(find_chibi_files "$search_path" -name chconf.h -or -name halconf.h -or -name mcuconf.h -or -name board.c -or -name board.h) ; do
+ local key="file_$(clang-format "$file" | sha1sum | cut -d' ' -f1)"
+ local relpath=$(realpath --relative-to="$search_path" "$file")
+ file_hashes[$key]="${file_hashes[$key]:-} $relpath"
+ done
+ for file in $(find_chibi_files "$search_path" -name board.mk -or -name board.chcfg) ; do
+ local key="file_$(cat "$file" | sha1sum | cut -d' ' -f1)"
+ local relpath=$(realpath --relative-to="$search_path" "$file")
+ file_hashes[$key]="${file_hashes[$key]:-} $relpath"
+ done
+}
+
+determine_equivalent_files() {
+ local search_file="$1"
+ for K in "${!file_hashes[@]}"; do
+ for V in ${file_hashes[$K]}; do
+ if [[ "$V" == "$search_file" ]] ; then
+ for V in ${file_hashes[$K]}; do
+ echo "$V"
+ done
+ return 0
+ fi
+ done
+ done
+ return 1
+}
+
+deploy_staged_files() {
+ shead "Deploying staged files..."
+ for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do
+ local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file")
+ sinfo "Deploying staged file: $relpath"
+ for other in $(determine_equivalent_files "$relpath") ; do
+ sinfo " => $other"
+ cp "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath" "$qmk_firmware_dir/$other"
+ done
+ done
+}
+
+swap_mcuconf_f3xx_f303() {
+ shead "Swapping STM32F3xx_MCUCONF -> STM32F303_MCUCONF..."
+ for file in $(find_chibi_files "$qmk_firmware_dir" -name mcuconf.h) ; do
+ sed -i 's#STM32F3xx_MCUCONF#STM32F303_MCUCONF#g' "$file"
+ dos2unix "$file" >/dev/null 2>&1
+ done
+}
+
+upgrade_conf_files_generic() {
+ local search_filename="$1"
+ local update_script="$2"
+ shead "Updating $search_filename files ($update_script)..."
+ pushd "$qmk_firmware_dir/lib/chibios/tools/updater" >/dev/null 2>&1
+ for file in $(find_chibi_files "$qmk_firmware_dir" -name "$search_filename") ; do
+ cp -f "$file" "$file.orig"
+ clang-format --style='{IndentPPDirectives: None}' -i "$file"
+ cp -f "$file" "$file.formatted"
+ bash "$update_script" "$file"
+ if ! diff "$file" "$file.formatted" >/dev/null 2>&1 ; then
+ dos2unix "$file" >/dev/null 2>&1
+ else
+ cp -f "$file.orig" "$file"
+ fi
+ rm -f "$file.orig" "$file.formatted"
+ done
+ popd >/dev/null 2>&1
+}
+
+upgrade_chconf_files() {
+ upgrade_conf_files_generic chconf.h update_chconf_rt.sh
+}
+
+upgrade_halconf_files() {
+ upgrade_conf_files_generic halconf.h update_halconf.sh
+
+ OIFS=$IFS
+ IFS=$'\n'
+ for file in $(find_chibi_files "$qmk_firmware_dir" -name halconf.h) ; do
+ echo $file
+ sed -i 's@#include "mcuconf.h"@#include <mcuconf.h>@g' "$file"
+ done
+ IFS=$OIFS
+}
+
+upgrade_mcuconf_files() {
+ pushd "$qmk_firmware_dir/lib/chibios/tools/updater" >/dev/null 2>&1
+ for f in $(find . -name 'update_mcuconf*') ; do
+ upgrade_conf_files_generic mcuconf.h $f
+ done
+ popd >/dev/null 2>&1
+}
+
+update_staged_files() {
+ shead "Updating staged files with ChibiOS upgraded versions..."
+ for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do
+ local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file")
+ sinfo "Updating staged file: $relpath"
+ cp "$qmk_firmware_dir/$relpath" "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath"
+ done
+}
+
+havecmd fmpp || build_fmpp
+revert_chibi_files "$qmk_firmware_dir"
+populate_file_hashes "$qmk_firmware_dir"
+
+shead "Showing duplicate ChibiOS files..."
+for K in "${!file_hashes[@]}"; do
+ sinfo ${K#file_}:
+ for V in ${file_hashes[$K]}; do
+ sinfo " $V"
+ done
+done
+
+if [ "${1:-}" == "-r" ] ; then
+ exit 0
+fi
+
+swap_mcuconf_f3xx_f303
+
+deploy_staged_files
+upgrade_mcuconf_files
+upgrade_chconf_files
+upgrade_halconf_files
+update_staged_files
diff --git a/util/docker_build.sh b/util/docker_build.sh
index 7106344690..2c2a26e776 100755
--- a/util/docker_build.sh
+++ b/util/docker_build.sh
@@ -17,12 +17,27 @@ done
if [ $# -gt 1 ]; then
errcho "$USAGE"
exit 1
-elif ! command -v docker >/dev/null 2>&1; then
- errcho "Error: docker not found"
- errcho "See https://docs.docker.com/install/#supported-platforms for installation instructions"
- exit 2
fi
+# Allow $RUNTIME to be overriden by the user as an environment variable
+# Else check if either docker or podman exit and set them as runtime
+# if none are found error out
+if [ -z "$RUNTIME" ]; then
+ if command -v docker >/dev/null 2>&1; then
+ RUNTIME="docker"
+ elif command -v podman >/dev/null 2>&1; then
+ RUNTIME="podman"
+ else
+ errcho "Error: no compatible container runtime found."
+ errcho "Either podman or docker are required."
+ errcho "See https://podman.io/getting-started/installation"
+ errcho "or https://docs.docker.com/install/#supported-platforms"
+ errcho "for installation instructions."
+ exit 2
+ fi
+fi
+
+
# Determine arguments
if [ $# -eq 0 ]; then
printf "keyboard=" && read -r keyboard
@@ -37,21 +52,30 @@ else
exit 1
fi
fi
+if [ -z "$keyboard" ]; then
+ keyboard=all
+fi
if [ -n "$target" ]; then
- if [ "$(uname)" = "Linux" ] || docker-machine active >/dev/null 2>&1; then
- usb_args="--privileged -v /dev/bus/usb:/dev/bus/usb"
- else
+ # IF we are using docker on non Linux and docker-machine isn't working print an error
+ # ELSE set usb_args
+ if [ ! "$(uname)" = "Linux" ] && [ "$RUNTIME" = "docker" ] && ! docker-machine active >/dev/null 2>&1; then
errcho "Error: target requires docker-machine to work on your platform"
errcho "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos"
errcho "Consider flashing with QMK Toolbox (https://github.com/qmk/qmk_toolbox) instead"
exit 3
+ else
+ usb_args="--privileged -v /dev:/dev"
fi
fi
dir=$(pwd -W 2>/dev/null) || dir=$PWD # Use Windows path if on Windows
+if [ "$RUNTIME" = "docker" ]; then
+ uid_arg="--user $(id -u):$(id -g)"
+fi
+
# Run container and build firmware
-docker run --rm -it $usb_args \
- --user $(id -u):$(id -g) \
+"$RUNTIME" run --rm -it $usb_args \
+ $uid_arg \
-w /qmk_firmware \
-v "$dir":/qmk_firmware \
-e ALT_GET_KEYBOARDS=true \
diff --git a/util/drivers.txt b/util/drivers.txt
index c3c5e286b1..1f6c67c4c5 100644
--- a/util/drivers.txt
+++ b/util/drivers.txt
@@ -4,6 +4,8 @@
# Driver can be one of winusb,libusb,libusbk
# Use Windows Powershell and type [guid]::NewGuid() to generate guids
winusb,STM32 Bootloader,0483,DF11,6d98a87f-4ecf-464d-89ed-8c684d857a75
+winusb,APM32 Bootloader,314B,0106,9ff3cc31-6772-4a3f-a492-a80d91f7a853
+winusb,STM32duino Bootloader,1EAF,0003,746915ec-99d8-4a90-a722-3c85ba31e4fe
libusbk,USBaspLoader,16C0,05DC,e69affdc-0ef0-427c-aefb-4e593c9d2724
winusb,Kiibohd DFU Bootloader,1C11,B007,aa5a3f86-b81e-4416-89ad-0c1ea1ed63af
libusb,ATmega16U2,03EB,2FEF,007274da-b75f-492e-a288-8fc0aff8339f
@@ -11,4 +13,5 @@ libusb,ATmega32U2,03EB,2FF0,ddc2c572-cb6e-4f61-a6cc-1a5de941f063
libusb,ATmega16U4,03EB,2FF3,3180d426-bf93-4578-a693-2efbc337da8e
libusb,ATmega32U4,03EB,2FF4,5f9726fd-f9de-487a-9fbd-8b3524a7a56a
libusb,AT90USB64,03EB,2FF9,c6a708ad-e97d-43cd-b04a-3180d737a71b
+libusb,AT90USB162,03EB,2FFA,ef8546f0-ef09-4e7c-8fc2-ffbae1dcd84a
libusb,AT90USB128,03EB,2FFB,fd217df3-59d0-440a-a8f3-4c0c8c84daa3
diff --git a/util/install/debian.sh b/util/install/debian.sh
index 0ae9764a33..885df723d9 100755
--- a/util/install/debian.sh
+++ b/util/install/debian.sh
@@ -5,7 +5,7 @@ DEBCONF_NONINTERACTIVE_SEEN=true
export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
_qmk_install_prepare() {
- sudo apt-get update
+ sudo apt-get update $SKIP_PROMPT
}
_qmk_install() {
diff --git a/util/install/fedora.sh b/util/install/fedora.sh
index 44b71b98bf..d9452f68d5 100755
--- a/util/install/fedora.sh
+++ b/util/install/fedora.sh
@@ -4,7 +4,7 @@ _qmk_install() {
echo "Installing dependencies"
# TODO: Check whether devel/headers packages are really needed
- sudo dnf -y install \
+ sudo dnf $SKIP_PROMPT install \
clang diffutils git gcc glibc-headers kernel-devel kernel-headers make unzip wget zip \
python3 \
avr-binutils avr-gcc avr-libc \
diff --git a/util/install/freebsd.sh b/util/install/freebsd.sh
index 353c52d647..d9399a5de9 100755
--- a/util/install/freebsd.sh
+++ b/util/install/freebsd.sh
@@ -1,7 +1,7 @@
#!/bin/bash
_qmk_install_prepare() {
- sudo pkg update
+ sudo pkg update $SKIP_PROMPT
}
_qmk_install() {
diff --git a/util/install/gentoo.sh b/util/install/gentoo.sh
index d4284e9a93..97eb5df07f 100755
--- a/util/install/gentoo.sh
+++ b/util/install/gentoo.sh
@@ -23,7 +23,7 @@ _qmk_install() {
sudo emerge -auN sys-devel/gcc
sudo emerge -au --noreplace \
app-arch/unzip app-arch/zip net-misc/wget sys-devel/clang sys-devel/crossdev \
- \>=dev-lang/python-3.6 \
+ \>=dev-lang/python-3.7 \
dev-embedded/avrdude dev-embedded/dfu-programmer app-mobilephone/dfu-util
sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
diff --git a/util/install/msys2.sh b/util/install/msys2.sh
index c8598a60fa..b1300a34d2 100755
--- a/util/install/msys2.sh
+++ b/util/install/msys2.sh
@@ -1,7 +1,7 @@
#!/bin/bash
_qmk_install_prepare() {
- pacman -Syu
+ pacman -Syu $MSYS2_CONFIRM
}
_qmk_install() {
diff --git a/util/install/void.sh b/util/install/void.sh
index 9ec7019e5c..c49c3ef63f 100755
--- a/util/install/void.sh
+++ b/util/install/void.sh
@@ -3,7 +3,7 @@
_qmk_install() {
echo "Installing dependencies"
- sudo xbps-install \
+ sudo xbps-install $SKIP_PROMPT \
gcc git make wget unzip zip \
python3-pip \
avr-binutils avr-gcc avr-libc \
diff --git a/util/linux_install.sh b/util/linux_install.sh
deleted file mode 100755
index 01518a29d7..0000000000
--- a/util/linux_install.sh
+++ /dev/null
@@ -1,245 +0,0 @@
-#!/bin/sh
-
-# Note: This file uses tabs to indent. Please don't mix tabs and spaces.
-
-GENTOO_WARNING="This script will make a USE change in order to ensure that that QMK works on your system. All changes will be sent to the the file /etc/portage/package.use/qmk_firmware -- please review it, and read Portage's output carefully before installing any packages on your system. You will also need to ensure that your kernel is compiled with support for the keyboard chip that you are using (e.g. enable Arduino for the Pro Micro). Further information can be found on the Gentoo wiki."
-
-SLACKWARE_WARNING="You will need the following packages from slackbuilds.org:\n\tarm-binutils\n\tarm-gcc\n\tavr-binutils\n\tavr-gcc\n\tavr-libc\n\tavrdude\n\tdfu-programmer\n\tdfu-util\n\tnewlib\nThese packages will be installed with sudo and sboinstall, so ensure that your user is added to sudoers and that sboinstall is configured."
-
-SOLUS_INFO="Your tools are now installed. To start using them, open new terminal or source these scripts:\n\t/usr/share/defaults/etc/profile.d/50-arm-toolchain-path.sh\n\t/usr/share/defaults/etc/profile.d/50-avr-toolchain-path.sh"
-
-util_dir=$(dirname "$0")
-
-# For those distros that do not package bootloadHID
-install_bootloadhid() {
- if ! command -v bootloadHID >/dev/null; then
- wget https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz -O - | tar -xz -C /tmp
- cd /tmp/bootloadHID.2012-12-08/commandline/
- if make; then
- sudo cp bootloadHID /usr/local/bin
- fi
- cd -
- fi
-}
-
-if grep ID /etc/os-release | grep -qE "fedora"; then
- sudo dnf install \
- arm-none-eabi-binutils-cs \
- arm-none-eabi-gcc-cs \
- arm-none-eabi-newlib \
- avr-binutils \
- avr-gcc \
- avr-libc \
- binutils-avr32-linux-gnu \
- clang \
- dfu-util \
- dfu-programmer \
- diffutils \
- git \
- gcc \
- glibc-headers \
- kernel-devel \
- kernel-headers \
- libusb-devel \
- make \
- perl \
- python3 \
- unzip \
- wget \
- zip
-
-elif grep ID /etc/os-release | grep -qE 'debian|ubuntu'; then
- DEBIAN_FRONTEND=noninteractive
- DEBCONF_NONINTERACTIVE_SEEN=true
- export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
- sudo apt-get update
- sudo apt-get install \
- build-essential \
- avr-libc \
- binutils-arm-none-eabi \
- binutils-avr \
- clang-format \
- dfu-programmer \
- dfu-util \
- diffutils \
- gcc \
- gcc-arm-none-eabi \
- gcc-avr \
- git \
- libnewlib-arm-none-eabi \
- libusb-dev \
- python3 \
- python3-pip \
- unzip \
- wget \
- zip
-
-elif grep ID /etc/os-release | grep -q 'arch\|manjaro'; then
- sudo pacman --needed -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz
- sudo pacman -S --needed \
- arm-none-eabi-binutils \
- arm-none-eabi-gcc \
- arm-none-eabi-newlib \
- avr-binutils \
- avr-libc \
- base-devel \
- clang \
- dfu-programmer \
- dfu-util \
- diffutils \
- gcc \
- git \
- libusb-compat \
- python \
- python-pip \
- unzip \
- wget \
- zip
-
-elif grep ID /etc/os-release | grep -q gentoo; then
- echo "$GENTOO_WARNING" | fmt
- printf "\nProceed (y/N)? "
- read -r answer
- if echo "$answer" | grep -iq "^y"; then
- sudo touch /etc/portage/package.use/qmkfirmware
- # tee is used here since sudo doesn't apply to >>
- echo "sys-devel/gcc multilib" | sudo tee --append /etc/portage/package.use/qmkfirmware >/dev/null
- sudo emerge -auN sys-devel/gcc
- sudo emerge -au --noreplace \
- app-arch/unzip \
- app-arch/zip \
- app-mobilephone/dfu-util \
- dev-embedded/avrdude \
- net-misc/wget \
- sys-devel/clang \
- sys-devel/crossdev
- sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
- sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi
- echo "Done!"
- else
- echo "Quitting..."
- fi
-
-elif grep ID /etc/os-release | grep -q sabayon; then
- sudo equo install \
- app-arch/unzip \
- app-arch/zip \
- app-mobilephone/dfu-util \
- dev-embedded/avrdude \
- dev-lang/python \
- net-misc/wget \
- sys-devel/clang \
- sys-devel/gcc \
- sys-devel/crossdev
- sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
- sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi
- echo "Done!"
-
-elif grep ID /etc/os-release | grep -qE "opensuse|tumbleweed"; then
- CROSS_AVR_GCC=cross-avr-gcc8
- CROSS_ARM_GCC=cross-arm-none-gcc8
- if grep ID /etc/os-release | grep -q "15."; then
- CROSS_AVR_GCC=cross-avr-gcc7
- CROSS_ARM_GCC=cross-arm-none-gcc7
- fi
- sudo zypper install \
- avr-libc \
- clang \
- $CROSS_AVR_GCC \
- $CROSS_ARM_GCC \
- cross-avr-binutils \
- cross-arm-none-newlib-devel \
- cross-arm-binutils cross-arm-none-newlib-devel \
- dfu-tool \
- dfu-programmer \
- gcc \
- libusb-devel \
- python3 \
- unzip \
- wget \
- zip
-
-elif grep ID /etc/os-release | grep -q slackware; then
- printf "$SLACKWARE_WARNING\n"
- printf "\nProceed (y/N)? "
- read -r answer
- if echo "$answer" | grep -iq "^y" ;then
- sudo sboinstall \
- avr-binutils \
- avr-gcc \
- avr-libc \
- avrdude \
- dfu-programmer \
- dfu-util \
- arm-binutils \
- arm-gcc \
- newlib \
- python3
- echo "Done!"
- else
- echo "Quitting..."
- fi
-
-elif grep ID /etc/os-release | grep -q solus; then
- sudo eopkg ur
- sudo eopkg it \
- -c system.devel \
- arm-none-eabi-gcc \
- arm-none-eabi-binutils \
- arm-none-eabi-newlib \
- avr-libc \
- avr-binutils \
- avr-gcc \
- avrdude \
- dfu-util \
- dfu-programmer \
- libusb-devel \
- python3 \
- git \
- wget \
- zip \
- unzip
- printf "\n$SOLUS_INFO\n"
-
-elif grep ID /etc/os-release | grep -q void; then
- sudo xbps-install \
- avr-binutils \
- avr-gcc \
- avr-libc \
- cross-arm-none-eabi-binutils \
- cross-arm-none-eabi-gcc \
- cross-arm-none-eabi-newlib \
- avrdude \
- dfu-programmer \
- dfu-util \
- gcc \
- git \
- libusb-compat-devel \
- make \
- wget \
- unzip \
- zip
-
-else
- echo "Sorry, we don't recognize your OS. Help us by contributing support!"
- echo
- echo "https://docs.qmk.fm/#/contributing"
-fi
-
-# Global install tasks
-install_bootloadhid
-pip3 install --user -r ${util_dir}/../requirements.txt
-
-if uname -a | grep -qi microsoft; then
- echo "********************************************************************************"
- echo "* Detected Windows Subsystem for Linux. *"
- echo "* Currently, WSL has no access to USB devices and so flashing from within the *"
- echo "* WSL terminal will not work. *"
- echo "* *"
- echo "* Please install the QMK Toolbox instead: *"
- echo "* https://github.com/qmk/qmk_toolbox/releases *"
- echo "* Then, map your WSL filesystem as a network drive: *"
- echo "* \\\\\\\\wsl$\\<distro> *"
- echo "********************************************************************************"
- echo
-fi
diff --git a/util/list_keyboards.sh b/util/list_keyboards.sh
index 1c103e0f11..aa6ed1c6af 100755
--- a/util/list_keyboards.sh
+++ b/util/list_keyboards.sh
@@ -4,5 +4,15 @@
# This allows us to exclude keyboards by including a .noci file.
find -L keyboards -type f -name rules.mk | grep -v keymaps | sed 's!keyboards/\(.*\)/rules.mk!\1!' | while read keyboard; do
- [ "$1" = "noci" -a -e "keyboards/${keyboard}/.noci" ] || echo "$keyboard"
+ if [ "$1" = "noci" ]; then
+ case "$keyboard" in
+ handwired/*)
+ ;;
+ *)
+ test -e "keyboards/${keyboard}/.noci" || echo "$keyboard"
+ ;;
+ esac
+ else
+ echo "$keyboard"
+ fi
done
diff --git a/util/macos_install.sh b/util/macos_install.sh
deleted file mode 100755
index 810f234ab3..0000000000
--- a/util/macos_install.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-util_dir=$(dirname "$0")
-
-if ! brew --version 2>&1 > /dev/null; then
- echo "Error! Homebrew not installed or broken!"
- echo -n "Would you like to install homebrew now? [y/n] "
- while read ANSWER; do
- case $ANSWER in
- y|Y)
- /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- break
- ;;
- n|N)
- exit 1
- ;;
- *)
- echo -n "Would you like to install homebrew now? [y/n] "
- ;;
- esac
- done
-fi
-
-# All macOS dependencies are managed in the homebrew package:
-# https://github.com/qmk/homebrew-qmk
-brew update
-brew install qmk/qmk/qmk
-brew link --force avr-gcc@8
-
-pip3 install -r "${util_dir}/../requirements.txt"
diff --git a/util/new_keyboard.sh b/util/new_keyboard.sh
index 01458b4f19..cf3339f9a7 100755
--- a/util/new_keyboard.sh
+++ b/util/new_keyboard.sh
@@ -32,8 +32,10 @@ set_git_username() {
# Copy the template files to the new keyboard directory.
copy_templates() {
+ mkdir -p "$keyboard_dir"
+
echo -n "Copying base template files..."
- cp -r "quantum/template/base" "${keyboard_dir}"
+ cp -r "quantum/template/base/." "${keyboard_dir}"
echo " done"
echo -n "Copying $keyboard_type template files..."
@@ -41,8 +43,8 @@ copy_templates() {
echo " done"
echo -n "Renaming keyboard files..."
- mv "${keyboard_dir}/template.c" "${keyboard_dir}/${keyboard_name}.c"
- mv "${keyboard_dir}/template.h" "${keyboard_dir}/${keyboard_name}.h"
+ mv "${keyboard_dir}/keyboard.c" "${keyboard_dir}/${keyboard_base_name}.c"
+ mv "${keyboard_dir}/keyboard.h" "${keyboard_dir}/${keyboard_base_name}.h"
echo " done"
}
@@ -87,10 +89,10 @@ replace_keyboard_placeholders() {
"${keyboard_dir}/config.h"
"${keyboard_dir}/info.json"
"${keyboard_dir}/readme.md"
- "${keyboard_dir}/${keyboard_name}.c"
+ "${keyboard_dir}/${keyboard_base_name}.c"
"${keyboard_dir}/keymaps/default/readme.md"
)
- replace_placeholders "%KEYBOARD%" "$keyboard_name" "${replace_keyboard_filenames[@]}"
+ replace_placeholders "%KEYBOARD%" "$keyboard_base_name" "${replace_keyboard_filenames[@]}"
}
# Replace %YOUR_NAME% with the username.
@@ -134,6 +136,7 @@ echo
while [ -z "$keyboard_name" ]; do
prompt "Keyboard Name" ""
keyboard_name=$prompt_return
+ keyboard_base_name=$(basename $keyboard_name)
done
keyboard_dir="keyboards/$keyboard_name"
diff --git a/util/new_project.sh b/util/new_project.sh
deleted file mode 100755
index 9dec714b02..0000000000
--- a/util/new_project.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-# Script to make a new quantum project
-# Jack Humbert 2015
-
-KEYBOARD=$1
-KEYBOARD_TYPE=$2
-
-if [ -z "$KEYBOARD" ]; then
- echo "Usage: $0 <keyboard_name> <keyboard_type>"
- echo "Example: $0 gh60 avr"
- echo "Example: $0 bfake ps2avrgb"
- exit 1
-elif [ -z "$KEYBOARD_TYPE" ]; then
- KEYBOARD_TYPE=avr
-fi
-
-if [ "$KEYBOARD_TYPE" != "avr" ] && [ "$KEYBOARD_TYPE" != "ps2avrgb" ]; then
- echo "Invalid keyboard type target"
- exit 1
-fi
-
-if [ -e "keyboards/$1" ]; then
- echo "Error! keyboards/$1 already exists!"
- exit 1
-fi
-
-cd "$(dirname "$0")/.." || exit
-
-KEYBOARD_NAME=$(basename "$1")
-KEYBOARD_NAME_UPPERCASE=$(echo "$KEYBOARD_NAME" | awk '{print toupper($0)}')
-NEW_KBD=keyboards/${KEYBOARD}
-
-
-cp -r quantum/template/base "$NEW_KBD"
-cp -r "quantum/template/$KEYBOARD_TYPE/." "$NEW_KBD"
-
-mv "${NEW_KBD}/template.c" "${NEW_KBD}/${KEYBOARD_NAME}.c"
-mv "${NEW_KBD}/template.h" "${NEW_KBD}/${KEYBOARD_NAME}.h"
-find "${NEW_KBD}" -type f -exec sed -i '' -e "s;%KEYBOARD%;${KEYBOARD_NAME};g" {} \;
-find "${NEW_KBD}" -type f -exec sed -i '' -e "s;%KEYBOARD_UPPERCASE%;${KEYBOARD_NAME_UPPERCASE};g" {} \;
-
-GIT=$(whereis git)
-if [ "$GIT" != "" ]; then
- IS_GIT_REPO=$($GIT log >>/dev/null 2>&1; echo $?)
- if [ "$IS_GIT_REPO" -eq 0 ]; then
- ID="$($GIT config --get user.name)"
- read -rp "What is your name? [$ID] " YOUR_NAME
- if [ -n "$YOUR_NAME" ]; then
- ID=$YOUR_NAME
- fi
- echo "Using $ID as user name"
-
- for i in "$NEW_KBD/config.h" \
- "$NEW_KBD/$KEYBOARD_NAME.c" \
- "$NEW_KBD/$KEYBOARD_NAME.h" \
- "$NEW_KBD/keymaps/default/config.h" \
- "$NEW_KBD/keymaps/default/keymap.c"
- do
- awk -v id="$ID" '{sub(/%YOUR_NAME%/,id); print}' < "$i" > "$i.$$"
- mv "$i.$$" "$i"
- done
- fi
-fi
-
-cat <<-EOF
-######################################################
-# $NEW_KBD project created. To start
-# working on things, cd into $NEW_KBD
-######################################################
-EOF
diff --git a/util/qmk_install.sh b/util/qmk_install.sh
index 5076e980a2..943069453a 100755
--- a/util/qmk_install.sh
+++ b/util/qmk_install.sh
@@ -2,6 +2,13 @@
QMK_FIRMWARE_DIR=$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)
QMK_FIRMWARE_UTIL_DIR=$QMK_FIRMWARE_DIR/util
+if [ "$1" = "-y" ]; then
+ SKIP_PROMPT='-y'
+ MSYS2_CONFIRM='--noconfirm'
+else
+ SKIP_PROMPT=''
+ MSYS2_CONFIRM=''
+fi
case $(uname -a) in
*Darwin*)
@@ -25,10 +32,6 @@ case $(uname -a) in
. "$QMK_FIRMWARE_UTIL_DIR/install/fedora.sh";;
*gentoo*)
. "$QMK_FIRMWARE_UTIL_DIR/install/gentoo.sh";;
- *opensuse*|*tumbleweed*)
- . "$QMK_FIRMWARE_UTIL_DIR/install/opensuse.sh";;
- *sabayon*)
- . "$QMK_FIRMWARE_UTIL_DIR/install/sabayon.sh";;
*slackware*)
. "$QMK_FIRMWARE_UTIL_DIR/install/slackware.sh";;
*solus*)
@@ -36,9 +39,9 @@ case $(uname -a) in
*void*)
. "$QMK_FIRMWARE_UTIL_DIR/install/void.sh";;
*)
- echo "Sorry, we don't recognize your distribution. Help us by contributing support!"
+ echo "Sorry, we don't recognize your distribution. Try using the docker image instead:"
echo
- echo "https://docs.qmk.fm/#/contributing"
+ echo "https://docs.qmk.fm/#/getting_started_docker"
exit 1;;
esac
diff --git a/util/qmk_tab_complete.sh b/util/qmk_tab_complete.sh
new file mode 100644
index 0000000000..ebcb5536ac
--- /dev/null
+++ b/util/qmk_tab_complete.sh
@@ -0,0 +1,2 @@
+# Register qmk with tab completion
+eval "$(register-python-argcomplete --no-defaults qmk)"
diff --git a/util/rules_cleaner.sh b/util/rules_cleaner.sh
new file mode 100755
index 0000000000..ac27c2b09b
--- /dev/null
+++ b/util/rules_cleaner.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# This script finds all rules.mk files in keyboards/ subdirectories,
+# and deletes the build option filesize impacts from them.
+
+# Print an error message with the word "ERROR" in red.
+echo_error() {
+ echo -e "[\033[0;91mERROR\033[m]: $1"
+}
+
+# If we've been started from util/, we want to be in qmk_firmware/
+[[ "$PWD" == *util ]] && cd ..
+
+# The root qmk_firmware/ directory should have a subdirectory called quantum/
+if [ ! -d "quantum" ]; then
+ echo_error "Could not detect the QMK firmware directory!"
+ echo_error "Are you sure you're in the right place?"
+ exit 1
+fi
+
+# Set the inplace editing parameter for sed.
+# macOS/BSD sed expects a file extension immediately following -i.
+set_sed_i() {
+ sed_i=(-i)
+
+ case $(uname -a) in
+ *Darwin*) sed_i=(-i "")
+ esac
+}
+set_sed_i
+
+# Exclude keyamps/ directories
+files=$(find keyboards -type f -name 'rules.mk' -not \( -path '*/keymaps*' -prune \))
+
+# Edit rules.mk files
+for file in $files; do
+ sed "${sed_i[@]}" -e "s/(+[0-9].*)$//g" "$file"
+done
+
+echo "Cleaned up rules.mk files."
diff --git a/util/sample_parser.py b/util/sample_parser.py
new file mode 100755
index 0000000000..70e193aee7
--- /dev/null
+++ b/util/sample_parser.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+#
+# Copyright 2019 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/>.
+#
+
+import wave, struct, sys
+
+waveFile = wave.open(sys.argv[1], 'r')
+# print(str(waveFile.getparams()))
+# sys.exit()
+
+if (waveFile.getsampwidth() != 2):
+ raise(Exception("This script currently only works with 16bit audio files"))
+
+length = waveFile.getnframes()
+out = "#define DAC_SAMPLE_CUSTOM_LENGTH " + str(length) + "\n\n"
+out += "static const dacsample_t dac_sample_custom[" + str(length) + "] = {"
+for i in range(0,length):
+ if (i % 8 == 0):
+ out += "\n "
+ waveData = waveFile.readframes(1)
+ data = struct.unpack("<h", waveData)
+ out += str(int((int(data[0]) + 0x8000) / 16)) + ", "
+out = out[:-2]
+out += "\n};"
+print(out)
diff --git a/util/travis_utils.sh b/util/travis_utils.sh
new file mode 100755
index 0000000000..e949946e22
--- /dev/null
+++ b/util/travis_utils.sh
@@ -0,0 +1,25 @@
+# Use this by sourcing it in your script.
+
+# Provide sane defaults for travis environment
+TRAVIS_BRANCH="${TRAVIS_BRANCH:master}"
+TRAVIS_PULL_REQUEST="${TRAVIS_PULL_REQUEST:false}"
+TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}"
+TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}"
+
+# test force push
+#TRAVIS_COMMIT_RANGE="c287f1bfc5c8...81f62atc4c1d"
+
+# Extra variables
+LOCAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+QMK_CHANGES=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE})
+NUM_CORE_CHANGES=$(echo "$QMK_CHANGES" | grep -Ec -e '^Makefile' -e '^[^/]*.mk' -e '^drivers/' -e '^lib/atsam' -e '^lib/lib8tion/' -e '^platforms' -e '^quantum' -e '^tests' -e '^tmk_core')
+
+# if docker is installed - patch calls to within the qmk docker image
+if command -v docker >/dev/null; then
+ function make() {
+ docker run --rm -e MAKEFLAGS="$MAKEFLAGS" -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container make "$@"
+ }
+ function qmk() {
+ docker run --rm -w /qmk_firmware/ -v "$PWD":/qmk_firmware --user $(id -u):$(id -g) qmkfm/base_container bin/qmk "$@"
+ }
+fi
diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules
index 70bd7e6e3e..acaa7dcc58 100644
--- a/util/udev/50-qmk.rules
+++ b/util/udev/50-qmk.rules
@@ -9,6 +9,8 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff3", TAG+="uacc
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff4", TAG+="uaccess"
### AT90USB64
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff9", TAG+="uaccess"
+### AT90USB162
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffa", TAG+="uaccess"
### AT90USB128
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffb", TAG+="uaccess"
diff --git a/util/wavetable_parser.py b/util/wavetable_parser.py
new file mode 100755
index 0000000000..be0f01f7b4
--- /dev/null
+++ b/util/wavetable_parser.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+#
+# Copyright 2019 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/>.
+#
+
+import wave, struct, sys
+
+waveFile = wave.open(sys.argv[1], 'r')
+
+length = waveFile.getnframes()
+out = "#define DAC_WAVETABLE_CUSTOM_LENGTH " + str(int(length / 256)) + "\n\n"
+out += "static const dacsample_t dac_wavetable_custom[" + str(int(length / 256)) + "][256] = {"
+for i in range(0,length):
+ if (i % 8 == 0):
+ out += "\n "
+ if (i % 256 == 0):
+ out = out[:-2]
+ out += "{\n "
+ waveData = waveFile.readframes(1)
+ data = struct.unpack("<h", waveData)
+ out += str(int((int(data[0]) + 0x8000) / 16)) + ", "
+ if (i % 256 == 255):
+ out = out[:-2]
+ out += "\n },"
+out = out[:-1]
+out += "\n};"
+print(out)