mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Refactoring: Scalability and performance (#252)
Refactoring v5.7 step 1
This commit is contained in:
parent
5a5cfc433b
commit
ffa7a54f20
77 changed files with 926 additions and 286 deletions
36
Software/src/devboard/utils/soc_scaling.cpp
Normal file
36
Software/src/devboard/utils/soc_scaling.cpp
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue