diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e66f9c9f7bb6af17ac9f69e0a9a79598099f6a5a..e291db87f946ecac4f8b5970468bf9ff73dda98c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 680f49f580b3a56f815c2835b6b21bcc17a116c7..dabe5ead082f53a0613ffaa61af21e1cf6e2a1a9 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 2f848454f7cb361880aaf837e6be69b3a54c24c6..a954e43ae2111b874b8bb333c52792b4d95d7c5f 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 5294766e62135f45d6986202c4b2ee624720092d..940acf7669f121570fa5d48f61bc1bd78791ed94 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index d48952e1a9bda2b01d7e90c431e7d9d33aa1fa8e..52c3a872f85e81a1bcfe9fb9f071c79ab715e2c3 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index b6acbff1034ba19f899764064d412eea84992e31..554a6b02ba1895c24c41897ffe0172dabf9a5918 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -435,6 +435,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index 0df0c0d7d3d275afb0ec186cbded02527e51d3ad..69043cd68f42c5799edff490820fd446712ae7fa 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 45671c1431d4ae2c84aa065cea135fa566d78df7..a8fd1940da3e6fcb9ff8fa068555dc473965516f 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 5f4e0e2cf3a65b66d8a371fe5437bb1c22bb497d..97684b06cc7677c012768e17c748b607a9af1b93 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 7e60618641ebbb43a7e80e220ecd6b3901ac9306..e81b9e23711a77fe16aaf034227c9542465de92f 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -430,6 +430,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 5294766e62135f45d6986202c4b2ee624720092d..940acf7669f121570fa5d48f61bc1bd78791ed94 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h index cabcff9cfeb5d0bb9fdc5da824ab7a60a22c27cd..9e83512ee42bdf4b15cf642f394803dd9ca76f0f 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h @@ -424,6 +424,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 591e898320d3eb2b9852042fa019f29798eae843..ae111f4094242cc23d6055a2d94dcea7931e6b45 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -424,6 +424,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 591e898320d3eb2b9852042fa019f29798eae843..ae111f4094242cc23d6055a2d94dcea7931e6b45 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -424,6 +424,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index 0a3becc21f164d9006b43206058df7b7695a616c..aa4825980a59c041e05126bd783349c58f92dabd 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -429,6 +429,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index 318fe6eccc49788389b1f792b8e36b0f7e717163..909a5bc048618f6035a3d4dfb21ed9118db61105 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -424,6 +424,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 749d842bd73a805543839a0051f01a25f7b6e922..e68116b19fac67f298fc5eb1aa51f34537cc5d3f 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 0097c6db25f8e00ab08b8aa639c5d359b771e41e..27dccc0fecf96391829a40044eb207cf0f664427 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -422,6 +422,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// On the Info Screen, display XY with one decimal place when possible +//#define LCD_DECIMAL_SMALL_XY + #if ENABLED(SDSUPPORT) // Some RAMPS and other boards don't detect when an SD card is inserted. You can work diff --git a/Marlin/utility.cpp b/Marlin/utility.cpp index 31be8275ce886b9509d3016bd51b561835140269..8d638067b0f21975e0619b01bd636fb3c24db786 100644 --- a/Marlin/utility.cpp +++ b/Marlin/utility.cpp @@ -129,29 +129,22 @@ void safe_delay(millis_t ms) { return conv; } - // Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format - char *ftostr4sign(const float& fx) { - int x = fx * 10, xx = abs(x); - bool ispos = x >= 0, - isten = xx >= 100, - ishun = xx >= 1000; - if (!isten || (ispos && !ishun)) { - // 12.3, _1.2, -1.2 - conv[0] = ispos ? (isten ? DIGIMOD(xx, 100) : ' ') : '-'; + #if ENABLED(LCD_DECIMAL_SMALL_XY) + + // Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format + char *ftostr4sign(const float& fx) { + int x = fx * 10; + if (x <= -100 || x >= 1000) return itostr4sign((int)fx); + int xx = abs(x); + conv[0] = x < 0 ? '-' : (xx >= 100 ? DIGIMOD(xx, 100) : ' '); conv[1] = DIGIMOD(xx, 10); conv[2] = '.'; conv[3] = DIGIMOD(xx, 1); + conv[4] = '\0'; + return conv; } - else { - // 1234, _123, -123, _-12 - conv[0] = ispos ? (xx >= 10000 ? DIGIMOD(xx, 10000) : ' ') : (ishun ? '-' : ' '); - conv[1] = ishun ? DIGIMOD(xx, 1000) : '-'; - conv[2] = DIGIMOD(xx, 100); - conv[3] = DIGIMOD(xx, 10); - } - conv[4] = '\0'; - return conv; - } + + #endif // LCD_DECIMAL_SMALL_XY // Convert float to fixed-length string with +123.4 / -123.4 format char* ftostr41sign(const float& x) { diff --git a/Marlin/utility.h b/Marlin/utility.h index 4bdf18f344acf66864736afaf44a9dca0b092ffa..09d569debb6e3448bfb9624b4d2142ed94c355e9 100644 --- a/Marlin/utility.h +++ b/Marlin/utility.h @@ -69,8 +69,13 @@ void safe_delay(millis_t ms); // Convert float to rj string with 123 or -12 format FORCE_INLINE char *ftostr3(const float& x) { return itostr3((int)x); } - // Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format - char *ftostr4sign(const float& fx); + #if ENABLED(LCD_DECIMAL_SMALL_XY) + // Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format + char *ftostr4sign(const float& fx); + #else + // Convert float to rj string with 1234, _123, -123, __12, _-12, ___1, or __-1 format + FORCE_INLINE char *ftostr4sign(const float& x) { return itostr4sign((int)x); } + #endif #endif // ULTRA_LCD