Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Add ExtUI::onLevelingDone, match DWIN to ExtUI
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 12, 2022
1 parent 5bbb345 commit 623c6b7
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 71 deletions.
1 change: 1 addition & 0 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ void unified_bed_leveling::restore_ubl_active_state_and_leave() {
}
#endif
set_bed_leveling_enabled(ubl_state_at_invocation);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}

mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,13 @@ G29_TYPE GcodeSuite::G29() {

planner.synchronize();

TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());

#if ENABLED(AUTO_BED_LEVELING_3POINT)
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart());
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LevelingStart());
#endif

if (!faux) {
Expand Down Expand Up @@ -577,6 +578,7 @@ G29_TYPE GcodeSuite::G29() {
SERIAL_ECHOLNPGM("Grid probing done.");
// Re-enable software endstops, if needed
SET_SOFT_ENDSTOP_LOOSE(false);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}

#elif ENABLED(AUTO_BED_LEVELING_3POINT)
Expand Down Expand Up @@ -606,6 +608,8 @@ G29_TYPE GcodeSuite::G29() {
abl.reenable = false;
}

TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());

}

#endif // AUTO_BED_LEVELING_3POINT
Expand Down Expand Up @@ -899,7 +903,7 @@ G29_TYPE GcodeSuite::G29() {
process_subcommands_now(F(Z_PROBE_END_SCRIPT));
#endif

TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling());
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone());

TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index));

Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/gcode/bedlevel/mbl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ void GcodeSuite::G29() {
mbl_probe_index = 0;
if (!ui.wait_for_move) {
queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2"));
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart());
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());
return;
}
state = MeshNext;
Expand Down Expand Up @@ -168,6 +168,7 @@ void GcodeSuite::G29() {
#endif

TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
break;

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void GcodeSuite::G28() {
set_and_report_grblstate(M_HOMING);
#endif

TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming());
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingStart());
TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart());

planner.synchronize(); // Wait for planner moves to finish!
Expand Down Expand Up @@ -552,8 +552,8 @@ void GcodeSuite::G28() {

ui.refresh();

TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedHoming());
TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete());
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingDone());
TERN_(EXTENSIBLE_UI, ExtUI::onHomingDone());

report_current_position();

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void GcodeSuite::M1001() {
process_subcommands_now(F(SD_FINISHED_RELEASECOMMAND));
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());
TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone());
TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished());

// Re-select the last printed file in the UI
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/creality/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4281,7 +4281,7 @@ void DWIN_HandleScreen() {
}
}

void DWIN_CompletedHoming() {
void DWIN_HomingDone() {
HMI_flag.home_flag = false;
dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
if (checkkey == Last_Prepare) {
Expand All @@ -4297,7 +4297,7 @@ void DWIN_CompletedHoming() {
}
}

void DWIN_CompletedLeveling() {
void DWIN_LevelingDone() {
if (checkkey == Leveling) Goto_MainMenu();
}

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/e3v2/creality/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void DWIN_HandleScreen();
void DWIN_StatusChanged(const char * const cstr=nullptr);
void DWIN_StatusChanged(FSTR_P const fstr);

inline void DWIN_StartHoming() { HMI_flag.home_flag = true; }
inline void DWIN_HomingStart() { HMI_flag.home_flag = true; }

void DWIN_CompletedHoming();
void DWIN_CompletedLeveling();
void DWIN_HomingDone();
void DWIN_LevelingDone();
8 changes: 4 additions & 4 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,20 +1542,20 @@ void HMI_SaveProcessID(const uint8_t id) {
}
}

void DWIN_StartHoming() {
void DWIN_HomingStart() {
HMI_flag.home_flag = true;
HMI_SaveProcessID(Homing);
Title.ShowCaption(GET_TEXT_F(MSG_HOMING));
DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT));
}

void DWIN_CompletedHoming() {
void DWIN_HomingDone() {
HMI_flag.home_flag = false;
dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
if (HMI_flag.abort_action) DWIN_Print_Aborted(); else HMI_ReturnScreen();
}

void DWIN_MeshLevelingStart() {
void DWIN_LevelingStart() {
#if HAS_ONESTEP_LEVELING
HMI_SaveProcessID(Leveling);
Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING));
Expand All @@ -1565,7 +1565,7 @@ void DWIN_MeshLevelingStart() {
#endif
}

void DWIN_CompletedLeveling() {
void DWIN_LevelingDone() {
TERN_(HAS_ONESTEP_LEVELING, if (planner.leveling_active) Goto_MeshViewer());
}

Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/lcd/e3v2/proui/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ void update_variable();
void DWIN_InitScreen();
void DWIN_HandleScreen();
void DWIN_CheckStatusMessage();
void DWIN_StartHoming();
void DWIN_CompletedHoming();
void DWIN_HomingStart();
void DWIN_HomingDone();
#if HAS_MESH
void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval);
#endif
void DWIN_MeshLevelingStart();
void DWIN_CompletedLeveling();
void DWIN_LevelingStart();
void DWIN_LevelingDone();
void DWIN_PidTuning(pidresult_t result);
void DWIN_Print_Started(const bool sd=false);
void DWIN_Print_Pause();
Expand Down
11 changes: 7 additions & 4 deletions Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ namespace ExtUI {

void onPrintTimerStarted() { Chiron.TimerEvent(AC_timer_started); }
void onPrintTimerPaused() { Chiron.TimerEvent(AC_timer_paused); }
void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); }
void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); }
void onPrintDone() {}

void onFilamentRunout(const extruder_t) { Chiron.FilamentRunout(); }

