From 22eba600418696542a6b84125f4dff2f37638c1e Mon Sep 17 00:00:00 2001 From: Albert Y <76888457+filterpaper@users.noreply.github.com> Date: Tue, 16 Nov 2021 09:05:15 +0800 Subject: [PATCH] [Keyboard] Add macro3 PCB support (#15131) Co-authored-by: Joel Challis Co-authored-by: Drashna Jaelre Co-authored-by: Ryan Co-authored-by: filterpaper --- keyboards/macro3/config.h | 55 +++++++++++++++++++++++ keyboards/macro3/info.json | 20 +++++++++ keyboards/macro3/keymaps/default/keymap.c | 30 +++++++++++++ keyboards/macro3/macro3.c | 39 ++++++++++++++++ keyboards/macro3/macro3.h | 28 ++++++++++++ keyboards/macro3/readme.md | 26 +++++++++++ keyboards/macro3/rules.mk | 22 +++++++++ 7 files changed, 220 insertions(+) create mode 100644 keyboards/macro3/config.h create mode 100644 keyboards/macro3/info.json create mode 100644 keyboards/macro3/keymaps/default/keymap.c create mode 100644 keyboards/macro3/macro3.c create mode 100644 keyboards/macro3/macro3.h create mode 100644 keyboards/macro3/readme.md create mode 100644 keyboards/macro3/rules.mk diff --git a/keyboards/macro3/config.h b/keyboards/macro3/config.h new file mode 100644 index 000000000..59f7a151c --- /dev/null +++ b/keyboards/macro3/config.h @@ -0,0 +1,55 @@ +/* Copyright 2020 David Philip Barr <@davidphilipbarr> + * Copyright 2021 @filterpaper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xC88B +#define PRODUCT_ID 0x3388 +#define DEVICE_VER 0x0003 +#define MANUFACTURER DPB +#define PRODUCT Macro3 + +/* key matrix size */ +#define MATRIX_ROWS 2 +#define MATRIX_COLS 4 + +/* key matrix pins */ +#define DIRECT_PINS { \ + { D7, C6, D4, D1 }, \ + { B1, B4, B5, B3 } \ +} + +#define ENCODERS_PAD_A { D2, F7 } +#define ENCODERS_PAD_B { D3, F6 } + +#define UNUSED_PINS + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* Top right key */ +#define BOOTMAGIC_LITE_ROW 0 +#define BOOTMAGIC_LITE_COLUMN 3 + diff --git a/keyboards/macro3/info.json b/keyboards/macro3/info.json new file mode 100644 index 000000000..b25779cb7 --- /dev/null +++ b/keyboards/macro3/info.json @@ -0,0 +1,20 @@ +{ + "keyboard_name": "Macro3", + "url": "https://github.com/davidphilipbarr/Macropads/tree/main/macro3", + "maintainer": "@davidphilipbarr", + "layouts": { + "LAYOUT": { + "layout": [ + {"x": 0, "y": 0}, + {"x": 1, "y": 0}, + {"x": 2, "y": 0}, + {"x": 3, "y": 0}, + + {"x": 0, "y": 1}, + {"x": 1, "y": 1}, + {"x": 2, "y": 1}, + {"x": 3, "y": 1}, + ] + } + } +} diff --git a/keyboards/macro3/keymaps/default/keymap.c b/keyboards/macro3/keymaps/default/keymap.c new file mode 100644 index 000000000..ca4db51f3 --- /dev/null +++ b/keyboards/macro3/keymaps/default/keymap.c @@ -0,0 +1,30 @@ +/* Copyright 2020 David Philip Barr <@davidphilipbarr> + * Copyright 2021 @filterpaper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT( + KC_HOME, KC_MUTE, KC_MPLY, KC_MSEL, + KC_UNDO, KC_CUT, KC_COPY, LT(1,KC_PSTE) + ), + [1] = LAYOUT( + _______, _______, _______, _______, + RESET, _______, _______, _______ + ) +}; + diff --git a/keyboards/macro3/macro3.c b/keyboards/macro3/macro3.c new file mode 100644 index 000000000..cc12c0268 --- /dev/null +++ b/keyboards/macro3/macro3.c @@ -0,0 +1,39 @@ +/* Copyright 2020 David Philip Barr <@davidphilipbarr> + * Copyright 2021 @filterpaper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "macro3.h" + +#ifdef ENCODER_ENABLE +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) { return false; } + if (index == 1) { + if (clockwise) { + tap_code(KC_VOLD); + } else { + tap_code(KC_VOLU); + } + } else if (index == 0) { + if (clockwise) { + tap_code(KC_WH_D); + } else { + tap_code(KC_WH_U); + } + } + return true; +} +#endif + diff --git a/keyboards/macro3/macro3.h b/keyboards/macro3/macro3.h new file mode 100644 index 000000000..12621d2c0 --- /dev/null +++ b/keyboards/macro3/macro3.h @@ -0,0 +1,28 @@ +/* Copyright 2020 David Philip Barr <@davidphilipbarr> + * Copyright 2021 @filterpaper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "quantum.h" + +#define LAYOUT( \ + K00, K01, K02, K03, \ + K10, K11, K12, K13 \ +) \ +{ \ + { K00, K01, K02, K03 }, \ + { K10, K11, K12, K13 } \ +} + diff --git a/keyboards/macro3/readme.md b/keyboards/macro3/readme.md new file mode 100644 index 000000000..66a142ecd --- /dev/null +++ b/keyboards/macro3/readme.md @@ -0,0 +1,26 @@ +# Macro3 + +![Macro3](https://github.com/davidphilipbarr/Macropads/raw/main/macro3/IMG_20200703_170424.jpg) + +Macro3 is a low-profile macro pad with encoder support designed by [@davidphilipbarr](https://github.com/davidphilipbarr) using direct micro-controller pin wiring. + +## Keyboard Info + +* Keyboard Maintainer: [davidphilipbarr](https://github.com/davidphilipbarr) +* Hardware Supported: [Macro3](https://github.com/davidphilipbarr/Macropads/tree/main/macro3) +* Hardware Availability: order PCBs with gerber file from the repository + +Make example for this keyboard (after setting up your build environment): + + make macro3:default + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +Enter the bootloader in 3 ways: + +* **Bootmagic reset**: Hold down the top right key and plug in the controller. +* **Physical reset button**: Briefly press the reset button soldered on the PCB. +* **Keycode in layout**: Press the key mapped to `RESET` if it is configured. + diff --git a/keyboards/macro3/rules.mk b/keyboards/macro3/rules.mk new file mode 100644 index 000000000..baba7d9d8 --- /dev/null +++ b/keyboards/macro3/rules.mk @@ -0,0 +1,22 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = atmel-dfu + +# 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 = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = no # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +ENCODER_ENABLE = yes