aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quantum/rgb_matrix.c60
-rw-r--r--quantum/rgb_matrix.h59
-rw-r--r--quantum/rgblight.c4
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
845uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { 845static 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
851uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { 851static 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
890void rgblight_toggle(void) { 890void 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
895void rgblight_step(void) { 895void rgb_matrix_enable(void) {
896 rgb_matrix_config.enable = 1;
897 eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
898}
899
900void rgb_matrix_enable_noeeprom(void) {
901 rgb_matrix_config.enable = 1;
902}
903
904void rgb_matrix_disable(void) {
905 rgb_matrix_config.enable = 0;
906 eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
907}
908
909void rgb_matrix_disable_noeeprom(void) {
910 rgb_matrix_config.enable = 0;
911}
912
913void 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
902void rgblight_step_reverse(void) { 920void 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
909void rgblight_increase_hue(void) { 927void 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
914void rgblight_decrease_hue(void) { 932void 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
919void rgblight_increase_sat(void) { 937void 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
924void rgblight_decrease_sat(void) { 942void 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
929void rgblight_increase_val(void) { 947void 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
934void rgblight_decrease_val(void) { 952void 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
939void rgblight_increase_speed(void) { 957void 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
944void rgblight_decrease_speed(void) { 962void 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
949void rgblight_mode(uint8_t mode) { 967void 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
954uint32_t rgblight_get_mode(void) { 972void rgb_matrix_mode_noeeprom(uint8_t mode) {
973 rgb_matrix_config.mode = mode;
974}
975
976uint32_t rgb_matrix_get_mode(void) {
955 return rgb_matrix_config.mode; 977 return rgb_matrix_config.mode;
956} 978}
957 979
958void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { 980void 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
987void 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
129void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ); 129void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
130void 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
161uint32_t rgb_matrix_get_tick(void); 162uint32_t rgb_matrix_get_tick(void);
162 163
163void rgblight_toggle(void); 164void rgb_matrix_toggle(void);
164void rgblight_step(void); 165void rgb_matrix_enable(void);
165void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); 166void rgb_matrix_enable_noeeprom(void);
166void rgblight_step_reverse(void); 167void rgb_matrix_disable(void);
167void rgblight_increase_hue(void); 168void rgb_matrix_disable_noeeprom(void);
168void rgblight_decrease_hue(void); 169void rgb_matrix_step(void);
169void rgblight_increase_sat(void); 170void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
170void rgblight_decrease_sat(void); 171void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
171void rgblight_increase_val(void); 172void rgb_matrix_step_reverse(void);
172void rgblight_decrease_val(void); 173void rgb_matrix_increase_hue(void);
173void rgblight_increase_speed(void); 174void rgb_matrix_decrease_hue(void);
174void rgblight_decrease_speed(void); 175void rgb_matrix_increase_sat(void);
175void rgblight_mode(uint8_t mode); 176void rgb_matrix_decrease_sat(void);
176uint32_t rgblight_get_mode(void); 177void rgb_matrix_increase_val(void);
178void rgb_matrix_decrease_val(void);
179void rgb_matrix_increase_speed(void);
180void rgb_matrix_decrease_speed(void);
181void rgb_matrix_mode(uint8_t mode);
182void rgb_matrix_mode_noeeprom(uint8_t mode);
183uint32_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
178typedef struct { 209typedef 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
328uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { 328static 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
334uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { 334static 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 );