From 3a3e5abac992712a8bb4e9b61430f5fc62dc6043 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 31 May 2023 11:44:06 -0700 Subject: [Keymap] Drashna Keymap updates for 0.21.0 (#21073) --- users/drashna/rgb/rgb_matrix_config.h | 2 +- users/drashna/rgb/rgb_matrix_stuff.c | 44 ++++++++++++++++++++++++++++++++++- users/drashna/rgb/rgb_matrix_stuff.h | 2 ++ users/drashna/rgb/rgb_stuff.c | 42 +++++++++++++++++++++++++++++++++ users/drashna/rgb/rgb_stuff.h | 3 +++ 5 files changed, 91 insertions(+), 2 deletions(-) (limited to 'users/drashna/rgb') diff --git a/users/drashna/rgb/rgb_matrix_config.h b/users/drashna/rgb/rgb_matrix_config.h index 86f238f392..bc2c04d981 100644 --- a/users/drashna/rgb/rgb_matrix_config.h +++ b/users/drashna/rgb/rgb_matrix_config.h @@ -6,7 +6,7 @@ #define RGB_MATRIX_KEYPRESSES // reacts to keypresses (will slow down matrix scan by a lot) // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) #define RGB_MATRIX_FRAMEBUFFER_EFFECTS -// # define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended +#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended #undef ENABLE_RGB_MATRIX_ALPHAS_MODS #undef ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN diff --git a/users/drashna/rgb/rgb_matrix_stuff.c b/users/drashna/rgb/rgb_matrix_stuff.c index eff9191eb7..588e51daf9 100644 --- a/users/drashna/rgb/rgb_matrix_stuff.c +++ b/users/drashna/rgb/rgb_matrix_stuff.c @@ -74,7 +74,7 @@ bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { userspace_config.rgb_matrix_idle_anim ^= 1; dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim); - eeconfig_update_user(userspace_config.raw); + eeconfig_update_user_config(&userspace_config.raw); if (userspace_config.rgb_matrix_idle_anim) { rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP); } @@ -146,3 +146,45 @@ __attribute__((weak)) bool rgb_matrix_indicators_keymap(void) { bool rgb_matrix_indicators_user(void) { return rgb_matrix_indicators_keymap(); } + + +//---------------------------------------------------------- +// RGB Matrix naming +#include + +#if defined(RGB_MATRIX_EFFECT) +# undef RGB_MATRIX_EFFECT +#endif // defined(RGB_MATRIX_EFFECT) + +#define RGB_MATRIX_EFFECT(x) RGB_MATRIX_EFFECT_##x, +enum { + RGB_MATRIX_EFFECT_NONE, +#include "rgb_matrix_effects.inc" +#undef RGB_MATRIX_EFFECT +#ifdef RGB_MATRIX_CUSTOM_KB +# include "rgb_matrix_kb.inc" +#endif +#ifdef RGB_MATRIX_CUSTOM_USER +# include "rgb_matrix_user.inc" +#endif +}; + +#define RGB_MATRIX_EFFECT(x) \ + case RGB_MATRIX_EFFECT_##x: \ + return #x; +const char* rgb_matrix_name(uint8_t effect) { + switch (effect) { + case RGB_MATRIX_EFFECT_NONE: + return "NONE"; +#include "rgb_matrix_effects.inc" +#undef RGB_MATRIX_EFFECT +#ifdef RGB_MATRIX_CUSTOM_KB +# include "rgb_matrix_kb.inc" +#endif +#ifdef RGB_MATRIX_CUSTOM_USER +# include "rgb_matrix_user.inc" +#endif + default: + return "UNKNOWN"; + } +} diff --git a/users/drashna/rgb/rgb_matrix_stuff.h b/users/drashna/rgb/rgb_matrix_stuff.h index 9559134c8c..80770bf40f 100644 --- a/users/drashna/rgb/rgb_matrix_stuff.h +++ b/users/drashna/rgb/rgb_matrix_stuff.h @@ -13,3 +13,5 @@ void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max); bool rgb_matrix_indicators_keymap(void); + +const char* rgb_matrix_name(uint8_t effect); diff --git a/users/drashna/rgb/rgb_stuff.c b/users/drashna/rgb/rgb_stuff.c index c283e58d26..cc85425aff 100644 --- a/users/drashna/rgb/rgb_stuff.c +++ b/users/drashna/rgb/rgb_stuff.c @@ -11,6 +11,9 @@ void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); } void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) { + if (val > RGBLIGHT_LIMIT_VAL) { + val = RGBLIGHT_LIMIT_VAL; + } rgblight_sethsv_noeeprom(hue, sat, val); // wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly rgblight_mode_noeeprom(mode); @@ -48,6 +51,15 @@ uint32_t rgb_startup_animation(uint32_t triger_time, void *cb_arg) { } #endif +bool is_rgblight_startup_running(void) { +#if defined(RGBLIGHT_STARTUP_ANIMATION) + return is_rgblight_startup && is_keyboard_master(); +#else + return false; +#endif +} + + void keyboard_post_init_rgb_light(void) { #if defined(RGBLIGHT_STARTUP_ANIMATION) is_enabled = rgblight_is_enabled(); @@ -121,3 +133,33 @@ layer_state_t default_layer_state_set_rgb_light(layer_state_t state) { } return state; } + +#define _RGBM_SINGLE_STATIC(sym) \ + case RGBLIGHT_MODE_##sym: \ + return #sym; +#define _RGBM_SINGLE_DYNAMIC(sym) \ + case RGBLIGHT_MODE_##sym: \ + return #sym; +#define _RGBM_MULTI_STATIC(sym) \ + case RGBLIGHT_MODE_##sym: \ + return #sym; +#define _RGBM_MULTI_DYNAMIC(sym) \ + case RGBLIGHT_MODE_##sym: \ + return #sym; +#define _RGBM_TMP_STATIC(sym, msym) \ + case RGBLIGHT_MODE_##sym: \ + return #msym; +#define _RGBM_TMP_DYNAMIC(sym, msym) \ + case RGBLIGHT_MODE_##sym: \ + return #msym; + + +const char* rgblight_name(uint8_t effect) { + switch (effect) { +#include "rgblight_modes.h" + case 0: + return "Off"; + default: + return "UNKNOWN"; + } +} diff --git a/users/drashna/rgb/rgb_stuff.h b/users/drashna/rgb/rgb_stuff.h index d720275b60..f76c591e03 100644 --- a/users/drashna/rgb/rgb_stuff.h +++ b/users/drashna/rgb/rgb_stuff.h @@ -10,3 +10,6 @@ void matrix_scan_rgb_light(void); layer_state_t layer_state_set_rgb_light(layer_state_t state); layer_state_t default_layer_state_set_rgb_light(layer_state_t state); void rgblight_sethsv_default_helper(uint8_t index); + +const char* rgblight_name(uint8_t effect); +bool is_rgblight_startup_running(void); -- cgit v1.2.3