Skip to content

Fix Z-Offset Calibration#206

Merged
HugoCLSC merged 8 commits intodevfrom
bugfix/calibrate_offset
Apr 14, 2026
Merged

Fix Z-Offset Calibration#206
HugoCLSC merged 8 commits intodevfrom
bugfix/calibrate_offset

Conversation

@gmmcosta15
Copy link
Copy Markdown
Collaborator

@gmmcosta15 gmmcosta15 commented Apr 10, 2026

Description

  • Feature
  • Bug fix
  • 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 transitions

…mergency reset

  - Replace 3 boolean flags with _CalibPhase enum (IDLE,PROBE_ACTIVE,EDDY_PHASE1, EDDY_PHASE1_RESTART,EDDY_PHASE2, SAVE_RESTART)
  - Add _cancel_calibration() helper used by abort/error/shutdown/disconnect
  - Add _show_option_cards() re-enables cards (setEnabled + show) on reset
  - Fix: Z_ENDSTOP_CALIBRATE already calls CLEAN_NOZZLE internally, skip pre-emit to prevent double cleaning
  - Fix: EDDY_PHASE1_RESTART phase suppresses gcode_move messages after Klipper restart so paper-test message is not overwritten
  - Fix: on_extruder_update and on_gcode_move_update gated on _calib_phase instead of helper_initialize (was prematurely cleared by 300ms query)
  - Fix: show "Cleaning nozzle..." only on target temp → 0 transition (prev_temp > 0) to avoid spurious message after Klipper restart
  - Fix: emergency stop now triggers evaluate_klippy_status() via notify_klippy_shutdown in moonrakerComm on_klippy_status("shutdown") calls _cancel_calibration()
  - Add lock_ui signal chain (probeHelperPage → controlTab → mainWindow) locks printTab/filamentTab/utilitiesTab/header during calibration; re-asserted in _toggle_tool_buttons(True) when probe session starts
  - Fix: -0.000 display in probeHelperPage and babystepPage using round(x, 3) or 0.0
  - Fix: save z-offset button never shows -0.000 (round(value[2], 3) != 0)
  - babystepPage: move buttons disabled by default, enabled only when print_stats.state == "printing"
  - Inline _DISCONNECT_MSG/_READY_MSG dicts as match/case in on_klippy_status
@gmmcosta15 gmmcosta15 requested a review from HugoCLSC April 10, 2026 10:23
@gmmcosta15 gmmcosta15 self-assigned this Apr 10, 2026
@gmmcosta15 gmmcosta15 marked this pull request as ready for review April 10, 2026 10:27
@HugoCLSC HugoCLSC merged commit de5a95e into dev Apr 14, 2026
8 checks passed
HugoCLSC added a commit that referenced this pull request Apr 15, 2026
## Description

The current PR, fixes some long standing issues with the GUI,
specifically on babystepping, filament changes during ongoing print
jobs, and probe calibration tools (Eddy, z endstop).


## Changes

- **Feature:** Dynamically retrieve the maximum temperature allowed for
each heater (#199 ) (#205 ).
- **Refactor:** Eddy calibration tool, save babystep value, UI locking
and unlocking on tool. Other fixes (#202 , #206 ).
- **Refactor:** FilamentTab can now be accessed during prints to make
filament changes easier, new progress messages during the load/unload
operations (#207 ).

---------
Signed-off-by: Hugo Costa <hugo.santos.costa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants