Add support for encoders on Planck rev 7 in QMK version 0.26 (#807)
This commit is contained in:
parent
fcc070929c
commit
159c088845
2 changed files with 221 additions and 61 deletions
|
@ -147,13 +147,69 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
* `-----------------------------------------------------------------------------------'
|
* `-----------------------------------------------------------------------------------'
|
||||||
*/
|
*/
|
||||||
[_ADJUST] = LAYOUT_planck_grid(
|
[_ADJUST] = LAYOUT_planck_grid(
|
||||||
_______, QK_BOOT, DB_TOGG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
|
_______, QK_BOOT, DB_TOGG, UG_TOGG, UG_NEXT, UG_HUEU, UG_HUED, UG_SATU, UG_SATD, UG_SPDU, UG_SPDD, KC_DEL ,
|
||||||
_______, EE_CLR, MU_NEXT, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______,
|
_______, EE_CLR, MU_NEXT, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______,
|
||||||
_______, AU_PREV, AU_NEXT, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______,
|
_______, AU_PREV, AU_NEXT, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
|
||||||
)
|
)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef ENCODER_MAP_ENABLE
|
||||||
|
/* Rotary Encoders
|
||||||
|
*/
|
||||||
|
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
|
||||||
|
/* Qwerty
|
||||||
|
* v- (index) Clockwise / Counter Clockwise v- (index) Clockwise / Counter Clockwise
|
||||||
|
* ,---------------------------------------------------------------------------------------.
|
||||||
|
* | (0) Vol- / Vol+ | | | | | | | | | | | (4) Vol- / Vol+ |
|
||||||
|
* |-----------------------+---+---+---+---+---+---+---+---+---+---+-----------------------|
|
||||||
|
* | (1) KC_MNXT / KC_MPRV | | | | | | | | | | | (5) KC_MNXT / KC_MPRV |
|
||||||
|
* |-----------------------+---+---+---+---+---+---+---+---+---+---+-----------------------|
|
||||||
|
* | (2) KC_WBAK / KC_WFWD | | | | | | | | | | | (6) KC_SPC / KC_ENT |
|
||||||
|
* |-----------------------+---+---+---+---+---+---+---+---+---+---+-----------------------|
|
||||||
|
* | (3) KC_LEFT / KC_RGHT | | | | | | | | | | (7) KC_DOWN / KC_UP |
|
||||||
|
* `---------------------------------------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
[_QWERTY] = {
|
||||||
|
// LEFT SIDE (index 0 to 3)
|
||||||
|
ENCODER_CCW_CW(KC_VOLU, KC_VOLD),
|
||||||
|
ENCODER_CCW_CW(KC_MNXT, KC_MPRV),
|
||||||
|
ENCODER_CCW_CW(KC_WBAK, KC_WFWD),
|
||||||
|
ENCODER_CCW_CW(KC_LEFT, KC_RGHT),
|
||||||
|
// RIGHT SIDE (index 4 to 7)
|
||||||
|
ENCODER_CCW_CW(KC_VOLU, KC_VOLD),
|
||||||
|
ENCODER_CCW_CW(KC_MNXT, KC_MPRV),
|
||||||
|
ENCODER_CCW_CW(KC_SPC, KC_ENT),
|
||||||
|
ENCODER_CCW_CW(KC_DOWN, KC_UP)
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Adjust (Lower + Raise)
|
||||||
|
* v- (index) Clockwise / Counter Clockwise v- (index) Clockwise / Counter Clockwise
|
||||||
|
* ,---------------------------------------------------------------------------------------.
|
||||||
|
* | (0) _______ / _______ | | | | | | | | | | | (4) _______ / _______ |
|
||||||
|
* |-----------------------+---+---+---+---+---+---+---+---+---+---+-----------------------|
|
||||||
|
* | (1) _______ / _______ | | | | | | | | | | | (5) _______ / _______ |
|
||||||
|
* |-----------------------+---+---+---+---+---+---+---+---+---+---+-----------------------|
|
||||||
|
* | (2) UG_NEXT / UG_PREV | | | | | | | | | | | (6) SAT- / SAT+ |
|
||||||
|
* |-----------------------+---+---+---+---+---+---+---+---+---+---+-----------------------|
|
||||||
|
* | (3) UG_VALD / UG_VALU | | | | | | | | | | (7) HUE- / HUE+ |
|
||||||
|
* `---------------------------------------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
[_ADJUST] = {
|
||||||
|
// LEFT SIDE (index 0 to 3)
|
||||||
|
ENCODER_CCW_CW(_______, _______),
|
||||||
|
ENCODER_CCW_CW(_______, _______),
|
||||||
|
ENCODER_CCW_CW(UG_NEXT, UG_PREV),
|
||||||
|
ENCODER_CCW_CW(UG_VALD, UG_VALU),
|
||||||
|
// RIGHT SIDE (index 4 to 7)
|
||||||
|
ENCODER_CCW_CW(_______, _______),
|
||||||
|
ENCODER_CCW_CW(_______, _______),
|
||||||
|
ENCODER_CCW_CW(UG_SATD, UG_SATU),
|
||||||
|
ENCODER_CCW_CW(UG_HUEU, UG_HUED)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
#ifdef AUDIO_ENABLE
|
#ifdef AUDIO_ENABLE
|
||||||
|
@ -161,14 +217,22 @@ float plover_song[][2] = SONG(PLOVER_SOUND);
|
||||||
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
|
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool play_encoder_melody(uint8_t index, bool clockwise);
|
||||||
|
|
||||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||||
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
#ifdef ENCODER_MAP_ENABLE
|
||||||
|
if (IS_ENCODEREVENT(record->event) && record->event.pressed) {
|
||||||
|
play_encoder_melody(record->event.key.col, record->event.type == ENCODER_CCW_EVENT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case QWERTY:
|
case QWERTY:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
|
print("mode just switched to qwerty and this is a huge string\n");
|
||||||
set_single_persistent_default_layer(_QWERTY);
|
set_single_persistent_default_layer(_QWERTY);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -227,13 +291,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
float melody[8][2][2] = {
|
float melody[8][2][2] = {
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
{{440.0f, 8}, {440.0f, 24}},
|
{{440.0f, 8}, {440.0f, 24}},
|
||||||
};
|
};
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
@ -250,7 +314,7 @@ float melody[8][2][2] = {
|
||||||
#define ET12_MAJOR_THIRD 1.259921
|
#define ET12_MAJOR_THIRD 1.259921
|
||||||
#define ET12_PERFECT_FOURTH 1.33484
|
#define ET12_PERFECT_FOURTH 1.33484
|
||||||
#define ET12_TRITONE 1.414214
|
#define ET12_TRITONE 1.414214
|
||||||
#define ET12_PERFECT_FIFTH 1.498307
|
#define ET12_PERFECT_FIFTH 1.498307
|
||||||
|
|
||||||
deferred_token tokens[8];
|
deferred_token tokens[8];
|
||||||
|
|
||||||
|
@ -259,7 +323,7 @@ uint32_t reset_note(uint32_t trigger_time, void *note) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool encoder_update_user(uint8_t index, bool clockwise) {
|
bool play_encoder_melody(uint8_t index, bool clockwise) {
|
||||||
cancel_deferred_exec(tokens[index]);
|
cancel_deferred_exec(tokens[index]);
|
||||||
if (clockwise) {
|
if (clockwise) {
|
||||||
melody[index][1][0] = melody[index][1][0] * ET12_MINOR_SECOND;
|
melody[index][1][0] = melody[index][1][0] * ET12_MINOR_SECOND;
|
||||||
|
@ -274,6 +338,10 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool encoder_update_user(uint8_t index, bool clockwise) {
|
||||||
|
return play_encoder_melody(index, clockwise);
|
||||||
|
}
|
||||||
|
|
||||||
bool dip_switch_update_user(uint8_t index, bool active) {
|
bool dip_switch_update_user(uint8_t index, bool active) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
@ -302,4 +370,4 @@ bool dip_switch_update_user(uint8_t index, bool active) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
{
|
{
|
||||||
"matrix": {"rows": 8, "cols": 6},
|
"matrix": {"rows": 8, "cols": 6},
|
||||||
"layouts": {
|
"layouts": {
|
||||||
"labels": [["Layout", "MIT (1x2u)", "Grid (2x1u)", "2x2u", "3x3u"]],
|
"labels": [["Layout", "MIT (1x2u)", "Grid (2x1u)", "2x2u", "3x3u"], "Encoders"],
|
||||||
"keymap": [
|
"keymap": [
|
||||||
[
|
[
|
||||||
{"c": "#aaaaaa"},
|
"0,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
{
|
||||||
|
"x": -1,
|
||||||
|
"d": true
|
||||||
|
},
|
||||||
|
"0,0\n\n\n1,0",
|
||||||
|
"0,1\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
{
|
||||||
|
"x": 1.5,
|
||||||
|
"c": "#aaaaaa"
|
||||||
|
},
|
||||||
"0,0",
|
"0,0",
|
||||||
{"c": "#cccccc"},
|
{
|
||||||
|
"c": "#cccccc"
|
||||||
|
},
|
||||||
"0,1",
|
"0,1",
|
||||||
"0,2",
|
"0,2",
|
||||||
"0,3",
|
"0,3",
|
||||||
|
@ -17,12 +29,26 @@
|
||||||
"4,2",
|
"4,2",
|
||||||
"4,3",
|
"4,3",
|
||||||
"4,4",
|
"4,4",
|
||||||
{"c": "#aaaaaa"},
|
{
|
||||||
"4,5"
|
"c": "#aaaaaa"
|
||||||
],
|
},
|
||||||
[
|
"4,5",
|
||||||
|
{
|
||||||
|
"x": 1.5
|
||||||
|
},
|
||||||
|
"4,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
"4,1\n\n\n1,1\n\n\n\n\n\ne"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"1,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
"1,1\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
{
|
||||||
|
"x": 1.5
|
||||||
|
},
|
||||||
"1,0",
|
"1,0",
|
||||||
{"c": "#cccccc"},
|
{
|
||||||
|
"c": "#cccccc"
|
||||||
|
},
|
||||||
"1,1",
|
"1,1",
|
||||||
"1,2",
|
"1,2",
|
||||||
"1,3",
|
"1,3",
|
||||||
|
@ -33,12 +59,26 @@
|
||||||
"5,2",
|
"5,2",
|
||||||
"5,3",
|
"5,3",
|
||||||
"5,4",
|
"5,4",
|
||||||
{"c": "#aaaaaa"},
|
{
|
||||||
"5,5"
|
"c": "#aaaaaa"
|
||||||
],
|
},
|
||||||
[
|
"5,5",
|
||||||
|
{
|
||||||
|
"x": 1.5
|
||||||
|
},
|
||||||
|
"5,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
"5,1\n\n\n1,1\n\n\n\n\n\ne"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"2,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
"2,1\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
{
|
||||||
|
"x": 1.5
|
||||||
|
},
|
||||||
"2,0",
|
"2,0",
|
||||||
{"c": "#cccccc"},
|
{
|
||||||
|
"c": "#cccccc"
|
||||||
|
},
|
||||||
"2,1",
|
"2,1",
|
||||||
"2,2",
|
"2,2",
|
||||||
"2,3",
|
"2,3",
|
||||||
|
@ -49,55 +89,107 @@
|
||||||
"6,2",
|
"6,2",
|
||||||
"6,3",
|
"6,3",
|
||||||
"6,4",
|
"6,4",
|
||||||
{"c": "#aaaaaa"},
|
{
|
||||||
"6,5"
|
"c": "#aaaaaa"
|
||||||
],
|
},
|
||||||
[
|
"6,5",
|
||||||
|
{
|
||||||
|
"x": 1.5
|
||||||
|
},
|
||||||
|
"6,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
"6,1\n\n\n1,1\n\n\n\n\n\ne"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"3,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
"3,1\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
|
{
|
||||||
|
"x": 1.5
|
||||||
|
},
|
||||||
"3,0",
|
"3,0",
|
||||||
"3,1",
|
"3,1",
|
||||||
"3,2",
|
"3,2",
|
||||||
"7,3\n\n\n0,0",
|
"3,3\n\n\n0,0",
|
||||||
{"c": "#777777"},
|
{
|
||||||
"7,4\n\n\n0,0",
|
"c": "#777777"
|
||||||
{"c": "#cccccc", "w": 2},
|
},
|
||||||
|
"3,4\n\n\n0,0",
|
||||||
|
{
|
||||||
|
"c": "#cccccc",
|
||||||
|
"w": 2
|
||||||
|
},
|
||||||
"7,0\n\n\n0,0",
|
"7,0\n\n\n0,0",
|
||||||
{"c": "#777777"},
|
{
|
||||||
|
"c": "#777777"
|
||||||
|
},
|
||||||
"7,1\n\n\n0,0",
|
"7,1\n\n\n0,0",
|
||||||
{"c": "#aaaaaa"},
|
{
|
||||||
|
"c": "#aaaaaa"
|
||||||
|
},
|
||||||
"7,2\n\n\n0,0",
|
"7,2\n\n\n0,0",
|
||||||
"3,3",
|
"7,3",
|
||||||
"3,4",
|
"7,4",
|
||||||
"3,5"
|
"7,5",
|
||||||
],
|
{
|
||||||
[
|
"x": 1.5
|
||||||
{"y": 0.25, "x": 3},
|
},
|
||||||
"7,3\n\n\n0,1",
|
"7,0\n\n\n1,1\n\n\n\n\n\ne",
|
||||||
{"c": "#777777"},
|
"7,1\n\n\n1,1\n\n\n\n\n\ne"
|
||||||
"7,4\n\n\n0,1",
|
],
|
||||||
{"c": "#cccccc"},
|
[
|
||||||
"7,5\n\n\n0,1",
|
{
|
||||||
|
"y": 0.25,
|
||||||
|
"x": 6.5
|
||||||
|
},
|
||||||
|
"3,3\n\n\n0,1",
|
||||||
|
{
|
||||||
|
"c": "#777777"
|
||||||
|
},
|
||||||
|
"3,4\n\n\n0,1",
|
||||||
|
{
|
||||||
|
"c": "#cccccc"
|
||||||
|
},
|
||||||
|
"3,5\n\n\n0,1",
|
||||||
"7,0\n\n\n0,1",
|
"7,0\n\n\n0,1",
|
||||||
{"c": "#777777"},
|
{
|
||||||
|
"c": "#777777"
|
||||||
|
},
|
||||||
"7,1\n\n\n0,1",
|
"7,1\n\n\n0,1",
|
||||||
{"c": "#aaaaaa"},
|
{
|
||||||
|
"c": "#aaaaaa"
|
||||||
|
},
|
||||||
"7,2\n\n\n0,1"
|
"7,2\n\n\n0,1"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{"x": 3},
|
{
|
||||||
"7,3\n\n\n0,2",
|
"x": 6.5
|
||||||
{"c": "#777777", "w": 2},
|
},
|
||||||
"7,5\n\n\n0,2",
|
"3,3\n\n\n0,2",
|
||||||
{"w": 2},
|
{
|
||||||
|
"c": "#777777",
|
||||||
|
"w": 2
|
||||||
|
},
|
||||||
|
"3,5\n\n\n0,2",
|
||||||
|
{
|
||||||
|
"w": 2
|
||||||
|
},
|
||||||
"7,1\n\n\n0,2",
|
"7,1\n\n\n0,2",
|
||||||
{"c": "#aaaaaa"},
|
{
|
||||||
|
"c": "#aaaaaa"
|
||||||
|
},
|
||||||
"7,2\n\n\n0,2"
|
"7,2\n\n\n0,2"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{"x": 3, "c": "#777777", "w": 3},
|
{
|
||||||
"7,4\n\n\n0,3",
|
"x": 6.5,
|
||||||
{"w": 3},
|
"c": "#777777",
|
||||||
|
"w": 3
|
||||||
|
},
|
||||||
|
"3,4\n\n\n0,3",
|
||||||
|
{
|
||||||
|
"w": 3
|
||||||
|
},
|
||||||
"7,1\n\n\n0,3"
|
"7,1\n\n\n0,3"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue