summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--Makefile25
-rw-r--r--keyboards/atreus/Makefile1
-rw-r--r--keyboards/chibios_test/Makefile14
-rw-r--r--keyboards/chibios_test/boards/GENERIC_STM32_F103/board.c (renamed from keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.c)0
-rw-r--r--keyboards/chibios_test/boards/GENERIC_STM32_F103/board.h (renamed from keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.h)0
-rw-r--r--keyboards/chibios_test/boards/GENERIC_STM32_F103/board.mk (renamed from keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.mk)0
-rw-r--r--keyboards/chibios_test/boards/GENERIC_STM32_F103/mini_stm32_mapping.png (renamed from keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/mini_stm32_mapping.png)bin162908 -> 162908 bytes
-rw-r--r--keyboards/chibios_test/boards/maple_mini_mapping.png (renamed from keyboards/stm32_f103_onekey/boards/maple_mini_mapping.png)bin237977 -> 237977 bytes
-rw-r--r--keyboards/chibios_test/chibios_test.c1
-rw-r--r--keyboards/chibios_test/chibios_test.h6
-rw-r--r--keyboards/chibios_test/config.h (renamed from keyboards/teensy_lc_onekey/config.h)9
-rw-r--r--keyboards/chibios_test/keymaps/default/keymap.c (renamed from keyboards/stm32_f072_onekey/keymaps/default/keymap.c)4
-rw-r--r--keyboards/chibios_test/ld/MKL26Z64.ld (renamed from keyboards/teensy_lc_onekey/ld/MKL26Z64.ld)0
-rw-r--r--keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld (renamed from keyboards/stm32_f103_onekey/ld/STM32F103x8_stm32duino_bootloader.ld)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/Makefile (renamed from keyboards/stm32_f072_onekey/Makefile)11
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/bootloader_defs.h (renamed from keyboards/stm32_f072_onekey/bootloader_defs.h)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/chconf.h (renamed from keyboards/stm32_f072_onekey/chconf.h)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/config.h7
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/halconf.h (renamed from keyboards/stm32_f072_onekey/halconf.h)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/led.c (renamed from keyboards/stm32_f072_onekey/led.c)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/matrix.c (renamed from keyboards/stm32_f072_onekey/matrix.c)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/mcuconf.h (renamed from keyboards/stm32_f072_onekey/mcuconf.h)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/stm32_f072_onekey.c (renamed from keyboards/stm32_f072_onekey/stm32_f072_onekey.c)0
-rw-r--r--keyboards/chibios_test/stm32_f072_onekey/stm32_f072_onekey.h (renamed from keyboards/stm32_f072_onekey/stm32_f072_onekey.h)2
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/Makefile (renamed from keyboards/stm32_f103_onekey/Makefile)14
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/bootloader_defs.h (renamed from keyboards/stm32_f103_onekey/bootloader_defs.h)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/chconf.h (renamed from keyboards/stm32_f103_onekey/chconf.h)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/config.h6
-rwxr-xr-xkeyboards/chibios_test/stm32_f103_onekey/flash.sh (renamed from keyboards/stm32_f103_onekey/flash.sh)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/halconf.h (renamed from keyboards/stm32_f103_onekey/halconf.h)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/led.c (renamed from keyboards/stm32_f103_onekey/led.c)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/matrix.c (renamed from keyboards/stm32_f103_onekey/matrix.c)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/mcuconf.h (renamed from keyboards/stm32_f103_onekey/mcuconf.h)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/stm32_f103_onekey.c (renamed from keyboards/stm32_f103_onekey/stm32_f103_onekey.c)0
-rw-r--r--keyboards/chibios_test/stm32_f103_onekey/stm32_f103_onekey.h (renamed from keyboards/stm32_f103_onekey/stm32_f103_onekey.h)2
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/Makefile (renamed from keyboards/teensy_lc_onekey/Makefile)17
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/Makefile.3.0 (renamed from keyboards/teensy_lc_onekey/Makefile.3.0)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/Makefile.3.2 (renamed from keyboards/teensy_lc_onekey/Makefile.3.2)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/chconf.h (renamed from keyboards/teensy_lc_onekey/chconf.h)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/config.h6
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/halconf.h (renamed from keyboards/teensy_lc_onekey/halconf.h)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/instructions.md (renamed from keyboards/teensy_lc_onekey/instructions.md)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/led.c (renamed from keyboards/teensy_lc_onekey/led.c)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/matrix.c (renamed from keyboards/teensy_lc_onekey/matrix.c)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/mcuconf.h (renamed from keyboards/teensy_lc_onekey/mcuconf.h)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/teensy_lc_onekey.c (renamed from keyboards/teensy_lc_onekey/teensy_lc_onekey.c)0
-rw-r--r--keyboards/chibios_test/teensy_lc_onekey/teensy_lc_onekey.h (renamed from keyboards/teensy_lc_onekey/teensy_lc_onekey.h)2
-rw-r--r--keyboards/clueboard/clueboard.c16
-rw-r--r--keyboards/clueboard/keymaps/default/keymap.c72
-rw-r--r--keyboards/clueboard/keymaps/max/keymap.c70
-rw-r--r--keyboards/clueboard/rev1/config.h5
-rw-r--r--keyboards/clueboard/rev1/rev1.c16
-rw-r--r--keyboards/clueboard/rev2/config.h5
-rw-r--r--keyboards/clueboard/rev2/rev2.c16
-rw-r--r--keyboards/clueboard/rev2/rev2.h2
-rw-r--r--keyboards/cluepad/config.h13
-rw-r--r--keyboards/cluepad/keymaps/default/keymap.c71
-rw-r--r--keyboards/ergodox_ez/matrix.c12
-rw-r--r--keyboards/gh60/keymaps/robotmaxtron/Makefile112
-rw-r--r--keyboards/gh60/keymaps/robotmaxtron/WS2812-wiring.jpgbin0 -> 1038926 bytes
-rw-r--r--keyboards/gh60/keymaps/robotmaxtron/config.h190
-rw-r--r--keyboards/gh60/keymaps/robotmaxtron/keymap.c226
-rw-r--r--keyboards/gh60/keymaps/robotmaxtron/readme.md16
-rw-r--r--keyboards/hhkb/Makefile4
-rw-r--r--keyboards/hhkb/config.h6
-rw-r--r--keyboards/hhkb/hhkb.h27
-rw-r--r--keyboards/hhkb/keymaps/jp/Makefile1
-rw-r--r--keyboards/hhkb/keymaps/jp/keymap.c58
-rw-r--r--keyboards/hhkb/keymaps/rdg_jp/Makefile1
-rw-r--r--keyboards/hhkb/keymaps/rdg_jp/keymap.c65
-rw-r--r--keyboards/infinity_ergodox/MEMO.txt385
-rw-r--r--keyboards/infinity_ergodox/Makefile85
-rw-r--r--keyboards/infinity_ergodox/bootloader_defs.h1
-rw-r--r--keyboards/infinity_ergodox/chconf.h524
-rw-r--r--keyboards/infinity_ergodox/config.h (renamed from keyboards/stm32_f103_onekey/config.h)23
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/board_IS31FL3731C.h113
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/driver.mk2
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c333
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_lld_config.h36
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/driver.mk2
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/emulator_lcd.c10
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/emulator_led/driver.mk2
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/emulator_led/emulator_led.c10
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/board_ST7565.h127
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/driver.mk2
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c292
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_config.h26
-rw-r--r--keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/st7565.h37
-rw-r--r--keyboards/infinity_ergodox/gfxconf.h331
-rw-r--r--keyboards/infinity_ergodox/halconf.h353
-rw-r--r--keyboards/infinity_ergodox/infinity_ergodox.c76
-rw-r--r--keyboards/infinity_ergodox/infinity_ergodox.h44
-rw-r--r--keyboards/infinity_ergodox/keymaps/default/keymap.c114
-rw-r--r--keyboards/infinity_ergodox/keymaps/default/visualizer.c168
-rw-r--r--keyboards/infinity_ergodox/led.c49
-rw-r--r--keyboards/infinity_ergodox/matrix.c169
-rw-r--r--keyboards/infinity_ergodox/mcuconf.h74
-rw-r--r--keyboards/kc60/keymaps/stanleylai/keymap.c67
-rw-r--r--keyboards/kc60/keymaps/ws2812/config.h5
-rw-r--r--keyboards/kc60/keymaps/ws2812/keymap.c65
-rw-r--r--keyboards/lets_split/Makefile78
-rw-r--r--keyboards/lets_split/config.h (renamed from keyboards/stm32_f072_onekey/config.h)53
-rw-r--r--keyboards/lets_split/eeprom-lefthand.eep2
-rw-r--r--keyboards/lets_split/eeprom-righthand.eep2
-rw-r--r--keyboards/lets_split/i2c.c159
-rw-r--r--keyboards/lets_split/i2c.h31
-rw-r--r--keyboards/lets_split/imgs/split-keyboard-i2c-schematic.pngbin0 -> 26565 bytes
-rw-r--r--keyboards/lets_split/imgs/split-keyboard-serial-schematic.pngbin0 -> 19487 bytes
-rw-r--r--keyboards/lets_split/keymaps/default/keymap.c214
-rw-r--r--keyboards/lets_split/lets_split.c30
-rw-r--r--keyboards/lets_split/lets_split.h25
-rw-r--r--keyboards/lets_split/matrix.c311
-rw-r--r--keyboards/lets_split/pro_micro.h362
-rw-r--r--keyboards/lets_split/readme.md102
-rw-r--r--keyboards/lets_split/serial.c225
-rw-r--r--keyboards/lets_split/serial.h26
-rw-r--r--keyboards/lets_split/split_util.c76
-rw-r--r--keyboards/lets_split/split_util.h22
-rw-r--r--keyboards/phantom/config.h13
-rw-r--r--keyboards/phantom/keymaps/default/keymap.c69
-rw-r--r--keyboards/phantom/led.c2
-rw-r--r--keyboards/planck/keymaps/experimental/Makefile6
-rw-r--r--keyboards/planck/keymaps/experimental/config.h8
-rw-r--r--keyboards/planck/keymaps/experimental/keymap.c73
-rw-r--r--keyboards/planck/keymaps/pvc/config.h5
-rw-r--r--keyboards/planck/keymaps/yang/config.h5
-rw-r--r--keyboards/planck/keymaps/yang/keymap.c66
-rw-r--r--keyboards/preonic/config.h5
-rw-r--r--keyboards/satan/config.h14
-rw-r--r--keyboards/satan/keymaps/default/keymap.c68
-rw-r--r--keyboards/satan/keymaps/poker/keymap.c116
-rw-r--r--keyboards/satan/keymaps/sethbc/keymap.c73
-rw-r--r--keyboards/satan/keymaps/stanleylai/config.h20
-rw-r--r--keyboards/satan/keymaps/stanleylai/keymap.c84
-rw-r--r--keyboards/stm32_f103_onekey/keymaps/default/keymap.c25
-rw-r--r--keyboards/teensy_lc_onekey/keymaps/default/keymap.c32
m---------lib/ugfx0
-rw-r--r--quantum/keymap.h10
-rw-r--r--quantum/keymap_common.c2
-rw-r--r--quantum/keymap_extras/keymap_spanish.h4
-rwxr-xr-xquantum/light_ws2812.c25
-rw-r--r--quantum/matrix.c14
-rw-r--r--quantum/quantum.c56
-rw-r--r--quantum/rgblight.c23
-rw-r--r--quantum/rgblight.h7
-rw-r--r--quantum/serial_link/LICENSE21
-rw-r--r--quantum/serial_link/README.md1
-rw-r--r--quantum/serial_link/protocol/byte_stuffer.c145
-rw-r--r--quantum/serial_link/protocol/byte_stuffer.h34
-rw-r--r--quantum/serial_link/protocol/frame_router.c69
-rw-r--r--quantum/serial_link/protocol/frame_router.h38
-rw-r--r--quantum/serial_link/protocol/frame_validator.c121
-rw-r--r--quantum/serial_link/protocol/frame_validator.h34
-rw-r--r--quantum/serial_link/protocol/physical.h30
-rw-r--r--quantum/serial_link/protocol/transport.c124
-rw-r--r--quantum/serial_link/protocol/transport.h151
-rw-r--r--quantum/serial_link/protocol/triple_buffered_object.c78
-rw-r--r--quantum/serial_link/protocol/triple_buffered_object.h51
-rw-r--r--quantum/serial_link/system/serial_link.c265
-rw-r--r--quantum/serial_link/system/serial_link.h63
-rw-r--r--quantum/serial_link/tests/Makefile61
-rw-r--r--quantum/serial_link/tests/byte_stuffer_tests.c506
-rw-r--r--quantum/serial_link/tests/frame_router_tests.c231
-rw-r--r--quantum/serial_link/tests/frame_validator_tests.c101
-rw-r--r--quantum/serial_link/tests/transport_tests.c168
-rw-r--r--quantum/serial_link/tests/triple_buffered_object_tests.c82
-rw-r--r--quantum/template/template.c2
-rw-r--r--quantum/visualizer/LICENSE.md29
-rw-r--r--quantum/visualizer/example_integration/callbacks.c36
-rw-r--r--quantum/visualizer/example_integration/gfxconf.h325
-rw-r--r--quantum/visualizer/example_integration/lcd_backlight_hal.c91
-rw-r--r--quantum/visualizer/example_integration/visualizer_user.c121
-rw-r--r--quantum/visualizer/lcd_backlight.c85
-rw-r--r--quantum/visualizer/lcd_backlight.h42
-rw-r--r--quantum/visualizer/led_test.c170
-rw-r--r--quantum/visualizer/led_test.h41
-rw-r--r--quantum/visualizer/readme.md18
-rw-r--r--quantum/visualizer/visualizer.c545
-rw-r--r--quantum/visualizer/visualizer.h147
-rw-r--r--quantum/visualizer/visualizer.mk61
-rw-r--r--readme.md95
-rw-r--r--tmk_core/avr.mk1
-rw-r--r--tmk_core/chibios.mk6
-rw-r--r--tmk_core/common.mk11
-rw-r--r--tmk_core/common/avr/bootloader.c54
-rw-r--r--tmk_core/common/keyboard.c19
-rw-r--r--tmk_core/common/keycode.h7
-rw-r--r--tmk_core/common/matrix.h5
-rw-r--r--tmk_core/protocol/chibios/main.c45
-rw-r--r--tmk_core/rules.mk81
191 files changed, 10703 insertions, 910 deletions
diff --git a/.gitmodules b/.gitmodules
index 1576b8dc0b..7e3c92d031 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,3 +4,6 @@
[submodule "lib/chibios-contrib"]
path = lib/chibios-contrib
url = https://github.com/ChibiOS/ChibiOS-Contrib.git
+[submodule "lib/ugfx"]
+ path = lib/ugfx
+ url = https://bitbucket.org/Tectu/ugfx
diff --git a/Makefile b/Makefile
index c285dabad4..a7a10bf326 100644
--- a/Makefile
+++ b/Makefile
@@ -59,6 +59,12 @@ ifndef KEYBOARD
KEYBOARD=planck
endif
+MASTER ?= left
+ifdef master
+ MASTER = $(master)
+endif
+
+
# converts things to keyboards/subproject
ifneq (,$(findstring /,$(KEYBOARD)))
TEMP:=$(KEYBOARD)
@@ -198,10 +204,20 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
endif
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
- OPT_DEFS += -DTAP_DANCE_ENABLE
+ OPT_DEFS += -DTAP_DANCE_ENABLE
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
endif
+ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
+ SERIAL_DIR = $(QUANTUM_DIR)/serial_link
+ SERIAL_PATH = $(QUANTUM_PATH)/serial_link
+ SERIAL_SRC = $(wildcard $(SERIAL_PATH)/protocol/*.c)
+ SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
+ SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
+ OPT_DEFS += -DSERIAL_LINK_ENABLE
+ VAPTH += $(SERIAL_PATH)
+endif
+
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
@@ -233,10 +249,17 @@ ifeq ($(PLATFORM),AVR)
else ifeq ($(PLATFORM),CHIBIOS)
include $(TMK_PATH)/protocol/chibios.mk
include $(TMK_PATH)/chibios.mk
+ OPT_OS = chibios
else
$(error Unknown platform)
endif
+ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
+ VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer
+ VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer
+ include $(VISUALIZER_PATH)/visualizer.mk
+endif
+
include $(TMK_PATH)/rules.mk
GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
diff --git a/keyboards/atreus/Makefile b/keyboards/atreus/Makefile
index 72b694faac..95ee1d4d7b 100644
--- a/keyboards/atreus/Makefile
+++ b/keyboards/atreus/Makefile
@@ -5,6 +5,7 @@ ifdef TEENSY2
ATRUES_UPLOAD_COMMAND = teensy_loader_cli -w -mmcu=$(MCU) $(TARGET).hex
else
OPT_DEFS += -DATREUS_ASTAR
+ OPT_DEFS += -DCATERINA_BOOTLOADER
ATRUES_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
endif
diff --git a/keyboards/chibios_test/Makefile b/keyboards/chibios_test/Makefile
new file mode 100644
index 0000000000..d9f2b8b83b
--- /dev/null
+++ b/keyboards/chibios_test/Makefile
@@ -0,0 +1,14 @@
+SUBPROJECT_DEFAULT = stm32_f072_onekey
+
+#BOOTMAGIC_ENABLE = yes # 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
+SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend
+NKRO_ENABLE ?= yes # USB Nkey Rollover
+CUSTOM_MATRIX ?= yes # Custom matrix file
+
+ifndef QUANTUM_DIR
+ include ../../Makefile
+endif \ No newline at end of file
diff --git a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.c b/keyboards/chibios_test/boards/GENERIC_STM32_F103/board.c
index 31319ef575..31319ef575 100644
--- a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.c
+++ b/keyboards/chibios_test/boards/GENERIC_STM32_F103/board.c
diff --git a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.h b/keyboards/chibios_test/boards/GENERIC_STM32_F103/board.h
index 7253e77826..7253e77826 100644
--- a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.h
+++ b/keyboards/chibios_test/boards/GENERIC_STM32_F103/board.h
diff --git a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.mk b/keyboards/chibios_test/boards/GENERIC_STM32_F103/board.mk
index d692c0ee46..d692c0ee46 100644
--- a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/board.mk
+++ b/keyboards/chibios_test/boards/GENERIC_STM32_F103/board.mk
diff --git a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/mini_stm32_mapping.png b/keyboards/chibios_test/boards/GENERIC_STM32_F103/mini_stm32_mapping.png
index c44a7d9ebc..c44a7d9ebc 100644
--- a/keyboards/stm32_f103_onekey/boards/GENERIC_STM32_F103/mini_stm32_mapping.png
+++ b/keyboards/chibios_test/boards/GENERIC_STM32_F103/mini_stm32_mapping.png
Binary files differ
diff --git a/keyboards/stm32_f103_onekey/boards/maple_mini_mapping.png b/keyboards/chibios_test/boards/maple_mini_mapping.png
index 12cfa81db2..12cfa81db2 100644
--- a/keyboards/stm32_f103_onekey/boards/maple_mini_mapping.png
+++ b/keyboards/chibios_test/boards/maple_mini_mapping.png
Binary files differ
diff --git a/keyboards/chibios_test/chibios_test.c b/keyboards/chibios_test/chibios_test.c
new file mode 100644
index 0000000000..efe2d4a5d6
--- /dev/null
+++ b/keyboards/chibios_test/chibios_test.c
@@ -0,0 +1 @@
+#include "chibios_test.h"
diff --git a/keyboards/chibios_test/chibios_test.h b/keyboards/chibios_test/chibios_test.h
new file mode 100644
index 0000000000..25b0317710
--- /dev/null
+++ b/keyboards/chibios_test/chibios_test.h
@@ -0,0 +1,6 @@
+#ifndef KEYBOARDS_CHIBIOS_TEST_CHIBIOS_TEST_H_
+#define KEYBOARDS_CHIBIOS_TEST_CHIBIOS_TEST_H_
+
+#include "quantum.h"
+
+#endif /* KEYBOARDS_CHIBIOS_TEST_CHIBIOS_TEST_H_ */
diff --git a/keyboards/teensy_lc_onekey/config.h b/keyboards/chibios_test/config.h
index 19b14fe61a..c32a77b37f 100644
--- a/keyboards/teensy_lc_onekey/config.h
+++ b/keyboards/chibios_test/config.h
@@ -18,18 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CONFIG_H
#define CONFIG_H
-
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6464
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
-#define MANUFACTURER "TMK"
+#define MANUFACTURER "QMK"
#define USBSTR_MANUFACTURER 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
-#define PRODUCT "ChibiOS TMK test"
-#define USBSTR_PRODUCT 'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
-#define DESCRIPTION "TMK keyboard firmware over ChibiOS"
+#define PRODUCT "ChibiOS QMK test"
+#define USBSTR_PRODUCT 'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'Q', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
+#define DESCRIPTION "QMK keyboard firmware test for ChibiOS"
/* key matrix size */
#define MATRIX_ROWS 1
diff --git a/keyboards/stm32_f072_onekey/keymaps/default/keymap.c b/keyboards/chibios_test/keymaps/default/keymap.c
index 6c48149f83..a362e2ccf6 100644
--- a/keyboards/stm32_f072_onekey/keymaps/default/keymap.c
+++ b/keyboards/chibios_test/keymaps/default/keymap.c
@@ -15,10 +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/>.
*/
-#include "stm32_f072_onekey.h"
+#include "chibios_test.h"
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- {{KC_CAPS}}, // test with KC_CAPS, KC_A, KC_BTLD
+ {{KC_CAPS}}, // test with KC_CAPS, KC_A, RESET
};
const uint16_t fn_actions[] = {
diff --git a/keyboards/teensy_lc_onekey/ld/MKL26Z64.ld b/keyboards/chibios_test/ld/MKL26Z64.ld
index fb141f888c..fb141f888c 100644
--- a/keyboards/teensy_lc_onekey/ld/MKL26Z64.ld
+++ b/keyboards/chibios_test/ld/MKL26Z64.ld
diff --git a/keyboards/stm32_f103_onekey/ld/STM32F103x8_stm32duino_bootloader.ld b/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld
index 00613328ed..00613328ed 100644
--- a/keyboards/stm32_f103_onekey/ld/STM32F103x8_stm32duino_bootloader.ld
+++ b/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld
diff --git a/keyboards/stm32_f072_onekey/Makefile b/keyboards/chibios_test/stm32_f072_onekey/Makefile
index 24abcb0e09..eae38c4b2b 100644
--- a/keyboards/stm32_f072_onekey/Makefile
+++ b/keyboards/chibios_test/stm32_f072_onekey/Makefile
@@ -36,15 +36,6 @@ ARMV = 6
# Build Options
# comment out to disable the options.
#
-#BOOTMAGIC_ENABLE = yes # 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
-SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend
-NKRO_ENABLE ?= yes # USB Nkey Rollover
-CUSTOM_MATRIX ?= yes # Custom matrix file
-
ifndef QUANTUM_DIR
- include ../../Makefile
+ include ../../../Makefile
endif
diff --git a/keyboards/stm32_f072_onekey/bootloader_defs.h b/keyboards/chibios_test/stm32_f072_onekey/bootloader_defs.h
index 02c48c4e6d..02c48c4e6d 100644
--- a/keyboards/stm32_f072_onekey/bootloader_defs.h
+++ b/keyboards/chibios_test/stm32_f072_onekey/bootloader_defs.h
diff --git a/keyboards/stm32_f072_onekey/chconf.h b/keyboards/chibios_test/stm32_f072_onekey/chconf.h
index 99fa8ce398..99fa8ce398 100644
--- a/keyboards/stm32_f072_onekey/chconf.h
+++ b/keyboards/chibios_test/stm32_f072_onekey/chconf.h
diff --git a/keyboards/chibios_test/stm32_f072_onekey/config.h b/keyboards/chibios_test/stm32_f072_onekey/config.h
new file mode 100644
index 0000000000..bbaf0dc4bf
--- /dev/null
+++ b/keyboards/chibios_test/stm32_f072_onekey/config.h
@@ -0,0 +1,7 @@
+#ifndef KEYBOARDS_CHIBIOS_TEST_STM32_F072_ONEKEY_CONFIG_H_
+#define KEYBOARDS_CHIBIOS_TEST_STM32_F072_ONEKEY_CONFIG_H_
+
+#include "../config.h"
+
+
+#endif /* KEYBOARDS_CHIBIOS_TEST_STM32_F072_ONEKEY_CONFIG_H_ */
diff --git a/keyboards/stm32_f072_onekey/halconf.h b/keyboards/chibios_test/stm32_f072_onekey/halconf.h
index 1a450d6327..1a450d6327 100644
--- a/keyboards/stm32_f072_onekey/halconf.h
+++ b/keyboards/chibios_test/stm32_f072_onekey/halconf.h
diff --git a/keyboards/stm32_f072_onekey/led.c b/keyboards/chibios_test/stm32_f072_onekey/led.c
index 18edb8ba89..18edb8ba89 100644
--- a/keyboards/stm32_f072_onekey/led.c
+++ b/keyboards/chibios_test/stm32_f072_onekey/led.c
diff --git a/keyboards/stm32_f072_onekey/matrix.c b/keyboards/chibios_test/stm32_f072_onekey/matrix.c
index a05b38cd4c..a05b38cd4c 100644
--- a/keyboards/stm32_f072_onekey/matrix.c
+++ b/keyboards/chibios_test/stm32_f072_onekey/matrix.c
diff --git a/keyboards/stm32_f072_onekey/mcuconf.h b/keyboards/chibios_test/stm32_f072_onekey/mcuconf.h
index 3d877aaa2b..3d877aaa2b 100644
--- a/keyboards/stm32_f072_onekey/mcuconf.h
+++ b/keyboards/chibios_test/stm32_f072_onekey/mcuconf.h
diff --git a/keyboards/stm32_f072_onekey/stm32_f072_onekey.c b/keyboards/chibios_test/stm32_f072_onekey/stm32_f072_onekey.c
index 820d062ffd..820d062ffd 100644
--- a/keyboards/stm32_f072_onekey/stm32_f072_onekey.c
+++ b/keyboards/chibios_test/stm32_f072_onekey/stm32_f072_onekey.c
diff --git a/keyboards/stm32_f072_onekey/stm32_f072_onekey.h b/keyboards/chibios_test/stm32_f072_onekey/stm32_f072_onekey.h
index 1f798c8255..0455ad342f 100644
--- a/keyboards/stm32_f072_onekey/stm32_f072_onekey.h
+++ b/keyboards/chibios_test/stm32_f072_onekey/stm32_f072_onekey.h
@@ -1,5 +1,5 @@
#ifndef STM32_F072_ONEKEY_H
#define STM32_F072_ONEKEY_H
-#include "quantum.h"
+#include "chibios_test.h"
#endif
diff --git a/keyboards/stm32_f103_onekey/Makefile b/keyboards/chibios_test/stm32_f103_onekey/Makefile
index 5c1793c867..307ca5b198 100644
--- a/keyboards/stm32_f103_onekey/Makefile
+++ b/keyboards/chibios_test/stm32_f103_onekey/Makefile
@@ -46,19 +46,7 @@ ARMV = 7
# <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800
-# Build Options
-# comment out to disable the options.
-#
-#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
-## BOOTMAGIC is not supported on STM32 chips yet.
-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
-SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
-NKRO_ENABLE ?= yes # USB Nkey Rollover
-CUSTOM_MATRIX ?= yes # Custom matrix file
ifndef QUANTUM_DIR
- include ../../Makefile
+ include ../../../Makefile
endif
diff --git a/keyboards/stm32_f103_onekey/bootloader_defs.h b/keyboards/chibios_test/stm32_f103_onekey/bootloader_defs.h
index 0f45203cb6..0f45203cb6 100644
--- a/keyboards/stm32_f103_onekey/bootloader_defs.h
+++ b/keyboards/chibios_test/stm32_f103_onekey/bootloader_defs.h
diff --git a/keyboards/stm32_f103_onekey/chconf.h b/keyboards/chibios_test/stm32_f103_onekey/chconf.h
index dfb1f9dfb9..dfb1f9dfb9 100644
--- a/keyboards/stm32_f103_onekey/chconf.h
+++ b/keyboards/chibios_test/stm32_f103_onekey/chconf.h
diff --git a/keyboards/chibios_test/stm32_f103_onekey/config.h b/keyboards/chibios_test/stm32_f103_onekey/config.h
new file mode 100644
index 0000000000..de0b906f35
--- /dev/null
+++ b/keyboards/chibios_test/stm32_f103_onekey/config.h
@@ -0,0 +1,6 @@
+#ifndef KEYBOARDS_CHIBIOS_TEST_STM32_F103_ONEKEY_CONFIG_H_
+#define KEYBOARDS_CHIBIOS_TEST_STM32_F103_ONEKEY_CONFIG_H_
+
+#include "../config.h"
+
+#endif /* KEYBOARDS_CHIBIOS_TEST_STM32_F103_ONEKEY_CONFIG_H_ */
diff --git a/keyboards/stm32_f103_onekey/flash.sh b/keyboards/chibios_test/stm32_f103_onekey/flash.sh
index 15501dfa57..15501dfa57 100755
--- a/keyboards/stm32_f103_onekey/flash.sh
+++ b/keyboards/chibios_test/stm32_f103_onekey/flash.sh
diff --git a/keyboards/stm32_f103_onekey/halconf.h b/keyboards/chibios_test/stm32_f103_onekey/halconf.h
index 1a450d6327..1a450d6327 100644
--- a/keyboards/stm32_f103_onekey/halconf.h
+++ b/keyboards/chibios_test/stm32_f103_onekey/halconf.h
diff --git a/keyboards/stm32_f103_onekey/led.c b/keyboards/chibios_test/stm32_f103_onekey/led.c
index f5c55f7d9b..f5c55f7d9b 100644
--- a/keyboards/stm32_f103_onekey/led.c
+++ b/keyboards/chibios_test/stm32_f103_onekey/led.c
diff --git a/keyboards/stm32_f103_onekey/matrix.c b/keyboards/chibios_test/stm32_f103_onekey/matrix.c
index ea9d8d057b..ea9d8d057b 100644
--- a/keyboards/stm32_f103_onekey/matrix.c
+++ b/keyboards/chibios_test/stm32_f103_onekey/matrix.c
diff --git a/keyboards/stm32_f103_onekey/mcuconf.h b/keyboards/chibios_test/stm32_f103_onekey/mcuconf.h
index 626332a6aa..626332a6aa 100644
--- a/keyboards/stm32_f103_onekey/mcuconf.h
+++ b/keyboards/chibios_test/stm32_f103_onekey/mcuconf.h
diff --git a/keyboards/stm32_f103_onekey/stm32_f103_onekey.c b/keyboards/chibios_test/stm32_f103_onekey/stm32_f103_onekey.c
index 7fa99bb28d..7fa99bb28d 100644
--- a/keyboards/stm32_f103_onekey/stm32_f103_onekey.c
+++ b/keyboards/chibios_test/stm32_f103_onekey/stm32_f103_onekey.c
diff --git a/keyboards/stm32_f103_onekey/stm32_f103_onekey.h b/keyboards/chibios_test/stm32_f103_onekey/stm32_f103_onekey.h
index e4d0dd9c4f..89a62b2bbe 100644
--- a/keyboards/stm32_f103_onekey/stm32_f103_onekey.h
+++ b/keyboards/chibios_test/stm32_f103_onekey/stm32_f103_onekey.h
@@ -1,4 +1,4 @@
#ifndef STM32_F103_ONEKEY_H
#define STM32_F103_ONEKEY_H
-#include "quantum.h"
+#include "chibios_test.h"
#endif
diff --git a/keyboards/teensy_lc_onekey/Makefile b/keyboards/chibios_test/teensy_lc_onekey/Makefile
index 064e618159..43ea9d82d9 100644
--- a/keyboards/teensy_lc_onekey/Makefile
+++ b/keyboards/chibios_test/teensy_lc_onekey/Makefile
@@ -44,19 +44,6 @@ MCU = cortex-m0plus
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
ARMV = 6
-# Build Options
-# comment out to disable the options.
-#
-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
-CONSOLE_ENABLE ?= yes # 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
-
ifndef QUANTUM_DIR
- include ../../Makefile
-endif
+ include ../../../Makefile
+endif \ No newline at end of file
diff --git a/keyboards/teensy_lc_onekey/Makefile.3.0 b/keyboards/chibios_test/teensy_lc_onekey/Makefile.3.0
index dbf12c3631..dbf12c3631 100644
--- a/keyboards/teensy_lc_onekey/Makefile.3.0
+++ b/keyboards/chibios_test/teensy_lc_onekey/Makefile.3.0
diff --git a/keyboards/teensy_lc_onekey/Makefile.3.2 b/keyboards/chibios_test/teensy_lc_onekey/Makefile.3.2
index 41bfa41a0c..41bfa41a0c 100644
--- a/keyboards/teensy_lc_onekey/Makefile.3.2
+++ b/keyboards/chibios_test/teensy_lc_onekey/Makefile.3.2
diff --git a/keyboards/teensy_lc_onekey/chconf.h b/keyboards/chibios_test/teensy_lc_onekey/chconf.h
index cb36996c33..cb36996c33 100644
--- a/keyboards/teensy_lc_onekey/chconf.h
+++ b/keyboards/chibios_test/teensy_lc_onekey/chconf.h
diff --git a/keyboards/chibios_test/teensy_lc_onekey/config.h b/keyboards/chibios_test/teensy_lc_onekey/config.h
new file mode 100644
index 0000000000..d9eb05d2ac
--- /dev/null
+++ b/keyboards/chibios_test/teensy_lc_onekey/config.h
@@ -0,0 +1,6 @@
+#ifndef KEYBOARDS_CHIBIOS_TEST_TEENSY_LC_ONEKEY_CONFIG_H_
+#define KEYBOARDS_CHIBIOS_TEST_TEENSY_LC_ONEKEY_CONFIG_H_
+
+#include "../config.h"
+
+#endif /* KEYBOARDS_CHIBIOS_TEST_TEENSY_LC_ONEKEY_CONFIG_H_ */
diff --git a/keyboards/teensy_lc_onekey/halconf.h b/keyboards/chibios_test/teensy_lc_onekey/halconf.h
index b1d2cd5502..b1d2cd5502 100644
--- a/keyboards/teensy_lc_onekey/halconf.h
+++ b/keyboards/chibios_test/teensy_lc_onekey/halconf.h
diff --git a/keyboards/teensy_lc_onekey/instructions.md b/keyboards/chibios_test/teensy_lc_onekey/instructions.md
index 16886a015c..16886a015c 100644
--- a/keyboards/teensy_lc_onekey/instructions.md
+++ b/keyboards/chibios_test/teensy_lc_onekey/instructions.md
diff --git a/keyboards/teensy_lc_onekey/led.c b/keyboards/chibios_test/teensy_lc_onekey/led.c
index dfa60c1076..dfa60c1076 100644
--- a/keyboards/teensy_lc_onekey/led.c
+++ b/keyboards/chibios_test/teensy_lc_onekey/led.c
diff --git a/keyboards/teensy_lc_onekey/matrix.c b/keyboards/chibios_test/teensy_lc_onekey/matrix.c
index 7dab04f02b..7dab04f02b 100644
--- a/keyboards/teensy_lc_onekey/matrix.c
+++ b/keyboards/chibios_test/teensy_lc_onekey/matrix.c
diff --git a/keyboards/teensy_lc_onekey/mcuconf.h b/keyboards/chibios_test/teensy_lc_onekey/mcuconf.h
index c636590197..c636590197 100644
--- a/keyboards/teensy_lc_onekey/mcuconf.h
+++ b/keyboards/chibios_test/teensy_lc_onekey/mcuconf.h
diff --git a/keyboards/teensy_lc_onekey/teensy_lc_onekey.c b/keyboards/chibios_test/teensy_lc_onekey/teensy_lc_onekey.c
index b6c4327932..b6c4327932 100644
--- a/keyboards/teensy_lc_onekey/teensy_lc_onekey.c
+++ b/keyboards/chibios_test/teensy_lc_onekey/teensy_lc_onekey.c
diff --git a/keyboards/teensy_lc_onekey/teensy_lc_onekey.h b/keyboards/chibios_test/teensy_lc_onekey/teensy_lc_onekey.h
index f598bcf66d..ea1c84e2f5 100644
--- a/keyboards/teensy_lc_onekey/teensy_lc_onekey.h
+++ b/keyboards/chibios_test/teensy_lc_onekey/teensy_lc_onekey.h
@@ -1,4 +1,4 @@
#ifndef TEENSY_LC_ONEKEY_H
#define TEENSY_LC_ONEKEY_H
-#include "quantum.h"
+#include "chibios_test.h"
#endif
diff --git a/keyboards/clueboard/clueboard.c b/keyboards/clueboard/clueboard.c
index 13195bda6b..3435202ba1 100644
--- a/keyboards/clueboard/clueboard.c
+++ b/keyboards/clueboard/clueboard.c
@@ -1,17 +1 @@
#include "clueboard.h"
-
-void led_init_ports() {
- // * Set our LED pins as output
- DDRB |= (1<<4);
-}
-
-void led_set_kb(uint8_t usb_led) {
- DDRF |= (1<<0);
- if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
- // Turn capslock on
- PORTF |= (1<<0);
- } else {
- // Turn capslock off
- PORTF &= ~(1<<0);
- }
-}
diff --git a/keyboards/clueboard/keymaps/default/keymap.c b/keyboards/clueboard/keymaps/default/keymap.c
index 89f71e83a7..896bc7ebcc 100644
--- a/keyboards/clueboard/keymaps/default/keymap.c
+++ b/keyboards/clueboard/keymaps/default/keymap.c
@@ -67,11 +67,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[_RS] = KEYMAP(
#ifdef RGBLIGHT_ENABLE
- 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, F(1), F(7), \
- KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,RESET, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, F(8), \
+ 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, RGB_TOG, RGB_VAI, \
+ KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,RESET, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD, \
KC_TRNS, KC_TRNS, MO(_RS),KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
- MO(_FL), KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FL), F(5), \
- KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS, F(2), F(2), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, F(4), F(6), F(3)),
+ MO(_FL), KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FL), RGB_SAI, \
+ KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS, RGB_MOD, RGB_MOD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI),
#else
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_TRNS,RESET, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
@@ -83,30 +83,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
enum function_id {
SHIFT_ESC,
- #ifdef RGBLIGHT_ENABLE
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL
- #endif
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_FUNCTION(SHIFT_ESC),
- #ifdef RGBLIGHT_ENABLE
- [1] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [2] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [3] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [5] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [7] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [8] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
- #endif
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
@@ -132,49 +112,5 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
}
break;
- //led operations
- #ifdef RGBLIGHT_ENABLE
- case RGBLED_TOGGLE:
- if (record->event.pressed) {
- rgblight_toggle();
- }
-
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
- #endif
}
}
diff --git a/keyboards/clueboard/keymaps/max/keymap.c b/keyboards/clueboard/keymaps/max/keymap.c
index 82c93401db..193809840b 100644
--- a/keyboards/clueboard/keymaps/max/keymap.c
+++ b/keyboards/clueboard/keymaps/max/keymap.c
@@ -66,78 +66,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `----------------------------------------------------------------------------------'
*/
[_RS] = KEYMAP(
- 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, F(0), F(6), \
- KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,RESET, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, F(7), \
+ 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, RGB_TOG, RGB_VAI, \
+ KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,RESET, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD, \
KC_TRNS, KC_TRNS, MO(_RS),KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
- MO(_FL), KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FL), F(4), \
- KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS, F(1), F(1), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, F(3), F(5), F(2)),
+ MO(_FL), KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FL), RGB_SAI, \
+ KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS, RGB_MOD, RGB_MOD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI),
};
-enum function_id {
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL,
-};
+/*enum function_id {
+};*/
const uint16_t PROGMEM fn_actions[] = {
- [0] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [1] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [2] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [3] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [5] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [7] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
switch (id) {
- case RGBLED_TOGGLE:
- //led operations
- if (record->event.pressed) {
- rgblight_toggle();
- }
-
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
}
}
diff --git a/keyboards/clueboard/rev1/config.h b/keyboards/clueboard/rev1/config.h
index 9bb58f56e8..8c94972324 100644
--- a/keyboards/clueboard/rev1/config.h
+++ b/keyboards/clueboard/rev1/config.h
@@ -25,9 +25,8 @@
/* Underlight configuration
*/
-#define ws2812_PORTREG PORTB
-#define ws2812_DDRREG DDRB
-#define ws2812_pin 2
+#define RGB_DI_PIN B2
+#define RGBLIGHT_TIMER
#define RGBLED_NUM 14 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
diff --git a/keyboards/clueboard/rev1/rev1.c b/keyboards/clueboard/rev1/rev1.c
index 520a869e57..90fc6956c9 100644
--- a/keyboards/clueboard/rev1/rev1.c
+++ b/keyboards/clueboard/rev1/rev1.c
@@ -1 +1,17 @@
#include "rev1.h"
+
+void led_init_ports() {
+ // * Set our LED pins as output
+ DDRF |= (1<<0);
+}
+
+void led_set_kb(uint8_t usb_led) {
+ DDRF |= (1<<0);
+ if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
+ // Turn capslock on
+ PORTF |= (1<<0);
+ } else {
+ // Turn capslock off
+ PORTF &= ~(1<<0);
+ }
+}
diff --git a/keyboards/clueboard/rev2/config.h b/keyboards/clueboard/rev2/config.h
index e2f8336beb..02982ff299 100644
--- a/keyboards/clueboard/rev2/config.h
+++ b/keyboards/clueboard/rev2/config.h
@@ -29,9 +29,8 @@
/* Underlight configuration
*/
-#define ws2812_PORTREG PORTD
-#define ws2812_DDRREG DDRD
-#define ws2812_pin 7
+#define RGB_DI_PIN D7
+#define RGBLIGHT_TIMER
#define RGBLED_NUM 14 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
diff --git a/keyboards/clueboard/rev2/rev2.c b/keyboards/clueboard/rev2/rev2.c
index 7a8ec368e6..1a35b87b84 100644
--- a/keyboards/clueboard/rev2/rev2.c
+++ b/keyboards/clueboard/rev2/rev2.c
@@ -45,3 +45,19 @@ void backlight_set(uint8_t level) {
PORTD &= ~(1<<4); // Arrows
}
}
+
+void led_init_ports() {
+ // * Set our LED pins as output
+ DDRB |= (1<<4);
+}
+
+void led_set_kb(uint8_t usb_led) {
+ DDRB |= (1<<4);
+ if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
+ // Turn capslock on
+ PORTB |= (1<<4);
+ } else {
+ // Turn capslock off
+ PORTB &= ~(1<<4);
+ }
+}
diff --git a/keyboards/clueboard/rev2/rev2.h b/keyboards/clueboard/rev2/rev2.h
index 912de405da..2e9cb9dc2e 100644
--- a/keyboards/clueboard/rev2/rev2.h
+++ b/keyboards/clueboard/rev2/rev2.h
@@ -13,7 +13,7 @@
* |------------------------------------------------------------.
* | 30| 31| 32| 33| 34| 35| 36| 37| 80| 81| 82| 83| 84| 85|86|
* |------------------------------------------------------------------.
- * | 40| 41| 42| 43| 45| 46| 90| 91| 92| 93| 94| 95| 96|
+ * | 40| 41| 42| 43| 45| 46| 90| 92| 93| 94| 95| 96| 97|
* `------------------------------------------------------------------'
* ,-----------------------------------------------------------. ,---.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Yen| BS| |Ins|
diff --git a/keyboards/cluepad/config.h b/keyboards/cluepad/config.h
index 0955e0f702..bae05fade3 100644
--- a/keyboards/cluepad/config.h
+++ b/keyboards/cluepad/config.h
@@ -69,13 +69,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Underlight configuration
*/
- #define ws2812_PORTREG PORTF
- #define ws2812_DDRREG DDRF
- #define ws2812_pin 6
- #define RGBLED_NUM 4 // Number of LEDs
- #define RGBLIGHT_HUE_STEP 10
- #define RGBLIGHT_SAT_STEP 17
- #define RGBLIGHT_VAL_STEP 17
+#define RGB_DI_PIN F6
+#define RGBLIGHT_TIMER
+#define RGBLED_NUM 4 // Number of LEDs
+#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_SAT_STEP 17
+#define RGBLIGHT_VAL_STEP 17
/*
* Feature disable options
diff --git a/keyboards/cluepad/keymaps/default/keymap.c b/keyboards/cluepad/keymaps/default/keymap.c
index 8ba49952f6..66827fe48b 100644
--- a/keyboards/cluepad/keymaps/default/keymap.c
+++ b/keyboards/cluepad/keymaps/default/keymap.c
@@ -1,7 +1,6 @@
#include "cluepad.h"
#include "backlight.h"
-#include "rgblight.h"
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
@@ -46,77 +45,21 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* '-------------------'
*/
[_FL] = KEYMAP(
- LT(_FL, KC_NLCK), KC_TRNS, KC_TRNS, F(0), \
- KC_TRNS, F(4), KC_TRNS, F(6), \
- F(3), BL_STEP, F(2), \
- KC_TRNS, F(5), KC_TRNS, F(7), \
- F(1), KC_TRNS)
+ LT(_FL, KC_NLCK), KC_TRNS, KC_TRNS, RGB_TOG, \
+ KC_TRNS, RGB_SAI, KC_TRNS, RGB_VAI, \
+ RGB_HUD, BL_STEP, RGB_HUI, \
+ KC_TRNS, RGB_SAD, KC_TRNS, RGB_VAD, \
+ RGB_MOD, KC_TRNS)
};
-enum function_id {
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL,
-};
+/*enum function_id {
+};*/
const uint16_t PROGMEM fn_actions[] = {
- [0] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [1] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [2] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [3] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [5] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [7] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
switch (id) {
- case RGBLED_TOGGLE:
- if (record->event.pressed) {
- rgblight_toggle();
- }
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
}
}
diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c
index 9c1efa1d05..dc29cf5cd0 100644
--- a/keyboards/ergodox_ez/matrix.c
+++ b/keyboards/ergodox_ez/matrix.c
@@ -39,6 +39,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "timer.h"
#endif
+/*
+ * This constant define not debouncing time in msecs, but amount of matrix
+ * scan loops which should be made to get stable debounced results.
+ *
+ * On Ergodox matrix scan rate is relatively low, because of slow I2C.
+ * Now it's only 317 scans/second, or about 3.15 msec/scan.
+ * According to Cherry specs, debouncing time is 5 msec.
+ *
+ * And so, there is no sense to have DEBOUNCE higher than 2.
+ */
+
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
@@ -181,6 +192,7 @@ uint8_t matrix_scan(void)
if (debouncing) {
if (--debouncing) {
wait_us(1);
+ // this should be wait_ms(1) but has been left as-is at EZ's request
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
diff --git a/keyboards/gh60/keymaps/robotmaxtron/Makefile b/keyboards/gh60/keymaps/robotmaxtron/Makefile
new file mode 100644
index 0000000000..2e69aee298
--- /dev/null
+++ b/keyboards/gh60/keymaps/robotmaxtron/Makefile
@@ -0,0 +1,112 @@
+#----------------------------------------------------------------------------
+# 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".
+#----------------------------------------------------------------------------
+
+# MCU name
+#MCU = at90usb1287
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 16000000
+
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+# This will define a symbol, F_USB, in all source code files equal to the
+# input clock frequency (before any prescaling is performed) in Hz. This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+# Teensy halfKay 512
+# Teensy++ halfKay 1024
+# Atmel DFU loader 4096
+# LUFA bootloader 4096
+# USBaspLoader 2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+
+# Build Options
+# comment out to disable the options.
+#
+BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
+EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
+# CONSOLE_ENABLE ?= yes # Console for debug(+400)
+# COMMAND_ENABLE ?= yes # Commands for debug and configuration
+KEYBOARD_LOCK_ENABLE ?= yes # Allow locking of keyboard via magic key
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+# SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend
+NKRO_ENABLE ?= yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+# BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality
+# MIDI_ENABLE ?= YES # MIDI controls
+# UNICODE_ENABLE ?= YES # Unicode
+# BLUETOOTH_ENABLE ?= yes # Enable Bluetooth with the Adafruit EZ-Key HID
+RGBLIGHT_ENABLE ?= yes # Enable RGB Underglow
+
+ifndef QUANTUM_DIR
+ include ../../../../Makefile
+endif
+
diff --git a/keyboards/gh60/keymaps/robotmaxtron/WS2812-wiring.jpg b/keyboards/gh60/keymaps/robotmaxtron/WS2812-wiring.jpg
new file mode 100644
index 0000000000..4ab8cc31ac
--- /dev/null
+++ b/keyboards/gh60/keymaps/robotmaxtron/WS2812-wiring.jpg
Binary files differ
diff --git a/keyboards/gh60/keymaps/robotmaxtron/config.h b/keyboards/gh60/keymaps/robotmaxtron/config.h
new file mode 100644
index 0000000000..8272875ed0
--- /dev/null
+++ b/keyboards/gh60/keymaps/robotmaxtron/config.h
@@ -0,0 +1,190 @@
+/*
+Copyright 2012 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/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6060
+#define DEVICE_VER 0x0001
+#define MANUFACTURER geekhack
+#define PRODUCT GH60
+#define DESCRIPTION t.m.k. keyboard firmware for GH60
+
+/* key matrix size */
+#define MATRIX_ROWS 5
+#define MATRIX_COLS 14
+
+/*
+ * Keyboard Matrix Assignments
+ *
+ * Change this to how you wired your keyboard
+ * COLS: AVR pins used for columns, left to right
+ * ROWS: AVR pins used for rows, top to bottom
+ * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
+ * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
+ *
+*/
+ #define MATRIX_ROW_PINS { D0, D1, D2, D3, D5 }
+// Rev A
+// #define MATRIX_COL_PINS { F0, F1, E6, C7, C6, B6, D4, B1, B0, B5, B4, D7, D6, B3 }
+// Rev B/C
+ #define MATRIX_COL_PINS { F0, F1, E6, C7, C6, B6, D4, B1, B7, B5, B4, D7, D6, B3 }
+#define UNUSED_PINS
+
+/* COL2ROW or ROW2COL */
+#define DIODE_DIRECTION COL2ROW
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCING_DELAY 5
+
+/* define if matrix has ghost (lacks anti-ghosting diodes) */
+//#define MATRIX_HAS_GHOST
+
+/* number of backlight levels */
+#define BACKLIGHT_LEVELS 3
+
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
+#define LOCKING_SUPPORT_ENABLE
+/* Locking resynchronize hack */
+#define LOCKING_RESYNC_ENABLE
+
+/*
+ * Force NKRO
+ *
+ * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
+ * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
+ * makefile for this to work.)
+ *
+ * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
+ * until the next keyboard reset.
+ *
+ * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
+ * fully operational during normal computer usage.
+ *
+ * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
+ * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
+ * bootmagic, NKRO mode will always be enabled until it is toggled again during a
+ * power-up.
+ *
+ */
+//#define FORCE_NKRO
+
+/*
+ * Magic Key Options
+ *
+ * Magic keys are hotkey commands that allow control over firmware functions of
+ * the keyboard. They are best used in combination with the HID Listen program,
+ * found here: https://www.pjrc.com/teensy/hid_listen.html
+ *
+ * The options below allow the magic key functionality to be changed. This is
+ * useful if your keyboard/keypad is missing keys and you want magic key support.
+ *
+ */
+
+/* key combination for magic key command */
+#define IS_COMMAND() ( \
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+/* control how magic key switches layers */
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
+
+/* override magic key keymap */
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
+//#define MAGIC_KEY_HELP1 H
+//#define MAGIC_KEY_HELP2 SLASH
+//#define MAGIC_KEY_DEBUG D
+//#define MAGIC_KEY_DEBUG_MATRIX X
+//#define MAGIC_KEY_DEBUG_KBD K
+//#define MAGIC_KEY_DEBUG_MOUSE M
+//#define MAGIC_KEY_VERSION V
+//#define MAGIC_KEY_STATUS S
+//#define MAGIC_KEY_CONSOLE C
+//#define MAGIC_KEY_LAYER0_ALT1 ESC
+//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
+//#define MAGIC_KEY_LAYER0 0
+//#define MAGIC_KEY_LAYER1 1
+//#define MAGIC_KEY_LAYER2 2
+//#define MAGIC_KEY_LAYER3 3
+//#define MAGIC_KEY_LAYER4 4
+//#define MAGIC_KEY_LAYER5 5
+//#define MAGIC_KEY_LAYER6 6
+//#define MAGIC_KEY_LAYER7 7
+//#define MAGIC_KEY_LAYER8 8
+//#define MAGIC_KEY_LAYER9 9
+//#define MAGIC_KEY_BOOTLOADER PAUSE
+//#define MAGIC_KEY_LOCK CAPS
+//#define MAGIC_KEY_EEPROM E
+//#define MAGIC_KEY_NKRO N
+//#define MAGIC_KEY_SLEEP_LED Z
+
+/*
+ * Feature disable options
+ * These options are also useful to firmware size reduction.
+ */
+
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
+//#define NO_ACTION_MACRO
+//#define NO_ACTION_FUNCTION
+
+/*
+ * RGB Underglow
+ * These settings are for the F4 by default:
+ *
+ *
+ * #define ws2812_PORTREG PORTF
+ * #define ws2812_DDRREG DDRF
+ * #define ws2812_pin PF4
+ * #define RGBLED_NUM 14 // Number of LEDs
+ * #define RGBLIGHT_HUE_STEP 10
+ * #define RGBLIGHT_SAT_STEP 17
+ * #define RGBLIGHT_VAL_STEP 17
+ *
+ * The firmware supports 5 different light effects, and the color (hue, saturation, brightness) can be customized in most effects.
+ * To control the underglow, you need to modify your keymap file to assign those functions to some keys/key combinations.
+ * For details, please check this keymap. keyboard/planck/keymaps/yang/keymap.c
+*/
+
+/* Deprecated code below
+#define ws2812_PORTREG PORTF
+#define ws2812_DDRREG DDRF
+#define ws2812_pin PF4
+*/
+#define RGB_DI_PIN F4
+#define RGBLIGHT_TIMER
+#define RGBLED_NUM 8 // Number of LEDs
+#define RGBLIGHT_HUE_STEP 8
+#define RGBLIGHT_SAT_STEP 8
+#define RGBLIGHT_VAL_STEP 8
+#endif
diff --git a/keyboards/gh60/keymaps/robotmaxtron/keymap.c b/keyboards/gh60/keymaps/robotmaxtron/keymap.c
new file mode 100644
index 0000000000..263eec4e53
--- /dev/null
+++ b/keyboards/gh60/keymaps/robotmaxtron/keymap.c
@@ -0,0 +1,226 @@
+#include "gh60.h"
+#include "action_layer.h"
+
+#define _BL 0
+#define _AL 1
+#define _FL 2
+#define _UL 3
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ /*
+ * Base layer, pretty standard ANSI layout.
+ * ,-----------------------------------------------------------.
+ * |FN12| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
+ * |-----------------------------------------------------------|
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
+ * |-----------------------------------------------------------|
+ * |Caps/Fn| A| S| D| F| G| H| J| K| L| ;| '|Return |
+ * |-----------------------------------------------------------|
+ * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
+ * |-----------------------------------------------------------|
+ * |Ctrl|Gui |Alt | Space |Alt |Fn |Menu|Ctrl|
+ * `-----------------------------------------------------------'
+ */
+ [_BL] = KEYMAP(
+ FN12,1,2,3,4,5,6,7,8,9,0,MINS,EQL,BSPC, \
+ TAB,Q,W,E,R,T,Y,U,I,O,P,LBRC,RBRC,BSLS, \
+ FN2,A,S,D,F,G,H,J,K,L,SCLN,QUOT,NO,ENT, \
+ LSFT,NO,Z,X,C,V,B,N,M,COMM,DOT,SLSH,NO,RSFT, \
+ LCTL,LGUI,LALT, SPC, NO,RALT,FN0,APP, RCTL),
+
+ /*
+ * Locking arrow keys to WASD for when you need dedicated arrow keys
+ * ,-----------------------------------------------------------.
+ * | | | | | | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | |Up | | | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | |Left|Down|Rght| | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | |
+ * `-----------------------------------------------------------'
+ */
+ [_AL] = KEYMAP(
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,UP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS),
+
+
+ /*
+ * Primary function layer, mostly the same as the traditional Pok3r layout.
+ * ,-------------------------------------------------------------.
+ * |`~ | F1| F2| F3| F4| F5| F6| F7| F8| F9| F10| F11| F12|DEL |
+ * |-------------------------------------------------------------|
+ * | |_AL| | | | |Calc|PgUp|Up|PgDn|Ptscn|Srlck|Pause| |
+ * |-------------------------------------------------------------|
+ * | | | | | | |Home|Left|Down|Rght|Ins| | |
+ * |-------------------------------------------------------------|
+ * | |_UL| | | | | | | | | | |
+ * |-------------------------------------------------------------|
+ * | | | | | | | | |
+ * `-------------------------------------------------------------'
+ */
+ [_FL] = KEYMAP(
+ GRAVE,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12, DELETE, \
+ TRNS,FN1,TRNS,TRNS,TRNS,TRNS,CALC,PGUP,UP,PGDN,PSCR,SLCK,PAUS,TRNS, \
+ TRNS,MUTE,_VOLDOWN,_VOLUP,TRNS,TRNS,HOME,LEFT,DOWN,RGHT,INS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,FN3,TRNS,TRNS,TRNS,TRNS,END,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS),
+
+ /*
+ * Locking layer for controlling the underglow.
+ *
+ * ,-----------------------------------------------------------.
+ * | | | | | | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | |On|Mode| | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | |Hue+|Hue-|Sat+|Sat-|Val+|Val-| | | | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | |
+ * `-----------------------------------------------------------'
+ */
+ [_UL] = KEYMAP(
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,FN4,FN5,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS,FN6,FN7,FN8,FN9,FN10,FN11,TRNS,TRNS,TRNS,TRNS,TRNS, \
+ TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS),
+};
+
+enum function_id {
+ RGBLED_TOGGLE,
+ RGBLED_STEP_MODE,
+ RGBLED_INCREASE_HUE,
+ RGBLED_DECREASE_HUE,
+ RGBLED_INCREASE_SAT,
+ RGBLED_DECREASE_SAT,
+ RGBLED_INCREASE_VAL,
+ RGBLED_DECREASE_VAL,
+ SHIFT_ESC,
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+ [0] = ACTION_LAYER_MOMENTARY(2), // Momentary Fn overlay
+ [1] = ACTION_LAYER_TOGGLE(1), // Toggle Arrow Layer overlay
+ [2] = ACTION_LAYER_TAP_KEY(2, KC_CAPS), // Tap to toggle caps lock and hold to activate function layer
+ [3] = ACTION_LAYER_TOGGLE(3), // Toggle Underglow Layer overlay
+ [4] = ACTION_FUNCTION(RGBLED_TOGGLE), //Turn on/off underglow
+ [5] = ACTION_FUNCTION(RGBLED_STEP_MODE), // Change underglow mode
+ [6] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
+ [7] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
+ [8] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
+ [9] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
+ [10] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
+ [11] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
+ [12] = ACTION_FUNCTION(SHIFT_ESC),
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+ // MACRODOWN only works in this function
+ switch(id) {
+ case 0:
+ if (record->event.pressed) {
+ register_code(KC_RSFT);
+ } else {
+ unregister_code(KC_RSFT);
+ }
+ break;
+ }
+ return MACRO_NONE;
+};
+
+void matrix_scan_user(void) {
+
+// Layer LED indicators
+// ESC led on when in function layer, WASD cluster leds enabled when on arrow cluster
+ uint32_t layer = layer_state;
+ if (layer & (1<<1)) {
+ gh60_wasd_leds_on();
+ } else {
+ gh60_wasd_leds_off();
+ }
+
+ if (layer & (1<<2)) {
+ gh60_esc_led_on();
+ } else {
+ gh60_esc_led_off();
+ }
+};
+
+#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
+
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
+ switch (id) {
+ case RGBLED_TOGGLE:
+ //led operations
+ if (record->event.pressed) {
+ rgblight_toggle();
+ }
+ break;
+ case RGBLED_INCREASE_HUE:
+ if (record->event.pressed) {
+ rgblight_increase_hue();
+ }
+ break;
+ case RGBLED_DECREASE_HUE:
+ if (record->event.pressed) {
+ rgblight_decrease_hue();
+ }
+ break;
+ case RGBLED_INCREASE_SAT:
+ if (record->event.pressed) {
+ rgblight_increase_sat();
+ }
+ break;
+ case RGBLED_DECREASE_SAT:
+ if (record->event.pressed) {
+ rgblight_decrease_sat();
+ }
+ break;
+ case RGBLED_INCREASE_VAL:
+ if (record->event.pressed) {
+ rgblight_increase_val();
+ }
+ break;
+ case RGBLED_DECREASE_VAL:
+ if (record->event.pressed) {
+ rgblight_decrease_val();
+ }
+ break;
+ case RGBLED_STEP_MODE:
+ if (record->event.pressed) {
+ rgblight_step();
+ }
+ break;
+ static uint8_t shift_esc_shift_mask;
+ // Shift + ESC = ~
+ case SHIFT_ESC:
+ shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
+ if (record->event.pressed) {
+ if (shift_esc_shift_mask) {
+ add_key(KC_GRV);
+ send_keyboard_report();
+ } else {
+ add_key(KC_ESC);
+ send_keyboard_report();
+ }
+ } else {
+ if (shift_esc_shift_mask) {
+ del_key(KC_GRV);
+ send_keyboard_report();
+ } else {
+ del_key(KC_ESC);
+ send_keyboard_report();
+ }
+ }
+ break;
+ }
+};
diff --git a/keyboards/gh60/keymaps/robotmaxtron/readme.md b/keyboards/gh60/keymaps/robotmaxtron/readme.md
new file mode 100644
index 0000000000..3e22925008
--- /dev/null
+++ b/keyboards/gh60/keymaps/robotmaxtron/readme.md
@@ -0,0 +1,16 @@
+robotmaxtron's GH60 Layout
+=====================
+
+##Quantum MK Firmware
+For the full Quantum feature list, see the parent readme.md.
+
+* Standard ANSI layout with Pok3r styled function layers
+* ESC key led enables when on function layer
+* Lockable layer with arrow keys on WASD with backlighting to indicate locked on arrow layer
+* Neopixel/WS2812 RGB Underglow Support
+
+## Reference Images
+![Wiring Refererence] (WS2812-wiring.jpg)
+
+### Additional Credits
+Keymap has been based on various keymaps available from the QMK Repo for the GH60-SATAN and KC60 keyboards.
diff --git a/keyboards/hhkb/Makefile b/keyboards/hhkb/Makefile
index 53eece3969..6fe973e1eb 100644
--- a/keyboards/hhkb/Makefile
+++ b/keyboards/hhkb/Makefile
@@ -78,6 +78,10 @@ ifndef QUANTUM_DIR
include ../../Makefile
endif
+ifneq (, $(findstring yes, $(HHKB_JP)))
+ OPT_DEFS += -DHHKB_JP
+endif
+
debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
debug-on: all
diff --git a/keyboards/hhkb/config.h b/keyboards/hhkb/config.h
index ee66e44571..3f0528b4b9 100644
--- a/keyboards/hhkb/config.h
+++ b/keyboards/hhkb/config.h
@@ -29,7 +29,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DESCRIPTION q.m.k keyboard firmware for HHKB
/* key matrix size */
-#define MATRIX_ROWS 8
+#ifdef HHKB_JP
+# define MATRIX_ROWS 16
+#else
+# define MATRIX_ROWS 8
+#endif
#define MATRIX_COLS 8
#define TAPPING_TERM 200
diff --git a/keyboards/hhkb/hhkb.h b/keyboards/hhkb/hhkb.h
index cc756c4565..e95125efcb 100644
--- a/keyboards/hhkb/hhkb.h
+++ b/keyboards/hhkb/hhkb.h
@@ -21,4 +21,31 @@
{ K70, K71, K72, K73, K74, K75, K76, KC_NO } \
}
+
+#define KEYMAP_JP( \
+ K02, K32, K62, K22, K12, K52, K72, KA2, K92, K82, KB2, KE2, KF2, KD2, KC2, \
+ K03, K63, K23, K13, K53, K73, KA3, K93, K83, KB3, KE3, KF3, KD3, \
+ K06, K66, K26, K16, K56, K76, KA6, K96, K86, KB6, KE6, KF6, KD6, KC6, \
+ K05, K65, K25, K15, K55, K75, KA5, K95, K85, KB5, KE5, KF5, KD5, KC5, \
+ K04, K34, K64, K24, K14, K74, K94, K84, KB4, KE4, KF4, KD4, KC4) \
+{ \
+ { KC_NO, KC_NO, K02, K03, K04, K05, K06, KC_NO }, \
+ { KC_NO, KC_NO, K12, K13, K14, K15, K16, KC_NO }, \
+ { KC_NO, KC_NO, K22, K23, K24, K25, K26, KC_NO }, \
+ { KC_NO, KC_NO, K32, KC_NO, K34, KC_NO, KC_NO, KC_NO }, \
+ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
+ { KC_NO, KC_NO, K52, K53, KC_NO, K55, K56, KC_NO }, \
+ { KC_NO, KC_NO, K62, K63, K64, K65, K66, KC_NO }, \
+ { KC_NO, KC_NO, K72, K73, K74, K75, K76, KC_NO }, \
+ { KC_NO, KC_NO, K82, K83, K84, K85, K86, KC_NO }, \
+ { KC_NO, KC_NO, K92, K93, K94, K95, K96, KC_NO }, \
+ { KC_NO, KC_NO, KA2, KA3, KC_NO, KA5, KA6, KC_NO }, \
+ { KC_NO, KC_NO, KB2, KB3, KB4, KB5, KB6, KC_NO }, \
+ { KC_NO, KC_NO, KC2, KC_NO, KC4, KC5, KC6, KC_NO }, \
+ { KC_NO, KC_NO, KD2, KD3, KD4, KD5, KD6, KC_NO }, \
+ { KC_NO, KC_NO, KE2, KE3, KE4, KE5, KE6, KC_NO }, \
+ { KC_NO, KC_NO, KF2, KF3, KF4, KF5, KF6, KC_NO } \
+}
+
+
#endif
diff --git a/keyboards/hhkb/keymaps/jp/Makefile b/keyboards/hhkb/keymaps/jp/Makefile
new file mode 100644
index 0000000000..92986292a2
--- /dev/null
+++ b/keyboards/hhkb/keymaps/jp/Makefile
@@ -0,0 +1 @@
+HHKB_JP=yes
diff --git a/keyboards/hhkb/keymaps/jp/keymap.c b/keyboards/hhkb/keymaps/jp/keymap.c
new file mode 100644
index 0000000000..8525adce59
--- /dev/null
+++ b/keyboards/hhkb/keymaps/jp/keymap.c
@@ -0,0 +1,58 @@
+#include "hhkb.h"
+
+#define _______ KC_TRNS
+
+
+/* Layer 0: HHKB JP
+ * ,-----------------------------------------------------------.
+ * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| -| =|Yen|Bsp|
+ * |-----------------------------------------------------------|
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
+ * |------------------------------------------------------` Ent|
+ * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| `| |
+ * |-----------------------------------------------------------|
+ * |Shft | Z| X| C| V| B| N| M| ,| .| /| \| Up|Sft|
+ * |-----------------------------------------------------------|
+ * | ||Ctl|Alt|Cmd| | Spc |Bsp| | | ||Lft|Dwn|Rgh|
+ * `-----------------------------------------------------------'
+ */
+
+/* Layer 1: HHKB mode (HHKB Fn)
+ * ,-----------------------------------------------------------.
+ * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+ * |-----------------------------------------------------------|
+ * |Caps | | | | | | | |Psc|Slk|Pus|Up | | |
+ * |------------------------------------------------------` |
+ * | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | +| -|End|PgD|Dow| | | |
+ * |-----------------------------------------------------------|
+ * | || | | | | | | | | || | | |
+ * `-----------------------------------------------------------'
+ */
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = KEYMAP_JP(
+ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_JYEN, KC_BSPC,
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,
+ KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_BSLS, KC_ENT,
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RO, KC_UP, KC_RSFT,
+ MO(1), KC_ZKHK, KC_LGUI, KC_LALT, KC_MHEN, KC_SPC, KC_HENK, KC_KANA, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT
+ ),
+
+ [1] = KEYMAP_JP(
+ KC_PWR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL,
+ KC_CAPS, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, _______,
+ _______, KC_VOLD, KC_VOLU, KC_MUTE, KC_PWR, _______, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, _______, KC_PENT,
+ _______, _______, _______, _______, _______, _______, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______ , _______, _______, _______, _______, _______, _______, _______
+ )
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t macro_id, uint8_t opt) {
+ return MACRO_NONE;
+}
+
+const uint16_t PROGMEM fn_actions[] = {
+
+};
diff --git a/keyboards/hhkb/keymaps/rdg_jp/Makefile b/keyboards/hhkb/keymaps/rdg_jp/Makefile
new file mode 100644
index 0000000000..92986292a2
--- /dev/null
+++ b/keyboards/hhkb/keymaps/rdg_jp/Makefile
@@ -0,0 +1 @@
+HHKB_JP=yes
diff --git a/keyboards/hhkb/keymaps/rdg_jp/keymap.c b/keyboards/hhkb/keymaps/rdg_jp/keymap.c
new file mode 100644
index 0000000000..700ba3a0b7
--- /dev/null
+++ b/keyboards/hhkb/keymaps/rdg_jp/keymap.c
@@ -0,0 +1,65 @@
+#include "hhkb.h"
+
+#define _______ KC_TRNS
+
+enum {
+ ZER,
+ HDN,
+ OSY
+};
+
+
+#define CTL_ESC CTL_T(KC_ESC)
+#define SFT_BSP SFT_T(KC_BSPC)
+
+#define SCRNS3 LGUI(LCTL(LSFT(KC_3)))
+#define SCRNS4 LGUI(LCTL(LSFT(KC_4)))
+
+
+/* hhkb jp ~ layout
+ * ,-----------------------------------------------------------.
+ * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| -| =|Yen|Bsp|
+ * |-----------------------------------------------------------|
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
+ * |------------------------------------------------------` Ent|
+ * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| `| |
+ * |-----------------------------------------------------------|
+ * |Shft | Z| X| C| V| B| N| M| ,| .| /| \| Up|Sft|
+ * |-----------------------------------------------------------|
+ * | ||Ctl|Alt|Cmd| | Spc |Bsp| | | ||Lft|Dwn|Rgh|
+ * `-----------------------------------------------------------'
+ */
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [ZER] = KEYMAP_JP(
+ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_INS, KC_BSPC,
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,
+ CTL_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_GRV, KC_ENT,
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, KC_UP, KC_RSFT,
+ MO(HDN), KC_LCTL, KC_LALT, KC_LGUI, MO(HDN), KC_SPC, SFT_BSP, MO(HDN), MO(OSY), KC_NO, KC_LEFT, KC_DOWN, KC_RGHT
+ ),
+
+ [HDN] = KEYMAP_JP(
+ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_DEL,
+ _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, _______,
+ _______, KC_TILD, KC_GRV, KC_BSLS, KC_PIPE, KC_MINS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_TILD, KC_GRV, _______, _______,
+ _______, KC_VOLD, KC_VOLU, KC_MUTE, KC_PWR, _______, _______, KC_ENT, _______, _______, _______, _______, KC_PGUP, _______,
+ _______, _______, _______, _______, _______, KC_UNDS , KC_DEL, _______, _______, _______, KC_HOME, KC_PGDN, KC_END
+ ),
+
+ [OSY] = KEYMAP_JP(
+ _______, _______, _______, SCRNS3, SCRNS4, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______ , _______, _______, _______, _______, _______, _______, _______
+ )
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t macro_id, uint8_t opt) {
+ return MACRO_NONE;
+}
+
+const uint16_t PROGMEM fn_actions[] = {
+
+};
diff --git a/keyboards/infinity_ergodox/MEMO.txt b/keyboards/infinity_ergodox/MEMO.txt
new file mode 100644
index 0000000000..e2886aa002
--- /dev/null
+++ b/keyboards/infinity_ergodox/MEMO.txt
@@ -0,0 +1,385 @@
+flabbergast's TMK/ChibiOS port
+==============================
+2015/10/16
+
+
+Build
+-----
+$ git clone -b chibios https://github.com/flabbergast/tmk_keyboard.git
+
+$ cd tmk_keyboard
+$ git submodule add -f -b kinetis https://github.com/flabbergast/ChibiOS.git tmk_core/tool/chibios/chibios
+or
+$ cd tmk_keyboard/tmk_core/tool/chibios
+$ git clone -b kinetis https://github.com/flabbergast/ChibiOS.git tmk_core/tool/chibios/chibios
+
+$ cd tmk_keyboard/keyboard/infinity_chibios
+$ make
+
+
+
+
+Chibios Configuration
+---------------------
+halconf.h: for HAL configuration
+ placed in project directory
+ read in chibios/os/hal/hal.mk
+ included in chibios/os/hal/include/hal.h
+mcuconf.h: for MCU configuration
+ placed in project directory
+ included in halconf.h
+
+
+Chibios Term
+------------
+PAL = Port Abstraction Layer
+ palWritePad
+ palReadPad
+ palSetPad
+ chibios/os/hal/include/pal.h
+
+LLD = Low Level Driver
+
+
+Makefile
+--------
+ # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = KINETIS
+ MCU_SERIES = KL2x
+
+ # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or <this_dir>/ld/
+ MCU_LDSCRIPT = MKL26Z64
+
+ # - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP = kl2x
+
+ # Board: it should exist either in <chibios>/os/hal/boards/
+ # or <this_dir>/boards
+ BOARD = PJRC_TEENSY_LC
+
+ MCU = cortex-m0
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV = 6
+
+
+halconf.h
+---------
+
+
+mcuconf.h
+---------
+
+
+chconf.h
+--------
+
+
+ld script
+---------
+--- ../../tmk_core/tool/chibios/chibios/os/common/ports/ARMCMx/compilers/GCC/ld/MKL26Z64.ld 2015-10-15 09:08:58.732904304 +0900
++++ ld/MKL26Z64.ld 2015-10-15 08:48:06.430215496 +0900
+@@ -27,7 +27,8 @@
+ {
+ flash0 : org = 0x00000000, len = 0xc0
+ flashcfg : org = 0x00000400, len = 0x10
+- flash : org = 0x00000410, len = 64k - 0x410
++ flash : org = 0x00000410, len = 62k - 0x410
++ eeprom_emu : org = 0x0000F800, len = 2k
+ ram : org = 0x1FFFF800, len = 8k
+ }
+
+@@ -35,6 +36,10 @@
+ __ram_size__ = LENGTH(ram);
+ __ram_end__ = __ram_start__ + __ram_size__;
+
++__eeprom_workarea_start__ = ORIGIN(eeprom_emu);
++__eeprom_workarea_size__ = LENGTH(eeprom_emu);
++__eeprom_workarea_end__ = __eeprom_workarea_start__ + __eeprom_workarea_size__;
++
+ SECTIONS
+ {
+ . = 0;
+
+
+
+Configuration/Startup for Infinity 60%
+--------------------------------------
+Configuration:
+
+
+Clock:
+Inifinity
+ FEI(FLL Engaged Internal) mode with core clock:48MHz, bus clock:48MHz, flash clock:24MHz
+ Clock dividor:
+ SIM_CLKDIV1[OUTDIV1] = 0 divide-by-1 for core clock
+ SIM_CLKDIV1[OUTDIV2] = 0 divide-by-1 for bus clock
+ SIM_CLKDIV1[OUTDIV4] = 1 divide-by-2 for flash clock
+ Internal reference clock:
+ MCG_C1[IREFS] = 1 Internal Reference Select for clock source for FLL
+ MCG_C1[IRCLKEN] = 1 Internal Reference Clock Enable
+ FLL multipilication:
+ MCG_C4[DMX32] = 1
+ MCG_C4[DRST_DRS] = 01 FLL factor 1464 * 32.768kHz = 48MHz
+
+chibios/os/hal/ports/KINETIS/K20x/hal_lld.c
+ k20x_clock_init(): called in __early_init() defined in board.c
+ disable watchdog and configure clock
+
+ configurable macros:
+ KINETIS_NO_INIT: whether init or not
+ KINETIS_MCG_MODE: clock mode
+ KINETIS_MCG_MODE_FEI
+ KINETIS_MCG_MODE_PEE
+ hal/ports/KINETIS/K20x/hal_lld.h
+
+
+chibios/os/hal/boards/FREESCALE_FREEDOM_K20D50M/board.h
+ PALConfig pal_default_config
+ boardInit()
+ __early_init()
+ macro definitions for board infos, freq and mcu type
+
+chibios/os/hal/boards/FREESCALE_FREEDOM_K20D50M/board.c
+
+USB
+
+
+Startup
+-------
+ common/ports/ARMCMx/GCC/crt0_v[67]m.s
+ Reset_Handler: startup code
+ common/ports/ARMCMx/GCC/crt1.c
+ __core_init(): weak
+ __early_init(): weak
+ __late_init(): weak
+ __default_exit(): weak
+ called from Reset_Handler of crt0
+ common/ports/ARMCMx/GCC/vector.c
+ common/ports/ARMCMx/GCC/ld/*.ld
+
+chibios/os/common/ports/ARMCMx/compilers/GCC/
+├── crt0_v6m.s
+├── crt0_v7m.s
+├── crt1.c
+├── ld
+│   ├── MK20DX128BLDR3.ld
+│   ├── MK20DX128BLDR4.ld
+│   ├── MK20DX128.ld
+│   ├── MK20DX256.ld
+│   ├── MKL25Z128.ld
+│   ├── MKL26Z128.ld
+│   ├── MKL26Z64.ld
+│   └── STM32L476xG.ld
+├── mk
+│   ├── startup_k20x5.mk
+│   ├── startup_k20x7.mk
+│   ├── startup_k20x.mk
+│   ├── startup_kl2x.mk
+│   └── startup_stm32l4xx.mk
+├── rules.ld
+├── rules.mk
+└── vectors.c
+
+chibios/os/hal/
+├── boards
+│   ├── FREESCALE_FREEDOM_K20D50M
+│   │   ├── board.c
+│   │   ├── board.h
+│   │   └── board.mk
+│   ├── MCHCK_K20
+│   │   ├── board.c
+│   │   ├── board.h
+│   │   └── board.mk
+│   ├── PJRC_TEENSY_3
+│   │   ├── board.c
+│   │   ├── board.h
+│   │   └── board.mk
+│   ├── PJRC_TEENSY_3_1
+│   │   ├── board.c
+│   │   ├── board.h
+│   │   └── board.mk
+│   ├── PJRC_TEENSY_LC
+│   │   ├── board.c
+│   │   ├── board.h
+│   │   └── board.mk
+│   ├── readme.txt
+│   ├── simulator
+│   │   ├── board.c
+│   │   ├── board.h
+│   │   └── board.mk
+│   ├── ST_NUCLEO_F030R8
+│   │   ├── board.c
+│   │   ├── board.h
+│   │   ├── board.mk
+│   │   └── cfg
+│   │   └── board.chcfg
+├── hal.mk
+├── include
+│   ├── adc.h
+│   ├── can.h
+│   ├── dac.h
+│   ├── ext.h
+│   ├── gpt.h
+│   ├── hal_channels.h
+│   ├── hal_files.h
+│   ├── hal.h
+│   ├── hal_ioblock.h
+│   ├── hal_mmcsd.h
+│   ├── hal_queues.h
+│   ├── hal_streams.h
+│   ├── i2c.h
+│   ├── i2s.h
+│   ├── icu.h
+│   ├── mac.h
+│   ├── mii.h
+│   ├── mmc_spi.h
+│   ├── pal.h
+│   ├── pwm.h
+│   ├── rtc.h
+│   ├── sdc.h
+│   ├── serial.h
+│   ├── serial_usb.h
+│   ├── spi.h
+│   ├── st.h
+│   ├── uart.h
+│   └── usb.h
+├── lib
+│   └── streams
+│   ├── chprintf.c
+│   ├── chprintf.h
+│   ├── memstreams.c
+│   ├── memstreams.h
+│   ├── nullstreams.c
+│   └── nullstreams.h
+├── osal
+│   ├── nil
+│   │   ├── osal.c
+│   │   ├── osal.h
+│   │   └── osal.mk
+│   ├── os-less
+│   │   └── ARMCMx
+│   │   ├── osal.c
+│   │   ├── osal.h
+│   │   └── osal.mk
+│   └── rt
+│   ├── osal.c
+│   ├── osal.h
+│   └── osal.mk
+├── ports
+│   ├── AVR
+│   ├── common
+│   │   └── ARMCMx
+│   │   ├── mpu.h
+│   │   ├── nvic.c
+│   │   └── nvic.h
+│   ├── KINETIS
+│   │   ├── K20x
+│   │   │   ├── hal_lld.c
+│   │   │   ├── hal_lld.h
+│   │   │   ├── kinetis_registry.h
+│   │   │   ├── platform.dox
+│   │   │   ├── platform.mk
+│   │   │   ├── pwm_lld.c
+│   │   │   ├── pwm_lld.h
+│   │   │   ├── spi_lld.c
+│   │   │   └── spi_lld.h
+│   │   ├── KL2x
+│   │   │   ├── hal_lld.c
+│   │   │   ├── hal_lld.h
+│   │   │   ├── kinetis_registry.h
+│   │   │   ├── platform.mk
+│   │   │   ├── pwm_lld.c
+│   │   │   └── pwm_lld.h
+│   │   ├── LLD
+│   │   │   ├── adc_lld.c
+│   │   │   ├── adc_lld.h
+│   │   │   ├── ext_lld.c
+│   │   │   ├── ext_lld.h
+│   │   │   ├── gpt_lld.c
+│   │   │   ├── gpt_lld.h
+│   │   │   ├── i2c_lld.c
+│   │   │   ├── i2c_lld.h
+│   │   │   ├── pal_lld.c
+│   │   │   ├── pal_lld.h
+│   │   │   ├── serial_lld.c
+│   │   │   ├── serial_lld.h
+│   │   │   ├── st_lld.c
+│   │   │   ├── st_lld.h
+│   │   │   ├── usb_lld.c
+│   │   │   └── usb_lld.h
+│   │   └── README.md
+│   ├── LPC
+│   ├── simulator
+│   └── STM32
+├── src
+│   ├── adc.c
+│   ├── can.c
+│   ├── dac.c
+│   ├── ext.c
+│   ├── gpt.c
+│   ├── hal.c
+│   ├── hal_mmcsd.c
+│   ├── hal_queues.c
+│   ├── i2c.c
+│   ├── i2s.c
+│   ├── icu.c
+│   ├── mac.c
+│   ├── mmc_spi.c
+│   ├── pal.c
+│   ├── pwm.c
+│   ├── rtc.c
+│   ├── sdc.c
+│   ├── serial.c
+│   ├── serial_usb.c
+│   ├── spi.c
+│   ├── st.c
+│   ├── uart.c
+│   └── usb.c
+└── templates
+ ├── adc_lld.c
+ ├── adc_lld.h
+ ├── can_lld.c
+ ├── can_lld.h
+ ├── dac_lld.c
+ ├── dac_lld.h
+ ├── ext_lld.c
+ ├── ext_lld.h
+ ├── gpt_lld.c
+ ├── gpt_lld.h
+ ├── halconf.h
+ ├── hal_lld.c
+ ├── hal_lld.h
+ ├── i2c_lld.c
+ ├── i2c_lld.h
+ ├── i2s_lld.c
+ ├── i2s_lld.h
+ ├── icu_lld.c
+ ├── icu_lld.h
+ ├── mac_lld.c
+ ├── mac_lld.h
+ ├── mcuconf.h
+ ├── osal
+ │   ├── osal.c
+ │   ├── osal.h
+ │   └── osal.mk
+ ├── pal_lld.c
+ ├── pal_lld.h
+ ├── platform.mk
+ ├── pwm_lld.c
+ ├── pwm_lld.h
+ ├── rtc_lld.c
+ ├── rtc_lld.h
+ ├── sdc_lld.c
+ ├── sdc_lld.h
+ ├── serial_lld.c
+ ├── serial_lld.h
+ ├── spi_lld.c
+ ├── spi_lld.h
+ ├── st_lld.c
+ ├── st_lld.h
+ ├── uart_lld.c
+ ├── uart_lld.h
+ ├── usb_lld.c
+ └── usb_lld.h
diff --git a/keyboards/infinity_ergodox/Makefile b/keyboards/infinity_ergodox/Makefile
new file mode 100644
index 0000000000..7edc03d8cc
--- /dev/null
+++ b/keyboards/infinity_ergodox/Makefile
@@ -0,0 +1,85 @@
+# project specific files
+SRC = matrix.c \
+ led.c
+
+## chip/board settings
+# - the next two should match the directories in
+# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+# - For Teensies, FAMILY = KINETIS and SERIES is either
+# KL2x (LC) or K20x (3.0,3.1,3.2).
+# - For Infinity KB, SERIES = K20x
+MCU_FAMILY = KINETIS
+MCU_SERIES = K20x
+
+# Linker script to use
+# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
+# or <this_dir>/ld/
+# - NOTE: a custom ld script is needed for EEPROM on Teensy LC
+# - LDSCRIPT =
+# - MKL26Z64 for Teensy LC
+# - MK20DX128 for Teensy 3.0
+# - MK20DX256 for Teensy 3.1 and 3.2
+# - MK20DX128BLDR4 for Infinity 60% with Kiibohd bootloader
+# - MK20DX256BLDR8 for Infinity ErgoDox with Kiibohd bootloader
+MCU_LDSCRIPT = MK20DX256BLDR8
+
+# Startup code to use
+# - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
+# - STARTUP =
+# - kl2x for Teensy LC
+# - k20x5 for Teensy 3.0 and Infinity 60%
+# - k20x7 for Teensy 3.1, 3.2 and Infinity ErgoDox
+MCU_STARTUP = k20x7
+
+# Board: it should exist either in <chibios>/os/hal/boards/
+# or <this_dir>/boards
+# - BOARD =
+# - PJRC_TEENSY_LC for Teensy LC
+# - PJRC_TEENSY_3 for Teensy 3.0
+# - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2
+# - MCHCK_K20 for Infinity KB
+#BOARD = MCHCK_K20
+BOARD = PJRC_TEENSY_3_1
+
+# Cortex version
+# Teensy LC is cortex-m0; Teensy 3.x are cortex-m4
+MCU = cortex-m4
+
+# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+# I.e. 6 for Teensy LC; 7 for Teensy 3.x
+ARMV = 7
+
+# Vector table for application
+# 0x00000000-0x00001000 area is occupied by bootlaoder.*/
+# The CORTEX_VTOR... is needed only for MCHCK/Infinity KB
+OPT_DEFS = -DCORTEX_VTOR_INIT=0x00002000
+
+# Build Options
+# comment out to disable the options.
+#
+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
+CONSOLE_ENABLE ?= yes # 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
+SERIAL_LINK_ENABLE = yes
+VISUALIZER_ENABLE ?= yes
+LCD_ENABLE ?= yes
+LED_ENABLE ?= yes
+LCD_BACKLIGHT_ENABLE ?= yes
+
+ifdef LCD_ENABLE
+include drivers/gdisp/st7565ergodox/driver.mk
+endif
+
+ifdef LED_ENABLE
+include drivers/gdisp/IS31FL3731C/driver.mk
+endif
+
+ifndef QUANTUM_DIR
+ include ../../Makefile
+endif \ No newline at end of file
diff --git a/keyboards/infinity_ergodox/bootloader_defs.h b/keyboards/infinity_ergodox/bootloader_defs.h
new file mode 100644
index 0000000000..c67153be60
--- /dev/null
+++ b/keyboards/infinity_ergodox/bootloader_defs.h
@@ -0,0 +1 @@
+#define KIIBOHD_BOOTLOADER
diff --git a/keyboards/infinity_ergodox/chconf.h b/keyboards/infinity_ergodox/chconf.h
new file mode 100644
index 0000000000..d59c35eb68
--- /dev/null
+++ b/keyboards/infinity_ergodox/chconf.h
@@ -0,0 +1,524 @@
+/*
+ ChibiOS - Copyright (C) 2006..2015 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/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_
+
+/*===========================================================================*/
+/**
+ * @name System timers settings
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief System time counter resolution.
+ * @note Allowed values are 16 or 32 bits.
+ */
+#define CH_CFG_ST_RESOLUTION 32
+
+/**
+ * @brief System tick frequency.
+ * @details Frequency of the system timer that drives the system ticks. This
+ * setting also defines the system tick time unit.
+ */
+#define CH_CFG_ST_FREQUENCY 100000
+
+/**
+ * @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.
+ */
+#define CH_CFG_ST_TIMEDELTA 0
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @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.
+ */
+#define CH_CFG_TIME_QUANTUM 20
+
+/**
+ * @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.
+ */
+#define CH_CFG_MEMCORE_SIZE 0
+
+/**
+ * @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.
+ */
+#define CH_CFG_NO_IDLE_THREAD FALSE
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @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.
+ */
+#define CH_CFG_OPTIMIZE_SPEED TRUE
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @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.
+ */
+#define CH_CFG_USE_TM FALSE
+
+/**
+ * @brief Threads registry APIs.
+ * @details If enabled then the registry APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_REGISTRY TRUE
+
+/**
+ * @brief Threads synchronization APIs.
+ * @details If enabled then the @p chThdWait() function is included in
+ * the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_WAITEXIT TRUE
+
+/**
+ * @brief Semaphores APIs.
+ * @details If enabled then the Semaphores APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_SEMAPHORES TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
+
+/**
+ * @brief Mutexes APIs.
+ * @details If enabled then the mutexes APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_MUTEXES TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_CONDVARS TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
+
+/**
+ * @brief Events Flags APIs.
+ * @details If enabled then the event flags APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_EVENTS TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
+
+/**
+ * @brief Synchronous Messages APIs.
+ * @details If enabled then the synchronous messages APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_MESSAGES TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_MAILBOXES TRUE
+
+/**
+ * @brief I/O Queues APIs.
+ * @details If enabled then the I/O queues APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#define CH_CFG_USE_QUEUES TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_MEMCORE TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_HEAP TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_MEMPOOLS TRUE
+
+/**
+ * @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.
+ */
+#define CH_CFG_USE_DYNAMIC TRUE
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Debug options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief Debug option, kernel statistics.
+ *
+ * @note The default is @p FALSE.
+ */
+#define CH_DBG_STATISTICS FALSE
+
+/**
+ * @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.
+ */
+#define CH_DBG_SYSTEM_STATE_CHECK FALSE
+
+/**
+ * @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.
+ */
+#define CH_DBG_ENABLE_CHECKS FALSE
+
+/**
+ * @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.
+ */
+#define CH_DBG_ENABLE_ASSERTS FALSE
+
+/**
+ * @brief Debug option, trace buffer.
+ * @details If enabled then the context switch circular trace buffer is
+ * activated.
+ *
+ * @note The default is @p FALSE.
+ */
+#define CH_DBG_ENABLE_TRACE FALSE
+
+/**
+ * @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.
+ */
+#define CH_DBG_ENABLE_STACK_CHECK FALSE
+
+/**
+ * @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.
+ */
+#define CH_DBG_FILL_THREADS FALSE
+
+/**
+ * @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.
+ */
+#define CH_DBG_THREADS_PROFILING FALSE
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Kernel hooks
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @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 chThdInit() API.
+ *
+ * @note It is invoked from within @p chThdInit() and implicitly from all
+ * the threads creation APIs.
+ */
+#define CH_CFG_THREAD_INIT_HOOK(tp) { \
+ /* Add threads initialization code here.*/ \
+}
+
+/**
+ * @brief Threads finalization hook.
+ * @details User finalization code added to the @p chThdExit() API.
+ *
+ * @note It is inserted into lock zone.
+ * @note It is also invoked when the threads simply return in order to
+ * terminate.
+ */
+#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() { \
+}
+
+/**
+ * @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() { \
+}
+
+/**
+ * @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/keyboards/stm32_f103_onekey/config.h b/keyboards/infinity_ergodox/config.h
index 19b14fe61a..d24ee0f056 100644
--- a/keyboards/stm32_f103_onekey/config.h
+++ b/keyboards/infinity_ergodox/config.h
@@ -26,15 +26,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER "TMK"
-#define USBSTR_MANUFACTURER 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
-#define PRODUCT "ChibiOS TMK test"
-#define USBSTR_PRODUCT 'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
-#define DESCRIPTION "TMK keyboard firmware over ChibiOS"
+#define USBSTR_MANUFACTURER 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00'
+#define PRODUCT "Infinity keyboard/TMK"
+#define USBSTR_PRODUCT 'I', '\x00', 'n', '\x00', 'f', '\x00', 'i', '\x00', 'n', '\x00', 'i', '\x00', 't', '\x00', 'y', '\x00', ' ', '\x00', 'k', '\x00', 'e', '\x00', 'y', '\x00', 'b', '\x00', 'o', '\x00', 'a', '\x00', 'r', '\x00', 'd', '\x00', '/', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00'
/* key matrix size */
-#define MATRIX_ROWS 1
-#define MATRIX_COLS 1
-#define DIODE_DIRECTION COL2ROW
+#define MATRIX_ROWS 18
+#define MATRIX_COLS 5
+#define LOCAL_MATRIX_ROWS 9
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
@@ -43,16 +42,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEBOUNCE 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
-#define LOCKING_SUPPORT_ENABLE
+//#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
-#define LOCKING_RESYNC_ENABLE
+//#define LOCKING_RESYNC_ENABLE
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
+/* Keymap for Infiity prototype */
+#define INFINITY_PROTOTYPE
+#define SERIAL_LINK_BAUD 562500
+#define SERIAL_LINK_THREAD_PRIORITY (NORMALPRIO - 1)
+// The visualizer needs gfx thread priorities
+#define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2)
/*
* Feature disable options
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/board_IS31FL3731C.h b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/board_IS31FL3731C.h
new file mode 100644
index 0000000000..2ea73f1fb3
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/board_IS31FL3731C.h
@@ -0,0 +1,113 @@
+/*
+Copyright 2016 Fred Sundvik <fsundvik@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/>.
+*/
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+static const I2CConfig i2ccfg = {
+ 400000 // clock speed (Hz); 400kHz max for IS31
+};
+
+#define GDISP_SCREEN_WIDTH 7
+#define GDISP_SCREEN_HEIGHT 7
+
+static const uint8_t led_mask[] = {
+ 0xFF, 0x00, /* C1-1 -> C1-16 */
+ 0xFF, 0x00, /* C2-1 -> C2-16 */
+ 0xFF, 0x00, /* C3-1 -> C3-16 */
+ 0xFF, 0x00, /* C4-1 -> C4-16 */
+ 0x3F, 0x00, /* C5-1 -> C5-16 */
+ 0x00, 0x00, /* C6-1 -> C6-16 */
+ 0x00, 0x00, /* C7-1 -> C7-16 */
+ 0x00, 0x00, /* C8-1 -> C8-16 */
+ 0x00, 0x00, /* C9-1 -> C9-16 */
+};
+
+// The address of the LED
+#define LA(c, r) (c + r * 16 )
+// Need to be an address that is not mapped, but inside the range of the controller matrix
+#define NA LA(8, 8)
+
+// The numbers in the comments are the led numbers DXX on the PCB
+// The mapping is taken from the schematic of left hand side
+static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = {
+// 45 44 43 42 41 40 39
+ { LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)},
+// 52 51 50 49 48 47 46
+ { LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2) },
+// 58 57 56 55 54 53 N/A
+ { LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA },
+// 67 66 65 64 63 62 61
+ { LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2) },
+// 76 75 74 73 72 60 59
+ { LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0) },
+// N/A N/A N/A N/A N/A N/A 68
+ { NA, NA, NA, NA, NA, NA, LA(5, 4) },
+// N/A N/A N/A N/A 71 70 69
+ { NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0) },
+};
+
+
+#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND
+#define IS31_TIMEOUT 5000
+
+static GFXINLINE void init_board(GDisplay *g) {
+ (void) g;
+ /* I2C pins */
+ palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL
+ palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA
+ palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL);
+ palClearPad(GPIOB, 16);
+ /* start I2C */
+ i2cStart(&I2CD1, &i2ccfg);
+ // try high drive (from kiibohd)
+ I2CD1.i2c->C2 |= I2Cx_C2_HDRS;
+ // try glitch fixing (from kiibohd)
+ I2CD1.i2c->FLT = 4;
+}
+
+static GFXINLINE void post_init_board(GDisplay *g) {
+ (void) g;
+}
+
+static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) {
+ (void) g;
+ return led_mask;
+}
+
+static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y)
+{
+ (void) g;
+ return led_mapping[y][x];
+}
+
+static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) {
+ (void) g;
+ if(!shutdown) {
+ palSetPad(GPIOB, 16);
+ }
+ else {
+ palClearPad(GPIOB, 16);
+ }
+}
+
+static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
+ (void) g;
+ i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT));
+}
+
+#endif /* _GDISP_LLD_BOARD_H */
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/driver.mk b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/driver.mk
new file mode 100644
index 0000000000..f32d0d8685
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/driver.mk
@@ -0,0 +1,2 @@
+GFXINC += drivers/gdisp/IS31FL3731C
+GFXSRC += drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c
new file mode 100644
index 0000000000..1d21f0c498
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c
@@ -0,0 +1,333 @@
+/*
+Copyright 2016 Fred Sundvik <fsundvik@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 "gfx.h"
+
+#if GFX_USE_GDISP
+
+#define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_ERGODOX
+#include "drivers/gdisp/IS31FL3731C/gdisp_lld_config.h"
+#include "src/gdisp/gdisp_driver.h"
+
+#include "board_IS31FL3731C.h"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#ifndef GDISP_SCREEN_HEIGHT
+ #define GDISP_SCREEN_HEIGHT 9
+#endif
+#ifndef GDISP_SCREEN_WIDTH
+ #define GDISP_SCREEN_WIDTH 16
+#endif
+#ifndef GDISP_INITIAL_CONTRAST
+ #define GDISP_INITIAL_CONTRAST 0
+#endif
+#ifndef GDISP_INITIAL_BACKLIGHT
+ #define GDISP_INITIAL_BACKLIGHT 100
+#endif
+
+#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
+
+#define IS31_ADDR_DEFAULT 0x74
+
+#define IS31_REG_CONFIG 0x00
+// bits in reg
+#define IS31_REG_CONFIG_PICTUREMODE 0x00
+#define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
+#define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
+// D2:D0 bits are starting frame for autoplay mode
+
+#define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode
+
+#define IS31_REG_AUTOPLAYCTRL1 0x02
+// D6:D4 number of loops (000=infty)
+// D2:D0 number of frames to be used
+
+#define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms)
+
+#define IS31_REG_DISPLAYOPT 0x05
+#define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames
+#define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8
+// D2:D0 bits blink period time (*0.27s)
+
+#define IS31_REG_AUDIOSYNC 0x06
+#define IS31_REG_AUDIOSYNC_ENABLE 0x1
+
+#define IS31_REG_FRAMESTATE 0x07
+
+#define IS31_REG_BREATHCTRL1 0x08
+// D6:D4 fade out time (26ms*2^i)
+// D2:D0 fade in time (26ms*2^i)
+
+#define IS31_REG_BREATHCTRL2 0x09
+#define IS31_REG_BREATHCTRL2_ENABLE 0x10
+// D2:D0 extinguish time (3.5ms*2^i)
+
+#define IS31_REG_SHUTDOWN 0x0A
+#define IS31_REG_SHUTDOWN_OFF 0x0
+#define IS31_REG_SHUTDOWN_ON 0x1
+
+#define IS31_REG_AGCCTRL 0x0B
+#define IS31_REG_ADCRATE 0x0C
+
+#define IS31_COMMANDREGISTER 0xFD
+#define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine'
+#define IS31_FUNCTIONREG_SIZE 0xD
+
+#define IS31_FRAME_SIZE 0xB4
+
+#define IS31_PWM_REG 0x24
+#define IS31_PWM_SIZE 0x90
+
+#define IS31_LED_MASK_SIZE 0x12
+#define IS31_SCREEN_WIDTH 16
+
+#define IS31
+
+//Generated by http://jared.geek.nz/2013/feb/linear-led-pwm
+const unsigned char cie[256] = {
+ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
+ 3, 4, 4, 4, 4, 4, 4, 5, 5, 5,
+ 5, 5, 6, 6, 6, 6, 6, 7, 7, 7,
+ 7, 8, 8, 8, 8, 9, 9, 9, 10, 10,
+ 10, 10, 11, 11, 11, 12, 12, 12, 13, 13,
+ 13, 14, 14, 15, 15, 15, 16, 16, 17, 17,
+ 17, 18, 18, 19, 19, 20, 20, 21, 21, 22,
+ 22, 23, 23, 24, 24, 25, 25, 26, 26, 27,
+ 28, 28, 29, 29, 30, 31, 31, 32, 32, 33,
+ 34, 34, 35, 36, 37, 37, 38, 39, 39, 40,
+ 41, 42, 43, 43, 44, 45, 46, 47, 47, 48,
+ 49, 50, 51, 52, 53, 54, 54, 55, 56, 57,
+ 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+ 68, 70, 71, 72, 73, 74, 75, 76, 77, 79,
+ 80, 81, 82, 83, 85, 86, 87, 88, 90, 91,
+ 92, 94, 95, 96, 98, 99, 100, 102, 103, 105,
+ 106, 108, 109, 110, 112, 113, 115, 116, 118, 120,
+ 121, 123, 124, 126, 128, 129, 131, 132, 134, 136,
+ 138, 139, 141, 143, 145, 146, 148, 150, 152, 154,
+ 155, 157, 159, 161, 163, 165, 167, 169, 171, 173,
+ 175, 177, 179, 181, 183, 185, 187, 189, 191, 193,
+ 196, 198, 200, 202, 204, 207, 209, 211, 214, 216,
+ 218, 220, 223, 225, 228, 230, 232, 235, 237, 240,
+ 242, 245, 247, 250, 252, 255,
+};
+
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+typedef struct{
+ uint8_t write_buffer_offset;
+ uint8_t write_buffer[IS31_FRAME_SIZE];
+ uint8_t frame_buffer[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH];
+ uint8_t page;
+}__attribute__((__packed__)) PrivData;
+
+// Some common routines and macros
+#define PRIV(g) ((PrivData*)g->priv)
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+static GFXINLINE void write_page(GDisplay* g, uint8_t page) {
+ uint8_t tx[2] __attribute__((aligned(2)));
+ tx[0] = IS31_COMMANDREGISTER;
+ tx[1] = page;
+ write_data(g, tx, 2);
+}
+
+static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uint8_t data) {
+ uint8_t tx[2] __attribute__((aligned(2)));
+ tx[0] = reg;
+ tx[1] = data;
+ write_page(g, page);
+ write_data(g, tx, 2);
+}
+
+static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint16_t length) {
+ PRIV(g)->write_buffer_offset = offset;
+ write_page(g, page);
+ write_data(g, (uint8_t*)PRIV(g), length + 1);
+}
+
+LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
+ // The private area is the display surface.
+ g->priv = gfxAlloc(sizeof(PrivData));
+ __builtin_memset(PRIV(g), 0, sizeof(PrivData));
+ PRIV(g)->page = 0;
+
+ // Initialise the board interface
+ init_board(g);
+ gfxSleepMilliseconds(10);
+
+ // zero function page, all registers (assuming full_page is all zeroes)
+ write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE);
+ set_hardware_shutdown(g, false);
+ gfxSleepMilliseconds(10);
+ // software shutdown
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
+ gfxSleepMilliseconds(10);
+ // zero function page, all registers
+ write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE);
+ gfxSleepMilliseconds(10);
+
+
+ // zero all LED registers on all 8 pages, and enable the mask
+ __builtin_memcpy(PRIV(g)->write_buffer, get_led_mask(g), IS31_LED_MASK_SIZE);
+ for(uint8_t i=0; i<8; i++) {
+ write_ram(g, i, 0, IS31_FRAME_SIZE);
+ gfxSleepMilliseconds(1);
+ }
+
+ // software shutdown disable (i.e. turn stuff on)
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
+ gfxSleepMilliseconds(10);
+
+ // Finish Init
+ post_init_board(g);
+
+ /* Initialise the GDISP structure */
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Orientation = GDISP_ROTATE_0;
+ g->g.Powermode = powerOn;
+ g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
+ g->g.Contrast = GDISP_INITIAL_CONTRAST;
+ return TRUE;
+}
+
+#if GDISP_HARDWARE_FLUSH
+ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
+ // Don't flush if we don't need it.
+ if (!(g->flags & GDISP_FLG_NEEDFLUSH))
+ return;
+
+ PRIV(g)->page++;
+ PRIV(g)->page %= 2;
+ // TODO: some smarter algorithm for this
+ // We should run only one physical page at a time
+ // This way we don't need to send so much data, and
+ // we could use slightly less memory
+ uint8_t* src = PRIV(g)->frame_buffer;
+ for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) {
+ for (int x=0;x<GDISP_SCREEN_WIDTH;x++) {
+ PRIV(g)->write_buffer[get_led_address(g, x, y)]=cie[*src];
+ ++src;
+ }
+ }
+ write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE);
+ gfxSleepMilliseconds(1);
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page);
+
+ g->flags &= ~GDISP_FLG_NEEDFLUSH;
+ }
+#endif
+
+#if GDISP_HARDWARE_DRAWPIXEL
+ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
+ coord_t x, y;
+
+ switch(g->g.Orientation) {
+ default:
+ case GDISP_ROTATE_0:
+ x = g->p.x;
+ y = g->p.y;
+ break;
+ case GDISP_ROTATE_180:
+ x = GDISP_SCREEN_WIDTH-1 - g->p.x;
+ y = g->p.y;
+ break;
+ }
+ PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color);
+ g->flags |= GDISP_FLG_NEEDFLUSH;
+ }
+#endif
+
+#if GDISP_HARDWARE_PIXELREAD
+ LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
+ coord_t x, y;
+
+ switch(g->g.Orientation) {
+ default:
+ case GDISP_ROTATE_0:
+ x = g->p.x;
+ y = g->p.y;
+ break;
+ case GDISP_ROTATE_180:
+ x = GDISP_SCREEN_WIDTH-1 - g->p.x;
+ y = g->p.y;
+ break;
+ }
+ return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]);
+ }
+#endif
+
+#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
+ LLDSPEC void gdisp_lld_control(GDisplay *g) {
+ switch(g->p.x) {
+ case GDISP_CONTROL_POWER:
+ if (g->g.Powermode == (powermode_t)g->p.ptr)
+ return;
+ switch((powermode_t)g->p.ptr) {
+ case powerOff:
+ case powerSleep:
+ case powerDeepSleep:
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
+ break;
+ case powerOn:
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
+ break;
+ default:
+ return;
+ }
+ g->g.Powermode = (powermode_t)g->p.ptr;
+ return;
+
+ case GDISP_CONTROL_ORIENTATION:
+ if (g->g.Orientation == (orientation_t)g->p.ptr)
+ return;
+ switch((orientation_t)g->p.ptr) {
+ /* Rotation is handled by the drawing routines */
+ case GDISP_ROTATE_0:
+ case GDISP_ROTATE_180:
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+ case GDISP_ROTATE_90:
+ case GDISP_ROTATE_270:
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+ default:
+ return;
+ }
+ g->g.Orientation = (orientation_t)g->p.ptr;
+ return;
+
+ case GDISP_CONTROL_CONTRAST:
+ return;
+ }
+ }
+#endif // GDISP_NEED_CONTROL
+
+#endif // GFX_USE_GDISP
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_lld_config.h b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_lld_config.h
new file mode 100644
index 0000000000..bb28ad775e
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/IS31FL3731C/gdisp_lld_config.h
@@ -0,0 +1,36 @@
+/*
+Copyright 2016 Fred Sundvik <fsundvik@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/>.
+*/
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if GFX_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
+#define GDISP_HARDWARE_DRAWPIXEL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+
+#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256
+
+#endif /* GFX_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/driver.mk b/keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/driver.mk
new file mode 100644
index 0000000000..16c3f80f53
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/driver.mk
@@ -0,0 +1,2 @@
+GFXINC += drivers/gdisp/emulator_lcd
+GFXSRC += drivers/gdisp/emulator_lcd/emulator_lcd.c
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/emulator_lcd.c b/keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/emulator_lcd.c
new file mode 100644
index 0000000000..babfe2b367
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/emulator_lcd/emulator_lcd.c
@@ -0,0 +1,10 @@
+#define GDISP_DRIVER_VMT GDISPVMT_EMULATOR_LCD_ERGODOX
+#define GDISP_HARDWARE_DRAWPIXEL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
+#define GDISP_SCREEN_WIDTH 128
+#define GDISP_SCREEN_HEIGHT 32
+#define ROTATE_180_IS_FLIP
+
+#include "emulator/emulator_driver_impl.h"
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/emulator_led/driver.mk b/keyboards/infinity_ergodox/drivers/gdisp/emulator_led/driver.mk
new file mode 100644
index 0000000000..2554344321
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/emulator_led/driver.mk
@@ -0,0 +1,2 @@
+GFXINC += drivers/gdisp/emulator_led
+GFXSRC += drivers/gdisp/emulator_led/emulator_led.c
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/emulator_led/emulator_led.c b/keyboards/infinity_ergodox/drivers/gdisp/emulator_led/emulator_led.c
new file mode 100644
index 0000000000..b0ebcdc475
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/emulator_led/emulator_led.c
@@ -0,0 +1,10 @@
+#define GDISP_DRIVER_VMT GDISPVMT_EMULATOR_LED_ERGODOX
+#define GDISP_HARDWARE_DRAWPIXEL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
+#define GDISP_SCREEN_WIDTH 7
+#define GDISP_SCREEN_HEIGHT 7
+#define ROTATE_180_IS_FLIP
+
+#include "emulator/emulator_driver_impl.h"
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/board_ST7565.h b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/board_ST7565.h
new file mode 100644
index 0000000000..290571ce5b
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/board_ST7565.h
@@ -0,0 +1,127 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _GDISP_LLD_BOARD_H
+#define _GDISP_LLD_BOARD_H
+
+#include "print.h"
+
+#define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6
+#define ST7565_ADC ST7565_ADC_NORMAL
+#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC
+#define ST7565_PAGE_ORDER 0,1,2,3
+/*
+ * Custom page order for several LCD boards, e.g. HEM12864-99
+ * #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3
+ */
+
+#define ST7565_GPIOPORT GPIOC
+#define ST7565_PORT PORTC
+#define ST7565_A0_PIN 7
+#define ST7565_RST_PIN 8
+#define ST7565_MOSI_PIN 6
+#define ST7565_SLCK_PIN 5
+#define ST7565_SS_PIN 4
+
+#define palSetPadModeRaw(portname, bits) \
+ ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
+
+#define palSetPadModeNamed(portname, portmode) \
+ palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
+
+#define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2)
+// DSPI Clock and Transfer Attributes
+// Frame Size: 8 bits
+// MSB First
+// CLK Low by default
+static const SPIConfig spi1config = {
+ NULL,
+ /* HW dependent part.*/
+ ST7565_GPIOPORT,
+ ST7565_SS_PIN,
+ SPIx_CTARn_FMSZ(7)
+ | SPIx_CTARn_ASC(7)
+ | SPIx_CTARn_DT(7)
+ | SPIx_CTARn_CSSCK(7)
+ | SPIx_CTARn_PBR(0)
+ | SPIx_CTARn_BR(7)
+ //SPI_CR1_BR_0
+};
+
+static bool_t st7565_is_data_mode = 1;
+
+static GFXINLINE void init_board(GDisplay *g) {
+ (void) g;
+ palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
+ st7565_is_data_mode = 1;
+ palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
+ palSetPadModeRaw(MOSI, ST7565_SPI_MODE);
+ palSetPadModeRaw(SLCK, ST7565_SPI_MODE);
+ palSetPadModeRaw(SS, ST7565_SPI_MODE);
+
+ spiInit();
+ spiStart(&SPID1, &spi1config);
+ spiSelect(&SPID1);
+}
+
+static GFXINLINE void post_init_board(GDisplay *g) {
+ (void) g;
+}
+
+static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
+ (void) g;
+ if (state) {
+ palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN);
+ }
+ else {
+ palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
+ }
+}
+
+static GFXINLINE void acquire_bus(GDisplay *g) {
+ (void) g;
+ // Only the LCD is using the SPI bus, so no need to acquire
+ // spiAcquireBus(&SPID1);
+}
+
+static GFXINLINE void release_bus(GDisplay *g) {
+ (void) g;
+ // Only the LCD is using the SPI bus, so no need to release
+ //spiReleaseBus(&SPID1);
+}
+
+static GFXINLINE void write_cmd(GDisplay *g, uint8_t cmd) {
+ (void) g;
+ if (st7565_is_data_mode) {
+ // The sleeps need to be at lest 10 vs 25 ns respectively
+ // So let's sleep two ticks, one tick might not be enough
+ // if we are at the end of the tick
+ chThdSleep(2);
+ palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN);
+ chThdSleep(2);
+ st7565_is_data_mode = 0;
+ }
+ spiSend(&SPID1, 1, &cmd);
+}
+
+static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
+ (void) g;
+ if (!st7565_is_data_mode) {
+ // The sleeps need to be at lest 10 vs 25 ns respectively
+ // So let's sleep two ticks, one tick might not be enough
+ // if we are at the end of the tick
+ chThdSleep(2);
+ palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
+ chThdSleep(2);
+ st7565_is_data_mode = 1;
+ }
+ spiSend(&SPID1, length, data);
+}
+
+#endif /* _GDISP_LLD_BOARD_H */
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/driver.mk b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/driver.mk
new file mode 100644
index 0000000000..889a1a0317
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/driver.mk
@@ -0,0 +1,2 @@
+GFXINC += drivers/gdisp/st7565ergodox
+GFXSRC += drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c
new file mode 100644
index 0000000000..c33aea81a8
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c
@@ -0,0 +1,292 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#include "gfx.h"
+
+#if GFX_USE_GDISP
+
+#define GDISP_DRIVER_VMT GDISPVMT_ST7565_ERGODOX
+#include "drivers/gdisp/st7565ergodox/gdisp_lld_config.h"
+#include "src/gdisp/gdisp_driver.h"
+
+#include "board_ST7565.h"
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#ifndef GDISP_SCREEN_HEIGHT
+ #define GDISP_SCREEN_HEIGHT 32
+#endif
+#ifndef GDISP_SCREEN_WIDTH
+ #define GDISP_SCREEN_WIDTH 128
+#endif
+#ifndef GDISP_INITIAL_CONTRAST
+ #define GDISP_INITIAL_CONTRAST 0
+#endif
+#ifndef GDISP_INITIAL_BACKLIGHT
+ #define GDISP_INITIAL_BACKLIGHT 100
+#endif
+
+#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
+
+#include "drivers/gdisp/st7565ergodox/st7565.h"
+
+/*===========================================================================*/
+/* Driver config defaults for backward compatibility. */
+/*===========================================================================*/
+#ifndef ST7565_LCD_BIAS
+ #define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
+#endif
+#ifndef ST7565_ADC
+ #define ST7565_ADC ST7565_ADC_NORMAL
+#endif
+#ifndef ST7565_COM_SCAN
+ #define ST7565_COM_SCAN ST7565_COM_SCAN_INC
+#endif
+#ifndef ST7565_PAGE_ORDER
+ #define ST7565_PAGE_ORDER 0,1,2,3
+#endif
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+typedef struct{
+ bool_t buffer2;
+ uint8_t ram[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8];
+}PrivData;
+
+// Some common routines and macros
+#define PRIV(g) ((PrivData*)g->priv)
+#define RAM(g) (PRIV(g)->ram)
+#define write_cmd2(g, cmd1, cmd2) { write_cmd(g, cmd1); write_cmd(g, cmd2); }
+#define write_cmd3(g, cmd1, cmd2, cmd3) { write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); }
+
+// Some common routines and macros
+#define delay(us) gfxSleepMicroseconds(us)
+#define delay_ms(ms) gfxSleepMilliseconds(ms)
+
+#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH)
+#define xybit(y) (1<<((y)&7))
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/*
+ * As this controller can't update on a pixel boundary we need to maintain the
+ * the entire display surface in memory so that we can do the necessary bit
+ * operations. Fortunately it is a small display in monochrome.
+ * 64 * 128 / 8 = 1024 bytes.
+ */
+
+LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
+ // The private area is the display surface.
+ g->priv = gfxAlloc(sizeof(PrivData));
+ PRIV(g)->buffer2 = false;
+
+ // Initialise the board interface
+ init_board(g);
+
+ // Hardware reset
+ setpin_reset(g, TRUE);
+ gfxSleepMilliseconds(20);
+ setpin_reset(g, FALSE);
+ gfxSleepMilliseconds(20);
+
+ acquire_bus(g);
+ write_cmd(g, ST7565_DISPLAY_OFF);
+ write_cmd(g, ST7565_LCD_BIAS);
+ write_cmd(g, ST7565_ADC);
+ write_cmd(g, ST7565_COM_SCAN);
+
+ write_cmd(g, ST7565_START_LINE | 0);
+
+ write_cmd(g, ST7565_RESISTOR_RATIO | 0x6);
+
+ // turn on voltage converter (VC=1, VR=0, VF=0)
+ write_cmd(g, ST7565_POWER_CONTROL | 0x04);
+ delay_ms(50);
+
+ // turn on voltage regulator (VC=1, VR=1, VF=0)
+ write_cmd(g, ST7565_POWER_CONTROL | 0x06);
+ delay_ms(50);
+
+ // turn on voltage follower (VC=1, VR=1, VF=1)
+ write_cmd(g, ST7565_POWER_CONTROL | 0x07);
+ delay_ms(50);
+
+ write_cmd(g, 0xE2);
+ write_cmd(g, ST7565_COM_SCAN);
+ write_cmd2(g, ST7565_CONTRAST, GDISP_INITIAL_CONTRAST*64/101);
+ //write_cmd2(g, ST7565_CONTRAST, 0);
+ write_cmd(g, ST7565_DISPLAY_ON);
+ write_cmd(g, ST7565_ALLON_NORMAL);
+ write_cmd(g, ST7565_INVERT_DISPLAY);
+
+ write_cmd(g, ST7565_RMW);
+
+ // Finish Init
+ post_init_board(g);
+
+ // Release the bus
+ release_bus(g);
+
+ /* Initialise the GDISP structure */
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Orientation = GDISP_ROTATE_0;
+ g->g.Powermode = powerOn;
+ g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
+ g->g.Contrast = GDISP_INITIAL_CONTRAST;
+ return TRUE;
+}
+
+#if GDISP_HARDWARE_FLUSH
+ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
+ unsigned p;
+
+ // Don't flush if we don't need it.
+ if (!(g->flags & GDISP_FLG_NEEDFLUSH))
+ return;
+
+ acquire_bus(g);
+ unsigned dstOffset = (PRIV(g)->buffer2 ? 4 : 0);
+ for (p = 0; p < 4; p++) {
+ write_cmd(g, ST7565_PAGE | (p + dstOffset));
+ write_cmd(g, ST7565_COLUMN_MSB | 0);
+ write_cmd(g, ST7565_COLUMN_LSB | 0);
+ write_cmd(g, ST7565_RMW);
+ write_data(g, RAM(g) + (p*GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH);
+ }
+ unsigned line = (PRIV(g)->buffer2 ? 32 : 0);
+ write_cmd(g, ST7565_START_LINE | line);
+ PRIV(g)->buffer2 = !PRIV(g)->buffer2;
+ release_bus(g);
+
+ g->flags &= ~GDISP_FLG_NEEDFLUSH;
+ }
+#endif
+
+#if GDISP_HARDWARE_DRAWPIXEL
+ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
+ coord_t x, y;
+
+ switch(g->g.Orientation) {
+ default:
+ case GDISP_ROTATE_0:
+ x = g->p.x;
+ y = g->p.y;
+ break;
+ case GDISP_ROTATE_90:
+ x = g->p.y;
+ y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
+ break;
+ case GDISP_ROTATE_180:
+ x = GDISP_SCREEN_WIDTH-1 - g->p.x;
+ y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
+ break;
+ case GDISP_ROTATE_270:
+ x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
+ y = g->p.x;
+ break;
+ }
+ if (gdispColor2Native(g->p.color) != Black)
+ RAM(g)[xyaddr(x, y)] |= xybit(y);
+ else
+ RAM(g)[xyaddr(x, y)] &= ~xybit(y);
+ g->flags |= GDISP_FLG_NEEDFLUSH;
+ }
+#endif
+
+#if GDISP_HARDWARE_PIXELREAD
+ LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
+ coord_t x, y;
+
+ switch(g->g.Orientation) {
+ default:
+ case GDISP_ROTATE_0:
+ x = g->p.x;
+ y = g->p.y;
+ break;
+ case GDISP_ROTATE_90:
+ x = g->p.y;
+ y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
+ break;
+ case GDISP_ROTATE_180:
+ x = GDISP_SCREEN_WIDTH-1 - g->p.x;
+ y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
+ break;
+ case GDISP_ROTATE_270:
+ x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
+ y = g->p.x;
+ break;
+ }
+ return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? White : Black;
+ }
+#endif
+
+#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
+ LLDSPEC void gdisp_lld_control(GDisplay *g) {
+ switch(g->p.x) {
+ case GDISP_CONTROL_POWER:
+ if (g->g.Powermode == (powermode_t)g->p.ptr)
+ return;
+ switch((powermode_t)g->p.ptr) {
+ case powerOff:
+ case powerSleep:
+ case powerDeepSleep:
+ acquire_bus(g);
+ write_cmd(g, ST7565_DISPLAY_OFF);
+ release_bus(g);
+ break;
+ case powerOn:
+ acquire_bus(g);
+ write_cmd(g, ST7565_DISPLAY_ON);
+ release_bus(g);
+ break;
+ default:
+ return;
+ }
+ g->g.Powermode = (powermode_t)g->p.ptr;
+ return;
+
+ case GDISP_CONTROL_ORIENTATION:
+ if (g->g.Orientation == (orientation_t)g->p.ptr)
+ return;
+ switch((orientation_t)g->p.ptr) {
+ /* Rotation is handled by the drawing routines */
+ case GDISP_ROTATE_0:
+ case GDISP_ROTATE_180:
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+ case GDISP_ROTATE_90:
+ case GDISP_ROTATE_270:
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+ default:
+ return;
+ }
+ g->g.Orientation = (orientation_t)g->p.ptr;
+ return;
+
+ case GDISP_CONTROL_CONTRAST:
+ if ((unsigned)g->p.ptr > 100)
+ g->p.ptr = (void *)100;
+ acquire_bus(g);
+ write_cmd2(g, ST7565_CONTRAST, ((((unsigned)g->p.ptr)<<6)/101) & 0x3F);
+ release_bus(g);
+ g->g.Contrast = (unsigned)g->p.ptr;
+ return;
+ }
+ }
+#endif // GDISP_NEED_CONTROL
+
+#endif // GFX_USE_GDISP
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_config.h b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_config.h
new file mode 100644
index 0000000000..48587b9e14
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/gdisp_lld_config.h
@@ -0,0 +1,26 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _GDISP_LLD_CONFIG_H
+#define _GDISP_LLD_CONFIG_H
+
+#if GFX_USE_GDISP
+
+/*===========================================================================*/
+/* Driver hardware support. */
+/*===========================================================================*/
+
+#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
+#define GDISP_HARDWARE_DRAWPIXEL TRUE
+#define GDISP_HARDWARE_PIXELREAD TRUE
+#define GDISP_HARDWARE_CONTROL TRUE
+
+#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
+
+#endif /* GFX_USE_GDISP */
+
+#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/st7565.h b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/st7565.h
new file mode 100644
index 0000000000..48636b33d6
--- /dev/null
+++ b/keyboards/infinity_ergodox/drivers/gdisp/st7565ergodox/st7565.h
@@ -0,0 +1,37 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _ST7565_H
+#define _ST7565_H
+
+#define ST7565_CONTRAST 0x81
+#define ST7565_ALLON_NORMAL 0xA4
+#define ST7565_ALLON 0xA5
+#define ST7565_POSITIVE_DISPLAY 0xA6
+#define ST7565_INVERT_DISPLAY 0xA7
+#define ST7565_DISPLAY_OFF 0xAE
+#define ST7565_DISPLAY_ON 0xAF
+
+#define ST7565_LCD_BIAS_7 0xA3
+#define ST7565_LCD_BIAS_9 0xA2
+
+#define ST7565_ADC_NORMAL 0xA0
+#define ST7565_ADC_REVERSE 0xA1
+
+#define ST7565_COM_SCAN_INC 0xC0
+#define ST7565_COM_SCAN_DEC 0xC8
+
+#define ST7565_START_LINE 0x40
+#define ST7565_PAGE 0xB0
+#define ST7565_COLUMN_MSB 0x10
+#define ST7565_COLUMN_LSB 0x00
+#define ST7565_RMW 0xE0
+
+#define ST7565_RESISTOR_RATIO 0x20
+#define ST7565_POWER_CONTROL 0x28
+
+#endif /* _ST7565_H */
diff --git a/keyboards/infinity_ergodox/gfxconf.h b/keyboards/infinity_ergodox/gfxconf.h
new file mode 100644
index 0000000000..8caa577b73
--- /dev/null
+++ b/keyboards/infinity_ergodox/gfxconf.h
@@ -0,0 +1,331 @@
+/**
+ * This file has a different license to the rest of the uGFX system.
+ * You can copy, modify and distribute this file as you see fit.
+ * You do not need to publish your source modifications to this file.
+ * The only thing you are not permitted to do is to relicense it
+ * under a different license.
+ */
+
+/**
+ * Copy this file into your project directory and rename it as gfxconf.h
+ * Edit your copy to turn on the uGFX features you want to use.
+ * The values below are the defaults.
+ *
+ * Only remove the comments from lines where you want to change the
+ * default value. This allows definitions to be included from
+ * driver makefiles when required and provides the best future
+ * compatibility for your project.
+ *
+ * Please use spaces instead of tabs in this file.
+ */
+
+#ifndef _GFXCONF_H
+#define _GFXCONF_H
+
+
+///////////////////////////////////////////////////////////////////////////
+// GOS - One of these must be defined, preferably in your Makefile //
+///////////////////////////////////////////////////////////////////////////
+//#define GFX_USE_OS_CHIBIOS TRUE
+//#define GFX_USE_OS_FREERTOS FALSE
+// #define GFX_FREERTOS_USE_TRACE FALSE
+//#define GFX_USE_OS_WIN32 FALSE
+//#define GFX_USE_OS_LINUX FALSE
+//#define GFX_USE_OS_OSX FALSE
+//#define GFX_USE_OS_ECOS FALSE
+//#define GFX_USE_OS_RAWRTOS FALSE
+//#define GFX_USE_OS_ARDUINO FALSE
+//#define GFX_USE_OS_KEIL FALSE
+//#define GFX_USE_OS_CMSIS FALSE
+//#define GFX_USE_OS_RAW32 FALSE
+// #define INTERRUPTS_OFF() optional_code
+// #define INTERRUPTS_ON() optional_code
+// These are not defined by default for some reason
+#define GOS_NEED_X_THREADS FALSE
+#define GOS_NEED_X_HEAP FALSE
+
+// Options that (should where relevant) apply to all operating systems
+ #define GFX_NO_INLINE FALSE
+// #define GFX_COMPILER GFX_COMPILER_UNKNOWN
+// #define GFX_CPU GFX_CPU_UNKNOWN
+// #define GFX_OS_HEAP_SIZE 0
+// #define GFX_OS_NO_INIT FALSE
+// #define GFX_OS_INIT_NO_WARNING FALSE
+// #define GFX_OS_PRE_INIT_FUNCTION myHardwareInitRoutine
+// #define GFX_OS_EXTRA_INIT_FUNCTION myOSInitRoutine
+// #define GFX_OS_EXTRA_DEINIT_FUNCTION myOSDeInitRoutine
+
+
+///////////////////////////////////////////////////////////////////////////
+// GDISP //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GDISP TRUE
+
+//#define GDISP_NEED_AUTOFLUSH FALSE
+//#define GDISP_NEED_TIMERFLUSH FALSE
+//#define GDISP_NEED_VALIDATION TRUE
+//#define GDISP_NEED_CLIP TRUE
+#define GDISP_NEED_CIRCLE TRUE
+#define GDISP_NEED_ELLIPSE TRUE
+#define GDISP_NEED_ARC TRUE
+#define GDISP_NEED_ARCSECTORS TRUE
+#define GDISP_NEED_CONVEX_POLYGON TRUE
+//#define GDISP_NEED_SCROLL FALSE
+#define GDISP_NEED_PIXELREAD TRUE
+#define GDISP_NEED_CONTROL TRUE
+//#define GDISP_NEED_QUERY FALSE
+//#define GDISP_NEED_MULTITHREAD FALSE
+//#define GDISP_NEED_STREAMING FALSE
+#define GDISP_NEED_TEXT TRUE
+// #define GDISP_NEED_TEXT_WORDWRAP FALSE
+// #define GDISP_NEED_ANTIALIAS FALSE
+// #define GDISP_NEED_UTF8 FALSE
+ #define GDISP_NEED_TEXT_KERNING TRUE
+// #define GDISP_INCLUDE_FONT_UI1 FALSE
+// #define GDISP_INCLUDE_FONT_UI2 FALSE // The smallest preferred font.
+// #define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS10 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS12 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS16 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS20 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE
+ #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 TRUE
+// #define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE
+// #define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE
+ #define GDISP_INCLUDE_FONT_FIXED_5X8 TRUE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA FALSE
+// #define GDISP_INCLUDE_USER_FONTS FALSE
+
+//#define GDISP_NEED_IMAGE FALSE
+// #define GDISP_NEED_IMAGE_NATIVE FALSE
+// #define GDISP_NEED_IMAGE_GIF FALSE
+// #define GDISP_NEED_IMAGE_BMP FALSE
+// #define GDISP_NEED_IMAGE_BMP_1 FALSE
+// #define GDISP_NEED_IMAGE_BMP_4 FALSE
+// #define GDISP_NEED_IMAGE_BMP_4_RLE FALSE
+// #define GDISP_NEED_IMAGE_BMP_8 FALSE
+// #define GDISP_NEED_IMAGE_BMP_8_RLE FALSE
+// #define GDISP_NEED_IMAGE_BMP_16 FALSE
+// #define GDISP_NEED_IMAGE_BMP_24 FALSE
+// #define GDISP_NEED_IMAGE_BMP_32 FALSE
+// #define GDISP_NEED_IMAGE_JPG FALSE
+// #define GDISP_NEED_IMAGE_PNG FALSE
+// #define GDISP_NEED_IMAGE_ACCOUNTING FALSE
+#ifdef EMULATOR
+#define GDISP_NEED_PIXMAP TRUE
+#endif
+// #define GDISP_NEED_PIXMAP_IMAGE FALSE
+
+//#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE // If not defined the native hardware orientation is used.
+//#define GDISP_LINEBUF_SIZE 128
+//#define GDISP_STARTUP_COLOR Black
+#define GDISP_NEED_STARTUP_LOGO FALSE
+
+//#define GDISP_TOTAL_DISPLAYS 2
+
+#ifndef EMULATOR
+#define GDISP_DRIVER_LIST GDISPVMT_ST7565_ERGODOX, GDISPVMT_IS31FL3731C_ERGODOX
+#else
+#define GDISP_DRIVER_LIST GDISPVMT_EMULATOR_LCD_ERGODOX, GDISPVMT_EMULATOR_LED_ERGODOX
+#endif
+
+ #ifdef GDISP_DRIVER_LIST
+ // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
+ #define GDISP_HARDWARE_STREAM_WRITE FALSE
+ #define GDISP_HARDWARE_STREAM_READ FALSE
+ #define GDISP_HARDWARE_STREAM_POS FALSE
+ #define GDISP_HARDWARE_DRAWPIXEL TRUE
+ #define GDISP_HARDWARE_CLEARS FALSE
+ #define GDISP_HARDWARE_FILLS FALSE
+ #define GDISP_HARDWARE_BITFILLS FALSE
+ #define GDISP_HARDWARE_SCROLL FALSE
+ #define GDISP_HARDWARE_PIXELREAD TRUE
+ #define GDISP_HARDWARE_CONTROL TRUE
+ #define GDISP_HARDWARE_QUERY FALSE
+ #define GDISP_HARDWARE_CLIP FALSE
+
+ #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
+ #endif
+
+// The custom format is not defined for some reason, so define it as error
+// so we don't get compiler warnings
+#define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR
+
+#define GDISP_USE_GFXNET FALSE
+// #define GDISP_GFXNET_PORT 13001
+// #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
+// #define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
+// #define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
+
+
+///////////////////////////////////////////////////////////////////////////
+// GWIN //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GWIN FALSE
+
+//#define GWIN_NEED_WINDOWMANAGER FALSE
+// #define GWIN_REDRAW_IMMEDIATE FALSE
+// #define GWIN_REDRAW_SINGLEOP FALSE
+// #define GWIN_NEED_FLASHING FALSE
+// #define GWIN_FLASHING_PERIOD 250
+
+//#define GWIN_NEED_CONSOLE FALSE
+// #define GWIN_CONSOLE_USE_HISTORY FALSE
+// #define GWIN_CONSOLE_HISTORY_AVERAGING FALSE
+// #define GWIN_CONSOLE_HISTORY_ATCREATE FALSE
+// #define GWIN_CONSOLE_ESCSEQ FALSE
+// #define GWIN_CONSOLE_USE_BASESTREAM FALSE
+// #define GWIN_CONSOLE_USE_FLOAT FALSE
+//#define GWIN_NEED_GRAPH FALSE
+//#define GWIN_NEED_GL3D FALSE
+
+//#define GWIN_NEED_WIDGET FALSE
+//#define GWIN_FOCUS_HIGHLIGHT_WIDTH 1
+// #define GWIN_NEED_LABEL FALSE
+// #define GWIN_LABEL_ATTRIBUTE FALSE
+// #define GWIN_NEED_BUTTON FALSE
+// #define GWIN_BUTTON_LAZY_RELEASE FALSE
+// #define GWIN_NEED_SLIDER FALSE
+// #define GWIN_SLIDER_NOSNAP FALSE
+// #define GWIN_SLIDER_DEAD_BAND 5
+// #define GWIN_SLIDER_TOGGLE_INC 20
+// #define GWIN_NEED_CHECKBOX FALSE
+// #define GWIN_NEED_IMAGE FALSE
+// #define GWIN_NEED_IMAGE_ANIMATION FALSE
+// #define GWIN_NEED_RADIO FALSE
+// #define GWIN_NEED_LIST FALSE
+// #define GWIN_NEED_LIST_IMAGES FALSE
+// #define GWIN_NEED_PROGRESSBAR FALSE
+// #define GWIN_PROGRESSBAR_AUTO FALSE
+// #define GWIN_NEED_KEYBOARD FALSE
+// #define GWIN_KEYBOARD_DEFAULT_LAYOUT VirtualKeyboard_English1
+// #define GWIN_NEED_KEYBOARD_ENGLISH1 TRUE
+// #define GWIN_NEED_TEXTEDIT FALSE
+// #define GWIN_FLAT_STYLING FALSE
+// #define GWIN_WIDGET_TAGS FALSE
+
+//#define GWIN_NEED_CONTAINERS FALSE
+// #define GWIN_NEED_CONTAINER FALSE
+// #define GWIN_NEED_FRAME FALSE
+// #define GWIN_NEED_TABSET FALSE
+// #define GWIN_TABSET_TABHEIGHT 18
+
+
+///////////////////////////////////////////////////////////////////////////
+// GEVENT //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GEVENT TRUE
+
+//#define GEVENT_ASSERT_NO_RESOURCE FALSE
+//#define GEVENT_MAXIMUM_SIZE 32
+//#define GEVENT_MAX_SOURCE_LISTENERS 32
+
+
+///////////////////////////////////////////////////////////////////////////
+// GTIMER //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GTIMER FALSE
+
+//#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
+//#define GTIMER_THREAD_WORKAREA_SIZE 2048
+
+
+///////////////////////////////////////////////////////////////////////////
+// GQUEUE //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GQUEUE FALSE
+
+//#define GQUEUE_NEED_ASYNC FALSE
+//#define GQUEUE_NEED_GSYNC FALSE
+//#define GQUEUE_NEED_FSYNC FALSE
+//#define GQUEUE_NEED_BUFFERS FALSE
+
+///////////////////////////////////////////////////////////////////////////
+// GINPUT //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GINPUT FALSE
+
+//#define GINPUT_NEED_MOUSE FALSE
+// #define GINPUT_TOUCH_STARTRAW FALSE
+// #define GINPUT_TOUCH_NOTOUCH FALSE
+// #define GINPUT_TOUCH_NOCALIBRATE FALSE
+// #define GINPUT_TOUCH_NOCALIBRATE_GUI FALSE
+// #define GINPUT_MOUSE_POLL_PERIOD 25
+// #define GINPUT_MOUSE_CLICK_TIME 300
+// #define GINPUT_TOUCH_CXTCLICK_TIME 700
+// #define GINPUT_TOUCH_USER_CALIBRATION_LOAD FALSE
+// #define GINPUT_TOUCH_USER_CALIBRATION_SAVE FALSE
+// #define GMOUSE_DRIVER_LIST GMOUSEVMT_Win32, GMOUSEVMT_Win32
+//#define GINPUT_NEED_KEYBOARD FALSE
+// #define GINPUT_KEYBOARD_POLL_PERIOD 200
+// #define GKEYBOARD_DRIVER_LIST GKEYBOARDVMT_Win32, GKEYBOARDVMT_Win32
+// #define GKEYBOARD_LAYOUT_OFF FALSE
+// #define GKEYBOARD_LAYOUT_SCANCODE2_US FALSE
+//#define GINPUT_NEED_TOGGLE FALSE
+//#define GINPUT_NEED_DIAL FALSE
+
+
+///////////////////////////////////////////////////////////////////////////
+// GFILE //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GFILE FALSE
+
+//#define GFILE_NEED_PRINTG FALSE
+//#define GFILE_NEED_SCANG FALSE
+//#define GFILE_NEED_STRINGS FALSE
+//#define GFILE_NEED_FILELISTS FALSE
+//#define GFILE_NEED_STDIO FALSE
+//#define GFILE_NEED_NOAUTOMOUNT FALSE
+//#define GFILE_NEED_NOAUTOSYNC FALSE
+
+//#define GFILE_NEED_MEMFS FALSE
+//#define GFILE_NEED_ROMFS FALSE
+//#define GFILE_NEED_RAMFS FALSE
+//#define GFILE_NEED_FATFS FALSE
+//#define GFILE_NEED_NATIVEFS FALSE
+//#define GFILE_NEED_CHBIOSFS FALSE
+
+//#define GFILE_ALLOW_FLOATS FALSE
+//#define GFILE_ALLOW_DEVICESPECIFIC FALSE
+//#define GFILE_MAX_GFILES 3
+
+///////////////////////////////////////////////////////////////////////////
+// GADC //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GADC FALSE
+
+//#define GADC_MAX_LOWSPEED_DEVICES 4
+
+
+///////////////////////////////////////////////////////////////////////////
+// GAUDIO //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GAUDIO FALSE
+// There seems to be a bug in the ugfx code, the wrong define is used
+// So define it in order to avoid warnings
+#define GFX_USE_GAUDIN GFX_USE_GAUDIO
+// #define GAUDIO_NEED_PLAY FALSE
+// #define GAUDIO_NEED_RECORD FALSE
+
+
+///////////////////////////////////////////////////////////////////////////
+// GMISC //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GMISC TRUE
+
+//#define GMISC_NEED_ARRAYOPS FALSE
+//#define GMISC_NEED_FASTTRIG FALSE
+//#define GMISC_NEED_FIXEDTRIG FALSE
+//#define GMISC_NEED_INVSQRT FALSE
+// #define GMISC_INVSQRT_MIXED_ENDIAN FALSE
+// #define GMISC_INVSQRT_REAL_SLOW FALSE
+#define GMISC_NEED_MATRIXFLOAT2D TRUE
+#define GMISC_NEED_MATRIXFIXED2D FALSE
+
+#endif /* _GFXCONF_H */
diff --git a/keyboards/infinity_ergodox/halconf.h b/keyboards/infinity_ergodox/halconf.h
new file mode 100644
index 0000000000..55dd5e88da
--- /dev/null
+++ b/keyboards/infinity_ergodox/halconf.h
@@ -0,0 +1,353 @@
+/*
+ ChibiOS - Copyright (C) 2006..2015 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_
+
+#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 DAC subsystem.
+ */
+#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
+#define HAL_USE_DAC FALSE
+#endif
+
+/**
+ * @brief Enables the EXT subsystem.
+ */
+#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
+#define HAL_USE_EXT FALSE
+#endif
+
+/**
+ * @brief Enables the GPT subsystem.
+ */
+#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
+#define HAL_USE_GPT FALSE
+#endif
+
+/**
+ * @brief Enables the I2C subsystem.
+ */
+#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
+#define HAL_USE_I2C TRUE
+#endif
+
+/**
+ * @brief Enables the I2S subsystem.
+ */
+#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
+#define HAL_USE_I2S FALSE
+#endif
+
+/**
+ * @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 TRUE
+#endif
+
+/**
+ * @brief Enables the SERIAL over USB subsystem.
+ */
+#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
+#define HAL_USE_SERIAL_USB TRUE
+#endif
+
+/**
+ * @brief Enables the SPI subsystem.
+ */
+#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
+#define HAL_USE_SPI TRUE
+#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
+
+/*===========================================================================*/
+/* 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
+
+/*===========================================================================*/
+/* 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 an event sources for incoming packets.
+ */
+#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
+
+/*===========================================================================*/
+/* 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 64 bytes for both the transmission and receive
+ * buffers.
+ */
+#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
+#define SERIAL_BUFFERS_SIZE 128
+#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 64 bytes for both the transmission and receive
+ * buffers.
+ */
+#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
+#define SERIAL_USB_BUFFERS_SIZE 256
+#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 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
+
+/*===========================================================================*/
+/* 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
+
+#endif /* _HALCONF_H_ */
+
+/** @} */
diff --git a/keyboards/infinity_ergodox/infinity_ergodox.c b/keyboards/infinity_ergodox/infinity_ergodox.c
new file mode 100644
index 0000000000..87ed40fabf
--- /dev/null
+++ b/keyboards/infinity_ergodox/infinity_ergodox.c
@@ -0,0 +1,76 @@
+#include "infinity_ergodox.h"
+#include "ch.h"
+#include "hal.h"
+#include "serial_link/system/serial_link.h"
+#include "lcd_backlight.h"
+
+void init_serial_link_hal(void) {
+ PORTA->PCR[1] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(2);
+ PORTA->PCR[2] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(2);
+ PORTE->PCR[0] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(3);
+ PORTE->PCR[1] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(3);
+}
+
+#define RED_PIN 1
+#define GREEN_PIN 2
+#define BLUE_PIN 3
+#define CHANNEL_RED FTM0->CHANNEL[0]
+#define CHANNEL_GREEN FTM0->CHANNEL[1]
+#define CHANNEL_BLUE FTM0->CHANNEL[2]
+
+#define RGB_PORT PORTC
+#define RGB_PORT_GPIO GPIOC
+
+// Base FTM clock selection (72 MHz system clock)
+// @ 0xFFFF period, 72 MHz / (0xFFFF * 2) = Actual period
+// Higher pre-scalar will use the most power (also look the best)
+// Pre-scalar calculations
+// 0 - 72 MHz -> 549 Hz
+// 1 - 36 MHz -> 275 Hz
+// 2 - 18 MHz -> 137 Hz
+// 3 - 9 MHz -> 69 Hz (Slightly visible flicker)
+// 4 - 4 500 kHz -> 34 Hz (Visible flickering)
+// 5 - 2 250 kHz -> 17 Hz
+// 6 - 1 125 kHz -> 9 Hz
+// 7 - 562 500 Hz -> 4 Hz
+// Using a higher pre-scalar without flicker is possible but FTM0_MOD will need to be reduced
+// Which will reduce the brightness range
+#define PRESCALAR_DEFINE 0
+
+void lcd_backlight_hal_init(void) {
+ // Setup Backlight
+ SIM->SCGC6 |= SIM_SCGC6_FTM0;
+ FTM0->CNT = 0; // Reset counter
+
+ // PWM Period
+ // 16-bit maximum
+ FTM0->MOD = 0xFFFF;
+
+ // Set FTM to PWM output - Edge Aligned, Low-true pulses
+#define CNSC_MODE FTM_SC_CPWMS | FTM_SC_PS(4) | FTM_SC_CLKS(0)
+ CHANNEL_RED.CnSC = CNSC_MODE;
+ CHANNEL_GREEN.CnSC = CNSC_MODE;
+ CHANNEL_BLUE.CnSC = CNSC_MODE;
+
+ // System clock, /w prescalar setting
+ FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(PRESCALAR_DEFINE);
+
+ CHANNEL_RED.CnV = 0;
+ CHANNEL_GREEN.CnV = 0;
+ CHANNEL_BLUE.CnV = 0;
+
+ RGB_PORT_GPIO->PDDR |= (1 << RED_PIN);
+ RGB_PORT_GPIO->PDDR |= (1 << GREEN_PIN);
+ RGB_PORT_GPIO->PDDR |= (1 << BLUE_PIN);
+
+#define RGB_MODE PORTx_PCRn_SRE | PORTx_PCRn_DSE | PORTx_PCRn_MUX(4)
+ RGB_PORT->PCR[RED_PIN] = RGB_MODE;
+ RGB_PORT->PCR[GREEN_PIN] = RGB_MODE;
+ RGB_PORT->PCR[BLUE_PIN] = RGB_MODE;
+}
+
+void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) {
+ CHANNEL_RED.CnV = r;
+ CHANNEL_GREEN.CnV = g;
+ CHANNEL_BLUE.CnV = b;
+}
diff --git a/keyboards/infinity_ergodox/infinity_ergodox.h b/keyboards/infinity_ergodox/infinity_ergodox.h
new file mode 100644
index 0000000000..de72675946
--- /dev/null
+++ b/keyboards/infinity_ergodox/infinity_ergodox.h
@@ -0,0 +1,44 @@
+#ifndef KEYBOARDS_INFINITY_ERGODOX_INFINITY_ERGODOX_H_
+#define KEYBOARDS_INFINITY_ERGODOX_INFINITY_ERGODOX_H_
+
+#include "quantum.h"
+
+#define KEYMAP( \
+ A80, A70, A60, A50, A40, A30, A20, \
+ A81, A71, A61, A51, A41, A31, A21, \
+ A82, A72, A62, A52, A42, A32, \
+ A83, A73, A63, A53, A43, A33, A23, \
+ A84, A74, A64, A54, A44, \
+ A13, A03, \
+ A04, \
+ A34, A24, A14, \
+ B20, B30, B40, B50, B60, B70, B80, \
+ B21, B31, B41, B51, B61, B71, B81, \
+ B32, B42, B52, B62, B72, B82, \
+ B23, B33, B43, B53, B63, B73, B83, \
+ B44, B54, B64, B74, B84, \
+ B03, B13, \
+ B04, \
+ B14, B24, B34 \
+) { \
+ { KC_NO, KC_NO, KC_NO, KC_##A03, KC_##A04 }, \
+ { KC_NO, KC_NO, KC_NO, KC_##A13, KC_##A14 }, \
+ { KC_##A20, KC_##A21, KC_NO, KC_##A23, KC_##A24 }, \
+ { KC_##A30, KC_##A31, KC_##A32, KC_##A33, KC_##A34 }, \
+ { KC_##A40, KC_##A41, KC_##A42, KC_##A43, KC_##A44 }, \
+ { KC_##A50, KC_##A51, KC_##A52, KC_##A53, KC_##A54 }, \
+ { KC_##A60, KC_##A61, KC_##A62, KC_##A63, KC_##A64 }, \
+ { KC_##A70, KC_##A71, KC_##A72, KC_##A73, KC_##A74 }, \
+ { KC_##A80, KC_##A81, KC_##A82, KC_##A83, KC_##A84 }, \
+ { KC_NO, KC_NO, KC_NO, KC_##B03, KC_##B04 }, \
+ { KC_NO, KC_NO, KC_NO, KC_##B13, KC_##B14 }, \
+ { KC_##B20, KC_##B21, KC_NO, KC_##B23, KC_##B24 }, \
+ { KC_##B30, KC_##B31, KC_##B32, KC_##B33, KC_##B34 }, \
+ { KC_##B40, KC_##B41, KC_##B42, KC_##B43, KC_##B44 }, \
+ { KC_##B50, KC_##B51, KC_##B52, KC_##B53, KC_##B54 }, \
+ { KC_##B60, KC_##B61, KC_##B62, KC_##B63, KC_##B64 }, \
+ { KC_##B70, KC_##B71, KC_##B72, KC_##B73, KC_##B74 }, \
+ { KC_##B80, KC_##B81, KC_##B82, KC_##B83, KC_##B84 } \
+}
+
+#endif /* KEYBOARDS_INFINITY_ERGODOX_INFINITY_ERGODOX_H_ */
diff --git a/keyboards/infinity_ergodox/keymaps/default/keymap.c b/keyboards/infinity_ergodox/keymaps/default/keymap.c
new file mode 100644
index 0000000000..f1e6b1c8ae
--- /dev/null
+++ b/keyboards/infinity_ergodox/keymaps/default/keymap.c
@@ -0,0 +1,114 @@
+/*
+Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
+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 "infinity_ergodox.h"
+
+// Workaround for old keymap format
+#define KC_RESET RESET
+
+const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ KEYMAP( // layer 0 : default
+ // left hand
+ EQL, 1, 2, 3, 4, 5, ESC,
+ BSLS,Q, W, E, R, T, FN1,
+ TAB, A, S, D, F, G,
+ LSFT,Z, X, C, V, B, FN0,
+ LGUI,GRV, BSLS,LEFT,RGHT,
+ LCTL,LALT,
+ HOME,
+ BSPC,DEL, END,
+ // right hand
+ FN2, 6, 7, 8, 9, 0, MINS,
+ LBRC,Y, U, I, O, P, RBRC,
+ H, J, K, L, SCLN,QUOT,
+ FN0, N, M, COMM,DOT, SLSH,RSFT,
+ LEFT,DOWN,UP, RGHT,RGUI,
+ RALT,RCTL,
+ PGUP,
+ PGDN,ENT, SPC
+ ),
+
+ KEYMAP( // layer 1 : function and symbol keys
+ // left hand
+ TRNS,F1, F2, F3, F4, F5, F11,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN3,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,
+ TRNS,
+ TRNS,TRNS,TRNS,
+ // right hand
+ F12, F6, F7, F8, F9, F10, TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,
+ TRNS,
+ TRNS,TRNS,TRNS
+ ),
+
+ KEYMAP( // layer 2 : keyboard functions
+ // left hand
+ RESET,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, FN3,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,
+ TRNS,
+ TRNS,TRNS,TRNS,
+ // right hand
+ TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,
+ TRNS,
+ TRNS,TRNS,TRNS
+ ),
+
+ KEYMAP( // layer 3: numpad
+ // left hand
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,TRNS,TRNS,TRNS,
+ TRNS,TRNS,
+ TRNS,
+ TRNS,TRNS,TRNS,
+ // right hand
+ TRNS,NLCK,PSLS,PAST,PAST,PMNS,BSPC,
+ TRNS,NO, P7, P8, P9, PMNS,BSPC,
+ NO, P4, P5, P6, PPLS,PENT,
+ TRNS,NO, P1, P2, P3, PPLS,PENT,
+ P0, PDOT,SLSH,PENT,PENT,
+ TRNS,TRNS,
+ TRNS,
+ TRNS,TRNS,TRNS
+ ),
+};
+const uint16_t fn_actions[] = {
+ ACTION_LAYER_MOMENTARY(1), // FN0 - switch to Layer1
+ ACTION_LAYER_SET(2, ON_PRESS), // FN1 - set Layer2
+ ACTION_LAYER_TOGGLE(3), // FN2 - toggle Layer3 aka Numpad layer
+ ACTION_LAYER_SET(0, ON_PRESS), // FN3 - set Layer0
+};
diff --git a/keyboards/infinity_ergodox/keymaps/default/visualizer.c b/keyboards/infinity_ergodox/keymaps/default/visualizer.c
new file mode 100644
index 0000000000..c0d335ce6a
--- /dev/null
+++ b/keyboards/infinity_ergodox/keymaps/default/visualizer.c
@@ -0,0 +1,168 @@
+/*
+Copyright 2016 Fred Sundvik <fsundvik@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/>.
+*/
+
+// Currently we are assuming that both the backlight and LCD are enabled
+// But it's entirely possible to write a custom visualizer that use only
+// one of them
+#ifndef LCD_BACKLIGHT_ENABLE
+#error This visualizer needs that LCD backlight is enabled
+#endif
+
+#ifndef LCD_ENABLE
+#error This visualizer needs that LCD is enabled
+#endif
+
+#include "visualizer.h"
+#include "led_test.h"
+
+static const char* welcome_text[] = {"TMK", "Infinity Ergodox"};
+
+// Just an example how to write custom keyframe functions, we could have moved
+// all this into the init function
+bool display_welcome(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ // Read the uGFX documentation for information how to use the displays
+ // http://wiki.ugfx.org/index.php/Main_Page
+ gdispClear(White);
+ // You can use static variables for things that can't be found in the animation
+ // or state structs
+ gdispDrawString(0, 3, welcome_text[0], state->font_dejavusansbold12, Black);
+ gdispDrawString(0, 15, welcome_text[1], state->font_dejavusansbold12, Black);
+ // Always remember to flush the display
+ gdispFlush();
+ // you could set the backlight color as well, but we won't do it here, since
+ // it's part of the following animation
+ // lcd_backlight_color(hue, saturation, intensity);
+ // We don't need constant updates, just drawing the screen once is enough
+ return false;
+}
+
+// Feel free to modify the animations below, or even add new ones if needed
+
+// Don't worry, if the startup animation is long, you can use the keyboard like normal
+// during that time
+static keyframe_animation_t startup_animation = {
+ .num_frames = 4,
+ .loop = false,
+ .frame_lengths = {0, gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(5000), 0},
+ .frame_functions = {
+ display_welcome,
+ keyframe_animate_backlight_color,
+ keyframe_no_operation,
+ enable_visualization
+ },
+};
+
+// The color animation animates the LCD color when you change layers
+static keyframe_animation_t color_animation = {
+ .num_frames = 2,
+ .loop = false,
+ // Note that there's a 200 ms no-operation frame,
+ // this prevents the color from changing when activating the layer
+ // momentarily
+ .frame_lengths = {gfxMillisecondsToTicks(200), gfxMillisecondsToTicks(500)},
+ .frame_functions = {keyframe_no_operation, keyframe_animate_backlight_color},
+};
+
+// The LCD animation alternates between the layer name display and a
+// bitmap that displays all active layers
+static keyframe_animation_t lcd_animation = {
+ .num_frames = 2,
+ .loop = true,
+ .frame_lengths = {gfxMillisecondsToTicks(2000), gfxMillisecondsToTicks(2000)},
+ .frame_functions = {keyframe_display_layer_text, keyframe_display_layer_bitmap},
+};
+
+static keyframe_animation_t suspend_animation = {
+ .num_frames = 3,
+ .loop = false,
+ .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0},
+ .frame_functions = {
+ keyframe_display_layer_text,
+ keyframe_animate_backlight_color,
+ keyframe_disable_lcd_and_backlight,
+ },
+};
+
+static keyframe_animation_t resume_animation = {
+ .num_frames = 5,
+ .loop = false,
+ .frame_lengths = {0, 0, gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(5000), 0},
+ .frame_functions = {
+ keyframe_enable_lcd_and_backlight,
+ display_welcome,
+ keyframe_animate_backlight_color,
+ keyframe_no_operation,
+ enable_visualization,
+ },
+};
+
+void initialize_user_visualizer(visualizer_state_t* state) {
+ // The brightness will be dynamically adjustable in the future
+ // But for now, change it here.
+ lcd_backlight_brightness(0x50);
+ state->current_lcd_color = LCD_COLOR(0x00, 0x00, 0xFF);
+ state->target_lcd_color = LCD_COLOR(0x10, 0xFF, 0xFF);
+ start_keyframe_animation(&startup_animation);
+ start_keyframe_animation(&led_test_animation);
+}
+
+void update_user_visualizer_state(visualizer_state_t* state) {
+ // Add more tests, change the colors and layer texts here
+ // Usually you want to check the high bits (higher layers first)
+ // because that's the order layers are processed for keypresses
+ // You can for check for example:
+ // state->status.layer
+ // state->status.default_layer
+ // state->status.leds (see led.h for available statuses)
+ if (state->status.layer & 0x8) {
+ state->target_lcd_color = LCD_COLOR(0xC0, 0xB0, 0xFF);
+ state->layer_text = "Numpad";
+ }
+ else if (state->status.layer & 0x4) {
+ state->target_lcd_color = LCD_COLOR(0, 0xB0, 0xFF);
+ state->layer_text = "KBD functions";
+ }
+ else if (state->status.layer & 0x2) {
+ state->target_lcd_color = LCD_COLOR(0x80, 0xB0, 0xFF);
+ state->layer_text = "Function keys";
+ }
+ else {
+ state->target_lcd_color = LCD_COLOR(0x40, 0xB0, 0xFF);
+ state->layer_text = "Default";
+ }
+ // You can also stop existing animations, and start your custom ones here
+ // remember that you should normally have only one animation for the LCD
+ // and one for the background. But you can also combine them if you want.
+ start_keyframe_animation(&lcd_animation);
+ start_keyframe_animation(&color_animation);
+}
+
+void user_visualizer_suspend(visualizer_state_t* state) {
+ state->layer_text = "Suspending...";
+ uint8_t hue = LCD_HUE(state->current_lcd_color);
+ uint8_t sat = LCD_SAT(state->current_lcd_color);
+ state->target_lcd_color = LCD_COLOR(hue, sat, 0);
+ start_keyframe_animation(&suspend_animation);
+}
+
+void user_visualizer_resume(visualizer_state_t* state) {
+ state->current_lcd_color = LCD_COLOR(0x00, 0x00, 0x00);
+ state->target_lcd_color = LCD_COLOR(0x10, 0xFF, 0xFF);
+ start_keyframe_animation(&resume_animation);
+ start_keyframe_animation(&led_test_animation);
+}
diff --git a/keyboards/infinity_ergodox/led.c b/keyboards/infinity_ergodox/led.c
new file mode 100644
index 0000000000..77195bb358
--- /dev/null
+++ b/keyboards/infinity_ergodox/led.c
@@ -0,0 +1,49 @@
+/*
+Copyright 2012 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 "hal.h"
+
+#include "led.h"
+
+
+void led_set(uint8_t usb_led) {
+// The LCD backlight functionality conflicts with this simple
+// red backlight
+#if !defined(LCD_BACKLIGHT_ENABLE) && defined(STATUS_LED_ENABLE)
+ // PTC1: LCD Backlight Red(0:on/1:off)
+ GPIOC->PDDR |= (1<<1);
+ PORTC->PCR[1] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
+ if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
+ GPIOC->PCOR |= (1<<1);
+ } else {
+ GPIOC->PSOR |= (1<<1);
+ }
+#elif !defined(LCD_BACKLIGHT_ENABLE)
+ (void)usb_led;
+ GPIOC->PDDR |= (1<<1);
+ PORTC->PCR[1] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
+ GPIOC->PSOR |= (1<<1);
+ GPIOC->PDDR |= (1<<2);
+ PORTC->PCR[2] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
+ GPIOC->PSOR |= (1<<2);
+ GPIOC->PDDR |= (1<<3);
+ PORTC->PCR[3] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
+ GPIOC->PSOR |= (1<<3);
+#else
+ (void)usb_led;
+#endif
+}
diff --git a/keyboards/infinity_ergodox/matrix.c b/keyboards/infinity_ergodox/matrix.c
new file mode 100644
index 0000000000..2b806cd649
--- /dev/null
+++ b/keyboards/infinity_ergodox/matrix.c
@@ -0,0 +1,169 @@
+/*
+Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
+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 <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include "hal.h"
+#include "timer.h"
+#include "wait.h"
+#include "print.h"
+#include "debug.h"
+#include "matrix.h"
+
+
+/*
+ * Infinity ErgoDox Pinusage:
+ * Column pins are input with internal pull-down. Row pins are output and strobe with high.
+ * Key is high or 1 when it turns on.
+ *
+ * col: { PTD1, PTD4, PTD5, PTD6, PTD7 }
+ * row: { PTB2, PTB3, PTB18, PTB19, PTC0, PTC9, PTC10, PTC11, PTD0 }
+ */
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[LOCAL_MATRIX_ROWS];
+static bool debouncing = false;
+static uint16_t debouncing_time = 0;
+
+
+void matrix_init(void)
+{
+ /* Column(sense) */
+ palSetPadMode(GPIOD, 1, PAL_MODE_INPUT_PULLDOWN);
+ palSetPadMode(GPIOD, 4, PAL_MODE_INPUT_PULLDOWN);
+ palSetPadMode(GPIOD, 5, PAL_MODE_INPUT_PULLDOWN);
+ palSetPadMode(GPIOD, 6, PAL_MODE_INPUT_PULLDOWN);
+ palSetPadMode(GPIOD, 7, PAL_MODE_INPUT_PULLDOWN);
+
+ /* Row(strobe) */
+ palSetPadMode(GPIOB, 2, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOB, 3, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOB, 18, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOB, 19, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOC, 0, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOC, 9, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOC, 10, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOC, 11, PAL_MODE_OUTPUT_PUSHPULL);
+ palSetPadMode(GPIOD, 0, PAL_MODE_OUTPUT_PUSHPULL);
+
+ memset(matrix, 0, MATRIX_ROWS);
+ memset(matrix_debouncing, 0, LOCAL_MATRIX_ROWS);
+}
+
+uint8_t matrix_scan(void)
+{
+ for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
+ matrix_row_t data = 0;
+
+ // strobe row
+ switch (row) {
+ case 0: palSetPad(GPIOB, 2); break;
+ case 1: palSetPad(GPIOB, 3); break;
+ case 2: palSetPad(GPIOB, 18); break;
+ case 3: palSetPad(GPIOB, 19); break;
+ case 4: palSetPad(GPIOC, 0); break;
+ case 5: palSetPad(GPIOC, 9); break;
+ case 6: palSetPad(GPIOC, 10); break;
+ case 7: palSetPad(GPIOC, 11); break;
+ case 8: palSetPad(GPIOD, 0); break;
+ }
+
+ // need wait to settle pin state
+ // if you wait too short, or have a too high update rate
+ // the keyboard might freeze, or there might not be enough
+ // processing power to update the LCD screen properly.
+ // 20us, or two ticks at 100000Hz seems to be OK
+ wait_us(20);
+
+ // read col data: { PTD1, PTD4, PTD5, PTD6, PTD7 }
+ data = ((palReadPort(GPIOD) & 0xF0) >> 3) |
+ ((palReadPort(GPIOD) & 0x02) >> 1);
+
+ // un-strobe row
+ switch (row) {
+ case 0: palClearPad(GPIOB, 2); break;
+ case 1: palClearPad(GPIOB, 3); break;
+ case 2: palClearPad(GPIOB, 18); break;
+ case 3: palClearPad(GPIOB, 19); break;
+ case 4: palClearPad(GPIOC, 0); break;
+ case 5: palClearPad(GPIOC, 9); break;
+ case 6: palClearPad(GPIOC, 10); break;
+ case 7: palClearPad(GPIOC, 11); break;
+ case 8: palClearPad(GPIOD, 0); break;
+ }
+
+ if (matrix_debouncing[row] != data) {
+ matrix_debouncing[row] = data;
+ debouncing = true;
+ debouncing_time = timer_read();
+ }
+ }
+
+ uint8_t offset = 0;
+#ifdef MASTER_IS_ON_RIGHT
+ if (is_serial_link_master()) {
+ offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS;
+ }
+#endif
+
+ if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
+ for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
+ matrix[offset + row] = matrix_debouncing[row];
+ }
+ debouncing = false;
+ }
+ return 1;
+}
+
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+ return (matrix[row] & (1<<col));
+}
+
+matrix_row_t matrix_get_row(uint8_t row)
+{
+ return matrix[row];
+}
+
+void matrix_print(void)
+{
+ xprintf("\nr/c 01234567\n");
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ xprintf("%X0: ", row);
+ matrix_row_t data = matrix_get_row(row);
+ for (int col = 0; col < MATRIX_COLS; col++) {
+ if (data & (1<<col))
+ xprintf("1");
+ else
+ xprintf("0");
+ }
+ xprintf("\n");
+ }
+}
+
+void matrix_set_remote(matrix_row_t* rows, uint8_t index) {
+ uint8_t offset = 0;
+#ifdef MASTER_IS_ON_RIGHT
+ offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2);
+#else
+ offset = LOCAL_MATRIX_ROWS * (index + 1);
+#endif
+ for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
+ matrix[offset + row] = rows[row];
+ }
+}
diff --git a/keyboards/infinity_ergodox/mcuconf.h b/keyboards/infinity_ergodox/mcuconf.h
new file mode 100644
index 0000000000..f6730b99ca
--- /dev/null
+++ b/keyboards/infinity_ergodox/mcuconf.h
@@ -0,0 +1,74 @@
+/*
+ ChibiOS - Copyright (C) 2006..2015 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_
+
+#define K20x_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+
+#define K20x7
+
+/* Select the MCU clocking mode below by enabling the appropriate block. */
+
+#define KINETIS_NO_INIT FALSE
+
+/* PEE mode - 48MHz system clock driven by external crystal. */
+#define KINETIS_MCG_MODE KINETIS_MCG_MODE_PEE
+#define KINETIS_PLLCLK_FREQUENCY 72000000UL
+#define KINETIS_SYSCLK_FREQUENCY 72000000UL
+#define KINETIS_BUSCLK_FREQUENCY 36000000UL
+#define KINETIS_FLASHCLK_FREQUENCY 24000000UL
+
+#if 0
+/* FEI mode - 48 MHz with internal 32.768 kHz crystal */
+#define KINETIS_MCG_MODE KINETIS_MCG_MODE_FEI
+#define KINETIS_MCG_FLL_DMX32 1 /* Fine-tune for 32.768 kHz */
+#define KINETIS_MCG_FLL_DRS 1 /* 1464x FLL factor */
+#define KINETIS_SYSCLK_FREQUENCY 47972352UL /* 32.768 kHz * 1464 (~48 MHz) */
+#define KINETIS_CLKDIV1_OUTDIV1 1
+#define KINETIS_CLKDIV1_OUTDIV2 1
+#define KINETIS_CLKDIV1_OUTDIV4 2
+#define KINETIS_BUSCLK_FREQUENCY KINETIS_SYSCLK_FREQUENCY
+#define KINETIS_FLASHCLK_FREQUENCY KINETIS_SYSCLK_FREQUENCY/2
+#endif
+
+/*
+ * SERIAL driver system settings.
+ */
+#define KINETIS_SERIAL_USE_UART0 TRUE
+#define KINETIS_SERIAL_USE_UART1 TRUE
+
+/*
+ * USB driver settings
+ */
+#define KINETIS_USB_USE_USB0 TRUE
+/* Need to redefine this, since the default is for K20x */
+/* This is for Teensy LC; you should comment it out (or change to 5)
+ * for Teensy 3.x */
+#define KINETIS_USB_USB0_IRQ_PRIORITY 2
+
+/*
+ * SPI driver system settings.
+ */
+#define KINETIS_SPI_USE_SPI0 TRUE
+
+#define KINETIS_I2C_USE_I2C0 TRUE
+
+#endif /* _MCUCONF_H_ */
diff --git a/keyboards/kc60/keymaps/stanleylai/keymap.c b/keyboards/kc60/keymaps/stanleylai/keymap.c
index a7ea6040d5..057c73bf4d 100644
--- a/keyboards/kc60/keymaps/stanleylai/keymap.c
+++ b/keyboards/kc60/keymaps/stanleylai/keymap.c
@@ -38,7 +38,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
RESET, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
- KC_TRNS,KC_NO, F(1), F(2), F(3), F(4), F(5), F(6), F(7), F(8), BL_STEP,BL_TOGG, KC_TRNS, KC_TRNS,\
+ KC_TRNS,KC_NO, RGB_TOG,RGB_MOD,RGB_HUI,RGB_HUD,RGB_SAI,RGB_SAD,RGB_VAI,RGB_VAD,BL_STEP,BL_TOGG, KC_TRNS, KC_TRNS,\
KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS),
#else
RESET, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
@@ -52,30 +52,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
enum function_id {
SHIFT_ESC,
- #ifdef RGBLIGHT_ENABLE
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL,
- #endif
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_FUNCTION(SHIFT_ESC),
- #ifdef RGBLIGHT_ENABLE
- [1] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [2] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [3] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [5] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [7] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [8] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
- #endif
};
#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
@@ -102,50 +82,5 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
}
break;
-
- #ifdef RGBLIGHT_ENABLE
-
- case RGBLED_TOGGLE:
- //led operations
- if (record->event.pressed) {
- rgblight_toggle();
- }
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
- #endif
}
}
diff --git a/keyboards/kc60/keymaps/ws2812/config.h b/keyboards/kc60/keymaps/ws2812/config.h
index 933bb0d2d1..2f39ea8e55 100644
--- a/keyboards/kc60/keymaps/ws2812/config.h
+++ b/keyboards/kc60/keymaps/ws2812/config.h
@@ -1,9 +1,8 @@
#include "../../config.h"
/* WS2812B RGB Underglow LED */
-#define ws2812_PORTREG PORTF
-#define ws2812_DDRREG DDRF
-#define ws2812_pin PF5 // Based on wiring depicted in ws2812_wiring.jpg
+#define RGB_DI_PIN F5 // Based on wiring depicted in ws2812_wiring.jpg
+#define RGBLIGHT_TIMER
#define RGBLED_NUM 16 // Number of LEDs. Change this to match your use case.
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
diff --git a/keyboards/kc60/keymaps/ws2812/keymap.c b/keyboards/kc60/keymaps/ws2812/keymap.c
index bd5bef787b..1c0574df09 100644
--- a/keyboards/kc60/keymaps/ws2812/keymap.c
+++ b/keyboards/kc60/keymaps/ws2812/keymap.c
@@ -52,7 +52,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, \
KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, BL_DEC, BL_INC, BL_TOGG, \
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
- KC_TRNS, KC_TRNS, F(1), F(2), F(3), F(4), F(5), F(6), F(7), F(8), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
+ KC_TRNS, KC_TRNS, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET),
#else
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, \
@@ -65,30 +65,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
enum function_id {
SHIFT_ESC,
- #ifdef RGBLIGHT_ENABLE
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL
- #endif
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_FUNCTION(SHIFT_ESC),
- #ifdef RGBLIGHT_ENABLE
- [1] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [2] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [3] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [5] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [7] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [8] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
- #endif
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
@@ -114,48 +94,5 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
}
break;
- //led operations
- #ifdef RGBLIGHT_ENABLE
- case RGBLED_TOGGLE:
- if (record->event.pressed) {
- rgblight_toggle();
- }
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
- #endif
}
}
diff --git a/keyboards/lets_split/Makefile b/keyboards/lets_split/Makefile
new file mode 100644
index 0000000000..b9f07636be
--- /dev/null
+++ b/keyboards/lets_split/Makefile
@@ -0,0 +1,78 @@
+SRC += matrix.c \
+ i2c.c \
+ split_util.c \
+ serial.c
+
+# MCU name
+#MCU = at90usb1287
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 16000000
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+# This will define a symbol, F_USB, in all source code files equal to the
+# input clock frequency (before any prescaling is performed) in Hz. This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+# Teensy halfKay 512
+# Teensy++ halfKay 1024
+# Atmel DFU loader 4096
+# LUFA bootloader 4096
+# USBaspLoader 2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+# 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 ?= yes # Mouse keys(+4700)
+EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
+CONSOLE_ENABLE ?= no # Console for debug(+400)
+COMMAND_ENABLE ?= yes # Commands for debug and configuration
+NKRO_ENABLE ?= no # 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. Do not enable this with audio at the same time.
+
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
+
+CUSTOM_MATRIX = yes
+
+ifndef QUANTUM_DIR
+ include ../../Makefile
+endif \ No newline at end of file
diff --git a/keyboards/stm32_f072_onekey/config.h b/keyboards/lets_split/config.h
index bb5251e1de..833818ce60 100644
--- a/keyboards/stm32_f072_onekey/config.h
+++ b/keyboards/lets_split/config.h
@@ -1,5 +1,5 @@
/*
-Copyright 2015 Jun Wako <wakojun@gmail.com>
+Copyright 2012 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
@@ -22,26 +22,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
-#define PRODUCT_ID 0x6464
+#define PRODUCT_ID 0x3060
#define DEVICE_VER 0x0001
-/* in python2: list(u"whatever".encode('utf-16-le')) */
-/* at most 32 characters or the ugly hack in usb_main.c borks */
-#define MANUFACTURER "TMK"
-#define USBSTR_MANUFACTURER 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
-#define PRODUCT "ChibiOS TMK test"
-#define USBSTR_PRODUCT 'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
-#define DESCRIPTION "TMK keyboard firmware over ChibiOS"
+#define MANUFACTURER Wootpatoot
+#define PRODUCT Lets Split
+#define DESCRIPTION A split keyboard for the cheap makers
/* key matrix size */
-#define MATRIX_ROWS 1
-#define MATRIX_COLS 1
+// Rows are doubled-up
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 6
+
+// wiring of each half
+#define MATRIX_ROW_PINS { B5, B4, E6, D7 }
+#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
+
+#define CATERINA_BOOTLOADER
+
+// #define USE_I2C
+
+// #define EE_HANDS
+
+#define I2C_MASTER_LEFT
+// #define I2C_MASTER_RIGHT
+
+/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
+/* number of backlight levels */
+// #define BACKLIGHT_LEVELS 3
+
/* Set 0 if debouncing isn't needed */
-#define DEBOUNCE 5
+#define DEBOUNCING_DELAY 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
@@ -53,7 +68,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
-
+/* ws2812 RGB LED */
+#define RGB_DI_PIN D2
+#define RGBLIGHT_TIMER
+#define RGBLED_NUM 28 // Number of LEDs
+#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_SAT_STEP 17
+#define RGBLIGHT_VAL_STEP 17
/*
* Feature disable options
@@ -61,10 +82,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* disable debug print */
-//#define NO_DEBUG
+// #define NO_DEBUG
/* disable print */
-//#define NO_PRINT
+// #define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
@@ -73,4 +94,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
-#endif
+#endif \ No newline at end of file
diff --git a/keyboards/lets_split/eeprom-lefthand.eep b/keyboards/lets_split/eeprom-lefthand.eep
new file mode 100644
index 0000000000..a92200b124
--- /dev/null
+++ b/keyboards/lets_split/eeprom-lefthand.eep
@@ -0,0 +1,2 @@
+:080000000000000000000001F7
+:00000001FF
diff --git a/keyboards/lets_split/eeprom-righthand.eep b/keyboards/lets_split/eeprom-righthand.eep
new file mode 100644
index 0000000000..91a6831704
--- /dev/null
+++ b/keyboards/lets_split/eeprom-righthand.eep
@@ -0,0 +1,2 @@
+:080000000000000000000000F8
+:00000001FF
diff --git a/keyboards/lets_split/i2c.c b/keyboards/lets_split/i2c.c
new file mode 100644
index 0000000000..c72789403e
--- /dev/null
+++ b/keyboards/lets_split/i2c.c
@@ -0,0 +1,159 @@
+#include <util/twi.h>
+#include <avr/io.h>
+#include <stdlib.h>
+#include <avr/interrupt.h>
+#include <util/twi.h>
+#include <stdbool.h>
+#include "i2c.h"
+
+// Limits the amount of we wait for any one i2c transaction.
+// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
+// 9 bits, a single transaction will take around 90μs to complete.
+//
+// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit
+// poll loop takes at least 8 clock cycles to execute
+#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
+
+#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
+
+volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
+
+static volatile uint8_t slave_buffer_pos;
+static volatile bool slave_has_register_set = false;
+
+// Wait for an i2c operation to finish
+inline static
+void i2c_delay(void) {
+ uint16_t lim = 0;
+ while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
+ lim++;
+
+ // easier way, but will wait slightly longer
+ // _delay_us(100);
+}
+
+// Setup twi to run at 100kHz
+void i2c_master_init(void) {
+ // no prescaler
+ TWSR = 0;
+ // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
+ // Check datasheets for more info.
+ TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
+}
+
+// Start a transaction with the given i2c slave address. The direction of the
+// transfer is set with I2C_READ and I2C_WRITE.
+// returns: 0 => success
+// 1 => error
+uint8_t i2c_master_start(uint8_t address) {
+ TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);
+
+ i2c_delay();
+
+ // check that we started successfully
+ if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
+ return 1;
+
+ TWDR = address;
+ TWCR = (1<<TWINT) | (1<<TWEN);
+
+ i2c_delay();
+
+ if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
+ return 1; // slave did not acknowledge
+ else
+ return 0; // success
+}
+
+
+// Finish the i2c transaction.
+void i2c_master_stop(void) {
+ TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
+
+ uint16_t lim = 0;
+ while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
+ lim++;
+}
+
+// Write one byte to the i2c slave.
+// returns 0 => slave ACK
+// 1 => slave NACK
+uint8_t i2c_master_write(uint8_t data) {
+ TWDR = data;
+ TWCR = (1<<TWINT) | (1<<TWEN);
+
+ i2c_delay();
+
+ // check if the slave acknowledged us
+ return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
+}
+
+// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
+// if ack=0 the acknowledge bit is not set.
+// returns: byte read from i2c device
+uint8_t i2c_master_read(int ack) {
+ TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
+
+ i2c_delay();
+ return TWDR;
+}
+
+void i2c_reset_state(void) {
+ TWCR = 0;
+}
+
+void i2c_slave_init(uint8_t address) {
+ TWAR = address << 0; // slave i2c address
+ // TWEN - twi enable
+ // TWEA - enable address acknowledgement
+ // TWINT - twi interrupt flag
+ // TWIE - enable the twi interrupt
+ TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
+}
+
+ISR(TWI_vect);
+
+ISR(TWI_vect) {
+ uint8_t ack = 1;
+ switch(TW_STATUS) {
+ case TW_SR_SLA_ACK:
+ // this device has been addressed as a slave receiver
+ slave_has_register_set = false;
+ break;
+
+ case TW_SR_DATA_ACK:
+ // this device has received data as a slave receiver
+ // The first byte that we receive in this transaction sets the location
+ // of the read/write location of the slaves memory that it exposes over
+ // i2c. After that, bytes will be written at slave_buffer_pos, incrementing
+ // slave_buffer_pos after each write.
+ if(!slave_has_register_set) {
+ slave_buffer_pos = TWDR;
+ // don't acknowledge the master if this memory loctaion is out of bounds
+ if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
+ ack = 0;
+ slave_buffer_pos = 0;
+ }
+ slave_has_register_set = true;
+ } else {
+ i2c_slave_buffer[slave_buffer_pos] = TWDR;
+ BUFFER_POS_INC();
+ }
+ break;
+
+ case TW_ST_SLA_ACK:
+ case TW_ST_DATA_ACK:
+ // master has addressed this device as a slave transmitter and is
+ // requesting data.
+ TWDR = i2c_slave_buffer[slave_buffer_pos];
+ BUFFER_POS_INC();
+ break;
+
+ case TW_BUS_ERROR: // something went wrong, reset twi state
+ TWCR = 0;
+ default:
+ break;
+ }
+ // Reset everything, so we are ready for the next TWI interrupt
+ TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
+}
diff --git a/keyboards/lets_split/i2c.h b/keyboards/lets_split/i2c.h
new file mode 100644
index 0000000000..08ce4b0093
--- /dev/null
+++ b/keyboards/lets_split/i2c.h
@@ -0,0 +1,31 @@
+#ifndef I2C_H
+#define I2C_H
+
+#include <stdint.h>
+
+#ifndef F_CPU
+#define F_CPU 16000000UL
+#endif
+
+#define I2C_READ 1
+#define I2C_WRITE 0
+
+#define I2C_ACK 1
+#define I2C_NACK 0
+
+#define SLAVE_BUFFER_SIZE 0x10
+
+// i2c SCL clock frequency
+#define SCL_CLOCK 100000L
+
+extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
+
+void i2c_master_init(void);
+uint8_t i2c_master_start(uint8_t address);
+void i2c_master_stop(void);
+uint8_t i2c_master_write(uint8_t data);
+uint8_t i2c_master_read(int);
+void i2c_reset_state(void);
+void i2c_slave_init(uint8_t address);
+
+#endif
diff --git a/keyboards/lets_split/imgs/split-keyboard-i2c-schematic.png b/keyboards/lets_split/imgs/split-keyboard-i2c-schematic.png
new file mode 100644
index 0000000000..8882947187
--- /dev/null
+++ b/keyboards/lets_split/imgs/split-keyboard-i2c-schematic.png
Binary files differ
diff --git a/keyboards/lets_split/imgs/split-keyboard-serial-schematic.png b/keyboards/lets_split/imgs/split-keyboard-serial-schematic.png
new file mode 100644
index 0000000000..7621d38ed9
--- /dev/null
+++ b/keyboards/lets_split/imgs/split-keyboard-serial-schematic.png
Binary files differ
diff --git a/keyboards/lets_split/keymaps/default/keymap.c b/keyboards/lets_split/keymaps/default/keymap.c
new file mode 100644
index 0000000000..0d2d94b672
--- /dev/null
+++ b/keyboards/lets_split/keymaps/default/keymap.c
@@ -0,0 +1,214 @@
+#include "lets_split.h"
+#include "action_layer.h"
+#include "eeconfig.h"
+
+extern keymap_config_t keymap_config;
+
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+#define _QWERTY 0
+#define _COLEMAK 1
+#define _DVORAK 2
+#define _LOWER 3
+#define _RAISE 4
+#define _ADJUST 16
+
+enum custom_keycodes {
+ QWERTY = SAFE_RANGE,
+ COLEMAK,
+ DVORAK,
+ LOWER,
+ RAISE,
+ ADJUST,
+};
+
+// Fillers to make layering more clear
+#define _______ KC_TRNS
+#define XXXXXXX KC_NO
+
+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 |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_QWERTY] = KEYMAP( \
+ 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 , \
+ ADJUST, 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 |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_COLEMAK] = KEYMAP( \
+ 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 , \
+ ADJUST, 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 |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_DVORAK] = KEYMAP( \
+ 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 , \
+ ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
+),
+
+/* Lower
+ * ,-----------------------------------------------------------------------------------.
+ * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
+ * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
+ * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | | | | | | | Next | Vol- | Vol+ | Play |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_LOWER] = KEYMAP( \
+ 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_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
+),
+
+/* 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 / | | |Enter |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | | | | | | | Next | Vol- | Vol+ | Play |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_RAISE] = KEYMAP( \
+ 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_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
+),
+
+/* Adjust (Lower + Raise)
+ * ,-----------------------------------------------------------------------------------.
+ * | | Reset| | | | | | | | | | Del |
+ * |------+------+------+------+------+-------------+------+------+------+------+------|
+ * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
+ * |------+------+------+------+------+------|------+------+------+------+------+------|
+ * | | | | | | | | | | | | |
+ * |------+------+------+------+------+------+------+------+------+------+------+------|
+ * | | | | | | | | | | | |
+ * `-----------------------------------------------------------------------------------'
+ */
+[_ADJUST] = KEYMAP( \
+ _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
+ _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
+)
+
+
+};
+
+#ifdef AUDIO_ENABLE
+float tone_qwerty[][2] = SONG(QWERTY_SOUND);
+float tone_dvorak[][2] = SONG(DVORAK_SOUND);
+float tone_colemak[][2] = SONG(COLEMAK_SOUND);
+#endif
+
+void persistant_default_layer_set(uint16_t default_layer) {
+ eeconfig_update_default_layer(default_layer);
+ default_layer_set(default_layer);
+}
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case QWERTY:
+ if (record->event.pressed) {
+ #ifdef AUDIO_ENABLE
+ PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
+ #endif
+ persistant_default_layer_set(1UL<<_QWERTY);
+ }
+ return false;
+ break;
+ case COLEMAK:
+ if (record->event.pressed) {
+ #ifdef AUDIO_ENABLE
+ PLAY_NOTE_ARRAY(tone_colemak, false, 0);
+ #endif
+ persistant_default_layer_set(1UL<<_COLEMAK);
+ }
+ return false;
+ break;
+ case DVORAK:
+ if (record->event.pressed) {
+ #ifdef AUDIO_ENABLE
+ PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
+ #endif
+ persistant_default_layer_set(1UL<<_DVORAK);
+ }
+ return false;
+ break;
+ case LOWER:
+ if (record->event.pressed) {
+ layer_on(_LOWER);
+ update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ } else {
+ layer_off(_LOWER);
+ update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ }
+ return false;
+ break;
+ case RAISE:
+ if (record->event.pressed) {
+ layer_on(_RAISE);
+ update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ } else {
+ layer_off(_RAISE);
+ update_tri_layer(_LOWER, _RAISE, _ADJUST);
+ }
+ return false;
+ break;
+ case ADJUST:
+ if (record->event.pressed) {
+ layer_on(_ADJUST);
+ } else {
+ layer_off(_ADJUST);
+ }
+ return false;
+ break;
+ }
+ return true;
+} \ No newline at end of file
diff --git a/keyboards/lets_split/lets_split.c b/keyboards/lets_split/lets_split.c
new file mode 100644
index 0000000000..574c116a75
--- /dev/null
+++ b/keyboards/lets_split/lets_split.c
@@ -0,0 +1,30 @@
+#include "lets_split.h"
+
+#ifdef AUDIO_ENABLE
+ float tone_startup[][2] = SONG(STARTUP_SOUND);
+ float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
+#endif
+
+void matrix_init_kb(void) {
+
+ #ifdef AUDIO_ENABLE
+ _delay_ms(20); // gets rid of tick
+ PLAY_NOTE_ARRAY(tone_startup, false, 0);
+ #endif
+
+ // // green led on
+ // DDRD |= (1<<5);
+ // PORTD &= ~(1<<5);
+
+ // // orange led on
+ // DDRB |= (1<<0);
+ // PORTB &= ~(1<<0);
+
+ matrix_init_user();
+};
+
+void shutdown_user(void) {
+ PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
+ _delay_ms(150);
+ stop_all_notes();
+}
diff --git a/keyboards/lets_split/lets_split.h b/keyboards/lets_split/lets_split.h
new file mode 100644
index 0000000000..fe7ae07679
--- /dev/null
+++ b/keyboards/lets_split/lets_split.h
@@ -0,0 +1,25 @@
+#ifndef LETS_SPLIT_H
+#define LETS_SPLIT_H
+
+#include "quantum.h"
+
+void promicro_bootloader_jmp(bool program);
+
+#define KEYMAP( \
+ k00, k01, k02, k03, k04, k05, k40, k41, k42, k43, k44, k45, \
+ k10, k11, k12, k13, k14, k15, k50, k51, k52, k53, k54, k55, \
+ k20, k21, k22, k23, k24, k25, k60, k61, k62, k63, k64, k65, \
+ k30, k31, k32, k33, k34, k35, k70, k71, k72, k73, k74, k75 \
+ ) \
+ { \
+ { k00, k01, k02, k03, k04, k05 }, \
+ { k10, k11, k12, k13, k14, k15 }, \
+ { k20, k21, k22, k23, k24, k25 }, \
+ { k30, k31, k32, k33, k34, k35 }, \
+ { k40, k41, k42, k43, k44, k45 }, \
+ { k50, k51, k52, k53, k54, k55 }, \
+ { k60, k61, k62, k63, k64, k65 }, \
+ { k70, k71, k72, k73, k74, k75 } \
+ }
+
+#endif \ No newline at end of file
diff --git a/keyboards/lets_split/matrix.c b/keyboards/lets_split/matrix.c
new file mode 100644
index 0000000000..1d768c59b3
--- /dev/null
+++ b/keyboards/lets_split/matrix.c
@@ -0,0 +1,311 @@
+/*
+Copyright 2012 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/>.
+*/
+
+/*
+ * scan matrix
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <avr/wdt.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+#include "i2c.h"
+#include "serial.h"
+#include "split_util.h"
+#include "pro_micro.h"
+#include "config.h"
+
+#ifndef DEBOUNCE
+# define DEBOUNCE 5
+#endif
+
+#define ERROR_DISCONNECT_COUNT 5
+
+static uint8_t debouncing = DEBOUNCE;
+static const int ROWS_PER_HAND = MATRIX_ROWS/2;
+static uint8_t error_count = 0;
+
+static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
+static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static matrix_row_t read_cols(void);
+static void init_cols(void);
+static void unselect_rows(void);
+static void select_row(uint8_t row);
+
+__attribute__ ((weak))
+void matrix_init_quantum(void) {
+ matrix_init_kb();
+}
+
+__attribute__ ((weak))
+void matrix_scan_quantum(void) {
+ matrix_scan_kb();
+}
+
+__attribute__ ((weak))
+void matrix_init_kb(void) {
+ matrix_init_user();
+}
+
+__attribute__ ((weak))
+void matrix_scan_kb(void) {
+ matrix_scan_user();
+}
+
+__attribute__ ((weak))
+void matrix_init_user(void) {
+}
+
+__attribute__ ((weak))
+void matrix_scan_user(void) {
+}
+
+inline
+uint8_t matrix_rows(void)
+{
+ return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+ return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+ debug_enable = true;
+ debug_matrix = true;
+ debug_mouse = true;
+ // initialize row and col
+ unselect_rows();
+ init_cols();
+
+ TX_RX_LED_INIT;
+
+ // initialize matrix state: all keys off
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ matrix[i] = 0;
+ matrix_debouncing[i] = 0;
+ }
+
+ matrix_init_quantum();
+}
+
+uint8_t _matrix_scan(void)
+{
+ // Right hand is stored after the left in the matirx so, we need to offset it
+ int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
+
+ for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
+ select_row(i);
+ _delay_us(30); // without this wait read unstable value.
+ matrix_row_t cols = read_cols();
+ if (matrix_debouncing[i+offset] != cols) {
+ matrix_debouncing[i+offset] = cols;
+ debouncing = DEBOUNCE;
+ }
+ unselect_rows();
+ }
+
+ if (debouncing) {
+ if (--debouncing) {
+ _delay_ms(1);
+ } else {
+ for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
+ matrix[i+offset] = matrix_debouncing[i+offset];
+ }
+ }
+ }
+
+ return 1;
+}
+
+// Get rows from other half over i2c
+int i2c_transaction(void) {
+ int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
+
+ int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
+ if (err) goto i2c_error;
+
+ // start of matrix stored at 0x00
+ err = i2c_master_write(0x00);
+ if (err) goto i2c_error;
+
+ // Start read
+ err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
+ if (err) goto i2c_error;
+
+ if (!err) {
+ int i;
+ for (i = 0; i < ROWS_PER_HAND-1; ++i) {
+ matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
+ }
+ matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
+ i2c_master_stop();
+ } else {
+i2c_error: // the cable is disconnceted, or something else went wrong
+ i2c_reset_state();
+ return err;
+ }
+
+ return 0;
+}
+
+#ifndef USE_I2C
+int serial_transaction(void) {
+ int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
+
+ if (serial_update_buffers()) {
+ return 1;
+ }
+
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ matrix[slaveOffset+i] = serial_slave_buffer[i];
+ }
+ return 0;
+}
+#endif
+
+uint8_t matrix_scan(void)
+{
+ int ret = _matrix_scan();
+
+
+
+#ifdef USE_I2C
+ if( i2c_transaction() ) {
+#else
+ if( serial_transaction() ) {
+#endif
+ // turn on the indicator led when halves are disconnected
+ TXLED1;
+
+ error_count++;
+
+ if (error_count > ERROR_DISCONNECT_COUNT) {
+ // reset other half if disconnected
+ int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ matrix[slaveOffset+i] = 0;
+ }
+ }
+ } else {
+ // turn off the indicator led on no error
+ TXLED0;
+ error_count = 0;
+ }
+
+ matrix_scan_quantum();
+
+ return ret;
+}
+
+void matrix_slave_scan(void) {
+ _matrix_scan();
+
+ int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2);
+
+#ifdef USE_I2C
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ /* i2c_slave_buffer[i] = matrix[offset+i]; */
+ i2c_slave_buffer[i] = matrix[offset+i];
+ }
+#else
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {
+ serial_slave_buffer[i] = matrix[offset+i];
+ }
+#endif
+}
+
+bool matrix_is_modified(void)
+{
+ if (debouncing) return false;
+ return true;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+ return (matrix[row] & ((matrix_row_t)1<<col));
+}
+
+inline
+matrix_row_t matrix_get_row(uint8_t row)
+{
+ return matrix[row];
+}
+
+void matrix_print(void)
+{
+ print("\nr/c 0123456789ABCDEF\n");
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+ phex(row); print(": ");
+ pbin_reverse16(matrix_get_row(row));
+ print("\n");
+ }
+}
+
+uint8_t matrix_key_count(void)
+{
+ uint8_t count = 0;
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+ count += bitpop16(matrix[i]);
+ }
+ return count;
+}
+
+static void init_cols(void)
+{
+ for(int x = 0; x < MATRIX_COLS; x++) {
+ _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
+ _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
+ }
+}
+
+static matrix_row_t read_cols(void)
+{
+ matrix_row_t result = 0;
+ for(int x = 0; x < MATRIX_COLS; x++) {
+ result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
+ }
+ return result;
+}
+
+static void unselect_rows(void)
+{
+ for(int x = 0; x < ROWS_PER_HAND; x++) {
+ _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
+ _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
+ }
+}
+
+static void select_row(uint8_t row)
+{
+ _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
+ _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
+}
diff --git a/keyboards/lets_split/pro_micro.h b/keyboards/lets_split/pro_micro.h
new file mode 100644
index 0000000000..09e219b7b1
--- /dev/null
+++ b/keyboards/lets_split/pro_micro.h
@@ -0,0 +1,362 @@
+/*
+ pins_arduino.h - Pin definition functions for Arduino
+ Part of Arduino - http://www.arduino.cc/
+
+ Copyright (c) 2007 David A. Mellis
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General
+ Public License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
+*/
+
+#ifndef Pins_Arduino_h
+#define Pins_Arduino_h
+
+#include <avr/pgmspace.h>
+
+// Workaround for wrong definitions in "iom32u4.h".
+// This should be fixed in the AVR toolchain.
+#undef UHCON
+#undef UHINT
+#undef UHIEN
+#undef UHADDR
+#undef UHFNUM
+#undef UHFNUML
+#undef UHFNUMH
+#undef UHFLEN
+#undef UPINRQX
+#undef UPINTX
+#undef UPNUM
+#undef UPRST
+#undef UPCONX
+#undef UPCFG0X
+#undef UPCFG1X
+#undef UPSTAX
+#undef UPCFG2X
+#undef UPIENX
+#undef UPDATX
+#undef TCCR2A
+#undef WGM20
+#undef WGM21
+#undef COM2B0
+#undef COM2B1
+#undef COM2A0
+#undef COM2A1
+#undef TCCR2B
+#undef CS20
+#undef CS21
+#undef CS22
+#undef WGM22
+#undef FOC2B
+#undef FOC2A
+#undef TCNT2
+#undef TCNT2_0
+#undef TCNT2_1
+#undef TCNT2_2
+#undef TCNT2_3
+#undef TCNT2_4
+#undef TCNT2_5
+#undef TCNT2_6
+#undef TCNT2_7
+#undef OCR2A
+#undef OCR2_0
+#undef OCR2_1
+#undef OCR2_2
+#undef OCR2_3
+#undef OCR2_4
+#undef OCR2_5
+#undef OCR2_6
+#undef OCR2_7
+#undef OCR2B
+#undef OCR2_0
+#undef OCR2_1
+#undef OCR2_2
+#undef OCR2_3
+#undef OCR2_4
+#undef OCR2_5
+#undef OCR2_6
+#undef OCR2_7
+
+#define NUM_DIGITAL_PINS 30
+#define NUM_ANALOG_INPUTS 12
+
+#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
+#define TXLED0 PORTD |= (1<<5)
+#define TXLED1 PORTD &= ~(1<<5)
+#define RXLED0 PORTB |= (1<<0)
+#define RXLED1 PORTB &= ~(1<<0)
+
+static const uint8_t SDA = 2;
+static const uint8_t SCL = 3;
+#define LED_BUILTIN 13
+
+// Map SPI port to 'new' pins D14..D17
+static const uint8_t SS = 17;
+static const uint8_t MOSI = 16;
+static const uint8_t MISO = 14;
+static const uint8_t SCK = 15;
+
+// Mapping of analog pins as digital I/O
+// A6-A11 share with digital pins
+static const uint8_t A0 = 18;
+static const uint8_t A1 = 19;
+static const uint8_t A2 = 20;
+static const uint8_t A3 = 21;
+static const uint8_t A4 = 22;
+static const uint8_t A5 = 23;
+static const uint8_t A6 = 24; // D4
+static const uint8_t A7 = 25; // D6
+static const uint8_t A8 = 26; // D8
+static const uint8_t A9 = 27; // D9
+static const uint8_t A10 = 28; // D10
+static const uint8_t A11 = 29; // D12
+
+#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
+#define digitalPinToPCICRbit(p) 0
+#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
+#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
+
+// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
+extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
+#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
+
+#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
+
+#ifdef ARDUINO_MAIN
+
+// On the Arduino board, digital pins are also used
+// for the analog output (software PWM). Analog input
+// pins are a separate set.
+
+// ATMEL ATMEGA32U4 / ARDUINO LEONARDO
+//
+// D0 PD2 RXD1/INT2
+// D1 PD3 TXD1/INT3
+// D2 PD1 SDA SDA/INT1
+// D3# PD0 PWM8/SCL OC0B/SCL/INT0
+// D4 A6 PD4 ADC8
+// D5# PC6 ??? OC3A/#OC4A
+// D6# A7 PD7 FastPWM #OC4D/ADC10
+// D7 PE6 INT6/AIN0
+//
+// D8 A8 PB4 ADC11/PCINT4
+// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5
+// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6
+// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7
+// D12 A11 PD6 T1/#OC4D/ADC9
+// D13# PC7 PWM10 CLK0/OC4A
+//
+// A0 D18 PF7 ADC7
+// A1 D19 PF6 ADC6
+// A2 D20 PF5 ADC5
+// A3 D21 PF4 ADC4
+// A4 D22 PF1 ADC1
+// A5 D23 PF0 ADC0
+//
+// New pins D14..D17 to map SPI port to digital pins
+//
+// MISO D14 PB3 MISO,PCINT3
+// SCK D15 PB1 SCK,PCINT1
+// MOSI D16 PB2 MOSI,PCINT2
+// SS D17 PB0 RXLED,SS/PCINT0
+//
+// Connected LEDs on board for TX and RX
+// TXLED D24 PD5 XCK1
+// RXLED D17 PB0
+// HWB PE2 HWB
+
+// these arrays map port names (e.g. port B) to the
+// appropriate addresses for various functions (e.g. reading
+// and writing)
+const uint16_t PROGMEM port_to_mode_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &DDRB,
+ (uint16_t) &DDRC,
+ (uint16_t) &DDRD,
+ (uint16_t) &DDRE,
+ (uint16_t) &DDRF,
+};
+
+const uint16_t PROGMEM port_to_output_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &PORTB,
+ (uint16_t) &PORTC,
+ (uint16_t) &PORTD,
+ (uint16_t) &PORTE,
+ (uint16_t) &PORTF,
+};
+
+const uint16_t PROGMEM port_to_input_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &PINB,
+ (uint16_t) &PINC,
+ (uint16_t) &PIND,
+ (uint16_t) &PINE,
+ (uint16_t) &PINF,
+};
+
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
+ PD, // D0 - PD2
+ PD, // D1 - PD3
+ PD, // D2 - PD1
+ PD, // D3 - PD0
+ PD, // D4 - PD4
+ PC, // D5 - PC6
+ PD, // D6 - PD7
+ PE, // D7 - PE6
+
+ PB, // D8 - PB4
+ PB, // D9 - PB5
+ PB, // D10 - PB6
+ PB, // D11 - PB7
+ PD, // D12 - PD6
+ PC, // D13 - PC7
+
+ PB, // D14 - MISO - PB3
+ PB, // D15 - SCK - PB1
+ PB, // D16 - MOSI - PB2
+ PB, // D17 - SS - PB0
+
+ PF, // D18 - A0 - PF7
+ PF, // D19 - A1 - PF6
+ PF, // D20 - A2 - PF5
+ PF, // D21 - A3 - PF4
+ PF, // D22 - A4 - PF1
+ PF, // D23 - A5 - PF0
+
+ PD, // D24 - PD5
+ PD, // D25 / D6 - A7 - PD7
+ PB, // D26 / D8 - A8 - PB4
+ PB, // D27 / D9 - A9 - PB5
+ PB, // D28 / D10 - A10 - PB6
+ PD, // D29 / D12 - A11 - PD6
+};
+
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
+ _BV(2), // D0 - PD2
+ _BV(3), // D1 - PD3
+ _BV(1), // D2 - PD1
+ _BV(0), // D3 - PD0
+ _BV(4), // D4 - PD4
+ _BV(6), // D5 - PC6
+ _BV(7), // D6 - PD7
+ _BV(6), // D7 - PE6
+
+ _BV(4), // D8 - PB4
+ _BV(5), // D9 - PB5
+ _BV(6), // D10 - PB6
+ _BV(7), // D11 - PB7
+ _BV(6), // D12 - PD6
+ _BV(7), // D13 - PC7
+
+ _BV(3), // D14 - MISO - PB3
+ _BV(1), // D15 - SCK - PB1
+ _BV(2), // D16 - MOSI - PB2
+ _BV(0), // D17 - SS - PB0
+
+ _BV(7), // D18 - A0 - PF7
+ _BV(6), // D19 - A1 - PF6
+ _BV(5), // D20 - A2 - PF5
+ _BV(4), // D21 - A3 - PF4
+ _BV(1), // D22 - A4 - PF1
+ _BV(0), // D23 - A5 - PF0
+
+ _BV(5), // D24 - PD5
+ _BV(7), // D25 / D6 - A7 - PD7
+ _BV(4), // D26 / D8 - A8 - PB4
+ _BV(5), // D27 / D9 - A9 - PB5
+ _BV(6), // D28 / D10 - A10 - PB6
+ _BV(6), // D29 / D12 - A11 - PD6
+};
+
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ TIMER0B, /* 3 */
+ NOT_ON_TIMER,
+ TIMER3A, /* 5 */
+ TIMER4D, /* 6 */
+ NOT_ON_TIMER,
+
+ NOT_ON_TIMER,
+ TIMER1A, /* 9 */
+ TIMER1B, /* 10 */
+ TIMER0A, /* 11 */
+
+ NOT_ON_TIMER,
+ TIMER4A, /* 13 */
+
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+};
+
+const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
+ 7, // A0 PF7 ADC7
+ 6, // A1 PF6 ADC6
+ 5, // A2 PF5 ADC5
+ 4, // A3 PF4 ADC4
+ 1, // A4 PF1 ADC1
+ 0, // A5 PF0 ADC0
+ 8, // A6 D4 PD4 ADC8
+ 10, // A7 D6 PD7 ADC10
+ 11, // A8 D8 PB4 ADC11
+ 12, // A9 D9 PB5 ADC12
+ 13, // A10 D10 PB6 ADC13
+ 9 // A11 D12 PD6 ADC9
+};
+
+#endif /* ARDUINO_MAIN */
+
+// These serial port names are intended to allow libraries and architecture-neutral
+// sketches to automatically default to the correct port name for a particular type
+// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.
+//
+// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
+//
+// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
+//
+// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
+//
+// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
+//
+// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
+// pins are NOT connected to anything by default.
+#define SERIAL_PORT_MONITOR Serial
+#define SERIAL_PORT_USBVIRTUAL Serial
+#define SERIAL_PORT_HARDWARE Serial1
+#define SERIAL_PORT_HARDWARE_OPEN Serial1
+
+#endif /* Pins_Arduino_h */
diff --git a/keyboards/lets_split/readme.md b/keyboards/lets_split/readme.md
new file mode 100644
index 0000000000..73fdb0f789
--- /dev/null
+++ b/keyboards/lets_split/readme.md
@@ -0,0 +1,102 @@
+Let's Split
+======
+
+This readme and most of the code are from https://github.com/ahtn/tmk_keyboard/
+
+Split keyboard firmware for Arduino Pro Micro or other ATmega32u4
+based boards.
+
+Features
+--------
+
+Some features supported by the firmware:
+
+* Either half can connect to the computer via USB, or both halves can be used
+ independently.
+* You only need 3 wires to connect the two halves. Two for VCC and GND and one
+ for serial communication.
+* Optional support for I2C connection between the two halves if for some
+ reason you require a faster connection between the two halves. Note this
+ requires an extra wire between halves and pull-up resistors on the data lines.
+
+Required Hardware
+-----------------
+
+Apart from diodes and key switches for the keyboard matrix in each half, you
+will need:
+
+* 2 Arduino Pro Micro's. You can find theses on aliexpress for ≈3.50USD each.
+* 2 TRS sockets
+* 1 TRS cable.
+
+Alternatively, you can use any sort of cable and socket that has at least 3
+wires. If you want to use I2C to communicate between halves, you will need a
+cable with at least 4 wires and 2x 4.7kΩ pull-up resistors
+
+Optional Hardware
+-----------------
+
+A speaker can be hooked-up to either side to the `5` (`C6`) pin and `GND`, and turned on via `AUDIO_ENABLE`.
+
+Wiring
+------
+
+The 3 wires of the TRS cable need to connect GND, VCC, and digital pin 3 (i.e.
+PD0 on the ATmega32u4) between the two Pro Micros.
+
+Then wire your key matrix to any of the remaining 17 IO pins of the pro micro
+and modify the `matrix.c` accordingly.
+
+The wiring for serial:
+
+![serial wiring](imgs/split-keyboard-serial-schematic.png)
+
+The wiring for i2c:
+
+![i2c wiring](imgs/split-keyboard-i2c-schematic.png)
+
+The pull-up resistors may be placed on either half. It is also possible
+to use 4 resistors and have the pull-ups in both halves, but this is
+unnecessary in simple use cases.
+
+Notes on Software Configuration
+-------------------------------
+
+Configuring the firmware is similar to any other TMK project. One thing
+to note is that `MATIX_ROWS` in `config.h` is the total number of rows between
+the two halves, i.e. if your split keyboard has 4 rows in each half, then
+`MATRIX_ROWS=8`.
+
+Also the current implementation assumes a maximum of 8 columns, but it would
+not be very difficult to adapt it to support more if required.
+
+
+Flashing
+--------
+
+If you define `EE_HANDS` in your `config.h`, you will need to set the
+EEPROM for the left and right halves. The EEPROM is used to store whether the
+half is left handed or right handed. This makes it so that the same firmware
+file will run on both hands instead of having to flash left and right handed
+versions of the firmware to each half. To flash the EEPROM file for the left
+half run:
+```
+make eeprom-left
+```
+and similarly for right half
+```
+make eeprom-right
+```
+
+After you have flashed the EEPROM for the first time, you then need to program
+the flash memory:
+```
+make program
+```
+Note that you need to program both halves, but you have the option of using
+different keymaps for each half. You could program the left half with a QWERTY
+layout and the right half with a Colemak layout. Then if you connect the left
+half to a computer by USB the keyboard will use QWERTY and Colemak when the
+right half is connected.
+
+
diff --git a/keyboards/lets_split/serial.c b/keyboards/lets_split/serial.c
new file mode 100644
index 0000000000..f439c2f20b
--- /dev/null
+++ b/keyboards/lets_split/serial.c
@@ -0,0 +1,225 @@
+/*
+ * WARNING: be careful changing this code, it is very timing dependent
+ */
+
+#ifndef F_CPU
+#define F_CPU 16000000
+#endif
+
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <stdbool.h>
+
+#include "serial.h"
+
+// Serial pulse period in microseconds. Its probably a bad idea to lower this
+// value.
+#define SERIAL_DELAY 24
+
+uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
+uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
+
+#define SLAVE_DATA_CORRUPT (1<<0)
+volatile uint8_t status = 0;
+
+inline static
+void serial_delay(void) {
+ _delay_us(SERIAL_DELAY);
+}
+
+inline static
+void serial_output(void) {
+ SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
+}
+
+// make the serial pin an input with pull-up resistor
+inline static
+void serial_input(void) {
+ SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
+ SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
+}
+
+inline static
+uint8_t serial_read_pin(void) {
+ return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
+}
+
+inline static
+void serial_low(void) {
+ SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
+}
+
+inline static
+void serial_high(void) {
+ SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
+}
+
+void serial_master_init(void) {
+ serial_output();
+ serial_high();
+}
+
+void serial_slave_init(void) {
+ serial_input();
+
+ // Enable INT0
+ EIMSK |= _BV(INT0);
+ // Trigger on falling edge of INT0
+ EICRA &= ~(_BV(ISC00) | _BV(ISC01));
+}
+
+// Used by the master to synchronize timing with the slave.
+static
+void sync_recv(void) {
+ serial_input();
+ // This shouldn't hang if the slave disconnects because the
+ // serial line will float to high if the slave does disconnect.
+ while (!serial_read_pin());
+ serial_delay();
+}
+
+// Used by the slave to send a synchronization signal to the master.
+static
+void sync_send(void) {
+ serial_output();
+
+ serial_low();
+ serial_delay();
+
+ serial_high();
+}
+
+// Reads a byte from the serial line
+static
+uint8_t serial_read_byte(void) {
+ uint8_t byte = 0;
+ serial_input();
+ for ( uint8_t i = 0; i < 8; ++i) {
+ byte = (byte << 1) | serial_read_pin();
+ serial_delay();
+ _delay_us(1);
+ }
+
+ return byte;
+}
+
+// Sends a byte with MSB ordering
+static
+void serial_write_byte(uint8_t data) {
+ uint8_t b = 8;
+ serial_output();
+ while( b-- ) {
+ if(data & (1 << b)) {
+ serial_high();
+ } else {
+ serial_low();
+ }
+ serial_delay();
+ }
+}
+
+// interrupt handle to be used by the slave device
+ISR(SERIAL_PIN_INTERRUPT) {
+ sync_send();
+
+ uint8_t checksum = 0;
+ for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
+ serial_write_byte(serial_slave_buffer[i]);
+ sync_send();
+ checksum += serial_slave_buffer[i];
+ }
+ serial_write_byte(checksum);
+ sync_send();
+
+ // wait for the sync to finish sending
+ serial_delay();
+
+ // read the middle of pulses
+ _delay_us(SERIAL_DELAY/2);
+
+ uint8_t checksum_computed = 0;
+ for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
+ serial_master_buffer[i] = serial_read_byte();
+ sync_send();
+ checksum_computed += serial_master_buffer[i];
+ }
+ uint8_t checksum_received = serial_read_byte();
+ sync_send();
+
+ serial_input(); // end transaction
+
+ if ( checksum_computed != checksum_received ) {
+ status |= SLAVE_DATA_CORRUPT;
+ } else {
+ status &= ~SLAVE_DATA_CORRUPT;
+ }
+}
+
+inline
+bool serial_slave_DATA_CORRUPT(void) {
+ return status & SLAVE_DATA_CORRUPT;
+}
+
+// Copies the serial_slave_buffer to the master and sends the
+// serial_master_buffer to the slave.
+//
+// Returns:
+// 0 => no error
+// 1 => slave did not respond
+int serial_update_buffers(void) {
+ // this code is very time dependent, so we need to disable interrupts
+ cli();
+
+ // signal to the slave that we want to start a transaction
+ serial_output();
+ serial_low();
+ _delay_us(1);
+
+ // wait for the slaves response
+ serial_input();
+ serial_high();
+ _delay_us(SERIAL_DELAY);
+
+ // check if the slave is present
+ if (serial_read_pin()) {
+ // slave failed to pull the line low, assume not present
+ sei();
+ return 1;
+ }
+
+ // if the slave is present syncronize with it
+ sync_recv();
+
+ uint8_t checksum_computed = 0;
+ // receive data from the slave
+ for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
+ serial_slave_buffer[i] = serial_read_byte();
+ sync_recv();
+ checksum_computed += serial_slave_buffer[i];
+ }
+ uint8_t checksum_received = serial_read_byte();
+ sync_recv();
+
+ if (checksum_computed != checksum_received) {
+ sei();
+ return 1;
+ }
+
+ uint8_t checksum = 0;
+ // send data to the slave
+ for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
+ serial_write_byte(serial_master_buffer[i]);
+ sync_recv();
+ checksum += serial_master_buffer[i];
+ }
+ serial_write_byte(checksum);
+ sync_recv();
+
+ // always, release the line when not in use
+ serial_output();
+ serial_high();
+
+ sei();
+ return 0;
+}
diff --git a/keyboards/lets_split/serial.h b/keyboards/lets_split/serial.h
new file mode 100644
index 0000000000..15fe4db7b4
--- /dev/null
+++ b/keyboards/lets_split/serial.h
@@ -0,0 +1,26 @@
+#ifndef MY_SERIAL_H
+#define MY_SERIAL_H
+
+#include "config.h"
+#include <stdbool.h>
+
+/* TODO: some defines for interrupt setup */
+#define SERIAL_PIN_DDR DDRD
+#define SERIAL_PIN_PORT PORTD
+#define SERIAL_PIN_INPUT PIND
+#define SERIAL_PIN_MASK _BV(PD0)
+#define SERIAL_PIN_INTERRUPT INT0_vect
+
+#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
+#define SERIAL_MASTER_BUFFER_LENGTH 1
+
+// Buffers for master - slave communication
+extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
+extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
+
+void serial_master_init(void);
+void serial_slave_init(void);
+int serial_update_buffers(void);
+bool serial_slave_data_corrupt(void);
+
+#endif
diff --git a/keyboards/lets_split/split_util.c b/keyboards/lets_split/split_util.c
new file mode 100644
index 0000000000..65003a71a4
--- /dev/null
+++ b/keyboards/lets_split/split_util.c
@@ -0,0 +1,76 @@
+#include <avr/io.h>
+#include <avr/wdt.h>
+#include <avr/power.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <avr/eeprom.h>
+#include "split_util.h"
+#include "matrix.h"
+#include "i2c.h"
+#include "serial.h"
+#include "keyboard.h"
+#include "config.h"
+
+volatile bool isLeftHand = true;
+
+static void setup_handedness(void) {
+ #ifdef EE_HANDS
+ isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
+ #else
+ #ifdef I2C_MASTER_RIGHT
+ isLeftHand = !has_usb();
+ #else
+ isLeftHand = has_usb();
+ #endif
+ #endif
+}
+
+static void keyboard_master_setup(void) {
+#ifdef USE_I2C
+ i2c_master_init();
+#else
+ serial_master_init();
+#endif
+}
+
+static void keyboard_slave_setup(void) {
+#ifdef USE_I2C
+ i2c_slave_init(SLAVE_I2C_ADDRESS);
+#else
+ serial_slave_init();
+#endif
+}
+
+bool has_usb(void) {
+ USBCON |= (1 << OTGPADE); //enables VBUS pad
+ _delay_us(5);
+ return (USBSTA & (1<<VBUS)); //checks state of VBUS
+}
+
+void split_keyboard_setup(void) {
+ setup_handedness();
+
+ if (has_usb()) {
+ keyboard_master_setup();
+ } else {
+ keyboard_slave_setup();
+ }
+ sei();
+}
+
+void keyboard_slave_loop(void) {
+ matrix_init();
+
+ while (1) {
+ matrix_slave_scan();
+ }
+}
+
+// this code runs before the usb and keyboard is initialized
+void matrix_setup(void) {
+ split_keyboard_setup();
+
+ if (!has_usb()) {
+ keyboard_slave_loop();
+ }
+}
diff --git a/keyboards/lets_split/split_util.h b/keyboards/lets_split/split_util.h
new file mode 100644
index 0000000000..6b896679ca
--- /dev/null
+++ b/keyboards/lets_split/split_util.h
@@ -0,0 +1,22 @@
+#ifndef SPLIT_KEYBOARD_UTIL_H
+#define SPLIT_KEYBOARD_UTIL_H
+
+#include <stdbool.h>
+
+#ifdef EE_HANDS
+ #define EECONFIG_BOOTMAGIC_END (uint8_t *)10
+ #define EECONFIG_HANDEDNESS EECONFIG_BOOTMAGIC_END
+#endif
+
+#define SLAVE_I2C_ADDRESS 0x32
+
+extern volatile bool isLeftHand;
+
+// slave version of matix scan, defined in matrix.c
+void matrix_slave_scan(void);
+
+void split_keyboard_setup(void);
+bool has_usb(void);
+void keyboard_slave_loop(void);
+
+#endif
diff --git a/keyboards/phantom/config.h b/keyboards/phantom/config.h
index d5878766f0..983a1d73f2 100644
--- a/keyboards/phantom/config.h
+++ b/keyboards/phantom/config.h
@@ -62,13 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Underlight configuration
*/
- #define ws2812_PORTREG PORTE
- #define ws2812_DDRREG DDRE
- #define ws2812_pin 2
- #define RGBLED_NUM 20 // Number of LEDs
- #define RGBLIGHT_HUE_STEP 10
- #define RGBLIGHT_SAT_STEP 17
- #define RGBLIGHT_VAL_STEP 17
+#define RGB_DI_PIN E2
+#define RGBLIGHT_TIMER
+#define RGBLED_NUM 20 // Number of LEDs
+#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_SAT_STEP 17
+#define RGBLIGHT_VAL_STEP 17
/*
* Feature disable options
diff --git a/keyboards/phantom/keymaps/default/keymap.c b/keyboards/phantom/keymaps/default/keymap.c
index 1368226aa9..a4fc319ac8 100644
--- a/keyboards/phantom/keymaps/default/keymap.c
+++ b/keyboards/phantom/keymaps/default/keymap.c
@@ -1,9 +1,5 @@
#include "phantom.h"
-#ifdef RGBLIGHT_ENABLE
-#include "rgblight.h"
-#endif
-
// Used for SHIFT_ESC
#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
@@ -59,7 +55,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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, RESET, 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_TRNS, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, \
- KC_TRNS, F(1), F(2), F(3), F(4), F(5), F(6), F(7), F(8), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
+ KC_TRNS, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, 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),
#else
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, \
@@ -73,30 +69,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
enum function_id {
SHIFT_ESC,
- #ifdef RGBLIGHT_ENABLE
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL
- #endif
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_FUNCTION(SHIFT_ESC),
- #ifdef RGBLIGHT_ENABLE
- [1] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [2] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [3] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [5] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [7] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [8] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
- #endif
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
@@ -122,48 +98,5 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
}
break;
- //led operations
- #ifdef RGBLIGHT_ENABLE
- case RGBLED_TOGGLE:
- if (record->event.pressed) {
- rgblight_toggle();
- }
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
- #endif
}
}
diff --git a/keyboards/phantom/led.c b/keyboards/phantom/led.c
index b2459c7743..69dba7d40e 100644
--- a/keyboards/phantom/led.c
+++ b/keyboards/phantom/led.c
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdint.h"
#include "led.h"
-void led_init(void) {
+void led_init_ports(void) {
// * Set our LED pins as output
DDRB |= (1<<6);
DDRB |= (1<<7);
diff --git a/keyboards/planck/keymaps/experimental/Makefile b/keyboards/planck/keymaps/experimental/Makefile
index 581e08cd02..877c4aed0e 100644
--- a/keyboards/planck/keymaps/experimental/Makefile
+++ b/keyboards/planck/keymaps/experimental/Makefile
@@ -10,12 +10,12 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = yes # 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 = yes # Enable keyboard backlight functionality
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
MIDI_ENABLE = no # MIDI controls
-AUDIO_ENABLE = yes # Audio output on port C6
+AUDIO_ENABLE = no # 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. Do not enable this with audio at the same time.
+RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
diff --git a/keyboards/planck/keymaps/experimental/config.h b/keyboards/planck/keymaps/experimental/config.h
index 985e250ab5..52acd1905e 100644
--- a/keyboards/planck/keymaps/experimental/config.h
+++ b/keyboards/planck/keymaps/experimental/config.h
@@ -6,4 +6,12 @@
#define LEADER_TIMEOUT 300
#define BACKLIGHT_BREATHING
+
+/* ws2812 RGB LED */
+#define RGB_DI_PIN B1
+#define RGBLIGHT_TIMER
+#define RGBLED_NUM 8 // Number of LEDs
+#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_SAT_STEP 17
+
#endif
diff --git a/keyboards/planck/keymaps/experimental/keymap.c b/keyboards/planck/keymaps/experimental/keymap.c
index 8ec335d7d2..d9303fcae5 100644
--- a/keyboards/planck/keymaps/experimental/keymap.c
+++ b/keyboards/planck/keymaps/experimental/keymap.c
@@ -15,7 +15,7 @@ extern keymap_config_t keymap_config;
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
-#define _QWERTY 0
+#define _QWERTY 10
#define _COLEMAK 1
#define _DVORAK 2
#define _LOWER 3
@@ -31,7 +31,15 @@ enum planck_keycodes {
LOWER,
RAISE,
BACKLIT,
- EXT_PLV
+ EXT_PLV,
+ RGBLED_TOGGLE,
+ RGBLED_STEP_MODE,
+ RGBLED_INCREASE_HUE,
+ RGBLED_DECREASE_HUE,
+ RGBLED_INCREASE_SAT,
+ RGBLED_DECREASE_SAT,
+ RGBLED_INCREASE_VAL,
+ RGBLED_DECREASE_VAL,
};
// Fillers to make layering more clear
@@ -39,14 +47,20 @@ enum planck_keycodes {
#define XXXXXXX KC_NO
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = {
+ {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL},
+ {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL},
+ {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL},
+ {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL}
+},
/* 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 |
+ * | Shift| Z | X | C | V | B | N | M |, | . | / |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
* `-----------------------------------------------------------------------------------'
@@ -292,6 +306,57 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;
return false;
+ case RGBLED_TOGGLE:
+ //led operations
+ if (record->event.pressed) {
+ rgblight_toggle();
+ }
+ return false;
+ break;
+ case RGBLED_INCREASE_HUE:
+ if (record->event.pressed) {
+ rgblight_increase_hue();
+ }
+ return false;
+ break;
+ case RGBLED_DECREASE_HUE:
+ if (record->event.pressed) {
+ rgblight_decrease_hue();
+ }
+ return false;
+ break;
+ case RGBLED_INCREASE_SAT:
+ if (record->event.pressed) {
+ rgblight_increase_sat();
+ }
+ return false;
+ break;
+ case RGBLED_DECREASE_SAT:
+ if (record->event.pressed) {
+ rgblight_decrease_sat();
+ }
+ return false;
+ break;
+ case RGBLED_INCREASE_VAL:
+ if (record->event.pressed) {
+ rgblight_increase_val();
+ }
+ return false;
+ break;
+ case RGBLED_DECREASE_VAL:
+ if (record->event.pressed) {
+ rgblight_decrease_val();
+ }
+ return false;
+ break;
+ case RGBLED_STEP_MODE:
+ if (record->event.pressed) {
+ rgblight_step();
+ }
+ return false;
+ break;
+
+
}
return true;
};
diff --git a/keyboards/planck/keymaps/pvc/config.h b/keyboards/planck/keymaps/pvc/config.h
index b648931081..c857a3e89d 100644
--- a/keyboards/planck/keymaps/pvc/config.h
+++ b/keyboards/planck/keymaps/pvc/config.h
@@ -60,9 +60,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
)
/* ws2812 RGB LED */
-#define ws2812_PORTREG PORTD
-#define ws2812_DDRREG DDRD
-#define ws2812_pin PD1
+#define RGB_DI_PIN D1
+#define RGBLIGHT_TIMER
#define RGBLED_NUM 28 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
diff --git a/keyboards/planck/keymaps/yang/config.h b/keyboards/planck/keymaps/yang/config.h
index 5921e9377c..feb5a11901 100644
--- a/keyboards/planck/keymaps/yang/config.h
+++ b/keyboards/planck/keymaps/yang/config.h
@@ -4,9 +4,8 @@
#include "../../config.h"
/* ws2812 RGB LED */
-#define ws2812_PORTREG PORTD
-#define ws2812_DDRREG DDRD
-#define ws2812_pin PD1
+#define RGB_DI_PIN D1
+#define RGBLIGHT_TIMER
#define RGBLED_NUM 28 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
diff --git a/keyboards/planck/keymaps/yang/keymap.c b/keyboards/planck/keymaps/yang/keymap.c
index 541b1a57e4..0ce849050b 100644
--- a/keyboards/planck/keymaps/yang/keymap.c
+++ b/keyboards/planck/keymaps/yang/keymap.c
@@ -51,33 +51,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_RGB] = { /* RGBLIGHT */
{KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_DEL},
{KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_HOME, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_END, KC_TRNS},
- {KC_TRNS, F(1), F(2), F(3), F(4), F(5), F(6), F(7), F(8), KC_TRNS, KC_TRNS, KC_TRNS},
+ {KC_TRNS, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, 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}
}
};
-enum function_id {
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL,
-};
+/*enum function_id {
+
+};*/
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_TAP_KEY(_RGB, KC_SPC),
- [1] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [2] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [3] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [5] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [7] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [8] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
@@ -100,47 +85,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
switch (id) {
- case RGBLED_TOGGLE:
- //led operations
- if (record->event.pressed) {
- rgblight_toggle();
- }
-
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
+
}
}
diff --git a/keyboards/preonic/config.h b/keyboards/preonic/config.h
index 04946f7fbb..3fb978c2f6 100644
--- a/keyboards/preonic/config.h
+++ b/keyboards/preonic/config.h
@@ -62,9 +62,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
)
/* ws2812 RGB LED */
-#define ws2812_PORTREG PORTD
-#define ws2812_DDRREG DDRD
-#define ws2812_pin PD1
+#define RGB_DI_PIN D1
+#define RGBLIGHT_TIMER
#define RGBLED_NUM 28 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
diff --git a/keyboards/satan/config.h b/keyboards/satan/config.h
index a7ea8f904c..7e9f91cc82 100644
--- a/keyboards/satan/config.h
+++ b/keyboards/satan/config.h
@@ -65,13 +65,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Underlight configuration
*/
- #define ws2812_PORTREG PORTE
- #define ws2812_DDRREG DDRE
- #define ws2812_pin 2
- #define RGBLED_NUM 8 // Number of LEDs
- #define RGBLIGHT_HUE_STEP 10
- #define RGBLIGHT_SAT_STEP 17
- #define RGBLIGHT_VAL_STEP 17
+
+#define RGB_DI_PIN E2
+#define RGBLIGHT_TIMER
+#define RGBLED_NUM 8 // Number of LEDs
+#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_SAT_STEP 17
+#define RGBLIGHT_VAL_STEP 17
/*
* Feature disable options
diff --git a/keyboards/satan/keymaps/default/keymap.c b/keyboards/satan/keymaps/default/keymap.c
index b19404afc7..35dbbb77b2 100644
--- a/keyboards/satan/keymaps/default/keymap.c
+++ b/keyboards/satan/keymaps/default/keymap.c
@@ -1,8 +1,5 @@
#include "satan.h"
-#ifdef RGBLIGHT_ENABLE
-#include "rgblight.h"
-#endif
// Used for SHIFT_ESC
#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
@@ -53,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_GRV, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, \
KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, BL_DEC, BL_INC, BL_TOGG, \
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, F(1), F(2), F(3), F(4), F(5), F(6), F(7), F(8), KC_TRNS, KC_TRNS, KC_TRNS, \
+ KC_TRNS,RGB_TOG,RGB_MOD,RGB_HUI,RGB_HUD,RGB_SAI,RGB_SAD,RGB_VAI,RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, \
KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
#else
KC_GRV, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, \
@@ -66,30 +63,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
enum function_id {
SHIFT_ESC,
- #ifdef RGBLIGHT_ENABLE
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL
- #endif
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_FUNCTION(SHIFT_ESC),
- #ifdef RGBLIGHT_ENABLE
- [1] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [2] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [3] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [5] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [7] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [8] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
- #endif
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
@@ -115,48 +92,5 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
}
break;
- //led operations
- #ifdef RGBLIGHT_ENABLE
- case RGBLED_TOGGLE:
- if (record->event.pressed) {
- rgblight_toggle();
- }
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
- #endif
}
}
diff --git a/keyboards/satan/keymaps/poker/keymap.c b/keyboards/satan/keymaps/poker/keymap.c
new file mode 100644
index 0000000000..8181955cf9
--- /dev/null
+++ b/keyboards/satan/keymaps/poker/keymap.c
@@ -0,0 +1,116 @@
+#include "satan.h"
+
+// Used for SHIFT_ESC
+#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
+
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+#define _BL 0
+#define _FL 1
+#define _RL 2
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ /* Keymap _BL: (Base Layer) Default Layer
+ * ,-----------------------------------------------------------.
+ * |Esc~| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
+ * |-----------------------------------------------------------|
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ |
+ * |-----------------------------------------------------------|
+ * |CAPS | A| S| D| F| G| H| J| K| L| ;| '|Return |
+ * |-----------------------------------------------------------|
+ * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
+ * |-----------------------------------------------------------|
+ * |Ctrl|Gui |Alt | Space |Alt |Gui |FN |Ctrl |
+ * `-----------------------------------------------------------'
+ */
+[_BL] = KEYMAP(
+ F(0), KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, \
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, \
+ KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, \
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, \
+ KC_LCTL, KC_LGUI,KC_LALT, KC_SPC, KC_RALT, MO(_RL), MO(_FL), KC_RCTL),
+
+/* Keymap _FL: Function Layer
+ * ,-----------------------------------------------------------.
+ * | ~ | F1|F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| DEL |
+ * |-----------------------------------------------------------|
+ * | | Up| | | | |Cal| |Ins| |PrSc|Sclk|Paus| |
+ * |-----------------------------------------------------------|
+ * | |Left|Down|Rig| | | | | | |Home|PgUp| |
+ * |-----------------------------------------------------------|
+ * | | |App| | | |Vdn|Vup|Mute|End|PgDn| |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | |
+ * `-----------------------------------------------------------'
+ */
+[_FL] = KEYMAP(
+ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, \
+ KC_TRNS,KC_TRNS, KC_UP, KC_TRNS,KC_TRNS,KC_TRNS, KC_CALC,KC_TRNS,KC_INS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_TRNS, \
+ KC_TRNS,KC_LEFT,KC_DOWN,KC_RGHT,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_HOME, KC_PGUP, KC_TRNS, \
+ KC_TRNS, KC_TRNS, KC_APP, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE, KC_END, KC_PGDN, KC_TRNS, \
+ KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
+
+ /* Keymap _RL: Function Layer
+ * ,-----------------------------------------------------------.
+ * | | | | | | | | | | | | | | RESET|
+ * |-----------------------------------------------------------|
+ * | | | | | | | | | | | |BL-|BL+|BL |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | | | | | |
+ * |-----------------------------------------------------------|
+ * | | F1|F2 | F3|F4 | F5| F6| F7| F8| | | |
+ * |-----------------------------------------------------------|
+ * | | | | | | | | |
+ * `-----------------------------------------------------------'
+ */
+[_RL] = KEYMAP(
+ #ifdef RGBLIGHT_ENABLE
+ KC_GRV, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, \
+ KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, BL_DEC, BL_INC, BL_TOGG, \
+ 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, RGB_TOG,RGB_MOD,RGB_HUI,RGB_HUD,RGB_SAI,RGB_SAD,RGB_VAI,RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, \
+ KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
+ #else
+ KC_GRV, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, \
+ KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, BL_DEC, BL_INC, BL_TOGG, \
+ 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_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),
+ #endif
+};
+
+enum function_id {
+ SHIFT_ESC,
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+ [0] = ACTION_FUNCTION(SHIFT_ESC),
+};
+
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
+ static uint8_t shift_esc_shift_mask;
+ switch (id) {
+ case SHIFT_ESC:
+ shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
+ if (record->event.pressed) {
+ if (shift_esc_shift_mask) {
+ add_key(KC_GRV);
+ send_keyboard_report();
+ } else {
+ add_key(KC_ESC);
+ send_keyboard_report();
+ }
+ } else {
+ if (shift_esc_shift_mask) {
+ del_key(KC_GRV);
+ send_keyboard_report();
+ } else {
+ del_key(KC_ESC);
+ send_keyboard_report();
+ }
+ }
+ break;
+ }
+}
diff --git a/keyboards/satan/keymaps/sethbc/keymap.c b/keyboards/satan/keymaps/sethbc/keymap.c
index 0ea4a7ae4f..f8991f9fd7 100644
--- a/keyboards/satan/keymaps/sethbc/keymap.c
+++ b/keyboards/satan/keymaps/sethbc/keymap.c
@@ -1,9 +1,5 @@
#include "satan.h"
-#ifdef RGBLIGHT_ENABLE
-#include "rgblight.h"
-#endif
-
// Used for SHIFT_ESC
#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
@@ -44,39 +40,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
#else
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, RESET, \
- KC_CAPS, KC_TRNS, F(1), F(2), F(3), KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC, \
- KC_TRNS, KC_VOLD, F(4), F(5), F(6), KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT, \
- KC_TRNS, F(7), F(8), KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, \
+ KC_CAPS, KC_TRNS, RGB_TOG,RGB_MOD,RGB_HUI, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC, \
+ KC_TRNS, KC_VOLD, RGB_HUD,RGB_SAI,RGB_SAD, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT, \
+ KC_TRNS, RGB_VAI,RGB_VAD,KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
#endif
};
enum function_id {
SHIFT_ESC,
- #ifdef RGBLIGHT_ENABLE
- RGBLED_TOGGLE,
- RGBLED_STEP_MODE,
- RGBLED_INCREASE_HUE,
- RGBLED_DECREASE_HUE,
- RGBLED_INCREASE_SAT,
- RGBLED_DECREASE_SAT,
- RGBLED_INCREASE_VAL,
- RGBLED_DECREASE_VAL
- #endif
};
const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_FUNCTION(SHIFT_ESC),
- #ifdef RGBLIGHT_ENABLE
- [1] = ACTION_FUNCTION(RGBLED_TOGGLE),
- [2] = ACTION_FUNCTION(RGBLED_STEP_MODE),
- [3] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
- [4] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
- [5] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
- [6] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
- [7] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
- [8] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
- #endif
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
@@ -102,48 +78,5 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
}
}
break;
- //led operations
- #ifdef RGBLIGHT_ENABLE
- case RGBLED_TOGGLE:
- if (record->event.pressed) {
- rgblight_toggle();
- }
- break;
- case RGBLED_INCREASE_HUE:
- if (record->event.pressed) {
- rgblight_increase_hue();
- }
- break;
- case RGBLED_DECREASE_HUE:
- if (record->event.pressed) {
- rgblight_decrease_hue();
- }
- break;
- case RGBLED_INCREASE_SAT:
- if (record->event.pressed) {
- rgblight_increase_sat();
- }
- break;
- case RGBLED_DECREASE_SAT:
- if (record->event.pressed) {
- rgblight_decrease_sat();
- }
- break;
- case RGBLED_INCREASE_VAL:
- if (record->event.pressed) {
- rgblight_increase_val();
- }
- break;
- case RGBLED_DECREASE_VAL:
- if (record->event.pressed) {
- rgblight_decrease_val();
- }
- break;
- case RGBLED_STEP_MODE:
- if (record->event.pressed) {
- rgblight_step();
- }
- break;
- #endif
}
}
diff --git a/keyboards/satan/keymaps/stanleylai/config.h b/keyboards/satan/keymaps/stanleylai/config.h
new file mode 100644
index 0000000000..ae2bd36dbb
--- /dev/null
+++ b/keyboards/satan/keymaps/stanleylai/config.h
@@ -0,0 +1,20 @@
+#include "../../config.h"
+
+// USB Device descriptor parameter
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6060
+#define DEVICE_VER 0x0003
+#define MANUFACTURER Custom
+#define PRODUCT GH60 rev.CHN
+#define DESCRIPTION QMK keyboard firmware for GH60 with WS2812 support
+
+// Backlight configuration
+#define BACKLIGHT_LEVELS 3
+
+// Underlight configuration
+#define RGB_DI_PIN E2
+#define RGBLIGHT_TIMER
+#define RGBLED_NUM 6 // Number of LEDs
+#define RGBLIGHT_HUE_STEP 8
+#define RGBLIGHT_SAT_STEP 8
+#define RGBLIGHT_VAL_STEP 8
diff --git a/keyboards/satan/keymaps/stanleylai/keymap.c b/keyboards/satan/keymaps/stanleylai/keymap.c
new file mode 100644
index 0000000000..623427e97c
--- /dev/null
+++ b/keyboards/satan/keymaps/stanleylai/keymap.c
@@ -0,0 +1,84 @@
+#include "satan.h"
+
+// Used for SHIFT_ESC
+#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
+
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+#define _BL 0
+#define _FL 1
+#define _RGBL 2
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+// See base_layer.png and rgb_layer.png for layout reference
+
+// Base Default Layer
+// Mac Modifier Layout. Use BootMagic to toggle GUI and ALT positions.
+[_BL] = KEYMAP_HHKB(
+ F(0), KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NO, \
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, \
+ LT(_FL, KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_UP, MO(_FL), \
+ KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, KC_LEFT, KC_DOWN, KC_RGHT),
+
+// Function layer
+[_FL] = KEYMAP_HHKB(
+ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_NO, \
+ KC_NO, KC_MPRV, KC_UP, KC_MNXT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_PSCR, KC_SLCK, KC_PAUS, KC_INS, \
+ KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
+ KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, LT(_RGBL, KC_PGUP), KC_TRNS, \
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, KC_TRNS, KC_HOME, KC_PGDN, KC_END),
+
+// RGB Layer
+[_RGBL] = KEYMAP_HHKB(
+ #ifdef RGBLIGHT_ENABLE
+ RESET, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
+ KC_NO, BL_TOGG, BL_STEP, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
+ KC_TRNS, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_NO, KC_NO, KC_TRNS, KC_TRNS,\
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
+ #else
+ RESET, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
+ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
+ KC_NO, BL_TOGG, BL_STEP, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
+ KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS,\
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
+ #endif
+};
+
+enum function_id {
+ SHIFT_ESC,
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+ [0] = ACTION_FUNCTION(SHIFT_ESC),
+};
+
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
+ static uint8_t shift_esc_shift_mask;
+ switch (id) {
+ case SHIFT_ESC:
+ shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
+ if (record->event.pressed) {
+ if (shift_esc_shift_mask) {
+ add_key(KC_GRV);
+ send_keyboard_report();
+ } else {
+ add_key(KC_ESC);
+ send_keyboard_report();
+ }
+ } else {
+ if (shift_esc_shift_mask) {
+ del_key(KC_GRV);
+ send_keyboard_report();
+ } else {
+ del_key(KC_ESC);
+ send_keyboard_report();
+ }
+ }
+ break;
+ }
+}
diff --git a/keyboards/stm32_f103_onekey/keymaps/default/keymap.c b/keyboards/stm32_f103_onekey/keymaps/default/keymap.c
deleted file mode 100644
index c3b0f08403..0000000000
--- a/keyboards/stm32_f103_onekey/keymaps/default/keymap.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2012,2013 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 "stm32_f103_onekey.h"
-
-const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- {{KC_CAPS}}, // test with KC_CAPS, KC_A, KC_BTLD
-};
-
-const uint16_t fn_actions[] = {
-};
diff --git a/keyboards/teensy_lc_onekey/keymaps/default/keymap.c b/keyboards/teensy_lc_onekey/keymaps/default/keymap.c
deleted file mode 100644
index a109b49600..0000000000
--- a/keyboards/teensy_lc_onekey/keymaps/default/keymap.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-Copyright 2012,2013 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 "keycode.h"
-#include "action.h"
-#include "action_macro.h"
-#include "report.h"
-#include "host.h"
-#include "print.h"
-#include "debug.h"
-#include "keymap.h"
-
-const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- {{KC_A}},
-}; // to test: KC_CAPS, KT_BTLD, KC_A
-
-const uint16_t fn_actions[] = {
-};
diff --git a/lib/ugfx b/lib/ugfx
new file mode 160000
+Subproject 13e084ae6231857cd0d472c529f34be07d93c08
diff --git a/quantum/keymap.h b/quantum/keymap.h
index 73f99f8211..a158651839 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -156,6 +156,16 @@ enum quantum_keycodes {
BL_INC,
BL_TOGG,
BL_STEP,
+
+ // RGB functionality
+ RGB_TOG,
+ RGB_MOD,
+ RGB_HUI,
+ RGB_HUD,
+ RGB_SAI,
+ RGB_SAD,
+ RGB_VAI,
+ RGB_VAD,
// Left shift, open paren
KC_LSPO,
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 76872ac592..d0a8312c1e 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -62,7 +62,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
break;
- case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
+ case KC_AUDIO_MUTE ... KC_MEDIA_REWIND:
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
break;
case KC_MS_UP ... KC_MS_ACCEL2:
diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h
index 512d8a374b..af76e39fcb 100644
--- a/quantum/keymap_extras/keymap_spanish.h
+++ b/quantum/keymap_extras/keymap_spanish.h
@@ -49,7 +49,7 @@
#define ES_PIPE ALGR(KC_1)
#define ES_AT ALGR(KC_2)
#define ES_HASH ALGR(KC_3)
-#define ES_TILD ALGR(KC_4)
+#define ES_TILD ALGR(ES_NTIL)
#define ES_EURO ALGR(KC_5)
#define ES_NOT ALGR(KC_6)
@@ -59,4 +59,4 @@
#define ES_LCBR ALGR(ES_ACUT)
#define ES_RCRB ALGR(ES_CCED)
-#endif \ No newline at end of file
+#endif
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c
index f20043067e..401845e855 100755
--- a/quantum/light_ws2812.c
+++ b/quantum/light_ws2812.c
@@ -19,12 +19,16 @@
// Setleds for standard RGB
void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds)
{
- ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
+ // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
+ ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF));
}
void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask)
{
- ws2812_DDRREG |= pinmask; // Enable DDR
+ // ws2812_DDRREG |= pinmask; // Enable DDR
+ // new universal format (DDR)
+ _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
+
ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask);
_delay_us(50);
}
@@ -32,14 +36,17 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin
// Setleds for SK6812RGBW
void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds)
{
- ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
- ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(ws2812_pin));
+ // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
+ // new universal format (DDR)
+ _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
+
+ ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
_delay_us(80);
}
void ws2812_sendarray(uint8_t *data,uint16_t datlen)
{
- ws2812_sendarray_mask(data,datlen,_BV(ws2812_pin));
+ ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF));
}
/*
@@ -108,8 +115,10 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
uint8_t curbyte,ctr,masklo;
uint8_t sreg_prev;
- masklo =~maskhi&ws2812_PORTREG;
- maskhi |= ws2812_PORTREG;
+ // masklo =~maskhi&ws2812_PORTREG;
+ // maskhi |= ws2812_PORTREG;
+ masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2);
+ maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2);
sreg_prev=SREG;
cli();
@@ -173,7 +182,7 @@ w_nop16
" dec %0 \n\t" // '1' [+2] '0' [+2]
" brne loop%=\n\t" // '1' [+3] '0' [+4]
: "=&d" (ctr)
- : "r" (curbyte), "I" (_SFR_IO_ADDR(ws2812_PORTREG)), "r" (maskhi), "r" (masklo)
+ : "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo)
);
}
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 0949170255..3174e07390 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -27,16 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h"
/* Set 0 if debouncing isn't needed */
-/*
- * This constant define not debouncing time in msecs, but amount of matrix
- * scan loops which should be made to get stable debounced results.
- *
- * On Ergodox matrix scan rate is relatively low, because of slow I2C.
- * Now it's only 317 scans/second, or about 3.15 msec/scan.
- * According to Cherry specs, debouncing time is 5 msec.
- *
- * And so, there is no sense to have DEBOUNCE higher than 2.
- */
#ifndef DEBOUNCING_DELAY
# define DEBOUNCING_DELAY 5
@@ -168,7 +158,7 @@ uint8_t matrix_scan(void)
if (debouncing) {
if (--debouncing) {
- wait_us(1);
+ wait_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
@@ -192,7 +182,7 @@ uint8_t matrix_scan(void)
if (debouncing) {
if (--debouncing) {
- wait_us(1);
+ wait_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_COLS; i++) {
matrix_reversed[i] = matrix_reversed_debouncing[i];
diff --git a/quantum/quantum.c b/quantum/quantum.c
index d91b8f2d06..d5b9753b76 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -89,20 +89,70 @@ bool process_record_quantum(keyrecord_t *record) {
shutdown_user();
#endif
wait_ms(250);
- #ifdef ATREUS_ASTAR
+ #ifdef CATERINA_BOOTLOADER
*(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
bootloader_jump();
- return false;
}
+ return false;
break;
case DEBUG:
if (record->event.pressed) {
print("\nDEBUG: enabled.\n");
debug_enable = true;
- return false;
}
+ return false;
+ break;
+ #ifdef RGBLIGHT_ENABLE
+ case RGB_TOG:
+ if (record->event.pressed) {
+ rgblight_toggle();
+ }
+ return false;
+ break;
+ case RGB_MOD:
+ if (record->event.pressed) {
+ rgblight_step();
+ }
+ return false;
+ break;
+ case RGB_HUI:
+ if (record->event.pressed) {
+ rgblight_increase_hue();
+ }
+ return false;
+ break;
+ case RGB_HUD:
+ if (record->event.pressed) {
+ rgblight_decrease_hue();
+ }
+ return false;
+ break;
+ case RGB_SAI:
+ if (record->event.pressed) {
+ rgblight_increase_sat();
+ }
+ return false;
+ break;
+ case RGB_SAD:
+ if (record->event.pressed) {
+ rgblight_decrease_sat();
+ }
+ return false;
+ break;
+ case RGB_VAI:
+ if (record->event.pressed) {
+ rgblight_increase_val();
+ }
+ return false;
+ break;
+ case RGB_VAD:
+ if (record->event.pressed) {
+ rgblight_decrease_val();
+ }
+ return false;
break;
+ #endif
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI:
if (record->event.pressed) {
// MAGIC actions (BOOTMAGIC without the boot)
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index c29ffedc38..b1b0f035d5 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -146,7 +146,9 @@ void rgblight_init(void) {
}
eeconfig_debug_rgblight(); // display current eeprom values
- rgblight_timer_init(); // setup the timer
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_init(); // setup the timer
+ #endif
if (rgblight_config.enable) {
rgblight_mode(rgblight_config.mode);
@@ -192,14 +194,19 @@ void rgblight_mode(uint8_t mode) {
eeconfig_update_rgblight(rgblight_config.raw);
xprintf("rgblight mode: %u\n", rgblight_config.mode);
if (rgblight_config.mode == 1) {
- rgblight_timer_disable();
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_disable();
+ #endif
} else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) {
// MODE 2-5, breathing
// MODE 6-8, rainbow mood
// MODE 9-14, rainbow swirl
// MODE 15-20, snake
// MODE 21-23, knight
- rgblight_timer_enable();
+
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_enable();
+ #endif
}
rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
}
@@ -211,7 +218,10 @@ void rgblight_toggle(void) {
if (rgblight_config.enable) {
rgblight_mode(rgblight_config.mode);
} else {
- rgblight_timer_disable();
+
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_disable();
+ #endif
_delay_ms(50);
rgblight_set();
}
@@ -328,6 +338,9 @@ void rgblight_set(void) {
}
}
+
+#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+
// Animation timer -- AVR Timer3
void rgblight_timer_init(void) {
static uint8_t rgblight_timer_is_init = 0;
@@ -503,3 +516,5 @@ void rgblight_effect_knight(uint8_t interval) {
}
}
+
+#endif \ No newline at end of file
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 64f92523e0..def26c428c 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -1,8 +1,11 @@
#ifndef RGBLIGHT_H
#define RGBLIGHT_H
-#ifndef RGBLIGHT_MODES
-#define RGBLIGHT_MODES 23
+
+#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ #define RGBLIGHT_MODES 23
+#else
+ #define RGBLIGHT_MODES 1
#endif
#ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH
diff --git a/quantum/serial_link/LICENSE b/quantum/serial_link/LICENSE
new file mode 100644
index 0000000000..d7cc3198cb
--- /dev/null
+++ b/quantum/serial_link/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
diff --git a/quantum/serial_link/README.md b/quantum/serial_link/README.md
new file mode 100644
index 0000000000..e8490e290d
--- /dev/null
+++ b/quantum/serial_link/README.md
@@ -0,0 +1 @@
+# qmk_serial_link \ No newline at end of file
diff --git a/quantum/serial_link/protocol/byte_stuffer.c b/quantum/serial_link/protocol/byte_stuffer.c
new file mode 100644
index 0000000000..fb4c45a8dc
--- /dev/null
+++ b/quantum/serial_link/protocol/byte_stuffer.c
@@ -0,0 +1,145 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "serial_link/protocol/byte_stuffer.h"
+#include "serial_link/protocol/frame_validator.h"
+#include "serial_link/protocol/physical.h"
+#include <stdbool.h>
+
+// This implements the "Consistent overhead byte stuffing protocol"
+// https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing
+// http://www.stuartcheshire.org/papers/COBSforToN.pdf
+
+#define MAX_FRAME_SIZE 1024
+#define NUM_LINKS 2
+
+typedef struct byte_stuffer_state {
+ uint16_t next_zero;
+ uint16_t data_pos;
+ bool long_frame;
+ uint8_t data[MAX_FRAME_SIZE];
+}byte_stuffer_state_t;
+
+static byte_stuffer_state_t states[NUM_LINKS];
+
+void init_byte_stuffer_state(byte_stuffer_state_t* state) {
+ state->next_zero = 0;
+ state->data_pos = 0;
+ state->long_frame = false;
+}
+
+void init_byte_stuffer(void) {
+ int i;
+ for (i=0;i<NUM_LINKS;i++) {
+ init_byte_stuffer_state(&states[i]);
+ }
+}
+
+void byte_stuffer_recv_byte(uint8_t link, uint8_t data) {
+ byte_stuffer_state_t* state = &states[link];
+ // Start of a new frame
+ if (state->next_zero == 0) {
+ state->next_zero = data;
+ state->long_frame = data == 0xFF;
+ state->data_pos = 0;
+ return;
+ }
+
+ state->next_zero--;
+ if (data == 0) {
+ if (state->next_zero == 0) {
+ // The frame is completed
+ if (state->data_pos > 0) {
+ validator_recv_frame(link, state->data, state->data_pos);
+ }
+ }
+ else {
+ // The frame is invalid, so reset
+ init_byte_stuffer_state(state);
+ }
+ }
+ else {
+ if (state->data_pos == MAX_FRAME_SIZE) {
+ // We exceeded our maximum frame size
+ // therefore there's nothing else to do than reset to a new frame
+ state->next_zero = data;
+ state->long_frame = data == 0xFF;
+ state->data_pos = 0;
+ }
+ else if (state->next_zero == 0) {
+ if (state->long_frame) {
+ // This is part of a long frame, so continue
+ state->next_zero = data;
+ state->long_frame = data == 0xFF;
+ }
+ else {
+ // Special case for zeroes
+ state->next_zero = data;
+ state->data[state->data_pos++] = 0;
+ }
+ }
+ else {
+ state->data[state->data_pos++] = data;
+ }
+ }
+}
+
+static void send_block(uint8_t link, uint8_t* start, uint8_t* end, uint8_t num_non_zero) {
+ send_data(link, &num_non_zero, 1);
+ if (end > start) {
+ send_data(link, start, end-start);
+ }
+}
+
+void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size) {
+ const uint8_t zero = 0;
+ if (size > 0) {
+ uint16_t num_non_zero = 1;
+ uint8_t* end = data + size;
+ uint8_t* start = data;
+ while (data < end) {
+ if (num_non_zero == 0xFF) {
+ // There's more data after big non-zero block
+ // So send it, and start a new block
+ send_block(link, start, data, num_non_zero);
+ start = data;
+ num_non_zero = 1;
+ }
+ else {
+ if (*data == 0) {
+ // A zero encountered, so send the block
+ send_block(link, start, data, num_non_zero);
+ start = data + 1;
+ num_non_zero = 1;
+ }
+ else {
+ num_non_zero++;
+ }
+ ++data;
+ }
+ }
+ send_block(link, start, data, num_non_zero);
+ send_data(link, &zero, 1);
+ }
+}
diff --git a/quantum/serial_link/protocol/byte_stuffer.h b/quantum/serial_link/protocol/byte_stuffer.h
new file mode 100644
index 0000000000..2cc88beb42
--- /dev/null
+++ b/quantum/serial_link/protocol/byte_stuffer.h
@@ -0,0 +1,34 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef SERIAL_LINK_BYTE_STUFFER_H
+#define SERIAL_LINK_BYTE_STUFFER_H
+
+#include <stdint.h>
+
+void init_byte_stuffer(void);
+void byte_stuffer_recv_byte(uint8_t link, uint8_t data);
+void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size);
+
+#endif
diff --git a/quantum/serial_link/protocol/frame_router.c b/quantum/serial_link/protocol/frame_router.c
new file mode 100644
index 0000000000..04b8c2e75c
--- /dev/null
+++ b/quantum/serial_link/protocol/frame_router.c
@@ -0,0 +1,69 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "serial_link/protocol/frame_router.h"
+#include "serial_link/protocol/transport.h"
+#include "serial_link/protocol/frame_validator.h"
+
+static bool is_master;
+
+void router_set_master(bool master) {
+ is_master = master;
+}
+
+void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size){
+ if (is_master) {
+ if (link == DOWN_LINK) {
+ transport_recv_frame(data[size-1], data, size - 1);
+ }
+ }
+ else {
+ if (link == UP_LINK) {
+ if (data[size-1] & 1) {
+ transport_recv_frame(0, data, size - 1);
+ }
+ data[size-1] >>= 1;
+ validator_send_frame(DOWN_LINK, data, size);
+ }
+ else {
+ data[size-1]++;
+ validator_send_frame(UP_LINK, data, size);
+ }
+ }
+}
+
+void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) {
+ if (destination == 0) {
+ if (!is_master) {
+ data[size] = 1;
+ validator_send_frame(UP_LINK, data, size + 1);
+ }
+ }
+ else {
+ if (is_master) {
+ data[size] = destination;
+ validator_send_frame(DOWN_LINK, data, size + 1);
+ }
+ }
+}
diff --git a/quantum/serial_link/protocol/frame_router.h b/quantum/serial_link/protocol/frame_router.h
new file mode 100644
index 0000000000..712250ff35
--- /dev/null
+++ b/quantum/serial_link/protocol/frame_router.h
@@ -0,0 +1,38 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef SERIAL_LINK_FRAME_ROUTER_H
+#define SERIAL_LINK_FRAME_ROUTER_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#define UP_LINK 0
+#define DOWN_LINK 1
+
+void router_set_master(bool master);
+void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size);
+void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size);
+
+#endif
diff --git a/quantum/serial_link/protocol/frame_validator.c b/quantum/serial_link/protocol/frame_validator.c
new file mode 100644
index 0000000000..474f80ee8e
--- /dev/null
+++ b/quantum/serial_link/protocol/frame_validator.c
@@ -0,0 +1,121 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "serial_link/protocol/frame_validator.h"
+#include "serial_link/protocol/frame_router.h"
+#include "serial_link/protocol/byte_stuffer.h"
+#include <string.h>
+
+const uint32_t poly8_lookup[256] =
+{
+ 0, 0x77073096, 0xEE0E612C, 0x990951BA,
+ 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
+ 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
+ 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
+ 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
+ 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
+ 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
+ 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
+ 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
+ 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
+ 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
+ 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
+ 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
+ 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
+ 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
+ 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
+ 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
+ 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
+ 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
+ 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
+ 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
+ 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
+ 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
+ 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
+ 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
+ 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
+ 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
+ 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
+ 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
+ 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
+ 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
+ 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
+ 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
+ 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
+ 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
+ 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
+ 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
+ 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
+ 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
+ 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
+ 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
+ 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
+ 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
+ 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
+ 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
+ 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
+ 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
+ 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
+ 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
+ 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
+ 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
+ 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
+ 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
+ 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
+ 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
+ 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
+ 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
+ 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
+ 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
+ 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
+ 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
+ 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
+ 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
+ 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
+};
+
+static uint32_t crc32_byte(uint8_t *p, uint32_t bytelength)
+{
+ uint32_t crc = 0xffffffff;
+ while (bytelength-- !=0) crc = poly8_lookup[((uint8_t) crc ^ *(p++))] ^ (crc >> 8);
+ // return (~crc); also works
+ return (crc ^ 0xffffffff);
+}
+
+void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size) {
+ if (size > 4) {
+ uint32_t frame_crc;
+ memcpy(&frame_crc, data + size -4, 4);
+ uint32_t expected_crc = crc32_byte(data, size - 4);
+ if (frame_crc == expected_crc) {
+ route_incoming_frame(link, data, size-4);
+ }
+ }
+}
+
+void validator_send_frame(uint8_t link, uint8_t* data, uint16_t size) {
+ uint32_t crc = crc32_byte(data, size);
+ memcpy(data + size, &crc, 4);
+ byte_stuffer_send_frame(link, data, size + 4);
+}
diff --git a/quantum/serial_link/protocol/frame_validator.h b/quantum/serial_link/protocol/frame_validator.h
new file mode 100644
index 0000000000..4a910d510b
--- /dev/null
+++ b/quantum/serial_link/protocol/frame_validator.h
@@ -0,0 +1,34 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef SERIAL_LINK_FRAME_VALIDATOR_H
+#define SERIAL_LINK_FRAME_VALIDATOR_H
+
+#include <stdint.h>
+
+void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size);
+// The buffer pointed to by the data needs 4 additional bytes
+void validator_send_frame(uint8_t link, uint8_t* data, uint16_t size);
+
+#endif
diff --git a/quantum/serial_link/protocol/physical.h b/quantum/serial_link/protocol/physical.h
new file mode 100644
index 0000000000..425e06cdd2
--- /dev/null
+++ b/quantum/serial_link/protocol/physical.h
@@ -0,0 +1,30 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef SERIAL_LINK_PHYSICAL_H
+#define SERIAL_LINK_PHYSICAL_H
+
+void send_data(uint8_t link, const uint8_t* data, uint16_t size);
+
+#endif
diff --git a/quantum/serial_link/protocol/transport.c b/quantum/serial_link/protocol/transport.c
new file mode 100644
index 0000000000..f418d11ceb
--- /dev/null
+++ b/quantum/serial_link/protocol/transport.c
@@ -0,0 +1,124 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "serial_link/protocol/transport.h"
+#include "serial_link/protocol/frame_router.h"
+#include "serial_link/protocol/triple_buffered_object.h"
+#include <string.h>
+
+#define MAX_REMOTE_OBJECTS 16
+static remote_object_t* remote_objects[MAX_REMOTE_OBJECTS];
+static uint32_t num_remote_objects = 0;
+
+void add_remote_objects(remote_object_t** _remote_objects, uint32_t _num_remote_objects) {
+ unsigned int i;
+ for(i=0;i<_num_remote_objects;i++) {
+ remote_object_t* obj = _remote_objects[i];
+ remote_objects[num_remote_objects++] = obj;
+ if (obj->object_type == MASTER_TO_ALL_SLAVES) {
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer;
+ triple_buffer_init(tb);
+ uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);
+ tb = (triple_buffer_object_t*)start;
+ triple_buffer_init(tb);
+ }
+ else if(obj->object_type == MASTER_TO_SINGLE_SLAVE) {
+ uint8_t* start = obj->buffer;
+ unsigned int j;
+ for (j=0;j<NUM_SLAVES;j++) {
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ triple_buffer_init(tb);
+ start += LOCAL_OBJECT_SIZE(obj->object_size);
+ }
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ triple_buffer_init(tb);
+ }
+ else {
+ uint8_t* start = obj->buffer;
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ triple_buffer_init(tb);
+ start += LOCAL_OBJECT_SIZE(obj->object_size);
+ unsigned int j;
+ for (j=0;j<NUM_SLAVES;j++) {
+ tb = (triple_buffer_object_t*)start;
+ triple_buffer_init(tb);
+ start += REMOTE_OBJECT_SIZE(obj->object_size);
+ }
+ }
+ }
+}
+
+void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size) {
+ uint8_t id = data[size-1];
+ if (id < num_remote_objects) {
+ remote_object_t* obj = remote_objects[id];
+ if (obj->object_size == size - 1) {
+ uint8_t* start;
+ if (obj->object_type == MASTER_TO_ALL_SLAVES) {
+ start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);
+ }
+ else if(obj->object_type == SLAVE_TO_MASTER) {
+ start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);
+ start += (from - 1) * REMOTE_OBJECT_SIZE(obj->object_size);
+ }
+ else {
+ start = obj->buffer + NUM_SLAVES * LOCAL_OBJECT_SIZE(obj->object_size);
+ }
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ void* ptr = triple_buffer_begin_write_internal(obj->object_size, tb);
+ memcpy(ptr, data, size - 1);
+ triple_buffer_end_write_internal(tb);
+ }
+ }
+}
+
+void update_transport(void) {
+ unsigned int i;
+ for(i=0;i<num_remote_objects;i++) {
+ remote_object_t* obj = remote_objects[i];
+ if (obj->object_type == MASTER_TO_ALL_SLAVES || obj->object_type == SLAVE_TO_MASTER) {
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer;
+ uint8_t* ptr = (uint8_t*)triple_buffer_read_internal(obj->object_size + LOCAL_OBJECT_EXTRA, tb);
+ if (ptr) {
+ ptr[obj->object_size] = i;
+ uint8_t dest = obj->object_type == MASTER_TO_ALL_SLAVES ? 0xFF : 0;
+ router_send_frame(dest, ptr, obj->object_size + 1);
+ }
+ }
+ else {
+ uint8_t* start = obj->buffer;
+ unsigned int j;
+ for (j=0;j<NUM_SLAVES;j++) {
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
+ uint8_t* ptr = (uint8_t*)triple_buffer_read_internal(obj->object_size + LOCAL_OBJECT_EXTRA, tb);
+ if (ptr) {
+ ptr[obj->object_size] = i;
+ uint8_t dest = j + 1;
+ router_send_frame(dest, ptr, obj->object_size + 1);
+ }
+ start += LOCAL_OBJECT_SIZE(obj->object_size);
+ }
+ }
+ }
+}
diff --git a/quantum/serial_link/protocol/transport.h b/quantum/serial_link/protocol/transport.h
new file mode 100644
index 0000000000..9a052d8809
--- /dev/null
+++ b/quantum/serial_link/protocol/transport.h
@@ -0,0 +1,151 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef SERIAL_LINK_TRANSPORT_H
+#define SERIAL_LINK_TRANSPORT_H
+
+#include "serial_link/protocol/triple_buffered_object.h"
+#include "serial_link/system/serial_link.h"
+
+#define NUM_SLAVES 8
+#define LOCAL_OBJECT_EXTRA 16
+
+// master -> slave = 1 local(target all), 1 remote object
+// slave -> master = 1 local(target 0), multiple remote objects
+// master -> single slave (multiple local, target id), 1 remote object
+typedef enum {
+ MASTER_TO_ALL_SLAVES,
+ MASTER_TO_SINGLE_SLAVE,
+ SLAVE_TO_MASTER,
+} remote_object_type;
+
+typedef struct {
+ remote_object_type object_type;
+ uint16_t object_size;
+ uint8_t buffer[] __attribute__((aligned(4)));
+} remote_object_t;
+
+#define REMOTE_OBJECT_SIZE(objectsize) \
+ (sizeof(triple_buffer_object_t) + objectsize * 3)
+#define LOCAL_OBJECT_SIZE(objectsize) \
+ (sizeof(triple_buffer_object_t) + (objectsize + LOCAL_OBJECT_EXTRA) * 3)
+
+#define REMOTE_OBJECT_HELPER(name, type, num_local, num_remote) \
+typedef struct { \
+ remote_object_t object; \
+ uint8_t buffer[ \
+ num_remote * REMOTE_OBJECT_SIZE(sizeof(type)) + \
+ num_local * LOCAL_OBJECT_SIZE(sizeof(type))]; \
+} remote_object_##name##_t;
+
+#define MASTER_TO_ALL_SLAVES_OBJECT(name, type) \
+ REMOTE_OBJECT_HELPER(name, type, 1, 1) \
+ remote_object_##name##_t remote_object_##name = { \
+ .object = { \
+ .object_type = MASTER_TO_ALL_SLAVES, \
+ .object_size = sizeof(type), \
+ } \
+ }; \
+ type* begin_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+ return (type*)triple_buffer_begin_write_internal(sizeof(type) + LOCAL_OBJECT_EXTRA, tb); \
+ }\
+ void end_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+ triple_buffer_end_write_internal(tb); \
+ signal_data_written(); \
+ }\
+ type* read_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);\
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ return triple_buffer_read_internal(obj->object_size, tb); \
+ }
+
+#define MASTER_TO_SINGLE_SLAVE_OBJECT(name, type) \
+ REMOTE_OBJECT_HELPER(name, type, NUM_SLAVES, 1) \
+ remote_object_##name##_t remote_object_##name = { \
+ .object = { \
+ .object_type = MASTER_TO_SINGLE_SLAVE, \
+ .object_size = sizeof(type), \
+ } \
+ }; \
+ type* begin_write_##name(uint8_t slave) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer;\
+ start += slave * LOCAL_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ return (type*)triple_buffer_begin_write_internal(sizeof(type) + LOCAL_OBJECT_EXTRA, tb); \
+ }\
+ void end_write_##name(uint8_t slave) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer;\
+ start += slave * LOCAL_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ triple_buffer_end_write_internal(tb); \
+ signal_data_written(); \
+ }\
+ type* read_##name() { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer + NUM_SLAVES * LOCAL_OBJECT_SIZE(obj->object_size);\
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ return triple_buffer_read_internal(obj->object_size, tb); \
+ }
+
+#define SLAVE_TO_MASTER_OBJECT(name, type) \
+ REMOTE_OBJECT_HELPER(name, type, 1, NUM_SLAVES) \
+ remote_object_##name##_t remote_object_##name = { \
+ .object = { \
+ .object_type = SLAVE_TO_MASTER, \
+ .object_size = sizeof(type), \
+ } \
+ }; \
+ type* begin_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+ return (type*)triple_buffer_begin_write_internal(sizeof(type) + LOCAL_OBJECT_EXTRA, tb); \
+ }\
+ void end_write_##name(void) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)obj->buffer; \
+ triple_buffer_end_write_internal(tb); \
+ signal_data_written(); \
+ }\
+ type* read_##name(uint8_t slave) { \
+ remote_object_t* obj = (remote_object_t*)&remote_object_##name; \
+ uint8_t* start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size);\
+ start+=slave * REMOTE_OBJECT_SIZE(obj->object_size); \
+ triple_buffer_object_t* tb = (triple_buffer_object_t*)start; \
+ return triple_buffer_read_internal(obj->object_size, tb); \
+ }
+
+#define REMOTE_OBJECT(name) (remote_object_t*)&remote_object_##name
+
+void add_remote_objects(remote_object_t** remote_objects, uint32_t num_remote_objects);
+void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size);
+void update_transport(void);
+
+#endif
diff --git a/quantum/serial_link/protocol/triple_buffered_object.c b/quantum/serial_link/protocol/triple_buffered_object.c
new file mode 100644
index 0000000000..e3e8989d30
--- /dev/null
+++ b/quantum/serial_link/protocol/triple_buffered_object.c
@@ -0,0 +1,78 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "serial_link/protocol/triple_buffered_object.h"
+#include "serial_link/system/serial_link.h"
+#include <stdbool.h>
+#include <stddef.h>
+
+#define GET_READ_INDEX() object->state & 3
+#define GET_WRITE_INDEX() (object->state >> 2) & 3
+#define GET_SHARED_INDEX() (object->state >> 4) & 3
+#define GET_DATA_AVAILABLE() (object->state >> 6) & 1
+
+#define SET_READ_INDEX(i) object->state = ((object->state & ~3) | i)
+#define SET_WRITE_INDEX(i) object->state = ((object->state & ~(3 << 2)) | (i << 2))
+#define SET_SHARED_INDEX(i) object->state = ((object->state & ~(3 << 4)) | (i << 4))
+#define SET_DATA_AVAILABLE(i) object->state = ((object->state & ~(1 << 6)) | (i << 6))
+
+void triple_buffer_init(triple_buffer_object_t* object) {
+ object->state = 0;
+ SET_WRITE_INDEX(0);
+ SET_READ_INDEX(1);
+ SET_SHARED_INDEX(2);
+ SET_DATA_AVAILABLE(0);
+}
+
+void* triple_buffer_read_internal(uint16_t object_size, triple_buffer_object_t* object) {
+ serial_link_lock();
+ if (GET_DATA_AVAILABLE()) {
+ uint8_t shared_index = GET_SHARED_INDEX();
+ uint8_t read_index = GET_READ_INDEX();
+ SET_READ_INDEX(shared_index);
+ SET_SHARED_INDEX(read_index);
+ SET_DATA_AVAILABLE(false);
+ serial_link_unlock();
+ return object->buffer + object_size * shared_index;
+ }
+ else {
+ serial_link_unlock();
+ return NULL;
+ }
+}
+
+void* triple_buffer_begin_write_internal(uint16_t object_size, triple_buffer_object_t* object) {
+ uint8_t write_index = GET_WRITE_INDEX();
+ return object->buffer + object_size * write_index;
+}
+
+void triple_buffer_end_write_internal(triple_buffer_object_t* object) {
+ serial_link_lock();
+ uint8_t shared_index = GET_SHARED_INDEX();
+ uint8_t write_index = GET_WRITE_INDEX();
+ SET_SHARED_INDEX(write_index);
+ SET_WRITE_INDEX(shared_index);
+ SET_DATA_AVAILABLE(true);
+ serial_link_unlock();
+}
diff --git a/quantum/serial_link/protocol/triple_buffered_object.h b/quantum/serial_link/protocol/triple_buffered_object.h
new file mode 100644
index 0000000000..2e57db3f50
--- /dev/null
+++ b/quantum/serial_link/protocol/triple_buffered_object.h
@@ -0,0 +1,51 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef SERIAL_LINK_TRIPLE_BUFFERED_OBJECT_H
+#define SERIAL_LINK_TRIPLE_BUFFERED_OBJECT_H
+
+#include <stdint.h>
+
+typedef struct {
+ uint8_t state;
+ uint8_t buffer[] __attribute__((aligned(4)));
+}triple_buffer_object_t;
+
+void triple_buffer_init(triple_buffer_object_t* object);
+
+#define triple_buffer_begin_write(object) \
+ (typeof(*object.buffer[0])*)triple_buffer_begin_write_internal(sizeof(*object.buffer[0]), (triple_buffer_object_t*)object)
+
+#define triple_buffer_end_write(object) \
+ triple_buffer_end_write_internal((triple_buffer_object_t*)object)
+
+#define triple_buffer_read(object) \
+ (typeof(*object.buffer[0])*)triple_buffer_read_internal(sizeof(*object.buffer[0]), (triple_buffer_object_t*)object)
+
+void* triple_buffer_begin_write_internal(uint16_t object_size, triple_buffer_object_t* object);
+void triple_buffer_end_write_internal(triple_buffer_object_t* object);
+void* triple_buffer_read_internal(uint16_t object_size, triple_buffer_object_t* object);
+
+
+#endif
diff --git a/quantum/serial_link/system/serial_link.c b/quantum/serial_link/system/serial_link.c
new file mode 100644
index 0000000000..75c7e77a76
--- /dev/null
+++ b/quantum/serial_link/system/serial_link.c
@@ -0,0 +1,265 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+#include "report.h"
+#include "host_driver.h"
+#include "serial_link/system/serial_link.h"
+#include "hal.h"
+#include "serial_link/protocol/byte_stuffer.h"
+#include "serial_link/protocol/transport.h"
+#include "serial_link/protocol/frame_router.h"
+#include "matrix.h"
+#include <stdbool.h>
+#include "print.h"
+#include "config.h"
+
+static event_source_t new_data_event;
+static bool serial_link_connected;
+static bool is_master = false;
+
+static uint8_t keyboard_leds(void);
+static void send_keyboard(report_keyboard_t *report);
+static void send_mouse(report_mouse_t *report);
+static void send_system(uint16_t data);
+static void send_consumer(uint16_t data);
+
+host_driver_t serial_driver = {
+ keyboard_leds,
+ send_keyboard,
+ send_mouse,
+ send_system,
+ send_consumer
+};
+
+// Define these in your Config.h file
+#ifndef SERIAL_LINK_BAUD
+#error "Serial link baud is not set"
+#endif
+
+#ifndef SERIAL_LINK_THREAD_PRIORITY
+#error "Serial link thread priority not set"
+#endif
+
+static SerialConfig config = {
+ .sc_speed = SERIAL_LINK_BAUD
+};
+
+//#define DEBUG_LINK_ERRORS
+
+static uint32_t read_from_serial(SerialDriver* driver, uint8_t link) {
+ const uint32_t buffer_size = 16;
+ uint8_t buffer[buffer_size];
+ uint32_t bytes_read = sdAsynchronousRead(driver, buffer, buffer_size);
+ uint8_t* current = buffer;
+ uint8_t* end = current + bytes_read;
+ while(current < end) {
+ byte_stuffer_recv_byte(link, *current);
+ current++;
+ }
+ return bytes_read;
+}
+
+static void print_error(char* str, eventflags_t flags, SerialDriver* driver) {
+#ifdef DEBUG_LINK_ERRORS
+ if (flags & SD_PARITY_ERROR) {
+ print(str);
+ print(" Parity error\n");
+ }
+ if (flags & SD_FRAMING_ERROR) {
+ print(str);
+ print(" Framing error\n");
+ }
+ if (flags & SD_OVERRUN_ERROR) {
+ print(str);
+ uint32_t size = qSpaceI(&(driver->iqueue));
+ xprintf(" Overrun error, queue size %d\n", size);
+
+ }
+ if (flags & SD_NOISE_ERROR) {
+ print(str);
+ print(" Noise error\n");
+ }
+ if (flags & SD_BREAK_DETECTED) {
+ print(str);
+ print(" Break detected\n");
+ }
+#else
+ (void)str;
+ (void)flags;
+ (void)driver;
+#endif
+}
+
+bool is_serial_link_master(void) {
+ return is_master;
+}
+
+// TODO: Optimize the stack size, this is probably way too big
+static THD_WORKING_AREA(serialThreadStack, 1024);
+static THD_FUNCTION(serialThread, arg) {
+ (void)arg;
+ event_listener_t new_data_listener;
+ event_listener_t sd1_listener;
+ event_listener_t sd2_listener;
+ chEvtRegister(&new_data_event, &new_data_listener, 0);
+ eventflags_t events = CHN_INPUT_AVAILABLE
+ | SD_PARITY_ERROR | SD_FRAMING_ERROR | SD_OVERRUN_ERROR | SD_NOISE_ERROR | SD_BREAK_DETECTED;
+ chEvtRegisterMaskWithFlags(chnGetEventSource(&SD1),
+ &sd1_listener,
+ EVENT_MASK(1),
+ events);
+ chEvtRegisterMaskWithFlags(chnGetEventSource(&SD2),
+ &sd2_listener,
+ EVENT_MASK(2),
+ events);
+ bool need_wait = false;
+ while(true) {
+ eventflags_t flags1 = 0;
+ eventflags_t flags2 = 0;
+ if (need_wait) {
+ eventmask_t mask = chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
+ if (mask & EVENT_MASK(1)) {
+ flags1 = chEvtGetAndClearFlags(&sd1_listener);
+ print_error("DOWNLINK", flags1, &SD1);
+ }
+ if (mask & EVENT_MASK(2)) {
+ flags2 = chEvtGetAndClearFlags(&sd2_listener);
+ print_error("UPLINK", flags2, &SD2);
+ }
+ }
+
+ // Always stay as master, even if the USB goes into sleep mode
+ is_master |= usbGetDriverStateI(&USBD1) == USB_ACTIVE;
+ router_set_master(is_master);
+
+ need_wait = true;
+ need_wait &= read_from_serial(&SD2, UP_LINK) == 0;
+ need_wait &= read_from_serial(&SD1, DOWN_LINK) == 0;
+ update_transport();
+ }
+}
+
+void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
+ if (link == DOWN_LINK) {
+ sdWrite(&SD1, data, size);
+ }
+ else {
+ sdWrite(&SD2, data, size);
+ }
+}
+
+static systime_t last_update = 0;
+
+typedef struct {
+ matrix_row_t rows[MATRIX_ROWS];
+} matrix_object_t;
+
+static matrix_object_t last_matrix = {};
+
+SLAVE_TO_MASTER_OBJECT(keyboard_matrix, matrix_object_t);
+MASTER_TO_ALL_SLAVES_OBJECT(serial_link_connected, bool);
+
+static remote_object_t* remote_objects[] = {
+ REMOTE_OBJECT(serial_link_connected),
+ REMOTE_OBJECT(keyboard_matrix),
+};
+
+void init_serial_link(void) {
+ serial_link_connected = false;
+ init_serial_link_hal();
+ add_remote_objects(remote_objects, sizeof(remote_objects)/sizeof(remote_object_t*));
+ init_byte_stuffer();
+ sdStart(&SD1, &config);
+ sdStart(&SD2, &config);
+ chEvtObjectInit(&new_data_event);
+ (void)chThdCreateStatic(serialThreadStack, sizeof(serialThreadStack),
+ SERIAL_LINK_THREAD_PRIORITY, serialThread, NULL);
+}
+
+void matrix_set_remote(matrix_row_t* rows, uint8_t index);
+
+void serial_link_update(void) {
+ if (read_serial_link_connected()) {
+ serial_link_connected = true;
+ }
+
+ matrix_object_t matrix;
+ bool changed = false;
+ for(uint8_t i=0;i<MATRIX_ROWS;i++) {
+ matrix.rows[i] = matrix_get_row(i);
+ changed |= matrix.rows[i] != last_matrix.rows[i];
+ }
+
+ systime_t current_time = chVTGetSystemTimeX();
+ systime_t delta = current_time - last_update;
+ if (changed || delta > US2ST(1000)) {
+ last_update = current_time;
+ last_matrix = matrix;
+ matrix_object_t* m = begin_write_keyboard_matrix();
+ for(uint8_t i=0;i<MATRIX_ROWS;i++) {
+ m->rows[i] = matrix.rows[i];
+ }
+ end_write_keyboard_matrix();
+ *begin_write_serial_link_connected() = true;
+ end_write_serial_link_connected();
+ }
+
+ matrix_object_t* m = read_keyboard_matrix(0);
+ if (m) {
+ matrix_set_remote(m->rows, 0);
+ }
+}
+
+void signal_data_written(void) {
+ chEvtBroadcast(&new_data_event);
+}
+
+bool is_serial_link_connected(void) {
+ return serial_link_connected;
+}
+
+host_driver_t* get_serial_link_driver(void) {
+ return &serial_driver;
+}
+
+// NOTE: The driver does nothing, because the master handles everything
+uint8_t keyboard_leds(void) {
+ return 0;
+}
+
+void send_keyboard(report_keyboard_t *report) {
+ (void)report;
+}
+
+void send_mouse(report_mouse_t *report) {
+ (void)report;
+}
+
+void send_system(uint16_t data) {
+ (void)data;
+}
+
+void send_consumer(uint16_t data) {
+ (void)data;
+}
+
diff --git a/quantum/serial_link/system/serial_link.h b/quantum/serial_link/system/serial_link.h
new file mode 100644
index 0000000000..351e03877b
--- /dev/null
+++ b/quantum/serial_link/system/serial_link.h
@@ -0,0 +1,63 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef SERIAL_LINK_H
+#define SERIAL_LINK_H
+
+#include "host_driver.h"
+#include <stdbool.h>
+
+void init_serial_link(void);
+void init_serial_link_hal(void);
+bool is_serial_link_connected(void);
+bool is_serial_link_master(void);
+host_driver_t* get_serial_link_driver(void);
+void serial_link_update(void);
+
+#if defined(PROTOCOL_CHIBIOS)
+#include "ch.h"
+
+static inline void serial_link_lock(void) {
+ chSysLock();
+}
+
+static inline void serial_link_unlock(void) {
+ chSysUnlock();
+}
+
+void signal_data_written(void);
+
+#else
+
+inline void serial_link_lock(void) {
+}
+
+inline void serial_link_unlock(void) {
+}
+
+void signal_data_written(void);
+
+#endif
+
+#endif
diff --git a/quantum/serial_link/tests/Makefile b/quantum/serial_link/tests/Makefile
new file mode 100644
index 0000000000..1b072c6f1d
--- /dev/null
+++ b/quantum/serial_link/tests/Makefile
@@ -0,0 +1,61 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2016 Fred Sundvik
+#
+# 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.
+
+CC = gcc
+CFLAGS =
+INCLUDES = -I. -I../../
+LDFLAGS = -L$(BUILDDIR)/cgreen/build-c/src -shared
+LDLIBS = -lcgreen
+UNITOBJ = $(BUILDDIR)/serialtest/unitobj
+DEPDIR = $(BUILDDIR)/serialtest/unit.d
+UNITTESTS = $(BUILDDIR)/serialtest/unittests
+DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
+EXT = .so
+UNAME := $(shell uname)
+ifneq (, $(findstring MINGW, $(UNAME)))
+ EXT = .dll
+endif
+ifneq (, $(findstring CYGWIN, $(UNAME)))
+ EXT = .dll
+endif
+
+SRC = $(wildcard *.c)
+TESTFILES = $(patsubst %.c, $(UNITTESTS)/%$(EXT), $(SRC))
+$(shell mkdir -p $(DEPDIR) >/dev/null)
+
+test: $(TESTFILES)
+ @$(BUILDDIR)/cgreen/build-c/tools/cgreen-runner --color $(TESTFILES)
+
+$(UNITTESTS)/%$(EXT): $(UNITOBJ)/%.o
+ @mkdir -p $(UNITTESTS)
+ $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
+$(UNITOBJ)/%.o : %.c
+$(UNITOBJ)/%.o: %.c $(DEPDIR)/%.d
+ @mkdir -p $(UNITOBJ)
+ $(CC) $(CFLAGS) $(DEPFLAGS) $(INCLUDES) -c $< -o $@
+ @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
+
+$(DEPDIR)/%.d: ;
+.PRECIOUS: $(DEPDIR)/%.d
+
+-include $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRC))) \ No newline at end of file
diff --git a/quantum/serial_link/tests/byte_stuffer_tests.c b/quantum/serial_link/tests/byte_stuffer_tests.c
new file mode 100644
index 0000000000..64b170e8c1
--- /dev/null
+++ b/quantum/serial_link/tests/byte_stuffer_tests.c
@@ -0,0 +1,506 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include <cgreen/cgreen.h>
+#include <cgreen/mocks.h>
+#include "serial_link/protocol/byte_stuffer.h"
+#include "serial_link/protocol/byte_stuffer.c"
+#include "serial_link/protocol/frame_validator.h"
+#include "serial_link/protocol/physical.h"
+
+static uint8_t sent_data[MAX_FRAME_SIZE*2];
+static uint16_t sent_data_size;
+
+Describe(ByteStuffer);
+BeforeEach(ByteStuffer) {
+ init_byte_stuffer();
+ sent_data_size = 0;
+}
+AfterEach(ByteStuffer) {}
+
+void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size) {
+ mock(data, size);
+}
+
+void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
+ memcpy(sent_data + sent_data_size, data, size);
+ sent_data_size += size;
+}
+
+Ensure(ByteStuffer, receives_no_frame_for_a_single_zero_byte) {
+ never_expect(validator_recv_frame);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_no_frame_for_a_single_FF_byte) {
+ never_expect(validator_recv_frame);
+ byte_stuffer_recv_byte(0, 0xFF);
+}
+
+Ensure(ByteStuffer, receives_no_frame_for_a_single_random_byte) {
+ never_expect(validator_recv_frame);
+ byte_stuffer_recv_byte(0, 0x4A);
+}
+
+Ensure(ByteStuffer, receives_no_frame_for_a_zero_length_frame) {
+ never_expect(validator_recv_frame);
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_single_byte_valid_frame) {
+ uint8_t expected[] = {0x37};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(1)),
+ when(data, is_equal_to_contents_of(expected, 1))
+ );
+ byte_stuffer_recv_byte(0, 2);
+ byte_stuffer_recv_byte(0, 0x37);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_three_bytes_valid_frame) {
+ uint8_t expected[] = {0x37, 0x99, 0xFF};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(3)),
+ when(data, is_equal_to_contents_of(expected, 3))
+ );
+ byte_stuffer_recv_byte(0, 4);
+ byte_stuffer_recv_byte(0, 0x37);
+ byte_stuffer_recv_byte(0, 0x99);
+ byte_stuffer_recv_byte(0, 0xFF);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_single_zero_valid_frame) {
+ uint8_t expected[] = {0};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(1)),
+ when(data, is_equal_to_contents_of(expected, 1))
+ );
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_valid_frame_with_zeroes) {
+ uint8_t expected[] = {5, 0, 3, 0};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(expected, 4))
+ );
+ byte_stuffer_recv_byte(0, 2);
+ byte_stuffer_recv_byte(0, 5);
+ byte_stuffer_recv_byte(0, 2);
+ byte_stuffer_recv_byte(0, 3);
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_two_valid_frames) {
+ uint8_t expected1[] = {5, 0};
+ uint8_t expected2[] = {3};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(2)),
+ when(data, is_equal_to_contents_of(expected1, 2))
+ );
+ expect(validator_recv_frame,
+ when(size, is_equal_to(1)),
+ when(data, is_equal_to_contents_of(expected2, 1))
+ );
+ byte_stuffer_recv_byte(1, 2);
+ byte_stuffer_recv_byte(1, 5);
+ byte_stuffer_recv_byte(1, 1);
+ byte_stuffer_recv_byte(1, 0);
+ byte_stuffer_recv_byte(1, 2);
+ byte_stuffer_recv_byte(1, 3);
+ byte_stuffer_recv_byte(1, 0);
+}
+
+Ensure(ByteStuffer, receives_valid_frame_after_unexpected_zero) {
+ uint8_t expected[] = {5, 7};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(2)),
+ when(data, is_equal_to_contents_of(expected, 2))
+ );
+ byte_stuffer_recv_byte(1, 3);
+ byte_stuffer_recv_byte(1, 1);
+ byte_stuffer_recv_byte(1, 0);
+ byte_stuffer_recv_byte(1, 3);
+ byte_stuffer_recv_byte(1, 5);
+ byte_stuffer_recv_byte(1, 7);
+ byte_stuffer_recv_byte(1, 0);
+}
+
+Ensure(ByteStuffer, receives_valid_frame_after_unexpected_non_zero) {
+ uint8_t expected[] = {5, 7};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(2)),
+ when(data, is_equal_to_contents_of(expected, 2))
+ );
+ byte_stuffer_recv_byte(0, 2);
+ byte_stuffer_recv_byte(0, 9);
+ byte_stuffer_recv_byte(0, 4); // This should have been zero
+ byte_stuffer_recv_byte(0, 0);
+ byte_stuffer_recv_byte(0, 3);
+ byte_stuffer_recv_byte(0, 5);
+ byte_stuffer_recv_byte(0, 7);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_and_then_end_of_frame) {
+ uint8_t expected[254];
+ int i;
+ for (i=0;i<254;i++) {
+ expected[i] = i + 1;
+ }
+ expect(validator_recv_frame,
+ when(size, is_equal_to(254)),
+ when(data, is_equal_to_contents_of(expected, 254))
+ );
+ byte_stuffer_recv_byte(0, 0xFF);
+ for (i=0;i<254;i++) {
+ byte_stuffer_recv_byte(0, i+1);
+ }
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_next_byte_is_non_zero) {
+ uint8_t expected[255];
+ int i;
+ for (i=0;i<254;i++) {
+ expected[i] = i + 1;
+ }
+ expected[254] = 7;
+ expect(validator_recv_frame,
+ when(size, is_equal_to(255)),
+ when(data, is_equal_to_contents_of(expected, 255))
+ );
+ byte_stuffer_recv_byte(0, 0xFF);
+ for (i=0;i<254;i++) {
+ byte_stuffer_recv_byte(0, i+1);
+ }
+ byte_stuffer_recv_byte(0, 2);
+ byte_stuffer_recv_byte(0, 7);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_a_valid_frame_with_over254_non_zeroes_next_byte_is_zero) {
+ uint8_t expected[255];
+ int i;
+ for (i=0;i<254;i++) {
+ expected[i] = i + 1;
+ }
+ expected[254] = 0;
+ expect(validator_recv_frame,
+ when(size, is_equal_to(255)),
+ when(data, is_equal_to_contents_of(expected, 255))
+ );
+ byte_stuffer_recv_byte(0, 0xFF);
+ for (i=0;i<254;i++) {
+ byte_stuffer_recv_byte(0, i+1);
+ }
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_two_long_frames_and_some_more) {
+ uint8_t expected[515];
+ int i;
+ int j;
+ for (j=0;j<2;j++) {
+ for (i=0;i<254;i++) {
+ expected[i+254*j] = i + 1;
+ }
+ }
+ for (i=0;i<7;i++) {
+ expected[254*2+i] = i + 1;
+ }
+ expect(validator_recv_frame,
+ when(size, is_equal_to(515)),
+ when(data, is_equal_to_contents_of(expected, 510))
+ );
+ byte_stuffer_recv_byte(0, 0xFF);
+ for (i=0;i<254;i++) {
+ byte_stuffer_recv_byte(0, i+1);
+ }
+ byte_stuffer_recv_byte(0, 0xFF);
+ for (i=0;i<254;i++) {
+ byte_stuffer_recv_byte(0, i+1);
+ }
+ byte_stuffer_recv_byte(0, 8);
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 2);
+ byte_stuffer_recv_byte(0, 3);
+ byte_stuffer_recv_byte(0, 4);
+ byte_stuffer_recv_byte(0, 5);
+ byte_stuffer_recv_byte(0, 6);
+ byte_stuffer_recv_byte(0, 7);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, receives_an_all_zeros_frame_that_is_maximum_size) {
+ uint8_t expected[MAX_FRAME_SIZE] = {};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(MAX_FRAME_SIZE)),
+ when(data, is_equal_to_contents_of(expected, MAX_FRAME_SIZE))
+ );
+ int i;
+ byte_stuffer_recv_byte(0, 1);
+ for(i=0;i<MAX_FRAME_SIZE;i++) {
+ byte_stuffer_recv_byte(0, 1);
+ }
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, doesnt_recv_a_frame_thats_too_long_all_zeroes) {
+ uint8_t expected[1] = {0};
+ never_expect(validator_recv_frame);
+ int i;
+ byte_stuffer_recv_byte(0, 1);
+ for(i=0;i<MAX_FRAME_SIZE;i++) {
+ byte_stuffer_recv_byte(0, 1);
+ }
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, received_frame_is_aborted_when_its_too_long) {
+ uint8_t expected[1] = {1};
+ expect(validator_recv_frame,
+ when(size, is_equal_to(1)),
+ when(data, is_equal_to_contents_of(expected, 1))
+ );
+ int i;
+ byte_stuffer_recv_byte(0, 1);
+ for(i=0;i<MAX_FRAME_SIZE;i++) {
+ byte_stuffer_recv_byte(0, 1);
+ }
+ byte_stuffer_recv_byte(0, 2);
+ byte_stuffer_recv_byte(0, 1);
+ byte_stuffer_recv_byte(0, 0);
+}
+
+Ensure(ByteStuffer, does_nothing_when_sending_zero_size_frame) {
+ assert_that(sent_data_size, is_equal_to(0));
+ byte_stuffer_send_frame(0, NULL, 0);
+}
+
+Ensure(ByteStuffer, send_one_byte_frame) {
+ uint8_t data[] = {5};
+ byte_stuffer_send_frame(1, data, 1);
+ uint8_t expected[] = {2, 5, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_two_byte_frame) {
+ uint8_t data[] = {5, 0x77};
+ byte_stuffer_send_frame(0, data, 2);
+ uint8_t expected[] = {3, 5, 0x77, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_one_byte_frame_with_zero) {
+ uint8_t data[] = {0};
+ byte_stuffer_send_frame(0, data, 1);
+ uint8_t expected[] = {1, 1, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_two_byte_frame_starting_with_zero) {
+ uint8_t data[] = {0, 9};
+ byte_stuffer_send_frame(1, data, 2);
+ uint8_t expected[] = {1, 2, 9, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_two_byte_frame_starting_with_non_zero) {
+ uint8_t data[] = {9, 0};
+ byte_stuffer_send_frame(1, data, 2);
+ uint8_t expected[] = {2, 9, 1, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_three_byte_frame_zero_in_the_middle) {
+ uint8_t data[] = {9, 0, 0x68};
+ byte_stuffer_send_frame(0, data, 3);
+ uint8_t expected[] = {2, 9, 2, 0x68, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_three_byte_frame_data_in_the_middle) {
+ uint8_t data[] = {0, 0x55, 0};
+ byte_stuffer_send_frame(0, data, 3);
+ uint8_t expected[] = {1, 2, 0x55, 1, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_three_byte_frame_with_all_zeroes) {
+ uint8_t data[] = {0, 0, 0};
+ byte_stuffer_send_frame(0, data, 3);
+ uint8_t expected[] = {1, 1, 1, 1, 0};
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_frame_with_254_non_zeroes) {
+ uint8_t data[254];
+ int i;
+ for(i=0;i<254;i++) {
+ data[i] = i + 1;
+ }
+ byte_stuffer_send_frame(0, data, 254);
+ uint8_t expected[256];
+ expected[0] = 0xFF;
+ for(i=1;i<255;i++) {
+ expected[i] = i;
+ }
+ expected[255] = 0;
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_frame_with_255_non_zeroes) {
+ uint8_t data[255];
+ int i;
+ for(i=0;i<255;i++) {
+ data[i] = i + 1;
+ }
+ byte_stuffer_send_frame(0, data, 255);
+ uint8_t expected[258];
+ expected[0] = 0xFF;
+ for(i=1;i<255;i++) {
+ expected[i] = i;
+ }
+ expected[255] = 2;
+ expected[256] = 255;
+ expected[257] = 0;
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_frame_with_254_non_zeroes_followed_by_zero) {
+ uint8_t data[255];
+ int i;
+ for(i=0;i<254;i++) {
+ data[i] = i + 1;
+ }
+ data[255] = 0;
+ byte_stuffer_send_frame(0, data, 255);
+ uint8_t expected[258];
+ expected[0] = 0xFF;
+ for(i=1;i<255;i++) {
+ expected[i] = i;
+ }
+ expected[255] = 1;
+ expected[256] = 1;
+ expected[257] = 0;
+ assert_that(sent_data_size, is_equal_to(sizeof(expected)));
+ assert_that(sent_data, is_equal_to_contents_of(expected, sizeof(expected)));
+}
+
+Ensure(ByteStuffer, sends_and_receives_full_roundtrip_small_packet) {
+ uint8_t original_data[] = { 1, 2, 3};
+ byte_stuffer_send_frame(0, original_data, sizeof(original_data));
+ expect(validator_recv_frame,
+ when(size, is_equal_to(sizeof(original_data))),
+ when(data, is_equal_to_contents_of(original_data, sizeof(original_data)))
+ );
+ int i;
+ for(i=0;i<sent_data_size;i++) {
+ byte_stuffer_recv_byte(1, sent_data[i]);
+ }
+}
+
+Ensure(ByteStuffer, sends_and_receives_full_roundtrip_small_packet_with_zeros) {
+ uint8_t original_data[] = { 1, 0, 3, 0, 0, 9};
+ byte_stuffer_send_frame(1, original_data, sizeof(original_data));
+ expect(validator_recv_frame,
+ when(size, is_equal_to(sizeof(original_data))),
+ when(data, is_equal_to_contents_of(original_data, sizeof(original_data)))
+ );
+ int i;
+ for(i=0;i<sent_data_size;i++) {
+ byte_stuffer_recv_byte(0, sent_data[i]);
+ }
+}
+
+Ensure(ByteStuffer, sends_and_receives_full_roundtrip_254_bytes) {
+ uint8_t original_data[254];
+ int i;
+ for(i=0;i<254;i++) {
+ original_data[i] = i + 1;
+ }
+ byte_stuffer_send_frame(0, original_data, sizeof(original_data));
+ expect(validator_recv_frame,
+ when(size, is_equal_to(sizeof(original_data))),
+ when(data, is_equal_to_contents_of(original_data, sizeof(original_data)))
+ );
+ for(i=0;i<sent_data_size;i++) {
+ byte_stuffer_recv_byte(1, sent_data[i]);
+ }
+}
+
+Ensure(ByteStuffer, sends_and_receives_full_roundtrip_256_bytes) {
+ uint8_t original_data[256];
+ int i;
+ for(i=0;i<254;i++) {
+ original_data[i] = i + 1;
+ }
+ original_data[254] = 22;
+ original_data[255] = 23;
+ byte_stuffer_send_frame(0, original_data, sizeof(original_data));
+ expect(validator_recv_frame,
+ when(size, is_equal_to(sizeof(original_data))),
+ when(data, is_equal_to_contents_of(original_data, sizeof(original_data)))
+ );
+ for(i=0;i<sent_data_size;i++) {
+ byte_stuffer_recv_byte(1, sent_data[i]);
+ }
+}
+
+Ensure(ByteStuffer, sends_and_receives_full_roundtrip_254_bytes_and_then_zero) {
+ uint8_t original_data[255];
+ int i;
+ for(i=0;i<254;i++) {
+ original_data[i] = i + 1;
+ }
+ original_data[254] = 0;
+ byte_stuffer_send_frame(0, original_data, sizeof(original_data));
+ expect(validator_recv_frame,
+ when(size, is_equal_to(sizeof(original_data))),
+ when(data, is_equal_to_contents_of(original_data, sizeof(original_data)))
+ );
+ for(i=0;i<sent_data_size;i++) {
+ byte_stuffer_recv_byte(1, sent_data[i]);
+ }
+}
diff --git a/quantum/serial_link/tests/frame_router_tests.c b/quantum/serial_link/tests/frame_router_tests.c
new file mode 100644
index 0000000000..6c806fa939
--- /dev/null
+++ b/quantum/serial_link/tests/frame_router_tests.c
@@ -0,0 +1,231 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include <cgreen/cgreen.h>
+#include <cgreen/mocks.h>
+#include "serial_link/protocol/byte_stuffer.c"
+#include "serial_link/protocol/frame_validator.c"
+#include "serial_link/protocol/frame_router.c"
+#include "serial_link/protocol/transport.h"
+
+static uint8_t received_data[256];
+static uint16_t received_data_size;
+
+typedef struct {
+ uint8_t sent_data[256];
+ uint16_t sent_data_size;
+} receive_buffer_t;
+
+typedef struct {
+ receive_buffer_t send_buffers[2];
+} router_buffer_t;
+
+router_buffer_t router_buffers[8];
+
+router_buffer_t* current_router_buffer;
+
+
+Describe(FrameRouter);
+BeforeEach(FrameRouter) {
+ init_byte_stuffer();
+ memset(router_buffers, 0, sizeof(router_buffers));
+ current_router_buffer = 0;
+}
+AfterEach(FrameRouter) {}
+
+typedef struct {
+ uint32_t data;
+ uint8_t extra[16];
+} frame_buffer_t;
+
+
+void send_data(uint8_t link, const uint8_t* data, uint16_t size) {
+ receive_buffer_t* buffer = &current_router_buffer->send_buffers[link];
+ memcpy(buffer->sent_data + buffer->sent_data_size, data, size);
+ buffer->sent_data_size += size;
+}
+
+static void receive_data(uint8_t link, uint8_t* data, uint16_t size) {
+ int i;
+ for(i=0;i<size;i++) {
+ byte_stuffer_recv_byte(link, data[i]);
+ }
+}
+
+static void activate_router(uint8_t num) {
+ current_router_buffer = router_buffers + num;
+ router_set_master(num==0);
+}
+
+static void simulate_transport(uint8_t from, uint8_t to) {
+ activate_router(to);
+ if (from > to) {
+ receive_data(DOWN_LINK,
+ router_buffers[from].send_buffers[UP_LINK].sent_data,
+ router_buffers[from].send_buffers[UP_LINK].sent_data_size);
+ }
+ else if(to > from) {
+ receive_data(UP_LINK,
+ router_buffers[from].send_buffers[DOWN_LINK].sent_data,
+ router_buffers[from].send_buffers[DOWN_LINK].sent_data_size);
+ }
+}
+
+void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size) {
+ mock(from, data, size);
+}
+
+
+Ensure(FrameRouter, master_broadcast_is_received_by_everyone) {
+ frame_buffer_t data;
+ data.data = 0xAB7055BB;
+ activate_router(0);
+ router_send_frame(0xFF, (uint8_t*)&data, 4);
+ assert_that(router_buffers[0].send_buffers[DOWN_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[0].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+
+ expect(transport_recv_frame,
+ when(from, is_equal_to(0)),
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(&data.data, 4))
+ );
+ simulate_transport(0, 1);
+ assert_that(router_buffers[1].send_buffers[DOWN_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[1].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+
+ expect(transport_recv_frame,
+ when(from, is_equal_to(0)),
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(&data.data, 4))
+ );
+ simulate_transport(1, 2);
+ assert_that(router_buffers[2].send_buffers[DOWN_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[2].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+}
+
+Ensure(FrameRouter, master_send_is_received_by_targets) {
+ frame_buffer_t data;
+ data.data = 0xAB7055BB;
+ activate_router(0);
+ router_send_frame((1 << 1) | (1 << 2), (uint8_t*)&data, 4);
+ assert_that(router_buffers[0].send_buffers[DOWN_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[0].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+
+ simulate_transport(0, 1);
+ assert_that(router_buffers[1].send_buffers[DOWN_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[1].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+
+ expect(transport_recv_frame,
+ when(from, is_equal_to(0)),
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(&data.data, 4))
+ );
+ simulate_transport(1, 2);
+ assert_that(router_buffers[2].send_buffers[DOWN_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[2].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+
+ expect(transport_recv_frame,
+ when(from, is_equal_to(0)),
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(&data.data, 4))
+ );
+ simulate_transport(2, 3);
+ assert_that(router_buffers[3].send_buffers[DOWN_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[3].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+}
+
+Ensure(FrameRouter, first_link_sends_to_master) {
+ frame_buffer_t data;
+ data.data = 0xAB7055BB;
+ activate_router(1);
+ router_send_frame(0, (uint8_t*)&data, 4);
+ assert_that(router_buffers[1].send_buffers[UP_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[1].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+
+ expect(transport_recv_frame,
+ when(from, is_equal_to(1)),
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(&data.data, 4))
+ );
+ simulate_transport(1, 0);
+ assert_that(router_buffers[0].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+ assert_that(router_buffers[0].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+}
+
+Ensure(FrameRouter, second_link_sends_to_master) {
+ frame_buffer_t data;
+ data.data = 0xAB7055BB;
+ activate_router(2);
+ router_send_frame(0, (uint8_t*)&data, 4);
+ assert_that(router_buffers[2].send_buffers[UP_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[2].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+
+ simulate_transport(2, 1);
+ assert_that(router_buffers[1].send_buffers[UP_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[1].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+
+ expect(transport_recv_frame,
+ when(from, is_equal_to(2)),
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(&data.data, 4))
+ );
+ simulate_transport(1, 0);
+ assert_that(router_buffers[0].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+ assert_that(router_buffers[0].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+}
+
+Ensure(FrameRouter, master_sends_to_master_does_nothing) {
+ frame_buffer_t data;
+ data.data = 0xAB7055BB;
+ activate_router(0);
+ router_send_frame(0, (uint8_t*)&data, 4);
+ assert_that(router_buffers[0].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+ assert_that(router_buffers[0].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+}
+
+Ensure(FrameRouter, link_sends_to_other_link_does_nothing) {
+ frame_buffer_t data;
+ data.data = 0xAB7055BB;
+ activate_router(1);
+ router_send_frame(2, (uint8_t*)&data, 4);
+ assert_that(router_buffers[1].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+ assert_that(router_buffers[1].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+}
+
+Ensure(FrameRouter, master_receives_on_uplink_does_nothing) {
+ frame_buffer_t data;
+ data.data = 0xAB7055BB;
+ activate_router(1);
+ router_send_frame(0, (uint8_t*)&data, 4);
+ assert_that(router_buffers[1].send_buffers[UP_LINK].sent_data_size, is_greater_than(0));
+ assert_that(router_buffers[1].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+
+ never_expect(transport_recv_frame);
+ activate_router(0);
+ receive_data(UP_LINK,
+ router_buffers[1].send_buffers[UP_LINK].sent_data,
+ router_buffers[1].send_buffers[UP_LINK].sent_data_size);
+ assert_that(router_buffers[0].send_buffers[UP_LINK].sent_data_size, is_equal_to(0));
+ assert_that(router_buffers[0].send_buffers[DOWN_LINK].sent_data_size, is_equal_to(0));
+}
diff --git a/quantum/serial_link/tests/frame_validator_tests.c b/quantum/serial_link/tests/frame_validator_tests.c
new file mode 100644
index 0000000000..d20947e2c9
--- /dev/null
+++ b/quantum/serial_link/tests/frame_validator_tests.c
@@ -0,0 +1,101 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include <cgreen/cgreen.h>
+#include <cgreen/mocks.h>
+#include "serial_link/protocol/frame_validator.c"
+
+void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size) {
+ mock(data, size);
+}
+
+void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size) {
+ mock(data, size);
+}
+
+Describe(FrameValidator);
+BeforeEach(FrameValidator) {}
+AfterEach(FrameValidator) {}
+
+Ensure(FrameValidator, doesnt_validate_frames_under_5_bytes) {
+ never_expect(route_incoming_frame);
+ uint8_t data[] = {1, 2};
+ validator_recv_frame(0, 0, 1);
+ validator_recv_frame(0, data, 2);
+ validator_recv_frame(0, data, 3);
+ validator_recv_frame(0, data, 4);
+}
+
+Ensure(FrameValidator, validates_one_byte_frame_with_correct_crc) {
+ uint8_t data[] = {0x44, 0x04, 0x6A, 0xB3, 0xA3};
+ expect(route_incoming_frame,
+ when(size, is_equal_to(1)),
+ when(data, is_equal_to_contents_of(data, 1))
+ );
+ validator_recv_frame(0, data, 5);
+}
+
+Ensure(FrameValidator, does_not_validate_one_byte_frame_with_incorrect_crc) {
+ uint8_t data[] = {0x44, 0, 0, 0, 0};
+ never_expect(route_incoming_frame);
+ validator_recv_frame(1, data, 5);
+}
+
+Ensure(FrameValidator, validates_four_byte_frame_with_correct_crc) {
+ uint8_t data[] = {0x44, 0x10, 0xFF, 0x00, 0x74, 0x4E, 0x30, 0xBA};
+ expect(route_incoming_frame,
+ when(size, is_equal_to(4)),
+ when(data, is_equal_to_contents_of(data, 4))
+ );
+ validator_recv_frame(1, data, 8);
+}
+
+Ensure(FrameValidator, validates_five_byte_frame_with_correct_crc) {
+ uint8_t data[] = {1, 2, 3, 4, 5, 0xF4, 0x99, 0x0B, 0x47};
+ expect(route_incoming_frame,
+ when(size, is_equal_to(5)),
+ when(data, is_equal_to_contents_of(data, 5))
+ );
+ validator_recv_frame(0, data, 9);
+}
+
+Ensure(FrameValidator, sends_one_byte_with_correct_crc) {
+ uint8_t original[] = {0x44, 0, 0, 0, 0};
+ uint8_t expected[] = {0x44, 0x04, 0x6A, 0xB3, 0xA3};
+ expect(byte_stuffer_send_frame,
+ when(size, is_equal_to(sizeof(expected))),
+ when(data, is_equal_to_contents_of(expected, sizeof(expected)))
+ );
+ validator_send_frame(0, original, 1);
+}
+
+Ensure(FrameValidator, sends_five_bytes_with_correct_crc) {
+ uint8_t original[] = {1, 2, 3, 4, 5, 0, 0, 0, 0};
+ uint8_t expected[] = {1, 2, 3, 4, 5, 0xF4, 0x99, 0x0B, 0x47};
+ expect(byte_stuffer_send_frame,
+ when(size, is_equal_to(sizeof(expected))),
+ when(data, is_equal_to_contents_of(expected, sizeof(expected)))
+ );
+ validator_send_frame(0, original, 5);
+}
diff --git a/quantum/serial_link/tests/transport_tests.c b/quantum/serial_link/tests/transport_tests.c
new file mode 100644
index 0000000000..358e1b9fd4
--- /dev/null
+++ b/quantum/serial_link/tests/transport_tests.c
@@ -0,0 +1,168 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include <cgreen/cgreen.h>
+#include <cgreen/mocks.h>
+#include "serial_link/protocol/transport.c"
+#include "serial_link/protocol/triple_buffered_object.c"
+
+void signal_data_written(void) {
+ mock();
+}
+
+static uint8_t sent_data[2048];
+static uint16_t sent_data_size;
+
+void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) {
+ mock(destination);
+ memcpy(sent_data + sent_data_size, data, size);
+ sent_data_size += size;
+}
+
+typedef struct {
+ uint32_t test;
+} test_object1_t;
+
+typedef struct {
+ uint32_t test1;
+ uint32_t test2;
+} test_object2_t;
+
+MASTER_TO_ALL_SLAVES_OBJECT(master_to_slave, test_object1_t);
+MASTER_TO_SINGLE_SLAVE_OBJECT(master_to_single_slave, test_object1_t);
+SLAVE_TO_MASTER_OBJECT(slave_to_master, test_object1_t);
+
+static remote_object_t* test_remote_objects[] = {
+ REMOTE_OBJECT(master_to_slave),
+ REMOTE_OBJECT(master_to_single_slave),
+ REMOTE_OBJECT(slave_to_master),
+};
+
+Describe(Transport);
+BeforeEach(Transport) {
+ add_remote_objects(test_remote_objects, sizeof(test_remote_objects) / sizeof(remote_object_t*));
+ sent_data_size = 0;
+}
+AfterEach(Transport) {}
+
+Ensure(Transport, write_to_local_signals_an_event) {
+ begin_write_master_to_slave();
+ expect(signal_data_written);
+ end_write_master_to_slave();
+ begin_write_slave_to_master();
+ expect(signal_data_written);
+ end_write_slave_to_master();
+ begin_write_master_to_single_slave(1);
+ expect(signal_data_written);
+ end_write_master_to_single_slave(1);
+}
+
+Ensure(Transport, writes_from_master_to_all_slaves) {
+ update_transport();
+ test_object1_t* obj = begin_write_master_to_slave();
+ obj->test = 5;
+ expect(signal_data_written);
+ end_write_master_to_slave();
+ expect(router_send_frame,
+ when(destination, is_equal_to(0xFF)));
+ update_transport();
+ transport_recv_frame(0, sent_data, sent_data_size);
+ test_object1_t* obj2 = read_master_to_slave();
+ assert_that(obj2, is_not_equal_to(NULL));
+ assert_that(obj2->test, is_equal_to(5));
+}
+
+Ensure(Transport, writes_from_slave_to_master) {
+ update_transport();
+ test_object1_t* obj = begin_write_slave_to_master();
+ obj->test = 7;
+ expect(signal_data_written);
+ end_write_slave_to_master();
+ expect(router_send_frame,
+ when(destination, is_equal_to(0)));
+ update_transport();
+ transport_recv_frame(3, sent_data, sent_data_size);
+ test_object1_t* obj2 = read_slave_to_master(2);
+ assert_that(read_slave_to_master(0), is_equal_to(NULL));
+ assert_that(obj2, is_not_equal_to(NULL));
+ assert_that(obj2->test, is_equal_to(7));
+}
+
+Ensure(Transport, writes_from_master_to_single_slave) {
+ update_transport();
+ test_object1_t* obj = begin_write_master_to_single_slave(3);
+ obj->test = 7;
+ expect(signal_data_written);
+ end_write_master_to_single_slave(3);
+ expect(router_send_frame,
+ when(destination, is_equal_to(4)));
+ update_transport();
+ transport_recv_frame(0, sent_data, sent_data_size);
+ test_object1_t* obj2 = read_master_to_single_slave();
+ assert_that(obj2, is_not_equal_to(NULL));
+ assert_that(obj2->test, is_equal_to(7));
+}
+
+Ensure(Transport, ignores_object_with_invalid_id) {
+ update_transport();
+ test_object1_t* obj = begin_write_master_to_single_slave(3);
+ obj->test = 7;
+ expect(signal_data_written);
+ end_write_master_to_single_slave(3);
+ expect(router_send_frame,
+ when(destination, is_equal_to(4)));
+ update_transport();
+ sent_data[sent_data_size - 1] = 44;
+ transport_recv_frame(0, sent_data, sent_data_size);
+ test_object1_t* obj2 = read_master_to_single_slave();
+ assert_that(obj2, is_equal_to(NULL));
+}
+
+Ensure(Transport, ignores_object_with_size_too_small) {
+ update_transport();
+ test_object1_t* obj = begin_write_master_to_slave();
+ obj->test = 7;
+ expect(signal_data_written);
+ end_write_master_to_slave();
+ expect(router_send_frame);
+ update_transport();
+ sent_data[sent_data_size - 2] = 0;
+ transport_recv_frame(0, sent_data, sent_data_size - 1);
+ test_object1_t* obj2 = read_master_to_slave();
+ assert_that(obj2, is_equal_to(NULL));
+}
+
+Ensure(Transport, ignores_object_with_size_too_big) {
+ update_transport();
+ test_object1_t* obj = begin_write_master_to_slave();
+ obj->test = 7;
+ expect(signal_data_written);
+ end_write_master_to_slave();
+ expect(router_send_frame);
+ update_transport();
+ sent_data[sent_data_size + 21] = 0;
+ transport_recv_frame(0, sent_data, sent_data_size + 22);
+ test_object1_t* obj2 = read_master_to_slave();
+ assert_that(obj2, is_equal_to(NULL));
+}
diff --git a/quantum/serial_link/tests/triple_buffered_object_tests.c b/quantum/serial_link/tests/triple_buffered_object_tests.c
new file mode 100644
index 0000000000..6f7c82b468
--- /dev/null
+++ b/quantum/serial_link/tests/triple_buffered_object_tests.c
@@ -0,0 +1,82 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include <cgreen/cgreen.h>
+#include "serial_link/protocol/triple_buffered_object.c"
+
+typedef struct {
+ uint8_t state;
+ uint32_t buffer[3];
+}test_object_t;
+
+test_object_t test_object;
+
+Describe(TripleBufferedObject);
+BeforeEach(TripleBufferedObject) {
+ triple_buffer_init((triple_buffer_object_t*)&test_object);
+}
+AfterEach(TripleBufferedObject) {}
+
+
+Ensure(TripleBufferedObject, writes_and_reads_object) {
+ *triple_buffer_begin_write(&test_object) = 0x3456ABCC;
+ triple_buffer_end_write(&test_object);
+ assert_that(*triple_buffer_read(&test_object), is_equal_to(0x3456ABCC));
+}
+
+Ensure(TripleBufferedObject, does_not_read_empty) {
+ assert_that(triple_buffer_read(&test_object), is_equal_to(NULL));
+}
+
+Ensure(TripleBufferedObject, writes_twice_and_reads_object) {
+ *triple_buffer_begin_write(&test_object) = 0x3456ABCC;
+ triple_buffer_end_write(&test_object);
+ *triple_buffer_begin_write(&test_object) = 0x44778899;
+ triple_buffer_end_write(&test_object);
+ assert_that(*triple_buffer_read(&test_object), is_equal_to(0x44778899));
+}
+
+Ensure(TripleBufferedObject, performs_another_write_in_the_middle_of_read) {
+ *triple_buffer_begin_write(&test_object) = 1;
+ triple_buffer_end_write(&test_object);
+ uint32_t* read = triple_buffer_read(&test_object);
+ *triple_buffer_begin_write(&test_object) = 2;
+ triple_buffer_end_write(&test_object);
+ assert_that(*read, is_equal_to(1));
+ assert_that(*triple_buffer_read(&test_object), is_equal_to(2));
+ assert_that(triple_buffer_read(&test_object), is_equal_to(NULL));
+}
+
+Ensure(TripleBufferedObject, performs_two_writes_in_the_middle_of_read) {
+ *triple_buffer_begin_write(&test_object) = 1;
+ triple_buffer_end_write(&test_object);
+ uint32_t* read = triple_buffer_read(&test_object);
+ *triple_buffer_begin_write(&test_object) = 2;
+ triple_buffer_end_write(&test_object);
+ *triple_buffer_begin_write(&test_object) = 3;
+ triple_buffer_end_write(&test_object);
+ assert_that(*read, is_equal_to(1));
+ assert_that(*triple_buffer_read(&test_object), is_equal_to(3));
+ assert_that(triple_buffer_read(&test_object), is_equal_to(NULL));
+}
diff --git a/quantum/template/template.c b/quantum/template/template.c
index dcc4b0a221..5ef349583c 100644
--- a/quantum/template/template.c
+++ b/quantum/template/template.c
@@ -18,7 +18,7 @@ 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_action_user(record);
+ return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
diff --git a/quantum/visualizer/LICENSE.md b/quantum/visualizer/LICENSE.md
new file mode 100644
index 0000000000..22d4c3f08b
--- /dev/null
+++ b/quantum/visualizer/LICENSE.md
@@ -0,0 +1,29 @@
+The files in this project are licensed under the MIT license
+It uses the following libraries
+uGFX - with it's own license, see the license.html file in the uGFX subfolder for more information
+tmk_core - is indirectly used and not included in the repository. It's licensed under the GPLv2 license
+Chibios - which is used by tmk_core is licensed under GPLv3.
+
+Therefore the effective license for any project using the library is GPLv3
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
diff --git a/quantum/visualizer/example_integration/callbacks.c b/quantum/visualizer/example_integration/callbacks.c
new file mode 100644
index 0000000000..2539615d65
--- /dev/null
+++ b/quantum/visualizer/example_integration/callbacks.c
@@ -0,0 +1,36 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "keyboard.h"
+#include "action_layer.h"
+#include "visualizer.h"
+#include "host.h"
+
+void post_keyboard_init(void) {
+ visualizer_init();
+}
+
+void post_keyboard_task() {
+ visualizer_set_state(default_layer_state, layer_state, host_keyboard_leds());
+}
diff --git a/quantum/visualizer/example_integration/gfxconf.h b/quantum/visualizer/example_integration/gfxconf.h
new file mode 100644
index 0000000000..304c5d187a
--- /dev/null
+++ b/quantum/visualizer/example_integration/gfxconf.h
@@ -0,0 +1,325 @@
+/**
+ * This file has a different license to the rest of the uGFX system.
+ * You can copy, modify and distribute this file as you see fit.
+ * You do not need to publish your source modifications to this file.
+ * The only thing you are not permitted to do is to relicense it
+ * under a different license.
+ */
+
+/**
+ * Copy this file into your project directory and rename it as gfxconf.h
+ * Edit your copy to turn on the uGFX features you want to use.
+ * The values below are the defaults.
+ *
+ * Only remove the comments from lines where you want to change the
+ * default value. This allows definitions to be included from
+ * driver makefiles when required and provides the best future
+ * compatibility for your project.
+ *
+ * Please use spaces instead of tabs in this file.
+ */
+
+#ifndef _GFXCONF_H
+#define _GFXCONF_H
+
+
+///////////////////////////////////////////////////////////////////////////
+// GOS - One of these must be defined, preferably in your Makefile //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_OS_CHIBIOS TRUE
+//#define GFX_USE_OS_FREERTOS FALSE
+// #define GFX_FREERTOS_USE_TRACE FALSE
+//#define GFX_USE_OS_WIN32 FALSE
+//#define GFX_USE_OS_LINUX FALSE
+//#define GFX_USE_OS_OSX FALSE
+//#define GFX_USE_OS_ECOS FALSE
+//#define GFX_USE_OS_RAWRTOS FALSE
+//#define GFX_USE_OS_ARDUINO FALSE
+//#define GFX_USE_OS_KEIL FALSE
+//#define GFX_USE_OS_CMSIS FALSE
+//#define GFX_USE_OS_RAW32 FALSE
+// #define INTERRUPTS_OFF() optional_code
+// #define INTERRUPTS_ON() optional_code
+// These are not defined by default for some reason
+#define GOS_NEED_X_THREADS FALSE
+#define GOS_NEED_X_HEAP FALSE
+
+// Options that (should where relevant) apply to all operating systems
+ #define GFX_NO_INLINE FALSE
+// #define GFX_COMPILER GFX_COMPILER_UNKNOWN
+// #define GFX_CPU GFX_CPU_UNKNOWN
+// #define GFX_OS_HEAP_SIZE 0
+// #define GFX_OS_NO_INIT FALSE
+// #define GFX_OS_INIT_NO_WARNING FALSE
+// #define GFX_OS_PRE_INIT_FUNCTION myHardwareInitRoutine
+// #define GFX_OS_EXTRA_INIT_FUNCTION myOSInitRoutine
+// #define GFX_OS_EXTRA_DEINIT_FUNCTION myOSDeInitRoutine
+
+
+///////////////////////////////////////////////////////////////////////////
+// GDISP //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GDISP TRUE
+
+//#define GDISP_NEED_AUTOFLUSH FALSE
+//#define GDISP_NEED_TIMERFLUSH FALSE
+//#define GDISP_NEED_VALIDATION TRUE
+//#define GDISP_NEED_CLIP TRUE
+//#define GDISP_NEED_CIRCLE FALSE
+//#define GDISP_NEED_ELLIPSE FALSE
+//#define GDISP_NEED_ARC FALSE
+//#define GDISP_NEED_ARCSECTORS FALSE
+//#define GDISP_NEED_CONVEX_POLYGON FALSE
+//#define GDISP_NEED_SCROLL FALSE
+//#define GDISP_NEED_PIXELREAD FALSE
+//#define GDISP_NEED_CONTROL FALSE
+//#define GDISP_NEED_QUERY FALSE
+//#define GDISP_NEED_MULTITHREAD FALSE
+//#define GDISP_NEED_STREAMING FALSE
+#define GDISP_NEED_TEXT TRUE
+// #define GDISP_NEED_TEXT_WORDWRAP FALSE
+// #define GDISP_NEED_ANTIALIAS FALSE
+// #define GDISP_NEED_UTF8 FALSE
+ #define GDISP_NEED_TEXT_KERNING TRUE
+// #define GDISP_INCLUDE_FONT_UI1 FALSE
+// #define GDISP_INCLUDE_FONT_UI2 FALSE // The smallest preferred font.
+// #define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS10 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS12 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS16 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS20 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE
+ #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 TRUE
+// #define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE
+// #define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE
+ #define GDISP_INCLUDE_FONT_FIXED_5X8 TRUE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA FALSE
+// #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA FALSE
+// #define GDISP_INCLUDE_USER_FONTS FALSE
+
+//#define GDISP_NEED_IMAGE FALSE
+// #define GDISP_NEED_IMAGE_NATIVE FALSE
+// #define GDISP_NEED_IMAGE_GIF FALSE
+// #define GDISP_NEED_IMAGE_BMP FALSE
+// #define GDISP_NEED_IMAGE_BMP_1 FALSE
+// #define GDISP_NEED_IMAGE_BMP_4 FALSE
+// #define GDISP_NEED_IMAGE_BMP_4_RLE FALSE
+// #define GDISP_NEED_IMAGE_BMP_8 FALSE
+// #define GDISP_NEED_IMAGE_BMP_8_RLE FALSE
+// #define GDISP_NEED_IMAGE_BMP_16 FALSE
+// #define GDISP_NEED_IMAGE_BMP_24 FALSE
+// #define GDISP_NEED_IMAGE_BMP_32 FALSE
+// #define GDISP_NEED_IMAGE_JPG FALSE
+// #define GDISP_NEED_IMAGE_PNG FALSE
+// #define GDISP_NEED_IMAGE_ACCOUNTING FALSE
+
+//#define GDISP_NEED_PIXMAP FALSE
+// #define GDISP_NEED_PIXMAP_IMAGE FALSE
+
+//#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE // If not defined the native hardware orientation is used.
+//#define GDISP_LINEBUF_SIZE 128
+//#define GDISP_STARTUP_COLOR Black
+#define GDISP_NEED_STARTUP_LOGO FALSE
+
+//#define GDISP_TOTAL_DISPLAYS 1
+
+//#define GDISP_DRIVER_LIST GDISPVMT_Win32, GDISPVMT_Win32
+// #ifdef GDISP_DRIVER_LIST
+// // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
+// #define GDISP_HARDWARE_STREAM_WRITE FALSE
+// #define GDISP_HARDWARE_STREAM_READ FALSE
+// #define GDISP_HARDWARE_STREAM_POS FALSE
+// #define GDISP_HARDWARE_DRAWPIXEL FALSE
+// #define GDISP_HARDWARE_CLEARS FALSE
+// #define GDISP_HARDWARE_FILLS FALSE
+// #define GDISP_HARDWARE_BITFILLS FALSE
+// #define GDISP_HARDWARE_SCROLL FALSE
+// #define GDISP_HARDWARE_PIXELREAD FALSE
+// #define GDISP_HARDWARE_CONTROL FALSE
+// #define GDISP_HARDWARE_QUERY FALSE
+// #define GDISP_HARDWARE_CLIP FALSE
+
+ #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
+// #endif
+
+// The custom format is not defined for some reason, so define it as error
+// so we don't get compiler warnings
+#define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR
+
+#define GDISP_USE_GFXNET FALSE
+// #define GDISP_GFXNET_PORT 13001
+// #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
+// #define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
+// #define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
+
+
+///////////////////////////////////////////////////////////////////////////
+// GWIN //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GWIN FALSE
+
+//#define GWIN_NEED_WINDOWMANAGER FALSE
+// #define GWIN_REDRAW_IMMEDIATE FALSE
+// #define GWIN_REDRAW_SINGLEOP FALSE
+// #define GWIN_NEED_FLASHING FALSE
+// #define GWIN_FLASHING_PERIOD 250
+
+//#define GWIN_NEED_CONSOLE FALSE
+// #define GWIN_CONSOLE_USE_HISTORY FALSE
+// #define GWIN_CONSOLE_HISTORY_AVERAGING FALSE
+// #define GWIN_CONSOLE_HISTORY_ATCREATE FALSE
+// #define GWIN_CONSOLE_ESCSEQ FALSE
+// #define GWIN_CONSOLE_USE_BASESTREAM FALSE
+// #define GWIN_CONSOLE_USE_FLOAT FALSE
+//#define GWIN_NEED_GRAPH FALSE
+//#define GWIN_NEED_GL3D FALSE
+
+//#define GWIN_NEED_WIDGET FALSE
+//#define GWIN_FOCUS_HIGHLIGHT_WIDTH 1
+// #define GWIN_NEED_LABEL FALSE
+// #define GWIN_LABEL_ATTRIBUTE FALSE
+// #define GWIN_NEED_BUTTON FALSE
+// #define GWIN_BUTTON_LAZY_RELEASE FALSE
+// #define GWIN_NEED_SLIDER FALSE
+// #define GWIN_SLIDER_NOSNAP FALSE
+// #define GWIN_SLIDER_DEAD_BAND 5
+// #define GWIN_SLIDER_TOGGLE_INC 20
+// #define GWIN_NEED_CHECKBOX FALSE
+// #define GWIN_NEED_IMAGE FALSE
+// #define GWIN_NEED_IMAGE_ANIMATION FALSE
+// #define GWIN_NEED_RADIO FALSE
+// #define GWIN_NEED_LIST FALSE
+// #define GWIN_NEED_LIST_IMAGES FALSE
+// #define GWIN_NEED_PROGRESSBAR FALSE
+// #define GWIN_PROGRESSBAR_AUTO FALSE
+// #define GWIN_NEED_KEYBOARD FALSE
+// #define GWIN_KEYBOARD_DEFAULT_LAYOUT VirtualKeyboard_English1
+// #define GWIN_NEED_KEYBOARD_ENGLISH1 TRUE
+// #define GWIN_NEED_TEXTEDIT FALSE
+// #define GWIN_FLAT_STYLING FALSE
+// #define GWIN_WIDGET_TAGS FALSE
+
+//#define GWIN_NEED_CONTAINERS FALSE
+// #define GWIN_NEED_CONTAINER FALSE
+// #define GWIN_NEED_FRAME FALSE
+// #define GWIN_NEED_TABSET FALSE
+// #define GWIN_TABSET_TABHEIGHT 18
+
+
+///////////////////////////////////////////////////////////////////////////
+// GEVENT //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GEVENT FALSE
+
+//#define GEVENT_ASSERT_NO_RESOURCE FALSE
+//#define GEVENT_MAXIMUM_SIZE 32
+//#define GEVENT_MAX_SOURCE_LISTENERS 32
+
+
+///////////////////////////////////////////////////////////////////////////
+// GTIMER //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GTIMER FALSE
+
+//#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
+//#define GTIMER_THREAD_WORKAREA_SIZE 2048
+
+
+///////////////////////////////////////////////////////////////////////////
+// GQUEUE //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GQUEUE FALSE
+
+//#define GQUEUE_NEED_ASYNC FALSE
+//#define GQUEUE_NEED_GSYNC FALSE
+//#define GQUEUE_NEED_FSYNC FALSE
+//#define GQUEUE_NEED_BUFFERS FALSE
+
+///////////////////////////////////////////////////////////////////////////
+// GINPUT //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GINPUT FALSE
+
+//#define GINPUT_NEED_MOUSE FALSE
+// #define GINPUT_TOUCH_STARTRAW FALSE
+// #define GINPUT_TOUCH_NOTOUCH FALSE
+// #define GINPUT_TOUCH_NOCALIBRATE FALSE
+// #define GINPUT_TOUCH_NOCALIBRATE_GUI FALSE
+// #define GINPUT_MOUSE_POLL_PERIOD 25
+// #define GINPUT_MOUSE_CLICK_TIME 300
+// #define GINPUT_TOUCH_CXTCLICK_TIME 700
+// #define GINPUT_TOUCH_USER_CALIBRATION_LOAD FALSE
+// #define GINPUT_TOUCH_USER_CALIBRATION_SAVE FALSE
+// #define GMOUSE_DRIVER_LIST GMOUSEVMT_Win32, GMOUSEVMT_Win32
+//#define GINPUT_NEED_KEYBOARD FALSE
+// #define GINPUT_KEYBOARD_POLL_PERIOD 200
+// #define GKEYBOARD_DRIVER_LIST GKEYBOARDVMT_Win32, GKEYBOARDVMT_Win32
+// #define GKEYBOARD_LAYOUT_OFF FALSE
+// #define GKEYBOARD_LAYOUT_SCANCODE2_US FALSE
+//#define GINPUT_NEED_TOGGLE FALSE
+//#define GINPUT_NEED_DIAL FALSE
+
+
+///////////////////////////////////////////////////////////////////////////
+// GFILE //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GFILE FALSE
+
+//#define GFILE_NEED_PRINTG FALSE
+//#define GFILE_NEED_SCANG FALSE
+//#define GFILE_NEED_STRINGS FALSE
+//#define GFILE_NEED_FILELISTS FALSE
+//#define GFILE_NEED_STDIO FALSE
+//#define GFILE_NEED_NOAUTOMOUNT FALSE
+//#define GFILE_NEED_NOAUTOSYNC FALSE
+
+//#define GFILE_NEED_MEMFS FALSE
+//#define GFILE_NEED_ROMFS FALSE
+//#define GFILE_NEED_RAMFS FALSE
+//#define GFILE_NEED_FATFS FALSE
+//#define GFILE_NEED_NATIVEFS FALSE
+//#define GFILE_NEED_CHBIOSFS FALSE
+
+//#define GFILE_ALLOW_FLOATS FALSE
+//#define GFILE_ALLOW_DEVICESPECIFIC FALSE
+//#define GFILE_MAX_GFILES 3
+
+///////////////////////////////////////////////////////////////////////////
+// GADC //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GADC FALSE
+
+//#define GADC_MAX_LOWSPEED_DEVICES 4
+
+
+///////////////////////////////////////////////////////////////////////////
+// GAUDIO //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GAUDIO FALSE
+// There seems to be a bug in the ugfx code, the wrong define is used
+// So define it in order to avoid warnings
+#define GFX_USE_GAUDIN GFX_USE_GAUDIO
+// #define GAUDIO_NEED_PLAY FALSE
+// #define GAUDIO_NEED_RECORD FALSE
+
+
+///////////////////////////////////////////////////////////////////////////
+// GMISC //
+///////////////////////////////////////////////////////////////////////////
+#define GFX_USE_GMISC FALSE
+
+//#define GMISC_NEED_ARRAYOPS FALSE
+//#define GMISC_NEED_FASTTRIG FALSE
+//#define GMISC_NEED_FIXEDTRIG FALSE
+//#define GMISC_NEED_INVSQRT FALSE
+// #define GMISC_INVSQRT_MIXED_ENDIAN FALSE
+// #define GMISC_INVSQRT_REAL_SLOW FALSE
+//#define GMISC_NEED_MATRIXFLOAT2D FALSE
+//#define GMISC_NEED_MATRIXFIXED2D FALSE
+
+#endif /* _GFXCONF_H */
diff --git a/quantum/visualizer/example_integration/lcd_backlight_hal.c b/quantum/visualizer/example_integration/lcd_backlight_hal.c
new file mode 100644
index 0000000000..913131b169
--- /dev/null
+++ b/quantum/visualizer/example_integration/lcd_backlight_hal.c
@@ -0,0 +1,91 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "lcd_backlight.h"
+#include "hal.h"
+
+#define RED_PIN 1
+#define GREEN_PIN 2
+#define BLUE_PIN 3
+#define CHANNEL_RED FTM0->CHANNEL[0]
+#define CHANNEL_GREEN FTM0->CHANNEL[1]
+#define CHANNEL_BLUE FTM0->CHANNEL[2]
+
+#define RGB_PORT PORTC
+#define RGB_PORT_GPIO GPIOC
+
+// Base FTM clock selection (72 MHz system clock)
+// @ 0xFFFF period, 72 MHz / (0xFFFF * 2) = Actual period
+// Higher pre-scalar will use the most power (also look the best)
+// Pre-scalar calculations
+// 0 - 72 MHz -> 549 Hz
+// 1 - 36 MHz -> 275 Hz
+// 2 - 18 MHz -> 137 Hz
+// 3 - 9 MHz -> 69 Hz (Slightly visible flicker)
+// 4 - 4 500 kHz -> 34 Hz (Visible flickering)
+// 5 - 2 250 kHz -> 17 Hz
+// 6 - 1 125 kHz -> 9 Hz
+// 7 - 562 500 Hz -> 4 Hz
+// Using a higher pre-scalar without flicker is possible but FTM0_MOD will need to be reduced
+// Which will reduce the brightness range
+#define PRESCALAR_DEFINE 0
+
+void lcd_backlight_hal_init(void) {
+ // Setup Backlight
+ SIM->SCGC6 |= SIM_SCGC6_FTM0;
+ FTM0->CNT = 0; // Reset counter
+
+ // PWM Period
+ // 16-bit maximum
+ FTM0->MOD = 0xFFFF;
+
+ // Set FTM to PWM output - Edge Aligned, Low-true pulses
+#define CNSC_MODE FTM_SC_CPWMS | FTM_SC_PS(4) | FTM_SC_CLKS(0)
+ CHANNEL_RED.CnSC = CNSC_MODE;
+ CHANNEL_GREEN.CnSC = CNSC_MODE;
+ CHANNEL_BLUE.CnSC = CNSC_MODE;
+
+ // System clock, /w prescalar setting
+ FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(PRESCALAR_DEFINE);
+
+ CHANNEL_RED.CnV = 0;
+ CHANNEL_GREEN.CnV = 0;
+ CHANNEL_BLUE.CnV = 0;
+
+ RGB_PORT_GPIO->PDDR |= (1 << RED_PIN);
+ RGB_PORT_GPIO->PDDR |= (1 << GREEN_PIN);
+ RGB_PORT_GPIO->PDDR |= (1 << BLUE_PIN);
+
+#define RGB_MODE PORTx_PCRn_SRE | PORTx_PCRn_DSE | PORTx_PCRn_MUX(4)
+ RGB_PORT->PCR[RED_PIN] = RGB_MODE;
+ RGB_PORT->PCR[GREEN_PIN] = RGB_MODE;
+ RGB_PORT->PCR[BLUE_PIN] = RGB_MODE;
+}
+
+void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) {
+ CHANNEL_RED.CnV = r;
+ CHANNEL_GREEN.CnV = g;
+ CHANNEL_BLUE.CnV = b;
+}
+
diff --git a/quantum/visualizer/example_integration/visualizer_user.c b/quantum/visualizer/example_integration/visualizer_user.c
new file mode 100644
index 0000000000..fc09fe2eaf
--- /dev/null
+++ b/quantum/visualizer/example_integration/visualizer_user.c
@@ -0,0 +1,121 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+// Currently we are assuming that both the backlight and LCD are enabled
+// But it's entirely possible to write a custom visualizer that use only
+// one of them
+#ifndef LCD_BACKLIGHT_ENABLE
+#error This visualizer needs that LCD backlight is enabled
+#endif
+
+#ifndef LCD_ENABLE
+#error This visualizer needs that LCD is enabled
+#endif
+
+#include "visualizer.h"
+
+static const char* welcome_text[] = {"TMK", "Infinity Ergodox"};
+
+// Just an example how to write custom keyframe functions, we could have moved
+// all this into the init function
+bool display_welcome(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ // Read the uGFX documentation for information how to use the displays
+ // http://wiki.ugfx.org/index.php/Main_Page
+ gdispClear(White);
+ // You can use static variables for things that can't be found in the animation
+ // or state structs
+ gdispDrawString(0, 3, welcome_text[0], state->font_dejavusansbold12, Black);
+ gdispDrawString(0, 15, welcome_text[1], state->font_dejavusansbold12, Black);
+ // Always remember to flush the display
+ gdispFlush();
+ // you could set the backlight color as well, but we won't do it here, since
+ // it's part of the following animation
+ // lcd_backlight_color(hue, saturation, intensity);
+ // We don't need constant updates, just drawing the screen once is enough
+ return false;
+}
+
+// Feel free to modify the animations below, or even add new ones if needed
+
+// Don't worry, if the startup animation is long, you can use the keyboard like normal
+// during that time
+static keyframe_animation_t startup_animation = {
+ .num_frames = 4,
+ .loop = false,
+ .frame_lengths = {0, MS2ST(1000), MS2ST(5000), 0},
+ .frame_functions = {display_welcome, keyframe_animate_backlight_color, keyframe_no_operation, enable_visualization},
+};
+
+// The color animation animates the LCD color when you change layers
+static keyframe_animation_t color_animation = {
+ .num_frames = 2,
+ .loop = false,
+ // Note that there's a 200 ms no-operation frame,
+ // this prevents the color from changing when activating the layer
+ // momentarily
+ .frame_lengths = {MS2ST(200), MS2ST(500)},
+ .frame_functions = {keyframe_no_operation, keyframe_animate_backlight_color},
+};
+
+// The LCD animation alternates between the layer name display and a
+// bitmap that displays all active layers
+static keyframe_animation_t lcd_animation = {
+ .num_frames = 2,
+ .loop = true,
+ .frame_lengths = {MS2ST(2000), MS2ST(2000)},
+ .frame_functions = {keyframe_display_layer_text, keyframe_display_layer_bitmap},
+};
+
+void initialize_user_visualizer(visualizer_state_t* state) {
+ // The brightness will be dynamically adjustable in the future
+ // But for now, change it here.
+ lcd_backlight_brightness(0x50);
+ state->current_lcd_color = LCD_COLOR(0x00, 0x00, 0xFF);
+ state->target_lcd_color = LCD_COLOR(0x10, 0xFF, 0xFF);
+ start_keyframe_animation(&startup_animation);
+}
+
+void update_user_visualizer_state(visualizer_state_t* state) {
+ // Add more tests, change the colors and layer texts here
+ // Usually you want to check the high bits (higher layers first)
+ // because that's the order layers are processed for keypresses
+ // You can for check for example:
+ // state->status.layer
+ // state->status.default_layer
+ // state->status.leds (see led.h for available statuses)
+ if (state->status.layer & 0x2) {
+ state->target_lcd_color = LCD_COLOR(0xA0, 0xB0, 0xFF);
+ state->layer_text = "Layer 2";
+ }
+ else {
+ state->target_lcd_color = LCD_COLOR(0x50, 0xB0, 0xFF);
+ state->layer_text = "Layer 1";
+ }
+ // You can also stop existing animations, and start your custom ones here
+ // remember that you should normally have only one animation for the LCD
+ // and one for the background. But you can also combine them if you want.
+ start_keyframe_animation(&lcd_animation);
+ start_keyframe_animation(&color_animation);
+}
diff --git a/quantum/visualizer/lcd_backlight.c b/quantum/visualizer/lcd_backlight.c
new file mode 100644
index 0000000000..70187d1e00
--- /dev/null
+++ b/quantum/visualizer/lcd_backlight.c
@@ -0,0 +1,85 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "lcd_backlight.h"
+#include <math.h>
+
+static uint8_t current_hue = 0x00;
+static uint8_t current_saturation = 0x00;
+static uint8_t current_intensity = 0xFF;
+static uint8_t current_brightness = 0x7F;
+
+void lcd_backlight_init(void) {
+ lcd_backlight_hal_init();
+ lcd_backlight_color(current_hue, current_saturation, current_intensity);
+}
+
+// This code is based on Brian Neltner's blogpost and example code
+// "Why every LED light should be using HSI colorspace".
+// http://blog.saikoled.com/post/43693602826/why-every-led-light-should-be-using-hsi
+static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_out, uint16_t* b_out) {
+ unsigned int r, g, b;
+ h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees
+ h = 3.14159f * h / 180.0f; // Convert to radians.
+ s = s > 0.0f ? (s < 1.0f ? s : 1.0f) : 0.0f; // clamp s and i to interval [0,1]
+ i = i > 0.0f ? (i < 1.0f ? i : 1.0f) : 0.0f;
+
+ // Math! Thanks in part to Kyle Miller.
+ if(h < 2.09439f) {
+ r = 65535.0f * i/3.0f *(1.0f + s * cos(h) / cosf(1.047196667f - h));
+ g = 65535.0f * i/3.0f *(1.0f + s *(1.0f - cosf(h) / cos(1.047196667f - h)));
+ b = 65535.0f * i/3.0f *(1.0f - s);
+ } else if(h < 4.188787) {
+ h = h - 2.09439;
+ g = 65535.0f * i/3.0f *(1.0f + s * cosf(h) / cosf(1.047196667f - h));
+ b = 65535.0f * i/3.0f *(1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h)));
+ r = 65535.0f * i/3.0f *(1.0f - s);
+ } else {
+ h = h - 4.188787;
+ b = 65535.0f*i/3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h));
+ r = 65535.0f*i/3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h)));
+ g = 65535.0f*i/3.0f * (1.0f - s);
+ }
+ *r_out = r > 65535 ? 65535 : r;
+ *g_out = g > 65535 ? 65535 : g;
+ *b_out = b > 65535 ? 65535 : b;
+}
+
+void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity) {
+ uint16_t r, g, b;
+ float hue_f = 360.0f * (float)hue / 255.0f;
+ float saturation_f = (float)saturation / 255.0f;
+ float intensity_f = (float)intensity / 255.0f;
+ intensity_f *= (float)current_brightness / 255.0f;
+ hsi_to_rgb(hue_f, saturation_f, intensity_f, &r, &g, &b);
+ current_hue = hue;
+ current_saturation = saturation;
+ current_intensity = intensity;
+ lcd_backlight_hal_color(r, g, b);
+}
+
+void lcd_backlight_brightness(uint8_t b) {
+ current_brightness = b;
+ lcd_backlight_color(current_hue, current_saturation, current_intensity);
+}
diff --git a/quantum/visualizer/lcd_backlight.h b/quantum/visualizer/lcd_backlight.h
new file mode 100644
index 0000000000..dd3e37a064
--- /dev/null
+++ b/quantum/visualizer/lcd_backlight.h
@@ -0,0 +1,42 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef LCD_BACKLIGHT_H_
+#define LCD_BACKLIGHT_H_
+#include "stdint.h"
+
+// Helper macros for storing hue, staturation and intensity as unsigned integers
+#define LCD_COLOR(hue, saturation, intensity) (hue << 16 | saturation << 8 | intensity)
+#define LCD_HUE(color) ((color >> 16) & 0xFF)
+#define LCD_SAT(color) ((color >> 8) & 0xFF)
+#define LCD_INT(color) (color & 0xFF)
+
+void lcd_backlight_init(void);
+void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity);
+void lcd_backlight_brightness(uint8_t b);
+
+void lcd_backlight_hal_init(void);
+void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b);
+
+#endif /* LCD_BACKLIGHT_H_ */
diff --git a/quantum/visualizer/led_test.c b/quantum/visualizer/led_test.c
new file mode 100644
index 0000000000..a9abace8df
--- /dev/null
+++ b/quantum/visualizer/led_test.c
@@ -0,0 +1,170 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+#include "led_test.h"
+#include "gfx.h"
+#include "math.h"
+
+#define CROSSFADE_TIME 1000
+#define GRADIENT_TIME 3000
+
+keyframe_animation_t led_test_animation = {
+ .num_frames = 14,
+ .loop = true,
+ .frame_lengths = {
+ gfxMillisecondsToTicks(1000), // fade in
+ gfxMillisecondsToTicks(1000), // no op (leds on)
+ gfxMillisecondsToTicks(1000), // fade out
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
+ 0, // mirror leds
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+ gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
+ 0, // normal leds
+ gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
+
+ },
+ .frame_functions = {
+ keyframe_fade_in_all_leds,
+ keyframe_no_operation,
+ keyframe_fade_out_all_leds,
+ keyframe_led_crossfade,
+ keyframe_led_left_to_right_gradient,
+ keyframe_led_crossfade,
+ keyframe_led_top_to_bottom_gradient,
+ keyframe_mirror_led_orientation,
+ keyframe_led_crossfade,
+ keyframe_led_left_to_right_gradient,
+ keyframe_led_crossfade,
+ keyframe_led_top_to_bottom_gradient,
+ keyframe_normal_led_orientation,
+ keyframe_led_crossfade,
+ },
+};
+
+static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) {
+ int frame_length = animation->frame_lengths[animation->current_frame];
+ int current_pos = frame_length - animation->time_left_in_frame;
+ int delta = to - from;
+ int luma = (delta * current_pos) / frame_length;
+ luma += from;
+ return luma;
+}
+
+static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) {
+ uint8_t luma = fade_led_color(animation, from, to);
+ color_t color = LUMA2COLOR(luma);
+ gdispGClear(LED_DISPLAY, color);
+}
+
+// TODO: Should be customizable per keyboard
+#define NUM_ROWS 7
+#define NUM_COLS 7
+
+static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
+static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
+
+static uint8_t compute_gradient_color(float t, float index, float num) {
+ const float two_pi = M_2_PI;
+ float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi;
+ float x = t * two_pi + normalized_index;
+ float v = 0.5 * (cosf(x) + 1.0f);
+ return (uint8_t)(255.0f * v);
+}
+
+bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)state;
+ keyframe_fade_all_leds_from_to(animation, 0, 255);
+ return true;
+}
+
+bool keyframe_fade_out_all_leds(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)state;
+ keyframe_fade_all_leds_from_to(animation, 255, 0);
+ return true;
+}
+
+bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)state;
+ float frame_length = animation->frame_lengths[animation->current_frame];
+ float current_pos = frame_length - animation->time_left_in_frame;
+ float t = current_pos / frame_length;
+ for (int i=0; i< NUM_COLS; i++) {
+ uint8_t color = compute_gradient_color(t, i, NUM_COLS);
+ gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color));
+ }
+ return true;
+}
+
+bool keyframe_led_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)state;
+ float frame_length = animation->frame_lengths[animation->current_frame];
+ float current_pos = frame_length - animation->time_left_in_frame;
+ float t = current_pos / frame_length;
+ for (int i=0; i< NUM_ROWS; i++) {
+ uint8_t color = compute_gradient_color(t, i, NUM_ROWS);
+ gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color));
+ }
+ return true;
+}
+
+static void copy_current_led_state(uint8_t* dest) {
+ for (int i=0;i<NUM_ROWS;i++) {
+ for (int j=0;j<NUM_COLS;j++) {
+ dest[i*NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i);
+ }
+ }
+}
+bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)state;
+ if (animation->first_update_of_frame) {
+ copy_current_led_state(&crossfade_start_frame[0][0]);
+ run_next_keyframe(animation, state);
+ copy_current_led_state(&crossfade_end_frame[0][0]);
+ }
+ for (int i=0;i<NUM_ROWS;i++) {
+ for (int j=0;j<NUM_COLS;j++) {
+ color_t color = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j]));
+ gdispGDrawPixel(LED_DISPLAY, j, i, color);
+ }
+ }
+ return true;
+}
+
+bool keyframe_mirror_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)state;
+ (void)animation;
+ gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180);
+ return false;
+}
+
+bool keyframe_normal_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)state;
+ (void)animation;
+ gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0);
+ return false;
+}
diff --git a/quantum/visualizer/led_test.h b/quantum/visualizer/led_test.h
new file mode 100644
index 0000000000..5e2325753e
--- /dev/null
+++ b/quantum/visualizer/led_test.h
@@ -0,0 +1,41 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef TMK_VISUALIZER_LED_TEST_H_
+#define TMK_VISUALIZER_LED_TEST_H_
+
+#include "visualizer.h"
+
+bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state);
+bool keyframe_fade_out_all_leds(keyframe_animation_t* animation, visualizer_state_t* state);
+bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
+bool keyframe_led_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
+bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* state);
+bool keyframe_mirror_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
+bool keyframe_normal_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
+
+extern keyframe_animation_t led_test_animation;
+
+
+#endif /* TMK_VISUALIZER_LED_TEST_H_ */
diff --git a/quantum/visualizer/readme.md b/quantum/visualizer/readme.md
new file mode 100644
index 0000000000..545ba22707
--- /dev/null
+++ b/quantum/visualizer/readme.md
@@ -0,0 +1,18 @@
+# A visualization library for the TMK keyboard firmware
+
+This library is designed to work together with the [TMK keyboard firmware](https://github.com/tmk/tmk_keyboard). Currently it only works for [Chibios](http://www.chibios.org/)
+ flavors, but it would be possible to add support for other configurations as well. The LCD display functionality is provided by the [uGFX library](http://www.ugfx.org/).
+
+## To use this library as a user
+You can and should modify the visualizer\_user.c file. Check the comments in the file for more information.
+
+## To add this library to custom keyboard projects
+
+1. Add tmk_visualizer as a submodule to your project
+1. Set VISUALIZER_DIR in the main keyboard project makefile to point to the submodule
+1. Define LCD\_ENABLE and/or LCD\_BACKLIGHT\_ENABLE, to enable support
+1. Include the visualizer.mk make file
+1. Copy the files in the example\_integration folder to your keyboard project
+1. All other files than the callback.c file are included automatically, so you will need to add callback.c to your makefile manually. If you already have a similar file in your project, you can just copy the functions instead of the whole file.
+1. Edit the files to match your hardware. You might might want to read the Chibios and UGfx documentation, for more information.
+1. If you enable LCD support you might also have to write a custom uGFX display driver, check the uGFX documentation for that. You probably also want to enable SPI support in your Chibios configuration.
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
new file mode 100644
index 0000000000..54f6faaa42
--- /dev/null
+++ b/quantum/visualizer/visualizer.c
@@ -0,0 +1,545 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#include "visualizer.h"
+#include "config.h"
+#include <string.h>
+#ifdef PROTOCOL_CHIBIOS
+#include "ch.h"
+#endif
+
+#include "gfx.h"
+
+#ifdef LCD_BACKLIGHT_ENABLE
+#include "lcd_backlight.h"
+#endif
+
+//#define DEBUG_VISUALIZER
+
+#ifdef DEBUG_VISUALIZER
+#include "debug.h"
+#else
+#include "nodebug.h"
+#endif
+
+#ifdef SERIAL_LINK_ENABLE
+#include "serial_link/protocol/transport.h"
+#include "serial_link/system/serial_link.h"
+#endif
+
+// Define this in config.h
+#ifndef VISUALIZER_THREAD_PRIORITY
+#define "Visualizer thread priority not defined"
+#endif
+
+
+static visualizer_keyboard_status_t current_status = {
+ .layer = 0xFFFFFFFF,
+ .default_layer = 0xFFFFFFFF,
+ .leds = 0xFFFFFFFF,
+ .suspended = false,
+};
+
+static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) {
+ return status1->layer == status2->layer &&
+ status1->default_layer == status2->default_layer &&
+ status1->leds == status2->leds &&
+ status1->suspended == status2->suspended;
+}
+
+static bool visualizer_enabled = false;
+
+#define MAX_SIMULTANEOUS_ANIMATIONS 4
+static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {};
+
+#ifdef SERIAL_LINK_ENABLE
+MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t);
+
+static remote_object_t* remote_objects[] = {
+ REMOTE_OBJECT(current_status),
+};
+
+#endif
+
+GDisplay* LCD_DISPLAY = 0;
+GDisplay* LED_DISPLAY = 0;
+
+__attribute__((weak))
+GDisplay* get_lcd_display(void) {
+ return gdispGetDisplay(0);
+}
+
+__attribute__((weak))
+GDisplay* get_led_display(void) {
+ return gdispGetDisplay(1);
+}
+
+void start_keyframe_animation(keyframe_animation_t* animation) {
+ animation->current_frame = -1;
+ animation->time_left_in_frame = 0;
+ animation->need_update = true;
+ int free_index = -1;
+ for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ if (animations[i] == animation) {
+ return;
+ }
+ if (free_index == -1 && animations[i] == NULL) {
+ free_index=i;
+ }
+ }
+ if (free_index!=-1) {
+ animations[free_index] = animation;
+ }
+}
+
+void stop_keyframe_animation(keyframe_animation_t* animation) {
+ animation->current_frame = animation->num_frames;
+ animation->time_left_in_frame = 0;
+ animation->need_update = true;
+ animation->first_update_of_frame = false;
+ animation->last_update_of_frame = false;
+ for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ if (animations[i] == animation) {
+ animations[i] = NULL;
+ return;
+ }
+ }
+}
+
+void stop_all_keyframe_animations(void) {
+ for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ if (animations[i]) {
+ animations[i]->current_frame = animations[i]->num_frames;
+ animations[i]->time_left_in_frame = 0;
+ animations[i]->need_update = true;
+ animations[i]->first_update_of_frame = false;
+ animations[i]->last_update_of_frame = false;
+ animations[i] = NULL;
+ }
+ }
+}
+
+static bool update_keyframe_animation(keyframe_animation_t* animation, visualizer_state_t* state, systemticks_t delta, systemticks_t* sleep_time) {
+ // TODO: Clean up this messy code
+ dprintf("Animation frame%d, left %d, delta %d\n", animation->current_frame,
+ animation->time_left_in_frame, delta);
+ if (animation->current_frame == animation->num_frames) {
+ animation->need_update = false;
+ return false;
+ }
+ if (animation->current_frame == -1) {
+ animation->current_frame = 0;
+ animation->time_left_in_frame = animation->frame_lengths[0];
+ animation->need_update = true;
+ animation->first_update_of_frame = true;
+ } else {
+ animation->time_left_in_frame -= delta;
+ while (animation->time_left_in_frame <= 0) {
+ int left = animation->time_left_in_frame;
+ if (animation->need_update) {
+ animation->time_left_in_frame = 0;
+ animation->last_update_of_frame = true;
+ (*animation->frame_functions[animation->current_frame])(animation, state);
+ animation->last_update_of_frame = false;
+ }
+ animation->current_frame++;
+ animation->need_update = true;
+ animation->first_update_of_frame = true;
+ if (animation->current_frame == animation->num_frames) {
+ if (animation->loop) {
+ animation->current_frame = 0;
+ }
+ else {
+ stop_keyframe_animation(animation);
+ return false;
+ }
+ }
+ delta = -left;
+ animation->time_left_in_frame = animation->frame_lengths[animation->current_frame];
+ animation->time_left_in_frame -= delta;
+ }
+ }
+ if (animation->need_update) {
+ animation->need_update = (*animation->frame_functions[animation->current_frame])(animation, state);
+ animation->first_update_of_frame = false;
+ }
+
+ systemticks_t wanted_sleep = animation->need_update ? gfxMillisecondsToTicks(10) : (unsigned)animation->time_left_in_frame;
+ if (wanted_sleep < *sleep_time) {
+ *sleep_time = wanted_sleep;
+ }
+
+ return true;
+}
+
+void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state) {
+ int next_frame = animation->current_frame + 1;
+ if (next_frame == animation->num_frames) {
+ next_frame = 0;
+ }
+ keyframe_animation_t temp_animation = *animation;
+ temp_animation.current_frame = next_frame;
+ temp_animation.time_left_in_frame = animation->frame_lengths[next_frame];
+ temp_animation.first_update_of_frame = true;
+ temp_animation.last_update_of_frame = false;
+ temp_animation.need_update = false;
+ visualizer_state_t temp_state = *state;
+ (*temp_animation.frame_functions[next_frame])(&temp_animation, &temp_state);
+}
+
+bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ (void)state;
+ return false;
+}
+
+#ifdef LCD_BACKLIGHT_ENABLE
+bool keyframe_animate_backlight_color(keyframe_animation_t* animation, visualizer_state_t* state) {
+ int frame_length = animation->frame_lengths[animation->current_frame];
+ int current_pos = frame_length - animation->time_left_in_frame;
+ uint8_t t_h = LCD_HUE(state->target_lcd_color);
+ uint8_t t_s = LCD_SAT(state->target_lcd_color);
+ uint8_t t_i = LCD_INT(state->target_lcd_color);
+ uint8_t p_h = LCD_HUE(state->prev_lcd_color);
+ uint8_t p_s = LCD_SAT(state->prev_lcd_color);
+ uint8_t p_i = LCD_INT(state->prev_lcd_color);
+
+ uint8_t d_h1 = t_h - p_h; //Modulo arithmetic since we want to wrap around
+ int d_h2 = t_h - p_h;
+ // Chose the shortest way around
+ int d_h = abs(d_h2) < d_h1 ? d_h2 : d_h1;
+ int d_s = t_s - p_s;
+ int d_i = t_i - p_i;
+
+ int hue = (d_h * current_pos) / frame_length;
+ int sat = (d_s * current_pos) / frame_length;
+ int intensity = (d_i * current_pos) / frame_length;
+ //dprintf("%X -> %X = %X\n", p_h, t_h, hue);
+ hue += p_h;
+ sat += p_s;
+ intensity += p_i;
+ state->current_lcd_color = LCD_COLOR(hue, sat, intensity);
+ lcd_backlight_color(
+ LCD_HUE(state->current_lcd_color),
+ LCD_SAT(state->current_lcd_color),
+ LCD_INT(state->current_lcd_color));
+
+ return true;
+}
+
+bool keyframe_set_backlight_color(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ state->prev_lcd_color = state->target_lcd_color;
+ state->current_lcd_color = state->target_lcd_color;
+ lcd_backlight_color(
+ LCD_HUE(state->current_lcd_color),
+ LCD_SAT(state->current_lcd_color),
+ LCD_INT(state->current_lcd_color));
+ return false;
+}
+#endif // LCD_BACKLIGHT_ENABLE
+
+#ifdef LCD_ENABLE
+bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ gdispClear(White);
+ gdispDrawString(0, 10, state->layer_text, state->font_dejavusansbold12, Black);
+ gdispFlush();
+ return false;
+}
+
+static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, char* buffer) {
+ for (int i=0; i<16;i++)
+ {
+ uint32_t mask = (1u << i);
+ if (default_layer & mask) {
+ if (layer & mask) {
+ *buffer = 'B';
+ } else {
+ *buffer = 'D';
+ }
+ } else if (layer & mask) {
+ *buffer = '1';
+ } else {
+ *buffer = '0';
+ }
+ ++buffer;
+
+ if (i==3 || i==7 || i==11) {
+ *buffer = ' ';
+ ++buffer;
+ }
+ }
+ *buffer = 0;
+}
+
+bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ const char* layer_help = "1=On D=Default B=Both";
+ char layer_buffer[16 + 4]; // 3 spaces and one null terminator
+ gdispClear(White);
+ gdispDrawString(0, 0, layer_help, state->font_fixed5x8, Black);
+ format_layer_bitmap_string(state->status.default_layer, state->status.layer, layer_buffer);
+ gdispDrawString(0, 10, layer_buffer, state->font_fixed5x8, Black);
+ format_layer_bitmap_string(state->status.default_layer >> 16, state->status.layer >> 16, layer_buffer);
+ gdispDrawString(0, 20, layer_buffer, state->font_fixed5x8, Black);
+ gdispFlush();
+ return false;
+}
+#endif // LCD_ENABLE
+
+bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ (void)state;
+#ifdef LCD_ENABLE
+ gdispSetPowerMode(powerOff);
+#endif
+#ifdef LCD_BACKLIGHT_ENABLE
+ lcd_backlight_hal_color(0, 0, 0);
+#endif
+ return false;
+}
+
+bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ (void)state;
+#ifdef LCD_ENABLE
+ gdispSetPowerMode(powerOn);
+#endif
+ return false;
+}
+
+bool enable_visualization(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ (void)state;
+ dprint("User visualizer inited\n");
+ visualizer_enabled = true;
+ return false;
+}
+
+// TODO: Optimize the stack size, this is probably way too big
+static DECLARE_THREAD_STACK(visualizerThreadStack, 1024);
+static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
+ (void)arg;
+
+ GListener event_listener;
+ geventListenerInit(&event_listener);
+ geventAttachSource(&event_listener, (GSourceHandle)&current_status, 0);
+
+ visualizer_keyboard_status_t initial_status = {
+ .default_layer = 0xFFFFFFFF,
+ .layer = 0xFFFFFFFF,
+ .leds = 0xFFFFFFFF,
+ .suspended = false,
+ };
+
+ visualizer_state_t state = {
+ .status = initial_status,
+ .current_lcd_color = 0,
+#ifdef LCD_ENABLE
+ .font_fixed5x8 = gdispOpenFont("fixed_5x8"),
+ .font_dejavusansbold12 = gdispOpenFont("DejaVuSansBold12")
+#endif
+ };
+ initialize_user_visualizer(&state);
+ state.prev_lcd_color = state.current_lcd_color;
+
+#ifdef LCD_BACKLIGHT_ENABLE
+ lcd_backlight_color(
+ LCD_HUE(state.current_lcd_color),
+ LCD_SAT(state.current_lcd_color),
+ LCD_INT(state.current_lcd_color));
+#endif
+
+ systemticks_t sleep_time = TIME_INFINITE;
+ systemticks_t current_time = gfxSystemTicks();
+
+ while(true) {
+ systemticks_t new_time = gfxSystemTicks();
+ systemticks_t delta = new_time - current_time;
+ current_time = new_time;
+ bool enabled = visualizer_enabled;
+ if (!same_status(&state.status, &current_status)) {
+ if (visualizer_enabled) {
+ if (current_status.suspended) {
+ stop_all_keyframe_animations();
+ visualizer_enabled = false;
+ state.status = current_status;
+ user_visualizer_suspend(&state);
+ }
+ else {
+ state.status = current_status;
+ update_user_visualizer_state(&state);
+ }
+ state.prev_lcd_color = state.current_lcd_color;
+ }
+ }
+ if (!enabled && state.status.suspended && current_status.suspended == false) {
+ // Setting the status to the initial status will force an update
+ // when the visualizer is enabled again
+ state.status = initial_status;
+ state.status.suspended = false;
+ stop_all_keyframe_animations();
+ user_visualizer_resume(&state);
+ state.prev_lcd_color = state.current_lcd_color;
+ }
+ sleep_time = TIME_INFINITE;
+ for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) {
+ if (animations[i]) {
+ update_keyframe_animation(animations[i], &state, delta, &sleep_time);
+ }
+ }
+#ifdef LED_ENABLE
+ gdispGFlush(LED_DISPLAY);
+#endif
+
+#ifdef EMULATOR
+ draw_emulator();
+#endif
+ // The animation can enable the visualizer
+ // And we might need to update the state when that happens
+ // so don't sleep
+ if (enabled != visualizer_enabled) {
+ sleep_time = 0;
+ }
+
+ systemticks_t after_update = gfxSystemTicks();
+ unsigned update_delta = after_update - current_time;
+ if (sleep_time != TIME_INFINITE) {
+ if (sleep_time > update_delta) {
+ sleep_time -= update_delta;
+ }
+ else {
+ sleep_time = 0;
+ }
+ }
+ dprintf("Update took %d, last delta %d, sleep_time %d\n", update_delta, delta, sleep_time);
+#ifdef PROTOCOL_CHIBIOS
+ // The gEventWait function really takes milliseconds, even if the documentation says ticks.
+ // Unfortunately there's no generic ugfx conversion from system time to milliseconds,
+ // so let's do it in a platform dependent way.
+
+ // On windows the system ticks is the same as milliseconds anyway
+ if (sleep_time != TIME_INFINITE) {
+ sleep_time = ST2MS(sleep_time);
+ }
+#endif
+ geventEventWait(&event_listener, sleep_time);
+ }
+#ifdef LCD_ENABLE
+ gdispCloseFont(state.font_fixed5x8);
+ gdispCloseFont(state.font_dejavusansbold12);
+#endif
+
+ return 0;
+}
+
+void visualizer_init(void) {
+ gfxInit();
+
+#ifdef LCD_BACKLIGHT_ENABLE
+ lcd_backlight_init();
+#endif
+
+#ifdef SERIAL_LINK_ENABLE
+ add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) );
+#endif
+
+#ifdef LCD_ENABLE
+ LCD_DISPLAY = get_lcd_display();
+#endif
+#ifdef LED_ENABLE
+ LED_DISPLAY = get_led_display();
+#endif
+
+ // We are using a low priority thread, the idea is to have it run only
+ // when the main thread is sleeping during the matrix scanning
+ gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack),
+ VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL);
+}
+
+void update_status(bool changed) {
+ if (changed) {
+ GSourceListener* listener = geventGetSourceListener((GSourceHandle)&current_status, NULL);
+ if (listener) {
+ geventSendEvent(listener);
+ }
+ }
+#ifdef SERIAL_LINK_ENABLE
+ static systime_t last_update = 0;
+ systime_t current_update = chVTGetSystemTimeX();
+ systime_t delta = current_update - last_update;
+ if (changed || delta > MS2ST(10)) {
+ last_update = current_update;
+ visualizer_keyboard_status_t* r = begin_write_current_status();
+ *r = current_status;
+ end_write_current_status();
+ }
+#endif
+}
+
+void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
+ // Note that there's a small race condition here, the thread could read
+ // a state where one of these are set but not the other. But this should
+ // not really matter as it will be fixed during the next loop step.
+ // Alternatively a mutex could be used instead of the volatile variables
+
+ bool changed = false;
+#ifdef SERIAL_LINK_ENABLE
+ if (is_serial_link_connected ()) {
+ visualizer_keyboard_status_t* new_status = read_current_status();
+ if (new_status) {
+ if (!same_status(&current_status, new_status)) {
+ changed = true;
+ current_status = *new_status;
+ }
+ }
+ }
+ else {
+#else
+ {
+#endif
+ visualizer_keyboard_status_t new_status = {
+ .layer = state,
+ .default_layer = default_state,
+ .leds = leds,
+ .suspended = current_status.suspended,
+ };
+ if (!same_status(&current_status, &new_status)) {
+ changed = true;
+ current_status = new_status;
+ }
+ }
+ update_status(changed);
+}
+
+void visualizer_suspend(void) {
+ current_status.suspended = true;
+ update_status(true);
+}
+
+void visualizer_resume(void) {
+ current_status.suspended = false;
+ update_status(true);
+}
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h
new file mode 100644
index 0000000000..53e250725c
--- /dev/null
+++ b/quantum/visualizer/visualizer.h
@@ -0,0 +1,147 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Fred Sundvik
+
+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.
+*/
+
+#ifndef VISUALIZER_H
+#define VISUALIZER_H
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "gfx.h"
+
+#ifdef LCD_BACKLIGHT_ENABLE
+#include "lcd_backlight.h"
+#endif
+
+// This need to be called once at the start
+void visualizer_init(void);
+// This should be called at every matrix scan
+void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds);
+// This should be called when the keyboard goes to suspend state
+void visualizer_suspend(void);
+// This should be called when the keyboard wakes up from suspend state
+void visualizer_resume(void);
+
+// These functions are week, so they can be overridden by the keyboard
+// if needed
+GDisplay* get_lcd_display(void);
+GDisplay* get_led_display(void);
+
+// For emulator builds, this function need to be implemented
+#ifdef EMULATOR
+void draw_emulator(void);
+#endif
+
+// If you need support for more than 16 keyframes per animation, you can change this
+#define MAX_VISUALIZER_KEY_FRAMES 16
+
+struct keyframe_animation_t;
+
+typedef struct {
+ uint32_t layer;
+ uint32_t default_layer;
+ uint32_t leds; // See led.h for available statuses
+ bool suspended;
+} visualizer_keyboard_status_t;
+
+// The state struct is used by the various keyframe functions
+// It's also used for setting the LCD color and layer text
+// from the user customized code
+typedef struct visualizer_state_t {
+ // The user code should primarily be modifying these
+ uint32_t target_lcd_color;
+ const char* layer_text;
+
+ // The user visualizer(and animation functions) can read these
+ visualizer_keyboard_status_t status;
+
+ // These are used by the animation functions
+ uint32_t current_lcd_color;
+ uint32_t prev_lcd_color;
+#ifdef LCD_ENABLE
+ font_t font_fixed5x8;
+ font_t font_dejavusansbold12;
+#endif
+} visualizer_state_t;
+
+// Any custom keyframe function should have this signature
+// return true to get continuous updates, otherwise you will only get one
+// update per frame
+typedef bool (*frame_func)(struct keyframe_animation_t*, visualizer_state_t*);
+
+// Represents a keyframe animation, so fields are internal to the system
+// while others are meant to be initialized by the user code
+typedef struct keyframe_animation_t {
+ // These should be initialized
+ int num_frames;
+ bool loop;
+ int frame_lengths[MAX_VISUALIZER_KEY_FRAMES];
+ frame_func frame_functions[MAX_VISUALIZER_KEY_FRAMES];
+
+ // Used internally by the system, and can also be read by
+ // keyframe update functions
+ int current_frame;
+ int time_left_in_frame;
+ bool first_update_of_frame;
+ bool last_update_of_frame;
+ bool need_update;
+
+} keyframe_animation_t;
+
+extern GDisplay* LCD_DISPLAY;
+extern GDisplay* LED_DISPLAY;
+
+void start_keyframe_animation(keyframe_animation_t* animation);
+void stop_keyframe_animation(keyframe_animation_t* animation);
+// This runs the next keyframe, but does not update the animation state
+// Useful for crossfades for example
+void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state);
+
+// Some predefined keyframe functions that can be used by the user code
+// Does nothing, useful for adding delays
+bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t* state);
+// Animates the LCD backlight color between the current color and the target color (of the state)
+bool keyframe_animate_backlight_color(keyframe_animation_t* animation, visualizer_state_t* state);
+// Sets the backlight color to the target color
+bool keyframe_set_backlight_color(keyframe_animation_t* animation, visualizer_state_t* state);
+// Displays the layer text centered vertically on the screen
+bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state);
+// Displays a bitmap (0/1) of all the currently active layers
+bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state);
+
+bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);
+bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);
+
+// Call this once, when the initial animation has finished, alternatively you can call it
+// directly from the initalize_user_visualizer function (the animation can be null)
+bool enable_visualization(keyframe_animation_t* animation, visualizer_state_t* state);
+
+// These functions have to be implemented by the user
+void initialize_user_visualizer(visualizer_state_t* state);
+void update_user_visualizer_state(visualizer_state_t* state);
+void user_visualizer_suspend(visualizer_state_t* state);
+void user_visualizer_resume(visualizer_state_t* state);
+
+
+#endif /* VISUALIZER_H */
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk
new file mode 100644
index 0000000000..2f4a41d66f
--- /dev/null
+++ b/quantum/visualizer/visualizer.mk
@@ -0,0 +1,61 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2016 Fred Sundvik
+#
+# 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.
+
+SRC += $(VISUALIZER_DIR)/visualizer.c
+EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
+GFXLIB = $(LIB_PATH)/ugfx
+VPATH += $(VISUALIZER_PATH)
+
+OPT_DEFS += -DVISUALIZER_ENABLE
+
+ifdef LCD_ENABLE
+OPT_DEFS += -DLCD_ENABLE
+ULIBS += -lm
+endif
+
+ifdef LCD_BACKLIGHT_ENABLE
+SRC += $(VISUALIZER_DIR)/lcd_backlight.c
+OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
+endif
+
+ifdef LED_ENABLE
+SRC += $(VISUALIZER_DIR)/led_test.c
+OPT_DEFS += -DLED_ENABLE
+endif
+
+include $(GFXLIB)/gfx.mk
+SRC += $(patsubst $(TOP_DIR)/%,%,$(GFXSRC))
+OPT_DEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
+
+ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","")
+ SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c
+else
+ ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/visualizer.c)","")
+$(error "$(KEYMAP_PATH)/visualizer.c" does not exist)
+ else
+ SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/visualizer.c
+ endif
+endif
+
+ifdef EMULATOR
+UINCDIR += $(TMK_DIR)/common
+endif \ No newline at end of file
diff --git a/readme.md b/readme.md
index cc36a34ffa..e0dcd56088 100644
--- a/readme.md
+++ b/readme.md
@@ -24,9 +24,6 @@ The project also includes community support for [lots of other keyboards](/keybo
QMK is developed and maintained by Jack Humbert of OLKB with contributions from the community, and of course, [Hasu](https://github.com/tmk). This repo used to be a fork of [TMK](https://github.com/tmk/tmk_keyboard), and we are incredibly grateful for his founding contributions to the firmware. We've had to break the fork due to purely technical reasons - it simply became too different over time, and we've had to start refactoring some of the basic bits and pieces. We are huge fans of TMK and Hasu :)
This documentation is edited and maintained by Erez Zukerman of ErgoDox EZ. If you spot any typos or inaccuracies, please [open an issue](https://github.com/jackhumbert/qmk_firmware/issues/new).
-#### 2016/02/10
-core: flabbergast's Chibios protocol was merged from <https://github.com/flabbergast/tmk_keyboard/tree/chibios> (@72b1668). See [tmk_core/protocol/chibios/README.md](tmk_core/protocol/chibios/README.md). Chibios protocol supports Cortex-M such as STM32 and Kinetis.
-
The OLKB product firmwares are maintained by [Jack Humbert](https://github.com/jackhumbert), the Ergodox EZ by [Erez Zukerman](https://github.com/ezuk), and the Clueboard by [Zach White](https://github.com/skullydazed).
@@ -359,6 +356,81 @@ void matrix_scan_user(void) {
As you can see, you have three function. you can use - `SEQ_ONE_KEY` for single-key sequences (Leader followed by just one key), and `SEQ_TWO_KEYS` and `SEQ_THREE_KEYS` for longer sequences. Each of these accepts one or more keycodes as arguments. This is an important point: You can use keycodes from **any layer on your keyboard**. That layer would need to be active for the leader macro to fire, obviously.
+### Tap Dance: A single key can do 3, 5, or 100 different things
+
+Hit the semicolon key once, send a semicolon. Hit it twice, rapidly -- send a colon. Hit it three times, and your keyboard's LEDs do a wild dance. That's just one example of what Tap Dance can do. It's one of the nicest community-contributed features in the firmware, conceived and created by [algernon](https://github.com/algernon) in [#451](https://github.com/jackhumbert/qmk_firmware/pull/451). Here's how Algernon describes the feature:
+
+With this feature one can specify keys that behave differently, based on the amount of times they have been tapped, and when interrupted, they get handled before the interrupter.
+
+To make it clear how this is different from `ACTION_FUNCTION_TAP`, lets explore a certain setup! We want one key to send `Space` on single tap, but `Enter` on double-tap.
+
+With `ACTION_FUNCTION_TAP`, it is quite a rain-dance to set this up, and has the problem that when the sequence is interrupted, the interrupting key will be send first. Thus, `SPC a` will result in `a SPC` being sent, if they are typed within `TAPPING_TERM`. With the tap dance feature, that'll come out as `SPC a`, correctly.
+
+The implementation hooks into two parts of the system, to achieve this: into `process_record_quantum()`, and the matrix scan. We need the latter to be able to time out a tap sequence even when a key is not being pressed, so `SPC` alone will time out and register after `TAPPING_TERM` time.
+
+But lets start with how to use it, first!
+
+First, you will need `TAP_DANCE_ENABLE=yes` in your `Makefile`, because the feature is disabled by default. This adds a little less than 1k to the firmware size. Next, you will want to define some tap-dance keys, which is easiest to do with the `TD()` macro, that - similar to `F()`, takes a number, which will later be used as an index into the `tap_dance_actions` array.
+
+This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are two possible options:
+
+* `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise.
+* `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the current state of the tap-dance action.
+
+The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise.
+
+And that's the bulk of it!
+
+Do note, however, that this implementation does have some consequences: keys do not register until either they reach the tapping ceiling, or they time out. This means that if you hold the key, nothing happens, no repeat, no nothing. It is possible to detect held state, and register an action then too, but that's not implemented yet. Keys also unregister immediately after being registered, so you can't even hold the second tap. This is intentional, to be consistent.
+
+And now, on to the explanation of how it works!
+
+The main entry point is `process_tap_dance()`, called from `process_record_quantum()`, which is run for every keypress, and our handler gets to run early. This function checks whether the key pressed is a tap-dance key. If it is not, and a tap-dance was in action, we handle that first, and enqueue the newly pressed key. If it is a tap-dance key, then we check if it is the same as the already active one (if there's one active, that is). If it is not, we fire off the old one first, then register the new one. If it was the same, we increment the counter and the timer.
+
+This means that you have `TAPPING_TERM` time to tap the key again, you do not have to input all the taps within that timeframe. This allows for longer tap counts, with minimal impact on responsiveness.
+
+Our next stop is `matrix_scan_tap_dance()`. This handles the timeout of tap-dance keys.
+
+For the sake of flexibility, tap-dance actions can be either a pair of keycodes, or a user function. The latter allows one to handle higher tap counts, or do extra things, like blink the LEDs, fiddle with the backlighting, and so on. This is accomplished by using an union, and some clever macros.
+
+In the end, let's see a full example!
+
+```c
+enum {
+ CT_SE = 0,
+ CT_CLN,
+ CT_EGG
+};
+
+/* Have the above three on the keymap, TD(CT_SE), etc... */
+
+void dance_cln (qk_tap_dance_state_t *state) {
+ if (state->count == 1) {
+ register_code (KC_RSFT);
+ register_code (KC_SCLN);
+ unregister_code (KC_SCLN);
+ unregister_code (KC_RSFT);
+ } else {
+ register_code (KC_SCLN);
+ unregister_code (KC_SCLN);
+ reset_tap_dance (state);
+ }
+}
+
+void dance_egg (qk_tap_dance_state_t *state) {
+ if (state->count >= 100) {
+ SEND_STRING ("Safety dance!");
+ reset_tap_dance (state);
+ }
+}
+
+const qk_tap_dance_action_t tap_dance_actions[] = {
+ [CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT)
+ ,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln)
+ ,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg)
+};
+```
+
### Temporarily setting the default layer
`DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.
@@ -710,23 +782,18 @@ For this mod, you need an unused pin wiring to DI of WS2812 strip. After wiring
RGBLIGHT_ENABLE = yes
-Please note that the underglow is not compatible with audio output. So you cannot enable both of them at the same time.
+In order to use the underglow timer functions, you need to have `#define RGBLIGHT_TIMER` in your `config.h`, and have audio disabled (`AUDIO_ENABLE = no` in your Makefile).
-Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the F4 by default:
-
- #define ws2812_PORTREG PORTF
- #define ws2812_DDRREG DDRF
- #define ws2812_pin PF4
+Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the `F4` pin by default:
+
+ #define RGB_DI_PIN F4 // The pin your RGB strip is wired to
+ #define RGBLIGHT_TIMER // Require for fancier stuff (not compatible with audio)
#define RGBLED_NUM 14 // Number of LEDs
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
#define RGBLIGHT_VAL_STEP 17
-You'll need to edit `PORTF`, `DDRF`, and `PF4` on the first three lines to the port/pin you have your LED(s) wired to, eg for B3 change things to:
-
- #define ws2812_PORTREG PORTB
- #define ws2812_DDRREG DDRB
- #define ws2812_pin PB3
+You'll need to edit `RGB_DI_PIN` to the pin you have your `DI` on your RGB strip wired to.
The firmware supports 5 different light effects, and the color (hue, saturation, brightness) can be customized in most effects. To control the underglow, you need to modify your keymap file to assign those functions to some keys/key combinations. For details, please check this keymap. `keyboards/planck/keymaps/yang/keymap.c`
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 72be5e6da1..3bf2b34f88 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -10,6 +10,7 @@ AR = avr-ar rcs
NM = avr-nm
HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature
EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT)
+BIN =
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 0abb933a8d..cb67ac6f25 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -113,6 +113,7 @@ AR = arm-none-eabi-ar
NM = arm-none-eabi-nm
HEX = $(OBJCOPY) -O $(FORMAT)
EEP =
+BIN = $(OBJCOPY) -O binary
THUMBFLAGS = -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB
@@ -151,4 +152,7 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h)","")
endif
# List any extra directories to look for libraries here.
-EXTRALIBDIRS = $(RULESPATH)/ld \ No newline at end of file
+EXTRALIBDIRS = $(RULESPATH)/ld
+
+dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter
+ dfu-util -D $(BUILD_DIR)/$(TARGET).bin \ No newline at end of file
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index d71fba9bc1..aa05b9491d 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -97,8 +97,17 @@ ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes)
endif
endif
+ifeq ($(MASTER),right)
+ OPT_DEFS += -DMASTER_IS_ON_RIGHT
+else
+ ifneq ($(MASTER),left)
+$(error MASTER does not have a valid value(left/right))
+ endif
+endif
+
+
# Version string
-OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null)
+OPT_DEFS += -DVERSION=$(GIT_VERSION)
# Bootloader address
ifdef STM32_BOOTLOADER_ADDRESS
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c
index 7c744e8c79..fb9bf2d1c3 100644
--- a/tmk_core/common/avr/bootloader.c
+++ b/tmk_core/common/avr/bootloader.c
@@ -73,26 +73,46 @@ uint32_t reset_key __attribute__ ((section (".noinit")));
/* initialize MCU status by watchdog reset */
void bootloader_jump(void) {
-#ifdef PROTOCOL_LUFA
- USB_Disable();
- cli();
- _delay_ms(2000);
-#endif
+ #ifndef CATERINA_BOOTLOADER
-#ifdef PROTOCOL_PJRC
- cli();
- UDCON = 1;
- USBCON = (1<<FRZCLK);
- UCSR1B = 0;
- _delay_ms(5);
-#endif
+ #ifdef PROTOCOL_LUFA
+ USB_Disable();
+ cli();
+ _delay_ms(2000);
+ #endif
- // watchdog reset
- reset_key = BOOTLOADER_RESET_KEY;
- wdt_enable(WDTO_250MS);
- for (;;);
-}
+ #ifdef PROTOCOL_PJRC
+ cli();
+ UDCON = 1;
+ USBCON = (1<<FRZCLK);
+ UCSR1B = 0;
+ _delay_ms(5);
+ #endif
+
+ // watchdog reset
+ reset_key = BOOTLOADER_RESET_KEY;
+ wdt_enable(WDTO_250MS);
+ for (;;);
+
+ #else
+ // this block may be optional
+ // TODO: figure it out
+
+ uint16_t *const bootKeyPtr = (uint16_t *)0x0800;
+ // Value used by Caterina bootloader use to determine whether to run the
+ // sketch or the bootloader programmer.
+ uint16_t bootKey = 0x7777;
+
+ *bootKeyPtr = bootKey;
+
+ // setup watchdog timeout
+ wdt_enable(WDTO_60MS);
+
+ while(1) {} // wait for watchdog timer to trigger
+
+ #endif
+}
/* this runs before main() */
void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3")));
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 81df8eb73b..c46a701b3b 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sendchar.h"
#include "eeconfig.h"
#include "backlight.h"
+#include "action_layer.h"
#ifdef BOOTMAGIC_ENABLE
# include "bootmagic.h"
#else
@@ -49,6 +50,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
#endif
+#ifdef SERIAL_LINK_ENABLE
+# include "serial_link/system/serial_link.h"
+#endif
+#ifdef VISUALIZER_ENABLE
+# include "visualizer/visualizer.h"
+#endif
#ifdef MATRIX_HAS_GHOST
static bool has_ghost_in_row(uint8_t row)
@@ -167,11 +174,19 @@ MATRIX_LOOP_END:
#endif
#ifdef SERIAL_MOUSE_ENABLE
- serial_mouse_task();
+ serial_mouse_task();
#endif
#ifdef ADB_MOUSE_ENABLE
- adb_mouse_task();
+ adb_mouse_task();
+#endif
+
+#ifdef SERIAL_LINK_ENABLE
+ serial_link_update();
+#endif
+
+#ifdef VISUALIZER_ENABLE
+ visualizer_update(default_layer_state, layer_state, host_keyboard_leds());
#endif
// update LED
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h
index 448195306f..2f208c54e0 100644
--- a/tmk_core/common/keycode.h
+++ b/tmk_core/common/keycode.h
@@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF))
#define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE)
-#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV)
+#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_MRWD)
#define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31)
#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)
@@ -156,8 +156,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_WSTP KC_WWW_STOP
#define KC_WREF KC_WWW_REFRESH
#define KC_WFAV KC_WWW_FAVORITES
-/* Jump to bootloader */
-#define KC_BTLD KC_BOOTLOADER
/* Transparent */
#define KC_TRANSPARENT 1
#define KC_TRNS KC_TRANSPARENT
@@ -428,9 +426,6 @@ enum internal_special_keycodes {
KC_MEDIA_FAST_FORWARD,
KC_MEDIA_REWIND, /* 0xBC */
- /* Jump to bootloader */
- KC_BOOTLOADER = 0xBF,
-
/* Fn key */
KC_FN0 = 0xC0,
KC_FN1,
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h
index 71153a5f58..cee3593eee 100644
--- a/tmk_core/common/matrix.h
+++ b/tmk_core/common/matrix.h
@@ -72,6 +72,11 @@ void matrix_scan_kb(void);
void matrix_init_user(void);
void matrix_scan_user(void);
+#ifdef I2C_SPLIT
+ void slave_matrix_init(void);
+ uint8_t slave_matrix_scan(void);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index 54bb6a8f55..b0eb9aef81 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -35,6 +35,12 @@
#ifdef SLEEP_LED_ENABLE
#include "sleep_led.h"
#endif
+#ifdef SERIAL_LINK_ENABLE
+#include "serial_link/system/serial_link.h"
+#endif
+#ifdef VISUALIZER_ENABLE
+#include "visualizer/visualizer.h"
+#endif
#include "suspend.h"
@@ -98,9 +104,32 @@ int main(void) {
/* init printf */
init_printf(NULL,sendchar_pf);
- /* Wait until the USB is active */
- while(USB_DRIVER.state != USB_ACTIVE)
+#ifdef SERIAL_LINK_ENABLE
+ init_serial_link();
+#endif
+
+#ifdef VISUALIZER_ENABLE
+ visualizer_init();
+#endif
+
+
+ host_driver_t* driver = NULL;
+
+ /* Wait until the USB or serial link is active */
+ while (true) {
+ if(USB_DRIVER.state == USB_ACTIVE) {
+ driver = &chibios_driver;
+ break;
+ }
+#ifdef SERIAL_LINK_ENABLE
+ if(is_serial_link_connected()) {
+ driver = get_serial_link_driver();
+ break;
+ }
+ serial_link_update();
+#endif
chThdSleepMilliseconds(50);
+ }
/* Do need to wait here!
* Otherwise the next print might start a transfer on console EP
@@ -113,7 +142,7 @@ int main(void) {
/* init TMK modules */
keyboard_init();
- host_set_driver(&chibios_driver);
+ host_set_driver(driver);
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
@@ -126,8 +155,14 @@ int main(void) {
if(USB_DRIVER.state == USB_SUSPENDED) {
print("[s]");
+#ifdef VISUALIZER_ENABLE
+ visualizer_suspend();
+#endif
while(USB_DRIVER.state == USB_SUSPENDED) {
/* Do this in the suspended state */
+#ifdef SERIAL_LINK_ENABLE
+ serial_link_update();
+#endif
suspend_power_down(); // on AVR this deep sleeps for 15ms
/* Remote wakeup */
if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) {
@@ -140,6 +175,10 @@ int main(void) {
#ifdef MOUSEKEY_ENABLE
mousekey_send();
#endif /* MOUSEKEY_ENABLE */
+
+#ifdef VISUALIZER_ENABLE
+ visualizer_resume();
+#endif
}
keyboard_task();
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index 7d3d8f9a6b..f13351ea19 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -234,6 +234,7 @@ MSG_COFF = Converting to AVR COFF:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
+MSG_BIN = Creating binary load file for Flash:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
@@ -259,7 +260,7 @@ LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst
# Compiler flags to generate dependency files.
#GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
-GENDEPFLAGS = -MMD -MP -MF $(BUILD_DIR)/.dep/$(subst /,_,$@).d
+GENDEPFLAGS = -MMD -MP -MF $(BUILD_DIR)/.dep/$(subst /,_,$(subst $(BUILD_DIR)/,,$@)).d
# Combine all necessary flags and optional flags.
@@ -270,23 +271,10 @@ ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
# Default target.
-all:
- @$(MAKE) begin
- @$(MAKE) gccversion
- @$(MAKE) sizebefore
- @$(MAKE) clean_list # force clean each time
- @$(MAKE) build
- @$(MAKE) sizeafter
- @$(MAKE) end
+all: build sizeafter
# Quick make that doesn't clean
-quick:
- @$(MAKE) begin
- @$(MAKE) gccversion
- @$(MAKE) sizebefore
- @$(MAKE) build
- @$(MAKE) sizeafter
- @$(MAKE) end
+quick: build sizeafter
# Change the build target to build a HEX file or a library.
build: elf hex
@@ -302,13 +290,7 @@ sym: $(BUILD_DIR)/$(TARGET).sym
LIBNAME=lib$(TARGET).a
lib: $(LIBNAME)
-
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
- @$(SECHO) $(MSG_BEGIN)
+check_submodule:
git submodule status --recursive | \
while IFS= read -r x; do \
case "$$x" in \
@@ -317,10 +299,6 @@ begin:
esac \
done
-end:
- @$(SECHO) $(MSG_END)
-
-
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
#ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
@@ -330,7 +308,7 @@ sizebefore:
@if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi
-sizeafter:
+sizeafter: $(BUILD_DIR)/$(TARGET).hex
@if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi
# test file sizes eventually
@@ -369,6 +347,11 @@ gccversion :
$(eval CMD=$(NM) -n $< > $@ )
@$(BUILD_CMD)
+%.bin: %.elf
+ @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD)
+ $(eval CMD=$(BIN) $< $@ || exit 0)
+ @$(BUILD_CMD)
+
# Create library from object files.
.SECONDARY : $(BUILD_DIR)/$(TARGET).a
.PRECIOUS : $(OBJ)
@@ -377,60 +360,55 @@ gccversion :
$(eval CMD=$(AR) $@ $(OBJ) )
@$(BUILD_CMD)
+BEGIN = gccversion check_submodule sizebefore
+
# Link: create ELF output file from object files.
.SECONDARY : $(BUILD_DIR)/$(TARGET).elf
.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
+%.elf: $(OBJ) | $(BEGIN)
@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
$(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS))
@$(BUILD_CMD)
# Compile: create object files from C source files.
-$(OBJDIR)/%.o : %.c
+$(OBJDIR)/%.o : %.c | $(BEGIN)
@mkdir -p $(@D)
@$(SILENT) || printf "$(MSG_COMPILING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -c $(ALL_CFLAGS) $< -o $@)
@$(BUILD_CMD)
# Compile: create object files from C++ source files.
-$(OBJDIR)/%.o : %.cpp
+$(OBJDIR)/%.o : %.cpp | $(BEGIN)
@mkdir -p $(@D)
@$(SILENT) || printf "$(MSG_COMPILING_CPP) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -c $(ALL_CPPFLAGS) $< -o $@)
@$(BUILD_CMD)
# Compile: create assembler files from C source files.
-%.s : %.c
+%.s : %.c | $(BEGIN)
@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -S $(ALL_CFLAGS) $< -o $@)
@$(BUILD_CMD)
# Compile: create assembler files from C++ source files.
-%.s : %.cpp
+%.s : %.cpp | $(BEGIN)
@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -S $(ALL_CPPFLAGS) $< -o $@)
@$(BUILD_CMD)
# Assemble: create object files from assembler source files.
-$(OBJDIR)/%.o : %.S
+$(OBJDIR)/%.o : %.S | $(BEGIN)
@mkdir -p $(@D)
@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
$(eval CMD=$(CC) -c $(ALL_ASFLAGS) $< -o $@)
@$(BUILD_CMD)
# Create preprocessed source for use in sending a bug report.
-%.i : %.c
+%.i : %.c | $(BEGIN)
$(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
- @$(REMOVE) -r $(BUILD_DIR)
- @$(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR)
- @$(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR)
- @if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi
- @$(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR)
+clean:
show_path:
@echo VPATH=$(VPATH)
@@ -490,6 +468,19 @@ all-keymaps-%:
all-keymaps: all-keymaps-all
+GOAL=$(MAKECMDGOALS)
+ifeq ($(MAKECMDGOALS),)
+GOAL = all
+endif
+CLEANING_GOALS=clean clean_list all
+ifneq ($(findstring $(GOAL),$(CLEANING_GOALS)),)
+$(shell $(REMOVE) -r $(BUILD_DIR) 2>/dev/null)
+$(shell $(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR))
+$(shell $(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR))
+$(shell if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi)
+$(shell $(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR))
+endif
+
# Create build directory
$(shell mkdir $(BUILD_DIR) 2>/dev/null)
@@ -502,8 +493,8 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
# Listing of phony targets.
-.PHONY : all quick begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
+.PHONY : all quick finish sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff check_submodule \
clean clean_list debug gdb-config show_path \
program teensy dfu flip dfu-ee flip-ee dfu-start \
all-keyboards-defaults all-keyboards all-keymaps \