From ebac02a7b2c9221387364b3116bcf912c191e333 Mon Sep 17 00:00:00 2001
From: ai03 <admin@ai03.com>
Date: Thu, 9 Nov 2023 02:39:13 +0900
Subject: [PATCH] [Keyboard] Add Duet Switch Tester (#22367)

Co-authored-by: jack <0x6a73@protonmail.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
---
 keyboards/ai03/duet/config.h                  |   6 +
 keyboards/ai03/duet/info.json                 | 139 ++++++++++++++++++
 .../ai03/duet/keymaps/coordinate/keymap.c     |  34 +++++
 .../ai03/duet/keymaps/coordinate/readme.md    |   4 +
 keyboards/ai03/duet/keymaps/default/keymap.c  |  14 ++
 keyboards/ai03/duet/keymaps/default/readme.md |   4 +
 keyboards/ai03/duet/readme.md                 |  28 ++++
 keyboards/ai03/duet/rules.mk                  |   1 +
 8 files changed, 230 insertions(+)
 create mode 100644 keyboards/ai03/duet/config.h
 create mode 100644 keyboards/ai03/duet/info.json
 create mode 100644 keyboards/ai03/duet/keymaps/coordinate/keymap.c
 create mode 100644 keyboards/ai03/duet/keymaps/coordinate/readme.md
 create mode 100644 keyboards/ai03/duet/keymaps/default/keymap.c
 create mode 100644 keyboards/ai03/duet/keymaps/default/readme.md
 create mode 100644 keyboards/ai03/duet/readme.md
 create mode 100644 keyboards/ai03/duet/rules.mk

diff --git a/keyboards/ai03/duet/config.h b/keyboards/ai03/duet/config.h
new file mode 100644
index 0000000000..9cebd11c6b
--- /dev/null
+++ b/keyboards/ai03/duet/config.h
@@ -0,0 +1,6 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 128
diff --git a/keyboards/ai03/duet/info.json b/keyboards/ai03/duet/info.json
new file mode 100644
index 0000000000..1d11c868a3
--- /dev/null
+++ b/keyboards/ai03/duet/info.json
@@ -0,0 +1,139 @@
+{
+    "manufacturer": "ai03 Design Studio",
+    "keyboard_name": "Duet Switch Tester",
+    "maintainer": "ai03-2725",
+    "bootloader": "rp2040",
+    "diode_direction": "COL2ROW",
+    "features": {
+        "bootmagic": true,
+        "command": false,
+        "console": false,
+        "extrakey": true,
+        "mousekey": false,
+        "nkro": true
+    },
+    "matrix_pins": {
+        "cols": ["GP29", "GP28", "GP27", "GP26", "GP25", "GP24", "GP23", "GP22", "GP18", "GP14", "GP13", "GP12", "GP11", "GP10", "GP9", "GP8", "GP7", "GP6"],
+        "rows": ["GP0", "GP1", "GP2", "GP3", "GP4", "GP5"]
+    },
+    "processor": "RP2040",
+    "usb": {
+        "device_version": "1.0.0",
+        "pid": "0x0028",
+        "vid": "0xA103"
+    },
+    "layouts": {
+        "LAYOUT": {
+            "layout": [
+                {"matrix": [0, 0], "x": 0, "y": 0},
+                {"matrix": [0, 1], "x": 1, "y": 0},
+                {"matrix": [0, 2], "x": 2.25, "y": 0},
+                {"matrix": [0, 3], "x": 3.25, "y": 0},
+                {"matrix": [0, 4], "x": 4.5, "y": 0},
+                {"matrix": [0, 5], "x": 5.5, "y": 0},
+                {"matrix": [0, 6], "x": 6.75, "y": 0},
+                {"matrix": [0, 7], "x": 7.75, "y": 0},
+                {"matrix": [0, 8], "x": 9, "y": 0},
+                {"matrix": [0, 9], "x": 10, "y": 0},
+                {"matrix": [0, 10], "x": 11.25, "y": 0},
+                {"matrix": [0, 11], "x": 12.25, "y": 0},
+                {"matrix": [0, 12], "x": 13.5, "y": 0},
+                {"matrix": [0, 13], "x": 14.5, "y": 0},
+                {"matrix": [0, 14], "x": 15.75, "y": 0},
+                {"matrix": [0, 15], "x": 16.75, "y": 0},
+                {"matrix": [0, 16], "x": 18, "y": 0},
+                {"matrix": [0, 17], "x": 19, "y": 0},
+                {"matrix": [1, 0], "x": 0, "y": 1},
+                {"matrix": [1, 1], "x": 1, "y": 1},
+                {"matrix": [1, 2], "x": 2.25, "y": 1},
+                {"matrix": [1, 3], "x": 3.25, "y": 1},
+                {"matrix": [1, 4], "x": 4.5, "y": 1},
+                {"matrix": [1, 5], "x": 5.5, "y": 1},
+                {"matrix": [1, 6], "x": 6.75, "y": 1},
+                {"matrix": [1, 7], "x": 7.75, "y": 1},
+                {"matrix": [1, 8], "x": 9, "y": 1},
+                {"matrix": [1, 9], "x": 10, "y": 1},
+                {"matrix": [1, 10], "x": 11.25, "y": 1},
+                {"matrix": [1, 11], "x": 12.25, "y": 1},
+                {"matrix": [1, 12], "x": 13.5, "y": 1},
+                {"matrix": [1, 13], "x": 14.5, "y": 1},
+                {"matrix": [1, 14], "x": 15.75, "y": 1},
+                {"matrix": [1, 15], "x": 16.75, "y": 1},
+                {"matrix": [1, 16], "x": 18, "y": 1},
+                {"matrix": [1, 17], "x": 19, "y": 1},
+                {"matrix": [2, 0], "x": 0, "y": 2},
+                {"matrix": [2, 1], "x": 1, "y": 2},
+                {"matrix": [2, 2], "x": 2.25, "y": 2},
+                {"matrix": [2, 3], "x": 3.25, "y": 2},
+                {"matrix": [2, 4], "x": 4.5, "y": 2},
+                {"matrix": [2, 5], "x": 5.5, "y": 2},
+                {"matrix": [2, 6], "x": 6.75, "y": 2},
+                {"matrix": [2, 7], "x": 7.75, "y": 2},
+                {"matrix": [2, 8], "x": 9, "y": 2},
+                {"matrix": [2, 9], "x": 10, "y": 2},
+                {"matrix": [2, 10], "x": 11.25, "y": 2},
+                {"matrix": [2, 11], "x": 12.25, "y": 2},
+                {"matrix": [2, 12], "x": 13.5, "y": 2},
+                {"matrix": [2, 13], "x": 14.5, "y": 2},
+                {"matrix": [2, 14], "x": 15.75, "y": 2},
+                {"matrix": [2, 15], "x": 16.75, "y": 2},
+                {"matrix": [2, 16], "x": 18, "y": 2},
+                {"matrix": [2, 17], "x": 19, "y": 2},
+                {"matrix": [3, 0], "x": 0, "y": 3},
+                {"matrix": [3, 1], "x": 1, "y": 3},
+                {"matrix": [3, 2], "x": 2.25, "y": 3},
+                {"matrix": [3, 3], "x": 3.25, "y": 3},
+                {"matrix": [3, 4], "x": 4.5, "y": 3},
+                {"matrix": [3, 5], "x": 5.5, "y": 3},
+                {"matrix": [3, 6], "x": 6.75, "y": 3},
+                {"matrix": [3, 7], "x": 7.75, "y": 3},
+                {"matrix": [3, 8], "x": 9, "y": 3},
+                {"matrix": [3, 9], "x": 10, "y": 3},
+                {"matrix": [3, 10], "x": 11.25, "y": 3},
+                {"matrix": [3, 11], "x": 12.25, "y": 3},
+                {"matrix": [3, 12], "x": 13.5, "y": 3},
+                {"matrix": [3, 13], "x": 14.5, "y": 3},
+                {"matrix": [3, 14], "x": 15.75, "y": 3},
+                {"matrix": [3, 15], "x": 16.75, "y": 3},
+                {"matrix": [3, 16], "x": 18, "y": 3},
+                {"matrix": [3, 17], "x": 19, "y": 3},
+                {"matrix": [4, 0], "x": 0, "y": 4},
+                {"matrix": [4, 1], "x": 1, "y": 4},
+                {"matrix": [4, 2], "x": 2.25, "y": 4},
+                {"matrix": [4, 3], "x": 3.25, "y": 4},
+                {"matrix": [4, 4], "x": 4.5, "y": 4},
+                {"matrix": [4, 5], "x": 5.5, "y": 4},
+                {"matrix": [4, 6], "x": 6.75, "y": 4},
+                {"matrix": [4, 7], "x": 7.75, "y": 4},
+                {"matrix": [4, 8], "x": 9, "y": 4},
+                {"matrix": [4, 9], "x": 10, "y": 4},
+                {"matrix": [4, 10], "x": 11.25, "y": 4},
+                {"matrix": [4, 11], "x": 12.25, "y": 4},
+                {"matrix": [4, 12], "x": 13.5, "y": 4},
+                {"matrix": [4, 13], "x": 14.5, "y": 4},
+                {"matrix": [4, 14], "x": 15.75, "y": 4},
+                {"matrix": [4, 15], "x": 16.75, "y": 4},
+                {"matrix": [4, 16], "x": 18, "y": 4},
+                {"matrix": [4, 17], "x": 19, "y": 4},
+                {"matrix": [5, 0], "x": 0, "y": 5},
+                {"matrix": [5, 1], "x": 1, "y": 5},
+                {"matrix": [5, 2], "x": 2.25, "y": 5},
+                {"matrix": [5, 3], "x": 3.25, "y": 5},
+                {"matrix": [5, 4], "x": 4.5, "y": 5},
+                {"matrix": [5, 5], "x": 5.5, "y": 5},
+                {"matrix": [5, 6], "x": 6.75, "y": 5},
+                {"matrix": [5, 7], "x": 7.75, "y": 5},
+                {"matrix": [5, 8], "x": 9, "y": 5},
+                {"matrix": [5, 9], "x": 10, "y": 5},
+                {"matrix": [5, 10], "x": 11.25, "y": 5},
+                {"matrix": [5, 11], "x": 12.25, "y": 5},
+                {"matrix": [5, 12], "x": 13.5, "y": 5},
+                {"matrix": [5, 13], "x": 14.5, "y": 5},
+                {"matrix": [5, 14], "x": 15.75, "y": 5},
+                {"matrix": [5, 15], "x": 16.75, "y": 5},
+                {"matrix": [5, 16], "x": 18, "y": 5},
+                {"matrix": [5, 17], "x": 19, "y": 5}
+            ]
+        }
+    }
+}
diff --git a/keyboards/ai03/duet/keymaps/coordinate/keymap.c b/keyboards/ai03/duet/keymaps/coordinate/keymap.c
new file mode 100644
index 0000000000..821c029534
--- /dev/null
+++ b/keyboards/ai03/duet/keymaps/coordinate/keymap.c
@@ -0,0 +1,34 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include QMK_KEYBOARD_H
+
+
+/* Coordinate keymap - designed to send a string in the format [a-r][0-5] corresponding to the matrix position, where a0 is the top left and r5 is bottom right */
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+	[0] = LAYOUT(
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0
+    ),
+};
+
+
+/* String generation */
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+
+    if (record->event.pressed) {
+        char col = record->event.key.col + 'a';
+        char row = record->event.key.row + '0';
+        char result[2] = {col, row};
+        send_string(result);
+    }
+
+    return false;
+}
diff --git a/keyboards/ai03/duet/keymaps/coordinate/readme.md b/keyboards/ai03/duet/keymaps/coordinate/readme.md
new file mode 100644
index 0000000000..de8245875d
--- /dev/null
+++ b/keyboards/ai03/duet/keymaps/coordinate/readme.md
@@ -0,0 +1,4 @@
+# The coordinate keymap for Duet
+
+An example keymap which sends a string `[a-r][0-5]` corresponding to the column-row position of the pressed switch.  
+Possibly useful for pairing to a kiosk device provided the display application can parse and handle this format.  
diff --git a/keyboards/ai03/duet/keymaps/default/keymap.c b/keyboards/ai03/duet/keymaps/default/keymap.c
new file mode 100644
index 0000000000..29f63678a8
--- /dev/null
+++ b/keyboards/ai03/duet/keymaps/default/keymap.c
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+	[0] = LAYOUT(
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,
+        KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0,    KC_0
+    ),
+};
diff --git a/keyboards/ai03/duet/keymaps/default/readme.md b/keyboards/ai03/duet/keymaps/default/readme.md
new file mode 100644
index 0000000000..fdf727dc96
--- /dev/null
+++ b/keyboards/ai03/duet/keymaps/default/readme.md
@@ -0,0 +1,4 @@
+# The default keymap for Duet
+
+Since this is a very irregular keyboard with unique use cases, the keymap should be customized to meet one's needs and to match the requirements of the corresponding display software (if any).  
+By default, all keys send `KC_0` to simply notify the host that an arbitrary key has been pressed.  
diff --git a/keyboards/ai03/duet/readme.md b/keyboards/ai03/duet/readme.md
new file mode 100644
index 0000000000..43c3d6f7c5
--- /dev/null
+++ b/keyboards/ai03/duet/readme.md
@@ -0,0 +1,28 @@
+# Duet Switch Tester
+
+![Cover image](https://i.imgur.com/sFuHJbLh.png)
+
+A switch tester intended for event/storefront use
+
+* Keyboard Maintainer: [ai03](https://github.com/ai03-2725)
+* Hardware Supported: The [Duet PCB](https://github.com/ai03-2725/duet-switch-tester/tree/main/Duet-MainPCB), powered by the RP2040
+* Hardware Availability: [Open-source](https://github.com/ai03-2725/duet-switch-tester)
+
+
+Make example for this keyboard (after setting up your build environment):
+
+    make ai03/duet:default
+
+Flashing example for this keyboard:
+
+    make ai03/duet: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 3 ways:
+
+* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
+* **Physical reset button**: Press the reset button on the back of the PCB while holding the Bootmode switch
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available
diff --git a/keyboards/ai03/duet/rules.mk b/keyboards/ai03/duet/rules.mk
new file mode 100644
index 0000000000..6e7633bfe0
--- /dev/null
+++ b/keyboards/ai03/duet/rules.mk
@@ -0,0 +1 @@
+# This file intentionally left blank