aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2020-05-09 09:31:49 +0000
committerQMK Bot <hello@qmk.fm>2020-05-09 09:31:49 +0000
commite7860d673b0e671988711a487931f61926dbbd56 (patch)
tree4aec9f1edabee6d8ca54e6507d3ac13b5098af26 /quantum
parent2fe7e221ec9e412cc008aa5c03eaf27e35ff62c6 (diff)
downloadqmk_firmware-e7860d673b0e671988711a487931f61926dbbd56.tar.gz
qmk_firmware-e7860d673b0e671988711a487931f61926dbbd56.zip
format code according to conventions [skip ci]
Diffstat (limited to 'quantum')
-rw-r--r--quantum/rgblight.c27
-rw-r--r--quantum/rgblight.h2
2 files changed, 14 insertions, 15 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 8d01bcf0e..4f227794f 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -1201,33 +1201,32 @@ void rgblight_effect_alternating(animation_status_t *anim) {
1201__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {50, 25, 10}; 1201__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {50, 25, 10};
1202 1202
1203typedef struct PACKED { 1203typedef struct PACKED {
1204 HSV hsv; 1204 HSV hsv;
1205 uint8_t life; 1205 uint8_t life;
1206 bool up; 1206 bool up;
1207} TwinkleState; 1207} TwinkleState;
1208 1208
1209static TwinkleState led_twinkle_state[RGBLED_NUM]; 1209static TwinkleState led_twinkle_state[RGBLED_NUM];
1210 1210
1211void rgblight_effect_twinkle(animation_status_t *anim) { 1211void rgblight_effect_twinkle(animation_status_t *anim) {
1212
1213 bool random_color = anim->delta / 3; 1212 bool random_color = anim->delta / 3;
1214 bool restart = anim->pos == 0; 1213 bool restart = anim->pos == 0;
1215 anim->pos = 1; 1214 anim->pos = 1;
1216 1215
1217 for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { 1216 for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) {
1218 TwinkleState *t = &(led_twinkle_state[i]); 1217 TwinkleState *t = &(led_twinkle_state[i]);
1219 HSV *c = &(t->hsv); 1218 HSV * c = &(t->hsv);
1220 if (restart) { 1219 if (restart) {
1221 // Restart 1220 // Restart
1222 t->life = 0; 1221 t->life = 0;
1223 t->hsv.v = 0; 1222 t->hsv.v = 0;
1224 } else if (t->life) { 1223 } else if (t->life) {
1225 // This LED is already on, either brightening or dimming 1224 // This LED is already on, either brightening or dimming
1226 t->life--; 1225 t->life--;
1227 uint8_t on = t->up ? RGBLIGHT_EFFECT_TWINKLE_LIFE - t->life : t->life; 1226 uint8_t on = t->up ? RGBLIGHT_EFFECT_TWINKLE_LIFE - t->life : t->life;
1228 c->v = (uint16_t) rgblight_config.val * on / RGBLIGHT_EFFECT_TWINKLE_LIFE; 1227 c->v = (uint16_t)rgblight_config.val * on / RGBLIGHT_EFFECT_TWINKLE_LIFE;
1229 if (t->life == 0 && t->up) { 1228 if (t->life == 0 && t->up) {
1230 t->up = false; 1229 t->up = false;
1231 t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE; 1230 t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE;
1232 } 1231 }
1233 if (!random_color) { 1232 if (!random_color) {
@@ -1236,11 +1235,11 @@ void rgblight_effect_twinkle(animation_status_t *anim) {
1236 } 1235 }
1237 } else if (rand() < RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY) { 1236 } else if (rand() < RAND_MAX * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY) {
1238 // This LED is off, but was randomly selected to start brightening 1237 // This LED is off, but was randomly selected to start brightening
1239 c->h = random_color ? rand() % 0xFF : rgblight_config.hue; 1238 c->h = random_color ? rand() % 0xFF : rgblight_config.hue;
1240 c->s = random_color ? (rand() % (rgblight_config.sat / 2)) + (rgblight_config.sat / 2) : rgblight_config.sat; 1239 c->s = random_color ? (rand() % (rgblight_config.sat / 2)) + (rgblight_config.sat / 2) : rgblight_config.sat;
1241 c->v = 0; 1240 c->v = 0;
1242 t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE; 1241 t->life = RGBLIGHT_EFFECT_TWINKLE_LIFE;
1243 t->up = true; 1242 t->up = true;
1244 } else { 1243 } else {
1245 // This LED is off, and was NOT selected to start brightening 1244 // This LED is off, and was NOT selected to start brightening
1246 } 1245 }
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 7de9c3f3d..f93a30c5a 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -154,7 +154,7 @@ enum RGBLIGHT_EFFECT_MODE {
154# endif 154# endif
155 155
156# ifndef RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 156# ifndef RGBLIGHT_EFFECT_TWINKLE_PROBABILITY
157# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1/127 157# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1 / 127
158# endif 158# endif
159 159
160# ifndef RGBLIGHT_HUE_STEP 160# ifndef RGBLIGHT_HUE_STEP