Added avg speed over time
This commit is contained in:
@ -126,6 +126,12 @@ class EfficiencyText : public virtual espgui::TextInterface {
|
||||
}
|
||||
};
|
||||
|
||||
class AverageSpeedKmhOverTime : public virtual espgui::TextInterface {
|
||||
public: std::string text() const override {
|
||||
return fmt::format("Avg speed: {:.1f} km/h", getAvgKmh());
|
||||
}
|
||||
};
|
||||
|
||||
class EfficiencyTextColor : public virtual espgui::ColorInterface {
|
||||
public:
|
||||
int color() const override
|
||||
@ -169,6 +175,7 @@ StatisticsMenu::StatisticsMenu()
|
||||
// constructMenuItem<makeComponent<MenuItem, SavedTotalCentimetersText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, CurrentWhUsedText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, AverageWhUsedText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, AverageSpeedKmhOverTime, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EfficiencyText, EfficiencyTextColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATSSAVE>, SaveKilometersAction, StaticMenuItemIcon<&bobbyicons::update>>>();
|
||||
|
@ -19,6 +19,11 @@ float getAvgWhPerKm()
|
||||
return drivingStatistics.wh_used / (drivingStatistics.meters_driven / 1000.f);
|
||||
}
|
||||
|
||||
float getAvgKmh()
|
||||
{
|
||||
return (drivingStatistics.meters_driven / 1000.) / (drivingStatistics.currentDrivingTime.count() / 1000 / 60 / 60); // (meter / 1000) / (ms / 1000 / 60 / 60)
|
||||
}
|
||||
|
||||
std::string getEfficiencyClassString()
|
||||
{
|
||||
const float avgWhPerKm = getAvgWhPerKm();
|
||||
|
@ -19,5 +19,6 @@ extern DrivingStatistics drivingStatistics;
|
||||
void initStatistics();
|
||||
void calculateStatistics();
|
||||
float getAvgWhPerKm();
|
||||
float getAvgKmh();
|
||||
std::string getEfficiencyClassString();
|
||||
uint16_t getEfficiencyClassColor();
|
||||
|
Reference in New Issue
Block a user