rusefi/firmware/controllers/math/lambda_monitor.h

32 lines
1017 B
C
Raw Normal View History

2023-06-28 23:31:53 -07:00
#pragma once
#include "lambda_monitor_generated.h"
struct LambdaMonitorBase : public lambda_monitor_s {
2023-06-28 23:31:53 -07:00
void update(float rpm, float load);
2023-06-28 23:49:50 -07:00
bool isCut() const;
2023-06-28 23:31:53 -07:00
protected:
// Returns whether lambda checking should happen at all
bool shouldCheckLambda(float rpm, float load) const;
// Returns false if the current lambda reading is leaner than allowable.
// Returns true in any other case (rich enough, bad sensor, recent fuel cut, rpm to low, load too low, etc)
2023-07-26 00:35:28 -07:00
virtual bool isCurrentlyGood(float rpm, float load) const;
2023-06-28 23:31:53 -07:00
virtual float getMaxAllowedLambda(float rpm, float load) const = 0;
2023-07-26 00:35:28 -07:00
virtual float getTimeout() const = 0;
2023-06-28 23:31:53 -07:00
2023-06-28 23:49:50 -07:00
// Determine whether fuel should be restored after a cut occurs
// Returns true if OK to leave the "cut" state
2023-07-26 00:35:28 -07:00
virtual bool restoreConditionsMet(float rpm, float load) const;
2023-06-28 23:49:50 -07:00
2023-06-28 23:31:53 -07:00
private:
Timer m_timeSinceGoodLambda;
};
class LambdaMonitor : public LambdaMonitorBase {
float getMaxAllowedLambda(float rpm, float load) const override;
2023-07-26 00:35:28 -07:00
float getTimeout() const override;
2023-06-28 23:31:53 -07:00
};