Add stealtMode flag into the global storage hive

May be used elsewhere to return to the desired motors' mode e.g. after homing
(which requires switching to normal mode)
pull/114/head
D.R.racer 2021-09-02 08:50:25 +02:00 committed by DRracer
parent 1e6194a9b9
commit 852ca37e8f
3 changed files with 18 additions and 0 deletions

View File

@ -272,6 +272,9 @@ void PlanCommand(const mp::RequestMsg &rq) {
} }
void SetMode(uint8_t m) { void SetMode(uint8_t m) {
mg::globals.SetMotorsMode(m != 0); // remember the last mode set
// distribute the mode to all motors immediately
mm::MotorMode mode = (m == 0) ? mm::Normal : mm::Stealth; mm::MotorMode mode = (m == 0) ? mm::Normal : mm::Stealth;
mm::motion.SetMode(mm::Pulley, mode); mm::motion.SetMode(mm::Pulley, mode);
mm::motion.SetMode(mm::Selector, mode); mm::motion.SetMode(mm::Selector, mode);

View File

@ -36,5 +36,10 @@ void Globals::IncDriveErrors() {
mps::DriveError::increment(); mps::DriveError::increment();
} }
void Globals::SetMotorsMode(bool stealth) {
stealthMode = stealth;
// @@TODO store into EEPROM
}
} // namespace globals } // namespace globals
} // namespace modules } // namespace modules

View File

@ -40,9 +40,19 @@ public:
/// Increment MMU errors by 1 /// Increment MMU errors by 1
void IncDriveErrors(); void IncDriveErrors();
/// Set normal or stealth mode for all of the motors
/// Used to keep track of the last set mode to be able to return to it properly
/// after homing sequences and/or after restarting the MMU
/// @param stealth true means use stealth mode, false means use normal mode
void SetMotorsMode(bool stealth);
/// @returns true if the motors are to be operated in stealth mode
bool MotorsStealth() const { return stealthMode; }
private: private:
uint8_t activeSlot; uint8_t activeSlot;
bool filamentLoaded; bool filamentLoaded;
bool stealthMode;
}; };
/// The one and only instance of global state variables /// The one and only instance of global state variables