# HG changeset patch # User Michiel Broek # Date 1427902106 -7200 # Node ID 1f89da6511a93f3f006b52fa923252509001d946 # Parent ffc4b8aa824f0d73eeb02b0bc9816bc30cc537e3 Added Fan delay logic. diff -r ffc4b8aa824f -r 1f89da6511a9 thermferm/thermferm.c --- a/thermferm/thermferm.c Wed Apr 01 15:56:04 2015 +0200 +++ b/thermferm/thermferm.c Wed Apr 01 17:28:26 2015 +0200 @@ -1436,16 +1436,28 @@ if ((unit->heater_address || unit->cooler_address) && unit->fan_address) { /* * If there is a heater or cooler and we have a fan, turn fan on if - * cooling or heating. + * cooling or heating. The Fan has a start/stop delay. */ if ((unit->heater_address && unit->heater_state) || (unit->cooler_address && unit->cooler_state)) { - if (! unit->fan_state) - syslog(LOG_NOTICE, "Fan Off => On"); - unit->fan_state = 100; + if (unit->fan_wait < unit->fan_delay) { + unit->fan_wait++; + syslog(LOG_NOTICE, "fan_wait + %d/%d", unit->fan_wait, unit->fan_delay); + } else { + if (! unit->fan_state) { + syslog(LOG_NOTICE, "Fan Off => On"); + unit->fan_state = 100; + } + } } else { - if (unit->fan_state) - syslog(LOG_NOTICE, "Fan On => Off"); - unit->fan_state = 0; + if (unit->fan_wait > 0) { + unit->fan_wait--; + syslog(LOG_NOTICE, "fan_wait - %d/%d", unit->fan_wait, unit->fan_delay); + } else { + if (unit->fan_state) { + syslog(LOG_NOTICE, "Fan On => Off"); + unit->fan_state = 0; + } + } } device_out(unit->fan_address, unit->fan_state); } @@ -1454,8 +1466,8 @@ P_err = 0.0; unit->PID_iState = 0.0; unit->PID_dState = 0.0; - } - } + } /* fridge beer or profile mode */ + } /* for units */ #ifdef HAVE_WIRINGPI_H piLock(LOCK_MENU); diff -r ffc4b8aa824f -r 1f89da6511a9 www-thermferm/getstate.php --- a/www-thermferm/getstate.php Wed Apr 01 15:56:04 2015 +0200 +++ b/www-thermferm/getstate.php Wed Apr 01 17:28:26 2015 +0200 @@ -39,7 +39,7 @@ $led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = ""; $fridge_set = "NA"; $beer_set = "NA"; -$heater = $cooler = $fan = "no"; +$heater = $cooler = $fan = $psu = $door = "no"; $prof_state = "OFF"; @@ -78,6 +78,10 @@ $fan_state = $f[1]; $led3 = $f[1] ? '
' : '
'; } + if (($f[0] == "PSU_ADDRESS") && (strcmp($f[1], "(null)"))) + $psu = "yes"; + if (($f[0] == "DOOR_ADDRESS") && (strcmp($f[1], "(null)"))) + $door = "yes"; if (($f[0] == "BEER_SET") && ($mode == "BEER")) $target_temperature = $f[1]; if (($f[0] == "FRIDGE_SET") && ($mode == "FRIDGE")) diff -r ffc4b8aa824f -r 1f89da6511a9 www-thermferm/units.php --- a/www-thermferm/units.php Wed Apr 01 15:56:04 2015 +0200 +++ b/www-thermferm/units.php Wed Apr 01 17:28:26 2015 +0200 @@ -99,6 +99,7 @@ $cmd[] = "COOLER_ADDRESS,".$_POST['CoolerAddress']; $cmd[] = "COOLER_DELAY,".$_POST['CoolerDelay']; $cmd[] = "FAN_ADDRESS,".$_POST['FanAddress']; + $cmd[] = "FAN_DELAY,".$_POST['FanDelay']; $cmd[] = "LIGHT_ADDRESS,".$_POST['LightAddress']; $cmd[] = "LIGHT_DELAY,".$_POST['LightDelay']; $cmd[] = "DOOR_ADDRESS,".$_POST['DoorAddress']; @@ -128,6 +129,7 @@ unset($_POST['LightAddress']); unset($_POST['LightDelay']); unset($_POST['FanAddress']); + unset($_POST['FanDelay']); unset($_POST['DoorAddress']); unset($_POST['PSUAddress']); unset($_POST['TempSetMin']); @@ -162,6 +164,7 @@ * 9 = IdleRangeL out of range * 10 = IdleRangeH out of range * 11 = LightDelay out of range + * 12 = FanDelay out of range * 99 = Cancel key */ function test_thedata() { @@ -172,7 +175,7 @@ isset($_POST['BeerAddress']) && isset($_POST['HeaterAddress']) && isset($_POST['CoolerAddress']) && isset($_POST['LightAddress']) && isset($_POST['HeaterDelay']) && isset($_POST['CoolerDelay']) && isset($_POST['LightDelay']) && isset($_POST['PSUAddress']) && isset($_POST['FanAddress']) && isset($_POST['DoorAddress']) && isset($_POST['TempSetMin']) && isset($_POST['TempSetMax']) && - isset($_POST['PID_Kp']) && isset($_POST['PID_Kd']) && isset($_POST['PID_Ki']) && + isset($_POST['PID_Kp']) && isset($_POST['PID_Kd']) && isset($_POST['PID_Ki']) && isset($_POST['FanDelay']) && isset($_POST['IdleRangeL']) && isset($_POST['IdleRangeH']) && isset($_POST['key']) && isset($_POST['command'])) { if ($_POST['key'] == 'Cancel') @@ -218,6 +221,9 @@ if (($_POST['LightDelay'] < 0) || ($_POST['LightDelay'] > 720)) return 11; + if (($_POST['FanDelay'] < 0) || ($_POST['FanDelay'] > 720)) + return 12; + } else { return 1; } @@ -266,6 +272,8 @@ break; case 11: $error = 'Light Delay must be bewteen 0 and 720 seconds'; break; + case 12: $error = 'Fan Delay must be bewteen 0 and 720 seconds'; + break; case 99: load('units.php'); break; @@ -448,6 +456,12 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; } + if ($f[0] == "FAN_DELAY") { + $outstr .= ' '.PHP_EOL; + $outstr .= ' Fan Switch Delay'.PHP_EOL; + $outstr .= ' seconds (0..720)'.PHP_EOL; + $outstr .= ' '.PHP_EOL; + } if ($f[0] == "LIGHT_ADDRESS") { $outstr .= ' '.PHP_EOL; $outstr .= ' Lights Address'.PHP_EOL;