Refactoring: Scalability and performance (#252)

Refactoring v5.7 step 1
This commit is contained in:
Cabooman 2024-04-14 14:41:01 +02:00 committed by GitHub
parent 5a5cfc433b
commit ffa7a54f20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
77 changed files with 926 additions and 286 deletions

View file

@ -0,0 +1,36 @@
#include "soc_scaling.h"
float ScaledSoc::set_real_soc(float soc) {
real_soc = soc;
scaled_soc = map_float(real_soc, 0.0f, 100.0f, min_real_soc, max_real_soc);
real_soc_initialized = true;
return scaled_soc;
}
float ScaledSoc::get_scaled_soc(void) {
if (real_soc_initialized) {
return scaled_soc;
} else {
return -1.0f;
}
}
float ScaledSoc::get_real_soc(void) {
if (real_soc_initialized) {
return real_soc;
} else {
return -1.0f;
}
}
float ScaledSoc::get_soc(void) {
if (real_soc_initialized) {
if (soc_scaling_active) {
return scaled_soc;
} else {
return real_soc;
}
} else {
return -1.0f;
}
}