aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2018-12-03 10:27:15 -0800
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2018-12-03 10:27:15 -0800
commitda1afe152af5a6dfb5c0bb28d86d34940162f960 (patch)
tree30f9572d46787799f4797a165464df0d2103f350 /quantum/rgb_matrix.c
parentfe982caf5d69fdb2d6f1dec123a630df11a98282 (diff)
downloadqmk_firmware-da1afe152af5a6dfb5c0bb28d86d34940162f960.tar.gz
qmk_firmware-da1afe152af5a6dfb5c0bb28d86d34940162f960.zip
Fix up RGB Matrix code (#4503)
* Fix up RGB Matrix code * Convert RGBLIGHT functions to rgbmatrix ones, and add defines
Diffstat (limited to 'quantum/rgb_matrix.c')
-rw-r--r--quantum/rgb_matrix.c60
1 files changed, 44 insertions, 16 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}