Преглед изворни кода

LCD position in current units (#20145)

rdhoggattjr пре 4 година
родитељ
комит
62680bb356
No account linked to committer's email address

+ 1
- 6
Marlin/src/gcode/host/M114.cpp Прегледај датотеку

55
   }
55
   }
56
 
56
 
57
   void report_current_position_detail() {
57
   void report_current_position_detail() {
58
-
59
     // Position as sent by G-code
58
     // Position as sent by G-code
60
     SERIAL_ECHOPGM("\nLogical:");
59
     SERIAL_ECHOPGM("\nLogical:");
61
     report_xyz(current_position.asLogical());
60
     report_xyz(current_position.asLogical());
81
 
80
 
82
     #if IS_KINEMATIC
81
     #if IS_KINEMATIC
83
       // Kinematics applied to the leveled position
82
       // Kinematics applied to the leveled position
84
-      #if IS_SCARA
85
-        SERIAL_ECHOPGM("ScaraK: ");
86
-      #else
87
-        SERIAL_ECHOPGM("DeltaK: ");
88
-      #endif
83
+      SERIAL_ECHOPGM(TERN(IS_SCARA, "ScaraK: ", "DeltaK: "));
89
       inverse_kinematics(leveled);  // writes delta[]
84
       inverse_kinematics(leveled);  // writes delta[]
90
       report_xyz(delta);
85
       report_xyz(delta);
91
     #endif
86
     #endif

+ 4
- 0
Marlin/src/gcode/parser.h Прегледај датотеку

329
 
329
 
330
   #endif
330
   #endif
331
 
331
 
332
+  static inline bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; }
333
+
334
+  #define IN_TO_MM(I)        ((I) * 25.4f)
335
+  #define MM_TO_IN(M)        ((M) / 25.4f)
332
   #define LINEAR_UNIT(V)     parser.mm_to_linear_unit(V)
336
   #define LINEAR_UNIT(V)     parser.mm_to_linear_unit(V)
333
   #define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V)
337
   #define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V)
334
 
338
 

+ 27
- 8
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Прегледај датотеку

38
 #include "../../module/motion.h"
38
 #include "../../module/motion.h"
39
 #include "../../module/temperature.h"
39
 #include "../../module/temperature.h"
40
 
40
 
41
+#include "../../gcode/parser.h" // for units (and volumetric)
42
+
41
 #if ENABLED(FILAMENT_LCD_DISPLAY)
43
 #if ENABLED(FILAMENT_LCD_DISPLAY)
42
   #include "../../feature/filwidth.h"
44
   #include "../../feature/filwidth.h"
43
   #include "../../module/planner.h"
45
   #include "../../module/planner.h"
44
-  #include "../../gcode/parser.h"
45
 #endif
46
 #endif
46
 
47
 
47
 #if HAS_CUTTER
48
 #if HAS_CUTTER
67
 #define X_LABEL_POS      3
68
 #define X_LABEL_POS      3
68
 #define X_VALUE_POS     11
69
 #define X_VALUE_POS     11
69
 #define XYZ_SPACING     37
70
 #define XYZ_SPACING     37
71
+
72
+#define X_LABEL_POS_IN (X_LABEL_POS - 2)
73
+#define X_VALUE_POS_IN (X_VALUE_POS - 5)
74
+#define XYZ_SPACING_IN (XYZ_SPACING + 9)
75
+
70
 #define XYZ_BASELINE    (30 + INFO_FONT_ASCENT)
76
 #define XYZ_BASELINE    (30 + INFO_FONT_ASCENT)
71
 #define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
77
 #define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
72
 #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
78
 #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
370
 // Homed and known, display constantly.
376
 // Homed and known, display constantly.
371
 //
377
 //
372
 FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
378
 FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
379
+  const bool is_inch = parser.using_inch_units();
373
   const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
380
   const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
374
-  const uint8_t offs = (XYZ_SPACING) * a;
375
-  lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, axis_codes[axis]);
376
-  lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
381
+  const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING);
382
+  lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, axis_codes[axis]);
383
+  lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE);
384
+
377
   if (blink)
