Browse Source

Copter: move zigzag exit into mode_zigzag.cpp

c415-sdk
Tatsuya Yamaguchi 5 years ago committed by Randy Mackay
parent
commit
735498e160
  1. 13
      ArduCopter/mode.cpp
  2. 1
      ArduCopter/mode.h
  3. 11
      ArduCopter/mode_zigzag.cpp

13
ArduCopter/mode.cpp

@ -256,13 +256,6 @@ bool Copter::set_mode(Mode::Number mode, ModeReason reason) @@ -256,13 +256,6 @@ bool Copter::set_mode(Mode::Number mode, ModeReason reason)
return false;
}
#if MODE_ZIGZAG_ENABLED == ENABLED && SPRAYER_ENABLED == ENABLED
// The pump will stop if the flight mode is changed from ZigZag to other
if (control_mode == Mode::Number::ZIGZAG && g2.zigzag_auto_pump_enabled) {
copter.sprayer.run(false);
}
#endif
// perform any cleanup required by previous flight mode
exit_mode(flightmode, new_flightmode);
@ -363,6 +356,12 @@ void Copter::exit_mode(Mode *&old_flightmode, @@ -363,6 +356,12 @@ void Copter::exit_mode(Mode *&old_flightmode,
}
#endif
#if MODE_ZIGZAG_ENABLED == ENABLED
if (old_flightmode == &mode_zigzag) {
mode_zigzag.exit();
}
#endif
#if FRAME_CONFIG == HELI_FRAME
// firmly reset the flybar passthrough to false when exiting acro mode.
if (old_flightmode == &mode_acro) {

1
ArduCopter/mode.h

@ -1388,6 +1388,7 @@ public: @@ -1388,6 +1388,7 @@ public:
using Mode::Mode;
bool init(bool ignore_checks) override;
void exit();
void run() override;
bool requires_GPS() const override { return true; }

11
ArduCopter/mode_zigzag.cpp

@ -41,6 +41,17 @@ bool ModeZigZag::init(bool ignore_checks) @@ -41,6 +41,17 @@ bool ModeZigZag::init(bool ignore_checks)
return true;
}
// perform cleanup required when leaving zigzag mode
void ModeZigZag::exit()
{
#if SPRAYER_ENABLED == ENABLED
// The pump will stop if the flight mode is changed from ZigZag to other
if (g2.zigzag_auto_pump_enabled) {
copter.sprayer.run(false);
}
#endif
}
// run the zigzag controller
// should be called at 100hz or more
void ModeZigZag::run()

Loading…
Cancel
Save