Browse Source

Implement as optional feature LCD_DECIMAL_SMALL_XY

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

+ 3
- 0
Marlin/Configuration_adv.h View File

422
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
435
 // Include a page of printer information in the LCD Main Menu
436
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
441
 #if ENABLED(SDSUPPORT)
439
 
442
 
440
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
430
 // Include a page of printer information in the LCD Main Menu
431
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
436
 #if ENABLED(SDSUPPORT)
434
 
437
 
435
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
424
 // Include a page of printer information in the LCD Main Menu
425
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
430
 #if ENABLED(SDSUPPORT)
428
 
431
 
429
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
424
 // Include a page of printer information in the LCD Main Menu
425
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
430
 #if ENABLED(SDSUPPORT)
428
 
431
 
429
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
424
 // Include a page of printer information in the LCD Main Menu
425
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
430
 #if ENABLED(SDSUPPORT)
428
 
431
 
429
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
429
 // Include a page of printer information in the LCD Main Menu
430
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
435
 #if ENABLED(SDSUPPORT)
433
 
436
 
434
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
424
 // Include a page of printer information in the LCD Main Menu
425
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
430
 #if ENABLED(SDSUPPORT)
428
 
431
 
429
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
 // Include a page of printer information in the LCD Main Menu
422
 // Include a page of printer information in the LCD Main Menu
423
 //#define LCD_INFO_MENU
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
 #if ENABLED(SDSUPPORT)
428
 #if ENABLED(SDSUPPORT)
426
 
429
 
427
   // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
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
     return conv;
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
       conv[1] = DIGIMOD(xx, 10);
140
       conv[1] = DIGIMOD(xx, 10);
142
       conv[2] = '.';
141
       conv[2] = '.';
143
       conv[3] = DIGIMOD(xx, 1);
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
   // Convert float to fixed-length string with +123.4 / -123.4 format
149
   // Convert float to fixed-length string with +123.4 / -123.4 format
157
   char* ftostr41sign(const float& x) {
150
   char* ftostr41sign(const float& x) {

+ 7
- 2
Marlin/utility.h View File

69
   // Convert float to rj string with 123 or -12 format
69
   // Convert float to rj string with 123 or -12 format
70
   FORCE_INLINE char *ftostr3(const float& x) { return itostr3((int)x); }
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
 #endif // ULTRA_LCD
80
 #endif // ULTRA_LCD
76
 
81
 

Loading…
Cancel
Save