Browse Source

Fix M106 with SINGLENOZZLE

pull/1/head
InsanityAutomation 6 years ago
committed by Scott Lahteine
parent
commit
4f2473053c
  1. 44
      Marlin/src/gcode/temperature/M106_M107.cpp

44
Marlin/src/gcode/temperature/M106_M107.cpp

@ -25,10 +25,11 @@
#if FAN_COUNT > 0
#include "../gcode.h"
#include "../../Marlin.h" // for fan_speed — should move those to Planner
#include "../../Marlin.h" // for fan_speed
#include "../../module/motion.h"
#if ENABLED(SINGLENOZZLE)
#include "../../module/motion.h"
#include "../../module/tool_change.h"
#endif
@ -46,36 +47,42 @@
* 3-255 = Set the speed for use with T2
*/
void GcodeSuite::M106() {
const uint8_t p = parser.byteval('P');
const uint16_t s = parser.ushortval('S', 255);
const uint8_t p = parser.byteval('P', active_extruder);
#if ENABLED(SINGLENOZZLE)
if (p != active_extruder) {
if (p < EXTRUDERS) singlenozzle_fan_speed[p] = MIN(s, 255U);
return;
}
#endif
if (p < MIN(EXTRUDERS, FAN_COUNT)) {
uint16_t s = parser.ushortval('S', 255);
NOMORE(s, 255);
uint8_t np = p;
#if ENABLED(SINGLENOZZLE)
if (p != active_extruder) {
if (p < EXTRUDERS) singlenozzle_fan_speed[p] = s;
return;
}
np = 0; // Always use fan index 0 with SINGLENOZZLE
#endif
if (p < FAN_COUNT) {
#if ENABLED(EXTRA_FAN_SPEED)
const int16_t t = parser.intval('T');
if (t > 0) {
switch (t) {
case 1:
fan_speed[p] = old_fan_speed[p];
fan_speed[np] = old_fan_speed[np];
break;
case 2:
old_fan_speed[p] = fan_speed[p];
fan_speed[p] = new_fan_speed[p];
old_fan_speed[np] = fan_speed[np];
fan_speed[np] = new_fan_speed[np];
break;
default:
new_fan_speed[p] = MIN(t, 255U);
new_fan_speed[np] = MIN(t, 255U);
break;
}
return;
}
#endif // EXTRA_FAN_SPEED
fan_speed[p] = MIN(s, 255U);
fan_speed[np] = s;
}
}
@ -83,7 +90,8 @@ void GcodeSuite::M106() {
* M107: Fan Off
*/
void GcodeSuite::M107() {
const uint16_t p = parser.ushortval('P');
const uint16_t p = parser.byteval('P', active_extruder);
#if ENABLED(SINGLENOZZLE)
if (p != active_extruder) {
if (p < EXTRUDERS) singlenozzle_fan_speed[p] = 0;
@ -91,7 +99,7 @@ void GcodeSuite::M107() {
}
#endif
if (p < FAN_COUNT) fan_speed[p] = 0;
if (p < MIN(EXTRUDERS, FAN_COUNT)) fan_speed[p] = 0;
}
#endif // FAN_COUNT > 0

Loading…
Cancel
Save