Explorar el Código

🐛 Fix Manual Move axis selection (#24404)

Scott Lahteine hace 2 años
padre
commit
d8545551fe

+ 9
- 9
Marlin/src/lcd/e3v2/jyersui/dwin.cpp Ver fichero

283
 
283
 
284
     #endif
284
     #endif
285
 
285
 
286
-    void manual_move(bool zmove=false) {
286
+    void manual_mesh_move(const bool zmove=false) {
287
       if (zmove) {
287
       if (zmove) {
288
         planner.synchronize();
288
         planner.synchronize();
289
         current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
289
         current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
3035
                   mesh_conf.goto_mesh_value = true;
3035
                   mesh_conf.goto_mesh_value = true;
3036
                   mesh_conf.mesh_x = mesh_conf.mesh_y = 0;
3036
                   mesh_conf.mesh_x = mesh_conf.mesh_y = 0;
3037
                   Popup_Handler(MoveWait);
3037
                   Popup_Handler(MoveWait);
3038
-                  mesh_conf.manual_move();
3038
+                  mesh_conf.manual_mesh_move();
3039
                   Draw_Menu(UBLMesh);
3039
                   Draw_Menu(UBLMesh);
3040
                 #endif
3040
                 #endif
3041
               #elif HAS_BED_PROBE
3041
               #elif HAS_BED_PROBE
3091
                 TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating());
3091
                 TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating());
3092
               #endif
3092
               #endif
3093
               Popup_Handler(MoveWait);
3093
               Popup_Handler(MoveWait);
3094
-              mesh_conf.manual_move();
3094
+              mesh_conf.manual_mesh_move();
3095
               Draw_Menu(LevelManual);
3095
               Draw_Menu(LevelManual);
3096
             }
3096
             }
3097
             break;
3097
             break;
3328
                   mesh_conf.mesh_x++;
3328
                   mesh_conf.mesh_x++;
3329
                 else
3329
                 else
3330
                   mesh_conf.mesh_x--;
3330
                   mesh_conf.mesh_x--;
3331
-                mesh_conf.manual_move();
3331
+                mesh_conf.manual_mesh_move();
3332
               }
3332
               }
3333
             }
3333
             }
3334
             break;
3334
             break;
3375
             else {
3375
             else {
3376
               mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value;
3376
               mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value;
3377
               current_position.z = 0;
3377
               current_position.z = 0;
3378
-              mesh_conf.manual_move(true);
3378
+              mesh_conf.manual_mesh_move(true);
3379
               Draw_Checkbox(row, mesh_conf.goto_mesh_value);
3379
               Draw_Checkbox(row, mesh_conf.goto_mesh_value);
3380
             }
3380
             }
3381
             break;
3381
             break;
3428
                   mesh_conf.mesh_x++;
3428
                   mesh_conf.mesh_x++;
3429
                 else
3429
                 else
3430
                   mesh_conf.mesh_x--;
3430
                   mesh_conf.mesh_x--;
3431
-                mesh_conf.manual_move();
3431
+                mesh_conf.manual_mesh_move();
3432
               }
3432
               }
3433
               else {
3433
               else {
3434
                 gcode.process_subcommands_now(F("G29 S"));
3434
                 gcode.process_subcommands_now(F("G29 S"));
3449
                   mesh_conf.mesh_x--;
3449
                   mesh_conf.mesh_x--;
3450
                 else
3450
                 else
3451
                   mesh_conf.mesh_x++;
3451
                   mesh_conf.mesh_x++;
3452
-                mesh_conf.manual_move();
3452
+                mesh_conf.manual_mesh_move();
3453
               }
3453
               }
3454
             }
3454
             }
3455
             break;
3455
             break;
4109
           planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
4109
           planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
4110
           planner.synchronize();
4110
           planner.synchronize();
4111
           break;
4111
           break;
4112
-        case UBLMesh:     mesh_conf.manual_move(true); break;
4113
-        case LevelManual: mesh_conf.manual_move(selection == LEVELING_M_OFFSET); break;
4112
+        case UBLMesh:     mesh_conf.manual_mesh_move(true); break;
4113
+        case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break;
4114
       #endif
4114
       #endif
4115
     }
4115
     }
4116
     if (valuepointer == &planner.flow_percentage[0])
4116
     if (valuepointer == &planner.flow_percentage[0])

