Add custom types for position (#15204)

This commit is contained in:
Scott Lahteine
2019-09-29 04:25:39 -05:00
committed by GitHub
parent 43d6e9fa43
commit 50e4545255
227 changed files with 3147 additions and 3264 deletions

View File

@ -48,8 +48,8 @@
#if ENABLED(ADVANCED_PAUSE_FEATURE)
do_pause_e_move(length, fr_mm_s);
#else
current_position[E_AXIS] += length / planner.e_factor[active_extruder];
planner.buffer_line(current_position, fr_mm_s, active_extruder);
current_position.e += length / planner.e_factor[active_extruder];
line_to_current_position(fr_mm_s);
#endif
}
}
@ -97,10 +97,10 @@ void GcodeSuite::M240() {
if (axis_unhomed_error()) return;
const float old_pos[XYZ] = {
current_position[X_AXIS] + parser.linearval('A'),
current_position[Y_AXIS] + parser.linearval('B'),
current_position[Z_AXIS]
const xyz_pos_t old_pos = {
current_position.x + parser.linearval('A'),
current_position.y + parser.linearval('B'),
current_position.z
};
#ifdef PHOTO_RETRACT_MM
@ -121,22 +121,22 @@ void GcodeSuite::M240() {
feedRate_t fr_mm_s = MMM_TO_MMS(parser.linearval('F'));
if (fr_mm_s) NOLESS(fr_mm_s, 10.0f);
constexpr float photo_position[XYZ] = PHOTO_POSITION;
float raw[XYZ] = {
parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : photo_position[X_AXIS],
parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : photo_position[Y_AXIS],
(parser.seenval('Z') ? parser.value_linear_units() : photo_position[Z_AXIS]) + current_position[Z_AXIS]
constexpr xyz_pos_t photo_position = PHOTO_POSITION;
xyz_pos_t raw = {
parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : photo_position.x,
parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : photo_position.y,
(parser.seenval('Z') ? parser.value_linear_units() : photo_position.z) + current_position.z
};
apply_motion_limits(raw);
do_blocking_move_to(raw, fr_mm_s);
#ifdef PHOTO_SWITCH_POSITION
constexpr float photo_switch_position[2] = PHOTO_SWITCH_POSITION;
const float sraw[] = {
parser.seenval('I') ? RAW_X_POSITION(parser.value_linear_units()) : photo_switch_position[X_AXIS],
parser.seenval('J') ? RAW_Y_POSITION(parser.value_linear_units()) : photo_switch_position[Y_AXIS]
constexpr xy_pos_t photo_switch_position = PHOTO_SWITCH_POSITION;
const xy_pos_t sraw = {
parser.seenval('I') ? RAW_X_POSITION(parser.value_linear_units()) : photo_switch_position.x,
parser.seenval('J') ? RAW_Y_POSITION(parser.value_linear_units()) : photo_switch_position.y
};
do_blocking_move_to_xy(sraw[X_AXIS], sraw[Y_AXIS], get_homing_bump_feedrate(X_AXIS));
do_blocking_move_to_xy(sraw, get_homing_bump_feedrate(X_AXIS));
#if PHOTO_SWITCH_MS > 0
safe_delay(parser.intval('D', PHOTO_SWITCH_MS));
#endif

View File

@ -58,7 +58,7 @@ void GcodeSuite::M125() {
#endif
);
point_t park_point = NOZZLE_PARK_POINT;
xyz_pos_t park_point = NOZZLE_PARK_POINT;
// Move XY axes to filament change position or given position
if (parser.seenval('X')) park_point.x = RAW_X_POSITION(parser.linearval('X'));
@ -68,8 +68,7 @@ void GcodeSuite::M125() {
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
#if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA)
park_point.x += hotend_offset[X_AXIS][active_extruder];
park_point.y += hotend_offset[Y_AXIS][active_extruder];
park_point += hotend_offset[active_extruder];
#endif
#if ENABLED(SDSUPPORT)

View File

@ -60,7 +60,6 @@
* Default values are used for omitted arguments.
*/
void GcodeSuite::M600() {
point_t park_point = NOZZLE_PARK_POINT;
#if ENABLED(MIXING_EXTRUDER)
const int8_t target_e_stepper = get_target_e_stepper_from_command();
@ -119,6 +118,8 @@ void GcodeSuite::M600() {
#endif
);
xyz_pos_t park_point NOZZLE_PARK_POINT;
// Lift Z axis
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
@ -127,8 +128,7 @@ void GcodeSuite::M600() {
if (parser.seenval('Y')) park_point.y = parser.linearval('Y');
#if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA)
park_point.x += hotend_offset[X_AXIS][active_extruder];
park_point.y += hotend_offset[Y_AXIS][active_extruder];
park_point += hotend_offset[active_extruder];
#endif
#if ENABLED(MMU2_MENUS)

View File

@ -28,7 +28,6 @@
#include "../../../Marlin.h"
#include "../../../module/motion.h"
#include "../../../module/temperature.h"
#include "../../../libs/point_t.h"
#if EXTRUDERS > 1
#include "../../../module/tool_change.h"
@ -57,7 +56,7 @@
* Default values are used for omitted arguments.
*/
void GcodeSuite::M701() {
point_t park_point = NOZZLE_PARK_POINT;
xyz_pos_t park_point = NOZZLE_PARK_POINT;
#if ENABLED(NO_MOTION_BEFORE_HOMING)
// Don't raise Z if the machine isn't homed
@ -97,7 +96,7 @@ void GcodeSuite::M701() {
// Lift Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
// Load filament
#if ENABLED(PRUSA_MMU2)
@ -116,7 +115,7 @@ void GcodeSuite::M701() {
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed
@ -146,7 +145,7 @@ void GcodeSuite::M701() {
* Default values are used for omitted arguments.
*/
void GcodeSuite::M702() {
point_t park_point = NOZZLE_PARK_POINT;
xyz_pos_t park_point = NOZZLE_PARK_POINT;
#if ENABLED(NO_MOTION_BEFORE_HOMING)
// Don't raise Z if the machine isn't homed
@ -196,7 +195,7 @@ void GcodeSuite::M702() {
// Lift Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
// Unload filament
#if ENABLED(PRUSA_MMU2)
@ -226,7 +225,7 @@ void GcodeSuite::M702() {
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed

View File

@ -31,8 +31,8 @@
* M122: Debug TMC drivers
*/
void GcodeSuite::M122() {
bool print_axis[XYZE] = { false, false, false, false },
print_all = true;
xyze_bool_t print_axis = { false, false, false, false };
bool print_all = true;
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) { print_axis[i] = true; print_all = false; }
if (print_all) LOOP_XYZE(i) print_axis[i] = true;
@ -45,12 +45,12 @@ void GcodeSuite::M122() {
#endif
if (parser.seen('V'))
tmc_get_registers(print_axis[X_AXIS], print_axis[Y_AXIS], print_axis[Z_AXIS], print_axis[E_AXIS]);
tmc_get_registers(print_axis.x, print_axis.y, print_axis.z, print_axis.e);
else
tmc_report_all(print_axis[X_AXIS], print_axis[Y_AXIS], print_axis[Z_AXIS], print_axis[E_AXIS]);
tmc_report_all(print_axis.x, print_axis.y, print_axis.z, print_axis.e);
#endif
test_tmc_connection(print_axis[X_AXIS], print_axis[Y_AXIS], print_axis[Z_AXIS], print_axis[E_AXIS]);
test_tmc_connection(print_axis.x, print_axis.y, print_axis.z, print_axis.e);
}
#endif // HAS_TRINAMIC

View File

@ -104,25 +104,25 @@
*/
void GcodeSuite::M912() {
#if M91x_SOME_X
const bool hasX = parser.seen(axis_codes[X_AXIS]);
const bool hasX = parser.seen(axis_codes.x);
#else
constexpr bool hasX = false;
#endif
#if M91x_SOME_Y
const bool hasY = parser.seen(axis_codes[Y_AXIS]);
const bool hasY = parser.seen(axis_codes.y);
#else
constexpr bool hasY = false;
#endif
#if M91x_SOME_Z
const bool hasZ = parser.seen(axis_codes[Z_AXIS]);
const bool hasZ = parser.seen(axis_codes.z);
#else
constexpr bool hasZ = false;
#endif
#if M91x_SOME_E
const bool hasE = parser.seen(axis_codes[E_AXIS]);
const bool hasE = parser.seen(axis_codes.e);
#else
constexpr bool hasE = false;
#endif
@ -130,7 +130,7 @@
const bool hasNone = !hasX && !hasY && !hasZ && !hasE;
#if M91x_SOME_X
const int8_t xval = int8_t(parser.byteval(axis_codes[X_AXIS], 0xFF));
const int8_t xval = int8_t(parser.byteval(axis_codes.x, 0xFF));
#if M91x_USE(X)
if (hasNone || xval == 1 || (hasX && xval < 0)) tmc_clear_otpw(stepperX);
#endif
@ -140,7 +140,7 @@
#endif
#if M91x_SOME_Y
const int8_t yval = int8_t(parser.byteval(axis_codes[Y_AXIS], 0xFF));
const int8_t yval = int8_t(parser.byteval(axis_codes.y, 0xFF));
#if M91x_USE(Y)
if (hasNone || yval == 1 || (hasY && yval < 0)) tmc_clear_otpw(stepperY);
#endif
@ -150,7 +150,7 @@
#endif
#if M91x_SOME_Z
const int8_t zval = int8_t(parser.byteval(axis_codes[Z_AXIS], 0xFF));
const int8_t zval = int8_t(parser.byteval(axis_codes.z, 0xFF));
#if M91x_USE(Z)
if (hasNone || zval == 1 || (hasZ && zval < 0)) tmc_clear_otpw(stepperZ);
#endif
@ -163,7 +163,7 @@
#endif
#if M91x_SOME_E
const int8_t eval = int8_t(parser.byteval(axis_codes[E_AXIS], 0xFF));
const int8_t eval = int8_t(parser.byteval(axis_codes.e, 0xFF));
#if M91x_USE_E(0)
if (hasNone || eval == 0 || (hasE && eval < 0)) tmc_clear_otpw(stepperE0);
#endif