Added calculation of megajoules

This commit is contained in:
CommanderRedYT
2022-03-02 15:09:44 +01:00
parent e7379fd3df
commit c3cf4a74b0
3 changed files with 14 additions and 2 deletions

View File

@ -155,6 +155,11 @@ float getPercentageByWh(float wh)
return maxWh / wh; return maxWh / wh;
} }
float getBatteryWattHours()
{
return (getTarget_mAh() / 1000.f) * 3.7 * configs.battery.cellsParallel.value * configs.battery.cellsSeries.value;
}
float getTarget_mAh() float getTarget_mAh()
{ {
float target_mah = 2000; //default float target_mah = 2000; //default

View File

@ -19,6 +19,8 @@ float getBatteryPercentage(float batVoltage, BatteryCellType cellType);
float getRemainingWattHours(); float getRemainingWattHours();
float getBatteryWattHours();
std::string getBatteryPercentageString(); std::string getBatteryPercentageString();
std::string getBatteryRemainingWattHoursString(); std::string getBatteryRemainingWattHoursString();

View File

@ -14,6 +14,11 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
float calculateMegaJoules()
{
return getBatteryWattHours() * 0.0036;
}
void ConfiscationDisplay::start() void ConfiscationDisplay::start()
{ {
Base::start(); Base::start();
@ -46,7 +51,7 @@ void ConfiscationDisplay::initScreen()
espgui::tft.drawString("Bei erneuter, widerrechtlicher", 10, y+=lineheight); espgui::tft.drawString("Bei erneuter, widerrechtlicher", 10, y+=lineheight);
espgui::tft.drawString("Beschlagnahmung wird die Selbst-", 10, y+=lineheight); espgui::tft.drawString("Beschlagnahmung wird die Selbst-", 10, y+=lineheight);
espgui::tft.drawString("Vernichtung durch Kurzschluss", 10, y+=lineheight); espgui::tft.drawString("Vernichtung durch Kurzschluss", 10, y+=lineheight);
espgui::tft.drawString("der Batterie eingeleitet (ca 4.31MJ)", 10, y+=lineheight); espgui::tft.drawString(fmt::format("der Batterie eingeleitet (ca {:.2f}MJ)", calculateMegaJoules()), 10, y+=lineheight);
} }
void ConfiscationDisplay::redraw() void ConfiscationDisplay::redraw()
@ -74,7 +79,7 @@ void ConfiscationDisplay::update()
{ {
m_progress = 500; m_progress = 500;
const auto timeout = cpputils::randomNumber(3, 7, espcpputils::esp_random_device{}); const auto timeout = cpputils::randomNumber(3, 7, espcpputils::esp_random_device{});
ESP_LOGI("BOBBY", "agian in %i", timeout); ESP_LOGI("BOBBY", "again in %i", timeout);
m_nextRestart = espchrono::millis_clock::now() + std::chrono::seconds{timeout}; m_nextRestart = espchrono::millis_clock::now() + std::chrono::seconds{timeout};
} }
else else