Browse Source

Optimize some G-code strings

Scott Lahteine 4 years ago
parent
commit
fb41413b76

+ 2
- 2
Marlin/src/gcode/calibrate/G76_M192_M871.cpp View File

@@ -38,7 +38,7 @@
38 38
 #include "../../feature/probe_temp_comp.h"
39 39
 
40 40
 #include "../../lcd/marlinui.h"
41
-#include "../../MarlinCore.h" // for wait_for_heatup and idle()
41
+#include "../../MarlinCore.h" // for wait_for_heatup, idle(), G28_STR
42 42
 
43 43
 #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
44 44
   #include "../../module/printcounter.h"
@@ -168,7 +168,7 @@ void GcodeSuite::G76() {
168 168
       return;
169 169
     }
170 170
 
171
-    process_subcommands_now_P(PSTR("G28"));
171
+    process_subcommands_now_P(G28_STR);
172 172
   }
173 173
 
174 174
   remember_feedrate_scaling_off();

+ 1
- 1
Marlin/src/lcd/dwin/e3v2/dwin.cpp View File

@@ -2332,7 +2332,7 @@ void HMI_Prepare() {
2332 2332
       case PREPARE_CASE_HOME: // Homing
2333 2333
         checkkey = Last_Prepare;
2334 2334
         index_prepare = MROWS;
2335
-        queue.inject_P(PSTR("G28")); // G28 will set home_flag
2335
+        queue.inject_P(G28_STR); // G28 will set home_flag
2336 2336
         Popup_Window_Home();
2337 2337
         break;
2338 2338
       #if HAS_ZOFFSET_ITEM

+ 6
- 6
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp View File

@@ -620,10 +620,10 @@ namespace Anycubic {
620 620
       case 21:   // A21 Home Axis  A21 X
621 621
         if (!isPrinting()) {
622 622
           switch ((char)panel_command[4]) {
623
-            case 'X': injectCommands_P(PSTR("G28 X")); break;
624
-            case 'Y': injectCommands_P(PSTR("G28 Y")); break;
625
-            case 'Z': injectCommands_P(PSTR("G28 Z")); break;
626
-            case 'C': injectCommands_P(PSTR("G28")); break;
623
+            case 'X': injectCommands_P(PSTR("G28X")); break;
624
+            case 'Y': injectCommands_P(PSTR("G28Y")); break;
625
+            case 'Z': injectCommands_P(PSTR("G28Z")); break;
626
+            case 'C': injectCommands_P(G28_STR); break;
627 627
           }
628 628
         }
629 629
         break;
@@ -718,7 +718,7 @@ namespace Anycubic {
718 718
           // If the same meshpoint is selected twice in a row, move the head to that ready for adjustment
719 719
           if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) {
720 720
             if (!isPositionKnown())
721
-              injectCommands_P(PSTR("G28")); // home
721
+              injectCommands_P(G28_STR); // home
722 722
 
723 723
             if (isPositionKnown()) {
724 724
               #if ACDEBUG(AC_INFO)
@@ -746,7 +746,7 @@ namespace Anycubic {
746 746
           if (isPrinting())
747 747
             SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
748 748
           else {
749
-            injectCommands_P(isMachineHomed() ? PSTR("G29") : PSTR("G28\nG29"));
749
+            injectCommands_P(PSTR("G28O\nG29"));
750 750
             printer_state = AC_printer_probing;
751 751
             SendtoTFTLN(AC_msg_start_probing);
752 752
           }

+ 2
- 2
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h View File

@@ -105,8 +105,8 @@
105 105
 
106 106
 #define AC_cmnd_manual_load_filament   PSTR("M83\nG1 E50 F700\nM82")   // replace the manual panel commands with something a little faster
107 107
 #define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82")
108
-#define AC_cmnd_enable_leveling        PSTR("M420 S1 V1")
109
-#define AC_cmnd_power_loss_recovery    PSTR("G28 X Y R5\nG28 Z")       // Lift, home X and Y then home Z when in 'safe' position
108
+#define AC_cmnd_enable_leveling        PSTR("M420SV")
109
+#define AC_cmnd_power_loss_recovery    PSTR("G28XYR5\nG28Z")           // Lift, home X and Y then home Z when in 'safe' position
110 110
 
111 111
 namespace Anycubic {
112 112
   enum heater_state_t : uint8_t {

+ 7
- 7
Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #include "../../../../libs/numtostr.h"
30 30
 #include "../../../../module/motion.h"  // for A20 read printing speed feedrate_percentage
31
-#include "../../../../MarlinCore.h"     // for quickstop_stepper and disable_steppers
31
+#include "../../../../MarlinCore.h"     // for quickstop_stepper, disable_steppers, G28_STR
32 32
 #include "../../../../inc/MarlinConfig.h"
33 33
 
34 34
 // command sending macro's with debugging capability
@@ -274,12 +274,12 @@ void AnycubicTFTClass::HandleSpecialMenu() {
274 274
 
275 275
               case '6': // "<06SMeshLvl>"
276 276
                 SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling");
277
-                ExtUI::injectCommands_P(PSTR("G29 S1"));
277
+                ExtUI::injectCommands_P(PSTR("G29S1"));
278 278
                 break;
279 279
 
280 280
               case '7': // "<07MeshNPnt>"
281 281
                 SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point");
282
-                ExtUI::injectCommands_P(PSTR("G29 S2"));
282
+                ExtUI::injectCommands_P(PSTR("G29S2"));
283 283
                 break;
284 284
 
285 285
               case '8': // "<08HtEndPID>"
@@ -758,14 +758,14 @@ void AnycubicTFTClass::GetCommandFromTFT() {
758 758
             if (!ExtUI::isPrinting() && !ExtUI::isPrintingFromMediaPaused()) {
759 759
               if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) {
760 760
                 if (CodeSeen('X'))
761
-                  ExtUI::injectCommands_P(PSTR("G28 X"));
761
+                  ExtUI::injectCommands_P(PSTR("G28X"));
762 762
                 if (CodeSeen('Y'))
763
-                  ExtUI::injectCommands_P(PSTR("G28 Y"));
763
+                  ExtUI::injectCommands_P(PSTR("G28Y"));
764 764
                 if (CodeSeen('Z'))
765
-                  ExtUI::injectCommands_P(PSTR("G28 Z"));
765
+                  ExtUI::injectCommands_P(PSTR("G28Z"));
766 766
               }
767 767
               else if (CodeSeen('C')) {
768
-                ExtUI::injectCommands_P(PSTR("G28"));
768
+                ExtUI::injectCommands_P(G28_STR);
769 769
               }
770 770
             }
771 771
             break;

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.cpp View File

@@ -319,7 +319,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
319 319
     case  9: GOTO_SCREEN(FilesScreen); break;
320 320
     case 10: GOTO_SCREEN(MainMenu); break;
321 321
     case 13: GOTO_SCREEN(BioConfirmHomeE); break;
322
-    case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break;
322
+    case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break;
323 323
     case 15: GOTO_SCREEN(TemperatureScreen);  break;
324 324
     case 16: fine_motion = !fine_motion; break;
325 325
     default: return false;

+ 3
- 3
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp View File

@@ -94,9 +94,9 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) {
94 94
     case 14: UI_DECREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] -= increment; break;
95 95
     case 15: UI_INCREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] += increment; break;
96 96
     #endif
97
-    case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28 X")); break;
98
-    case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28 Y")); break;
99
-    case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break;
97
+    case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28X")); break;
98
+    case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28Y")); break;
99
+    case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break;
100 100
     case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28"));   break;
101 101
     default:
102 102
       return false;

+ 7
- 5
Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp View File

@@ -31,6 +31,8 @@
31 31
 #include "../../../../gcode/queue.h"
32 32
 #include "../../../../inc/MarlinConfig.h"
33 33
 
34
+extern const char G28_STR[];
35
+
34 36
 extern lv_group_t *g;
35 37
 static lv_obj_t *scr;
36 38
 
@@ -48,22 +50,22 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
48 50
   if (event != LV_EVENT_RELEASED) return;
49 51
   switch (obj->mks_obj_id) {
50 52
     case ID_H_ALL:
51
-      queue.inject_P(PSTR("G28"));
53
+      queue.inject_P(G28_STR);
52 54
       break;
53 55
     case ID_H_X:
54
-      queue.inject_P(PSTR("G28 X0"));
56
+      queue.inject_P(PSTR("G28X"));
55 57
       break;
56 58
     case ID_H_Y:
57
-      queue.inject_P(PSTR("G28 Y0"));
59
+      queue.inject_P(PSTR("G28Y"));
58 60
       break;
59 61
     case ID_H_Z:
60
-      queue.inject_P(PSTR("G28 Z0"));
62
+      queue.inject_P(PSTR("G28Z"));
61 63
       break;
62 64
     case ID_H_OFF_ALL:
63 65
       queue.inject_P(PSTR("M84"));
64 66
       break;
65 67
     case ID_H_OFF_XY:
66
-      queue.inject_P(PSTR("M84 X Y"));
68
+      queue.inject_P(PSTR("M84XY"));
67 69
       break;
68 70
     case ID_H_RETURN:
69 71
       clear_cur_ui();

+ 8
- 56
Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp View File

@@ -29,6 +29,8 @@
29 29
 #include "../../../../gcode/queue.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
+extern const char G28_STR[];
33
+
32 34
 extern lv_group_t *g;
33 35
 static lv_obj_t *scr;
34 36
 
@@ -45,65 +47,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
45 47
   if (event != LV_EVENT_RELEASED) return;
46 48
 
47 49
   switch (obj->mks_obj_id) {
48
-    case ID_M_POINT1:
49
-      if (queue.length == 0) {
50
-        if (uiCfg.leveling_first_time) {
51
-          queue.enqueue_now_P(PSTR("G28"));
52
-          uiCfg.leveling_first_time = 0;
53
-        }
54
-        queue.enqueue_now_P(PSTR("G1 Z10"));
55
-        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]);
56
-        queue.enqueue_one_now(public_buf_l);
57
-        queue.enqueue_now_P(PSTR("G1 Z0"));
58
-      }
59
-      break;
60
-    case ID_M_POINT2:
61
-      if (queue.length == 0) {
62
-        if (uiCfg.leveling_first_time) {
63
-          queue.enqueue_now_P(PSTR("G28"));
64
-          uiCfg.leveling_first_time = 0;
65
-        }
66
-        queue.enqueue_now_P(PSTR("G1 Z10"));
67
-        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]);
68
-        queue.enqueue_one_now(public_buf_l);
69
-        queue.enqueue_now_P(PSTR("G1 Z0"));
70
-      }
71
-      break;
72
-    case ID_M_POINT3:
73
-      if (queue.length == 0) {
74
-        if (uiCfg.leveling_first_time) {
75
-          queue.enqueue_now_P(PSTR("G28"));
76
-          uiCfg.leveling_first_time = 0;
77
-        }
78
-        queue.enqueue_now_P(PSTR("G1 Z10"));
79
-        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]);
80
-        queue.enqueue_one_now(public_buf_l);
81
-        queue.enqueue_now_P(PSTR("G1 Z0"));
82
-      }
83
-
84
-      break;
85
-    case ID_M_POINT4:
86
-      if (queue.length == 0) {
87
-        if (uiCfg.leveling_first_time) {
88
-          queue.enqueue_now_P(PSTR("G28"));
89
-          uiCfg.leveling_first_time = 0;
90
-        }
91
-        queue.enqueue_now_P(PSTR("G1 Z10"));
92
-        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]);
93
-        queue.enqueue_one_now(public_buf_l);
94
-        queue.enqueue_now_P(PSTR("G1 Z0"));
95
-      }
96
-      break;
97
-    case ID_M_POINT5:
50
+    case ID_M_POINT1 ... ID_M_POINT5:
98 51
       if (queue.length == 0) {
99 52
         if (uiCfg.leveling_first_time) {
100
-          queue.enqueue_now_P(PSTR("G28"));
101
-          uiCfg.leveling_first_time = 0;
53
+          uiCfg.leveling_first_time = false;
54
+          queue.inject_P(G28_STR);
102 55
         }
103
-        queue.enqueue_now_P(PSTR("G1 Z10"));
104
-        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]);
105
-        queue.enqueue_one_now(public_buf_l);
106
-        queue.enqueue_now_P(PSTR("G1 Z0"));
56
+        const int ind = obj->mks_obj_id - ID_M_POINT1;
57
+        sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), (int)gCfgItems.levelingPos[ind][0], (int)gCfgItems.levelingPos[ind][1]);
58
+        queue.inject(public_buf_l);
107 59
       }
