diff -r 78242696c15a -r f84501d8dd87 brewco/brewco.c --- a/brewco/brewco.c Fri Dec 11 15:52:37 2015 +0100 +++ b/brewco/brewco.c Sat Dec 12 19:31:35 2015 +0100 @@ -107,7 +107,7 @@ -void tempstatus(float hlttemp, float mlttemp) +void tempstatus(double hlttemp, double mlttemp) { char text[81]; @@ -132,10 +132,10 @@ -int manual_menu(units_list *); -int manual_menu(units_list *unit) +int manual_menu(units_list *, double, double); +int manual_menu(units_list *unit, double hlt, double mlt) { - int key; + int key, i; static int man_hlt_heat, man_mlt_heat, man_mlt_pump; switch (manual) { @@ -177,8 +177,15 @@ break; case MANUAL_HLT: prompt(104, NULL); prompt(413, NULL); - - key = keywait(); + tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); + + for (i = 1; i < 100; i++) { + usleep(10000); + slcdDummy(slcdHandle); + key = keycheck(); + if ((key != KEY_NONE) || my_shutdown) + break; + } if (key == KEY_RETURN) { if (man_hlt_heat) man_hlt_heat = 0; @@ -195,7 +202,15 @@ break; case MANUAL_MLT: prompt(104, NULL); prompt(406, NULL); - key = keywait(); + tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); + + for (i = 1; i < 100; i++) { + usleep(10000); + slcdDummy(slcdHandle); + key = keycheck(); + if ((key != KEY_NONE) || my_shutdown) + break; + } if (key == KEY_RETURN) { if (man_mlt_heat) man_mlt_heat = 0; @@ -225,14 +240,13 @@ int server(void); int server(void) { - int rc = 0, run = 1, key; + int rc = 0, run = 1, key, temp; int do_init = TRUE, seconds = 0, minutes = 0; units_list *unit; brew_session *brew = NULL; #ifndef HAVE_WIRINGPI_H long t = 0; #endif - struct tm *tm; time_t now, last = (time_t)0; static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint; @@ -426,7 +440,32 @@ */ last = now; seconds++; -fprintf(stdout, "1 second %ld millis\n", millis()); + if (seconds > 59) { + seconds = 0; + minutes++; + } + +fprintf(stdout, "%d seconds %d minutes %ld millis\n", seconds, minutes, millis()); + + rc = device_in(unit->hlt_sensor.uuid, &temp); + if (rc == DEVPRESENT_YES) { + hltInput = temp / 1000.0; + unit->hlt_sensor.state = 0; + } else if (rc == DEVPRESENT_ERROR) { + unit->hlt_sensor.state = 1; + } else { + unit->hlt_sensor.state = 2; + } + rc = device_in(unit->mlt_sensor.uuid, &temp); + if (rc == DEVPRESENT_YES) { + mltInput = temp / 1000.0; + unit->mlt_sensor.state = 0; + } else if (rc == DEVPRESENT_ERROR) { + unit->mlt_sensor.state = 1; + } else { + unit->mlt_sensor.state = 2; + } + if (debug && ((seconds % 10) == 1)) { fprintf(stdout, "MLT: In=%.2lf Out=%.2lf Set=%.2lf HLT: In=%.2lf Out=%.2lf Set=%.2lf\n", mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint); @@ -443,7 +482,7 @@ /* * Manual mode */ - manual_menu(unit); + manual_menu(unit, hltInput, mltInput); if (manual == MANUAL_NONE) { /* * Rewrite the display @@ -456,7 +495,7 @@ /* * Not running. */ - tempstatus(120.3, 165.34); + tempstatus(hltInput, mltInput); key = keycheck(); if (key == KEY_ENTER) { setup();