diff options
author | horchi <vdr@jwendel.de> | 2012-11-29 07:05:54 +0100 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2012-11-29 07:05:54 +0100 |
commit | 3a2a85db5e18c027c84ec6a40dfe0babfa9dae98 (patch) | |
tree | eac9664f899ad56de9cfef6c73edcefed09d4f96 /seduthread.c | |
parent | 6f0d9df3807c95e2c10549a0c578d5c1a6d2fa91 (diff) | |
download | vdr-plugin-seduatmo-3a2a85db5e18c027c84ec6a40dfe0babfa9dae98.tar.gz vdr-plugin-seduatmo-3a2a85db5e18c027c84ec6a40dfe0babfa9dae98.tar.bz2 |
added rainbow fader
Diffstat (limited to 'seduthread.c')
-rw-r--r-- | seduthread.c | 131 |
1 files changed, 119 insertions, 12 deletions
diff --git a/seduthread.c b/seduthread.c index 545ad53..b3910cf 100644 --- a/seduthread.c +++ b/seduthread.c @@ -100,9 +100,13 @@ void cSeduThread::Action() else { putData(); - wait = 500; // less load on fixed color or black - } + if (cfg.viewMode != vmRainbow) + wait = 500; // less load on fixed color or black + else + wait = 100; // for Rainbow sleep always 100ms + } + waitCondition.TimedWait(mutex, wait); // wait time in ms } @@ -270,21 +274,36 @@ int cSeduThread::putData() return fail; } - if (cfg.viewMode != vmAtmo) + switch (cfg.viewMode) { - pFixedCol.r = cfg.viewMode == vmFixedCol ? cfg.fixedR : 0; - pFixedCol.g = cfg.viewMode == vmFixedCol ? cfg.fixedG : 0; - pFixedCol.b = cfg.viewMode == vmFixedCol ? cfg.fixedB : 0; + case vmBlack: + case vmFixedCol: + { + pFixedCol.r = cfg.viewMode == vmFixedCol ? cfg.fixedR : 0; + pFixedCol.g = cfg.viewMode == vmFixedCol ? cfg.fixedG : 0; + pFixedCol.b = cfg.viewMode == vmFixedCol ? cfg.fixedB : 0; + + if (cfg.viewMode != vmBlack) + { + gammaAdj(&pFixedCol); + whiteAdj(&pFixedCol); + } - if (cfg.viewMode != vmBlack) + break; + } + case vmRainbow: { - gammaAdj(&pFixedCol); - whiteAdj(&pFixedCol); + pFixedCol = getRainbowColor(); + + break; } + + default: + break; } - + sedu.writeStartSeq(); - + // loop over all LEDs for (int led = 0; led < cfg.ledCount; led++) @@ -453,6 +472,94 @@ void cSeduThread::gammaAdj(Pixel* p) } //*************************************************************************** +// Get Rainbow Color +//*************************************************************************** + +Pixel cSeduThread::getRainbowColor() +{ + static int rainbowColorTone = 0; + static int callCount = 0; + + Pixel p = hsv2Rgb(rainbowColorTone, 1, 1); + + if (!(callCount++ % (cfg.effectSpeed / 100))) + { + if (++rainbowColorTone >= 360) + rainbowColorTone = 0; + } + + gammaAdj(&p); + whiteAdj(&p); + + return p; +} + +//*************************************************************************** +// Convert from HSV to RGB +//*************************************************************************** + +Pixel cSeduThread::hsv2Rgb(int h, double s, double v) +{ + Pixel pix = {0,0,0,0}; + double r = 0; + double g = 0; + double b = 0; + + int i = floor(h/60.0); + double f = h/60.0 - i; + double pv = v * (1 - s); + double qv = v * (1 - s * f); + double tv = v * (1 - s * (1-f)); + + switch (i) + { + case 0: // rojo dominante + r = v; + g = tv; + b = pv; + break; + + case 1: // verde + r = qv; + g = v; + b = pv; + break; + + case 2: + r = pv; + g = v; + b = tv; + break; + + case 3: // azul + r = pv; + g = qv; + b = v; + break; + + case 4: + r = tv; + g = pv; + b = v; + break; + + case 5: // rojo + r = v; + g = pv; + b = qv; + break; + } + + // set each component to a integer value between 0 and 255 + + pix.r = minMax(255*r, 0, 255); + pix.g = minMax(255*g, 0, 255); + pix.b = minMax(255*b, 0, 255); + + return pix; +} + +//*************************************************************************** // Class cSeduLine //*************************************************************************** //*************************************************************************** @@ -731,7 +838,7 @@ int cSeduLine::writeColor(Pixel* p, int index) } //*************************************************************************** -// Checl Line +// Check Line //*************************************************************************** int cSeduLine::checkLine() |