+ 1
- 2
Marlin/src/lcd/e3v2/marlinui/ui_common.cpp Ver fichero

410
       const dwin_coord_t by = (row * MENU_LINE_HEIGHT) + MENU_FONT_HEIGHT + EXTRA_ROW_HEIGHT / 2;
410
       const dwin_coord_t by = (row * MENU_LINE_HEIGHT) + MENU_FONT_HEIGHT + EXTRA_ROW_HEIGHT / 2;
411
       DWIN_Draw_String(true, font16x32, Color_Yellow, Color_Bg_Black, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string()));
411
       DWIN_Draw_String(true, font16x32, Color_Yellow, Color_Bg_Black, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string()));
412
 
412
 
413
-      extern screenFunc_t _manual_move_func_ptr;
414
-      if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
413
+      if (ui.can_show_slider()) {
415
 
414
 
416
         const dwin_coord_t slider_length = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_LANDSCAPE, 120, 20),
415
         const dwin_coord_t slider_length = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_LANDSCAPE, 120, 20),
417
                            slider_height = 16,
416
                            slider_height = 16,

+ 1
- 1
Marlin/src/lcd/language/language_en.h Ver fichero

309
   LSTR MSG_MOVE_Z                         = _UxGT("Move Z");
309
   LSTR MSG_MOVE_Z                         = _UxGT("Move Z");
310
   LSTR MSG_MOVE_N                         = _UxGT("Move @");
310
   LSTR MSG_MOVE_N                         = _UxGT("Move @");
311
   LSTR MSG_MOVE_E                         = _UxGT("Move Extruder");
311
   LSTR MSG_MOVE_E                         = _UxGT("Move Extruder");
312
-  LSTR MSG_MOVE_EN                        = _UxGT("Move E*");
312
+  LSTR MSG_MOVE_EN                        = _UxGT("Move *");
313
   LSTR MSG_HOTEND_TOO_COLD                = _UxGT("Hotend too cold");
313
   LSTR MSG_HOTEND_TOO_COLD                = _UxGT("Hotend too cold");
314
   LSTR MSG_MOVE_N_MM                      = _UxGT("Move $mm");
314
   LSTR MSG_MOVE_N_MM                      = _UxGT("Move $mm");
315
   LSTR MSG_MOVE_01MM                      = _UxGT("Move 0.1mm");
315
   LSTR MSG_MOVE_01MM                      = _UxGT("Move 0.1mm");

+ 5
- 4
Marlin/src/lcd/marlinui.cpp Ver fichero

763
 
763
 
764
     millis_t ManualMove::start_time = 0;
764
     millis_t ManualMove::start_time = 0;
765
     float ManualMove::menu_scale = 1;
765
     float ManualMove::menu_scale = 1;
766
+    screenFunc_t ManualMove::screen_ptr;
766
     #if IS_KINEMATIC
767
     #if IS_KINEMATIC
767
       float ManualMove::offset = 0;
768
       float ManualMove::offset = 0;
768
       xyze_pos_t ManualMove::all_axes_destination = { 0 };
769
       xyze_pos_t ManualMove::all_axes_destination = { 0 };
772
       int8_t ManualMove::e_index = 0;
773
       int8_t ManualMove::e_index = 0;
773
     #endif
774
     #endif
774
     AxisEnum ManualMove::axis = NO_AXIS_ENUM;
775
     AxisEnum ManualMove::axis = NO_AXIS_ENUM;
776
+    #if ENABLED(MANUAL_E_MOVES_RELATIVE)
777
+      float ManualMove::e_origin = 0;
778
+    #endif
775
 
779
 
776
     /**
780
     /**
777
      * If a manual move has been posted and its time has arrived, and if the planner
781
      * If a manual move has been posted and its time has arrived, and if the planner
788
      * For kinematic machines:
792
      * For kinematic machines:
789
      *   - Set manual_move.offset to modify one axis and post the move.
793
      *   - Set manual_move.offset to modify one axis and post the move.
790
      *     This is used to achieve more rapid stepping on kinematic machines.
794
      *     This is used to achieve more rapid stepping on kinematic machines.
791
-     *
792
-     * Currently used by the _lcd_move_xyz function in menu_motion.cpp
793
-     * and the ubl_map_move_to_xy function in menu_ubl.cpp.
794
      */
795
      */
