Various Laser / Spindle improvements (#15335)

This commit is contained in:
Ben
2020-04-03 01:31:08 +01:00
committed by GitHub
parent e7e9304819
commit df8b7dfc40
24 changed files with 776 additions and 169 deletions

View File

@ -28,6 +28,12 @@
#include "../../feature/spindle_laser.h"
#include "../../module/stepper.h"
inline cutter_power_t get_s_power() {
return cutter_power_t(
parser.intval('S', cutter.interpret_power(SPEED_POWER_STARTUP))
);
}
/**
* Laser:
*
@ -71,29 +77,52 @@
*/
void GcodeSuite::M3_M4(const bool is_M4) {
#if ENABLED(SPINDLE_FEATURE)
planner.synchronize(); // Wait for movement to complete before changing power
#if ENABLED(LASER_POWER_INLINE)
if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) {
// Laser power in inline mode
cutter.inline_direction(is_M4); // Should always be unused
#if ENABLED(SPINDLE_LASER_PWM)
if (parser.seen('O'))
cutter.inline_ocr_power(parser.value_byte()); // The OCR is a value from 0 to 255 (uint8_t)
else
cutter.inline_power(get_s_power());
#else
cutter.inline_enabled(true);
#endif
return;
}
// Non-inline, standard case
cutter.inline_disable(); // Prevent future blocks re-setting the power
#endif
planner.synchronize(); // Wait for previous movement commands (G0/G0/G2/G3) to complete before changing power
cutter.set_direction(is_M4);
#if ENABLED(SPINDLE_LASER_PWM)
if (parser.seenval('O'))
cutter.set_ocr_power(parser.value_byte()); // The OCR is a value from 0 to 255 (uint8_t)
else
cutter.set_power(parser.intval('S', 255));
cutter.set_power(get_s_power());
#else
cutter.set_enabled(true);
#endif
}
/**
* M5 - Cutter OFF
* M5 - Cutter OFF (when moves are complete)
*/
void GcodeSuite::M5() {
#if ENABLED(SPINDLE_FEATURE)
planner.synchronize();
#if ENABLED(LASER_POWER_INLINE)
if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) {
cutter.inline_enabled(false); // Laser power in inline mode
return;
}
// Non-inline, standard case
cutter.inline_disable(); // Prevent future blocks re-setting the power
#endif
planner.synchronize();
cutter.set_enabled(false);
}

View File

@ -53,6 +53,10 @@ GcodeSuite gcode;
#include "../feature/cancel_object.h"
#endif
#if ENABLED(LASER_MOVE_POWER)
#include "../feature/spindle_laser.h"
#endif
#include "../MarlinCore.h" // for idle()
millis_t GcodeSuite::previous_move_ms;
@ -172,6 +176,18 @@ void GcodeSuite::get_destination_from_command() {
#if BOTH(MIXING_EXTRUDER, DIRECT_MIXING_IN_G1)
M165();
#endif
#if ENABLED(LASER_MOVE_POWER)
// Set the laser power in the planner to configure this move
if (parser.seen('S'))
cutter.inline_power(parser.value_int());
else {
#if ENABLED(LASER_MOVE_G0_OFF)
if (parser.codenum == 0) // G0
cutter.inline_enabled(false);
#endif
}
#endif
}
/**

View File

@ -69,7 +69,7 @@ void GcodeSuite::G0_G1(
#endif
#endif
get_destination_from_command(); // Process X Y Z E F parameters
get_destination_from_command(); // Get X Y Z E F (and set cutter power)
#ifdef G0_FEEDRATE
if (fast_move) {

View File

@ -283,7 +283,7 @@ void GcodeSuite::G2_G3(const bool clockwise) {
relative_mode = true;
#endif
get_destination_from_command();
get_destination_from_command(); // Get X Y Z E F (and set cutter power)
#if ENABLED(SF_ARC_FIX)
relative_mode = relative_mode_backup;