From 2b3f6d0ec6bf504b0b5794bd4f1f3ed7e792a221 Mon Sep 17 00:00:00 2001
From: Peter Park <peterchpark@gmail.com>
Date: Sat, 1 Oct 2022 10:56:41 -0700
Subject: [PATCH] [Keyboard] Add Uni v4 keyboard (#18280)

Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Peter Park <peter@Peters-MacBook-Air.local>
---
 keyboards/the_uni/pro_micro/readme.md | 10 +++--
 keyboards/the_uni/readme.md           |  9 +++-
 keyboards/the_uni/rp_2040/config.h    | 61 +++++++++++++++++++++++++++
 keyboards/the_uni/rp_2040/info.json   |  5 +++
 keyboards/the_uni/rp_2040/readme.md   | 25 +++++++++++
 keyboards/the_uni/rp_2040/rp_2040.c   | 17 ++++++++
 keyboards/the_uni/rp_2040/rp_2040.h   | 30 +++++++++++++
 keyboards/the_uni/rp_2040/rules.mk    | 19 +++++++++
 keyboards/the_uni/usb_c/info.json     |  2 +-
 9 files changed, 171 insertions(+), 7 deletions(-)
 create mode 100644 keyboards/the_uni/rp_2040/config.h
 create mode 100644 keyboards/the_uni/rp_2040/info.json
 create mode 100644 keyboards/the_uni/rp_2040/readme.md
 create mode 100644 keyboards/the_uni/rp_2040/rp_2040.c
 create mode 100644 keyboards/the_uni/rp_2040/rp_2040.h
 create mode 100644 keyboards/the_uni/rp_2040/rules.mk

diff --git a/keyboards/the_uni/pro_micro/readme.md b/keyboards/the_uni/pro_micro/readme.md
index d6b6231561..397cf7a198 100644
--- a/keyboards/the_uni/pro_micro/readme.md
+++ b/keyboards/the_uni/pro_micro/readme.md
@@ -1,7 +1,9 @@
-# The Uni
+# The Uni v1 and v2
+
+![Uni v2](https://i.imgur.com/hIIK8xN.jpg)
 
 -   Keyboard Maintainer: [Peter](https://github.com/petercpark)
--   Link to Keyboard Files: [The_Uni](https://github.com/petercpark/The_Uni)
+-   Link to Keyboard Files: [The_Uni](https://github.com/petercpark/The_Uni) (For personal use only)
 -   Hardware Supported:
     -   The Uni v1 and v2 (pro_micro)
 -   Hardware Availability: [https://www.stenokeyboards.com](https://www.stenokeyboards.com)
@@ -10,8 +12,8 @@
 
 Enter the bootloader by:
 
-* **Physical reset button**: On the Uni v3, briefly press the button on the back of the PCB.
-* **Reset Pads**: Uni v1 and v2 have pins/pads you must short instead (RST to GND).
+-   **Physical reset button**: On the Uni v3, briefly press the button on the back of the PCB.
+-   **Reset Pads**: Uni v1 and v2 have pins/pads you must short instead (RST to GND).
 
 Make examples for this keyboard (after setting up your build environment):
 
diff --git a/keyboards/the_uni/readme.md b/keyboards/the_uni/readme.md
index cd1c99e435..88cb81b111 100644
--- a/keyboards/the_uni/readme.md
+++ b/keyboards/the_uni/readme.md
@@ -19,13 +19,18 @@ A compact unibody split ortholinear keyboard made specifically for stenography.
 
 Enter the bootloader by:
 
-* **Physical reset button**: On the Uni v3, briefly press the button on the back of the PCB.
-* **Reset Pads**: Uni v1 and v2 have pins/pads you must short instead (RST to GND).
+-   **Physical reset button**: On the Uni v3, briefly press the button on the back of the PCB.
+-   **Reset Pads**: Uni v1 and v2 have pins/pads you must short instead (RST to GND).
 
 Make examples for this keyboard (after setting up your build environment):
 
+    # version 1 and 2
     make the_uni/pro_micro:default
 
+    # version 3
     make the_uni/usb_c:default
 
+    # version 4
+    qmk compile -kb the_uni/rp_2040 -km default
+
 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).
diff --git a/keyboards/the_uni/rp_2040/config.h b/keyboards/the_uni/rp_2040/config.h
new file mode 100644
index 0000000000..a083ee20b7
--- /dev/null
+++ b/keyboards/the_uni/rp_2040/config.h
@@ -0,0 +1,61 @@
+/* Copyright 2019
+ *
+ * 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"
+/* key matrix size */
+#define MATRIX_ROWS 3
+#define MATRIX_COLS 11
+
+#define MATRIX_COL_PINS { GP24, GP23, GP21, GP20, GP19, GP6, GP5, GP4, GP3, GP2, GP1 }
+#define MATRIX_ROW_PINS { GP25, GP18, GP17 }
+// #define DEBUG_MATRIX_SCAN_RATE
+
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
+//#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP25
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U
+
+/* COL2ROW or ROW2COL */
+#define DIODE_DIRECTION COL2ROW
+
+/* number of backlight levels */
+
+// #ifdef BACKLIGHT_PIN
+// #define BACKLIGHT_LEVELS 3
+// #endif
+
+/* Set 0 if debouncing isn't 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
+
+
+// #ifdef RGB_DI_PIN
+// #define RGBLIGHT_ANIMATIONS
+// #define RGBLED_NUM 0
+// #define RGBLIGHT_HUE_STEP 8
+// #define RGBLIGHT_SAT_STEP 8
+// #define RGBLIGHT_VAL_STEP 8
+// #endif
+
+// #endif
+
+#define FORCE_NKRO
diff --git a/keyboards/the_uni/rp_2040/info.json b/keyboards/the_uni/rp_2040/info.json
new file mode 100644
index 0000000000..cebd90c01e
--- /dev/null
+++ b/keyboards/the_uni/rp_2040/info.json
@@ -0,0 +1,5 @@
+{
+    "usb": {
+        "device_version": "0.0.4"
+    }
+}
diff --git a/keyboards/the_uni/rp_2040/readme.md b/keyboards/the_uni/rp_2040/readme.md
new file mode 100644
index 0000000000..5867a213d9
--- /dev/null
+++ b/keyboards/the_uni/rp_2040/readme.md
@@ -0,0 +1,25 @@
+# Uni v4
+
+![Uni v4](https://i.imgur.com/HyvMu26h.png)
+
+-   Hardware Supported:
+    -   The Uni v4
+-   Hardware Availability: [https://www.stenokeyboards.com](https://www.stenokeyboards.com)
+-   Uses the rp2040 chip
+
+Make the .uf2 file by doing:
+
+# Bootloader
+
+Enter the bootloader by:
+
+-   **Physical boot button**:
+    -   First, unplug the Uni v4.
+    -   Then press and hold the button on the back of the PCB marked "B" while you plug in the keyboard. This will create register the keyboard as a storage device on the computer.
+    -   Copy and paste the .uf2 file in the top directory of the device. Once done, it will automatically reboot the keyboard.
+
+Make examples for this keyboard (after setting up your build environment):
+
+    qmk compile -kb the_uni/rp_2040 -km default
+
+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).
diff --git a/keyboards/the_uni/rp_2040/rp_2040.c b/keyboards/the_uni/rp_2040/rp_2040.c
new file mode 100644
index 0000000000..b032a22f42
--- /dev/null
+++ b/keyboards/the_uni/rp_2040/rp_2040.c
@@ -0,0 +1,17 @@
+/* Copyright 2021 Stefan Kerkmann
+ *
+ * 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 "rp_2040.h"
+
diff --git a/keyboards/the_uni/rp_2040/rp_2040.h b/keyboards/the_uni/rp_2040/rp_2040.h
new file mode 100644
index 0000000000..9371c3a241
--- /dev/null
+++ b/keyboards/the_uni/rp_2040/rp_2040.h
@@ -0,0 +1,30 @@
+/*
+Copyright 2021 Peter C. Park <peter@stenokeyboards.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 "quantum.h"
+
+#define LAYOUT( \
+	K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, \
+	K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, \
+	            K202, K203, K204, K205, K206, K207  \
+) { \
+	{ K000,  K001,  K002,  K003,  K004,  K005,  K006,  K007,  K008,  K009,  K010 }, \
+	{ K100,  K101,  K102,  K103,  K104,  K105,  K106,  K107,  K108,  K109,  K110 }, \
+	{ KC_NO, KC_NO, K202,  K203,  K204,  K205,  K206,  K207,  KC_NO, KC_NO, KC_NO }  \
+}
diff --git a/keyboards/the_uni/rp_2040/rules.mk b/keyboards/the_uni/rp_2040/rules.mk
new file mode 100644
index 0000000000..da6a3dc6a8
--- /dev/null
+++ b/keyboards/the_uni/rp_2040/rules.mk
@@ -0,0 +1,19 @@
+# MCU name
+MCU = RP2040
+
+# Bootloader selection
+BOOTLOADER = rp2040
+
+# Build Options
+#   change yes to no to disable
+#
+BOOTMAGIC_ENABLE = yes      # 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
+NKRO_ENABLE = yes           # Enable N-Key Rollover
+BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no        # Enable keyboard RGB underglow
+AUDIO_ENABLE = no           # Audio output
+STENO_ENABLE = yes
diff --git a/keyboards/the_uni/usb_c/info.json b/keyboards/the_uni/usb_c/info.json
index e557e4d307..b377cdff00 100644
--- a/keyboards/the_uni/usb_c/info.json
+++ b/keyboards/the_uni/usb_c/info.json
@@ -1,5 +1,5 @@
 {
     "usb": {
-        "device_version": "0.0.2"
+        "device_version": "0.0.3"
     }
 }