2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file tps.h
|
|
|
|
* @brief
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @date Nov 15, 2013
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2020-01-20 22:40:11 -08:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "engine_configuration.h"
|
|
|
|
|
2020-02-03 22:54:05 -08:00
|
|
|
// Scaled to 1000 counts = 5.0 volts
|
|
|
|
#define TPS_TS_CONVERSION 200
|
|
|
|
|
2023-03-01 13:53:48 -08:00
|
|
|
// we have this '100' magic constant too often for two many other reasons todo: refactor further?
|
|
|
|
#define POSITION_FULLY_OPEN 100
|
|
|
|
|
2020-04-05 06:11:25 -07:00
|
|
|
constexpr inline int convertVoltageTo10bitADC(float voltage) {
|
|
|
|
return (int) (voltage * TPS_TS_CONVERSION);
|
|
|
|
}
|
|
|
|
|
2023-02-23 02:26:42 -08:00
|
|
|
struct SentTps : public StoredValueSensor {
|
|
|
|
SentTps() : StoredValueSensor(SensorType::Tps1, MS2NT(200)) {
|
|
|
|
}
|
2023-03-01 11:26:24 -08:00
|
|
|
|
|
|
|
bool isRedundant() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2023-02-23 02:26:42 -08:00
|
|
|
};
|
|
|
|
|
2019-04-29 22:21:09 -07:00
|
|
|
void grabTPSIsClosed();
|
|
|
|
void grabTPSIsWideOpen();
|
2019-04-30 15:46:39 -07:00
|
|
|
void grabPedalIsUp();
|
|
|
|
void grabPedalIsWideOpen();
|
2022-11-27 15:44:44 -08:00
|
|
|
|
2023-02-28 19:10:19 -08:00
|
|
|
void sentTpsDecode();
|
2023-03-01 14:20:34 -08:00
|
|
|
float decodeTpsSentValue(float sentValue);
|
2023-03-01 06:19:22 -08:00
|
|
|
bool isDigitalTps1();
|
2023-02-28 19:10:19 -08:00
|
|
|
|
2022-11-29 17:11:29 -08:00
|
|
|
bool isTps1Error();
|
2022-11-27 15:44:44 -08:00
|
|
|
bool isTps2Error();
|
|
|
|
bool isPedalError();
|