Implement as optional feature LCD_DECIMAL_SMALL_XY
And reduce the function size to simplify
This commit is contained in:
parent
bfb8d3b53e
commit
d5bf1684fe
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -435,6 +435,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -430,6 +430,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -424,6 +424,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -424,6 +424,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -424,6 +424,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -429,6 +429,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -424,6 +424,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -422,6 +422,9 @@
|
|||||||
// Include a page of printer information in the LCD Main Menu
|
// Include a page of printer information in the LCD Main Menu
|
||||||
//#define LCD_INFO_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)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work
|
||||||
|
@ -129,29 +129,22 @@ void safe_delay(millis_t ms) {
|
|||||||
return conv;
|
return conv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format
|
#if ENABLED(LCD_DECIMAL_SMALL_XY)
|
||||||
char *ftostr4sign(const float& fx) {
|
|
||||||
int x = fx * 10, xx = abs(x);
|
// Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format
|
||||||
bool ispos = x >= 0,
|
char *ftostr4sign(const float& fx) {
|
||||||
isten = xx >= 100,
|
int x = fx * 10;
|
||||||
ishun = xx >= 1000;
|
if (x <= -100 || x >= 1000) return itostr4sign((int)fx);
|
||||||
if (!isten || (ispos && !ishun)) {
|
int xx = abs(x);
|
||||||
// 12.3, _1.2, -1.2
|
conv[0] = x < 0 ? '-' : (xx >= 100 ? DIGIMOD(xx, 100) : ' ');
|
||||||
conv[0] = ispos ? (isten ? DIGIMOD(xx, 100) : ' ') : '-';
|
|
||||||
conv[1] = DIGIMOD(xx, 10);
|
conv[1] = DIGIMOD(xx, 10);
|
||||||
conv[2] = '.';
|
conv[2] = '.';
|
||||||
conv[3] = DIGIMOD(xx, 1);
|
conv[3] = DIGIMOD(xx, 1);
|
||||||
|
conv[4] = '\0';
|
||||||
|
return conv;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// 1234, _123, -123, _-12
|
#endif // LCD_DECIMAL_SMALL_XY
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert float to fixed-length string with +123.4 / -123.4 format
|
// Convert float to fixed-length string with +123.4 / -123.4 format
|
||||||
char* ftostr41sign(const float& x) {
|
char* ftostr41sign(const float& x) {
|
||||||
|
@ -69,8 +69,13 @@ void safe_delay(millis_t ms);
|
|||||||
// Convert float to rj string with 123 or -12 format
|
// Convert float to rj string with 123 or -12 format
|
||||||
FORCE_INLINE char *ftostr3(const float& x) { return itostr3((int)x); }
|
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
|
#if ENABLED(LCD_DECIMAL_SMALL_XY)
|
||||||
char *ftostr4sign(const float& fx);
|
// 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
|
#endif // ULTRA_LCD
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user