Skip to content

Commit

Permalink
Add dev menu items for manipulating IS wizard results
Browse files Browse the repository at this point in the history
Especially on XL, it is quite annoying to test various
input shaper calibration behaviours when doing factory reset.

This should be reverted if we ever need more FLASH memory
and/or after product managers stop rapidly changing specs.
  • Loading branch information
danopernis committed Jul 22, 2024
1 parent 1ab11ee commit b117f00
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/gui/MItem_input_shaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ MI_IS_CALIB::MI_IS_CALIB()
void MI_IS_CALIB::click([[maybe_unused]] IWindowMenu &window_menu) {
marlin_client::gcode("M1959");
}

// dev item, no need to translate
MI_IS_CALIB_RESULT::MI_IS_CALIB_RESULT(const char *label, const char *gcode)
: IWindowMenuItem { _(label), nullptr, is_enabled_t::yes, is_hidden_t::dev }
, gcode { gcode } {
}

void MI_IS_CALIB_RESULT::click(IWindowMenu &) {
marlin_client::gcode(gcode);
}

#endif

MI_IS_RESTORE_DEFAULTS::MI_IS_RESTORE_DEFAULTS()
Expand Down
35 changes: 35 additions & 0 deletions src/gui/MItem_input_shaper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,39 @@ class MI_IS_CALIB : public IWindowMenuItem {
protected:
virtual void click(IWindowMenu &window_menu) override;
};

class MI_IS_CALIB_RESULT : public IWindowMenuItem {
private:
const char *gcode;

protected:
MI_IS_CALIB_RESULT(const char *label, const char *gcode);

virtual void click(IWindowMenu &) final;
};

class MI_IS_CALIB_RESULT_UNKNOWN final : public MI_IS_CALIB_RESULT {
public:
MI_IS_CALIB_RESULT_UNKNOWN()
: MI_IS_CALIB_RESULT("Set Result Unknown", "M1959 W0") {}
};

class MI_IS_CALIB_RESULT_SKIPPED final : public MI_IS_CALIB_RESULT {
public:
MI_IS_CALIB_RESULT_SKIPPED()
: MI_IS_CALIB_RESULT("Set Result Skipped", "M1959 W1") {}
};

class MI_IS_CALIB_RESULT_PASSED final : public MI_IS_CALIB_RESULT {
public:
MI_IS_CALIB_RESULT_PASSED()
: MI_IS_CALIB_RESULT("Set Result Passed", "M1959 W2") {}
};

class MI_IS_CALIB_RESULT_FAILED final : public MI_IS_CALIB_RESULT {
public:
MI_IS_CALIB_RESULT_FAILED()
: MI_IS_CALIB_RESULT("Set Result Failed", "M1959 W3") {}
};

#endif
4 changes: 4 additions & 0 deletions src/gui/screen_menu_input_shaper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ using ScreenMenuInputShaper = ScreenMenu<
MI_RETURN,
#if HAS_INPUT_SHAPER_CALIBRATION()
MI_IS_CALIB,
MI_IS_CALIB_RESULT_UNKNOWN,
MI_IS_CALIB_RESULT_SKIPPED,
MI_IS_CALIB_RESULT_PASSED,
MI_IS_CALIB_RESULT_FAILED,
#endif
MI_IS_ENABLE_EDITING,
MI_IS_X_ONOFF,
Expand Down
11 changes: 11 additions & 0 deletions src/marlin_stubs/M1959.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,17 @@ static void M1959_internal(PhasesInputShaperCalibration phase) {
namespace PrusaGcodeSuite {

void M1959() {
if (parser.seen('W')) {
switch (const uint8_t w = parser.value_byte()) {
case 0:
case 1:
case 2:
case 3:
set_test_result(static_cast<TestResult>(w));
}
return;
}

switch (get_test_result()) {
case TestResult_Unknown:
// Do not run calibration on the initial wizard after factory reset,
Expand Down

0 comments on commit b117f00

Please sign in to comment.