void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); }
void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); }

void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}

void onFactoryReset() {}

Expand Down Expand Up @@ -103,7 +105,8 @@ namespace ExtUI {
}

#if HAS_MESH
void onMeshLevelingStart() {}
void onLevelingStart() {}
void onLevelingDone() {}

void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
// Called when any mesh points are updated
Expand Down
48 changes: 27 additions & 21 deletions Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,23 @@ void ChironTFT::Startup() {
TFTSer.begin(115200);

// wait for the TFT panel to initialise and finish the animation
delay_ms(250);
safe_delay(1000);

// There are different panels for the Chiron with slightly different commands
// So we need to know what we are working with.

// Panel type can be defined otherwise detect it automatically
if (panel_type == AC_panel_unknown) DetectPanelType();
switch (panel_type) {
case AC_panel_new:
SERIAL_ECHOLNF(AC_msg_new_panel_set);
break;
case AC_panel_standard:
SERIAL_ECHOLNF(AC_msg_old_panel_set);
break;
default:
SERIAL_ECHOLNF(AC_msg_auto_panel_detection);
DetectPanelType();
break;
}

// Signal Board has reset
SendtoTFTLN(AC_msg_main_board_has_reset);
Expand Down Expand Up @@ -358,15 +368,14 @@ bool ChironTFT::ReadTFTCommand() {
}

int8_t ChironTFT::FindToken(char c) {
int8_t pos = 0;
do {
for (int8_t pos = 0; pos < command_len; pos++) {
if (panel_command[pos] == c) {
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Tpos:", pos, " ", c);
#endif
return pos;
}
} while (++pos < command_len);
}
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Not found: ", c);
#endif
Expand Down Expand Up @@ -623,18 +632,18 @@ void ChironTFT::PanelAction(uint8_t req) {
SelectFile();
break;

case 14: { // A14 Start Printing
case 14: // A14 Start Printing
// Allows printer to restart the job if we don't want to recover
if (printer_state == AC_printer_resuming_from_power_outage) {
injectCommands(F("M1000 C")); // Cancel recovery
printer_state = AC_printer_idle;
}
#if ACDebugLevel >= 1
SERIAL_ECHOLNPAIR_F("Print: ", selectedfile);
SERIAL_ECHOLNPGM("Print: ", selectedfile);
#endif
printFile(selectedfile);
SendtoTFTLN(AC_msg_print_from_sd_card);
} break;
break;

case 15: // A15 Resuming from outage
if (printer_state == AC_printer_resuming_from_power_outage) {
Expand Down Expand Up @@ -801,25 +810,22 @@ void ChironTFT::PanelProcess(uint8_t req) {
}
} break;

case 30: { // A30 Auto leveling
case 30: // A30 Auto leveling
if (FindToken('S') != -1) { // Start probing New panel adds spaces..
// Ignore request if printing
if (isPrinting())
SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
else {


SendtoTFTLN(AC_msg_start_probing);
injectCommands(F("G28\nG29"));
printer_state = AC_printer_probing;
}
}
else {
else
SendtoTFTLN(AC_msg_start_probing); // Just enter levelling menu
}
} break;
break;

case 31: { // A31 Adjust all Probe Points
case 31: // A31 Adjust all Probe Points
// The tokens can occur in different places on the new panel so we need to find it.

if (FindToken('C') != -1) { // Restore and apply original offsets
Expand Down Expand Up @@ -907,18 +913,18 @@ void ChironTFT::PanelProcess(uint8_t req) {
}
}
}
} break;
break;

case 32: { // A32 clean leveling beep flag
case 32: // A32 clean leveling beep flag
// Ignore request if printing
//if (isPrinting()) break;
//injectCommands(F("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000"));
//TFTSer.println();
} break;
break;

// A33 firmware info request see PanelInfo()

case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123
case 34: // A34 Adjust single mesh point A34 C/S X1 Y1 V123
if (panel_command[3] == 'C') { // Restore original offsets
injectCommands(F("M501\nM420 S1"));
selectedmeshpoint.x = selectedmeshpoint.y = 99;
Expand Down Expand Up @@ -950,7 +956,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
}
}
}
} break;
break;

case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code!
SendtoTFTLN(AC_msg_start_probing);
Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ namespace ExtUI {
void onStatusChanged(const char * const msg) {}

void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}
void onPrintDone() {}

void onFactoryReset() {}

Expand Down Expand Up @@ -95,7 +95,8 @@ namespace ExtUI {

#if HAS_MESH

void onMeshLevelingStart() {}
void onLevelingStart() {}
void onLevelingDone() {}

void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
// Called when any mesh points are updated
Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/lcd/extui/dgus/dgus_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namespace ExtUI {
void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }

void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}
void onPrintDone() {}

void onFactoryReset() {}

Expand Down Expand Up @@ -113,7 +113,8 @@ namespace ExtUI {
}

#if HAS_MESH
void onMeshLevelingStart() {}
void onLevelingStart() {}
void onLevelingDone() {}

void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
// Called when any mesh points are updated
Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ namespace ExtUI {
}

void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}
void onPrintDone() {}

void onFactoryReset() {
dgus_screen_handler.SettingsReset();
Expand All @@ -109,7 +109,8 @@ namespace ExtUI {
}

#if HAS_MESH
void onMeshLevelingStart() {}
void onLevelingStart() {}
void onLevelingDone() {}

void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {
dgus_screen_handler.MeshUpdate(xpos, ypos);
Expand Down
Loading

0 comments on commit 623c6b7

Please sign in to comment.