From abf1902ff597e77e910c0fb9a8d132b46f78317b Mon Sep 17 00:00:00 2001
From: Legonut <legonut3@gmail.com>
Date: Tue, 10 Nov 2020 01:22:22 -0500
Subject: [PATCH] [Keyboard] RGBKB Pan (#9587)

* Add new keyboard Pan

Encoder switches still need work

* New keyboard Pan

Should be complete

* Split MCU selection into 2 revision folders

* [rgbkb/pan] Make requested changes for PR

Additionally, set DEFAULT_FOLDER to rev1, and default rev1
 to atmega32a (as all shipped kits include an atmega32a)

* Apply suggestions from code review

* Fix default keymap typo

* add usb max power define

* Commit suggested changes

* Update keyboards/rgbkb/pan/config.h

* Apply suggestions from code review

Small copyright updates

* Apply suggestions from code review
---
 keyboards/rgbkb/pan/config.h                  |  43 +++++++
 keyboards/rgbkb/pan/keymaps/default/keymap.c  | 117 ++++++++++++++++++
 keyboards/rgbkb/pan/keymaps/default/rules.mk  |   6 +
 keyboards/rgbkb/pan/pan.c                     |  88 +++++++++++++
 keyboards/rgbkb/pan/pan.h                     |  37 ++++++
 keyboards/rgbkb/pan/post_rules.mk             |  22 ++++
 keyboards/rgbkb/pan/readme.md                 |  19 +++
 keyboards/rgbkb/pan/rev1/32a/config.h         |  24 ++++
 keyboards/rgbkb/pan/rev1/32a/post_rules.mk    |  22 ++++
 keyboards/rgbkb/pan/rev1/32a/rules.mk         |   8 ++
 keyboards/rgbkb/pan/rev1/proton_c/config.h    |  24 ++++
 .../rgbkb/pan/rev1/proton_c/post_rules.mk     |  22 ++++
 keyboards/rgbkb/pan/rev1/proton_c/rules.mk    |   2 +
 keyboards/rgbkb/pan/rev1/rules.mk             |   2 +
 keyboards/rgbkb/pan/rules.mk                  |  25 ++++
 15 files changed, 461 insertions(+)
 create mode 100644 keyboards/rgbkb/pan/config.h
 create mode 100644 keyboards/rgbkb/pan/keymaps/default/keymap.c
 create mode 100644 keyboards/rgbkb/pan/keymaps/default/rules.mk
 create mode 100644 keyboards/rgbkb/pan/pan.c
 create mode 100644 keyboards/rgbkb/pan/pan.h
 create mode 100644 keyboards/rgbkb/pan/post_rules.mk
 create mode 100644 keyboards/rgbkb/pan/readme.md
 create mode 100644 keyboards/rgbkb/pan/rev1/32a/config.h
 create mode 100644 keyboards/rgbkb/pan/rev1/32a/post_rules.mk
 create mode 100644 keyboards/rgbkb/pan/rev1/32a/rules.mk
 create mode 100644 keyboards/rgbkb/pan/rev1/proton_c/config.h
 create mode 100644 keyboards/rgbkb/pan/rev1/proton_c/post_rules.mk
 create mode 100644 keyboards/rgbkb/pan/rev1/proton_c/rules.mk
 create mode 100644 keyboards/rgbkb/pan/rev1/rules.mk
 create mode 100644 keyboards/rgbkb/pan/rules.mk

diff --git a/keyboards/rgbkb/pan/config.h b/keyboards/rgbkb/pan/config.h
new file mode 100644
index 0000000000..a1a2aae9fc
--- /dev/null
+++ b/keyboards/rgbkb/pan/config.h
@@ -0,0 +1,43 @@
+/*Copyright 2020 RGBKB
+
+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"
+
+#define VENDOR_ID       0x5247  // "RG" - RGBKB
+#define PRODUCT_ID      0x8C9C  // Pan
+#define DEVICE_VER      0x0002
+#define MANUFACTURER    RGBKB
+#define PRODUCT         Pan
+
+/* key matrix size */
+#define MATRIX_ROWS 5
+#define MATRIX_COLS 13
+
+#define ENCODER_RESOLUTION 4
+#define RGBLED_NUM 64
+#define RGBLIGHT_ANIMATIONS
+#define DRIVER_LED_TOTAL RGBLED_NUM
+
+/* COL2ROW, ROW2COL*/
+#define DIODE_DIRECTION COL2ROW
+
+#define RGBLIGHT_LIMIT_VAL 120
+#define USB_MAX_POWER_CONSUMPTION 500
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCE 5
diff --git a/keyboards/rgbkb/pan/keymaps/default/keymap.c b/keyboards/rgbkb/pan/keymaps/default/keymap.c
new file mode 100644
index 0000000000..c041c0b57b
--- /dev/null
+++ b/keyboards/rgbkb/pan/keymaps/default/keymap.c
@@ -0,0 +1,117 @@
+ /* Copyright 2020 RGBKB
+  * 
+  * 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/>. 
+  */ 
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+#include QMK_KEYBOARD_H
+
+enum layer_number {
+    _QWERTY,
+    _COLEMAK,
+    _FN,
+    _ADJ
+};
+
+#define FN_ESC   LT(_FN, KC_ESC)
+#define FN_CAPS  LT(_FN, KC_CAPS)
+#define QWERTY   DF(_QWERTY)
+#define COLEMAK  DF(_COLEMAK)
+
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [_QWERTY] = LAYOUT_all(
+        KC_NO,                                                                                                      KC_NO,
+        GRAVE_ESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,   KC_6,   KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC, KC_DEL,
+        KC_TAB,    KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,   KC_Y,   KC_U,    KC_I,    KC_O,    KC_P,    KC_BSLS,
+        FN_CAPS,   KC_A,    KC_S,    KC_D,    KC_F,    KC_G,   KC_H,   KC_J,    KC_K,    KC_L,    KC_SCLN, KC_ENT,
+        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_RSPC,
+        KC_LCTL,   KC_LGUI, KC_LALT, RGB_TOG, MO(_ADJ),KC_SPC, KC_SPC, MO(_FN), KC_LEFT, KC_DOWN, KC_UP,   KC_RIGHT
+    ),
+
+    [_COLEMAK] = LAYOUT_all(
+        KC_NO,                                                                                                      KC_NO,
+        GRAVE_ESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,   KC_6,   KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC, KC_DEL,
+        KC_TAB,    KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,   KC_J,   KC_L,    KC_U,    KC_Y,    KC_SCLN, KC_BSLS,
+        FN_CAPS,   KC_A,    KC_R,    KC_S,    KC_T,    KC_D,   KC_H,   KC_N,    KC_E,    KC_I,    KC_O,    KC_ENT,
+        KC_LSFT,   KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,   KC_N,   KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_RSPC, KC_ENT,
+        KC_LCTL,   KC_LGUI, KC_LALT, RGB_TOG, MO(_ADJ),KC_SPC, KC_SPC, MO(_FN), KC_LEFT, KC_DOWN, KC_UP,   KC_RIGHT
+    ),
+
+    [_FN] = LAYOUT_all(
+        KC_NO,                                                                                                      KC_NO,
+        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_PGDN, KC_UP,   KC_PGUP, _______, _______, _______, KC_PGDN, KC_UP,   KC_PGUP, KC_PSCR, KC_HOME,
+        _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS,  KC_END,
+        _______, _______, _______, _______, _______, _______, _______, KC_LBRC, _______, KC_RBRC, _______, _______, _______,
+        _______, _______, _______, RGB_MOD, _______, _______, _______, _______, _______, _______, _______, _______
+    ),
+
+    [_ADJ] = LAYOUT_all(
+        KC_NO,                                                                                                      KC_NO,
+        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,
+        _______, RGB_SAD, RGB_VAI, RGB_SAI, RESET,   _______, _______, KC_P7,   KC_P8,   KC_P9,   _______, _______,
+        _______, RGB_HUD, RGB_VAD, RGB_HUI, _______, _______, _______, KC_P4,   KC_P5,   KC_P6,   _______, _______,
+        _______, RGB_SPD, _______, RGB_SPI, _______, _______, _______, KC_P1,   KC_P2,   KC_P3,   _______, _______, _______,
+        _______, _______, _______, RGB_MOD, _______, _______, _______, KC_P0,   KC_PDOT, KC_NLCK, _QWERTY, _COLEMAK
+    )
+};
+
+#ifdef OLED_DRIVER_ENABLE
+void oled_task_user(void) {
+    // Host Keyboard Layer Status
+    oled_write_P(PSTR("RGBKB Pan\n"), false);
+    oled_write_P(PSTR("Layer: "), false);
+    uint8_t layer = layer_state ? biton(layer_state) : biton32(default_layer_state);
+    switch (layer) {
+        case _QWERTY:
+            oled_write_P(PSTR("Default\n"), false);
+            break;
+        case _COLEMAK:
+            oled_write_P(PSTR("Colemak\n"), false);
+            break;
+        case _FN:
+            oled_write_P(PSTR("Function\n"), false);
+            break;
+        case _ADJ:
+            oled_write_P(PSTR("Adjust\n"), false);
+            break;
+        default:
+            oled_write_P(PSTR("Undefined\n"), false);
+            // Or use the write_ln shortcut over adding '\n' to the end of your string
+            //oled_write_ln_P(PSTR("Undefined"), false);
+    }
+    led_t led_state = host_keyboard_led_state();
+    oled_write_P(led_state.num_lock ? PSTR("Numlock On\n") : PSTR("           \n"), false);
+    oled_write_P(led_state.caps_lock ? PSTR("Capslock On \n") : PSTR("           \n"), false);
+}
+#endif
+
+void encoder_update_user(uint8_t index, bool clockwise) {
+  if (index == 0) {         // First encoder - right
+    if (clockwise) {
+      tap_code(KC_VOLU);
+    } else {
+      tap_code(KC_VOLD);
+    }
+  } else if (index == 1) {  // Second encoder - left
+    if (clockwise) {
+      tap_code(KC_VOLU);
+    } else {
+      tap_code(KC_VOLD);
+    }
+  }
+}
diff --git a/keyboards/rgbkb/pan/keymaps/default/rules.mk b/keyboards/rgbkb/pan/keymaps/default/rules.mk
new file mode 100644
index 0000000000..9ad29c645c
--- /dev/null
+++ b/keyboards/rgbkb/pan/keymaps/default/rules.mk
@@ -0,0 +1,6 @@
+# RGB layout selection
+RGB_ENCODERS          = yes    # For RGB encoders, solder on both WS2811 chips
+STAGGERED_LAYOUT      = no     # If you soldered R1-A12 and R4-A12, enable this.
+
+# Do not edit past here
+include keyboards/$(KEYBOARD)/post_rules.mk
diff --git a/keyboards/rgbkb/pan/pan.c b/keyboards/rgbkb/pan/pan.c
new file mode 100644
index 0000000000..bc438f2d08
--- /dev/null
+++ b/keyboards/rgbkb/pan/pan.c
@@ -0,0 +1,88 @@
+ /* Copyright 2020 RGBKB
+  * 
+  * 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 "pan.h"
+#include "quantum.h"
+#include "rgb_matrix_types.h"
+
+
+#if defined RGB_MATRIX_ENABLE
+    led_config_t g_led_config = { {
+       { 2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14 },
+       { 0, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15 },
+       { 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1 },
+       { 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40 },
+       { 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, NO_LED  }
+    }, {
+#ifdef STAGGERED_RGB_ENCODERS
+        {0, -19},{228, -19},
+        {0, 0}, {14, 0}, {33, 0}, {52, 0}, {71, 0}, {90, 0}, {109, 0}, {128, 0}, {147, 0}, {166, 0}, {185, 0}, {204, 0}, {223, 0},
+        {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19},
+        {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38},
+        {223, 57}, {204, 57}, {185, 57}, {171, 57}, {147, 57}, {128, 57}, {109, 57}, {90, 57}, {71, 57}, {52, 57}, {33, 57}, {14, 57}, {0, 57},
+        {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76},
+#elif defined RGB_ENCODERS
+        {0, -19},{228, -19},
+        {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0},
+        {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19},
+        {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38},
+        {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57},
+        {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76},
+        {0, 95},{19, 95}, //not used
+#elif defined STAGGERED_LAYOUT
+        {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0}, {0, 0},
+        {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19},
+        {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38},
+        {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57}, {0, 0},
+        {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76},
+        {0, 95},{19, 95},//not used
+#else
+        {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0},
+        {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19},
+        {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38},
+        {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57},
+        {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76},
+        {0, 0},{0, 0}, {0, 0},{0, 0},//not used
+#endif
+    }, {
+#ifdef STAGGERED_RGB_ENCODERS
+        1,                               1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#elif defined RGB_ENCODERS
+        1,                               1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#elif defined STAGGERED_LAYOUT
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#else
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+#endif
+    } };
+#endif
diff --git a/keyboards/rgbkb/pan/pan.h b/keyboards/rgbkb/pan/pan.h
new file mode 100644
index 0000000000..c1b9f77f6d
--- /dev/null
+++ b/keyboards/rgbkb/pan/pan.h
@@ -0,0 +1,37 @@
+/* Copyright 2020 RGBKB
+ *
+ * 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 _x_ KC_NO
+
+#include "quantum.h"
+
+#define LAYOUT_all( \
+         E01,                                                          E02, \
+/*       0    1    2    3    4    5    6    7    8    9    10   11     12 */\
+/* 0 */  K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11,   K12, \
+/* 1 */  K13, K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, K24,        \
+/* 2 */  K26, K27, K28, K29, K30, K31, K32, K33, K34, K35, K36, K37,        \
+/* 3 */  K38, K39, K40, K41, K42, K43, K44, K45, K46, K47, K48, K49,   K50, \
+/* 4 */  K51, K52, K53, K54, K55, K56, K57, K58, K59, K60, K61, K62         \
+  ) { \
+/* 0 */{ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11,   K12   }, \
+/* 1 */{ K13, K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, K24,   KC_NO }, \
+/* 2 */{ K26, K27, K28, K29, K30, K31, K32, K33, K34, K35, K36, K37,   KC_NO }, \
+/* 3 */{ K38, K39, K40, K41, K42, K43, K44, K45, K46, K47, K48, K49,   K50   }, \
+/* 4 */{ K51, K52, K53, K54, K55, K56, K57, K58, K59, K60, K61, KC_NO, K62   }  \
+  }
diff --git a/keyboards/rgbkb/pan/post_rules.mk b/keyboards/rgbkb/pan/post_rules.mk
new file mode 100644
index 0000000000..7947d1d9bf
--- /dev/null
+++ b/keyboards/rgbkb/pan/post_rules.mk
@@ -0,0 +1,22 @@
+# As long as the users rules.mk has include $(KEYBOARD)/post_rules.mk this will be run after to properly setup any keyboard features and defines
+ifeq ($(strip $(RGB_MATRIX_KEYPRESSES)), yes)
+    OPT_DEFS += -DRGB_MATRIX_KEYPRESSES
+endif
+
+ifeq ($(strip $(RGB_MATRIX_FRAMEBUFFER)), yes)
+    OPT_DEFS += -DRGB_MATRIX_FRAMEBUFFER_EFFECTS
+endif
+
+ifeq ($(strip $(STAGGERED_LAYOUT)), yes)
+    OPT_DEFS += -DSTAGGERED_LAYOUT
+endif
+
+ifeq ($(strip $(RGB_ENCODERS)), yes)
+    OPT_DEFS += -DRGB_ENCODERS
+endif
+
+ifeq ($(strip $(RGB_ENCODERS)), yes)
+    ifeq ($(strip $(STAGGERED_LAYOUT)), yes)
+        OPT_DEFS += -DSTAGGERED_RGB_ENCODERS=$(strip $(STAGGERED_RGB_ENCODERS))
+    endif
+endif
diff --git a/keyboards/rgbkb/pan/readme.md b/keyboards/rgbkb/pan/readme.md
new file mode 100644
index 0000000000..f7041605c6
--- /dev/null
+++ b/keyboards/rgbkb/pan/readme.md
@@ -0,0 +1,19 @@
+# Pan
+
+![pan](https://i.imgur.com/Q6pqCFFl.jpg)
+
+Ortho or Staggered DIY kit with RGB
+
+* Keyboard Maintainer: [RGBKB](https://github.com/RGBKB)
+* Hardware Supported: Pan, atmega32a or Proton-C
+* Hardware Availability: [rgbkb.net](https://www.rgbkb.net/), [GitHub](https://github.com/RGBKB/Keyboard-files/tree/master/Pan)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make rgbkb/pan/rev1/32a:default
+
+If you are using the Proton-C:
+
+    make rgbkb/pan/rev1/proton_c: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/rgbkb/pan/rev1/32a/config.h b/keyboards/rgbkb/pan/rev1/32a/config.h
new file mode 100644
index 0000000000..ed5d3457c7
--- /dev/null
+++ b/keyboards/rgbkb/pan/rev1/32a/config.h
@@ -0,0 +1,24 @@
+/*Copyright 2020 RGBKB
+
+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"
+#define MATRIX_ROW_PINS { D7, D1, D5, D6, C2 }
+#define MATRIX_COL_PINS { C3, C4, C5, C6, C7, A7, A6, A5, A4, A3, A2, A1, A0 }
+#define ENCODERS_PAD_A { B0, D0 }
+#define ENCODERS_PAD_B { B1, B2}
+#define RGB_DI_PIN B3
diff --git a/keyboards/rgbkb/pan/rev1/32a/post_rules.mk b/keyboards/rgbkb/pan/rev1/32a/post_rules.mk
new file mode 100644
index 0000000000..7947d1d9bf
--- /dev/null
+++ b/keyboards/rgbkb/pan/rev1/32a/post_rules.mk
@@ -0,0 +1,22 @@
+# As long as the users rules.mk has include $(KEYBOARD)/post_rules.mk this will be run after to properly setup any keyboard features and defines
+ifeq ($(strip $(RGB_MATRIX_KEYPRESSES)), yes)
+    OPT_DEFS += -DRGB_MATRIX_KEYPRESSES
+endif
+
+ifeq ($(strip $(RGB_MATRIX_FRAMEBUFFER)), yes)
+    OPT_DEFS += -DRGB_MATRIX_FRAMEBUFFER_EFFECTS
+endif
+
+ifeq ($(strip $(STAGGERED_LAYOUT)), yes)
+    OPT_DEFS += -DSTAGGERED_LAYOUT
+endif
+
+ifeq ($(strip $(RGB_ENCODERS)), yes)
+    OPT_DEFS += -DRGB_ENCODERS
+endif
+
+ifeq ($(strip $(RGB_ENCODERS)), yes)
+    ifeq ($(strip $(STAGGERED_LAYOUT)), yes)
+        OPT_DEFS += -DSTAGGERED_RGB_ENCODERS=$(strip $(STAGGERED_RGB_ENCODERS))
+    endif
+endif
diff --git a/keyboards/rgbkb/pan/rev1/32a/rules.mk b/keyboards/rgbkb/pan/rev1/32a/rules.mk
new file mode 100644
index 0000000000..321ecc5c1a
--- /dev/null
+++ b/keyboards/rgbkb/pan/rev1/32a/rules.mk
@@ -0,0 +1,8 @@
+# MCU name
+MCU = atmega32a
+
+# Processor frequency
+F_CPU = 16000000
+
+# Bootloader selection
+BOOTLOADER = USBasp
diff --git a/keyboards/rgbkb/pan/rev1/proton_c/config.h b/keyboards/rgbkb/pan/rev1/proton_c/config.h
new file mode 100644
index 0000000000..7a909a9a13
--- /dev/null
+++ b/keyboards/rgbkb/pan/rev1/proton_c/config.h
@@ -0,0 +1,24 @@
+/*Copyright 2020 RGBKB
+
+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"
+#define MATRIX_ROW_PINS { A15, B10, A14, A13, A7 }
+#define MATRIX_COL_PINS { A8, A6, B0, B1, B2, B4, B5, A1, A2, B3, B9, A10, A9 }
+#define ENCODERS_PAD_A { B14, B11 }
+#define ENCODERS_PAD_B { B15, B12 }
+#define RGB_DI_PIN A3
diff --git a/keyboards/rgbkb/pan/rev1/proton_c/post_rules.mk b/keyboards/rgbkb/pan/rev1/proton_c/post_rules.mk
new file mode 100644
index 0000000000..7947d1d9bf
--- /dev/null
+++ b/keyboards/rgbkb/pan/rev1/proton_c/post_rules.mk
@@ -0,0 +1,22 @@
+# As long as the users rules.mk has include $(KEYBOARD)/post_rules.mk this will be run after to properly setup any keyboard features and defines
+ifeq ($(strip $(RGB_MATRIX_KEYPRESSES)), yes)
+    OPT_DEFS += -DRGB_MATRIX_KEYPRESSES
+endif
+
+ifeq ($(strip $(RGB_MATRIX_FRAMEBUFFER)), yes)
+    OPT_DEFS += -DRGB_MATRIX_FRAMEBUFFER_EFFECTS
+endif
+
+ifeq ($(strip $(STAGGERED_LAYOUT)), yes)
+    OPT_DEFS += -DSTAGGERED_LAYOUT
+endif
+
+ifeq ($(strip $(RGB_ENCODERS)), yes)
+    OPT_DEFS += -DRGB_ENCODERS
+endif
+
+ifeq ($(strip $(RGB_ENCODERS)), yes)
+    ifeq ($(strip $(STAGGERED_LAYOUT)), yes)
+        OPT_DEFS += -DSTAGGERED_RGB_ENCODERS=$(strip $(STAGGERED_RGB_ENCODERS))
+    endif
+endif
diff --git a/keyboards/rgbkb/pan/rev1/proton_c/rules.mk b/keyboards/rgbkb/pan/rev1/proton_c/rules.mk
new file mode 100644
index 0000000000..b17a3d0316
--- /dev/null
+++ b/keyboards/rgbkb/pan/rev1/proton_c/rules.mk
@@ -0,0 +1,2 @@
+# MCU name
+MCU = STM32F303
diff --git a/keyboards/rgbkb/pan/rev1/rules.mk b/keyboards/rgbkb/pan/rev1/rules.mk
new file mode 100644
index 0000000000..4d3c0f6679
--- /dev/null
+++ b/keyboards/rgbkb/pan/rev1/rules.mk
@@ -0,0 +1,2 @@
+# The default configuration is a atmega32a
+DEFAULT_FOLDER = rgbkb/pan/rev1/32a
diff --git a/keyboards/rgbkb/pan/rules.mk b/keyboards/rgbkb/pan/rules.mk
new file mode 100644
index 0000000000..1960304505
--- /dev/null
+++ b/keyboards/rgbkb/pan/rules.mk
@@ -0,0 +1,25 @@
+# Build Options
+#   change yes to no to disable
+#
+BOOTMAGIC_ENABLE = lite     # Virtual DIP switch configuration
+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
+BLUETOOTH_ENABLE = no       # Enable Bluetooth
+AUDIO_ENABLE = no           # Audio output
+RGB_MATRIX_ENABLE = WS2812
+WS2812_DRIVER = bitbang
+ENCODER_ENABLE = yes
+OLED_DRIVER_ENABLE = yes
+
+# RGB layout selection
+RGB_ENCODERS = yes # For RGB encoders, solder on both WS2811 chips
+STAGGERED_LAYOUT = no # If you soldered R1-A12 and R4-A12, enable this.
+
+# Default to revision 1
+DEFAULT_FOLDER = rgbkb/pan/rev1