From 80b2b710da1795940ec519909594bd19872346ec Mon Sep 17 00:00:00 2001
From: cole smith <38364556+daysgobye@users.noreply.github.com>
Date: Tue, 16 Jun 2020 12:08:30 -0700
Subject: [PATCH] added 4x12 (#9411)

Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
---
 keyboards/boardsource/4x12/4x12.c             |   1 +
 keyboards/boardsource/4x12/4x12.h             |  14 ++
 keyboards/boardsource/4x12/config.h           | 142 ++++++++++++++++++
 keyboards/boardsource/4x12/info.json          |  64 ++++++++
 .../boardsource/4x12/keymaps/default/keymap.c |  36 +++++
 keyboards/boardsource/4x12/readme.md          |  12 ++
 keyboards/boardsource/4x12/rules.mk           |  32 ++++
 7 files changed, 301 insertions(+)
 create mode 100644 keyboards/boardsource/4x12/4x12.c
 create mode 100644 keyboards/boardsource/4x12/4x12.h
 create mode 100644 keyboards/boardsource/4x12/config.h
 create mode 100644 keyboards/boardsource/4x12/info.json
 create mode 100644 keyboards/boardsource/4x12/keymaps/default/keymap.c
 create mode 100644 keyboards/boardsource/4x12/readme.md
 create mode 100644 keyboards/boardsource/4x12/rules.mk

diff --git a/keyboards/boardsource/4x12/4x12.c b/keyboards/boardsource/4x12/4x12.c
new file mode 100644
index 0000000000..2aec6900ad
--- /dev/null
+++ b/keyboards/boardsource/4x12/4x12.c
@@ -0,0 +1 @@
+#include "4x12.h"
diff --git a/keyboards/boardsource/4x12/4x12.h b/keyboards/boardsource/4x12/4x12.h
new file mode 100644
index 0000000000..52c23708fa
--- /dev/null
+++ b/keyboards/boardsource/4x12/4x12.h
@@ -0,0 +1,14 @@
+#pragma once
+#include "quantum.h"
+
+#define LAYOUT_ortho_4x12( \
+    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, \
+    K12, K13, K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, \
+    K24, K25, K26, K27, K28, K29, K30, K31, K32, K33, K34, K35, \
+    K36, K37, K38, K39, K40, K41, K42, K43, K44, K45, K46, K47 \
+    ) { \
+        {K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11}, \
+        {K12, K13, K14, K15, K16, K17, K18, K19, K20, K21, K22, K23}, \
+        {K24, K25, K26, K27, K28, K29, K30, K31, K32, K33, K34, K35}, \
+        {K36, K37, K38, K39, K40, K41, K42, K43, K44, K45, K46, K47} \
+    }
diff --git a/keyboards/boardsource/4x12/config.h b/keyboards/boardsource/4x12/config.h
new file mode 100644
index 0000000000..e8f858586c
--- /dev/null
+++ b/keyboards/boardsource/4x12/config.h
@@ -0,0 +1,142 @@
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xF7E0
+#define PRODUCT_ID      0x0412
+#define DEVICE_VER      0x0000
+#define MANUFACTURER    Boardsource
+#define PRODUCT         4x12
+#define DESCRIPTION     40 percent ortho keyboard
+
+/* key matrix size */
+#define MATRIX_ROWS 4
+#define MATRIX_COLS 12
+#define MATRIX_ROW_PINS { D2, D3, D1, D0}
+#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3, B2, B6, B5, B4, E6, D7 }
+
+#define DIODE_DIRECTION COL2ROW
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not 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
+
+/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
+ * This is userful for the Windows task manager shortcut (ctrl+shift+esc).
+ */
+// #define GRAVE_ESC_CTRL_OVERRIDE
+
+/*
+ * Force NKRO
+ *
+ * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
+ * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
+ * makefile for this to work.)
+ *
+ * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
+ * until the next keyboard reset.
+ *
+ * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
+ * fully operational during normal computer usage.
+ *
+ * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
+ * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
+ * bootmagic, NKRO mode will always be enabled until it is toggled again during a
+ * power-up.
+ *
+ */
+//#define FORCE_NKRO
+
+/*
+ * Magic Key Options
+ *
+ * Magic keys are hotkey commands that allow control over firmware functions of
+ * the keyboard. They are best used in combination with the HID Listen program,
+ * found here: https://www.pjrc.com/teensy/hid_listen.html
+ *
+ * The options below allow the magic key functionality to be changed. This is
+ * useful if your keyboard/keypad is missing keys and you want magic key support.
+ *
+ */
+
+/* control how magic key switches layers */
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS  true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS  true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
+
+/* override magic key keymap */
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
+//#define MAGIC_KEY_HELP1          H
+//#define MAGIC_KEY_HELP2          SLASH
+//#define MAGIC_KEY_DEBUG          D
+//#define MAGIC_KEY_DEBUG_MATRIX   X
+//#define MAGIC_KEY_DEBUG_KBD      K
+//#define MAGIC_KEY_DEBUG_MOUSE    M
+//#define MAGIC_KEY_VERSION        V
+//#define MAGIC_KEY_STATUS         S
+//#define MAGIC_KEY_CONSOLE        C
+//#define MAGIC_KEY_LAYER0_ALT1    ESC
+//#define MAGIC_KEY_LAYER0_ALT2    GRAVE
+//#define MAGIC_KEY_LAYER0         0
+//#define MAGIC_KEY_LAYER1         1
+//#define MAGIC_KEY_LAYER2         2
+//#define MAGIC_KEY_LAYER3         3
+//#define MAGIC_KEY_LAYER4         4
+//#define MAGIC_KEY_LAYER5         5
+//#define MAGIC_KEY_LAYER6         6
+//#define MAGIC_KEY_LAYER7         7
+//#define MAGIC_KEY_LAYER8         8
+//#define MAGIC_KEY_LAYER9         9
+//#define MAGIC_KEY_BOOTLOADER     PAUSE
+//#define MAGIC_KEY_LOCK           CAPS
+//#define MAGIC_KEY_EEPROM         E
+//#define MAGIC_KEY_NKRO           N
+//#define MAGIC_KEY_SLEEP_LED      Z
+
+/*
+ * 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 NO_ACTION_MACRO
+//#define NO_ACTION_FUNCTION
+
+/*
+ * MIDI options
+ */
+
+/* Prevent use of disabled MIDI features in the keymap */
+//#define MIDI_ENABLE_STRICT 1
+
+/* enable basic MIDI features:
+   - MIDI notes can be sent when in Music mode is on
+*/
+//#define MIDI_BASIC
+
+/* enable advanced MIDI features:
+   - MIDI notes can be added to the keymap
+   - Octave shift and transpose
+   - Virtual sustain, portamento, and modulation wheel
+   - etc.
+*/
+//#define MIDI_ADVANCED
+
+/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
+//#define MIDI_TONE_KEYCODE_OCTAVES 1
diff --git a/keyboards/boardsource/4x12/info.json b/keyboards/boardsource/4x12/info.json
new file mode 100644
index 0000000000..d5f40fd3b2
--- /dev/null
+++ b/keyboards/boardsource/4x12/info.json
@@ -0,0 +1,64 @@
+{
+    "keyboard_name": "Boardsource 4x12",
+    "url": "https://boardsource.xyz",
+    "maintainer": "Boardsource",
+    "width": 12,
+    "height": 4,
+    "layouts": {
+        "LAYOUT_ortho_4x12": {
+            "layout": [
+                { "label": "K01", "x": 0, "y": 0 },
+                { "label": "K02", "x": 1, "y": 0 },
+                { "label": "K03", "x": 2, "y": 0 },
+                { "label": "K04", "x": 3, "y": 0 },
+                { "label": "K05", "x": 4, "y": 0 },
+                { "label": "K06", "x": 5, "y": 0 },
+                { "label": "K07", "x": 6, "y": 0 },
+                { "label": "K08", "x": 7, "y": 0 },
+                { "label": "K09", "x": 8, "y": 0 },
+                { "label": "K010", "x": 9, "y": 0 },
+                { "label": "K011", "x": 10, "y": 0 },
+                { "label": "K012", "x": 11, "y": 0 },
+
+                { "label": "K11", "x": 0, "y": 1 },
+                { "label": "K12", "x": 1, "y": 1 },
+                { "label": "K13", "x": 2, "y": 1 },
+                { "label": "K14", "x": 3, "y": 1 },
+                { "label": "K15", "x": 4, "y": 1 },
+                { "label": "K16", "x": 5, "y": 1 },
+                { "label": "K17", "x": 6, "y": 1 },
+                { "label": "K18", "x": 7, "y": 1 },
+                { "label": "K19", "x": 8, "y": 1 },
+                { "label": "K110", "x": 9, "y": 1 },
+                { "label": "K111", "x": 10, "y": 1 },
+                { "label": "K112", "x": 11, "y": 1 },
+
+                { "label": "K21", "x": 0, "y": 2 },
+                { "label": "K22", "x": 1, "y": 2 },
+                { "label": "K23", "x": 2, "y": 2 },
+                { "label": "K24", "x": 3, "y": 2 },
+                { "label": "K25", "x": 4, "y": 2 },
+                { "label": "K26", "x": 5, "y": 2 },
+                { "label": "K27", "x": 6, "y": 2 },
+                { "label": "K28", "x": 7, "y": 2 },
+                { "label": "K29", "x": 8, "y": 2 },
+                { "label": "K210", "x": 9, "y": 2 },
+                { "label": "K211", "x": 10, "y": 2 },
+                { "label": "K212", "x": 11, "y": 2 },
+
+                { "label": "K31", "x": 0, "y": 3 },
+                { "label": "K32", "x": 1, "y": 3 },
+                { "label": "K33", "x": 2, "y": 3 },
+                { "label": "K34", "x": 3, "y": 3 },
+                { "label": "K35", "x": 4, "y": 3 },
+                { "label": "K36", "x": 5, "y": 3 },
+                { "label": "K37", "x": 6, "y": 3 },
+                { "label": "K38", "x": 7, "y": 3 },
+                { "label": "K39", "x": 8, "y": 3 },
+                { "label": "K310", "x": 9, "y": 3 },
+                { "label": "K311", "x": 10, "y": 3 },
+                { "label": "K312", "x": 11, "y": 3 }
+            ]
+        }
+    }
+}
diff --git a/keyboards/boardsource/4x12/keymaps/default/keymap.c b/keyboards/boardsource/4x12/keymaps/default/keymap.c
new file mode 100644
index 0000000000..d9a0c47a6b
--- /dev/null
+++ b/keyboards/boardsource/4x12/keymaps/default/keymap.c
@@ -0,0 +1,36 @@
+#include QMK_KEYBOARD_H
+
+enum layers {
+    _MAIN,
+    _RAISE,
+    _LOWER,
+};
+
+// Readability keycodes
+#define LOWER   MO(_LOWER)
+#define RAISE   MO(_RAISE)
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+  [_MAIN] = LAYOUT_ortho_4x12(
+    KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC,
+    KC_ESC,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,
+    KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT ,
+    KC_PIPE, KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT
+  ),
+
+  [_RAISE] = LAYOUT_ortho_4x12(
+  KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR,    KC_ASTR,    KC_LPRN, KC_RPRN, KC_BSPC,
+  KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS,    KC_PLUS,    KC_LCBR, KC_RCBR, KC_PIPE,
+  _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  S(KC_NUHS), S(KC_NUBS), KC_HOME, KC_END,  _______,
+  RESET,   _______, _______, _______, _______, _______, _______, _______,    KC_MNXT,    KC_VOLD, KC_VOLU, KC_MPLY
+  ),
+
+  [_LOWER] = LAYOUT_ortho_4x12(
+ KC_GRV,  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_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS,
+ _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
+  )
+
+};
diff --git a/keyboards/boardsource/4x12/readme.md b/keyboards/boardsource/4x12/readme.md
new file mode 100644
index 0000000000..17cf01ed02
--- /dev/null
+++ b/keyboards/boardsource/4x12/readme.md
@@ -0,0 +1,12 @@
+# 4x12
+![boardsource 4x12](https://i.imgur.com/rVtAEq5.jpg)
+
+* Keyboard Maintainer: [Boardsource](https://github.com/daysgobye) 
+* Hardware Supported: 4x12 v1
+* Hardware Availability: this keyboard is available from the [Boardsource store](https://boardsource.xyz/store/5ecb7dad86879c9a0c22db32)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make boardsource/4x12: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).
\ No newline at end of file
diff --git a/keyboards/boardsource/4x12/rules.mk b/keyboards/boardsource/4x12/rules.mk
new file mode 100644
index 0000000000..0999b9d62b
--- /dev/null
+++ b/keyboards/boardsource/4x12/rules.mk
@@ -0,0 +1,32 @@
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+#   Teensy       halfkay
+#   Pro Micro    caterina
+#   Atmel DFU    atmel-dfu
+#   LUFA DFU     lufa-dfu
+#   QMK DFU      qmk-dfu
+#   ATmega32A    bootloadHID
+#   ATmega328P   USBasp
+BOOTLOADER = caterina
+
+# Build Options
+#   change yes to no to disable
+#
+BOOTMAGIC_ENABLE = lite      # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = yes       # Mouse keys
+EXTRAKEY_ENABLE = yes       # Audio control and System control
+CONSOLE_ENABLE = yes        # Console for debug
+COMMAND_ENABLE = yes        # 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
+BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
+MIDI_ENABLE = no            # MIDI support
+UNICODE_ENABLE = no         # Unicode
+BLUETOOTH_ENABLE = no       # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE = no           # Audio output on port C6
+FAUXCLICKY_ENABLE = no      # Use buzzer to emulate clicky switches
+LAYOUTS = ortho_4x12