summaryrefslogtreecommitdiff
path: root/keyboards/zsa/moonlander
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/zsa/moonlander')
-rw-r--r--keyboards/zsa/moonlander/config.h147
-rw-r--r--keyboards/zsa/moonlander/halconf.h22
-rw-r--r--keyboards/zsa/moonlander/info.json114
-rw-r--r--keyboards/zsa/moonlander/keymaps/default/config.h21
-rw-r--r--keyboards/zsa/moonlander/keymaps/default/keymap.c73
-rw-r--r--keyboards/zsa/moonlander/keymaps/via/keymap.c126
-rw-r--r--keyboards/zsa/moonlander/keymaps/via/readme.md7
-rw-r--r--keyboards/zsa/moonlander/keymaps/via/rules.mk1
-rw-r--r--keyboards/zsa/moonlander/matrix.c233
-rw-r--r--keyboards/zsa/moonlander/mcuconf.h39
-rw-r--r--keyboards/zsa/moonlander/moonlander.c469
-rw-r--r--keyboards/zsa/moonlander/moonlander.h58
-rw-r--r--keyboards/zsa/moonlander/readme.md58
-rw-r--r--keyboards/zsa/moonlander/rules.mk22
14 files changed, 1390 insertions, 0 deletions
diff --git a/keyboards/zsa/moonlander/config.h b/keyboards/zsa/moonlander/config.h
new file mode 100644
index 0000000000..76e9906d3d
--- /dev/null
+++ b/keyboards/zsa/moonlander/config.h
@@ -0,0 +1,147 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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 WEBUSB_LANDING_PAGE_URL u8"configure.ergodox-ez.com"
+
+/* key matrix size */
+#define MATRIX_ROWS 12
+#define MATRIX_COLS 7
+
+/* PCB default pin-out */
+// #define MATRIX_ROW_PINS { B10, B11, B12, B13, B14, B15 }
+// #define MATRIX_COL_PINS { A0, A1, A2, A3, A6, A7, B0 }
+
+// #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 }
+// #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 }
+
+// #define MCP23_LED_R GPB7
+// #define MCP23_LED_G GPB6
+// #define MCP23_LED_B GPA7
+
+#define EEPROM_I2C_24LC128
+
+// Not needed, is default address:
+// #define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10100000
+
+/* COL2ROW or ROW2COL */
+#define DIODE_DIRECTION ROW2COL
+
+/* 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
+
+/*
+ * 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 IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
+#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC
+
+#define DRIVER_1_LED_TOTAL 36
+#define DRIVER_2_LED_TOTAL 36
+#define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
+#define RGB_MATRIX_CENTER { 120, 36 }
+#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175
+#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
+#define RGB_MATRIX_KEYPRESSES
+#define RGB_MATRIX_SLEEP
+// RGB Matrix Animation modes. Explicitly enabled
+// For full list of effects, see:
+// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
+# define ENABLE_RGB_MATRIX_ALPHAS_MODS
+# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
+# define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
+# define ENABLE_RGB_MATRIX_BREATHING
+# define ENABLE_RGB_MATRIX_BAND_SAT
+# define ENABLE_RGB_MATRIX_BAND_VAL
+# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
+# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
+# define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
+# define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
+# define ENABLE_RGB_MATRIX_CYCLE_ALL
+# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
+# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
+# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
+# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN
+# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
+# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
+# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL
+# define ENABLE_RGB_MATRIX_DUAL_BEACON
+# define ENABLE_RGB_MATRIX_RAINBOW_BEACON
+# define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
+# define ENABLE_RGB_MATRIX_RAINDROPS
+# define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
+# define ENABLE_RGB_MATRIX_HUE_BREATHING
+# define ENABLE_RGB_MATRIX_HUE_PENDULUM
+# define ENABLE_RGB_MATRIX_HUE_WAVE
+# define ENABLE_RGB_MATRIX_PIXEL_RAIN
+# define ENABLE_RGB_MATRIX_PIXEL_FLOW
+# define ENABLE_RGB_MATRIX_PIXEL_FRACTAL
+// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined
+# define ENABLE_RGB_MATRIX_TYPING_HEATMAP
+# define ENABLE_RGB_MATRIX_DIGITAL_RAIN
+// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
+# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
+# define ENABLE_RGB_MATRIX_SPLASH
+# define ENABLE_RGB_MATRIX_MULTISPLASH
+# define ENABLE_RGB_MATRIX_SOLID_SPLASH
+# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
+
+// #define RGB_MATRIX_LED_PROCESS_LIMIT 5
+// #define RGB_MATRIX_LED_FLUSH_LIMIT 26
+
+#define MOUSEKEY_INTERVAL 20
+#define MOUSEKEY_DELAY 0
+#define MOUSEKEY_TIME_TO_MAX 60
+#define MOUSEKEY_MAX_SPEED 7
+#define MOUSEKEY_WHEEL_DELAY 400
+#define MOUSEKEY_WHEEL_INTERVAL MOUSEKEY_INTERVAL
+#define MOUSEKEY_WHEEL_MAX_SPEED MOUSEKEY_MAX_SPEED
+#define MOUSEKEY_WHEEL_TIME_TO_MAX MOUSEKEY_TIME_TO_MAX
+
+#define MUSIC_MAP
+
+#define FIRMWARE_VERSION_SIZE 17
+#define DYNAMIC_KEYMAP_EEPROM_ADDR (EECONFIG_SIZE + FIRMWARE_VERSION_SIZE)
+
+#define AUDIO_PIN A5
+#define AUDIO_PIN_ALT A4
+#define AUDIO_PIN_ALT_AS_NEGATIVE
diff --git a/keyboards/zsa/moonlander/halconf.h b/keyboards/zsa/moonlander/halconf.h
new file mode 100644
index 0000000000..46b53b1a7f
--- /dev/null
+++ b/keyboards/zsa/moonlander/halconf.h
@@ -0,0 +1,22 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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 <https://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#define HAL_USE_I2C TRUE
+#define HAL_USE_GPT TRUE
+#define HAL_USE_DAC TRUE
+
+#include_next <halconf.h>
diff --git a/keyboards/zsa/moonlander/info.json b/keyboards/zsa/moonlander/info.json
new file mode 100644
index 0000000000..1a7982ed57
--- /dev/null
+++ b/keyboards/zsa/moonlander/info.json
@@ -0,0 +1,114 @@
+{
+ "keyboard_name": "Moonlander Mark I",
+ "manufacturer": "ZSA Technology Labs",
+ "url": "zsa.io/moonlander",
+ "maintainer": "ZSA via Drashna",
+ "usb": {
+ "vid": "0x3297",
+ "pid": "0x1969",
+ "device_version": "0.0.1"
+ },
+ "dynamic_keymap": {
+ "layer_count": 8
+ },
+ "eeprom": {
+ "driver": "i2c"
+ },
+ "rgb_matrix": {
+ "driver": "is31fl3731"
+ },
+ "processor": "STM32F303",
+ "bootloader": "stm32-dfu",
+ "layout_aliases": {
+ "LAYOUT_moonlander": "LAYOUT"
+ },
+ "layouts": {
+ "LAYOUT": {
+ "layout": [
+ {"matrix": [0, 0], "x": 0, "y": 0.375},
+ {"matrix": [0, 1], "x": 1, "y": 0.375},
+ {"matrix": [0, 2], "x": 2, "y": 0.125},
+ {"matrix": [0, 3], "x": 3, "y": 0},
+ {"matrix": [0, 4], "x": 4, "y": 0.125},
+ {"matrix": [0, 5], "x": 5, "y": 0.25},
+ {"matrix": [0, 6], "x": 6, "y": 0.25},
+
+ {"matrix": [6, 0], "x": 10, "y": 0.25},
+ {"matrix": [6, 1], "x": 11, "y": 0.25},
+ {"matrix": [6, 2], "x": 12, "y": 0.125},
+ {"matrix": [6, 3], "x": 13, "y": 0},
+ {"matrix": [6, 4], "x": 14, "y": 0.125},
+ {"matrix": [6, 5], "x": 15, "y": 0.375},
+ {"matrix": [6, 6], "x": 16, "y": 0.375},
+
+ {"matrix": [1, 0], "x": 0, "y": 1.375},
+ {"matrix": [1, 1], "x": 1, "y": 1.375},
+ {"matrix": [1, 2], "x": 2, "y": 1.125},
+ {"matrix": [1, 3], "x": 3, "y": 1},
+ {"matrix": [1, 4], "x": 4, "y": 1.125},
+ {"matrix": [1, 5], "x": 5, "y": 1.25},
+ {"matrix": [1, 6], "x": 6, "y": 1.25},
+
+ {"matrix": [7, 0], "x": 10, "y": 1.25},
+ {"matrix": [7, 1], "x": 11, "y": 1.25},
+ {"matrix": [7, 2], "x": 12, "y": 1.125},
+ {"matrix": [7, 3], "x": 13, "y": 1},
+ {"matrix": [7, 4], "x": 14, "y": 1.125},
+ {"matrix": [7, 5], "x": 15, "y": 1.375},
+ {"matrix": [7, 6], "x": 16, "y": 1.375},
+
+ {"matrix": [2, 0], "x": 0, "y": 2.375},
+ {"matrix": [2, 1], "x": 1, "y": 2.375},
+ {"matrix": [2, 2], "x": 2, "y": 2.125},
+ {"matrix": [2, 3], "x": 3, "y": 2},
+ {"matrix": [2, 4], "x": 4, "y": 2.125},
+ {"matrix": [2, 5], "x": 5, "y": 2.25},
+ {"matrix": [2, 6], "x": 6, "y": 2.25},
+
+ {"matrix": [8, 0], "x": 10, "y": 2.25},
+ {"matrix": [8, 1], "x": 11, "y": 2.25},
+ {"matrix": [8, 2], "x": 12, "y": 2.125},
+ {"matrix": [8, 3], "x": 13, "y": 2},
+ {"matrix": [8, 4], "x": 14, "y": 2.125},
+ {"matrix": [8, 5], "x": 15, "y": 2.375},
+ {"matrix": [8, 6], "x": 16, "y": 2.375},
+
+ {"matrix": [3, 0], "x": 0, "y": 3.375},
+ {"matrix": [3, 1], "x": 1, "y": 3.375},
+ {"matrix": [3, 2], "x": 2, "y": 3.125},
+ {"matrix": [3, 3], "x": 3, "y": 3},
+ {"matrix": [3, 4], "x": 4, "y": 3.125},
+ {"matrix": [3, 5], "x": 5, "y": 3.25},
+
+ {"matrix": [9, 1], "x": 11, "y": 3.25},
+ {"matrix": [9, 2], "x": 12, "y": 3.125},
+ {"matrix": [9, 3], "x": 13, "y": 3},
+ {"matrix": [9, 4], "x": 14, "y": 3.125},
+ {"matrix": [9, 5], "x": 15, "y": 3.375},
+ {"matrix": [9, 6], "x": 16, "y": 3.375},
+
+ {"matrix": [4, 0], "x": 0, "y": 4.375},
+ {"matrix": [4, 1], "x": 1, "y": 4.375},
+ {"matrix": [4, 2], "x": 2, "y": 4.125},
+ {"matrix": [4, 3], "x": 3, "y": 4},
+ {"matrix": [4, 4], "x": 4, "y": 4.125},
+ {"matrix": [5, 3], "x": 5, "y": 4.5, "w": 2},
+
+ {"matrix": [11, 3], "x": 10, "y": 4.5, "w": 2},
+ {"matrix": [10, 2], "x": 12, "y": 4.125},
+ {"matrix": [10, 3], "x": 13, "y": 4},
+ {"matrix": [10, 4], "x": 14, "y": 4.125},
+ {"matrix": [10, 5], "x": 15, "y": 4.375},
+ {"matrix": [10, 6], "x": 16, "y": 4.375},
+
+ {"matrix": [5, 0], "x": 5, "y": 5.5, "h": 1.5},
+ {"matrix": [5, 1], "x": 6, "y": 5.5, "h": 1.5},
+ {"matrix": [5, 2], "x": 7, "y": 5.5, "h": 1.5},
+
+ {"matrix": [11, 4], "x": 9, "y": 5.5, "h": 1.5},
+ {"matrix": [11, 5], "x": 10, "y": 5.5, "h": 1.5},
+ {"matrix": [11, 6], "x": 11, "y": 5.5, "h": 1.5}
+ ]
+ }
+ }
+}
diff --git a/keyboards/zsa/moonlander/keymaps/default/config.h b/keyboards/zsa/moonlander/keymaps/default/config.h
new file mode 100644
index 0000000000..83ea2a1b58
--- /dev/null
+++ b/keyboards/zsa/moonlander/keymaps/default/config.h
@@ -0,0 +1,21 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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 ORYX_CONFIGURATOR
diff --git a/keyboards/zsa/moonlander/keymaps/default/keymap.c b/keyboards/zsa/moonlander/keymaps/default/keymap.c
new file mode 100644
index 0000000000..ad7705eff8
--- /dev/null
+++ b/keyboards/zsa/moonlander/keymaps/default/keymap.c
@@ -0,0 +1,73 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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
+#include "version.h"
+
+enum layers {
+ BASE, // default layer
+ SYMB, // symbols
+ MDIA, // media keys
+};
+
+enum custom_keycodes {
+ VRSN = SAFE_RANGE,
+};
+
+// clang-format off
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [BASE] = LAYOUT(
+ KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
+ KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
+ KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_HYPR, KC_MEH, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), LGUI_T(KC_QUOT),
+ KC_LSFT, LCTL_T(KC_Z),KC_X,KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, RCTL_T(KC_SLSH), KC_RSFT,
+ LT(SYMB,KC_GRV),WEBUSB_PAIR,A(KC_LSFT),KC_LEFT, KC_RGHT, LALT_T(KC_APP), RCTL_T(KC_ESC), KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, MO(SYMB),
+ KC_SPC, KC_BSPC, KC_LGUI, KC_LALT, KC_TAB, KC_ENT
+ ),
+
+ [SYMB] = LAYOUT(
+ VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
+ _______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, _______, _______, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
+ _______, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, _______, _______, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, _______,
+ _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, _______,
+ EE_CLR, _______, _______, _______, _______, RGB_VAI, RGB_TOG, _______, KC_DOT, KC_0, KC_EQL, _______,
+ RGB_HUD, RGB_VAD, RGB_HUI, TOGGLE_LAYER_COLOR,_______, _______
+ ),
+
+ [MDIA] = LAYOUT(
+ LED_LEVEL,_______,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT,
+ _______, _______, _______, KC_MS_U, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY,
+ _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, _______, _______,
+ _______, _______, _______, KC_BTN1, KC_BTN2, _______, _______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______,
+ _______, _______, _______, _______, _______, _______
+ ),
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ if (record->event.pressed) {
+ switch (keycode) {
+ case VRSN:
+ SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/keyboards/zsa/moonlander/keymaps/via/keymap.c b/keyboards/zsa/moonlander/keymaps/via/keymap.c
new file mode 100644
index 0000000000..4b1e4c83e7
--- /dev/null
+++ b/keyboards/zsa/moonlander/keymaps/via/keymap.c
@@ -0,0 +1,126 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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
+#include "version.h"
+
+enum layers {
+ BASE, // default layer
+ SYMB, // symbols
+ MDIA, // media keys
+};
+
+// clang-format off
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [BASE] = LAYOUT(
+ KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
+ KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
+ KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_HYPR, KC_MEH, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), LGUI_T(KC_QUOT),
+ KC_LSFT, LCTL_T(KC_Z),KC_X,KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, RCTL_T(KC_SLSH), KC_RSFT,
+ LT(SYMB,KC_GRV),WEBUSB_PAIR,A(KC_LSFT),KC_LEFT, KC_RGHT, LALT_T(KC_APP), RCTL_T(KC_ESC), KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, MO(SYMB),
+ KC_SPC, KC_BSPC, KC_LGUI, KC_LALT, KC_TAB, KC_ENT
+ ),
+
+ [SYMB] = LAYOUT(
+ QK_KB_0, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
+ _______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, _______, _______, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
+ _______, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, _______, _______, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, _______,
+ _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, _______,
+ _______, _______, _______, _______, _______, RGB_VAI, RGB_TOG, _______, KC_DOT, KC_0, KC_EQL, _______,
+ RGB_HUD, RGB_VAD, RGB_HUI, _______, _______, _______
+ ),
+
+ [MDIA] = LAYOUT(
+ QK_KB_1, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT,
+ _______, _______, _______, KC_MS_U, _______, _______, _______, _______, _______, _______, _______, _______, _______, EE_CLR,
+ _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY,
+ _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, _______, _______,
+ _______, _______, _______, KC_BTN1, KC_BTN2, _______, _______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______,
+ _______, _______, _______, _______, _______, _______
+ ),
+ [3] = LAYOUT(
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______
+ ),
+ [4] = LAYOUT(
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______
+ ),
+ [5] = LAYOUT(
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______
+ ),
+ [6] = LAYOUT(
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______
+ ),
+ [7] = LAYOUT(
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+ _______, _______, _______, _______, _______, _______
+ ),
+};
+// clang-format on
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case QK_KB_0:
+ if (record->event.pressed) {
+ SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
+ }
+ return false;
+ case QK_KB_1:
+ if (record->event.pressed) {
+ keyboard_config.led_level ^= 1;
+ eeconfig_update_kb(keyboard_config.raw);
+ if (keyboard_config.led_level) {
+ layer_state_set_kb(layer_state);
+ } else {
+ ML_LED_1(false);
+ ML_LED_2(false);
+ ML_LED_3(false);
+ ML_LED_4(false);
+ ML_LED_5(false);
+ ML_LED_6(false);
+ }
+ }
+ break;
+ }
+ return true;
+}
diff --git a/keyboards/zsa/moonlander/keymaps/via/readme.md b/keyboards/zsa/moonlander/keymaps/via/readme.md
new file mode 100644
index 0000000000..8bede7bee3
--- /dev/null
+++ b/keyboards/zsa/moonlander/keymaps/via/readme.md
@@ -0,0 +1,7 @@
+# VIA Keymap for the Moonlander
+
+This is based on the default layout for the Moonlander keyboard from ZSA Techonology Labs.
+
+ZSA does not provide any support for VIA (the app or firmware feature). Any and all issues should be directed to [VIA](https://github.com/the-via).
+
+Initial flash and reflash may make the keyboard look like it has locked up. This is because it can take a while to load the EEPROM data (the keymap), and is halted by that process until it's finished.
diff --git a/keyboards/zsa/moonlander/keymaps/via/rules.mk b/keyboards/zsa/moonlander/keymaps/via/rules.mk
new file mode 100644
index 0000000000..1e5b99807c
--- /dev/null
+++ b/keyboards/zsa/moonlander/keymaps/via/rules.mk
@@ -0,0 +1 @@
+VIA_ENABLE = yes
diff --git a/keyboards/zsa/moonlander/matrix.c b/keyboards/zsa/moonlander/matrix.c
new file mode 100644
index 0000000000..36017fcd12
--- /dev/null
+++ b/keyboards/zsa/moonlander/matrix.c
@@ -0,0 +1,233 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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 "moonlander.h"
+#include "i2c_master.h"
+
+/*
+#define MATRIX_ROW_PINS { B10, B11, B12, B13, B14, B15 } outputs
+#define MATRIX_COL_PINS { A0, A1, A2, A3, A6, A7, B0 } inputs
+ */
+/* matrix state(1:on, 0:off) */
+extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
+extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
+static matrix_row_t raw_matrix_right[MATRIX_COLS];
+
+#define ROWS_PER_HAND (MATRIX_ROWS / 2)
+#ifndef MOONLANDER_I2C_TIMEOUT
+# define MOONLANDER_I2C_TIMEOUT 100
+#endif
+
+extern bool mcp23018_leds[3];
+extern bool is_launching;
+
+bool mcp23018_initd = false;
+static uint8_t mcp23018_reset_loop;
+
+uint8_t mcp23018_tx[3];
+uint8_t mcp23018_rx[1];
+
+void mcp23018_init(void) {
+ i2c_init();
+
+ // #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 } outputs
+ // #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 } inputs
+
+ mcp23018_tx[0] = 0x00; // IODIRA
+ mcp23018_tx[1] = 0b00000000; // A is output
+ mcp23018_tx[2] = 0b00111111; // B is inputs
+
+ if (MSG_OK != i2c_transmit(MCP23018_DEFAULT_ADDRESS << 1, mcp23018_tx, 3, MOONLANDER_I2C_TIMEOUT)) {
+ dprintf("error hori\n");
+ } else {
+ mcp23018_tx[0] = 0x0C; // GPPUA
+ mcp23018_tx[1] = 0b10000000; // A is not pulled-up
+ mcp23018_tx[2] = 0b11111111; // B is pulled-up
+
+ if (MSG_OK != i2c_transmit(MCP23018_DEFAULT_ADDRESS << 1, mcp23018_tx, 3, MOONLANDER_I2C_TIMEOUT)) {
+ dprintf("error hori\n");
+ } else {
+ mcp23018_initd = is_launching = true;
+ }
+ }
+}
+
+void matrix_init_custom(void) {
+ dprintf("matrix init\n");
+ // debug_matrix = true;
+ // outputs
+ setPinOutput(B10);
+ setPinOutput(B11);
+ setPinOutput(B12);
+ setPinOutput(B13);
+ setPinOutput(B14);
+ setPinOutput(B15);
+
+ // inputs
+ setPinInputLow(A0);
+ setPinInputLow(A1);
+ setPinInputLow(A2);
+ setPinInputLow(A3);
+ setPinInputLow(A6);
+ setPinInputLow(A7);
+ setPinInputLow(B0);
+
+ mcp23018_init();
+}
+
+bool matrix_scan_custom(matrix_row_t current_matrix[]) {
+ bool changed = false;
+
+ // Try to re-init right side
+ if (!mcp23018_initd) {
+ if (++mcp23018_reset_loop == 0) {
+ // if (++mcp23018_reset_loop >= 1300) {
+ // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans
+ // this will be approx bit more frequent than once per second
+ print("trying to reset mcp23018\n");
+ mcp23018_init();
+ if (!mcp23018_initd) {
+ print("right side not responding\n");
+ } else {
+ print("right side attached\n");
+#ifdef RGB_MATRIX_ENABLE
+ rgb_matrix_init();
+#endif
+ }
+ }
+ }
+
+ matrix_row_t data = 0;
+ // actual matrix
+ for (uint8_t row = 0; row <= ROWS_PER_HAND; row++) {
+ // strobe row
+ switch (row) {
+ case 0: writePinHigh(B10); break;
+ case 1: writePinHigh(B11); break;
+ case 2: writePinHigh(B12); break;
+ case 3: writePinHigh(B13); break;
+ case 4: writePinHigh(B14); break;
+ case 5: writePinHigh(B15); break;
+ case 6: break; // Left hand has 6 rows
+ }
+
+ // right side
+ if (mcp23018_initd) {
+ // #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 } outputs
+ // #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 } inputs
+
+ // select row
+ mcp23018_tx[0] = 0x12; // GPIOA
+ mcp23018_tx[1] = (0b01111111 & ~(1 << (row))) | ((uint8_t)!mcp23018_leds[2] << 7); // activate row
+ mcp23018_tx[2] = ((uint8_t)!mcp23018_leds[1] << 6) | ((uint8_t)!mcp23018_leds[0] << 7); // activate row
+
+ if (MSG_OK != i2c_transmit(MCP23018_DEFAULT_ADDRESS << 1, mcp23018_tx, 3, MOONLANDER_I2C_TIMEOUT)) {
+ dprintf("error hori\n");
+ mcp23018_initd = false;
+ }
+
+ // read col
+
+ mcp23018_tx[0] = 0x13; // GPIOB
+ if (MSG_OK != i2c_readReg(MCP23018_DEFAULT_ADDRESS << 1, mcp23018_tx[0], &mcp23018_rx[0], 1, MOONLANDER_I2C_TIMEOUT)) {
+ dprintf("error vert\n");
+ mcp23018_initd = false;
+ }
+
+ data = ~(mcp23018_rx[0] & 0b00111111);
+ // data = 0x01;
+ } else {
+ data = 0;
+ }
+
+ if (raw_matrix_right[row] != data) {
+ raw_matrix_right[row] = data;
+ changed = true;
+ }
+
+
+ // left side
+ if (row < ROWS_PER_HAND) {
+ // i2c comm incur enough wait time
+ if (!mcp23018_initd) {
+ // need wait to settle pin state
+ matrix_io_delay();
+ }
+ // read col data
+ data = (
+ (readPin(A0) << 0 ) |
+ (readPin(A1) << 1 ) |
+ (readPin(A2) << 2 ) |
+ (readPin(A3) << 3 ) |
+ (readPin(A6) << 4 ) |
+ (readPin(A7) << 5 ) |
+ (readPin(B0) << 6 )
+ );
+ // unstrobe row
+ switch (row) {
+ case 0: writePinLow(B10); break;
+ case 1: writePinLow(B11); break;
+ case 2: writePinLow(B12); break;
+ case 3: writePinLow(B13); break;
+ case 4: writePinLow(B14); break;
+ case 5: writePinLow(B15); break;
+ case 6: break;
+ }
+
+ if (current_matrix[row] != data) {
+ current_matrix[row] = data;
+ changed = true;
+ }
+ }
+ }
+ for (uint8_t row = 0; row < ROWS_PER_HAND; row++) {
+ current_matrix[11 - row] = 0;
+ for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+ current_matrix[11 - row] |= ((raw_matrix_right[6 - col] & (1 << row) ? 1 : 0) << col);
+ }
+ }
+ return changed;
+}
+
+// DO NOT REMOVE
+// Needed for proper wake/sleep
+void matrix_power_up(void) {
+ bool temp_launching = is_launching;
+
+ matrix_init_custom();
+
+ is_launching = temp_launching;
+ if (!is_launching) {
+ ML_LED_1(false);
+ ML_LED_2(false);
+ ML_LED_3(false);
+ ML_LED_4(false);
+ ML_LED_5(false);
+ ML_LED_6(false);
+ }
+
+ // initialize matrix state: all keys off
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ matrix[i] = 0;
+ }
+
+}
+
+bool is_transport_connected(void) {
+ return mcp23018_initd;
+} \ No newline at end of file
diff --git a/keyboards/zsa/moonlander/mcuconf.h b/keyboards/zsa/moonlander/mcuconf.h
new file mode 100644
index 0000000000..032c853f4e
--- /dev/null
+++ b/keyboards/zsa/moonlander/mcuconf.h
@@ -0,0 +1,39 @@
+/* Copyright 2021 QMK
+ *
+ * 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 3 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 <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include_next <mcuconf.h>
+
+// for i2c expander, and ISSI
+#undef STM32_I2C_USE_I2C1
+#define STM32_I2C_USE_I2C1 TRUE
+
+// for future hardwar
+#undef STM32_I2C_USE_I2C2
+#define STM32_I2C_USE_I2C2 TRUE
+
+// for audio
+#undef STM32_DAC_USE_DAC1_CH1
+#define STM32_DAC_USE_DAC1_CH1 TRUE
+#undef STM32_DAC_USE_DAC1_CH2
+#define STM32_DAC_USE_DAC1_CH2 TRUE
+#undef STM32_GPT_USE_TIM6
+#define STM32_GPT_USE_TIM6 TRUE
+#undef STM32_GPT_USE_TIM7
+#define STM32_GPT_USE_TIM7 TRUE
+#undef STM32_GPT_USE_TIM8
+#define STM32_GPT_USE_TIM8 TRUE
diff --git a/keyboards/zsa/moonlander/moonlander.c b/keyboards/zsa/moonlander/moonlander.c
new file mode 100644
index 0000000000..dad795d315
--- /dev/null
+++ b/keyboards/zsa/moonlander/moonlander.c
@@ -0,0 +1,469 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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 "moonlander.h"
+
+keyboard_config_t keyboard_config;
+
+bool mcp23018_leds[3] = {0, 0, 0};
+bool is_launching = false;
+
+#ifdef DYNAMIC_MACRO_ENABLE
+static bool is_dynamic_recording = false;
+
+void dynamic_macro_record_start_user(int8_t direction) { is_dynamic_recording = true; }
+
+void dynamic_macro_record_end_user(int8_t direction) {
+ is_dynamic_recording = false;
+ ML_LED_3(false);
+}
+#endif
+
+void moonlander_led_task(void) {
+ if (is_launching) {
+ ML_LED_1(false);
+ ML_LED_2(false);
+ ML_LED_3(false);
+ ML_LED_4(false);
+ ML_LED_5(false);
+ ML_LED_6(false);
+
+ ML_LED_1(true);
+ wait_ms(250);
+ ML_LED_2(true);
+ wait_ms(250);
+ ML_LED_3(true);
+ wait_ms(250);
+ ML_LED_4(true);
+ wait_ms(250);
+ ML_LED_5(true);
+ wait_ms(250);
+ ML_LED_6(true);
+ wait_ms(250);
+ ML_LED_1(false);
+ wait_ms(250);
+ ML_LED_2(false);
+ wait_ms(250);
+ ML_LED_3(false);
+ wait_ms(250);
+ ML_LED_4(false);
+ wait_ms(250);
+ ML_LED_5(false);
+ wait_ms(250);
+ ML_LED_6(false);
+ wait_ms(250);
+ is_launching = false;
+ layer_state_set_kb(layer_state);
+ }
+#ifdef DYNAMIC_MACRO_ENABLE
+ else if (is_dynamic_recording) {
+ ML_LED_3(true);
+ wait_ms(100);
+ ML_LED_3(false);
+ wait_ms(155);
+ }
+#endif
+#if !defined(MOONLANDER_USER_LEDS)
+ else {
+ layer_state_set_kb(layer_state);
+ }
+#endif
+}
+
+static THD_WORKING_AREA(waLEDThread, 128);
+static THD_FUNCTION(LEDThread, arg) {
+ (void)arg;
+ chRegSetThreadName("LEDThread");
+ while (true) {
+ moonlander_led_task();
+ }
+}
+
+void keyboard_pre_init_kb(void) {
+ setPinOutput(B5);
+ setPinOutput(B4);
+ setPinOutput(B3);
+
+ writePinLow(B5);
+ writePinLow(B4);
+ writePinLow(B3);
+
+ chThdCreateStatic(waLEDThread, sizeof(waLEDThread), NORMALPRIO - 16, LEDThread, NULL);
+
+ /* the array is initialized to 0, no need to re-set it here */
+ // mcp23018_leds[0] = 0; // blue
+ // mcp23018_leds[1] = 0; // green
+ // mcp23018_leds[2] = 0; // red
+
+ keyboard_pre_init_user();
+}
+
+#if !defined(MOONLANDER_USER_LEDS)
+layer_state_t layer_state_set_kb(layer_state_t state) {
+ state = layer_state_set_user(state);
+ if (is_launching || !keyboard_config.led_level) return state;
+ bool LED_1 = false;
+ bool LED_2 = false;
+ bool LED_3 = false;
+ bool LED_4 = false;
+ bool LED_5 = false;
+#if !defined(CAPS_LOCK_STATUS)
+ bool LED_6 = false;
+#endif
+
+ uint8_t layer = get_highest_layer(state);
+ switch (layer) {
+ case 1:
+ LED_1 = true;
+ LED_4 = true;
+ break;
+ case 2:
+ LED_2 = true;
+ LED_5 = true;
+ break;
+ case 3:
+ LED_3 = true;
+#if !defined(CAPS_LOCK_STATUS)
+ LED_6 = true;
+#endif
+ break;
+ case 4:
+ LED_4 = true;
+ break;
+ case 5:
+ LED_5 = true;
+ break;
+ case 6:
+#if !defined(CAPS_LOCK_STATUS)
+ LED_6 = true;
+#endif
+ break;
+ default:
+ break;
+ }
+
+ ML_LED_1(LED_1);
+ ML_LED_2(LED_2);
+ ML_LED_3(LED_3);
+ ML_LED_4(LED_4);
+ ML_LED_5(LED_5);
+#if !defined(CAPS_LOCK_STATUS)
+ ML_LED_6(LED_6);
+#endif
+
+ return state;
+}
+#endif
+
+#ifdef RGB_MATRIX_ENABLE
+// clang-format off
+const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, C3_2, C1_1, C4_2}, // 1
+ {0, C2_2, C1_2, C4_3},
+ {0, C2_3, C1_3, C3_3},
+ {0, C2_4, C1_4, C3_4},
+ {0, C2_5, C1_5, C3_5},
+ {0, C2_6, C1_6, C3_6},
+ {0, C2_7, C1_7, C3_7},
+ {0, C2_8, C1_8, C3_8},
+ {0, C3_1, C2_1, C4_1},
+
+ {0, C7_8, C6_8, C8_8}, // 10
+ {0, C7_7, C6_7, C9_8},
+ {0, C8_7, C6_6, C9_7},
+ {0, C8_6, C7_6, C9_6},
+ {0, C8_5, C7_5, C9_5},
+ {0, C8_4, C7_4, C9_4},
+ {0, C8_3, C7_3, C9_3},
+ {0, C8_2, C7_2, C9_2},
+ {0, C8_1, C7_1, C9_1},
+
+ {0, C3_10, C1_9, C4_10}, // 19
+ {0, C2_10, C1_10, C4_11},
+ {0, C2_11, C1_11, C3_11},
+ {0, C2_12, C1_12, C3_12},
+ {0, C2_13, C1_13, C3_13},
+ {0, C2_14, C1_14, C3_14},
+ {0, C2_15, C1_15, C3_15},
+ {0, C2_16, C1_16, C3_16},
+ {0, C3_9, C2_9, C4_9},
+
+ {0, C7_16, C6_16, C8_16}, // 28
+ {0, C7_15, C6_15, C9_16},
+ {0, C8_15, C6_14, C9_15},
+ {0, C8_10, C7_10, C9_10},
+ {0, C8_9, C7_9, C9_9},
+ {0, C8_11, C7_11, C9_11},
+ {0, C8_12, C7_12, C9_12},
+ {0, C8_13, C7_13, C9_13},
+ {0, C8_14, C7_14, C9_14},
+
+ {1, C3_2, C1_1, C4_2}, // 1
+ {1, C2_2, C1_2, C4_3},
+ {1, C2_3, C1_3, C3_3},
+ {1, C2_4, C1_4, C3_4},
+ {1, C2_5, C1_5, C3_5},
+ {1, C2_6, C1_6, C3_6},
+ {1, C2_7, C1_7, C3_7},
+ {1, C2_8, C1_8, C3_8},
+ {1, C3_1, C2_1, C4_1},
+
+ {1, C7_8, C6_8, C8_8}, // 10
+ {1, C7_7, C6_7, C9_8},
+ {1, C8_7, C6_6, C9_7},
+ {1, C8_6, C7_6, C9_6},
+ {1, C8_5, C7_5, C9_5},
+ {1, C8_4, C7_4, C9_4},
+ {1, C8_3, C7_3, C9_3},
+ {1, C8_2, C7_2, C9_2},
+ {1, C8_1, C7_1, C9_1},
+
+ {1, C3_10, C1_9, C4_10}, // 19
+ {1, C2_10, C1_10, C4_11},
+ {1, C2_11, C1_11, C3_11},
+ {1, C2_12, C1_12, C3_12},
+ {1, C2_13, C1_13, C3_13},
+ {1, C2_14, C1_14, C3_14},
+ {1, C2_15, C1_15, C3_15},
+ {1, C2_16, C1_16, C3_16},
+ {1, C3_9, C2_9, C4_9},
+
+ {1, C7_16, C6_16, C8_16}, // 28
+ {1, C7_15, C6_15, C9_16},
+ {1, C8_15, C6_14, C9_15},
+ {1, C8_10, C7_10, C9_10},
+ {1, C8_9, C7_9, C9_9},
+ {1, C8_11, C7_11, C9_11},
+ {1, C8_12, C7_12, C9_12},
+ {1, C8_13, C7_13, C9_13},
+ {1, C8_14, C7_14, C9_14},
+
+};
+
+led_config_t g_led_config = { {
+ { 0, 5, 10, 15, 20, 25, 29 },
+ { 1, 6, 11, 16, 21, 26, 30 },
+ { 2, 7, 12, 17, 22, 27, 31 },
+ { 3, 8, 13, 18, 23, 28, NO_LED },
+ { 4, 9, 14, 19, 24, NO_LED, NO_LED },
+ { 32, 33, 34, 35, NO_LED, NO_LED, NO_LED },
+ { 65, 61, 56, 51, 46, 41, 36 },
+ { 66, 62, 57, 52, 47, 42, 37 },
+ { 67, 63, 58, 53, 48, 43, 38 },
+ { NO_LED, 64, 59, 54, 49, 44, 39 },
+ { NO_LED, NO_LED, 60, 55, 50, 45, 40 },
+ { NO_LED, NO_LED, NO_LED, 71, 70, 69, 68 }
+}, {
+ { 0, 4}, { 0, 20}, { 0, 36}, { 0, 52}, { 0, 68},
+ { 16, 3}, { 16, 19}, { 16, 35}, { 16, 51}, { 16, 67},
+ { 32, 1}, { 32, 17}, { 32, 33}, { 32, 49}, { 32, 65},
+ { 48, 0}, { 48, 16}, { 48, 32}, { 48, 48}, { 48, 64},
+ { 64, 1}, { 64, 17}, { 64, 33}, { 64, 49}, { 64, 65},
+ { 80, 3}, { 80, 19}, { 80, 35}, { 80, 51},
+ { 96, 4}, { 96, 20}, { 96, 36},
+ { 88, 69}, {100, 80}, {112, 91}, {108, 69},
+
+ {240, 4}, {240, 20}, {240, 36}, {240, 52}, {240, 68},
+ {224, 3}, {224, 19}, {224, 35}, {224, 51}, {224, 67},
+ {208, 1}, {208, 17}, {208, 33}, {208, 49}, {208, 65},
+ {192, 0}, {192, 16}, {192, 32}, {192, 48}, {192, 64},
+ {176, 1}, {176, 17}, {176, 33}, {176, 49}, {176, 65},
+ {160, 3}, {160, 19}, {160, 35}, {160, 51},
+ {144, 4}, {144, 20}, {144, 36},
+ {152, 69}, {140, 80}, {128, 91}, {132, 69}
+}, {
+ 1, 1, 1, 1, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4,
+ 1, 1, 1,
+ 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4, 1,
+ 4, 4, 4, 4,
+ 1, 1, 1,
+ 1, 1, 1, 1
+} };
+// clang-format on
+
+#endif
+
+#ifdef AUDIO_ENABLE
+bool music_mask_kb(uint16_t keycode) {
+ switch (keycode) {
+ case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
+ case QK_TO ... QK_TO_MAX:
+ case QK_MOMENTARY ... QK_MOMENTARY_MAX:
+ case QK_DEF_LAYER ... QK_DEF_LAYER_MAX:
+ case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX:
+ case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX:
+ case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
+ case QK_LAYER_MOD ... QK_LAYER_MOD_MAX:
+ case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:
+ case QK_MOD_TAP ... QK_MOD_TAP_MAX:
+ case AU_ON ... AU_PREV:
+ case QK_BOOT:
+ case QK_CLEAR_EEPROM:
+ return false;
+ default:
+ return music_mask_user(keycode);
+ }
+}
+#endif
+
+#ifdef SWAP_HANDS_ENABLE
+// swap-hands action needs a matrix to define the swap
+// clang-format off
+const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
+ /* Left hand, matrix positions */
+ {{6,6}, {5,6}, {4,6}, {3,6}, {2,6}, {1,6},{0,6}},
+ {{6,7}, {5,7}, {4,7}, {3,7}, {2,7}, {1,7},{0,7}},
+ {{6,8}, {5,8}, {4,8}, {3,8}, {2,8}, {1,8},{0,8}},
+ {{6,9}, {5,9}, {4,9}, {3,9}, {2,9}, {1,9},{0,9}},
+ {{6,10},{5,10},{4,10},{3,10},{2,10},{1,10},{0,10}},
+ {{6,11},{5,11},{4,11},{3,11},{2,11},{1,11},{0,11}},
+ /* Right hand, matrix positions */
+ {{6,0}, {5,0}, {4,0}, {3,0}, {2,0}, {1,0},{0,0}},
+ {{6,1}, {5,1}, {4,1}, {3,1}, {2,1}, {1,1},{0,1}},
+ {{6,2}, {5,2}, {4,2}, {3,2}, {2,2}, {1,2},{0,2}},
+ {{6,3}, {5,3}, {4,3}, {3,3}, {2,3}, {1,3},{0,3}},
+ {{6,4}, {5,4}, {4,4}, {3,4}, {2,4}, {1,4},{0,4}},
+ {{6,5}, {5,5}, {4,5}, {3,5}, {2,5}, {1,5},{0,5}},
+};
+// clang-format on
+
+void keyboard_post_init_kb(void) {
+ rgb_matrix_enable_noeeprom();
+ keyboard_post_init_user();
+}
+#endif
+
+#if defined(AUDIO_ENABLE) && defined(MUSIC_MAP)
+// clang-format off
+__attribute__ ((weak))
+const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = {
+ {58, 59, 60, 61, 62, 63, 64},
+ {44, 45, 46, 47, 48, 49, 50},
+ {30, 31, 32, 33, 34, 35, 36},
+ {18, 19, 20, 21, 22, 23, 0},
+ { 8, 9, 10, 11, 12, 0, 0},
+ { 0, 1, 2, 3, 0, 0, 0},
+ {65, 66, 67, 68, 69, 70, 71},
+ {51, 52, 53, 54, 55, 56, 57},
+ {37, 38, 39, 40, 41, 42, 43},
+ { 0, 24, 25, 26, 27, 28, 29},
+ { 0, 0, 13, 14, 15, 16, 17},
+ { 0, 0, 0, 4, 5, 6, 7}
+};
+// clang-format on
+#endif
+
+#ifdef CAPS_LOCK_STATUS
+void led_update_ports(led_t led_state) {
+ ML_LED_6(led_state.caps_lock);
+}
+#endif
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+ if (!process_record_user(keycode, record)) { return false; }
+ switch (keycode) {
+#if !defined(MOONLANDER_USER_LEDS)
+ case LED_LEVEL:
+ if (record->event.pressed) {
+ keyboard_config.led_level ^= 1;
+ eeconfig_update_kb(keyboard_config.raw);
+ if (keyboard_config.led_level) {
+ layer_state_set_kb(layer_state);
+ } else {
+ ML_LED_1(false);
+ ML_LED_2(false);
+ ML_LED_3(false);
+ ML_LED_4(false);
+ ML_LED_5(false);
+ ML_LED_6(false);
+ }
+ }
+ break;
+#endif
+#ifdef RGB_MATRIX_ENABLE
+ case TOGGLE_LAYER_COLOR:
+ if (record->event.pressed) {
+ keyboard_config.disable_layer_led ^= 1;
+ if (keyboard_config.disable_layer_led) rgb_matrix_set_color_all(0, 0, 0);
+ eeconfig_update_kb(keyboard_config.raw);
+ }
+ break;
+ case RGB_TOG:
+ if (record->event.pressed) {
+ switch (rgb_matrix_get_flags()) {
+ case LED_FLAG_ALL: {
+ rgb_matrix_set_flags(LED_FLAG_NONE);
+ keyboard_config.rgb_matrix_enable = false;
+ rgb_matrix_set_color_all(0, 0, 0);
+ } break;
+ default: {
+ rgb_matrix_set_flags(LED_FLAG_ALL);
+ keyboard_config.rgb_matrix_enable = true;
+ } break;
+ }
+ eeconfig_update_kb(keyboard_config.raw);
+ }
+ return false;
+#endif
+ }
+ return true;
+}
+
+void matrix_init_kb(void) {
+ keyboard_config.raw = eeconfig_read_kb();
+
+ if (!keyboard_config.led_level && !keyboard_config.led_level_res) {
+ keyboard_config.led_level = true;
+ keyboard_config.led_level_res = 0b11;
+ eeconfig_update_kb(keyboard_config.raw);
+ }
+#ifdef RGB_MATRIX_ENABLE
+ if (keyboard_config.rgb_matrix_enable) {
+ rgb_matrix_set_flags(LED_FLAG_ALL);
+ } else {
+ rgb_matrix_set_flags(LED_FLAG_NONE);
+ }
+#endif
+ matrix_init_user();
+}
+
+void eeconfig_init_kb(void) { // EEPROM is getting reset!
+ keyboard_config.raw = 0;
+ keyboard_config.rgb_matrix_enable = true;
+ keyboard_config.led_level = true;
+ keyboard_config.led_level_res = 0b11;
+ eeconfig_update_kb(keyboard_config.raw);
+ eeconfig_init_user();
+}
diff --git a/keyboards/zsa/moonlander/moonlander.h b/keyboards/zsa/moonlander/moonlander.h
new file mode 100644
index 0000000000..0e5282c511
--- /dev/null
+++ b/keyboards/zsa/moonlander/moonlander.h
@@ -0,0 +1,58 @@
+/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
+ * Copyright 2020 Jack Humbert <jack.humb@gmail.com>
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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 "quantum.h"
+
+extern bool mcp23018_leds[];
+
+#define MCP23018_DEFAULT_ADDRESS 0b0100000
+
+#define ML_LED_1(status) writePin(B5, (bool)status)
+#define ML_LED_2(status) writePin(B4, (bool)status)
+#define ML_LED_3(status) writePin(B3, (bool)status)
+
+#define ML_LED_4(status) mcp23018_leds[0] = (bool)status
+#define ML_LED_5(status) mcp23018_leds[1] = (bool)status
+#define ML_LED_6(status) mcp23018_leds[2] = (bool)status
+
+enum planck_ez_keycodes {
+ TOGGLE_LAYER_COLOR = QK_KB_0,
+ LED_LEVEL,
+};
+
+#ifndef WEBUSB_ENABLE
+# define WEBUSB_PAIR KC_NO
+#endif
+
+typedef union {
+ uint32_t raw;
+ struct {
+ bool disable_layer_led :1;
+ bool rgb_matrix_enable :1;
+ bool led_level :1;
+ uint8_t led_level_res :2; // DO NOT REMOVE
+ };
+} keyboard_config_t;
+
+extern keyboard_config_t keyboard_config;
+
+bool is_transport_connected(void);
diff --git a/keyboards/zsa/moonlander/readme.md b/keyboards/zsa/moonlander/readme.md
new file mode 100644
index 0000000000..546681e630
--- /dev/null
+++ b/keyboards/zsa/moonlander/readme.md
@@ -0,0 +1,58 @@
+# Moonlander
+
+![Moonlander](https://i.imgur.com/st2PCgph.png)
+
+A next-gen split, ergonomic keyboard with an active left side, USB type C, integrated wrist rest, and a thumb cluster that can move.
+
+
+* Keyboard Maintainer: [drashna](https://github.com/drashna), [ZSA](https://github.com/zsa/)
+* Hardware Supported: Moonlander MK 1 (STM32F303xC)
+* Hardware Availability: [ZSA Store](https://zsa.io/moonlander/)
+
+Make example for this keyboard (after setting up your build environment):
+
+ make zsa/moonlander:default
+
+Flashing example for this keyboard:
+
+ make zsa/moonlander: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).
+
+
+## Moonlander Customization
+
+### Indicator LEDs
+
+There are 6 functions for enabling and disabling the LEDs on the top of the boards. The functions are `ML_LED_1(bool)` through `ML_LED_6(bool)`, with the first LED being the left most LED on the left hand, and the sixth LED being the right most LED on the right side.
+
+By default, the Indicator LEDs are used to indicate the layer state for the keyboard. If you wish to change this (and indicate caps/num/scroll lock status instead), then define `MOONLANDER_USER_LEDS` in your `config.h` file.
+
+
+### Oryx Configuration
+
+To enable the features from Oryx (ZSA's Configurator), either compile the `default` keymap, or add `#define ORYX_CONFIGURATOR` to your `config.h` file.
+
+This enables the front Indicator LEDs, and the `TOGGLE_LAYER_COLOR` keycode. The `TOGGLE_LAYER_COLOR` keycode toggles the customized LED map configured on Oryx.
+
+### RGB Matrix Features
+
+If you're using the Smart LED (layer indication) feature from the Oryx Configurator, you want to make sure that you enable these options by adding `#define ORYX_CONFIGURATOR` to your keymap's `config.h`.
+
+This changes the `RGB_TOG` keycode so that it will toggle the lights on and off, in a way that will allow the Smart LEDs to continue to work, even with the rest of the LEDs turned off.
+
+Additionally, a new keycode has been added to toggle the Smart LEDs. Use `TOGGLE_LAYER_COLOR`, if you aren't already.
+
+### Detecting split / Gaming mode
+
+To make it extra gaming friendly, you can configure what happens when you disconnect the right half. This is especially useful when using gaming unfriendly layers or layouts (e.g. home row mods, dvorak, colemak).
+
+Example for enabling a specific layer while right side is disconnected:
+
+```
+void housekeeping_task_user(void) {
+ if (!is_transport_connected()) {
+ // set layer
+ }
+}
+```
diff --git a/keyboards/zsa/moonlander/rules.mk b/keyboards/zsa/moonlander/rules.mk
new file mode 100644
index 0000000000..204c5940e4
--- /dev/null
+++ b/keyboards/zsa/moonlander/rules.mk
@@ -0,0 +1,22 @@
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
+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
+NKRO_ENABLE = yes # Enable N-Key Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
+AUDIO_ENABLE = yes # Audio output
+AUDIO_DRIVER = dac_additive
+CUSTOM_MATRIX = lite
+SWAP_HANDS_ENABLE = yes
+RGB_MATRIX_ENABLE = yes
+
+#project specific files
+SRC += matrix.c
+I2C_DRIVER_REQUIRED = yes
+
+MOUSE_SHARED_EP = no