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; break;
case ProgressCode::DisengagingIdler: case ProgressCode::DisengagingIdler:
if (!mi::idler.Engaged()) { // idler disengaged if (!mi::idler.Engaged()) { // idler disengaged
mm::motion.DisableAxis(mm::Pulley); mm::motion.Disable(mm::Pulley);
state = ProgressCode::OK; state = ProgressCode::OK;
} }
break; break;

View File

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

View File

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

View File

@ -66,7 +66,7 @@ bool Idler::Step() {
currentSlot = plannedSlot; currentSlot = plannedSlot;
if (!Engaged()) // turn off power into the Idler motor when disengaged (no force necessary) 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; return true;
case Failed: case Failed:

View File

@ -7,7 +7,10 @@ Motion motion;
void Motion::InitAxis(Axis axis) {} 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; } bool Motion::StallGuard(Axis axis) { return false; }

View File

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

View File

@ -44,7 +44,7 @@ bool Selector::Step() {
return false; return false;
case Ready: case Ready:
currentSlot = plannedSlot; 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; return true;
case Failed: case Failed:
default: default:

View File

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