diff options
Diffstat (limited to 'keyboards/kbdmania/kmac_pad')
-rw-r--r-- | keyboards/kbdmania/kmac_pad/config.h | 52 | ||||
-rw-r--r-- | keyboards/kbdmania/kmac_pad/info.json | 41 | ||||
-rw-r--r-- | keyboards/kbdmania/kmac_pad/keymaps/default/keymap.c | 143 | ||||
-rw-r--r-- | keyboards/kbdmania/kmac_pad/keymaps/default/readme.md | 61 | ||||
-rw-r--r-- | keyboards/kbdmania/kmac_pad/kmac_pad.c | 29 | ||||
-rw-r--r-- | keyboards/kbdmania/kmac_pad/matrix.c | 111 | ||||
-rw-r--r-- | keyboards/kbdmania/kmac_pad/readme.md | 56 | ||||
-rw-r--r-- | keyboards/kbdmania/kmac_pad/rules.mk | 19 |
8 files changed, 512 insertions, 0 deletions
diff --git a/keyboards/kbdmania/kmac_pad/config.h b/keyboards/kbdmania/kmac_pad/config.h new file mode 100644 index 0000000000..ee27565dce --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/config.h @@ -0,0 +1,52 @@ +/* +Copyright 2021 talsu <talsu84@gmail.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 + + +/* key matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 4 + +/* + * Keyboard Matrix Assignments + * The KMAC uses demultiplexers for the cols, they are only included here as documentation. + * See matrix.c for more details. + */ +#define MATRIX_ROW_PINS { E2, D0, D1, D2, D3, D5 } +#define MATRIX_COL_PINS { C7, C6, B6, B5 } + +/* 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 diff --git a/keyboards/kbdmania/kmac_pad/info.json b/keyboards/kbdmania/kmac_pad/info.json new file mode 100644 index 0000000000..f41da8a452 --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/info.json @@ -0,0 +1,41 @@ +{ + "keyboard_name": "KMAC PAD", + "manufacturer": "KBDMania", + "maintainer": "talsu", + "usb": { + "vid": "0x4B4D", + "pid": "0x4143", + "device_version": "1.0.4" + }, + "processor": "atmega32u4", + "bootloader": "atmel-dfu", + "layouts": { + "LAYOUT": { + "layout": [ + {"matrix": [0, 0], "x": 3, "y": 0}, + + {"matrix": [1, 0], "x": 0, "y": 1.25}, + {"matrix": [1, 1], "x": 1, "y": 1.25}, + {"matrix": [1, 2], "x": 2, "y": 1.25}, + {"matrix": [1, 3], "x": 3, "y": 1.25}, + + {"matrix": [2, 0], "x": 0, "y": 2.25}, + {"matrix": [2, 1], "x": 1, "y": 2.25}, + {"matrix": [2, 2], "x": 2, "y": 2.25}, + {"matrix": [2, 3], "x": 3, "y": 2.25, "h": 2}, + + {"matrix": [3, 0], "x": 0, "y": 3.25}, + {"matrix": [3, 1], "x": 1, "y": 3.25}, + {"matrix": [3, 2], "x": 2, "y": 3.25}, + + {"matrix": [4, 0], "x": 0, "y": 4.25}, + {"matrix": [4, 1], "x": 1, "y": 4.25}, + {"matrix": [4, 2], "x": 2, "y": 4.25}, + {"matrix": [4, 3], "x": 3, "y": 4.25, "h": 2}, + + {"matrix": [5, 0], "x": 0, "y": 5.25, "w": 2}, + {"matrix": [5, 2], "x": 2, "y": 5.25} + ] + } + } +} diff --git a/keyboards/kbdmania/kmac_pad/keymaps/default/keymap.c b/keyboards/kbdmania/kmac_pad/keymaps/default/keymap.c new file mode 100644 index 0000000000..e6afa53346 --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/keymaps/default/keymap.c @@ -0,0 +1,143 @@ +/* +Copyright 2021 talsu <talsu84@gmail.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 + +enum kmac_pad_keycodes { + MD_BOOT = SAFE_RANGE, + MCR1, + MCR2, + MCR3, + MCR4, + MCR5, + MCR6, + MCR7, + MCR8, + MCR9, + MCR10, + MCR11, + MCR12 +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT( /* Base */ + TG(1), + KC_NUM, KC_PSLS, KC_PAST, KC_PMNS, + KC_P7, KC_P8, KC_P9, KC_PPLS, + KC_P4, KC_P5, KC_P6, + KC_P1, KC_P2, KC_P3, KC_PENT, + KC_P0, KC_PDOT ), + [1] = LAYOUT( /* FN */ + KC_TRNS, + MCR1, MCR2, MCR3, KC_TRNS, + MCR4, MCR5, MCR6, KC_TRNS, + MCR7, MCR8, MCR9, + MCR10, MCR11, MCR12, KC_TRNS, + KC_TRNS, MD_BOOT ) +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + + switch (keycode) { + case MD_BOOT: + { + static uint32_t key_timer; + if (record->event.pressed) { + key_timer = timer_read32(); + } else { + if (timer_elapsed32(key_timer) >= 2000) { + reset_keyboard(); + } + } + return false; + } + case MCR1: + if (record->event.pressed) { + SEND_STRING("Macro 1"); + } + return false; + case MCR2: + if (record->event.pressed) { + SEND_STRING("Macro 2"); + } + return false; + case MCR3: + if (record->event.pressed) { + SEND_STRING("Macro 3"); + } + return false; + case MCR4: + if (record->event.pressed) { + SEND_STRING("Macro 4"); + } + return false; + case MCR5: + if (record->event.pressed) { + SEND_STRING("Macro 5"); + } + return false; + case MCR6: + if (record->event.pressed) { + SEND_STRING("Macro 6"); + } + return false; + case MCR7: + if (record->event.pressed) { + SEND_STRING("Macro 7"); + } + return false; + case MCR8: + if (record->event.pressed) { + SEND_STRING("Macro 8"); + } + return false; + case MCR9: + if (record->event.pressed) { + SEND_STRING("Macro 9"); + } + return false; + case MCR10: + if (record->event.pressed) { + SEND_STRING("Macro 10"); + } + return false; + case MCR11: + if (record->event.pressed) { + SEND_STRING("Macro 12"); + } + return false; + case MCR12: + if (record->event.pressed) { + SEND_STRING("Macro 12"); + } + return false; + default: + return true; + } + +} + +bool led_update_user(led_t led_state) { + writePin(B1, led_state.num_lock); + return false; +} + + +layer_state_t layer_state_set_user(layer_state_t state) { + writePin(B3, !IS_LAYER_ON_STATE(state, 0)); + return state; +} diff --git a/keyboards/kbdmania/kmac_pad/keymaps/default/readme.md b/keyboards/kbdmania/kmac_pad/keymaps/default/readme.md new file mode 100644 index 0000000000..3b9b739a2a --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/keymaps/default/readme.md @@ -0,0 +1,61 @@ +# The default keymap for KMAC PAD + +This is the default keymap. It implements the same features as the official default KMAC PAD firmware. + +## Layers + +The keymap has two layers. Press the 'FN' key to toggle the Default layer and Function layer. + +### Layer 1: Default Layer + + ,---. + |TG1| + `---' + ,---------------. + |NUM| / | * | - | + |---------------| + | 7 | 8 | 9 | | + |-----------| + | + | 4 | 5 | 6 | | + |---------------| + | 1 | 2 | 3 | | + |-----------|Ent| + | 0 | . | | + '---------------' + +### Layer 2: Function Layer + + ,---. + |TG1| + `---' + ,---------------. + |M1 |M2 |M3 | | + |---------------| + |M4 |M5 |M6 | | + |-----------| | + |M7 |M8 |M9 | | + |---------------| + |M10|M11|M12| | + |-----------| | + | | | | + '---------------' + +## Macros + +The default macro is typed with meaningless strings that exist as samples. + + +| Macro | Action | +|:-----:| -------------------------------------- | +| 1 | Types `Macro 1` | +| 2 | Types `Macro 2` | +| 3 | Types `Macro 3` | +| 4 | Types `Macro 4` | +| 5 | Types `Macro 5` | +| 6 | Types `Macro 6` | +| 7 | Types `Macro 7` | +| 8 | Types `Macro 8` | +| 9 | Types `Macro 9` | +| 10 | Types `Macro 10` | +| 11 | Types `Macro 11` | +| 12 | Types `Macro 12` | diff --git a/keyboards/kbdmania/kmac_pad/kmac_pad.c b/keyboards/kbdmania/kmac_pad/kmac_pad.c new file mode 100644 index 0000000000..3de2cb711e --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/kmac_pad.c @@ -0,0 +1,29 @@ +/* +Copyright 2021 talsu <talsu84@gmail.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 "quantum.h" + +void keyboard_pre_init_kb(void) { + + /* Set Backlight pin as output + * FN Pin PB3 + * PAD Pin PB1 + */ + setPinOutput(B3); + setPinOutput(B1); + keyboard_pre_init_user(); +} diff --git a/keyboards/kbdmania/kmac_pad/matrix.c b/keyboards/kbdmania/kmac_pad/matrix.c new file mode 100644 index 0000000000..476e40f514 --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/matrix.c @@ -0,0 +1,111 @@ +/* +Copyright 2021 talsu <talsu84@gmail.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 "wait.h" +#include "matrix.h" +#include "quantum.h" + +static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; +static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; + +/* Columns 0 - 3 + * col / pin: + * 0: C7 + * 1: C6 + * 2: B6 + * 3: B5 + */ +static void unselect_cols(void) { + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + setPinOutput(col_pins[col]); + writePinLow(col_pins[col]); + } +} + +static void select_col(uint8_t col) { + writePinHigh(col_pins[col]); +} + +static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { + bool matrix_changed = false; + + // Select col and wait for col selecton to stabilize + select_col(current_col); + wait_us(30); + + // row:0 , col:0 FN key is DIRECT_PIN + if (current_col == 0) { + + matrix_row_t last_row_value = current_matrix[0]; + if (readPin(row_pins[0]) == 0) { + // Pin LO, set col bit + current_matrix[0] |= (1 << current_col); + } else { + // Pin HI, clear col bit + current_matrix[0] &= ~(1 << current_col); + } + + // Determine if the matrix changed state + if ((last_row_value != current_matrix[0]) && !(matrix_changed)) { + matrix_changed = true; + } + } + + // other row use MATRIX + for (uint8_t row_index = 1; row_index < MATRIX_ROWS; row_index++) { + + matrix_row_t last_row_value = current_matrix[row_index]; + if (readPin(row_pins[row_index]) == 0) { + // Pin HI, clear col bit + current_matrix[row_index] &= ~(1 << current_col); + } else { + // Pin LO, set col bit + current_matrix[row_index] |= (1 << current_col); + } + + // Determine if the matrix changed state + if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) { + matrix_changed = true; + } + } + + + // Unselect cols + unselect_cols(); + + return matrix_changed; +} + +void matrix_init_custom(void) { + // initialize hardware and global matrix state here + unselect_cols(); + + // initialize key pins + for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) { + setPinInputHigh(row_pins[row_index]); + } +} + +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + bool changed = false; + + for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { + changed |= read_rows_on_col(current_matrix, current_col); + } + + return changed; +} diff --git a/keyboards/kbdmania/kmac_pad/readme.md b/keyboards/kbdmania/kmac_pad/readme.md new file mode 100644 index 0000000000..59cc307073 --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/readme.md @@ -0,0 +1,56 @@ +# KMAC PAD + +![kmac_pad](https://i.imgur.com/4P1ybgNl.jpg) + +KMAC PAD is a num pad keyboard. +It can be used independently, but can also be used by connecting with KMAC keyboard case. + +* Keyboard Maintainer: [talsu](https://github.com/talsu) +* Hardware Supported: KMAC PAD +* Hardware Availability: [KBDMania](http://www.kbdmania.net/xe/news/5232321) + +Make example for this keyboard (after setting up your build environment): + + make kbdmania/kmac_pad:default + +Flashing example for this keyboard: + + make kbdmania/kmac_pad: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 + +The PCB is hardwired to run the bootloader if the key at the `FN` position (the only key in first row) is held down when connecting the keyboard. + +## PCB + +![Imgur](https://i.imgur.com/ML66cvfl.jpg) +![Imgur](https://i.imgur.com/Kr2Wdtkl.jpg) + +### Switch Pins + +The FN key in the `Row 0` is directly connected to the E2 pin. +The rest of the rows below that use MATRIX. (`Row 1 ~ Row 5`) +| Row | Pin | +|:-----:| ---------------------- | +| 0 | x (Not in Matrix) | +| 1 | D0 | +| 2 | D1 | +| 3 | D2 | +| 4 | D3 | +| 5 | D5 | + +| Column | Pin | +|:------:| --------------------- | +| 0 | C7 | +| 1 | C6 | +| 2 | B6 | +| 3 | B5 | + +### Backlight Pins + +There are 2 pins for backlight. + +The LED of the FN key uses pin `B3`. +All other keys are connected to the `B1` pin. diff --git a/keyboards/kbdmania/kmac_pad/rules.mk b/keyboards/kbdmania/kmac_pad/rules.mk new file mode 100644 index 0000000000..1c42620aca --- /dev/null +++ b/keyboards/kbdmania/kmac_pad/rules.mk @@ -0,0 +1,19 @@ +# Processor frequency +F_CPU = 8000000 + +# 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 +NKRO_ENABLE = yes # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +CUSTOM_MATRIX = lite # Custom matrix file + +# Project specific files +SRC += matrix.c |