Browse Source

Allocate sufficient MSG_MOVE_Z_DIST buffer

See #19158
Scott Lahteine 3 years ago
parent
commit
e8dcbd8300
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      Marlin/src/lcd/menu/menu_motion.cpp

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

@@ -195,11 +195,12 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
195 195
     SUBMENU(MSG_MOVE_1MM,  []{ _goto_manual_move( 1);    });
196 196
     SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); });
197 197
     if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
198
-      char tmp[20], numstr[10];
199 198
       // Determine digits needed right of decimal
200
-      const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
201
-                           !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) *  100 - int((SHORT_MANUAL_Z_MOVE) *  100)) ? 3 : 2;
202
-      sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
199
+      constexpr uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
200
+                               !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) *  100 - int((SHORT_MANUAL_Z_MOVE) *  100)) ? 3 : 2;
201
+      PGM_P const label = GET_TEXT(MSG_MOVE_Z_DIST);
202
+      char tmp[strlen_P(label) + 10 + 1], numstr[10];
203
+      sprintf_P(tmp, label, dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
203 204
 
204 205
       #if DISABLED(HAS_GRAPHICAL_TFT)
205 206
         extern const char NUL_STR[];

Loading…
Cancel
Save