diff options
author | lokher <lokher@gmail.com> | 2022-12-06 17:04:10 +0800 |
---|---|---|
committer | lokher <lokher@gmail.com> | 2022-12-06 17:04:10 +0800 |
commit | 27fc28fd2ff52e079a5bc58d6aaea4c752420615 (patch) | |
tree | 7ac943fb1ba4f430a7220efd18f66f6a77205c30 /keyboards/keebwerk/nano_slider | |
parent | e736133392fe6427cfb995da0787337189828272 (diff) | |
parent | 2709b6ed616f8012ff4cfd3ee69a822a8d188351 (diff) |
Merge upstream master
Diffstat (limited to 'keyboards/keebwerk/nano_slider')
-rw-r--r-- | keyboards/keebwerk/nano_slider/config.h | 102 | ||||
-rw-r--r-- | keyboards/keebwerk/nano_slider/keymaps/midi2vol/keymap.c | 154 |
2 files changed, 256 insertions, 0 deletions
diff --git a/keyboards/keebwerk/nano_slider/config.h b/keyboards/keebwerk/nano_slider/config.h new file mode 100644 index 0000000000..eca9d160cb --- /dev/null +++ b/keyboards/keebwerk/nano_slider/config.h @@ -0,0 +1,102 @@ +/* +Copyright 2020 Duckle + +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 + +#include "config_common.h" + +/* key matrix size */ +#define MATRIX_ROWS 2 +#define MATRIX_COLS 4 + +/* + * Keyboard Matrix Assignments + */ +#define MATRIX_ROW_PINS { F0, F1 } +#define MATRIX_COL_PINS { B0, B1, B2, B3 } + +#define SLIDER_PIN D4 + +/* COL2ROW, ROW2COL*/ +#define DIODE_DIRECTION COL2ROW + +#define BACKLIGHT_PIN B7 +#define BACKLIGHT_BREATHING +#define BACKLIGHT_LEVELS 3 + +#define RGB_DI_PIN F6 +#ifdef RGB_DI_PIN +# define RGBLED_NUM 4 +# define RGBLIGHT_HUE_STEP 8 +# define RGBLIGHT_SAT_STEP 8 +# define RGBLIGHT_VAL_STEP 8 +# define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */ +# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ + /*== all animations enable ==*/ +# define RGBLIGHT_EFFECT_BREATHING +# define RGBLIGHT_EFFECT_RAINBOW_MOOD +# define RGBLIGHT_EFFECT_RAINBOW_SWIRL +# define RGBLIGHT_EFFECT_SNAKE +# define RGBLIGHT_EFFECT_KNIGHT +# define RGBLIGHT_EFFECT_CHRISTMAS +# define RGBLIGHT_EFFECT_STATIC_GRADIENT +# define RGBLIGHT_EFFECT_RGB_TEST +# define RGBLIGHT_EFFECT_ALTERNATING +# define RGBLIGHT_EFFECT_TWINKLE +// /*== customize breathing effect ==*/ +// /*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/ +// #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64 +// /*==== use exp() and sin() ====*/ +// #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7 +// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 +#endif + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* define if matrix has ghost (lacks anti-ghosting diodes) */ +//#define MATRIX_HAS_GHOST + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. + * This is userful for the Windows task manager shortcut (ctrl+shift+esc). + */ +// #define GRAVE_ESC_CTRL_OVERRIDE + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT + +/* Bootmagic Lite key configuration */ +// #define BOOTMAGIC_LITE_ROW 0 +// #define BOOTMAGIC_LITE_COLUMN 0 diff --git a/keyboards/keebwerk/nano_slider/keymaps/midi2vol/keymap.c b/keyboards/keebwerk/nano_slider/keymaps/midi2vol/keymap.c new file mode 100644 index 0000000000..bd1f399086 --- /dev/null +++ b/keyboards/keebwerk/nano_slider/keymaps/midi2vol/keymap.c @@ -0,0 +1,154 @@ +/* Copyright 2020 Duckle, 2021 Jesús Vallejo + * + * 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 "qmk_midi.h" + +/* +This keymap works with midi2vol: linux version https://github.com/jesusvallejo/Midi2Vol-Linux +and windows version https://github.com/jesusvallejo/Midi2Vol + +Enables the user to change the volume on the host computer if running midi2vol software. + +Example to extend usability is provided check VLC in: enum custom_keycodes {} and bool process_record_user(uint16_t keycode, keyrecord_t *record) {} +Remember to give allways the new volume control a hex value not used by other volume control, +and add it to the midi2vol software. +Check respective midi2vol readme on how to do so.In linux change config.json,in windows you can use configuration option. + +A compiled version of this keymap is provided in here: https://github.com/jesusvallejo/nanokeymaps/ + +*/ + +uint8_t midi2vol = 0x3E; + +/* Defines names for use in layer keycodes and the keymap */ + +enum custom_layers { + _MEDIA, /* Controls Pause, Mute , Forward ... */ + _NAV, /* Nav arrows, Enter, Space*/ + _VOLUME, /* Changes midi2vol int to interface with midi2vol program: Chrome Volume, General Volume */ + _DISCORD, /* FXX unsused keys to interface with Discord: Mute , Silence */ + _LIGHTS, /* Edits underglow and retroilumination */ + _EDIT, /* Cut, Copy ,Paste */ + _QK_BOOT, /* Layer to set nano in bootloader mode */ + _TOOGLE, /* Momentary layer to switch between layers */ +}; + + + +/* Defines the keycodes used by our macros in process_record_user */ +enum custom_keycodes { /* In order to add more volume controls, add here a custom keycode, ex: VLC */ + DEFAULT= SAFE_RANGE,SPOTIFY,DISCORD,CHROME/*,VLC*/ +}; + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Base */ + [_MEDIA] = LAYOUT( + MO(_TOOGLE), + KC_MPLY, KC_MNXT, KC_COPY, + KC_MUTE, KC_MPRV, KC_PASTE, KC_ENTER + ), + [_NAV] = LAYOUT( + MO(_TOOGLE), + KC_SPC, KC_UP, KC_BSPC, + KC_LEFT, KC_DOWN, KC_RIGHT, KC_ENTER + ), + [_VOLUME] = LAYOUT( + MO(_TOOGLE), + SPOTIFY, DISCORD, CHROME, + KC_NO, KC_NO, KC_NO, DEFAULT + ), + [_DISCORD] = LAYOUT( + MO(_TOOGLE), + KC_F18, KC_F19, KC_F20, + KC_F21, KC_F22, KC_F23, KC_F24 + ), + [_LIGHTS] = LAYOUT( + MO(_TOOGLE), + RGB_TOG, RGB_MOD, RGB_VAI, + RGB_SAI, BL_BRTG, BL_STEP, KC_LSFT + ), + [_EDIT] = LAYOUT( + MO(_TOOGLE), + KC_MENU, KC_CUT, KC_COPY, + KC_FIND, KC_UNDO, KC_PASTE, KC_MPLY + ), + [_RESET] = LAYOUT( + MO(_TOOGLE), + KC_NO, KC_NO, KC_NO, + KC_NO, KC_NO, KC_NO, QK_BOOT + ), + [_TOOGLE] = LAYOUT( + MO(_TOOGLE), + TO(_MEDIA), TO(_NAV), TO(_VOLUME), + TO(_DISCORD), TO(_LIGHTS), TO(_EDIT), TO(_RESET) + ) +}; +/* In order to add more volume controls, add here code to detect custom keycode, ex: VLC */ +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case DEFAULT: + if (record->event.pressed) { + /* when keycode DEFAULT is pressed */ + midi2vol= 0x3E; + } else { + /* when keycode DEFAULT is released */ + } + break; + case SPOTIFY: + if (record->event.pressed) { + midi2vol= 0x3F; + } + break; + case DISCORD: + if (record->event.pressed) { + + midi2vol= 0x40; + } + break; + case CHROME: + if (record->event.pressed) { + + midi2vol= 0x41; + } + break; + /* + case VLC: + if (record->event.pressed) { + midi2vol= 0x42; + } + break; + */ + } + return true; +} + +uint8_t divisor = 0; + + +void slider(void) { + if (divisor++) { /* only run the slider function 1/256 times it's called */ + return; + } + midi_send_cc(&midi_device, 2, midi2vol, 0x7F - (analogReadPin(SLIDER_PIN) >> 3)); +} + +void matrix_scan_user(void) { + slider(); +} |