summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2019-12-20 13:23:25 +0100
committerhorchi <vdr@jwendel.de>2019-12-20 13:23:25 +0100
commit6853f2b6327e468efb77fa989dfa6080c257cf6c (patch)
tree5fbd295b9b165806230e1cc69b2c242f054bbd3f
parenta5d6d09bfae8ee47d77dc4c0c5ef994b47240f44 (diff)
downloadvdr-plugin-seduatmo-6853f2b6327e468efb77fa989dfa6080c257cf6c.tar.gz
vdr-plugin-seduatmo-6853f2b6327e468efb77fa989dfa6080c257cf6c.tar.bz2
2019-12-20: Version 0.0.9\n Added config RGB order for each LED\n\n
-rw-r--r--HISTORY.h5
-rw-r--r--config.c22
-rw-r--r--config.h6
-rw-r--r--ledsconf.c48
-rw-r--r--ledsconf.h24
-rw-r--r--seduatmo.c6
-rw-r--r--seduservice.h3
-rw-r--r--seduthread.c16
-rw-r--r--seduthread.h4
9 files changed, 74 insertions, 60 deletions
diff --git a/HISTORY.h b/HISTORY.h
index 5e0e8ab..a41c602 100644
--- a/HISTORY.h
+++ b/HISTORY.h
@@ -7,7 +7,7 @@
*
*/
-#define _VERSION "0.0.8"
+#define _VERSION "0.0.9"
#define VERSION_DATE "20.12.2019"
#ifdef GIT_REV
@@ -19,6 +19,9 @@
/*
* ------------------------------------
+2019-12-20: Version 0.0.9
+ Added config RGB order for each LED
+
2019-12-20: Version 0.0.8
Added support of softhdvaapi and softhddrm plugin
diff --git a/config.c b/config.c
index fbb7918..2069333 100644
--- a/config.c
+++ b/config.c
@@ -70,25 +70,25 @@ cSeduConfig::~cSeduConfig()
cSeduConfig::cLed* cSeduConfig::createLeds(cLedConfs* conf)
{
int seq = 0;
- delete leds;
-
+ delete leds;
+
grabWidth = 0;
grabHeight = 0;
-
+
ledCount = conf->Count();
leds = new cLed[ledCount];
memset(leds, 0, ledCount*sizeof(cLed));
-
+
for (cLedConf* l = conf->First(); l; l = conf->Next(l))
{
tell(1, "led%d (%d) %d/%d %d/%d", seq, l->Pos(),
- l->X(), l->Y(),
+ l->X(), l->Y(),
l->ToX(), l->ToY());
-
+
if (l->isValid())
{
- // calc size of led matrix
-
+ // calc size of led matrix
+
if (grabWidth < l->X())
grabWidth = l->X();
if (grabWidth < l->ToX())
@@ -97,13 +97,13 @@ cSeduConfig::cLed* cSeduConfig::createLeds(cLedConfs* conf)
grabHeight = l->Y();
if (grabHeight < l->ToY())
grabHeight = l->ToY();
-
+
leds[seq].lp = (LedPosition)l->Pos();
leds[seq].x = l->X();
- leds[seq].y = l->Y();
+ leds[seq].y = l->Y();
leds[seq].toX = l->ToX();
leds[seq].toY = l->ToY();
-
+ strcpy(leds[seq].rgbOrder, l->RgbOrder());
seq++;
}
}
diff --git a/config.h b/config.h
index cb52d6f..6631c6f 100644
--- a/config.h
+++ b/config.h
@@ -29,7 +29,7 @@ class cSeduConfig : public cSeduService
int grabWidth;
int grabHeight;
- // adjust
+ // adjust
int threshold;
int adjGreen;
@@ -63,12 +63,12 @@ class cSeduConfig : public cSeduService
// functions
cLed* createLeds(cLedConfs* conf);
- void copyLeds(cSeduConfig* c)
+ void copyLeds(cSeduConfig* c)
{
ledCount = c->ledCount;
leds = new cLed[ledCount];
memset(leds, 0, ledCount*sizeof(cLed));
-
+
for (int i = 0; i < ledCount; i++)
leds[i] = c->leds[i];
}
diff --git a/ledsconf.c b/ledsconf.c
index 5cbd98a..c4c18a4 100644
--- a/ledsconf.c
+++ b/ledsconf.c
@@ -13,22 +13,6 @@
#include "ledsconf.h"
//***************************************************************************
-// cLedConf
-//***************************************************************************
-//***************************************************************************
-// Object
-//***************************************************************************
-
-cLedConf::cLedConf()
-{
- x = na;
- toX = na;
- y = na;
- toY = na;
- lp = na;
-}
-
-//***************************************************************************
// Parse like like "led 0-1 14-17"
//***************************************************************************
@@ -60,9 +44,9 @@ bool cLedConf::Parse(const char* s)
lp = lpRight;
else
return error("Missing location {top,left,bot(tom),right}");
-
+
// skip to delemiter
-
+
while (*p && *p != ' ' && *p != '\t')
p++;
@@ -73,16 +57,19 @@ bool cLedConf::Parse(const char* s)
skipWs(p);
- // parse X
+ // parse X
if (!parseRange(p, x, toX))
return false;
// parse Y
-
+
if (!parseRange(p, y, toY))
return false;
-
+
+ if (!parseOrder(p, rgbOrder))
+ return false;
+
return true;
}
@@ -115,6 +102,25 @@ bool cLedConf::parseRange(const char*& p, int& from, int& to)
}
//***************************************************************************
+// Parse RGB Order Range "GBR"
+//***************************************************************************
+
+bool cLedConf::parseOrder(const char*& p, char* order)
+{
+ p = skipWs(p);
+
+ if (!(*p))
+ return true;
+
+ if (!strstr("RGB:RBG:GBR:GRB:BGR:BRG", p))
+ return false;
+
+ sprintf(order, "%.3s", p);
+
+ return true;
+}
+
+//***************************************************************************
// Skip Whitespaces
//***************************************************************************
diff --git a/ledsconf.h b/ledsconf.h
index 3e01144..3d0ea54 100644
--- a/ledsconf.h
+++ b/ledsconf.h
@@ -21,9 +21,9 @@
class cLedConf : public cListObject, public cSeduService
{
public:
-
- cLedConf();
-
+
+ cLedConf() {};
+
bool Parse(const char* s);
int X() { return x; }
@@ -31,25 +31,29 @@ class cLedConf : public cListObject, public cSeduService
int Y() { return y; }
int ToY() { return toY; }
int Pos() { return lp; }
+ const char* RgbOrder() { return rgbOrder; }
+
int isValid() { return x > na && y > na && lp > na; }
private:
- bool parseRange(const char*& s, int& from, int& to);
+ bool parseRange(const char*& p, int& from, int& to);
+ bool parseOrder(const char*& p, char* order);
const char* skipWs(const char* p);
- int x;
- int toX;
- int y;
- int toY;
- int lp;
+ int x {na};
+ int toX {na};
+ int y {na};
+ int toY {na};
+ int lp {na}; // LED postition
+ char rgbOrder[4] {'\0'};
};
//***************************************************************************
// cLedConfs
//***************************************************************************
-class cLedConfs : public cConfig<cLedConf>
+class cLedConfs : public cConfig<cLedConf>
{
};
diff --git a/seduatmo.c b/seduatmo.c
index 8ee0e16..5d22cfb 100644
--- a/seduatmo.c
+++ b/seduatmo.c
@@ -16,11 +16,9 @@
#include "ledsconf.h"
//***************************************************************************
-//
-//***************************************************************************
-static const char *DESCRIPTION = "sedu ambi light control with data from softhddevice";
-static const char *MAINMENUENTRY = "Seduatmo";
+static const char *DESCRIPTION = "sedu ambi light control with data from softhddevice";
+static const char *MAINMENUENTRY = "Seduatmo";
//***************************************************************************
// Setup
diff --git a/seduservice.h b/seduservice.h
index 7079041..2c281e7 100644
--- a/seduservice.h
+++ b/seduservice.h
@@ -10,7 +10,7 @@
#define __SEDU_SERVICE_H
//***************************************************************************
-// Pixel - format as provided by softhddevice
+// Pixel - format as provided by softhddevice
//***************************************************************************
struct Pixel
@@ -71,6 +71,7 @@ class cSeduService
int y;
int toY;
LedPosition lp;
+ char rgbOrder[4] {'\0'};
};
// static
diff --git a/seduthread.c b/seduthread.c
index c5b3530..2ae3bb3 100644
--- a/seduthread.c
+++ b/seduthread.c
@@ -373,7 +373,7 @@ int cSeduThread::putData()
p = &pFixedCol;
}
- sedu.writePix(p);
+ sedu.writePix(p, cfg.leds[led].rgbOrder);
}
sedu.writeEndSeq();
@@ -836,18 +836,20 @@ int cSeduLine::writeEndSeq()
// Write Pixel
//***************************************************************************
-int cSeduLine::writePix(Pixel* p)
+int cSeduLine::writePix(Pixel* p, char* rgbOrder)
{
- writeColor(p, 0);
- writeColor(p, 1);
- writeColor(p, 2);
+ writeColor(p, 0, rgbOrder);
+ writeColor(p, 1, rgbOrder);
+ writeColor(p, 2, rgbOrder);
return success;
}
-int cSeduLine::writeColor(Pixel* p, int index)
+int cSeduLine::writeColor(Pixel* p, int index, char* rgbOrder)
{
- switch (cfg.seduRGBOrder[index])
+ const char* order = *rgbOrder != 0 ? rgbOrder : cfg.seduRGBOrder;
+
+ switch (order[index])
{
case 'R': dataBytesSend += write(p ? p->r : 0); break;
case 'B': dataBytesSend += write(p ? p->b : 0); break;
diff --git a/seduthread.h b/seduthread.h
index 53261dd..a2bbbfb 100644
--- a/seduthread.h
+++ b/seduthread.h
@@ -112,8 +112,8 @@ class cSeduLine : public cSeduService
int writeStartSeq();
int writeEndSeq();
- int writePix(Pixel* p);
- int writeColor(Pixel* p, int index);
+ int writePix(Pixel* p, char* rgbOrder);
+ int writeColor(Pixel* p, int index, char* rgbOrder);
// set ..