ソースを参照

Merge pull request #5385 from thinkyhead/rc_ftostr4sign_decimal

Show decimal for small numbers in ftostr4sign
Scott Lahteine 8年前
コミット
20e834461d

+ 3
- 0
Marlin/Configuration_adv.h ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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

+ 33
- 9
Marlin/utility.cpp ファイルの表示

@@ -74,25 +74,32 @@ void safe_delay(millis_t ms) {
74 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 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 82
       conv[1] = DIGIMOD(xx, 100);
82 83
       conv[2] = DIGIMOD(xx, 10);
83 84
     }
84 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 89
         conv[2] = DIGIMOD(xx, 10);
89 90
       }
90 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 103
     conv[3] = DIGIMOD(xx, 1);
97 104
     conv[4] = '\0';
98 105
     return conv;
@@ -122,6 +129,23 @@ void safe_delay(millis_t ms) {
122 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 149
   // Convert float to fixed-length string with +123.4 / -123.4 format
126 150
   char* ftostr41sign(const float& x) {
127 151
     int xx = x * 10;

+ 7
- 2
Marlin/utility.h ファイルの表示

@@ -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 _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 80
 #endif // ULTRA_LCD
76 81
 

読み込み中…
キャンセル
保存