Browse Source

Merge pull request #8966 from thinkyhead/bf2_better_no_reentry

[2.0.x] ultralcd.cpp: Better no_reentry, use in queuing G-code
pull/1/head
Scott Lahteine 7 years ago
committed by GitHub
parent
commit
2b1e6829b3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Marlin/src/Marlin.cpp
  2. 19
      Marlin/src/feature/pause.cpp
  3. 2
      Marlin/src/feature/pause.h
  4. 4
      Marlin/src/gcode/calibrate/G33.cpp
  5. 78
      Marlin/src/lcd/ultralcd.cpp

2
Marlin/src/Marlin.cpp

@ -346,7 +346,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
// Prevent steppers timing-out in the middle of M600 // Prevent steppers timing-out in the middle of M600
#if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT) #if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT)
#define MOVE_AWAY_TEST !move_away_flag #define MOVE_AWAY_TEST !did_pause_print
#else #else
#define MOVE_AWAY_TEST true #define MOVE_AWAY_TEST true
#endif #endif

19
Marlin/src/feature/pause.cpp

@ -54,7 +54,6 @@ static float resume_position[XYZE];
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "../sd/cardreader.h" #include "../sd/cardreader.h"
static bool sd_print_paused = false;
#endif #endif
#if HAS_BUZZER #if HAS_BUZZER
@ -107,12 +106,12 @@ void do_pause_e_move(const float &length, const float fr) {
// public: // public:
bool move_away_flag = false; uint8_t did_pause_print = 0;
bool pause_print(const float &retract, const point_t &park_point, const float &unload_length/*=0*/, bool pause_print(const float &retract, const point_t &park_point, const float &unload_length/*=0*/,
const int8_t max_beep_count/*=0*/, const bool show_lcd/*=false*/ const int8_t max_beep_count/*=0*/, const bool show_lcd/*=false*/
) { ) {
if (move_away_flag) return false; // already paused if (did_pause_print) return false; // already paused
#ifdef ACTION_ON_PAUSE #ifdef ACTION_ON_PAUSE
SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE); SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE);
@ -132,13 +131,13 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u
} }
// Indicate that the printer is paused // Indicate that the printer is paused
move_away_flag = true; ++did_pause_print;
// Pause the print job and timer // Pause the print job and timer
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (IS_SD_PRINTING) { if (IS_SD_PRINTING) {
card.pauseSDPrint(); card.pauseSDPrint();
sd_print_paused = true; ++did_pause_print;
} }
#endif #endif
print_job_timer.pause(); print_job_timer.pause();
@ -256,7 +255,7 @@ void wait_for_filament_reload(const int8_t max_beep_count/*=0*/) {
void resume_print(const float &load_length/*=0*/, const float &initial_extrude_length/*=0*/, const int8_t max_beep_count/*=0*/) { void resume_print(const float &load_length/*=0*/, const float &initial_extrude_length/*=0*/, const int8_t max_beep_count/*=0*/) {
bool nozzle_timed_out = false; bool nozzle_timed_out = false;
if (!move_away_flag) return; if (!did_pause_print) return;
// Re-enable the heaters if they timed out // Re-enable the heaters if they timed out
HOTEND_LOOP() { HOTEND_LOOP() {
@ -350,14 +349,14 @@ void resume_print(const float &load_length/*=0*/, const float &initial_extrude_l
SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME); SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME);
#endif #endif
--did_pause_print;
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (sd_print_paused) { if (did_pause_print) {
card.startFileprint(); card.startFileprint();
sd_print_paused = false; --did_pause_print;
} }
#endif #endif
move_away_flag = false;
} }
#endif // ADVANCED_PAUSE_FEATURE || PARK_HEAD_ON_PAUSE #endif // ADVANCED_PAUSE_FEATURE || PARK_HEAD_ON_PAUSE

2
Marlin/src/feature/pause.h

@ -30,7 +30,7 @@
#include "../libs/nozzle.h" #include "../libs/nozzle.h"
extern bool move_away_flag; extern bool did_pause_print;
bool pause_print(const float &retract, const point_t &park_point, const float &unload_length=0, bool pause_print(const float &retract, const point_t &park_point, const float &unload_length=0,
const int8_t max_beep_count=0, const bool show_lcd=false const int8_t max_beep_count=0, const bool show_lcd=false

4
Marlin/src/gcode/calibrate/G33.cpp

@ -491,7 +491,7 @@ void GcodeSuite::G33() {
// Report settings // Report settings
const char *checkingac = PSTR("Checking... AC"); // TODO: Make translatable string PGM_P checkingac = PSTR("Checking... AC"); // TODO: Make translatable string
serialprintPGM(checkingac); serialprintPGM(checkingac);
if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)"); if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
SERIAL_EOL(); SERIAL_EOL();
@ -673,7 +673,7 @@ void GcodeSuite::G33() {
} }
} }
else { // dry run else { // dry run
const char *enddryrun = PSTR("End DRY-RUN"); PGM_P enddryrun = PSTR("End DRY-RUN");
serialprintPGM(enddryrun); serialprintPGM(enddryrun);
SERIAL_PROTOCOL_SP(35); SERIAL_PROTOCOL_SP(35);
SERIAL_PROTOCOLPGM("std dev:"); SERIAL_PROTOCOLPGM("std dev:");

78
Marlin/src/lcd/ultralcd.cpp

@ -164,6 +164,8 @@ uint16_t max_display_update_time = 0;
extern bool powersupply_on; extern bool powersupply_on;
#endif #endif
bool no_reentry = false;
//////////////////////////////////////////// ////////////////////////////////////////////
///////////////// Menu Tree //////////////// ///////////////// Menu Tree ////////////////
//////////////////////////////////////////// ////////////////////////////////////////////
@ -572,14 +574,13 @@ uint16_t max_display_update_time = 0;
// done. ** This blocks the command queue! ** // done. ** This blocks the command queue! **
// //
void _lcd_synchronize() { void _lcd_synchronize() {
static bool no_reentry = false;
if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message); if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
if (no_reentry) return; if (no_reentry) return;
// Make this the current handler till all moves are done // Make this the current handler till all moves are done
no_reentry = true; no_reentry = true;
const screenFunc_t old_screen = currentScreen; const screenFunc_t old_screen = currentScreen;
lcd_goto_screen(_lcd_synchronize); lcd_goto_screen(_lcd_synchronize);
stepper.synchronize(); stepper.synchronize(); // idle() is called until moves complete
no_reentry = false; no_reentry = false;
lcd_goto_screen(old_screen); lcd_goto_screen(old_screen);
} }
@ -1741,6 +1742,20 @@ void kill_screen(const char* lcd_msg) {
lcd_return_to_status(); lcd_return_to_status();
} }
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE)
/**
* If the queue is full, the command will fail, so we have to loop
* with idle() to make sure the command has been enqueued.
*/
void lcd_enqueue_command_sram(char * const cmd) {
no_reentry = true;
while (enqueue_and_echo_command(cmd)) idle();
no_reentry = false;
}
#endif
#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART) #if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
void lcd_autostart_sd() { void lcd_autostart_sd() {
@ -1917,7 +1932,6 @@ void kill_screen(const char* lcd_msg) {
* Step 5: Initiate a move to the next point * Step 5: Initiate a move to the next point
*/ */
void _lcd_level_goto_next_point() { void _lcd_level_goto_next_point() {
// Set the menu to display ahead of blocking call
lcd_goto_screen(_lcd_level_bed_moving); lcd_goto_screen(_lcd_level_bed_moving);
// G29 Records Z, moves, and signals when it pauses // G29 Records Z, moves, and signals when it pauses
@ -2065,10 +2079,10 @@ void kill_screen(const char* lcd_msg) {
enqueue_and_echo_commands_P(PSTR("G28")); enqueue_and_echo_commands_P(PSTR("G28"));
#if HAS_TEMP_BED #if HAS_TEMP_BED
sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp); sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp);
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram(UBL_LCD_GCODE);
#endif #endif
sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp); sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp);
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram(UBL_LCD_GCODE);
enqueue_and_echo_commands_P(PSTR("G29 P1")); enqueue_and_echo_commands_P(PSTR("G29 P1"));
} }
@ -2099,7 +2113,7 @@ void kill_screen(const char* lcd_msg) {
const int ind = ubl_height_amount > 0 ? 9 : 10; const int ind = ubl_height_amount > 0 ? 9 : 10;
strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -")); strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -"));
sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), abs(ubl_height_amount)); sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), abs(ubl_height_amount));
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram(UBL_LCD_GCODE);
} }
/** /**
@ -2149,8 +2163,9 @@ void kill_screen(const char* lcd_msg) {
0 0
#endif #endif
; ;
sprintf_P(UBL_LCD_GCODE, PSTR("G28\nG26 C B%i H%i P"), temp, custom_hotend_temp); sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram("G28");
lcd_enqueue_command_sram(UBL_LCD_GCODE);
} }
/** /**
@ -2183,7 +2198,7 @@ void kill_screen(const char* lcd_msg) {
void _lcd_ubl_grid_level_cmd() { void _lcd_ubl_grid_level_cmd() {
char UBL_LCD_GCODE[10]; char UBL_LCD_GCODE[10];
sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points); sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points);
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram(UBL_LCD_GCODE);
} }
/** /**
@ -2224,16 +2239,7 @@ void kill_screen(const char* lcd_msg) {
void _lcd_ubl_fillin_amount_cmd() { void _lcd_ubl_fillin_amount_cmd() {
char UBL_LCD_GCODE[16]; char UBL_LCD_GCODE[16];
sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount); sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram(UBL_LCD_GCODE);
}
/**
* UBL Smart Fill-in Command
*/
void _lcd_ubl_smart_fillin_cmd() {
char UBL_LCD_GCODE[12];
sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 T0"));
enqueue_and_echo_command(UBL_LCD_GCODE);
} }
/** /**
@ -2250,7 +2256,7 @@ void kill_screen(const char* lcd_msg) {
START_MENU(); START_MENU();
MENU_BACK(MSG_UBL_BUILD_MESH_MENU); MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd); MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
MENU_ITEM(function, MSG_UBL_SMART_FILLIN, _lcd_ubl_smart_fillin_cmd); MENU_ITEM(gcode, MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0")); MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
MENU_ITEM(function, MSG_WATCH, lcd_return_to_status); MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
END_MENU(); END_MENU();
@ -2323,22 +2329,20 @@ void kill_screen(const char* lcd_msg) {
* UBL Load Mesh Command * UBL Load Mesh Command
*/ */
void _lcd_ubl_load_mesh_cmd() { void _lcd_ubl_load_mesh_cmd() {
char UBL_LCD_GCODE[25]; char UBL_LCD_GCODE[10];
sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot); sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot);
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram(UBL_LCD_GCODE);
sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_LOADED "."), ubl_storage_slot); enqueue_and_echo_commands_P(PSTR("M117 " MSG_MESH_LOADED "."));
enqueue_and_echo_command(UBL_LCD_GCODE);
} }
/** /**
* UBL Save Mesh Command * UBL Save Mesh Command
*/ */
void _lcd_ubl_save_mesh_cmd() { void _lcd_ubl_save_mesh_cmd() {
char UBL_LCD_GCODE[25]; char UBL_LCD_GCODE[10];
sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot); sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot);
enqueue_and_echo_command(UBL_LCD_GCODE); lcd_enqueue_command_sram(UBL_LCD_GCODE);
sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_SAVED "."), ubl_storage_slot); enqueue_and_echo_commands_P(PSTR("M117 " MSG_MESH_SAVED "."));
enqueue_and_echo_command(UBL_LCD_GCODE);
} }
/** /**
@ -2384,12 +2388,11 @@ void kill_screen(const char* lcd_msg) {
* UBL LCD "radar" map point editing * UBL LCD "radar" map point editing
*/ */
void _lcd_ubl_map_lcd_edit_cmd() { void _lcd_ubl_map_lcd_edit_cmd() {
char ubl_lcd_gcode [50], str[10], str2[10]; char UBL_LCD_GCODE[50], str[10], str2[10];
dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str); dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2); dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts); snprintf_P(UBL_LCD_GCODE, sizeof(UBL_LCD_GCODE), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
enqueue_and_echo_command(ubl_lcd_gcode); lcd_enqueue_command_sram(UBL_LCD_GCODE);
} }
/** /**
@ -2537,7 +2540,7 @@ void kill_screen(const char* lcd_msg) {
START_MENU(); START_MENU();
MENU_BACK(MSG_UBL_LEVEL_BED); MENU_BACK(MSG_UBL_LEVEL_BED);
MENU_ITEM(gcode, "1 " MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1")); MENU_ITEM(gcode, "1 " MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
MENU_ITEM(function, "2 " MSG_UBL_SMART_FILLIN, _lcd_ubl_smart_fillin_cmd); MENU_ITEM(gcode, "2 " MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
MENU_ITEM(submenu, "3 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); MENU_ITEM(submenu, "3 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
MENU_ITEM(gcode, "4 " MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T")); MENU_ITEM(gcode, "4 " MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
MENU_ITEM(submenu, "5 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); MENU_ITEM(submenu, "5 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
@ -2979,11 +2982,10 @@ void kill_screen(const char* lcd_msg) {
#endif #endif
manual_move_to_current(axis); manual_move_to_current(axis);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
encoderPosition = 0; encoderPosition = 0;
if (lcdDrawUpdate && !processing_manual_move) { if (lcdDrawUpdate) {
const float pos = current_position[axis] const float pos = current_position[axis]
#if IS_KINEMATIC #if IS_KINEMATIC
+ manual_move_offset + manual_move_offset
@ -3019,7 +3021,7 @@ void kill_screen(const char* lcd_msg) {
} }
encoderPosition = 0; encoderPosition = 0;
} }
if (lcdDrawUpdate && !processing_manual_move) { if (lcdDrawUpdate) {
PGM_P pos_label; PGM_P pos_label;
#if E_MANUAL == 1 #if E_MANUAL == 1
pos_label = PSTR(MSG_MOVE_E); pos_label = PSTR(MSG_MOVE_E);
@ -3283,7 +3285,7 @@ void kill_screen(const char* lcd_msg) {
autotune_temp[e] autotune_temp[e]
#endif #endif
); );
enqueue_and_echo_command(cmd); lcd_enqueue_command_sram(cmd);
} }
#endif // PID_AUTOTUNE_MENU #endif // PID_AUTOTUNE_MENU
@ -4719,7 +4721,7 @@ void lcd_update() {
if (UBL_CONDITION && LCD_CLICKED) { if (UBL_CONDITION && LCD_CLICKED) {
if (!wait_for_unclick) { // If not waiting for a debounce release: if (!wait_for_unclick) { // If not waiting for a debounce release:
wait_for_unclick = true; // Set debounce flag to ignore continous clicks wait_for_unclick = true; // Set debounce flag to ignore continous clicks
lcd_clicked = !wait_for_user; // Keep the click if not waiting for a user-click lcd_clicked = !wait_for_user && !no_reentry; // Flag the click if allowed
wait_for_user = false; // Any click clears wait for user wait_for_user = false; // Any click clears wait for user
lcd_quick_feedback(); // Always make a click sound lcd_quick_feedback(); // Always make a click sound
} }

Loading…
Cancel
Save