Added debug information for current calibration (will be moved in the future)

This commit is contained in:
CommanderRedYT
2021-11-13 15:42:46 +01:00
parent b739244320
commit 34135f01b1
3 changed files with 34 additions and 0 deletions

View File

@ -156,3 +156,14 @@ std::string getRemainingRangeString()
{
return fmt::format("{:.1f} km", getRemainingWattHours() / settings.battery.watthoursPerKilometer);
}
std::string getBatteryDebugString()
{
float avgVoltage = 0;
for (auto &controller : controllers)
{
avgVoltage += controller.getCalibratedVoltage();
}
avgVoltage = avgVoltage / controllers.size();
return fmt::format("{:.1f}V {}A", avgVoltage, sumCurrent);
}

View File

@ -27,3 +27,5 @@ std::string getBatteryRemainingWattHoursString();
std::string getBatteryCellTypeString();
std::string getRemainingRangeString();
std::string getBatteryDebugString();

View File

@ -7,8 +7,26 @@
#include "mainmenu.h"
#include "displays/calibratevoltagedisplay.h"
#include "accessors/settingsaccessors.h"
#include "fmt/core.h"
class CurrentBatteryStatusText : public virtual espgui::TextInterface { public: std::string text() const override { return getBatteryPercentageString(); } };
class BatteryDebugText : public virtual espgui::TextInterface { public: std::string text() const override { return getBatteryDebugString(); } };
class BatteryDebug2Text : public virtual espgui::TextInterface {
public: std::string text() const override {
float avgVoltage = 0;
for (auto &controller : controllers)
{
avgVoltage += controller.getCalibratedVoltage();
}
avgVoltage = avgVoltage / controllers.size();
auto watt = sumCurrent * avgVoltage;
auto w_per_kmh = watt / avgSpeedKmh;
return fmt::format("{:.1f} {:.2f}W/kmh", avgSpeedKmh, w_per_kmh);
}
};
class BatteryDebug3Text : public virtual espgui::TextInterface { public: std::string text() const override { return fmt::format("{}fA {}bA", fixCurrent(controllers.front.feedback.left.dcLink + controllers.front.feedback.right.dcLink), fixCurrent(controllers.back.feedback.left.dcLink + controllers.back.feedback.right.dcLink)); } };
using BatteryCellSeriesChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
@ -39,6 +57,9 @@ using namespace espgui;
BatteryMenu::BatteryMenu()
{
constructMenuItem<makeComponent<MenuItem, CurrentBatteryStatusText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryDebugText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryDebug2Text, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryDebug3Text, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CELL_SERIES, BatterySeriesCellsAccessor>, SwitchScreenAction<BatteryCellSeriesChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CELL_PARALLEL, BatteryParallelCellsAccessor>, SwitchScreenAction<BatteryCellParallelChangeScreen>>>();