diff -r 5e538c4e1ecb -r a5a964148e34 thermferm/thermferm.c --- a/thermferm/thermferm.c Sat Jul 12 22:32:29 2014 +0200 +++ b/thermferm/thermferm.c Sat Jul 12 23:50:48 2014 +0200 @@ -228,12 +228,15 @@ int server(void) { - char buf[1024], *filename; + char buf[1024], *filename, target[40], heater[40], cooler[40], fan[40], door[40]; time_t now, last = (time_t)0; w1_therm *tmp1; units_list *unit; int rc, run = 1, temp, seconds = 0; -#ifndef HAVE_WIRINGPI_H +#ifdef HAVE_WIRINGPI_H + int lcdshow = 0; + struct tm *tm; +#else long t = 0; #endif @@ -311,20 +314,6 @@ } } -#ifdef HAVE_WIRINGPI_H - if (run && lcdupdate) { - lcdPosition(lcdHandle, 0, 0); - tmp1 = Config.w1therms; - snprintf(buf, 16, "%5.2f %cC %s ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias); - mb_lcdPuts(lcdHandle, buf); - temp = tmp1->lastval; - tmp1 = tmp1->next; - lcdPosition(lcdHandle, 0, 1); - snprintf(buf, 16, "%5.2f %cC %s ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias); - mb_lcdPuts(lcdHandle, buf); - } -#endif - /* * Timed schedulers */ @@ -333,6 +322,41 @@ last = now; seconds++; +#ifdef HAVE_WIRINGPI_H + if ((seconds % 5) == 0) { + + if (lcdshow == 0) { + lcdPosition(lcdHandle, 0, 0); + snprintf(buf, 17, " ThermFerm "); + mb_lcdPuts(lcdHandle, buf); + lcdPosition(lcdHandle, 0, 1); + snprintf(buf, 17, " Version %s ", VERSION); + mb_lcdPuts(lcdHandle, buf); + lcdshow++; + } else if (lcdshow == 1) { + tm = localtime(&now); + lcdPosition(lcdHandle, 0, 0); + snprintf(buf, 17, " %02d-%02d-%04d ", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900); + mb_lcdPuts(lcdHandle, buf); + lcdPosition(lcdHandle, 0, 1); + snprintf(buf, 17, " %02d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec); + mb_lcdPuts(lcdHandle, buf); + lcdshow++; + } else { + lcdPosition(lcdHandle, 0, 0); + tmp1 = Config.w1therms; + snprintf(buf, 17, "%5.2f %cC %s ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias); + mb_lcdPuts(lcdHandle, buf); + temp = tmp1->lastval; + tmp1 = tmp1->next; + lcdPosition(lcdHandle, 0, 1); + snprintf(buf, 17, "%5.2f %cC %s ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias); + mb_lcdPuts(lcdHandle, buf); + lcdshow = 0; + } + } +#endif + if (seconds == 60) { seconds = 0; @@ -348,8 +372,35 @@ for (unit = Config.units; unit; unit = unit->next) { if (unit->mode != UNITMODE_OFF) { - snprintf(buf, 1023, "%s,%.3f,%.3f,Target,Heater,Cooler,Fan,Door", - UNITMODE[unit->mode], unit->air_temperature / 1000.0, unit->beer_temperature / 1000.0); + + snprintf(target, 39, "NA"); + snprintf(heater, 39, "NA"); + snprintf(cooler, 39, "NA"); + snprintf(fan, 39, "NA"); + snprintf(door, 39, "NA"); + + if (unit->mode == UNITMODE_BEER) + snprintf(target, 39, "%.1f", unit->beer_set); + else if (unit->mode == UNITMODE_FRIDGE) + snprintf(target, 39, "%.1f", unit->fridge_set); + + if (unit->io1_address) { + if (unit->heater_available) { + + } + if (unit->cooler_available) { + + } + } + if (unit->io2_address) { + if (unit->fan_available) { + + } + } + + snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s", + UNITMODE[unit->mode], unit->air_temperature / 1000.0, + unit->beer_temperature / 1000.0, target, heater, cooler, fan, door); filename = xstrcpy(unit->name); filename = xstrcat(filename, (char *)".log"); logger(filename, buf);