summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorY.KEISUKE <yamagutikeisuke@gmail.com>2024-10-27 15:10:46 +0900
committerGitHub <noreply@github.com>2024-10-27 00:10:46 -0600
commit159c0888457e5675c6dc0a881e7c5bd8b54203e7 (patch)
tree9df15c5b7008d35e3d71c53f586c961ba9b9c0b5
parentfcc070929cf66339e6af7dd4fe852e2fab01eb0c (diff)
Add support for encoders on Planck rev 7 in QMK version 0.26 (#807)
-rw-r--r--keyboards/planck/rev7/keymaps/vial/keymap.c90
-rw-r--r--keyboards/planck/rev7/keymaps/vial/vial.json192
2 files changed, 221 insertions, 61 deletions
diff --git a/keyboards/planck/rev7/keymaps/vial/keymap.c b/keyboards/planck/rev7/keymaps/vial/keymap.c
index 56389f761b..85f5097332 100644
--- a/keyboards/planck/rev7/keymaps/vial/keymap.c
+++ b/keyboards/planck/rev7/keymaps/vial/keymap.c
@@ -147,13 +147,69 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------------------------------'
*/
[_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, _______,
_______, 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 */
#ifdef AUDIO_ENABLE
@@ -161,14 +217,22 @@ float plover_song[][2] = SONG(PLOVER_SOUND);
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
#endif
+bool play_encoder_melody(uint8_t index, bool clockwise);
+
layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}
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) {
case QWERTY:
if (record->event.pressed) {
+ print("mode just switched to qwerty and this is a huge string\n");
set_single_persistent_default_layer(_QWERTY);
}
return false;
@@ -227,13 +291,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
/* clang-format off */
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}},
};
/* clang-format on */
@@ -250,7 +314,7 @@ float melody[8][2][2] = {
#define ET12_MAJOR_THIRD 1.259921
#define ET12_PERFECT_FOURTH 1.33484
#define ET12_TRITONE 1.414214
-#define ET12_PERFECT_FIFTH 1.498307
+#define ET12_PERFECT_FIFTH 1.498307
deferred_token tokens[8];
@@ -259,7 +323,7 @@ uint32_t reset_note(uint32_t trigger_time, void *note) {
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]);
if (clockwise) {
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;
}
+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) {
switch (index) {
case 0: {
@@ -302,4 +370,4 @@ bool dip_switch_update_user(uint8_t index, bool active) {
}
}
return true;
-} \ No newline at end of file
+}
diff --git a/keyboards/planck/rev7/keymaps/vial/vial.json b/keyboards/planck/rev7/keymaps/vial/vial.json
index 0b71556093..61157d3d99 100644
--- a/keyboards/planck/rev7/keymaps/vial/vial.json
+++ b/keyboards/planck/rev7/keymaps/vial/vial.json
@@ -1,12 +1,24 @@
{
"matrix": {"rows": 8, "cols": 6},
"layouts": {
- "labels": [["Layout", "MIT (1x2u)", "Grid (2x1u)", "2x2u", "3x3u"]],
+ "labels": [["Layout", "MIT (1x2u)", "Grid (2x1u)", "2x2u", "3x3u"], "Encoders"],
"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",
- {"c": "#cccccc"},
+ {
+ "c": "#cccccc"
+ },
"0,1",
"0,2",
"0,3",
@@ -17,12 +29,26 @@
"4,2",
"4,3",
"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",
- {"c": "#cccccc"},
+ {
+ "c": "#cccccc"
+ },
"1,1",
"1,2",
"1,3",
@@ -33,12 +59,26 @@
"5,2",
"5,3",
"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",
- {"c": "#cccccc"},
+ {
+ "c": "#cccccc"
+ },
"2,1",
"2,2",
"2,3",
@@ -49,55 +89,107 @@
"6,2",
"6,3",
"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,1",
"3,2",
- "7,3\n\n\n0,0",
- {"c": "#777777"},
- "7,4\n\n\n0,0",
- {"c": "#cccccc", "w": 2},
+ "3,3\n\n\n0,0",
+ {
+ "c": "#777777"
+ },
+ "3,4\n\n\n0,0",
+ {
+ "c": "#cccccc",
+ "w": 2
+ },
"7,0\n\n\n0,0",
- {"c": "#777777"},
+ {
+ "c": "#777777"
+ },
"7,1\n\n\n0,0",
- {"c": "#aaaaaa"},
+ {
+ "c": "#aaaaaa"
+ },
"7,2\n\n\n0,0",
- "3,3",
- "3,4",
- "3,5"
- ],
- [
- {"y": 0.25, "x": 3},
- "7,3\n\n\n0,1",
- {"c": "#777777"},
- "7,4\n\n\n0,1",
- {"c": "#cccccc"},
- "7,5\n\n\n0,1",
+ "7,3",
+ "7,4",
+ "7,5",
+ {
+ "x": 1.5
+ },
+ "7,0\n\n\n1,1\n\n\n\n\n\ne",
+ "7,1\n\n\n1,1\n\n\n\n\n\ne"
+ ],
+ [
+ {
+ "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",
- {"c": "#777777"},
+ {
+ "c": "#777777"
+ },
"7,1\n\n\n0,1",
- {"c": "#aaaaaa"},
+ {
+ "c": "#aaaaaa"
+ },
"7,2\n\n\n0,1"
- ],
- [
- {"x": 3},
- "7,3\n\n\n0,2",
- {"c": "#777777", "w": 2},
- "7,5\n\n\n0,2",
- {"w": 2},
+ ],
+ [
+ {
+ "x": 6.5
+ },
+ "3,3\n\n\n0,2",
+ {
+ "c": "#777777",
+ "w": 2
+ },
+ "3,5\n\n\n0,2",
+ {
+ "w": 2
+ },
"7,1\n\n\n0,2",
- {"c": "#aaaaaa"},
+ {
+ "c": "#aaaaaa"
+ },
"7,2\n\n\n0,2"
- ],
- [
- {"x": 3, "c": "#777777", "w": 3},
- "7,4\n\n\n0,3",
- {"w": 3},
+ ],
+ [
+ {
+ "x": 6.5,
+ "c": "#777777",
+ "w": 3
+ },
+ "3,4\n\n\n0,3",
+ {
+ "w": 3
+ },
"7,1\n\n\n0,3"
- ]
+ ]
]
}
}