35 |
35 |
36 char char_data_buffer[1024]; ///< Data buffer |
36 char char_data_buffer[1024]; ///< Data buffer |
37 size_t offs; ///< Offset in buffer |
37 size_t offs; ///< Offset in buffer |
38 bool overflow; ///< Overflow in buffer |
38 bool overflow; ///< Overflow in buffer |
39 |
39 |
|
40 extern const char *mashTypes[]; |
|
41 |
40 |
42 |
41 |
43 |
42 /** |
44 /** |
43 * @brief Add addition to the recipe. |
45 * @brief Add addition to the recipe. |
44 * @param Name The addition name. |
46 * @param Name The addition name. |
45 * @param Type The addition type. |
47 * @param Type The addition type. |
46 * @param Time The addition time to add. |
48 * @param Time The addition time to add. |
47 */ |
49 */ |
48 void Addition_Add(char *Name, uint8_t Type, uint16_t Time) |
50 void Addition_Add(char *Name, uint8_t Type, uint16_t Time) |
49 { |
51 { |
50 // printf("Addition_Add(%s, %d, %d)\n", Name, Type, Time); |
|
51 if (! recipe.Additions) { |
52 if (! recipe.Additions) { |
52 // No entries yet, add the first one. |
53 // No entries yet, add the first one. |
53 sprintf(recipe.Addition[recipe.Additions].Name, "%s", Name); |
54 sprintf(recipe.Addition[recipe.Additions].Name, "%s", Name); |
54 recipe.Addition[recipe.Additions].Type = Type; |
55 recipe.Addition[recipe.Additions].Type = Type; |
55 recipe.Addition[recipe.Additions].Time = Time; |
56 recipe.Addition[recipe.Additions].Time = Time; |
67 } |
68 } |
68 |
69 |
69 // A new entry and we already have some. Add it and keep the list sorted. |
70 // A new entry and we already have some. Add it and keep the list sorted. |
70 for (int i = 0; i < recipe.Additions; i++) { |
71 for (int i = 0; i < recipe.Additions; i++) { |
71 if (Time > recipe.Addition[i].Time) { |
72 if (Time > recipe.Addition[i].Time) { |
72 // printf("Insert at %d\n", i); |
|
73 // Make room |
73 // Make room |
74 for (int j = i; j < recipe.Additions; j++) { |
74 for (int j = i; j < recipe.Additions; j++) { |
75 sprintf(recipe.Addition[j+1].Name, "%s", recipe.Addition[j].Name); |
75 sprintf(recipe.Addition[j+1].Name, "%s", recipe.Addition[j].Name); |
76 recipe.Addition[j+1].Type = recipe.Addition[j].Type; |
76 recipe.Addition[j+1].Type = recipe.Addition[j].Type; |
77 recipe.Addition[j+1].Time = recipe.Addition[j].Time; |
77 recipe.Addition[j+1].Time = recipe.Addition[j].Time; |
285 if (_xml_add_valid) { |
285 if (_xml_add_valid) { |
286 Addition_Add(_xml_add_name, _xml_add_type, _xml_add_time); |
286 Addition_Add(_xml_add_name, _xml_add_type, _xml_add_time); |
287 } |
287 } |
288 } |
288 } |
289 if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) { |
289 if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) { |
290 // printf("Flush End MASH_STEP %d %s\n", _xml_depth, _xml_add_name); |
|
291 _xml_mashsteps++; |
290 _xml_mashsteps++; |
292 sprintf(recipe.MashStep[_xml_mashsteps].Name, "%s", _xml_add_name); |
291 sprintf(recipe.MashStep[_xml_mashsteps].Name, "%s", _xml_add_name); |
293 recipe.MashStep[_xml_mashsteps].Type = _xml_add_type; |
292 recipe.MashStep[_xml_mashsteps].Type = _xml_add_type; |
294 recipe.MashStep[_xml_mashsteps].Temperature = _xml_add_temp; |
293 recipe.MashStep[_xml_mashsteps].Temperature = _xml_add_temp; |
295 recipe.MashStep[_xml_mashsteps].Resttime = _xml_add_time; |
294 recipe.MashStep[_xml_mashsteps].Resttime = _xml_add_time; |
348 break; |
347 break; |
349 } |
348 } |
350 } |
349 } |
351 recipe.CoolTemp = 20.0; |
350 recipe.CoolTemp = 20.0; |
352 sprintf(recipe.MashStep[0].Name, "Mash-in"); |
351 sprintf(recipe.MashStep[0].Name, "Mash-in"); |
353 if (_xml_tun_temp > recipe.MashStep[1].Temperature) { |
352 if ((recipe.MashStep[1].Type == MASHTYPE_INFUSION) && (recipe.MashStep[1].Infusion_temp > 0.0)) { |
|
353 /* If next (first original) step is infusion, take that temperature. */ |
|
354 recipe.MashStep[0].Temperature = recipe.MashStep[1].Infusion_temp; |
|
355 } else if (_xml_tun_temp > recipe.MashStep[1].Temperature) { |
354 recipe.MashStep[0].Temperature = _xml_tun_temp; |
356 recipe.MashStep[0].Temperature = _xml_tun_temp; |
355 } else { |
357 } else { |
356 recipe.MashStep[0].Temperature = recipe.MashStep[1].Temperature + 1.25; |
358 recipe.MashStep[0].Temperature = recipe.MashStep[1].Temperature + 1.25; |
357 } |
359 } |
358 recipe.MashStep[0].Resttime = recipe.MashStep[0].Ramptime = 1; |
360 recipe.MashStep[0].Resttime = recipe.MashStep[0].Ramptime = 1; |
547 _fg = TFT_YELLOW; |
549 _fg = TFT_YELLOW; |
548 y += 16; |
550 y += 16; |
549 for (int i = 1; i < 8; i++) { |
551 for (int i = 1; i < 8; i++) { |
550 if (recipe.MashStep[i].Resttime) { |
552 if (recipe.MashStep[i].Resttime) { |
551 TFT_print(recipe.MashStep[i].Name, 2, y); |
553 TFT_print(recipe.MashStep[i].Name, 2, y); |
552 switch (recipe.MashStep[i].Type) { |
554 strcpy(tmp, mashTypes[recipe.MashStep[i].Type]); |
553 case MASHTYPE_INFUSION: TFT_print("I", 200, y); break; |
555 tmp[1] = '\0'; |
554 case MASHTYPE_TEMPERATURE: TFT_print("T", 200, y); break; |
556 TFT_print(tmp, 200, y); |
555 case MASHTYPE_DECOCTION: TFT_print("D", 200, y); break; |
|
556 } |
|
557 sprintf(tmp, "%.2f", recipe.MashStep[i].Temperature); |
557 sprintf(tmp, "%.2f", recipe.MashStep[i].Temperature); |
558 TFT_print(tmp, 220, y); |
558 TFT_print(tmp, 220, y); |
559 sprintf(tmp, "%2d m", recipe.MashStep[i].Resttime); |
559 sprintf(tmp, "%2d m", recipe.MashStep[i].Resttime); |
560 TFT_print(tmp, 280, y); |
560 TFT_print(tmp, 280, y); |
561 y += 16; |
561 y += 16; |
620 case 0: Main_Screen = MAIN_TOOLS; |
620 case 0: Main_Screen = MAIN_TOOLS; |
621 break; |
621 break; |
622 |
622 |
623 case 1: memset(&recipe, 0, sizeof(recipe)); |
623 case 1: memset(&recipe, 0, sizeof(recipe)); |
624 recipe.Version = 1; |
624 recipe.Version = 1; |
|
625 for (int i = 1; i < 8; i++) |
|
626 recipe.MashStep[i].Type = MASHTYPE_TEMPERATURE; |
625 sprintf(recipe.Name, "Recipe %d", r_Records + 1); |
627 sprintf(recipe.Name, "Recipe %d", r_Records + 1); |
626 sprintf(recipe.Code, "00%d", r_Records + 1); |
628 sprintf(recipe.Code, "00%d", r_Records + 1); |
627 sprintf(recipe.MashStep[0].Name, "Mash-in"); |
629 sprintf(recipe.MashStep[0].Name, "Mash-in"); |
628 recipe.MashStep[0].Type = MASHTYPE_INFUSION; |
630 recipe.MashStep[0].Type = MASHTYPE_INFUSION; |
629 recipe.MashStep[0].Temperature = recipe.MashStep[0].Infusion_temp = 67.5; |
631 recipe.MashStep[0].Temperature = recipe.MashStep[0].Infusion_temp = 67.5; |
630 recipe.MashStep[0].Infusion_amount = 15.0; |
632 recipe.MashStep[0].Infusion_amount = 15.0; |
631 recipe.MashStep[0].Resttime = 1; |
633 recipe.MashStep[0].Resttime = 1; |
632 recipe.MashStep[0].Ramptime = 1; |
634 recipe.MashStep[0].Ramptime = 1; |
633 sprintf(recipe.MashStep[1].Name, "Mash"); |
635 sprintf(recipe.MashStep[1].Name, "Mash"); |
634 recipe.MashStep[1].Type = MASHTYPE_TEMPERATURE; |
|
635 recipe.MashStep[1].Temperature = 67.0; |
636 recipe.MashStep[1].Temperature = 67.0; |
636 recipe.MashStep[1].Resttime = 75; |
637 recipe.MashStep[1].Resttime = 75; |
637 recipe.MashStep[1].Ramptime = 1; |
638 recipe.MashStep[1].Ramptime = 1; |
638 sprintf(recipe.MashStep[7].Name, "Mash-out"); |
639 sprintf(recipe.MashStep[7].Name, "Mash-out"); |
639 recipe.MashStep[7].Type = MASHTYPE_TEMPERATURE; |
|
640 recipe.MashStep[7].Temperature = 78.0; |
640 recipe.MashStep[7].Temperature = 78.0; |
641 recipe.MashStep[7].Resttime = 5; |
641 recipe.MashStep[7].Resttime = 5; |
642 recipe.MashStep[7].Ramptime = 11; |
642 recipe.MashStep[7].Ramptime = 11; |
643 recipe.BoilTime = 60; |
643 recipe.BoilTime = 60; |
644 recipe.Additions = 2; |
644 recipe.Additions = 2; |
713 // Round to 0.25 values |
713 // Round to 0.25 values |
714 recipe.MashStep[0].Temperature = ((int)(recipe.MashStep[0].Temperature * 4)) / 4.0; |
714 recipe.MashStep[0].Temperature = ((int)(recipe.MashStep[0].Temperature * 4)) / 4.0; |
715 for (int i = 1; i <= mashsteps; i++) { |
715 for (int i = 1; i <= mashsteps; i++) { |
716 sprintf(tmp, "Maisch stap %d naam", i); |
716 sprintf(tmp, "Maisch stap %d naam", i); |
717 EditText(tmp, recipe.MashStep[i].Name, 31); |
717 EditText(tmp, recipe.MashStep[i].Name, 31); |
|
718 EditMashType(&recipe.MashStep[i].Type); |
718 sprintf(tmp, "Maisch stap %d temperatuur", i); |
719 sprintf(tmp, "Maisch stap %d temperatuur", i); |
719 if (i == 1) |
720 if (i == 1) |
720 mintemp = recipe.MashStep[0].Temperature - 5; |
721 mintemp = recipe.MashStep[0].Temperature - 5; |
721 else |
722 else |
722 mintemp = recipe.MashStep[i - 1].Temperature; |
723 mintemp = recipe.MashStep[i - 1].Temperature; |
727 if (i == 1) { |
728 if (i == 1) { |
728 recipe.MashStep[i].Ramptime = 1; |
729 recipe.MashStep[i].Ramptime = 1; |
729 } else { |
730 } else { |
730 recipe.MashStep[i].Ramptime = (int)(recipe.MashStep[i].Temperature - recipe.MashStep[i - 1].Temperature); |
731 recipe.MashStep[i].Ramptime = (int)(recipe.MashStep[i].Temperature - recipe.MashStep[i - 1].Temperature); |
731 } |
732 } |
|
733 if (recipe.MashStep[i].Type == MASHTYPE_INFUSION) { |
|
734 sprintf(tmp, "Stap %d infusie temperatuur", i); |
|
735 mintemp = recipe.MashStep[i].Temperature; |
|
736 EditFloat(tmp, &recipe.MashStep[i].Infusion_temp, mintemp, 100, 2); |
|
737 sprintf(tmp, "Stap %d infusie volume", i); |
|
738 EditFloat(tmp, &recipe.MashStep[i].Infusion_amount, 0.5, 1000.0, 2); |
|
739 } else { |
|
740 recipe.MashStep[i].Infusion_temp = recipe.MashStep[i].Infusion_amount = 0.0; |
|
741 } |
732 } |
742 } |
733 mintemp = recipe.MashStep[mashsteps].Temperature; |
743 mintemp = recipe.MashStep[mashsteps].Temperature; |
734 EditFloat("Uitmaischen temperatuur", &recipe.MashStep[7].Temperature, mintemp, 80, 2); |
744 EditFloat("Uitmaischen temperatuur", &recipe.MashStep[7].Temperature, mintemp, 80, 2); |
735 recipe.MashStep[7].Temperature = ((int)(recipe.MashStep[7].Temperature * 4)) / 4.0; |
745 recipe.MashStep[7].Temperature = ((int)(recipe.MashStep[7].Temperature * 4)) / 4.0; |
736 EditUint16("Uitmaischen tijd in minuten", &recipe.MashStep[7].Resttime, 1, 15); |
746 EditUint16("Uitmaischen tijd in minuten", &recipe.MashStep[7].Resttime, 1, 15); |