Feature #175 » imonlcd-0.0.2-turnoff.patch
| imon.c | ||
|---|---|---|
|
}
|
||
|
/*
|
||
|
* Send commands needed to initialize Display.
|
||
|
*
|
||
|
*/
|
||
|
bool ciMonLCD::SendCmdInitSequence() {
|
||
|
SendCmd(this->cmd_clear_alarm);
|
||
|
SendCmd(this->cmd_display_on);
|
||
|
SendCmd(CMD_INIT); /* unknown, required init command */
|
||
|
SendCmd(CMD_SET_ICONS);
|
||
|
/* clear the progress-bars on top and bottom of the display */
|
||
|
SendCmd(CMD_SET_LINES0);
|
||
|
SendCmd(CMD_SET_LINES1);
|
||
|
SendCmd(CMD_SET_LINES2);
|
||
|
return true;
|
||
|
}
|
||
|
/*
|
||
|
* Show the big clock. We need to set it to the current time, then it just
|
||
|
* keeps counting automatically.
|
||
|
*/
|
||
| imon.h | ||
|---|---|---|
|
bool SendCmd(const uint64_t & cmdData);
|
||
|
bool SendCmdClock(time_t tAlarm);
|
||
|
bool SendCmdShutdown();
|
||
|
bool SendCmdInitSequence();
|
||
|
bool Contrast(int nContrast);
|
||
|
public:
|
||
|
ciMonLCD();
|
||
| watch.c | ||
|---|---|---|
|
#include "setup.h"
|
||
|
#include <vdr/tools.h>
|
||
|
#include <vdr/shutdown.h>
|
||
|
#define DEFAULT_BEDTIME_HOUR 21
|
||
|
struct cMutexLooker {
|
||
|
cMutex& mutex;
|
||
| ... | ... | |
|
replayTitleLast = NULL;
|
||
|
currentTime = NULL;
|
||
|
tsCurrentLast = 0;
|
||
|
display_off = false;
|
||
|
m_eWatchMode = eLiveTV;
|
||
|
m_eVideoMode = eVideoNone;
|
||
| ... | ... | |
|
unsigned int nIcons = 0;
|
||
|
bool bUpdateIcons = false;
|
||
|
bool bFlush = false;
|
||
|
if (ShutdownHandler.IsUserInactive() && isBedtime())
|
||
|
{
|
||
|
if (!display_off)
|
||
|
{ // turn off display
|
||
|
SendCmdShutdown();
|
||
|
display_off = true;
|
||
|
}
|
||
|
continue; // start next iteration
|
||
|
}
|
||
|
|
||
|
if (display_off)
|
||
|
{ // turn display on
|
||
|
SendCmdInitSequence();
|
||
|
display_off = false;
|
||
|
}
|
||
|
if(m_bShutdown)
|
||
|
break;
|
||
|
else {
|
||
| ... | ... | |
|
cString* scRender;
|
||
|
cString* scHeader = NULL;
|
||
|
bool bForce = m_bUpdateScreen;
|
||
|
if(osdMessage) {
|
||
|
scRender = osdMessage;
|
||
|
} else if(osdItem) {
|
||
| ... | ... | |
|
return false;
|
||
|
}
|
||
|
bool ciMonWatch::isBedtime() {
|
||
|
if (tsCurrentLast == 0)
|
||
|
{
|
||
|
CurrentTime();
|
||
|
}
|
||
|
struct tm l;
|
||
|
localtime_r(&tsCurrentLast, &l);
|
||
|
|
||
|
if(l.tm_hour >= DEFAULT_BEDTIME_HOUR)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
bool ciMonWatch::CurrentTime() {
|
||
|
time_t ts = time(NULL);
|
||
| watch.h | ||
|---|---|---|
|
time_t tsCurrentLast;
|
||
|
cString* currentTime;
|
||
|
bool display_off;
|
||
|
protected:
|
||
|
virtual void Action(void);
|
||
|
bool Program();
|
||
|
bool Replay();
|
||
|
bool RenderScreen();
|
||
|
bool isBedtime();
|
||
|
eReplayState ReplayMode() const;
|
||
|
bool ReplayPosition(int ¤t, int &total) const;
|
||
|
bool CurrentTime();
|
||