Skip to content

Commit

Permalink
Fix issues with RGB Matrix flags (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna authored Jul 12, 2022
1 parent 085f089 commit 764ac89
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 39 deletions.
12 changes: 0 additions & 12 deletions keyboards/ergodox_ez/ergodox_ez.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ void matrix_init_kb(void) {

keyboard_config.raw = eeconfig_read_kb();
ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4);
#ifdef RGB_MATRIX_ENABLE
if (keyboard_config.rgb_matrix_enable) {
rgb_matrix_set_flags(LED_FLAG_ALL);
} else {
rgb_matrix_set_flags(LED_FLAG_NONE);
}
#endif

ergodox_blink_all_leds();

matrix_init_user();
Expand Down Expand Up @@ -376,15 +368,12 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
switch (rgb_matrix_get_flags()) {
case LED_FLAG_ALL: {
rgb_matrix_set_flags(LED_FLAG_NONE);
keyboard_config.rgb_matrix_enable = false;
rgb_matrix_set_color_all(0, 0, 0);
} break;
default: {
rgb_matrix_set_flags(LED_FLAG_ALL);
keyboard_config.rgb_matrix_enable = true;
} break;
}
eeconfig_update_kb(keyboard_config.raw);
}
return false;
# endif
Expand All @@ -396,7 +385,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
void eeconfig_init_kb(void) { // EEPROM is getting reset!
keyboard_config.raw = 0;
keyboard_config.led_level = 4;
keyboard_config.rgb_matrix_enable = true;
eeconfig_update_kb(keyboard_config.raw);
eeconfig_init_user();
}
Expand Down
2 changes: 1 addition & 1 deletion keyboards/ergodox_ez/ergodox_ez.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ typedef union {
struct {
uint8_t led_level :3;
bool disable_layer_led :1;
bool rgb_matrix_enable :1;
bool placeholder :1;
};
} keyboard_config_t;

Expand Down
12 changes: 0 additions & 12 deletions keyboards/moonlander/moonlander.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,23 +407,19 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
keyboard_config.disable_layer_led ^= 1;
if (keyboard_config.disable_layer_led) rgb_matrix_set_color_all(0, 0, 0);
eeconfig_update_kb(keyboard_config.raw);
}
break;
case RGB_TOG:
if (record->event.pressed) {
switch (rgb_matrix_get_flags()) {
case LED_FLAG_ALL: {
rgb_matrix_set_flags(LED_FLAG_NONE);
keyboard_config.rgb_matrix_enable = false;
rgb_matrix_set_color_all(0, 0, 0);
} break;
default: {
rgb_matrix_set_flags(LED_FLAG_ALL);
keyboard_config.rgb_matrix_enable = true;
} break;
}
eeconfig_update_kb(keyboard_config.raw);
}
return false;
#endif
Expand All @@ -439,19 +435,11 @@ void matrix_init_kb(void) {
keyboard_config.led_level_res = 0b11;
eeconfig_update_kb(keyboard_config.raw);
}
#ifdef RGB_MATRIX_ENABLE
if (keyboard_config.rgb_matrix_enable) {
rgb_matrix_set_flags(LED_FLAG_ALL);
} else {
rgb_matrix_set_flags(LED_FLAG_NONE);
}
#endif
matrix_init_user();
}

void eeconfig_init_kb(void) { // EEPROM is getting reset!
keyboard_config.raw = 0;
keyboard_config.rgb_matrix_enable = true;
keyboard_config.led_level = true;
keyboard_config.led_level_res = 0b11;
eeconfig_update_kb(keyboard_config.raw);
Expand Down
2 changes: 1 addition & 1 deletion keyboards/moonlander/moonlander.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ typedef union {
uint32_t raw;
struct {
bool disable_layer_led :1;
bool rgb_matrix_enable :1;
bool placeholder :1;
bool led_level :1;
uint8_t led_level_res :2; // DO NOT REMOVE
};
Expand Down
11 changes: 0 additions & 11 deletions keyboards/planck/ez/ez.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,12 @@ void keyboard_pre_init_kb(void) {
}
// read kb settings from eeprom
keyboard_config.raw = eeconfig_read_kb();
#ifdef RGB_MATRIX_ENABLE
if (keyboard_config.rgb_matrix_enable) {
rgb_matrix_set_flags(LED_FLAG_ALL);
} else {
rgb_matrix_set_flags(LED_FLAG_NONE);
}
#endif
led_initialize_hardware();
keyboard_pre_init_user();
}

void eeconfig_init_kb(void) { // EEPROM is getting reset!
keyboard_config.raw = 0;
keyboard_config.rgb_matrix_enable = true;
keyboard_config.led_level = 4;
eeconfig_update_kb(keyboard_config.raw);
eeconfig_init_user();
Expand Down Expand Up @@ -277,17 +269,14 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
switch (rgb_matrix_get_flags()) {
case LED_FLAG_ALL: {
rgb_matrix_set_flags(LED_FLAG_NONE);
keyboard_config.rgb_matrix_enable = false;
rgb_matrix_set_color_all(0, 0, 0);
}
break;
default: {
rgb_matrix_set_flags(LED_FLAG_ALL);
keyboard_config.rgb_matrix_enable = true;
}
break;
}
eeconfig_update_kb(keyboard_config.raw);
}
return false;
#endif
Expand Down
2 changes: 1 addition & 1 deletion keyboards/planck/ez/ez.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef union {
struct {
uint8_t led_level :3;
bool disable_layer_led :1;
bool rgb_matrix_enable :1;
bool placeholder :1;
};
} keyboard_config_t;

Expand Down
7 changes: 6 additions & 1 deletion quantum/rgb_matrix/rgb_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,15 @@ void rgb_matrix_decrease_speed(void) {
rgb_matrix_decrease_speed_helper(true);
}

void rgb_matrix_set_flags_eeprom_helper(led_flags_t flags, bool write_to_eeprom) {
rgb_matrix_config.flags = flags;
eeconfig_flag_rgb_matrix(write_to_eeprom);
dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.flags);
}
led_flags_t rgb_matrix_get_flags(void) {
return rgb_matrix_config.flags;
}

void rgb_matrix_set_flags(led_flags_t flags) {
rgb_matrix_config.flags = flags;
rgb_matrix_set_flags_eeprom_helper(flags, true);
}

0 comments on commit 764ac89

Please sign in to comment.