diff options
Diffstat (limited to 'qmk/keyboards/sofle_choc/keymaps')
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c | 4 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/lighting.c | 67 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/lighting.h | 5 |
3 files changed, 50 insertions, 26 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c index 2843bbd..1d9c017 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c @@ -2,9 +2,10 @@ #include "keymap_bepo.h" #include "keycodes.h" #include "star_key.h" +#include "lighting.h" void keyboard_post_init_user(void) { - rgb_matrix_sethsv_noeeprom(HSV_WHITE); + lighting_init(); star_key_init(); } @@ -12,6 +13,7 @@ void housekeeping_task_user(void) { if (is_keyboard_master()) { sync_star_key(); } + housekeeping_task_lighting(); } /* diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c index 3060dce..fd491e6 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c @@ -1,6 +1,7 @@ #include QMK_KEYBOARD_H uint8_t flags = 0; #include "keycodes.h" +#include "lighting.h" // The variable is defined in star_key.h // The LED is on when the key is pressed. @@ -17,10 +18,15 @@ HSV hsv_of_color(uint8_t h, uint8_t s, uint8_t v) { return (HSV){h, s, v > 100 ? 100:v}; } -#define KEY_5 MT(MOD_LCTL, KC_P5) -#define KEY_DOWN MT(MOD_RCTL, KC_DOWN) -bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { - // Activate effects depending of mods +void lighting_init(void) { + rgb_matrix_sethsv_noeeprom(HSV_WHITE); + rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_SIMPLE); +} + + +static uint8_t last_flags; + +void housekeeping_task_lighting(void) { // Colors for the mods HSV const colors[] = { @@ -34,14 +40,6 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { hsv_of_color(HSV_WHITE), // 111 }; - if (is_caps_word_on()) { - if (rgb_matrix_get_mode() != RGB_MATRIX_BREATHING) { - rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING); - } - rgb_matrix_sethsv_noeeprom(HSV_SPRINGGREEN); - return false; - } - uint8_t counter = 0; uint8_t flags = 0; if (get_mods() & MOD_MASK_CTRL) { @@ -57,6 +55,38 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { counter += 1; } + if (flags == last_flags) { + return; + } + last_flags = flags; + + if (get_mods()) { + if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_COLOR) { + rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); + } + uint8_t v = colors[flags].v; + if (counter >= 2) + v *= 2; + rgb_matrix_sethsv_noeeprom(colors[flags].h, colors[flags].s, v); + } else if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_REACTIVE_SIMPLE) { + rgb_matrix_sethsv_noeeprom(HSV_WHITE); + rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_SIMPLE); + } +} + +#define KEY_5 MT(MOD_LCTL, KC_P5) +#define KEY_DOWN MT(MOD_RCTL, KC_DOWN) +bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + // Activate effects depending of mods + + if (is_caps_word_on()) { + if (rgb_matrix_get_mode() != RGB_MATRIX_BREATHING) { + rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING); + } + rgb_matrix_sethsv_noeeprom(HSV_SPRINGGREEN); + return false; + } + for (uint8_t row = 0; row < MATRIX_ROWS; ++row) { for (uint8_t col = 0; col < MATRIX_COLS; ++col) { uint8_t index = g_led_config.matrix_co[row][col]; @@ -103,18 +133,5 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { } } - if (get_mods()) { - if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_COLOR) { - rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); - } - uint8_t v = colors[flags].v; - if (counter == 2) - v *= 2; - rgb_matrix_sethsv_noeeprom(colors[flags].h, colors[flags].s, v); - } else if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_REACTIVE_SIMPLE) { - rgb_matrix_sethsv_noeeprom(HSV_WHITE); - rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_SIMPLE); - } - return false; } diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.h b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.h new file mode 100644 index 0000000..b3bd615 --- /dev/null +++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.h @@ -0,0 +1,5 @@ +#pragma once + +void lighting_init(void); + +void housekeeping_task_lighting(void); |