Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noeeprom functions for rgb_matrix #9487

Merged
merged 4 commits into from
Aug 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
qmk cformat rgb_matrix
  • Loading branch information
tynanbe committed Aug 5, 2020
commit c2845143e5a73b7a9e5bedef273a08cac9dd1901
123 changes: 17 additions & 106 deletions quantum/rgb_matrix.c
Original file line number Diff line number Diff line change
@@ -468,12 +468,7 @@ void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
if (write_to_eeprom) {
eeconfig_update_rgb_matrix();
}
dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n",
(write_to_eeprom)
? "EEPROM"
: "NOEEPROM",
rgb_matrix_config.enable
);
dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable);
}
void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); }
void rgb_matrix_toggle(void) { rgb_matrix_toggle_eeprom_helper(true); }
@@ -506,23 +501,16 @@ void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
}
if (mode < 1) {
rgb_matrix_config.mode = 1;
}
else if (mode >= RGB_MATRIX_EFFECT_MAX) {
} else if (mode >= RGB_MATRIX_EFFECT_MAX) {
rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1;
}
else {
} else {
rgb_matrix_config.mode = mode;
}
rgb_task_state = STARTING;
if (write_to_eeprom) {
eeconfig_update_rgb_matrix();
}
dprintf("rgb matrix mode [%s]: %u\n",
(write_to_eeprom)
? "EEPROM"
: "NOEEPROM",
rgb_matrix_config.mode
);
dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode);
}
void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); }
void rgb_matrix_mode(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, true); }
@@ -531,24 +519,14 @@ uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; }

void rgb_matrix_step_helper(bool write_to_eeprom) {
uint8_t mode = rgb_matrix_config.mode + 1;
rgb_matrix_mode_eeprom_helper(
(mode < RGB_MATRIX_EFFECT_MAX)
? mode
: 1,
write_to_eeprom
);
rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, 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(
(mode < 1)
? RGB_MATRIX_EFFECT_MAX - 1
: mode,
write_to_eeprom
);
rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, 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); }
@@ -559,21 +537,11 @@ void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, boo
}
rgb_matrix_config.hsv.h = hue;
rgb_matrix_config.hsv.s = sat;
rgb_matrix_config.hsv.v =
(val > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
? RGB_MATRIX_MAXIMUM_BRIGHTNESS
: val;
rgb_matrix_config.hsv.v = (val > RGB_MATRIX_MAXIMUM_BRIGHTNESS) ? RGB_MATRIX_MAXIMUM_BRIGHTNESS : val;
if (write_to_eeprom) {
eeconfig_update_rgb_matrix();
}
dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n",
(write_to_eeprom)
? "EEPROM"
: "NOEEPROM",
rgb_matrix_config.hsv.h,
rgb_matrix_config.hsv.s,
rgb_matrix_config.hsv.v
);
dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v);
}
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); }
@@ -583,69 +551,27 @@ uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; }
uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; }
uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; }

void rgb_matrix_increase_hue_helper(bool write_to_eeprom) {
rgb_matrix_sethsv_eeprom_helper(
rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP,
rgb_matrix_config.hsv.s,
rgb_matrix_config.hsv.v,
write_to_eeprom
);
}
void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, 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,
rgb_matrix_config.hsv.s,
rgb_matrix_config.hsv.v,
write_to_eeprom
);
}
void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, 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,
qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP),
rgb_matrix_config.hsv.v,
write_to_eeprom
);
}
void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, 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,
qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP),
rgb_matrix_config.hsv.v,
write_to_eeprom
);
}
void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, 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,
rgb_matrix_config.hsv.s,
qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP),
write_to_eeprom
);
}
void rgb_matrix_increase_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), 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,
rgb_matrix_config.hsv.s,
qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP),
write_to_eeprom
);
}
void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), 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); }

@@ -654,33 +580,18 @@ void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
if (write_to_eeprom) {
eeconfig_update_rgb_matrix();
}
dprintf("rgb matrix set speed [%s]: %u\n",
(write_to_eeprom)
? "EEPROM"
: "NOEEPROM",
rgb_matrix_config.speed
);
dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed);
}
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); }

uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; }

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),
write_to_eeprom
);
}
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), 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),
write_to_eeprom
);
}
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), 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); }