From b0ed49aafb036a73346ee2594c77f24e034fd27e Mon Sep 17 00:00:00 2001 From: tynanbe Date: Wed, 24 Jun 2020 15:14:32 -0500 Subject: [PATCH] Note what should be removed when QMK merges PR #9487 --- users/tynanbe/tynanbe_rgb.c | 86 ++++++------------------------------- users/tynanbe/tynanbe_rgb.h | 6 +-- 2 files changed, 16 insertions(+), 76 deletions(-) diff --git a/users/tynanbe/tynanbe_rgb.c b/users/tynanbe/tynanbe_rgb.c index 72feeb42d7cc..d9cbd75e529a 100644 --- a/users/tynanbe/tynanbe_rgb.c +++ b/users/tynanbe/tynanbe_rgb.c @@ -6,12 +6,10 @@ # include "rgb_matrix.h" #endif // RGBLIGHT_ENABLE - - +//TODO remove after QMK merges https://github.com/qmk/qmk_firmware/pull/9487 static rgb_task_states rgb_task_state = SYNCING; void my_eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } - void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { rgb_matrix_config.enable ^= 1; rgb_task_state = STARTING; @@ -29,7 +27,6 @@ void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); } //void rgb_matrix_toggle(void) { rgb_matrix_toggle_eeprom_helper(true); } - void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { if (! rgb_matrix_config.enable) { return; @@ -70,7 +67,6 @@ void rgb_matrix_step_helper(bool write_to_eeprom) { void rgb_matrix_step_noeeprom(void) { rgb_matrix_step_helper(false); } //void rgb_matrix_step(void) { rgb_matrix_step_helper(true); } - void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { uint8_t mode = rgb_matrix_config.mode - 1; rgb_matrix_mode_eeprom_helper( @@ -83,7 +79,6 @@ void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { void rgb_matrix_step_reverse_noeeprom(void) { rgb_matrix_step_reverse_helper(false); } //void rgb_matrix_step_reverse(void) { rgb_matrix_step_reverse_helper(true); } - void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { if (! rgb_matrix_config.enable) { return; @@ -110,7 +105,6 @@ void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, boo //void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); } //void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); } - void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper( rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, @@ -122,7 +116,6 @@ void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { void rgb_matrix_increase_hue_noeeprom(void) { rgb_matrix_increase_hue_helper(false); } //void rgb_matrix_increase_hue(void) { rgb_matrix_increase_hue_helper(true); } - void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper( rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, @@ -134,7 +127,6 @@ void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { void rgb_matrix_decrease_hue_noeeprom(void) { rgb_matrix_decrease_hue_helper(false); } //void rgb_matrix_decrease_hue(void) { rgb_matrix_decrease_hue_helper(true); } - void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper( rgb_matrix_config.hsv.h, @@ -146,7 +138,6 @@ void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { void rgb_matrix_increase_sat_noeeprom(void) { rgb_matrix_increase_sat_helper(false); } //void rgb_matrix_increase_sat(void) { rgb_matrix_increase_sat_helper(true); } - void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper( rgb_matrix_config.hsv.h, @@ -158,7 +149,6 @@ void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { void rgb_matrix_decrease_sat_noeeprom(void) { rgb_matrix_decrease_sat_helper(false); } //void rgb_matrix_decrease_sat(void) { rgb_matrix_decrease_sat_helper(true); } - void rgb_matrix_increase_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper( rgb_matrix_config.hsv.h, @@ -170,7 +160,6 @@ void rgb_matrix_increase_val_helper(bool write_to_eeprom) { void rgb_matrix_increase_val_noeeprom(void) { rgb_matrix_increase_val_helper(false); } //void rgb_matrix_increase_val(void) { rgb_matrix_increase_val_helper(true); } - void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper( rgb_matrix_config.hsv.h, @@ -182,7 +171,6 @@ void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { void rgb_matrix_decrease_val_noeeprom(void) { rgb_matrix_decrease_val_helper(false); } //void rgb_matrix_decrease_val(void) { rgb_matrix_decrease_val_helper(true); } - void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { rgb_matrix_config.speed = speed; if (write_to_eeprom) { @@ -199,7 +187,6 @@ void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { void rgb_matrix_set_speed_noeeprom(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, false); } void rgb_matrix_set_speed(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, true); } - void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper( qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), @@ -209,7 +196,6 @@ void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { void rgb_matrix_increase_speed_noeeprom(void) { rgb_matrix_increase_speed_helper(false); } //void rgb_matrix_increase_speed(void) { rgb_matrix_increase_speed_helper(true); } - void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper( qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), @@ -218,17 +204,15 @@ void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { } void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } //void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } - - +//TODO /remove void keyboard_post_init_rgb(void) { + //TODO set mode, hsv, speed first #if defined(RGBLIGHT_ENABLE) rgblight_disable_noeeprom(); #elif defined(RGB_MATRIX_ENABLE) rgb_matrix_disable_noeeprom(); #endif // RGBLIGHT_ENABLE - - return; } @@ -250,8 +234,7 @@ typedef void (*rgb_func_pointer)(void); static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted, const rgb_func_pointer inc_func, const rgb_func_pointer dec_func) { if (is_shifted) { dec_func(); - } - else { + } else { inc_func(); } } @@ -271,78 +254,37 @@ bool process_record_rgb(const uint16_t keycode, const keyrecord_t *record) { rgblight_toggle_noeeprom(); return false; case RGB_MODE_FORWARD: - handleKeycodeRGB( - shifted, - rgblight_step_noeeprom, - rgblight_step_reverse_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_step_noeeprom, rgblight_step_reverse_noeeprom); return false; case RGB_MODE_REVERSE: - handleKeycodeRGB( - shifted, - rgblight_step_reverse_noeeprom, - rgblight_step_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_step_reverse_noeeprom, rgblight_step_noeeprom); return false; case RGB_HUI: - handleKeycodeRGB( - shifted, - rgblight_increase_hue_noeeprom, - rgblight_decrease_hue_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_increase_hue_noeeprom, rgblight_decrease_hue_noeeprom); return false; case RGB_HUD: - handleKeycodeRGB( - shifted, - rgblight_decrease_hue_noeeprom, - rgblight_increase_hue_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_decrease_hue_noeeprom, rgblight_increase_hue_noeeprom); return false; case RGB_SAI: - handleKeycodeRGB( - shifted, - rgblight_increase_sat_noeeprom, - rgblight_decrease_sat_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_increase_sat_noeeprom, rgblight_decrease_sat_noeeprom); return false; case RGB_SAD: - handleKeycodeRGB( - shifted, - rgblight_decrease_sat_noeeprom, - rgblight_increase_sat_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_decrease_sat_noeeprom, rgblight_increase_sat_noeeprom); return false; case RGB_VAI: - handleKeycodeRGB( - shifted, - rgblight_increase_val_noeeprom, - rgblight_decrease_val_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_increase_val_noeeprom, rgblight_decrease_val_noeeprom); return false; case RGB_VAD: - handleKeycodeRGB( - shifted, - rgblight_decrease_val_noeeprom, - rgblight_increase_val_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_decrease_val_noeeprom, rgblight_increase_val_noeeprom); return false; case RGB_SPI: - handleKeycodeRGB( - shifted, - rgblight_increase_speed_noeeprom, - rgblight_decrease_speed_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_increase_speed_noeeprom, rgblight_decrease_speed_noeeprom); return false; case RGB_SPD: - handleKeycodeRGB( - shifted, - rgblight_decrease_speed_noeeprom, - rgblight_increase_speed_noeeprom - ); + handleKeycodeRGB(shifted, rgblight_decrease_speed_noeeprom, rgblight_increase_speed_noeeprom); return false; } #endif // RGB_USE_NOEEPROM } - return true; } diff --git a/users/tynanbe/tynanbe_rgb.h b/users/tynanbe/tynanbe_rgb.h index c6dae722c3d4..696c07ddb0b5 100644 --- a/users/tynanbe/tynanbe_rgb.h +++ b/users/tynanbe/tynanbe_rgb.h @@ -2,14 +2,12 @@ #include "quantum.h" - - void keyboard_post_init_rgb(void); layer_state_t layer_state_set_rgb(layer_state_t state); void matrix_scan_rgb(void); bool process_record_rgb(const uint16_t keycode, const keyrecord_t *record); - +//TODO remove after QMK merges https://github.com/qmk/qmk_firmware/pull/9487 void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom); void rgb_matrix_toggle_noeeprom(void); void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); @@ -28,7 +26,6 @@ void rgb_matrix_set_speed_noeeprom(uint8_t speed); void rgb_matrix_increase_speed_noeeprom(void); void rgb_matrix_decrease_speed_noeeprom(void); - #ifndef RGBLIGHT_ENABLE # define rgblight_toggle_noeeprom rgb_matrix_toggle_noeeprom # define rgblight_step_noeeprom rgb_matrix_step_noeeprom @@ -44,3 +41,4 @@ void rgb_matrix_decrease_speed_noeeprom(void); # define rgblight_increase_speed_noeeprom rgb_matrix_increase_speed_noeeprom # define rgblight_decrease_speed_noeeprom rgb_matrix_decrease_speed_noeeprom #endif // RGBLIGHT_ENABLE +//TODO /remove