summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--display.c57
-rw-r--r--display.h9
-rw-r--r--plugin.c3
-rw-r--r--state.c111
-rw-r--r--state.h25
6 files changed, 204 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 60bf203..137b401 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ CXXFLAGS ?= -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
### The directory environment:
+DVBDIR = ../../../../DVB
VDRDIR = ../../..
LIBDIR = ../../lib
TMPDIR = /tmp
diff --git a/display.c b/display.c
index d6f385b..5040fb9 100644
--- a/display.c
+++ b/display.c
@@ -8,6 +8,7 @@
*
* (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
* (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
+ * (c) 2010 Wolfgang Astleitner <mrwastl AT users sourceforge net>
*/
#include <stdlib.h>
@@ -44,6 +45,10 @@ cGraphLCDDisplay::cGraphLCDDisplay()
mLastState = StateNormal;
mShowVolume = false;
+
+ nCurrentBrightness = -1;
+ LastTimeBrightness = 0;
+ bBrightnessActive = true;
}
cGraphLCDDisplay::~cGraphLCDDisplay()
@@ -173,6 +178,19 @@ void cGraphLCDDisplay::Action(void)
mUpdate = true;
}
+ // update display if BrightnessDelay is exceeded
+ if ((nCurrentBrightness == GraphLCDSetup.BrightnessActive) &&
+ ((cTimeMs::Now() - LastTimeBrightness) > (uint64_t) (GraphLCDSetup.BrightnessDelay*1000)))
+ {
+ mUpdate = true;
+ }
+
+ // external service changed (check each second)
+ if ( (currTimeMs/1000 != mLastTimeMs/1000) && mGraphLCDState->CheckServiceEventUpdate())
+ {
+ mUpdate = true;
+ }
+
if (mUpdate)
{
mUpdateAt = 0;
@@ -206,6 +224,7 @@ void cGraphLCDDisplay::Action(void)
mLcd->SetScreen(mScreen->Data(), mScreen->Width(), mScreen->Height(), mScreen->LineSize());
mLcd->Refresh(false);
mLastTimeMs = currTimeMs;
+ SetBrightness();
}
else
{
@@ -297,3 +316,41 @@ void cGraphLCDDisplay::SetMenuCurrent()
}
UpdateIn(100);
}
+
+void cGraphLCDDisplay::SetBrightness()
+{
+ //mutex.Lock();
+ bool bActive = bBrightnessActive
+ || (mState != StateNormal)
+ || (GraphLCDSetup.ShowVolume && mShowVolume)
+ || (GraphLCDSetup.ShowMessages && mGraphLCDState->ShowMessage())
+ || (GraphLCDSetup.BrightnessDelay == 900);
+ if (bActive)
+ {
+ LastTimeBrightness = cTimeMs::Now();
+ bBrightnessActive = false;
+ }
+ if ((bActive ? GraphLCDSetup.BrightnessActive : GraphLCDSetup.BrightnessIdle) != nCurrentBrightness)
+ {
+ if (bActive)
+ {
+ mLcd->SetBrightness(GraphLCDSetup.BrightnessActive);
+ nCurrentBrightness = GraphLCDSetup.BrightnessActive;
+ }
+ else
+ {
+ if (GraphLCDSetup.BrightnessDelay < 1
+ || ((cTimeMs::Now() - LastTimeBrightness) > (uint64_t) (GraphLCDSetup.BrightnessDelay*1000)))
+ {
+ mLcd->SetBrightness(GraphLCDSetup.BrightnessIdle);
+ nCurrentBrightness = GraphLCDSetup.BrightnessIdle;
+ }
+ }
+ }
+ //mutex.Unlock();
+}
+
+void cGraphLCDDisplay::ForceUpdateBrightness() {
+ bBrightnessActive = true;
+ SetBrightness();
+}
diff --git a/display.h b/display.h
index d3c2d43..a86dc53 100644
--- a/display.h
+++ b/display.h
@@ -8,6 +8,7 @@
*
* (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
* (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
+ * (c) 2010 Wolfgang Astleitner <mrwastl AT users sourceforge net>
*/
#ifndef _GRAPHLCD_DISPLAY_H_
@@ -53,6 +54,8 @@ public:
void SetMenuCurrent();
const GLCD::cBitmap * GetScreen() const { return mScreen; }
+ void ForceUpdateBrightness();
+
protected:
virtual void Action();
@@ -75,6 +78,12 @@ private:
bool mShowVolume;
void UpdateIn(uint64_t msec);
+
+ /** set brightness depending on user activity */
+ void SetBrightness();
+ uint64_t LastTimeBrightness;
+ int nCurrentBrightness;
+ bool bBrightnessActive;
};
#endif
diff --git a/plugin.c b/plugin.c
index be9607f..56130f8 100644
--- a/plugin.c
+++ b/plugin.c
@@ -8,6 +8,7 @@
*
* (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
* (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
+ * (c) 2010 Wolfgang Astleitner <mrwastl AT users sourceforge net>
*/
#include <getopt.h>
@@ -24,7 +25,7 @@
static const char * kPluginName = "graphlcd";
-static const char *VERSION = "0.2.0-pre2";
+static const char *VERSION = "0.2.0-git";
static const char *DESCRIPTION = "Output to graphic LCD";
static const char *MAINMENUENTRY = NULL;
diff --git a/state.c b/state.c
index c9a05d9..d70d58e 100644
--- a/state.c
+++ b/state.c
@@ -4,6 +4,7 @@
* status.c - status monitor class
*
* (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
+ * (c) 2010 Wolfgang Astleitner <mrwastl AT users sourceforge net>
**/
#include <ctype.h>
@@ -16,6 +17,7 @@
#include <vdr/eitscan.h>
#include <vdr/i18n.h>
+#include <vdr/plugin.h>
cGraphLCDState::cGraphLCDState(cGraphLCDDisplay * Display)
@@ -72,6 +74,12 @@ cGraphLCDState::cGraphLCDState(cGraphLCDDisplay * Display)
mVolume.value = -1;
mVolume.lastChange = 0;
+ /* change flags for RDS and LCR services */
+ rtsChanged = false;
+ rtsActive = false;
+ lcrChanged = false;
+ lcrActive = false;
+
SetChannel(cDevice::CurrentChannel());
}
@@ -566,6 +574,7 @@ void cGraphLCDState::OsdChannel(const char * Text)
//printf("graphlcd plugin: cGraphLCDState::OsdChannel %s\n", Text);
if (GraphLCDSetup.PluginActive)
{
+ mDisplay->ForceUpdateBrightness();
if (Text)
mDisplay->Update();
}
@@ -641,10 +650,18 @@ void cGraphLCDState::UpdateChannelInfo(void)
void cGraphLCDState::UpdateEventInfo(void)
{
+ bool ptitle = false;
+
mutex.Lock();
const cEvent * present = NULL, * following = NULL;
cSchedulesLock schedulesLock;
+ // backup current values
+ std::string currTitle = mPresent.title;
+ std::string currShortText = mPresent.shortText;
+ std::string currDescription = mPresent.description;
+
+
// reset event data to empty values
mPresent.valid = false;
mPresent.startTime = 0;
@@ -677,8 +694,10 @@ void cGraphLCDState::UpdateEventInfo(void)
mPresent.vpsTime = present->Vps();
mPresent.duration = present->Duration();
mPresent.title = "";
- if (present->Title())
+ if (present->Title()) {
mPresent.title = present->Title();
+ ptitle = true;
+ }
mPresent.shortText = "";
if (present->ShortText())
mPresent.shortText = present->ShortText();
@@ -705,6 +724,32 @@ void cGraphLCDState::UpdateEventInfo(void)
}
}
}
+
+ /* get events from add. services (if activated) */
+ if (rtsActive) {
+ if (currRTSData.rds_info == 2 && strstr(currRTSData.rds_title, "---") == NULL) {
+ char rtpinfo[2][65], rtstr[140];
+ strcpy(rtpinfo[0], currRTSData.rds_title);
+ strcpy(rtpinfo[1], currRTSData.rds_artist);
+ sprintf(rtstr, "%02d:%02d %s | %s", currRTSData.title_start->tm_hour, currRTSData.title_start->tm_min, trim(((std::string)(rtpinfo[0]))).c_str(), trim(((std::string)(rtpinfo[1]))).c_str());
+ ptitle ? mPresent.shortText = rtstr : mPresent.title = rtstr;
+ } else if (currRTSData.rds_info > 0) {
+ char rtstr[65];
+ strcpy(rtstr, currRTSData.rds_text);
+ ptitle ? mPresent.shortText = trim(rtstr) : mPresent.title = trim(rtstr);
+ }
+ } else if (lcrActive && lcrChanged) {
+ if ( strstr( currLcrData.destination, "---" ) == NULL ) {
+ char lcrStringParts[3][25], lcrString[100];
+ strcpy( lcrStringParts[0], (const char *)currLcrData.destination );
+ strcpy( lcrStringParts[1], (const char *)currLcrData.price );
+ strcpy( lcrStringParts[2], (const char *)currLcrData.pulse );
+ sprintf(lcrString, "%s | %s", trim((std::string)(lcrStringParts[1])).c_str(), trim((std::string)(lcrStringParts[2])).c_str());
+ mPresent.title = trim(lcrStringParts[0]);
+ mPresent.shortText = trim(lcrString);
+ }
+ }
+
mutex.Unlock();
}
@@ -861,3 +906,67 @@ bool cGraphLCDState::ShowMessage()
mutex.Unlock();
return ret;
}
+
+
+/* async. check event updates for services from other plugins */
+/* only sets flags but does NOT update display output */
+bool cGraphLCDState::CheckServiceEventUpdate(void)
+{
+ mutex.Lock();
+
+ rtsChanged = false;
+ lcrChanged = false;
+ rtsActive = false;
+ lcrActive = false;
+
+ // get&display Radiotext
+ cPlugin *p;
+ p = cPluginManager::CallFirstService("RadioTextService-v1.0", NULL);
+ if (p) {
+ rtsActive = true;
+ if (cPluginManager::CallFirstService("RadioTextService-v1.0", &checkRTSData)) {
+ if (
+ (currRTSData.rds_info != checkRTSData.rds_info) ||
+ (currRTSData.rds_pty != checkRTSData.rds_pty) ||
+ (strcmp(currRTSData.rds_text, checkRTSData.rds_text) != 0) ||
+ (strcmp(currRTSData.rds_title, checkRTSData.rds_title) != 0) ||
+ (strcmp(currRTSData.rds_artist, checkRTSData.rds_artist) != 0)
+ )
+ {
+ currRTSData.rds_info = checkRTSData.rds_info;
+ currRTSData.rds_pty = checkRTSData.rds_pty;
+ currRTSData.rds_text = checkRTSData.rds_text;
+ currRTSData.rds_title = checkRTSData.rds_title;
+ currRTSData.rds_artist = checkRTSData.rds_artist;
+ currRTSData.title_start= checkRTSData.title_start;
+
+ rtsChanged = true;
+ }
+ }
+ }
+
+
+ // get&display LcrData
+ p = cPluginManager::CallFirstService("LcrService-v1.0", NULL);
+ if (p) {
+ lcrActive = true;
+ if (cPluginManager::CallFirstService("LcrService-v1.0", &checkLcrData)) {
+ if (
+ (strcmp(currLcrData.destination, checkLcrData.destination) != 0) ||
+ (strcmp(currLcrData.price, checkLcrData.price) != 0) ||
+ (strcmp(currLcrData.pulse, checkLcrData.pulse) != 0)
+ )
+ {
+ currLcrData.destination = checkLcrData.destination;
+ currLcrData.price = checkLcrData.price;
+ currLcrData.pulse = checkLcrData.pulse;
+
+ lcrChanged = true;
+ }
+ }
+ }
+ mutex.Unlock();
+ return (rtsChanged || lcrChanged);
+}
+
+
diff --git a/state.h b/state.h
index 608139d..5182586 100644
--- a/state.h
+++ b/state.h
@@ -4,6 +4,7 @@
* state.h - status monitor class
*
* (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
+ * (c) 2010 Wolfgang Astleitner <mrwastl AT users sourceforge net>
**/
#ifndef _GRAPHLCD_STATE_H_
@@ -92,6 +93,23 @@ struct tVolumeState
uint64_t lastChange;
};
+// Radiotext
+struct RadioTextService_v1_0 {
+ int rds_info;
+ int rds_pty;
+ char *rds_text;
+ char *rds_title;
+ char *rds_artist;
+ struct tm *title_start;
+};
+
+// LcrData
+struct LcrService_v1_0 {
+ cString destination;
+ cString price;
+ cString pulse;
+};
+
class cGraphLCDDisplay;
class cGraphLCDState : public cStatus
@@ -111,6 +129,11 @@ private:
tOsdState mOsd;
tVolumeState mVolume;
+ RadioTextService_v1_0 checkRTSData, currRTSData;
+ LcrService_v1_0 checkLcrData, currLcrData;
+ bool rtsChanged, rtsActive;
+ bool lcrChanged, lcrActive;
+
void SetChannel(int ChannelNumber);
void UpdateChannelInfo(void);
void UpdateEventInfo(void);
@@ -145,6 +168,8 @@ public:
tOsdState GetOsdState();
tVolumeState GetVolumeState();
bool ShowMessage();
+
+ bool CheckServiceEventUpdate();
};
#endif