Browse Source

Merge pull request #5385 from thinkyhead/rc_ftostr4sign_decimal

Show decimal for small numbers in ftostr4sign
Scott Lahteine 8 years ago
parent
commit
20e834461d

+ 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

+ 33
- 9
Marlin/utility.cpp View File

74
     return str;
74
     return str;
75
   }
75
   }
76
 
76
 
77
-  // Convert signed int to rj string with _123, -123, _-12, or __-1 format
77
+  // Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
78
   char *itostr4sign(const int& x) {
78
   char *itostr4sign(const int& x) {
79
-    int xx = abs(x), sign = 0;
80
-    if (xx >= 100) {
79
+    int xx = abs(x);
80
+    if (x >= 1000) {
81
+      conv[0] = DIGIMOD(xx, 1000);
81
       conv[1] = DIGIMOD(xx, 100);
82
       conv[1] = DIGIMOD(xx, 100);
82
       conv[2] = DIGIMOD(xx, 10);
83
       conv[2] = DIGIMOD(xx, 10);
83
     }
84
     }
84
     else {
85
     else {
85
-      conv[0] = ' ';
86
-      if (xx >= 10) {
87
-        sign = 1;
86
+      if (xx >= 100) {
87
+        conv[0] = x < 0 ? '-' : ' ';
88
+        conv[1] = DIGIMOD(xx, 100);
88
         conv[2] = DIGIMOD(xx, 10);
89
         conv[2] = DIGIMOD(xx, 10);
89
       }
90
       }
90
       else {
91
       else {
91
-        conv[1] = ' ';
92
-        sign = 2;
92
+        conv[0] = ' ';
93
+        if (xx >= 10) {
94
+          conv[1] = x < 0 ? '-' : ' ';
95
+          conv[2] = DIGIMOD(xx, 10);
96
+        }
97
+        else {
98
+          conv[1] = ' ';
99
+          conv[2] = x < 0 ? '-' : ' ';
100
+        }
93
       }
101
       }
94
     }
102
     }
95
-    conv[sign] = x < 0 ? '-' : ' ';
96
     conv[3] = DIGIMOD(xx, 1);
103
     conv[3] = DIGIMOD(xx, 1);
97
     conv[4] = '\0';
104
     conv[4] = '\0';
98
     return conv;
105
     return conv;
122
     return conv;
129
     return conv;
123
   }
130
   }
124
 
131
 
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) : ' ');
140
+      conv[1] = DIGIMOD(xx, 10);
141
+      conv[2] = '.';
142
+      conv[3] = DIGIMOD(xx, 1);
143
+      conv[4] = '\0';
144
+      return conv;
145
+    }
146
+
147
+  #endif // LCD_DECIMAL_SMALL_XY
148
+
125
   // 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
126
   char* ftostr41sign(const float& x) {
150
   char* ftostr41sign(const float& x) {
127
     int xx = x * 10;
151
     int xx = x * 10;

+ 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 _123, -123, _-12, or __-1 format
73
-  FORCE_INLINE char *ftostr4sign(const float& x) { return itostr4sign((int)x); }
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