Browse Source

More decimal places for babystep / Z probe offset (#17195)

Joe Prints 4 years ago
parent
commit
1f5824247f
No account linked to committer's email address

+ 2
- 2
Marlin/src/lcd/menu/menu.cpp View File

@@ -193,7 +193,7 @@ DEFINE_MENU_EDIT_ITEM(uint16_3);    // 123        right-justified
193 193
 DEFINE_MENU_EDIT_ITEM(uint16_4);    // 1234       right-justified
194 194
 DEFINE_MENU_EDIT_ITEM(uint16_5);    // 12345      right-justified
195 195
 DEFINE_MENU_EDIT_ITEM(float3);      // 123        right-justified
196
-DEFINE_MENU_EDIT_ITEM(float52);     // _2.34, 12.34, -2.34 or 123.45, -23.45
196
+DEFINE_MENU_EDIT_ITEM(float42_52);  // _2.34, 12.34, -2.34 or 123.45, -23.45
197 197
 DEFINE_MENU_EDIT_ITEM(float43);     // 1.234
198 198
 DEFINE_MENU_EDIT_ITEM(float5);      // 12345      right-justified
199 199
 DEFINE_MENU_EDIT_ITEM(float5_25);   // 12345      right-justified (25 increment)
@@ -428,7 +428,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
428 428
           MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z));
429 429
       #endif
430 430
       if (do_probe) {
431
-        MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), ftostr52sign(probe.offset.z));
431
+        MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), BABYSTEP_TO_STR(probe.offset.z));
432 432
         #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
433 433
           _lcd_zoffset_overlay_gfx(probe.offset.z);
434 434
         #endif

+ 13
- 9
Marlin/src/lcd/menu/menu.h View File

@@ -47,14 +47,18 @@ typedef void (*selectFunc_t)();
47 47
   void _lcd_zoffset_overlay_gfx(const float zvalue);
48 48
 #endif
49 49
 
50
-#if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
51
-  // Only values from -9.999 to 9.999
52
-  #define LCD_Z_OFFSET_FUNC(N) ftostr54sign(N)
53
-  #define LCD_Z_OFFSET_TYPE float43
54
-#else
55
-  // Values from -99.99 to 99.99
56
-  #define LCD_Z_OFFSET_FUNC(N) ftostr52sign(N)
57
-  #define LCD_Z_OFFSET_TYPE float52
50
+#if HAS_BED_PROBE
51
+  #if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
52
+    #define LCD_Z_OFFSET_TYPE float43    // Values from -9.000 to +9.000
53
+  #else
54
+    #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
55
+  #endif
56
+#endif
57
+
58
+#if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
59
+  #define BABYSTEP_TO_STR(N) ftostr43sign(N)
60
+#elif ENABLED(BABYSTEPPING)
61
+  #define BABYSTEP_TO_STR(N) ftostr53sign(N)
58 62
 #endif
59 63
 
60 64
 ////////////////////////////////////////////
@@ -289,7 +293,7 @@ DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3    ,uint16_t ,ui16tostr3rj    ,   1     );
289 293
 DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4    ,uint16_t ,ui16tostr4rj    ,   0.1f  );   // 1234       right-justified
290 294
 DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5    ,uint16_t ,ui16tostr5rj    ,   0.01f );   // 12345      right-justified
291 295
 DEFINE_MENU_EDIT_ITEM_TYPE(float3      ,float    ,ftostr3         ,   1     );   // 123        right-justified
292
-DEFINE_MENU_EDIT_ITEM_TYPE(float52     ,float    ,ftostr42_52     , 100     );   // _2.34, 12.34, -2.34 or 123.45, -23.45
296
+DEFINE_MENU_EDIT_ITEM_TYPE(float42_52  ,float    ,ftostr42_52     , 100     );   // _2.34, 12.34, -2.34 or 123.45, -23.45
293 297
 DEFINE_MENU_EDIT_ITEM_TYPE(float43     ,float    ,ftostr43sign    ,1000     );   // -1.234, _1.234, +1.234
294 298
 DEFINE_MENU_EDIT_ITEM_TYPE(float5      ,float    ,ftostr5rj       ,   1     );   // 12345      right-justified
295 299
 DEFINE_MENU_EDIT_ITEM_TYPE(float5_25   ,float    ,ftostr5rj       ,   0.04f );   // 12345      right-justified (25 increment)

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

@@ -112,10 +112,10 @@ void menu_cancelobject();
112 112
 
113 113
     #if ENABLED(LIN_ADVANCE)
114 114
       #if EXTRUDERS == 1
