Skip to content

Commit

Permalink
[CURA-12017] Fix fan-speed got set to (-)NaN (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
HellAholic authored Jul 10, 2024
2 parents cf9ccbf + 9b610fe commit 5d97590
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
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

0 comments on commit 5d97590

Please sign in to comment.