Skip to content

Commit acf2ac2

Browse files
authored
Merge pull request #100 from smartin015/fix_clearing_cooldown
Actually run bed clearing script when exiting cooldown mode
2 parents 46c7064 + e6e3084 commit acf2ac2

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

continuousprint/driver.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,22 @@ def _state_start_clearing(self, a: Action, p: Printer):
266266
return self._state_clearing
267267

268268
def _state_cooldown(self, a: Action, p: Printer):
269+
clear = False
269270
if self._bed_temp < self.cooldown_threshold:
270271
self._logger.info(
271272
f"Cooldown threshold of {self.cooldown_threshold} has been met"
272273
)
273-
return self._state_clearing
274+
clear = True
274275
elif (time.time() - self.cooldown_start) > (60 * self.cooldown_timeout):
275276
self._logger.info(f"Timeout of {self.cooldown_timeout} minutes exceeded")
276-
return self._state_clearing
277+
clear = True
277278
else:
278279
self._set_status("Cooling down")
279280

281+
if clear:
282+
self._runner.clear_bed()
283+
return self._state_clearing
284+
280285
def _state_clearing(self, a: Action, p: Printer):
281286
if a == Action.SUCCESS:
282287
return self._enter_start_print(a, p)

continuousprint/driver_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ def test_bed_clearing_cooldown_threshold(self):
108108
DA.TICK, DP.IDLE, bed_temp=21
109109
) # -> stays in cooldown since bed temp too high
110110
self.assertEqual(self.d.state.__name__, self.d._state_cooldown.__name__)
111+
self.d._runner.clear_bed.assert_not_called()
111112
self.d.action(DA.TICK, DP.IDLE, bed_temp=19) # -> exits cooldown
112113
self.assertEqual(self.d.state.__name__, self.d._state_clearing.__name__)
114+
self.d._runner.clear_bed.assert_called()
113115

114116
def test_bed_clearing_cooldown_timeout(self):
115117
self.d.set_managed_cooldown(True, 20, 60)
@@ -121,8 +123,10 @@ def test_bed_clearing_cooldown_timeout(self):
121123
self.d.action(DA.TICK, DP.IDLE, bed_temp=21)
122124
self.assertEqual(self.d.state.__name__, self.d._state_cooldown.__name__)
123125
self.d.cooldown_start = orig_start - 60 * 61
126+
self.d._runner.clear_bed.assert_not_called()
124127
self.d.action(DA.TICK, DP.IDLE, bed_temp=21) # exit due to timeout
125128
self.assertEqual(self.d.state.__name__, self.d._state_clearing.__name__)
129+
self.d._runner.clear_bed.assert_called()
126130

127131
def test_finishing_failure(self):
128132
self.d.state = self.d._state_finishing

continuousprint/script_runner.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ def start_cooldown(self):
5656
self._printer.set_temperature("bed", 0) # turn bed off
5757

5858
def clear_bed(self):
59-
if self._get_key(Keys.BED_COOLDOWN_ENABLED):
60-
self.wait_for_bed_cooldown()
61-
return self._execute_gcode(Keys.CLEARING_SCRIPT)
59+
self._msg("Clearing bed")
60+
self._execute_gcode(Keys.CLEARING_SCRIPT)
6261

6362
def start_print(self, item):
6463
self._msg(f"{item.job.name}: printing {item.path}")

continuousprint/script_runner_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def test_cancel_print(self):
3737
self.s._printer.cancel_print.assert_called()
3838

3939
def test_clear_bed(self):
40-
self.s._get_key.return_value = False # cooldown disabled
4140
self.s.clear_bed()
4241
self.s._printer.select_file.assert_called_with(
4342
"ContinuousPrint/cp_bed_clearing_script.gcode",

0 commit comments

Comments
 (0)