main/automation.c

changeset 126
e133a292ad21
parent 121
30aca5888d2b
equal deleted inserted replaced
125:d2a33b279b11 126:e133a292ad21
654 xSemaphoreGive(xSemaphoreDriver); 654 xSemaphoreGive(xSemaphoreDriver);
655 } 655 }
656 if (MashState == MASH_NONE) { 656 if (MashState == MASH_NONE) {
657 if (runtime.MashStep == 0 && ! runtime.MaltAdded && recipe.MashStep[0].Infuse_temp) { 657 if (runtime.MashStep == 0 && ! runtime.MaltAdded && recipe.MashStep[0].Infuse_temp) {
658 stageTemp = recipe.MashStep[0].Infuse_temp; 658 stageTemp = recipe.MashStep[0].Infuse_temp;
659 } else { 659 } else if (recipe.MashStep[runtime.MashStep].Type != MASHTYPE_DECOCTION) {
660 /* Only change temperature if not doing decoction */
660 stageTemp = recipe.MashStep[runtime.MashStep].Step_temp; 661 stageTemp = recipe.MashStep[runtime.MashStep].Step_temp;
661 } 662 }
662 stageTime = recipe.MashStep[runtime.MashStep].Step_time; 663 stageTime = recipe.MashStep[runtime.MashStep].Step_time;
663 TempReached = false; 664 TempReached = false;
664 if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { 665 if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) {
669 MashState = Sub_Screen = MASH_WAITTEMP; 670 MashState = Sub_Screen = MASH_WAITTEMP;
670 snprintf(msg, 255, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); 671 snprintf(msg, 255, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen);
671 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); 672 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg));
672 log_msg(TAG, "Mash step %d type: %s time: %d sp: %6.4f-%6.4f sv: %6.4f", 673 log_msg(TAG, "Mash step %d type: %s time: %d sp: %6.4f-%6.4f sv: %6.4f",
673 runtime.MashStep, mashTypes[recipe.MashStep[runtime.MashStep].Type], 674 runtime.MashStep, mashTypes[recipe.MashStep[runtime.MashStep].Type],
674 stageTime, stageTemp, recipe.MashStep[runtime.MashStep].End_temp, temp_MLT); 675 stageTime, recipe.MashStep[runtime.MashStep].Step_temp, recipe.MashStep[runtime.MashStep].End_temp, temp_MLT);
675 676
676 if (runtime.MashStep) { 677 if (runtime.MashStep) {
677 // Do not annotate before the log is open. 678 // Do not annotate before the log is open.
678 if (runtime.MashStep == (recipe.Mashsteps -1)) { 679 if (runtime.MashStep == (recipe.Mashsteps -1)) {
679 log_annotation(ANNOTATION_STAGE, (char *)"Uitmaischen"); 680 log_annotation(ANNOTATION_STAGE, (char *)"Uitmaischen");
967 case 0: Main_Screen = MAIN_AUTO_ABORT; 968 case 0: Main_Screen = MAIN_AUTO_ABORT;
968 break; 969 break;
969 case 1: 970 case 1:
970 #ifdef CONFIG_TEMP_SENSORS_SIMULATOR 971 #ifdef CONFIG_TEMP_SENSORS_SIMULATOR
971 if (MashState == MASH_DECOCT) { 972 if (MashState == MASH_DECOCT) {
972 Fake_MLT = recipe.MashStep[runtime.MashStep].Step_temp - 0.72; // Fake the decoction amt. 973 temp_MLT = Fake_MLT = recipe.MashStep[runtime.MashStep].Step_temp - 0.72; // Fake the decoction amt.
973 if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) { 974 if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) {
974 ds18b20_state->mlt_temperature = ((int)(Fake_MLT * 16)) / 16.0; 975 ds18b20_state->mlt_temperature = ((int)(Fake_MLT * 16)) / 16.0;
975 xSemaphoreGive(xSemaphoreDS18B20); 976 xSemaphoreGive(xSemaphoreDS18B20);
976 } 977 }
977 } 978 }
978 #endif 979 #endif
980 if (MashState == MASH_DECOCT) {
981 /* After decoction set the desired step temperature */
982 stageTemp = recipe.MashStep[runtime.MashStep].Step_temp;
983 }
979 if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { 984 if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) {
980 // Start PID again. 985 // Start PID again.
981 driver_state->mlt_sp = stageTemp; 986 driver_state->mlt_sp = stageTemp;
982 driver_state->mlt_mode = MLT_MODE_PID; 987 driver_state->mlt_mode = MLT_MODE_PID;
983 xSemaphoreGive(xSemaphoreDriver); 988 xSemaphoreGive(xSemaphoreDriver);
987 Buttons_Add( 5, 30, 60, 40, (char *)"+sp", 0); 992 Buttons_Add( 5, 30, 60, 40, (char *)"+sp", 0);
988 Buttons_Add(255, 30, 60, 40, (char *)"-sp", 1); 993 Buttons_Add(255, 30, 60, 40, (char *)"-sp", 1);
989 Buttons_Show(); 994 Buttons_Show();
990 TFT_fillRect(65, 120, 190, 40, TFT_BLACK); 995 TFT_fillRect(65, 120, 190, 40, TFT_BLACK);
991 if (MashState == MASH_INFUSE) { 996 if (MashState == MASH_INFUSE) {
992 log_msg(TAG, "Eind infusie"); 997 log_msg(TAG, "End infusion");
993 log_annotation(ANNOTATION_EVENT, (char *)"Eind infusie"); 998 log_annotation(ANNOTATION_EVENT, (char *)"Eind infusie");
994 } else { 999 } else {
995 log_msg(TAG, "Eind decoctie"); 1000 log_msg(TAG, "End decoction, sp: %6.4f-%6.4f sv: %6.4f",
1001 recipe.MashStep[runtime.MashStep].Step_temp, recipe.MashStep[runtime.MashStep].End_temp, temp_MLT);
996 log_annotation(ANNOTATION_EVENT, (char *)"Eind decoctie"); 1002 log_annotation(ANNOTATION_EVENT, (char *)"Eind decoctie");
997 } 1003 }
998 MashState = Sub_Screen = MASH_WAITTEMP; 1004 MashState = Sub_Screen = MASH_WAITTEMP;
999 snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); 1005 snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen);
1000 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); 1006 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg));

mercurial