🧑‍💻 Add ExtUI::onLevelingDone, match DWIN to ExtUI

This commit is contained in:
Scott Lahteine 2022-03-12 15:58:28 -06:00 committed by Scott Lahteine
parent 16271377e2
commit 4817efcf81
19 changed files with 94 additions and 71 deletions

View File

@ -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() {

View File

@ -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) {
@ -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)
@ -606,6 +608,8 @@ G29_TYPE GcodeSuite::G29() {
abl.reenable = false;
}
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
#endif // AUTO_BED_LEVELING_3POINT
@ -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));

View File

@ -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;
@ -168,6 +168,7 @@ void GcodeSuite::G29() {
#endif
TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
}
break;

View File

@ -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!
@ -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();

View File

@ -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

View File

@ -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) {
@ -4297,7 +4297,7 @@ void DWIN_CompletedHoming() {
}
}
void DWIN_CompletedLeveling() {
void DWIN_LevelingDone() {
if (checkkey == Leveling) Goto_MainMenu();
}

View File

@ -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();

View File

@ -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));
@ -1565,7 +1565,7 @@ void DWIN_MeshLevelingStart() {
#endif
}
void DWIN_CompletedLeveling() {
void DWIN_LevelingDone() {
TERN_(HAS_ONESTEP_LEVELING, if (planner.leveling_active) Goto_MeshViewer());
}

View File

@ -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();

View File

@ -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() {}
@ -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

View File

@ -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);
@ -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
@ -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) {
@ -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
@ -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;
@ -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);

View File

@ -54,8 +54,8 @@ namespace ExtUI {
void onStatusChanged(const char * const msg) {}
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {}
@ -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

View File

@ -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() {}
@ -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

View File

@ -83,8 +83,8 @@ namespace ExtUI {
}
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {
dgus_screen_handler.SettingsReset();
@ -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);

View File

@ -59,8 +59,8 @@ namespace ExtUI {
void onStatusChanged(const char * const msg) {}
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {}
@ -99,7 +99,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

View File

@ -80,7 +80,7 @@ namespace ExtUI {
}
void onPrintTimerPaused() {}
void onPrintFinished() {}
void onPrintDone() {}
void onFilamentRunout(const extruder_t extruder) {
char lcd_msg[30];
@ -90,7 +90,7 @@ namespace ExtUI {
}
void onHomingStart() {}
void onHomingComplete() {}
void onHomingDone() {}
void onFactoryReset() { InterfaceSettingsScreen::defaultSettings(); }
void onStoreSettings(char *buff) { InterfaceSettingsScreen::saveSettings(buff); }
@ -118,7 +118,8 @@ namespace ExtUI {
}
#if HAS_LEVELING && HAS_MESH
void onMeshLevelingStart() {}
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t x, const int8_t y, const_float_t val) { BedMeshViewScreen::onMeshUpdate(x, y, val); }
void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { BedMeshViewScreen::onMeshUpdate(x, y, state); }
#endif

View File

@ -141,8 +141,8 @@ namespace ExtUI {
void onFilamentRunout(const extruder_t extruder) {}
void onUserConfirmRequired(const char * const) {}
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() {}
void onHomingDone() {}
void onPrintDone() {}
void onFactoryReset() {}
void onStoreSettings(char*) {}
void onLoadSettings(const char*) {}
@ -151,7 +151,8 @@ namespace ExtUI {
void onConfigurationStoreRead(bool) {}
#if HAS_MESH
void onMeshLevelingStart() {}
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {}
#endif

View File

@ -50,8 +50,8 @@ namespace ExtUI {
void onStatusChanged(const char * const msg) { nextion.StatusChange(msg); }
void onHomingStart() {}
void onHomingComplete() {}
void onPrintFinished() { nextion.PrintFinished(); }
void onHomingDone() {}
void onPrintDone() { nextion.PrintFinished(); }
void onFactoryReset() {}
@ -90,7 +90,8 @@ namespace ExtUI {
}
#if HAS_MESH
void onMeshLevelingStart() {}
void onLevelingStart() {}
void onLevelingDone() {}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
// Called when any mesh points are updated

View File

@ -172,7 +172,8 @@ namespace ExtUI {
float getMeshPoint(const xy_uint8_t &pos);
void setMeshPoint(const xy_uint8_t &pos, const_float_t zval);
void moveToMeshPoint(const xy_uint8_t &pos, const_float_t z);
void onMeshLevelingStart();
void onLevelingStart();
void onLevelingDone();
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval);
inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); }
@ -403,14 +404,14 @@ namespace ExtUI {
void onPrintTimerStarted();
void onPrintTimerPaused();
void onPrintTimerStopped();
void onPrintFinished();
void onPrintDone();
void onFilamentRunout(const extruder_t extruder);
void onUserConfirmRequired(const char * const msg);
void onUserConfirmRequired(FSTR_P const fstr);
void onStatusChanged(const char * const msg);
void onStatusChanged(FSTR_P const fstr);
void onHomingStart();
void onHomingComplete();
void onHomingDone();
void onSteppersDisabled();
void onSteppersEnabled();
void onFactoryReset();