Ver código fonte

Use ftostr43 with '+' option in MBL Z adjuster

Scott Lahteine 8 anos atrás
pai
commit
782c598e66
2 arquivos alterados com 9 adições e 9 exclusões
  1. 8
    8
      Marlin/ultralcd.cpp
  2. 1
    1
      Marlin/ultralcd.h

+ 8
- 8
Marlin/ultralcd.cpp Ver arquivo

@@ -2223,13 +2223,13 @@ char *ftostr32(const float& x) {
2223 2223
   return conv;
2224 2224
 }
2225 2225
 
2226
-// Convert signed float to string (len 5 or 6) with 1.234 / -1.234 format
2227
-char* ftostr43(const float& x) {
2226
+// Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
2227
+char* ftostr43(const float& x, char plus/*=' '*/) {
2228 2228
   long xx = x * 1000;
2229
-  char *conv_ptr = conv;
2230
-  if (xx >= 0) {
2231
-    conv_ptr++;
2232
-  }
2229
+  if (xx == 0)
2230
+    conv[0] = ' ';
2231
+  else if (xx > 0)
2232
+    conv[0] = plus;
2233 2233
   else {
2234 2234
     xx = -xx;
2235 2235
     conv[0] = '-';
@@ -2240,7 +2240,7 @@ char* ftostr43(const float& x) {
2240 2240
   conv[4] = (xx / 10) % 10 + '0';
2241 2241
   conv[5] = (xx) % 10 + '0';
2242 2242
   conv[6] = 0;
2243
-  return conv_ptr;
2243
+  return conv;
2244 2244
 }
2245 2245
 
2246 2246
 // Convert unsigned float to string with 1.23 format
@@ -2453,7 +2453,7 @@ char* ftostr52(const float& x) {
2453 2453
     }
2454 2454
     if (lcdDrawUpdate) {
2455 2455
       float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
2456
-      lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001)));
2456
+      lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001), '+'));
2457 2457
     }
2458 2458
     static bool debounce_click = false;
2459 2459
     if (LCD_CLICKED) {

+ 1
- 1
Marlin/ultralcd.h Ver arquivo

@@ -156,7 +156,7 @@ char* ftostr4sign(const float& x);
156 156
 char* ftostr31ns(const float& x); // float to string without sign character
157 157
 char* ftostr31(const float& x);
158 158
 char* ftostr32(const float& x);
159
-char* ftostr43(const float& x);
159
+char* ftostr43(const float& x, char plus=' ');
160 160
 char* ftostr12ns(const float& x);
161 161
 char* ftostr32sp(const float& x); // remove zero-padding from ftostr32
162 162
 char* ftostr5(const float& x);

Carregando…
Cancelar
Salvar