Fixed formatting

This commit is contained in:
CommanderRedYT
2022-06-23 20:04:51 +02:00
parent 0393ac750b
commit 55386b5fb3

View File

@@ -44,13 +44,16 @@ void SpeedInfoDisplay::redraw()
tft.setTextSize(1); tft.setTextSize(1);
m_batteryPercentLabel.redraw(getBatteryPercentageString()); m_batteryPercentLabel.redraw(getBatteryPercentageString());
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage) { if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
{
auto watt = sumCurrent * *avgVoltage; auto watt = sumCurrent * *avgVoltage;
auto wh_per_km = std::abs(avgSpeedKmh) > 0.1 ? watt / std::abs(avgSpeedKmh) : 0; auto wh_per_km = std::abs(avgSpeedKmh) > 0.1 ? watt / std::abs(avgSpeedKmh) : 0;
m_voltageLabel.redraw(fmt::format("{:.1f} V", avgVoltage.value())); m_voltageLabel.redraw(fmt::format("{:.1f} V", avgVoltage.value()));
m_currentConsumptionLabel.redraw(fmt::format("{:.1f} Wh/km", wh_per_km)); m_currentConsumptionLabel.redraw(fmt::format("{:.1f} Wh/km", wh_per_km));
} else { }
else
{
m_voltageLabel.redraw("No voltage"); m_voltageLabel.redraw("No voltage");
m_currentConsumptionLabel.redraw("No comsumption"); m_currentConsumptionLabel.redraw("No comsumption");
} }
@@ -72,7 +75,8 @@ void SpeedInfoDisplay::buttonPressed(espgui::Button button)
{ {
Base::buttonPressed(button); Base::buttonPressed(button);
switch (button) { switch (button)
{
using espgui::Button; using espgui::Button;
case Button::Right: case Button::Right:
espgui::pushScreen<MainMenu>(); espgui::pushScreen<MainMenu>();