MCPcopy Create free account
hub / github.com/SmingHub/Sming / colorWheel

Function colorWheel

samples/Basic_APA102/app/application.cpp:44–66  ·  view source on GitHub ↗

color wheel function: * (simple) three 120° shifted colors -> color transitions r-g-b-r */

Source from the content-addressed store, hash-verified

42/* color wheel function:
43 * (simple) three 120° shifted colors -> color transitions r-g-b-r */
44col_t colorWheel(uint16_t step, uint16_t numStep)
45{
46 col_t col = {0};
47 col.br = 10;
48 uint8_t index = (step * 256) / numStep;
49 uint8_t phase = 255 - index;
50 if(phase < 85) { // 256/3 -> 2pi/3 -> 120°
51 col.r = 255 - phase * 3;
52 col.g = 0;
53 col.b = phase * 3;
54 } else if(phase < 170) {
55 phase -= 85;
56 col.r = 0;
57 col.g = phase * 3;
58 col.b = 255 - phase * 3;
59 } else {
60 phase -= 170;
61 col.r = phase * 3;
62 col.g = 255 - phase * 3;
63 col.b = 0;
64 }
65 return col;
66}
67
68void updateLED()
69{

Callers 1

updateLEDFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected