From f4f679779e1404d9dc34c64823b9eb993bfa7ab3 Mon Sep 17 00:00:00 2001
From: GG <72414103+spbgzh@users.noreply.github.com>
Date: Thu, 19 Aug 2021 21:17:54 +0300
Subject: [Keyboard] Add Mammoth20x (#14014)
---
keyboards/wuque/mammoth20x/config.h | 54 ++++++++++++++++++++
keyboards/wuque/mammoth20x/info.json | 41 +++++++++++++++
.../wuque/mammoth20x/keymaps/default/keymap.c | 36 +++++++++++++
.../wuque/mammoth20x/keymaps/default/readme.md | 1 +
keyboards/wuque/mammoth20x/keymaps/via/keymap.c | 52 +++++++++++++++++++
keyboards/wuque/mammoth20x/keymaps/via/readme.md | 1 +
keyboards/wuque/mammoth20x/keymaps/via/rules.mk | 2 +
keyboards/wuque/mammoth20x/mammoth20x.c | 59 ++++++++++++++++++++++
keyboards/wuque/mammoth20x/mammoth20x.h | 36 +++++++++++++
keyboards/wuque/mammoth20x/readme.md | 22 ++++++++
keyboards/wuque/mammoth20x/rules.mk | 24 +++++++++
11 files changed, 328 insertions(+)
create mode 100644 keyboards/wuque/mammoth20x/config.h
create mode 100644 keyboards/wuque/mammoth20x/info.json
create mode 100644 keyboards/wuque/mammoth20x/keymaps/default/keymap.c
create mode 100644 keyboards/wuque/mammoth20x/keymaps/default/readme.md
create mode 100644 keyboards/wuque/mammoth20x/keymaps/via/keymap.c
create mode 100644 keyboards/wuque/mammoth20x/keymaps/via/readme.md
create mode 100644 keyboards/wuque/mammoth20x/keymaps/via/rules.mk
create mode 100644 keyboards/wuque/mammoth20x/mammoth20x.c
create mode 100644 keyboards/wuque/mammoth20x/mammoth20x.h
create mode 100644 keyboards/wuque/mammoth20x/readme.md
create mode 100644 keyboards/wuque/mammoth20x/rules.mk
(limited to 'keyboards/wuque/mammoth20x')
diff --git a/keyboards/wuque/mammoth20x/config.h b/keyboards/wuque/mammoth20x/config.h
new file mode 100644
index 0000000000..a29ab2cb21
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/config.h
@@ -0,0 +1,54 @@
+/*
+Copyright 2021 wuquestudio
+
+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 .
+*/
+
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0xB06B
+#define PRODUCT_ID 0x0005
+#define DEVICE_VER 0x0001
+#define MANUFACTURER wuque studio
+#define PRODUCT mammoth20x
+
+/* key matrix size */
+#define MATRIX_ROWS 6
+#define MATRIX_COLS 4
+
+#define MATRIX_ROW_PINS { D5, F0, F1, F4, F5, F6 }
+#define MATRIX_COL_PINS { B0, B1, E6, F7 }
+
+#define DIODE_DIRECTION COL2ROW
+
+/* Set 0 if debouncing isn't 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
+
+/* Enable encoder */
+#define ENCODERS_PAD_A { D3 }
+#define ENCODERS_PAD_B { D2 }
+
+#define ENCODERS 1
+// Note: array is { col, row )
+#define ENCODERS_CW_KEY { { 3, 2 } }
+#define ENCODERS_CCW_KEY { { 3, 4 } }
diff --git a/keyboards/wuque/mammoth20x/info.json b/keyboards/wuque/mammoth20x/info.json
new file mode 100644
index 0000000000..c889aa36b0
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/info.json
@@ -0,0 +1,41 @@
+{
+ "keyboard_name": "mammoth20x",
+ "url": "https://shop.wuquestudio.com/",
+ "maintainer": "spbgzh",
+ "width": 4,
+ "height": 6,
+ "layouts": {
+ "LAYOUT_default": {
+ "layout": [
+ { "label": "Esc", "x": 0, "y": 0 },
+ { "label": "Pause", "x": 1, "y": 0 },
+ { "label": "Delete", "x": 2, "y": 0 },
+ { "label": "E", "x": 3.5, "y": 0 },
+
+ { "label": "Num", "x": 0, "y": 1 },
+ { "label": "/", "x": 1, "y": 1 },
+ { "label": "*", "x": 2, "y": 1 },
+ { "label": "-", "x": 3, "y": 1 },
+
+ { "label": "7", "x": 0, "y": 2 },
+ { "label": "8", "x": 1, "y": 2 },
+ { "label": "9", "x": 2, "y": 2 },
+ { "label": "LeftEncode", "x": 3, "y": 0, "w": 0.5 },
+
+ { "label": "4", "x": 0, "y": 3 },
+ { "label": "5", "x": 1, "y": 3 },
+ { "label": "6", "x": 2, "y": 3 },
+ { "label": "+", "x": 3, "y": 2, "h": 2 },
+
+ { "label": "1", "x": 0, "y": 4 },
+ { "label": "2", "x": 1, "y": 4 },
+ { "label": "3", "x": 2, "y": 4 },
+ { "label": "RightEncode", "x": 4.5, "y": 0, "w" : 0.25 },
+
+ { "label": "0", "x": 0, "y": 5, "w": 2 },
+ { "label": ".", "x": 2, "y": 5 },
+ { "label": "Enter", "x": 3, "y": 4,"h":2 }
+ ]
+ }
+ }
+}
diff --git a/keyboards/wuque/mammoth20x/keymaps/default/keymap.c b/keyboards/wuque/mammoth20x/keymaps/default/keymap.c
new file mode 100644
index 0000000000..77946f373d
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/keymaps/default/keymap.c
@@ -0,0 +1,36 @@
+/* Copyright 2021 wuquestudio
+ *
+ * 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 .
+ */
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT_default(
+ KC_ESC, KC_PAUS, KC_DEL, KC_MUTE,
+ KC_LNUM, KC_PSLS, KC_PAST, KC_PMNS,
+ KC_P7, KC_P8, KC_P9, KC_VOLU,
+ KC_P4, KC_P5, KC_P6, KC_PPLS,
+ KC_P1, KC_P2, KC_P3, KC_VOLD,
+ KC_P0, KC_PDOT, KC_PENT
+ ),
+ [1] = LAYOUT_default(
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______
+ ),
+};
diff --git a/keyboards/wuque/mammoth20x/keymaps/default/readme.md b/keyboards/wuque/mammoth20x/keymaps/default/readme.md
new file mode 100644
index 0000000000..5bad9b4558
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/keymaps/default/readme.md
@@ -0,0 +1 @@
+# The default keymap for mammoth20x
diff --git a/keyboards/wuque/mammoth20x/keymaps/via/keymap.c b/keyboards/wuque/mammoth20x/keymaps/via/keymap.c
new file mode 100644
index 0000000000..c8c434a60b
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/keymaps/via/keymap.c
@@ -0,0 +1,52 @@
+/* Copyright 2021 wuquestudio
+ *
+ * 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 .
+ */
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT_default(
+ KC_ESC, KC_PAUS, KC_DEL, KC_MUTE,
+ KC_LNUM, KC_PSLS, KC_PAST, KC_PMNS,
+ KC_P7, KC_P8, KC_P9, KC_VOLU,
+ KC_P4, KC_P5, KC_P6, KC_PPLS,
+ KC_P1, KC_P2, KC_P3, KC_VOLD,
+ KC_P0, KC_PDOT, KC_PENT
+ ),
+ [1] = LAYOUT_default(
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______
+ ),
+ [2] = LAYOUT_default(
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______
+ ),
+ [3] = LAYOUT_default(
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______, _______,
+ _______, _______, _______
+ ),
+};
diff --git a/keyboards/wuque/mammoth20x/keymaps/via/readme.md b/keyboards/wuque/mammoth20x/keymaps/via/readme.md
new file mode 100644
index 0000000000..fcd4ba857f
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/keymaps/via/readme.md
@@ -0,0 +1 @@
+# The via keymap for mammoth20x
diff --git a/keyboards/wuque/mammoth20x/keymaps/via/rules.mk b/keyboards/wuque/mammoth20x/keymaps/via/rules.mk
new file mode 100644
index 0000000000..36b7ba9cbc
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/keymaps/via/rules.mk
@@ -0,0 +1,2 @@
+VIA_ENABLE = yes
+LTO_ENABLE = yes
diff --git a/keyboards/wuque/mammoth20x/mammoth20x.c b/keyboards/wuque/mammoth20x/mammoth20x.c
new file mode 100644
index 0000000000..da6ccecd3b
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/mammoth20x.c
@@ -0,0 +1,59 @@
+/* Copyright 2021 wuquestudio
+ *
+ * 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 .
+ */
+
+#include "mammoth20x.h"
+
+
+static uint8_t encoder_state[ENCODERS] = {0};
+static keypos_t encoder_cw[ENCODERS] = ENCODERS_CW_KEY;
+static keypos_t encoder_ccw[ENCODERS] = ENCODERS_CCW_KEY;
+
+void encoder_action_unregister(void)
+{
+ for (int index = 0; index < ENCODERS; ++index)
+ {
+ if (encoder_state[index])
+ {
+ keyevent_t encoder_event = (keyevent_t){
+ .key = encoder_state[index] >> 1 ? encoder_cw[index] : encoder_ccw[index],
+ .pressed = false,
+ .time = (timer_read() | 1)};
+ encoder_state[index] = 0;
+ action_exec(encoder_event);
+ }
+ }
+}
+void encoder_action_register(uint8_t index, bool clockwise)
+{
+ keyevent_t encoder_event = (keyevent_t){
+ .key = clockwise ? encoder_cw[index] : encoder_ccw[index],
+ .pressed = true,
+ .time = (timer_read() | 1)};
+ encoder_state[index] = (clockwise ^ 1) | (clockwise << 1);
+ action_exec(encoder_event);
+}
+
+void matrix_scan_kb(void)
+{
+ encoder_action_unregister();
+ matrix_scan_user();
+}
+
+bool encoder_update_kb(uint8_t index, bool clockwise)
+{
+ encoder_action_register(index, clockwise);
+ return true;
+};
diff --git a/keyboards/wuque/mammoth20x/mammoth20x.h b/keyboards/wuque/mammoth20x/mammoth20x.h
new file mode 100644
index 0000000000..cd0d8d4789
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/mammoth20x.h
@@ -0,0 +1,36 @@
+/* Copyright 2021 wuquestudio
+ *
+ * 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 .
+ */
+
+#pragma once
+
+#include "quantum.h"
+
+#define LAYOUT_default( \
+ K00, K01, K02, K03, \
+ K10, K11, K12, K13, \
+ K20, K21, K22, K23, \
+ K30, K31, K32, K33, \
+ K40, K41, K42, K43, \
+ K50, K52, K53 \
+) { \
+ { K00, K01, K02, K03 }, \
+ { K10, K11, K12, K13 }, \
+ { K20, K21, K22, K23 }, \
+ { K30, K31, K32, K33 }, \
+ { K40, K41, K42, K43 }, \
+ { K50, KC_NO, K52, K53 }, \
+}
+
diff --git a/keyboards/wuque/mammoth20x/readme.md b/keyboards/wuque/mammoth20x/readme.md
new file mode 100644
index 0000000000..4b731a159c
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/readme.md
@@ -0,0 +1,22 @@
+# mammoth20x
+
+More Info at[wuquestudio](https://shop.wuquestudio.com/).
+
+* Keyboard Maintainer: [spbgzh](https://github.com/spbgzh)
+* Hardware Supported: mammoth20x Standard
+* Hardware Availability: [mammoth20x](https://shop.wuquestudio.com/)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make wuque/mammoth20x:default
+
+Flashing example for this keyboard:
+
+ make wuque/mammoth20x:default:flash
+
+To reset the board into bootloader mode, do one of the following:
+
+* Tap the Reset switch mounted on the PCB
+* Hold the Esc key while connecting the USB cable (also erases persistent settings)
+
+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/wuque/mammoth20x/rules.mk b/keyboards/wuque/mammoth20x/rules.mk
new file mode 100644
index 0000000000..8431b98173
--- /dev/null
+++ b/keyboards/wuque/mammoth20x/rules.mk
@@ -0,0 +1,24 @@
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+BOOTLOADER = atmel-dfu
+
+# 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 = 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 = yes # USB Nkey Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
+BLUETOOTH_ENABLE = no # Enable Bluetooth
+AUDIO_ENABLE = no # Audio output
+ENCODER_ENABLE = yes # Enable Encoder
+
--
cgit v1.2.3