main/recipes.c

changeset 56
756d1a63d129
parent 54
7b134c27fadb
child 70
d6838a268020
equal deleted inserted replaced
55:38e1c91bfd88 56:756d1a63d129
157 /* 157 /*
158 * Hops that are added during the boil. 158 * Hops that are added during the boil.
159 * But check for whirlpool hops too. 159 * But check for whirlpool hops too.
160 */ 160 */
161 if (strcmp("NAME", _xml_element[4]) == 0) { 161 if (strcmp("NAME", _xml_element[4]) == 0) {
162 snprintf(_xml_add_name, 63, "%s", char_data_buffer); 162 _xml_add_name[0] = '\0';
163 strncat(_xml_add_name, char_data_buffer, 63);
163 } else if (strcmp("USE", _xml_element[4]) == 0) { 164 } else if (strcmp("USE", _xml_element[4]) == 0) {
164 _xml_add_valid = (strcmp("Boil", char_data_buffer) == 0); // Only "Boil" is a valid hop 165 _xml_add_valid = (strcmp("Boil", char_data_buffer) == 0); // Only "Boil" is a valid hop
165 if (strcmp("Aroma", char_data_buffer) == 0) { 166 if (strcmp("Aroma", char_data_buffer) == 0) {
166 recipe.Whirlpool7 = 30; 167 recipe.Whirlpool7 = 30;
167 } 168 }
179 } else if ((_xml_depth == 5) && (strcmp("FERMENTABLES", _xml_element[2]) == 0) && (strcmp("FERMENTABLE", _xml_element[3]) == 0)) { 180 } else if ((_xml_depth == 5) && (strcmp("FERMENTABLES", _xml_element[2]) == 0) && (strcmp("FERMENTABLE", _xml_element[3]) == 0)) {
180 /* 181 /*
181 * Fermentabes that must be added during the boil. 182 * Fermentabes that must be added during the boil.
182 */ 183 */
183 if (strcmp("NAME", _xml_element[4]) == 0) { 184 if (strcmp("NAME", _xml_element[4]) == 0) {
184 snprintf(_xml_add_name, 63, "%s", char_data_buffer); 185 _xml_add_name[0] = '\0';
186 strncat(_xml_add_name, char_data_buffer, 63);
185 } else if (strcmp("TYPE", _xml_element[4]) == 0) { 187 } else if (strcmp("TYPE", _xml_element[4]) == 0) {
186 if ((strcmp("Sugar", char_data_buffer) == 0)/* || (strcmp("Adjunct", char_data_buffer) == 0)*/) { 188 if ((strcmp("Sugar", char_data_buffer) == 0)/* || (strcmp("Adjunct", char_data_buffer) == 0)*/) {
187 _xml_add_type = ADDITION_FERMENTABLE; 189 _xml_add_type = ADDITION_FERMENTABLE;
188 _xml_add_time = 10; 190 _xml_add_time = 10;
189 } else { 191 } else {
195 } else if ((_xml_depth == 5) && (strcmp("MISCS", _xml_element[2]) == 0) && (strcmp("MISC", _xml_element[3]) == 0)) { 197 } else if ((_xml_depth == 5) && (strcmp("MISCS", _xml_element[2]) == 0) && (strcmp("MISC", _xml_element[3]) == 0)) {
196 /* 198 /*
197 * Check for Misc additions to add during the boil. 199 * Check for Misc additions to add during the boil.
198 */ 200 */
199 if (strcmp("NAME", _xml_element[4]) == 0) { 201 if (strcmp("NAME", _xml_element[4]) == 0) {
200 snprintf(_xml_add_name, 63, "%s", char_data_buffer); 202 _xml_add_name[0] = '\0';
203 strncat(_xml_add_name, char_data_buffer, 63);
201 } else if (strcmp("USE", _xml_element[4]) == 0) { 204 } else if (strcmp("USE", _xml_element[4]) == 0) {
202 _xml_add_valid = (strcmp("Boil", char_data_buffer) == 0); // Only "Boil" is a valid hop. 205 _xml_add_valid = (strcmp("Boil", char_data_buffer) == 0); // Only "Boil" is a valid hop.
203 } else if (strcmp("TYPE", _xml_element[4]) == 0) { 206 } else if (strcmp("TYPE", _xml_element[4]) == 0) {
204 if (strcmp("Spice", char_data_buffer) == 0) 207 if (strcmp("Spice", char_data_buffer) == 0)
205 _xml_add_type = ADDITION_SPICE; 208 _xml_add_type = ADDITION_SPICE;
215 _xml_add_time = atoi(char_data_buffer); 218 _xml_add_time = atoi(char_data_buffer);
216 } 219 }
217 } else if ((_xml_depth >= 4) && (strcmp("MASH", _xml_element[2]) == 0)) { 220 } else if ((_xml_depth >= 4) && (strcmp("MASH", _xml_element[2]) == 0)) {
218 if ((_xml_depth >= 6) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) { 221 if ((_xml_depth >= 6) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) {
219 if (strcmp("NAME", _xml_element[5]) == 0) { 222 if (strcmp("NAME", _xml_element[5]) == 0) {
220 snprintf(_xml_add_name, 31, "%s", char_data_buffer); 223 _xml_add_name[0] = '\0';
224 strncat(_xml_add_name, char_data_buffer, 63);
221 } else if (strcmp("TYPE", _xml_element[5]) == 0) { 225 } else if (strcmp("TYPE", _xml_element[5]) == 0) {
222 // Temperature Infusion Decoction 226 // Temperature Infusion Decoction
223 _xml_add_valid = (strcmp("Temperature", char_data_buffer) == 0); 227 _xml_add_valid = (strcmp("Temperature", char_data_buffer) == 0);
224 if (strcmp("Infusion", char_data_buffer) == 0) 228 if (strcmp("Infusion", char_data_buffer) == 0)
225 _xml_add_type = MASHTYPE_INFUSION; 229 _xml_add_type = MASHTYPE_INFUSION;
291 Addition_Add(_xml_add_name, _xml_add_type, _xml_add_time); 295 Addition_Add(_xml_add_name, _xml_add_type, _xml_add_time);
292 } 296 }
293 } 297 }
294 if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) { 298 if ((_xml_depth == 5) && (strcmp("MASH_STEP", _xml_element[4]) == 0)) {
295 _xml_mashsteps++; 299 _xml_mashsteps++;
296 sprintf(recipe.MashStep[_xml_mashsteps].Name, "%s", _xml_add_name); 300 recipe.MashStep[_xml_mashsteps].Name[0] = '\0';
301 strncat(recipe.MashStep[_xml_mashsteps].Name, _xml_add_name, 31);
297 recipe.MashStep[_xml_mashsteps].Type = _xml_add_type; 302 recipe.MashStep[_xml_mashsteps].Type = _xml_add_type;
298 recipe.MashStep[_xml_mashsteps].Temperature = _xml_add_temp; 303 recipe.MashStep[_xml_mashsteps].Temperature = _xml_add_temp;
299 recipe.MashStep[_xml_mashsteps].Resttime = _xml_add_time; 304 recipe.MashStep[_xml_mashsteps].Resttime = _xml_add_time;
300 recipe.MashStep[_xml_mashsteps].Ramptime = _xml_add_ramp; 305 recipe.MashStep[_xml_mashsteps].Ramptime = _xml_add_ramp;
301 if (_xml_add_type == MASHTYPE_INFUSION) { 306 if (_xml_add_type == MASHTYPE_INFUSION) {
442 DIR *dir; 447 DIR *dir;
443 struct dirent *de; 448 struct dirent *de;
444 size_t bytes; 449 size_t bytes;
445 uint8_t *dst; 450 uint8_t *dst;
446 uint16_t y; 451 uint16_t y;
447 char filename[256], newname[256]; 452 char filename[288], newname[288];
448 int rc; 453 int rc;
449 454
450 switch (Main_Screen) { 455 switch (Main_Screen) {
451 case MAIN_TOOLS_RECIPE: 456 case MAIN_TOOLS_RECIPE:
452 TopMessage((char *)"Recepten importeren"); 457 TopMessage((char *)"Recepten importeren");
457 de = readdir(dir); 462 de = readdir(dir);
458 while (de) { 463 while (de) {
459 if (strstr(de->d_name, ".xml") || strstr(de->d_name, ".XML")) { 464 if (strstr(de->d_name, ".xml") || strstr(de->d_name, ".XML")) {
460 _fg = TFT_YELLOW; 465 _fg = TFT_YELLOW;
461 TFT_print(de->d_name, 2, y); 466 TFT_print(de->d_name, 2, y);
462 snprintf(filename, 255, "/sdcard/recipe/%s", de->d_name); 467 snprintf(filename, 287, "/sdcard/recipe/%s", de->d_name);
463 snprintf(newname, 255, "/sdcard/recipe/%s", de->d_name); 468 snprintf(newname, 287, "/sdcard/recipe/%s", de->d_name);
464 newname[strlen(newname) -2] = 'o'; 469 newname[strlen(newname) -2] = 'o';
465 newname[strlen(newname) -1] = 'k'; 470 newname[strlen(newname) -1] = 'k';
466 rc = ParseRecipe(filename, de->d_name); 471 rc = ParseRecipe(filename, de->d_name);
467 ESP_LOGI(TAG, "Recipe %s parsed, rc=%d", filename, rc); 472 ESP_LOGI(TAG, "Recipe %s parsed, rc=%d", filename, rc);
468 if (rc == 0) { 473 if (rc == 0) {
510 { 515 {
511 uint32_t crc1, crc2; 516 uint32_t crc1, crc2;
512 uint8_t *dst; 517 uint8_t *dst;
513 int mashsteps; 518 int mashsteps;
514 uint16_t y; 519 uint16_t y;
515 char tmp[32]; 520 char tmp[64];
516 float mintemp; 521 float mintemp;
517 522
518 switch (Main_Screen) { 523 switch (Main_Screen) {
519 case MAIN_TOOLS_RECIPE: 524 case MAIN_TOOLS_RECIPE:
520 if (r_Imported) { 525 if (r_Imported) {

mercurial