diff -r 5d4a40fe9967 -r 49e2960d4642 main/recipes.c --- a/main/recipes.c Fri Oct 26 13:29:14 2018 +0200 +++ b/main/recipes.c Fri Oct 26 21:23:46 2018 +0200 @@ -37,6 +37,8 @@ size_t offs; ///< Offset in buffer bool overflow; ///< Overflow in buffer +extern const char *mashTypes[]; + /** @@ -47,7 +49,6 @@ */ void Addition_Add(char *Name, uint8_t Type, uint16_t Time) { -// printf("Addition_Add(%s, %d, %d)\n", Name, Type, Time); if (! recipe.Additions) { // No entries yet, add the first one. sprintf(recipe.Addition[recipe.Additions].Name, "%s", Name); @@ -69,7 +70,6 @@ // A new entry and we already have some. Add it and keep the list sorted. for (int i = 0; i < recipe.Additions; i++) { if (Time > recipe.Addition[i].Time) { -// printf("Insert at %d\n", i); // Make room for (int j = i; j < recipe.Additions; j++) { sprintf(recipe.Addition[j+1].Name, "%s", recipe.Addition[j].Name); @@ -287,7 +287,6 @@ } } if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) { -// printf("Flush End MASH_STEP %d %s\n", _xml_depth, _xml_add_name); _xml_mashsteps++; sprintf(recipe.MashStep[_xml_mashsteps].Name, "%s", _xml_add_name); recipe.MashStep[_xml_mashsteps].Type = _xml_add_type; @@ -350,7 +349,10 @@ } recipe.CoolTemp = 20.0; sprintf(recipe.MashStep[0].Name, "Mash-in"); - if (_xml_tun_temp > recipe.MashStep[1].Temperature) { + if ((recipe.MashStep[1].Type == MASHTYPE_INFUSION) && (recipe.MashStep[1].Infusion_temp > 0.0)) { + /* If next (first original) step is infusion, take that temperature. */ + recipe.MashStep[0].Temperature = recipe.MashStep[1].Infusion_temp; + } else if (_xml_tun_temp > recipe.MashStep[1].Temperature) { recipe.MashStep[0].Temperature = _xml_tun_temp; } else { recipe.MashStep[0].Temperature = recipe.MashStep[1].Temperature + 1.25; @@ -549,11 +551,9 @@ for (int i = 1; i < 8; i++) { if (recipe.MashStep[i].Resttime) { TFT_print(recipe.MashStep[i].Name, 2, y); - switch (recipe.MashStep[i].Type) { - case MASHTYPE_INFUSION: TFT_print("I", 200, y); break; - case MASHTYPE_TEMPERATURE: TFT_print("T", 200, y); break; - case MASHTYPE_DECOCTION: TFT_print("D", 200, y); break; - } + strcpy(tmp, mashTypes[recipe.MashStep[i].Type]); + tmp[1] = '\0'; + TFT_print(tmp, 200, y); sprintf(tmp, "%.2f", recipe.MashStep[i].Temperature); TFT_print(tmp, 220, y); sprintf(tmp, "%2d m", recipe.MashStep[i].Resttime); @@ -622,6 +622,8 @@ case 1: memset(&recipe, 0, sizeof(recipe)); recipe.Version = 1; + for (int i = 1; i < 8; i++) + recipe.MashStep[i].Type = MASHTYPE_TEMPERATURE; sprintf(recipe.Name, "Recipe %d", r_Records + 1); sprintf(recipe.Code, "00%d", r_Records + 1); sprintf(recipe.MashStep[0].Name, "Mash-in"); @@ -631,12 +633,10 @@ recipe.MashStep[0].Resttime = 1; recipe.MashStep[0].Ramptime = 1; sprintf(recipe.MashStep[1].Name, "Mash"); - recipe.MashStep[1].Type = MASHTYPE_TEMPERATURE; recipe.MashStep[1].Temperature = 67.0; recipe.MashStep[1].Resttime = 75; recipe.MashStep[1].Ramptime = 1; sprintf(recipe.MashStep[7].Name, "Mash-out"); - recipe.MashStep[7].Type = MASHTYPE_TEMPERATURE; recipe.MashStep[7].Temperature = 78.0; recipe.MashStep[7].Resttime = 5; recipe.MashStep[7].Ramptime = 11; @@ -715,6 +715,7 @@ for (int i = 1; i <= mashsteps; i++) { sprintf(tmp, "Maisch stap %d naam", i); EditText(tmp, recipe.MashStep[i].Name, 31); + EditMashType(&recipe.MashStep[i].Type); sprintf(tmp, "Maisch stap %d temperatuur", i); if (i == 1) mintemp = recipe.MashStep[0].Temperature - 5; @@ -729,6 +730,15 @@ } else { recipe.MashStep[i].Ramptime = (int)(recipe.MashStep[i].Temperature - recipe.MashStep[i - 1].Temperature); } + if (recipe.MashStep[i].Type == MASHTYPE_INFUSION) { + sprintf(tmp, "Stap %d infusie temperatuur", i); + mintemp = recipe.MashStep[i].Temperature; + EditFloat(tmp, &recipe.MashStep[i].Infusion_temp, mintemp, 100, 2); + sprintf(tmp, "Stap %d infusie volume", i); + EditFloat(tmp, &recipe.MashStep[i].Infusion_amount, 0.5, 1000.0, 2); + } else { + recipe.MashStep[i].Infusion_temp = recipe.MashStep[i].Infusion_amount = 0.0; + } } mintemp = recipe.MashStep[mashsteps].Temperature; EditFloat("Uitmaischen temperatuur", &recipe.MashStep[7].Temperature, mintemp, 80, 2);