1434 } |
1434 } |
1435 |
1435 |
1436 if ((unit->heater_address || unit->cooler_address) && unit->fan_address) { |
1436 if ((unit->heater_address || unit->cooler_address) && unit->fan_address) { |
1437 /* |
1437 /* |
1438 * If there is a heater or cooler and we have a fan, turn fan on if |
1438 * If there is a heater or cooler and we have a fan, turn fan on if |
1439 * cooling or heating. |
1439 * cooling or heating. The Fan has a start/stop delay. |
1440 */ |
1440 */ |
1441 if ((unit->heater_address && unit->heater_state) || (unit->cooler_address && unit->cooler_state)) { |
1441 if ((unit->heater_address && unit->heater_state) || (unit->cooler_address && unit->cooler_state)) { |
1442 if (! unit->fan_state) |
1442 if (unit->fan_wait < unit->fan_delay) { |
1443 syslog(LOG_NOTICE, "Fan Off => On"); |
1443 unit->fan_wait++; |
1444 unit->fan_state = 100; |
1444 syslog(LOG_NOTICE, "fan_wait + %d/%d", unit->fan_wait, unit->fan_delay); |
|
1445 } else { |
|
1446 if (! unit->fan_state) { |
|
1447 syslog(LOG_NOTICE, "Fan Off => On"); |
|
1448 unit->fan_state = 100; |
|
1449 } |
|
1450 } |
1445 } else { |
1451 } else { |
1446 if (unit->fan_state) |
1452 if (unit->fan_wait > 0) { |
1447 syslog(LOG_NOTICE, "Fan On => Off"); |
1453 unit->fan_wait--; |
1448 unit->fan_state = 0; |
1454 syslog(LOG_NOTICE, "fan_wait - %d/%d", unit->fan_wait, unit->fan_delay); |
|
1455 } else { |
|
1456 if (unit->fan_state) { |
|
1457 syslog(LOG_NOTICE, "Fan On => Off"); |
|
1458 unit->fan_state = 0; |
|
1459 } |
|
1460 } |
1449 } |
1461 } |
1450 device_out(unit->fan_address, unit->fan_state); |
1462 device_out(unit->fan_address, unit->fan_state); |
1451 } |
1463 } |
1452 |
1464 |
1453 } else { |
1465 } else { |
1454 P_err = 0.0; |
1466 P_err = 0.0; |
1455 unit->PID_iState = 0.0; |
1467 unit->PID_iState = 0.0; |
1456 unit->PID_dState = 0.0; |
1468 unit->PID_dState = 0.0; |
1457 } |
1469 } /* fridge beer or profile mode */ |
1458 } |
1470 } /* for units */ |
1459 |
1471 |
1460 #ifdef HAVE_WIRINGPI_H |
1472 #ifdef HAVE_WIRINGPI_H |
1461 piLock(LOCK_MENU); |
1473 piLock(LOCK_MENU); |
1462 if (setupmenu == MENU_NONE) { |
1474 if (setupmenu == MENU_NONE) { |
1463 piLock(LOCK_LCD); |
1475 piLock(LOCK_LCD); |