Improve editing, fix some small value editing

This commit is contained in:
Scott Lahteine
2019-05-25 15:24:26 -05:00
parent 612eaa87bd
commit 44caf70917
4 changed files with 18 additions and 3 deletions

View File

@ -161,6 +161,18 @@ void safe_delay(millis_t ms) {
return &conv[3];
}
// Convert signed float to fixed-length string with 12.34 / -2.34 format or 123.45 / -23.45 format
char* ftostr42_52(const float &f) {
if (f <= -10 || f >= 100) return ftostr52(f); // need more digits
long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;
conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000));
conv[3] = DIGIMOD(i, 100);
conv[4] = '.';
conv[5] = DIGIMOD(i, 10);
conv[6] = DIGIMOD(i, 1);
return &conv[2];
}
// Convert signed float to fixed-length string with 023.45 / -23.45 format
char* ftostr52(const float &f) {
long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;

View File

@ -82,6 +82,9 @@ inline void serial_delay(const millis_t ms) {
// Convert unsigned float to string with 1.23 format
char* ftostr12ns(const float &x);
// Convert signed float to fixed-length string with 12.34 / -2.34 or 023.45 / -23.45 format
char* ftostr42_52(const float &x);
// Convert signed float to fixed-length string with 023.45 / -23.45 format
char* ftostr52(const float &x);