summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.c16
-rw-r--r--common.h6
-rw-r--r--config.c4
-rw-r--r--config.h1
-rw-r--r--seduatmo.c43
-rw-r--r--seduservice.c1
-rw-r--r--seduservice.h1
-rw-r--r--seduthread.c131
-rw-r--r--seduthread.h14
9 files changed, 189 insertions, 28 deletions
diff --git a/common.c b/common.c
index 524e614..d457a6a 100644
--- a/common.c
+++ b/common.c
@@ -78,3 +78,19 @@ MsTime msNow()
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
+
+//***************************************************************************
+//
+//***************************************************************************
+
+int minMax(int x, int min, int max)
+{
+ if (x < min)
+ return min;
+
+ if (max < x)
+ return max;
+
+ return x;
+}
+
diff --git a/common.h b/common.h
index 747a085..ea6701d 100644
--- a/common.h
+++ b/common.h
@@ -27,6 +27,12 @@ enum Misc
};
//***************************************************************************
+// Misc ..
+//***************************************************************************
+
+int minMax(int x, int min, int max);
+
+//***************************************************************************
// Time
//***************************************************************************
diff --git a/config.c b/config.c
index 1411775..4712e24 100644
--- a/config.c
+++ b/config.c
@@ -35,7 +35,6 @@ cSeduConfig::cSeduConfig()
xDeep = 2;
yDeep = 1;
black = 0;
-
detectCineBars = cbBoth;
seduMode = smMiniDMX;
@@ -44,10 +43,13 @@ cSeduConfig::cSeduConfig()
showMainmenu = yes;
viewMode = vmAtmo;
+ effectSpeed = 500;
+
fixedR = 111;
fixedG = 101;
fixedB = 0;
+
// calculated
leds = 0;
diff --git a/config.h b/config.h
index a1fa19a..cb52d6f 100644
--- a/config.h
+++ b/config.h
@@ -48,6 +48,7 @@ class cSeduConfig : public cSeduService
int fixedR;
int fixedG;
int fixedB;
+ int effectSpeed;
int showMainmenu;
char seduRGBOrder[4];
diff --git a/seduatmo.c b/seduatmo.c
index cee90de..46ee757 100644
--- a/seduatmo.c
+++ b/seduatmo.c
@@ -105,15 +105,17 @@ class cSeduPluginMenu : public cMenuSetupPage
protected:
- void Store() { }
+ void Store();
cPluginSeduatmo* plugin;
+ int effectSpeed;
};
cSeduPluginMenu::cSeduPluginMenu(const char* title, cPluginSeduatmo* aPlugin)
{
SetTitle(title ? title : "");
plugin = aPlugin;
-
+ effectSpeed = cfg.effectSpeed;
+
Clear();
cOsdMenu::Add(new cMenuEditStraItem(tr("View Mode"),
@@ -125,6 +127,8 @@ cSeduPluginMenu::cSeduPluginMenu(const char* title, cPluginSeduatmo* aPlugin)
Add(new cMenuEditIntItem(tr("Fixed Color Green"), &cfg.fixedG, 0, 255));
Add(new cMenuEditIntItem(tr("Fixed Color Blue"), &cfg.fixedB, 0, 255));
+ Add(new cMenuEditIntItem(tr("Effect Speed [ms]"), &effectSpeed, 100, 5000));
+
SetHelp(0, 0, 0, 0);
Display();
@@ -146,21 +150,28 @@ eOSState cSeduPluginMenu::ProcessKey(eKeys key)
plugin->startAtmo();
}
- if (state != osUnknown)
- return state;
-
if (key == kOk)
{
- SetupStore("FixedColorRed", cfg.fixedR);
- SetupStore("FixedColorGreen", cfg.fixedG);
- SetupStore("FixedColorBlue", cfg.fixedB);
- SetupStore("ViewMode", (int)cfg.viewMode);
+ cfg.effectSpeed = effectSpeed;
+ Store();
return osEnd;
}
+
return state;
}
+void cSeduPluginMenu::Store()
+{
+ plugin->SetupStore("FixedColorRed", cfg.fixedR);
+ plugin->SetupStore("FixedColorGreen", cfg.fixedG);
+ plugin->SetupStore("FixedColorBlue", cfg.fixedB);
+ plugin->SetupStore("ViewMode", (int)cfg.viewMode);
+ plugin->SetupStore("EffectSpeed", cfg.effectSpeed);
+
+ Setup.Save();
+}
+
//***************************************************************************
// Plugin
//***************************************************************************
@@ -279,6 +290,7 @@ bool cPluginSeduatmo::SetupParse(const char* Name, const char* Value)
else if (!strcasecmp(Name, "FixedColorRed")) cfg.fixedR = atoi(Value);
else if (!strcasecmp(Name, "FixedColorGreen")) cfg.fixedG = atoi(Value);
else if (!strcasecmp(Name, "FixedColorBlue")) cfg.fixedB = atoi(Value);
+ else if (!strcasecmp(Name, "EffectSpeed")) cfg.effectSpeed = atoi(Value);
else if (!strcasecmp(Name, "SeduMode")) cfg.seduMode = (cSeduService::SeduMode)atoi(Value);
else if (!strcasecmp(Name, "SeduRGBOrder")) strcpy(cfg.seduRGBOrder, Value);
@@ -296,9 +308,6 @@ bool cPluginSeduatmo::Service(const char* Id, void* Data)
cString cPluginSeduatmo::SVDRPCommand(const char* Command, const char* Option, int &ReplyCode)
{
- if (!update)
- return "Error: Plugin not initialized!";
-
if (!strcasecmp(Command, "MODE"))
{
if (Option && strcasecmp(Option, "atmo") == 0)
@@ -315,6 +324,13 @@ cString cPluginSeduatmo::SVDRPCommand(const char* Command, const char* Option, i
ReplyCode = 550;
return "fixed color activated";
}
+ else if (Option && strcasecmp(Option, "rainbow") == 0)
+ {
+ cfg.viewMode = cSeduService::vmRainbow;
+ startAtmo();
+ ReplyCode = 550;
+ return "rainbow effect activated";
+ }
else if (Option && strcasecmp(Option, "black") == 0)
{
cfg.viewMode = cSeduService::vmBlack;
@@ -346,7 +362,7 @@ const char** cPluginSeduatmo::SVDRPHelpPages(void)
static const char* HelpPages[] =
{
"MODE <mode>\n"
- " Set mode {atmo|fixed|black|detach}\n",
+ " Set mode {atmo|fixed|rainbow|black|detach}\n",
0
};
@@ -465,6 +481,7 @@ void cSeduSetup::Store()
SetupStore("FixedColorRed", data.fixedR);
SetupStore("FixedColorGreen", data.fixedG);
SetupStore("FixedColorBlue", data.fixedB);
+ SetupStore("EffectSpeed", data.effectSpeed);
SetupStore("SeduMode", data.seduMode);
SetupStore("SeduRgbOrder", data.seduRGBOrder);
diff --git a/seduservice.c b/seduservice.c
index b371435..d82f86e 100644
--- a/seduservice.c
+++ b/seduservice.c
@@ -16,6 +16,7 @@ const char* cSeduService::viewModes[] =
{
"atmo",
"fixed color",
+ "rainbow",
"black",
"detached",
diff --git a/seduservice.h b/seduservice.h
index eb2dff3..9612331 100644
--- a/seduservice.h
+++ b/seduservice.h
@@ -36,6 +36,7 @@ class cSeduService
{
vmAtmo,
vmFixedCol,
+ vmRainbow,
vmBlack,
vmDetached,
vmCount
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()
diff --git a/seduthread.h b/seduthread.h
index 038a2ec..38ca6cc 100644
--- a/seduthread.h
+++ b/seduthread.h
@@ -1,3 +1,10 @@
+/*
+ * seduthread.h: A plugin for the Video Disk Recorder
+ *
+ * See the README file for copyright information and how to reach the author.
+ *
+ * $Id: seduthread.h,v 1.64 2012/11/28 06:29:24 wendel Exp $
+ */
#include <termios.h>
#include <queue>
@@ -23,8 +30,8 @@ class PixQueue
{
public:
- PixQueue() { clear(); }
- virtual ~PixQueue() { clear(); }
+ PixQueue() { clear(); }
+ virtual ~PixQueue() { clear(); }
void clear() { while (!pQueue.empty()) pQueue.pop(); r=g=b=0; }
int getCount() { return pQueue.size(); }
@@ -191,4 +198,7 @@ class cSeduThread : public cThread, public cSeduService
int imageSize;
int imageWidth;
int imageHeight;
+
+ Pixel getRainbowColor();
+ Pixel hsv2Rgb(int h, double s, double v);
};