# HG changeset patch # User Michiel Broek # Date 1427896564 -7200 # Node ID ffc4b8aa824f0d73eeb02b0bc9816bc30cc537e3 # Parent 0ab5c3fd7c77c239b69a123a2cf06e083eaaf9a4 Changed Fan switch logic. diff -r 0ab5c3fd7c77 -r ffc4b8aa824f thermferm/devices.c --- a/thermferm/devices.c Wed Apr 01 15:20:05 2015 +0200 +++ b/thermferm/devices.c Wed Apr 01 15:56:04 2015 +0200 @@ -339,9 +339,9 @@ } if ((write_w1(device->address, (char *)"output", output)) == 0) { - syslog(LOG_NOTICE, "DS2413 PIO%c value=%d", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1); + syslog(LOG_NOTICE, "DS2413 PIO%c value=%d (%s)", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment); if (debug) - fprintf(stdout, "DS2413 PIO%c value=%d\n", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1); + fprintf(stdout, "DS2413 PIO%c value=%d (%s)\n", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment); device->value = (value == 0) ? 0 : 1; device->timestamp = time(NULL); } diff -r 0ab5c3fd7c77 -r ffc4b8aa824f thermferm/thermferm.c --- a/thermferm/thermferm.c Wed Apr 01 15:20:05 2015 +0200 +++ b/thermferm/thermferm.c Wed Apr 01 15:56:04 2015 +0200 @@ -1432,16 +1432,13 @@ } device_out(unit->cooler_address, unit->cooler_state); } - if (unit->heater_address && unit->cooler_address && unit->fan_address) { + + if ((unit->heater_address || unit->cooler_address) && unit->fan_address) { /* - * If the temperature difference between air and beer is more then - * xxx degrees, turn the fan on to make an airflow. - * Maybe, run the fan too if the heater is on because the heater in - * most cases will be some sort of radiating heat device. - * For cooling ??? dunno yet. + * If there is a heater or cooler and we have a fan, turn fan on if + * cooling or heating. */ - if (((unit->air_temperature - unit->beer_temperature) > 1000) || - ((unit->air_temperature - unit->beer_temperature) < -1000)) { + 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; @@ -1452,6 +1449,7 @@ } device_out(unit->fan_address, unit->fan_state); } + } else { P_err = 0.0; unit->PID_iState = 0.0;