mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-13 19:25:54 +08:00
Implement option from old Slic3r mainline to permit printer firmware to define their fan speeds from 0-100 instead of 0-255.
This commit is contained in:
parent
68ea889207
commit
b0492858f5
@ -227,6 +227,7 @@ std::string GCodeWriter::set_fan(const unsigned int speed, bool dont_save, uint1
|
||||
if (tool != nullptr)
|
||||
fan_speed += int8_t(tool->fan_offset());
|
||||
fan_speed = std::max(int16_t(0), std::min(int16_t(100), fan_speed));
|
||||
const auto fan_baseline = (this->config.fan_percentage.value ? 100.0 : 255.0);
|
||||
|
||||
// fan_speed has an effective minimum value of 0, so this cast is safe.
|
||||
//test if it's useful to write it
|
||||
@ -258,7 +259,7 @@ std::string GCodeWriter::set_fan(const unsigned int speed, bool dont_save, uint1
|
||||
} else {
|
||||
gcode << "S";
|
||||
}
|
||||
gcode << (255.0 * fan_speed / 100.0);
|
||||
gcode << (fan_baseline * (fan_speed / 100.0));
|
||||
}
|
||||
if (this->config.gcode_comments) gcode << " ; enable fan";
|
||||
gcode << "\n";
|
||||
|
@ -2528,6 +2528,14 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionInts{ 35 });
|
||||
|
||||
def = this->add("fan_percentage", coBool);
|
||||
def->label = _("Fan PWM from 0-100");
|
||||
def->category = OptionCategory::output;
|
||||
def->tooltip = _("Set this if your printer uses control values from 0-100 instead of 0-255.");
|
||||
def->cli = "fan-percentage";
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("min_layer_height", coFloats);
|
||||
def->label = L("Min");
|
||||
def->full_label = ("Min layer height");
|
||||
|
@ -1011,6 +1011,7 @@ public:
|
||||
ConfigOptionFloats extruder_temperature_offset;
|
||||
ConfigOptionString extrusion_axis;
|
||||
ConfigOptionFloats extrusion_multiplier;
|
||||
ConfigOptionBool fan_percentage;
|
||||
ConfigOptionFloat fan_kickstart;
|
||||
ConfigOptionBool fan_speedup_overhangs;
|
||||
ConfigOptionFloat fan_speedup_time;
|
||||
@ -1121,6 +1122,7 @@ protected:
|
||||
OPT_PTR(extruder_temperature_offset);
|
||||
OPT_PTR(extrusion_axis);
|
||||
OPT_PTR(extrusion_multiplier);
|
||||
OPT_PTR(fan_percentage);
|
||||
OPT_PTR(fan_kickstart);
|
||||
OPT_PTR(fan_speedup_overhangs);
|
||||
OPT_PTR(fan_speedup_time);
|
||||
|
Loading…
x
Reference in New Issue
Block a user