trip odometer run time
This commit is contained in:
parent
9d0a390bab
commit
085415868f
|
@ -45,6 +45,18 @@ void TripOdometer::onSlowCallback() {
|
||||||
m_distanceMeters++;
|
m_distanceMeters++;
|
||||||
m_distanceRemainder--;
|
m_distanceRemainder--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr float slowCallbackPerSecond = 1000 / SLOW_CALLBACK_PERIOD_MS;
|
||||||
|
m_slowCallbackCounter++;
|
||||||
|
if (m_slowCallbackCounter == slowCallbackPerSecond) {
|
||||||
|
m_slowCallbackCounter = 0;
|
||||||
|
|
||||||
|
m_ignitionOnSeconds++;
|
||||||
|
|
||||||
|
if (engine->rpmCalculator.isRunning()) {
|
||||||
|
m_engineRunningSeconds++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TripOdometer::getDistanceMeters() const {
|
uint32_t TripOdometer::getDistanceMeters() const {
|
||||||
|
|
|
@ -12,12 +12,19 @@ public:
|
||||||
uint32_t getDistanceMeters() const;
|
uint32_t getDistanceMeters() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Fuel consumed
|
||||||
uint32_t m_consumedGrams = 0;
|
uint32_t m_consumedGrams = 0;
|
||||||
float m_consumedRemainder = 0;
|
float m_consumedRemainder = 0;
|
||||||
float m_rate = 0;
|
float m_rate = 0;
|
||||||
|
|
||||||
|
// Distance travelled
|
||||||
uint32_t m_distanceMeters = 0;
|
uint32_t m_distanceMeters = 0;
|
||||||
float m_distanceRemainder = 0;
|
float m_distanceRemainder = 0;
|
||||||
|
|
||||||
|
// Engine run time and ign on time
|
||||||
|
uint32_t m_slowCallbackCounter = 0;
|
||||||
|
uint32_t m_ignitionOnSeconds = 0;
|
||||||
|
uint32_t m_engineRunningSeconds = 0;
|
||||||
|
|
||||||
Timer m_timer;
|
Timer m_timer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue