Skip to content

Commit

Permalink
Misc. ExtUI fixes (MarlinFirmware#14971)
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanityAutomation authored and thinkyhead committed Aug 20, 2019
1 parent 6039893 commit 5a7c021
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Marlin/src/lcd/extensible_ui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#include "../../libs/numtostr.h"
#endif

#if DO_SWITCH_EXTRUDER || EITHER(SWITCHING_NOZZLE, PARKING_EXTRUDER)
#if EXTRUDERS > 1
#include "../../module/tool_change.h"
#endif

Expand Down Expand Up @@ -267,8 +267,12 @@ namespace ExtUI {
return flags.manual_motion ? destination[axis] : current_position[axis];
}

float getAxisPosition_mm(const extruder_t) {
return flags.manual_motion ? destination[E_AXIS] : current_position[E_AXIS];
float getAxisPosition_mm(const extruder_t extruder) {
const uint8_t old_tool = active_extruder;
setActiveTool(extruder, true);
const float pos = flags.manual_motion ? destination[E_AXIS] : current_position[E_AXIS];
setActiveTool(old_tool, true);
return pos;
}

void setAxisPosition_mm(const float position, const axis_t axis) {
Expand Down Expand Up @@ -315,6 +319,9 @@ namespace ExtUI {
}
#endif

constexpr float max_manual_feedrate[XYZE] = MANUAL_FEEDRATE;
setFeedrate_mm_s(max_manual_feedrate[axis]);

if (!flags.manual_motion) set_destination_from_current();
destination[axis] = clamp(position, min, max);
flags.manual_motion = true;
Expand All @@ -323,6 +330,8 @@ namespace ExtUI {
void setAxisPosition_mm(const float position, const extruder_t extruder) {
setActiveTool(extruder, true);

constexpr float max_manual_feedrate[XYZE] = MANUAL_FEEDRATE;
setFeedrate_mm_s(max_manual_feedrate[E_AXIS]);
if (!flags.manual_motion) set_destination_from_current();
destination[E_AXIS] = position;
flags.manual_motion = true;
Expand Down Expand Up @@ -363,9 +372,7 @@ namespace ExtUI {
void setActiveTool(const extruder_t extruder, bool no_move) {
#if EXTRUDERS > 1
const uint8_t e = extruder - E0;
#if DO_SWITCH_EXTRUDER || EITHER(SWITCHING_NOZZLE, PARKING_EXTRUDER)
if (e != active_extruder) tool_change(e, no_move);
#endif
if (e != active_extruder) tool_change(e, no_move);
active_extruder = e;
#else
UNUSED(extruder);
Expand Down

0 comments on commit 5a7c021

Please sign in to comment.