Move some MarlinCore and MarlinUI code (#20832)
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "core/utility.h"
|
||||
|
||||
#include "module/motion.h"
|
||||
#include "module/planner.h"
|
||||
#include "module/endstops.h"
|
||||
@@ -57,6 +58,7 @@
|
||||
#include "gcode/parser.h"
|
||||
#include "gcode/queue.h"
|
||||
|
||||
#include "feature/pause.h"
|
||||
#include "sd/cardreader.h"
|
||||
|
||||
#include "lcd/marlinui.h"
|
||||
@@ -139,7 +141,6 @@
|
||||
|
||||
#if ENABLED(EXPERIMENTAL_I2CBUS)
|
||||
#include "feature/twibus.h"
|
||||
TWIBus i2c;
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
@@ -173,10 +174,6 @@
|
||||
#include "feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#if BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT)
|
||||
#include "feature/pause.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(GCODE_REPEAT_MARKERS)
|
||||
#include "feature/repeat.h"
|
||||
#endif
|
||||
@@ -267,40 +264,12 @@ bool wait_for_heatup = true;
|
||||
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(CHDK)
|
||||
extern millis_t chdk_timeout;
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
I2CPositionEncodersMgr I2CPEM;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ***************************************************************************
|
||||
* ******************************** FUNCTIONS ********************************
|
||||
* ***************************************************************************
|
||||
*/
|
||||
|
||||
void setup_killpin() {
|
||||
#if HAS_KILL
|
||||
#if KILL_PIN_STATE
|
||||
SET_INPUT_PULLDOWN(KILL_PIN);
|
||||
#else
|
||||
SET_INPUT_PULLUP(KILL_PIN);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup_powerhold() {
|
||||
#if HAS_SUICIDE
|
||||
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
|
||||
#endif
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
powersupply_on = ENABLED(PSU_DEFAULT_OFF);
|
||||
if (ENABLED(PSU_DEFAULT_OFF)) PSU_OFF(); else PSU_ON();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Stepper Reset (RigidBoard, et.al.)
|
||||
*/
|
||||
@@ -309,18 +278,6 @@ void setup_powerhold() {
|
||||
void enableStepperDrivers() { SET_INPUT(STEPPER_RESET_PIN); } // Set to input, allowing pullups to pull the pin high
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
|
||||
|
||||
void i2c_on_receive(int bytes) { // just echo all bytes received to serial
|
||||
i2c.receive(bytes);
|
||||
}
|
||||
|
||||
void i2c_on_request() { // just send dummy data for now
|
||||
i2c.reply("Hello World!\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sensitive pin test for M42, M226
|
||||
*/
|
||||
@@ -342,17 +299,6 @@ bool pin_is_protected(const pin_t pin) {
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void protected_pin_err() {
|
||||
SERIAL_ERROR_MSG(STR_ERR_PROTECTED_PIN);
|
||||
}
|
||||
|
||||
void quickstop_stepper() {
|
||||
planner.quick_stop();
|
||||
planner.synchronize();
|
||||
set_current_from_steppers_for_axis(ALL_AXES);
|
||||
sync_plan_position();
|
||||
}
|
||||
|
||||
void enable_e_steppers() {
|
||||
#define _ENA_E(N) ENABLE_AXIS_E##N();
|
||||
REPEAT(E_STEPPERS, _ENA_E)
|
||||
@@ -389,41 +335,6 @@ void disable_all_steppers() {
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled());
|
||||
}
|
||||
|
||||
#if ENABLED(G29_RETRY_AND_RECOVER)
|
||||
|
||||
void event_probe_failure() {
|
||||
#ifdef ACTION_ON_G29_FAILURE
|
||||
host_action(PSTR(ACTION_ON_G29_FAILURE));
|
||||
#endif
|
||||
#ifdef G29_FAILURE_COMMANDS
|
||||
gcode.process_subcommands_now_P(PSTR(G29_FAILURE_COMMANDS));
|
||||
#endif
|
||||
#if ENABLED(G29_HALT_ON_FAILURE)
|
||||
#ifdef ACTION_ON_CANCEL
|
||||
host_action_cancel();
|
||||
#endif
|
||||
kill(GET_TEXT(MSG_LCD_PROBING_FAILED));
|
||||
#endif
|
||||
}
|
||||
|
||||
void event_probe_recover() {
|
||||
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR));
|
||||
#ifdef ACTION_ON_G29_RECOVER
|
||||
host_action(PSTR(ACTION_ON_G29_RECOVER));
|
||||
#endif
|
||||
#ifdef G29_RECOVER_COMMANDS
|
||||
gcode.process_subcommands_now_P(PSTR(G29_RECOVER_COMMANDS));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
#include "feature/pause.h"
|
||||
#else
|
||||
constexpr bool did_pause_print = false;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Print Job exists when the timer is running or SD printing
|
||||
*/
|
||||
@@ -511,8 +422,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
|
||||
// Prevent steppers timing-out in the middle of M600
|
||||
// unless PAUSE_PARK_NO_STEPPER_TIMEOUT is disabled
|
||||
const bool parked_or_ignoring = ignore_stepper_queue ||
|
||||
(BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print);
|
||||
const bool parked_or_ignoring = ignore_stepper_queue
|
||||
|| TERN0(PAUSE_PARK_NO_STEPPER_TIMEOUT, did_pause_print);
|
||||
|
||||
// Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout
|
||||
if (parked_or_ignoring) gcode.reset_stepper_timeout(ms);
|
||||
@@ -550,6 +461,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
}
|
||||
|
||||
#if PIN_EXISTS(CHDK) // Check if pin should be set to LOW (after M240 set it HIGH)
|
||||
extern millis_t chdk_timeout;
|
||||
if (chdk_timeout && ELAPSED(ms, chdk_timeout)) {
|
||||
chdk_timeout = 0;
|
||||
WRITE(CHDK_PIN, LOW);
|
||||
@@ -1038,13 +950,29 @@ void setup() {
|
||||
SETUP_RUN(recovery.setup());
|
||||
#endif
|
||||
|
||||
SETUP_RUN(setup_killpin());
|
||||
#if HAS_KILL
|
||||
SETUP_LOG("KILL_PIN");
|
||||
#if KILL_PIN_STATE
|
||||
SET_INPUT_PULLDOWN(KILL_PIN);
|
||||
#else
|
||||
SET_INPUT_PULLUP(KILL_PIN);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_TMC220x
|
||||
SETUP_RUN(tmc_serial_begin());
|
||||
#endif
|
||||
|
||||
SETUP_RUN(setup_powerhold());
|
||||
#if HAS_SUICIDE
|
||||
SETUP_LOG("SUICIDE_PIN")
|
||||
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
|
||||
#endif
|
||||
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
SETUP_LOG("PSU_CONTROL");
|
||||
powersupply_on = ENABLED(PSU_DEFAULT_OFF);
|
||||
if (ENABLED(PSU_DEFAULT_OFF)) PSU_OFF(); else PSU_ON();
|
||||
#endif
|
||||
|
||||
#if HAS_STEPPER_RESET
|
||||
SETUP_RUN(disableStepperDrivers());
|
||||
|
||||
Reference in New Issue
Block a user