optimize rgblight_effect_alternating(void)
rgblight_effect_alternating (void) calls rgblight_sethsv_at () RGBLED_NUM times. As a result, rgblight_set () is called RGBLED_NUM + 1 times. This is wasteful processing.
This commit is contained in:
parent
14bdd5ed2a
commit
db03b76910
|
@ -860,13 +860,13 @@ void rgblight_effect_alternating(void){
|
||||||
last_timer = timer_read();
|
last_timer = timer_read();
|
||||||
|
|
||||||
for(int i = 0; i<RGBLED_NUM; i++){
|
for(int i = 0; i<RGBLED_NUM; i++){
|
||||||
if(i<RGBLED_NUM/2 && pos){
|
if(i<RGBLED_NUM/2 && pos){
|
||||||
rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, i);
|
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
|
||||||
}else if (i>=RGBLED_NUM/2 && !pos){
|
}else if (i>=RGBLED_NUM/2 && !pos){
|
||||||
rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, i);
|
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]);
|
||||||
}else{
|
}else{
|
||||||
rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, 0, i);
|
sethsv(rgblight_config.hue, rgblight_config.sat, 0, (LED_TYPE *)&led[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rgblight_set();
|
rgblight_set();
|
||||||
pos = (pos + 1) % 2;
|
pos = (pos + 1) % 2;
|
||||||
|
|
Loading…
Reference in New Issue