From 463b3ea70e41f8c3bb09ca337feac493755922f8 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Tue, 3 Oct 2023 01:25:35 -0400 Subject: [PATCH] odometry output channels --- firmware/console/binary/output_channels.txt | 9 ++++++++- firmware/console/status_loop.cpp | 5 +++++ firmware/controllers/algo/trip_odometer.cpp | 12 ++++++++++++ firmware/controllers/algo/trip_odometer.h | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/firmware/console/binary/output_channels.txt b/firmware/console/binary/output_channels.txt index 9d312a4f01..9ce5af293c 100644 --- a/firmware/console/binary/output_channels.txt +++ b/firmware/console/binary/output_channels.txt @@ -367,5 +367,12 @@ float mapFast int16_t autoscale ambientTemp;;"deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0, 0, 0, 1 int16_t autoscale compressorDischargeTemp;;"deg C",{1/@@PACK_MULT_TEMPERATURE@@}, 0, 0, 0, 1 - uint8_t[132 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 + uint16_t autoscale compressorDischargePressure;;"kPa",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 1 + uint16_t autoscale throttleInletPressure;;"kPa",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 1 + + uint16_t ignitionOnTime;;"sec",1,0,0,0,1 + uint16_t engineRunTime;;"sec",1,0,0,0,1 + uint16_t autoscale distanceTraveled;;"km",0.1,0,0,0,1 + + uint8_t[124 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 end_struct diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 3f7ee35b75..795c74c522 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -547,6 +547,11 @@ static void updateFuelResults() { #if EFI_VEHICLE_SPEED engine->outputChannels.fuelFlowRate = engine->module()->getConsumptionGramPerSecond(); engine->outputChannels.totalFuelConsumption = engine->module()->getConsumedGrams(); + engine->outputChannels.ignitionOnTime = engine->module()->getIgnitionOnTime(); + engine->outputChannels.engineRunTime = engine->module()->getEngineRunTime(); + + // output channel in km + engine->outputChannels.distanceTraveled = 0.001f * engine->module()->getDistanceMeters(); #endif // EFI_VEHICLE_SPEED } diff --git a/firmware/controllers/algo/trip_odometer.cpp b/firmware/controllers/algo/trip_odometer.cpp index 7e69b67027..5ee825e624 100644 --- a/firmware/controllers/algo/trip_odometer.cpp +++ b/firmware/controllers/algo/trip_odometer.cpp @@ -6,6 +6,10 @@ void TripOdometer::reset() { m_distanceMeters = 0; m_distanceRemainder = 0; + + m_slowCallbackCounter = 0; + m_engineRunningSeconds = 0; + m_ignitionOnSeconds = 0; } void TripOdometer::consumeFuel(float grams, efitick_t nowNt) { @@ -64,3 +68,11 @@ void TripOdometer::onSlowCallback() { uint32_t TripOdometer::getDistanceMeters() const { return m_distanceMeters; } + +uint32_t TripOdometer::getIgnitionOnTime() const { + return m_ignitionOnSeconds; +} + +uint32_t TripOdometer::getEngineRunTime() const { + return m_engineRunningSeconds; +} diff --git a/firmware/controllers/algo/trip_odometer.h b/firmware/controllers/algo/trip_odometer.h index af452a1b20..7a70fe08ad 100644 --- a/firmware/controllers/algo/trip_odometer.h +++ b/firmware/controllers/algo/trip_odometer.h @@ -10,6 +10,8 @@ public: uint32_t getConsumedGrams() const; float getConsumptionGramPerSecond() const; uint32_t getDistanceMeters() const; + uint32_t getIgnitionOnTime() const; + uint32_t getEngineRunTime() const; private: // Fuel consumed