Skip to content

Commit

Permalink
Note what should be removed when QMK merges PR qmk#9487
Browse files Browse the repository at this point in the history
  • Loading branch information
tynanbe committed Jun 25, 2020
1 parent 0f2fd93 commit b0ed49a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 76 deletions.
86 changes: 14 additions & 72 deletions users/tynanbe/tynanbe_rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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) {
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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;
}

Expand All @@ -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();
}
}
Expand All @@ -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;
}
6 changes: 2 additions & 4 deletions users/tynanbe/tynanbe_rgb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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

0 comments on commit b0ed49a

Please sign in to comment.