G-code queue singleton, front injection (#14236)
This commit is contained in:
@ -99,7 +99,7 @@ void MarlinUI::goto_previous_screen() {
|
||||
/////////// Common Menu Actions ////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
void MenuItem_gcode::action(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode); }
|
||||
void MenuItem_gcode::action(PGM_P pgcode) { queue.inject_P(pgcode); }
|
||||
|
||||
////////////////////////////////////////////
|
||||
/////////// Menu Editing Actions ///////////
|
||||
@ -410,15 +410,15 @@ void MarlinUI::completion_feedback(const bool good/*=true*/) {
|
||||
|
||||
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
|
||||
|
||||
void lcd_enqueue_command(const char * const cmd) {
|
||||
void lcd_enqueue_one_now(const char * const cmd) {
|
||||
no_reentry = true;
|
||||
enqueue_and_echo_command_now(cmd);
|
||||
queue.enqueue_one_now(cmd);
|
||||
no_reentry = false;
|
||||
}
|
||||
|
||||
void lcd_enqueue_commands_P(PGM_P const cmd) {
|
||||
void lcd_enqueue_one_now_P(PGM_P const cmd) {
|
||||
no_reentry = true;
|
||||
enqueue_and_echo_commands_now_P(cmd);
|
||||
queue.enqueue_now_P(cmd);
|
||||
no_reentry = false;
|
||||
}
|
||||
|
||||
|
@ -375,8 +375,8 @@ void _lcd_draw_homing();
|
||||
#endif
|
||||
|
||||
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
|
||||
void lcd_enqueue_command(const char * const cmd);
|
||||
void lcd_enqueue_commands_P(PGM_P const cmd);
|
||||
void lcd_enqueue_one_now(const char * const cmd);
|
||||
void lcd_enqueue_one_now_P(PGM_P const cmd);
|
||||
#endif
|
||||
|
||||
#if ENABLED(LEVEL_BED_CORNERS)
|
||||
|
@ -101,7 +101,7 @@ void menu_backlash();
|
||||
// Set the home offset based on the current_position
|
||||
//
|
||||
void _lcd_set_home_offsets() {
|
||||
enqueue_and_echo_commands_P(PSTR("M428"));
|
||||
queue.inject_P(PSTR("M428"));
|
||||
ui.return_to_status();
|
||||
}
|
||||
#endif
|
||||
@ -255,7 +255,7 @@ void menu_backlash();
|
||||
autotune_temp[e]
|
||||
#endif
|
||||
);
|
||||
lcd_enqueue_command(cmd);
|
||||
lcd_enqueue_one_now(cmd);
|
||||
}
|
||||
|
||||
#endif // PID_AUTOTUNE_MENU
|
||||
|
@ -120,7 +120,7 @@ void _lcd_level_bed_corners() {
|
||||
ui.defer_status_screen();
|
||||
if (!all_axes_known()) {
|
||||
set_all_unhomed();
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
queue.inject_P(PSTR("G28"));
|
||||
}
|
||||
|
||||
// Disable leveling so the planner won't mess with us
|
||||
|
@ -105,9 +105,9 @@
|
||||
ui.wait_for_bl_move = true;
|
||||
ui.goto_screen(_lcd_level_bed_done);
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
enqueue_and_echo_commands_P(PSTR("G29 S2"));
|
||||
queue.inject_P(PSTR("G29 S2"));
|
||||
#elif ENABLED(PROBE_MANUALLY)
|
||||
enqueue_and_echo_commands_P(PSTR("G29 V1"));
|
||||
queue.inject_P(PSTR("G29 V1"));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -157,9 +157,9 @@
|
||||
// G29 Records Z, moves, and signals when it pauses
|
||||
ui.wait_for_bl_move = true;
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
|
||||
queue.inject_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
|
||||
#elif ENABLED(PROBE_MANUALLY)
|
||||
enqueue_and_echo_commands_P(PSTR("G29 V1"));
|
||||
queue.inject_P(PSTR("G29 V1"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@
|
||||
ui.defer_status_screen();
|
||||
set_all_unhomed();
|
||||
ui.goto_screen(_lcd_level_bed_homing);
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
queue.inject_P(PSTR("G28"));
|
||||
}
|
||||
|
||||
#endif // PROBE_MANUALLY || MESH_BED_LEVELING
|
||||
|
@ -127,7 +127,7 @@ static void lcd_factory_settings() {
|
||||
|
||||
auto _recalc_offsets = []{
|
||||
if (active_extruder && all_axes_known()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
|
||||
enqueue_and_echo_commands_P(PSTR("G28")); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
|
||||
queue.inject_P(PSTR("G28")); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
|
||||
active_extruder = 0;
|
||||
}
|
||||
};
|
||||
|
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
|
||||
void _lcd_user_gcode(PGM_P const cmd) {
|
||||
enqueue_and_echo_commands_P(cmd);
|
||||
queue.inject_P(cmd);
|
||||
#if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK)
|
||||
ui.completion_feedback();
|
||||
#endif
|
||||
|
@ -73,7 +73,7 @@ void _man_probe_pt(const float &rx, const float &ry) {
|
||||
}
|
||||
|
||||
void _lcd_delta_calibrate_home() {
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
queue.inject_P(PSTR("G28"));
|
||||
ui.goto_screen(_lcd_calibrate_homing);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ static void _change_filament_temp(const uint16_t temperature) {
|
||||
char cmd[11];
|
||||
sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
|
||||
thermalManager.setTargetHotend(temperature, _change_filament_temp_extruder);
|
||||
lcd_enqueue_command(cmd);
|
||||
lcd_enqueue_one_now(cmd);
|
||||
}
|
||||
inline void _lcd_change_filament_temp_1_func() { _change_filament_temp(ui.preheat_hotend_temp[0]); }
|
||||
inline void _lcd_change_filament_temp_2_func() { _change_filament_temp(ui.preheat_hotend_temp[1]); }
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
static void lcd_power_loss_recovery_resume() {
|
||||
ui.return_to_status();
|
||||
enqueue_and_echo_commands_P(PSTR("M1000"));
|
||||
queue.inject_P(PSTR("M1000"));
|
||||
}
|
||||
|
||||
static void lcd_power_loss_recovery_cancel() {
|
||||
|
@ -107,15 +107,15 @@ void lcd_z_offset_edit_setup(const float &initial) {
|
||||
* UBL Build Custom Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_build_custom_mesh() {
|
||||
char UBL_LCD_GCODE[20];
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
char ubl_lcd_gcode[20];
|
||||
queue.inject_P(PSTR("G28"));
|
||||
#if HAS_HEATED_BED
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
#endif
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
enqueue_and_echo_commands_P(PSTR("G29 P1"));
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("M109 S%i"), custom_hotend_temp);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
queue.inject_P(PSTR("G29 P1"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,11 +141,11 @@ void _lcd_ubl_custom_mesh() {
|
||||
* UBL Adjust Mesh Height Command
|
||||
*/
|
||||
void _lcd_ubl_adjust_height_cmd() {
|
||||
char UBL_LCD_GCODE[16];
|
||||
char ubl_lcd_gcode[16];
|
||||
const int ind = ubl_height_amount > 0 ? 9 : 10;
|
||||
strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -"));
|
||||
sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), ABS(ubl_height_amount));
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
strcpy_P(ubl_lcd_gcode, PSTR("G29 P6 C -"));
|
||||
sprintf_P(&ubl_lcd_gcode[ind], PSTR(".%i"), ABS(ubl_height_amount));
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,7 +187,7 @@ void _lcd_ubl_edit_mesh() {
|
||||
* UBL Validate Custom Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_validate_custom_mesh() {
|
||||
char UBL_LCD_GCODE[24];
|
||||
char ubl_lcd_gcode[24];
|
||||
const int temp =
|
||||
#if HAS_HEATED_BED
|
||||
custom_bed_temp
|
||||
@ -195,9 +195,9 @@ void _lcd_ubl_validate_custom_mesh() {
|
||||
0
|
||||
#endif
|
||||
;
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
|
||||
lcd_enqueue_commands_P(PSTR("G28"));
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
|
||||
lcd_enqueue_one_now_P(PSTR("G28"));
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,9 +228,9 @@ void _lcd_ubl_validate_mesh() {
|
||||
* UBL Grid Leveling Command
|
||||
*/
|
||||
void _lcd_ubl_grid_level_cmd() {
|
||||
char UBL_LCD_GCODE[12];
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
char ubl_lcd_gcode[12];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 J%i"), side_points);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -269,9 +269,9 @@ void _lcd_ubl_mesh_leveling() {
|
||||
* UBL Fill-in Amount Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_fillin_amount_cmd() {
|
||||
char UBL_LCD_GCODE[18];
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
char ubl_lcd_gcode[18];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -361,22 +361,22 @@ void _lcd_ubl_build_mesh() {
|
||||
* UBL Load Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_load_mesh_cmd() {
|
||||
char UBL_LCD_GCODE[25];
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_LOADED), ubl_storage_slot);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
char ubl_lcd_gcode[25];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 L%i"), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("M117 " MSG_MESH_LOADED), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Save Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_save_mesh_cmd() {
|
||||
char UBL_LCD_GCODE[25];
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_SAVED), ubl_storage_slot);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
char ubl_lcd_gcode[25];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 S%i"), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("M117 " MSG_MESH_SAVED), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -420,11 +420,11 @@ void _lcd_ubl_map_homing() {
|
||||
* UBL LCD "radar" map point editing
|
||||
*/
|
||||
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_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);
|
||||
lcd_enqueue_command(UBL_LCD_GCODE);
|
||||
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -529,7 +529,7 @@ void _lcd_ubl_output_map_lcd() {
|
||||
void _lcd_ubl_output_map_lcd_cmd() {
|
||||
if (!all_axes_known()) {
|
||||
set_all_unhomed();
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
queue.inject_P(PSTR("G28"));
|
||||
}
|
||||
ui.goto_screen(_lcd_ubl_map_homing);
|
||||
}
|
||||
|
Reference in New Issue
Block a user