main/automation.c

changeset 81
72c715ac0444
parent 79
cb5c73a8ae90
child 82
7d17e2cb31a8
equal deleted inserted replaced
80:9d2c0a85ee6e 81:72c715ac0444
23 float MaxMash = 80.0; ///< Maximum edit value 23 float MaxMash = 80.0; ///< Maximum edit value
24 uint32_t power_MLT = 0; ///< MLT power 24 uint32_t power_MLT = 0; ///< MLT power
25 uint32_t power_HLT = 0; ///< HLT power 25 uint32_t power_HLT = 0; ///< HLT power
26 uint32_t counts = 0; ///< Counter for power average 26 uint32_t counts = 0; ///< Counter for power average
27 float stageTemp = 0.0; ///< Current stage temperature 27 float stageTemp = 0.0; ///< Current stage temperature
28 float newTemp = 0.0; ///< New stage temperature
28 uint16_t stageTime = 0; ///< Current stage timer 29 uint16_t stageTime = 0; ///< Current stage timer
29 uint16_t TimeWhirlPool = 0; ///< Whirlpool timer 30 uint16_t TimeWhirlPool = 0; ///< Whirlpool timer
30 uint32_t TimeLeft = 0; ///< Tie left in this stage 31 uint32_t TimeLeft = 0; ///< Time left in this stage
32 uint32_t oldTimeLeft = 0; ///< The previous time left
31 uint32_t TimeSpent = 0; ///< Tota time spent 33 uint32_t TimeSpent = 0; ///< Tota time spent
32 uint32_t SecsCount = 0; ///< Seconds counter 34 uint32_t SecsCount = 0; ///< Seconds counter
33 uint32_t pumpTime = 0; ///< Pump running time 35 uint32_t pumpTime = 0; ///< Pump running time
34 uint32_t TimeBrewing = 0; ///< Brewing time elapsed 36 uint32_t TimeBrewing = 0; ///< Brewing time elapsed
35 uint16_t Steady = 0; ///< Temperature is steady 37 uint16_t Steady = 0; ///< Temperature is steady
649 xSemaphoreGive(xSemaphoreDriver); 651 xSemaphoreGive(xSemaphoreDriver);
650 } 652 }
651 MashState = Sub_Screen = MASH_WAITTEMP; 653 MashState = Sub_Screen = MASH_WAITTEMP;
652 snprintf(msg, 255, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); 654 snprintf(msg, 255, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen);
653 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); 655 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg));
654 log_msg(TAG, "Mash step %d type: %s time: %d sp: %6.4f sv: %6.4f", 656 log_msg(TAG, "Mash step %d type: %s time: %d sp: %6.4f-%6.4f sv: %6.4f",
655 runtime.MashStep, mashTypes[recipe.MashStep[runtime.MashStep].Type], 657 runtime.MashStep, mashTypes[recipe.MashStep[runtime.MashStep].Type],
656 stageTime, stageTemp, temp_MLT); 658 stageTime, stageTemp, recipe.MashStep[runtime.MashStep].End_temp, temp_MLT);
657 659
658 if (runtime.MashStep) { 660 if (runtime.MashStep) {
659 // Do not annotate before the log is open. 661 // Do not annotate before the log is open.
660 if (runtime.MashStep == (recipe.Mashsteps -1)) { 662 if (runtime.MashStep == (recipe.Mashsteps -1)) {
661 log_annotation(ANNOTATION_STAGE, (char *)"Uitmaischen"); 663 log_annotation(ANNOTATION_STAGE, (char *)"Uitmaischen");
717 Steady = 0; 719 Steady = 0;
718 } 720 }
719 if ((temp_MLT >= stageTemp) && (Steady > 10)) { 721 if ((temp_MLT >= stageTemp) && (Steady > 10)) {
720 SoundPlay(SOUND_TempReached); 722 SoundPlay(SOUND_TempReached);
721 TempReached = true; 723 TempReached = true;
724 newTemp = stageTemp;
722 MashState = Sub_Screen = MASH_REST; 725 MashState = Sub_Screen = MASH_REST;
723 snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); 726 snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen);
724 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); 727 ws_server_send_text_clients((char *)"/ws", msg, strlen(msg));
725 if (! runtime.MaltAdded && runtime.MashStep == 0) { 728 if (! runtime.MaltAdded && runtime.MashStep == 0) {
726 TimerSet(0); 729 TimerSet(0);
730 else 733 else
731 TimerSet(stageTime * 60); 734 TimerSet(stageTime * 60);
732 } 735 }
733 Resume = false; 736 Resume = false;
734 runtime.StageTimeLeft = TimeLeft / 60; 737 runtime.StageTimeLeft = TimeLeft / 60;
738 oldTimeLeft = TimeLeft;
735 updateRuntime = true; 739 updateRuntime = true;
736 log_msg(TAG, "Mash step %d temperature reached, rest %d minutes", runtime.MashStep, TimeLeft / 60); 740 log_msg(TAG, "Mash step %d temperature reached, rest %d minutes", runtime.MashStep, TimeLeft / 60);
737 Buttons_Clear(); 741 Buttons_Clear();
738 Buttons_Add( 0, 120, 60, 40, (char *)"+1m", 0); 742 Buttons_Add( 0, 120, 60, 40, (char *)"+1m", 0);
739 Buttons_Add(260, 120, 60, 40, (char *)"-1m", 1); 743 Buttons_Add(260, 120, 60, 40, (char *)"-1m", 1);
789 break; 793 break;
790 794
791 default: break; 795 default: break;
792 } 796 }
793 } 797 }
798
799 if ((recipe.MashStep[runtime.MashStep].Step_temp != recipe.MashStep[runtime.MashStep].End_temp) &&
800 (recipe.MashStep[runtime.MashStep].Type != MASHTYPE_DECOCTION) && (oldTimeLeft != TimeLeft)) {
801 float part = ((stageTime * 60.0) - TimeLeft) / (stageTime * 60.0);
802 newTemp = ((int)(((part * (recipe.MashStep[runtime.MashStep].End_temp - recipe.MashStep[runtime.MashStep].Step_temp)) +
803 recipe.MashStep[runtime.MashStep].Step_temp) * 16)) / 16.0;
804 //newTemp = ((int)(newTemp * 16)) / 16.0;
805 if (newTemp != stageTemp) {
806 stageTemp = newTemp;
807 if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) {
808 driver_state->mlt_sp = stageTemp;
809 xSemaphoreGive(xSemaphoreDriver);
810 }
811 ESP_LOGI(TAG, "Curent %7.4f new %7.4f part %7.4f", stageTemp, newTemp, part);
812 }
813 }
814 oldTimeLeft = TimeLeft;
794 815
795 if (TimeLeft == 0) { 816 if (TimeLeft == 0) {
796 runtime.StageTimeLeft = 0; 817 runtime.StageTimeLeft = 0;
797 updateRuntime = true; 818 updateRuntime = true;
798 if (runtime.MashStep == 0 && ! runtime.MaltAdded && config.AskAdd) { 819 if (runtime.MashStep == 0 && ! runtime.MaltAdded && config.AskAdd) {

mercurial