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
|
|
|
|
2022-08-16 22:12:25 -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
|
|
|
|
2019-09-22 14:39:13 -07:00
|
|
|
#define MOCK_ADC_SIZE 26
|
2019-05-27 15:50:23 -07:00
|
|
|
|
2022-02-03 17:43:34 -08: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
|
|
|
};
|
|
|
|
|
2022-02-03 17:43:34 -08:00
|
|
|
struct SensorsState {
|
2019-05-27 15:50:23 -07:00
|
|
|
Accelerometer accelerometer;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TransmissionState {
|
|
|
|
public:
|
|
|
|
gear_e gearSelectorPosition;
|
|
|
|
};
|
|
|
|
|
2022-08-16 22:12:25 -07:00
|
|
|
struct warning_t {
|
|
|
|
Timer LastTriggered;
|
2023-04-11 17:01:34 -07:00
|
|
|
ObdCode Code = ObdCode::None;
|
2022-08-16 22:12:25 -07:00
|
|
|
|
|
|
|
warning_t() { }
|
|
|
|
|
2023-04-11 16:32:47 -07:00
|
|
|
explicit warning_t(ObdCode code)
|
2022-08-16 22:12:25 -07:00
|
|
|
: 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
|
2023-04-11 16:32:47 -07:00
|
|
|
bool operator ==(const ObdCode other) const {
|
2022-08-16 22:12:25 -07:00
|
|
|
return other == Code;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-01-08 11:56:33 -08:00
|
|
|
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();
|
2023-04-11 16:32:47 -07:00
|
|
|
void addWarningCode(ObdCode code);
|
2022-08-16 22:12:25 -07:00
|
|
|
bool isWarningNow() const;
|
2023-04-11 16:32:47 -07:00
|
|
|
bool isWarningNow(ObdCode code) const;
|
2019-05-27 15:50:23 -07:00
|
|
|
void clear();
|
|
|
|
int warningCounter;
|
2023-04-11 17:01:34 -07:00
|
|
|
ObdCode lastErrorCode = ObdCode::None;
|
2022-08-16 22:12:25 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2024-04-25 12:57:10 -07:00
|
|
|
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
|
|
|
};
|