Browse Source

Implement as optional feature LCD_DECIMAL_SMALL_XY

And reduce the function size to simplify
Scott Lahteine 7 years ago
parent
commit
d5bf1684fe

+ 3
- 0
Marlin/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -435,6 +435,9 @@
435 435
 // Include a page of printer information in the LCD Main Menu
436 436
 //#define LCD_INFO_MENU
437 437
 
438
+// On the Info Screen, display XY with one decimal place when possible
439
+//#define LCD_DECIMAL_SMALL_XY
440
+
438 441
 #if ENABLED(SDSUPPORT)
439 442
 
440 443
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -430,6 +430,9 @@
430 430
 // Include a page of printer information in the LCD Main Menu
431 431
 //#define LCD_INFO_MENU
432 432
 
433
+// On the Info Screen, display XY with one decimal place when possible
434
+//#define LCD_DECIMAL_SMALL_XY
435
+
433 436
 #if ENABLED(SDSUPPORT)
434 437
 
435 438
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

@@ -424,6 +424,9 @@
424 424
 // Include a page of printer information in the LCD Main Menu
425 425
 //#define LCD_INFO_MENU
426 426
 
427
+// On the Info Screen, display XY with one decimal place when possible
428
+//#define LCD_DECIMAL_SMALL_XY
429
+
427 430
 #if ENABLED(SDSUPPORT)
428 431
 
429 432
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -424,6 +424,9 @@
424 424
 // Include a page of printer information in the LCD Main Menu
425 425
 //#define LCD_INFO_MENU
426 426
 
427
+// On the Info Screen, display XY with one decimal place when possible
428
+//#define LCD_DECIMAL_SMALL_XY
429
+
427 430
 #if ENABLED(SDSUPPORT)
428 431
 
429 432
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -424,6 +424,9 @@
424 424
 // Include a page of printer information in the LCD Main Menu
425 425
 //#define LCD_INFO_MENU
426 426
 
427
+// On the Info Screen, display XY with one decimal place when possible
428
+//#define LCD_DECIMAL_SMALL_XY
429
+
427 430
 #if ENABLED(SDSUPPORT)
428 431
 
429 432
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -429,6 +429,9 @@
429 429
 // Include a page of printer information in the LCD Main Menu
430 430
 //#define LCD_INFO_MENU
431 431
 
432
+// On the Info Screen, display XY with one decimal place when possible
433
+//#define LCD_DECIMAL_SMALL_XY
434
+
432 435
 #if ENABLED(SDSUPPORT)
433 436
 
434 437
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -424,6 +424,9 @@
424 424
 // Include a page of printer information in the LCD Main Menu
425 425
 //#define LCD_INFO_MENU
426 426
 
427
+// On the Info Screen, display XY with one decimal place when possible
428
+//#define LCD_DECIMAL_SMALL_XY
429
+
427 430
 #if ENABLED(SDSUPPORT)
428 431
 
429 432
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 3
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -422,6 +422,9 @@
422 422
 // Include a page of printer information in the LCD Main Menu
423 423
 //#define LCD_INFO_MENU
424 424
 
425
+// On the Info Screen, display XY with one decimal place when possible
426
+//#define LCD_DECIMAL_SMALL_XY
427
+
425 428
 #if ENABLED(SDSUPPORT)
426 429
 
427 430
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work

+ 12
- 19
Marlin/utility.cpp View File

@@ -129,29 +129,22 @@ void safe_delay(millis_t ms) {
129 129
     return conv;
130 130
   }
131 131
 
132
-  // Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format
133
-  char *ftostr4sign(const float& fx) { 
134
-    int x = fx * 10, xx = abs(x);
135
-    bool ispos = x >= 0,
136
-         isten = xx >= 100,
137
-         ishun = xx >= 1000;
138
-    if (!isten || (ispos && !ishun)) {
139
-      // 12.3, _1.2, -1.2
140
-      conv[0] = ispos ? (isten ? DIGIMOD(xx, 100) : ' ') : '-';
132
+  #if ENABLED(LCD_DECIMAL_SMALL_XY)
133
+
134
+    // Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format
135
+    char *ftostr4sign(const float& fx) {
136
+      int x = fx * 10;
137
+      if (x <= -100 || x >= 1000) return itostr4sign((int)fx);
138
+      int xx = abs(x);
139
+      conv[0] = x < 0 ? '-' : (xx >= 100 ? DIGIMOD(xx, 100) : ' ');
141 140
       conv[1] = DIGIMOD(xx, 10);
142 141
       conv[2] = '.';
143 142
       conv[3] = DIGIMOD(xx, 1);
143
+      conv[4] = '\0';
144
+      return conv;
144 145
     }
145
-    else {
146
-      // 1234, _123, -123, _-12
147
-      conv[0] = ispos ? (xx >= 10000 ? DIGIMOD(xx, 10000) : ' ') : (ishun ? '-' : ' ');
148
-      conv[1] = ishun ? DIGIMOD(xx, 1000) : '-';
149
-      conv[2] = DIGIMOD(xx, 100);
150
-      conv[3] = DIGIMOD(xx, 10);
151
-    }
152
-    conv[4] = '\0';
153
-    return conv;
154
-  }
146
+
147
+  #endif // LCD_DECIMAL_SMALL_XY
155 148
 
156 149
   // Convert float to fixed-length string with +123.4 / -123.4 format
157 150
   char* ftostr41sign(const float& x) {

+ 7
- 2
Marlin/utility.h View File

@@ -69,8 +69,13 @@ void safe_delay(millis_t ms);
69 69
   // Convert float to rj string with 123 or -12 format
70 70
   FORCE_INLINE char *ftostr3(const float& x) { return itostr3((int)x); }
71 71
 
72
-  // Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format
73
-  char *ftostr4sign(const float& fx);
72
+  #if ENABLED(LCD_DECIMAL_SMALL_XY)
73
+    // Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format
74
+    char *ftostr4sign(const float& fx);
75
+  #else
76
+    // Convert float to rj string with 1234, _123, -123, __12, _-12, ___1, or __-1 format
77
+    FORCE_INLINE char *ftostr4sign(const float& x) { return itostr4sign((int)x); }
78
+  #endif
74 79
 
75 80
 #endif // ULTRA_LCD
76 81
 

Loading…
Cancel
Save