From 598f3fa7a76412b45745962b79ec34c7b8fde70e Mon Sep 17 00:00:00 2001
From: Sergi Meseguer <zigotica@gmail.com>
Date: Tue, 12 Oct 2021 03:04:47 +0200
Subject: [PATCH] [Keyboard] z34 split keyboard by zigotica (#14582)

Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
---
 keyboards/z34/config.h                  | 65 +++++++++++++++++++++
 keyboards/z34/info.json                 | 52 +++++++++++++++++
 keyboards/z34/keymaps/default/config.h  | 22 +++++++
 keyboards/z34/keymaps/default/keymap.c  | 77 +++++++++++++++++++++++++
 keyboards/z34/keymaps/default/readme.md |  3 +
 keyboards/z34/keymaps/default/rules.mk  |  3 +
 keyboards/z34/readme.md                 |  3 +
 keyboards/z34/rules.mk                  | 28 +++++++++
 keyboards/z34/z34.c                     | 17 ++++++
 keyboards/z34/z34.h                     | 39 +++++++++++++
 10 files changed, 309 insertions(+)
 create mode 100644 keyboards/z34/config.h
 create mode 100644 keyboards/z34/info.json
 create mode 100644 keyboards/z34/keymaps/default/config.h
 create mode 100644 keyboards/z34/keymaps/default/keymap.c
 create mode 100644 keyboards/z34/keymaps/default/readme.md
 create mode 100644 keyboards/z34/keymaps/default/rules.mk
 create mode 100644 keyboards/z34/readme.md
 create mode 100644 keyboards/z34/rules.mk
 create mode 100644 keyboards/z34/z34.c
 create mode 100644 keyboards/z34/z34.h

diff --git a/keyboards/z34/config.h b/keyboards/z34/config.h
new file mode 100644
index 0000000000..71d6528ce8
--- /dev/null
+++ b/keyboards/z34/config.h
@@ -0,0 +1,65 @@
+/* Copyright 2020 Sergi Meseguer <zigotica@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/>.
+*/
+
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0x7A74
+#define PRODUCT_ID      0x0002
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    zigotica
+#define PRODUCT         z34
+
+/* key matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 5
+
+/*Keyboard Matrix Assignments */
+
+#define DIRECT_PINS { \
+    { C6, F7, F6, F5, F4 }, \
+    { D7, B6, B2, B3, B1 }, \
+    { E6, D4, D0, D1, D3 }, \
+    { B4, B5, NO_PIN, NO_PIN, NO_PIN } \
+}
+
+#define DIRECT_PINS_RIGHT { \
+    { F4, F5, F6, F7, C6 }, \
+    { B1, B3, B2, B6, D7 }, \
+    { D3, D1, D0, D4, E6 }, \
+    { B5, B4, NO_PIN, NO_PIN, NO_PIN } \
+}
+
+#define UNUSED_PINS
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCE 5
+
+/* 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
+
+/* Serial settings */
+#define USE_SERIAL
+/* serial.c configuration for split keyboard */
+#define SOFT_SERIAL_PIN D2
+
+// EE_HANDS MASTER_RIGHT MASTER_LEFT
+#define MASTER_RIGHT
+
diff --git a/keyboards/z34/info.json b/keyboards/z34/info.json
new file mode 100644
index 0000000000..4a6dce7525
--- /dev/null
+++ b/keyboards/z34/info.json
@@ -0,0 +1,52 @@
+{
+    "keyboard_name": "z34",
+    "url": "https://github.com/zigotica/mechanical-keyboards/tree/main/z34",
+    "maintainer": "@zigotica",
+    "layouts": {
+        "LAYOUT": {
+            "layout": [
+                {"x": 0, "y": 0.93},
+                {"x": 1, "y": 0.31},
+                {"x": 2, "y": 0},
+                {"x": 3, "y": 0.28},
+                {"x": 4, "y": 0.42},
+
+                {"x": 7, "y": 0.42},
+                {"x": 8, "y": 0.28},
+                {"x": 9, "y": 0},
+                {"x": 10, "y": 0.31},
+                {"x": 11, "y": 0.93},
+
+                {"x": 0, "y": 1.93},
+                {"x": 1, "y": 1.31},
+                {"x": 2, "y": 1},
+                {"x": 3, "y": 1.28},
+                {"x": 4, "y": 1.42},
+
+                {"x": 7, "y": 1.42},
+                {"x": 8, "y": 1.28},
+                {"x": 9, "y": 1},
+                {"x": 10, "y": 1.31},
+                {"x": 11, "y": 1.93},
+
+                {"x": 0, "y": 2.93},
+                {"x": 1, "y": 2.31},
+                {"x": 2, "y": 2},
+                {"x": 3, "y": 2.28},
+                {"x": 4, "y": 2.42},
+
+                {"x": 7, "y": 2.42},
+                {"x": 8, "y": 2.28},
+                {"x": 9, "y": 2},
+                {"x": 10, "y": 2.31},
+                {"x": 11, "y": 2.93},
+
+                {"x": 3.5, "y": 3.5},
+                {"x": 4.5, "y": 4},
+
+                {"x": 6.5, "y": 4},
+                {"x": 7.5, "y": 3.5}
+            ]
+        }
+    }
+}
diff --git a/keyboards/z34/keymaps/default/config.h b/keyboards/z34/keymaps/default/config.h
new file mode 100644
index 0000000000..ae9881d3ab
--- /dev/null
+++ b/keyboards/z34/keymaps/default/config.h
@@ -0,0 +1,22 @@
+/* Copyright 2020 Sergi Meseguer <zigotica@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/>.
+*/
+
+#pragma once
+
+#include "config_common.h"
+
+// EE_HANDS MASTER_RIGHT MASTER_LEFT
+#define MASTER_RIGHT
diff --git a/keyboards/z34/keymaps/default/keymap.c b/keyboards/z34/keymaps/default/keymap.c
new file mode 100644
index 0000000000..973d24eafb
--- /dev/null
+++ b/keyboards/z34/keymaps/default/keymap.c
@@ -0,0 +1,77 @@
+/* Copyright 2020 Sergi Meseguer <zigotica@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 QMK_KEYBOARD_H
+
+enum layers {
+    BASE = 0
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+/*
+ * Base Layer: BASE
+ *
+ *   ,---------------------------------------.                 ,---------------------------------------.
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |   Q   |   W   |   E   |   R   |   T   |                 |   Y   |   U   |   I   |   O   |   P   |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |-------+-------+-------+-------+-------|                 |-------+-------+-------+-------+-------|
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |   A   |   S   |   D   |   F   |   G   |                 |   H   |   J   |   K   |   L   |   '   |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |-------+-------+-------+-------+-------|                 |-------+-------+-------+-------+-------|
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |   Z   |   X   |   C   |   V   |   B   |                 |   N   |   M   |   ,   |   .   |   /   |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   `-------+-------+-------+-------+-------|                 |-------+-------+-------+-------+-------.
+ *                           |       |       |                 |       |       |
+ *                           |  ESC  |  SPC  |                 | ENTER |  BSPC |
+ *                           |       |       |                 |       |       |
+ *                           `---------------'                 `---------------'
+ *
+ */
+    [BASE] = LAYOUT(
+       KC_Q,   KC_W,   KC_E,   KC_R,   KC_T,                     KC_Y,   KC_U,   KC_I,   KC_O,   KC_P,
+       KC_A,   KC_S,   KC_D,   KC_F,   KC_G,                     KC_H,   KC_J,   KC_K,   KC_L,   KC_QUOT,
+       KC_Z,   KC_X,   KC_C,   KC_V,   KC_B,                     KC_N,   KC_M,   KC_COMM,KC_DOT, KC_SLSH,
+                               KC_ESC, KC_SPC,                   KC_ENT, KC_BSPC
+    ),
+
+/*
+ * TEMPLATE
+ *
+ *   ,---------------------------------------.                 ,---------------------------------------.
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |-------+-------+-------+-------+-------|                 |-------+-------+-------+-------+-------|
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |-------+-------+-------+-------+-------|                 |-------+-------+-------+-------+-------|
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   |       |       |       |       |       |                 |       |       |       |       |       |
+ *   `-------+-------+-------+-------+-------|                 |-------+-------+-------+-------+-------.
+ *                           |       |       |                 |       |       |
+ *                           |       |       |                 |       |       |
+ *                           |       |       |                 |       |       |
+ *                           `---------------'                 `---------------'
+ *
+ */
+
+};
+
diff --git a/keyboards/z34/keymaps/default/readme.md b/keyboards/z34/keymaps/default/readme.md
new file mode 100644
index 0000000000..c6a0115573
--- /dev/null
+++ b/keyboards/z34/keymaps/default/readme.md
@@ -0,0 +1,3 @@
+# Default z34 Layout
+
+This is the default QWERTY layout that comes flashed on every z34. 
diff --git a/keyboards/z34/keymaps/default/rules.mk b/keyboards/z34/keymaps/default/rules.mk
new file mode 100644
index 0000000000..9281e9843b
--- /dev/null
+++ b/keyboards/z34/keymaps/default/rules.mk
@@ -0,0 +1,3 @@
+# There are no extra pins, so we make sure to disable OLED and Encoders
+OLED_ENABLE = no   		  # Enables the use of OLED displays
+ENCODER_ENABLE = no       # Enables the use of encoders
diff --git a/keyboards/z34/readme.md b/keyboards/z34/readme.md
new file mode 100644
index 0000000000..29bbf571a3
--- /dev/null
+++ b/keyboards/z34/readme.md
@@ -0,0 +1,3 @@
+# z34
+
+Firmware for [z34 split keyboard](https://github.com/zigotica/mechanical-keyboards/tree/main/z34) designed by @zigotica
diff --git a/keyboards/z34/rules.mk b/keyboards/z34/rules.mk
new file mode 100644
index 0000000000..6370c7a93f
--- /dev/null
+++ b/keyboards/z34/rules.mk
@@ -0,0 +1,28 @@
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+BOOTLOADER = caterina
+
+# Build Options
+#   change yes to no to disable
+#
+BOOTMAGIC_ENABLE = no      # Enable Bootmagic Lite
+MOUSEKEY_ENABLE = no       # Mouse keys
+EXTRAKEY_ENABLE = yes      # Audio control and System control
+CONSOLE_ENABLE = no        # Console for debug
+COMMAND_ENABLE = no        # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no      # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = no           # USB Nkey Rollover
+BACKLIGHT_ENABLE = no      # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no       # Enable keyboard RGB underglow
+AUDIO_ENABLE = no          # Audio output
+SPLIT_KEYBOARD = yes       # Split common
+LTO_ENABLE = yes           # Enables Link Time Optimization (LTO) which reduces the compiled size
+
+# There are no extra pins, so we make sure to disable OLED and Encoders
+OLED_SUPPORTED = no        # Enables the use of OLED displays
+ENCODER_SUPPORTED = no      # Enables the use of encoders
+
diff --git a/keyboards/z34/z34.c b/keyboards/z34/z34.c
new file mode 100644
index 0000000000..779562e630
--- /dev/null
+++ b/keyboards/z34/z34.c
@@ -0,0 +1,17 @@
+/* Copyright 2020 Sergi Meseguer <zigotica@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 "z34.h"
diff --git a/keyboards/z34/z34.h b/keyboards/z34/z34.h
new file mode 100644
index 0000000000..3def2d4c2c
--- /dev/null
+++ b/keyboards/z34/z34.h
@@ -0,0 +1,39 @@
+/* Copyright 2020 Sergi Meseguer <zigotica@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 "quantum.h"
+
+/* This a shortcut to help you visually see your layout */
+
+#define ___ KC_NO
+
+#define LAYOUT( \
+        L05, L04, L03, L02, L01, R01, R02, R03, R04, R05, \
+        L10, L09, L08, L07, L06, R06, R07, R08, R09, R10, \
+        L15, L14, L13, L12, L11, R11, R12, R13, R14, R15, \
+                       L17, L16, R16, R17                 \
+    ) \
+    { \
+        { L05, L04, L03, L02, L01 }, \
+        { L10, L09, L08, L07, L06 }, \
+        { L15, L14, L13, L12, L11 }, \
+        { L17, L16, ___, ___ , ___}, \
+        { R01, R02, R03, R04, R05 }, \
+        { R06, R07, R08, R09, R10 }, \
+        { R11, R12, R13, R14, R15 }, \
+        { R16, R17, ___, ___, ___ }  \
+    }
+