rusefi/firmware/controllers/algo/engine_parts.h

77 lines
1.3 KiB
C
Raw Normal View History

2019-05-27 15:50:23 -07:00
/*
* @file engine_parts.h
*
* @date May 27, 2019
2020-01-07 21:02:40 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2019-05-27 15:50:23 -07:00
*/
2019-09-19 21:25:43 -07:00
#pragma once
2019-05-27 15:50:23 -07:00
#include "static_vector.h"
2023-08-30 20:11:24 -07:00
#include <rusefi/timer.h>
2019-05-27 15:50:23 -07:00
#define MOCK_ADC_SIZE 26
2019-05-27 15:50:23 -07:00
struct Accelerometer {
2023-11-27 01:30:18 -08:00
float lat = 0; // G value
float lon = 0;
float vert = 0;
float yawRate = 0;
2019-05-27 15:50:23 -07:00
};
struct SensorsState {
2019-05-27 15:50:23 -07:00
Accelerometer accelerometer;
};
class TransmissionState {
public:
gear_e gearSelectorPosition;
};
struct warning_t {
Timer LastTriggered;
ObdCode Code = ObdCode::None;
warning_t() { }
explicit warning_t(ObdCode code)
: Code(code)
{
}
// Equality just checks the code, timer doesn't matter
bool operator ==(const warning_t& other) const {
return other.Code == Code;
}
// Compare against a plain OBD code
bool operator ==(const ObdCode other) const {
return other == Code;
}
};
typedef static_vector<warning_t, 24> warningBuffer_t;
2021-06-23 03:37:32 -07:00
2019-05-27 15:50:23 -07:00
class WarningCodeState {
public:
WarningCodeState();
void addWarningCode(ObdCode code);
bool isWarningNow() const;
bool isWarningNow(ObdCode code) const;
2019-05-27 15:50:23 -07:00
void clear();
int warningCounter;
ObdCode lastErrorCode = ObdCode::None;
Timer timeSinceLastWarning;
2019-05-27 15:50:23 -07:00
// todo: we need a way to post multiple recent warnings into TS
2021-06-23 03:37:32 -07:00
warningBuffer_t recentWarnings;
2019-05-27 15:50:23 -07:00
};
2020-03-26 08:52:19 -07:00
struct multispark_state
{
efidur_t delay = 0;
efidur_t dwell = 0;
2020-07-29 02:22:54 -07:00
uint8_t count = 0;
2020-03-26 08:52:19 -07:00
};