115
-        EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
115
+        EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
116 116
       #elif EXTRUDERS > 1
117 117
         LOOP_L_N(n, EXTRUDERS)
118
-          EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
118
+          EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
119 119
       #endif
120 120
     #endif
121 121
 
@@ -257,7 +257,7 @@ void menu_cancelobject();
257 257
       EDIT_ITEM(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
258 258
       EDIT_ITEM(float3, MSG_MIN, &planner.autotemp_min, 0, float(HEATER_0_MAXTEMP) - 15);
259 259
       EDIT_ITEM(float3, MSG_MAX, &planner.autotemp_max, 0, float(HEATER_0_MAXTEMP) - 15);
260
-      EDIT_ITEM(float52, MSG_FACTOR, &planner.autotemp_factor, 0, 10);
260
+      EDIT_ITEM(float42_52, MSG_FACTOR, &planner.autotemp_factor, 0, 10);
261 261
     #endif
262 262
 
263 263
     //
@@ -556,10 +556,10 @@ void menu_advanced_settings() {
556 556
     SUBMENU(MSG_FILAMENT, menu_advanced_filament);
557 557
   #elif ENABLED(LIN_ADVANCE)
558 558
     #if EXTRUDERS == 1
559
-      EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
559
+      EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
560 560
     #elif EXTRUDERS > 1
561 561
       LOOP_L_N(n, E_STEPPERS)
562
-        EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
562
+        EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
563 563
     #endif
564 564
   #endif
565 565
 

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

@@ -138,12 +138,12 @@ void menu_advanced_settings();
138 138
     START_MENU();
139 139
     BACK_ITEM(MSG_CONFIGURATION);
140 140
     #if ENABLED(DUAL_X_CARRIAGE)
141
-      EDIT_ITEM_FAST(float52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets);
141
+      EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets);
142 142
     #else
143
-      EDIT_ITEM_FAST(float52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets);
143
+      EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets);
144 144
     #endif
