Reduce some G-code strings

This commit is contained in:
Scott Lahteine 2021-01-16 23:15:43 -06:00
parent 522c78b5e6
commit 7836b85c96

View File

@ -139,9 +139,9 @@ void _lcd_ubl_custom_mesh() {
* UBL Adjust Mesh Height Command * UBL Adjust Mesh Height Command
*/ */
void _lcd_ubl_adjust_height_cmd() { void _lcd_ubl_adjust_height_cmd() {
char ubl_lcd_gcode[16]; char ubl_lcd_gcode[13];
const int ind = ubl_height_amount > 0 ? 9 : 10; const int ind = ubl_height_amount > 0 ? 6 : 7;
strcpy_P(ubl_lcd_gcode, PSTR("G29 P6 C -")); strcpy_P(ubl_lcd_gcode, PSTR("G29P6C-"));
sprintf_P(&ubl_lcd_gcode[ind], PSTR(".%i"), ABS(ubl_height_amount)); sprintf_P(&ubl_lcd_gcode[ind], PSTR(".%i"), ABS(ubl_height_amount));
queue.inject(ubl_lcd_gcode); queue.inject(ubl_lcd_gcode);
} }
@ -174,8 +174,8 @@ void _menu_ubl_height_adjust() {
void _lcd_ubl_edit_mesh() { void _lcd_ubl_edit_mesh() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_UBL_TOOLS); BACK_ITEM(MSG_UBL_TOOLS);
GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T")); GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29P4R999T"));
GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T")); GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29P4T"));
SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust); SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU(); END_MENU();
@ -187,8 +187,8 @@ void _lcd_ubl_edit_mesh() {
* UBL Validate Custom Mesh Command * UBL Validate Custom Mesh Command
*/ */
void _lcd_ubl_validate_custom_mesh() { void _lcd_ubl_validate_custom_mesh() {
char ubl_lcd_gcode[24]; char ubl_lcd_gcode[20];
sprintf_P(ubl_lcd_gcode, PSTR("G28\nG26 C P H%" PRIi16 TERN_(HAS_HEATED_BED, " B%" PRIi16)) sprintf_P(ubl_lcd_gcode, PSTR("G28\nG26CPH%" PRIi16 TERN_(HAS_HEATED_BED, "B%" PRIi16))
, custom_hotend_temp , custom_hotend_temp
#if HAS_HEATED_BED #if HAS_HEATED_BED
, custom_bed_temp , custom_bed_temp
@ -211,10 +211,10 @@ void _lcd_ubl_edit_mesh() {
#if PREHEAT_COUNT #if PREHEAT_COUNT
#if HAS_HEATED_BED #if HAS_HEATED_BED
#define VALIDATE_MESH_GCODE_ITEM(M) \ #define VALIDATE_MESH_GCODE_ITEM(M) \
GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26 C P I" STRINGIFY(M))) GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPI" STRINGIFY(M)))
#else #else
#define VALIDATE_MESH_GCODE_ITEM(M) \ #define VALIDATE_MESH_GCODE_ITEM(M) \
GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26 C P B0 I" STRINGIFY(M))) GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPB0I" STRINGIFY(M)))
#endif #endif
VALIDATE_MESH_GCODE_ITEM(0); VALIDATE_MESH_GCODE_ITEM(0);
@ -251,7 +251,7 @@ void _lcd_ubl_grid_level() {
EDIT_ITEM(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6); EDIT_ITEM(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6);
ACTION_ITEM(MSG_UBL_MESH_LEVEL, []{ ACTION_ITEM(MSG_UBL_MESH_LEVEL, []{
char ubl_lcd_gcode[12]; char ubl_lcd_gcode[12];
sprintf_P(ubl_lcd_gcode, PSTR("G29 J%i"), side_points); sprintf_P(ubl_lcd_gcode, PSTR("G29J%i"), side_points);
queue.inject(ubl_lcd_gcode); queue.inject(ubl_lcd_gcode);
}); });
END_MENU(); END_MENU();
@ -268,7 +268,7 @@ void _lcd_ubl_grid_level() {
void _lcd_ubl_mesh_leveling() { void _lcd_ubl_mesh_leveling() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_UBL_TOOLS); BACK_ITEM(MSG_UBL_TOOLS);
GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0")); GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29J0"));
SUBMENU(MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level); SUBMENU(MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU(); END_MENU();
@ -279,7 +279,7 @@ void _lcd_ubl_mesh_leveling() {
*/ */
void _lcd_ubl_fillin_amount_cmd() { void _lcd_ubl_fillin_amount_cmd() {
char ubl_lcd_gcode[18]; char ubl_lcd_gcode[18];
sprintf_P(ubl_lcd_gcode, PSTR("G29 P3 R C.%i"), ubl_fillin_amount); sprintf_P(ubl_lcd_gcode, PSTR("G29P3RC.%i"), ubl_fillin_amount);
gcode.process_subcommands_now(ubl_lcd_gcode); gcode.process_subcommands_now(ubl_lcd_gcode);
} }
@ -297,8 +297,8 @@ void _menu_ubl_fillin() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_UBL_BUILD_MESH_MENU); BACK_ITEM(MSG_UBL_BUILD_MESH_MENU);
EDIT_ITEM(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd); EDIT_ITEM(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
GCODES_ITEM(MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0")); GCODES_ITEM(MSG_UBL_SMART_FILLIN, PSTR("G29P3T0"));
GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0")); GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, PSTR("G29P2BT0"));
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU(); END_MENU();
} }
@ -326,7 +326,7 @@ void _lcd_ubl_build_mesh() {
BACK_ITEM(MSG_UBL_TOOLS); BACK_ITEM(MSG_UBL_TOOLS);
#if PREHEAT_COUNT #if PREHEAT_COUNT
#if HAS_HEATED_BED #if HAS_HEATED_BED
#define PREHEAT_BED_GCODE(M) "M190 I" STRINGIFY(M) "\n" #define PREHEAT_BED_GCODE(M) "M190I" STRINGIFY(M) "\n"
#else #else
#define PREHEAT_BED_GCODE(M) "" #define PREHEAT_BED_GCODE(M) ""
#endif #endif
@ -334,10 +334,10 @@ void _lcd_ubl_build_mesh() {
PSTR( \ PSTR( \
"G28\n" \ "G28\n" \
PREHEAT_BED_GCODE(M) \ PREHEAT_BED_GCODE(M) \
"M109 I" STRINGIFY(M) "\n" \ "M109I" STRINGIFY(M) "\n" \
"G29 P1\n" \ "G29P1\n" \
"M104 S0\n" \ "M104S0\n" \
"M140 S0" \ "M140S0" \
) ) ) )
BUILD_MESH_GCODE_ITEM(0); BUILD_MESH_GCODE_ITEM(0);
#if PREHEAT_COUNT > 1 #if PREHEAT_COUNT > 1
@ -355,11 +355,11 @@ void _lcd_ubl_build_mesh() {
#endif // PREHEAT_COUNT #endif // PREHEAT_COUNT
SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh); SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1")); GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29P1"));
SUBMENU(MSG_UBL_FILLIN_MESH, _menu_ubl_fillin); SUBMENU(MSG_UBL_FILLIN_MESH, _menu_ubl_fillin);
GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C")); GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29P1C"));
ACTION_ITEM(MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate); ACTION_ITEM(MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I")); GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29I"));
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
END_MENU(); END_MENU();
} }
@ -369,7 +369,7 @@ void _lcd_ubl_build_mesh() {
*/ */
inline void _lcd_ubl_load_save_cmd(const char loadsave, PGM_P const msg) { inline void _lcd_ubl_load_save_cmd(const char loadsave, PGM_P const msg) {
char ubl_lcd_gcode[40]; char ubl_lcd_gcode[40];
sprintf_P(ubl_lcd_gcode, PSTR("G29 %c%i\nM117 "), loadsave, ubl_storage_slot); sprintf_P(ubl_lcd_gcode, PSTR("G29%c%i\nM117 "), loadsave, ubl_storage_slot);
sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], msg, ubl_storage_slot); sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], msg, ubl_storage_slot);
gcode.process_subcommands_now(ubl_lcd_gcode); gcode.process_subcommands_now(ubl_lcd_gcode);
} }
@ -405,7 +405,7 @@ void _lcd_ubl_map_edit_cmd() {
char ubl_lcd_gcode[50], str[10], str2[10]; char ubl_lcd_gcode[50], str[10], str2[10];
dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str); dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str);
dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2); dtostrf(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, int(n_edit_pts)); snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29P4X%sY%sR%i"), str, str2, int(n_edit_pts));
queue.inject(ubl_lcd_gcode); queue.inject(ubl_lcd_gcode);
} }
@ -544,9 +544,9 @@ void _ubl_goto_map_screen() {
void _lcd_ubl_output_map() { void _lcd_ubl_output_map() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED); BACK_ITEM(MSG_UBL_LEVEL_BED);
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29 T0")); GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29T0"));
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29 T1")); GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29T1"));
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29 S-1")); GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29S-1"));
END_MENU(); END_MENU();
} }
@ -563,7 +563,7 @@ void _menu_ubl_tools() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED); BACK_ITEM(MSG_UBL_LEVEL_BED);
SUBMENU(MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh); SUBMENU(MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
GCODES_ITEM(MSG_UBL_MANUAL_MESH, PSTR("G29 I999\nG29 P2 B T0")); GCODES_ITEM(MSG_UBL_MANUAL_MESH, PSTR("G29I999\nG29P2BT0"));
#if ENABLED(G26_MESH_VALIDATION) #if ENABLED(G26_MESH_VALIDATION)
SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
#endif #endif
@ -589,12 +589,12 @@ void _menu_ubl_tools() {
void _lcd_ubl_step_by_step() { void _lcd_ubl_step_by_step() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED); BACK_ITEM(MSG_UBL_LEVEL_BED);
GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G28\nG29 P1")); GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G28\nG29P1"));
GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29 P3 T0")); GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0"));
SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29 P4 R999 T")); GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4R999T"));
SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29 P4 R999 T")); GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29P4R999T"));
ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd); ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
END_MENU(); END_MENU();
} }
@ -618,9 +618,9 @@ void _lcd_ubl_level_bed() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_MOTION); BACK_ITEM(MSG_MOTION);
if (planner.leveling_active) if (planner.leveling_active)
GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D")); GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, PSTR("G29D"));
else else
GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, PSTR("G29 A")); GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, PSTR("G29A"));
#if ENABLED(G26_MESH_VALIDATION) #if ENABLED(G26_MESH_VALIDATION)
SUBMENU(MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step); SUBMENU(MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step);
#endif #endif
@ -628,7 +628,7 @@ void _lcd_ubl_level_bed() {
SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh); SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map); SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
SUBMENU(MSG_UBL_TOOLS, _menu_ubl_tools); SUBMENU(MSG_UBL_TOOLS, _menu_ubl_tools);
GCODES_ITEM(MSG_UBL_INFO_UBL, PSTR("G29 W")); GCODES_ITEM(MSG_UBL_INFO_UBL, PSTR("G29W"));
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
editable.decimal = planner.z_fade_height; editable.decimal = planner.z_fade_height;
EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); }); EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });