Skip to content

Commit

Permalink
Belt tuning: Add gantry align phase
Browse files Browse the repository at this point in the history
Add a new phase as instructed by the research team.

BFW-6029
  • Loading branch information
CZDanol-prusa authored and CZDanol committed Sep 5, 2024
1 parent f2ad772 commit a4eb54a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/common/feature/belt_tuning/belt_tuning_wizard.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "belt_tuning_wizard.hpp"

#include <module/stepper.h>
#include <module/prusa/accelerometer.h>
#include <Marlin/src/gcode/gcode.h>
#include <gcode/calibrate/M958.hpp>
Expand Down Expand Up @@ -31,7 +32,27 @@ class FSMBeltTuning final {

private:
PhaseOpt phase_init(const Meta::LoopCallbackArgs &) {
return Phase::preparing;
return Phase::ask_for_gantry_align;
}

void phase_ask_for_gantry_align_init(const Meta::InitCallbackArgs &) {
// Disable the XY gantry - the user is prompted to move it by hand in this phase
planner.synchronize();
disable_XY();
}

PhaseOpt phase_ask_for_gantry_align(const Meta::LoopCallbackArgs &args) {
switch (args.response.value_or<Response>(Response::_none)) {

case Response::Done:
return Phase::preparing;

case Response::Abort:
return Phase::finish;

default:
return std::nullopt;
}
}

PhaseOpt phase_preparing(const Meta::LoopCallbackArgs &) {
Expand Down Expand Up @@ -195,6 +216,7 @@ class FSMBeltTuning final {
using C = FSMBeltTuning;
static constexpr Config config {
{ Phase::init, { &C::phase_init } },
{ Phase::ask_for_gantry_align, { &C::phase_ask_for_gantry_align, &C::phase_ask_for_gantry_align_init } },
{ Phase::preparing, { &C::phase_preparing } },
{ Phase::ask_for_dampeners_installation, { &C::phase_ask_for_dampeners_installation } },
{ Phase::calibrating_accelerometer, { &C::phase_calibrating_accelerometer } },
Expand Down
4 changes: 4 additions & 0 deletions src/common/marlin_server_types/client_response.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ constexpr inline ClientFSM client_fsm_from_phase(PhasesSerialPrinting) { return
enum class PhaseBeltTuning : PhaseUnderlyingType {
init,

/// The user is prompted to loose the belts so that the gantry is aligned
ask_for_gantry_align,

/// Homing, selecting a proper tool and moving it to the measuring position
preparing,

Expand Down Expand Up @@ -880,6 +883,7 @@ class ClientResponses {
#if HAS_BELT_TUNING()
static constexpr EnumArray<PhaseBeltTuning, PhaseResponses, CountPhases<PhaseBeltTuning>()> belt_tuning_responses {
{ PhaseBeltTuning::init, {} },
{ PhaseBeltTuning::ask_for_gantry_align, { Response::Done, Response::Abort } },
{ PhaseBeltTuning::preparing, { Response::Abort } },
{ PhaseBeltTuning::ask_for_dampeners_installation, { Response::Done, Response::Abort } },
{ PhaseBeltTuning::calibrating_accelerometer, { Response::Abort } },
Expand Down
3 changes: 3 additions & 0 deletions src/gui/wizard/screen_belt_tuning_wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#include <display.hpp>

#include <gui/standard_frame/frame_prompt.hpp>
#include <gui/standard_frame/frame_qr_prompt.hpp>
#include <feature/belt_tuning/belt_tuning_wizard.hpp>
#include <feature/belt_tuning/printer_belt_parameters.hpp>

using Phase = PhaseBeltTuning;

namespace {

using FrameAskForGantryAlign = WithConstructorArgs<FrameQRPrompt, Phase::ask_for_gantry_align, N_("Please follow the XY gantry alignment process in the manual."), "belt-tuning"_tstr>;
using FramePreparing = WithConstructorArgs<FramePrompt, Phase::preparing, N_("Preparing"), N_("Setting the printer up for the calibration.\n\nPlease wait.")>;

// TODO: Maybe add progress bar?
Expand Down Expand Up @@ -189,6 +191,7 @@ class FrameResults : public FramePrompt {
};

using Frames = FrameDefinitionList<ScreenBeltTuningWizard::FrameStorage,
FrameDefinition<Phase::ask_for_gantry_align, FrameAskForGantryAlign>,
FrameDefinition<Phase::preparing, FramePreparing>,
FrameDefinition<Phase::ask_for_dampeners_installation, FrameAskForDampenersInstallation>,
FrameDefinition<Phase::calibrating_accelerometer, FrameCalibratingAccelerometer>,
Expand Down

0 comments on commit a4eb54a

Please sign in to comment.