Power monitor and display (#17437)

This commit is contained in:
Scott Lahteine
2020-06-18 15:23:03 -05:00
committed by GitHub
parent c8e99d572c
commit 424569b4c4
32 changed files with 652 additions and 28 deletions

View File

@@ -174,6 +174,27 @@ const char* ftostr12ns(const float &f) {
return &conv[3];
}
// Convert unsigned float to string with 12.3 format
const char* ftostr31ns(const float &f) {
const long i = ((f < 0 ? -f : f) * 100 + 5) / 10;
conv[3] = DIGIMOD(i, 100);
conv[4] = DIGIMOD(i, 10);
conv[5] = '.';
conv[6] = DIGIMOD(i, 1);
return &conv[3];
}
// Convert unsigned float to string with 123.4 format
const char* ftostr41ns(const float &f) {
const long i = ((f < 0 ? -f : f) * 100 + 5) / 10;
conv[2] = DIGIMOD(i, 1000);
conv[3] = DIGIMOD(i, 100);
conv[4] = DIGIMOD(i, 10);
conv[5] = '.';
conv[6] = DIGIMOD(i, 1);
return &conv[2];
}
// Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format
const char* ftostr42_52(const float &f) {
if (f <= -10 || f >= 100) return ftostr52(f); // -23.45 / 123.45

View File

@@ -58,6 +58,12 @@ const char* i16tostr4signrj(const int16_t x);
// Convert unsigned float to string with 1.23 format
const char* ftostr12ns(const float &x);
// Convert unsigned float to string with 12.3 format
const char* ftostr31ns(const float &x);
// Convert unsigned float to string with 123.4 format
const char* ftostr41ns(const float &x);
// Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format
const char* ftostr42_52(const float &x);