795
     void ManualMove::task() {
796
     void ManualMove::task() {
796
 
797
 
861
 
862
 
862
       void MarlinUI::external_encoder() {
863
       void MarlinUI::external_encoder() {
863
         if (external_control && encoderDiff) {
864
         if (external_control && encoderDiff) {
864
-          bedlevel.encoder_diff += encoderDiff;  // Encoder for UBL G29 mesh editing
865
+          bedlevel.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing
865
           encoderDiff = 0;                  // Hide encoder events from the screen handler
866
           encoderDiff = 0;                  // Hide encoder events from the screen handler
866
           refresh(LCDVIEW_REDRAW_NOW);      // ...but keep the refresh.
867
           refresh(LCDVIEW_REDRAW_NOW);      // ...but keep the refresh.
867
         }
868
         }

+ 9
- 9
Marlin/src/lcd/marlinui.h Ver fichero

137
       static xyze_pos_t all_axes_destination;
137
       static xyze_pos_t all_axes_destination;
138
     #endif
138
     #endif
139
   public:
139
   public:
140
+    static screenFunc_t screen_ptr;
140
     static float menu_scale;
141
     static float menu_scale;
141
     #if IS_KINEMATIC
142
     #if IS_KINEMATIC
142
       static float offset;
143
       static float offset;
143
     #endif
144
     #endif
145
+    #if ENABLED(MANUAL_E_MOVES_RELATIVE)
146
+      static float e_origin;
147
+    #endif
144
     template <typename T>
148
     template <typename T>
145
-    void set_destination(const T& dest) {
149
+    static void set_destination(const T& dest) {
146
       #if IS_KINEMATIC
150
       #if IS_KINEMATIC
147
         // Moves are segmented, so the entire move is not submitted at once.
151
         // Moves are segmented, so the entire move is not submitted at once.
148
         // Using a separate variable prevents corrupting the in-progress move.
152
         // Using a separate variable prevents corrupting the in-progress move.
153
         current_position.set(dest);
157
         current_position.set(dest);
154
       #endif
158
       #endif
155
     }
159
     }
156
-    float axis_value(const AxisEnum axis) {
160
+    static float axis_value(const AxisEnum axis) {
157
       return NATIVE_TO_LOGICAL(processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], offset), axis);
161
       return NATIVE_TO_LOGICAL(processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], offset), axis);
158
     }
162
     }
159
-    bool apply_diff(const AxisEnum axis, const_float_t diff, const_float_t min, const_float_t max) {
163
+    static bool apply_diff(const AxisEnum axis, const_float_t diff, const_float_t min, const_float_t max) {
160
       #if IS_KINEMATIC
164
       #if IS_KINEMATIC
161
         float &valref = offset;
165
         float &valref = offset;
162
         const float rmin = min - current_position[axis], rmax = max - current_position[axis];
166
         const float rmin = min - current_position[axis], rmax = max - current_position[axis];
166
       #endif
170
       #endif
167
       valref += diff;
171
       valref += diff;
168
       const float pre = valref;
172
       const float pre = valref;
169
-      if (min != max) {
170
-        if (diff < 0)
171
-          NOLESS(valref, rmin);
172
-        else
173
-          NOMORE(valref, rmax);
174
-      }
173
+      if (min != max) { if (diff < 0) NOLESS(valref, rmin); else NOMORE(valref, rmax); }
175
       return pre != valref;
174
       return pre != valref;
176
     }
175
     }
177
     #if IS_KINEMATIC
176
     #if IS_KINEMATIC
552
 
551
 
553
     // Manual Movement
552
     // Manual Movement
554
     static ManualMove manual_move;
553
     static ManualMove manual_move;
554
+    static bool can_show_slider() { return !external_control && currentScreen != manual_move.screen_ptr; }
555
 
555
 
556
     // Select Screen (modal NO/YES style dialog)
556
     // Select Screen (modal NO/YES style dialog)
557
     static bool selection;
557
     static bool selection;

+ 18
- 31
Marlin/src/lcd/menu/menu_motion.cpp Ver fichero

46
   #include "../../feature/bedlevel/bedlevel.h"
46
   #include "../../feature/bedlevel/bedlevel.h"
47
 #endif
47
 #endif
48
 
48
 
49
-#if ENABLED(MANUAL_E_MOVES_RELATIVE)
50
-  float manual_move_e_origin = 0;
51
-#endif
52
-
53
 //
49
 //
54
 // "Motion" > "Move Axis" submenu
