Extend M106/M107 for better laser module support (#16082)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
		@@ -28,6 +28,10 @@
 | 
			
		||||
#include "../../module/motion.h"
 | 
			
		||||
#include "../../module/temperature.h"
 | 
			
		||||
 | 
			
		||||
#if ENABLED(LASER_SYNCHRONOUS_M106_M107)
 | 
			
		||||
  #include "../../module/planner.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if PREHEAT_COUNT
 | 
			
		||||
  #include "../../lcd/marlinui.h"
 | 
			
		||||
#endif
 | 
			
		||||
@@ -82,6 +86,8 @@ void GcodeSuite::M106() {
 | 
			
		||||
    // Set speed, with constraint
 | 
			
		||||
    thermalManager.set_fan_speed(pfan, speed);
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
  }
 | 
			
		||||
@@ -92,12 +98,14 @@ void GcodeSuite::M106() {
 | 
			
		||||
 */
 | 
			
		||||
void GcodeSuite::M107() {
 | 
			
		||||
  const uint8_t pfan = parser.byteval('P', _ALT_P);
 | 
			
		||||
  if (pfan < _CNT_P) {
 | 
			
		||||
    thermalManager.set_fan_speed(pfan, 0);
 | 
			
		||||
  if (pfan >= _CNT_P) return;
 | 
			
		||||
 | 
			
		||||
    if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()))  // pfan == 0 when duplicating
 | 
			
		||||
      thermalManager.set_fan_speed(1 - pfan, 0);
 | 
			
		||||
  }
 | 
			
		||||
  thermalManager.set_fan_speed(pfan, 0);
 | 
			
		||||
 | 
			
		||||
  if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()))  // pfan == 0 when duplicating
 | 
			
		||||
    thermalManager.set_fan_speed(1 - pfan, 0);
 | 
			
		||||
 | 
			
		||||
  TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // HAS_FAN
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user