-
Notifications
You must be signed in to change notification settings - Fork 3
/
effects.cpp
31 lines (26 loc) · 860 Bytes
/
effects.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* Copyright Ben XO https://github.com/ben-xo All rights reserved.
*/
// helpers used by many effects.
#include "effects.h"
void fade_pixel(uint8_t pixel) {
uint8_t r = leds[pixel].r;
uint8_t g = leds[pixel].g;
uint8_t b = leds[pixel].b;
// this is equivalent to r*0.875
leds[pixel] = CRGB(qsub8(r, (r>>3)+1), qsub8(g, (g>>3)+1), qsub8(b, (b>>3)+1));
}
void fade_pixel_slow(uint8_t pixel) {
uint8_t r = leds[pixel].r;
uint8_t g = leds[pixel].g;
uint8_t b = leds[pixel].b;
// this is equivalent to r*0.9375
leds[pixel] = CRGB(qsub8(r, (r>>4)+1), qsub8(g, (g>>4)+1), qsub8(b, (b>>4)+1));
}
void fade_pixel_fast(uint8_t pixel) {
uint8_t r = leds[pixel].r;
uint8_t g = leds[pixel].g;
uint8_t b = leds[pixel].b;
leds[pixel] = CRGB(qsub8(r, (r>>2)+1), qsub8(g, (g>>2)+1), qsub8(b, (b>>2)+1));
// this is equivalent to r*0.75
}