From e44cbf75562243f68be2a0e5da02bd032df98b3b Mon Sep 17 00:00:00 2001
From: Kyrre Havik <Kyrremann@gmail.com>
Date: Fri, 29 Mar 2024 04:22:41 +0100
Subject: [Keyboard] Bartlesplit (#23114)

Co-authored-by: jack <0x6a73@protonmail.com>
Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
---
 keyboards/minimon/bartlesplit/config.h             |  20 +++
 keyboards/minimon/bartlesplit/info.json            | 114 ++++++++++++++++
 .../bartlesplit/keymaps/default/keymap.json        |  33 +++++
 keyboards/minimon/bartlesplit/matrix.c             | 148 +++++++++++++++++++++
 keyboards/minimon/bartlesplit/readme.md            |  31 +++++
 keyboards/minimon/bartlesplit/rules.mk             |   2 +
 keyboards/minimon/readme.md                        |   1 +
 7 files changed, 349 insertions(+)
 create mode 100644 keyboards/minimon/bartlesplit/config.h
 create mode 100644 keyboards/minimon/bartlesplit/info.json
 create mode 100644 keyboards/minimon/bartlesplit/keymaps/default/keymap.json
 create mode 100644 keyboards/minimon/bartlesplit/matrix.c
 create mode 100644 keyboards/minimon/bartlesplit/readme.md
 create mode 100644 keyboards/minimon/bartlesplit/rules.mk

(limited to 'keyboards')

diff --git a/keyboards/minimon/bartlesplit/config.h b/keyboards/minimon/bartlesplit/config.h
new file mode 100644
index 0000000000..e4ca83f5e9
--- /dev/null
+++ b/keyboards/minimon/bartlesplit/config.h
@@ -0,0 +1,20 @@
+/*
+Copyright 2019-2023 e3w2q Kyrremann
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#define DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD
diff --git a/keyboards/minimon/bartlesplit/info.json b/keyboards/minimon/bartlesplit/info.json
new file mode 100644
index 0000000000..83f93560b6
--- /dev/null
+++ b/keyboards/minimon/bartlesplit/info.json
@@ -0,0 +1,114 @@
+{
+    "keyboard_name": "Bartlesplit",
+    "development_board": "promicro",
+    "diode_direction": "ROW2COL",
+    "features": {
+        "bootmagic": true,
+        "command": false,
+        "console": false,
+        "extrakey": true,
+        "mousekey": true,
+        "nkro": false,
+        "caps_word": true
+    },
+    "matrix_pins": {
+        "cols": ["B3", "B3", "B1", "B1", "F7", "F7", "E6", "E6", "D7", "D7", "C6", "C6"],
+        "rows": ["B5", "B4", "B2", "B6"]
+    },
+    "pin_compatible": "promicro",
+    "url": "https://github.com/Kyrremann/bartlesplit",
+    "usb": {
+        "device_version": "1.0.0",
+        "pid": "0x1306",
+        "vid": "0x4B49"
+    },
+    "community_layouts": ["split_3x6_3", "split_3x5_3"],
+    "layouts": {
+        "LAYOUT_split_3x5_3": {
+            "layout": [
+                {"matrix": [0, 4], "x": 0, "y": 0.5},
+                {"matrix": [0, 3], "x": 1, "y": 0.25},
+                {"matrix": [0, 2], "x": 2, "y": 0},
+                {"matrix": [0, 1], "x": 3, "y": 0.25},
+                {"matrix": [0, 0], "x": 4, "y": 0.25},
+                {"matrix": [0, 6], "x": 6.5, "y": 0.25},
+                {"matrix": [0, 7], "x": 7.5, "y": 0.25},
+                {"matrix": [0, 8], "x": 8.5, "y": 0},
+                {"matrix": [0, 9], "x": 9.5, "y": 0.25},
+                {"matrix": [0, 10], "x": 10.5, "y": 0.5},
+                {"matrix": [1, 4], "x": 0, "y": 1.5},
+                {"matrix": [1, 3], "x": 1, "y": 1.25},
+                {"matrix": [1, 2], "x": 2, "y": 1},
+                {"matrix": [1, 1], "x": 3, "y": 1.25},
+                {"matrix": [1, 0], "x": 4, "y": 1.25},
+                {"matrix": [1, 6], "x": 6.5, "y": 1.25},
+                {"matrix": [1, 7], "x": 7.5, "y": 1.25},
+                {"matrix": [1, 8], "x": 8.5, "y": 1},
+                {"matrix": [1, 9], "x": 9.5, "y": 1.25},
+                {"matrix": [1, 10], "x": 10.5, "y": 1.5},
+                {"matrix": [2, 4], "x": 0, "y": 2.5},
+                {"matrix": [2, 3], "x": 1, "y": 2.25},
+                {"matrix": [2, 2], "x": 2, "y": 2},
+                {"matrix": [2, 1], "x": 3, "y": 2.25},
+                {"matrix": [2, 0], "x": 4, "y": 2.25},
+                {"matrix": [2, 6], "x": 6.5, "y": 2.25},
+                {"matrix": [2, 7], "x": 7.5, "y": 2.25},
+                {"matrix": [2, 8], "x": 8.5, "y": 2},
+                {"matrix": [2, 9], "x": 9.5, "y": 2.25},
+                {"matrix": [2, 10], "x": 10.5, "y": 2.5},
+                {"matrix": [3, 1], "x": 2.5, "y": 3.25},
+                {"matrix": [3, 0], "x": 3.5, "y": 3.25},
+                {"matrix": [3, 3], "x": 4.5, "y": 3.5},
+                {"matrix": [3, 6], "x": 6, "y": 3.5},
+                {"matrix": [3, 7], "x": 7, "y": 3.25},
+                {"matrix": [3, 8], "x": 8, "y": 3.25}
+            ]
+        },
+        "LAYOUT_split_3x6_3": {
+            "layout": [
+                {"matrix": [0, 5], "x": 0, "y": 0.25},
+                {"matrix": [0, 4], "x": 1, "y": 0.125},
+                {"matrix": [0, 3], "x": 2, "y": 0},
+                {"matrix": [0, 2], "x": 3, "y": 0.125},
+                {"matrix": [0, 1], "x": 4, "y": 0.25},
+                {"matrix": [0, 0], "x": 5, "y": 0.25},
+                {"matrix": [0, 6], "x": 7, "y": 0.25},
+                {"matrix": [0, 7], "x": 8, "y": 0.125},
+                {"matrix": [0, 8], "x": 9, "y": 0},
+                {"matrix": [0, 9], "x": 10, "y": 0.125},
+                {"matrix": [0, 10], "x": 11, "y": 0.25},
+                {"matrix": [0, 11], "x": 12, "y": 0.25},
+                {"matrix": [1, 5], "x": 0, "y": 1.25},
+                {"matrix": [1, 4], "x": 1, "y": 1.125},
+                {"matrix": [1, 3], "x": 2, "y": 1},
+                {"matrix": [1, 2], "x": 3, "y": 1.125},
+                {"matrix": [1, 1], "x": 4, "y": 1.25},
+                {"matrix": [1, 0], "x": 5, "y": 1.25},
+                {"matrix": [1, 6], "x": 7, "y": 1.25},
+                {"matrix": [1, 7], "x": 8, "y": 1.125},
+                {"matrix": [1, 8], "x": 9, "y": 1},
+                {"matrix": [1, 9], "x": 10, "y": 1.125},
+                {"matrix": [1, 10], "x": 11, "y": 1.25},
+                {"matrix": [1, 11], "x": 12, "y": 1.25},
+                {"matrix": [2, 5], "x": 0, "y": 2.25},
+                {"matrix": [2, 4], "x": 1, "y": 2.125},
+                {"matrix": [2, 3], "x": 2, "y": 2},
+                {"matrix": [2, 2], "x": 3, "y": 2.125},
+                {"matrix": [2, 1], "x": 4, "y": 2.25},
+                {"matrix": [2, 0], "x": 5, "y": 2.25},
+                {"matrix": [2, 6], "x": 7, "y": 2.25},
+                {"matrix": [2, 7], "x": 8, "y": 2.125},
+                {"matrix": [2, 8], "x": 9, "y": 2},
+                {"matrix": [2, 9], "x": 10, "y": 2.125},
+                {"matrix": [2, 10], "x": 11, "y": 2.25},
+                {"matrix": [2, 11], "x": 12, "y": 2.25},
+                {"matrix": [3, 1], "x": 3.5, "y": 3.25},
+                {"matrix": [3, 0], "x": 4.5, "y": 3.5},
+                {"matrix": [3, 3], "x": 5.5, "y": 3.75},
+                {"matrix": [3, 6], "x": 6.5, "y": 3.75},
+                {"matrix": [3, 7], "x": 7.5, "y": 3.5},
+                {"matrix": [3, 8], "x": 8.5, "y": 3.25}
+            ]
+        }
+    }
+}
diff --git a/keyboards/minimon/bartlesplit/keymaps/default/keymap.json b/keyboards/minimon/bartlesplit/keymaps/default/keymap.json
new file mode 100644
index 0000000000..03a5762839
--- /dev/null
+++ b/keyboards/minimon/bartlesplit/keymaps/default/keymap.json
@@ -0,0 +1,33 @@
+{
+  "version": 1,
+  "notes": "Bartlesplit default keymap",
+  "keyboard": "minimon/bartlesplit",
+  "keymap": "default",
+  "layout": "LAYOUT_split_3x6_3",
+  "layers": [
+    [
+      "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_LCTL",        "KC_A", "KC_S",      "KC_D",      "KC_F",      "KC_G",      "KC_H",      "KC_J",      "KC_K",      "KC_L",      "KC_SCLN",      "KC_QUOT",
+      "LSFT_T(KC_ESC)", "KC_Z",         "KC_X",      "KC_C",      "KC_V",      "KC_B",      "KC_N",      "KC_M",      "KC_COMM",      "KC_DOT",      "KC_SLSH",      "RSFT_T(KC_ESC)",
+      "KC_LALT",      "KC_LGUI",      "LT(2,KC_SPC)",      "KC_ENT",      "MO(1)",      "KC_BSPC"
+    ],
+    [
+        "KC_NUBS", "KC_1",    "KC_2",    "KC_3",      "KC_4",       "KC_5",    "KC_6",    "KC_7",    "KC_8",    "KC_9",    "KC_0",    "KC_MINS",
+        "KC_TRNS", "LSFT(KC_1)", "LSFT(KC_2)", "LSFT(KC_3)",   "LSFT(KC_4)",    "LSFT(KC_5)", "LSFT(KC_6)", "LSFT(KC_7)", "LSFT(KC_8)", "LSFT(KC_9)", "LSFT(KC_0)", "LSFT(KC_MINS)",
+        "KC_TRNS", "KC_GRV",  "KC_TRNS", "LSFT(KC_EQL)", "LSFT(KC_RBRC)", "LSFT(KC_BSLS)", "KC_BSLS", "KC_RBRC", "KC_EQL", "KC_TRNS", "KC_TRNS", "KC_TRNS",
+                                         "KC_RALT",   "KC_TRNS",    "KC_ESC", "KC_TRNS", "KC_TRNS", "KC_DEL"
+    ],
+    [
+        "KC_ESC", "KC_NO", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_NO", "KC_NO", "KC_UP", "KC_NO", "KC_KB_VOLUME_UP", "KC_MEDIA_PLAY_PAUSE",
+        "KC_TRNS", "KC_NO", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "KC_NO", "KC_LEFT", "KC_DOWN", "KC_RGHT", "KC_KB_VOLUME_DOWN", "KC_NO",
+        "KC_TRNS", "KC_NO", "KC_F9", "KC_F10", "KC_F11", "KC_F12", "KC_LCBR", "RALT(KC_8)", "RALT(KC_9)", "KC_RCBR", "KC_NO", "KC_TRNS",
+                                            "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "MO(3)", "KC_TRNS"
+    ],
+    [
+      "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_LCTL",        "LGUI_T(KC_A)", "LALT_T(KC_S)",      "LCTL_T(KC_D)",      "LSFT_T(KC_F)",      "KC_G",      "KC_H",      "RSFT_T(KC_J)",      "LCTL_T(KC_K)",      "LALT_T(KC_L)",      "LGUI_T(KC_SCLN)",      "KC_QUOT",
+      "LSFT_T(KC_ESC)", "KC_Z",         "KC_X",      "KC_C",      "KC_V",      "KC_B",      "KC_N",      "KC_M",      "KC_COMM",      "KC_DOT",      "KC_SLSH",      "RSFT_T(KC_ESC)",
+      "KC_LALT",      "KC_LGUI",      "LT(2,KC_SPC)",      "KC_ENT",      "MO(1)",      "KC_BSPC"
+    ]
+  ]
+}
diff --git a/keyboards/minimon/bartlesplit/matrix.c b/keyboards/minimon/bartlesplit/matrix.c
new file mode 100644
index 0000000000..351781f520
--- /dev/null
+++ b/keyboards/minimon/bartlesplit/matrix.c
@@ -0,0 +1,148 @@
+/*
+Copyright 2012-2023 Jun Wako <wakojun@gmail.com> Kyrremann <kyrremann@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/>.
+
+ Copied from here: https://github.com/e3w2q/qmk_firmware/blob/762fe3e0a7cbea768245a75520f06ff5a2f00b9f/keyboards/2x3test/matrix.c
+*/
+
+/*
+ * scan matrix
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include "wait.h"
+#include "util.h"
+#include "matrix.h"
+#include "quantum.h"
+
+#define ROW_SHIFTER ((uint16_t)1)
+
+static const pin_t row_pins[] = MATRIX_ROW_PINS;
+static const pin_t col_pins[] = MATRIX_COL_PINS;
+
+static void select_row(uint8_t row) {
+    setPinOutput(row_pins[row]);
+    writePinLow(row_pins[row]);
+}
+
+static void unselect_row(uint8_t row) {
+    setPinInputHigh(row_pins[row]);
+}
+
+static void unselect_rows(void) {
+    for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
+        setPinInputHigh(row_pins[x]);
+    }
+}
+
+static void select_col(uint8_t col) {
+    setPinOutput(col_pins[col]);
+    writePinLow(col_pins[col]);
+}
+
+static void unselect_col(uint8_t col) {
+    setPinInputHigh(col_pins[col]);
+}
+
+static void unselect_cols(void) {
+    for (uint8_t x = 0; x < MATRIX_COLS/2; x++) {
+        setPinInputHigh(col_pins[x*2]);
+    }
+}
+
+static void init_pins(void) {
+    unselect_cols();
+    unselect_rows();
+}
+
+static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
+    // Store last value of row prior to reading
+    matrix_row_t last_row_value = current_matrix[current_row];
+
+    // Select row and wait for row selection to stabilize
+    select_row(current_row);
+    wait_us(30);
+
+    // For each col...
+    for (uint8_t col_index = 0; col_index < MATRIX_COLS / 2; col_index++) {
+        uint16_t column_index_bitmask = ROW_SHIFTER << ((col_index * 2) + 1);
+        // Check row pin state
+        if (readPin(col_pins[col_index*2])) {
+            // Pin HI, clear col bit
+            current_matrix[current_row] &= ~column_index_bitmask;
+        } else {
+            // Pin LO, set col bit
+            current_matrix[current_row] |= column_index_bitmask;
+        }
+    }
+
+    // Unselect row
+    unselect_row(current_row);
+
+    return (last_row_value != current_matrix[current_row]);
+}
+
+static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
+    bool matrix_changed = false;
+
+    // Select col and wait for col selection to stabilize
+    select_col(current_col*2);
+    wait_us(30);
+
+    // For each row...
+    for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
+        // Store last value of row prior to reading
+        matrix_row_t last_row_value = current_matrix[row_index];
+
+        uint16_t column_index_bitmask = ROW_SHIFTER << (current_col * 2);
+        // Check row pin state
+        if (readPin(row_pins[row_index])) {
+            // Pin HI, clear col bit
+            current_matrix[row_index] &= ~column_index_bitmask;
+        } else {
+            // Pin LO, set col bit
+            current_matrix[row_index] |= column_index_bitmask;
+        }
+
+        // Determine if the matrix changed state
+        if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
+                   matrix_changed = true;
+        }
+    }
+
+    // Unselect col
+    unselect_col(current_col*2);
+
+    return matrix_changed;
+}
+
+
+void matrix_init_custom(void) {
+    // initialize key pins
+    init_pins();
+}
+
+bool matrix_scan_custom(matrix_row_t current_matrix[]) {
+
+    bool changed = false;
+
+    // Set row, read cols
+    for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
+        changed |= read_cols_on_row(current_matrix, current_row);
+    }
+    // Set col, read rows
+    for (uint8_t current_col = 0; current_col < MATRIX_COLS/2; current_col++) {
+        changed |= read_rows_on_col(current_matrix, current_col);
+    }
+
+    return changed;
+}
diff --git a/keyboards/minimon/bartlesplit/readme.md b/keyboards/minimon/bartlesplit/readme.md
new file mode 100644
index 0000000000..c7109ddf47
--- /dev/null
+++ b/keyboards/minimon/bartlesplit/readme.md
@@ -0,0 +1,31 @@
+# Bartlesplitt
+
+![Bartlesplit with the hub in the 3x6 setup](https://i.imgur.com/IoMpwylh.png)
+
+Bartlesplit is based on [Cheapino](https://github.com/tompi/cheapino) by Tompi.
+The original idea was to build a Cheapino with hot swaps, but it evolved into something more!
+
+At the same time I was working on Bartlesplit, a friend of mine suggested that we try to make a splithub, letting us avoid having the Pro Micro directly on the board.
+This is mostly a design choice, making each split less clutered.
+We have called the hub [The Japanese Connection](https://github.com/Kyrremann/the-japanese-connection) since it's relying on the Japanese duplex matrix.
+
+One of the main feature of the board is the built-in tenting, so you don't need to make a case to get simple tenting.
+
+
+* Keyboard Maintainer: [Kyrre Havik](https://github.com/Kyrremann)
+* Hardware Supported: Rev 1, Pro Micro
+* Hardware Availability: https://github.com/Kyrremann/bartlesplit
+
+Make example for this keyboard (after setting up your build environment):
+
+    make minimon/bartlesplit:default
+
+Flashing example for this keyboard:
+
+    make minimon/bartlesplit:default:flash
+
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
+
+## Bootloader
+
+Enter the bootloader in shorting the reset pin on Pro Micro on the hub.
diff --git a/keyboards/minimon/bartlesplit/rules.mk b/keyboards/minimon/bartlesplit/rules.mk
new file mode 100644
index 0000000000..30ce5d293b
--- /dev/null
+++ b/keyboards/minimon/bartlesplit/rules.mk
@@ -0,0 +1,2 @@
+CUSTOM_MATRIX = lite
+SRC += matrix.c
diff --git a/keyboards/minimon/readme.md b/keyboards/minimon/readme.md
index cd020a1110..807e4a7c52 100644
--- a/keyboards/minimon/readme.md
+++ b/keyboards/minimon/readme.md
@@ -7,3 +7,4 @@ Maintained by [Kyrremann](https://github.com/Kyrremann).
 ## Keyboards
 
 * [Index Tab](index_tab/) - 13x6 ortho keyboard
+* [Bartlesplit](bartlesplit/) - 42 (36) split board with Pro Micro hub
-- 
cgit v1.2.3