50
 // "Motion" > "Move Axis" submenu
55
 //
51
 //
56
 
52
 
57
-static void _lcd_move_xyz(const AxisEnum axis) {
53
+void lcd_move_axis(const AxisEnum axis) {
58
   if (ui.use_click()) return ui.goto_previous_screen_no_defer();
54
   if (ui.use_click()) return ui.goto_previous_screen_no_defer();
59
   if (ui.encoderPosition && !ui.manual_move.processing) {
55
   if (ui.encoderPosition && !ui.manual_move.processing) {
60
     // Get motion limit from software endstops, if any
56
     // Get motion limit from software endstops, if any
88
   }
84
   }
89
 }
85
 }
90
 
86
 
91
-void _lcd_move_axis_n() { _lcd_move_xyz(AxisEnum(MenuItemBase::itemIndex)); }
92
-
93
-// Move functions for non-menu code that hasn't set itemIndex (e.g., keypad)
94
-void lcd_move_axis(const AxisEnum axis) { MenuEditItemBase::itemIndex = int8_t(axis); _lcd_move_axis_n(); }
95
-
96
 // Move Z easy accessor
87
 // Move Z easy accessor
97
 void lcd_move_z() { lcd_move_axis(Z_AXIS); }
88
 void lcd_move_z() { lcd_move_axis(Z_AXIS); }
98
 
89
 
115
         GET_TEXT_F(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)),
106
         GET_TEXT_F(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)),
116
         ftostr41sign(current_position.e
107
         ftostr41sign(current_position.e
117
           PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset)
108
           PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset)
118
-          MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin)
109
+          MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, ui.manual_move.e_origin)
119
         )
110
         )
120
       );
111
       );
121
     } // should_draw
112
     } // should_draw
140
   #define FINE_MANUAL_MOVE 0.025
131
   #define FINE_MANUAL_MOVE 0.025
141
 #endif
132
 #endif
142
 
133
 
143
-screenFunc_t _manual_move_func_ptr;
144
-
145
 void _goto_manual_move(const_float_t scale) {
134
 void _goto_manual_move(const_float_t scale) {
146
   ui.defer_status_screen();
135
   ui.defer_status_screen();
147
   ui.manual_move.menu_scale = scale;
136
   ui.manual_move.menu_scale = scale;
148
-  ui.goto_screen(_manual_move_func_ptr);
137
+  ui.goto_screen(ui.manual_move.screen_ptr);
149
   thermalManager.set_menu_cold_override(true);
138
   thermalManager.set_menu_cold_override(true);
150
 }
139
 }
151
 
140
 
152
 void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) {
141
 void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) {
153
-  _manual_move_func_ptr = func;
142
+  ui.manual_move.screen_ptr = func;
154
   START_MENU();
143
   START_MENU();
155
   if (LCD_HEIGHT >= 4) {
144
   if (LCD_HEIGHT >= 4) {
156
-    switch (axis) {
157
-      #define _CASE_MOVE(N) case N##_AXIS: STATIC_ITEM_N(N##_AXIS, MSG_MOVE_N, SS_DEFAULT|SS_INVERT); break;
158
-      MAIN_AXIS_MAP(_CASE_MOVE)
159
-      default:
160
-        TERN_(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin = current_position.e);
161
-        STATIC_ITEM(MSG_MOVE_E, SS_DEFAULT|SS_INVERT);
162
-        break;
145
+    if (axis < NUM_AXES)
146
+      STATIC_ITEM_N(axis, MSG_MOVE_N, SS_DEFAULT|SS_INVERT);
147
+    else {
148
+      TERN_(MANUAL_E_MOVES_RELATIVE, ui.manual_move.e_origin = current_position.e);
149
+      STATIC_ITEM_N(eindex, MSG_MOVE_EN, SS_DEFAULT|SS_INVERT);
163
     }
150
     }
164
   }
151
   }
165
 
152
 
181
   END_MENU();
168
   END_MENU();
182
 }
169
 }
183
 
170
 
184
-void _menu_move_n_distance() { _menu_move_distance(AxisEnum(MenuItemBase::itemIndex), _lcd_move_axis_n); }
185
-
186
 #if E_MANUAL
171
 #if E_MANUAL
187
 
172
 