108 60
       break;
109 61
     case ID_MANUAL_RETURN:

+ 4
- 4
Marlin/src/lcd/menu/menu_bed_leveling.cpp View File

@@ -103,9 +103,9 @@
103 103
         ui.wait_for_move = true;
104 104
         ui.goto_screen(_lcd_level_bed_done);
105 105
         #if ENABLED(MESH_BED_LEVELING)
106
-          queue.inject_P(PSTR("G29 S2"));
106
+          queue.inject_P(PSTR("G29S2"));
107 107
         #elif ENABLED(PROBE_MANUALLY)
108
-          queue.inject_P(PSTR("G29 V1"));
108
+          queue.inject_P(PSTR("G29V1"));
109 109
         #endif
110 110
       }
111 111
       else
@@ -155,9 +155,9 @@
155 155
     // G29 Records Z, moves, and signals when it pauses
156 156
     ui.wait_for_move = true;
157 157
     #if ENABLED(MESH_BED_LEVELING)
158
-      queue.inject_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
158
+      queue.inject_P(manual_probe_index ? PSTR("G29S2") : PSTR("G29S1"));
159 159
     #elif ENABLED(PROBE_MANUALLY)
160
-      queue.inject_P(PSTR("G29 V1"));
160
+      queue.inject_P(PSTR("G29V1"));
161 161
     #endif
162 162
   }
163 163
 

+ 1
- 1
Marlin/src/lcd/menu/menu_motion.cpp View File

@@ -402,7 +402,7 @@ void menu_motion() {
402 402
   #endif
403 403
 
404 404
   #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
405
-    GCODES_ITEM(MSG_M48_TEST, PSTR("G28 O\nM48 P10"));
405
+    GCODES_ITEM(MSG_M48_TEST, PSTR("G28O\nM48 P10"));
406 406
   #endif
407 407
 
408 408
   //

Loading…
Cancel
Save