From 805cdadb6f3e875575589352e9c657fa8999ea2b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 2 Aug 2016 15:08:34 +0200 Subject: [PATCH] Show "Calibrating nth point" on the display when running G80 if initiated from SD card. Don't show Z height during the calibration. Update status of the Toshiba FlashAir on sd card insert / removal. --- Firmware/Marlin_main.cpp | 30 ++++++++------ Firmware/ultralcd.cpp | 19 +++++---- Firmware/ultralcd.h | 2 +- .../ultralcd_implementation_hitachi_HD44780.h | 40 ++++++++++--------- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 563dc9b79..507778dc6 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2328,14 +2328,6 @@ void process_commands() case 80: case_G80: { - if (!IS_SD_PRINTING) - { - custom_message = true; - custom_message_type = 1; - custom_message_state = (MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) + 10; - } - - // Firstly check if we know where we are if ( !( axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS] ) ){ // We don't know where we are! HOME! @@ -2345,6 +2337,15 @@ void process_commands() enquecommand_front_P((PSTR("G28 W0"))); break; } + + // Save custom message state, set a new custom message state to display: Calibrating point 9. + bool custom_message_old = custom_message; + unsigned int custom_message_type_old = custom_message_type; + unsigned int custom_message_state_old = custom_message_state; + custom_message = true; + custom_message_type = 1; + custom_message_state = (MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) + 10; + lcd_update(1); mbl.reset(); @@ -2429,12 +2430,9 @@ void process_commands() mbl.set_z(ix, iy, current_position[Z_AXIS]); - if (!IS_SD_PRINTING) - { - custom_message_state--; - } + custom_message_state--; mesh_point++; - + lcd_update(1); } current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder); @@ -2526,6 +2524,12 @@ void process_commands() world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); plan_buffer_line(current_position[X_AXIS], current_position[X_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder); st_synchronize(); + + // Restore custom message state + custom_message = custom_message_old; + custom_message_type = custom_message_type_old; + custom_message_state = custom_message_state_old; + lcd_update(1); } break; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 398598502..2e8aa07e9 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -397,7 +397,7 @@ static void lcd_status_screen() } break; } - } + } // end of farm_mode @@ -410,7 +410,7 @@ static void lcd_status_screen() } - } + } // end of lcdDrawUpdate #ifdef ULTIPANEL bool current_click = LCD_CLICKED; @@ -755,8 +755,8 @@ static void lcd_preheat_menu() static void lcd_support_menu() { - if (menuData.supportMenu.status == 0) { - // Menu was entered. + if (menuData.supportMenu.status == 0 || lcdDrawUpdate == 2) { + // Menu was entered or SD card status has changed (plugged in or removed). // Initialize its status. menuData.supportMenu.status = 1; menuData.supportMenu.is_flash_air = card.ToshibaFlashAir_GetIP(menuData.supportMenu.ip); @@ -1224,7 +1224,7 @@ static void _lcd_babystep(int axis, const char *msg) menuData.babyStep.babystepMemMM[0] = menuData.babyStep.babystepMem[0]/axis_steps_per_unit[X_AXIS]; menuData.babyStep.babystepMemMM[1] = menuData.babyStep.babystepMem[1]/axis_steps_per_unit[Y_AXIS]; menuData.babyStep.babystepMemMM[2] = menuData.babyStep.babystepMem[2]/axis_steps_per_unit[Z_AXIS]; - lcdDrawUpdate = true; + lcdDrawUpdate = 1; } if (encoderPosition != 0) @@ -1236,7 +1236,7 @@ static void _lcd_babystep(int axis, const char *msg) menuData.babyStep.babystepMemMM[axis] = menuData.babyStep.babystepMem[axis]/axis_steps_per_unit[Z_AXIS]; delay(50); encoderPosition = 0; - lcdDrawUpdate = true; + lcdDrawUpdate = 1; } if (lcdDrawUpdate) lcd_implementation_drawedit_2(msg, ftostr13ns(menuData.babyStep.babystepMemMM[axis])); @@ -1300,7 +1300,7 @@ static void lcd_adjust_bed() menuData.adjustBed.front2 = 0; menuData.adjustBed.rear2 = 0; } - lcdDrawUpdate = true; + lcdDrawUpdate = 1; eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID, 1); } @@ -3230,8 +3230,11 @@ void lcd_update_enable(bool enabled) lcd_update_enabled = enabled; } -void lcd_update() +void lcd_update(uint8_t lcdDrawUpdateOverride) { + if (lcdDrawUpdate < lcdDrawUpdateOverride) + lcdDrawUpdate = lcdDrawUpdateOverride; + static unsigned long timeoutToStatus = 0; if (! lcd_update_enabled) diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 5867e5db4..d408cdf14 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -6,7 +6,7 @@ #ifdef ULTRA_LCD - void lcd_update(); + void lcd_update(uint8_t lcdDrawUpdateOverride = 0); // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. void lcd_update_enable(bool enable); void lcd_init(); diff --git a/Firmware/ultralcd_implementation_hitachi_HD44780.h b/Firmware/ultralcd_implementation_hitachi_HD44780.h index c2b7f7a5d..f8be3f497 100644 --- a/Firmware/ultralcd_implementation_hitachi_HD44780.h +++ b/Firmware/ultralcd_implementation_hitachi_HD44780.h @@ -655,16 +655,18 @@ static void lcd_implementation_status_screen() lcd.print('/'); lcd.print(itostr3left(tTarget)); lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); //Print the Z coordinates - // if (custom_message_type != 1) { - // Not in a bed calibration mode. lcd.setCursor(LCD_WIDTH - 8-2, 0); - lcd.print(" Z"); - lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001)); - lcd.print(' '); - //} + lcd_printPGM(PSTR(" Z")); + if (custom_message_type == 1) { + // In a bed calibration mode. + lcd_printPGM(PSTR(" --- ")); + } else { + lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001)); + lcd.print(' '); + } //Print the Bedtemperature lcd.setCursor(0, 1); @@ -675,15 +677,15 @@ static void lcd_implementation_status_screen() lcd.print('/'); lcd.print(itostr3left(tTarget)); lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); //Print Feedrate lcd.setCursor(LCD_WIDTH - 8-2, 1); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); lcd.print(LCD_STR_FEEDRATE[0]); lcd.print(itostr3(feedmultiply)); lcd.print('%'); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); @@ -716,14 +718,14 @@ static void lcd_implementation_status_screen() } if (farm_mode) { - lcd.print(" F"); + lcd_printPGM(PSTR(" F")); lcd.print(farm_no); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); } //Print time elapsed lcd.setCursor(LCD_WIDTH - 8 -2, 2); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); lcd.print(LCD_STR_CLOCK[0]); if(starttime != 0) { @@ -734,7 +736,7 @@ static void lcd_implementation_status_screen() }else{ lcd_printPGM(PSTR("--:--")); } - lcd.print(" "); + lcd_printPGM(PSTR(" ")); //Print status line @@ -748,7 +750,7 @@ static void lcd_implementation_status_screen() if(strcmp(longFilenameOLD, card.longFilename) != 0) { memset(longFilenameOLD,'\0',strlen(longFilenameOLD)); - sprintf(longFilenameOLD, "%s", card.longFilename); + sprintf_P(longFilenameOLD, PSTR("%s"), card.longFilename); scrollstuff = 0; } @@ -803,7 +805,7 @@ static void lcd_implementation_status_screen() for (int dots = 0; dots < heating_status_counter; dots++) { lcd.setCursor(7 + dots, 3); - lcd_printPGM(PSTR(".")); + lcd.print('.'); } switch (heating_status) @@ -840,10 +842,10 @@ static void lcd_implementation_status_screen() if (custom_message_state > 10) { lcd.setCursor(0, 3); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); lcd.setCursor(0, 3); lcd_printPGM(MSG_HOMEYZ_PROGRESS); - lcd.print(" : "); + lcd_printPGM(PSTR(" : ")); lcd.print(custom_message_state-10); } else @@ -858,7 +860,7 @@ static void lcd_implementation_status_screen() if (custom_message_state > 3 && custom_message_state < 10 ) { lcd.setCursor(0, 3); - lcd.print(" "); + lcd_printPGM(PSTR(" ")); lcd.setCursor(0, 3); lcd_printPGM(MSG_HOMEYZ_DONE); custom_message_state--;