Skip to content

fix: ironing fan speed not restored after ironing ends - #659

Open
mwz-iot wants to merge 1 commit into
process_optimistic_julyfrom
fix/ironing-fan-speed-reset
Open

fix: ironing fan speed not restored after ironing ends#659
mwz-iot wants to merge 1 commit into
process_optimistic_julyfrom
fix/ironing-fan-speed-reset

Conversation

@mwz-iot

@mwz-iot mwz-iot commented Aug 4, 2026

Copy link
Copy Markdown

Description

This PR fixes an issue where the part-cooling fan speed was not restored after an ironing path finished.

The ironing fan speed is a temporary override that should only apply while printing ironing paths. After leaving ironing, the fan should return to the speed calculated by the existing cooling logic.

Before this fix:

Normal path: 100%
→ Ironing path: 50%
→ Next non-ironing path: 50%

Expected behavior:

Normal path: 100%
→ Ironing path: 50%
→ Next non-ironing path: 100%

Root Cause

CoolingBuffer::apply_layer_cooldown() creates a new fan_speed_change_requests map for each CoolingBuffer processing batch.

The original TYPE_IRONING_FAN_END handler required the current batch to contain both _IRONING_FAN_START and _IRONING_FAN_END.

When ironing was the final extrusion role before a flush boundary, the markers could be split across two batches:

Batch N:
_IRONING_FAN_START
Ironing paths
Flush

Batch N+1:
_IRONING_FAN_END
Non-ironing paths

The map was recreated for batch N+1, so the TYPE_IRONING_FAN_START flag was reset to false.

As a result, the END handler was skipped, no restoring M106 command was generated, and subsequent non-ironing paths continued using the ironing fan speed.

Changes

1. Process TYPE_IRONING_FAN_END across batch boundaries

The same-batch START condition was removed from the END handler.

// Before
} else if (
    line->type & CoolingLine::TYPE_IRONING_FAN_END &&
    fan_speed_change_requests[
        CoolingLine::TYPE_IRONING_FAN_START
    ]
) {

// After
} else if (
    line->type & CoolingLine::TYPE_IRONING_FAN_END
) {

A valid _IRONING_FAN_END marker can now restore the fan speed even when its matching START marker was processed in the previous batch.

2. Synchronize the cached current fan speed

The restore branch now updates m_current_fan_speed before emitting the restoring fan command:

m_current_fan_speed = m_fan_speed;
new_gcode += GCodeWriter::set_fan(
    m_config.gcode_flavor,
    m_fan_speed
);

This keeps the internal cached fan state consistent with the fan speed written to G-code.

The restored value is not hard-coded to 100%. It uses m_fan_speed, which is calculated by the existing cooling logic.

Compatibility

This change does not modify:

  • Ironing toolpaths.
  • Extrusion amounts.
  • Toolpath ordering.
  • Normal cooling calculations.
  • Bridge or overhang fan settings.
  • Auxiliary or exhaust fan behavior.

There are no breaking changes or new external dependencies introduced by this PR.

Screenshots/Recordings/Graphs

Before

After an ironing path finished, subsequent non-ironing paths could continue using the ironing fan speed.

Normal: 100%
→ Ironing: 50%
→ Non-ironing: 50%
image

After

The fan speed is restored when leaving ironing, including when START and END are separated by a CoolingBuffer flush boundary.

Normal: 100%
→ Ironing: 50%
→ Non-ironing: 100%
image

Tests

Build

  • Built the libslic3r Release target successfully.
  • Generated libslic3r.lib.
  • Build completed with 0 errors and 0 warnings.

Manual Tests

  • Verified 100% normal → 50% ironing → 100% normal.
  • Verified fan restoration when START and END are separated by a layer/CoolingBuffer batch boundary.
  • Verified 70% normal → 50% ironing → 70% normal.
  • Verified that the restored speed is not hard-coded to 100%.
  • Verified fan restoration when START and END are processed in the same batch.
  • Verified repeated transitions across multiple ironing regions.
  • Disabled ironing and verified that the existing normal cooling behavior remains unchanged.

Root cause: CoolingBuffer::apply_layer_cooldown creates a fresh
fan_speed_change_requests map per batch. When _IRONING_FAN_START
is in batch N and _IRONING_FAN_END lands in batch N+1 (because
ironing was the last extrusion role before a flush boundary), the
END handler was gated on a flag that is always false in the new
batch, so the fan speed was never restored.

Fix 1: Remove the cross-batch gate condition on TYPE_IRONING_FAN_END.
Fix 2: Sync m_current_fan_speed = m_fan_speed in the restore branch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mwz-iot mwz-iot self-assigned this Aug 4, 2026
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.

3 participants