Commit de5a95e
authored
Fix Z-Offset Calibration (#206)
# Description
- [ ] Feature
- [x] Bug fix
- [x] Code refactor
- [ ] Documentation
Summary of changes to the probe calibration flow (`probeHelperPage.py`,
`babystepPage.py`, `printTab.py`, `controlTab.py`, `mainWindow.py`,
`moonrakerComm.py`).
- Replace 3 boolean calibration flags with a `_CalibPhase` enum with 6
states
- Extract `_cancel_calibration()`, `_reset_calibration_state()`,
`_restore_ui()`, `_show_option_cards()` helpers
- Fix double `CLEAN_NOZZLE` execution: `Z_ENDSTOP_CALIBRATE` already
calls it internally
- Fix `EDDY_PHASE1_RESTART` phase: prevents post-restart subscription
updates from overwriting the paper-test loading message
- Fix `on_extruder_update` / `on_gcode_move_update` guards: use
`_calib_phase` instead of `helper_initialize` (was cleared prematurely
by 300ms manual_probe query)
- Fix heating message stuck after emergency stop:
`notify_klippy_shutdown` now triggers `evaluate_klippy_status()` in
`moonrakerComm.py`; `on_klippy_status("shutdown")` calls
`_cancel_calibration()`
- Add `lock_ui` signal: disables all tabs except `controlTab` and header
during calibration; re-asserted when probe session becomes active
- Fix `-0.000` display in `probeHelperPage` and `babystepPage` using
`round(x, 3) or 0.0`
- Fix save z-offset button showing for `-0.000` in `printTab`
- `babystepPage`: move buttons start disabled, enabled only when
`print_stats.state == "printing"`
- Inline `_DISCONNECT_MSG`/`_READY_MSG` module-level dicts into
`match/case` in `on_klippy_status`
# Motivation
The calibration flow had accumulated several interacting boolean flags
that made state transitions brittle and hard to reason about. The
`_CalibPhase` enum makes the state machine explicit and eliminates
entire categories of bugs (premature flag clears, wrong phase handling
on reconnect, no reset on emergency stop). The UI lock prevents
navigating away mid-calibration. The `-0.000` fixes prevent confusing
display values at the zero crossing.
# Future work
- Add unit tests covering the `_CalibPhase` state machine transitions1 parent 14c4407 commit de5a95e
6 files changed
Lines changed: 517 additions & 474 deletions
File tree
- BlocksScreen/lib
- panels
- widgets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
285 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| 88 | + | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
| |||
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| 121 | + | |
115 | 122 | | |
116 | 123 | | |
117 | 124 | | |
| |||
145 | 152 | | |
146 | 153 | | |
147 | 154 | | |
| 155 | + | |
148 | 156 | | |
149 | 157 | | |
150 | 158 | | |
| |||
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
217 | 228 | | |
| 229 | + | |
218 | 230 | | |
219 | 231 | | |
220 | 232 | | |
| |||
432 | 444 | | |
433 | 445 | | |
434 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
435 | 465 | | |
436 | 466 | | |
437 | 467 | | |
| |||
709 | 739 | | |
710 | 740 | | |
711 | 741 | | |
712 | | - | |
713 | | - | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
714 | 752 | | |
715 | | - | |
| 753 | + | |
716 | 754 | | |
717 | 755 | | |
718 | 756 | | |
| |||
721 | 759 | | |
722 | 760 | | |
723 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
724 | 767 | | |
725 | 768 | | |
726 | 769 | | |
| |||
874 | 917 | | |
875 | 918 | | |
876 | 919 | | |
877 | | - | |
| 920 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| |||
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
| 81 | + | |
78 | 82 | | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
| |||
224 | 229 | | |
225 | 230 | | |
226 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
227 | 235 | | |
228 | 236 | | |
229 | 237 | | |
| |||
268 | 276 | | |
269 | 277 | | |
270 | 278 | | |
| 279 | + | |
271 | 280 | | |
272 | 281 | | |
273 | 282 | | |
| |||
276 | 285 | | |
277 | 286 | | |
278 | 287 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
283 | 296 | | |
284 | 297 | | |
285 | 298 | | |
| |||
292 | 305 | | |
293 | 306 | | |
294 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
295 | 312 | | |
296 | 313 | | |
297 | 314 | | |
| |||
311 | 328 | | |
312 | 329 | | |
313 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
314 | 335 | | |
315 | 336 | | |
316 | 337 | | |
| |||
334 | 355 | | |
335 | 356 | | |
336 | 357 | | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
| 358 | + | |
341 | 359 | | |
342 | | - | |
| 360 | + | |
343 | 361 | | |
344 | 362 | | |
345 | 363 | | |
| |||
352 | 370 | | |
353 | 371 | | |
354 | 372 | | |
355 | | - | |
| 373 | + | |
356 | 374 | | |
357 | 375 | | |
358 | 376 | | |
359 | 377 | | |
360 | 378 | | |
361 | | - | |
| 379 | + | |
362 | 380 | | |
363 | 381 | | |
364 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
365 | 386 | | |
366 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
367 | 397 | | |
368 | 398 | | |
369 | 399 | | |
370 | | - | |
| 400 | + | |
371 | 401 | | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
| 402 | + | |
| 403 | + | |
377 | 404 | | |
378 | 405 | | |
379 | 406 | | |
| |||
401 | 428 | | |
402 | 429 | | |
403 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
404 | 437 | | |
405 | 438 | | |
406 | 439 | | |
| |||
422 | 455 | | |
423 | 456 | | |
424 | 457 | | |
| 458 | + | |
425 | 459 | | |
426 | 460 | | |
427 | 461 | | |
| |||
442 | 476 | | |
443 | 477 | | |
444 | 478 | | |
| 479 | + | |
445 | 480 | | |
446 | 481 | | |
447 | 482 | | |
| |||
0 commit comments