Added encoder & slider keymaps

This commit is contained in:
spacehangover 2024-10-08 23:55:20 -03:00
parent 5902ff1097
commit a9d7240b2c
3 changed files with 41 additions and 2 deletions

View File

@ -12,10 +12,13 @@
"mousekey": true,
"nkro": true,
"consumer_enable": false,
"via_enable": true,
"encoder_enable": true,
"encoder_map_enable": true,
"midi_enable": true,
"audio_enable": false,
"analog_enable": true
"analog_enable": true,
"analog_driver_required": true
},
"matrix_pins": {

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
#include "analog.h"
#include "qmk_midi.h"
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@ -10,4 +12,30 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17,
KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24
)
};
};
uint8_t divisor = 0;
void slider(void) {
static int previousPotValue = 0;
int currentPotValue = analogReadPin(POT1_PIN);
int threshold = 75;
if (abs(currentPotValue - previousPotValue) > threshold) {
midi_send_cc(&midi_device, 2, 0x0A, 0x7F - (currentPotValue >> 3));
previousPotValue = currentPotValue;
}
}
#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), ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
};
#endif
void matrix_scan_user(void) {
slider();
}

View File

@ -0,0 +1,8 @@
CONSUMER_ENABLE = no
VIA_ENABLE = yes
ENCODER_ENABLE = yes
ENCODER_MAP_ENABLE = yes
MIDI_ENABLE = yes
AUDIO_ENABLE = no
ANALOG_ENABLE = yes
ANALOG_DRIVER_REQUIRED = yes