From 6a9a6e6d8edaae5f3e5bc37033a9391bc66e786a Mon Sep 17 00:00:00 2001
From: Nigel Rodriguez <anr.rod@gmail.com>
Date: Sat, 24 Oct 2020 12:21:15 +0800
Subject: [PATCH] Add Boardsource 3x4 shield

---
 .github/workflows/build.yml                   |  1 +
 .../shields/boardsource3x4/Kconfig.defconfig  | 13 +++++
 .../shields/boardsource3x4/Kconfig.shield     |  9 ++++
 .../boardsource3x4/boardsource3x4.conf        |  0
 .../boardsource3x4/boardsource3x4.keymap      | 49 +++++++++++++++++++
 .../boardsource3x4/boardsource3x4.overlay     | 38 ++++++++++++++
 6 files changed, 110 insertions(+)
 create mode 100644 app/boards/shields/boardsource3x4/Kconfig.defconfig
 create mode 100644 app/boards/shields/boardsource3x4/Kconfig.shield
 create mode 100644 app/boards/shields/boardsource3x4/boardsource3x4.conf
 create mode 100644 app/boards/shields/boardsource3x4/boardsource3x4.keymap
 create mode 100644 app/boards/shields/boardsource3x4/boardsource3x4.overlay

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 60c337de..afaa8af7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,6 +10,7 @@ jobs:
       matrix:
         board: [proton_c, nice_nano, bluemicro840_v1, nrfmicro_13]
         shield:
+          - boardsource3x4
           - corne_left
           - corne_right
           - kyria_left
diff --git a/app/boards/shields/boardsource3x4/Kconfig.defconfig b/app/boards/shields/boardsource3x4/Kconfig.defconfig
new file mode 100644
index 00000000..c03703b0
--- /dev/null
+++ b/app/boards/shields/boardsource3x4/Kconfig.defconfig
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+
+if SHIELD_BOARDSOURCE3X4
+
+config ZMK_KEYBOARD_NAME
+    default "Boardsource 3x4"
+
+endif
\ No newline at end of file
diff --git a/app/boards/shields/boardsource3x4/Kconfig.shield b/app/boards/shields/boardsource3x4/Kconfig.shield
new file mode 100644
index 00000000..2e9e228c
--- /dev/null
+++ b/app/boards/shields/boardsource3x4/Kconfig.shield
@@ -0,0 +1,9 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+config SHIELD_BOARDSOURCE3X4
+	def_bool $(shields_list_contains,boardsource3x4)
+
diff --git a/app/boards/shields/boardsource3x4/boardsource3x4.conf b/app/boards/shields/boardsource3x4/boardsource3x4.conf
new file mode 100644
index 00000000..e69de29b
diff --git a/app/boards/shields/boardsource3x4/boardsource3x4.keymap b/app/boards/shields/boardsource3x4/boardsource3x4.keymap
new file mode 100644
index 00000000..031b7c97
--- /dev/null
+++ b/app/boards/shields/boardsource3x4/boardsource3x4.keymap
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/keys.h>
+#include <dt-bindings/zmk/bt.h>
+
+/ {
+    keymap {
+        compatible = "zmk,keymap";
+
+        default_layer {
+
+            bindings = <
+    &tog 1 &cp M_PREV &cp M_PLAY &cp M_NEXT
+    &mo 2  &cp M_VOLD &kp UARW   &cp M_VOLU
+    &mo 3  &kp LARW   &kp DARW   &kp RARW
+            >;
+
+        };
+
+        num_layer {
+            bindings = <
+    &tog 1       &kp NUM_7 &kp NUM_8 &kp NUM_9
+    &mo 2        &kp NUM_4 &kp NUM_5 &kp NUM_6
+    &lt 3 NUM_0  &kp NUM_1 &kp NUM_2 &kp NUM_3
+            >;
+        };
+
+        lower_layer {
+            bindings = <
+    &bt BT_CLR &none        &reset       &bootloader
+    &trans     &bt BT_SEL 3 &bt BT_SEL 4 &none
+    &none      &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2
+            >;
+        };
+
+        raise_layer {
+            bindings = <
+    &kp 0x68 &kp 0x69 &kp 0x6A &kp 0x6B
+    &kp 0x6C &kp 0x6D &kp 0x6E &kp 0x6F
+    &trans   &kp 0x70 &kp 0x71 &kp 0x72
+            >;
+        };
+    };
+};
\ No newline at end of file
diff --git a/app/boards/shields/boardsource3x4/boardsource3x4.overlay b/app/boards/shields/boardsource3x4/boardsource3x4.overlay
new file mode 100644
index 00000000..d68ac30b
--- /dev/null
+++ b/app/boards/shields/boardsource3x4/boardsource3x4.overlay
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <dt-bindings/zmk/matrix-transform.h>
+
+/ {
+    chosen {
+        zmk,kscan = &kscan0;
+    };
+
+    kscan0: kscan {
+        compatible = "zmk,kscan-gpio-matrix";
+        label = "KSCAN";
+        diode-direction = "col2row";
+
+         row-gpios
+            = <&pro_micro_a 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+            , <&pro_micro_a 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+            , <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+            ;
+
+        col-gpios
+            = <&pro_micro_d 10 GPIO_ACTIVE_HIGH>
+            , <&pro_micro_d 16 GPIO_ACTIVE_HIGH>
+            , <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
+            , <&pro_micro_d 15 GPIO_ACTIVE_HIGH>
+            ;
+
+    };
+
+    bt_unpair_combo: bt_unpair_combo {
+		compatible = "zmk,bt-unpair-combo";
+		key-positions = <0 11>;
+	};
+};
\ No newline at end of file