diff --git a/keyboards/qvex/lynepad/config.h b/keyboards/qvex/lynepad/config.h index e266f72ad5b7..eb1718b7c8b9 100644 --- a/keyboards/qvex/lynepad/config.h +++ b/keyboards/qvex/lynepad/config.h @@ -1,11 +1,10 @@ /* -Copyright 2020 KemoNine +Copyright 2023 QVEX Tech 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 @@ -17,27 +16,20 @@ along with this program. If not, see . #pragma once -/* LEDs */ -#define RGBLIGHT_EFFECT_BREATHING -#define RGBLIGHT_EFFECT_RAINBOW_MOOD -#define RGBLIGHT_EFFECT_RAINBOW_SWIRL -#define RGBLIGHT_EFFECT_SNAKE -#define RGBLIGHT_EFFECT_KNIGHT -#define RGBLIGHT_EFFECT_CHRISTMAS -#define RGBLIGHT_EFFECT_STATIC_GRADIENT -#define RGBLIGHT_EFFECT_RGB_TEST -#define RGBLIGHT_EFFECT_ALTERNATING -#define RGBLIGHT_EFFECT_TWINKLE -#define RGBLED_NUM 4 -#define RGBLIGHT_HUE_STEP 8 -#define RGBLIGHT_SAT_STEP 8 -#define RGBLIGHT_VAL_STEP 8 - -/* Definitions for encoder tilt/press support */ -#define ENC_TILT_THRESHOLD 1 -#define PIN_TW_SW D2 // Center -#define PIN_RJ_SW C6 // Center -#define PIN_RJ_DIR_A D4 // Up -#define PIN_RJ_DIR_B D7 // Left -#define PIN_RJ_DIR_C B6 // Down -#define PIN_RJ_DIR_D B4 // Right +#define DYNAMIC_KEYMAP_LAYER_COUNT 5 + +//Digital joystick (4-way switch + encoder) +#define PIN_JU D4 +#define PIN_JD B6 +#define PIN_JL D7 +#define PIN_JR B4 +#define PIN_JC C6 + +//Thumbwheel +#define PIN_TC D2 + +//Backlighting +#define BACKLIGHT_DEFAULT_LEVEL 5 + +//RGB ring +#define RGBLIGHT_DEFAULT_VAL 64 \ No newline at end of file diff --git a/keyboards/qvex/lynepad/info.json b/keyboards/qvex/lynepad/info.json index fa8b71b5d6d6..b14ac341cdf7 100644 --- a/keyboards/qvex/lynepad/info.json +++ b/keyboards/qvex/lynepad/info.json @@ -1,49 +1,69 @@ { + "manufacturer": "QVEX Tech", "keyboard_name": "Lynepad", - "manufacturer": "QVEX", - "url": "https://www.tindie.com/products/qvex_tech/qvex-lynepad-macro-keypad/", - "maintainer": "KemoNine", - "usb": { - "vid": "0x5156", - "pid": "0x4C50", - "device_version": "0.0.1" - }, + "maintainer": "QVEX-Tech", + "bootloader": "caterina", + "diode_direction": "COL2ROW", "matrix_pins": { - "cols": ["F0", "F1", "F4", "F5"], - "rows": ["C7", "F7", "F6"] + "cols": [ "F0", "F1", "F4", "F5"], + "rows": [ "C7", "F7" ,"F6", "F6", "F6"] + }, + "processor": "atmega32u4", + "url": "https://qvex.eu", + "usb": { + "device_version": "1.0.0", + "vid": "0x5156", + "pid": "0x4C50" }, - "diode_direction": "COL2ROW", "encoder": { - "rotary": [ - {"pin_a": "D0", "pin_b": "D1"}, - {"pin_a": "B5", "pin_b": "D6"} - ] + "rotary": [ + {"pin_a": "D6", "pin_b": "B5", "resolution": 2}, + {"pin_a": "D1", "pin_b": "D0", "resolution": 2} + ] }, - "ws2812": { - "pin": "D3" + "features": { + "backlight": true, + "bootmagic": true, + "encoder": true, + "extrakey": true, + "mousekey": true, + "rgblight": true }, "rgblight": { - "max_brightness": 240 + "led_count": 5, + "max_brightness": 192, + "sleep": true + }, + "ws2812": { + "pin": "D3" + }, + "backlight": { + "breathing": true, + "levels": 8, + "max_brightness": 192, + "pin": "B7" }, - "processor": "atmega32u4", - "bootloader": "caterina", "layouts": { - "LAYOUT": { - "layout": [ - {"matrix": [0, 0], "x": 0, "y": 0}, - {"matrix": [0, 1], "x": 1, "y": 0}, - {"matrix": [0, 2], "x": 2, "y": 0}, - {"matrix": [0, 3], "x": 3, "y": 0}, - - {"matrix": [1, 0], "x": 0, "y": 1}, - {"matrix": [1, 1], "x": 1, "y": 1}, - {"matrix": [1, 2], "x": 2, "y": 1}, - {"matrix": [1, 3], "x": 3, "y": 1}, - - {"matrix": [2, 0], "x": 0, "y": 2}, - {"matrix": [2, 1], "x": 1, "y": 2}, - {"matrix": [2, 2], "x": 2, "y": 2} - ] - } + "LAYOUT": { + "layout": [ + { "matrix": [0, 0], "x": 0, "y": 0 }, + { "matrix": [0, 1], "x": 1, "y": 0 }, + { "matrix": [0, 2], "x": 2, "y": 0 }, + { "matrix": [0, 3], "x": 3, "y": 0 }, + { "matrix": [1, 0], "x": 0, "y": 1 }, + { "matrix": [1, 1], "x": 1, "y": 1 }, + { "matrix": [1, 2], "x": 2, "y": 1 }, + { "matrix": [1, 3], "x": 3, "y": 1 }, + { "matrix": [2, 0], "x": 0, "y": 2 }, + { "matrix": [2, 1], "x": 1, "y": 2 }, + { "matrix": [2, 2], "x": 2, "y": 2 }, + { "matrix": [3, 0], "x": 0, "y": 3 }, + { "matrix": [3, 1], "x": 1, "y": 3 }, + { "matrix": [3, 2], "x": 2, "y": 3 }, + { "matrix": [3, 3], "x": 3, "y": 3 }, + { "matrix": [4, 0], "x": 0, "y": 4 }, + { "matrix": [4, 1], "x": 1, "y": 4 } + ] + } } - } +} diff --git a/keyboards/qvex/lynepad/keymaps/default/keymap.c b/keyboards/qvex/lynepad/keymaps/default/keymap.c index 142f295de6ff..22286170f134 100644 --- a/keyboards/qvex/lynepad/keymaps/default/keymap.c +++ b/keyboards/qvex/lynepad/keymaps/default/keymap.c @@ -1,118 +1,142 @@ -/* Copyright 2020 KemoNine - * - * 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 . - */ +/* +Copyright 2023 QVEX Tech + +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 . +*/ + #include QMK_KEYBOARD_H +#define RGB_HUE_LAYER0 0 //default layer +#define RGB_HUE_LAYER1 50 +#define RGB_HUE_LAYER2 100 +#define RGB_HUE_LAYER3 150 +#define RGB_HUE_LAYER4 200 + + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -/* Keymap (Base Layer) Default Layer - * |----------------------------| - * | 1 | 2 | 3 | 4 | | - * | 5 | 6 | 7 | 8 | | - * | 9 | 10 | 11 | | - * |----------------------------| - */ -[0] = LAYOUT( - KC_MS_BTN4, KC_MS_BTN2, KC_MS_UP, KC_MS_BTN1, - KC_MS_BTN5, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, - KC_MS_ACCEL0, KC_MS_ACCEL1, KC_MS_ACCEL2 - ) + [0] = LAYOUT //Default + ( + G(KC_D), G(KC_TAB), C(G(KC_LEFT)), C(G(KC_RIGHT)), + G(KC_E), XXXXXXX, C(KC_C), C(KC_V), + KC_LGUI, XXXXXXX, XXXXXXX, + + KC_VOLU, KC_VOLD, KC_MPRV, KC_MNXT, //joystick up, down, left, right + KC_MPLY, MO(4) //joystick center push, thumbwheel push + ), + + [1] = LAYOUT //KiCad + ( + KC_ESC, KC_R, KC_M, KC_DEL, + KC_V, KC_G, KC_D, KC_X, + MO(3), KC_B, C(KC_V), + + KC_PLUS, KC_MINUS, C(KC_Y), C(KC_Z), //joystick up, down, left, right + KC_PGDN, MO(4) //joystick center push, thumbwheel push + ), + + [2] = LAYOUT + ( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + XXXXXXX, MO(4) //joystick center push, thumbwheel push + ), + + [3] = LAYOUT + ( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + XXXXXXX, MO(4) //joystick center push, thumbwheel push + ), + + [4] = LAYOUT + ( + TO(0), TO(1), TO(2), TO(3), + BL_TOGG, BL_STEP, XXXXXXX, XXXXXXX, + QK_RBT, EE_CLR, QK_BOOT, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + RGB_TOG, XXXXXXX //joystick center push, thumbwheel push + ) }; -// Standard encoder functionality -bool encoder_update_user(uint8_t index, bool clockwise) { - // Process encoder rotational movements - if (index == 0) { /* First encoder */ - if (clockwise) { - tap_code(KC_AUDIO_VOL_DOWN); - } else { - tap_code(KC_AUDIO_VOL_UP); - } - } else if (index == 1) { /* Second encoder */ - if (clockwise) { - tap_code(KC_MS_WH_UP); - } else { - tap_code(KC_MS_WH_DOWN); - } +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [0] = { + ENCODER_CCW_CW(KC_VOLD, KC_VOLU), + ENCODER_CCW_CW(KC_VOLD, KC_VOLU) + }, + + [1] = { + ENCODER_CCW_CW(LSFT(KC_W), KC_W), + ENCODER_CCW_CW(KC_N, LSFT(KC_N)) + }, + + [2] = { + ENCODER_CCW_CW(XXXXXXX, XXXXXXX), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + }, + + [3] = { + ENCODER_CCW_CW(XXXXXXX, XXXXXXX), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + }, + + [4] = { + ENCODER_CCW_CW(RGB_VAD, RGB_VAI), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) } - return true; +}; +#endif + +//set only hue, retain saturation, and value +void rgblight_sethue_noeeprom(uint8_t hue){ + //only if rgb led ring is on + if (rgblight_get_mode()) { + rgblight_sethsv_noeeprom(hue,rgblight_get_sat(),rgblight_get_val()); + } } -// Encoder press / tilt event handling -// the core lynepad implementation will update the below variables on each matrix scan -// Update the various codes below for customizing the tilt / push config - -extern int16_t enc1Center; -extern int16_t enc1CenterPrev; -extern int16_t enc2Center; -extern int16_t enc2CenterPrev; -extern int16_t enc2Up; -extern int16_t enc2UpPrev; -extern int16_t enc2Down; -extern int16_t enc2DownPrev; -extern int16_t enc2Left; -extern int16_t enc2LeftPrev; -extern int16_t enc2Right; -extern int16_t enc2RightPrev; - -void matrix_scan_user(void) { - if (enc1Center != enc1CenterPrev) { - if (enc1Center < ENC_TILT_THRESHOLD) { - } - else { - reset_keyboard(); - } - } - if (enc2Center != enc2CenterPrev) { - if (enc2Center < ENC_TILT_THRESHOLD) { - register_code16(KC_MS_BTN3); - } - else { - unregister_code16(KC_MS_BTN3); - } - /* - * Encoder sets ALL values when center is pressed so bail out at this point - * to avoid the rest of the encoder buttons registering events - */ - return; - } - if (enc2Up != enc2UpPrev) { - if (enc2Up < ENC_TILT_THRESHOLD) { - } - else { - rgblight_increase_val_noeeprom(); - } - } - if (enc2Down != enc2DownPrev) { - if (enc2Down < ENC_TILT_THRESHOLD) { - } - else { - rgblight_decrease_val_noeeprom(); - } - } - if (enc2Left != enc2LeftPrev) { - if (enc2Left < ENC_TILT_THRESHOLD) { - } - else { - rgblight_toggle_noeeprom(); - } - } - if (enc2Right != enc2RightPrev) { - if (enc2Right < ENC_TILT_THRESHOLD) { - } - else { - rgblight_step_noeeprom(); - } +//set correct layer hue on layer change +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { + case 1: + rgblight_sethue_noeeprom(RGB_HUE_LAYER1); + break; + case 2: + rgblight_sethue_noeeprom(RGB_HUE_LAYER2); + break; + case 3: + rgblight_sethue_noeeprom(RGB_HUE_LAYER3); + break; + case 4: + rgblight_sethue_noeeprom(RGB_HUE_LAYER4); + break; + default: + rgblight_sethue_noeeprom(RGB_HUE_LAYER0); + break; + } + return state; } + +//set default layer hue upon init +void keyboard_post_init_user(void) { + rgblight_init(); + rgblight_sethue_noeeprom(RGB_HUE_LAYER0); +} \ No newline at end of file diff --git a/keyboards/qvex/lynepad/keymaps/default/readme.md b/keyboards/qvex/lynepad/keymaps/default/readme.md deleted file mode 100644 index 8884d1a91a2f..000000000000 --- a/keyboards/qvex/lynepad/keymaps/default/readme.md +++ /dev/null @@ -1 +0,0 @@ -# The default keymap for lynepad diff --git a/keyboards/qvex/lynepad/keymaps/default/rules.mk b/keyboards/qvex/lynepad/keymaps/default/rules.mk new file mode 100644 index 000000000000..a40474b4d5c7 --- /dev/null +++ b/keyboards/qvex/lynepad/keymaps/default/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes \ No newline at end of file diff --git a/keyboards/qvex/lynepad/keymaps/mcrosson/keymap.c b/keyboards/qvex/lynepad/keymaps/mcrosson/keymap.c new file mode 100644 index 000000000000..ead8ab40a6da --- /dev/null +++ b/keyboards/qvex/lynepad/keymaps/mcrosson/keymap.c @@ -0,0 +1,142 @@ +/* +Copyright 2023 QVEX Tech + +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 . +*/ + +#include QMK_KEYBOARD_H + +#define RGB_HUE_LAYER0 0 //default layer +#define RGB_HUE_LAYER1 50 +#define RGB_HUE_LAYER2 100 +#define RGB_HUE_LAYER3 150 +#define RGB_HUE_LAYER4 200 + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT //Default + ( + KC_MS_BTN4, KC_MS_BTN2, KC_MS_UP, KC_MS_BTN1, + KC_MS_BTN5, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, + KC_MS_ACCEL0, KC_MS_ACCEL1, KC_MS_ACCEL2, + + KC_VOLU, KC_VOLD, KC_MPRV, KC_MNXT, //joystick up, down, left, right + KC_MPLY, MO(4) //joystick center push, thumbwheel push + ), + + [1] = LAYOUT //KiCad + ( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + XXXXXXX, MO(4) //joystick center push, thumbwheel push + ), + + [2] = LAYOUT + ( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + XXXXXXX, MO(4) //joystick center push, thumbwheel push + ), + + [3] = LAYOUT + ( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + XXXXXXX, MO(4) //joystick center push, thumbwheel push + ), + + [4] = LAYOUT + ( + TO(0), TO(1), TO(2), TO(3), + BL_TOGG, BL_STEP, XXXXXXX, XXXXXXX, + QK_RBT, EE_CLR, QK_BOOT, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + RGB_TOG, XXXXXXX //joystick center push, thumbwheel push + ) +}; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [0] = { + ENCODER_CCW_CW(KC_VOLD, KC_VOLU), + ENCODER_CCW_CW(KC_MS_WH_DOWN, KC_MS_WH_UP) + }, + + [1] = { + ENCODER_CCW_CW(XXXXXXX, XXXXXXX), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + }, + + [2] = { + ENCODER_CCW_CW(XXXXXXX, XXXXXXX), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + }, + + [3] = { + ENCODER_CCW_CW(XXXXXXX, XXXXXXX), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + }, + + [4] = { + ENCODER_CCW_CW(RGB_VAD, RGB_VAI), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + } +}; +#endif + +//set only hue, retain saturation, and value +void rgblight_sethue_noeeprom(uint8_t hue) { + //only if rgb led ring is on + if (rgblight_get_mode()) { + rgblight_sethsv_noeeprom(hue,rgblight_get_sat(),rgblight_get_val()); + } +} + +//set correct layer hue on layer change +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { + case 1: + rgblight_sethue_noeeprom(RGB_HUE_LAYER1); + break; + case 2: + rgblight_sethue_noeeprom(RGB_HUE_LAYER2); + break; + case 3: + rgblight_sethue_noeeprom(RGB_HUE_LAYER3); + break; + case 4: + rgblight_sethue_noeeprom(RGB_HUE_LAYER4); + break; + default: + rgblight_sethue_noeeprom(RGB_HUE_LAYER0); + break; + + } + return state; +} + +//set default layer hue upon init +void keyboard_post_init_user(void) { + rgblight_init(); + rgblight_sethue_noeeprom(RGB_HUE_LAYER0); +} \ No newline at end of file diff --git a/keyboards/qvex/lynepad/keymaps/mcrosson/rules.mk b/keyboards/qvex/lynepad/keymaps/mcrosson/rules.mk new file mode 100644 index 000000000000..a40474b4d5c7 --- /dev/null +++ b/keyboards/qvex/lynepad/keymaps/mcrosson/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes \ No newline at end of file diff --git a/keyboards/qvex/lynepad/keymaps/via/keymap.c b/keyboards/qvex/lynepad/keymaps/via/keymap.c new file mode 100644 index 000000000000..ff86cdc7fa18 --- /dev/null +++ b/keyboards/qvex/lynepad/keymaps/via/keymap.c @@ -0,0 +1,142 @@ +/* +Copyright 2023 QVEX Tech + +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 . +*/ + +#include QMK_KEYBOARD_H + +#define RGB_HUE_LAYER0 0 //default layer +#define RGB_HUE_LAYER1 50 +#define RGB_HUE_LAYER2 100 +#define RGB_HUE_LAYER3 150 +#define RGB_HUE_LAYER4 200 + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT //Default + ( + G(KC_D), G(KC_TAB), C(G(KC_LEFT)), C(G(KC_RIGHT)), + G(KC_E), XXXXXXX, C(KC_C), C(KC_V), + KC_LGUI, XXXXXXX, XXXXXXX, + + KC_VOLU, KC_VOLD, KC_MPRV, KC_MNXT, //joystick up, down, left, right + KC_MPLY, MO(4) //joystick center push, thumbwheel push + ), + + [1] = LAYOUT //KiCad + ( + KC_ESC, KC_R, KC_M, KC_DEL, + KC_V, KC_G, KC_D, KC_X, + MO(3), KC_B, C(KC_V), + + KC_PLUS, KC_MINUS, C(KC_Y), C(KC_Z), //joystick up, down, left, right + KC_PGDN, MO(4) //joystick center push, thumbwheel push + ), + + [2] = LAYOUT + ( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + XXXXXXX, MO(4) //joystick center push, thumbwheel push + ), + + [3] = LAYOUT + ( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + XXXXXXX, MO(4) //joystick center push, thumbwheel push + ), + + [4] = LAYOUT + ( + TO(0), TO(1), TO(2), TO(3), + BL_TOGG, BL_STEP, XXXXXXX, XXXXXXX, + QK_RBT, EE_CLR, QK_BOOT, + + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //joystick up, down, left, right + RGB_TOG, XXXXXXX //joystick center push, thumbwheel push + ) +}; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [0] = { + ENCODER_CCW_CW(KC_VOLD, KC_VOLU), + ENCODER_CCW_CW(KC_VOLD, KC_VOLU) + }, + + [1] = { + ENCODER_CCW_CW(LSFT(KC_W), KC_W), + ENCODER_CCW_CW(KC_N, LSFT(KC_N)) + }, + + [2] = { + ENCODER_CCW_CW(XXXXXXX, XXXXXXX), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + }, + + [3] = { + ENCODER_CCW_CW(XXXXXXX, XXXXXXX), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + }, + + [4] = { + ENCODER_CCW_CW(RGB_VAD, RGB_VAI), + ENCODER_CCW_CW(XXXXXXX, XXXXXXX) + } +}; +#endif + +//set only hue, retain saturation, and value +void rgblight_sethue_noeeprom(uint8_t hue) { + //only if rgb led ring is on + if (rgblight_get_mode()) { + rgblight_sethsv_noeeprom(hue,rgblight_get_sat(),rgblight_get_val()); + } +} + +//set correct layer hue on layer change +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { + case 1: + rgblight_sethue_noeeprom(RGB_HUE_LAYER1); + break; + case 2: + rgblight_sethue_noeeprom(RGB_HUE_LAYER2); + break; + case 3: + rgblight_sethue_noeeprom(RGB_HUE_LAYER3); + break; + case 4: + rgblight_sethue_noeeprom(RGB_HUE_LAYER4); + break; + default: + rgblight_sethue_noeeprom(RGB_HUE_LAYER0); + break; + + } + return state; +} + +//set default layer hue upon init +void keyboard_post_init_user(void) { + rgblight_init(); + rgblight_sethue_noeeprom(RGB_HUE_LAYER0); +} \ No newline at end of file diff --git a/keyboards/qvex/lynepad/keymaps/via/rules.mk b/keyboards/qvex/lynepad/keymaps/via/rules.mk new file mode 100644 index 000000000000..6ccd6d91943d --- /dev/null +++ b/keyboards/qvex/lynepad/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/qvex/lynepad/lynepad.c b/keyboards/qvex/lynepad/lynepad.c deleted file mode 100644 index cc69e12240cc..000000000000 --- a/keyboards/qvex/lynepad/lynepad.c +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2020 KemoNine -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 . -*/ -#include "quantum.h" - -void keyboard_pre_init_kb(void) { - // Encoder pins - setPinInput(PIN_TW_SW); - setPinInput(PIN_RJ_SW); - setPinInput(PIN_RJ_DIR_A); - setPinInput(PIN_RJ_DIR_C); - setPinInput(PIN_RJ_DIR_B); - setPinInput(PIN_RJ_DIR_D); - - keyboard_pre_init_user(); -} - -int16_t enc1Center = 1; -int16_t enc1CenterPrev = 1; -int16_t enc2Center = 1; -int16_t enc2CenterPrev = 1; -int16_t enc2Up = 1; -int16_t enc2UpPrev = 1; -int16_t enc2Down = 1; -int16_t enc2DownPrev = 1; -int16_t enc2Left = 1; -int16_t enc2LeftPrev = 1; -int16_t enc2Right = 1; -int16_t enc2RightPrev = 1; - -void matrix_scan_kb(void) { - enc1CenterPrev = enc1Center; - enc1Center = readPin(PIN_TW_SW); - - enc2CenterPrev = enc2Center; - enc2Center = readPin(PIN_RJ_SW); - enc2UpPrev = enc2Up; - enc2Up = readPin(PIN_RJ_DIR_A); - enc2DownPrev = enc2Down; - enc2Down = readPin(PIN_RJ_DIR_C); - enc2LeftPrev = enc2Left; - enc2Left = readPin(PIN_RJ_DIR_B); - enc2RightPrev = enc2Right; - enc2Right = readPin(PIN_RJ_DIR_D); - - // Ensure any user customizations are called (for some reason this wasn't happening by default) - matrix_scan_user(); -} diff --git a/keyboards/qvex/lynepad/matrix.c b/keyboards/qvex/lynepad/matrix.c new file mode 100644 index 000000000000..878ee6e2f724 --- /dev/null +++ b/keyboards/qvex/lynepad/matrix.c @@ -0,0 +1,119 @@ +/* +Copyright 2023 QVEX Tech + +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 . +*/ + +#include +#include +#include +#include "util.h" +#include "matrix.h" +#include "debounce.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; + +extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values +extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values + +static void select_row(uint8_t row) { + setPinOutput(row_pins[row]); + writePinLow(row_pins[row]); +} + +static void unselect_row(uint8_t row) { + setPinInputHigh(row_pins[row]); +} + +static void unselect_rows(void) { + for (uint8_t x = 0; x < MATRIX_ROWS; x++) { + setPinInputHigh(row_pins[x]); + } +} + +static void init_pins(void) { + unselect_rows(); + for (uint8_t x = 0; x < MATRIX_COLS; x++) { + setPinInputHigh(col_pins[x]); + } + setPinInputHigh(PIN_JU); + setPinInputHigh(PIN_JD); + setPinInputHigh(PIN_JL); + setPinInputHigh(PIN_JR); + setPinInputHigh(PIN_JC); + setPinInputHigh(PIN_TC); +} + +static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { + if (current_row > 2) return false; + + matrix_row_t last_row_value = current_matrix[current_row]; + + current_matrix[current_row] = 0; + + select_row(current_row); + wait_us(30); + + for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { + uint8_t pin_state = readPin(col_pins[col_index]); + current_matrix[current_row] |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index); + } + + unselect_row(current_row); + + return (last_row_value != current_matrix[current_row]); +} + +static bool read_encoder_switches(matrix_row_t current_matrix[]) { + matrix_row_t last_fourth_row = current_matrix[3]; + matrix_row_t last_fifth_row = current_matrix[4]; + + current_matrix[3] = 0; + current_matrix[4] = 0; + + current_matrix[4] |= !readPin(PIN_TC) ? (1 << 1) : 0; + + if (!readPin(PIN_JC)) { + if (!readPin(PIN_JU)) { + current_matrix[3] |= (1 << 0); + } else if (!readPin(PIN_JD)) { + current_matrix[3] |= (1 << 1); + } else if (!readPin(PIN_JL)) { + current_matrix[3] |= (1 << 2); + } else if (!readPin(PIN_JR)) { + current_matrix[3] |= (1 << 3); + } else { + current_matrix[4] |= (1 << 0); + } + } + + return last_fourth_row != current_matrix[3] || last_fifth_row != current_matrix[4]; +} + +void matrix_init_custom(void) { + init_pins(); +} + +bool matrix_scan_custom(void) { + bool changed = false; + + for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { + changed |= read_cols_on_row(raw_matrix, current_row); + } + + changed |= read_encoder_switches(raw_matrix); + + return changed; +} \ No newline at end of file diff --git a/keyboards/qvex/lynepad/readme.md b/keyboards/qvex/lynepad/readme.md index 68dd85a673d3..e52f3cb05d9a 100644 --- a/keyboards/qvex/lynepad/readme.md +++ b/keyboards/qvex/lynepad/readme.md @@ -1,13 +1,34 @@ # QVEX Lynepad -Macro pad with 11 keys and 2 rotary encoders. +![QVEX Lynepad](https://qvex.eu/img/lynepad.jpg) -* Keyboard Maintainer: [KemoNine](https://git.kemonine.info/kemonine/keyboard) -* Hardware Supported: QVEX Lynepad: macro keypad -* Hardware Availability: Tindie [Keyboard Kit](https://www.tindie.com/products/qvex_tech/qvex-lynepad-macro-keypad/) +*Macropad with 11 keys, thumbwheel, and a rotary 4-way switch* -Make example for this macro pad (after setting up your build environment): +* Keyboard Maintainer: [QVEX Tech](https://github.com/QVEX-Tech) ([seflm](https://github.com/seflm)) +* Hardware Supported: QVEX Lynepad +* Hardware Availability: [QVEX Lynepad on Tindie](https://www.tindie.com/products/qvex_tech/lynepad-21-hot-swap-macropad-w-joystick/) + +Make example for this keyboard (after setting up your build environment): make qvex/lynepad:default +Flashing example for this keyboard: + + make qvex/lynepad: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 + +Enter the bootloader in 3 ways: + +* **Bootmagic reset**: Hold down the top left key and plug in the keyboard +* **Physical reset button**: Briefly press the reset button on the back of the Lynepad using SIM tool (rev.2.0 or newer) +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available + +  +  +  +  + +*Thanks [@mcrosson](https://github.com/mcrosson) for the original Lynepad implementation* diff --git a/keyboards/qvex/lynepad/rules.mk b/keyboards/qvex/lynepad/rules.mk index fe695a8986e8..c25bdff0cf95 100644 --- a/keyboards/qvex/lynepad/rules.mk +++ b/keyboards/qvex/lynepad/rules.mk @@ -1,12 +1,2 @@ -# 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 = yes # Enable keyboard RGB underglow -ENCODER_ENABLE = yes # Enable the encoders +CUSTOM_MATRIX = lite +SRC += matrix.c \ No newline at end of file diff --git a/keyboards/qvex/readme.md b/keyboards/qvex/readme.md index 854fd4d767b1..d71f1e6731ec 100644 --- a/keyboards/qvex/readme.md +++ b/keyboards/qvex/readme.md @@ -1,7 +1,7 @@ -# QVEX +# QVEX Tech -QVEX is a keyboard vendor based in Czechia +QVEX Tech is a keyboard vendor based in the Czech Republic ## Online Stores -**Website:** https://www.tindie.com/products/qvex_tech/qvex-lynepad-macro-keypad/ +**Website:** https://www.qvex.eu