From 915d7a18d757ddb22498d66b82c6309077cdb178 Mon Sep 17 00:00:00 2001 From: Kyle McCreery Date: Wed, 15 Mar 2023 11:49:14 -0400 Subject: [PATCH] [Keyboard] New Keyboard - Sugar Glider (#19933) Co-authored-by: Drashna Jaelre Co-authored-by: Less/Rikki <86894501+lesshonor@users.noreply.github.com> Co-authored-by: jack <0x6a73@protonmail.com> --- keyboards/mechwild/sugarglider/config.h | 41 ++ keyboards/mechwild/sugarglider/f401/rules.mk | 3 + keyboards/mechwild/sugarglider/f411/rules.mk | 3 + keyboards/mechwild/sugarglider/glcdfont.c | 231 ++++++++++ keyboards/mechwild/sugarglider/halconf.h | 12 + keyboards/mechwild/sugarglider/info.json | 110 +++++ .../sugarglider/keymaps/default/keymap.c | 70 +++ .../sugarglider/keymaps/default/rules.mk | 2 + .../mechwild/sugarglider/keymaps/via/keymap.c | 61 +++ .../mechwild/sugarglider/keymaps/via/rules.mk | 5 + keyboards/mechwild/sugarglider/matrix.c | 95 ++++ keyboards/mechwild/sugarglider/mcuconf.h | 12 + keyboards/mechwild/sugarglider/post_rules.mk | 4 + keyboards/mechwild/sugarglider/readme.md | 27 ++ keyboards/mechwild/sugarglider/rules.mk | 23 + keyboards/mechwild/sugarglider/sugarglider.c | 426 ++++++++++++++++++ keyboards/mechwild/sugarglider/sugarglider.h | 28 ++ .../sugarglider/wide_oled/f401/rules.mk | 3 + .../sugarglider/wide_oled/f411/rules.mk | 3 + .../mechwild/sugarglider/wide_oled/rules.mk | 6 + 20 files changed, 1165 insertions(+) create mode 100644 keyboards/mechwild/sugarglider/config.h create mode 100644 keyboards/mechwild/sugarglider/f401/rules.mk create mode 100644 keyboards/mechwild/sugarglider/f411/rules.mk create mode 100644 keyboards/mechwild/sugarglider/glcdfont.c create mode 100644 keyboards/mechwild/sugarglider/halconf.h create mode 100644 keyboards/mechwild/sugarglider/info.json create mode 100644 keyboards/mechwild/sugarglider/keymaps/default/keymap.c create mode 100644 keyboards/mechwild/sugarglider/keymaps/default/rules.mk create mode 100644 keyboards/mechwild/sugarglider/keymaps/via/keymap.c create mode 100644 keyboards/mechwild/sugarglider/keymaps/via/rules.mk create mode 100644 keyboards/mechwild/sugarglider/matrix.c create mode 100644 keyboards/mechwild/sugarglider/mcuconf.h create mode 100644 keyboards/mechwild/sugarglider/post_rules.mk create mode 100644 keyboards/mechwild/sugarglider/readme.md create mode 100644 keyboards/mechwild/sugarglider/rules.mk create mode 100644 keyboards/mechwild/sugarglider/sugarglider.c create mode 100644 keyboards/mechwild/sugarglider/sugarglider.h create mode 100644 keyboards/mechwild/sugarglider/wide_oled/f401/rules.mk create mode 100644 keyboards/mechwild/sugarglider/wide_oled/f411/rules.mk create mode 100644 keyboards/mechwild/sugarglider/wide_oled/rules.mk diff --git a/keyboards/mechwild/sugarglider/config.h b/keyboards/mechwild/sugarglider/config.h new file mode 100644 index 00000000000..dc3a85a7282 --- /dev/null +++ b/keyboards/mechwild/sugarglider/config.h @@ -0,0 +1,41 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define DYNAMIC_KEYMAP_LAYER_COUNT 5 + +/* Matrix COL and ROW definitions */ +#define MATRIX_ROWS 9 +#define MATRIX_COLS 6 + +/* Cirque Touchpad Settings */ +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE +#define CIRQUE_PINNACLE_ATTENUATION EXTREG__TRACK_ADCCONFIG__ADC_ATTENUATE_2X + +/* Define custom font */ +#define OLED_FONT_H "keyboards/mechwild/sugarglider/glcdfont.c" + +/* allows the "key" button on the blackpill to toggle caps lock for user testing before soldering */ +#define DIP_SWITCH_PINS { A0 } + +/* TAPPING_TERM value is used for the CIRQUE_PINNACLE_TAPPING_TERM as well by default + * defining it this way allows us to easily modify it with DYNAMIC_TAPPING_TERM_ENABLE + */ +#define TAPPING_TERM 0 +#define CIRQUE_PINNACLE_TAP_ENABLE +#define POINTING_DEVICE_GESTURES_SCROLL_ENABLE + +/* spi config */ +#define SPI_DRIVER SPID1 +#define SPI_SCK_PIN A5 +#define SPI_SCK_PAL_MODE 5 +#define SPI_MOSI_PIN A7 +#define SPI_MOSI_PAL_MODE 5 +#define SPI_MISO_PIN A6 +#define SPI_MISO_PAL_MODE 5 +#define CIRQUE_PINNACLE_SPI_DIVISOR 8 +#define CIRQUE_PINNACLE_SPI_CS_PIN A3 + +/* Force NKRO */ +#define FORCE_NKRO diff --git a/keyboards/mechwild/sugarglider/f401/rules.mk b/keyboards/mechwild/sugarglider/f401/rules.mk new file mode 100644 index 00000000000..a92d8a85c61 --- /dev/null +++ b/keyboards/mechwild/sugarglider/f401/rules.mk @@ -0,0 +1,3 @@ +# MCU name +MCU = STM32F401 +BOARD = BLACKPILL_STM32_F401 diff --git a/keyboards/mechwild/sugarglider/f411/rules.mk b/keyboards/mechwild/sugarglider/f411/rules.mk new file mode 100644 index 00000000000..db1d4054fdf --- /dev/null +++ b/keyboards/mechwild/sugarglider/f411/rules.mk @@ -0,0 +1,3 @@ +# MCU name +MCU = STM32F411 +BOARD = BLACKPILL_STM32_F411 diff --git a/keyboards/mechwild/sugarglider/glcdfont.c b/keyboards/mechwild/sugarglider/glcdfont.c new file mode 100644 index 00000000000..2a0353759d3 --- /dev/null +++ b/keyboards/mechwild/sugarglider/glcdfont.c @@ -0,0 +1,231 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "progmem.h" + +const unsigned char font[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, + 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, + 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, + 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, + 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, + 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, + 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, + 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, + 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, + 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, + 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, + 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, + 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, + 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, + 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, + 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, + 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, + 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, + 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, + 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, + 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, + 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, + 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, + 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, + 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, + 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, + 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, + 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, + 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, + 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, + 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, + 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, + 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, + 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, + 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, + 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, + 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, + 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, + 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, + 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, + 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, + 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, + 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, + 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, + 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, + 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, + 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, + 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, + 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, + 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, + 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, + 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, + 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, + 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, + 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, + 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, + 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, + 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, + 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, + 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, + 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, + 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, + 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, + 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, + 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, + 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, + 0x38, 0x44, 0x44, 0x28, 0x7E, 0x00, + 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, + 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, + 0x18, 0x24, 0x24, 0x1C, 0x78, 0x00, + 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, + 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, + 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, + 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, + 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, + 0x7C, 0x18, 0x24, 0x24, 0x18, 0x00, + 0x18, 0x24, 0x24, 0x18, 0x7C, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, + 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, + 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, + 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, + 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, + 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, + 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, + 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, + 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, + 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, + 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, + 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, + 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0xE0, 0xFE, 0xFF, + 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFE, + 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x3E, + 0xE0, 0x80, 0x70, 0x0E, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x3C, 0xE0, + 0x80, 0x78, 0x07, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, + 0x07, 0x1F, 0xFF, 0xFE, 0xF0, 0xC0, + 0xF8, 0xFF, 0xF7, 0x07, 0x07, 0x7F, + 0xFF, 0xFF, 0xF8, 0x00, 0xC0, 0x38, + 0x0C, 0x18, 0x60, 0x80, 0x00, 0x00, + 0x00, 0xF0, 0x0C, 0x04, 0xF4, 0x1C, + 0x00, 0x1F, 0x1F, 0x1F, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x1F, 0x1F, + 0x0F, 0x01, 0x03, 0x06, 0xF8, 0x00, + 0x07, 0x7F, 0x3F, 0x0E, 0xC1, 0x38, + 0x07, 0x0E, 0x70, 0x83, 0x1C, 0x60, + 0x1E, 0x03, 0xC0, 0x3E, 0x01, 0x00, + 0x80, 0xC0, 0xFC, 0xE6, 0xC3, 0xC1, + 0xC1, 0xC3, 0xE6, 0xFC, 0xC0, 0x80, + 0x3F, 0x7F, 0xFF, 0xFF, 0xF9, 0xC0, + 0xC0, 0xF9, 0xFF, 0xFF, 0x7F, 0x3F, + 0x00, 0x80, 0x40, 0x40, 0xC0, 0xC0, + 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xF8, 0x86, 0xC1, 0xC1, + 0x41, 0x41, 0x81, 0x01, 0x01, 0x01, + 0x02, 0x06, 0x18, 0x60, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0E, 0xF1, 0x00, 0x00, 0x00, 0x00, + 0x81, 0xC7, 0xCF, 0xFF, 0xB1, 0x01, + 0x1F, 0x7F, 0x7F, 0x1F, 0x01, 0xB1, + 0xFF, 0xDF, 0xC7, 0x83, 0x01, 0x00, + 0x00, 0x00, 0xE0, 0xDF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x1C, + 0xE0, 0x00, 0x00, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x0B, 0x15, 0x22, 0x40, 0x41, + 0x80, 0x41, 0x7E, 0x0C, 0x0C, 0x1C, + 0x1C, 0x3C, 0x3C, 0x3C, 0x7C, 0x7C, + 0x7C, 0x78, 0x7B, 0xFE, 0xC6, 0x84, + 0x03, 0x0F, 0x0F, 0x0E, 0x0D, 0x07, + 0x50, 0x78, 0x78, 0x50, 0x07, 0x0F, + 0x0F, 0x0F, 0x0E, 0x07, 0x04, 0xC6, + 0xFE, 0x7B, 0x79, 0x7D, 0x7E, 0x7C, + 0x3C, 0x3C, 0x3C, 0x1C, 0x1C, 0x0C, + 0x3F, 0x46, 0x41, 0x80, 0x41, 0x40, + 0x21, 0x15, 0x0B, 0x04, 0x00, 0x00, + 0x01, 0x06, 0x38, 0xE0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x03, 0x02, 0x04, 0x08, 0x08, 0x08, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, + 0x08, 0x0C, 0x04, 0x02, 0x01, 0x00, + 0xF0, 0x1C, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xC7, 0x78, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0xC0, 0x3F, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0xF0, 0xE0, 0xC0, + 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xE0, + 0xF8, 0xBF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x3A, + 0x51, 0x21, 0x60, 0x40, 0x21, 0x33, + 0x1F, 0x07, 0x07, 0x07, 0x0F, 0x37, + 0x27, 0x27, 0x46, 0x46, 0x46, 0x46, + 0x4E, 0x4F, 0x4F, 0x4F, 0x47, 0x47, + 0x43, 0x41, 0x41, 0x23, 0x27, 0x1F, + 0x0F, 0x0F, 0x0F, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x0F, 0x17, 0x23, 0x41, + 0x40, 0x60, 0x21, 0x75, 0x3A, 0x14, + 0x00, 0x00, 0x00, 0xE0, 0xFE, 0xFF, + 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0xFE, + 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xF8, 0xFF, 0xF7, 0x07, + 0x07, 0x1F, 0xFF, 0xFE, 0xF0, 0xC0, + 0xF8, 0x3F, 0x8F, 0x0F, 0x3F, 0xFF, + 0xFF, 0xFE, 0x80, 0xF0, 0x0C, 0x04, + 0xF4, 0x1C, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1F, 0x1F, 0x1F, 0x07, 0x06, + 0xF8, 0x00, 0x00, 0x73, 0x3F, 0x0F, + 0xC1, 0x38, 0x07, 0x0F, 0x70, 0x83, + 0x07, 0x7F, 0x1F, 0x03, 0xC0, 0x3F, + 0x01, 0x3E, 0xE0, 0x80, 0x70, 0x0E, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x3C, 0xE0, 0x80, 0x78, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/keyboards/mechwild/sugarglider/halconf.h b/keyboards/mechwild/sugarglider/halconf.h new file mode 100644 index 00000000000..23a1dc04b39 --- /dev/null +++ b/keyboards/mechwild/sugarglider/halconf.h @@ -0,0 +1,12 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define HAL_USE_I2C TRUE + +#define HAL_USE_SPI TRUE +#define SPI_USE_WAIT TRUE +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD + +#include_next diff --git a/keyboards/mechwild/sugarglider/info.json b/keyboards/mechwild/sugarglider/info.json new file mode 100644 index 00000000000..9d9ee27eb5c --- /dev/null +++ b/keyboards/mechwild/sugarglider/info.json @@ -0,0 +1,110 @@ +{ + "manufacturer": "MechWild", + "keyboard_name": "Sugar Glider", + "maintainer": "kylemccreery", + "url": "https://mechwild.com/product/sugar-glider/", + "bootloader": "stm32-dfu", + "features": { + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": true, + "nkro": true, + "encoder": true, + "rgblight": true, + "dip_switch": true, + "steno": true + }, + "usb": { + "vid": "0x6D77", + "pid": "0x1710", + "device_version": "0.2.0" + }, + "diode_direction": "COL2ROW", + "rgblight": { + "led_count": 10, + "pin": "B5", + "max_brightness": 255, + "hue_steps": 8, + "saturation_steps": 8, + "brightness_steps": 8, + "animations": { + "alternating": true, + "breathing": true, + "christmas": true, + "knight": true, + "rainbow_mood": true, + "rainbow_swirl": true, + "rgb_test": true, + "snake": true, + "static_gradient": true, + "twinkle": true + } + }, + "encoder": { + "rotary": [ + { "pin_a": "B0", "pin_b": "A2", "resolution": 4 }, + { "pin_a": "B3", "pin_b": "A15", "resolution": 4 }, + { "pin_a": "B9", "pin_b": "B8", "resolution": 4 }, + { "pin_a": "C15", "pin_b": "C14", "resolution": 4 } + ] + }, + "layouts": { + "LAYOUT": { + "layout": [ + { "matrix": [0, 0], "x":0, "y":0}, + { "matrix": [0, 1], "x":1, "y":0}, + { "matrix": [0, 2], "x":2, "y":0}, + { "matrix": [0, 3], "x":3, "y":0}, + { "matrix": [0, 4], "x":4, "y":0}, + { "matrix": [0, 5], "x":5, "y":0}, + { "matrix": [8, 0], "x":9, "y":0}, + { "matrix": [4, 0], "x":10.5, "y":0}, + { "matrix": [4, 1], "x":11.5, "y":0}, + { "matrix": [4, 2], "x":12.5, "y":0}, + { "matrix": [4, 3], "x":13.5, "y":0}, + { "matrix": [4, 4], "x":14.5, "y":0}, + { "matrix": [4, 5], "x":15.5, "y":0}, + { "matrix": [1, 0], "x":0, "y":1}, + { "matrix": [1, 1], "x":1, "y":1}, + { "matrix": [1, 2], "x":2, "y":1}, + { "matrix": [1, 3], "x":3, "y":1}, + { "matrix": [1, 4], "x":4, "y":1}, + { "matrix": [1, 5], "x":5, "y":1}, + { "matrix": [8, 5], "x":8, "y":1}, + { "matrix": [8, 1], "x":9, "y":1}, + { "matrix": [5, 0], "x":10.5, "y":1}, + { "matrix": [5, 1], "x":11.5, "y":1}, + { "matrix": [5, 2], "x":12.5, "y":1}, + { "matrix": [5, 3], "x":13.5, "y":1}, + { "matrix": [5, 4], "x":14.5, "y":1}, + { "matrix": [5, 5], "x":15.5, "y":1}, + { "matrix": [2, 0], "x":0, "y":2}, + { "matrix": [2, 1], "x":1, "y":2}, + { "matrix": [2, 2], "x":2, "y":2}, + { "matrix": [2, 3], "x":3, "y":2}, + { "matrix": [2, 4], "x":4, "y":2}, + { "matrix": [2, 5], "x":5, "y":2}, + { "matrix": [8, 2], "x":9, "y":2}, + { "matrix": [6, 0], "x":10.5, "y":2}, + { "matrix": [6, 1], "x":11.5, "y":2}, + { "matrix": [6, 2], "x":12.5, "y":2}, + { "matrix": [6, 3], "x":13.5, "y":2}, + { "matrix": [6, 4], "x":14.5, "y":2}, + { "matrix": [6, 5], "x":15.5, "y":2}, + { "matrix": [3, 0], "x":2.25, "y":3.5}, + { "matrix": [3, 1], "x":3.5, "y":3.5, "h":1.5}, + { "matrix": [3, 2], "x":4.5, "y":3.5, "h":1.5}, + { "matrix": [3, 3], "x":5.5, "y":3.5, "h":1.5}, + { "matrix": [3, 4], "x":6.75, "y":3.5}, + { "matrix": [7, 0], "x":7.75, "y":3.5}, + { "matrix": [7, 1], "x":8.75, "y":3.5}, + { "matrix": [7, 2], "x":10, "y":3.5, "h":1.5}, + { "matrix": [7, 3], "x":11, "y":3.5, "h":1.5}, + { "matrix": [7, 4], "x":12, "y":3.5, "h":1.5}, + { "matrix": [7, 5], "x":13.25, "y":3.5} + ] + } + } +} diff --git a/keyboards/mechwild/sugarglider/keymaps/default/keymap.c b/keyboards/mechwild/sugarglider/keymaps/default/keymap.c new file mode 100644 index 00000000000..77541edf130 --- /dev/null +++ b/keyboards/mechwild/sugarglider/keymaps/default/keymap.c @@ -0,0 +1,70 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H +#include "keymap_steno.h" + +// Defines names for use in layer keycodes and the keymap +enum layer_names { + _QWERTY, + _LOWER, + _RAISE, + _ADJUST, + _MOUSE, + _STENO +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT( + QK_GESC, KC_Q, KC_W, KC_E, KC_R, KC_T, TAP_UP, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, + KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_MUTE, TAP_DN, KC_H, KC_J, KC_K, KC_L, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, TG(_STENO), KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + KC_MUTE, KC_LGUI, KC_LALT, TL_LOWR, KC_MS_BTN1, TAP_TOG, KC_MS_BTN2, TL_UPPR, KC_SPC, KC_RSFT, KC_MUTE + ), + [_LOWER] = LAYOUT( + KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, DPI_UP, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, + KC_TRNS, KC_MINS, KC_EQL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, DPI_DN, KC_TRNS, KC_LBRC, KC_RBRC, KC_BSLS, KC_SCLN, KC_SCLN, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_RAISE] = LAYOUT( + KC_TRNS, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_TRNS, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TRNS, + KC_TRNS, KC_UNDS, KC_PLUS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LCBR, KC_RCBR, KC_PIPE, KC_DQUO, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_ADJUST] = LAYOUT( + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS, + KC_TRNS, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD, RGB_RMOD, RGB_TOG, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAI, RGB_MOD, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_MOUSE] = LAYOUT( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, DPI_FINE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_STENO] = LAYOUT( + STN_N1, STN_N2, STN_N3, STN_N4, STN_N5, STN_N6, KC_TRNS, STN_N7, STN_N8, STN_N9, STN_NA, STN_NB, STN_NC, + STN_RES1, STN_S1, STN_TL, STN_PL, STN_HL, STN_ST1, KC_TRNS, KC_TRNS, STN_ST3, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, + STN_RES2, STN_S2, STN_KL, STN_WL, STN_RL, STN_ST2, KC_TRNS, STN_ST4, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, + KC_TRNS, STN_N1, STN_A, STN_O, KC_TRNS, KC_TRNS, KC_TRNS, STN_E, STN_U, STN_N2, KC_TRNS + ) +}; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][4][2] = { + [_QWERTY] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_WH_U, KC_WH_D) }, + [_LOWER] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_LEFT, KC_RIGHT), ENCODER_CCW_CW(KC_HOME, KC_END), ENCODER_CCW_CW(DPI_UP, DPI_DN) }, + [_RAISE] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_HOME, KC_END), ENCODER_CCW_CW(KC_LEFT, KC_RIGHT), ENCODER_CCW_CW(KC_HOME, KC_END) }, + [_ADJUST] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU), ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU) }, + [_MOUSE] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU), ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU) }, + [_STENO] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_HOME, KC_END), ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_HOME, KC_END) } +}; +#endif + +void pointing_device_init_user(void) { + set_auto_mouse_layer(_MOUSE); + set_auto_mouse_enable(true); +} diff --git a/keyboards/mechwild/sugarglider/keymaps/default/rules.mk b/keyboards/mechwild/sugarglider/keymaps/default/rules.mk new file mode 100644 index 00000000000..14d46f300c2 --- /dev/null +++ b/keyboards/mechwild/sugarglider/keymaps/default/rules.mk @@ -0,0 +1,2 @@ +ENCODER_MAP_ENABLE = yes +TRI_LAYER_ENABLE = yes diff --git a/keyboards/mechwild/sugarglider/keymaps/via/keymap.c b/keyboards/mechwild/sugarglider/keymaps/via/keymap.c new file mode 100644 index 00000000000..692af70359a --- /dev/null +++ b/keyboards/mechwild/sugarglider/keymaps/via/keymap.c @@ -0,0 +1,61 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +// Defines names for use in layer keycodes and the keymap +enum layer_names { + _QWERTY, + _LOWER, + _RAISE, + _ADJUST, + _MOUSE +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT( + QK_GESC, KC_Q, KC_W, KC_E, KC_R, KC_T, TAP_UP, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, + KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_MUTE, TAP_DN, KC_H, KC_J, KC_K, KC_L, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_TRNS, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + KC_MUTE, KC_LGUI, KC_LALT, MO(_LOWER), KC_MS_BTN1, TAP_TOG, KC_MS_BTN2, MO(_RAISE), KC_SPC, KC_RSFT, KC_MUTE + ), + [_LOWER] = LAYOUT( + KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, DPI_UP, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, + KC_TRNS, KC_MINS, KC_EQL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, DPI_DN, KC_TRNS, KC_LBRC, KC_RBRC, KC_BSLS, KC_QUOT, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_RAISE] = LAYOUT( + KC_TRNS, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_TRNS, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TRNS, + KC_TRNS, KC_UNDS, KC_PLUS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LCBR, KC_RCBR, KC_PIPE, KC_DQUO, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_ADJUST] = LAYOUT( + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS, + KC_TRNS, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD, RGB_RMOD, RGB_TOG, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, QK_BOOT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAI, RGB_MOD, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_MOUSE] = LAYOUT( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, DPI_FINE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ) +}; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][4][2] = { + [_QWERTY] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_WH_U, KC_WH_D) }, + [_LOWER] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_LEFT, KC_RIGHT), ENCODER_CCW_CW(KC_HOME, KC_END), ENCODER_CCW_CW(DPI_UP, DPI_DN) }, + [_RAISE] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_HOME, KC_END), ENCODER_CCW_CW(KC_LEFT, KC_RIGHT), ENCODER_CCW_CW(KC_HOME, KC_END) }, + [_ADJUST] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU), ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU) }, + [_MOUSE] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU), ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_BRID, KC_BRIU) } +}; +#endif + +void pointing_device_init_user(void) { + set_auto_mouse_layer(_MOUSE); + set_auto_mouse_enable(true); +} diff --git a/keyboards/mechwild/sugarglider/keymaps/via/rules.mk b/keyboards/mechwild/sugarglider/keymaps/via/rules.mk new file mode 100644 index 00000000000..6591ae36538 --- /dev/null +++ b/keyboards/mechwild/sugarglider/keymaps/via/rules.mk @@ -0,0 +1,5 @@ +VIA_ENABLE = yes +ENCODER_MAP_ENABLE = yes + +# Steno needs to be disabled to allow endpoints for VIA +STENO_ENABLE = no # Enable stenography endpoint diff --git a/keyboards/mechwild/sugarglider/matrix.c b/keyboards/mechwild/sugarglider/matrix.c new file mode 100644 index 00000000000..96a16df542a --- /dev/null +++ b/keyboards/mechwild/sugarglider/matrix.c @@ -0,0 +1,95 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "matrix.h" +#include "mcp23018.h" +#include "wait.h" +#include "debug.h" +#include "encoder.h" + +#define I2C_ADDR 0x20 +#define ROW_POS { 0b01000000, 0b10000000, 0b01000000, 0b10000000, 0b00000100, 0b00010000, 0b00100000, 0b00000010, 0b00001000 } + +static uint8_t mcp23018_errors = 0; + +static void mcp23018_init_cols(void) { + mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTA, ALL_INPUT); + mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTB, ALL_INPUT); +} + +static void mcp23018_scan(void) { + if (!mcp23018_errors) { + return; + } + + static uint16_t mcp23018_reset_loop = 0; + if (++mcp23018_reset_loop > 0x1FFF) { + // tuned to about 5s given the current scan rate + dprintf("trying to reset mcp23018\n"); + mcp23018_reset_loop = 0; + mcp23018_errors = 0; + mcp23018_init_cols(); + } +} + +static matrix_row_t read_cols(void) { + if (mcp23018_errors) { + return 0; + } + + uint8_t ret = 0xFF; // sets all to 1 + mcp23018_errors += !mcp23018_readPins(I2C_ADDR, mcp23018_PORTB, &ret); // will update with values 0 = pulled down by connection, 1 = pulled up by pullup resistors + + return (~ret) & 0b00111111; // Clears out the two row bits in the B buffer. +} + +static void select_row(uint8_t row) { + uint8_t row_pos[MATRIX_ROWS] = ROW_POS; + if (mcp23018_errors) { + // wait to mimic i2c interactions + //wait_us(100); + return; + } + + if (row > 1) { + mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTB, ALL_INPUT); + mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTA, ~(row_pos[row])); + } else { + mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTA, ALL_INPUT); + mcp23018_errors += !mcp23018_set_config(I2C_ADDR, mcp23018_PORTB, ~(row_pos[row])); + } +} + +static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { + // Store last value of row prior to reading + matrix_row_t last_row_value = current_matrix[current_row]; + + // Clear data in matrix row + current_matrix[current_row] = 0; + + // Select row and wait for row selection to stabilize + select_row(current_row); + // Skip the wait_us(30); as i2c is slow enough to debounce the io changes + + current_matrix[current_row] = read_cols(); + + return (last_row_value != current_matrix[current_row]); +} + +void matrix_init_custom(void) { + mcp23018_init(I2C_ADDR); + mcp23018_init_cols(); +} + +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + mcp23018_scan(); + + bool changed = false; + for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { + changed |= read_cols_on_row(current_matrix, current_row); +#ifdef ENCODER_ENABLE + encoder_read(); +#endif + } + return changed; +} diff --git a/keyboards/mechwild/sugarglider/mcuconf.h b/keyboards/mechwild/sugarglider/mcuconf.h new file mode 100644 index 00000000000..7fe57709092 --- /dev/null +++ b/keyboards/mechwild/sugarglider/mcuconf.h @@ -0,0 +1,12 @@ +// Copyright 2023 Kyle McCreery (@kylemccreery) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE + +#undef STM32_SPI_USE_SPI1 +#define STM32_SPI_USE_SPI1 TRUE diff --git a/keyboards/mechwild/sugarglider/post_rules.mk b/keyboards/mechwild/sugarglider/post_rules.mk new file mode 100644 index 00000000000..c94ac22fabb --- /dev/null +++ b/keyboards/mechwild/sugarglider/post_rules.mk @@ -0,0 +1,4 @@ +# Checking if WIDE_OLED +ifeq ($(strip $(WIDE_OLED_ENABLE)), yes) + OPT_DEFS += -DOLED_DISPLAY_128X64 +endif diff --git a/keyboards/mechwild/sugarglider/readme.md b/keyboards/mechwild/sugarglider/readme.md new file mode 100644 index 00000000000..df6942eed27 --- /dev/null +++ b/keyboards/mechwild/sugarglider/readme.md @@ -0,0 +1,27 @@ +# mechwild/sugarglider + +![mechwild/sugarglider](https://i.imgur.com/IYhOU3xh.jpg) + +The Sugar Glider is an ergonomic keyboard with columnar stagger and a central touchpad, OLED, and status LEDs. + +* Keyboard Maintainer: [Kyle McCreery](https://github.com/kylemccreery) +* Hardware Supported: Sugar Glider v0.2 +* Hardware Availability: [Sugar Glider on MechWild](https://mechwild.com/product/sugar-glider/) + +Make example for this keyboard (after setting up your build environment): + + make mechwild/sugarglider:default + +Flashing example for this keyboard: + + make mechwild/sugarglider:default:flash + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +Enter the bootloader in 3 ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (assigned to the top left key) and plug in the keyboard while holding it. +* **Physical reset button**: Press and hold the boot0 button on the blackpill, tap and release the nrst button on the blackpill, then release the boot0 button. +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available. By default this is the top right key on layer 1. diff --git a/keyboards/mechwild/sugarglider/rules.mk b/keyboards/mechwild/sugarglider/rules.mk new file mode 100644 index 00000000000..acf0b6f1f4c --- /dev/null +++ b/keyboards/mechwild/sugarglider/rules.mk @@ -0,0 +1,23 @@ +# Build Options +# change yes to no to disable +# +OLED_ENABLE = yes # OLED Enabled +OLED_DRIVER = SSD1306 # OLED Driver + +# Cirque touchpad settings +POINTING_DEVICE_ENABLE = yes # Pointing Device Enabled +POINTING_DEVICE_DRIVER = cirque_pinnacle_spi # Pointing Device Driver +DYNAMIC_TAPPING_TERM_ENABLE = yes # Enable Dynamic Tapping Term to control the Tap term for the Cirque Pad easily + +# Custom matrix setup +CUSTOM_MATRIX = lite +DEBOUNCE_TYPE = sym_eager_pk + +VPATH += drivers/gpio +SRC += mcp23018.c matrix.c +QUANTUM_LIB_SRC += i2c_master.c + +DEFAULT_FOLDER = mechwild/sugarglider/wide_oled + +# Necessary for stenography functionality +KEYBOARD_SHARED_EP = yes # Needed to free up an endpoint in blackpill diff --git a/keyboards/mechwild/sugarglider/sugarglider.c b/keyboards/mechwild/sugarglider/sugarglider.c new file mode 100644 index 00000000000..76c6d298320 --- /dev/null +++ b/keyboards/mechwild/sugarglider/sugarglider.c @@ -0,0 +1,426 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "sugarglider.h" + +#ifndef GLIDEPOINT_DPI_OPTIONS +# define GLIDEPOINT_DPI_OPTIONS \ + { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 3600, 4000 } +#endif + +#ifndef GLIDEPOINT_DPI_DEFAULT +# define GLIDEPOINT_DPI_DEFAULT 1 +#endif + +keyboard_config_t keyboard_config; +uint16_t dpi_array[] = GLIDEPOINT_DPI_OPTIONS; +#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) + +void board_init(void) { + // B9 is configured as I2C1_SDA in the board file; that function must be + // disabled before using B7 as I2C1_SDA. + setPinInputHigh(B9); + setPinOutput(B12); + setPinOutput(B13); + setPinOutput(B14); + writePinLow(B12); + writePinLow(B13); + writePinLow(B14); + setPinOutput(C13); +} + +#ifdef DYNAMIC_TAPPING_TERM_ENABLE +void tap_modify(int change_value, bool tap_status) { + if (keyboard_config.dt_term_config < 0) { + keyboard_config.dt_term_config *= -1; + } + + keyboard_config.dt_term_config += change_value; + + if (tap_status == false ) { + keyboard_config.dt_term_config *= -1; + g_tapping_term = 0; + } else { + g_tapping_term = keyboard_config.dt_term_config; + } + eeconfig_update_kb(keyboard_config.raw); +} + +void tap_toggle(void) { + keyboard_config.dt_term_config *= -1; + if (keyboard_config.dt_term_config > 0) { + g_tapping_term = keyboard_config.dt_term_config; + } else { + g_tapping_term = 0; + } + eeconfig_update_kb(keyboard_config.raw); +} +#endif // ifdef DYNAMIC_TAPPING_TERM_ENABLE + +#ifdef DIP_SWITCH_ENABLE +bool dip_switch_update_kb(uint8_t index, bool active) { + if (!dip_switch_update_user(index, active)) { return false; } + switch (index) { + case 0: + if(active != host_keyboard_led_state().caps_lock) { tap_code(KC_CAPS); } + break; + break; + } + return true; +} +#endif + +#if defined(ENCODER_ENABLE) && ! defined(ENCODER_MAP_ENABLE) +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) { return false; } + switch (index) { + case 0: + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + break; + case 1: + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + break; + case 2: + if (clockwise) { + tap_code(KC_PGUP); + } else { + tap_code(KC_PGDN); + } + break; + case 3: + if (clockwise) { + tap_code(KC_WH_U); + } else { + tap_code(KC_WH_D); + } + break; + } + return true; +} +#endif + +bool led_update_kb(led_t led_state) { + bool res = led_update_user(led_state); + if(res) { + writePin(B12, led_state.num_lock); // Updates status LEDs + writePin(B13, led_state.caps_lock); // Updates status LEDs + writePin(B14, led_state.scroll_lock); // Updates status LEDs + writePin(C13, !led_state.caps_lock); // Updates status LEDs, this is the LED on the blackpill itself + } + return res; +} + +#ifdef OLED_ENABLE +static void render_logo(void) { // Render MechWild "MW" Logo + static const char PROGMEM logo_1[] = {0xCC, 0xCD, 0xCE, 0xCF, 0x00}; + static const char PROGMEM logo_2[] = {0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00}; + static const char PROGMEM logo_3[] = {0xD5, 0xD6, 0xD7, 0xD8, 0x00}; + static const char PROGMEM logo_4[] = {0xDE, 0xD9, 0xDA, 0xDB, 0x00}; + + oled_write_P(logo_1, false); + oled_set_cursor(0,1); + oled_write_P(logo_2, false); + oled_set_cursor(0,2); + oled_write_P(logo_3, false); + oled_set_cursor(0,3); + oled_write_P(logo_4, false); +} + +#ifdef OLED_DISPLAY_128X64 // Wide OLED Functionality +oled_rotation_t oled_init_kb(oled_rotation_t rotation) { + return OLED_ROTATION_180; // flips the display 180 degrees +} + +bool clear_screen = true; // used to manage singular screen clears to prevent display glitch +bool clear_screen_art = true; // used to manage singular screen clears to prevent display glitch +static void render_sugarglider_wide(void) { // Render sugarglider logo + static const char PROGMEM sgl_1[] = {0xDE, 0xDE, 0xDE, 0x98, 0x99, 0xDE, 0x9A, 0x9B, 0x9C, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xCC, 0xCD, 0xCE, 0xCF, 0x00}; + static const char PROGMEM sgl_2[] = {0x9D, 0x9E, 0xDE, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xDE, 0xDE, 0xDE, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00}; + static const char PROGMEM sgl_3[] = {0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xDE, 0xDE, 0xDE, 0xD5, 0xD6, 0xD7, 0xD8, 0x00}; + static const char PROGMEM sgl_4[] = {0xDE, 0xB2, 0xDE, 0xB3, 0xB4, 0xB5, 0xB6, 0xDE, 0xDE, 0xB7, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xD9, 0xDA, 0xDB, 0x00}; + static const char PROGMEM sgl_5[] = {0xDE, 0xB8, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xB9, 0x00}; + static const char PROGMEM sgl_6[] = {0xDE, 0xBA, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xBB, 0xBC, 0x00}; + static const char PROGMEM sgl_7[] = {0xDE, 0xBD, 0xBE, 0xDE, 0xDE, 0xBF, 0xDE, 0xDE, 0xC0, 0xC1, 0x00}; + static const char PROGMEM sgl_8[] = {0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0x00}; + + oled_write_P(sgl_1, false); + oled_set_cursor(0,1); + oled_write_P(sgl_2, false); + oled_set_cursor(0,2); + oled_write_P(sgl_3, false); + oled_set_cursor(0,3); + oled_write_P(sgl_4, false); + oled_set_cursor(0,4); + oled_write_P(sgl_5, false); + oled_set_cursor(0,5); + oled_write_P(sgl_6, false); + oled_set_cursor(0,6); + oled_write_P(sgl_7, false); + oled_set_cursor(0,7); + oled_write_P(sgl_8, false); +} + +bool oled_task_kb(void) { + if(!oled_task_user()) { + return false; + } + if ( !(host_keyboard_led_state().num_lock || host_keyboard_led_state().caps_lock || host_keyboard_led_state().scroll_lock ) && get_highest_layer(layer_state) == 0 ) { // If none of the status LEDs are active and also the active layer is the base layer + if (clear_screen_art == true) { + oled_clear(); + oled_render(); + clear_screen_art = false; + } + render_sugarglider_wide(); +#ifdef POINTING_DEVICE_ENABLE // only display dpi and tap info if pointing devices are active + oled_set_cursor(10,5); + oled_write_P(PSTR(" DPI:"), false); + oled_write(get_u16_str(dpi_array[keyboard_config.dpi_config], ' '), false); +#ifdef DYNAMIC_TAPPING_TERM_ENABLE // only display tap info if it is being configured dynamically + oled_set_cursor(10,6); + oled_write_P(PSTR(" TAP:"), false); + if (keyboard_config.dt_term_config < 0) { + oled_write_P(PSTR("Off "), false); + } else { + oled_write(get_u16_str(g_tapping_term, ' '), false); + } +#endif +#endif + clear_screen = true; + } else { // If any of the status LEDs are active or if the active layer is not the base layer + if (clear_screen == true) { + oled_clear(); + oled_render(); + clear_screen = false; + } + render_logo(); + oled_set_cursor(8,1); + switch (get_highest_layer(layer_state)) { + case 0: + oled_write_P(PSTR("Base "), false); + break; + case 1: + oled_write_P(PSTR("Lower "), false); + break; + case 2: + oled_write_P(PSTR("Raise "), false); + break; + case 3: + oled_write_P(PSTR("Adjust"), false); + break; + case 4: + oled_write_P(PSTR("Mouse "), false); + break; +#ifdef STENO_ENABLE + case 5: + oled_write_P(PSTR("Steno Layer"), false); + break; +#endif + default: + oled_write_P(PSTR("Layer ?"), false); // Should never display, here as a catchall + } + led_t led_state = host_keyboard_led_state(); + oled_set_cursor(8,0); + oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("SCR") : PSTR(" "), false); +#ifdef POINTING_DEVICE_ENABLE // only display dpi and tap info if pointing devices are active + oled_set_cursor(8,2); + oled_write_P(PSTR("DPI:"), false); + oled_write(get_u16_str(dpi_array[keyboard_config.dpi_config], ' '), false); +#ifdef DYNAMIC_TAPPING_TERM_ENABLE // only display tap info if it is being configured dynamically + oled_set_cursor(8,3); + oled_write_P(PSTR("TAP:"), false); + if (keyboard_config.dt_term_config < 0) { + oled_write_P(PSTR("Off "), false); + } else { + oled_write(get_u16_str(g_tapping_term, ' '), false); + } +#endif +#endif + clear_screen_art = true; + } + return true; +} +#else // Using an OLED but not the wide OLED +oled_rotation_t oled_init_kb(oled_rotation_t rotation) { + return OLED_ROTATION_270; // flips the display 270 degrees +} + + +bool oled_task_kb(void) { + if(!oled_task_user()) { + return false; + } + render_logo(); + + oled_set_cursor(0,5); + switch (get_highest_layer(layer_state)) { + case 0: + oled_write_P(PSTR("Base "), false); + break; + case 1: + oled_write_P(PSTR("Lower"), false); + break; + case 2: + oled_write_P(PSTR("Raise"), false); + break; + case 3: + oled_write_P(PSTR("Adjst"), false); + break; + case 4: + oled_write_P(PSTR("Mouse"), false); + break; +#ifdef STENO_ENABLE + case 5: + oled_write_P(PSTR("Steno"), false); + break; +#endif + default: + oled_write_P(PSTR("?????"), false); // Should never display, here as a catchall + } + led_t led_state = host_keyboard_led_state(); + oled_set_cursor(0,6); + oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false); +#ifdef POINTING_DEVICE_ENABLE + oled_set_cursor(0,11); + oled_write_P(PSTR("DPI: "), false); + oled_write(get_u16_str(dpi_array[keyboard_config.dpi_config], ' '), false); +#endif +#ifdef DYNAMIC_TAPPING_TERM_ENABLE // only display tap info if it is being configured dynamically + oled_set_cursor(0,13); + oled_write_P(PSTR("TAP: "), false); + if (keyboard_config.dt_term_config < 0) { + oled_write_P(PSTR("Off "), false); + } else { + oled_write(get_u16_str(g_tapping_term, ' '), false); + } +#endif + return true; +} +#endif // Not using wide OLED +#endif // ifdef OLED_ENABLE + +bool process_record_kb(uint16_t keycode, keyrecord_t* record) { + switch(keycode) { +#ifdef POINTING_DEVICE_ENABLE + case DPI_UP: + if (record->event.pressed) { + keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE; + eeconfig_update_kb(keyboard_config.raw); + pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]); + } + return false; + case DPI_DN: + if (record->event.pressed) { + if (keyboard_config.dpi_config > 0) { + keyboard_config.dpi_config = (keyboard_config.dpi_config - 1) % DPI_OPTION_SIZE; + } else { + keyboard_config.dpi_config = DPI_OPTION_SIZE - 1; + } + eeconfig_update_kb(keyboard_config.raw); + pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]); + } + return false; + case DPI_FINE: + if (record->event.pressed) { + pointing_device_set_cpi(dpi_array[0]); + } else { + pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]); + } + return false; +#endif +#ifdef DYNAMIC_TAPPING_TERM_ENABLE // only include tap info keycodes if it is being configured dynamically + case TAP_UP: + if (record->event.pressed) { + if (keyboard_config.dt_term_config < 5000) { + tap_modify(DYNAMIC_TAPPING_TERM_INCREMENT, true); + } + } + return false; + case TAP_DN: + if (record->event.pressed) { + if (keyboard_config.dt_term_config > 0) { + tap_modify(-1 * DYNAMIC_TAPPING_TERM_INCREMENT, true); + } + } + return false; + case TAP_ON: + if (record->event.pressed) { + tap_modify(0, true); + } + return false; + case TAP_OFF: + if (record->event.pressed) { + tap_modify(0, false); + } + return false; + case TAP_TOG: + if (record->event.pressed) { + tap_toggle(); + } + return false; +#endif // ifdef + } + return process_record_user(keycode, record); +} + +void pointing_device_init_kb(void) { +#ifdef POINTING_DEVICE_ENABLE + pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]); +#endif +} + +void eeconfig_init_kb(void) { +#ifdef POINTING_DEVICE_ENABLE + keyboard_config.dpi_config = GLIDEPOINT_DPI_DEFAULT; +#endif +#ifdef DYNAMIC_TAPPING_TERM_ENABLE // only set tap term from eeprom if it is being configured dynamically + keyboard_config.dt_term_config = TAPPING_TERM; +#endif + eeconfig_update_kb(keyboard_config.raw); +#ifdef STENO_ENABLE + steno_set_mode(STENO_MODE_GEMINI); // or STENO_MODE_BOLT +#endif + eeconfig_init_user(); +} + +void matrix_init_kb(void) { + // is safe to just read DPI setting since matrix init + // comes before pointing device init. + keyboard_config.raw = eeconfig_read_kb(); +#ifdef POINTING_DEVICE_ENABLE + if (keyboard_config.dpi_config > DPI_OPTION_SIZE) { + eeconfig_init_kb(); + } +#endif + matrix_init_user(); +} + +void keyboard_post_init_kb(void) { +#ifdef POINTING_DEVICE_ENABLE + pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]); +#endif +#ifdef RGBLIGHT_ENABLE + rgblight_toggle_noeeprom(); //double toggle post init removes the weirdness with rgb strips having a yellow first LED + rgblight_toggle_noeeprom(); +#endif +#ifdef DYNAMIC_TAPPING_TERM_ENABLE + tap_toggle(); // Need it to reevaluate this setting after initiating so that it is current after init + tap_toggle(); +#endif + keyboard_post_init_user(); +#ifdef OLED_ENABLE // purposefully after user post init to allow the RGB to startup first + wait_ms(200); // Avoids a startup issue where the oled renders and then turns off with blackpill + oled_on(); +#endif +} diff --git a/keyboards/mechwild/sugarglider/sugarglider.h b/keyboards/mechwild/sugarglider/sugarglider.h new file mode 100644 index 00000000000..d1fa540985a --- /dev/null +++ b/keyboards/mechwild/sugarglider/sugarglider.h @@ -0,0 +1,28 @@ +// Copyright 2023 Kyle McCreery +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "quantum.h" + +typedef union { + uint32_t raw; + struct { + uint8_t dpi_config; + int16_t dt_term_config; + }; +} keyboard_config_t; + +extern keyboard_config_t keyboard_config; +extern uint16_t dpi_array[]; + +enum keyboard_keycodes { + DPI_UP = QK_KB, + DPI_DN, + DPI_FINE, + TAP_UP, + TAP_DN, + TAP_ON, + TAP_OFF, + TAP_TOG +}; diff --git a/keyboards/mechwild/sugarglider/wide_oled/f401/rules.mk b/keyboards/mechwild/sugarglider/wide_oled/f401/rules.mk new file mode 100644 index 00000000000..a92d8a85c61 --- /dev/null +++ b/keyboards/mechwild/sugarglider/wide_oled/f401/rules.mk @@ -0,0 +1,3 @@ +# MCU name +MCU = STM32F401 +BOARD = BLACKPILL_STM32_F401 diff --git a/keyboards/mechwild/sugarglider/wide_oled/f411/rules.mk b/keyboards/mechwild/sugarglider/wide_oled/f411/rules.mk new file mode 100644 index 00000000000..db1d4054fdf --- /dev/null +++ b/keyboards/mechwild/sugarglider/wide_oled/f411/rules.mk @@ -0,0 +1,3 @@ +# MCU name +MCU = STM32F411 +BOARD = BLACKPILL_STM32_F411 diff --git a/keyboards/mechwild/sugarglider/wide_oled/rules.mk b/keyboards/mechwild/sugarglider/wide_oled/rules.mk new file mode 100644 index 00000000000..193169239b2 --- /dev/null +++ b/keyboards/mechwild/sugarglider/wide_oled/rules.mk @@ -0,0 +1,6 @@ +# Build Options +# change yes to no to disable +# +WIDE_OLED_ENABLE = yes + +DEFAULT_FOLDER = mechwild/sugarglider/wide_oled/f401 \ No newline at end of file