Przeglądaj źródła

Least stack-usage self-contained ftostr32np()

This is the optimal code for a self-contained formatter, although the
original code is crafty in being smaller and simpler, and can be
evaluated as using the original output as a scratch pad for state,
making the final formatter more straightforward. While this code is
longer, all code-paths are minimal.
Scott Lahteine 10 lat temu
rodzic
commit
10e1b6ef8b
1 zmienionych plików z 1 dodań i 15 usunięć
  1. 1
    15
      Marlin/ultralcd.cpp

+ 1
- 15
Marlin/ultralcd.cpp Wyświetl plik

@@ -1498,7 +1498,6 @@ char *ftostr12ns(const float &x)
1498 1498
 
1499 1499
 //  convert float to space-padded string with -_23.4_ format
1500 1500
 char *ftostr32np(const float &x) {
1501
-<<<<<<< HEAD
1502 1501
   long xx = abs(x * 100);
1503 1502
   uint8_t dig;
1504 1503
 
@@ -1525,8 +1524,7 @@ char *ftostr32np(const float &x) {
1525 1524
   dig = xx % 10;
1526 1525
   if (dig) { // 2 decimal places
1527 1526
     conv[5] = '0' + dig;
1528
-    dig = (xx / 10) % 10;
1529
-    conv[4] = '0' + dig;
1527
+    conv[4] = '0' + (xx / 10) % 10;
1530 1528
     conv[3] = '.';
1531 1529
   }
1532 1530
   else { // 1 or 0 decimal place
@@ -1542,18 +1540,6 @@ char *ftostr32np(const float &x) {
1542 1540
   }
1543 1541
   conv[6] = '\0';
1544 1542
   return conv;
1545
-=======
1546
-  char *c = ftostr32(x);
1547
-  if (c[0] == '0' || c[0] == '-') {
1548
-    if (c[0] == '0') c[0] = ' ';
1549
-    if (c[1] == '0') c[1] = ' ';
1550
-  }
1551
-  if (c[5] == '0') {
1552
-    c[5] = ' ';
1553
-    if (c[4] == '0') c[4] = c[3] = ' ';
1554
-  }
1555
-  return c;
1556
->>>>>>> Patch to make Z look more like X and Y on UltraLCD
1557 1543
 }
1558 1544
 
1559 1545
 char *itostr31(const int &xx)

Ładowanie…
Anuluj
Zapisz