change Wh/km to W in speed info display

This commit is contained in:
Peter Poetzi
2022-07-17 16:31:29 +02:00
parent a462e97d5f
commit d805bcfb2c
2 changed files with 6 additions and 5 deletions

View File

@ -22,7 +22,7 @@ void SpeedInfoDisplay::initScreen()
m_batteryPercentLabel.start();
m_voltageLabel.start();
m_distanceLabel.start();
m_currentConsumptionLabel.start();
m_currentPowerLabel.start();
}
void SpeedInfoDisplay::redraw()
@ -46,15 +46,16 @@ void SpeedInfoDisplay::redraw()
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
{
auto watt = sumCurrent * *avgVoltage;
auto wh_per_km = std::abs(avgSpeedKmh) > 0.1 ? watt / std::abs(avgSpeedKmh) : 0;
m_voltageLabel.redraw(fmt::format("{:.1f} V", avgVoltage.value()));
m_currentConsumptionLabel.redraw(fmt::format("{:.1f} Wh/km", wh_per_km));
tft.setTextSize(2);
m_currentPowerLabel.redraw(fmt::format("{:.0f} W", watt));
tft.setTextSize(1);
}
else
{
m_voltageLabel.redraw("No voltage");
m_currentConsumptionLabel.redraw("No comsumption");
m_currentPowerLabel.redraw("No power");
}
m_distanceLabel.redraw(

View File

@ -28,5 +28,5 @@ private:
espgui::Label m_batteryPercentLabel{5, START_Y};
espgui::Label m_voltageLabel{5, START_Y + 29 * 1};
espgui::Label m_distanceLabel{5, START_Y + 29 * 2};
espgui::Label m_currentConsumptionLabel{5, START_Y + 29 * 3};
espgui::Label m_currentPowerLabel{5, START_Y + 29 * 3};
};