diff options
author | anbr <vdr07@deltab.de> | 2010-10-23 18:45:18 +0200 |
---|---|---|
committer | anbr <vdr07@deltab.de> | 2010-10-23 18:45:18 +0200 |
commit | 4fb594582ea4587a83328b3e9964fde3c5bc36c1 (patch) | |
tree | d3470805a748949f9940a0a913a5bd4ce8287084 | |
parent | e9b86fb4adaa470041d1bc02329e20ddb6b1e48b (diff) | |
download | vdr-plugin-targavfd-4fb594582ea4587a83328b3e9964fde3c5bc36c1.tar.gz vdr-plugin-targavfd-4fb594582ea4587a83328b3e9964fde3c5bc36c1.tar.bz2 |
Allow turn display off at night (Feature #175)
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | po/de_DE.po | 18 | ||||
-rw-r--r-- | po/it_IT.po | 19 | ||||
-rw-r--r-- | setup.c | 57 | ||||
-rw-r--r-- | setup.h | 11 | ||||
-rw-r--r-- | watch.c | 128 |
7 files changed, 182 insertions, 54 deletions
@@ -2,6 +2,7 @@ VDR Plugin 'targavfd' Revision History ------------------------------------- 2010- +- Allow turn display off at night (Feature #175) - Add render mode "show channel names only" (Feature #426) - Show next timer on lines (Feature #427) - Update italian translation (Support #357) @@ -100,6 +100,8 @@ This options are editable at run time. (Menu: Setup > Plugin > targavfd ... ) - Timed - Show the volume bar only a short time, if volume changed - Ever - Show the volume bar every time +* Suspend display at night + - Allow turn display off at night, depends selected mode and time frame. Plugin SVDRP commands --------------------- diff --git a/po/de_DE.po b/po/de_DE.po index e616ed9..de565be 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-targavfd-plugin 0.0.5\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2010-10-09 18:56+0200\n" +"POT-Creation-Date: 2010-10-23 18:00+0200\n" "PO-Revision-Date: 2010-07-02 21:25+0200\n" "Last-Translator: Andreas Brachold <vdr07 AT deltab de>\n" "Language-Team: Andreas Brachold <vdr07 AT deltab de>\n" @@ -81,6 +81,21 @@ msgstr "Immer" msgid "Show volume bargraph" msgstr "Lautstärkebargraph anzeigen" +msgid "Resume on activities" +msgstr "Reaktivieren bei Aktivität" + +msgid "Only per time" +msgstr "Gemäß der Zeit" + +msgid "Suspend display at night" +msgstr "Nächtliches Aussetzen der Anzeige" + +msgid "Beginning of suspend" +msgstr "Anfangszeit" + +msgid "End time of suspend" +msgstr "Endzeit" + msgid "Control a targa vfd" msgstr "Steuert ein Targa VFD" @@ -89,4 +104,3 @@ msgstr "Kein aktiver Timer" msgid "Unknown title" msgstr "Unbekannter Titel" - diff --git a/po/it_IT.po b/po/it_IT.po index b62314a..949366d 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-targavfd-plugin 0.0.5\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2010-10-09 18:56+0200\n" +"POT-Creation-Date: 2010-10-23 18:00+0200\n" "PO-Revision-Date: 2010-07-17 23:32+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: \n" @@ -84,6 +84,22 @@ msgstr "Sempre" msgid "Show volume bargraph" msgstr "Mostra grafico a barre volume" +msgid "Resume on activities" +msgstr "" + +#, fuzzy +msgid "Only per time" +msgstr "Titolo solo" + +msgid "Suspend display at night" +msgstr "" + +msgid "Beginning of suspend" +msgstr "" + +msgid "End time of suspend" +msgstr "" + msgid "Control a targa vfd" msgstr "Controlla una targa VFD" @@ -92,4 +108,3 @@ msgstr "Nessun timer attivo" msgid "Unknown title" msgstr "Titolo sconosciuto" - @@ -32,6 +32,7 @@ #define DEFAULT_BIG_FONT_HEIGHT 14 #define DEFAULT_SMALL_FONT_HEIGHT 7 #define DEFAULT_VOLUME_MODE eVolumeMode_ShowEver /**< Show the volume bar ever */ +#define DEFAULT_SUSPEND_MODE eSuspendMode_Never /**< Suspend display never */ /// The one and only Stored setup data cVFDSetup theSetup; @@ -47,6 +48,9 @@ cVFDSetup::cVFDSetup(void) m_nBigFontHeight = DEFAULT_BIG_FONT_HEIGHT; m_nSmallFontHeight = DEFAULT_SMALL_FONT_HEIGHT; m_nVolumeMode = DEFAULT_VOLUME_MODE; + m_nSuspendMode = DEFAULT_SUSPEND_MODE; + m_nSuspendTimeOn = 2200; + m_nSuspendTimeOff = 800; strncpy(m_szFont,DEFAULT_FONT,sizeof(m_szFont)); } @@ -68,6 +72,9 @@ cVFDSetup& cVFDSetup::operator = (const cVFDSetup& x) m_nSmallFontHeight = x.m_nSmallFontHeight; m_nVolumeMode = x.m_nVolumeMode; + m_nSuspendMode = x.m_nSuspendMode; + m_nSuspendTimeOn = x.m_nSuspendTimeOn; + m_nSuspendTimeOff = x.m_nSuspendTimeOff; strncpy(m_szFont,x.m_szFont,sizeof(m_szFont)); @@ -162,6 +169,40 @@ bool cVFDSetup::SetupParse(const char *szName, const char *szValue) return true; } + // SuspendMode + if(!strcasecmp(szName, "SuspendMode")) { + int n = atoi(szValue); + if ((n < eSuspendMode_Never) || (n >= eSuspendMode_LASTITEM)) { + esyslog("targaVFD: SuspendMode must be between %d and %d, using default %d", + eSuspendMode_Never, eSuspendMode_LASTITEM, DEFAULT_SUSPEND_MODE); + n = DEFAULT_SUSPEND_MODE; + } + m_nSuspendMode = n; + return true; + } + // SuspendTimeOn + if(!strcasecmp(szName, "SuspendTimeOn")) { + int n = atoi(szValue); + if ((n < 0) || (n >= 2400)) { + esyslog("targaVFD: SuspendTimeOn must be between %d and %d, using default %d", + 0, 2359, 0); + n = 0; + } + m_nSuspendTimeOn = n; + return true; + } + // SuspendTimeOff + if(!strcasecmp(szName, "SuspendTimeOff")) { + int n = atoi(szValue); + if ((n < 0) || (n >= 2400)) { + esyslog("targaVFD: SuspendTimeOff must be between %d and %d, using default %d", + 0, 2359, 0); + n = 0; + } + m_nSuspendTimeOff = n; + return true; + } + //Unknow parameter return false; } @@ -179,6 +220,9 @@ void cVFDMenuSetup::Store(void) SetupStore("SmallFont", theSetup.m_nSmallFontHeight); SetupStore("TwoLineMode",theSetup.m_nRenderMode); SetupStore("VolumeMode", theSetup.m_nVolumeMode); + SetupStore("SuspendMode", theSetup.m_nSuspendTimeOn); + SetupStore("SuspendTimeOn", theSetup.m_nSuspendTimeOn); + SetupStore("SuspendTimeOff", theSetup.m_nSuspendTimeOff); } cVFDMenuSetup::cVFDMenuSetup(cVFDWatch* pDev) @@ -238,6 +282,19 @@ cVFDMenuSetup::cVFDMenuSetup(cVFDWatch* pDev) Add(new cMenuEditStraItem (tr("Show volume bargraph"), &m_tmpSetup.m_nVolumeMode, memberof(szVolumeMode), szVolumeMode)); + + static const char * szSuspendMode[eSuspendMode_LASTITEM]; + szSuspendMode[eSuspendMode_Never] = tr("Never"); + szSuspendMode[eSuspendMode_Timed] = tr("Resume on activities"); + szSuspendMode[eSuspendMode_Ever] = tr("Only per time"); + + Add(new cMenuEditStraItem (tr("Suspend display at night"), + &m_tmpSetup.m_nSuspendMode, + memberof(szSuspendMode), szSuspendMode)); + Add(new cMenuEditTimeItem (tr("Beginning of suspend"), + &m_tmpSetup.m_nSuspendTimeOn)); + Add(new cMenuEditTimeItem (tr("End time of suspend"), + &m_tmpSetup.m_nSuspendTimeOff)); } eOSState cVFDMenuSetup::ProcessKey(eKeys nKey) @@ -40,6 +40,13 @@ enum eRenderMode { ,eRenderMode_LASTITEM }; +enum eSuspendMode { + eSuspendMode_Never /**< Suspend display never */ + ,eSuspendMode_Timed /**< Suspend display, resume short time */ + ,eSuspendMode_Ever /**< Suspend display ever */ + ,eSuspendMode_LASTITEM +}; + struct cVFDSetup { int m_nOnExit; @@ -57,6 +64,10 @@ struct cVFDSetup int m_nVolumeMode; + int m_nSuspendMode; + int m_nSuspendTimeOn; + int m_nSuspendTimeOff; + cVFDSetup(void); cVFDSetup(const cVFDSetup& x); cVFDSetup& operator = (const cVFDSetup& x); @@ -20,6 +20,7 @@ #include "ffont.h" #include <vdr/tools.h> +#include <vdr/shutdown.h> struct cMutexLooker { cMutex& mutex; @@ -65,7 +66,6 @@ cVFDWatch::cVFDWatch() replayTime = NULL; currentTime = NULL; - m_eWatchMode = eLiveTV; m_nScrollOffset = -1; @@ -210,6 +210,8 @@ void cVFDWatch::Action(void) unsigned int nCnt = 0; cTimeMs runTime; + struct tm tm_r; + bool bLastSuspend = false; for (;!m_bShutdown;++nCnt) { @@ -218,6 +220,7 @@ void cVFDWatch::Action(void) unsigned int nIcons = 0; bool bFlush = false; bool bReDraw = false; + bool bSuspend = false; if(m_bShutdown) break; else { @@ -225,64 +228,89 @@ void cVFDWatch::Action(void) runTime.Set(); time_t ts = time(NULL); - - // every second the clock need updates. - if (theSetup.m_nRenderMode == eRenderMode_DualLine) { - if((0 == (nCnt % 2))) { - bReDraw = CurrentTime(ts); - if(m_eWatchMode != eLiveTV) { - bReDraw |= ReplayTime(); - } + if(theSetup.m_nSuspendMode != eSuspendMode_Never + && theSetup.m_nSuspendTimeOff != theSetup.m_nSuspendTimeOn) { + struct tm *now = localtime_r(&ts, &tm_r); + int clock = now->tm_hour * 100 + now->tm_min; + if(theSetup.m_nSuspendTimeOff > theSetup.m_nSuspendTimeOn) { //like 8-20 + bSuspend = (clock >= theSetup.m_nSuspendTimeOn) + && (clock <= theSetup.m_nSuspendTimeOff); + } else { //like 0-8 and 20..24 + bSuspend = (clock >= theSetup.m_nSuspendTimeOn) + || (clock <= theSetup.m_nSuspendTimeOff); + } + if(theSetup.m_nSuspendMode == eSuspendMode_Timed + && !ShutdownHandler.IsUserInactive()) { + bSuspend = false; } } - - bFlush = RenderScreen(bReDraw); - if(m_eWatchMode != eLiveTV) { - switch(ReplayMode()) { - case eReplayNone: - case eReplayPaused: - nIcons |= eIconPAUSE; - break; - default: - case eReplayPlay: - nIcons |= eIconPLAY; - break; - case eReplayBackward1: - case eReplayBackward2: - case eReplayBackward3: - break; - case eReplayForward1: - case eReplayForward2: - case eReplayForward3: - break; - } + if(bSuspend != bLastSuspend) { + bReDraw = true; } - for(n=0;n<memberof(m_nCardIsRecording);++n) { - if(0 != m_nCardIsRecording[n]) { - nIcons |= eIconRECORD; - break; + if(!bSuspend) { + // every second the clock need updates. + if (theSetup.m_nRenderMode == eRenderMode_DualLine) { + if((0 == (nCnt % 2))) { + bReDraw = CurrentTime(ts); + if(m_eWatchMode != eLiveTV) { + bReDraw |= ReplayTime(); + } } - } + } - // update volume - bargraph or mute symbol - if(theSetup.m_nVolumeMode != eVolumeMode_ShowNever) { - if(m_bVolumeMute) { - nIcons |= eIconMUTE; - } else { - if(theSetup.m_nVolumeMode == eVolumeMode_ShowEver - || ( theSetup.m_nVolumeMode == eVolumeMode_ShowTimed - && (ts - tsVolumeLast) < 15 )) { // if timed - delay 15 seconds - nIcons |= eIconVOLUME; - const int nVolSteps = (MAXVOLUME/14); - nIcons |= (((1 << (m_nLastVolume / nVolSteps)) - 1) << 0x0B); - } + bFlush = RenderScreen(bReDraw); + if(m_eWatchMode != eLiveTV) { + switch(ReplayMode()) { + case eReplayNone: + case eReplayPaused: + nIcons |= eIconPAUSE; + break; + default: + case eReplayPlay: + nIcons |= eIconPLAY; + break; + case eReplayBackward1: + case eReplayBackward2: + case eReplayBackward3: + break; + case eReplayForward1: + case eReplayForward2: + case eReplayForward3: + break; + } + } + + for(n=0;n<memberof(m_nCardIsRecording);++n) { + if(0 != m_nCardIsRecording[n]) { + nIcons |= eIconRECORD; + break; + } + } + + // update volume - bargraph or mute symbol + if(theSetup.m_nVolumeMode != eVolumeMode_ShowNever) { + if(m_bVolumeMute) { + nIcons |= eIconMUTE; + } else { + if(theSetup.m_nVolumeMode == eVolumeMode_ShowEver + || ( theSetup.m_nVolumeMode == eVolumeMode_ShowTimed + && (ts - tsVolumeLast) < 15 )) { // if timed - delay 15 seconds + nIcons |= eIconVOLUME; + const int nVolSteps = (MAXVOLUME/14); + nIcons |= (((1 << (m_nLastVolume / nVolSteps)) - 1) << 0x0B); + } + } } } - if(theSetup.m_nBrightness != nBrightness) { + // Set Brightness if setup value changed or display set to suspend + if(theSetup.m_nBrightness != nBrightness || + bSuspend != bLastSuspend) { nBrightness = theSetup.m_nBrightness; - Brightness(nBrightness); + Brightness(bSuspend ? 0 : nBrightness); + bLastSuspend = bSuspend; + bFlush = true; } //Force icon state (defined by svdrp) @@ -300,7 +328,7 @@ void cVFDWatch::Action(void) flush(false); } } - int nDelay = 100 - runTime.Elapsed(); + int nDelay = (bSuspend ? 1000 : 100) - runTime.Elapsed(); if(nDelay <= 10) { nDelay = 10; } |