⚡️ Fix and improve Inline Laser Power (#22690)
This commit is contained in:
committed by
Scott Lahteine
parent
5b6c46db29
commit
d965303a7a
@@ -53,7 +53,7 @@ GcodeSuite gcode;
|
||||
#include "../feature/cancel_object.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(LASER_MOVE_POWER)
|
||||
#if ENABLED(LASER_FEATURE)
|
||||
#include "../feature/spindle_laser.h"
|
||||
#endif
|
||||
|
||||
@@ -210,8 +210,11 @@ void GcodeSuite::get_destination_from_command() {
|
||||
recovery.save();
|
||||
#endif
|
||||
|
||||
if (parser.floatval('F') > 0)
|
||||
if (parser.floatval('F') > 0) {
|
||||
feedrate_mm_s = parser.value_feedrate();
|
||||
// Update the cutter feed rate for use by M4 I set inline moves.
|
||||
TERN_(LASER_FEATURE, cutter.feedrate_mm_m = MMS_TO_MMM(feedrate_mm_s));
|
||||
}
|
||||
|
||||
#if BOTH(PRINTCOUNTER, HAS_EXTRUDERS)
|
||||
if (!DEBUGGING(DRYRUN) && !skip_move)
|
||||
@@ -223,15 +226,29 @@ void GcodeSuite::get_destination_from_command() {
|
||||
M165();
|
||||
#endif
|
||||
|
||||
#if ENABLED(LASER_MOVE_POWER)
|
||||
// Set the laser power in the planner to configure this move
|
||||
if (parser.seen('S')) {
|
||||
const float spwr = parser.value_float();
|
||||
cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.power_to_range(cutter_power_t(round(spwr))), spwr > 0 ? 255 : 0));
|
||||
#if ENABLED(LASER_FEATURE)
|
||||
if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) {
|
||||
// Set the cutter power in the planner to configure this move
|
||||
cutter.last_feedrate_mm_m = 0;
|
||||
if (WITHIN(parser.codenum, 1, TERN(ARC_SUPPORT, 3, 1)) || TERN0(BEZIER_CURVE_SUPPORT, parser.codenum == 5)) {
|
||||
planner.laser_inline.status.isPowered = true;
|
||||
if (parser.seen('I')) cutter.set_enabled(true); // This is set for backward LightBurn compatibility.
|
||||
if (parser.seen('S')) {
|
||||
const float v = parser.value_float(),
|
||||
u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v));
|
||||
cutter.menuPower = cutter.unitPower = u;
|
||||
cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0));
|
||||
}
|
||||
}
|
||||
else if (parser.codenum == 0) {
|
||||
// For dynamic mode we need to flag isPowered off, dynamic power is calculated in the stepper based on feedrate.
|
||||
if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) planner.laser_inline.status.isPowered = false;
|
||||
cutter.inline_power(0); // This is planner-based so only set power and do not disable inline control flags.
|
||||
}
|
||||
}
|
||||
else if (ENABLED(LASER_MOVE_G0_OFF) && parser.codenum == 0) // G0
|
||||
cutter.set_inline_enabled(false);
|
||||
#endif
|
||||
else if (parser.codenum == 0)
|
||||
cutter.apply_power(0);
|
||||
#endif // LASER_FEATURE
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user