4545#include " core/utility.h"
4646#include " module/motion.h"
4747#include " module/planner.h"
48+ #include " module/probe.h"
4849#include " module/endstops.h"
4950#include " module/temperature.h"
5051#include " module/settings.h"
6061#include " sd/cardreader.h"
6162
6263#include " lcd/marlinui.h"
64+
6365#if HAS_TOUCH_XPT2046
6466 #include " lcd/touch/touch_buttons.h"
6567#endif
7779 #include " lcd/dwin/e3v2/rotary_encoder.h"
7880#endif
7981
82+ #if ENABLED(EXTENSIBLE_UI)
83+ #include " lcd/extui/ui_api.h"
84+ #endif
85+
8086#if HAS_ETHERNET
8187 #include " feature/ethernet.h"
8288#endif
@@ -356,6 +362,8 @@ void enable_all_steppers() {
356362 ENABLE_AXIS_Y ();
357363 ENABLE_AXIS_Z ();
358364 enable_e_steppers ();
365+
366+ TERN_ (EXTENSIBLE_UI, ExtUI::onSteppersEnabled ());
359367}
360368
361369void disable_e_steppers () {
@@ -375,6 +383,8 @@ void disable_all_steppers() {
375383 DISABLE_AXIS_Y ();
376384 DISABLE_AXIS_Z ();
377385 disable_e_steppers ();
386+
387+ TERN_ (EXTENSIBLE_UI, ExtUI::onSteppersDisabled ());
378388}
379389
380390#if ENABLED(G29_RETRY_AND_RECOVER)
@@ -751,6 +761,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
751761 // Handle UI input / draw events
752762 TERN (DWIN_CREALITY_LCD, DWIN_Update (), ui.update ());
753763
764+ #if PIN_EXISTS(OPTO_SWITCH)
765+ static bool optoSwitch;
766+ const bool opto = READ (OPTO_SWITCH_PIN);
767+ if (optoSwitch != opto) {
768+ optoSwitch = opto;
769+ // SERIAL_ECHOLNPAIR("Opto switch says: ", opto);
770+ }
771+ if (is_homing_z) endstops.enable_z_probe (!opto);
772+ #endif
773+
754774 // Run i2c Position Encoders
755775 #if ENABLED(I2C_POSITION_ENCODERS)
756776 static millis_t i2cpem_next_update_ms;
@@ -1090,6 +1110,16 @@ void setup() {
10901110 SETUP_RUN (ui.reset_status ()); // Load welcome message early. (Retained if no errors exist.)
10911111 #endif
10921112
1113+ #if PIN_EXISTS(COM)
1114+ SETUP_LOG (" Init COM_PIN" );
1115+ OUT_WRITE (COM_PIN, HIGH);
1116+ #endif
1117+
1118+ #if PIN_EXISTS(OPTO_SWITCH)
1119+ SETUP_LOG (" Init OPTO_SWITCH_PIN" );
1120+ SET_INPUT (OPTO_SWITCH_PIN);
1121+ #endif
1122+
10931123 #if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
10941124 SETUP_RUN (card.mount ()); // Mount media with settings before first_load
10951125 #endif
0 commit comments