Use ftostr43 with '+' option in MBL Z adjuster

2.0.x
Scott Lahteine 9 years ago
parent f08b0d034f
commit 782c598e66

@ -2223,13 +2223,13 @@ char *ftostr32(const float& x) {
return conv; return conv;
} }
// Convert signed float to string (len 5 or 6) with 1.234 / -1.234 format // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
char* ftostr43(const float& x) { char* ftostr43(const float& x, char plus/*=' '*/) {
long xx = x * 1000; long xx = x * 1000;
char *conv_ptr = conv; if (xx == 0)
if (xx >= 0) { conv[0] = ' ';
conv_ptr++; else if (xx > 0)
} conv[0] = plus;
else { else {
xx = -xx; xx = -xx;
conv[0] = '-'; conv[0] = '-';
@ -2240,7 +2240,7 @@ char* ftostr43(const float& x) {
conv[4] = (xx / 10) % 10 + '0'; conv[4] = (xx / 10) % 10 + '0';
conv[5] = (xx) % 10 + '0'; conv[5] = (xx) % 10 + '0';
conv[6] = 0; conv[6] = 0;
return conv_ptr; return conv;
} }
// Convert unsigned float to string with 1.23 format // Convert unsigned float to string with 1.23 format
@ -2453,7 +2453,7 @@ char* ftostr52(const float& x) {
} }
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z; float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001))); lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43(v + (v < 0 ? -0.0001 : 0.0001), '+'));
} }
static bool debounce_click = false; static bool debounce_click = false;
if (LCD_CLICKED) { if (LCD_CLICKED) {

@ -156,7 +156,7 @@ char* ftostr4sign(const float& x);
char* ftostr31ns(const float& x); // float to string without sign character char* ftostr31ns(const float& x); // float to string without sign character
char* ftostr31(const float& x); char* ftostr31(const float& x);
char* ftostr32(const float& x); char* ftostr32(const float& x);
char* ftostr43(const float& x); char* ftostr43(const float& x, char plus=' ');
char* ftostr12ns(const float& x); char* ftostr12ns(const float& x);
char* ftostr32sp(const float& x); // remove zero-padding from ftostr32 char* ftostr32sp(const float& x); // remove zero-padding from ftostr32
char* ftostr5(const float& x); char* ftostr5(const float& x);

Loading…
Cancel
Save