brewco/brewco.c

changeset 455
f84501d8dd87
parent 454
78242696c15a
child 456
045db83dd013
equal deleted inserted replaced
454:78242696c15a 455:f84501d8dd87
105 my_shutdown = TRUE; 105 my_shutdown = TRUE;
106 } 106 }
107 107
108 108
109 109
110 void tempstatus(float hlttemp, float mlttemp) 110 void tempstatus(double hlttemp, double mlttemp)
111 { 111 {
112 char text[81]; 112 char text[81];
113 113
114 snprintf(text, 7, "%5.1f\001", hlttemp); 114 snprintf(text, 7, "%5.1f\001", hlttemp);
115 #ifdef HAVE_WIRINGPI_H 115 #ifdef HAVE_WIRINGPI_H
130 slcdPuts(slcdHandle, text); 130 slcdPuts(slcdHandle, text);
131 } 131 }
132 132
133 133
134 134
135 int manual_menu(units_list *); 135 int manual_menu(units_list *, double, double);
136 int manual_menu(units_list *unit) 136 int manual_menu(units_list *unit, double hlt, double mlt)
137 { 137 {
138 int key; 138 int key, i;
139 static int man_hlt_heat, man_mlt_heat, man_mlt_pump; 139 static int man_hlt_heat, man_mlt_heat, man_mlt_pump;
140 140
141 switch (manual) { 141 switch (manual) {
142 case MANUAL_SELHLT: prompt(104, NULL); 142 case MANUAL_SELHLT: prompt(104, NULL);
143 prompt(219, NULL); 143 prompt(219, NULL);
175 device_out(unit->mlt_pump.uuid, man_mlt_pump); 175 device_out(unit->mlt_pump.uuid, man_mlt_pump);
176 } 176 }
177 break; 177 break;
178 case MANUAL_HLT: prompt(104, NULL); 178 case MANUAL_HLT: prompt(104, NULL);
179 prompt(413, NULL); 179 prompt(413, NULL);
180 180 tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput);
181 key = keywait(); 181
182 for (i = 1; i < 100; i++) {
183 usleep(10000);
184 slcdDummy(slcdHandle);
185 key = keycheck();
186 if ((key != KEY_NONE) || my_shutdown)
187 break;
188 }
182 if (key == KEY_RETURN) { 189 if (key == KEY_RETURN) {
183 if (man_hlt_heat) 190 if (man_hlt_heat)
184 man_hlt_heat = 0; 191 man_hlt_heat = 0;
185 else 192 else
186 man_hlt_heat = 1; 193 man_hlt_heat = 1;
193 if (debug) 200 if (debug)
194 fprintf(stdout, "device_out(%s, %d) HLT heater\n", unit->hlt_heater.uuid, man_hlt_heat); 201 fprintf(stdout, "device_out(%s, %d) HLT heater\n", unit->hlt_heater.uuid, man_hlt_heat);
195 break; 202 break;
196 case MANUAL_MLT: prompt(104, NULL); 203 case MANUAL_MLT: prompt(104, NULL);
197 prompt(406, NULL); 204 prompt(406, NULL);
198 key = keywait(); 205 tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput);
206
207 for (i = 1; i < 100; i++) {
208 usleep(10000);
209 slcdDummy(slcdHandle);
210 key = keycheck();
211 if ((key != KEY_NONE) || my_shutdown)
212 break;
213 }
199 if (key == KEY_RETURN) { 214 if (key == KEY_RETURN) {
200 if (man_mlt_heat) 215 if (man_mlt_heat)
201 man_mlt_heat = 0; 216 man_mlt_heat = 0;
202 else 217 else
203 man_mlt_heat = 1; 218 man_mlt_heat = 1;
223 238
224 239
225 int server(void); 240 int server(void);
226 int server(void) 241 int server(void)
227 { 242 {
228 int rc = 0, run = 1, key; 243 int rc = 0, run = 1, key, temp;
229 int do_init = TRUE, seconds = 0, minutes = 0; 244 int do_init = TRUE, seconds = 0, minutes = 0;
230 units_list *unit; 245 units_list *unit;
231 brew_session *brew = NULL; 246 brew_session *brew = NULL;
232 #ifndef HAVE_WIRINGPI_H 247 #ifndef HAVE_WIRINGPI_H
233 long t = 0; 248 long t = 0;
234 #endif 249 #endif
235 struct tm *tm;
236 time_t now, last = (time_t)0; 250 time_t now, last = (time_t)0;
237 static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint; 251 static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint;
238 252
239 prompt(101, NULL); 253 prompt(101, NULL);
240 254
424 /* 438 /*
425 * Each second 439 * Each second
426 */ 440 */
427 last = now; 441 last = now;
428 seconds++; 442 seconds++;
429 fprintf(stdout, "1 second %ld millis\n", millis()); 443 if (seconds > 59) {
444 seconds = 0;
445 minutes++;
446 }
447
448 fprintf(stdout, "%d seconds %d minutes %ld millis\n", seconds, minutes, millis());
449
450 rc = device_in(unit->hlt_sensor.uuid, &temp);
451 if (rc == DEVPRESENT_YES) {
452 hltInput = temp / 1000.0;
453 unit->hlt_sensor.state = 0;
454 } else if (rc == DEVPRESENT_ERROR) {
455 unit->hlt_sensor.state = 1;
456 } else {
457 unit->hlt_sensor.state = 2;
458 }
459 rc = device_in(unit->mlt_sensor.uuid, &temp);
460 if (rc == DEVPRESENT_YES) {
461 mltInput = temp / 1000.0;
462 unit->mlt_sensor.state = 0;
463 } else if (rc == DEVPRESENT_ERROR) {
464 unit->mlt_sensor.state = 1;
465 } else {
466 unit->mlt_sensor.state = 2;
467 }
468
430 if (debug && ((seconds % 10) == 1)) { 469 if (debug && ((seconds % 10) == 1)) {
431 fprintf(stdout, "MLT: In=%.2lf Out=%.2lf Set=%.2lf HLT: In=%.2lf Out=%.2lf Set=%.2lf\n", 470 fprintf(stdout, "MLT: In=%.2lf Out=%.2lf Set=%.2lf HLT: In=%.2lf Out=%.2lf Set=%.2lf\n",
432 mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint); 471 mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint);
433 } 472 }
434 473
441 480
442 } else if (manual != MANUAL_NONE) { 481 } else if (manual != MANUAL_NONE) {
443 /* 482 /*
444 * Manual mode 483 * Manual mode
445 */ 484 */
446 manual_menu(unit); 485 manual_menu(unit, hltInput, mltInput);
447 if (manual == MANUAL_NONE) { 486 if (manual == MANUAL_NONE) {
448 /* 487 /*
449 * Rewrite the display 488 * Rewrite the display
450 */ 489 */
451 prompt(0, NULL); 490 prompt(0, NULL);
454 } 493 }
455 } else { 494 } else {
456 /* 495 /*
457 * Not running. 496 * Not running.
458 */ 497 */
459 tempstatus(120.3, 165.34); 498 tempstatus(hltInput, mltInput);
460 key = keycheck(); 499 key = keycheck();
461 if (key == KEY_ENTER) { 500 if (key == KEY_ENTER) {
462 setup(); 501 setup();
463 prompt(0, NULL); 502 prompt(0, NULL);
464 prompt(101, NULL); 503 prompt(101, NULL);

mercurial