Version 0.3.21. Changed HLT heatup speed calculation to 0.67 degrees/minute. Include the mash ramp times in the calculation for the initial temperature. With a combined HLT and MLT setup, the HLT preheat time is now much shorter. Fixed problems reading beerxml if there is an aroma hop. If the time was 0 or missing it was assumed to be a whirlpool hop. Now it's treated as flameout hop as it should be. Fixed sorting hop/misc additions, this could lead to missing ingredients warnings. The recipe cool temperature was treated as an integer value.

Sat, 25 Jun 2022 15:24:55 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 25 Jun 2022 15:24:55 +0200
changeset 121
30aca5888d2b
parent 120
afd58d4c7b5b
child 122
9a0da652c5c4

Version 0.3.21. Changed HLT heatup speed calculation to 0.67 degrees/minute. Include the mash ramp times in the calculation for the initial temperature. With a combined HLT and MLT setup, the HLT preheat time is now much shorter. Fixed problems reading beerxml if there is an aroma hop. If the time was 0 or missing it was assumed to be a whirlpool hop. Now it's treated as flameout hop as it should be. Fixed sorting hop/misc additions, this could lead to missing ingredients warnings. The recipe cool temperature was treated as an integer value.

CMakeLists.txt file | annotate | diff | comparison | revisions
README.md file | annotate | diff | comparison | revisions
main/automation.c file | annotate | diff | comparison | revisions
main/config.c file | annotate | diff | comparison | revisions
main/config.h file | annotate | diff | comparison | revisions
main/recipes.c file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Tue Nov 02 14:47:43 2021 +0100
+++ b/CMakeLists.txt	Sat Jun 25 15:24:55 2022 +0200
@@ -2,7 +2,7 @@
 # in this exact order for cmake to work correctly
 cmake_minimum_required(VERSION 3.5)
 
-set(PROJECT_VER "0.3.20")
+set(PROJECT_VER "0.3.21")
 set(PROJECT_NAME "brewboard")
 
 include($ENV{IDF_PATH}/tools/cmake/project.cmake)
--- a/README.md	Tue Nov 02 14:47:43 2021 +0100
+++ b/README.md	Sat Jun 25 15:24:55 2022 +0200
@@ -109,7 +109,6 @@
 
 TODO:
       - Nosleep js code toevoegen.
-      - Bug: import 2 x hop met dezelfde naam met verschillende tijden krijgen 1 tijd na import.
 
 Voor kleinere image, van 10000272 -> 914944 de volgende settings:
 
--- a/main/automation.c	Tue Nov 02 14:47:43 2021 +0100
+++ b/main/automation.c	Sat Jun 25 15:24:55 2022 +0200
@@ -109,7 +109,7 @@
 		log_msg(TAG, "Automation startup");
 #ifdef CONFIG_TEMP_SENSORS_SIMULATOR
 		Fake_MLT = recipe.MashStep[0].Step_temp - 10;
-		Fake_HLT = recipe.SpargeTemp - 15;
+		Fake_HLT = recipe.SpargeTemp - 45;
                 if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) {
                     ds18b20_state->mlt_temperature = ((int)(Fake_MLT * 16)) / 16.0;
                     ds18b20_state->hlt_temperature = ((int)(Fake_HLT * 16)) / 16.0;
@@ -594,16 +594,21 @@
 		ESP_LOGD(TAG, "Use HLT %s", (_UseHLT)?"true":"false");
                 updateRuntime = true;
                 if (_UseHLT) {
-                    /*
-                     * Calculate HLT setpoint for pre-heat. Substract the
-                     * available Mash rest times, asume 0.5 degrees/minute
-                     * heat capacity during mash.
-                     */
+		    /*
+		     * Calculate HLT setpoint for pre-heat.
+		     * Substract the available Mash rest plus ramp times,
+		     * asume 0.67 degrees/minute heat capacity during mash.
+		     */
                     int AvailableTime = 0;
-                    for (int i = 1; i < 6; i++) // Only normal Mash steps
-                        AvailableTime += recipe.MashStep[i].Step_time;
+                    for (int i = 0; i < recipe.Mashsteps; i++) {
+			if (recipe.MashStep[i].Step_temp < 75) {
+                            AvailableTime += (recipe.MashStep[i].Step_time + recipe.MashStep[i].Ramp_time);
+			}
+		    }
                     if (xSemaphoreTake(xSemaphoreDriver, 10) == pdTRUE) {
-                        driver_state->hlt_sp = recipe.SpargeTemp - ((AvailableTime / 2) + 2);
+                        driver_state->hlt_sp = recipe.SpargeTemp - ((AvailableTime / 1.5) + 2);
+			if (driver_state->hlt_sp < 10.0)
+			    driver_state->hlt_sp = 10.0;
                         log_msg(TAG, "HLT preheat set to %4.2f", driver_state->hlt_sp);
                         xSemaphoreGive(xSemaphoreDriver);
                     }
--- a/main/config.c	Tue Nov 02 14:47:43 2021 +0100
+++ b/main/config.c	Sat Jun 25 15:24:55 2022 +0200
@@ -520,10 +520,10 @@
 	recipe.Additions = 2;
 	sprintf(recipe.Addition[0].Name, "Hop");
 	recipe.Addition[0].Time = 60;
-	recipe.Addition[0].Type = ADDITION_HOP;
+	recipe.Addition[0].Type = ADDITION_HOP_BOIL;
 	sprintf(recipe.Addition[1].Name, "Hop");
 	recipe.Addition[1].Time = 10;
-	recipe.Addition[1].Type = ADDITION_HOP;
+	recipe.Addition[1].Type = ADDITION_HOP_BOIL;
 	recipe.CoolTemp = 20.0;
 	recipe.Whirlpool9 = 0;
 	recipe.Whirlpool7 = 0;
--- a/main/config.h	Tue Nov 02 14:47:43 2021 +0100
+++ b/main/config.h	Sat Jun 25 15:24:55 2022 +0200
@@ -342,7 +342,7 @@
  * @brief Addition types
  */
 typedef enum {
-    ADDITION_HOP = 0,
+    ADDITION_HOP_BOIL = 0,
     ADDITION_FERMENTABLE = 1,
     ADDITION_SPICE = 2,
     ADDITION_FINING = 3,
@@ -350,6 +350,7 @@
     ADDITION_HERB = 5,
     ADDITION_FLAVOR = 6,
     ADDITION_OTHER = 7,
+    ADDITION_HOP_AROMA = 8,
 } ADDITION_TYPE;
 
 /**
--- a/main/recipes.c	Tue Nov 02 14:47:43 2021 +0100
+++ b/main/recipes.c	Sat Jun 25 15:24:55 2022 +0200
@@ -20,8 +20,8 @@
 int				r_Imported = 0;			///< Total imported
 char                            _xml_element[10][32];		///< XML element array
 int                             _xml_depth;			///< Current depths
-char                            _xml_add_name[64];		///< Mash name
-int                             _xml_add_type;			///< Mash type 
+char                            _xml_add_name[64];		///< Addition name
+int                             _xml_add_type;			///< Addition type
 int                             _xml_add_time;			///< Mash rest time
 int				_xml_add_ramp;			///< Mash ramp time
 float				_xml_add_temp;			///< Mash start temperature
@@ -49,6 +49,16 @@
  */
 void Addition_Add(char *Name, uint8_t Type, uint16_t Time)
 {
+    if (Type == ADDITION_HOP_AROMA && Time > 0) {
+	/*
+	 * Whirlpool hop.
+	 */
+	recipe.Whirlpool7 = Time;
+	return;
+    }
+    if (Type == ADDITION_HOP_AROMA)
+	Type = ADDITION_HOP_BOIL;	/* Flame-out hop, change to boil with zero time. */
+
     if (! recipe.Additions) {
 	// No entries yet, add the first one.
     	snprintf(recipe.Addition[recipe.Additions].Name, 63, "%s", Name);
@@ -72,10 +82,10 @@
     for (int i = 0; i < recipe.Additions; i++) {
 	if (Time > recipe.Addition[i].Time) {
 	    // Make room
-	    for (int j = i; j < recipe.Additions; j++) {
-		sprintf(recipe.Addition[j+1].Name, "%s", recipe.Addition[j].Name);
-		recipe.Addition[j+1].Type = recipe.Addition[j].Type;
-		recipe.Addition[j+1].Time = recipe.Addition[j].Time;
+	    for (int j = recipe.Additions; j > i; j--) {
+		sprintf(recipe.Addition[j].Name, "%s", recipe.Addition[j-1].Name);
+		recipe.Addition[j].Type = recipe.Addition[j-1].Type;
+		recipe.Addition[j].Time = recipe.Addition[j-1].Time;
 	    }
 	    snprintf(recipe.Addition[i].Name, 63, "%s", Name);
 	    recipe.Addition[i].Type = Type;
@@ -151,19 +161,23 @@
             } else if ((_xml_depth == 3) && (strcmp("BOIL_TIME", _xml_element[2]) == 0)) {
                 recipe.BoilTime = atoi(char_data_buffer);
 	    } else if ((_xml_depth == 3) && (strcmp("BMS_COOLING_TO", _xml_element[2]) == 0)) {
-		recipe.CoolTemp = atoi(char_data_buffer);
+		recipe.CoolTemp = atof(char_data_buffer);
             } else if ((_xml_depth == 5) && (strcmp("HOPS", _xml_element[2]) == 0) && (strcmp("HOP", _xml_element[3]) == 0)) {
 		/*
 		 * Hops that are added during the boil.
-		 * But check for whirlpool hops too.
+		 * But check for "Aroma" hops too.
 		 */
                 if (strcmp("NAME", _xml_element[4]) == 0) {
 		    _xml_add_name[0] = '\0';
                     strncat(_xml_add_name, char_data_buffer, 63);
+		    _xml_add_time = 0;	// reset
                 } else if (strcmp("USE", _xml_element[4]) == 0) {
-                    _xml_add_valid = (strcmp("Boil", char_data_buffer) == 0);   // Only "Boil" is a valid hop
-                    if (strcmp("Aroma", char_data_buffer) == 0) {
-                        recipe.Whirlpool7 = 30;
+		    if (strcmp("Boil", char_data_buffer) == 0) {
+			_xml_add_valid = true;
+			_xml_add_type = ADDITION_HOP_BOIL;
+		    } else if (strcmp("Aroma", char_data_buffer) == 0) {
+			_xml_add_type = ADDITION_HOP_AROMA;
+			_xml_add_valid = true;
                     }
                 } else if (strcmp("TIME", _xml_element[4]) == 0) {
                     _xml_add_time = atoi(char_data_buffer);
@@ -285,7 +299,7 @@
     reset_char_data_buffer();
     if ((_xml_depth == 4) && (strcmp("HOP", _xml_element[3]) == 0)) {
         if (_xml_add_valid) {
-	    Addition_Add(_xml_add_name, ADDITION_HOP, _xml_add_time);
+	    Addition_Add(_xml_add_name, _xml_add_type, _xml_add_time);
         }
     }
     if ((_xml_depth == 4) && (strcmp("FERMENTABLE", _xml_element[3]) == 0)) {
@@ -311,7 +325,6 @@
 	 */
 	if (_xml_add_type == MASHTYPE_TEMPERATURE && recipe.Mashsteps == 0) {
 	    _xml_add_type = MASHTYPE_INFUSION;
-//	    _xml_add_infusion = _xml_add_temp + 1.25;
 	    recipe.MashStep[recipe.Mashsteps].Ramp_time = 1;
 	}
 	recipe.MashStep[recipe.Mashsteps].Type = _xml_add_type;
@@ -388,18 +401,16 @@
 #if 0
     printf("Recipe: %s\n", recipe.Name);
     printf("Code  : %s\n", recipe.Code);
-    printf("Boil time %d minutes\n", recipe.BoilTime);
+    printf("Boil  : %d minutes\n", recipe.BoilTime);
     printf("n Stepname                       T  temp   end time ramp  inft  infa\n");
     printf("- ------------------------------ - ----- ----- ---- ---- ----- -----\n");
-    for (int i = 0; i < 8; i++) {
-        if (recipe.MashStep[i].Step_time) {
-            printf("%d %-30s %d %5.2f %5.2f %4d %4d %5.2f %5.2f\n", i, recipe.MashStep[i].Name, recipe.MashStep[i].Type,
+    for (int i = 0; i < recipe.Mashsteps; i++) {
+        printf("%d %-30s %d %5.2f %5.2f %4d %4d %5.2f %5.2f\n", i, recipe.MashStep[i].Name, recipe.MashStep[i].Type,
 			    recipe.MashStep[i].Step_temp, recipe.MashStep[i].End_temp,
                             recipe.MashStep[i].Step_time, recipe.MashStep[i].Ramp_time,
 			    recipe.MashStep[i].Infuse_temp, recipe.MashStep[i].Infuse_amount);
-        }
     }
-    printf("%d additions\n", recipe.Additions);
+    printf("\n%d additions\n", recipe.Additions);
     printf("n Addition name                                                   t Tim\n");
     printf("- --------------------------------------------------------------- - ---\n");
     for (int i = 0; i < recipe.Additions; i++) {
@@ -642,10 +653,10 @@
 					recipe.Additions = 2;
 					sprintf(recipe.Addition[0].Name, "Bitterhop");
 					recipe.Addition[0].Time = 60;
-					recipe.Addition[0].Type = ADDITION_HOP;
+					recipe.Addition[0].Type = ADDITION_HOP_BOIL;
 					sprintf(recipe.Addition[1].Name, "Aromahop");
 					recipe.Addition[1].Time = 10;
-					recipe.Addition[1].Type = ADDITION_HOP;
+					recipe.Addition[1].Type = ADDITION_HOP_BOIL;
 					recipe.CoolTemp = 20.0;
 					recipe.Whirlpool9 = 0;
 					recipe.Whirlpool7 = 0;
@@ -786,7 +797,7 @@
 			    	} else {
 				    EditUint16(tmp, &recipe.Addition[i].Time, 0, recipe.Addition[i-1].Time - 1);
 			    	}
-			    	recipe.Addition[i].Type = ADDITION_HOP;
+			    	recipe.Addition[i].Type = ADDITION_HOP_BOIL;
 			    }
 			} else {
 			    recipe.Additions = 0;

mercurial