Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CURA-12017] Fix fan-speed got set to (-)NaN #2117

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/GCodePathConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace cura
*/
struct GCodePathConfig
{
static constexpr double FAN_SPEED_DEFAULT = -1.0;

coord_t z_offset{}; //<! vertical offset from 'full' layer height
PrintFeatureType type{}; //!< name of the feature type
coord_t line_width{}; //!< width of the line extruded
Expand All @@ -27,7 +29,6 @@ struct GCodePathConfig
bool is_bridge_path{ false }; //!< whether current config is used when bridging
double fan_speed{ FAN_SPEED_DEFAULT }; //!< fan speed override for this path, value should be within range 0-100 (inclusive) and ignored otherwise
double extrusion_mm3_per_mm{ calculateExtrusion() }; //!< current mm^3 filament moved per mm line traversed
static constexpr double FAN_SPEED_DEFAULT = -1;

[[nodiscard]] constexpr bool operator==(const GCodePathConfig& other) const noexcept = default;
[[nodiscard]] constexpr auto operator<=>(const GCodePathConfig& other) const = default;
Expand Down
2 changes: 1 addition & 1 deletion src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ void ExtruderPlan::processFanSpeedForMinimalLayerTime(Duration minTime, double t

const double total_layer_time = estimates_.getTotalTime() + time_other_extr_plans;
const double layer_time_diff = fan_speed_layer_time_settings_.cool_min_layer_time_fan_speed_max - minTime;
const double fraction_of_slope = std::clamp((total_layer_time - minTime) / layer_time_diff, 0.0, 1.0);
const double fraction_of_slope = (layer_time_diff != 0.0) ? std::clamp((total_layer_time - minTime) / layer_time_diff, 0.0, 1.0) : 1.0;
fan_speed = std::lerp(fan_speed_layer_time_settings_.cool_fan_speed_max, fan_speed, fraction_of_slope);
}

Expand Down
Loading