From 640dee1139be7ec8c38780cf7b3f101d5b6883e4 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 15 Jun 2022 16:29:22 -0700 Subject: [PATCH] Added code for right-hand backlight mod --- config.h | 21 +++++-- keymaps/default/config.h | 6 +- keymaps/default/keymap.c | 93 ++++++++++++++++++++++++++++--- keymaps/default/layers/keyboard.h | 30 +++++----- keymaps/default/layers/main.h | 4 +- post_config.h | 2 + rules.mk | 5 +- 7 files changed, 126 insertions(+), 35 deletions(-) diff --git a/config.h b/config.h index a01f38e..e1721cf 100644 --- a/config.h +++ b/config.h @@ -78,26 +78,37 @@ along with this program. If not, see . #ifndef LED_BRIGHTNESS_HI #define LED_BRIGHTNESS_HI 255 #endif -#define LED_BRIGHTNESS_DEFAULT (LED_BRIGHTNESS_HI) +#define LED_BRIGHTNESS_DEFAULT (LED_BRIGHTNESS_LO) + +// Backlight /* ws2812 RGB LED */ +#define RGBLED_NUM 8 #define RGB_DI_PIN D7 -#define RGBLIGHT_ANIMATIONS +//#define RGBLIGHT_ANIMATIONS #define RGBLIGHT_HUE_STEP 12 -#define RGBLIGHT_SAT_STEP 255 +#define RGBLIGHT_SAT_STEP 12 #define RGBLIGHT_VAL_STEP 12 +#define RGBLIGHT_LIMIT_VAL 200 + + +// RGB keycodes should not affect backlight +#define RGBLIGHT_DISABLE_KEYCODES // Pick one of the modes // Defaults to 15 mirror, for legacy behavior -// #define ERGODOX_LED_15 // Addresses 15 LEDs, but same position on both halves +//#define ERGODOX_LED_15 +// Addresses 15 LEDs, but same position on both halves // #define ERGODOX_LED_15_MIRROR // Addresses 15 LEDs, but are mirrored // #define ERGODOX_LED_30 // Addresses all 30 LED individually /* fix space cadet rollover issue */ #define DISABLE_SPACE_CADET_ROLLOVER -#define RGBW +// The underglow LEDs I used for the backlight mod aren't RGBW, +// undef this just to be sure. +#undef RGBW #define RGBLIGHT_SLEEP diff --git a/keymaps/default/config.h b/keymaps/default/config.h index 422c7ed..a349f67 100644 --- a/keymaps/default/config.h +++ b/keymaps/default/config.h @@ -2,7 +2,7 @@ Set any config.h overrides for your specific keymap here. See config.h options at https://docs.qmk.fm/#/config_options?id=the-configh-file */ -#define ORYX_CONFIGURATOR +//#define ORYX_CONFIGURATOR #undef RGB_MATRIX_HUE_STEP #define RGB_MATRIX_HUE_STEP 10 @@ -16,6 +16,8 @@ #define CAPS_LOCK_STATUS #define RGB_MATRIX_STARTUP_SPD 60 +#define RGBLIGHT_EFFECT_STATIC_LIGHT +#define RGBLIGHT_EFFECT_STATIC_GRADIENT // Disable unused animations #define DISABLE_RGB_MATRIX_ALPHAS_MODS // Static dual hue, speed is hue for secondary hue @@ -23,7 +25,7 @@ #define DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT // Static gradient left to right, speed controls how much gradient changes #define DISABLE_RGB_MATRIX_BREATHING // Single hue brightness cycling animation #define DISABLE_RGB_MATRIX_BAND_SAT // Single hue band fading saturation scrolling left to right -//#define DISABLE_RGB_MATRIX_BAND_VAL // Single hue band fading brightness scrolling left to right +#define DISABLE_RGB_MATRIX_BAND_VAL // Single hue band fading brightness scrolling left to right #define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT // Single hue 3 blade spinning pinwheel fades saturation #define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL // Single hue 3 blade spinning pinwheel fades brightness #define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT // Single hue spinning spiral fades saturation diff --git a/keymaps/default/keymap.c b/keymaps/default/keymap.c index 24ce1f9..f7603e8 100644 --- a/keymaps/default/keymap.c +++ b/keymaps/default/keymap.c @@ -6,14 +6,23 @@ // Define custom keys // (Must be done BEFORE keymaps) enum custom_keycodes { - RGB_SLD = EZ_SAFE_RANGE, - M_SHUTDOWN, + M_SHUTDOWN = EZ_SAFE_RANGE, M_RESETWM, RU_LAYER, EN_LAYER, M_RU_CTRL, M_RU_ALT, - + // Custom RGBLIGHT macros + LIGHT_TOG, // Toggle backlight + LIGHT_HUI, // Increase backlight hue + LIGHT_HUD, // Decrease backlight hue + LIGHT_SAI, // Increase backlight sat + LIGHT_SAD, // Decrease backlight sat + LIGHT_VAI, // Increase backlight val + LIGHT_VAD, // Decrease backlight val + LIGHT_SPI, // Increase backlight speed + LIGHT_SPD, // Decrease backlight speed + LIGHT_MOD, // Change backlight animation mode }; enum tap_dance_codes { @@ -35,7 +44,7 @@ enum layer_indices { LAYER_KEYBOARD_IDX, }; -// Used by to set system keymap +// Used to set system keymap enum key_encodings { LANG_NULL, // For layers that don't care about input lang LANG_EN, @@ -80,7 +89,17 @@ const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = { int current_lang = LANG_EN; void keyboard_post_init_user(void) { - rgb_matrix_enable(); + // Enable RGB key lights + rgb_matrix_enable_noeeprom(); + + // Set indicator LEDs to min brightness + ergodox_led_all_set(15); + + #ifdef RGBLIGHT_ENABLE + // Disable RGB backlight + rgblight_disable_noeeprom(); + #endif + //set_lang(LANG_EN); } @@ -121,9 +140,11 @@ void rgb_matrix_indicators_user(void) { break; case LAYER_SYMBOLS_IDX: set_layer_color(LAYER_SYMBOLS_LEDS_IDX); + //rgblight_setrgb(255, 255, 0); break; case LAYER_ARROWS_IDX: set_layer_color(LAYER_ARROWS_LEDS_IDX); + //rgblight_setrgb(255, 0, 0); break; case LAYER_FKEYS_IDX: set_layer_color(LAYER_FKEYS_LEDS_IDX); @@ -137,6 +158,7 @@ void rgb_matrix_indicators_user(void) { default: if (rgb_matrix_get_flags() == LED_FLAG_NONE) { rgb_matrix_set_color_all(0, 0, 0); + //rgblight_setrgb(0, 0, 0); } break; } @@ -209,11 +231,66 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } break; - case RGB_SLD: + // Custom RGBLIGHT macros + case LIGHT_TOG: if (record->event.pressed) { - rgblight_mode(1); + rgblight_toggle_noeeprom(); } - return false; + break; + + case LIGHT_MOD: + if (record->event.pressed) { + rgblight_step_noeeprom(); + } + break; + + case LIGHT_HUI: + if (record->event.pressed) { + rgblight_increase_hue_noeeprom(); + } + break; + + case LIGHT_HUD: + if (record->event.pressed) { + rgblight_decrease_hue_noeeprom(); + } + break; + + case LIGHT_SAI: + if (record->event.pressed) { + rgblight_increase_sat_noeeprom(); + } + break; + + case LIGHT_SAD: + if (record->event.pressed) { + rgblight_decrease_sat_noeeprom(); + } + break; + + case LIGHT_VAI: + if (record->event.pressed) { + rgblight_increase_val_noeeprom(); + } + break; + + case LIGHT_VAD: + if (record->event.pressed) { + rgblight_decrease_val_noeeprom(); + } + break; + + case LIGHT_SPI: + if (record->event.pressed) { + rgblight_increase_speed_noeeprom(); + } + break; + + case LIGHT_SPD: + if (record->event.pressed) { + rgblight_decrease_speed_noeeprom(); + } + break; } return true; } diff --git a/keymaps/default/layers/keyboard.h b/keymaps/default/layers/keyboard.h index fa639f0..e15d2f6 100644 --- a/keymaps/default/layers/keyboard.h +++ b/keymaps/default/layers/keyboard.h @@ -2,24 +2,24 @@ #include "keymap.h" #define LAYER_KEYBOARD LAYOUT_ergodox(\ - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\ - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, RGB_HUI,\ - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\ - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, RGB_HUD,\ - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\ + RGB_TOG, RGB_HUD, RGB_HUI, KC_NO, KC_NO, KC_NO, KC_NO,\ + TOGGLE_LAYER_COLOR, RGB_SAD, RGB_SAI, KC_NO, KC_NO, KC_NO, RGB_HUI,\ + KC_NO, RGB_VAD, RGB_VAI, KC_NO, KC_NO, KC_NO,\ + KC_NO, RGB_SPD, RGB_SPI, KC_NO, KC_NO, KC_NO, RGB_HUD,\ + KC_NO, KC_NO, KC_NO, KC_NO, RGB_MOD,\ \ - RGB_TOG, KC_NO,\ - RGB_SPI,\ - RGB_MOD, RGB_SLD, RGB_SPD,\ + KC_NO, KC_NO,\ + KC_NO,\ + KC_NO, KC_NO, KC_NO,\ \ \ - LED_LEVEL, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, RESET,\ - RGB_SAI, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\ - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\ - RGB_SAD, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\ - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,\ + KC_NO, LIGHT_HUD, LIGHT_HUI, KC_NO, KC_NO, KC_NO, LIGHT_TOG,\ + KC_NO, LIGHT_SAD, LIGHT_SAI, KC_NO, KC_NO, KC_NO, KC_NO,\ + LIGHT_VAD, LIGHT_VAI, KC_NO, KC_NO, KC_NO, KC_NO,\ + KC_NO, LIGHT_SPD, LIGHT_SPI, KC_NO, KC_NO, KC_NO, KC_NO,\ + LIGHT_MOD, KC_NO, KC_NO, TO(LAYER_MAIN_IDX), KC_NO,\ \ - KC_NO, RGB_TOG,\ + KC_NO, RGB_TOG,\ KC_NO,\ - TOGGLE_LAYER_COLOR, RGB_VAD, RGB_VAI\ + RESET, KC_NO, KC_NO\ ) diff --git a/keymaps/default/layers/main.h b/keymaps/default/layers/main.h index 3c325cc..fc75da8 100644 --- a/keymaps/default/layers/main.h +++ b/keymaps/default/layers/main.h @@ -8,7 +8,7 @@ M_RU_CTRL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_TRANSPARENT,\ MO(LAYER_DESKTOP_IDX), OSL(LAYER_FKEYS_IDX), KC_LALT, KC_LSHIFT, MO(LAYER_ARROWS_IDX),\ \ - KC_PSCREEN, LT(LAYER_KEYBOARD_IDX,KC_NO),\ + KC_PSCREEN, KC_NO,\ TD(TD_WMLAYOUT),\ KC_SPACE, KC_BSPACE, LCTL(KC_BSPACE),\ \ @@ -17,7 +17,7 @@ KC_TRANSPARENT, KC_Y, KC_U, KC_I, KC_O, KC_TRANSPARENT, TG(LAYER_NAVIGATE_IDX),\ KC_H, KC_J, KC_K, MO(LAYER_SYMBOLS_IDX), KC_L, KC_TRANSPARENT,\ KC_TRANSPARENT, KC_N, KC_M, KC_P, KC_DOT, KC_COMMA, KC_TRANSPARENT,\ - KC_RIGHT, KC_TRANSPARENT, KC_TRANSPARENT, OSL(LAYER_FKEYS_IDX), KC_TRANSPARENT,\ + KC_RIGHT, KC_TRANSPARENT, KC_TRANSPARENT, TO(LAYER_KEYBOARD_IDX), KC_TRANSPARENT,\ \ LGUI(KC_SPACE), TO(LAYER_RUSSIAN_IDX),\ TG(LAYER_COLEMAK_IDX),\ diff --git a/post_config.h b/post_config.h index 0d4fe5c..b32669a 100644 --- a/post_config.h +++ b/post_config.h @@ -20,6 +20,7 @@ along with this program. If not, see . #pragma once +/* #if !defined(ERGODOX_LED_15) && !defined(ERGODOX_LED_30) // if no value is defined, assume previous behavior // # define ERGODOX_LED_15 @@ -38,3 +39,4 @@ along with this program. If not, see . // If not, then only define 15 # define RGBLED_NUM 15 // Number of LEDs #endif +*/ \ No newline at end of file diff --git a/rules.mk b/rules.mk index 1080a89..bd60630 100644 --- a/rules.mk +++ b/rules.mk @@ -31,8 +31,6 @@ SWAP_HANDS_ENABLE= no # Allow swapping hands of keyboard SLEEP_LED_ENABLE = no API_SYSEX_ENABLE = no -RGB_MATRIX_ENABLE = no # enable later -RGB_MATRIX_DRIVER = IS31FL3731 DEBOUNCE_TYPE = eager_pr # project specific files @@ -47,6 +45,7 @@ MOUSE_SHARED_EP = no # FROM glow dir -RGB_MATRIX_ENABLE = IS31FL3731 RGB_MATRIX_ENABLE = yes RGB_MATRIX_DRIVER = IS31FL3731 +RGBLIGHT_ENABLE = yes +RGBLIGHT_DRIVER = WS2812 \ No newline at end of file