188
   inline void _goto_menu_move_distance_e() {
173
   inline void _goto_menu_move_distance_e() {
216
   // Move submenu for each axis
201
   // Move submenu for each axis
217
   if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) {
202
   if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) {
218
     if (TERN1(DELTA, current_position.z <= delta_clip_start_height)) {
203
     if (TERN1(DELTA, current_position.z <= delta_clip_start_height)) {
219
-      for (uint8_t a = X_AXIS; a <= min(int(Y_AXIS), NUM_AXES - 1); a++)
220
-        SUBMENU_N(a, MSG_MOVE_N, _menu_move_n_distance);
204
+      SUBMENU_N(X_AXIS, MSG_MOVE_N, []{ _menu_move_distance(X_AXIS, []{ lcd_move_axis(X_AXIS); }); });
205
+      #if HAS_Y_AXIS
206
+        SUBMENU_N(Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance(Y_AXIS, []{ lcd_move_axis(Y_AXIS); }); });
207
+      #endif
221
     }
208
     }
222
     else {
209
     else {
223
       #if ENABLED(DELTA)
210
       #if ENABLED(DELTA)
225
       #endif
212
       #endif
226
     }
213
     }
227
     #if HAS_Z_AXIS
214
     #if HAS_Z_AXIS
228
-      for (uint8_t a = Z_AXIS; a < NUM_AXES; a++)
229
-        SUBMENU_N(a, MSG_MOVE_N, _menu_move_n_distance);
215
+      #define _AXIS_MOVE(N) SUBMENU_N(N, MSG_MOVE_N, []{ _menu_move_distance(AxisEnum(N), []{ lcd_move_axis(AxisEnum(N)); }); });
216
+      REPEAT_S(2, NUM_AXES, _AXIS_MOVE);
230
     #endif
217
     #endif
231
   }
218
   }
232
   else
219
   else
271
   #if E_MANUAL
258
   #if E_MANUAL
272
 
259
 
273
     // The current extruder
260
     // The current extruder
274
-    SUBMENU(MSG_MOVE_E, []{ _menu_move_distance_e_maybe(); });
261
+    SUBMENU(MSG_MOVE_E, _menu_move_distance_e_maybe);
275
 
262
 
276
-    #define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(MenuItemBase::itemIndex); }, MenuItemBase::itemIndex); });
263
+    #define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(N); }, N); });
277
 
264
 
278
     #if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
265
     #if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
279
 
266
 
285
     #elif MULTI_E_MANUAL
272
     #elif MULTI_E_MANUAL
286
 
273
 
287
       // Independent extruders with one E stepper per hotend
274
       // Independent extruders with one E stepper per hotend
288
-      LOOP_L_N(n, E_MANUAL) SUBMENU_MOVE_E(n);
275
+      REPEAT(E_MANUAL, SUBMENU_MOVE_E);
289
 
276
 
290
     #endif
277
     #endif
291
 
278
 

+ 1
- 2
Marlin/src/lcd/tft/ui_1024x600.cpp Ver fichero

394
     }
394
     }
395
   #endif
395
   #endif
396
 
396
 
397
-  extern screenFunc_t _manual_move_func_ptr;
398
-  if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
397
+  if (ui.can_show_slider()) {
399
 
398
 
400
     #define SLIDER_LENGTH 600
399
     #define SLIDER_LENGTH 600
401
     #define SLIDER_Y_POSITION 200
400
     #define SLIDER_Y_POSITION 200

+ 1
- 2
Marlin/src/lcd/tft/ui_320x240.cpp Ver fichero

383
     }
383
     }
384
   #endif
384
   #endif
385
 
385
 
386
-  extern screenFunc_t _manual_move_func_ptr;
387
-  if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
386
+  if (ui.can_show_slider()) {
388
 
387
 
389
     #define SLIDER_LENGTH 224
388
     #define SLIDER_LENGTH 224
390
     #define SLIDER_Y_POSITION 140
389
     #define SLIDER_Y_POSITION 140

+ 1
- 2
Marlin/src/lcd/tft/ui_480x320.cpp Ver fichero

388
     }
388
     }
389
   #endif
389
   #endif
390
 
390
 
391
-  extern screenFunc_t _manual_move_func_ptr;
392
-  if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
391
+  if (ui.can_show_slider()) {
393
 
392
 
394
     #define SLIDER_LENGTH 336
393
     #define SLIDER_LENGTH 336
395
     #define SLIDER_Y_POSITION 186
394
     #define SLIDER_Y_POSITION 186

Loading…
Cancelar
Guardar