From 3e264e46d4c53ed7198731fcdfefc74396b48f1a Mon Sep 17 00:00:00 2001
From: Derek <dschmell91@gmail.com>
Date: Sat, 15 Aug 2020 16:01:35 -0400
Subject: [PATCH] Add splitreus62 shield

---
 .../shields/splitreus62/Kconfig.defconfig     | 54 +++++++++++++++++++
 app/boards/shields/splitreus62/Kconfig.shield |  8 +++
 .../shields/splitreus62/splitreus62.conf      |  2 +
 .../shields/splitreus62/splitreus62.dtsi      | 50 +++++++++++++++++
 .../shields/splitreus62/splitreus62.keymap    | 25 +++++++++
 .../shields/splitreus62/splitreus62_left.conf |  2 +
 .../splitreus62/splitreus62_left.overlay      | 19 +++++++
 .../splitreus62/splitreus62_right.conf        |  3 ++
 .../splitreus62/splitreus62_right.overlay     | 22 ++++++++
 9 files changed, 185 insertions(+)
 create mode 100644 app/boards/shields/splitreus62/Kconfig.defconfig
 create mode 100644 app/boards/shields/splitreus62/Kconfig.shield
 create mode 100644 app/boards/shields/splitreus62/splitreus62.conf
 create mode 100644 app/boards/shields/splitreus62/splitreus62.dtsi
 create mode 100644 app/boards/shields/splitreus62/splitreus62.keymap
 create mode 100644 app/boards/shields/splitreus62/splitreus62_left.conf
 create mode 100644 app/boards/shields/splitreus62/splitreus62_left.overlay
 create mode 100644 app/boards/shields/splitreus62/splitreus62_right.conf
 create mode 100644 app/boards/shields/splitreus62/splitreus62_right.overlay

diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig
new file mode 100644
index 00000000..c52752a0
--- /dev/null
+++ b/app/boards/shields/splitreus62/Kconfig.defconfig
@@ -0,0 +1,54 @@
+
+if SHIELD_SPLITREUS62_LEFT
+
+config ZMK_KEYBOARD_NAME
+	default "Splitreus62 Left"
+
+endif
+
+if SHIELD_SPLITREUS62_RIGHT
+
+config ZMK_KEYBOARD_NAME
+	default "Splitreus62 Right"
+
+endif
+
+if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT
+
+if ZMK_DISPLAY
+
+config I2C
+	default n
+
+config SSD1306
+	default n
+
+config SSD1306_REVERSE_MODE
+	default n
+
+endif # ZMK_DISPLAY
+
+if LVGL
+
+config LVGL_HOR_RES
+	default 128
+
+config LVGL_VER_RES
+	default 32
+
+config LVGL_VDB_SIZE
+	default 64
+
+config LVGL_DPI
+	default 148
+
+config LVGL_BITS_PER_PIXEL
+	default 1
+
+choice LVGL_COLOR_DEPTH
+	default LVGL_COLOR_DEPTH_1
+endchoice
+
+endif # LVGL
+
+endif
diff --git a/app/boards/shields/splitreus62/Kconfig.shield b/app/boards/shields/splitreus62/Kconfig.shield
new file mode 100644
index 00000000..f20f2362
--- /dev/null
+++ b/app/boards/shields/splitreus62/Kconfig.shield
@@ -0,0 +1,8 @@
+# Copyright (c) 2020 Pete Johanson
+# SPDX-License-Identifier: MIT
+
+config SHIELD_SPLITREUS62_LEFT
+	def_bool $(shields_list_contains,splitreus62_left)
+
+config SHIELD_SPLITREUS62_RIGHT
+	def_bool $(shields_list_contains,splitreus62_right)
diff --git a/app/boards/shields/splitreus62/splitreus62.conf b/app/boards/shields/splitreus62/splitreus62.conf
new file mode 100644
index 00000000..73f0d9de
--- /dev/null
+++ b/app/boards/shields/splitreus62/splitreus62.conf
@@ -0,0 +1,2 @@
+# Uncomment the following line to enable the Lily58 OLED Display
+# CONFIG_ZMK_DISPLAY=y
diff --git a/app/boards/shields/splitreus62/splitreus62.dtsi b/app/boards/shields/splitreus62/splitreus62.dtsi
new file mode 100644
index 00000000..e1fb40b2
--- /dev/null
+++ b/app/boards/shields/splitreus62/splitreus62.dtsi
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2020 Pete Johanson, Derek Schmell
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <dt-bindings/zmk/matrix-transform.h>
+
+/ {
+	chosen {
+		zmk,kscan = &kscan0;
+		zmk,matrix_transform = &default_transform;
+	};
+
+	default_transform: keymap_transform_0 {
+		compatible = "zmk,matrix-transform";
+		columns = <12>;
+		rows = <6>;
+// | SW0 | SW5 | SW10 | SW15 | SW20 | SW25		             | SW25 | SW20 | SW15 | SW10 | SW5 | SW1 |
+// | SW1 | SW6 | SW11 | SW16 | SW21 | SW26		             | SW26 | SW21 | SW16 | SW11 | SW6 | SW2 |
+// | SW2 | SW7 | SW12 | SW17 | SW22 | SW27		             | SW27 | SW22 | SW17 | SW12 | SW7 | SW3 |
+// | SW3 | SW8 | SW13 | SW18 | SW23 | SW28		             | SW28 | SW23 | SW18 | SW13 | SW8 | SW4 |
+// | SW4 | SW9 | SW14 | SW19 | SW24 | SW29                   | SW29 | SW24 | SW19 | SW14 | SW9 | SW5 |
+//                                    SW30                   | SW30
+		map = <
+RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5)                 RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11)
+RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5)                 RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11)
+RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5)                 RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11)
+RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5)                 RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11)
+RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5)                 RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11)
+                                        RC(5,5)                 RC(5,6)
+		>;
+	};
+
+	kscan0: kscan {
+		compatible = "zmk,kscan-gpio-matrix";
+		label = "KSCAN";
+
+		diode-direction = "row2col";
+		row-gpios
+			= <&pro_micro_d 1 GPIO_ACTIVE_HIGH >
+			, <&pro_micro_d 0 GPIO_ACTIVE_HIGH>
+			, <&pro_micro_d 2 GPIO_ACTIVE_HIGH>
+			, <&pro_micro_d 4 GPIO_ACTIVE_HIGH>
+			, <&pro_micro_d 5 GPIO_ACTIVE_HIGH>
+			, <&pro_micro_d 6 GPIO_ACTIVE_HIGH>
+			;
+		
+	};
+};
diff --git a/app/boards/shields/splitreus62/splitreus62.keymap b/app/boards/shields/splitreus62/splitreus62.keymap
new file mode 100644
index 00000000..cd683a22
--- /dev/null
+++ b/app/boards/shields/splitreus62/splitreus62.keymap
@@ -0,0 +1,25 @@
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/keys.h>
+
+/ {
+	keymap {
+		compatible = "zmk,keymap";
+
+		default_layer {
+// ------------------------------------------------------------------------------------------------------------
+// |  ESC  |  1  |  2  |  3   |  4   |  5   |                   |  6   |  7    |  8    |  9   |   0   |   -   |
+// |  TAB  |  Q  |  W  |  E   |  R   |  T   |                   |  Y   |  U    |  I    |  O   |   P   |   \   |
+// |  CTRL |  A  |  S  |  D   |  F   |  G   |                   |  H   |  J    |  K    |  L   |   ;   |   '   |
+// | SHIFT |  Z  |  X  |  C   |  V   |  B   |                   |  N   |  M    |  ,    |  .   |   /   | SHIFT |
+// | LCTL  | LGUI  | LALT |  GRAV |  | EQL | DEL | BKSP|  | RET | SPC  | LBKT |  RBKT  | LBKT | HOME  |   END |
+			bindings = <
+&kp ESC  &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5                    &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS
+&kp TAB  &kp Q     &kp W     &kp E     &kp R     &kp T                        &kp Y     &kp U     &kp I     &kp O     &kp P     &kp BSLH
+&kp LCTL &kp A     &kp S     &kp D     &kp F     &kp G                        &kp H     &kp J     &kp K     &kp L     &kp SCLN  &kp QUOT
+&kp LSFT &kp Z     &kp X     &kp C     &kp V     &kp B                        &kp N     &kp M     &kp CMMA  &kp DOT   &kp FSLH  &kp RSFT
+&kp LCTL  &kp LGUI  &kp LALT &kp GRAV   &kp EQL  &kp DEL                     &kp SPC  &kp LBKT    &kp RBKT   &kp MINUS  &kp HOME   &kp END
+                                                 &kp BKSP                    &kp RET
+			>;
+		};
+	};
+};
diff --git a/app/boards/shields/splitreus62/splitreus62_left.conf b/app/boards/shields/splitreus62/splitreus62_left.conf
new file mode 100644
index 00000000..a835adc1
--- /dev/null
+++ b/app/boards/shields/splitreus62/splitreus62_left.conf
@@ -0,0 +1,2 @@
+CONFIG_ZMK_SPLIT=y
+CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
\ No newline at end of file
diff --git a/app/boards/shields/splitreus62/splitreus62_left.overlay b/app/boards/shields/splitreus62/splitreus62_left.overlay
new file mode 100644
index 00000000..aea374a4
--- /dev/null
+++ b/app/boards/shields/splitreus62/splitreus62_left.overlay
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2020 Pete Johanson
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "splitreus62.dtsi"
+
+&kscan0 {
+	col-gpios
+		= <&pro_micro_d  7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d  8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		;
+};
+
diff --git a/app/boards/shields/splitreus62/splitreus62_right.conf b/app/boards/shields/splitreus62/splitreus62_right.conf
new file mode 100644
index 00000000..ab43d049
--- /dev/null
+++ b/app/boards/shields/splitreus62/splitreus62_right.conf
@@ -0,0 +1,3 @@
+CONFIG_ZMK_SPLIT=y
+CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
+#CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
diff --git a/app/boards/shields/splitreus62/splitreus62_right.overlay b/app/boards/shields/splitreus62/splitreus62_right.overlay
new file mode 100644
index 00000000..3c0f9899
--- /dev/null
+++ b/app/boards/shields/splitreus62/splitreus62_right.overlay
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2020 Pete Johanson
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "splitreus62.dtsi"
+
+&default_transform {
+	col-offset = <6>;
+};
+
+&kscan0 {
+	col-gpios
+		= <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d  8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		, <&pro_micro_d  7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+		;
+};
\ No newline at end of file