From ac7524213236dd09a99da2d97004dec1c288596c Mon Sep 17 00:00:00 2001
From: Ning <vipning@qq.com>
Date: Wed, 22 Mar 2023 02:20:25 +0800
Subject: [PATCH] [Keyboard] Add tiny board 16 rgb keyboard (#20158)

Co-authored-by: jack <0x6a73@protonmail.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
---
 keyboards/ning/tiny_board/tb16_rgb/config.h   | 28 +++++++++++
 keyboards/ning/tiny_board/tb16_rgb/info.json  | 48 +++++++++++++++++++
 .../tb16_rgb/keymaps/default/keymap.c         | 37 ++++++++++++++
 .../tb16_rgb/keymaps/ningjx/keymap.c          | 37 ++++++++++++++
 keyboards/ning/tiny_board/tb16_rgb/readme.md  | 26 ++++++++++
 keyboards/ning/tiny_board/tb16_rgb/rules.mk   |  1 +
 keyboards/ning/tiny_board/tb16_rgb/tb16_rgb.c | 31 ++++++++++++
 7 files changed, 208 insertions(+)
 create mode 100644 keyboards/ning/tiny_board/tb16_rgb/config.h
 create mode 100644 keyboards/ning/tiny_board/tb16_rgb/info.json
 create mode 100644 keyboards/ning/tiny_board/tb16_rgb/keymaps/default/keymap.c
 create mode 100644 keyboards/ning/tiny_board/tb16_rgb/keymaps/ningjx/keymap.c
 create mode 100644 keyboards/ning/tiny_board/tb16_rgb/readme.md
 create mode 100644 keyboards/ning/tiny_board/tb16_rgb/rules.mk
 create mode 100644 keyboards/ning/tiny_board/tb16_rgb/tb16_rgb.c

diff --git a/keyboards/ning/tiny_board/tb16_rgb/config.h b/keyboards/ning/tiny_board/tb16_rgb/config.h
new file mode 100644
index 0000000000..d6e6c6a154
--- /dev/null
+++ b/keyboards/ning/tiny_board/tb16_rgb/config.h
@@ -0,0 +1,28 @@
+/* Copyright 2023 Ning (@ningjx)
+ *
+ * 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 RGB_DI_PIN B5
+#define RGB_MATRIX_LED_COUNT 16
+
+#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
+#define ENABLE_RGB_MATRIX_TYPING_HEATMAP
+
+#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_TYPING_HEATMAP
+#define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS
+
+
diff --git a/keyboards/ning/tiny_board/tb16_rgb/info.json b/keyboards/ning/tiny_board/tb16_rgb/info.json
new file mode 100644
index 0000000000..5c19f2fe6b
--- /dev/null
+++ b/keyboards/ning/tiny_board/tb16_rgb/info.json
@@ -0,0 +1,48 @@
+{
+    "manufacturer": "Ning",
+    "keyboard_name": "TB16 RGB",
+    "maintainer": "ningjx",
+    "diode_direction": "COL2ROW",
+    "features": {
+        "bootmagic": true,
+        "command": false,
+        "console": false,
+        "extrakey": true,
+        "mousekey": true,
+        "nkro": true,
+        "rgb_matrix": true
+    },
+    "matrix_pins": {
+        "cols": ["B6", "B1", "B3", "B2"],
+        "rows": ["F7", "F6", "F5", "F4"]
+    },
+    "development_board": "promicro",
+    "url": "",
+    "usb": {
+        "device_version": "1.0.0",
+        "pid": "0x0000",
+        "vid": "0xFEED"
+    },
+    "layouts": {
+        "LAYOUT_ortho_4x4": {
+            "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": [1, 0], "x": 0, "y": 1 },
+                { "matrix": [1, 1], "x": 1, "y": 1 },
+                { "matrix": [1, 2], "x": 2, "y": 1 },
+                { "matrix": [1, 3], "x": 3, "y": 1 },
+                { "matrix": [2, 0], "x": 0, "y": 2 },
+                { "matrix": [2, 1], "x": 1, "y": 2 },
+                { "matrix": [2, 2], "x": 2, "y": 2 },
+                { "matrix": [2, 3], "x": 3, "y": 2 },
+                { "matrix": [3, 0], "x": 0, "y": 3 },
+                { "matrix": [3, 1], "x": 1, "y": 3 },
+                { "matrix": [3, 2], "x": 2, "y": 3 },
+                { "matrix": [3, 3], "x": 3, "y": 3 }
+            ]
+        }
+    }
+}
diff --git a/keyboards/ning/tiny_board/tb16_rgb/keymaps/default/keymap.c b/keyboards/ning/tiny_board/tb16_rgb/keymaps/default/keymap.c
new file mode 100644
index 0000000000..e9529fe91e
--- /dev/null
+++ b/keyboards/ning/tiny_board/tb16_rgb/keymaps/default/keymap.c
@@ -0,0 +1,37 @@
+/* Copyright 2023 Ning (@ningjx)
+ *
+ * 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
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /*
+     * ┌───┬───┬───┬───┐
+     * │ 7 │ 8 │ 9 │RGB│
+     * ├───┼───┼───┼───┤
+     * │ 4 │ 5 │ 6 │MOD│
+     * ├───┼───┼───┼───┤
+     * │ 1 │ 2 │ 3 │ - │
+     * ├───┼───┼───┼───┤
+     * │ 0 │ . │Ent│ + │
+     * └───┴───┴───┴───┘
+     */
+    [0] = LAYOUT_ortho_4x4(
+        KC_P7,   KC_P8,   KC_P9,   RGB_TOG,
+        KC_P4,   KC_P5,   KC_P6,   RGB_MODE_FORWARD,
+        KC_P1,   KC_P2,   KC_P3,   KC_PMNS,
+        KC_P0,   KC_PDOT, KC_PENT, KC_PPLS
+    )
+};
diff --git a/keyboards/ning/tiny_board/tb16_rgb/keymaps/ningjx/keymap.c b/keyboards/ning/tiny_board/tb16_rgb/keymaps/ningjx/keymap.c
new file mode 100644
index 0000000000..e9529fe91e
--- /dev/null
+++ b/keyboards/ning/tiny_board/tb16_rgb/keymaps/ningjx/keymap.c
@@ -0,0 +1,37 @@
+/* Copyright 2023 Ning (@ningjx)
+ *
+ * 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
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /*
+     * ┌───┬───┬───┬───┐
+     * │ 7 │ 8 │ 9 │RGB│
+     * ├───┼───┼───┼───┤
+     * │ 4 │ 5 │ 6 │MOD│
+     * ├───┼───┼───┼───┤
+     * │ 1 │ 2 │ 3 │ - │
+     * ├───┼───┼───┼───┤
+     * │ 0 │ . │Ent│ + │
+     * └───┴───┴───┴───┘
+     */
+    [0] = LAYOUT_ortho_4x4(
+        KC_P7,   KC_P8,   KC_P9,   RGB_TOG,
+        KC_P4,   KC_P5,   KC_P6,   RGB_MODE_FORWARD,
+        KC_P1,   KC_P2,   KC_P3,   KC_PMNS,
+        KC_P0,   KC_PDOT, KC_PENT, KC_PPLS
+    )
+};
diff --git a/keyboards/ning/tiny_board/tb16_rgb/readme.md b/keyboards/ning/tiny_board/tb16_rgb/readme.md
new file mode 100644
index 0000000000..e755555e7b
--- /dev/null
+++ b/keyboards/ning/tiny_board/tb16_rgb/readme.md
@@ -0,0 +1,26 @@
+# ning/tiny_board/tb16_rgb
+
+
+A 4*4 tiny keyboard whith rgb lights.
+
+* Keyboard Maintainer: [Ning](https://github.com/ningjx)
+* Hardware Supported: The PCB is designed by [Ning](https://github.com/ningjx),with ATMega32U4.
+* Hardware Availability: https://oshwhub.com/iqirtryi/atmega32a-kb40
+
+Make example for this keyboard (after setting up your build environment):
+
+    make ning/tiny_board/tb16_rgb:default
+
+Flashing example for this keyboard:
+
+    make ning/tiny_board/tb16_rgb: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:
+
+* **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**: Briefly press the button on the back of the PCB - some may have pads you must short instead
+
diff --git a/keyboards/ning/tiny_board/tb16_rgb/rules.mk b/keyboards/ning/tiny_board/tb16_rgb/rules.mk
new file mode 100644
index 0000000000..32afd21635
--- /dev/null
+++ b/keyboards/ning/tiny_board/tb16_rgb/rules.mk
@@ -0,0 +1 @@
+RGB_MATRIX_DRIVER = WS2812
diff --git a/keyboards/ning/tiny_board/tb16_rgb/tb16_rgb.c b/keyboards/ning/tiny_board/tb16_rgb/tb16_rgb.c
new file mode 100644
index 0000000000..e7807be5e8
--- /dev/null
+++ b/keyboards/ning/tiny_board/tb16_rgb/tb16_rgb.c
@@ -0,0 +1,31 @@
+/* Copyright 2023 Ning (@ningjx)
+ *
+ * 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"
+
+led_config_t g_led_config = { {
+  { 0, 1, 2, 3 },
+  { 4, 5, 6, 7 },
+  { 8, 9, 10, 11 },
+  { 12, 13, 14, 15 }
+}, {
+  {0,0},{75,0},{150,0},{224,0},
+  {0,21},{75,21},{150,21},{224,21},
+  {0,42},{75,42},{150,42},{224,42},
+  {0,64},{75,64},{150,64},{224,64}
+}, {
+  4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
+} };