|
|
@ -364,6 +364,11 @@
|
|
|
|
#define LED_WHITE 0, 0, 0, 255
|
|
|
|
#define LED_WHITE 0, 0, 0, 255
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
|
|
|
|
|
|
|
int8_t active_coordinate_system = -1; // machine space
|
|
|
|
|
|
|
|
float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
bool Running = true;
|
|
|
|
bool Running = true;
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t marlin_debug_flags = DEBUG_NONE;
|
|
|
|
uint8_t marlin_debug_flags = DEBUG_NONE;
|
|
|
@ -745,6 +750,7 @@ void stop();
|
|
|
|
|
|
|
|
|
|
|
|
void get_available_commands();
|
|
|
|
void get_available_commands();
|
|
|
|
void process_next_command();
|
|
|
|
void process_next_command();
|
|
|
|
|
|
|
|
void process_parsed_command();
|
|
|
|
void prepare_move_to_destination();
|
|
|
|
void prepare_move_to_destination();
|
|
|
|
|
|
|
|
|
|
|
|
void get_cartesian_from_steppers();
|
|
|
|
void get_cartesian_from_steppers();
|
|
|
@ -3672,6 +3678,73 @@ inline void gcode_G4() {
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CNC_WORKSPACE_PLANES
|
|
|
|
#endif // CNC_WORKSPACE_PLANES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Select a coordinate system and update the current position.
|
|
|
|
|
|
|
|
* System index -1 is used to specify machine-native.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool select_coordinate_system(const int8_t _new) {
|
|
|
|
|
|
|
|
if (active_coordinate_system == _new) return false;
|
|
|
|
|
|
|
|
float old_offset[XYZ] = { 0 }, new_offset[XYZ] = { 0 };
|
|
|
|
|
|
|
|
if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
|
|
|
|
|
|
|
|
COPY(old_offset, coordinate_system[active_coordinate_system]);
|
|
|
|
|
|
|
|
if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1))
|
|
|
|
|
|
|
|
COPY(new_offset, coordinate_system[_new]);
|
|
|
|
|
|
|
|
active_coordinate_system = _new;
|
|
|
|
|
|
|
|
bool didXYZ = false;
|
|
|
|
|
|
|
|
LOOP_XYZ(i) {
|
|
|
|
|
|
|
|
const float diff = new_offset[i] - old_offset[i];
|
|
|
|
|
|
|
|
if (diff) {
|
|
|
|
|
|
|
|
position_shift[i] += diff;
|
|
|
|
|
|
|
|
update_software_endstops((AxisEnum)i);
|
|
|
|
|
|
|
|
didXYZ = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (didXYZ) SYNC_PLAN_POSITION_KINEMATIC();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* In CNC G-code G53 is like a modifier
|
|
|
|
|
|
|
|
* It precedes a movement command (or other modifiers) on the same line.
|
|
|
|
|
|
|
|
* This is the first command to use parser.chain() to make this possible.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline void gcode_G53() {
|
|
|
|
|
|
|
|
// If this command has more following...
|
|
|
|
|
|
|
|
if (parser.chain()) {
|
|
|
|
|
|
|
|
const int8_t _system = active_coordinate_system;
|
|
|
|
|
|
|
|
active_coordinate_system = -1;
|
|
|
|
|
|
|
|
process_parsed_command();
|
|
|
|
|
|
|
|
active_coordinate_system = _system;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* G54-G59.3: Select a new workspace
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* A workspace is an XYZ offset to the machine native space.
|
|
|
|
|
|
|
|
* All workspaces default to 0,0,0 at start, or with EEPROM
|
|
|
|
|
|
|
|
* support they may be restored from a previous session.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* G92 is used to set the current workspace's offset.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline void gcode_G54_59(uint8_t subcode=0) {
|
|
|
|
|
|
|
|
const int8_t _space = parser.codenum - 54 + subcode;
|
|
|
|
|
|
|
|
if (select_coordinate_system(_space)) {
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("Select workspace ", _space);
|
|
|
|
|
|
|
|
report_current_position();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCE_INLINE void gcode_G54() { gcode_G54_59(); }
|
|
|
|
|
|
|
|
FORCE_INLINE void gcode_G55() { gcode_G54_59(); }
|
|
|
|
|
|
|
|
FORCE_INLINE void gcode_G56() { gcode_G54_59(); }
|
|
|
|
|
|
|
|
FORCE_INLINE void gcode_G57() { gcode_G54_59(); }
|
|
|
|
|
|
|
|
FORCE_INLINE void gcode_G58() { gcode_G54_59(); }
|
|
|
|
|
|
|
|
FORCE_INLINE void gcode_G59() { gcode_G54_59(parser.subcode); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(INCH_MODE_SUPPORT)
|
|
|
|
#if ENABLED(INCH_MODE_SUPPORT)
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* G20: Set input mode to inches
|
|
|
|
* G20: Set input mode to inches
|
|
|
@ -4153,13 +4226,12 @@ inline void gcode_G28(const bool always_home_all) {
|
|
|
|
|
|
|
|
|
|
|
|
// Restore the active tool after homing
|
|
|
|
// Restore the active tool after homing
|
|
|
|
#if HOTENDS > 1
|
|
|
|
#if HOTENDS > 1
|
|
|
|
tool_change(old_tool_index, 0,
|
|
|
|
#if ENABLED(PARKING_EXTRUDER)
|
|
|
|
#if ENABLED(PARKING_EXTRUDER)
|
|
|
|
#define NO_FETCH false // fetch the previous toolhead
|
|
|
|
false // fetch the previous toolhead
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define NO_FETCH true
|
|
|
|
true
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
tool_change(old_tool_index, 0, NO_FETCH);
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
lcd_refresh();
|
|
|
|
lcd_refresh();
|
|
|
@ -5498,16 +5570,18 @@ void home_all_axes() { gcode_G28(true); }
|
|
|
|
dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
|
|
|
|
dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
|
|
|
|
LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
|
|
|
|
|
|
|
|
|
|
|
|
if (!_0p_calibration) {
|
|
|
|
if (!_0p_calibration) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
|
|
|
|
if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
|
|
|
|
#if ENABLED(PROBE_MANUALLY)
|
|
|
|
z_at_pt[CEN] +=
|
|
|
|
z_at_pt[CEN] += lcd_probe_pt(0, 0);
|
|
|
|
#if ENABLED(PROBE_MANUALLY)
|
|
|
|
#else
|
|
|
|
lcd_probe_pt(0, 0)
|
|
|
|
z_at_pt[CEN] += probe_pt(dx, dy, stow_after_each, 1, false);
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
probe_pt(dx, dy, stow_after_each, 1, false)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_7p_calibration) { // probe extra center points
|
|
|
|
if (_7p_calibration) { // probe extra center points
|
|
|
@ -5516,11 +5590,13 @@ void home_all_axes() { gcode_G28(true); }
|
|
|
|
I_LOOP_CAL_PT(axis, start, steps) {
|
|
|
|
I_LOOP_CAL_PT(axis, start, steps) {
|
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (axis - 1)),
|
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (axis - 1)),
|
|
|
|
r = delta_calibration_radius * 0.1;
|
|
|
|
r = delta_calibration_radius * 0.1;
|
|
|
|
#if ENABLED(PROBE_MANUALLY)
|
|
|
|
z_at_pt[CEN] +=
|
|
|
|
z_at_pt[CEN] += lcd_probe_pt(cos(a) * r, sin(a) * r);
|
|
|
|
#if ENABLED(PROBE_MANUALLY)
|
|
|
|
#else
|
|
|
|
lcd_probe_pt(cos(a) * r, sin(a) * r)
|
|
|
|
z_at_pt[CEN] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z_at_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
|
|
|
|
z_at_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -5543,29 +5619,22 @@ void home_all_axes() { gcode_G28(true); }
|
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (axis - 1)),
|
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (axis - 1)),
|
|
|
|
r = delta_calibration_radius * (1 + 0.1 * (zig_zag ? circle : - circle)),
|
|
|
|
r = delta_calibration_radius * (1 + 0.1 * (zig_zag ? circle : - circle)),
|
|
|
|
interpol = fmod(axis, 1);
|
|
|
|
interpol = fmod(axis, 1);
|
|
|
|
#if ENABLED(PROBE_MANUALLY)
|
|
|
|
const float z_temp =
|
|
|
|
float z_temp = lcd_probe_pt(cos(a) * r, sin(a) * r);
|
|
|
|
#if ENABLED(PROBE_MANUALLY)
|
|
|
|
#else
|
|
|
|
lcd_probe_pt(cos(a) * r, sin(a) * r)
|
|
|
|
float z_temp = probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
;
|
|
|
|
// split probe point to neighbouring calibration points
|
|
|
|
// split probe point to neighbouring calibration points
|
|
|
|
z_at_pt[round(axis - interpol + NPP - 1) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
|
|
|
z_at_pt[uint8_t(round(axis - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
|
|
|
z_at_pt[round(axis - interpol) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
|
|
|
z_at_pt[uint8_t(round(axis - interpol )) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zig_zag = !zig_zag;
|
|
|
|
zig_zag = !zig_zag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_7p_intermed_points)
|
|
|
|
if (_7p_intermed_points)
|
|
|
|
LOOP_CAL_RAD(axis) {
|
|
|
|
LOOP_CAL_RAD(axis)
|
|
|
|
/*
|
|
|
|
|
|
|
|
// average intermediate points to towers and opposites - only required with _7P_STEP >= 2
|
|
|
|
|
|
|
|
for (int8_t i = 1; i < _7P_STEP; i++) {
|
|
|
|
|
|
|
|
const float interpol = i * (1.0 / _7P_STEP);
|
|
|
|
|
|
|
|
z_at_pt[axis] += (z_at_pt[(axis + NPP - i - 1) % NPP + 1]
|
|
|
|
|
|
|
|
+ z_at_pt[axis + i]) * sq(cos(RADIANS(interpol * 90)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
z_at_pt[axis] /= _7P_STEP / steps;
|
|
|
|
z_at_pt[axis] /= _7P_STEP / steps;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -6204,7 +6273,30 @@ inline void gcode_G92() {
|
|
|
|
|
|
|
|
|
|
|
|
if (!didE) stepper.synchronize();
|
|
|
|
if (!didE) stepper.synchronize();
|
|
|
|
|
|
|
|
|
|
|
|
LOOP_XYZE(i) {
|
|
|
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
|
|
|
|
|
|
|
switch (parser.subcode) {
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
// Zero the G92 values and restore current position
|
|
|
|
|
|
|
|
#if !IS_SCARA
|
|
|
|
|
|
|
|
LOOP_XYZ(i) {
|
|
|
|
|
|
|
|
const float v = position_shift[i];
|
|
|
|
|
|
|
|
if (v) {
|
|
|
|
|
|
|
|
position_shift[i] = 0;
|
|
|
|
|
|
|
|
update_software_endstops((AxisEnum)i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // Not SCARA
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
|
|
|
|
|
|
|
#define IS_G92_0 (parser.subcode == 0)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define IS_G92_0 true
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IS_G92_0) LOOP_XYZE(i) {
|
|
|
|
if (parser.seenval(axis_codes[i])) {
|
|
|
|
if (parser.seenval(axis_codes[i])) {
|
|
|
|
#if IS_SCARA
|
|
|
|
#if IS_SCARA
|
|
|
|
if (i != E_AXIS) didXYZ = true;
|
|
|
|
if (i != E_AXIS) didXYZ = true;
|
|
|
@ -6219,16 +6311,18 @@ inline void gcode_G92() {
|
|
|
|
#if HAS_POSITION_SHIFT
|
|
|
|
#if HAS_POSITION_SHIFT
|
|
|
|
position_shift[i] += v - p; // Offset the coordinate space
|
|
|
|
position_shift[i] += v - p; // Offset the coordinate space
|
|
|
|
update_software_endstops((AxisEnum)i);
|
|
|
|
update_software_endstops((AxisEnum)i);
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
|
|
|
|
|
|
|
I2CPEM.encoders[I2CPEM.idx_from_axis((AxisEnum)i)].set_axis_offset(position_shift[i]);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
|
|
|
|
|
|
|
// Apply workspace offset to the active coordinate system
|
|
|
|
|
|
|
|
if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
|
|
|
|
|
|
|
|
COPY(coordinate_system[active_coordinate_system], position_shift);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (didXYZ)
|
|
|
|
if (didXYZ)
|
|
|
|
SYNC_PLAN_POSITION_KINEMATIC();
|
|
|
|
SYNC_PLAN_POSITION_KINEMATIC();
|
|
|
|
else if (didE)
|
|
|
|
else if (didE)
|
|
|
@ -10713,7 +10807,7 @@ inline void invalid_extruder_error(const uint8_t e) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE void fanmux_init(void){
|
|
|
|
FORCE_INLINE void fanmux_init(void) {
|
|
|
|
SET_OUTPUT(FANMUX0_PIN);
|
|
|
|
SET_OUTPUT(FANMUX0_PIN);
|
|
|
|
#if PIN_EXISTS(FANMUX1)
|
|
|
|
#if PIN_EXISTS(FANMUX1)
|
|
|
|
SET_OUTPUT(FANMUX1_PIN);
|
|
|
|
SET_OUTPUT(FANMUX1_PIN);
|
|
|
@ -11202,26 +11296,11 @@ inline void gcode_T(const uint8_t tmp_extruder) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Process a single command and dispatch it to its handler
|
|
|
|
* Process the parsed command and dispatch it to its handler
|
|
|
|
* This is called from the main loop()
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void process_next_command() {
|
|
|
|
void process_parsed_command() {
|
|
|
|
char * const current_command = command_queue[cmd_queue_index_r];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(ECHO)) {
|
|
|
|
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
|
|
|
|
SERIAL_ECHOLN(current_command);
|
|
|
|
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
|
|
|
|
|
|
|
SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
|
|
|
|
|
|
|
|
M100_dump_routine(" Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
|
|
|
|
|
|
|
|
|
// Parse the next command in the queue
|
|
|
|
|
|
|
|
parser.parse(current_command);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle a known G, M, or T
|
|
|
|
// Handle a known G, M, or T
|
|
|
|
switch (parser.command_letter) {
|
|
|
|
switch (parser.command_letter) {
|
|
|
|
case 'G': switch (parser.codenum) {
|
|
|
|
case 'G': switch (parser.codenum) {
|
|
|
@ -12061,6 +12140,23 @@ void process_next_command() {
|
|
|
|
ok_to_send();
|
|
|
|
ok_to_send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void process_next_command() {
|
|
|
|
|
|
|
|
char * const current_command = command_queue[cmd_queue_index_r];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(ECHO)) {
|
|
|
|
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
|
|
|
|
SERIAL_ECHOLN(current_command);
|
|
|
|
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
|
|
|
|
|
|
|
SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
|
|
|
|
|
|
|
|
M100_dump_routine(" Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Parse the next command in the queue
|
|
|
|
|
|
|
|
parser.parse(current_command);
|
|
|
|
|
|
|
|
process_parsed_command();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Send a "Resend: nnn" message to the host to
|
|
|
|
* Send a "Resend: nnn" message to the host to
|
|
|
|
* indicate that a command needs to be re-sent.
|
|
|
|
* indicate that a command needs to be re-sent.
|
|
|
|