@@ -201,7 +201,7 @@ void Heater::Run()
201
201
// Turn the heater off.
202
202
_heater_on = false ;
203
203
heater_off ();
204
- ScheduleDelayed (_controller_period_usec - _controller_time_on_usec);
204
+ ScheduleDelayed (CONTROLLER_PERIOD_DEFAULT - _controller_time_on_usec);
205
205
206
206
} else if (_sensor_accel_sub.update (&sensor_accel)) {
207
207
@@ -217,9 +217,9 @@ void Heater::Run()
217
217
_integrator_value = math::constrain (_integrator_value, -0 .25f , 0 .25f );
218
218
219
219
_controller_time_on_usec = static_cast <int >((_param_sens_imu_temp_ff.get () + _proportional_value +
220
- _integrator_value) * static_cast <float >(_controller_period_usec ));
220
+ _integrator_value) * static_cast <float >(CONTROLLER_PERIOD_DEFAULT ));
221
221
222
- _controller_time_on_usec = math::constrain (_controller_time_on_usec, 0 , _controller_period_usec );
222
+ _controller_time_on_usec = math::constrain (_controller_time_on_usec, 0 , CONTROLLER_PERIOD_DEFAULT );
223
223
224
224
if (fabsf (temperature_delta) < TEMPERATURE_TARGET_THRESHOLD) {
225
225
_temperature_target_met = true ;
@@ -229,9 +229,16 @@ void Heater::Run()
229
229
_temperature_target_met = false ;
230
230
}
231
231
232
- _heater_on = true ;
233
- heater_on ();
234
- ScheduleDelayed (_controller_time_on_usec);
232
+ if (_controller_time_on_usec > 0 ) {
233
+ // Turn the heater on.
234
+ _heater_on = true ;
235
+ heater_on ();
236
+ ScheduleDelayed (_controller_time_on_usec);
237
+
238
+ } else {
239
+ // Turn the heater off.
240
+ ScheduleDelayed (CONTROLLER_PERIOD_DEFAULT);
241
+ }
235
242
}
236
243
237
244
publish_status ();
@@ -245,7 +252,7 @@ void Heater::publish_status()
245
252
status.temperature_sensor = _temperature_last;
246
253
status.temperature_target = _param_sens_imu_temp.get ();
247
254
status.temperature_target_met = _temperature_target_met;
248
- status.controller_period_usec = _controller_period_usec ;
255
+ status.controller_period_usec = CONTROLLER_PERIOD_DEFAULT ;
249
256
status.controller_time_on_usec = _controller_time_on_usec;
250
257
status.proportional_value = _proportional_value;
251
258
status.integrator_value = _integrator_value;
0 commit comments