Implemented remaining estimate km left

This commit is contained in:
CommanderRedYT
2022-01-17 10:10:08 +01:00
parent d8c97d7f20
commit bc340a3319
3 changed files with 19 additions and 0 deletions

View File

@@ -132,6 +132,12 @@ class AverageSpeedKmhOverTime : public virtual espgui::TextInterface {
} }
}; };
class EstimatedKmLeft : public virtual espgui::TextInterface {
public: std::string text() const override {
return fmt::format("est km:{}", getRemainingEstimateRangeString());
}
};
class EfficiencyTextColor : public virtual espgui::ColorInterface { class EfficiencyTextColor : public virtual espgui::ColorInterface {
public: public:
int color() const override int color() const override

View File

@@ -24,6 +24,11 @@ float getAvgKmh()
return (drivingStatistics.meters_driven / 1000.) / (drivingStatistics.currentDrivingTime.count() / 1000 / 60 / 60); // (meter / 1000) / (ms / 1000 / 60 / 60) return (drivingStatistics.meters_driven / 1000.) / (drivingStatistics.currentDrivingTime.count() / 1000 / 60 / 60); // (meter / 1000) / (ms / 1000 / 60 / 60)
} }
float getEstimatedKmLeft()
{
return (getRemainingWattHours() / getAvgWhPerKm());
}
std::string getEfficiencyClassString() std::string getEfficiencyClassString()
{ {
const float avgWhPerKm = getAvgWhPerKm(); const float avgWhPerKm = getAvgWhPerKm();
@@ -54,6 +59,12 @@ uint16_t getEfficiencyClassColor()
else return 0xF800; else return 0xF800;
} }
std::string getRemainingEstimateRangeString()
{
return fmt::format("{:.1f} km", getEstimatedKmLeft());
}
void initStatistics() void initStatistics()
{ {

View File

@@ -20,5 +20,7 @@ void initStatistics();
void calculateStatistics(); void calculateStatistics();
float getAvgWhPerKm(); float getAvgWhPerKm();
float getAvgKmh(); float getAvgKmh();
float getEstimatedKmLeft();
std::string getEfficiencyClassString(); std::string getEfficiencyClassString();
std::string getRemainingEstimateRangeString();
uint16_t getEfficiencyClassColor(); uint16_t getEfficiencyClassColor();