|
|
@ -74,25 +74,32 @@ void safe_delay(millis_t ms) {
|
|
|
|
return str;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Convert signed int to rj string with _123, -123, _-12, or __-1 format
|
|
|
|
// Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
|
|
|
|
char *itostr4sign(const int& x) {
|
|
|
|
char *itostr4sign(const int& x) {
|
|
|
|
int xx = abs(x), sign = 0;
|
|
|
|
int xx = abs(x);
|
|
|
|
|
|
|
|
if (x >= 1000) {
|
|
|
|
|
|
|
|
conv[0] = DIGIMOD(xx, 1000);
|
|
|
|
|
|
|
|
conv[1] = DIGIMOD(xx, 100);
|
|
|
|
|
|
|
|
conv[2] = DIGIMOD(xx, 10);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
if (xx >= 100) {
|
|
|
|
if (xx >= 100) {
|
|
|
|
|
|
|
|
conv[0] = x < 0 ? '-' : ' ';
|
|
|
|
conv[1] = DIGIMOD(xx, 100);
|
|
|
|
conv[1] = DIGIMOD(xx, 100);
|
|
|
|
conv[2] = DIGIMOD(xx, 10);
|
|
|
|
conv[2] = DIGIMOD(xx, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
conv[0] = ' ';
|
|
|
|
conv[0] = ' ';
|
|
|
|
if (xx >= 10) {
|
|
|
|
if (xx >= 10) {
|
|
|
|
sign = 1;
|
|
|
|
conv[1] = x < 0 ? '-' : ' ';
|
|
|
|
conv[2] = DIGIMOD(xx, 10);
|
|
|
|
conv[2] = DIGIMOD(xx, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
conv[1] = ' ';
|
|
|
|
conv[1] = ' ';
|
|
|
|
sign = 2;
|
|
|
|
conv[2] = x < 0 ? '-' : ' ';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
conv[sign] = x < 0 ? '-' : ' ';
|
|
|
|
|
|
|
|
conv[3] = DIGIMOD(xx, 1);
|
|
|
|
conv[3] = DIGIMOD(xx, 1);
|
|
|
|
conv[4] = '\0';
|
|
|
|
conv[4] = '\0';
|
|
|
|
return conv;
|
|
|
|
return conv;
|
|
|
@ -122,6 +129,23 @@ void safe_delay(millis_t ms) {
|
|
|
|
return conv;
|
|
|
|
return conv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // LCD_DECIMAL_SMALL_XY
|
|
|
|
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
int xx = x * 10;
|
|
|
|
int xx = x * 10;
|
|
|
|