main/automation.c

changeset 19
49e2960d4642
parent 1
ad2c8b13eb88
child 24
bb3d6e22e78b
equal deleted inserted replaced
18:5d4a40fe9967 19:49e2960d4642
50 50
51 #ifdef CONFIG_TEMP_SENSORS_SIMULATOR 51 #ifdef CONFIG_TEMP_SENSORS_SIMULATOR
52 extern float Fake_MLT; 52 extern float Fake_MLT;
53 extern float Fake_HLT; 53 extern float Fake_HLT;
54 #endif 54 #endif
55
56 extern const char *mashTypes[];
55 57
56 static const char *TAG = "automation"; 58 static const char *TAG = "automation";
57 59
58 60
59 /* 61 /*
391 ShowFloat(2, y, "Maisch in", " C", recipe.MashStep[0].Temperature, 2); 393 ShowFloat(2, y, "Maisch in", " C", recipe.MashStep[0].Temperature, 2);
392 ShowFloat(162, y, "Spoelwater", " C", recipe.SpargeTemp, 2); 394 ShowFloat(162, y, "Spoelwater", " C", recipe.SpargeTemp, 2);
393 y += 16; 395 y += 16;
394 _fg = TFT_WHITE; 396 _fg = TFT_WHITE;
395 TFT_print("Maisch stap", 2, y); 397 TFT_print("Maisch stap", 2, y);
396 TFT_print("Temp.", 200, y); 398 TFT_print("T", 200, y);
397 TFT_print("Rust", 260, y); 399 TFT_print("Temp.", 220, y);
400 TFT_print("Rust", 280, y);
398 _fg = TFT_YELLOW; 401 _fg = TFT_YELLOW;
399 y += 16; 402 y += 16;
400 for (int i = 1; i < 8; i++) { 403 for (int i = 1; i < 8; i++) {
401 if (recipe.MashStep[i].Resttime) { 404 if (recipe.MashStep[i].Resttime) {
402 TFT_print(recipe.MashStep[i].Name, 2, y); 405 TFT_print(recipe.MashStep[i].Name, 2, y);
406 strcpy(tmp, mashTypes[recipe.MashStep[i].Type]);
407 tmp[1] = '\0';
408 TFT_print(tmp, 200, y);
403 sprintf(tmp, "%.2f", recipe.MashStep[i].Temperature); 409 sprintf(tmp, "%.2f", recipe.MashStep[i].Temperature);
404 TFT_print(tmp, 200, y); 410 TFT_print(tmp, 220, y);
405 sprintf(tmp, "%2d min", recipe.MashStep[i].Resttime); 411 sprintf(tmp, "%2d m", recipe.MashStep[i].Resttime);
406 TFT_print(tmp, 260, y); 412 TFT_print(tmp, 280, y);
407 y += 16; 413 y += 16;
408 } 414 }
409 } 415 }
410 ShowInteger(2, y, "Kooktijd", " miniuten", recipe.BoilTime); 416 ShowInteger(2, y, "Kooktijd", " min", recipe.BoilTime);
417 ShowFloat(162, y, "Koel tot", " C", recipe.CoolTemp, 2);
411 y += 16; 418 y += 16;
412 if (recipe.Additions) { 419 if (recipe.Additions) {
413 _fg = TFT_YELLOW; 420 _fg = TFT_YELLOW;
414 sprintf(tmp, "%d ", recipe.Additions); 421 sprintf(tmp, "%d ", recipe.Additions);
415 TFT_print(tmp, 2, y); 422 TFT_print(tmp, 2, y);
425 } else { 432 } else {
426 _fg = TFT_WHITE; 433 _fg = TFT_WHITE;
427 TFT_print("Geen hop toevoegingen.", 2, y); 434 TFT_print("Geen hop toevoegingen.", 2, y);
428 } 435 }
429 y += 16; 436 y += 16;
430 ShowFloat(2, y, "Koelen tot", " C", recipe.CoolTemp, 2);
431 if (recipe.Whirlpool9) { 437 if (recipe.Whirlpool9) {
432 ShowInteger(2, y, "Whirlpool 88..100 graden", " minuten", recipe.Whirlpool9); 438 ShowInteger(2, y, "Whirlpool 88..100 graden", " minuten", recipe.Whirlpool9);
433 y += 16; 439 y += 16;
434 } 440 }
435 if (recipe.Whirlpool7) { 441 if (recipe.Whirlpool7) {
591 driver_state->mlt_sp = stageTemp; 597 driver_state->mlt_sp = stageTemp;
592 driver_state->mlt_mode = MLT_MODE_PID; 598 driver_state->mlt_mode = MLT_MODE_PID;
593 xSemaphoreGive(xSemaphoreDriver); 599 xSemaphoreGive(xSemaphoreDriver);
594 } 600 }
595 MashState = MASH_WAITTEMP; 601 MashState = MASH_WAITTEMP;
596 ESP_LOGI(TAG, "Mash step %d time: %d temp: %4.1f min: %4.1f max: %4.1f", 602 ESP_LOGI(TAG, "Mash step %d type: %s time: %d temp: %4.1f min: %4.1f max: %4.1f",
597 Main_Screen - MAIN_AUTO_MASH_IN, stageTime, stageTemp, MinMash, MaxMash); 603 Main_Screen - MAIN_AUTO_MASH_IN, mashTypes[recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Type],
604 stageTime, stageTemp, MinMash, MaxMash);
598 605
599 if (Main_Screen > MAIN_AUTO_MASH_IN) { 606 if (Main_Screen > MAIN_AUTO_MASH_IN) {
600 // Do not annotate before the log is open. 607 // Do not annotate before the log is open.
601 if (Main_Screen == MAIN_AUTO_MASH_OUT) { 608 if (Main_Screen == MAIN_AUTO_MASH_OUT) {
602 log_annotation(ANNOTATION_STAGE, "Uitmaischen"); 609 log_annotation(ANNOTATION_STAGE, "Uitmaischen");
610 TopMessage(recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Name); 617 TopMessage(recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Name);
611 } else { 618 } else {
612 sprintf(temp_buf, "Maisch stap #%d", Main_Screen - MAIN_AUTO_MASH_IN); 619 sprintf(temp_buf, "Maisch stap #%d", Main_Screen - MAIN_AUTO_MASH_IN);
613 TopMessage(temp_buf); 620 TopMessage(temp_buf);
614 } 621 }
615 Buttons_Add( 5, 30, 60, 40, "+sp", 0); 622 if ((Main_Screen > MAIN_AUTO_MASH_IN) && (Main_Screen < MAIN_AUTO_MASH_OUT) &&
616 Buttons_Add(255, 30, 60, 40, "-sp", 1); 623 (recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Type == MASHTYPE_INFUSION)) {
617 Buttons_Show(); 624 Buttons_Add( 5,120, 60, 40, "Halt", 0);
625 Buttons[0].dark = true;
626 Buttons_Add(255,120, 60, 40, "Ok", 1);
627 Buttons_Show();
628 _fg = TFT_WHITE;
629 _bg = TFT_BLACK;
630 TFT_setFont(DEJAVU18_FONT, NULL);
631 sprintf(temp_buf, "Infuse %.1f L/%.1f C", recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Infusion_amount,
632 recipe.MashStep[Main_Screen - MAIN_AUTO_MASH_IN].Infusion_temp);
633 TFT_print(temp_buf, CENTER, 135);
634 SoundPlay(SOUND_Prompt);
635 MashState = MASH_INFUSE;
636 if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) {
637 // No heating during the infusion.
638 driver_state->mlt_sp = stageTemp;
639 driver_state->mlt_mode = MLT_MODE_OFF;
640 xSemaphoreGive(xSemaphoreDriver);
641 }
642 ESP_LOGI(TAG, "Mash infusion prompt");
643 } else {
644 Buttons_Add( 5, 30, 60, 40, "+sp", 0);
645 Buttons_Add(255, 30, 60, 40, "-sp", 1);
646 Buttons_Show();
647 }
618 648
619 } else if (MashState == MASH_WAITTEMP) { 649 } else if (MashState == MASH_WAITTEMP) {
620 pumpRest = false; 650 pumpRest = false;
621 if (temp_MLT < stageTemp) { 651 if (temp_MLT < stageTemp) {
622 Steady = 0; 652 Steady = 0;
815 break; 845 break;
816 case 1: Main_Screen++; 846 case 1: Main_Screen++;
817 break; 847 break;
818 default: break; 848 default: break;
819 } 849 }
850 } else if (MashState == MASH_INFUSE) {
851 switch (Buttons_Scan()) {
852 case 0: Main_Screen = MAIN_AUTO_ABORT;
853 break;
854 case 1: MashState = MASH_WAITTEMP;
855 if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) {
856 // Start PID again.
857 driver_state->mlt_sp = stageTemp;
858 driver_state->mlt_mode = MLT_MODE_PID;
859 xSemaphoreGive(xSemaphoreDriver);
860 }
861 Buttons_Clear();
862 Buttons_Add( 5, 30, 60, 40, "+sp", 0);
863 Buttons_Add(255, 30, 60, 40, "-sp", 1);
864 Buttons_Show();
865 TFT_fillRect(65, 120, 190, 40, TFT_BLACK);
866 break;
867 default: break;
868 }
820 } /* MashState */ 869 } /* MashState */
821 MLT_info(71, 26, true); 870 MLT_info(71, 26, true);
822 if (_UseHLT) { 871 if (_UseHLT) {
823 HLT_info(71, 170, true, true); 872 HLT_info(71, 170, true, true);
824 } 873 }

mercurial