Bladeren bron

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 jaren geleden
bovenliggende
commit
bdf2c94bff
1 gewijzigde bestanden met toevoegingen van 1 en 15 verwijderingen
  1. 1
    15
      Marlin/ultralcd.cpp

+ 1
- 15
Marlin/ultralcd.cpp Bestand weergeven

@@ -1445,7 +1445,6 @@ char *ftostr12ns(const float &x)
1445 1445
 
1446 1446
 //  convert float to space-padded string with -_23.4_ format
1447 1447
 char *ftostr32np(const float &x) {
1448
-<<<<<<< HEAD
1449 1448
   long xx = abs(x * 100);
1450 1449
   uint8_t dig;
1451 1450
 
@@ -1472,8 +1471,7 @@ char *ftostr32np(const float &x) {
1472 1471
   dig = xx % 10;
1473 1472
   if (dig) { // 2 decimal places
1474 1473
     conv[5] = '0' + dig;
1475
-    dig = (xx / 10) % 10;
1476
-    conv[4] = '0' + dig;
1474
+    conv[4] = '0' + (xx / 10) % 10;
1477 1475
     conv[3] = '.';
1478 1476
   }
1479 1477
   else { // 1 or 0 decimal place
@@ -1489,18 +1487,6 @@ char *ftostr32np(const float &x) {
1489 1487
   }
1490 1488
   conv[6] = '\0';
1491 1489
   return conv;
1492
-=======
1493
-  char *c = ftostr32(x);
1494
-  if (c[0] == '0' || c[0] == '-') {
1495
-    if (c[0] == '0') c[0] = ' ';
1496
-    if (c[1] == '0') c[1] = ' ';
1497
-  }
1498
-  if (c[5] == '0') {
1499
-    c[5] = ' ';
1500
-    if (c[4] == '0') c[4] = c[3] = ' ';
1501
-  }
1502
-  return c;
1503
->>>>>>> Patch to make Z look more like X and Y on UltraLCD
1504 1490
 }
1505 1491
 
1506 1492
 char *itostr31(const int &xx)

Laden…
Annuleren
Opslaan