Redundant Part Cooling Fan (#21888)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
ellensp
2021-06-15 11:45:54 +12:00
committed by Scott Lahteine
parent 781257bc64
commit c8898b5ca0
6 changed files with 61 additions and 34 deletions

View File

@ -60,39 +60,40 @@
*/
void GcodeSuite::M106() {
const uint8_t pfan = parser.byteval('P', _ALT_P);
if (pfan >= _CNT_P) return;
#if REDUNDANT_PART_COOLING_FAN
if (pfan == REDUNDANT_PART_COOLING_FAN) return;
#endif
if (pfan < _CNT_P) {
#if ENABLED(EXTRA_FAN_SPEED)
const uint16_t t = parser.intval('T');
if (t > 0) return thermalManager.set_temp_fan_speed(pfan, t);
#endif
#if ENABLED(EXTRA_FAN_SPEED)
const uint16_t t = parser.intval('T');
if (t > 0) return thermalManager.set_temp_fan_speed(pfan, t);
#endif
const uint16_t dspeed = parser.seen_test('A') ? thermalManager.fan_speed[active_extruder] : 255;
const uint16_t dspeed = parser.seen_test('A') ? thermalManager.fan_speed[active_extruder] : 255;
uint16_t speed = dspeed;
uint16_t speed = dspeed;
// Accept 'I' if temperature presets are defined
#if PREHEAT_COUNT
const bool got_preset = parser.seenval('I');
if (got_preset) speed = ui.material_preset[_MIN(parser.value_byte(), PREHEAT_COUNT - 1)].fan_speed;
#else
constexpr bool got_preset = false;
#endif
// Accept 'I' if temperature presets are defined
#if PREHEAT_COUNT
const bool got_preset = parser.seenval('I');
if (got_preset) speed = ui.material_preset[_MIN(parser.value_byte(), PREHEAT_COUNT - 1)].fan_speed;
#else
constexpr bool got_preset = false;
#endif
if (!got_preset && parser.seenval('S'))
speed = parser.value_ushort();
if (!got_preset && parser.seenval('S'))
speed = parser.value_ushort();
TERN_(FOAMCUTTER_XYUV, speed *= 2.55); // Get command in % of max heat
TERN_(FOAMCUTTER_XYUV, speed *= 2.55); // Get command in % of max heat
// Set speed, with constraint
thermalManager.set_fan_speed(pfan, speed);
// Set speed, with constraint
thermalManager.set_fan_speed(pfan, speed);
TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS));
TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS));
if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating
thermalManager.set_fan_speed(1 - pfan, speed);
}
if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating
thermalManager.set_fan_speed(1 - pfan, speed);
}
/**
@ -101,6 +102,9 @@ void GcodeSuite::M106() {
void GcodeSuite::M107() {
const uint8_t pfan = parser.byteval('P', _ALT_P);
if (pfan >= _CNT_P) return;
#if REDUNDANT_PART_COOLING_FAN
if (pfan == REDUNDANT_PART_COOLING_FAN) return;
#endif
thermalManager.set_fan_speed(pfan, 0);