Rename Motion::DisableAxis to Disable

Implement Motion::SetEnabled (for symmetry with TMC2130::SetEnabled).

Rename DisableAxis to Disable and use the new SetEnabled. This makes the
member names more consistent.
pull/47/head
Yuri D'Elia 2021-07-11 21:38:01 +02:00
parent 066aab7adc
commit 7337e97765
8 changed files with 16 additions and 9 deletions

View File

@ -61,7 +61,7 @@ bool EjectFilament::Step() {
break;
case ProgressCode::DisengagingIdler:
if (!mi::idler.Engaged()) { // idler disengaged
mm::motion.DisableAxis(mm::Pulley);
mm::motion.Disable(mm::Pulley);
state = ProgressCode::OK;
}
break;

View File

@ -59,7 +59,7 @@ bool LoadFilament::Step() {
case FeedToBondtech::Failed:
case FeedToBondtech::OK:
mm::motion.DisableAxis(mm::Pulley);
mm::motion.Disable(mm::Pulley);
mi::idler.Disengage();
state = ProgressCode::DisengagingIdler;
}

View File

@ -63,7 +63,7 @@ bool UnloadFilament::Step() {
case ProgressCode::FinishingMoves:
if (mm::motion.QueueEmpty()) {
state = ProgressCode::OK;
mm::motion.DisableAxis(mm::Pulley);
mm::motion.Disable(mm::Pulley);
mg::globals.SetFilamentLoaded(false); // filament unloaded
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
}

View File

@ -66,7 +66,7 @@ bool Idler::Step() {
currentSlot = plannedSlot;
if (!Engaged()) // turn off power into the Idler motor when disengaged (no force necessary)
mm::motion.DisableAxis(mm::Idler);
mm::motion.Disable(mm::Idler);
return true;
case Failed:

View File

@ -7,7 +7,10 @@ Motion motion;
void Motion::InitAxis(Axis axis) {}
void Motion::DisableAxis(Axis axis) {}
void Motion::SetEnabled(Axis axis, bool enabled) {
axisData[axis].drv.SetEnabled(axisParams[axis].params, enabled);
axisData[axis].enabled = enabled;
}
bool Motion::StallGuard(Axis axis) { return false; }

View File

@ -77,8 +77,11 @@ public:
/// state especially when the TMC may get randomly reset (deinited)
void InitAxis(Axis axis);
/// Set axis power status
void SetEnabled(Axis axis, bool enabled);
/// Disable axis motor
void DisableAxis(Axis axis);
void Disable(Axis axis) { SetEnabled(axis, false); }
/// @returns true if a stall guard event occurred recently on the axis
bool StallGuard(Axis axis);
@ -148,6 +151,7 @@ private:
struct AxisData {
TMC2130 drv; ///< Motor driver
pulse_gen::PulseGen ctrl; ///< Motor controller
bool enabled; ///< Axis enabled
};
/// Helper to initialize AxisData members

View File

@ -44,7 +44,7 @@ bool Selector::Step() {
return false;
case Ready:
currentSlot = plannedSlot;
mm::motion.DisableAxis(mm::Selector); // turn off selector motor's power every time
mm::motion.Disable(mm::Selector); // turn off selector motor's power every time
return true;
case Failed:
default:

View File

@ -18,8 +18,8 @@ void Motion::InitAxis(Axis axis) {
axes[axis].enabled = true;
}
void Motion::DisableAxis(Axis axis) {
axes[axis].enabled = false;
void Motion::SetEnabled(Axis axis, bool enabled) {
axes[axis].enabled = enabled;
}
bool Motion::StallGuard(Axis axis) {