Add custom types for position (#15204)
This commit is contained in:
@ -379,8 +379,8 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
|
||||
#if HAS_LINE_TO_Z
|
||||
|
||||
void line_to_z(const float &z) {
|
||||
current_position[Z_AXIS] = z;
|
||||
planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[Z_AXIS]), active_extruder);
|
||||
current_position.z = z;
|
||||
line_to_current_position(MMM_TO_MMS(manual_feedrate_mm_m.z));
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -402,10 +402,10 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
|
||||
ui.encoderPosition = 0;
|
||||
|
||||
const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
|
||||
new_probe_offset = probe_offset[Z_AXIS] + diff,
|
||||
new_probe_offset = probe_offset.z + diff,
|
||||
new_offs =
|
||||
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
||||
do_probe ? new_probe_offset : hotend_offset[Z_AXIS][active_extruder] - diff
|
||||
do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
|
||||
#else
|
||||
new_probe_offset
|
||||
#endif
|
||||
@ -414,9 +414,9 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
|
||||
|
||||
babystep.add_steps(Z_AXIS, babystep_increment);
|
||||
|
||||
if (do_probe) probe_offset[Z_AXIS] = new_offs;
|
||||
if (do_probe) probe_offset.z = new_offs;
|
||||
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
||||
else hotend_offset[Z_AXIS][active_extruder] = new_offs;
|
||||
else hotend_offset[active_extruder].z = new_offs;
|
||||
#endif
|
||||
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
@ -425,13 +425,13 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
|
||||
if (ui.should_draw()) {
|
||||
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
||||
if (!do_probe)
|
||||
draw_edit_screen(PSTR(MSG_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
|
||||
draw_edit_screen(PSTR(MSG_Z_OFFSET), ftostr43sign(hotend_offset[active_extruder].z));
|
||||
else
|
||||
#endif
|
||||
draw_edit_screen(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(probe_offset[Z_AXIS]));
|
||||
draw_edit_screen(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(probe_offset.z));
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
|
||||
if (do_probe) _lcd_zoffset_overlay_gfx(probe_offset[Z_AXIS]);
|
||||
if (do_probe) _lcd_zoffset_overlay_gfx(probe_offset.z);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ void menu_backlash();
|
||||
|
||||
#include "../../feature/dac/stepper_dac.h"
|
||||
|
||||
uint8_t driverPercent[XYZE];
|
||||
xyze_uint8_t driverPercent;
|
||||
inline void dac_driver_getValues() { LOOP_XYZE(i) driverPercent[i] = dac_current_get_percent((AxisEnum)i); }
|
||||
static void dac_driver_commit() { dac_current_set_percents(driverPercent); }
|
||||
|
||||
@ -552,7 +552,7 @@ void menu_backlash();
|
||||
#if ENABLED(DELTA)
|
||||
EDIT_JERK(C);
|
||||
#else
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1f, 990);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, 990);
|
||||
#endif
|
||||
#if !BOTH(JUNCTION_DEVIATION, LIN_ADVANCE)
|
||||
EDIT_JERK(E);
|
||||
|
@ -58,26 +58,24 @@ static inline void _lcd_goto_next_corner() {
|
||||
line_to_z(LEVEL_CORNERS_Z_HOP);
|
||||
switch (bed_corner) {
|
||||
case 0:
|
||||
current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
|
||||
current_position[Y_AXIS] = Y_MIN_BED + LEVEL_CORNERS_INSET;
|
||||
current_position.set(X_MIN_BED + LEVEL_CORNERS_INSET, Y_MIN_BED + LEVEL_CORNERS_INSET);
|
||||
break;
|
||||
case 1:
|
||||
current_position[X_AXIS] = X_MAX_BED - (LEVEL_CORNERS_INSET);
|
||||
current_position.x = X_MAX_BED - (LEVEL_CORNERS_INSET);
|
||||
break;
|
||||
case 2:
|
||||
current_position[Y_AXIS] = Y_MAX_BED - (LEVEL_CORNERS_INSET);
|
||||
current_position.y = Y_MAX_BED - (LEVEL_CORNERS_INSET);
|
||||
break;
|
||||
case 3:
|
||||
current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
|
||||
current_position.x = X_MIN_BED + LEVEL_CORNERS_INSET;
|
||||
break;
|
||||
#if ENABLED(LEVEL_CENTER_TOO)
|
||||
case 4:
|
||||
current_position[X_AXIS] = X_CENTER;
|
||||
current_position[Y_AXIS] = Y_CENTER;
|
||||
current_position.set(X_CENTER, Y_CENTER);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[X_AXIS]), active_extruder);
|
||||
line_to_current_position(MMM_TO_MMS(manual_feedrate_mm_m.x));
|
||||
line_to_z(LEVEL_CORNERS_HEIGHT);
|
||||
if (++bed_corner > 3
|
||||
#if ENABLED(LEVEL_CENTER_TOO)
|
||||
|
@ -121,7 +121,7 @@
|
||||
// Encoder knob or keypad buttons adjust the Z position
|
||||
//
|
||||
if (ui.encoderPosition) {
|
||||
const float z = current_position[Z_AXIS] + float(int16_t(ui.encoderPosition)) * (MESH_EDIT_Z_STEP);
|
||||
const float z = current_position.z + float(int16_t(ui.encoderPosition)) * (MESH_EDIT_Z_STEP);
|
||||
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
ui.encoderPosition = 0;
|
||||
@ -131,7 +131,7 @@
|
||||
// Draw on first display, then only on Z change
|
||||
//
|
||||
if (ui.should_draw()) {
|
||||
const float v = current_position[Z_AXIS];
|
||||
const float v = current_position.z;
|
||||
draw_edit_screen(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
|
||||
}
|
||||
}
|
||||
@ -279,7 +279,7 @@ void menu_bed_leveling() {
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
||||
#elif HAS_BED_PROBE
|
||||
MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &probe_offset[Z_AXIS], Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
#endif
|
||||
|
||||
#if ENABLED(LEVEL_BED_CORNERS)
|
||||
|
@ -145,12 +145,12 @@ static void lcd_factory_settings() {
|
||||
START_MENU();
|
||||
MENU_BACK(MSG_CONFIGURATION);
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float51, MSG_X_OFFSET, &hotend_offset[X_AXIS][1], float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float51, MSG_X_OFFSET, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets);
|
||||
#else
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52sign, MSG_X_OFFSET, &hotend_offset[X_AXIS][1], -99.0, 99.0, _recalc_offsets);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52sign, MSG_X_OFFSET, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets);
|
||||
#endif
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52sign, MSG_Y_OFFSET, &hotend_offset[Y_AXIS][1], -99.0, 99.0, _recalc_offsets);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52sign, MSG_Z_OFFSET, &hotend_offset[Z_AXIS][1], Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52sign, MSG_Y_OFFSET, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
|
||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52sign, MSG_Z_OFFSET, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
|
||||
#endif
|
||||
@ -347,7 +347,7 @@ void menu_configuration() {
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
||||
#elif HAS_BED_PROBE
|
||||
MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &probe_offset[Z_AXIS], Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
#endif
|
||||
|
||||
const bool busy = printer_busy();
|
||||
|
@ -40,8 +40,8 @@
|
||||
#include "../../lcd/extensible_ui/ui_api.h"
|
||||
#endif
|
||||
|
||||
void _man_probe_pt(const float &rx, const float &ry) {
|
||||
do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
|
||||
void _man_probe_pt(const xy_pos_t &xy) {
|
||||
do_blocking_move_to(xy, Z_CLEARANCE_BETWEEN_PROBES);
|
||||
ui.synchronize();
|
||||
move_menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
|
||||
ui.goto_screen(lcd_move_z);
|
||||
@ -51,8 +51,8 @@ void _man_probe_pt(const float &rx, const float &ry) {
|
||||
|
||||
#include "../../gcode/gcode.h"
|
||||
|
||||
float lcd_probe_pt(const float &rx, const float &ry) {
|
||||
_man_probe_pt(rx, ry);
|
||||
float lcd_probe_pt(const xy_pos_t &xy) {
|
||||
_man_probe_pt(xy);
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
ui.defer_status_screen();
|
||||
wait_for_user = true;
|
||||
@ -64,7 +64,7 @@ void _man_probe_pt(const float &rx, const float &ry) {
|
||||
#endif
|
||||
while (wait_for_user) idle();
|
||||
ui.goto_previous_screen_no_defer();
|
||||
return current_position[Z_AXIS];
|
||||
return current_position.z;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -83,10 +83,14 @@ void _man_probe_pt(const float &rx, const float &ry) {
|
||||
ui.goto_screen(_lcd_calibrate_homing);
|
||||
}
|
||||
|
||||
void _goto_tower_x() { _man_probe_pt(cos(RADIANS(210)) * delta_calibration_radius, sin(RADIANS(210)) * delta_calibration_radius); }
|
||||
void _goto_tower_y() { _man_probe_pt(cos(RADIANS(330)) * delta_calibration_radius, sin(RADIANS(330)) * delta_calibration_radius); }
|
||||
void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); }
|
||||
void _goto_center() { _man_probe_pt(0,0); }
|
||||
void _goto_tower_a(const float &a) {
|
||||
xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
|
||||
_man_probe_pt(tower_vec * delta_calibration_radius);
|
||||
}
|
||||
void _goto_tower_x() { _goto_tower_a(210); }
|
||||
void _goto_tower_y() { _goto_tower_a(330); }
|
||||
void _goto_tower_z() { _goto_tower_a( 90); }
|
||||
void _goto_center() { xy_pos_t ctr{0}; _man_probe_pt(ctr); }
|
||||
|
||||
#endif
|
||||
|
||||
@ -101,15 +105,15 @@ void lcd_delta_settings() {
|
||||
START_MENU();
|
||||
MENU_BACK(MSG_DELTA_CALIBRATE);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
|
||||
#define EDIT_ENDSTOP_ADJ(LABEL,N) MENU_ITEM_EDIT_CALLBACK(float43, LABEL, &delta_endstop_adj[_AXIS(N)], -5, 5, _recalc_delta_settings)
|
||||
EDIT_ENDSTOP_ADJ("Ex",A);
|
||||
EDIT_ENDSTOP_ADJ("Ey",B);
|
||||
EDIT_ENDSTOP_ADJ("Ez",C);
|
||||
#define EDIT_ENDSTOP_ADJ(LABEL,N) MENU_ITEM_EDIT_CALLBACK(float43, LABEL, &delta_endstop_adj.N, -5, 5, _recalc_delta_settings)
|
||||
EDIT_ENDSTOP_ADJ("Ex",a);
|
||||
EDIT_ENDSTOP_ADJ("Ey",b);
|
||||
EDIT_ENDSTOP_ADJ("Ez",c);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings);
|
||||
#define EDIT_ANGLE_TRIM(LABEL,N) MENU_ITEM_EDIT_CALLBACK(float43, LABEL, &delta_tower_angle_trim[_AXIS(N)], -5, 5, _recalc_delta_settings)
|
||||
EDIT_ANGLE_TRIM("Tx",A);
|
||||
EDIT_ANGLE_TRIM("Ty",B);
|
||||
EDIT_ANGLE_TRIM("Tz",C);
|
||||
#define EDIT_ANGLE_TRIM(LABEL,N) MENU_ITEM_EDIT_CALLBACK(float43, LABEL, &delta_tower_angle_trim.N, -5, 5, _recalc_delta_settings)
|
||||
EDIT_ANGLE_TRIM("Tx",a);
|
||||
EDIT_ANGLE_TRIM("Ty",b);
|
||||
EDIT_ANGLE_TRIM("Tz",c);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5, delta_diagonal_rod + 5, _recalc_delta_settings);
|
||||
END_MENU();
|
||||
}
|
||||
|
@ -92,26 +92,26 @@ static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
|
||||
if (soft_endstops_enabled) switch (axis) {
|
||||
case X_AXIS:
|
||||
#if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
|
||||
min = soft_endstop[X_AXIS].min;
|
||||
min = soft_endstop.min.x;
|
||||
#endif
|
||||
#if ENABLED(MAX_SOFTWARE_ENDSTOP_X)
|
||||
max = soft_endstop[X_AXIS].max;
|
||||
max = soft_endstop.max.x;
|
||||
#endif
|
||||
break;
|
||||
case Y_AXIS:
|
||||
#if ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
|
||||
min = soft_endstop[Y_AXIS].min;
|
||||
min = soft_endstop.min.y;
|
||||
#endif
|
||||
#if ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
|
||||
max = soft_endstop[Y_AXIS].max;
|
||||
max = soft_endstop.max.y;
|
||||
#endif
|
||||
break;
|
||||
case Z_AXIS:
|
||||
#if ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
|
||||
min = soft_endstop[Z_AXIS].min;
|
||||
min = soft_endstop.min.z;
|
||||
#endif
|
||||
#if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
|
||||
max = soft_endstop[Z_AXIS].max;
|
||||
max = soft_endstop.max.z;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
@ -173,7 +173,7 @@ void lcd_move_z() { _lcd_move_xyz(PSTR(MSG_MOVE_Z), Z_AXIS); }
|
||||
#if IS_KINEMATIC
|
||||
manual_move_offset += diff;
|
||||
#else
|
||||
current_position[E_AXIS] += diff;
|
||||
current_position.e += diff;
|
||||
#endif
|
||||
manual_move_to_current(E_AXIS
|
||||
#if E_MANUAL > 1
|
||||
@ -207,7 +207,7 @@ void lcd_move_z() { _lcd_move_xyz(PSTR(MSG_MOVE_Z), Z_AXIS); }
|
||||
}
|
||||
#endif // E_MANUAL > 1
|
||||
|
||||
draw_edit_screen(pos_label, ftostr41sign(current_position[E_AXIS]
|
||||
draw_edit_screen(pos_label, ftostr41sign(current_position.e
|
||||
#if IS_KINEMATIC
|
||||
+ manual_move_offset
|
||||
#endif
|
||||
@ -267,7 +267,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
|
||||
case Z_AXIS: STATIC_ITEM(MSG_MOVE_Z, SS_CENTER|SS_INVERT); break;
|
||||
default:
|
||||
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
|
||||
manual_move_e_origin = current_position[E_AXIS];
|
||||
manual_move_e_origin = current_position.e;
|
||||
#endif
|
||||
STATIC_ITEM(MSG_MOVE_E, SS_CENTER|SS_INVERT);
|
||||
break;
|
||||
@ -345,7 +345,7 @@ void menu_move() {
|
||||
) {
|
||||
if (
|
||||
#if ENABLED(DELTA)
|
||||
current_position[Z_AXIS] <= delta_clip_start_height
|
||||
current_position.z <= delta_clip_start_height
|
||||
#else
|
||||
true
|
||||
#endif
|
||||
|
@ -432,18 +432,16 @@ void _lcd_ubl_map_lcd_edit_cmd() {
|
||||
void ubl_map_move_to_xy() {
|
||||
const feedRate_t fr_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
|
||||
|
||||
set_destination_from_current(); // sync destination at the start
|
||||
destination = current_position; // sync destination at the start
|
||||
|
||||
#if ENABLED(DELTA)
|
||||
if (current_position[Z_AXIS] > delta_clip_start_height) {
|
||||
destination[Z_AXIS] = delta_clip_start_height;
|
||||
if (current_position.z > delta_clip_start_height) {
|
||||
destination.z = delta_clip_start_height;
|
||||
prepare_internal_move_to_destination(fr_mm_s);
|
||||
}
|
||||
#endif
|
||||
|
||||
destination[X_AXIS] = pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]);
|
||||
destination[Y_AXIS] = pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]);
|
||||
|
||||
destination.set(ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot));
|
||||
prepare_internal_move_to_destination(fr_mm_s);
|
||||
}
|
||||
|
||||
@ -491,9 +489,8 @@ void _lcd_ubl_output_map_lcd() {
|
||||
if (y_plot < 0) y_plot = GRID_MAX_POINTS_Y - 1;
|
||||
|
||||
#if IS_KINEMATIC
|
||||
const float x = pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]),
|
||||
y = pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]);
|
||||
if (position_is_reachable(x, y)) break; // Found a valid point
|
||||
const xy_pos_t xy = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) };
|
||||
if (position_is_reachable(xy)) break; // Found a valid point
|
||||
x_plot += (step_scaler < 0) ? -1 : 1;
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user