thermferm/thermferm.c

changeset 293
881b1ae75468
parent 289
d810df0df36a
child 297
a70527a4e56a
equal deleted inserted replaced
292:138d5e15be01 293:881b1ae75468
1250 if (unit->mode == UNITMODE_NONE) { 1250 if (unit->mode == UNITMODE_NONE) {
1251 device_out(unit->heater_address, unit->heater_state); 1251 device_out(unit->heater_address, unit->heater_state);
1252 device_out(unit->cooler_address, unit->cooler_state); 1252 device_out(unit->cooler_address, unit->cooler_state);
1253 device_out(unit->fan_address, unit->fan_state); 1253 device_out(unit->fan_address, unit->fan_state);
1254 } 1254 }
1255
1256 /*
1257 * Usage counters
1258 */
1259 if (unit->heater_address && unit->heater_state)
1260 unit->heater_usage++;
1261 if (unit->cooler_address && unit->cooler_state)
1262 unit->cooler_usage++;
1263 if (unit->fan_address && unit->fan_state)
1264 unit->fan_usage++;
1265
1255 #ifdef HAVE_WIRINGPI_H 1266 #ifdef HAVE_WIRINGPI_H
1256 if (unit->heater_address && unit->cooler_address) { 1267 if (unit->heater_address && unit->cooler_address) {
1257 piLock(LOCK_LCD); 1268 piLock(LOCK_LCD);
1258 if (unit->heater_state) { 1269 if (unit->heater_state) {
1259 lcd_buf_write(row++, "Heater On "); 1270 lcd_buf_write(row++, "Heater On ");
1467 filename = NULL; 1478 filename = NULL;
1468 } 1479 }
1469 } 1480 }
1470 1481
1471 minutes++; 1482 minutes++;
1472 if (minutes == 60) 1483 if (minutes == 60) {
1473 minutes = 0; 1484 minutes = 0;
1485 /*
1486 * Log usage counters every hour
1487 */
1488 for (unit = Config.units; unit; unit = unit->next) {
1489 syslog(LOG_NOTICE, "Unit `%s' usage heater=%d cooler=%d fan=%d", unit->name, unit->heater_usage, unit->cooler_usage, unit->fan_usage);
1490 }
1491 }
1474 1492
1475 /* 1493 /*
1476 * Save the configuration each half hour. 1494 * Save the configuration each half hour.
1477 */ 1495 */
1478 if ((minutes == 15) || (minutes == 45)) 1496 if ((minutes == 15) || (minutes == 45))

mercurial