diff options
author | Drashna Jaelre <drashna@live.com> | 2018-12-03 10:27:15 -0800 |
---|---|---|
committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2018-12-03 10:27:15 -0800 |
commit | da1afe152af5a6dfb5c0bb28d86d34940162f960 (patch) | |
tree | 30f9572d46787799f4797a165464df0d2103f350 /quantum/rgb_matrix.c | |
parent | fe982caf5d69fdb2d6f1dec123a630df11a98282 (diff) | |
download | qmk_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.c | 60 |
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 |
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 | } | ||