diff options
| author | Josh Johnson <josh@joshajohnson.com> | 2020-07-17 22:35:44 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-17 13:35:44 +0100 |
| commit | 07a817d3e5454f9dc3ecd5f7e7b49197bfb36599 (patch) | |
| tree | 79eff4d7426a6243c9b45672804ca2dc43bcab08 /keyboards/hub16 | |
| parent | 56beaf7d3f5bb135fbb516b4824d3e8c3643978f (diff) | |
| download | qmk_firmware-07a817d3e5454f9dc3ecd5f7e7b49197bfb36599.tar.gz qmk_firmware-07a817d3e5454f9dc3ecd5f7e7b49197bfb36599.zip | |
[keymap] Add VIA support for Hub16 (#9638)
* fix encoder switch not staying depressed
* add via support
* change default keymap
* change VID-PID
* remove LTO
* fix hold bug keeping debouncing
Diffstat (limited to 'keyboards/hub16')
| -rwxr-xr-x | keyboards/hub16/config.h | 8 | ||||
| -rwxr-xr-x | keyboards/hub16/keymaps/via/keymap.c | 66 | ||||
| -rw-r--r-- | keyboards/hub16/keymaps/via/rules.mk | 4 | ||||
| -rw-r--r-- | keyboards/hub16/matrix.c | 30 |
4 files changed, 87 insertions, 21 deletions
diff --git a/keyboards/hub16/config.h b/keyboards/hub16/config.h index ed14178d6..a18e0027b 100755 --- a/keyboards/hub16/config.h +++ b/keyboards/hub16/config.h | |||
| @@ -20,8 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include "config_common.h" | 20 | #include "config_common.h" |
| 21 | 21 | ||
| 22 | /* USB Device descriptor parameter */ | 22 | /* USB Device descriptor parameter */ |
| 23 | #define VENDOR_ID 0xFEED | 23 | #define VENDOR_ID 0x6A6A |
| 24 | #define PRODUCT_ID 0x8F73 | 24 | #define PRODUCT_ID 0x4810 |
| 25 | #define DEVICE_VER 0x0001 | 25 | #define DEVICE_VER 0x0001 |
| 26 | #define MANUFACTURER Josh Johnson | 26 | #define MANUFACTURER Josh Johnson |
| 27 | #define PRODUCT Hub16 | 27 | #define PRODUCT Hub16 |
| @@ -42,9 +42,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 42 | * | 42 | * |
| 43 | */ | 43 | */ |
| 44 | #define MATRIX_ROW_PINS \ | 44 | #define MATRIX_ROW_PINS \ |
| 45 | { F0, C7, C6, B6, E6} | 45 | { F0, C7, C6, B6, E6} |
| 46 | #define MATRIX_COL_PINS \ | 46 | #define MATRIX_COL_PINS \ |
| 47 | { F4, F1, D5, D3 } | 47 | { F4, F1, D5, D3 } |
| 48 | 48 | ||
| 49 | /* COL2ROW, ROW2COL*/ | 49 | /* COL2ROW, ROW2COL*/ |
| 50 | #define DIODE_DIRECTION COL2ROW | 50 | #define DIODE_DIRECTION COL2ROW |
diff --git a/keyboards/hub16/keymaps/via/keymap.c b/keyboards/hub16/keymaps/via/keymap.c new file mode 100755 index 000000000..c6f119adb --- /dev/null +++ b/keyboards/hub16/keymaps/via/keymap.c | |||
| @@ -0,0 +1,66 @@ | |||
| 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 | const 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 | [2] = LAYOUT( | ||
| 36 | _______, _______, | ||
| 37 | _______, _______, _______, _______, | ||
| 38 | _______, _______, _______, _______, | ||
| 39 | _______, _______, _______, _______, | ||
| 40 | _______, _______, _______, _______ | ||
| 41 | ), | ||
| 42 | |||
| 43 | [3] = LAYOUT( | ||
| 44 | _______, _______, | ||
| 45 | _______, _______, _______, _______, | ||
| 46 | _______, _______, _______, _______, | ||
| 47 | _______, _______, _______, _______, | ||
| 48 | _______, _______, _______, _______ | ||
| 49 | ), | ||
| 50 | }; | ||
| 51 | |||
| 52 | void encoder_update_user(uint8_t index, bool clockwise) { | ||
| 53 | if (index == 0) { /* Left Encoder */ | ||
| 54 | if (clockwise) { | ||
| 55 | tap_code(KC_VOLD); | ||
| 56 | } else { | ||
| 57 | tap_code(KC_VOLU); | ||
| 58 | } | ||
| 59 | } else if (index == 1) { /* Right Encoder */ | ||
| 60 | if (clockwise) { | ||
| 61 | tap_code(KC_MPRV); | ||
| 62 | } else { | ||
| 63 | tap_code(KC_MNXT); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
diff --git a/keyboards/hub16/keymaps/via/rules.mk b/keyboards/hub16/keymaps/via/rules.mk new file mode 100644 index 000000000..b1c00b69f --- /dev/null +++ b/keyboards/hub16/keymaps/via/rules.mk | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | VIA_ENABLE = yes | ||
| 2 | CONSOLE_ENABLE = no | ||
| 3 | COMMAND_ENABLE = no | ||
| 4 | TAP_DANCE_ENABLE = no | ||
diff --git a/keyboards/hub16/matrix.c b/keyboards/hub16/matrix.c index ad77c923b..a0d8314de 100644 --- a/keyboards/hub16/matrix.c +++ b/keyboards/hub16/matrix.c | |||
| @@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | // Encoder things | 25 | // Encoder things |
| 26 | #define SWITCH_1 F7 | 26 | #define SWITCH_1 F7 |
| 27 | #define SWITCH_2 D7 | 27 | #define SWITCH_2 D7 |
| 28 | static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_row); | 28 | static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row); |
| 29 | 29 | ||
| 30 | #ifdef MATRIX_MASKED | 30 | #ifdef MATRIX_MASKED |
| 31 | extern const matrix_row_t matrix_mask[]; | 31 | extern const matrix_row_t matrix_mask[]; |
| @@ -128,7 +128,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | // Unselect row | 130 | // Unselect row |
| 131 | unselect_row(current_row); | 131 | unselect_row(current_row); |
| 132 | 132 | ||
| 133 | return (last_row_value != current_matrix[current_row]); | 133 | return (last_row_value != current_matrix[current_row]); |
| 134 | } | 134 | } |
| @@ -223,27 +223,23 @@ uint8_t matrix_scan(void) { | |||
| 223 | debounce(raw_matrix, matrix, MATRIX_ROWS, changed); | 223 | debounce(raw_matrix, matrix, MATRIX_ROWS, changed); |
| 224 | 224 | ||
| 225 | // Read encoder switches, already debounced | 225 | // Read encoder switches, already debounced |
| 226 | changed |= read_encoder_values(matrix, 4); | 226 | changed |= read_encoder_switches(matrix, 4); |
| 227 | 227 | ||
| 228 | matrix_scan_quantum(); | 228 | matrix_scan_quantum(); |
| 229 | return (uint8_t)changed; | 229 | return (uint8_t)changed; |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | // Customisations for the encoders | 232 | // Customisations for the encoders |
| 233 | void matrix_init_kb(void){ | 233 | void matrix_init_kb(void) { |
| 234 | setPinInput(SWITCH_1); | 234 | setPinInput(SWITCH_1); |
| 235 | setPinInput(SWITCH_2); | 235 | setPinInput(SWITCH_2); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | void matrix_scan_kb(void){ | 238 | void matrix_scan_kb(void) {} |
| 239 | 239 | ||
| 240 | } | 240 | void matrix_print(void) {} |
| 241 | |||
| 242 | void matrix_print(void){ | ||
| 243 | |||
| 244 | } | ||
| 245 | 241 | ||
| 246 | static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_row) { | 242 | static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row) { |
| 247 | // Store last value of row prior to reading | 243 | // Store last value of row prior to reading |
| 248 | matrix_row_t last_row_value = current_matrix[current_row]; | 244 | matrix_row_t last_row_value = current_matrix[current_row]; |
| 249 | 245 | ||
| @@ -253,18 +249,18 @@ static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_r | |||
| 253 | // Debounce the encoder buttons using a shift register | 249 | // Debounce the encoder buttons using a shift register |
| 254 | static uint8_t btn_1_array; | 250 | static uint8_t btn_1_array; |
| 255 | static uint8_t btn_2_array; | 251 | static uint8_t btn_2_array; |
| 256 | bool btn_1_rising = 0; | 252 | bool btn_1_pressed = 0; |
| 257 | bool btn_2_rising = 0; | 253 | bool btn_2_pressed = 0; |
| 258 | btn_1_array <<= 1; | 254 | btn_1_array <<= 1; |
| 259 | btn_2_array <<= 1; | 255 | btn_2_array <<= 1; |
| 260 | btn_1_array |= readPin(SWITCH_1); | 256 | btn_1_array |= readPin(SWITCH_1); |
| 261 | btn_2_array |= readPin(SWITCH_2); | 257 | btn_2_array |= readPin(SWITCH_2); |
| 262 | (btn_1_array == 0b01111111) ? (btn_1_rising = 1) : (btn_1_rising = 0); | 258 | (btn_1_array == 0b11111111) ? (btn_1_pressed = 1) : (btn_1_pressed = 0); |
| 263 | (btn_2_array == 0b01111111) ? (btn_2_rising = 1) : (btn_2_rising = 0); | 259 | (btn_2_array == 0b11111111) ? (btn_2_pressed = 1) : (btn_2_pressed = 0); |
| 264 | 260 | ||
| 265 | // Populate the matrix row with the state of the encoder | 261 | // Populate the matrix row with the state of the encoder |
| 266 | current_matrix[current_row] |= btn_1_rising ? (1 << 0) : 0; | 262 | current_matrix[current_row] |= btn_1_pressed ? (1 << 0) : 0; |
| 267 | current_matrix[current_row] |= btn_2_rising ? (1 << 1) : 0; | 263 | current_matrix[current_row] |= btn_2_pressed ? (1 << 1) : 0; |
| 268 | 264 | ||
| 269 | return (last_row_value != current_matrix[current_row]); | 265 | return (last_row_value != current_matrix[current_row]); |
| 270 | } \ No newline at end of file | 266 | } \ No newline at end of file |
