mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Fix off by one index
This commit is contained in:
parent
0ba4f9e84b
commit
9eed56f7a5
2 changed files with 9 additions and 2 deletions
|
@ -135,6 +135,7 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
|
||||
datalayer.battery.status.cell_min_voltage_mV = BMS_lowest_cell_voltage_mV;
|
||||
|
||||
#ifdef SKIP_TEMPERATURE_SENSOR_NUMBER
|
||||
// Initialize min and max variables for temperature calculation
|
||||
battery_calc_min_temperature = battery_daughterboard_temperatures[0];
|
||||
battery_calc_max_temperature = battery_daughterboard_temperatures[0];
|
||||
|
@ -146,7 +147,7 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
battery_calc_max_temperature = battery_daughterboard_temperatures[1];
|
||||
}
|
||||
for (int i = 1; i < 10; i++) {
|
||||
if (i == SKIP_TEMPERATURE_SENSOR_NUMBER) {
|
||||
if (i == (SKIP_TEMPERATURE_SENSOR_NUMBER - 1)) {
|
||||
i++;
|
||||
}
|
||||
if (battery_daughterboard_temperatures[i] < battery_calc_min_temperature) {
|
||||
|
@ -159,6 +160,10 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
//Write the result to datalayer
|
||||
datalayer.battery.status.temperature_min_dC = battery_calc_min_temperature * 10;
|
||||
datalayer.battery.status.temperature_max_dC = battery_calc_max_temperature * 10;
|
||||
#else //User does not need filtering out a broken sensor, just use the min-max the BMS sends
|
||||
datalayer.battery.status.temperature_min_dC = BMS_lowest_cell_temperature * 10;
|
||||
datalayer.battery.status.temperature_max_dC = BMS_highest_cell_temperature * 10;
|
||||
#endif //!SKIP_TEMPERATURE_SENSOR_NUMBER
|
||||
|
||||
// Update webserver datalayer
|
||||
datalayer_extended.bydAtto3.SOC_method = SOC_method;
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#define MAXPOWER_CHARGE_W 10000
|
||||
#define MAXPOWER_DISCHARGE_W 10000
|
||||
|
||||
#define SKIP_TEMPERATURE_SENSOR_NUMBER 0 // Enter incase one of your temperature sensors are broken (1-10)
|
||||
//Uncomment and configure this line, if you want to filter out a broken temperature sensor (1-10)
|
||||
//Make sure you understand risks associated with disabling. Values can be read via "More Battery info"
|
||||
//#define SKIP_TEMPERATURE_SENSOR_NUMBER 1
|
||||
|
||||
/* Do not modify the rows below */
|
||||
#define BATTERY_SELECTED
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue