main/recipes.c

changeset 17
f3451031d6c6
parent 16
d43b393a4461
child 19
49e2960d4642
equal deleted inserted replaced
16:d43b393a4461 17:f3451031d6c6
45 * @param Type The addition type. 45 * @param Type The addition type.
46 * @param Time The addition time to add. 46 * @param Time The addition time to add.
47 */ 47 */
48 void Addition_Add(char *Name, uint8_t Type, uint16_t Time) 48 void Addition_Add(char *Name, uint8_t Type, uint16_t Time)
49 { 49 {
50 printf("Addition_Add(%s, %d, %d)\n", Name, Type, Time); 50 // printf("Addition_Add(%s, %d, %d)\n", Name, Type, Time);
51 if (! recipe.Additions) { 51 if (! recipe.Additions) {
52 // No entries yet, add the first one. 52 // No entries yet, add the first one.
53 sprintf(recipe.Addition[recipe.Additions].Name, "%s", Name); 53 sprintf(recipe.Addition[recipe.Additions].Name, "%s", Name);
54 recipe.Addition[recipe.Additions].Type = Type; 54 recipe.Addition[recipe.Additions].Type = Type;
55 recipe.Addition[recipe.Additions].Time = Time; 55 recipe.Addition[recipe.Additions].Time = Time;
67 } 67 }
68 68
69 // A new entry and we already have some. Add it and keep the list sorted. 69 // A new entry and we already have some. Add it and keep the list sorted.
70 for (int i = 0; i < recipe.Additions; i++) { 70 for (int i = 0; i < recipe.Additions; i++) {
71 if (Time > recipe.Addition[i].Time) { 71 if (Time > recipe.Addition[i].Time) {
72 printf("Insert at %d\n", i); 72 // printf("Insert at %d\n", i);
73 // Nake 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;
78 } 78 }
359 recipe.MashStep[0].Type = MASHTYPE_INFUSION; 359 recipe.MashStep[0].Type = MASHTYPE_INFUSION;
360 /* 360 /*
361 * Because we inserted the first infusion step and the next (original first) 361 * Because we inserted the first infusion step and the next (original first)
362 * step is infusion, change that one into temperature. 362 * step is infusion, change that one into temperature.
363 */ 363 */
364 if (recipe.MashStep[1].Type == MASHTYPE_INFUSION) 364 if (recipe.MashStep[1].Type == MASHTYPE_INFUSION) {
365 recipe.MashStep[1].Type = MASHTYPE_TEMPERATURE; 365 recipe.MashStep[1].Type = MASHTYPE_TEMPERATURE;
366 recipe.MashStep[1].Infusion_temp = recipe.MashStep[1].Infusion_amount = 0.0;
367 }
366 368
367 if (! recipe.MashStep[7].Resttime) { 369 if (! recipe.MashStep[7].Resttime) {
368 // Move last mash step to position 7. 370 // Move last mash step to position 7.
369 for (int i = 6; i > 1; i--) { 371 for (int i = 6; i > 1; i--) {
370 if (recipe.MashStep[i].Resttime) { 372 if (recipe.MashStep[i].Resttime) {
386 break; 388 break;
387 } 389 }
388 } 390 }
389 } 391 }
390 392
391 #if 1 393 #if 0
392 printf("Recipe: %s\n", recipe.Name); 394 printf("Recipe: %s\n", recipe.Name);
393 printf("Code : %s\n", recipe.Code); 395 printf("Code : %s\n", recipe.Code);
394 printf("Boil time %d minutes\n", recipe.BoilTime); 396 printf("Boil time %d minutes\n", recipe.BoilTime);
395 printf("n Stepname T temp time ramp inft infa\n"); 397 printf("n Stepname T temp time ramp inft infa\n");
396 printf("- ------------------------------ - ----- ---- ---- ----- -----\n"); 398 printf("- ------------------------------ - ----- ---- ---- ----- -----\n");

mercurial