Skip to content

Commit dbcbc3f

Browse files
committed
heater control: way out of NoHeaterSupply state
1 parent 99b87b5 commit dbcbc3f

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

firmware/heater_control.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
5656
{
5757
bool heaterAllowed = heaterAllowState == HeaterAllow::Allowed;
5858

59-
// Check battery voltage for thresholds only if there is still no command over CAN
59+
#if defined(HEATER_INPUT_DIVIDER) || defined(BOARD_HAS_VOLTAGE_SENSE)
60+
// Check localy measured battery voltage for thresholds only if there is still no command over CAN
6061
if (heaterAllowState == HeaterAllow::Unknown)
6162
{
6263
// measured voltage too low to auto-start heating
@@ -71,6 +72,7 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
7172
heaterAllowed = m_heaterStableTimer.hasElapsedSec(HEATER_SUPPLY_STAB_TIME);
7273
}
7374
}
75+
#endif
7476

7577
if (!heaterAllowed)
7678
{
@@ -150,9 +152,23 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
150152

151153
break;
152154
case HeaterState::Stopped:
153-
case HeaterState::NoHeaterSupply:
154155
/* nop */
155156
break;
157+
case HeaterState::NoHeaterSupply:
158+
#if defined(HEATER_INPUT_DIVIDER) || defined(BOARD_HAS_VOLTAGE_SENSE)
159+
if (heaterSupplyVoltage > HEATER_SUPPLY_ON_VOLTAGE)
160+
{
161+
// measured voltage is high enougth to auto-start heating, wait some time to stabilize
162+
if (m_heaterStableTimer.hasElapsedSec(HEATER_SUPPLY_STAB_TIME)) {
163+
m_preheatTimer.reset();
164+
return HeaterState::Preheat;
165+
}
166+
}
167+
#else
168+
m_preheatTimer.reset();
169+
return HeaterState::Preheat;
170+
#endif
171+
break;
156172
}
157173

158174
return currentState;

0 commit comments

Comments
 (0)