diff options
-rw-r--r-- | imon.c | 9 | ||||
-rw-r--r-- | imon.h | 2 | ||||
-rw-r--r-- | imonlcd.c | 2 | ||||
-rw-r--r-- | watch.c | 96 |
4 files changed, 55 insertions, 54 deletions
@@ -286,8 +286,8 @@ bool ciMonLCD::flush() unsigned char msb; int offset = 0; - if(this->imon_fd<0) { - esyslog("iMonLCD: error writing to dead file descriptor"); + if(!this->isopen()) { + esyslog("iMonLCD: error flush frame to dead file descriptor"); return false; } @@ -504,8 +504,9 @@ bool ciMonLCD::SendCmd(const uint64_t & cmdData) { unsigned int i; unsigned char buf[8]; - if(this->imon_fd<0) { - esyslog("iMonLCD: error writing to dead file descriptor"); + if(!this->isopen()) { + dsyslog("iMonLCD: can't write : %08llx", cmdData); + esyslog("iMonLCD: error writing to dead file descriptor"); return false; } //dsyslog("iMonLCD: writing : %08llx", cmdData); @@ -122,7 +122,7 @@ public: virtual int open(const char* szDevice, eProtocol pro); virtual void close (); - + bool isopen() const { return imon_fd >= 0; } void clear (); int DrawText(int x, int y, const char* string); bool flush (); @@ -20,7 +20,7 @@ #include "status.h" #include "setup.h" -static const char *VERSION = "0.0.2"; +static const char *VERSION = "0.0.3"; static const char *DEFAULT_LCDDEVICE = "/dev/lcd0"; @@ -120,59 +120,59 @@ void ciMonWatch::close() { Cancel(); } - cTimer* t = Timers.GetNextActiveTimer(); - - switch(theSetup.m_nOnExit) { - case eOnExitMode_NEXTTIMER: { - isyslog("iMonLCD: closing, show only next timer."); - this->setLineLength(0,0,0,0); - - this->clear(); - if(t) { - struct tm l; - cString topic; - time_t tn = time(NULL); - time_t tt = t->StartTime(); - localtime_r(&tt, &l); - if((tt - tn) > 86400) { - // next timer more then 24h - topic = cString::sprintf("%d. %02d:%02d %s", l.tm_mday, l.tm_hour, l.tm_min, t->File()); + if(this->isopen()) { + cTimer* t = Timers.GetNextActiveTimer(); + + switch(theSetup.m_nOnExit) { + case eOnExitMode_NEXTTIMER: { + isyslog("iMonLCD: closing, show only next timer."); + this->setLineLength(0,0,0,0); + + this->clear(); + if(t) { + struct tm l; + cString topic; + time_t tn = time(NULL); + time_t tt = t->StartTime(); + localtime_r(&tt, &l); + if((tt - tn) > 86400) { + // next timer more then 24h + topic = cString::sprintf("%d. %02d:%02d %s", l.tm_mday, l.tm_hour, l.tm_min, t->File()); + } else { + // next timer (today) + topic = cString::sprintf("%02d:%02d %s", l.tm_hour, l.tm_min, t->File()); + } + this->DrawText(0,0,topic); + this->icons(eIconTime); } else { - // next timer (today) - topic = cString::sprintf("%02d:%02d %s", l.tm_hour, l.tm_min, t->File()); + this->DrawText(0,0,tr("None active timer")); + this->icons(0); } - this->DrawText(0,0,topic); - this->icons(eIconTime); - } else { - this->DrawText(0,0,tr("None active timer")); - this->icons(0); + this->flush(); + break; } - this->flush(); - break; + case eOnExitMode_SHOWMSG: { + isyslog("iMonLCD: closing, leaving \"last\" message."); + break; + } + case eOnExitMode_BLANKSCREEN: { + isyslog("iMonLCD: closing, turning backlight off."); + SendCmdShutdown(); + break; + } + case eOnExitMode_WAKEUP: { + isyslog("iMonLCD: closing, set wakeup time and showing clock."); + SendCmdClock(t ? t->StartTime() - (theSetup.m_nWakeup * 60) : NULL); + break; + } + default: + case eOnExitMode_SHOWCLOCK: { + isyslog("iMonLCD: closing, showing clock."); + SendCmdClock(NULL); + break; + } } - case eOnExitMode_SHOWMSG: { - isyslog("iMonLCD: closing, leaving \"last\" message."); - break; - } - case eOnExitMode_BLANKSCREEN: { - isyslog("iMonLCD: closing, turning backlight off."); - SendCmdShutdown(); - break; - } - case eOnExitMode_WAKEUP: { - isyslog("iMonLCD: closing, set wakeup time and showing clock."); - SendCmdClock(t ? t->StartTime() - (theSetup.m_nWakeup * 60) : NULL); - break; - } - default: - case eOnExitMode_SHOWCLOCK: { - isyslog("iMonLCD: closing, showing clock."); - SendCmdClock(NULL); - break; - } } - - ciMonLCD::close(); } |