fome-fw/firmware/controllers/sensors/map.h

45 lines
1.2 KiB
C
Raw Normal View History

2015-12-31 13:02:30 -08:00
/**
2018-01-21 13:11:39 -08:00
* @file map.h
*
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-12-31 13:02:30 -08:00
*/
2020-01-20 22:40:11 -08:00
#pragma once
2015-07-10 06:01:56 -07:00
#include "engine_ptr.h"
class Logging;
struct air_pressure_sensor_config_s;
2015-07-10 06:01:56 -07:00
2017-05-15 20:33:22 -07:00
void initMapDecoder(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
/**
* @return Raw MAP sensor value right now
*/
2017-05-15 20:33:22 -07:00
float getRawMap(DECLARE_ENGINE_PARAMETER_SIGNATURE);
float getBaroPressure(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool hasBaroSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool hasMapSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
2016-12-17 08:01:40 -08:00
2015-07-10 06:01:56 -07:00
/**
* @return MAP value averaged within a window of measurement
*/
float getMap(DECLARE_ENGINE_PARAMETER_SIGNATURE);
2017-05-15 20:33:22 -07:00
float getMapByVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX);
float decodePressure(float voltage, air_pressure_sensor_config_s * mapConfig DECLARE_ENGINE_PARAMETER_SUFFIX);
float validateMap(float mapKPa DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
#define KPA_PER_PSI 6.89475728f
2018-01-21 13:11:39 -08:00
2020-10-27 22:01:54 -07:00
#define PSI2KPA(psi) (KPA_PER_PSI * (psi))
2020-10-31 21:33:18 -07:00
#define BAR2KPA(bar) (100 * (bar))
2020-11-22 22:10:12 -08:00
#define KPA2BAR(kpa) (0.01f * (kpa))
2020-10-31 21:33:18 -07:00
2018-01-21 13:11:39 -08:00
// PSI (relative to atmosphere) to kPa (relative to vacuum)
2020-10-27 22:01:54 -07:00
#define PSI2KPA_RELATIVE(psi) (101.32500411216164f + PSI2KPA(psi))
2018-01-21 13:11:39 -08:00
2020-11-22 22:10:12 -08:00
#define INHG2KPA(inhg) ((inhg) * 3.386375f)
#define KPA2INHG(kpa) ((kpa) / 3.386375f)
2016-06-26 11:01:41 -07:00