From 4098ff5574ab8129b83239ed9de6f1820b31b686 Mon Sep 17 00:00:00 2001
From: era <73109780+eerraa@users.noreply.github.com>
Date: Tue, 17 Jan 2023 10:55:13 +0900
Subject: [PATCH] [Keyboard] Add ERA65 (#19591)

Co-authored-by: Ryan <fauxpark@gmail.com>
---
 keyboards/era/era65/config.h                 |  30 +++++
 keyboards/era/era65/halconf.h                |   8 ++
 keyboards/era/era65/info.json                | 113 +++++++++++++++++++
 keyboards/era/era65/keymaps/default/keymap.c |  37 ++++++
 keyboards/era/era65/keymaps/via/keymap.c     |  68 +++++++++++
 keyboards/era/era65/keymaps/via/rules.mk     |   1 +
 keyboards/era/era65/mcuconf.h                |   8 ++
 keyboards/era/era65/readme.md                |  25 ++++
 keyboards/era/era65/rules.mk                 |   2 +
 9 files changed, 292 insertions(+)
 create mode 100644 keyboards/era/era65/config.h
 create mode 100644 keyboards/era/era65/halconf.h
 create mode 100644 keyboards/era/era65/info.json
 create mode 100644 keyboards/era/era65/keymaps/default/keymap.c
 create mode 100644 keyboards/era/era65/keymaps/via/keymap.c
 create mode 100644 keyboards/era/era65/keymaps/via/rules.mk
 create mode 100644 keyboards/era/era65/mcuconf.h
 create mode 100644 keyboards/era/era65/readme.md
 create mode 100644 keyboards/era/era65/rules.mk

diff --git a/keyboards/era/era65/config.h b/keyboards/era/era65/config.h
new file mode 100644
index 0000000000..41dbe2178a
--- /dev/null
+++ b/keyboards/era/era65/config.h
@@ -0,0 +1,30 @@
+// Copyright 2023 eerraa (@era)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+/*
+ * Feature disable options
+ *  These options are also useful to firmware size reduction.
+ */
+
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
+
+#define DYNAMIC_KEYMAP_LAYER_COUNT 6
+
+#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
+
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET // Activates the double-tap behavior
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 1000U // Timeout window in ms in which the double tap can occur.
+
+#define BACKLIGHT_PWM_DRIVER PWMD0
+#define BACKLIGHT_PWM_CHANNEL RP2040_PWM_CHANNEL_A
\ No newline at end of file
diff --git a/keyboards/era/era65/halconf.h b/keyboards/era/era65/halconf.h
new file mode 100644
index 0000000000..1960fffb5d
--- /dev/null
+++ b/keyboards/era/era65/halconf.h
@@ -0,0 +1,8 @@
+// Copyright 2022 MatteoDM <matteodalmo@gmail.com>
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#define HAL_USE_PWM TRUE
+
+
+#include_next <halconf.h>
\ No newline at end of file
diff --git a/keyboards/era/era65/info.json b/keyboards/era/era65/info.json
new file mode 100644
index 0000000000..38199a2001
--- /dev/null
+++ b/keyboards/era/era65/info.json
@@ -0,0 +1,113 @@
+{
+    "manufacturer": "ERA",
+    "keyboard_name": "ERA65 1.0.4",
+    "maintainer": "eerraa",
+    "bootloader": "rp2040",
+    "diode_direction": "COL2ROW",
+    "features": {
+        "bootmagic": true,
+        "command": false,
+        "console": false,
+        "extrakey": true,
+        "mousekey": true,
+        "nkro": true,
+		"backlight": true
+		
+    },
+    "matrix_pins": {
+        "cols": ["GP29", "GP28", "GP27", "GP26", "GP25", "GP24", "GP21", "GP20", "GP19", "GP18", "GP17", "GP16", "GP22", "GP23", "GP3"],
+        "rows": ["GP1", "GP2", "GP4", "GP10", "GP11"]
+    },
+    "processor": "RP2040",
+    "url": "",
+    "usb": {
+        "device_version": "1.0.4",
+        "pid": "0x0001",
+        "vid": "0x4552"
+    },
+    "backlight": {
+        "breathing": true,
+        "breathing_period": 6,
+        "levels": 15,
+        "pin": "GP0"
+    },
+    "indicators": {
+        "caps_lock": "GP12",
+    },
+    "layouts": {
+        "LAYOUT_65_combo": {
+            "layout": [
+                { "matrix": [0, 0], "x": 0, "y": 0 },
+                { "matrix": [0, 1], "x": 1, "y": 0 },
+                { "matrix": [0, 2], "x": 2, "y": 0 },
+                { "matrix": [0, 3], "x": 3, "y": 0 },
+                { "matrix": [0, 4], "x": 4, "y": 0 },
+                { "matrix": [0, 5], "x": 5, "y": 0 },
+                { "matrix": [0, 6], "x": 6, "y": 0 },
+                { "matrix": [0, 7], "x": 7, "y": 0 },
+                { "matrix": [0, 8], "x": 8, "y": 0 },
+                { "matrix": [0, 9], "x": 9, "y": 0 },
+                { "matrix": [0, 10], "x": 10, "y": 0 },
+                { "matrix": [0, 11], "x": 11, "y": 0 },
+                { "matrix": [0, 12], "x": 12, "y": 0 },
+                { "matrix": [0, 13], "w": 2, "x": 13, "y": 0 },
+                { "matrix": [0, 14], "x": 15.5, "y": 0 },
+                { "matrix": [1, 0], "w": 1.5, "x": 0, "y": 1 },
+                { "matrix": [1, 1], "x": 1.5, "y": 1 },
+                { "matrix": [1, 2], "x": 2.5, "y": 1 },
+                { "matrix": [1, 3], "x": 3.5, "y": 1 },
+                { "matrix": [1, 4], "x": 4.5, "y": 1 },
+                { "matrix": [1, 5], "x": 5.5, "y": 1 },
+                { "matrix": [1, 6], "x": 6.5, "y": 1 },
+                { "matrix": [1, 7], "x": 7.5, "y": 1 },
+                { "matrix": [1, 8], "x": 8.5, "y": 1 },
+                { "matrix": [1, 9], "x": 9.5, "y": 1 },
+                { "matrix": [1, 10], "x": 10.5, "y": 1 },
+                { "matrix": [1, 11], "x": 11.5, "y": 1 },
+                { "matrix": [1, 12], "x": 12.5, "y": 1 },
+                { "matrix": [1, 13], "w": 1.5, "x": 13.5, "y": 1 },
+                { "matrix": [1, 14], "x": 15.5, "y": 1 },
+                { "matrix": [2, 0], "w": 1.75, "x": 0, "y": 2 },
+                { "matrix": [2, 1], "x": 1.75, "y": 2 },
+                { "matrix": [2, 2], "x": 2.75, "y": 2 },
+                { "matrix": [2, 3], "x": 3.75, "y": 2 },
+                { "matrix": [2, 4], "x": 4.75, "y": 2 },
+                { "matrix": [2, 5], "x": 5.75, "y": 2 },
+                { "matrix": [2, 6], "x": 6.75, "y": 2 },
+                { "matrix": [2, 7], "x": 7.75, "y": 2 },
+                { "matrix": [2, 8], "x": 8.75, "y": 2 },
+                { "matrix": [2, 9], "x": 9.75, "y": 2 },
+                { "matrix": [2, 10], "x": 10.75, "y": 2 },
+                { "matrix": [2, 11], "x": 11.75, "y": 2 },
+                { "matrix": [2, 12], "x": 12.75, "y": 2 },
+				{ "matrix": [2, 13], "w": 1.25, "x": 13.75, "y": 2 },
+                { "matrix": [2, 14], "x": 15.5, "y": 2 },
+                { "matrix": [3, 0], "w": 1.25, "x": 0, "y": 3 },
+				{ "matrix": [3, 1], "x": 1.25, "y": 3 },
+                { "matrix": [3, 2], "x": 2.25, "y": 3 },
+                { "matrix": [3, 3], "x": 3.25, "y": 3 },
+                { "matrix": [3, 4], "x": 4.25, "y": 3 },
+                { "matrix": [3, 5], "x": 5.25, "y": 3 },
+                { "matrix": [3, 6], "x": 6.25, "y": 3 },
+                { "matrix": [3, 7], "x": 7.25, "y": 3 },
+                { "matrix": [3, 8], "x": 8.25, "y": 3 },
+                { "matrix": [3, 9], "x": 9.25, "y": 3 },
+                { "matrix": [3, 10], "x": 10.25, "y": 3 },
+                { "matrix": [3, 11], "x": 11.25, "y": 3 },
+                { "matrix": [3, 12], "w": 1.75, "x": 12.25, "y": 3 },
+                { "matrix": [3, 13], "x": 14.25, "y": 3.25 },
+                { "matrix": [3, 14], "x": 15.5, "y": 3 },
+                { "matrix": [4, 0], "w": 1.25, "x": 0, "y": 4 },
+                { "matrix": [4, 1], "w": 1.25, "x": 1.25, "y": 4 },
+                { "matrix": [4, 2], "w": 1.25, "x": 2.5, "y": 4 },
+                { "matrix": [4, 6], "w": 6.25, "x": 3.75, "y": 4 },
+                { "matrix": [4, 9], "x": 10, "y": 4 },
+                { "matrix": [4, 10], "x": 11, "y": 4 },
+                { "matrix": [4, 11], "x": 12, "y": 4 },
+                { "matrix": [4, 12], "x": 13.25, "y": 4.25 },
+                { "matrix": [4, 13], "x": 14.25, "y": 4.25 },
+                { "matrix": [4, 14], "x": 15.25, "y": 4.25 }
+            ]
+        }
+    }
+}
\ No newline at end of file
diff --git a/keyboards/era/era65/keymaps/default/keymap.c b/keyboards/era/era65/keymaps/default/keymap.c
new file mode 100644
index 0000000000..b412fe3d08
--- /dev/null
+++ b/keyboards/era/era65/keymaps/default/keymap.c
@@ -0,0 +1,37 @@
+// Copyright 2018-2022 QMK (@qmk)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+    [0] = LAYOUT_65_combo(
+        QK_GESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_MINS, KC_EQL,  KC_BSPC, KC_INS,
+        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_RBRC, KC_BSLS, KC_DEL,
+        KC_CAPS, KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT,  KC_PGUP,
+        KC_LSFT, KC_BSLS, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_RSFT, KC_UP,   KC_PGDN,
+        KC_LCTL, KC_LGUI, KC_LALT,                            KC_SPC,                    KC_RALT, MO(1),   KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
+    ),
+
+    /*
+     * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐
+     * │ ` │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│       │   │
+     * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤
+     * │     │   │   │   │   │   │   │   │   │   │   │PSc│Scr│Pause│Ins│
+     * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤
+     * │      │   │   │   │   │   │   │   │   │   │   │   │        │Hom│
+     * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤
+     * │        │   │   │   │   │   │   │Mut│Vl-│Vl+│   │      │   │End│
+     * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┼───┤
+     * │    │    │    │                        │   │   │   │   │   │   │
+     * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┴───┘
+     */
+    [1] = LAYOUT_65_combo(
+        KC_GRV,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_SCRL, KC_PAUS, KC_INS,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME,
+        _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______, KC_END,
+        _______, _______, _______,                            _______,                   _______, _______, _______, _______, _______, _______
+    ),
+
+};
diff --git a/keyboards/era/era65/keymaps/via/keymap.c b/keyboards/era/era65/keymaps/via/keymap.c
new file mode 100644
index 0000000000..f87b1b9114
--- /dev/null
+++ b/keyboards/era/era65/keymaps/via/keymap.c
@@ -0,0 +1,68 @@
+// Copyright 2018-2022 QMK (@qmk)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+    [0] = LAYOUT_65_combo(
+        QK_GESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_MINS, KC_EQL,  KC_BSPC, KC_INS,
+        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_RBRC, KC_BSLS, KC_DEL,
+        KC_CAPS, KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT,  KC_PGUP,
+        KC_LSFT, KC_BSLS, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_RSFT, KC_UP,   KC_PGDN,
+        KC_LCTL, KC_LGUI, KC_LALT,                            KC_SPC,                    KC_RALT, MO(1),   KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
+    ),
+
+    /*
+     * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐
+     * │ ` │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│       │   │
+     * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤
+     * │     │   │   │   │   │   │   │   │   │   │   │PSc│Scr│Pause│Ins│
+     * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤
+     * │      │   │   │   │   │   │   │   │   │   │   │   │        │Hom│
+     * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤
+     * │        │   │   │   │   │   │   │Mut│Vl-│Vl+│   │      │   │End│
+     * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┼───┤
+     * │    │    │    │                        │   │   │   │   │   │   │
+     * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┴───┘
+     */
+    [1] = LAYOUT_65_combo(
+        KC_GRV,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_SCRL, KC_PAUS, KC_INS,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME,
+        _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______, KC_END,
+        _______, _______, _______,                            _______,                   _______, _______, _______, _______, _______, _______
+    ),
+	
+    [2] = LAYOUT_65_combo(
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______,                            _______,                   _______, _______, _______, _______, _______, _______
+    ),
+		
+    [3] = LAYOUT_65_combo(
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______,                            _______,                   _______, _______, _______, _______, _______, _______
+    ),
+		
+    [4] = LAYOUT_65_combo(
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______,                            _______,                   _______, _______, _______, _______, _______, _______
+    ),
+		
+    [5] = LAYOUT_65_combo(
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+        _______, _______, _______,                            _______,                   _______, _______, _______, _______, _______, _______
+    ),
+};
diff --git a/keyboards/era/era65/keymaps/via/rules.mk b/keyboards/era/era65/keymaps/via/rules.mk
new file mode 100644
index 0000000000..036bd6d1c3
--- /dev/null
+++ b/keyboards/era/era65/keymaps/via/rules.mk
@@ -0,0 +1 @@
+VIA_ENABLE = yes
\ No newline at end of file
diff --git a/keyboards/era/era65/mcuconf.h b/keyboards/era/era65/mcuconf.h
new file mode 100644
index 0000000000..c9de0026f1
--- /dev/null
+++ b/keyboards/era/era65/mcuconf.h
@@ -0,0 +1,8 @@
+// Copyright 2022 MatteoDM <matteodalmo@gmail.com>
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+#include_next <mcuconf.h>
+
+/* Used for backlight display */
+#undef RP_PWM_USE_PWM0
+#define RP_PWM_USE_PWM0         TRUE
\ No newline at end of file
diff --git a/keyboards/era/era65/readme.md b/keyboards/era/era65/readme.md
new file mode 100644
index 0000000000..cd25aafb1f
--- /dev/null
+++ b/keyboards/era/era65/readme.md
@@ -0,0 +1,25 @@
+# ERA65
+
+ERA65 Keyboard
+
+* Keyboard Maintainer: [ERA](https://github.com/eerraa)
+* Hardware Supported: RP2040
+* Hardware Availability: [ERA](https://github.com/eerraa)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make era/era65:default
+
+Flashing example for this keyboard:
+
+    make era/era65: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**: Short the reset hole of the PCB twice within 1 second.
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available
\ No newline at end of file
diff --git a/keyboards/era/era65/rules.mk b/keyboards/era/era65/rules.mk
new file mode 100644
index 0000000000..12a6f414c4
--- /dev/null
+++ b/keyboards/era/era65/rules.mk
@@ -0,0 +1,2 @@
+BACKLIGHT_DRIVER = pwm
+DEBOUNCE_TYPE = asym_eager_defer_pk
\ No newline at end of file