mirror of https://github.com/rusefi/wideband.git
listen to heater enable bit
This commit is contained in:
parent
24cdee9c28
commit
18cc209f72
|
@ -61,8 +61,8 @@ void CanRxThread(void*)
|
||||||
SetBatteryVoltage(vbatt);
|
SetBatteryVoltage(vbatt);
|
||||||
|
|
||||||
// data1 contains heater enable bit
|
// data1 contains heater enable bit
|
||||||
// TODO use this
|
bool heaterAllowed = (frame.data8[1] & 0x1) == 0x1;
|
||||||
//bool heaterEnabled = (frame.data8[1] & 0x1) == 0x1;
|
SetHeaterAllowed(heaterAllowed);
|
||||||
}
|
}
|
||||||
// If it's a bootloader entry request, reboot to the bootloader!
|
// If it's a bootloader entry request, reboot to the bootloader!
|
||||||
else if (frame.DLC == 0 && frame.EID == 0xEF0'0000)
|
else if (frame.DLC == 0 && frame.EID == 0xEF0'0000)
|
||||||
|
|
|
@ -20,11 +20,20 @@ enum class HeaterState
|
||||||
Stopped,
|
Stopped,
|
||||||
};
|
};
|
||||||
|
|
||||||
int timeCounter = HEATER_PREHEAT_TIME / HEATER_CONTROL_PERIOD;
|
constexpr int preheatTimeCounter = HEATER_PREHEAT_TIME / HEATER_CONTROL_PERIOD;
|
||||||
float rampVoltage = 0;
|
static int timeCounter = preheatTimeCounter;
|
||||||
|
static float rampVoltage = 0;
|
||||||
|
static bool heaterAllowed = false;
|
||||||
|
|
||||||
static HeaterState GetNextState(HeaterState state, float sensorEsr)
|
static HeaterState GetNextState(HeaterState state, float sensorEsr)
|
||||||
{
|
{
|
||||||
|
if (!heaterAllowed)
|
||||||
|
{
|
||||||
|
// ECU hasn't allowed preheat yet, reset timer, and force preheat state
|
||||||
|
timeCounter = preheatTimeCounter;
|
||||||
|
return HeaterState::Preheat;
|
||||||
|
}
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case HeaterState::Preheat:
|
case HeaterState::Preheat:
|
||||||
|
@ -187,3 +196,8 @@ void SetBatteryVoltage(float vbatt)
|
||||||
batteryVoltage = vbatt;
|
batteryVoltage = vbatt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetHeaterAllowed(bool allowed)
|
||||||
|
{
|
||||||
|
heaterAllowed = allowed;
|
||||||
|
}
|
||||||
|
|
|
@ -5,3 +5,4 @@
|
||||||
void StartHeaterControl();
|
void StartHeaterControl();
|
||||||
bool IsRunningClosedLoop();
|
bool IsRunningClosedLoop();
|
||||||
void SetBatteryVoltage(float vbatt);
|
void SetBatteryVoltage(float vbatt);
|
||||||
|
void SetHeaterAllowed(bool allowed);
|
||||||
|
|
Loading…
Reference in New Issue