From e3d4bbb0cf8166a568d5a98c1987f28ef0ca1d2d Mon Sep 17 00:00:00 2001 From: TinkerGnome Date: Wed, 18 Feb 2015 22:00:50 +0100 Subject: [PATCH] use local variables as string buffer whenever possible --- Marlin/Configuration.h | 2 +- Marlin/SdBaseFile.cpp | 4 +- Marlin/UltiLCD2.cpp | 4 +- Marlin/UltiLCD2_hi_lib.cpp | 3 +- Marlin/UltiLCD2_menu_first_run.cpp | 8 +- Marlin/UltiLCD2_menu_maintenance.cpp | 129 ++++--- Marlin/UltiLCD2_menu_material.cpp | 56 +-- Marlin/UltiLCD2_menu_print.cpp | 131 ++++--- Marlin/UltiLCD2_menu_utils.cpp | 19 +- Marlin/UltiLCD2_menu_utils.h | 4 +- Marlin/cardreader.cpp | 3 +- Marlin/package.sh | 10 +- Marlin/tinkergnome.cpp | 518 ++++++++++++++------------- 13 files changed, 450 insertions(+), 441 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e21126457..00427d5ff 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -10,7 +10,7 @@ // build by the user have been successfully uploaded into firmware. #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #ifndef STRING_CONFIG_H_AUTHOR -#define STRING_CONFIG_H_AUTHOR "Tinker 15.01a" // Who made the changes. +#define STRING_CONFIG_H_AUTHOR "Tinker_15.02-RC1" // Who made the changes. #endif // SERIAL_PORT selects which serial port should be used for communication with the host. diff --git a/Marlin/SdBaseFile.cpp b/Marlin/SdBaseFile.cpp index 94d30e033..9f767d7df 100644 --- a/Marlin/SdBaseFile.cpp +++ b/Marlin/SdBaseFile.cpp @@ -1116,7 +1116,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { - longFilename[0] = '\0'; + memset( longFilename, '\0', LONG_FILENAME_LENGTH ); } while (1) { @@ -1151,7 +1151,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { longFilename[n+12] = VFAT->name3[2]; //If this VFAT entry is the last one, add a NUL terminator at the end of the string if (VFAT->sequenceNumber & 0x40) - longFilename[n+13] = '\0'; + longFilename[n+13] = '\0'; } } // return if normal file or subdirectory diff --git a/Marlin/UltiLCD2.cpp b/Marlin/UltiLCD2.cpp index a07809b13..a26590a87 100644 --- a/Marlin/UltiLCD2.cpp +++ b/Marlin/UltiLCD2.cpp @@ -256,7 +256,7 @@ static void lcd_main_maintenance() static const menu_t & get_main_menuoption(uint8_t nr, menu_t &opt) { - menu_index = 0; + uint8_t menu_index = 0; if (nr == menu_index++) { opt.setData(MENU_NORMAL, lcd_main_print); @@ -274,7 +274,7 @@ static const menu_t & get_main_menuoption(uint8_t nr, menu_t &opt) void drawMainSubmenu(uint8_t nr, uint8_t &flags) { - menu_index = 0; + uint8_t menu_index = 0; if (nr == menu_index++) { LCDMenu::drawMenuString_P(LCD_CHAR_MARGIN_LEFT+3 diff --git a/Marlin/UltiLCD2_hi_lib.cpp b/Marlin/UltiLCD2_hi_lib.cpp index 2ccbd50d7..68079e998 100644 --- a/Marlin/UltiLCD2_hi_lib.cpp +++ b/Marlin/UltiLCD2_hi_lib.cpp @@ -183,13 +183,14 @@ void lcd_scroll_menu(const char* menuNameP, int8_t entryCount, entryNameCallback uint8_t drawOffset = 10 - (uint16_t(viewPos) % 8); uint8_t itemOffset = uint16_t(viewPos) / 8; + char buffer[32]; for(uint8_t n=0; n<6; n++) { uint8_t itemIdx = n + itemOffset; if (itemIdx >= entryCount) continue; - char* ptr = entryNameCallback(itemIdx); + char* ptr = entryNameCallback(itemIdx, buffer); //ptr[10] = '\0'; ptr[20] = '\0'; if (itemIdx == selIndex) diff --git a/Marlin/UltiLCD2_menu_first_run.cpp b/Marlin/UltiLCD2_menu_first_run.cpp index 84157afcc..39831f638 100644 --- a/Marlin/UltiLCD2_menu_first_run.cpp +++ b/Marlin/UltiLCD2_menu_first_run.cpp @@ -444,11 +444,11 @@ static void lcd_menu_first_run_material_select_1() lcd_lib_update_screen(); } -static char* lcd_material_select_callback(uint8_t nr) +static char* lcd_material_select_callback(uint8_t nr, char *buffer) { - eeprom_read_block(LCD_CACHE_FILENAME(0), EEPROM_MATERIAL_NAME_OFFSET(nr), 8); - LCD_CACHE_FILENAME(0)[8] = '\0'; - return LCD_CACHE_FILENAME(0); + eeprom_read_block(buffer, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); + buffer[8] = '\0'; + return buffer; } static void lcd_material_select_details_callback(uint8_t nr) diff --git a/Marlin/UltiLCD2_menu_maintenance.cpp b/Marlin/UltiLCD2_menu_maintenance.cpp index 6fd5cd433..0b15352ab 100644 --- a/Marlin/UltiLCD2_menu_maintenance.cpp +++ b/Marlin/UltiLCD2_menu_maintenance.cpp @@ -46,95 +46,93 @@ void lcd_menu_maintenance() lcd_lib_update_screen(); } -static char* lcd_advanced_item(uint8_t nr) +static char* lcd_advanced_item(uint8_t nr, char *buffer) { uint8_t index(0); if (nr == index++) { - strcpy_P(card.longFilename, PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); } else if (nr == index++) { - strcpy_P(card.longFilename, PSTR("LED settings")); + strcpy_P(buffer, PSTR("LED settings")); } else if (nr == index++) #if EXTRUDERS < 2 - strcpy_P(card.longFilename, PSTR("Heatup nozzle")); + strcpy_P(buffer, PSTR("Heatup nozzle")); #else - strcpy_P(card.longFilename, PSTR("Heatup first nozzle")); + strcpy_P(buffer, PSTR("Heatup first nozzle")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Heatup second nozzle")); + strcpy_P(buffer, PSTR("Heatup second nozzle")); #endif #if TEMP_SENSOR_BED != 0 else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Heatup buildplate")); + strcpy_P(buffer, PSTR("Heatup buildplate")); #endif else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Home head")); + strcpy_P(buffer, PSTR("Home head")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Lower buildplate")); + strcpy_P(buffer, PSTR("Lower buildplate")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Raise buildplate")); + strcpy_P(buffer, PSTR("Raise buildplate")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Insert material")); + strcpy_P(buffer, PSTR("Insert material")); else if (nr == index++) #if EXTRUDERS < 2 - strcpy_P(card.longFilename, PSTR("Move material")); + strcpy_P(buffer, PSTR("Move material")); #else - strcpy_P(card.longFilename, PSTR("Move material (1)")); + strcpy_P(buffer, PSTR("Move material (1)")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Move material (2)")); + strcpy_P(buffer, PSTR("Move material (2)")); #endif else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Set fan speed")); + strcpy_P(buffer, PSTR("Set fan speed")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Retraction settings")); + strcpy_P(buffer, PSTR("Retraction settings")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Motion settings")); + strcpy_P(buffer, PSTR("Motion settings")); else if ((ui_mode & UI_MODE_EXPERT) && (nr == index++)) - strcpy_P(card.longFilename, PSTR("Adjust buildplate")); + strcpy_P(buffer, PSTR("Adjust buildplate")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Expert settings")); + strcpy_P(buffer, PSTR("Expert settings")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Version")); + strcpy_P(buffer, PSTR("Version")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Runtime stats")); + strcpy_P(buffer, PSTR("Runtime stats")); else if (nr == index++) - strcpy_P(card.longFilename, PSTR("Factory reset")); + strcpy_P(buffer, PSTR("Factory reset")); else - strcpy_P(card.longFilename, PSTR("???")); + strcpy_P(buffer, PSTR("???")); - return card.longFilename; + return buffer; } static void lcd_advanced_details(uint8_t nr) { - LCD_CACHE_FILENAME(1)[0] = '\0'; + char buffer[32]; + buffer[0] = '\0'; if (!(ui_mode & UI_MODE_EXPERT) && (nr > 8+BED_MENU_OFFSET+2*EXTRUDERS)) ++nr; if (nr == 1) { - int_to_string(led_brightness_level, LCD_CACHE_FILENAME(1), PSTR("%")); + int_to_string(led_brightness_level, buffer, PSTR("%")); }else if (nr == 2) { - int_to_string(int(dsp_temperature[0]), LCD_CACHE_FILENAME(1), PSTR("C/")); - int_to_string(int(target_temperature[0]), LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("C")); + int_to_string(int(target_temperature[0]), int_to_string(int(dsp_temperature[0]), buffer, PSTR("C/")), PSTR("C")); #if EXTRUDERS > 1 }else if (nr == 3) { - int_to_string(int(dsp_temperature[1]), LCD_CACHE_FILENAME(1), PSTR("C/")); - int_to_string(int(target_temperature[1]), LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("C")); + int_to_string(int(target_temperature[1]), int_to_string(int(dsp_temperature[1]), buffer, PSTR("C/")), PSTR("C")); #endif #if TEMP_SENSOR_BED != 0 }else if (nr == 2 + EXTRUDERS) { - int_to_string(int(dsp_temperature_bed), LCD_CACHE_FILENAME(1), PSTR("C/")); - int_to_string(int(target_temperature_bed), LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("C")); + int_to_string(int(target_temperature_bed), int_to_string(int(dsp_temperature_bed), buffer, PSTR("C/")), PSTR("C")); #endif }else if (nr == 6 + BED_MENU_OFFSET + EXTRUDERS * 2) { - int_to_string(int(fanSpeed) * 100 / 255, LCD_CACHE_FILENAME(1), PSTR("%")); + int_to_string(int(fanSpeed) * 100 / 255, buffer, PSTR("%")); }else if (nr == 11 + BED_MENU_OFFSET + EXTRUDERS * 2) { lcd_lib_draw_stringP(5, BOTTOM_MENU_YPOS, PSTR(STRING_CONFIG_H_AUTHOR)); @@ -142,7 +140,7 @@ static void lcd_advanced_details(uint8_t nr) }else{ return; } - lcd_lib_draw_string_left(BOTTOM_MENU_YPOS, LCD_CACHE_FILENAME(1)); + lcd_lib_draw_string_left(BOTTOM_MENU_YPOS, buffer); } static void homeHead() @@ -313,9 +311,10 @@ static void lcd_menu_maintenance_extrude() lcd_lib_draw_string_centerP(40, PSTR("Rotate to extrude")); lcd_lib_draw_string_centerP(BOTTOM_MENU_YPOS, PSTR("Click to return")); - int_to_string(int(dsp_temperature[active_extruder]), LCD_CACHE_FILENAME(0), PSTR("C/")); - int_to_string(int(target_temperature[active_extruder]), LCD_CACHE_FILENAME(0)+strlen(LCD_CACHE_FILENAME(0)), PSTR("C")); - lcd_lib_draw_string_center(20, LCD_CACHE_FILENAME(0)); + char buffer[32]; + ; + int_to_string(int(target_temperature[active_extruder]), int_to_string(int(dsp_temperature[active_extruder]), buffer, PSTR("C/")), PSTR("C")); + lcd_lib_draw_string_center(20, buffer); lcd_lib_draw_heater(LCD_GFX_WIDTH/2-2, 30, getHeaterPower(active_extruder)); lcd_lib_update_screen(); } @@ -418,17 +417,17 @@ static void lcd_menu_advanced_factory_reset() lcd_lib_update_screen(); } -static char* lcd_retraction_item(uint8_t nr) +static char* lcd_retraction_item(uint8_t nr, char *buffer) { if (nr == 0) - strcpy_P(card.longFilename, PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); else if (nr == 1) - strcpy_P(card.longFilename, PSTR("Retract length")); + strcpy_P(buffer, PSTR("Retract length")); else if (nr == 2) - strcpy_P(card.longFilename, PSTR("Retract speed")); + strcpy_P(buffer, PSTR("Retract speed")); else - strcpy_P(card.longFilename, PSTR("???")); - return card.longFilename; + strcpy_P(buffer, PSTR("???")); + return buffer; } static void lcd_retraction_details(uint8_t nr) @@ -460,29 +459,29 @@ static void lcd_menu_maintenance_retraction() } } -static char* lcd_motion_item(uint8_t nr) +static char* lcd_motion_item(uint8_t nr, char *buffer) { if (nr == 0) - strcpy_P(card.longFilename, PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); else if (nr == 1) - strcpy_P(card.longFilename, PSTR("Acceleration")); + strcpy_P(buffer, PSTR("Acceleration")); else if (nr == 2) - strcpy_P(card.longFilename, PSTR("X/Y Jerk")); + strcpy_P(buffer, PSTR("X/Y Jerk")); else if (nr == 3) - strcpy_P(card.longFilename, PSTR("Max speed X")); + strcpy_P(buffer, PSTR("Max speed X")); else if (nr == 4) - strcpy_P(card.longFilename, PSTR("Max speed Y")); + strcpy_P(buffer, PSTR("Max speed Y")); else if (nr == 5) - strcpy_P(card.longFilename, PSTR("Max speed Z")); + strcpy_P(buffer, PSTR("Max speed Z")); else if (nr == 6) - strcpy_P(card.longFilename, PSTR("Current X/Y")); + strcpy_P(buffer, PSTR("Current X/Y")); else if (nr == 7) - strcpy_P(card.longFilename, PSTR("Current Z")); + strcpy_P(buffer, PSTR("Current Z")); else if (nr == 8) - strcpy_P(card.longFilename, PSTR("Current E")); + strcpy_P(buffer, PSTR("Current E")); else - strcpy_P(card.longFilename, PSTR("???")); - return card.longFilename; + strcpy_P(buffer, PSTR("???")); + return buffer; } static void lcd_motion_details(uint8_t nr) @@ -541,25 +540,25 @@ static void lcd_menu_maintenance_motion() } } -static char* lcd_led_item(uint8_t nr) +static char* lcd_led_item(uint8_t nr, char *buffer) { if (nr == 0) - strcpy_P(card.longFilename, PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); else if (nr == 1) - strcpy_P(card.longFilename, PSTR("Brightness")); + strcpy_P(buffer, PSTR("Brightness")); else if (nr == 2) - strcpy_P(card.longFilename, PSTR(" Always On")); + strcpy_P(buffer, PSTR(" Always On")); else if (nr == 3) - strcpy_P(card.longFilename, PSTR(" Always Off")); + strcpy_P(buffer, PSTR(" Always Off")); else if (nr == 4) - strcpy_P(card.longFilename, PSTR(" On while printing")); + strcpy_P(buffer, PSTR(" On while printing")); else if (nr == 5) - strcpy_P(card.longFilename, PSTR(" Glow when done")); + strcpy_P(buffer, PSTR(" Glow when done")); else - strcpy_P(card.longFilename, PSTR("???")); + strcpy_P(buffer, PSTR("???")); if (nr - 2 == led_mode) - card.longFilename[0] = '>'; - return card.longFilename; + buffer[0] = '>'; + return buffer; } static void lcd_led_details(uint8_t nr) diff --git a/Marlin/UltiLCD2_menu_material.cpp b/Marlin/UltiLCD2_menu_material.cpp index 8e915d630..05be8db57 100644 --- a/Marlin/UltiLCD2_menu_material.cpp +++ b/Marlin/UltiLCD2_menu_material.cpp @@ -303,11 +303,11 @@ static void lcd_menu_change_material_insert() lcd_lib_update_screen(); } -static char* lcd_menu_change_material_select_material_callback(uint8_t nr) +static char* lcd_menu_change_material_select_material_callback(uint8_t nr, char *buffer) { - eeprom_read_block(LCD_CACHE_FILENAME(0), EEPROM_MATERIAL_NAME_OFFSET(nr), 8); - LCD_CACHE_FILENAME(0)[8] = '\0'; - return LCD_CACHE_FILENAME(0); + eeprom_read_block(buffer, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); + buffer[8] = '\0'; + return buffer; } static void lcd_menu_change_material_select_material_details_callback(uint8_t nr) @@ -520,22 +520,22 @@ static void lcd_menu_material_import() menu.replace_menu(menu_t(lcd_menu_material_import_done)); } -static char* lcd_material_select_callback(uint8_t nr) +static char* lcd_material_select_callback(uint8_t nr, char *buffer) { uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (nr == 0) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); else if (nr == count + 1) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Customize")); + strcpy_P(buffer, PSTR("Customize")); else if (nr == count + 2) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Export to SD")); + strcpy_P(buffer, PSTR("Export to SD")); else if (nr == count + 3) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Import from SD")); + strcpy_P(buffer, PSTR("Import from SD")); else{ - eeprom_read_block(LCD_CACHE_FILENAME(0), EEPROM_MATERIAL_NAME_OFFSET(nr - 1), 8); - LCD_CACHE_FILENAME(0)[8] = '\0'; + eeprom_read_block(buffer, EEPROM_MATERIAL_NAME_OFFSET(nr - 1), 8); + buffer[8] = '\0'; } - return LCD_CACHE_FILENAME(0); + return buffer; } static void lcd_material_select_details_callback(uint8_t nr) @@ -618,27 +618,27 @@ static void lcd_menu_material_selected() lcd_lib_update_screen(); } -static char* lcd_material_settings_callback(uint8_t nr) +static char* lcd_material_settings_callback(uint8_t nr, char *buffer) { if (nr == 0) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); else if (nr == 1) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Temperature")); + strcpy_P(buffer, PSTR("Temperature")); #if TEMP_SENSOR_BED != 0 else if (nr == 2) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Heated buildplate")); + strcpy_P(buffer, PSTR("Heated buildplate")); #endif else if (nr == 2 + BED_MENU_OFFSET) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Diameter")); + strcpy_P(buffer, PSTR("Diameter")); else if (nr == 3 + BED_MENU_OFFSET) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Fan")); + strcpy_P(buffer, PSTR("Fan")); else if (nr == 4 + BED_MENU_OFFSET) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Flow %")); + strcpy_P(buffer, PSTR("Flow %")); else if (nr == 5 + BED_MENU_OFFSET) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Store as preset")); + strcpy_P(buffer, PSTR("Store as preset")); else - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("???")); - return LCD_CACHE_FILENAME(0); + strcpy_P(buffer, PSTR("???")); + return buffer; } static void lcd_material_settings_details_callback(uint8_t nr) @@ -695,18 +695,18 @@ static void lcd_menu_material_settings() } } -static char* lcd_menu_material_settings_store_callback(uint8_t nr) +static char* lcd_menu_material_settings_store_callback(uint8_t nr, char *buffer) { uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (nr == 0) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); else if (nr > count) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("New preset")); + strcpy_P(buffer, PSTR("New preset")); else{ - eeprom_read_block(LCD_CACHE_FILENAME(0), EEPROM_MATERIAL_NAME_OFFSET(nr - 1), 8); - LCD_CACHE_FILENAME(0)[8] = '\0'; + eeprom_read_block(buffer, EEPROM_MATERIAL_NAME_OFFSET(nr - 1), 8); + buffer[8] = '\0'; } - return LCD_CACHE_FILENAME(0); + return buffer; } static void lcd_menu_material_settings_store_details_callback(uint8_t nr) diff --git a/Marlin/UltiLCD2_menu_print.cpp b/Marlin/UltiLCD2_menu_print.cpp index cfb6bb53a..74a89f1e5 100644 --- a/Marlin/UltiLCD2_menu_print.cpp +++ b/Marlin/UltiLCD2_menu_print.cpp @@ -180,40 +180,44 @@ static void cardUpdir() card.updir(); } -static char* lcd_sd_menu_filename_callback(uint8_t nr) +static char* lcd_sd_menu_filename_callback(uint8_t nr, char *buffer) { //This code uses the card.longFilename as buffer to store the filename, to save memory. if (nr == 0) { if (card.atRoot()) { - strcpy_P(card.longFilename, PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); }else{ - strcpy_P(card.longFilename, PSTR("< BACK")); + strcpy_P(buffer, PSTR("< BACK")); } }else{ - card.longFilename[0] = '\0'; - for(uint8_t idx=0; idx 1 else if (index++ == nr) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Temperature 2")); + strcpy_P(buffer, PSTR("Temperature 2")); #endif #if TEMP_SENSOR_BED != 0 else if (index++ == nr) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Buildplate temp.")); + strcpy_P(buffer, PSTR("Buildplate temp.")); #endif else if (index++ == nr) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Fan speed")); + strcpy_P(buffer, PSTR("Fan speed")); else if (index++ == nr) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Material flow")); + strcpy_P(buffer, PSTR("Material flow")); #if EXTRUDERS > 1 else if (index++ == nr) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Material flow 2")); + strcpy_P(buffer, PSTR("Material flow 2")); #endif else if (index++ == nr) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Retraction")); + strcpy_P(buffer, PSTR("Retraction")); else if (index++ == nr) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("LED Brightness")); + strcpy_P(buffer, PSTR("LED Brightness")); else - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("???")); - return LCD_CACHE_FILENAME(0); + strcpy_P(buffer, PSTR("???")); + return buffer; } static void tune_item_details_callback(uint8_t nr) { - char* c = LCD_CACHE_FILENAME(0); + char buffer[32]; if (nr == 1) - c = int_to_string(feedmultiply, c, PSTR("%")); + int_to_string(feedmultiply, buffer, PSTR("%")); else if (nr == 2) { - c = int_to_string(dsp_temperature[0], c, PSTR("C")); - *c++ = '/'; - c = int_to_string(target_temperature[0], c, PSTR("C")); + int_to_string(target_temperature[0], int_to_string(dsp_temperature[0], buffer, PSTR("C/")), PSTR("C")); } #if EXTRUDERS > 1 else if (nr == 3) { - c = int_to_string(dsp_temperature[1], c, PSTR("C")); - *c++ = '/'; - c = int_to_string(target_temperature[1], c, PSTR("C")); + int_to_string(target_temperature[1], int_to_string(dsp_temperature[1], buffer, PSTR("C/")), PSTR("C")); } #endif #if TEMP_SENSOR_BED != 0 else if (nr == 2 + EXTRUDERS) { - c = int_to_string(dsp_temperature_bed, c, PSTR("C")); - *c++ = '/'; - c = int_to_string(target_temperature_bed, c, PSTR("C")); + int_to_string(target_temperature_bed, int_to_string(dsp_temperature_bed, buffer, PSTR("C/")), PSTR("C")); } #endif else if (nr == 2 + BED_MENU_OFFSET + EXTRUDERS) - c = int_to_string(int(fanSpeed) * 100 / 255, c, PSTR("%")); + int_to_string(int(fanSpeed) * 100 / 255, buffer, PSTR("%")); else if (nr == 3 + BED_MENU_OFFSET + EXTRUDERS) - c = int_to_string(extrudemultiply[0], c, PSTR("%")); + int_to_string(extrudemultiply[0], buffer, PSTR("%")); #if EXTRUDERS > 1 else if (nr == 4 + BED_MENU_OFFSET + EXTRUDERS) - c = int_to_string(extrudemultiply[1], c, PSTR("%")); + int_to_string(extrudemultiply[1], buffer, PSTR("%")); #endif else if (nr == 5 + BED_MENU_OFFSET + EXTRUDERS) { - c = int_to_string(led_brightness_level, c, PSTR("%")); + int_to_string(led_brightness_level, buffer, PSTR("%")); if (led_mode == LED_MODE_ALWAYS_ON || led_mode == LED_MODE_WHILE_PRINTING || led_mode == LED_MODE_BLINK_ON_DONE) analogWrite(LED_PIN, 255 * int(led_brightness_level) / 100); } else return; - lcd_lib_draw_string(5, BOTTOM_MENU_YPOS, LCD_CACHE_FILENAME(0)); + lcd_lib_draw_string(5, BOTTOM_MENU_YPOS, buffer); } void lcd_menu_print_tune_heatup_nozzle0() @@ -888,36 +882,37 @@ void lcd_menu_print_tune() } } -static char* lcd_retraction_item(uint8_t nr) +static char* lcd_retraction_item(uint8_t nr, char *buffer) { if (nr == 0) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); else if (nr == 1) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Retract length")); + strcpy_P(buffer, PSTR("Retract length")); else if (nr == 2) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Retract speed")); + strcpy_P(buffer, PSTR("Retract speed")); #if EXTRUDERS > 1 else if (nr == 3) - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Extruder change len")); + strcpy_P(buffer, PSTR("Extruder change len")); #endif else - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("???")); - return LCD_CACHE_FILENAME(0); + strcpy_P(buffer, PSTR("???")); + return buffer; } static void lcd_retraction_details(uint8_t nr) { - if (nr == 0) - return; - else if(nr == 1) - float_to_string(retract_length, LCD_CACHE_FILENAME(0), PSTR("mm")); + char buffer[32]; + if(nr == 1) + float_to_string(retract_length, buffer, PSTR("mm")); else if(nr == 2) - int_to_string(retract_feedrate / 60 + 0.5, LCD_CACHE_FILENAME(0), PSTR("mm/sec")); + int_to_string(retract_feedrate / 60 + 0.5, buffer, PSTR("mm/sec")); #if EXTRUDERS > 1 else if(nr == 3) - int_to_string(extruder_swap_retract_length, LCD_CACHE_FILENAME(0), PSTR("mm")); + int_to_string(extruder_swap_retract_length, buffer, PSTR("mm")); #endif - lcd_lib_draw_string(5, BOTTOM_MENU_YPOS, LCD_CACHE_FILENAME(0)); + else + return; + lcd_lib_draw_string(5, BOTTOM_MENU_YPOS, buffer); } static void lcd_menu_print_tune_retraction() @@ -1000,7 +995,7 @@ static void lcd_show_pause_menu() static const menu_t & get_pause_menuoption(uint8_t nr, menu_t &opt) { - menu_index = 0; + uint8_t menu_index = 0; if (nr == menu_index++) { opt.setData(MENU_NORMAL, lcd_show_pause_menu); @@ -1106,7 +1101,7 @@ void lcd_menu_print_pause() static const menu_t & get_resume_menuoption(uint8_t nr, menu_t &opt) { - menu_index = 0; + uint8_t menu_index = 0; if (nr == menu_index++) { opt.setData(MENU_NORMAL, lcd_print_resume); diff --git a/Marlin/UltiLCD2_menu_utils.cpp b/Marlin/UltiLCD2_menu_utils.cpp index 2a1635cab..79da6c3bf 100644 --- a/Marlin/UltiLCD2_menu_utils.cpp +++ b/Marlin/UltiLCD2_menu_utils.cpp @@ -10,7 +10,6 @@ #define LED_INPUT() lcd_lib_led_color(192, 8, 0) LCDMenu menu; -uint8_t menu_index; static int16_t lastEncoderPos = 0; @@ -153,6 +152,7 @@ void LCDMenu::drawMenuBox(uint8_t left, uint8_t top, uint8_t width, uint8_t heig void LCDMenu::drawMenuString(uint8_t left, uint8_t top, uint8_t width, uint8_t height, const char * str, uint8_t textAlign, uint8_t flags) { drawMenuBox(left, top, width, height, flags); + char buffer[32]; const char* split = strchr(str, '|'); uint8_t textX1; @@ -162,8 +162,8 @@ void LCDMenu::drawMenuString(uint8_t left, uint8_t top, uint8_t width, uint8_t h if (split) { - strncpy(LCD_CACHE_FILENAME(1), str, split - str); - LCD_CACHE_FILENAME(1)[split - str] = '\0'; + strncpy(buffer, str, split - str); + buffer[split - str] = '\0'; ++split; // calculate text position @@ -173,12 +173,12 @@ void LCDMenu::drawMenuString(uint8_t left, uint8_t top, uint8_t width, uint8_t h } else if (textAlign & ALIGN_RIGHT) { - textX1 = left + width - (LCD_CHAR_SPACING * strlen(LCD_CACHE_FILENAME(1))); + textX1 = left + width - (LCD_CHAR_SPACING * strlen(buffer)); textX2 = left + width - (LCD_CHAR_SPACING * strlen(split)); } else // if (textAlign & ALIGN_HCENTER) { - textX1 = left + width/2 - (LCD_CHAR_SPACING/2 * strlen(LCD_CACHE_FILENAME(1))); + textX1 = left + width/2 - (LCD_CHAR_SPACING/2 * strlen(buffer)); textX2 = left + width/2 - (LCD_CHAR_SPACING/2 * strlen(split)); } @@ -200,10 +200,10 @@ void LCDMenu::drawMenuString(uint8_t left, uint8_t top, uint8_t width, uint8_t h if (flags & MENU_SELECTED) { - lcd_lib_clear_string(textX1, textY1, LCD_CACHE_FILENAME(1)); + lcd_lib_clear_string(textX1, textY1, buffer); lcd_lib_clear_string(textX2, textY2, split); } else { - lcd_lib_draw_string(textX1, textY1, LCD_CACHE_FILENAME(1)); + lcd_lib_draw_string(textX1, textY1, buffer); lcd_lib_draw_string(textX2, textY2, split); } }else{ @@ -234,8 +234,9 @@ void LCDMenu::drawMenuString(uint8_t left, uint8_t top, uint8_t width, uint8_t h void LCDMenu::drawMenuString_P(uint8_t left, uint8_t top, uint8_t width, uint8_t height, const char * str, uint8_t textAlign, uint8_t flags) { - strcpy_P(LCD_CACHE_FILENAME(0), str); - drawMenuString(left, top, width, height, LCD_CACHE_FILENAME(0), textAlign, flags); + char buffer[32]; + strcpy_P(buffer, str); + drawMenuString(left, top, width, height, buffer, textAlign, flags); } void LCDMenu::process_submenu(menuItemCallback_t getMenuItem, uint8_t len) diff --git a/Marlin/UltiLCD2_menu_utils.h b/Marlin/UltiLCD2_menu_utils.h index f0de95639..b32d0b368 100644 --- a/Marlin/UltiLCD2_menu_utils.h +++ b/Marlin/UltiLCD2_menu_utils.h @@ -86,7 +86,7 @@ struct menu_t { } }; -typedef char* (*entryNameCallback_t)(uint8_t nr); +typedef char* (*entryNameCallback_t)(uint8_t nr, char *buffer); typedef void (*entryDetailsCallback_t)(uint8_t nr); typedef const menu_t & (*menuItemCallback_t) (uint8_t nr, menu_t &opt); typedef void (*menuDrawCallback_t) (uint8_t nr, uint8_t &flags); @@ -146,9 +146,7 @@ class LCDMenu }; - extern LCDMenu menu; -extern uint8_t menu_index; FORCE_INLINE void lcd_change_to_previous_menu() { menu.return_to_previous(); } FORCE_INLINE void lcd_return_to_main_menu() { menu.return_to_main(); } diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index edc3c8957..d661046b7 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -51,7 +51,7 @@ char *createFilename(char *buffer,const dir_t &p) //buffer>12characters } -void CardReader::lsDive(const char *prepend,SdFile parent) +void CardReader::lsDive(const char *prepend, SdFile parent) { dir_t p; uint8_t cnt=0; @@ -128,7 +128,6 @@ void CardReader::lsDive(const char *prepend,SdFile parent) if(cnt==nrFiles) return; cnt++; - } } } diff --git a/Marlin/package.sh b/Marlin/package.sh index 99ad8a8d0..6af537c92 100644 --- a/Marlin/package.sh +++ b/Marlin/package.sh @@ -8,7 +8,7 @@ ############################# ##Which version name are we appending to the final archive -export BUILD_NAME=15.02-RC1 +export BUILD_NAME=15.02-RC2 ############################# # Support functions @@ -112,14 +112,14 @@ fi #Build the Ultimaker2 firmwares. # gitClone https://github.com/TinkerGnome/Ultimaker2Marlin.git _Ultimaker2Marlin # cd _Ultimaker2Marlin/Marlin -$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2 DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker ${BUILD_NAME}\"' TEMP_SENSOR_1=0 EXTRUDERS=1" clean +$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2 DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker_${BUILD_NAME}\"' TEMP_SENSOR_1=0 EXTRUDERS=1" clean sleep 2 mkdir _Ultimaker2 -$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2 DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker ${BUILD_NAME}\"' TEMP_SENSOR_1=0 EXTRUDERS=1" -$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2Dual DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker ${BUILD_NAME}\"' TEMP_SENSOR_1=20 EXTRUDERS=2" clean +$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2 DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker_${BUILD_NAME}\"' TEMP_SENSOR_1=0 EXTRUDERS=1" +$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2Dual DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker_${BUILD_NAME}\"' TEMP_SENSOR_1=20 EXTRUDERS=2" clean sleep 2 mkdir _Ultimaker2Dual -$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2Dual DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker ${BUILD_NAME}\"' TEMP_SENSOR_1=20 EXTRUDERS=2" +$MAKE -j 3 HARDWARE_MOTHERBOARD=72 ARDUINO_INSTALL_DIR=${ARDUINO_PATH} ARDUINO_VERSION=${ARDUINO_VERSION} BUILD_DIR=_Ultimaker2Dual DEFINES="'STRING_CONFIG_H_AUTHOR=\"Tinker_${BUILD_NAME}\"' TEMP_SENSOR_1=20 EXTRUDERS=2" # cd - cp _Ultimaker2/Marlin.hex resources/firmware/TinkerGnome-MarlinUltimaker2-${BUILD_NAME}.hex diff --git a/Marlin/tinkergnome.cpp b/Marlin/tinkergnome.cpp index 50bbca347..4e1eef474 100644 --- a/Marlin/tinkergnome.cpp +++ b/Marlin/tinkergnome.cpp @@ -42,7 +42,7 @@ float recover_height = 0.0f; // these are used to maintain a simple low-pass filter on the speeds - thanks norpchen static float e_smoothed_speed[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0.0, 0.0, 0.0); - +static float nominal_speed = 0.0; static float target_position[NUM_AXIS]; static int8_t movingSpeed = 0; static bool delayMove = false; @@ -189,7 +189,7 @@ void menu_printing_init() // return heatup menu option static const menu_t & get_heatup_menuoption(uint8_t nr, menu_t &opt) { - menu_index = 0; + uint8_t menu_index = 0; if (nr == menu_index++) { opt.setData(MENU_NORMAL, lcd_print_tune); @@ -228,7 +228,7 @@ static void lcd_print_ask_pause() // return print menu option static const menu_t & get_print_menuoption(uint8_t nr, menu_t &opt) { - menu_index = 0; + uint8_t menu_index = 0; if (printing_page == 1) { if (nr == menu_index++) @@ -573,6 +573,8 @@ static void lcd_print_tune_xyjerk() static void drawHeatupSubmenu (uint8_t nr, uint8_t &flags) { uint8_t index(0); + char buffer[32]; + if (nr == index++) { if (flags & MENU_SELECTED) @@ -618,20 +620,20 @@ static void drawHeatupSubmenu (uint8_t nr, uint8_t &flags) if (flags & (MENU_SELECTED | MENU_ACTIVE)) { #if EXTRUDERS < 2 - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Nozzle ")); + strcpy_P(buffer, PSTR("Nozzle ")); #else - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Nozzle(1) ")); + strcpy_P(buffer, PSTR("Nozzle(1) ")); #endif - int_to_string(target_temperature[0], int_to_string(dsp_temperature[0], LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + int_to_string(target_temperature[0], int_to_string(dsp_temperature[0], buffer+strlen(buffer), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string(target_temperature[0], LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); + int_to_string(target_temperature[0], buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , 51-(EXTRUDERS*LCD_LINE_HEIGHT)-(BED_MENU_OFFSET*LCD_LINE_HEIGHT) , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -641,17 +643,17 @@ static void drawHeatupSubmenu (uint8_t nr, uint8_t &flags) // temp nozzle 2 if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Nozzle(2) ")); - int_to_string(target_temperature[1], int_to_string(dsp_temperature[1], LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + strcpy_P(buffer, PSTR("Nozzle(2) ")); + int_to_string(target_temperature[1], int_to_string(dsp_temperature[1], buffer+strlen(buffer), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string(target_temperature[1], LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); + int_to_string(target_temperature[1], buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , 42-(BED_MENU_OFFSET*LCD_LINE_HEIGHT) , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -662,17 +664,17 @@ static void drawHeatupSubmenu (uint8_t nr, uint8_t &flags) // temp buildplate if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Buildplate ")); - int_to_string(target_temperature_bed, int_to_string(dsp_temperature_bed, LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + strcpy_P(buffer, PSTR("Buildplate ")); + int_to_string(target_temperature_bed, int_to_string(dsp_temperature_bed, buffer+strlen(buffer), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string(target_temperature_bed, LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); + int_to_string(target_temperature_bed, buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , 42 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -682,6 +684,7 @@ static void drawHeatupSubmenu (uint8_t nr, uint8_t &flags) static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) { uint8_t index(0); + char buffer[32]; if (printing_page == 1) // second page { if (nr == index++) @@ -737,12 +740,12 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) } // lcd_lib_draw_string_leftP(42, PSTR("LED")); lcd_lib_draw_gfx(LCD_GFX_WIDTH-2*LCD_CHAR_MARGIN_RIGHT-5*LCD_CHAR_SPACING, BOTTOM_MENU_YPOS, brightnessGfx); - int_to_string(led_brightness_level, LCD_CACHE_FILENAME(1), PSTR("%")); + int_to_string(led_brightness_level, buffer, PSTR("%")); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , BOTTOM_MENU_YPOS , 4*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -756,12 +759,12 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) } lcd_lib_draw_string_leftP(15, PSTR("Retract")); lcd_lib_draw_stringP(LCD_GFX_WIDTH - 2*LCD_CHAR_MARGIN_RIGHT - 8*LCD_CHAR_SPACING, 15, PSTR("L")); - float_to_string(retract_length, LCD_CACHE_FILENAME(1), PSTR("mm")); + float_to_string(retract_length, buffer, PSTR("mm")); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-7*LCD_CHAR_SPACING , 15 , 7*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -775,12 +778,12 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) flags |= MENU_STATUSLINE; } lcd_lib_draw_string_leftP(24, PSTR("E")); - float_to_string(extruder_swap_retract_length, LCD_CACHE_FILENAME(1), PSTR("mm")); + float_to_string(extruder_swap_retract_length, buffer, PSTR("mm")); LCDMenu::drawMenuString(2*LCD_CHAR_MARGIN_LEFT+LCD_CHAR_SPACING , 24 , 7*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -794,12 +797,12 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) flags |= MENU_STATUSLINE; } lcd_lib_draw_stringP(LCD_GFX_WIDTH - 2*LCD_CHAR_MARGIN_RIGHT - 8*LCD_CHAR_SPACING, 24, PSTR("S")); - int_to_string(retract_feedrate / 60 + 0.5, LCD_CACHE_FILENAME(1), PSTR("mm/s")); + int_to_string(retract_feedrate / 60 + 0.5, buffer, PSTR("mm/s")); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-7*LCD_CHAR_SPACING , 24 , 7*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -812,12 +815,12 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) flags |= MENU_STATUSLINE; } lcd_lib_draw_string_leftP(33, PSTR("Accel")); - int_to_string(acceleration, LCD_CACHE_FILENAME(1), PSTR("mm/s" SQUARED_SYMBOL)); + int_to_string(acceleration, buffer, PSTR("mm/s" SQUARED_SYMBOL)); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-10*LCD_CHAR_SPACING // 2*LCD_CHAR_MARGIN_LEFT+5*LCD_CHAR_SPACING // , 33 , 10*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -831,12 +834,12 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) } lcd_lib_draw_string_leftP(42, PSTR("X/Y Jerk")); - int_to_string(max_xy_jerk, LCD_CACHE_FILENAME(1), PSTR("mm/s")); + int_to_string(max_xy_jerk, buffer, PSTR("mm/s")); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-7*LCD_CHAR_SPACING , 42 , 7*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -892,20 +895,20 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) if (flags & (MENU_SELECTED | MENU_ACTIVE)) { #if EXTRUDERS < 2 - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Flow ")); + strcpy_P(buffer, PSTR("Flow ")); #else - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Flow(1) ")); + strcpy_P(buffer, PSTR("Flow(1) ")); #endif - float_to_string2(e_smoothed_speed[0], LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("mm" CUBED_SYMBOL PER_SECOND_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + float_to_string2(e_smoothed_speed[0], buffer+strlen(buffer), PSTR("mm" CUBED_SYMBOL PER_SECOND_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string(extrudemultiply[0], LCD_CACHE_FILENAME(0), PSTR("%")); + int_to_string(extrudemultiply[0], buffer, PSTR("%")); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+12 , 24 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -915,17 +918,17 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) // flow nozzle 2 if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Flow(2) ")); - float_to_string2(e_smoothed_speed[1], LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("mm" CUBED_SYMBOL PER_SECOND_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + strcpy_P(buffer, PSTR("Flow(2) ")); + float_to_string2(e_smoothed_speed[1], buffer+strlen(buffer), PSTR("mm" CUBED_SYMBOL PER_SECOND_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string(extrudemultiply[1], LCD_CACHE_FILENAME(0), PSTR("%")); + int_to_string(extrudemultiply[1], buffer, PSTR("%")); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+42 , 24 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -936,20 +939,20 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) if (flags & (MENU_SELECTED | MENU_ACTIVE)) { #if EXTRUDERS < 2 - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Nozzle ")); + strcpy_P(buffer, PSTR("Nozzle ")); #else - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Nozzle(1) ")); + strcpy_P(buffer, PSTR("Nozzle(1) ")); #endif - int_to_string(target_temperature[0], int_to_string(dsp_temperature[0], LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + int_to_string(target_temperature[0], int_to_string(dsp_temperature[0], buffer+strlen(buffer), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string((flags & MENU_ACTIVE) ? target_temperature[0] : dsp_temperature[0], LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); + int_to_string((flags & MENU_ACTIVE) ? target_temperature[0] : dsp_temperature[0], buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+12 , 33 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -959,17 +962,17 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) // temp nozzle 2 if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Nozzle(2) ")); - int_to_string(target_temperature[1], int_to_string(dsp_temperature[1], LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + strcpy_P(buffer, PSTR("Nozzle(2) ")); + int_to_string(target_temperature[1], int_to_string(dsp_temperature[1], buffer+strlen(buffer), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string((flags & MENU_ACTIVE) ? target_temperature[1] : dsp_temperature[1], LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); + int_to_string((flags & MENU_ACTIVE) ? target_temperature[1] : dsp_temperature[1], buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+42 , 33 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -980,17 +983,17 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) // temp buildplate if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Buildplate ")); - int_to_string(target_temperature_bed, int_to_string(dsp_temperature_bed, LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + strcpy_P(buffer, PSTR("Buildplate ")); + int_to_string(target_temperature_bed, int_to_string(dsp_temperature_bed, buffer+strlen(buffer), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string((flags & MENU_ACTIVE) ? target_temperature_bed : dsp_temperature_bed, LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); + int_to_string((flags & MENU_ACTIVE) ? target_temperature_bed : dsp_temperature_bed, buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , 33 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -1000,20 +1003,17 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) // speed if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Speed ")); - if (current_block!=NULL) - { - int_to_string(current_block->nominal_speed+0.5, LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("mm" PER_SECOND_SYMBOL)); - } - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + strcpy_P(buffer, PSTR("Speed ")); + int_to_string(nominal_speed+0.5, buffer+strlen(buffer), PSTR("mm" PER_SECOND_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } - int_to_string(feedmultiply, LCD_CACHE_FILENAME(0), PSTR("%")); + int_to_string(feedmultiply, buffer, PSTR("%")); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+12 , 42 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -1022,17 +1022,16 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) // fan if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Fan")); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + lcd_lib_draw_string_leftP(5, PSTR("Fan")); lcd_lib_draw_bargraph(LCD_CHAR_MARGIN_LEFT+5*LCD_CHAR_SPACING, 5, LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT, 11, float(fanSpeed)/255); flags |= MENU_STATUSLINE; } - int_to_string(float(fanSpeed)*100/255 + 0.5f, LCD_CACHE_FILENAME(0), PSTR("%")); + int_to_string(float(fanSpeed)*100/255 + 0.5f, buffer, PSTR("%")); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , 42 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -1044,6 +1043,7 @@ void lcd_menu_print_heatup_tg() lcd_basic_screen(); lcd_lib_draw_hline(3, 124, 13); + char buffer[32]; #if TEMP_SENSOR_BED != 0 if (current_temperature_bed > target_temperature_bed - 10) { @@ -1097,8 +1097,8 @@ void lcd_menu_print_heatup_tg() lcd_lib_draw_string_leftP(15, PSTR("Heating up... ")); - int_to_string(progress*100/124, LCD_CACHE_FILENAME(0), PSTR("%")); - lcd_lib_draw_string_right(15, LCD_CACHE_FILENAME(0)); + int_to_string(progress*100/124, buffer, PSTR("%")); + lcd_lib_draw_string_right(15, buffer); lcd_progressline(progress); @@ -1107,8 +1107,8 @@ void lcd_menu_print_heatup_tg() #if TEMP_SENSOR_BED != 0 // bed temperature lcd_lib_draw_string_rightP(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-26, ypos, PSTR("/")); - int_to_string(dsp_temperature_bed, LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_right(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-34, ypos, LCD_CACHE_FILENAME(0)); + int_to_string(dsp_temperature_bed, buffer, PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_right(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-34, ypos, buffer); lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-71, ypos, bedTempGfx); // lcd_lib_draw_heater(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-70, ypos, getHeaterPower(-1)); ypos -= LCD_LINE_HEIGHT; @@ -1116,15 +1116,15 @@ void lcd_menu_print_heatup_tg() #if EXTRUDERS > 1 // temperature second extruder lcd_lib_draw_string_rightP(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-26, ypos, PSTR("/")); - int_to_string(dsp_temperature[1], LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_right(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-34, ypos, LCD_CACHE_FILENAME(0)); + int_to_string(dsp_temperature[1], buffer, PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_right(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-34, ypos, buffer); lcd_lib_draw_heater(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-70, ypos, getHeaterPower(1)); ypos -= LCD_LINE_HEIGHT; #endif // EXTRUDERS // temperature first extruder lcd_lib_draw_string_rightP(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-26, ypos, PSTR("/")); - int_to_string(dsp_temperature[0], LCD_CACHE_FILENAME(0), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_right(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-34, ypos, LCD_CACHE_FILENAME(0)); + int_to_string(dsp_temperature[0], buffer, PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_right(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-34, ypos, buffer); lcd_lib_draw_heater(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-70, ypos, getHeaterPower(0)); menu.process_submenu(get_heatup_menuoption, EXTRUDERS + BED_MENU_OFFSET + 2); @@ -1174,250 +1174,260 @@ unsigned long predictTimeLeft() void lcd_menu_printing_tg() { - lcd_basic_screen(); - lcd_lib_draw_hline(3, 124, 13); - - // calculate speeds - thanks norpchen - if (current_block!=NULL) + if (card.pause) + { + menu.add_menu(menu_t(lcd_select_first_submenu, lcd_menu_print_resume, NULL, MAIN_MENU_ITEM_POS(0)), true); + } + else { + lcd_basic_screen(); + lcd_lib_draw_hline(3, 124, 13); - if ((current_block->steps_e > 0) && (current_block->steps_x || current_block->steps_y)) + // calculate speeds + if (current_block!=NULL) { -// float block_time = current_block->millimeters / current_block->nominal_speed; -// float mm_e = current_block->steps_e / axis_steps_per_unit[E_AXIS]; - // calculate live extrusion rate from e speed and filament area - float speed_e = current_block->steps_e * current_block->nominal_rate / axis_steps_per_unit[E_AXIS] / current_block->step_event_count; - float volume = (volume_to_filament_length[current_block->active_extruder] < 0.99) ? speed_e / volume_to_filament_length[current_block->active_extruder] : speed_e*DEFAULT_FILAMENT_AREA; + if ((current_block->steps_e > 0) && (current_block->steps_x || current_block->steps_y)) + { + // float block_time = current_block->millimeters / current_block->nominal_speed; + // float mm_e = current_block->steps_e / axis_steps_per_unit[E_AXIS]; + + // calculate live extrusion rate from e speed and filament area + float speed_e = current_block->steps_e * current_block->nominal_rate / axis_steps_per_unit[E_AXIS] / current_block->step_event_count; + float volume = (volume_to_filament_length[current_block->active_extruder] < 0.99) ? speed_e / volume_to_filament_length[current_block->active_extruder] : speed_e*DEFAULT_FILAMENT_AREA; - e_smoothed_speed[current_block->active_extruder] = (e_smoothed_speed[current_block->active_extruder]*LOW_PASS_SMOOTHING) + ( volume *(1.0-LOW_PASS_SMOOTHING)); + e_smoothed_speed[current_block->active_extruder] = (e_smoothed_speed[current_block->active_extruder]*LOW_PASS_SMOOTHING) + ( volume *(1.0-LOW_PASS_SMOOTHING)); + nominal_speed = current_block->nominal_speed; + } } - } - if (printing_page == 0) - { - uint8_t progress = card.getFilePos() / ((card.getFileSize() + 123) / 124); - unsigned long timeLeftSec; - switch(printing_state) + if (printing_page == 0) { - default: + uint8_t progress = card.getFilePos() / ((card.getFileSize() + 123) / 124); + unsigned long timeLeftSec; + char buffer[32]; - if (card.pause || isPauseRequested()) + switch(printing_state) { + default: + + if (card.pause || isPauseRequested()) + { + lcd_lib_draw_gfx(54, 15, hourglassGfx); + lcd_lib_draw_stringP(64, 15, (movesplanned() < 1) ? PSTR("Paused...") : PSTR("Pausing...")); + } + else + { + // time left + timeLeftSec = predictTimeLeft(); + if (timeLeftSec > 0) + { + lcd_lib_draw_gfx(54, 15, clockInverseGfx); + int_to_time_string_tg(timeLeftSec, buffer); + lcd_lib_draw_string(64, 15, buffer); + + // draw progress string right aligned + int_to_string(progress*100/124, buffer, PSTR("%")); + lcd_lib_draw_string_right(15, buffer); + lcd_progressline(progress); + } + } + + break; + case PRINT_STATE_WAIT_USER: + lcd_lib_encoder_pos = ENCODER_NO_SELECTION; + menu.reset_submenu(); + // lcd_lib_draw_string_left(5, PSTR("Paused...")); + lcd_lib_draw_string_left(5, card.longFilename); lcd_lib_draw_gfx(54, 15, hourglassGfx); - lcd_lib_draw_stringP(64, 15, (movesplanned() < 1) ? PSTR("Paused...") : PSTR("Pausing...")); - } - else - { - // time left - timeLeftSec = predictTimeLeft(); - if (timeLeftSec > 0) + if (movesplanned() < 1) + { + lcd_lib_draw_stringP(64, 15, PSTR("Paused...")); + lcd_lib_draw_string_leftP(BOTTOM_MENU_YPOS, PSTR("Click to continue...")); + } + else + { + lcd_lib_draw_stringP(64, 15, PSTR("Pausing...")); + } + if (!led_glow) { - lcd_lib_draw_gfx(54, 15, clockInverseGfx); - int_to_time_string_tg(timeLeftSec, LCD_CACHE_FILENAME(0)); - lcd_lib_draw_string(64, 15, LCD_CACHE_FILENAME(0)); - - // draw progress string right aligned - int_to_string(progress*100/124, LCD_CACHE_FILENAME(0), PSTR("%")); - lcd_lib_draw_string_right(15, LCD_CACHE_FILENAME(0)); - lcd_progressline(progress); + lcd_lib_tick(); } + break; } - break; - case PRINT_STATE_WAIT_USER: - lcd_lib_encoder_pos = ENCODER_NO_SELECTION; - menu.reset_submenu(); - // lcd_lib_draw_string_left(5, PSTR("Paused...")); - lcd_lib_draw_string_left(5, card.longFilename); - lcd_lib_draw_gfx(54, 15, hourglassGfx); - if (movesplanned() < 1) - { - lcd_lib_draw_stringP(64, 15, PSTR("Paused...")); - lcd_lib_draw_string_leftP(BOTTOM_MENU_YPOS, PSTR("Click to continue...")); - } - else - { - lcd_lib_draw_stringP(64, 15, PSTR("Pausing...")); - } - if (!led_glow) - { - lcd_lib_tick(); - } - break; - } + // all printing states + // z position + lcd_lib_draw_string_leftP(15, PSTR("Z")); - // all printing states - // z position - lcd_lib_draw_string_leftP(15, PSTR("Z")); + // calculate current z position + float_to_string(st_get_position(Z_AXIS) / axis_steps_per_unit[Z_AXIS], buffer, 0); + lcd_lib_draw_string(LCD_CHAR_MARGIN_LEFT+12, 15, buffer); - // float_to_string(current_position[Z_AXIS], LCD_CACHE_FILENAME(0), NULL); - // calculate current z position - float_to_string(st_get_position(Z_AXIS) / axis_steps_per_unit[Z_AXIS], LCD_CACHE_FILENAME(0), NULL); - lcd_lib_draw_string(LCD_CHAR_MARGIN_LEFT+12, 15, LCD_CACHE_FILENAME(0)); + // flow + lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT-1, 24, flowGfx); + // temperature first extruder + lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT, 33, thermometerGfx); - // flow - lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT-1, 24, flowGfx); - // temperature first extruder - lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT, 33, thermometerGfx); - - #if TEMP_SENSOR_BED != 0 - // temperature build-plate - lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING-12, 33, bedTempGfx); - #endif - - // speed - lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT, 42, speedGfx); - // fan speed - static uint8_t fanAnimate = 0; - static uint8_t prevFanSpeed = 0; + #if TEMP_SENSOR_BED != 0 + // temperature build-plate + lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING-12, 33, bedTempGfx); + #endif - // start animation - if (!fanAnimate && fanSpeed!=prevFanSpeed) - fanAnimate = 32; - if ((fanSpeed == 0) || (!fanAnimate) || (fanAnimate%4)) - { - lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING-11, 42, fan1Gfx); - } - if (fanAnimate && !(led_glow%16)) - { - --fanAnimate; + // speed + lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT, 42, speedGfx); + // fan speed + static uint8_t fanAnimate = 0; + static uint8_t prevFanSpeed = 0; + + // start animation + if (!fanAnimate && fanSpeed!=prevFanSpeed) + fanAnimate = 32; + if ((fanSpeed == 0) || (!fanAnimate) || (fanAnimate%4)) + { + lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING-11, 42, fan1Gfx); + } + if (fanAnimate && !(led_glow%16)) + { + --fanAnimate; + } + prevFanSpeed = fanSpeed; } - prevFanSpeed = fanSpeed; - } - uint8_t index = 0; - uint8_t len = (printing_page == 1) ? 6 + min(EXTRUDERS, 2) : EXTRUDERS*2 + BED_MENU_OFFSET + 4; - if (printing_state == PRINT_STATE_WAIT_USER) - { - index += (printing_page == 1) ? 3 : 2; - } - else - { - menu.process_submenu(get_print_menuoption, len); - const char *message = lcd_getstatus(); - if (!menu.isSubmenuSelected() && message && *message) + uint8_t index = 0; + uint8_t len = (printing_page == 1) ? 6 + min(EXTRUDERS, 2) : EXTRUDERS*2 + BED_MENU_OFFSET + 4; + if (printing_state == PRINT_STATE_WAIT_USER) { - lcd_lib_draw_string_left(BOTTOM_MENU_YPOS, message); index += (printing_page == 1) ? 3 : 2; } - } - - uint8_t flags = 0; - for (; index < len; ++index) { - menu.drawSubMenu(drawPrintSubmenu, index, flags); - } - if (!(flags & MENU_STATUSLINE)) - { - if (printing_state == PRINT_STATE_HEATING) + else { - lcd_lib_draw_string_leftP(5, PSTR("Heating")); + menu.process_submenu(get_print_menuoption, len); + const char *message = lcd_getstatus(); + if (!menu.isSubmenuSelected() && message && *message) + { + lcd_lib_draw_string_left(BOTTOM_MENU_YPOS, message); + index += (printing_page == 1) ? 3 : 2; + } } - else if (printing_state == PRINT_STATE_HEATING_BED) - { - lcd_lib_draw_string_leftP(5, PSTR("Heating buildplate")); + + uint8_t flags = 0; + for (; index < len; ++index) { + menu.drawSubMenu(drawPrintSubmenu, index, flags); } - else + if (!(flags & MENU_STATUSLINE)) { - lcd_lib_draw_string_left(5, card.longFilename); + if (printing_state == PRINT_STATE_HEATING) + { + lcd_lib_draw_string_leftP(5, PSTR("Heating")); + } + else if (printing_state == PRINT_STATE_HEATING_BED) + { + lcd_lib_draw_string_leftP(5, PSTR("Heating buildplate")); + } + else + { + lcd_lib_draw_string_left(5, card.longFilename); + } } + lcd_lib_update_screen(); } - lcd_lib_update_screen(); } -static char* lcd_expert_item(uint8_t nr) +static char* lcd_expert_item(uint8_t nr, char *buffer) { if (nr == 0) { - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); } else if (nr == 1) { - LCD_CACHE_FILENAME(0)[0] = ' '; - strcpy_P(LCD_CACHE_FILENAME(0)+1, PSTR("User interface")); + buffer[0] = ' '; + strcpy_P(buffer+1, PSTR("User interface")); } else if (nr == 2) { - LCD_CACHE_FILENAME(0)[0] = ' '; - strcpy_P(LCD_CACHE_FILENAME(0)+1, PSTR("LED timeout")); + buffer[0] = ' '; + strcpy_P(buffer+1, PSTR("LED timeout")); } else if (nr == 3) { - LCD_CACHE_FILENAME(0)[0] = ' '; - strcpy_P(LCD_CACHE_FILENAME(0)+1, PSTR("Move axis")); + buffer[0] = ' '; + strcpy_P(buffer+1, PSTR("Move axis")); } else if (nr == 4) { - LCD_CACHE_FILENAME(0)[0] = ' '; - strcpy_P(LCD_CACHE_FILENAME(0)+1, PSTR("Disable steppers")); + buffer[0] = ' '; + strcpy_P(buffer+1, PSTR("Disable steppers")); } else { - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("???")); + strcpy_P(buffer, PSTR("???")); } - return LCD_CACHE_FILENAME(0); + return buffer; } -static char* lcd_uimode_item(uint8_t nr) +static char* lcd_uimode_item(uint8_t nr, char *buffer) { if (nr == 0) { - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("< RETURN")); + strcpy_P(buffer, PSTR("< RETURN")); } else if (nr == 1) { - LCD_CACHE_FILENAME(0)[0] = ' '; - strcpy_P(LCD_CACHE_FILENAME(0)+1, PSTR("Standard Mode")); + buffer[0] = ' '; + strcpy_P(buffer+1, PSTR("Standard Mode")); } else if (nr == 2) { - LCD_CACHE_FILENAME(0)[0] = ' '; - strcpy_P(LCD_CACHE_FILENAME(0)+1, PSTR("Geek Mode")); + buffer[0] = ' '; + strcpy_P(buffer+1, PSTR("Geek Mode")); } else { - LCD_CACHE_FILENAME(0)[0] = ' '; - strcpy_P(LCD_CACHE_FILENAME(0)+1, PSTR("???")); + buffer[0] = ' '; + strcpy_P(buffer+1, PSTR("???")); } if (nr-1 == ui_mode) - LCD_CACHE_FILENAME(0)[0] = '>'; + buffer[0] = '>'; - return LCD_CACHE_FILENAME(0); + return buffer; } static void lcd_expert_details(uint8_t nr) { + char buffer[32]; if (nr == 0) return; else if(nr == 1) { if (ui_mode & UI_MODE_EXPERT) { - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Geek Mode")); + strcpy_P(buffer, PSTR("Geek Mode")); } else { - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("Standard Mode")); + strcpy_P(buffer, PSTR("Standard Mode")); } } else if(nr == 2) { if (led_timeout > 0) { - int_to_string(led_timeout, LCD_CACHE_FILENAME(0), PSTR(" min")); + int_to_string(led_timeout, buffer, PSTR(" min")); } else { - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("off")); + strcpy_P(buffer, PSTR("off")); } } else { - LCD_CACHE_FILENAME(0)[0] = '\0'; + buffer[0] = '\0'; } - lcd_lib_draw_string_left(BOTTOM_MENU_YPOS, LCD_CACHE_FILENAME(0)); + lcd_lib_draw_string_left(BOTTOM_MENU_YPOS, buffer); } static void lcd_uimode_details(uint8_t nr) @@ -1466,15 +1476,17 @@ static void lcd_menu_led_timeout() lcd_lib_clear(); lcd_lib_draw_string_centerP(20, PSTR("LED timeout")); lcd_lib_draw_string_centerP(BOTTOM_MENU_YPOS, PSTR("Click to return")); + + char buffer[32]; if (led_timeout > 0) { - int_to_string(int(led_timeout), LCD_CACHE_FILENAME(0), PSTR(" min")); + int_to_string(int(led_timeout), buffer, PSTR(" min")); } else { - strcpy_P(LCD_CACHE_FILENAME(0), PSTR("off")); + strcpy_P(buffer, PSTR("off")); } - lcd_lib_draw_string_center(30, LCD_CACHE_FILENAME(0)); + lcd_lib_draw_string_center(30, buffer); lcd_lib_update_screen(); } @@ -1693,8 +1705,9 @@ FORCE_INLINE void lcd_home_all() { enquecommand_P(PSTR("G28")); } static void drawMoveDetails() { - int_to_string(abs(movingSpeed), LCD_CACHE_FILENAME(1), PSTR("mm" PER_SECOND_SYMBOL)); - lcd_lib_draw_string_center(5, LCD_CACHE_FILENAME(1)); + char buffer[32]; + int_to_string(abs(movingSpeed), buffer, PSTR("mm" PER_SECOND_SYMBOL)); + lcd_lib_draw_string_center(5, buffer); if (movingSpeed <= 0) { lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT, 5, revSpeedGfx); @@ -1770,6 +1783,7 @@ static const menu_t & get_move_menuoption(uint8_t nr, menu_t &opt) static void drawMoveSubmenu(uint8_t nr, uint8_t &flags) { uint8_t index(0); + char buffer[32]; if (nr == index++) { // Home all axis @@ -1839,12 +1853,12 @@ static void drawMoveSubmenu(uint8_t nr, uint8_t &flags) lcd_lib_draw_string_leftP(5, PSTR("X axis position")); flags |= MENU_STATUSLINE; } - float_to_string(st_get_position(X_AXIS) / axis_steps_per_unit[X_AXIS], LCD_CACHE_FILENAME(0), PSTR("mm")); + float_to_string(st_get_position(X_AXIS) / axis_steps_per_unit[X_AXIS], buffer, PSTR("mm")); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+5*LCD_CHAR_SPACING , 17 , 48 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -1899,12 +1913,12 @@ static void drawMoveSubmenu(uint8_t nr, uint8_t &flags) lcd_lib_draw_string_leftP(5, PSTR("Y axis position")); flags |= MENU_STATUSLINE; } - float_to_string(st_get_position(Y_AXIS) / axis_steps_per_unit[Y_AXIS], LCD_CACHE_FILENAME(0), PSTR("mm")); + float_to_string(st_get_position(Y_AXIS) / axis_steps_per_unit[Y_AXIS], buffer, PSTR("mm")); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+5*LCD_CHAR_SPACING , 29 , 48 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -1959,12 +1973,12 @@ static void drawMoveSubmenu(uint8_t nr, uint8_t &flags) lcd_lib_draw_string_leftP(5, PSTR("Z axis position")); flags |= MENU_STATUSLINE; } - float_to_string(st_get_position(Z_AXIS) / axis_steps_per_unit[Z_AXIS], LCD_CACHE_FILENAME(0), PSTR("mm")); + float_to_string(st_get_position(Z_AXIS) / axis_steps_per_unit[Z_AXIS], buffer, PSTR("mm")); LCDMenu::drawMenuString(LCD_CHAR_MARGIN_LEFT+5*LCD_CHAR_SPACING , 41 , 48 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(0) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -2142,7 +2156,7 @@ static void lcd_extrude_pull() static const menu_t & get_extrude_menuoption(uint8_t nr, menu_t &opt) { - menu_index = 0; + uint8_t menu_index = 0; if (nr == menu_index++) { opt.setData(MENU_NORMAL, lcd_extrude_return); @@ -2169,6 +2183,7 @@ static const menu_t & get_extrude_menuoption(uint8_t nr, menu_t &opt) static void drawExtrudeSubmenu (uint8_t nr, uint8_t &flags) { uint8_t index(0); + char buffer[32]; if (nr == index++) { if (flags & MENU_SELECTED) @@ -2189,21 +2204,21 @@ static void drawExtrudeSubmenu (uint8_t nr, uint8_t &flags) // temp nozzle if (flags & (MENU_SELECTED | MENU_ACTIVE)) { - strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Nozzle ")); - int_to_string(target_temperature[active_extruder], int_to_string(dsp_temperature[active_extruder], LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); - lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); + strcpy_P(buffer, PSTR("Nozzle ")); + int_to_string(target_temperature[active_extruder], int_to_string(dsp_temperature[active_extruder], buffer+strlen(buffer), PSTR(DEGREE_SYMBOL"/")), PSTR(DEGREE_SYMBOL)); + lcd_lib_draw_string_left(5, buffer); flags |= MENU_STATUSLINE; } lcd_lib_draw_heater(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING, 20, getHeaterPower(active_extruder)); - int_to_string(dsp_temperature[active_extruder], LCD_CACHE_FILENAME(1), PSTR(DEGREE_SYMBOL "/")); - lcd_lib_draw_string_right(LCD_GFX_WIDTH-2*LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING, 20, LCD_CACHE_FILENAME(1)); - int_to_string(target_temperature[active_extruder], LCD_CACHE_FILENAME(1), PSTR(DEGREE_SYMBOL)); + int_to_string(dsp_temperature[active_extruder], buffer, PSTR(DEGREE_SYMBOL "/")); + lcd_lib_draw_string_right(LCD_GFX_WIDTH-2*LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING, 20, buffer); + int_to_string(target_temperature[active_extruder], buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , 20 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -2264,12 +2279,12 @@ static void drawExtrudeSubmenu (uint8_t nr, uint8_t &flags) flags |= MENU_STATUSLINE; } // lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-1, 35, flowGfx); - float_to_string(st_get_position(E_AXIS) / axis_steps_per_unit[E_AXIS], LCD_CACHE_FILENAME(1), PSTR("mm")); + float_to_string(st_get_position(E_AXIS) / axis_steps_per_unit[E_AXIS], buffer, PSTR("mm")); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-11*LCD_CHAR_SPACING , 35 , 11*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -2308,7 +2323,7 @@ static void lcd_recover_zvalue() static const menu_t & get_recover_menuoption(uint8_t nr, menu_t &opt) { - menu_index = 0; + uint8_t menu_index = 0; if (nr == menu_index++) { opt.setData(MENU_NORMAL, lcd_recover_start); @@ -2327,6 +2342,7 @@ static const menu_t & get_recover_menuoption(uint8_t nr, menu_t &opt) static void drawRecoverSubmenu (uint8_t nr, uint8_t &flags) { uint8_t index(0); + char buffer[32]; if (nr == index++) { if (flags & MENU_SELECTED) @@ -2366,12 +2382,12 @@ static void drawRecoverSubmenu (uint8_t nr, uint8_t &flags) flags |= MENU_STATUSLINE; } - float_to_string(recover_height, LCD_CACHE_FILENAME(1), PSTR(DEGREE_SYMBOL)); + float_to_string(recover_height, buffer, PSTR(DEGREE_SYMBOL)); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING , 20 , 24 , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); } @@ -2432,12 +2448,12 @@ static void drawRecoverSubmenu (uint8_t nr, uint8_t &flags) flags |= MENU_STATUSLINE; } // lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-1, 35, flowGfx); - float_to_string(st_get_position(E_AXIS) / axis_steps_per_unit[E_AXIS], LCD_CACHE_FILENAME(1), PSTR("mm")); + float_to_string(st_get_position(E_AXIS) / axis_steps_per_unit[E_AXIS], buffer, PSTR("mm")); LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-11*LCD_CHAR_SPACING , 35 , 11*LCD_CHAR_SPACING , LCD_CHAR_HEIGHT - , LCD_CACHE_FILENAME(1) + , buffer , ALIGN_RIGHT | ALIGN_VCENTER , flags); }