diff options
author | Moritz Plattner <moritz.plattner@gmx.net> | 2023-04-02 20:02:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-02 12:02:20 -0600 |
commit | 5687fc76468803db27dd9f04a72766f80141c6cd (patch) | |
tree | d91bf941b810ba958085efd81bca55a26325912c /keyboards/geistmaschine | |
parent | ebe36ea83c860fc26e4e8344a133eb0355b411f0 (diff) |
Add support for Geistmaschine Macropod (#20116)
Co-authored-by: Pablo MartÃnez <58857054+elpekenin@users.noreply.github.com>
Diffstat (limited to 'keyboards/geistmaschine')
-rw-r--r-- | keyboards/geistmaschine/macropod/config.h | 21 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/info.json | 41 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/keymaps/default/keymap.c | 35 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/keymaps/default/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/keymaps/via/keymap.c | 35 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/keymaps/via/rules.mk | 2 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/macropod.c | 21 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/matrix.c | 87 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/readme.md | 25 | ||||
-rw-r--r-- | keyboards/geistmaschine/macropod/rules.mk | 5 |
10 files changed, 273 insertions, 0 deletions
diff --git a/keyboards/geistmaschine/macropod/config.h b/keyboards/geistmaschine/macropod/config.h new file mode 100644 index 0000000000..f6dad6ebe0 --- /dev/null +++ b/keyboards/geistmaschine/macropod/config.h @@ -0,0 +1,21 @@ +/* + * 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 + +/* key matrix size, only 1x4 are used in current state. + IO expander setup would allow up to 1x16 + 1 from the MCU */ +#define MATRIX_ROWS 1 +#define MATRIX_COLS 17 diff --git a/keyboards/geistmaschine/macropod/info.json b/keyboards/geistmaschine/macropod/info.json new file mode 100644 index 0000000000..c2a77905b1 --- /dev/null +++ b/keyboards/geistmaschine/macropod/info.json @@ -0,0 +1,41 @@ +{ + "manufacturer": "Geistmaschine", + "keyboard_name": "Macropod", + "maintainer": "ebastler", + "bootloader": "atmel-dfu", + "processor": "atmega32u4", + "url": "https://geistmaschine.io/", + "usb": { + "device_version": "1.0.0", + "pid": "0x0004", + "vid": "0x676D" + }, + "features": { + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": false, + "nkro": false, + "encoder": true + }, + "encoder": { + "rotary": [ + { + "pin_a": "D3", + "pin_b": "D5", + "resolution": 2 + } + ] + }, + "layouts": { + "LAYOUT_fourkey": { + "layout": [ + {"x":0, "y":0, "matrix":[0,0] }, + {"x":0, "y":1.25, "matrix":[0,1] }, + {"x":0, "y":2.25, "matrix":[0,2] }, + {"x":0, "y":3.25, "matrix":[0,3] } + ] + } + } +}
\ No newline at end of file diff --git a/keyboards/geistmaschine/macropod/keymaps/default/keymap.c b/keyboards/geistmaschine/macropod/keymaps/default/keymap.c new file mode 100644 index 0000000000..fb2d971202 --- /dev/null +++ b/keyboards/geistmaschine/macropod/keymaps/default/keymap.c @@ -0,0 +1,35 @@ +/* Copyright 2023 Moritz Plattner + * + * 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 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT_fourkey ( + LT(1, KC_MUTE), KC_MPRV, KC_MPLY, KC_MNXT + ), + + [1] = LAYOUT_fourkey ( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + +}; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { + [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [1] = { ENCODER_CCW_CW(KC_MRWD, KC_MFFD) }, +}; +#endif
\ No newline at end of file diff --git a/keyboards/geistmaschine/macropod/keymaps/default/rules.mk b/keyboards/geistmaschine/macropod/keymaps/default/rules.mk new file mode 100644 index 0000000000..ee32568148 --- /dev/null +++ b/keyboards/geistmaschine/macropod/keymaps/default/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/geistmaschine/macropod/keymaps/via/keymap.c b/keyboards/geistmaschine/macropod/keymaps/via/keymap.c new file mode 100644 index 0000000000..fb2d971202 --- /dev/null +++ b/keyboards/geistmaschine/macropod/keymaps/via/keymap.c @@ -0,0 +1,35 @@ +/* Copyright 2023 Moritz Plattner + * + * 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 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT_fourkey ( + LT(1, KC_MUTE), KC_MPRV, KC_MPLY, KC_MNXT + ), + + [1] = LAYOUT_fourkey ( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + +}; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { + [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [1] = { ENCODER_CCW_CW(KC_MRWD, KC_MFFD) }, +}; +#endif
\ No newline at end of file diff --git a/keyboards/geistmaschine/macropod/keymaps/via/rules.mk b/keyboards/geistmaschine/macropod/keymaps/via/rules.mk new file mode 100644 index 0000000000..6ccd6d9194 --- /dev/null +++ b/keyboards/geistmaschine/macropod/keymaps/via/rules.mk @@ -0,0 +1,2 @@ +ENCODER_MAP_ENABLE = yes +VIA_ENABLE = yes
\ No newline at end of file diff --git a/keyboards/geistmaschine/macropod/macropod.c b/keyboards/geistmaschine/macropod/macropod.c new file mode 100644 index 0000000000..2f6825e2ee --- /dev/null +++ b/keyboards/geistmaschine/macropod/macropod.c @@ -0,0 +1,21 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "quantum.h" + +// This will be overridden by encoder map in all default keymaps, but serves as a catch-all for user keymaps that may omit the map. +#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; /* Don't process further events if user function exists and returns false */ + } + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code_delay(KC_VOLU, 10); + } else { + tap_code_delay(KC_VOLD, 10); + } + } + return true; +} +#endif
\ No newline at end of file diff --git a/keyboards/geistmaschine/macropod/matrix.c b/keyboards/geistmaschine/macropod/matrix.c new file mode 100644 index 0000000000..60b1dafe63 --- /dev/null +++ b/keyboards/geistmaschine/macropod/matrix.c @@ -0,0 +1,87 @@ +/* Copyright 2023 ebastler and elpekenin + * + * 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 "pca9555.h" +#include "quantum.h" + +// PCA9555 i2c address, 0x20: A0 = 0, A1 = 0, A2 = 0 +#define IC1 0x20 + +// Define how long to wait to reach the IO expander after connection loss again +// Since this board is modular, it should not spam unnecessary i2c requests if used without a module +#define RETRY_TIMESPAN 2000 + +typedef enum { + PLUGGED, + DOUBTFUL, + UNPLUGGED +} expander_status_t; + +void pca9555_setup(void) { + // Initialize the expander, no need to set ports to inputs as that is the default behavior + pca9555_init(IC1); +} + +void matrix_init_custom(void) { + // Encoder pushbutton on the MCU is connected to PD2 + setPinInputHigh(D2); + pca9555_setup(); +} + +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + static expander_status_t status = DOUBTFUL; + static uint32_t retry_timer = 0; + + // initialize one byte filled with 1 + uint8_t pin_states = 0xFF; + + + if (status != UNPLUGGED || timer_elapsed32(retry_timer) > RETRY_TIMESPAN) { + // If the chip was unplugged before, it needs to be re-initialized + if(status==UNPLUGGED) { + pca9555_setup(); + } + // Read the entire port into this byte, 1 = not pressed, 0 = pressed + bool ret = pca9555_readPins(IC1, PCA9555_PORT0, &pin_states); + + // Update state + if (ret) { + status = PLUGGED; + } else { + switch (status) { + case PLUGGED: + status = DOUBTFUL; + break; + + case DOUBTFUL: + status = UNPLUGGED; + break; + + // If we've diagnosed as unplugged, update timer to not read I2C + case UNPLUGGED: + retry_timer = timer_read32(); + } + } + } + + // Shift pin states by 1 to make room for the switch connected to the MCU, then OR them together and invert (as QMK uses inverted logic compared to the electrical levels) + matrix_row_t data = ~(pin_states << 1 | readPin(D2)); + + bool changed = current_matrix[0] != data; + current_matrix[0] = data; + + return changed; +}
\ No newline at end of file diff --git a/keyboards/geistmaschine/macropod/readme.md b/keyboards/geistmaschine/macropod/readme.md new file mode 100644 index 0000000000..5d074437cb --- /dev/null +++ b/keyboards/geistmaschine/macropod/readme.md @@ -0,0 +1,25 @@ +# Geistmaschine Macropod + +![macropod](https://i.imgur.com/lAsCslA.png) + +Macropod is a modular macropad, designed around a central big encoder with a magnetic connector for modularity. The default module uses three MX style keys. +* Keyboard Maintainer: [ebastler](https://github.com/ebastler) +* Hardware Supported: Macropod rev1 +* Hardware Availability: [geistmaschine.io](https://geistmaschine.io/) + +Make example for this keyboard (after setting up your build environment): + + qmk compile -kb geistmaschine/macropod -km default + +Flashing example for this keyboard: + + qmk flash -kb geistmaschine/macropod -km 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 2 ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (the knob on the main module) and plug in the keyboard +* **Physical reset button**: Briefly tap the button marked "RST" on the back of the main module PCB diff --git a/keyboards/geistmaschine/macropod/rules.mk b/keyboards/geistmaschine/macropod/rules.mk new file mode 100644 index 0000000000..cf2b38601e --- /dev/null +++ b/keyboards/geistmaschine/macropod/rules.mk @@ -0,0 +1,5 @@ +CUSTOM_MATRIX = lite + +VPATH += drivers/gpio +SRC += pca9555.c matrix.c +QUANTUM_LIB_SRC += i2c_master.c
\ No newline at end of file |