145
-    EDIT_ITEM_FAST(float52,   MSG_HOTEND_OFFSET_Y, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
146
-    EDIT_ITEM_FAST(float52,   MSG_HOTEND_OFFSET_Z, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
145
+    EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Y, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
146
+    EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Z, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
147 147
     #if ENABLED(EEPROM_SETTINGS)
148 148
       ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
149 149
     #endif

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

@@ -182,7 +182,7 @@ void lcd_mixer_mix_edit() {
182 182
     #if CHANNEL_MIX_EDITING
183 183
 
184 184
       LOOP_S_LE_N(n, 1, MIXING_STEPPERS)
185
-        EDIT_ITEM_FAST_N(float52, n, MSG_MIX_COMPONENT_N, &mixer.collector[n-1], 0, 10);
185
+        EDIT_ITEM_FAST_N(float42_52, n, MSG_MIX_COMPONENT_N, &mixer.collector[n-1], 0, 10);
186 186
 
187 187
       ACTION_ITEM(MSG_CYCLE_MIX, _lcd_mixer_cycle_mix);
188 188
       ACTION_ITEM(MSG_COMMIT_VTOOL, _lcd_mixer_commit_vtool);

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

@@ -65,7 +65,7 @@
65 65
     }
66 66
     if (ui.should_draw()) {
67 67
       const float spm = planner.steps_to_mm[axis];
68
-      MenuEditItemBase::draw_edit_screen(msg, LCD_Z_OFFSET_FUNC(spm * babystep.accum));
68
+      MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(spm * babystep.accum));
69 69
       #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
70 70
         const bool in_view = (true
71 71
           #if HAS_GRAPHICAL_LCD
@@ -81,7 +81,7 @@
81 81
           #endif
82 82
           lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
83 83
           lcd_put_wchar(':');
84
-          lcd_put_u8str(LCD_Z_OFFSET_FUNC(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
84
+          lcd_put_u8str(BABYSTEP_TO_STR(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
85 85
         }
86 86
       #endif
87 87
     }
@@ -232,10 +232,10 @@ void menu_tune() {
232 232
   //
233 233
   #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS)
234 234
     #if EXTRUDERS == 1
235
-      EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
235
+      EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
236 236
     #elif EXTRUDERS > 1
237 237
       LOOP_L_N(n, EXTRUDERS)
238
-        EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
238
+        EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
239 239
     #endif
240 240
   #endif
241 241
 

+ 19
- 6
Marlin/src/libs/numtostr.cpp View File

@@ -174,9 +174,9 @@ const char* ftostr12ns(const float &f) {
174 174
   return &conv[3];
175 175
 }
176 176
 
177
-// Convert signed float to fixed-length string with 12.34 / -2.34 or 023.45 / -23.45 format
177
+// Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format
178 178
 const char* ftostr42_52(const float &f) {
179
-  if (f <= -10 || f >= 100) return ftostr52(f); // need more digits
179
+  if (f <= -10 || f >= 100) return ftostr52(f); // -23.45 / 123.45
180 180
   long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;
181 181
   conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000));
182 182
   conv[3] = DIGIMOD(i, 100);
@@ -198,9 +198,9 @@ const char* ftostr52(const float &f) {
198 198
   return &conv[1];
199 199
 }
200 200
 
201
-// Convert signed float to fixed-length string with 12.345 / -2.345 or 023.456 / -23.456 format
202
-const char* ftostr43_53(const float &f) {
203
-  if (f <= -10 || f >= 100) return ftostr53(f); // need more digits
201
+// Convert signed float to fixed-length string with 12.345 / _2.345 / -2.345 or -23.45 / 123.45 format
202
+const char* ftostr53_63(const float &f) {
203
+  if (f <= -10 || f >= 100) return ftostr63(f); // -23.456 / 123.456
204 204
   long i = (f * 10000 + (f < 0 ? -5: 5)) / 10;
205 205
   conv[1] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 10000));
206 206
   conv[2] = DIGIMOD(i, 1000);
@@ -212,7 +212,7 @@ const char* ftostr43_53(const float &f) {
212 212
 }
213 213
 
214 214
 // Convert signed float to fixed-length string with 023.456 / -23.456 format
215
-const char* ftostr53(const float &f) {
215
+const char* ftostr63(const float &f) {
216 216
   long i = (f * 10000 + (f < 0 ? -5: 5)) / 10;
217 217
   conv[0] = MINUSOR(i, DIGIMOD(i, 100000));
218 218
   conv[1] = DIGIMOD(i, 10000);
@@ -310,6 +310,19 @@ const char* ftostr52sign(const float &f) {
310 310
   return conv;
311 311
 }
312 312
 
313
+// Convert signed float to string with +12.345 format
314
+const char* ftostr53sign(const float &f) {
315
+  long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;
316
+  conv[0] = MINUSOR(i, '+');
317
+  conv[1] = DIGIMOD(i, 10000);
318
+  conv[2] = DIGIMOD(i, 1000);
319
+  conv[3] = '.';
320
+  conv[4] = DIGIMOD(i, 100);
321
+  conv[5] = DIGIMOD(i, 10);
322
+  conv[6] = DIGIMOD(i, 1);
323
+  return conv;
324
+}
325
+
313 326
 // Convert unsigned float to string with ____4.5, __34.5, _234.5, 1234.5 format
314 327
 const char* ftostr51rj(const float &f) {
315 328
   const long i = ((f < 0 ? -f : f) * 100 + 5) / 10;

+ 6
- 3
Marlin/src/libs/numtostr.h View File

@@ -58,17 +58,17 @@ const char* i16tostr4signrj(const int16_t x);
58 58
 // Convert unsigned float to string with 1.23 format
59 59
 const char* ftostr12ns(const float &x);
60 60
 
61
-// Convert signed float to fixed-length string with 12.34 / -2.34 or 023.45 / -23.45 format
61
+// Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format
62 62
 const char* ftostr42_52(const float &x);
63 63
 
64 64
 // Convert signed float to fixed-length string with 023.45 / -23.45 format
65 65
 const char* ftostr52(const float &x);
66 66
 
67 67
 // Convert signed float to fixed-length string with 12.345 / -2.345 or 023.456 / -23.456 format
68
-const char* ftostr43_53(const float &x);
68
+const char* ftostr53_63(const float &x);
69 69
 
70 70
 // Convert signed float to fixed-length string with 023.456 / -23.456 format
71
-const char* ftostr53(const float &x);
71
+const char* ftostr63(const float &x);
72 72
 
73 73
 // Convert float to fixed-length string with +123.4 / -123.4 format
74 74
 const char* ftostr41sign(const float &x);
@@ -91,6 +91,9 @@ const char* ftostr52sp(const float &x);
91 91
 // Convert signed float to string with +123.45 format
92 92
 const char* ftostr52sign(const float &x);
93 93
 
94
+// Convert signed float to string with +12.345 format
95
+const char* ftostr53sign(const float &f);
96
+
94 97
 // Convert unsigned float to string with 1234.5 format omitting trailing zeros
95 98
 const char* ftostr51rj(const float &x);
96 99
 

Loading…
Cancel
Save