aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Johnson <josh@joshajohnson.com>2021-02-28 16:03:49 +1100
committerGitHub <noreply@github.com>2021-02-28 16:03:49 +1100
commit03ea478f205e37419032c15c16143c17a5d2b5ae (patch)
tree31c4e588ccb563f9b0ec68ce5df2e3a9b167bdf4
parente4d3ff2374142fe6431b68874f6604a471732fae (diff)
downloadqmk_firmware-03ea478f205e37419032c15c16143c17a5d2b5ae.tar.gz
qmk_firmware-03ea478f205e37419032c15c16143c17a5d2b5ae.zip
Hub16 QMK configurator support + various bugfixes (#11496)
* qmk configurator support + various bugfixes * Update keyboards/hub16/rules.mk Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Nick Brassel <nick@tzarc.org>
-rwxr-xr-xkeyboards/hub16/config.h42
-rw-r--r--keyboards/hub16/info.json31
-rw-r--r--keyboards/hub16/keymaps/ahk_companion/readme.md4
-rwxr-xr-xkeyboards/hub16/keymaps/ahk_companion/rules.mk3
-rwxr-xr-xkeyboards/hub16/keymaps/default/keymap.c50
-rw-r--r--keyboards/hub16/keymaps/default/keymap.json1
-rw-r--r--keyboards/hub16/keymaps/default_tap_dance/rules.mk1
-rwxr-xr-xkeyboards/hub16/keymaps/macro/keymap.c (renamed from keyboards/hub16/keymaps/default_tap_dance/keymap.c)16
-rw-r--r--keyboards/hub16/keymaps/macro/rules.mk1
-rwxr-xr-xkeyboards/hub16/keymaps/no_mod/keymap.c78
-rw-r--r--keyboards/hub16/keymaps/via/rules.mk3
-rw-r--r--keyboards/hub16/matrix.c166
-rwxr-xr-xkeyboards/hub16/readme.md4
-rwxr-xr-xkeyboards/hub16/rules.mk24
14 files changed, 126 insertions, 298 deletions
diff --git a/keyboards/hub16/config.h b/keyboards/hub16/config.h
index 3372105a4..eeaa5f1a7 100755
--- a/keyboards/hub16/config.h
+++ b/keyboards/hub16/config.h
@@ -30,16 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30#define MATRIX_ROWS 5 30#define MATRIX_ROWS 5
31#define MATRIX_COLS 4 31#define MATRIX_COLS 4
32 32
33/*
34 * Keyboard Matrix Assignments
35 *
36 * Change this to how you wired your keyboard
37 * COLS: AVR pins used for columns, left to right
38 * ROWS: AVR pins used for rows, top to bottom
39 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
41 *
42 */
43#define MATRIX_ROW_PINS \ 33#define MATRIX_ROW_PINS \
44 { F0, C7, C6, B6, E6} 34 { F0, C7, C6, B6, E6}
45#define MATRIX_COL_PINS \ 35#define MATRIX_COL_PINS \
@@ -49,7 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
49#define DIODE_DIRECTION COL2ROW 39#define DIODE_DIRECTION COL2ROW
50 40
51#define RGB_DI_PIN D1 41#define RGB_DI_PIN D1
52// #ifdef RGB_DI_PIN
53#define RGBLED_NUM 11 42#define RGBLED_NUM 11
54#define RGBLIGHT_HUE_STEP 8 43#define RGBLIGHT_HUE_STEP 8
55#define RGBLIGHT_SAT_STEP 8 44#define RGBLIGHT_SAT_STEP 8
@@ -57,24 +46,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
57#define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */ 46#define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
58#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ 47#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
59// /*== all animations enable ==*/ 48// /*== all animations enable ==*/
60// #define RGBLIGHT_ANIMATIONS 49#define RGBLIGHT_ANIMATIONS
61// /*== or choose animations ==*/ 50// /*== or choose animations ==*/
62#define RGBLIGHT_EFFECT_BREATHING 51// #define RGBLIGHT_EFFECT_BREATHING
63#define RGBLIGHT_EFFECT_RAINBOW_MOOD 52// #define RGBLIGHT_EFFECT_RAINBOW_MOOD
64#define RGBLIGHT_EFFECT_RAINBOW_SWIRL 53// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
65#define RGBLIGHT_EFFECT_SNAKE 54// #define RGBLIGHT_EFFECT_SNAKE
66#define RGBLIGHT_EFFECT_KNIGHT 55// #define RGBLIGHT_EFFECT_KNIGHT
67// #define RGBLIGHT_EFFECT_CHRISTMAS 56// #define RGBLIGHT_EFFECT_CHRISTMAS
68// #define RGBLIGHT_EFFECT_STATIC_GRADIENT 57// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
69// #define RGBLIGHT_EFFECT_RGB_TEST 58// #define RGBLIGHT_EFFECT_RGB_TEST
70// #define RGBLIGHT_EFFECT_ALTERNATING 59// #define RGBLIGHT_EFFECT_ALTERNATING
71// /*== customize breathing effect ==*/
72// /*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
73// #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
74// /*==== use exp() and sin() ====*/
75// #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
76// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
77// #endif
78 60
79/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 61/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
80#define DEBOUNCE 20 62#define DEBOUNCE 20
@@ -82,9 +64,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
82/* ENCODER THINGS */ 64/* ENCODER THINGS */
83// #define ENCODER_DIRECTION_FLIP 65// #define ENCODER_DIRECTION_FLIP
84#define ENCODERS_PAD_A \ 66#define ENCODERS_PAD_A \
85 { F6, B4 }
86#define ENCODERS_PAD_B \
87 { F5, B5 } 67 { F5, B5 }
68#define ENCODERS_PAD_B \
69 { F6, B4 }
88 70
89/* Tap Dance timing */ 71/* Tap Dance timing */
90#define TAPPING_TERM 200 72#define TAPPING_TERM 200
diff --git a/keyboards/hub16/info.json b/keyboards/hub16/info.json
new file mode 100644
index 000000000..ea6c5ece5
--- /dev/null
+++ b/keyboards/hub16/info.json
@@ -0,0 +1,31 @@
1{
2 "keyboard_name": "Hub16",
3 "url": "https://joshajohnson.com/hub16-keyboard/",
4 "maintainer": "Josh Johnson",
5 "width": 4,
6 "height": 5,
7 "layouts": {
8 "LAYOUT": {
9 "layout": [
10 {"label":"Mute", "x":0.5, "y":0},
11 {"label":"Play / Pause", "x":2.5, "y":0},
12 {"label":"7", "x":0, "y":1},
13 {"label":"8", "x":1, "y":1},
14 {"label":"9", "x":2, "y":1},
15 {"label":"*", "x":3, "y":1},
16 {"label":"4", "x":0, "y":2},
17 {"label":"5", "x":1, "y":2},
18 {"label":"6", "x":2, "y":2},
19 {"label":"-", "x":3, "y":2},
20 {"label":"1", "x":0, "y":3},
21 {"label":"2", "x":1, "y":3},
22 {"label":"3", "x":2, "y":3},
23 {"label":"+", "x":3, "y":3},
24 {"label":"MO(1)", "x":0, "y":4},
25 {"label":"0", "x":1, "y":4},
26 {"label":".", "x":2, "y":4},
27 {"label":"N.ENT", "x":3, "y":4}
28 ]
29 }
30 }
31}
diff --git a/keyboards/hub16/keymaps/ahk_companion/readme.md b/keyboards/hub16/keymaps/ahk_companion/readme.md
index 6e8f9f2d2..a6163a3d5 100644
--- a/keyboards/hub16/keymaps/ahk_companion/readme.md
+++ b/keyboards/hub16/keymaps/ahk_companion/readme.md
@@ -1,7 +1,7 @@
1# AutoHotKey Companion 1# AutoHotKey Companion
2 2
3## Overview 3## Overview
4AutoHotKey Companion Keymap for <a href="https://www.tindie.com/products/joshajohnson/hub16-programmable-macro-keyboard/">Hub16 macropad</a> is designed be a quick and easy way to get started with AutoHotKey and to provide a foundation for customizing your own macropad. I upgraded to the Super16 from a Super16 because it kept the RGB underglow lights for an easy way (RGB) to identify what layer I was on with a quick glance or peripheral vision and added 2 rotary encoders and a USB 2.0 hub with USB-C ports. The F13 to F24 keys were selected as they are rarely used so you won't run into conflicts with existing application shortcuts and AutoHotKey recognizes them without any issues. *Note:* MacOS does not support/recognize F21 to F24 so these would need to be remapped for Mac users. 4AutoHotKey Companion Keymap for <a href="https://www.tindie.com/products/joshajohnson/hub16-programmable-macro-keyboard/">Hub16 macropad</a> is designed be a quick and easy way to get started with AutoHotKey and to provide a foundation for customizing your own macropad. I upgraded to the Hub16 from a Super16 because it kept the RGB underglow lights for an easy way (RGB) to identify what layer I was on with a quick glance or peripheral vision and added 2 rotary encoders and a USB 2.0 hub with USB-C ports. The F13 to F24 keys were selected as they are rarely used so you won't run into conflicts with existing application shortcuts and AutoHotKey recognizes them without any issues. *Note:* MacOS does not support/recognize F21 to F24 so these would need to be remapped for Mac users.
5 5
6Same functionality can be accomplished with other similar applications on the host system like Keyboard Maestro, AutoIt, etc. 6Same functionality can be accomplished with other similar applications on the host system like Keyboard Maestro, AutoIt, etc.
7 7
@@ -64,7 +64,7 @@ While the first 5 layers are accessible with only 1 key press at most, the 5th (
64 64
65## Host Configuration 65## Host Configuration
66 66
67Once the keymap has been flashed to the Super16, you can download the accompanying AutoHotKey file or create your own and have it start automatically either via a Windows Task or another way. Using AutoHotKey allows adjustment of functionality of the buttons without the need to change your map and reflash the macropad every time. 67Once the keymap has been flashed to the Hub16, you can download the accompanying AutoHotKey file or create your own and have it start automatically either via a Windows Task or another way. Using AutoHotKey allows adjustment of functionality of the buttons without the need to change your map and reflash the macropad every time.
68Starting the AHK file can be done either by: 68Starting the AHK file can be done either by:
69* Creating a Windows Task 69* Creating a Windows Task
70* Adding the AHK to the startup folder 70* Adding the AHK to the startup folder
diff --git a/keyboards/hub16/keymaps/ahk_companion/rules.mk b/keyboards/hub16/keymaps/ahk_companion/rules.mk
deleted file mode 100755
index 022a3eeee..000000000
--- a/keyboards/hub16/keymaps/ahk_companion/rules.mk
+++ /dev/null
@@ -1,3 +0,0 @@
1TAP_DANCE_ENABLE = no # Support for tap dancing
2
3
diff --git a/keyboards/hub16/keymaps/default/keymap.c b/keyboards/hub16/keymaps/default/keymap.c
new file mode 100755
index 000000000..e077fe740
--- /dev/null
+++ b/keyboards/hub16/keymaps/default/keymap.c
@@ -0,0 +1,50 @@
1/* Copyright 2019 Josh Johnson
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
19 [0] = LAYOUT( /* Base */
20 KC_MUTE, KC_MPLY,
21 KC_7, KC_8, KC_9, KC_PAST,
22 KC_4, KC_5, KC_6, KC_PMNS,
23 KC_1, KC_2, KC_3, KC_PPLS,
24 MO(1), KC_0, KC_PDOT,KC_PENT
25 ),
26
27 [1] = LAYOUT( /* LED Control */
28 _______, _______,
29 _______, RGB_MOD, RGB_RMOD, RGB_TOG,
30 RGB_VAD, RGB_VAI, RGB_HUD, RGB_HUI,
31 RGB_SAD, RGB_SAI, _______, _______,
32 _______, _______, RESET, _______
33 ),
34};
35
36void encoder_update_user(uint8_t index, bool clockwise) {
37 if (index == 0) { /* Left Encoder */
38 if (clockwise) {
39 tap_code(KC_VOLD);
40 } else {
41 tap_code(KC_VOLU);
42 }
43 } else if (index == 1) { /* Right Encoder */
44 if (clockwise) {
45 tap_code(KC_MPRV);
46 } else {
47 tap_code(KC_MNXT);
48 }
49 }
50}
diff --git a/keyboards/hub16/keymaps/default/keymap.json b/keyboards/hub16/keymaps/default/keymap.json
deleted file mode 100644
index 6f4814eac..000000000
--- a/keyboards/hub16/keymaps/default/keymap.json
+++ /dev/null
@@ -1 +0,0 @@
1{"version":1,"notes":"","documentation":"\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n","keyboard":"hub16","keymap":"default","layout":"LAYOUT","layers":[["KC_NLCK","KC_PSLS","KC_P7","KC_P8","KC_P9","KC_PPLS","KC_P4","KC_P5","KC_P6","KC_PCMM","KC_P1","KC_P2","KC_P3","KC_PEQL","KC_P0","KC_P0","KC_PDOT","KC_PENT"]],"author":""}
diff --git a/keyboards/hub16/keymaps/default_tap_dance/rules.mk b/keyboards/hub16/keymaps/default_tap_dance/rules.mk
deleted file mode 100644
index 25ec20cc4..000000000
--- a/keyboards/hub16/keymaps/default_tap_dance/rules.mk
+++ /dev/null
@@ -1 +0,0 @@
1TAP_DANCE_ENABLE = yes # Support for tap dancing
diff --git a/keyboards/hub16/keymaps/default_tap_dance/keymap.c b/keyboards/hub16/keymaps/macro/keymap.c
index d3cad67ae..3bf8fa31f 100755
--- a/keyboards/hub16/keymaps/default_tap_dance/keymap.c
+++ b/keyboards/hub16/keymaps/macro/keymap.c
@@ -36,18 +36,18 @@ qk_tap_dance_action_t tap_dance_actions[] = {
36 36
37const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 37const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
38 [_BASE] = LAYOUT( /* Base */ 38 [_BASE] = LAYOUT( /* Base */
39 KC_S, KC_V, 39 KC_S, KC_V,
40 KC_A, KC_B, KC_C, KC_D, 40 KC_A, KC_B, KC_C, KC_D,
41 KC_E, KC_F, KC_G, KC_H, 41 KC_E, KC_F, KC_G, KC_H,
42 KC_I, KC_J, KC_K, KC_L, 42 KC_I, KC_J, KC_K, KC_L,
43 KC_M, KC_N, KC_O, TD(CTRL) 43 KC_M, KC_N, KC_O, TD(CTRL)
44 ), 44 ),
45 45
46 [_CTRL] = LAYOUT( /* Control */ 46 [_CTRL] = LAYOUT( /* Control */
47 KC_NO, KC_NO, 47 KC_NO, KC_NO,
48 _______, RGB_MOD, RGB_RMOD, RGB_TOG, 48 _______, RGB_MOD, RGB_RMOD, RGB_TOG,
49 RGB_VAD, RGB_VAI, RGB_HUD, RGB_HUI, 49 RGB_VAD, RGB_VAI, RGB_HUD, RGB_HUI,
50 RGB_SAD, RGB_SAI, _______, _______, 50 RGB_SAD, RGB_SAI, _______, _______,
51 _______, _______, RESET, TD(BASE) 51 _______, _______, RESET, TD(BASE)
52 ), 52 ),
53}; 53};
@@ -112,4 +112,4 @@ void td_ctrl (qk_tap_dance_state_t *state, void *user_data) {
112 } else if (state->count == 2) { 112 } else if (state->count == 2) {
113 layer_move(_CTRL); 113 layer_move(_CTRL);
114 } 114 }
115} \ No newline at end of file 115}
diff --git a/keyboards/hub16/keymaps/macro/rules.mk b/keyboards/hub16/keymaps/macro/rules.mk
new file mode 100644
index 000000000..e5ddcae8d
--- /dev/null
+++ b/keyboards/hub16/keymaps/macro/rules.mk
@@ -0,0 +1 @@
TAP_DANCE_ENABLE = yes
diff --git a/keyboards/hub16/keymaps/no_mod/keymap.c b/keyboards/hub16/keymaps/no_mod/keymap.c
deleted file mode 100755
index 7c57ffbfe..000000000
--- a/keyboards/hub16/keymaps/no_mod/keymap.c
+++ /dev/null
@@ -1,78 +0,0 @@
1/* Copyright 2019 Josh Johnson
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18// Keyboard Layers
19enum keyboard_layers{
20 _BASE = 0,
21 _CONTROL
22};
23
24// Tap Dance Declarations
25enum tap_dance { TD_TO_LED = 0, TD_TO_DEFAULT = 1 };
26
27qk_tap_dance_action_t tap_dance_actions[] = {
28 // Tap once for standard key, twice to toggle to control layer
29 [TD_TO_LED] = ACTION_TAP_DANCE_DUAL_ROLE(KC_P, _CONTROL),
30 [TD_TO_DEFAULT] = ACTION_TAP_DANCE_DUAL_ROLE(KC_P, _BASE)};
31
32const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
33 [_BASE] = LAYOUT( /* Base */
34 KC_S, KC_V,
35 KC_A, KC_B, KC_C, KC_D,
36 KC_E, KC_F, KC_G, KC_H,
37 KC_I, KC_J, KC_K, KC_L,
38 KC_M, KC_N, KC_O, TD(TD_TO_LED)
39 ),
40
41 [_CONTROL] = LAYOUT( /* LED Control */
42 KC_NO, KC_NO,
43 _______, RGB_MOD, RGB_RMOD, RGB_TOG,
44 RGB_VAD, RGB_VAI, RGB_HUD, RGB_HUI,
45 RGB_SAD, RGB_SAI, _______, _______,
46 _______, _______, RESET, TD(TD_TO_DEFAULT)
47 ),
48};
49
50void encoder_update_user(uint8_t index, bool clockwise) {
51 if (index == 0) { /* Left Encoder */
52 if (clockwise) {
53 tap_code(KC_R);
54 } else {
55 tap_code(KC_Q);
56 }
57 } else if (index == 1) { /* Right Encoder */
58 if (clockwise) {
59 tap_code(KC_U);
60 } else {
61 tap_code(KC_T);
62 }
63 }
64}
65
66bool process_record_user(uint16_t keycode, keyrecord_t *record) {
67 switch (keycode) {
68 // Example of "pressing" CONTROL+SHIFT+V instead of "A" on keyboard
69 // More info: https://docs.qmk.fm/#/feature_macros
70 // case KC_A:
71 // if (record->event.pressed) {
72 // SEND_STRING(SS_LCTL(SS_LSFT("v")));
73 // } else {
74 // }
75 // break;
76 }
77 return true;
78};
diff --git a/keyboards/hub16/keymaps/via/rules.mk b/keyboards/hub16/keymaps/via/rules.mk
index b1c00b69f..1e5b99807 100644
--- a/keyboards/hub16/keymaps/via/rules.mk
+++ b/keyboards/hub16/keymaps/via/rules.mk
@@ -1,4 +1 @@
1VIA_ENABLE = yes VIA_ENABLE = yes
2CONSOLE_ENABLE = no
3COMMAND_ENABLE = no
4TAP_DANCE_ENABLE = no
diff --git a/keyboards/hub16/matrix.c b/keyboards/hub16/matrix.c
index a0d8314de..4f32070e6 100644
--- a/keyboards/hub16/matrix.c
+++ b/keyboards/hub16/matrix.c
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#include "wait.h" 19#include "wait.h"
20#include "util.h" 20#include "util.h"
21#include "matrix.h" 21#include "matrix.h"
22#include "debounce.h"
23#include "quantum.h" 22#include "quantum.h"
24 23
25// Encoder things 24// Encoder things
@@ -27,65 +26,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
27#define SWITCH_2 D7 26#define SWITCH_2 D7
28static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row); 27static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row);
29 28
30#ifdef MATRIX_MASKED
31extern const matrix_row_t matrix_mask[];
32#endif
33
34#ifdef DIRECT_PINS
35static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS;
36#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
37static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; 29static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
38static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; 30static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
39#endif
40 31
41/* matrix state(1:on, 0:off) */ 32/* matrix state(1:on, 0:off) */
42static matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values 33extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
43static matrix_row_t matrix[MATRIX_ROWS]; // debounced values 34extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
44
45// helper functions
46
47inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); }
48
49inline matrix_row_t matrix_get_row(uint8_t row) {
50 // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
51 // switch blocker installed and the switch is always pressed.
52#ifdef MATRIX_MASKED
53 return matrix[row] & matrix_mask[row];
54#else
55 return matrix[row];
56#endif
57}
58
59// matrix code
60
61#ifdef DIRECT_PINS
62
63static void init_pins(void) {
64 for (int row = 0; row < MATRIX_ROWS; row++) {
65 for (int col = 0; col < MATRIX_COLS; col++) {
66 pin_t pin = direct_pins[row][col];
67 if (pin != NO_PIN) {
68 setPinInputHigh(pin);
69 }
70 }
71 }
72}
73
74static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
75 matrix_row_t last_row_value = current_matrix[current_row];
76 current_matrix[current_row] = 0;
77
78 for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
79 pin_t pin = direct_pins[current_row][col_index];
80 if (pin != NO_PIN) {
81 current_matrix[current_row] |= readPin(pin) ? 0 : (MATRIX_ROW_SHIFTER << col_index);
82 }
83 }
84
85 return (last_row_value != current_matrix[current_row]);
86}
87
88#elif (DIODE_DIRECTION == COL2ROW)
89 35
90static void select_row(uint8_t row) { 36static void select_row(uint8_t row) {
91 setPinOutput(row_pins[row]); 37 setPinOutput(row_pins[row]);
@@ -133,112 +79,28 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
133 return (last_row_value != current_matrix[current_row]); 79 return (last_row_value != current_matrix[current_row]);
134} 80}
135 81
136#elif (DIODE_DIRECTION == ROW2COL)
137
138static void select_col(uint8_t col) {
139 setPinOutput(col_pins[col]);
140 writePinLow(col_pins[col]);
141}
142
143static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); }
144
145static void unselect_cols(void) {
146 for (uint8_t x = 0; x < MATRIX_COLS; x++) {
147 setPinInputHigh(col_pins[x]);
148 }
149}
150
151static void init_pins(void) {
152 unselect_cols();
153 for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
154 setPinInputHigh(row_pins[x]);
155 }
156}
157
158static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
159 bool matrix_changed = false;
160
161 // Select col and wait for col selecton to stabilize
162 select_col(current_col);
163 wait_us(30);
164
165 // For each row...
166 for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
167 // Store last value of row prior to reading
168 matrix_row_t last_row_value = current_matrix[row_index];
169
170 // Check row pin state
171 if (readPin(row_pins[row_index]) == 0) {
172 // Pin LO, set col bit
173 current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col);
174 } else {
175 // Pin HI, clear col bit
176 current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col);
177 }
178
179 // Determine if the matrix changed state
180 if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
181 matrix_changed = true;
182 }
183 }
184
185 // Unselect col
186 unselect_col(current_col);
187
188 return matrix_changed;
189}
190
191#endif
192 82
193void matrix_init(void) { 83void matrix_init_custom(void) {
194 // initialize key pins 84 // initialize key pins
85 setPinInput(SWITCH_1);
86 setPinInput(SWITCH_2);
195 init_pins(); 87 init_pins();
196
197 // initialize matrix state: all keys off
198 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
199 raw_matrix[i] = 0;
200 matrix[i] = 0;
201 }
202
203 debounce_init(MATRIX_ROWS);
204
205 matrix_init_quantum();
206} 88}
207 89
208uint8_t matrix_scan(void) { 90bool matrix_scan_custom(void) {
209 bool changed = false; 91 bool changed = false;
210 92
211#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
212 // Set row, read cols 93 // Set row, read cols
213 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { 94 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
214 changed |= read_cols_on_row(raw_matrix, current_row); 95 changed |= read_cols_on_row(raw_matrix, current_row);
215 } 96 }
216#elif (DIODE_DIRECTION == ROW2COL)
217 // Set col, read rows
218 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
219 changed |= read_rows_on_col(raw_matrix, current_col);
220 }
221#endif
222
223 debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
224 97
225 // Read encoder switches, already debounced 98 // Read encoder switches, already debounced
226 changed |= read_encoder_switches(matrix, 4); 99 changed |= read_encoder_switches(matrix, 4);
227 100
228 matrix_scan_quantum(); 101 return changed;
229 return (uint8_t)changed;
230} 102}
231 103
232// Customisations for the encoders
233void matrix_init_kb(void) {
234 setPinInput(SWITCH_1);
235 setPinInput(SWITCH_2);
236}
237
238void matrix_scan_kb(void) {}
239
240void matrix_print(void) {}
241
242static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row) { 104static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row) {
243 // Store last value of row prior to reading 105 // Store last value of row prior to reading
244 matrix_row_t last_row_value = current_matrix[current_row]; 106 matrix_row_t last_row_value = current_matrix[current_row];
@@ -249,18 +111,18 @@ static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current
249 // Debounce the encoder buttons using a shift register 111 // Debounce the encoder buttons using a shift register
250 static uint8_t btn_1_array; 112 static uint8_t btn_1_array;
251 static uint8_t btn_2_array; 113 static uint8_t btn_2_array;
252 bool btn_1_pressed = 0; 114 bool btn_1_rise = 0;
253 bool btn_2_pressed = 0; 115 bool btn_2_rise = 0;
254 btn_1_array <<= 1; 116 btn_1_array <<= 1;
255 btn_2_array <<= 1; 117 btn_2_array <<= 1;
256 btn_1_array |= readPin(SWITCH_1); 118 btn_1_array |= readPin(SWITCH_1);
257 btn_2_array |= readPin(SWITCH_2); 119 btn_2_array |= readPin(SWITCH_2);
258 (btn_1_array == 0b11111111) ? (btn_1_pressed = 1) : (btn_1_pressed = 0); 120 (btn_1_array == 0b01111111) ? (btn_1_rise = 1) : (btn_1_rise = 0);
259 (btn_2_array == 0b11111111) ? (btn_2_pressed = 1) : (btn_2_pressed = 0); 121 (btn_2_array == 0b01111111) ? (btn_2_rise = 1) : (btn_2_rise = 0);
260 122
261 // Populate the matrix row with the state of the encoder 123 // Populate the matrix row with the state of the encoder
262 current_matrix[current_row] |= btn_1_pressed ? (1 << 0) : 0; 124 current_matrix[current_row] |= btn_1_rise ? (1 << 0) : 0;
263 current_matrix[current_row] |= btn_2_pressed ? (1 << 1) : 0; 125 current_matrix[current_row] |= btn_2_rise ? (1 << 1) : 0;
264 126
265 return (last_row_value != current_matrix[current_row]); 127 return (last_row_value != current_matrix[current_row]);
266} \ No newline at end of file 128}
diff --git a/keyboards/hub16/readme.md b/keyboards/hub16/readme.md
index 1409af5bb..db2822c87 100755
--- a/keyboards/hub16/readme.md
+++ b/keyboards/hub16/readme.md
@@ -1,6 +1,6 @@
1# Hub16 1# Hub16
2 2
3Hub16 is a 16 Key Macro Pad with an inbuilt USB 2.0 hub and dual rotary encoders. 3Hub16 is a 16 Key Macro Pad with an inbuilt USB 2.0 hub and dual rotary encoders.
4 4
5For more information regarding the keyboard, please visit the [Hub16 Website](https://www.joshajohnson.com/hub16-keyboard/) or [GitHub Repo](https://github.com/joshajohnson/Hub16). 5For more information regarding the keyboard, please visit the [Hub16 Website](https://www.joshajohnson.com/hub16-keyboard/) or [GitHub Repo](https://github.com/joshajohnson/Hub16).
6 6
@@ -10,6 +10,6 @@ For more information regarding the keyboard, please visit the [Hub16 Website](ht
10 10
11Make example for this keyboard (after setting up your build environment): 11Make example for this keyboard (after setting up your build environment):
12 12
13 make hub16:default 13 make hub16:default:flash
14 14
15See 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). 15See 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).
diff --git a/keyboards/hub16/rules.mk b/keyboards/hub16/rules.mk
index 84ed6efcf..b7f940198 100755
--- a/keyboards/hub16/rules.mk
+++ b/keyboards/hub16/rules.mk
@@ -1,35 +1,23 @@
1# MCU name
2MCU = atmega32u4 1MCU = atmega32u4
3 2
4# Bootloader selection
5# Teensy halfkay
6# Pro Micro caterina
7# Atmel DFU atmel-dfu
8# LUFA DFU lufa-dfu
9# QMK DFU qmk-dfu
10# ATmega32A bootloadHID
11# ATmega328P USBasp
12BOOTLOADER = caterina 3BOOTLOADER = caterina
13 4
14# Build Options 5# Build Options
15# change yes to no to disable 6CUSTOM_MATRIX = lite # Custom scanning of matrix
16#
17CUSTOM_MATRIX = yes # Custom scanning of matrix
18BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration 7BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
19MOUSEKEY_ENABLE = no # Mouse keys 8MOUSEKEY_ENABLE = yes # Mouse keys
20EXTRAKEY_ENABLE = yes # Audio control and System control 9EXTRAKEY_ENABLE = yes # Audio control and System control
21CONSOLE_ENABLE = yes # Console for debug 10CONSOLE_ENABLE = no # Console for debug
22COMMAND_ENABLE = yes # Commands for debug and configuration 11COMMAND_ENABLE = no # Commands for debug and configuration
23# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 12# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
24SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 13SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
25# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 14# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
26NKRO_ENABLE = no # USB Nkey Rollover 15NKRO_ENABLE = no # USB Nkey Rollover
27BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 16BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
28RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow 17RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
29MIDI_ENABLE = no # MIDI support
30UNICODE_ENABLE = no # Unicode 18UNICODE_ENABLE = no # Unicode
31BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 19BLUETOOTH_ENABLE = no # Enable Bluetooth
32AUDIO_ENABLE = no # Audio output on port C6 20AUDIO_ENABLE = no # Audio output
33ENCODER_ENABLE = yes # Rotary Encoder support 21ENCODER_ENABLE = yes # Rotary Encoder support
34 22
35SRC = matrix.c 23SRC = matrix.c