Project

General

Profile

Feature #175 » final.patch

anbr, 10/20/2009 09:03 PM

View differences:

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>
// during following times display is turned off
// when user is inactive
#define DEFAULT_BEDTIME_HOUR 22
#define DEFAULT_BEDTIME_END_HOUR 8
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 {
......
}
// every second the clock need updates.
if (theSetup.m_bTwoLineMode && m_eWatchMode != eLiveTV) {
if (theSetup.m_bTwoLineMode) {
if((0 == (nCnt % 10))) {
m_bUpdateScreen |= CurrentTime();
}
if(m_eWatchMode >= eReplayNormal)
{
m_bUpdateScreen = true;
}
}
bFlush = RenderScreen();
......
bool ciMonWatch::RenderScreen() {
cString* scRender;
cString* scHeader = NULL;
int current = 0, total = 0;
bool bForce = m_bUpdateScreen;
if(osdMessage) {
scRender = osdMessage;
......
if(chPresentTitle)
scRender = chPresentTitle;
else {
scHeader = currentTime;
scRender = chName;
// in twoline Mode don't show channel name in lower line
if(theSetup.m_bTwoLineMode)
{
scRender = NULL;
}
}
} else {
if(Replay()) {
bForce = true;
}
scHeader = currentTime;
ReplayPosition(current,total);
scRender = replayTitle;
}
if(bForce) {
m_nScrollOffset = 0;
m_bScrollBackward = false;
......
}
}
if(scHeader && theSetup.m_bTwoLineMode) {
this->DrawText(0, 0, *scHeader);
if(theSetup.m_bTwoLineMode)
{
if(scHeader) {
this->DrawText(0, 0, *scHeader);
} else if(current > 0) {
this->DrawText(0, 0, IndexToHMSF(current));
}
this->DrawText(70, 0, *currentTime); // time top right
}
m_bUpdateScreen = false;
......
return false;
}
bool ciMonWatch::isBedtime() {
if (tsCurrentLast == 0)
{
CurrentTime();
}
struct tm l;
localtime_r(&tsCurrentLast, &l);
// from now til midnight
if(l.tm_hour >= DEFAULT_BEDTIME_HOUR)
{
return true;
}
// from midnight til now
if(l.tm_hour <= DEFAULT_BEDTIME_END_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 &current, int &total) const;
bool CurrentTime();
(2-2/2)