385
   if (blink)
378
     lcd_put_u8str(value);
386
     lcd_put_u8str(value);
379
   else {
387
   else {
390
   }
398
   }
391
 }
399
 }
392
 
400
 
401
+/**
402
+ * Draw the Status Screen for a 128x64 DOGM (U8glib) display.
403
+ *
404
+ * Called as needed to update the current display stripe.
405
+ * Use the PAGE_CONTAINS macros to avoid pointless draw calls.
406
+ */
393
 void MarlinUI::draw_status_screen() {
407
 void MarlinUI::draw_status_screen() {
408
+  constexpr int xystorage = TERN(INCH_MODE_SUPPORT, 8, 5);
409
+  static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, xystorage)], ystring[xystorage], zstring[8];
394
 
410
 
395
-  static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, 5)], ystring[5], zstring[8];
396
   #if ENABLED(FILAMENT_LCD_DISPLAY)
411
   #if ENABLED(FILAMENT_LCD_DISPLAY)
397
     static char wstring[5], mstring[4];
412
     static char wstring[5], mstring[4];
398
   #endif
413
   #endif
439
     #endif
454
     #endif
440
 
455
 
441
     const xyz_pos_t lpos = current_position.asLogical();
456
     const xyz_pos_t lpos = current_position.asLogical();
442
-    strcpy(zstring, ftostr52sp(lpos.z));
457
+    const bool is_inch = parser.using_inch_units();
458
+    strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z));
443
 
459
 
444
     if (show_e_total) {
460
     if (show_e_total) {
445
       #if ENABLED(LCD_SHOW_E_TOTAL)
461
       #if ENABLED(LCD_SHOW_E_TOTAL)
448
       #endif
464
       #endif
449
     }
465
     }
450
     else {
466
     else {
451
-      strcpy(xstring, ftostr4sign(lpos.x));
452
-      strcpy(ystring, ftostr4sign(lpos.y));
467
+      strcpy(xstring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.x)) : ftostr4sign(lpos.x));
468
+      strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y));
453
     }
469
     }
454
 
470
 
455
     #if ENABLED(FILAMENT_LCD_DISPLAY)
471
     #if ENABLED(FILAMENT_LCD_DISPLAY)
854
   }
870
   }
855
 }
871
 }
856
 
872
 
873
+/**
874
+ * Draw the Status Message area
875
+ */
857
 void MarlinUI::draw_status_message(const bool blink) {
876
 void MarlinUI::draw_status_message(const bool blink) {
858
 
877
 
859
   // Get the UTF8 character count of the string
878
   // Get the UTF8 character count of the string

+ 3
- 0
Marlin/src/lcd/language/language_en.h Прегледај датотеку

258
   PROGMEM Language_Str MSG_MOVE_01MM                       = _UxGT("Move 0.1mm");
258
   PROGMEM Language_Str MSG_MOVE_01MM                       = _UxGT("Move 0.1mm");
259
   PROGMEM Language_Str MSG_MOVE_1MM                        = _UxGT("Move 1mm");
259
   PROGMEM Language_Str MSG_MOVE_1MM                        = _UxGT("Move 1mm");
260
   PROGMEM Language_Str MSG_MOVE_10MM                       = _UxGT("Move 10mm");
260
   PROGMEM Language_Str MSG_MOVE_10MM                       = _UxGT("Move 10mm");
261
+  PROGMEM Language_Str MSG_MOVE_0001IN                     = _UxGT("Move 0.001in");
262
+  PROGMEM Language_Str MSG_MOVE_001IN                      = _UxGT("Move 0.01in");
263
+  PROGMEM Language_Str MSG_MOVE_01IN                       = _UxGT("Move 0.1in");
261
   PROGMEM Language_Str MSG_SPEED                           = _UxGT("Speed");
264
   PROGMEM Language_Str MSG_SPEED                           = _UxGT("Speed");
262
   PROGMEM Language_Str MSG_BED_Z                           = _UxGT("Bed Z");
265
   PROGMEM Language_Str MSG_BED_Z                           = _UxGT("Bed Z");
263
   PROGMEM Language_Str MSG_NOZZLE                          = _UxGT("Nozzle");
266
   PROGMEM Language_Str MSG_NOZZLE                          = _UxGT("Nozzle");

+ 34
- 21
Marlin/src/lcd/menu/menu_motion.cpp Прегледај датотеку

32
 #include "menu_addon.h"
32
 #include "menu_addon.h"
33
 
33
 
34
 #include "../../module/motion.h"
34
 #include "../../module/motion.h"
35
+#include "../../gcode/parser.h" // for inch support
35
 
36
 
36
 #if ENABLED(DELTA)
37
 #if ENABLED(DELTA)
37
   #include "../../module/delta.h"
38
   #include "../../module/delta.h"
95
       ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset),
96
       ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset),
