aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/kmac_pad/config.h102
-rw-r--r--keyboards/kmac_pad/info.json35
-rw-r--r--keyboards/kmac_pad/keymaps/default/keymap.c143
-rw-r--r--keyboards/kmac_pad/keymaps/default/readme.md61
-rw-r--r--keyboards/kmac_pad/kmac_pad.c29
-rw-r--r--keyboards/kmac_pad/kmac_pad.h37
-rw-r--r--keyboards/kmac_pad/matrix.c111
-rw-r--r--keyboards/kmac_pad/readme.md56
-rw-r--r--keyboards/kmac_pad/rules.mk29
9 files changed, 603 insertions, 0 deletions
diff --git a/keyboards/kmac_pad/config.h b/keyboards/kmac_pad/config.h
new file mode 100644
index 000000000..eb33a994b
--- /dev/null
+++ b/keyboards/kmac_pad/config.h
@@ -0,0 +1,102 @@
1/*
2Copyright 2021 talsu <talsu84@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include "config_common.h"
21
22/* USB Device descriptor parameter */
23#define VENDOR_ID 0x4B4D // KM
24#define PRODUCT_ID 0x4143 // AC
25#define DEVICE_VER 0x0104
26#define MANUFACTURER KBDMania
27#define PRODUCT KMAC PAD
28
29/* key matrix size */
30#define MATRIX_ROWS 6
31#define MATRIX_COLS 4
32
33/*
34 * Keyboard Matrix Assignments
35 * The KMAC uses demultiplexers for the cols, they are only included here as documentation.
36 * See matrix.c for more details.
37 */
38#define MATRIX_ROW_PINS { E2, D0, D1, D2, D3, D5 }
39#define MATRIX_COL_PINS { C7, C6, B6, B5 }
40#define UNUSED_PINS
41
42/* COL2ROW, ROW2COL*/
43// #define DIODE_DIRECTION COL2ROW
44
45// #define LED_CAPS_LOCK_PIN B0
46// #define LED_SCROLL_LOCK_PIN E6
47// #define LED_PIN_ON_STATE 0
48
49/* number of backlight levels */
50// #define BACKLIGHT_LEVELS 3
51// #define BACKLIGHT_PIN B7
52// #define BACKLIGHT_BREATHING
53
54/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
55#define DEBOUNCE 5
56
57/* define if matrix has ghost (lacks anti-ghosting diodes) */
58//#define MATRIX_HAS_GHOST
59
60/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
61#define LOCKING_SUPPORT_ENABLE
62/* Locking resynchronize hack */
63#define LOCKING_RESYNC_ENABLE
64
65/*
66 * Force NKRO
67 *
68 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
69 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
70 * makefile for this to work.)
71 *
72 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
73 * until the next keyboard reset.
74 *
75 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
76 * fully operational during normal computer usage.
77 *
78 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
79 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
80 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
81 * power-up.
82 *
83 */
84//#define FORCE_NKRO
85
86/*
87 * Feature disable options
88 * These options are also useful to firmware size reduction.
89 */
90
91/* disable debug print */
92//#define NO_DEBUG
93
94/* disable print */
95//#define NO_PRINT
96
97/* disable action features */
98//#define NO_ACTION_LAYER
99//#define NO_ACTION_TAPPING
100//#define NO_ACTION_ONESHOT
101//#define NO_ACTION_MACRO
102//#define NO_ACTION_FUNCTION
diff --git a/keyboards/kmac_pad/info.json b/keyboards/kmac_pad/info.json
new file mode 100644
index 000000000..6a17b3d45
--- /dev/null
+++ b/keyboards/kmac_pad/info.json
@@ -0,0 +1,35 @@
1{
2 "keyboard_name": "KMAC PAD",
3 "maintainer": "talsu",
4 "width": 4,
5 "height": 6.5,
6 "layouts": {
7 "LAYOUT": {
8 "layout": [
9 {"label":"K00", "x":3, "y":0},
10
11 {"label":"K10", "x":0, "y":1.25},
12 {"label":"K11", "x":1, "y":1.25},
13 {"label":"K12", "x":2, "y":1.25},
14 {"label":"K13", "x":3, "y":1.25},
15
16 {"label":"K20", "x":0, "y":2.25},
17 {"label":"K21", "x":1, "y":2.25},
18 {"label":"K22", "x":2, "y":2.25},
19 {"label":"K23", "x":3, "y":2.25, "h":2},
20
21 {"label":"K30", "x":0, "y":3.25},
22 {"label":"K31", "x":1, "y":3.25},
23 {"label":"K32", "x":2, "y":3.25},
24
25 {"label":"K40", "x":0, "y":4.25},
26 {"label":"K41", "x":1, "y":4.25},
27 {"label":"K42", "x":2, "y":4.25},
28 {"label":"K43", "x":3, "y":4.25, "h":2},
29
30 {"label":"K50", "x":0, "y":5.25, "w":2},
31 {"label":"K52", "x":2, "y":5.25}
32 ]
33 }
34 }
35}
diff --git a/keyboards/kmac_pad/keymaps/default/keymap.c b/keyboards/kmac_pad/keymaps/default/keymap.c
new file mode 100644
index 000000000..b9b9f823f
--- /dev/null
+++ b/keyboards/kmac_pad/keymaps/default/keymap.c
@@ -0,0 +1,143 @@
1/*
2Copyright 2021 talsu <talsu84@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include QMK_KEYBOARD_H
19
20enum kmac_pad_keycodes {
21 MD_BOOT = SAFE_RANGE,
22 MCR1,
23 MCR2,
24 MCR3,
25 MCR4,
26 MCR5,
27 MCR6,
28 MCR7,
29 MCR8,
30 MCR9,
31 MCR10,
32 MCR11,
33 MCR12
34};
35
36const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
37 [0] = LAYOUT( /* Base */
38 TG(1),
39 KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS,
40 KC_P7, KC_P8, KC_P9, KC_PPLS,
41 KC_P4, KC_P5, KC_P6,
42 KC_P1, KC_P2, KC_P3, KC_PENT,
43 KC_P0, KC_PDOT ),
44 [1] = LAYOUT( /* FN */
45 KC_TRNS,
46 MCR1, MCR2, MCR3, KC_TRNS,
47 MCR4, MCR5, MCR6, KC_TRNS,
48 MCR7, MCR8, MCR9,
49 MCR10, MCR11, MCR12, KC_TRNS,
50 KC_TRNS, MD_BOOT )
51};
52
53bool process_record_user(uint16_t keycode, keyrecord_t *record) {
54
55 switch (keycode) {
56 case MD_BOOT:
57 {
58 static uint32_t key_timer;
59 if (record->event.pressed) {
60 key_timer = timer_read32();
61 } else {
62 if (timer_elapsed32(key_timer) >= 2000) {
63 reset_keyboard();
64 }
65 }
66 return false;
67 }
68 case MCR1:
69 if (record->event.pressed) {
70 SEND_STRING("Macro 1");
71 }
72 return false;
73 case MCR2:
74 if (record->event.pressed) {
75 SEND_STRING("Macro 2");
76 }
77 return false;
78 case MCR3:
79 if (record->event.pressed) {
80 SEND_STRING("Macro 3");
81 }
82 return false;
83 case MCR4:
84 if (record->event.pressed) {
85 SEND_STRING("Macro 4");
86 }
87 return false;
88 case MCR5:
89 if (record->event.pressed) {
90 SEND_STRING("Macro 5");
91 }
92 return false;
93 case MCR6:
94 if (record->event.pressed) {
95 SEND_STRING("Macro 6");
96 }
97 return false;
98 case MCR7:
99 if (record->event.pressed) {
100 SEND_STRING("Macro 7");
101 }
102 return false;
103 case MCR8:
104 if (record->event.pressed) {
105 SEND_STRING("Macro 8");
106 }
107 return false;
108 case MCR9:
109 if (record->event.pressed) {
110 SEND_STRING("Macro 9");
111 }
112 return false;
113 case MCR10:
114 if (record->event.pressed) {
115 SEND_STRING("Macro 10");
116 }
117 return false;
118 case MCR11:
119 if (record->event.pressed) {
120 SEND_STRING("Macro 12");
121 }
122 return false;
123 case MCR12:
124 if (record->event.pressed) {
125 SEND_STRING("Macro 12");
126 }
127 return false;
128 default:
129 return true;
130 }
131
132}
133
134bool led_update_user(led_t led_state) {
135 writePin(B1, led_state.num_lock);
136 return false;
137}
138
139
140layer_state_t layer_state_set_user(layer_state_t state) {
141 writePin(B3, !IS_LAYER_ON_STATE(state, 0));
142 return state;
143}
diff --git a/keyboards/kmac_pad/keymaps/default/readme.md b/keyboards/kmac_pad/keymaps/default/readme.md
new file mode 100644
index 000000000..3b9b739a2
--- /dev/null
+++ b/keyboards/kmac_pad/keymaps/default/readme.md
@@ -0,0 +1,61 @@
1# The default keymap for KMAC PAD
2
3This is the default keymap. It implements the same features as the official default KMAC PAD firmware.
4
5## Layers
6
7The keymap has two layers. Press the 'FN' key to toggle the Default layer and Function layer.
8
9### Layer 1: Default Layer
10
11 ,---.
12 |TG1|
13 `---'
14 ,---------------.
15 |NUM| / | * | - |
16 |---------------|
17 | 7 | 8 | 9 | |
18 |-----------| + |
19 | 4 | 5 | 6 | |
20 |---------------|
21 | 1 | 2 | 3 | |
22 |-----------|Ent|
23 | 0 | . | |
24 '---------------'
25
26### Layer 2: Function Layer
27
28 ,---.
29 |TG1|
30 `---'
31 ,---------------.
32 |M1 |M2 |M3 | |
33 |---------------|
34 |M4 |M5 |M6 | |
35 |-----------| |
36 |M7 |M8 |M9 | |
37 |---------------|
38 |M10|M11|M12| |
39 |-----------| |
40 | | | |
41 '---------------'
42
43## Macros
44
45The default macro is typed with meaningless strings that exist as samples.
46
47
48| Macro | Action |
49|:-----:| -------------------------------------- |
50| 1 | Types `Macro 1` |
51| 2 | Types `Macro 2` |
52| 3 | Types `Macro 3` |
53| 4 | Types `Macro 4` |
54| 5 | Types `Macro 5` |
55| 6 | Types `Macro 6` |
56| 7 | Types `Macro 7` |
57| 8 | Types `Macro 8` |
58| 9 | Types `Macro 9` |
59| 10 | Types `Macro 10` |
60| 11 | Types `Macro 11` |
61| 12 | Types `Macro 12` |
diff --git a/keyboards/kmac_pad/kmac_pad.c b/keyboards/kmac_pad/kmac_pad.c
new file mode 100644
index 000000000..87083668c
--- /dev/null
+++ b/keyboards/kmac_pad/kmac_pad.c
@@ -0,0 +1,29 @@
1/*
2Copyright 2021 talsu <talsu84@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "kmac_pad.h"
19
20void keyboard_pre_init_kb(void) {
21
22 /* Set Backlight pin as output
23 * FN Pin PB3
24 * PAD Pin PB1
25 */
26 setPinOutput(B3);
27 setPinOutput(B1);
28 keyboard_pre_init_user();
29}
diff --git a/keyboards/kmac_pad/kmac_pad.h b/keyboards/kmac_pad/kmac_pad.h
new file mode 100644
index 000000000..997960833
--- /dev/null
+++ b/keyboards/kmac_pad/kmac_pad.h
@@ -0,0 +1,37 @@
1/*
2Copyright 2021 talsu <talsu84@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include "quantum.h"
21
22#define LAYOUT( \
23 K00, \
24 K10, K11, K12, K13, \
25 K20, K21, K22, K23, \
26 K30, K31, K32, \
27 K40, K41, K42, K43, \
28 K50, K52 \
29) \
30{ \
31 { K00, KC_NO, KC_NO, KC_NO }, \
32 { K10, K11, K12, K13 }, \
33 { K20, K21, K22, K23 }, \
34 { K30, K31, K32, KC_NO }, \
35 { K40, K41, K42, K43 }, \
36 { K50, KC_NO, K52, KC_NO } \
37}
diff --git a/keyboards/kmac_pad/matrix.c b/keyboards/kmac_pad/matrix.c
new file mode 100644
index 000000000..476e40f51
--- /dev/null
+++ b/keyboards/kmac_pad/matrix.c
@@ -0,0 +1,111 @@
1/*
2Copyright 2021 talsu <talsu84@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "wait.h"
19#include "matrix.h"
20#include "quantum.h"
21
22static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
23static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
24
25/* Columns 0 - 3
26 * col / pin:
27 * 0: C7
28 * 1: C6
29 * 2: B6
30 * 3: B5
31 */
32static void unselect_cols(void) {
33 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
34 setPinOutput(col_pins[col]);
35 writePinLow(col_pins[col]);
36 }
37}
38
39static void select_col(uint8_t col) {
40 writePinHigh(col_pins[col]);
41}
42
43static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
44 bool matrix_changed = false;
45
46 // Select col and wait for col selecton to stabilize
47 select_col(current_col);
48 wait_us(30);
49
50 // row:0 , col:0 FN key is DIRECT_PIN
51 if (current_col == 0) {
52
53 matrix_row_t last_row_value = current_matrix[0];
54 if (readPin(row_pins[0]) == 0) {
55 // Pin LO, set col bit
56 current_matrix[0] |= (1 << current_col);
57 } else {
58 // Pin HI, clear col bit
59 current_matrix[0] &= ~(1 << current_col);
60 }
61
62 // Determine if the matrix changed state
63 if ((last_row_value != current_matrix[0]) && !(matrix_changed)) {
64 matrix_changed = true;
65 }
66 }
67
68 // other row use MATRIX
69 for (uint8_t row_index = 1; row_index < MATRIX_ROWS; row_index++) {
70
71 matrix_row_t last_row_value = current_matrix[row_index];
72 if (readPin(row_pins[row_index]) == 0) {
73 // Pin HI, clear col bit
74 current_matrix[row_index] &= ~(1 << current_col);
75 } else {
76 // Pin LO, set col bit
77 current_matrix[row_index] |= (1 << current_col);
78 }
79
80 // Determine if the matrix changed state
81 if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
82 matrix_changed = true;
83 }
84 }
85
86
87 // Unselect cols
88 unselect_cols();
89
90 return matrix_changed;
91}
92
93void matrix_init_custom(void) {
94 // initialize hardware and global matrix state here
95 unselect_cols();
96
97 // initialize key pins
98 for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
99 setPinInputHigh(row_pins[row_index]);
100 }
101}
102
103bool matrix_scan_custom(matrix_row_t current_matrix[]) {
104 bool changed = false;
105
106 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
107 changed |= read_rows_on_col(current_matrix, current_col);
108 }
109
110 return changed;
111}
diff --git a/keyboards/kmac_pad/readme.md b/keyboards/kmac_pad/readme.md
new file mode 100644
index 000000000..7605501f3
--- /dev/null
+++ b/keyboards/kmac_pad/readme.md
@@ -0,0 +1,56 @@
1# KMAC PAD
2
3![kmac_pad](https://i.imgur.com/4P1ybgNl.jpg)
4
5KMAC PAD is a num pad keyboard.
6It can be used independently, but can also be used by connecting with KMAC keyboard case.
7
8* Keyboard Maintainer: [talsu](https://github.com/talsu)
9* Hardware Supported: KMAC PAD
10* Hardware Availability: http://www.kbdmania.net/xe/news/5232321
11
12Make example for this keyboard (after setting up your build environment):
13
14 make kmac_pad:default
15
16Flashing example for this keyboard:
17
18 make kmac_pad:default:flash
19
20See 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).
21
22## Bootloader
23
24The 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.
25
26## PCB
27
28![Imgur](https://i.imgur.com/ML66cvfl.jpg)
29![Imgur](https://i.imgur.com/Kr2Wdtkl.jpg)
30
31### Switch Pins
32
33The FN key in the `Row 0` is directly connected to the E2 pin.
34The rest of the rows below that use MATRIX. (`Row 1 ~ Row 5`)
35| Row | Pin |
36|:-----:| ---------------------- |
37| 0 | x (Not in Matrix) |
38| 1 | D0 |
39| 2 | D1 |
40| 3 | D2 |
41| 4 | D3 |
42| 5 | D5 |
43
44| Column | Pin |
45|:------:| --------------------- |
46| 0 | C7 |
47| 1 | C6 |
48| 2 | B6 |
49| 3 | B5 |
50
51### Backlight Pins
52
53There are 2 pins for backlight.
54
55The LED of the FN key uses pin `B3`.
56All other keys are connected to the `B1` pin.
diff --git a/keyboards/kmac_pad/rules.mk b/keyboards/kmac_pad/rules.mk
new file mode 100644
index 000000000..3f63076c4
--- /dev/null
+++ b/keyboards/kmac_pad/rules.mk
@@ -0,0 +1,29 @@
1# MCU name
2MCU = atmega32u4
3
4# Processor frequency
5F_CPU = 8000000
6
7# Bootloader selection
8BOOTLOADER = atmel-dfu
9
10# Build Options
11# change yes to no to disable
12#
13BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration
14MOUSEKEY_ENABLE = yes # Mouse keys
15EXTRAKEY_ENABLE = yes # Audio control and System control
16CONSOLE_ENABLE = no # Console for debug
17COMMAND_ENABLE = no # Commands for debug and configuration
18# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
19SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
20# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
21NKRO_ENABLE = yes # USB Nkey Rollover
22BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
23RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
24BLUETOOTH_ENABLE = no # Enable Bluetooth
25AUDIO_ENABLE = no # Audio output
26CUSTOM_MATRIX = lite # Custom matrix file
27
28# Project specific files
29SRC += matrix.c