rusefi/firmware/controllers/engine_cycle/map_averaging.h

61 lines
1.1 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file map_averaging.h
*
* @date Dec 11, 2013
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
2019-11-14 21:00:13 -08:00
#pragma once
2015-07-10 06:01:56 -07:00
#include "sensor_converter_func.h"
2019-04-12 19:07:03 -07:00
#if EFI_MAP_AVERAGING
2015-07-10 06:01:56 -07:00
2019-04-12 19:07:03 -07:00
#if HAL_USE_ADC
void mapAveragingAdcCallback(float instantVoltage);
2015-07-10 06:01:56 -07:00
#endif
void initMapAveraging();
void refreshMapAveragingPreCalc();
2020-10-03 23:09:12 -07:00
void mapAveragingTriggerCallback(
uint32_t index, efitick_t edgeTimestamp);
#if EFI_TUNER_STUDIO
2018-02-06 13:21:41 -08:00
void postMapState(TunerStudioOutputChannels *tsOutputChannels);
#endif
2015-07-10 06:01:56 -07:00
// allow smoothing up to number of cylinders
#define MAX_MAP_BUFFER_LENGTH (MAX_CYLINDER_COUNT)
2015-07-10 06:01:56 -07:00
#endif /* EFI_MAP_AVERAGING */
class MapAverager : public StoredValueSensor {
public:
MapAverager(SensorType type, efitick_t timeout)
: StoredValueSensor(type, timeout)
{
}
void start();
void stop();
SensorResult submit(float sensorVolts);
void setFunction(SensorConverter& func) {
m_function = &func;
}
void showInfo(const char* sensorName) const override;
private:
SensorConverter* m_function = nullptr;
bool m_isAveraging = false;
size_t m_counter = 0;
size_t m_lastCounter = 0;
float m_sum = 0;
};
MapAverager& getMapAvg(size_t idx);