diff options
Diffstat (limited to 'keyboards/crkbd/keymaps/gotham/rgb.c')
| -rw-r--r-- | keyboards/crkbd/keymaps/gotham/rgb.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/gotham/rgb.c b/keyboards/crkbd/keymaps/gotham/rgb.c new file mode 100644 index 000000000..9f6642883 --- /dev/null +++ b/keyboards/crkbd/keymaps/gotham/rgb.c | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #ifdef RGBLIGHT_ENABLE | ||
| 4 | extern rgblight_config_t rgblight_config; | ||
| 5 | rgblight_config_t RGB_current_config; | ||
| 6 | #endif | ||
| 7 | |||
| 8 | #ifdef RGB_MATRIX_ENABLE | ||
| 9 | extern rgb_config_t rgb_matrix_config; | ||
| 10 | rgb_config_t RGB_current_config; | ||
| 11 | #endif | ||
| 12 | |||
| 13 | void save_rgb_config(void) { | ||
| 14 | #ifdef RGBLIGHT_ENABLE | ||
| 15 | RGB_current_config.enable = rgblight_config.enable; | ||
| 16 | RGB_current_config.mode = rgblight_get_mode(); | ||
| 17 | RGB_current_config.speed = rgblight_get_speed(); | ||
| 18 | RGB_current_config.hue = rgblight_get_hue(); | ||
| 19 | RGB_current_config.sat = rgblight_get_sat(); | ||
| 20 | RGB_current_config.val = rgblight_get_val(); | ||
| 21 | #elif RGB_MATRIX_ENABLE | ||
| 22 | RGB_current_config.enable = rgb_matrix_config.enable; | ||
| 23 | RGB_current_config.mode = rgb_matrix_get_mode(); | ||
| 24 | RGB_current_config.speed = rgb_matrix_config.speed; | ||
| 25 | RGB_current_config.hsv = rgb_matrix_config.hsv; | ||
| 26 | #endif | ||
| 27 | } | ||
| 28 | |||
| 29 | void restore_rgb_config(void) { | ||
| 30 | #ifdef RGBLIGHT_ENABLE | ||
| 31 | rgblight_set_speed_noeeprom(RGB_current_config.speed); | ||
| 32 | if (rgblight_config.mode != RGB_current_config.mode) { | ||
| 33 | rgblight_mode_noeeprom(RGB_current_config.mode); | ||
| 34 | } | ||
| 35 | if ((RGB_current_config.hue != rgblight_config.hue) || (RGB_current_config.sat != rgblight_config.sat) || (RGB_current_config.val != rgblight_config.val)) { | ||
| 36 | rgblight_sethsv_noeeprom(RGB_current_config.hue, RGB_current_config.sat, RGB_current_config.val); | ||
| 37 | } | ||
| 38 | if (rgblight_config.enable) { | ||
| 39 | rgblight_enable_noeeprom(); | ||
| 40 | } else { | ||
| 41 | rgblight_disable_noeeprom(); | ||
| 42 | } | ||
| 43 | #elif RGB_MATRIX_ENABLE | ||
| 44 | rgb_matrix_config.speed = RGB_current_config.speed; | ||
| 45 | if (rgb_matrix_config.mode != RGB_current_config.mode) { | ||
| 46 | rgb_matrix_mode_noeeprom(RGB_current_config.mode); | ||
| 47 | } | ||
| 48 | if ((RGB_current_config.hsv.h != rgb_matrix_config.hsv.h) || (RGB_current_config.hsv.s != rgb_matrix_config.hsv.s) || (RGB_current_config.hsv.v != rgb_matrix_config.hsv.v)) { | ||
| 49 | rgb_matrix_sethsv_noeeprom(RGB_current_config.hsv.h, RGB_current_config.hsv.s, RGB_current_config.hsv.v); | ||
| 50 | } | ||
| 51 | if (rgb_matrix_config.enable) { | ||
| 52 | rgb_matrix_enable_noeeprom(); | ||
| 53 | } else { | ||
| 54 | rgb_matrix_disable_noeeprom(); | ||
| 55 | } | ||
| 56 | #endif | ||
| 57 | } | ||
| 58 | |||
| 59 | void rgb_by_layer(int layer) { | ||
| 60 | #ifdef RGBLIGHT_ENABLE | ||
| 61 | rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); | ||
| 62 | #elif RGB_MATRIX_ENABLE | ||
| 63 | rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); | ||
| 64 | #endif | ||
| 65 | |||
| 66 | switch (layer) { | ||
| 67 | case _ADJUST: | ||
| 68 | rgblight_sethsv_noeeprom(9, 255, 255); | ||
| 69 | break; | ||
| 70 | case _RAISE: | ||
| 71 | rgblight_sethsv_noeeprom(HSV_CYAN); | ||
| 72 | break; | ||
| 73 | case _LOWER: | ||
| 74 | rgblight_sethsv_noeeprom(HSV_MAGENTA); | ||
| 75 | break; | ||
| 76 | default: | ||
| 77 | rgblight_sethsv_noeeprom(HSV_RED); | ||
| 78 | } | ||
| 79 | } | ||
