Power monitor and display (#17437)
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user