* WIP

* WIP

* WIP

* Corrected name

* WIP

* WIP

* WIP

* WIP

* Added new calc

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Added debug serial lines

* WIP

* Fixed issue

* Fixed calculation issue

* Added voltage to performance DFU menu

* Added padding function and added voltage to perf menu

* Clean up

* Refactor

* Fixed linting

* Hides voltage if PP does not conatin IC

* WIP showing battery %

* made the percentage a int

* Added % to header

* Removed test UI

* Removed comment

* Added fix for precision too large

* Added fix for precision too large

* Linting
This commit is contained in:
jLynx 2024-04-21 20:44:47 +12:00 committed by GitHub
parent 282e4da1cb
commit 67975d76a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 235 additions and 2 deletions

View file

@ -172,6 +172,31 @@ std::string to_string_decimal(float decimal, int8_t precision) {
return result;
}
std::string to_string_decimal_padding(float decimal, int8_t precision, const int32_t l) {
double integer_part;
double fractional_part;
std::string result;
if (precision > 9) precision = 9; // we will convert to uin32_t, and that is the max it can hold.
fractional_part = modf(decimal, &integer_part) * pow(10, precision);
if (fractional_part < 0) {
fractional_part = -fractional_part;
}
result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision, '0');
// Add padding with spaces to meet the length requirement
if (result.length() < l) {
int padding_length = l - result.length();
std::string padding(padding_length, ' ');
result = padding + result;
}
return result;
}
// right-justified frequency in Hz, always 10 characters
std::string to_string_freq(const uint64_t f) {
std::string final_str{""};