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

@ -817,11 +817,10 @@ void MarlinUI::draw_status_screen() {
#else
_draw_axis_value(X_AXIS, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])), blink);
xy_pos_t lpos = current_position; toLogical(lpos);
_draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink);
lcd_put_wchar(' ');
_draw_axis_value(Y_AXIS, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])), blink);
_draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink);
#endif
@ -830,7 +829,7 @@ void MarlinUI::draw_status_screen() {
#endif // LCD_WIDTH >= 20
lcd_moveto(LCD_WIDTH - 8, 1);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
#if HAS_LEVELING && !HAS_HEATED_BED
lcd_put_wchar(planner.leveling_active || blink ? '_' : ' ');
@ -902,7 +901,7 @@ void MarlinUI::draw_status_screen() {
// Z Coordinate
//
lcd_moveto(LCD_WIDTH - 9, 0);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink);
_draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink);
#if HAS_LEVELING && (HOTENDS > 1 || !HAS_HEATED_BED)
lcd_put_wchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' ');
@ -1189,10 +1188,9 @@ void MarlinUI::draw_status_screen() {
* Show X and Y positions
*/
_XLABEL(_PLOT_X, 0);
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot))));
_YLABEL(_LCD_W_POS, 0);
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot))));
lcd_moveto(_PLOT_X, 0);
@ -1395,9 +1393,9 @@ void MarlinUI::draw_status_screen() {
* Show all values at right of screen
*/
_XLABEL(_LCD_W_POS, 1);
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot))));
_YLABEL(_LCD_W_POS, 2);
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot))));
/**
* Show the location value

View File

@ -345,9 +345,10 @@ void MarlinUI::draw_status_screen() {
#endif
heat_bits = new_bits;
#endif
strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
strcpy(zstring, ftostr52sp( LOGICAL_Z_POSITION(current_position[Z_AXIS])));
const xyz_pos_t lpos = current_position.asLogical();
strcpy(xstring, ftostr4sign(lpos.x));
strcpy(ystring, ftostr4sign(lpos.y));
strcpy(zstring, ftostr52sp( lpos.z));
#if ENABLED(FILAMENT_LCD_DISPLAY)
strcpy(wstring, ftostr12ns(filwidth.measured_mm));
strcpy(mstring, i16tostr3(planner.volumetric_percent(parser.volumetric_enabled)));

View File

@ -660,7 +660,7 @@ void ST7920_Lite_Status_Screen::draw_status_message() {
#endif
}
void ST7920_Lite_Status_Screen::draw_position(const float (&pos)[XYZE], const bool position_known) {
void ST7920_Lite_Status_Screen::draw_position(const xyz_pos_t &pos, const bool position_known) {
char str[7];
set_ddram_address(DDRAM_LINE_4);
begin_data();
@ -669,13 +669,13 @@ void ST7920_Lite_Status_Screen::draw_position(const float (&pos)[XYZE], const bo
const unsigned char alt_label = position_known ? 0 : (ui.get_blink() ? ' ' : 0);
write_byte(alt_label ? alt_label : 'X');
write_str(dtostrf(pos[X_AXIS], -4, 0, str), 4);
write_str(dtostrf(pos.x, -4, 0, str), 4);
write_byte(alt_label ? alt_label : 'Y');
write_str(dtostrf(pos[Y_AXIS], -4, 0, str), 4);
write_str(dtostrf(pos.y, -4, 0, str), 4);
write_byte(alt_label ? alt_label : 'Z');
write_str(dtostrf(pos[Z_AXIS], -5, 1, str), 5);
write_str(dtostrf(pos.z, -5, 1, str), 5);
}
bool ST7920_Lite_Status_Screen::indicators_changed() {
@ -750,8 +750,8 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
}
bool ST7920_Lite_Status_Screen::position_changed() {
const float x_pos = current_position[X_AXIS], y_pos = current_position[Y_AXIS], z_pos = current_position[Z_AXIS];
const uint8_t checksum = uint8_t(x_pos) ^ uint8_t(y_pos) ^ uint8_t(z_pos);
const xyz_pos_t pos = current_position;
const uint8_t checksum = uint8_t(pos.x) ^ uint8_t(pos.y) ^ uint8_t(pos.z);
static uint8_t last_checksum = 0, changed = last_checksum != checksum;
if (changed) last_checksum = checksum;
return changed;

View File

@ -17,6 +17,7 @@
#include "../../HAL/shared/HAL_ST7920.h"
#include "../../core/types.h"
#include "../../core/macros.h"
#include "../../libs/duration_t.h"
@ -86,7 +87,7 @@ class ST7920_Lite_Status_Screen {
static void draw_print_time(const duration_t &elapsed);
static void draw_feedrate_percentage(const uint16_t percentage);
static void draw_status_message();
static void draw_position(const float (&pos)[XYZE], bool position_known = true);
static void draw_position(const xyz_pos_t &pos, bool position_known = true);
static bool indicators_changed();
static bool position_changed();

View File

@ -547,10 +547,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
// Show X and Y positions at top of screen
u8g.setColorIndex(1);
if (PAGE_UNDER(7)) {
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
lpos = pos.asLogical();
lcd_put_u8str(5, 7, "X:");
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
lcd_put_u8str(ftostr52(lpos.x));
lcd_put_u8str(74, 7, "Y:");
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
lcd_put_u8str(ftostr52(lpos.y));
}
// Print plot position

View File

@ -169,7 +169,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[0].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination[3], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_EPos, &destination.e, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),
#endif
#if HOTENDS >= 2
@ -195,9 +195,9 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, DGUSScreenVariableHandler::DGUSLCD_SetValueDirectly<int16_t>, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay ),
// Position Data.
VPHELPER(VP_XPos, &current_position[0], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_YPos, &current_position[1], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_ZPos, &current_position[2], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_XPos, &current_position.x, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_YPos, &current_position.y, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_ZPos, &current_position.z, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
// Print Progress.
VPHELPER(VP_PrintProgress_Percentage, &ui.progress_bar_percent, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay ),

View File

@ -258,22 +258,22 @@ bool StatusScreen::onTouchStart(uint8_t) {
bool StatusScreen::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1:
case 2:
case 3:
case 4:
case 1:
case 2:
case 3:
case 4:
case 12:
if (!jog_xy) {
jog_xy = true;
injectCommands_P(PSTR("M17"));
}
jog(0, 0, 0);
jog({ 0, 0, 0 });
break;
case 5:
case 6:
jog(0, 0, 0);
case 5:
case 6:
jog({ 0, 0, 0 });
break;
case 9: GOTO_SCREEN(FilesScreen); break;
case 9: GOTO_SCREEN(FilesScreen); break;
case 10: GOTO_SCREEN(MainMenu); break;
case 13: SpinnerDialogBox::enqueueAndWait_P(F("G112")); break;
case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break;
@ -291,14 +291,13 @@ bool StatusScreen::onTouchHeld(uint8_t tag) {
if (tag >= 1 && tag <= 4 && !jog_xy) return false;
const float s = min_speed + (fine_motion ? 0 : (max_speed - min_speed) * sq(increment));
switch (tag) {
case 1: jog(-s, 0, 0); break;
case 2: jog( s, 0, 0); break;
case 4: jog( 0, -s, 0); break; // NOTE: Y directions inverted because bed rather than needle moves
case 3: jog( 0, s, 0); break;
case 5: jog( 0, 0, -s); break;
case 6: jog( 0, 0, s); break;
case 7:
case 8:
case 1: jog({-s, 0, 0}); break;
case 2: jog({ s, 0, 0}); break;
case 4: jog({ 0, -s, 0}); break; // NOTE: Y directions inverted because bed rather than needle moves
case 3: jog({ 0, s, 0}); break;
case 5: jog({ 0, 0, -s}); break;
case 6: jog({ 0, 0, s}); break;
case 7: case 8:
{
if (ExtUI::isMoving()) return false;
const feedRate_t feedrate = emin_speed + (fine_motion ? 0 : (emax_speed - emin_speed) * sq(increment));

View File

@ -305,8 +305,8 @@ bool ChangeFilamentScreen::onTouchEnd(uint8_t tag) {
bool ChangeFilamentScreen::onTouchHeld(uint8_t tag) {
if (ExtUI::isMoving()) return false; // Don't allow moves to accumulate
constexpr float increment = 1;
#define UI_INCREMENT_AXIS(axis) MoveAxisScreen::setManualFeedrate(axis, increment); UI_INCREMENT(AxisPosition_mm, axis);
#define UI_DECREMENT_AXIS(axis) MoveAxisScreen::setManualFeedrate(axis, increment); UI_DECREMENT(AxisPosition_mm, axis);
#define UI_INCREMENT_AXIS(axis) UI_INCREMENT(AxisPosition_mm, axis);
#define UI_DECREMENT_AXIS(axis) UI_DECREMENT(AxisPosition_mm, axis);
switch (tag) {
case 5: case 7: UI_DECREMENT_AXIS(getExtruder()); break;
case 6: case 8: UI_INCREMENT_AXIS(getExtruder()); break;

View File

@ -110,8 +110,8 @@ float MoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) {
// Compute feedrate so that the tool lags the adjuster when it is
// being held down, this allows enough margin for the planner to
// connect segments and even out the motion.
constexpr float manual_feedrate[XYZE] = MANUAL_FEEDRATE;
return min(manual_feedrate[axis] / 60.0f, abs(increment_mm * (TOUCH_REPEATS_PER_SECOND) * 0.80f));
constexpr xyze_feedrate_t max_manual_feedrate = MANUAL_FEEDRATE;
return min(max_manual_feedrate[axis] / 60.0f, abs(increment_mm * (TOUCH_REPEATS_PER_SECOND) * 0.80f));
}
void MoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_mm) {

View File

@ -36,9 +36,8 @@ void NudgeNozzleScreen::onEntry() {
#if EXTRUDERS > 1
screen_data.NudgeNozzleScreen.link_nozzles = true;
#endif
LOOP_XYZ(i) {
screen_data.NudgeNozzleScreen.rel[i] = 0;
}
screen_data.NudgeNozzleScreen.rel.reset();
BaseNumericAdjustmentScreen::onEntry();
}
@ -48,10 +47,10 @@ void NudgeNozzleScreen::onRedraw(draw_mode_t what) {
w.heading( GET_TEXTF(NUDGE_NOZZLE));
#if ENABLED(BABYSTEP_XY)
w.color(x_axis).adjuster(2, GET_TEXTF(AXIS_X), screen_data.NudgeNozzleScreen.rel[0] / getAxisSteps_per_mm(X));
w.color(y_axis).adjuster(4, GET_TEXTF(AXIS_Y), screen_data.NudgeNozzleScreen.rel[1] / getAxisSteps_per_mm(Y));
w.color(x_axis).adjuster(2, GET_TEXTF(AXIS_X), screen_data.NudgeNozzleScreen.rel.x / getAxisSteps_per_mm(X));
w.color(y_axis).adjuster(4, GET_TEXTF(AXIS_Y), screen_data.NudgeNozzleScreen.rel.y / getAxisSteps_per_mm(Y));
#endif
w.color(z_axis).adjuster(6, GET_TEXTF(AXIS_Z), screen_data.NudgeNozzleScreen.rel[2] / getAxisSteps_per_mm(Z));
w.color(z_axis).adjuster(6, GET_TEXTF(AXIS_Z), screen_data.NudgeNozzleScreen.rel.z / getAxisSteps_per_mm(Z));
w.increments();
#if EXTRUDERS > 1
w.toggle (8, GET_TEXTF(ADJUST_BOTH_NOZZLES), screen_data.NudgeNozzleScreen.link_nozzles);
@ -90,12 +89,12 @@ bool NudgeNozzleScreen::onTouchHeld(uint8_t tag) {
#endif
int16_t steps;
switch (tag) {
case 2: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps(-steps, X, link); screen_data.NudgeNozzleScreen.rel[0] -= steps; break;
case 3: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps( steps, X, link); screen_data.NudgeNozzleScreen.rel[0] += steps; break;
case 4: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps(-steps, Y, link); screen_data.NudgeNozzleScreen.rel[1] -= steps; break;
case 5: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps( steps, Y, link); screen_data.NudgeNozzleScreen.rel[1] += steps; break;
case 6: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps(-steps, Z, link); screen_data.NudgeNozzleScreen.rel[2] -= steps; break;
case 7: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps( steps, Z, link); screen_data.NudgeNozzleScreen.rel[2] += steps; break;
case 2: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps(-steps, X, link); screen_data.NudgeNozzleScreen.rel.x -= steps; break;
case 3: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps( steps, X, link); screen_data.NudgeNozzleScreen.rel.x += steps; break;
case 4: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps(-steps, Y, link); screen_data.NudgeNozzleScreen.rel.y -= steps; break;
case 5: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps( steps, Y, link); screen_data.NudgeNozzleScreen.rel.y += steps; break;
case 6: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps(-steps, Z, link); screen_data.NudgeNozzleScreen.rel.z -= steps; break;
case 7: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps( steps, Z, link); screen_data.NudgeNozzleScreen.rel.z += steps; break;
#if EXTRUDERS > 1
case 8: screen_data.NudgeNozzleScreen.link_nozzles = !link; break;
#endif

View File

@ -65,7 +65,7 @@ union screen_data_t {
#if ENABLED(BABYSTEPPING)
struct {
struct base_numeric_adjustment_t placeholder;
int16_t rel[XYZ];
xyz_int_t rel;
#if EXTRUDERS > 1
bool link_nozzles;
#endif

View File

@ -204,33 +204,29 @@ namespace ExtUI {
* The axis will continue to jog until this function is
* called with all zeros.
*/
void jog(float dx, float dy, float dz) {
void jog(const xyz_float_t &dir) {
// The "destination" variable is used as a scratchpad in
// Marlin by GCODE routines, but should remain untouched
// during manual jogging, allowing us to reuse the space
// for our direction vector.
destination[X] = dx;
destination[Y] = dy;
destination[Z] = dz;
flags.jogging = !NEAR_ZERO(dx) || !NEAR_ZERO(dy) || !NEAR_ZERO(dz);
destination = dir;
flags.jogging = !NEAR_ZERO(dir.x) || !NEAR_ZERO(dir.y) || !NEAR_ZERO(dir.z);
}
// Called by the polling routine in "joystick.cpp"
void _joystick_update(float (&norm_jog)[XYZ]) {
void _joystick_update(xyz_float_t &norm_jog) {
if (flags.jogging) {
#define OUT_OF_RANGE(VALUE) (VALUE < -1.0f || VALUE > 1.0f)
if (OUT_OF_RANGE(destination[X_AXIS]) || OUT_OF_RANGE(destination[Y_AXIS]) || OUT_OF_RANGE(destination[Z_AXIS])) {
// If destination[] on any axis is out of range, it
if (OUT_OF_RANGE(destination.x) || OUT_OF_RANGE(destination.y) || OUT_OF_RANGE(destination.z)) {
// If destination on any axis is out of range, it
// probably means the UI forgot to stop jogging and
// ran GCODE that wrote a position to destination[].
// ran GCODE that wrote a position to destination.
// To prevent a disaster, stop jogging.
flags.jogging = false;
return;
}
norm_jog[X_AXIS] = destination[X_AXIS];
norm_jog[Y_AXIS] = destination[Y_AXIS];
norm_jog[Z_AXIS] = destination[Z_AXIS];
norm_jog = destination;
}
}
#endif
@ -328,18 +324,16 @@ namespace ExtUI {
float getAxisPosition_mm(const extruder_t extruder) {
const extruder_t old_tool = getActiveTool();
setActiveTool(extruder, true);
const float pos = (
const float epos = (
#if ENABLED(JOYSTICK)
flags.jogging ? destination[E_AXIS] :
flags.jogging ? destination.e :
#endif
current_position[E_AXIS]
current_position.e
);
setActiveTool(old_tool, true);
return pos;
return epos;
}
constexpr feedRate_t manual_feedrate_mm_m[XYZE] = MANUAL_FEEDRATE;
void setAxisPosition_mm(const float position, const axis_t axis) {
// Start with no limits to movement
float min = current_position[axis] - 1000,
@ -350,26 +344,26 @@ namespace ExtUI {
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;
}
@ -391,8 +385,8 @@ namespace ExtUI {
void setAxisPosition_mm(const float position, const extruder_t extruder) {
setActiveTool(extruder, true);
current_position[E_AXIS] = position;
line_to_current_position(MMM_TO_MMS(manual_feedrate_mm_m[E_AXIS]));
current_position.e = position;
line_to_current_position(MMM_TO_MMS(manual_feedrate_mm_m.e));
}
void setActiveTool(const extruder_t extruder, bool no_move) {
@ -652,7 +646,7 @@ namespace ExtUI {
}
float getAxisMaxJerk_mm_s(const extruder_t) {
return planner.max_jerk[E_AXIS];
return planner.max_jerk.e;
}
void setAxisMaxJerk_mm_s(const float value, const axis_t axis) {
@ -660,7 +654,7 @@ namespace ExtUI {
}
void setAxisMaxJerk_mm_s(const float value, const extruder_t) {
planner.max_jerk[E_AXIS] = value;
planner.max_jerk.e = value;
}
#endif
@ -710,7 +704,7 @@ namespace ExtUI {
#if EXTRUDERS > 1
&& (linked_nozzles || active_extruder == 0)
#endif
) probe_offset[Z_AXIS] += mm;
) probe_offset.z += mm;
#else
UNUSED(mm);
#endif
@ -724,7 +718,7 @@ namespace ExtUI {
if (!linked_nozzles) {
HOTEND_LOOP()
if (e != active_extruder)
hotend_offset[axis][e] += mm;
hotend_offset[e][axis] += mm;
normalizeNozzleOffset(X);
normalizeNozzleOffset(Y);
@ -748,7 +742,7 @@ namespace ExtUI {
float getZOffset_mm() {
#if HAS_BED_PROBE
return probe_offset[Z_AXIS];
return probe_offset.z;
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
return babystep.axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1];
#else
@ -759,7 +753,7 @@ namespace ExtUI {
void setZOffset_mm(const float value) {
#if HAS_BED_PROBE
if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
probe_offset[Z_AXIS] = value;
probe_offset.z = value;
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
babystep.add_mm(Z_AXIS, (value - babystep.axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]));
#else
@ -771,12 +765,12 @@ namespace ExtUI {
float getNozzleOffset_mm(const axis_t axis, const extruder_t extruder) {
if (extruder - E0 >= HOTENDS) return 0;
return hotend_offset[axis][extruder - E0];
return hotend_offset[extruder - E0][axis];
}
void setNozzleOffset_mm(const float value, const axis_t axis, const extruder_t extruder) {
if (extruder - E0 >= HOTENDS) return;
hotend_offset[axis][extruder - E0] = value;
hotend_offset[extruder - E0][axis] = value;
}
/**
@ -785,8 +779,8 @@ namespace ExtUI {
* user to edit the offset the first nozzle).
*/
void normalizeNozzleOffset(const axis_t axis) {
const float offs = hotend_offset[axis][0];
HOTEND_LOOP() hotend_offset[axis][e] -= offs;
const float offs = hotend_offset[0][axis];
HOTEND_LOOP() hotend_offset[e][axis] -= offs;
}
#endif // HAS_HOTEND_OFFSET
@ -820,10 +814,10 @@ namespace ExtUI {
bool getMeshValid() { return leveling_is_valid(); }
#if HAS_MESH
bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; }
float getMeshPoint(const uint8_t xpos, const uint8_t ypos) { return Z_VALUES(xpos,ypos); }
void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zoff) {
if (WITHIN(xpos, 0, GRID_MAX_POINTS_X) && WITHIN(ypos, 0, GRID_MAX_POINTS_Y)) {
Z_VALUES(xpos, ypos) = zoff;
float getMeshPoint(const xy_uint8_t &pos) { return Z_VALUES(pos.x, pos.y); }
void setMeshPoint(const xy_uint8_t &pos, const float zoff) {
if (WITHIN(pos.x, 0, GRID_MAX_POINTS_X) && WITHIN(pos.y, 0, GRID_MAX_POINTS_Y)) {
Z_VALUES(pos.x, pos.y) = zoff;
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
bed_level_virt_interpolate();
#endif

View File

@ -81,8 +81,8 @@ namespace ExtUI {
void enableHeater(const extruder_t);
#if ENABLED(JOYSTICK)
void jog(float dx, float dy, float dz);
void _joystick_update(float (&norm_jog)[XYZ]);
void jog(const xyz_float_t &dir);
void _joystick_update(xyz_float_t &norm_jog);
#endif
/**
@ -135,9 +135,10 @@ namespace ExtUI {
bool getMeshValid();
#if HAS_MESH
bed_mesh_t& getMeshArray();
float getMeshPoint(const uint8_t xpos, const uint8_t ypos);
void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval);
float getMeshPoint(const xy_uint8_t &pos);
void setMeshPoint(const xy_uint8_t &pos, const float zval);
void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval);
inline void onMeshUpdate(const xy_uint8_t &pos, const float zval) { setMeshPoint(pos, zval); }
#endif
#endif

View File

@ -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
}
}

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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();

View File

@ -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();
}

View File

@ -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

View File

@ -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

View File

@ -671,7 +671,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
#endif
// Set movement on a single axis
set_destination_from_current();
destination = current_position;
destination[manual_move_axis] += manual_move_offset;
// Reset for the next move

View File

@ -90,7 +90,6 @@
typedef void (*menuAction_t)();
// Manual Movement
constexpr feedRate_t manual_feedrate_mm_m[XYZE] = MANUAL_FEEDRATE;
extern float move_menu_scale;
#if ENABLED(ADVANCED_PAUSE_FEATURE)