added two options for the slider

This commit is contained in:
Felix Jen 2023-01-28 14:25:26 -06:00
parent 2c2be57694
commit 2c736f08dd
No known key found for this signature in database
GPG Key ID: 4E7AA63CBBCE400E
7 changed files with 147 additions and 35 deletions

View File

@ -54,7 +54,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Define RGB */
#define RGB_DI_PIN C7
#define RGBLED_NUM 4
#define RGBLED_NUM 36
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
@ -67,6 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_EFFECT_TWINKLE
#define RGBLIGHT_LIMIT_VAL 255
#define RGB_VAL_STEP 12
#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_RAINBOW_SWIRL
/* Define MIDI */
#define MIDI_ADVANCED

View File

@ -9,7 +9,7 @@
"device_version": "0.0.1"
},
"layouts": {
"LAYOUT_all": {
"LAYOUT": {
"layout": [
{"x": 0, "y": 0},
{"x": 1, "y": 0},
@ -26,6 +26,7 @@
{"x": 12, "y": 0},
{"x": 13, "y": 0},
{"x": 14, "y": 0},
{"x": 15, "y": 0},
{"x": 0, "y": 1, "w": 1.5},
{"x": 1.5, "y": 1},

View File

@ -0,0 +1,116 @@
/*
Copyright 2021 <felix@fjlaboratories.com>
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
#include "analog.h"
#include "print.h"
#include "string.h"
enum layers {
_LAYER0,
_LAYER1,
_LAYER2,
_LAYER3
};
enum custom_keycodeas {
A_CW = USER00,
A_CCW
};
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[_LAYER1] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_LAYER0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_LAYER2] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_LAYER3] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
};
#endif
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_LAYER0] = LAYOUT(
QK_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_BSPC, KC_PGDN,
KC_LSFT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_MUTE,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT
),
[_LAYER1] = LAYOUT(
QK_GESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_HOME,
KC_TRNS, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_TRNS, KC_PSCR, KC_SCRL, KC_PAUSE, QK_BOOT, KC_PGUP,
KC_TRNS, RGB_SPI, RGB_SPD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGDN,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, NK_TOGG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AUDIO_VOL_UP, KC_AUDIO_MUTE,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MEDIA_PREV_TRACK, KC_AUDIO_VOL_DOWN, KC_MEDIA_NEXT_TRACK
),
[_LAYER2] = LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS , KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
),
[_LAYER3] = LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
),
};
/* Define MIDI custom keycodes here */
extern MidiDevice midi_device;
#define MIDI_CC_OFF 0
#define MIDI_CC_ON 127
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case A_CW:
if (record->event.pressed) {
midi_send_cc(&midi_device, midi_config.channel, 89, 1);
}
return true;
case A_CCW:
if (record->event.pressed) {
midi_send_cc(&midi_device, midi_config.channel, 89, 127);
}
return true;
default:
return true;
};
}
/* MIDI Slider controls */
uint16_t denoise_level = 16;
uint8_t last_val = 0;
void slider(void) {
uint8_t current_val = analogReadPin(SLIDER_PINA) >>3;
if ( last_val - current_val < -1 || last_val - current_val > 1 ) {
midi_send_cc(&midi_device, 0, 90, current_val ); // (&midi_device, chan, message, highest control value - (current pin reading) >>resolution)
last_val = current_val;
}
}
void matrix_scan_user(void) {
slider();
}

View File

@ -0,0 +1,3 @@
VIA_ENABLE = yes
ENCODER_MAP_ENABLE = yes
SRC += analog.c

View File

@ -32,24 +32,24 @@ enum custom_keycodeas {
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[_LAYER0] = { ENCODER_CCW_CW(A_CCW, A_CW) },
[_LAYER1] = { ENCODER_CCW_CW(A_CCW, A_CW) },
[_LAYER2] = { ENCODER_CCW_CW(A_CCW, A_CW) },
[_LAYER3] = { ENCODER_CCW_CW(A_CCW, A_CW) },
[_LAYER1] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_LAYER2] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_LAYER3] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
[_LAYER0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
};
#endif
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_LAYER0] = LAYOUT_all(
QK_BOOTLOADER, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL,
[_LAYER0] = LAYOUT(
QK_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_BSPC, KC_PGDN,
KC_LSFT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
KC_LSFT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_MUTE,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RGHT
),
[_LAYER1] = LAYOUT_all(
[_LAYER1] = LAYOUT(
QK_GESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_HOME,
KC_TRNS, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_TRNS, KC_PSCR, KC_SCRL, KC_PAUSE, QK_BOOT, KC_PGUP,
KC_TRNS, RGB_SPI, RGB_SPD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGDN,
@ -57,7 +57,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MEDIA_PREV_TRACK, KC_AUDIO_VOL_DOWN, KC_MEDIA_NEXT_TRACK
),
[_LAYER2] = LAYOUT_all(
[_LAYER2] = LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS , KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@ -65,7 +65,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
),
[_LAYER3] = LAYOUT_all(
[_LAYER3] = LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
@ -84,12 +84,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case A_CW:
if (record->event.pressed) {
midi_send_cc(&midi_device, midi_config.channel, 90, 1);
midi_send_cc(&midi_device, midi_config.channel, 89, 1);
}
return true;
case A_CCW:
if (record->event.pressed) {
midi_send_cc(&midi_device, midi_config.channel, 90, 127);
midi_send_cc(&midi_device, midi_config.channel, 89, 127);
}
return true;
default:
@ -100,14 +100,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
/* MIDI Slider controls */
uint16_t denoise_level = 16;
uint8_t last_val = 0;
uint8_t rgb_hue = 0;
uint8_t rgb_sat = 0;
void slider(void) {
uint8_t current_val = analogReadPin(SLIDER_PINA) >>3;
if ( last_val - current_val < -1 || last_val - current_val > 1 ) {
midi_send_cc(&midi_device, 0, 90, current_val ); // (&midi_device, chan, message, highest control value - (current pin reading) >>resolution)
last_val = comp_val;
rgb_hue = rgblight_get_hue();
rgb_sat = rgblight_get_sat();
rgblight_sethsv(rgb_hue, rgb_sat, current_val * 2);
last_val = current_val;
}
}

View File

@ -9,27 +9,14 @@ BOOTLOADER = atmel-dfu
# Build Options
# change yes to no to disable
#
# LTO_ENABLE = yes
# BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
# MOUSEKEY_ENABLE = yes # Mouse keys [NOTE TO SELF CHANGE TO YES]
# EXTRAKEY_ENABLE = yes # Audio control and System control [NOTE TO SELF CHANGE TO YES]
# 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 encoder
# MIDI_ENABLE = yes # Enable MIDI
LTO_ENABLE = yes
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
MOUSEKEY_ENABLE = no # Mouse keys [NOTE TO SELF CHANGE TO YES]
EXTRAKEY_ENABLE = no # Audio control and System control [NOTE TO SELF CHANGE TO YES]
CONSOLE_ENABLE = yes # Console for debug
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 = no # Enable N-Key Rollover
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 encoder
MIDI_ENABLE = yes # Enable MIDI
MIDI_ENABLE = yes # Enable MIDI

View File

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "quantum.h"
/* Vanguard65 Keymap Definitions */
#define LAYOUT_all( \
#define LAYOUT( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, \