Change XY formatting on LCD (PR#2740)

According to #123 negative values for XY at or below -100 are displaying incorrectly, dropping the first digit. Deltas can easily have XY values in this range. This PR adds a function to display floats/ints formatted like `_123`, `-123`, `_-12`, or `__-1` as appropriate and applies it to the XY coordinates on Hitachi displays. It also moves the Z value to the right to be consistent with the XY formatting.
This commit is contained in:
AnHardt
2015-11-03 12:06:05 +01:00
committed by Richard Wackerbarth
parent 9acdc6c234
commit be7167ed97
3 changed files with 42 additions and 15 deletions

View File

@ -1882,10 +1882,11 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
char conv[8];
// Convert float to string with +123.4 format
char* ftostr3(const float& x) {
return itostr3((int)x);
}
// Convert float to rj string with 123 or -12 format
char *ftostr3(const float& x) { return itostr3((int)x); }
// Convert float to rj string with _123, -123, _-12, or __-1 format
char *ftostr4sign(const float& x) { return itostr4sign((int)x); }
// Convert int to string with 12 format
char* itostr2(const uint8_t& x) {
@ -1922,8 +1923,8 @@ char* ftostr31ns(const float& x) {
return conv;
}
// Convert float to string with 123.4 format
char* ftostr32(const float& x) {
// Convert float to string with 123.45 format
char *ftostr32(const float& x) {
long xx = abs(x * 100);
conv[0] = x >= 0 ? (xx / 10000) % 10 + '0' : '-';
conv[1] = (xx / 1000) % 10 + '0';
@ -2067,6 +2068,30 @@ char* itostr4(const int& xx) {
return conv;
}
// Convert int to rj string with _123, -123, _-12, or __-1 format
char *itostr4sign(const int& x) {
int xx = abs(x);
int sign = 0;
if (xx >= 100) {
conv[1] = (xx / 100) % 10 + '0';
conv[2] = (xx / 10) % 10 + '0';
}
else if (xx >= 10) {
conv[0] = ' ';
sign = 1;
conv[2] = (xx / 10) % 10 + '0';
}
else {
conv[0] = ' ';
conv[1] = ' ';
sign = 2;
}
conv[sign] = x < 0 ? '-' : ' ';
conv[3] = xx % 10 + '0';
conv[4] = 0;
return conv;
}
// Convert float to rj string with 12345 format
char* ftostr5(const float& x) {
long xx = abs(x);