diff -r 8d0287a1a9e1 -r 47253f294a9f main/automation.c --- a/main/automation.c Sun Jun 07 22:30:07 2020 +0200 +++ b/main/automation.c Wed Jun 10 09:43:51 2020 +0200 @@ -51,6 +51,7 @@ extern time_t now; ///< Current time extern struct tm timeinfo; ///< Current time structure + #ifdef CONFIG_TEMP_SENSORS_SIMULATOR extern float Fake_MLT; extern float Fake_HLT; @@ -118,7 +119,7 @@ LastMashStep = recipe.Mashsteps - 2; else LastMashStep = 0; - log_msg(TAG, "Last mash step %d", LastMashStep); + ESP_LOGD(TAG, "Last mash step %d", LastMashStep); // Check for a crashed session. if (runtime.AutoModeStarted) { @@ -182,6 +183,8 @@ runtime.PumpCooling = false; runtime.MashStep = 0; runtime.MaltAdded = false; + runtime.MLT_usage = 0; + runtime.HLT_usage = 0; write_runtime(); power_MLT = power_HLT = counts = 0; log_clean(); @@ -380,6 +383,9 @@ driver_state->pump_run = 0; xSemaphoreGive(xSemaphoreDriver); } + double mwu = (runtime.MLT_usage / 1000.0 / 60.0 / 60.0) * equipment.MLT_watt / 1000.0; + double hwu = (runtime.HLT_usage / 1000.0 / 60.0 / 60.0) * equipment.HLT_watt / 1000.0; + log_msg(TAG, "MLT usage %.3f KWU, HLT usage %.3f KWU, total %.3f KWU", mwu, hwu, mwu + hwu); _fg = TFT_YELLOW; TFT_setFont(DEJAVU24_FONT, NULL); if (Main_Screen == MAIN_AUTO_DONE) { @@ -576,7 +582,7 @@ } else { runtime.UseHLT = _UseHLT = false; } - log_msg(TAG, "Use HLT %s", (_UseHLT)?"true":"false"); + ESP_LOGD(TAG, "Use HLT %s", (_UseHLT)?"true":"false"); updateRuntime = true; if (_UseHLT) { /* @@ -613,7 +619,7 @@ if (driver_state->hlt_pv >= driver_state->hlt_sp) { Main_Screen = MAIN_AUTO_MASH; driver_state->hlt_sp = recipe.SpargeTemp; // Set final setpoint - log_msg(TAG, "HLT preheat done"); + ESP_LOGD(TAG, "HLT preheat done"); } xSemaphoreGive(xSemaphoreDriver); } @@ -801,14 +807,13 @@ float part = ((stageTime * 60.0) - TimeLeft) / (stageTime * 60.0); newTemp = ((int)(((part * (recipe.MashStep[runtime.MashStep].End_temp - recipe.MashStep[runtime.MashStep].Step_temp)) + recipe.MashStep[runtime.MashStep].Step_temp) * 16)) / 16.0; - //newTemp = ((int)(newTemp * 16)) / 16.0; if (newTemp != stageTemp) { stageTemp = newTemp; if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) { driver_state->mlt_sp = stageTemp; xSemaphoreGive(xSemaphoreDriver); } - ESP_LOGI(TAG, "Curent %7.4f new %7.4f part %7.4f", stageTemp, newTemp, part); + //ESP_LOGI(TAG, "Current %7.4f new %7.4f part %7.4f", stageTemp, newTemp, part); } } oldTimeLeft = TimeLeft; @@ -816,6 +821,10 @@ if (TimeLeft == 0) { runtime.StageTimeLeft = 0; updateRuntime = true; + TFT_fillRect(0, 120, 320, 50, TFT_BLACK); + snprintf(msg, 63, "{\"main\":\"%d\",\"sub\":\"%d\",\"timer\":\"\"}", Main_Screen, Sub_Screen); + ws_server_send_text_clients((char *)"/ws", msg, strlen(msg)); + if (runtime.MashStep == 0 && ! runtime.MaltAdded && config.AskAdd) { /* * Add Mash prompt. @@ -826,7 +835,6 @@ xSemaphoreGive(xSemaphoreDriver); } log_annotation(ANNOTATION_EVENT, (char *)"Mout storten"); - TFT_fillRect(0, 120, 320, 50, TFT_BLACK); Buttons_Clear(); Buttons_Add( 5,120, 60, 40, (char *)"Halt", 0); Buttons[0].dark = true; @@ -848,7 +856,6 @@ * Iodone test prompt. */ log_annotation(ANNOTATION_EVENT, (char *)"Jodium test"); - TFT_fillRect(0, 120, 320, 50, TFT_BLACK); Buttons_Clear(); Buttons_Add( 5,120, 60, 40, (char *)"Halt", 0); Buttons[0].dark = true; @@ -872,7 +879,6 @@ * Mash remove prompt. */ log_annotation(ANNOTATION_EVENT, (char *)"Mout verwijderen"); - TFT_fillRect(0, 120, 320, 50, TFT_BLACK); Buttons_Clear(); Buttons_Add( 5,120, 60, 40, (char *)"Halt", 0); Buttons[0].dark = true; @@ -1347,7 +1353,7 @@ driver_state->pump_run = (driver_state->mlt_pv < equipment.PumpMaxTemp) ? 1 : 0; xSemaphoreGive(xSemaphoreDriver); } - log_annotation(ANNOTATION_STAGE, (char *)"Whirlpool"); + log_annotation(ANNOTATION_EVENT, (char *)"Whirlpool"); TimerSet(TimeWhirlPool * 60); runtime.StageTimeLeft = TimeWhirlPool;