void lcd_material_set_material(uint8_t nr, uint8_t e) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)); #if TEMP_SENSOR_BED != 0 material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)); #endif material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)); eeprom_read_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); card.longFilename[8] = '\0'; if (material[e].temperature > HEATER_0_MAXTEMP - 15) material[e].temperature = HEATER_0_MAXTEMP - 15; #if TEMP_SENSOR_BED != 0 if (material[e].bed_temperature > BED_MAXTEMP - 15) material[e].bed_temperature = BED_MAXTEMP - 15; #endif material[e].change_temperature = eeprom_read_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(nr)); material[e].change_preheat_wait_time = eeprom_read_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(nr)); if (material[e].change_temperature < 10) material[e].change_temperature = material[e].temperature; lcd_material_store_current_material(); }
static void lcd_material_select_details_callback(uint8_t nr) { uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (nr == 0) { } else if (nr <= count) { char buffer[32]; char* c = buffer; nr -= 1; if (led_glow_dir) { c = float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)), c, PSTR("mm")); while(c < buffer + 10) *c++ = ' '; strcpy_P(c, PSTR("Flow:")); c += 5; c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)), c, PSTR("%")); }else{ c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)), c, PSTR("C")); *c++ = ' '; c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)), c, PSTR("C")); while(c < buffer + 10) *c++ = ' '; strcpy_P(c, PSTR("Fan: ")); c += 5; c = int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)), c, PSTR("%")); } lcd_lib_draw_string(5, 53, buffer); }else{ lcd_lib_draw_string_centerP(53, PSTR("Modify the settings")); } }
static void lcd_menu_change_material_select_material_details_callback(uint8_t nr) { char buffer[32]; char* c = buffer; if (led_glow_dir) { c = float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)), c, PSTR("mm")); while(c < buffer + 10) *c++ = ' '; strcpy_P(c, PSTR("Flow:")); c += 5; c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)), c, PSTR("%")); }else{ c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)), c, PSTR("C")); #if TEMP_SENSOR_BED != 0 *c++ = ' '; c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)), c, PSTR("C")); #endif while(c < buffer + 10) *c++ = ' '; strcpy_P(c, PSTR("Fan: ")); c += 5; c = int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)), c, PSTR("%")); } lcd_lib_draw_string(5, 53, buffer); }
void lcd_material_reset_defaults() { //Fill in the defaults SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Materials reset"); char buffer[MATERIAL_NAME_LENGTH]; for (int a= 0; a< MATERIAL_PRESETS; a++) { strncpy_P(buffer, (char PROGMEM *) presets[a].name,MATERIAL_NAME_LENGTH); // this will pad out the whole length with 0 as needed. eeprom_write_block(buffer , EEPROM_MATERIAL_NAME_OFFSET(a), MATERIAL_NAME_LENGTH); material_preset temp; memcpy_P((void*) &temp,&presets[a],sizeof (material_preset)); eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(a) ,temp.temperature); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(a),temp.bed); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(a) ,temp.fan_speed); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(a) ,temp.flow); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(a) ,temp.diameter); } uint8_t e; for(e=0; e<EXTRUDERS; e++) { makeCustomName(e); strcpy(material_name[e],material_name_buf); lcd_material_store_current_material(); } eeprom_write_byte(EEPROM_MATERIAL_COUNT_OFFSET(), MATERIAL_PRESETS); lcd_lib_beep_ext(500,150); lcd_lib_beep_ext(750,100); }
void lcd_material_store_material(uint8_t nr) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr), material[active_extruder].temperature); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr), material[active_extruder].bed_temperature); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(nr), material[active_extruder].flow); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr), material[active_extruder].fan_speed); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr), material[active_extruder].diameter); //eeprom_write_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); }
void lcd_material_store_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].temperature); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].bed_temperature); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].fan_speed); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].flow); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].diameter); } }
void lcd_material_read_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); } }
void lcd_material_reset_defaults() { //Fill in the defaults char buffer[8]; strcpy_P(buffer, PSTR("PLA")); eeprom_write_block(buffer, EEPROM_MATERIAL_NAME_OFFSET(0), 4); eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(0), 210); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(0), 60); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(0), 100); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(0), 100); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(0), 2.85); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(0), 210); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(0), 0); strcpy_P(buffer, PSTR("ABS")); eeprom_write_block(buffer, EEPROM_MATERIAL_NAME_OFFSET(1), 4); eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(1), 260); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(1), 90); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(1), 50); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(1), 107); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(1), 2.85); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(1), 260); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(1), 0); strcpy_P(buffer, PSTR("CPE")); eeprom_write_block(buffer, EEPROM_MATERIAL_NAME_OFFSET(2), 5); eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(2), 250); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(2), 60); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(2), 50); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(2), 100); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(2), 2.85); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(2), 250); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(2), 0); eeprom_write_byte(EEPROM_MATERIAL_COUNT_OFFSET(), 3); }
void lcd_material_store_material(uint8_t nr) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr), material[active_extruder].temperature); #if TEMP_SENSOR_BED != 0 eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr), material[active_extruder].bed_temperature); #endif eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(nr), material[active_extruder].flow); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr), material[active_extruder].fan_speed); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr), material[active_extruder].diameter); //eeprom_write_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(nr), material[active_extruder].change_temperature); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(nr), material[active_extruder].change_preheat_wait_time); }
void lcd_material_store_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].temperature); #if TEMP_SENSOR_BED != 0 eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].bed_temperature); #endif eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].fan_speed); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].flow); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].diameter); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].change_temperature); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].change_preheat_wait_time); } }
void lcd_material_read_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); strcpy_P(material_name[e],PSTR("???")); eeprom_read_block(material_name[e], EEPROM_MATERIAL_NAME_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), MATERIAL_NAME_LENGTH); material_name[e][MATERIAL_NAME_LENGTH] = '\0'; } }
void lcd_material_set_material(uint8_t nr, uint8_t e) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)); material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)); material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)); eeprom_read_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); card.longFilename[8] = '\0'; if (material[e].temperature > HEATER_0_MAXTEMP - 15) material[e].temperature = HEATER_0_MAXTEMP - 15; if (material[e].bed_temperature > BED_MAXTEMP - 15) material[e].bed_temperature = BED_MAXTEMP - 15; lcd_material_store_current_material(); }
bool lcd_material_verify_material_settings() { SERIAL_ECHO_START; uint8_t max_mats = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); SERIAL_ECHOPAIR("Checking ", (unsigned long) max_mats); SERIAL_ECHOPAIR(" presets and ", (unsigned long) EXTRUDERS); SERIAL_ECHOLNPGM (" extruder settings:"); if (max_mats < 2 || max_mats > EEPROM_MATERIAL_SETTINGS_MAX_COUNT) return false; byte cnt =0; while(cnt < max_mats+EXTRUDERS) { SERIAL_ECHOPAIR("Checking preset # ",(unsigned long) cnt); if (eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt)) > HEATER_0_MAXTEMP) return false; if (eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(cnt)) > BED_MAXTEMP) return false; if (eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(cnt)) > 100) return false; if (eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(cnt)) > 1000) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) > 10.0) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) < 0.1) return false; strcpy_P (material_name_buf,"???"); eeprom_read_block(material_name_buf, EEPROM_MATERIAL_NAME_OFFSET(cnt), MATERIAL_NAME_LENGTH); material_name_buf[MATERIAL_NAME_LENGTH] = '\0'; if (cnt >= max_mats ) { SERIAL_ECHOPAIR(".....verified extruder setting # ",(unsigned long) cnt-max_mats);} else { SERIAL_ECHOPAIR(".....verified preset # ",(unsigned long) cnt);} SERIAL_ECHO(" ("); SERIAL_ECHO(material_name_buf); SERIAL_ECHO(")"); SERIAL_ECHOLN(""); cnt++; } return true; }
void lcd_material_read_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); #if TEMP_SENSOR_BED != 0 material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); #endif material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].change_temperature = eeprom_read_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].change_preheat_wait_time = eeprom_read_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); if (material[e].change_temperature < 10) material[e].change_temperature = material[e].temperature; } }
bool lcd_material_verify_material_settings() { uint8_t cnt = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (cnt < 2 || cnt > 16) return false; while(cnt > 0) { cnt --; if (eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt)) > HEATER_0_MAXTEMP) return false; if (eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(cnt)) > BED_MAXTEMP) return false; if (eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(cnt)) > 100) return false; if (eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(cnt)) > 1000) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) > 10.0) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) < 0.1) return false; } return true; }
static void lcd_menu_material_import() { if (!card.sdInserted) { LED_GLOW(); lcd_lib_encoder_pos = MAIN_MENU_ITEM_POS(0); lcd_info_screen(lcd_menu_material_select); lcd_lib_draw_string_centerP(15, PSTR("No SD-CARD!")); lcd_lib_draw_string_centerP(25, PSTR("Please insert card")); lcd_lib_update_screen(); card.release(); return; } if (!card.isOk()) { lcd_info_screen(lcd_menu_material_select); lcd_lib_draw_string_centerP(16, PSTR("Reading card...")); lcd_lib_update_screen(); card.initsd(); return; } card.setroot(); card.openFile("MATERIAL.TXT", true); if (!card.isFileOpen()) { lcd_info_screen(lcd_menu_material_select); lcd_lib_draw_string_centerP(15, PSTR("No export file")); lcd_lib_draw_string_centerP(25, PSTR("Found on card.")); lcd_lib_update_screen(); return; } char buffer[32]; uint8_t count = 0xFF; while(card.fgets(buffer, sizeof(buffer)) > 0) { buffer[sizeof(buffer)-1] = '\0'; char* c = strchr(buffer, '\n'); if (c) *c = '\0'; if(strcmp_P(buffer, PSTR("[material]")) == 0) { count++; }else if (count < EEPROM_MATERIAL_SETTINGS_MAX_COUNT) { c = strchr(buffer, '='); if (c) { *c++ = '\0'; if (strcmp_P(buffer, PSTR("name")) == 0) { eeprom_write_block(c, EEPROM_MATERIAL_NAME_OFFSET(count), 8); }else if (strcmp_P(buffer, PSTR("temperature")) == 0) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(count), strtol(c, NULL, 10)); }else if (strcmp_P(buffer, PSTR("bed_temperature")) == 0) { eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(count), strtol(c, NULL, 10)); }else if (strcmp_P(buffer, PSTR("fan_speed")) == 0) { eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(count), strtol(c, NULL, 10)); }else if (strcmp_P(buffer, PSTR("flow")) == 0) { eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(count), strtol(c, NULL, 10)); }else if (strcmp_P(buffer, PSTR("diameter")) == 0) { eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(count), strtod(c, NULL)); #ifdef USE_CHANGE_TEMPERATURE }else if (strcmp_P(buffer, PSTR("change_temp")) == 0) { eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(count), strtol(c, NULL, 10)); }else if (strcmp_P(buffer, PSTR("change_wait")) == 0) { eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(count), strtol(c, NULL, 10)); #endif } } } } count++; if (count > 0) { eeprom_write_byte(EEPROM_MATERIAL_COUNT_OFFSET(), count); } card.closefile(); currentMenu = lcd_menu_material_import_done; }
static void lcd_menu_material_export() { if (!card.sdInserted) { LED_GLOW(); lcd_lib_encoder_pos = MAIN_MENU_ITEM_POS(0); lcd_info_screen(lcd_menu_material_select); lcd_lib_draw_string_centerP(15, PSTR("No SD-CARD!")); lcd_lib_draw_string_centerP(25, PSTR("Please insert card")); lcd_lib_update_screen(); card.release(); return; } if (!card.isOk()) { lcd_info_screen(lcd_menu_material_select); lcd_lib_draw_string_centerP(16, PSTR("Reading card...")); lcd_lib_update_screen(); card.initsd(); return; } card.setroot(); card.openFile("MATERIAL.TXT", false); uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); for(uint8_t n=0; n<count; n++) { char buffer[32]; strcpy_P(buffer, PSTR("[material]\n")); card.write_string(buffer); strcpy_P(buffer, PSTR("name=")); char* ptr = buffer + strlen(buffer); eeprom_read_block(ptr, EEPROM_MATERIAL_NAME_OFFSET(n), 8); ptr[8] = '\0'; strcat_P(buffer, PSTR("\n")); card.write_string(buffer); strcpy_P(buffer, PSTR("temperature=")); ptr = buffer + strlen(buffer); int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(n)), ptr, PSTR("\n")); card.write_string(buffer); #if TEMP_SENSOR_BED != 0 strcpy_P(buffer, PSTR("bed_temperature=")); ptr = buffer + strlen(buffer); int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(n)), ptr, PSTR("\n")); card.write_string(buffer); #endif strcpy_P(buffer, PSTR("fan_speed=")); ptr = buffer + strlen(buffer); int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(n)), ptr, PSTR("\n")); card.write_string(buffer); strcpy_P(buffer, PSTR("flow=")); ptr = buffer + strlen(buffer); int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(n)), ptr, PSTR("\n")); card.write_string(buffer); strcpy_P(buffer, PSTR("diameter=")); ptr = buffer + strlen(buffer); float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(n)), ptr, PSTR("\n\n")); card.write_string(buffer); #ifdef USE_CHANGE_TEMPERATURE strcpy_P(buffer, PSTR("change_temp=")); ptr = buffer + strlen(buffer); float_to_string(eeprom_read_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(n)), ptr, PSTR("\n\n")); card.write_string(buffer); strcpy_P(buffer, PSTR("change_wait=")); ptr = buffer + strlen(buffer); float_to_string(eeprom_read_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(n)), ptr, PSTR("\n\n")); card.write_string(buffer); #endif } card.closefile(); currentMenu = lcd_menu_material_export_done; }
bool lcd_material_verify_material_settings() { bool hasCPE = false; uint8_t cnt = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (cnt < 2 || cnt > EEPROM_MATERIAL_SETTINGS_MAX_COUNT) return false; while(cnt > 0) { cnt --; if (eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt)) > HEATER_0_MAXTEMP) return false; #if TEMP_SENSOR_BED != 0 if (eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(cnt)) > BED_MAXTEMP) return false; #endif if (eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(cnt)) > 100) return false; if (eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(cnt)) > 1000) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) > 10.0) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) < 0.1) return false; eeprom_read_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(cnt), 8); if (strcmp_P(card.longFilename, PSTR("UPET")) == 0) { strcpy_P(card.longFilename, PSTR("CPE")); eeprom_write_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(cnt), 4); } if (strcmp_P(card.longFilename, PSTR("CPE")) == 0) { hasCPE = true; } if (eeprom_read_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(cnt)) > HEATER_0_MAXTEMP || eeprom_read_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(cnt)) < 10) { //Invalid temperature for change temperature. eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(cnt), eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt))); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(cnt), 0); } } cnt = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (!hasCPE && cnt < EEPROM_MATERIAL_SETTINGS_MAX_COUNT) { strcpy_P(card.longFilename, PSTR("CPE")); eeprom_write_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(cnt), 4); eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt), 250); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(cnt), 60); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(cnt), 50); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(cnt), 100); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt), 2.85); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(cnt), 250); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(cnt), 0); eeprom_write_byte(EEPROM_MATERIAL_COUNT_OFFSET(), cnt + 1); } return true; }