Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idler/selector: simplify init #343

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/modules/idler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ bool Idler::Step() {
return false;
case Ready:
if (!homingValid && mg::globals.FilamentLoaded() < mg::InFSensor) {
// home the Idler only in case we don't have filament loaded in the printer (or at least we think we don't)
PlanHome();
return false;
}
Expand All @@ -166,14 +167,8 @@ bool Idler::Step() {
}

void Idler::Init() {
if (mg::globals.FilamentLoaded() < mg::InFSensor) {
// home the Idler only in case we don't have filament loaded in the printer (or at least we think we don't)
PlanHome();
} else {
// otherwise assume the Idler is at its idle position (that's where it usually is)
mm::motion.SetPosition(mm::Idler, SlotPosition(IdleSlotIndex()).v);
InvalidateHoming(); // and plan homing sequence ASAP
}
// Re-home axis at first opportunity. See 'Ready' state.
InvalidateHoming();
}

} // namespace idler
Expand Down
11 changes: 3 additions & 8 deletions src/modules/selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ bool Selector::Step() {
return false;
case Ready:
if (!homingValid && mg::globals.FilamentLoaded() < mg::InSelector && (!mf::finda.Pressed())) {
// home the Selector only in case we don't have filament loaded (or at least we think we don't)
PlanHome();
return false;
}
Expand All @@ -133,14 +134,8 @@ bool Selector::Step() {
}

void Selector::Init() {
if (mg::globals.FilamentLoaded() < mg::FilamentLoadState::InSelector && (!mf::finda.Pressed())) {
// home the Selector only in case we don't have filament loaded (or at least we think we don't)
PlanHome();
} else {
// otherwise set selector's position according to know slot positions (and pretend it is correct)
mm::motion.SetPosition(mm::Selector, SlotPosition(mg::globals.ActiveSlot()).v);
InvalidateHoming(); // and plan homing sequence ASAP
}
// Re-home axis at first opportunity. See 'Ready' state.
InvalidateHoming();
}

} // namespace selector
Expand Down
Loading