[Keyboard] Add QVEX Lynepad 2.0 (#21070)

This commit is contained in:
seflm 2023-07-11 11:15:08 +03:00 committed by GitHub
parent fed4becdf4
commit 8a955a2428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 682 additions and 0 deletions

View File

@ -0,0 +1,35 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#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 arc
#define RGBLIGHT_DEFAULT_VAL 64

View File

@ -0,0 +1,69 @@
{
"manufacturer": "QVEX Tech",
"keyboard_name": "Lynepad",
"maintainer": "QVEX-Tech",
"bootloader": "caterina",
"diode_direction": "COL2ROW",
"matrix_pins": {
"cols": [ "F0", "F1", "F4", "F5"],
"rows": [ "C7", "F7" ,"F6", null, null]
},
"processor": "atmega32u4",
"url": "https://qvex.eu",
"usb": {
"device_version": "1.0.0",
"vid": "0x04D8",
"pid": "0xE678"
},
"encoder": {
"rotary": [
{"pin_a": "D6", "pin_b": "B5", "resolution": 2},
{"pin_a": "D1", "pin_b": "D0", "resolution": 2}
]
},
"features": {
"backlight": true,
"bootmagic": true,
"encoder": true,
"extrakey": true,
"mousekey": true,
"rgblight": true
},
"rgblight": {
"led_count": 5,
"max_brightness": 192,
"sleep": true
},
"ws2812": {
"pin": "D3"
},
"backlight": {
"breathing": true,
"levels": 8,
"max_brightness": 192,
"pin": "B7"
},
"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 },
{ "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 }
]
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View File

@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View File

@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View File

@ -0,0 +1,2 @@
ENCODER_MAP_ENABLE = yes
VIA_ENABLE = yes

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#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;
}

View File

@ -0,0 +1,27 @@
# QVEX Lynepad 2
![QVEX Lynepad 2.1](https://i.imgur.com/eDvVaE4h.jpeg)
*Macropad with 11 keys, thumbwheel, and a rotary 4-way switch*
* 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

View File

@ -0,0 +1,2 @@
CUSTOM_MATRIX = lite
SRC += matrix.c