Initial commit. Unusable Marlin 2.0.5.3 core without any custimization.
This commit is contained in:
53
Marlin/src/gcode/geometry/G17-G19.cpp
Executable file
53
Marlin/src/gcode/geometry/G17-G19.cpp
Executable file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(CNC_WORKSPACE_PLANES)
|
||||
|
||||
#include "../gcode.h"
|
||||
|
||||
inline void report_workspace_plane() {
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPGM("Workspace Plane ");
|
||||
serialprintPGM(
|
||||
gcode.workspace_plane == GcodeSuite::PLANE_YZ ? PSTR("YZ\n")
|
||||
: gcode.workspace_plane == GcodeSuite::PLANE_ZX ? PSTR("ZX\n")
|
||||
: PSTR("XY\n")
|
||||
);
|
||||
}
|
||||
|
||||
inline void set_workspace_plane(const GcodeSuite::WorkspacePlane plane) {
|
||||
gcode.workspace_plane = plane;
|
||||
if (DEBUGGING(INFO)) report_workspace_plane();
|
||||
}
|
||||
|
||||
/**
|
||||
* G17: Select Plane XY
|
||||
* G18: Select Plane ZX
|
||||
* G19: Select Plane YZ
|
||||
*/
|
||||
void GcodeSuite::G17() { set_workspace_plane(PLANE_XY); }
|
||||
void GcodeSuite::G18() { set_workspace_plane(PLANE_ZX); }
|
||||
void GcodeSuite::G19() { set_workspace_plane(PLANE_YZ); }
|
||||
|
||||
#endif // CNC_WORKSPACE_PLANES
|
101
Marlin/src/gcode/geometry/G53-G59.cpp
Executable file
101
Marlin/src/gcode/geometry/G53-G59.cpp
Executable file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../module/motion.h"
|
||||
|
||||
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
||||
|
||||
#include "../../module/stepper.h"
|
||||
|
||||
//#define DEBUG_M53
|
||||
|
||||
/**
|
||||
* Select a coordinate system and update the workspace offset.
|
||||
* System index -1 is used to specify machine-native.
|
||||
*/
|
||||
bool GcodeSuite::select_coordinate_system(const int8_t _new) {
|
||||
if (active_coordinate_system == _new) return false;
|
||||
active_coordinate_system = _new;
|
||||
xyz_float_t new_offset{0};
|
||||
if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1))
|
||||
new_offset = coordinate_system[_new];
|
||||
LOOP_XYZ(i) {
|
||||
if (position_shift[i] != new_offset[i]) {
|
||||
position_shift[i] = new_offset[i];
|
||||
update_workspace_offset((AxisEnum)i);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* G53: Apply native workspace to the current move
|
||||
*
|
||||
* In CNC G-code G53 is 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.
|
||||
*
|
||||
* Marlin also uses G53 on a line by itself to go back to native space.
|
||||
*/
|
||||
void GcodeSuite::G53() {
|
||||
const int8_t old_system = active_coordinate_system;
|
||||
select_coordinate_system(-1); // Always remove workspace offsets
|
||||
#ifdef DEBUG_M53
|
||||
SERIAL_ECHOLNPGM("Go to native space");
|
||||
report_current_position();
|
||||
#endif
|
||||
|
||||
if (parser.chain()) { // Command to chain?
|
||||
process_parsed_command(); // ...process the chained command
|
||||
select_coordinate_system(old_system);
|
||||
#ifdef DEBUG_M53
|
||||
SERIAL_ECHOLNPAIR("Go back to workspace ", old_system);
|
||||
report_current_position();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void G54_59(uint8_t subcode=0) {
|
||||
const int8_t _space = parser.codenum - 54 + subcode;
|
||||
if (gcode.select_coordinate_system(_space)) {
|
||||
SERIAL_ECHOLNPAIR("Select workspace ", _space);
|
||||
report_current_position();
|
||||
}
|
||||
}
|
||||
void GcodeSuite::G54() { G54_59(); }
|
||||
void GcodeSuite::G55() { G54_59(); }
|
||||
void GcodeSuite::G56() { G54_59(); }
|
||||
void GcodeSuite::G57() { G54_59(); }
|
||||
void GcodeSuite::G58() { G54_59(); }
|
||||
void GcodeSuite::G59() { G54_59(parser.subcode); }
|
||||
|
||||
#endif // CNC_COORDINATE_SYSTEMS
|
103
Marlin/src/gcode/geometry/G92.cpp
Executable file
103
Marlin/src/gcode/geometry/G92.cpp
Executable file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../module/motion.h"
|
||||
#include "../../module/stepper.h"
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
#include "../../feature/encoder_i2c.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* G92: Set current position to given X Y Z E
|
||||
*/
|
||||
void GcodeSuite::G92() {
|
||||
|
||||
bool sync_E = false, sync_XYZ = false;
|
||||
|
||||
#if ENABLED(USE_GCODE_SUBCODES)
|
||||
const uint8_t subcode_G92 = parser.subcode;
|
||||
#else
|
||||
constexpr uint8_t subcode_G92 = 0;
|
||||
#endif
|
||||
|
||||
switch (subcode_G92) {
|
||||
default: break;
|
||||
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
||||
case 1: {
|
||||
// Zero the G92 values and restore current position
|
||||
#if !IS_SCARA
|
||||
LOOP_XYZ(i) if (position_shift[i]) {
|
||||
position_shift[i] = 0;
|
||||
update_workspace_offset((AxisEnum)i);
|
||||
}
|
||||
#endif // Not SCARA
|
||||
} return;
|
||||
#endif
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
case 9: {
|
||||
LOOP_XYZE(i) {
|
||||
if (parser.seenval(axis_codes[i])) {
|
||||
current_position[i] = parser.value_axis_units((AxisEnum)i);
|
||||
if (i == E_AXIS) sync_E = true; else sync_XYZ = true;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
case 0: {
|
||||
LOOP_XYZE(i) {
|
||||
if (parser.seenval(axis_codes[i])) {
|
||||
const float l = parser.value_axis_units((AxisEnum)i),
|
||||
v = i == E_AXIS ? l : LOGICAL_TO_NATIVE(l, i),
|
||||
d = v - current_position[i];
|
||||
if (!NEAR_ZERO(d)) {
|
||||
#if IS_SCARA || !HAS_POSITION_SHIFT
|
||||
if (i == E_AXIS) sync_E = true; else sync_XYZ = true;
|
||||
current_position[i] = v; // Without workspaces revert to Marlin 1.0 behavior
|
||||
#elif HAS_POSITION_SHIFT
|
||||
if (i == E_AXIS) {
|
||||
sync_E = true;
|
||||
current_position.e = v; // When using coordinate spaces, only E is set directly
|
||||
}
|
||||
else {
|
||||
position_shift[i] += d; // Other axes simply offset the coordinate space
|
||||
update_workspace_offset((AxisEnum)i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
||||
// Apply workspace offset to the active coordinate system
|
||||
if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
|
||||
coordinate_system[active_coordinate_system] = position_shift;
|
||||
#endif
|
||||
|
||||
if (sync_XYZ) sync_plan_position();
|
||||
else if (sync_E) sync_plan_position_e();
|
||||
|
||||
report_current_position();
|
||||
}
|
86
Marlin/src/gcode/geometry/M206_M428.cpp
Executable file
86
Marlin/src/gcode/geometry/M206_M428.cpp
Executable file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_M206_COMMAND
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../module/motion.h"
|
||||
#include "../../lcd/ultralcd.h"
|
||||
#include "../../libs/buzzer.h"
|
||||
|
||||
/**
|
||||
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
|
||||
*
|
||||
* *** @thinkyhead: I recommend deprecating M206 for SCARA in favor of M665.
|
||||
* *** M206 for SCARA will remain enabled in 1.1.x for compatibility.
|
||||
* *** In the 2.0 release, it will simply be disabled by default.
|
||||
*/
|
||||
void GcodeSuite::M206() {
|
||||
LOOP_XYZ(i)
|
||||
if (parser.seen(XYZ_CHAR(i)))
|
||||
set_home_offset((AxisEnum)i, parser.value_linear_units());
|
||||
|
||||
#if ENABLED(MORGAN_SCARA)
|
||||
if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta
|
||||
if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi
|
||||
#endif
|
||||
|
||||
report_current_position();
|
||||
}
|
||||
|
||||
/**
|
||||
* M428: Set home_offset based on the distance between the
|
||||
* current_position and the nearest "reference point."
|
||||
* If an axis is past center its endstop position
|
||||
* is the reference-point. Otherwise it uses 0. This allows
|
||||
* the Z offset to be set near the bed when using a max endstop.
|
||||
*
|
||||
* M428 can't be used more than 2cm away from 0 or an endstop.
|
||||
*
|
||||
* Use M206 to set these values directly.
|
||||
*/
|
||||
void GcodeSuite::M428() {
|
||||
if (axis_unhomed_error()) return;
|
||||
|
||||
xyz_float_t diff;
|
||||
LOOP_XYZ(i) {
|
||||
diff[i] = base_home_pos((AxisEnum)i) - current_position[i];
|
||||
if (!WITHIN(diff[i], -20, 20) && home_dir((AxisEnum)i) > 0)
|
||||
diff[i] = -current_position[i];
|
||||
if (!WITHIN(diff[i], -20, 20)) {
|
||||
SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR);
|
||||
LCD_ALERTMESSAGEPGM_P(PSTR("Err: Too far!"));
|
||||
BUZZ(200, 40);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LOOP_XYZ(i) set_home_offset((AxisEnum)i, diff[i]);
|
||||
report_current_position();
|
||||
LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
|
||||
BUZZ(100, 659);
|
||||
BUZZ(100, 698);
|
||||
}
|
||||
|
||||
#endif // HAS_M206_COMMAND
|
Reference in New Issue
Block a user