96
       axis
97
       axis
97
     );
98
     );
98
-    MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr63(pos));
99
+    if (parser.using_inch_units()) {
100
+      const float imp_pos = LINEAR_UNIT(pos);
101
+      MenuEditItemBase::draw_edit_screen(name, ftostr63(imp_pos));
102
+    }
103
+    else
104
+      MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr63(pos));
99
   }
105
   }
100
 }
106
 }
101
 void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); }
107
 void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); }
165
   }
171
   }
166
 
172
 
167
   BACK_ITEM(MSG_MOVE_AXIS);
173
   BACK_ITEM(MSG_MOVE_AXIS);
168
-  SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10);    });
169
-  SUBMENU(MSG_MOVE_1MM,  []{ _goto_manual_move( 1);    });
170
-  SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); });
171
-  if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
172
-    // Determine digits needed right of decimal
173
-    constexpr uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
174
-                              !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) *  100 - int((SHORT_MANUAL_Z_MOVE) *  100)) ? 3 : 2;
175
-    PGM_P const label = GET_TEXT(MSG_MOVE_Z_DIST);
176
-    char tmp[strlen_P(label) + 10 + 1], numstr[10];
177
-    sprintf_P(tmp, label, dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
178
-
179
-    #if DISABLED(HAS_GRAPHICAL_TFT)
180
-      extern const char NUL_STR[];
181
-      SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
182
-      MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780));
183
-      lcd_put_u8str(tmp);
184
-      MENU_ITEM_ADDON_END();
185
-    #else
186
-      SUBMENU_P(tmp, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
187
-    #endif
174
+  if (parser.using_inch_units()) {
175
+    SUBMENU(MSG_MOVE_01IN,   []{ _goto_manual_move(IN_TO_MM(0.100f)); });
176
+    SUBMENU(MSG_MOVE_001IN,  []{ _goto_manual_move(IN_TO_MM(0.010f)); });
177
+    SUBMENU(MSG_MOVE_0001IN, []{ _goto_manual_move(IN_TO_MM(0.001f)); });
178
+  }
179
+  else {
180
+    SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10);    });
181
+    SUBMENU(MSG_MOVE_1MM,  []{ _goto_manual_move( 1);    });
182
+    SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); });
183
+    if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
184
+      // Determine digits needed right of decimal
185
+      constexpr uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
186
+                               !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) *  100 - int((SHORT_MANUAL_Z_MOVE) *  100)) ? 3 : 2;
187
+      PGM_P const label = GET_TEXT(MSG_MOVE_Z_DIST);
188
+      char tmp[strlen_P(label) + 10 + 1], numstr[10];
189
+      sprintf_P(tmp, label, dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
190
+
191
+      #if DISABLED(HAS_GRAPHICAL_TFT)
192
+        extern const char NUL_STR[];
193
+        SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
194
+        MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780));
195
+        lcd_put_u8str(tmp);
196
+        MENU_ITEM_ADDON_END();
197
+      #else
198
+        SUBMENU_P(tmp, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
199
+      #endif
200
+    }
188
   }
201
   }
189
   END_MENU();
202
   END_MENU();
190
 }
203
 }

Loading…
Откажи
Сачувај