summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--imon.c9
-rw-r--r--imon.h2
-rw-r--r--imonlcd.c2
-rw-r--r--watch.c96
4 files changed, 55 insertions, 54 deletions
diff --git a/imon.c b/imon.c
index 9c78261..958d809 100644
--- a/imon.c
+++ b/imon.c
@@ -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);
diff --git a/imon.h b/imon.h
index 6e38217..513eef2 100644
--- a/imon.h
+++ b/imon.h
@@ -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 ();
diff --git a/imonlcd.c b/imonlcd.c
index 472a60b..3179bae 100644
--- a/imonlcd.c
+++ b/imonlcd.c
@@ -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";
diff --git a/watch.c b/watch.c
index 6bb0129..a303471 100644
--- a/watch.c
+++ b/watch.c
@@ -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();
}