diff options
| -rw-r--r-- | quantum/rgb_matrix.c | 60 | ||||
| -rw-r--r-- | quantum/rgb_matrix.h | 59 | ||||
| -rw-r--r-- | quantum/rgblight.c | 4 |
3 files changed, 91 insertions, 32 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 15bd13671..82d36177b 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
| @@ -842,13 +842,13 @@ void rgb_matrix_init(void) { | |||
| 842 | } | 842 | } |
| 843 | 843 | ||
| 844 | // Deals with the messy details of incrementing an integer | 844 | // Deals with the messy details of incrementing an integer |
| 845 | uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | 845 | static uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { |
| 846 | int16_t new_value = value; | 846 | int16_t new_value = value; |
| 847 | new_value += step; | 847 | new_value += step; |
| 848 | return MIN( MAX( new_value, min ), max ); | 848 | return MIN( MAX( new_value, min ), max ); |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | 851 | static uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { |
| 852 | int16_t new_value = value; | 852 | int16_t new_value = value; |
| 853 | new_value -= step; | 853 | new_value -= step; |
| 854 | return MIN( MAX( new_value, min ), max ); | 854 | return MIN( MAX( new_value, min ), max ); |
| @@ -887,77 +887,105 @@ uint32_t rgb_matrix_get_tick(void) { | |||
| 887 | return g_tick; | 887 | return g_tick; |
| 888 | } | 888 | } |
| 889 | 889 | ||
| 890 | void rgblight_toggle(void) { | 890 | void rgb_matrix_toggle(void) { |
| 891 | rgb_matrix_config.enable ^= 1; | 891 | rgb_matrix_config.enable ^= 1; |
| 892 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 892 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 893 | } | 893 | } |
| 894 | 894 | ||
| 895 | void rgblight_step(void) { | 895 | void rgb_matrix_enable(void) { |
| 896 | rgb_matrix_config.enable = 1; | ||
| 897 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | ||
| 898 | } | ||
| 899 | |||
| 900 | void rgb_matrix_enable_noeeprom(void) { | ||
| 901 | rgb_matrix_config.enable = 1; | ||
| 902 | } | ||
| 903 | |||
| 904 | void rgb_matrix_disable(void) { | ||
| 905 | rgb_matrix_config.enable = 0; | ||
| 906 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | ||
| 907 | } | ||
| 908 | |||
| 909 | void rgb_matrix_disable_noeeprom(void) { | ||
| 910 | rgb_matrix_config.enable = 0; | ||
| 911 | } | ||
| 912 | |||
| 913 | void rgb_matrix_step(void) { | ||
| 896 | rgb_matrix_config.mode++; | 914 | rgb_matrix_config.mode++; |
| 897 | if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) | 915 | if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) |
| 898 | rgb_matrix_config.mode = 1; | 916 | rgb_matrix_config.mode = 1; |
| 899 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 917 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 900 | } | 918 | } |
| 901 | 919 | ||
| 902 | void rgblight_step_reverse(void) { | 920 | void rgb_matrix_step_reverse(void) { |
| 903 | rgb_matrix_config.mode--; | 921 | rgb_matrix_config.mode--; |
| 904 | if (rgb_matrix_config.mode < 1) | 922 | if (rgb_matrix_config.mode < 1) |
| 905 | rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; | 923 | rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; |
| 906 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 924 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 907 | } | 925 | } |
| 908 | 926 | ||
| 909 | void rgblight_increase_hue(void) { | 927 | void rgb_matrix_increase_hue(void) { |
| 910 | rgb_matrix_config.hue = increment( rgb_matrix_config.hue, 8, 0, 255 ); | 928 | rgb_matrix_config.hue = increment( rgb_matrix_config.hue, 8, 0, 255 ); |
| 911 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 929 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 912 | } | 930 | } |
| 913 | 931 | ||
| 914 | void rgblight_decrease_hue(void) { | 932 | void rgb_matrix_decrease_hue(void) { |
| 915 | rgb_matrix_config.hue = decrement( rgb_matrix_config.hue, 8, 0, 255 ); | 933 | rgb_matrix_config.hue = decrement( rgb_matrix_config.hue, 8, 0, 255 ); |
| 916 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 934 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 917 | } | 935 | } |
| 918 | 936 | ||
| 919 | void rgblight_increase_sat(void) { | 937 | void rgb_matrix_increase_sat(void) { |
| 920 | rgb_matrix_config.sat = increment( rgb_matrix_config.sat, 8, 0, 255 ); | 938 | rgb_matrix_config.sat = increment( rgb_matrix_config.sat, 8, 0, 255 ); |
| 921 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 939 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 922 | } | 940 | } |
| 923 | 941 | ||
| 924 | void rgblight_decrease_sat(void) { | 942 | void rgb_matrix_decrease_sat(void) { |
| 925 | rgb_matrix_config.sat = decrement( rgb_matrix_config.sat, 8, 0, 255 ); | 943 | rgb_matrix_config.sat = decrement( rgb_matrix_config.sat, 8, 0, 255 ); |
| 926 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 944 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 927 | } | 945 | } |
| 928 | 946 | ||
| 929 | void rgblight_increase_val(void) { | 947 | void rgb_matrix_increase_val(void) { |
| 930 | rgb_matrix_config.val = increment( rgb_matrix_config.val, 8, 0, RGB_MATRIX_MAXIMUM_BRIGHTNESS ); | 948 | rgb_matrix_config.val = increment( rgb_matrix_config.val, 8, 0, RGB_MATRIX_MAXIMUM_BRIGHTNESS ); |
| 931 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 949 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 932 | } | 950 | } |
| 933 | 951 | ||
| 934 | void rgblight_decrease_val(void) { | 952 | void rgb_matrix_decrease_val(void) { |
| 935 | rgb_matrix_config.val = decrement( rgb_matrix_config.val, 8, 0, RGB_MATRIX_MAXIMUM_BRIGHTNESS ); | 953 | rgb_matrix_config.val = decrement( rgb_matrix_config.val, 8, 0, RGB_MATRIX_MAXIMUM_BRIGHTNESS ); |
| 936 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 954 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 937 | } | 955 | } |
| 938 | 956 | ||
| 939 | void rgblight_increase_speed(void) { | 957 | void rgb_matrix_increase_speed(void) { |
| 940 | rgb_matrix_config.speed = increment( rgb_matrix_config.speed, 1, 0, 3 ); | 958 | rgb_matrix_config.speed = increment( rgb_matrix_config.speed, 1, 0, 3 ); |
| 941 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this | 959 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this |
| 942 | } | 960 | } |
| 943 | 961 | ||
| 944 | void rgblight_decrease_speed(void) { | 962 | void rgb_matrix_decrease_speed(void) { |
| 945 | rgb_matrix_config.speed = decrement( rgb_matrix_config.speed, 1, 0, 3 ); | 963 | rgb_matrix_config.speed = decrement( rgb_matrix_config.speed, 1, 0, 3 ); |
| 946 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this | 964 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this |
| 947 | } | 965 | } |
| 948 | 966 | ||
| 949 | void rgblight_mode(uint8_t mode) { | 967 | void rgb_matrix_mode(uint8_t mode) { |
| 950 | rgb_matrix_config.mode = mode; | 968 | rgb_matrix_config.mode = mode; |
| 951 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 969 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 952 | } | 970 | } |
| 953 | 971 | ||
| 954 | uint32_t rgblight_get_mode(void) { | 972 | void rgb_matrix_mode_noeeprom(uint8_t mode) { |
| 973 | rgb_matrix_config.mode = mode; | ||
| 974 | } | ||
| 975 | |||
| 976 | uint32_t rgb_matrix_get_mode(void) { | ||
| 955 | return rgb_matrix_config.mode; | 977 | return rgb_matrix_config.mode; |
| 956 | } | 978 | } |
| 957 | 979 | ||
| 958 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | 980 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { |
| 959 | rgb_matrix_config.hue = hue; | 981 | rgb_matrix_config.hue = hue; |
| 960 | rgb_matrix_config.sat = sat; | 982 | rgb_matrix_config.sat = sat; |
| 961 | rgb_matrix_config.val = val; | 983 | rgb_matrix_config.val = val; |
| 962 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 984 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 963 | } | 985 | } |
| 986 | |||
| 987 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 988 | rgb_matrix_config.hue = hue; | ||
| 989 | rgb_matrix_config.sat = sat; | ||
| 990 | rgb_matrix_config.val = val; | ||
| 991 | } | ||
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 3cd248ffc..0cfeb4e06 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h | |||
| @@ -127,6 +127,7 @@ enum rgb_matrix_effects { | |||
| 127 | }; | 127 | }; |
| 128 | 128 | ||
| 129 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); | 129 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); |
| 130 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); | ||
| 130 | 131 | ||
| 131 | // This runs after another backlight effect and replaces | 132 | // This runs after another backlight effect and replaces |
| 132 | // colors already set | 133 | // colors already set |
| @@ -160,20 +161,50 @@ void rgb_matrix_decrease(void); | |||
| 160 | 161 | ||
| 161 | uint32_t rgb_matrix_get_tick(void); | 162 | uint32_t rgb_matrix_get_tick(void); |
| 162 | 163 | ||
| 163 | void rgblight_toggle(void); | 164 | void rgb_matrix_toggle(void); |
| 164 | void rgblight_step(void); | 165 | void rgb_matrix_enable(void); |
| 165 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); | 166 | void rgb_matrix_enable_noeeprom(void); |
| 166 | void rgblight_step_reverse(void); | 167 | void rgb_matrix_disable(void); |
| 167 | void rgblight_increase_hue(void); | 168 | void rgb_matrix_disable_noeeprom(void); |
| 168 | void rgblight_decrease_hue(void); | 169 | void rgb_matrix_step(void); |
| 169 | void rgblight_increase_sat(void); | 170 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val); |
| 170 | void rgblight_decrease_sat(void); | 171 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); |
| 171 | void rgblight_increase_val(void); | 172 | void rgb_matrix_step_reverse(void); |
| 172 | void rgblight_decrease_val(void); | 173 | void rgb_matrix_increase_hue(void); |
| 173 | void rgblight_increase_speed(void); | 174 | void rgb_matrix_decrease_hue(void); |
| 174 | void rgblight_decrease_speed(void); | 175 | void rgb_matrix_increase_sat(void); |
| 175 | void rgblight_mode(uint8_t mode); | 176 | void rgb_matrix_decrease_sat(void); |
| 176 | uint32_t rgblight_get_mode(void); | 177 | void rgb_matrix_increase_val(void); |
| 178 | void rgb_matrix_decrease_val(void); | ||
| 179 | void rgb_matrix_increase_speed(void); | ||
| 180 | void rgb_matrix_decrease_speed(void); | ||
| 181 | void rgb_matrix_mode(uint8_t mode); | ||
| 182 | void rgb_matrix_mode_noeeprom(uint8_t mode); | ||
| 183 | uint32_t rgb_matrix_get_mode(void); | ||
| 184 | |||
| 185 | #ifndef RGBLIGHT_ENABLE | ||
| 186 | #define rgblight_toggle() rgb_matrix_toggle() | ||
| 187 | #define rgblight_enable() rgb_matrix_enable() | ||
| 188 | #define rgblight_enable_noeeprom() rgb_matrix_enable_noeeprom() | ||
| 189 | #define rgblight_disable() rgb_matrix_disable() | ||
| 190 | #define rgblight_disable_noeeprom() rgb_matrix_disable_noeeprom() | ||
| 191 | #define rgblight_step() rgb_matrix_step() | ||
| 192 | #define rgblight_sethsv(hue, sat, val) rgb_matrix_sethsv(hue, sat, val) | ||
| 193 | #define rgblight_sethsv_noeeprom(hue, sat, val) rgb_matrix_sethsv_noeeprom(hue, sat, val) | ||
| 194 | #define rgblight_step_reverse() rgb_matrix_step_reverse() | ||
| 195 | #define rgblight_increase_hue() rgb_matrix_increase_hue() | ||
| 196 | #define rgblight_decrease_hue() rgb_matrix_decrease_hue() | ||
| 197 | #define rgblight_increase_sat() rgb_matrix_increase_sat() | ||
| 198 | #define rgblight_decrease_sat() rgb_matrix_decrease_sat() | ||
| 199 | #define rgblight_increase_val() rgb_matrix_increase_val() | ||
| 200 | #define rgblight_decrease_val() rgb_matrix_decrease_val() | ||
| 201 | #define rgblight_increase_speed() rgb_matrix_increase_speed() | ||
| 202 | #define rgblight_decrease_speed() rgb_matrix_decrease_speed() | ||
| 203 | #define rgblight_mode(mode) rgb_matrix_mode(mode) | ||
| 204 | #define rgblight_mode_noeeprom(mode) rgb_matrix_mode_noeeprom(mode) | ||
| 205 | #define rgblight_get_mode() rgb_matrix_get_mode() | ||
| 206 | |||
| 207 | #endif | ||
| 177 | 208 | ||
| 178 | typedef struct { | 209 | typedef struct { |
| 179 | /* Perform any initialisation required for the other driver functions to work. */ | 210 | /* Perform any initialisation required for the other driver functions to work. */ |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 9ce3b2309..a2d6fe7a0 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -325,13 +325,13 @@ void rgblight_disable_noeeprom(void) { | |||
| 325 | 325 | ||
| 326 | 326 | ||
| 327 | // Deals with the messy details of incrementing an integer | 327 | // Deals with the messy details of incrementing an integer |
| 328 | uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | 328 | static uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { |
| 329 | int16_t new_value = value; | 329 | int16_t new_value = value; |
| 330 | new_value += step; | 330 | new_value += step; |
| 331 | return MIN( MAX( new_value, min ), max ); | 331 | return MIN( MAX( new_value, min ), max ); |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | 334 | static uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { |
| 335 | int16_t new_value = value; | 335 | int16_t new_value = value; |
| 336 | new_value -= step; | 336 | new_value -= step; |
| 337 | return MIN( MAX( new_value, min ), max ); | 337 | return MIN( MAX( new_value, min ), max ); |
