thermferm/thermferm.c

changeset 188
4fc17ef4593f
parent 185
4f34271cf1e7
child 189
cc2b04d4db99
equal deleted inserted replaced
187:3c8bf18fdf42 188:4fc17ef4593f
352 352
353 for (unit = Config.units; unit; unit = unit->next) { 353 for (unit = Config.units; unit; unit = unit->next) {
354 #ifdef HAVE_WIRINGPI_H 354 #ifdef HAVE_WIRINGPI_H
355 lcd_buf_write(row++, "Unit %s ", unit->name); 355 lcd_buf_write(row++, "Unit %s ", unit->name);
356 lcd_buf_write(row++, "Mode %s ", UNITMODE[unit->mode]); 356 lcd_buf_write(row++, "Mode %s ", UNITMODE[unit->mode]);
357 if (unit->air_address) {
358 lcd_buf_write(row++, " Air %.3f %cC ", unit->air_temperature / 1000.0, 0xdf);
359 }
360 if (unit->beer_address) {
361 lcd_buf_write(row++, "Beer %.3f %cC ", unit->beer_temperature / 1000.0, 0xdf);
362 }
363 #endif 357 #endif
364 358
365 if (unit->air_address) { 359 if (unit->air_address) {
366 rc = read_w1_28(unit->air_address, &temp); 360 rc = read_w1_28(unit->air_address, &temp);
367 if (rc == DEVPRESENT_YES) { 361 if (rc == DEVPRESENT_YES) {
376 deviation = 40000; 370 deviation = 40000;
377 if ((unit->air_temperature == 0) || 371 if ((unit->air_temperature == 0) ||
378 (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { 372 (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) {
379 unit->air_temperature = temp; 373 unit->air_temperature = temp;
380 unit->air_state = 0; 374 unit->air_state = 0;
375 #ifdef HAVE_WIRINGPI_H
376 lcd_buf_write(row++, " Air %.3f %cC ", unit->air_temperature / 1000.0, 0xdf);
377 #endif
381 } else { 378 } else {
382 syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp); 379 syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp);
383 if (debug) { 380 if (debug) {
384 fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->air_temperature, temp); 381 fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->air_temperature, temp);
385 } 382 }
397 deviation = 40000; 394 deviation = 40000;
398 if ((unit->beer_temperature == 0) || 395 if ((unit->beer_temperature == 0) ||
399 (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { 396 (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) {
400 unit->beer_temperature = temp; 397 unit->beer_temperature = temp;
401 unit->beer_state = 0; 398 unit->beer_state = 0;
399 #ifdef HAVE_WIRINGPI_H
400 lcd_buf_write(row++, "Beer %.3f %cC ", unit->beer_temperature / 1000.0, 0xdf);
401 #endif
402 } else { 402 } else {
403 syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp); 403 syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp);
404 if (debug) { 404 if (debug) {
405 fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->beer_temperature, temp); 405 fprintf(stdout, "deviation error deviation=%d, old=%d new=%d\n", deviation, unit->beer_temperature, temp);
406 } 406 }
418 if (unit->mode == UNITMODE_NONE) { 418 if (unit->mode == UNITMODE_NONE) {
419 device_out(unit->heater_address, unit->heater_state); 419 device_out(unit->heater_address, unit->heater_state);
420 device_out(unit->cooler_address, unit->cooler_state); 420 device_out(unit->cooler_address, unit->cooler_state);
421 device_out(unit->fan_address, unit->fan_state); 421 device_out(unit->fan_address, unit->fan_state);
422 } 422 }
423 #ifdef HAVE_WIRINGPI_H
424 if (unit->heater_address) {
425 lcd_buf_write(row++, "Heater %s ", unit->heater_state ? "On ":"Off");
426 }
427 if (unit->cooler_address) {
428 lcd_buf_write(row++, "Cooler %s ", unit->cooler_state ? "On ":"Off");
429 }
430 #endif
423 } 431 }
424 432
425 #ifdef HAVE_WIRINGPI_H 433 #ifdef HAVE_WIRINGPI_H
426 lcd_buf_show(); 434 lcd_buf_show();
427 #endif 435 #endif

mercurial