🧑‍💻 Add a "Marlin" class
Some checks are pending
CI - Build Tests / Build Test (push) Waiting to run
CI - Unit Tests / Unit Test (push) Waiting to run
CI - Validate Source Files / Validate Source Files (push) Waiting to run

This commit is contained in:
Scott Lahteine 2025-11-24 15:16:03 -06:00
parent 0ac1435a8c
commit e99d801e6b
154 changed files with 501 additions and 531 deletions

View file

@ -119,7 +119,6 @@ void MarlinHAL::reboot() {
#if ENABLED(USE_WATCHDOG)
#include <avr/wdt.h>
#include "../../MarlinCore.h"
// Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s.
void MarlinHAL::watchdog_init() {
@ -154,7 +153,7 @@ void MarlinHAL::reboot() {
ISR(WDT_vect) {
sei(); // With the interrupt driven serial we need to allow interrupts.
SERIAL_ERROR_MSG(STR_WATCHDOG_FIRED);
minkill(); // interrupt-safe final kill and infinite loop
marlin.minkill(); // interrupt-safe final kill and infinite loop
}
#endif

View file

@ -206,7 +206,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() {}
// Reset

View file

@ -41,7 +41,6 @@
#if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
#include "MarlinSerial.h"
#include "../../MarlinCore.h"
#if ENABLED(DIRECT_STEPPING)
#include "../../feature/direct_stepping.h"

View file

@ -27,7 +27,6 @@
#ifdef ARDUINO_ARCH_SAM
#include "../../inc/MarlinConfig.h"
#include "../../MarlinCore.h"
#include <Wire.h>
#include "usb/usb_task.h"

View file

@ -132,7 +132,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask();
// Reset

View file

@ -31,7 +31,6 @@
#include "MarlinSerial.h"
#include "InterruptVectors.h"
#include "../../MarlinCore.h"
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };

View file

@ -194,7 +194,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask();
// Reset

View file

@ -67,7 +67,7 @@ public:
static void delay_ms(const int ms);
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask();
// Reset

View file

@ -126,7 +126,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() {}
// Reset

View file

@ -160,7 +160,7 @@ public:
static bool watchdog_timed_out() IF_DISABLED(USE_WATCHDOG, { return false; });
static void watchdog_clear_timeout_flag() IF_DISABLED(USE_WATCHDOG, {});
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask();
// Reset

View file

@ -49,6 +49,8 @@
#include <Servo.h>
#include "../../MarlinCore.h"
class libServo: public Servo {
public:
void move(const int value) {

View file

@ -197,7 +197,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask();
// Reset

View file

@ -144,7 +144,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() { TERN_(HAS_SD_HOST_DRIVE, tuh_task()); }
// Reset

View file

@ -144,7 +144,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() {}
// Reset

View file

@ -121,7 +121,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() {}
// Reset

View file

@ -157,7 +157,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask();
// Reset

View file

@ -187,7 +187,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask();
// Reset

View file

@ -29,8 +29,6 @@ uint8_t ServoCount = 0;
#include "Servo.h"
//#include "Servo.h"
#include <boards.h>
#include <io.h>
#include <pwm.h>

View file

@ -142,7 +142,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() {}
// Reset

View file

@ -147,7 +147,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() {}
// Reset

View file

@ -160,7 +160,7 @@ public:
static void delay_ms(const int ms) { delay(ms); }
// Tasks, called from idle()
// Tasks, called from marlin.idle()
static void idletask() {}
// Reset

View file

@ -160,10 +160,6 @@
#include "feature/spindle_laser.h"
#endif
#if HAS_MEDIA
CardReader card;
#endif
#if ENABLED(DELTA)
#include "module/delta.h"
#elif ENABLED(POLARGRAPH)
@ -264,33 +260,51 @@
#include "feature/rs485.h"
#endif
/**
* Spin in place here while keeping temperature processing alive
*/
void safe_delay(millis_t ms) {
while (ms > 50) {
ms -= 50;
delay(50);
thermalManager.task();
}
delay(ms);
thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made
}
// Singleton for Marlin global data and methods
Marlin marlin;
// Marlin static data
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
MString<64> Marlin::machine_name;
#endif
// Global state of the firmware
MarlinState Marlin::state = MarlinState::MF_INITIALIZING;
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
bool Marlin::wait_for_heatup = false;
#if !HAS_MEDIA
CardReader card; // Stub instance with "no media" methods
#endif
PGMSTR(M112_KILL_STR, "M112 Shutdown");
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
MString<64> machine_name;
#endif
MarlinState marlin_state = MarlinState::MF_INITIALIZING;
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
bool wait_for_heatup = false;
// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
#if HAS_RESUME_CONTINUE
bool wait_for_user; // = false
bool Marlin::wait_for_user; // = false
void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
void Marlin::wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
UNUSED(no_sleep);
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
wait_start();
if (ms) ms += millis(); // expire time
while (wait_for_user && !(ms && ELAPSED(millis(), ms)))
idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep));
wait_for_user = false;
user_resume();
while (ui.button_pressed()) safe_delay(50);
}
@ -320,7 +334,7 @@ bool wait_for_heatup = false;
#pragma GCC diagnostic ignored "-Wnarrowing"
#pragma GCC diagnostic ignored "-Wsign-compare"
bool pin_is_protected(const pin_t pin) {
bool Marlin::pin_is_protected(const pin_t pin) {
#define pgm_read_pin(P) (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(P) : (pin_t)pgm_read_byte(P))
for (uint8_t i = 0; i < COUNT(sensitive_dio); ++i)
if (pin == pgm_read_pin(&sensitive_dio[i])) return true;
@ -331,28 +345,28 @@ bool pin_is_protected(const pin_t pin) {
#pragma GCC diagnostic pop
bool printer_busy() {
bool Marlin::printer_busy() {
return planner.has_blocks_queued() || printingIsActive();
}
/**
* A Print Job exists when the timer is running or SD is printing
*/
bool printJobOngoing() { return print_job_timer.isRunning() || card.isStillPrinting(); }
bool Marlin::printJobOngoing() { return print_job_timer.isRunning() || card.isStillPrinting(); }
/**
* Printing is active when a job is underway but not paused
*/
bool printingIsActive() { return !did_pause_print && printJobOngoing(); }
bool Marlin::printingIsActive() { return !did_pause_print && printJobOngoing(); }
/**
* Printing is paused according to SD or host indicators
*/
bool printingIsPaused() {
bool Marlin::printingIsPaused() {
return did_pause_print || print_job_timer.isPaused() || card.isPaused();
}
void startOrResumeJob() {
void Marlin::startOrResumeJob() {
if (!printingIsPaused()) {
TERN_(GCODE_REPEAT_MARKERS, repeat.reset());
TERN_(CANCEL_OBJECTS, cancelable.reset());
@ -378,7 +392,7 @@ void startOrResumeJob() {
TERN(HAS_CUTTER, cutter.kill(), thermalManager.zero_fan_speeds()); // Full cutter shutdown including ISR control
wait_for_heatup = false;
marlin.heatup_done();
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
@ -390,8 +404,8 @@ void startOrResumeJob() {
}
inline void finishSDPrinting() {
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
marlin_state = MarlinState::MF_RUNNING; // Signal to stop trying
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
marlin.setState(MarlinState::MF_RUNNING); // Signal to stop trying
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
TERN_(DGUS_LCD_UI_MKS, screen.sdPrintingFinished());
}
@ -412,7 +426,7 @@ void startOrResumeJob() {
* - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
* - Pulse FET_SAFETY_PIN if it exists
*/
inline void manage_inactivity(const bool no_stepper_sleep=false) {
void Marlin::manage_inactivity(const bool no_stepper_sleep/*=false*/) {
queue.get_available_commands();
@ -708,7 +722,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
#if ENABLED(DUAL_X_CARRIAGE)
// handle delayed move timeout
if (delayed_move_time && ELAPSED(ms, delayed_move_time) && IsRunning()) {
if (delayed_move_time && ELAPSED(ms, delayed_move_time) && isRunning()) {
// travel moves have been received so enact them
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
destination = current_position;
@ -737,7 +751,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED);
}
#endif
} // manage_inactivity()
} // Marlin::manage_inactivity()
#if ALL(EP_BABYSTEPPING, EMERGENCY_PARSER)
#include "feature/babystep.h"
@ -765,14 +780,14 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
* - Update the Průša MMU2
* - Handle Joystick jogging
*/
void idle(const bool no_stepper_sleep/*=false*/) {
void Marlin::idle(const bool no_stepper_sleep/*=false*/) {
#ifdef MAX7219_DEBUG_PROFILE
CodeProfiler idle_profiler;
#endif
#if ENABLED(MARLIN_DEV_MODE)
static uint16_t idle_depth = 0;
if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth);
if (++idle_depth > 5) SERIAL_ECHOLNPGM("Marlin::idle() call depth: ", idle_depth);
#endif
// Bed Distance Sensor task
@ -788,7 +803,7 @@ void idle(const bool no_stepper_sleep/*=false*/) {
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
// Return if setup() isn't completed
if (marlin_state == MarlinState::MF_INITIALIZING) goto IDLE_DONE;
if (state == MarlinState::MF_INITIALIZING) goto IDLE_DONE;
// TODO: Still causing errors
TERN_(TOOL_SENSOR, (void)check_tool_sensor_stats(active_extruder, true));
@ -888,13 +903,14 @@ void idle(const bool no_stepper_sleep/*=false*/) {
TERN_(MARLIN_DEV_MODE, idle_depth--);
return;
} // idle()
} // Marlin::idle()
/**
* Kill all activity and lock the machine.
* After this the machine will need to be reset.
*/
void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
void Marlin::kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
thermalManager.disable_all_heaters();
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
@ -920,7 +936,7 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp
minkill(steppers_off);
}
void minkill(const bool steppers_off/*=false*/) {
void Marlin::minkill(const bool steppers_off/*=false*/) {
// Wait a short time (allows messages to get out before shutting down.
for (int i = 1000; i--;) DELAY_US(600);
@ -960,13 +976,14 @@ void minkill(const bool steppers_off/*=false*/) {
for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle
#endif
}
} // Marlin::minkill
/**
* Turn off heaters and stop the print in progress
* After a stop the machine may be resumed with M999
*/
void stop() {
void Marlin::stop() {
thermalManager.disable_all_heaters(); // 'unpause' taken care of in here
print_job_timer.stop();
@ -975,13 +992,13 @@ void stop() {
thermalManager.set_fans_paused(false); // Un-pause fans for safety
#endif
if (!IsStopped()) {
if (!isStopped()) {
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
LCD_MESSAGE(MSG_STOPPED);
safe_delay(350); // allow enough time for messages to get out before stopping
marlin_state = MarlinState::MF_STOPPED;
safe_delay(350); // Allow enough time for messages to get out before stopping
state = MarlinState::MF_STOPPED;
}
} // stop()
} // Marlin::stop()
inline void tmc_standby_setup() {
#if PIN_EXISTS(X_STDBY)
@ -1692,7 +1709,7 @@ void setup() {
SETUP_RUN(ftMotion.init());
#endif
marlin_state = MarlinState::MF_RUNNING;
marlin.setState(MarlinState::MF_RUNNING);
#ifdef STARTUP_TUNE
// Play a short startup tune before continuing.
@ -1708,7 +1725,7 @@ void setup() {
/**
* The main Marlin program loop
*
* - Call idle() to handle all tasks between G-code commands
* - Call marlin.idle() to handle all tasks between G-code commands
* Note that no G-codes from the queue can be executed during idle()
* but many G-codes can be called directly anytime like macros.
* - Check whether SD card auto-start is needed now.
@ -1720,11 +1737,11 @@ void setup() {
*/
void loop() {
do {
idle();
marlin.idle();
#if HAS_MEDIA
if (card.flag.abort_sd_printing) abortSDPrinting();
if (marlin_state == MarlinState::MF_SD_COMPLETE) finishSDPrinting();
if (marlin.is(MarlinState::MF_SD_COMPLETE)) finishSDPrinting();
#endif
queue.advance();

View file

@ -27,19 +27,6 @@
#include <stdio.h>
#include <stdlib.h>
void stop();
// Pass true to keep steppers from timing out
void idle(const bool no_stepper_sleep=false);
inline void idle_no_sleep() { idle(true); }
void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false);
void minkill(const bool steppers_off=false);
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
extern MString<64> machine_name;
#endif
// Global State of the firmware
enum class MarlinState : uint8_t {
MF_INITIALIZING = 0,
@ -51,35 +38,81 @@ enum class MarlinState : uint8_t {
MF_WAITING,
};
extern MarlinState marlin_state;
inline bool IsRunning() { return marlin_state >= MarlinState::MF_RUNNING; }
inline bool IsStopped() { return marlin_state == MarlinState::MF_STOPPED; }
typedef bool (*testFunc_t)();
bool printingIsActive();
bool printJobOngoing();
bool printingIsPaused();
void startOrResumeJob();
// Delay ensuring that temperatures are updated and the watchdog is kept alive
void safe_delay(millis_t ms);
bool printer_busy();
// Singleton for Marlin global data and methods
extern bool wait_for_heatup;
#if HAS_RESUME_CONTINUE
extern bool wait_for_user;
void wait_for_user_response(millis_t ms=0, const bool no_sleep=false);
#endif
bool pin_is_protected(const pin_t pin);
#if HAS_SUICIDE
inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_STATE); }
#endif
#if HAS_KILL
#ifndef KILL_PIN_STATE
#define KILL_PIN_STATE LOW
class Marlin {
public:
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
static MString<64> machine_name;
#endif
inline bool kill_state() { return READ(KILL_PIN) == KILL_PIN_STATE; }
#endif
static MarlinState state;
static void setState(const MarlinState s) { state = s; }
static bool is(const MarlinState s) { return state == s; }
static bool isStopped() { return is(MarlinState::MF_STOPPED); }
static bool isRunning() { return state >= MarlinState::MF_RUNNING; }
static bool printingIsActive();
static bool printJobOngoing();
static bool printingIsPaused();
static void startOrResumeJob();
static bool printer_busy();
static void stop();
// Maintain all important activities
static void manage_inactivity(const bool no_stepper_sleep=false);
// Pass true to keep steppers from timing out
static void idle(const bool no_stepper_sleep=false);
static void idle_no_sleep() { idle(true); }
static void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false);
static void minkill(const bool steppers_off=false);
#if HAS_RESUME_CONTINUE
// Global waiting for user response
static bool wait_for_user;
static void wait_start() { wait_for_user = true; }
static void user_resume() { wait_for_user = false; }
static void wait_for_user_response(millis_t ms=0, const bool no_sleep=false);
#endif
// Global waiting for heatup state
static bool wait_for_heatup;
static bool is_heating() { return wait_for_heatup; }
static void heatup_start() { wait_for_heatup = true; }
static void heatup_done() { wait_for_heatup = false; }
static void end_waiting() { TERN_(HAS_RESUME_CONTINUE, wait_for_user =) wait_for_heatup = false; }
// Shared function for M42 / M43
static bool pin_is_protected(const pin_t pin);
#if HAS_SUICIDE
static void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_STATE); }
#endif
static bool kill_state() {
return (
#if HAS_KILL
#ifndef KILL_PIN_STATE
#define KILL_PIN_STATE LOW
#endif
READ(KILL_PIN) == KILL_PIN_STATE
#else
false
#endif
);
}
};
extern Marlin marlin;
extern const char M112_KILL_STR[];

View file

@ -210,6 +210,8 @@
#define STR_KILL_BUTTON "KILL button/pin"
// temperature.cpp strings
#define STR_WAIT_FOR_HOTEND "Wait for hotend heating..."
#define STR_WAIT_FOR_BED "Wait for bed heating..."
#define STR_PID_AUTOTUNE "PID Autotune"
#define STR_PID_AUTOTUNE_START " start"
#define STR_PID_BAD_HEATER_ID " failed! Bad heater id"
@ -230,6 +232,8 @@
#define STR_PID_DEBUG_INPUT ": Input "
#define STR_PID_DEBUG_OUTPUT " Output "
#define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !"
// MPCTEMP strings
#define STR_MPC_AUTOTUNE_START "MPC Autotune start for " STR_E
#define STR_MPC_AUTOTUNE_INTERRUPTED "MPC Autotune interrupted!"
#define STR_MPC_AUTOTUNE_FINISHED "MPC Autotune finished! Put the constants below into Configuration.h"
@ -238,6 +242,7 @@
#define STR_MPC_MEASURING_AMBIENT "Measuring ambient heatloss at "
#define STR_MPC_TEMPERATURE_ERROR "Temperature error"
// Temperature Sensors
#define STR_HEATER_BED "bed"
#define STR_HEATER_CHAMBER "chamber"
#define STR_COOLER "cooler"
@ -247,6 +252,7 @@
#define STR_REDUNDANT "redundant "
#define STR_LASER_TEMP "laser temperature"
// Misc. Errors, Thermal Runaway
#define STR_STOPPED_HEATER ", system stopped! Heater_ID: "
#define STR_DETECTED_TEMP_B " (temp: "
#define STR_DETECTED_TEMP_E ")"
@ -269,6 +275,7 @@
#define STR_DEBUG_COMMUNICATION "COMMUNICATION"
#define STR_DEBUG_DETAIL "DETAIL"
// Password Security
#define STR_PRINTER_LOCKED "Printer locked! (Unlock with M511 or LCD)"
#define STR_WRONG_PASSWORD "Incorrect Password"
#define STR_PASSWORD_TOO_LONG "Password too long"

View file

@ -22,26 +22,16 @@
#include "utility.h"
#include "../MarlinCore.h"
#include "../module/temperature.h"
#if ENABLED(MARLIN_DEV_MODE)
MarlinError marlin_error_number; // Error Number - Marlin can beep X times periodically, display, and emit...
#endif
void safe_delay(millis_t ms) {
while (ms > 50) {
ms -= 50;
delay(50);
thermalManager.task();
}
delay(ms);
thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made
}
// A delay to provide brittle hosts time to receive bytes
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
#include "../MarlinCore.h" // for safe_delay
#include "../gcode/gcode.h" // for set_autoreport_paused
void serial_delay(const millis_t ms) {

View file

@ -25,8 +25,6 @@
#include "../core/types.h"
#include "../core/millis_t.h"
void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive.
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
void serial_delay(const millis_t ms);
#else

View file

@ -25,7 +25,6 @@
#if ENABLED(BABYSTEPPING)
#include "babystep.h"
#include "../MarlinCore.h"
#include "../module/motion.h" // for axis_should_home(), BABYSTEP_ALLOWED
#include "../module/planner.h" // for axis_steps_per_mm[]
#include "../module/stepper.h"

View file

@ -24,7 +24,6 @@
#if ENABLED(BD_SENSOR)
#include "../../../MarlinCore.h"
#include "../../../gcode/gcode.h"
#include "../../../module/settings.h"
#include "../../../module/motion.h"
@ -110,7 +109,7 @@ float BDS_Leveling::read() {
}
void BDS_Leveling::process() {
if (config_state == BDS_IDLE && printingIsActive()) return;
if (config_state == BDS_IDLE && marlin.printingIsActive()) return;
static millis_t next_check_ms = 0; // starting at T=0
static float zpos = 0.0f;
const millis_t ms = millis();
@ -156,7 +155,7 @@ void BDS_Leveling::process() {
}
else if (config_state == BDS_HOMING_Z) {
SERIAL_ECHOLNPGM("Read:", tmp);
kill(F("BDsensor connect Err!"));
marlin.kill(F("BDsensor connect Err!"));
}
DEBUG_ECHOLNPGM("BD:", tmp & 0x3FF, " Z:", cur_z, "|", current_position.z);

View file

@ -28,7 +28,6 @@
unified_bed_leveling bedlevel;
#include "../../../MarlinCore.h"
#include "../../../gcode/gcode.h"
#include "../../../module/settings.h"
@ -221,7 +220,7 @@ void unified_bed_leveling::display_map(const uint8_t map_type) {
if (human) SERIAL_CHAR(is_current ? ']' : ' ');
SERIAL_FLUSHTX();
idle_no_sleep();
marlin.idle_no_sleep();
}
if (!lcd) SERIAL_EOL();

View file

@ -26,7 +26,6 @@
#include "../bedlevel.h"
#include "../../../MarlinCore.h"
#include "../../../HAL/shared/eeprom_api.h"
#include "../../../libs/hex_print.h"
#include "../../../module/settings.h"
@ -375,7 +374,7 @@ void unified_bed_leveling::G29() {
bool invalidate_all = count >= GRID_MAX_POINTS;
if (!invalidate_all) {
while (count--) {
if ((count & 0x0F) == 0x0F) idle();
if ((count & 0x0F) == 0x0F) marlin.idle();
const mesh_index_pair closest = find_closest_mesh_point_of_type(REAL, param.XY_pos);
// No more REAL mesh points to invalidate? Assume the user meant
// to invalidate the ENTIRE mesh, which can't be done with
@ -856,7 +855,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
ui.quick_feedback(false); // Preserve button state for click-and-hold
const millis_t nxt = millis() + 1500UL;
while (ui.button_pressed()) { // Loop while the encoder is pressed. Uses hardware flag!
idle(); // idle, of course
marlin.idle(); // idle, of course
if (ELAPSED(millis(), nxt)) { // After 1.5 seconds
ui.quick_feedback();
if (func) (*func)();
@ -872,7 +871,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
void unified_bed_leveling::move_z_with_encoder(const float multiplier) {
ui.wait_for_release();
while (!ui.button_pressed()) {
idle();
marlin.idle();
gcode.reset_stepper_timeout(); // Keep steppers powered
if (encoder_diff) {
do_blocking_move_to_z(current_position.z + float(encoder_diff) * multiplier);
@ -1088,7 +1087,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
SET_SOFT_ENDSTOP_LOOSE(true);
do {
idle_no_sleep();
marlin.idle_no_sleep();
new_z = ui.ubl_mesh_value();
TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
@ -1728,7 +1727,7 @@ void unified_bed_leveling::smart_fill_mesh() {
const float ez = -lsf_results.D - lsf_results.A * ppos.x - lsf_results.B * ppos.y;
z_values[ix][iy] = ez;
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]));
idle(); // housekeeping
marlin.idle(); // housekeeping
}
}
}
@ -1785,7 +1784,7 @@ void unified_bed_leveling::smart_fill_mesh() {
SERIAL_EOL();
#if HAS_KILL
SERIAL_ECHOLNPGM("Kill pin on :", KILL_PIN, " state:", kill_state());
SERIAL_ECHOLNPGM("Kill pin on :", KILL_PIN, " state:", marlin.kill_state());
#endif
SERIAL_EOL();
@ -1823,7 +1822,7 @@ void unified_bed_leveling::smart_fill_mesh() {
SERIAL_ECHO_MSG("EEPROM Dump:");
persistentStore.access_start();
for (uint16_t i = 0; i < persistentStore.capacity(); i += 16) {
if (!(i & 0x3)) idle();
if (!(i & 0x3)) marlin.idle();
print_hex_word(i);
SERIAL_ECHOPGM(": ");
for (uint16_t j = 0; j < 16; j++) {

View file

@ -32,7 +32,6 @@
#include "../../../module/delta.h"
#endif
#include "../../../MarlinCore.h"
#include <math.h>
//#define DEBUG_UBL_MOTION

View file

@ -10,7 +10,6 @@
#include "dac_dac084s085.h"
#include "../../MarlinCore.h"
#include "../../HAL/shared/Delay.h"
dac084s085::dac084s085() { }

View file

@ -175,7 +175,7 @@ namespace DirectStepping {
template <typename Cfg>
void SerialPageManager<Cfg>::write_responses() {
if (fatal_error) {
kill(GET_TEXT_F(MSG_BAD_PAGE));
marlin.kill(GET_TEXT_F(MSG_BAD_PAGE));
return;
}

View file

@ -49,9 +49,6 @@ bool EmergencyParser::killed_by_M112, // = false
// Global instance
EmergencyParser emergency_parser;
// External references
extern bool wait_for_user, wait_for_heatup;
#if ENABLED(EP_BABYSTEPPING)
#include "babystep.h"
#endif
@ -208,7 +205,7 @@ void EmergencyParser::update(EmergencyParser::State &state, const uint8_t c) {
default:
if (ISEOL(c)) {
if (enabled) switch (state) {
case EP_M108: wait_for_user = wait_for_heatup = false; break;
case EP_M108: marlin.end_waiting(); break;
case EP_M112: killed_by_M112 = true; break;
case EP_M410: quickstop_by_M410 = true; break;
#if ENABLED(FTM_RESONANCE_TEST)

View file

@ -91,7 +91,7 @@ void EasythreedUI::blinkLED() {
// Load/Unload buttons are a 3 position switch with a common center ground.
//
void EasythreedUI::loadButton() {
if (printingIsActive()) return;
if (marlin.printingIsActive()) return;
enum FilamentStatus : uint8_t { FS_IDLE, FS_PRESS, FS_CHECK, FS_PROCEED };
static uint8_t filament_status = FS_IDLE;
@ -185,7 +185,7 @@ void EasythreedUI::printButton() {
if (PENDING(ms, key_time, 1200 - BTN_DEBOUNCE_MS)) { // Register a press < 1.2 seconds
switch (print_key_flag) {
case PF_START: { // The "Print" button starts an SD card print
if (printingIsActive()) break; // Already printing? (find another line that checks for 'is planner doing anything else right now?')
if (marlin.printingIsActive()) break; // Already printing? (find another line that checks for 'is planner doing anything else right now?')
blink_interval_ms = LED_BLINK_2; // Blink the indicator LED at 1 second intervals
print_key_flag = PF_PAUSE; // The "Print" button now pauses the print
card.mount(); // Force SD card to mount - now!
@ -201,13 +201,13 @@ void EasythreedUI::printButton() {
card.openAndPrintFile(card.filename); // Start printing it
} break;
case PF_PAUSE: { // Pause printing (not currently firing)
if (!printingIsActive()) break;
if (!marlin.printingIsActive()) break;
blink_interval_ms = LED_ON; // Set indicator to steady ON
queue.inject(F("M25")); // Queue Pause
print_key_flag = PF_RESUME; // The "Print" button now resumes the print
} break;
case PF_RESUME: { // Resume printing
if (printingIsActive()) break;
if (marlin.printingIsActive()) break;
blink_interval_ms = LED_BLINK_2; // Blink the indicator LED at 1 second intervals
queue.inject(F("M24")); // Queue resume
print_key_flag = PF_PAUSE; // The "Print" button now pauses the print
@ -215,7 +215,7 @@ void EasythreedUI::printButton() {
}
}
else { // Register a longer press
if (print_key_flag == PF_START && !printingIsActive()) { // While not printing, this moves Z up 10mm
if (print_key_flag == PF_START && !marlin.printingIsActive()) { // While not printing, this moves Z up 10mm
blink_interval_ms = LED_ON;
queue.inject(F("G91\nG0 Z10 F600\nG90")); // Raise Z soon after returning to main loop
}

View file

@ -149,7 +149,7 @@ void I2CPositionEncoder::update() {
#ifdef I2CPE_ERR_THRESH_ABORT
if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.settings.axis_steps_per_mm[encoderAxis]) {
//kill(F("Significant Error"));
//marlin.kill(F("Significant Error"));
SERIAL_ECHOLNPGM("Axis error over threshold, aborting!", error);
safe_delay(5000);
}

View file

@ -93,7 +93,7 @@ void FanCheck::compute_speed(uint16_t elapsedTime) {
// Drop the error when all fans are ok
if (!fan_error_msk && error == TachoError::REPORTED) error = TachoError::FIXED;
if (error == TachoError::FIXED && !printJobOngoing() && !printingIsPaused()) {
if (error == TachoError::FIXED && !marlin.printJobOngoing() && !marlin.printingIsPaused()) {
error = TachoError::NONE; // if the issue has been fixed while the printer is idle, reenable immediately
ui.reset_alert_level();
}
@ -106,17 +106,17 @@ void FanCheck::compute_speed(uint16_t elapsedTime) {
}
void FanCheck::report_speed_error(uint8_t fan) {
if (printJobOngoing()) {
if (marlin.printJobOngoing()) {
if (error == TachoError::NONE) {
if (thermalManager.degTargetHotend(fan) != 0) {
kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT));
marlin.kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT));
error = TachoError::REPORTED;
}
else
error = TachoError::DETECTED; // Plans error for next processed command
}
}
else if (!printingIsPaused()) {
else if (!marlin.printingIsPaused()) {
thermalManager.setTargetHotend(0, fan); // Always disable heating
if (error == TachoError::NONE) error = TachoError::REPORTED;
}

View file

@ -25,7 +25,6 @@
#if HAS_FANCHECK
#include "../MarlinCore.h"
#include "../lcd/marlinui.h"
#if ENABLED(AUTO_REPORT_FANS)
@ -74,7 +73,11 @@ class FanCheck {
static void check_deferred_error() {
if (error == TachoError::DETECTED) {
error = TachoError::REPORTED;
TERN(PARK_HEAD_ON_PAUSE, queue.inject(F("M125")), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)));
#if ENABLED(PARK_HEAD_ON_PAUSE)
queue.inject(F("M125"));
#else
marlin.kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT));
#endif
}
}

View file

@ -87,10 +87,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
PGMSTR(CONTINUE_STR, "Continue");
PGMSTR(DISMISS_STR, "Dismiss");
#if HAS_RESUME_CONTINUE
extern bool wait_for_user;
#endif
void HostUI::notify(const char * const cstr) {
PORT_REDIRECT(SerialMask::All);
action(F("notification "), false);
@ -205,7 +201,7 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
}
break;
case PROMPT_USER_CONTINUE:
TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
TERN_(HAS_RESUME_CONTINUE, marlin.user_resume());
break;
case PROMPT_PAUSE_RESUME:
#if ALL(ADVANCED_PAUSE_FEATURE, HAS_MEDIA)

View file

@ -43,7 +43,7 @@ millis_t HotendIdleProtection::next_protect_ms = 0;
hotend_idle_settings_t HotendIdleProtection::cfg; // Initialized by settings.load
void HotendIdleProtection::check_hotends(const millis_t &ms) {
const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued());
const bool busy = (TERN0(HAS_RESUME_CONTINUE, marlin.wait_for_user) || planner.has_blocks_queued());
bool do_prot = false;
if (!busy && cfg.timeout != 0) {
HOTEND_LOOP() {

View file

@ -74,14 +74,13 @@
#ifdef MAX7219_DEBUG_PROFILE
// This class sums up the amount of time for which its instances exist.
// By default there is one instantiated for the duration of the idle()
// function. But an instance can be created in any code block to measure
// the time spent from the point of instantiation until the CPU leaves
// block. Be careful about having multiple instances of CodeProfiler as
// it does not guard against double counting. In general mixing ISR and
// non-ISR use will require critical sections but note that mode setting
// is atomic so the total or average times can safely be read if you set
// mode to FREEZE first.
// By default there is one instantiated for the duration of marlin.idle()
// but an instance can be created in any code block to measure time spent
// from instantiation until the CPU leaves the block.
// Be careful about having multiple instances of CodeProfiler as it does
// not guard against double counting. In general mixing ISR and non-ISR
// use will require critical sections but note that mode setting is atomic
// so the total or average times can safely be read if you set mode to FREEZE first.
class CodeProfiler {
public:
enum Mode : uint8_t { ACCUMULATE_AVERAGE, ACCUMULATE_TOTAL, FREEZE };

View file

@ -24,7 +24,6 @@
#if HAS_PRUSA_MMU1
#include "../../MarlinCore.h"
#include "../../module/planner.h"
#include "../../module/stepper.h"

View file

@ -40,7 +40,6 @@ MMU2 mmu2;
#include "../../module/temperature.h"
#include "../../module/planner.h"
#include "../../module/stepper.h"
#include "../../MarlinCore.h"
#if ENABLED(HOST_PROMPT_SUPPORT)
#include "../host_actions.h"
@ -446,7 +445,7 @@ bool MMU2::rx_ok() {
void MMU2::check_version(const uint16_t buildnr) {
if (buildnr < MMU_REQUIRED_FW_BUILDNR) {
SERIAL_ERROR_MSG("Invalid MMU2 firmware. Version >= " STRINGIFY(MMU_REQUIRED_FW_BUILDNR) " required.");
kill(GET_TEXT_F(MSG_KILL_MMU2_FIRMWARE));
marlin.kill(GET_TEXT_F(MSG_KILL_MMU2_FIRMWARE));
}
}
@ -786,10 +785,10 @@ void MMU2::command(const uint8_t mmu_cmd) {
* Wait for response from MMU
*/
bool MMU2::get_response() {
while (cmd != MMU_CMD_NONE) idle();
while (cmd != MMU_CMD_NONE) marlin.idle();
while (!ready) {
idle();
marlin.idle();
if (state != 3) break;
}
@ -985,7 +984,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
mmu2_attn_buzz();
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response());
mmu2_attn_buzz();
command(MMU_CMD_R0);

View file

@ -274,7 +274,7 @@ namespace MMU3 {
*/
void MMU3::checkFINDARunout() {
if (!findaDetectsFilament()
//&& printJobOngoing()
//&& marlin.printJobOngoing()
&& parser.codenum != 600
&& TERN1(HAS_LEVELING, planner.leveling_active)
&& xy_are_trusted()
@ -857,7 +857,7 @@ namespace MMU3 {
for (;;) {
// in our new implementation, we know the exact state of the MMU at any moment, we do not have to wait for a timeout
// So in this case we should decide if the operation is:
// - still running -> wait normally in idle()
// - still running -> wait normally in marlin.idle()
// - failed -> then do the safety moves on the printer like before
// - finished ok -> proceed with reading other commands
safe_delay_keep_alive(0); // calls logicStep() and remembers its return status

View file

@ -122,15 +122,15 @@ namespace MMU3 {
#endif
}
bool marlin_printingIsActive() { return printingIsActive(); }
bool marlin_printingIsActive() { return marlin.printingIsActive(); }
void marlin_manage_heater() { thermalManager.task(); }
void marlin_manage_inactivity(const bool b) { idle(b); }
void marlin_manage_inactivity(const bool b) { marlin.idle(b); }
void marlin_idle(bool b) {
void marlin_idle(const bool b) {
thermalManager.task();
idle(b);
marlin.idle(b);
}
void marlin_refresh_print_state_in_ram() {
@ -157,7 +157,7 @@ namespace MMU3 {
void thermal_setTargetHotend(int16_t t) { thermalManager.setTargetHotend(t, 0); }
void safe_delay_keep_alive(uint16_t t) {
idle(true);
marlin.idle(true);
safe_delay(t);
}

View file

@ -213,7 +213,7 @@ namespace MMU3 {
void EndReport(CommandInProgress /*cip*/, ProgressCode /*ec*/) {
// clear the status msg line - let the printed filename get visible again
if (!printJobOngoing()) ui.reset_status();
if (!marlin.printJobOngoing()) ui.reset_status();
//custom_message_type = CustomMsg::Status;
}

View file

@ -187,7 +187,7 @@
}
// Wait for 5 seconds before displaying the next text.
for (uint8_t i = 0; i < 100; ++i) {
idle(true);
marlin.idle(true);
safe_delay(50);
if (ui.use_click()) {
if (fmsg_next == nullptr) {

View file

@ -160,10 +160,10 @@ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=P
if (wait) return thermalManager.wait_for_hotend(active_extruder);
// Allow interruption by Emergency Parser M108
wait_for_heatup = TERN1(PREVENT_COLD_EXTRUSION, !thermalManager.allow_cold_extrude);
while (wait_for_heatup && ABS(thermalManager.wholeDegHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > (TEMP_WINDOW))
idle();
wait_for_heatup = false;
marlin.wait_for_heatup = TERN1(PREVENT_COLD_EXTRUSION, !thermalManager.allow_cold_extrude);
while (marlin.is_heating() && ABS(thermalManager.wholeDegHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > (TEMP_WINDOW))
marlin.idle();
marlin.heatup_done();
#if ENABLED(PREVENT_COLD_EXTRUSION)
// A user can cancel wait-for-heating with M108
@ -206,7 +206,7 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len
first_impatient_beep(max_beep_count);
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this
marlin.wait_start(); // LCD click or M108 will clear this
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENTLOAD)));
@ -215,19 +215,19 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len
hostui.prompt_do(PROMPT_USER_CONTINUE, F("Load Filament T"), tool, FPSTR(CONTINUE_STR));
#endif
while (wait_for_user) {
while (marlin.wait_for_user) {
impatient_beep(max_beep_count);
#if ALL(HAS_FILAMENT_SENSOR, FILAMENT_CHANGE_RESUME_ON_INSERT)
#if MULTI_FILAMENT_SENSOR
#define _CASE_INSERTED(N) case N-1: if (!FILAMENT_IS_OUT(N)) wait_for_user = false; break;
#define _CASE_INSERTED(N) case N-1: if (!FILAMENT_IS_OUT(N)) marlin.user_resume(); break;
switch (active_extruder) {
REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED)
}
#else
if (!FILAMENT_IS_OUT()) wait_for_user = false;
if (!FILAMENT_IS_OUT()) marlin.user_resume();
#endif
#endif
idle_no_sleep();
marlin.idle_no_sleep();
}
}
@ -270,10 +270,10 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)));
wait_for_user = true; // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
marlin.wait_start(); // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && marlin.wait_for_user; --purge_count)
unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
wait_for_user = false;
marlin.user_resume();
#else
@ -297,14 +297,14 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len
if (show_lcd) {
// Show "Purge More" / "Resume" menu and wait for reply
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = false;
marlin.user_resume();
#if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI)
ui.pause_show_message(PAUSE_MESSAGE_OPTION); // MarlinUI and MKS UI also set PAUSE_RESPONSE_WAIT_FOR
#else
pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
TERN_(SOVOL_SV06_RTS, rts.gotoPage(ID_PurgeMore_L, ID_PurgeMore_D));
#endif
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle_no_sleep();
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) marlin.idle_no_sleep();
}
#endif
@ -553,8 +553,8 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
KEEPALIVE_STATE(PAUSED_FOR_USER);
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_NOZZLE_PARKED)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_NOZZLE_PARKED)));
wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user) {
marlin.wait_start(); // LCD click or M108 will clear this
while (marlin.wait_for_user) {
impatient_beep(max_beep_count);
// If the nozzle has timed out...
@ -579,7 +579,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_HEATER_TIMEOUT));
#endif
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(0, true)); // Wait for LCD click or M108
TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response(0, true)); // Wait for LCD click or M108
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_INFO, GET_TEXT_F(MSG_REHEATING)));
@ -606,12 +606,12 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
LCD_MESSAGE(MSG_REHEATDONE);
#endif
IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true);
IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, marlin.wait_start());
nozzle_timed_out = false;
first_impatient_beep(max_beep_count);
}
idle_no_sleep();
marlin.idle_no_sleep();
}
TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext));
}

View file

@ -119,7 +119,7 @@ void Power::power_on() {
* Processes any PSU_POWEROFF_GCODE and makes a PS_OFF_SOUND if enabled.
*/
void Power::power_off() {
TERN_(HAS_SUICIDE, suicide());
TERN_(HAS_SUICIDE, marlin.suicide());
if (!psu_on) return;
@ -208,7 +208,7 @@ void Power::power_off() {
// If any of the stepper drivers are enabled...
if (stepper.axis_enabled.bits) return true;
if (printJobOngoing() || printingIsPaused()) return true;
if (marlin.printJobOngoing() || marlin.printingIsPaused()) return true;
#if ENABLED(AUTO_POWER_FANS)
FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true;

View file

@ -321,7 +321,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
void PrintJobRecovery::_outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated/*=false*/)) {
#if ENABLED(BACKUP_POWER_SUPPLY)
static bool lock = false;
if (lock) return; // No re-entrance from idle() during retract_and_lift()
if (lock) return; // No re-entrance from marlin.idle() during retract_and_lift()
lock = true;
#endif
@ -355,7 +355,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
sync_plan_position();
}
else
kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY));
marlin.kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY));
}
#endif // POWER_LOSS_PIN || DEBUG_POWER_LOSS_RECOVERY

View file

@ -31,7 +31,6 @@
#include "../module/stepper.h" // for block_t
#include "../gcode/queue.h"
#include "pause.h" // for did_pause_print
#include "../MarlinCore.h" // for printingIsActive()
#include "../inc/MarlinConfig.h"
@ -64,7 +63,7 @@ typedef Flags<
> runout_flags_t;
void event_filament_runout(const uint8_t extruder);
inline bool should_monitor_runout() { return did_pause_print || printingIsActive(); }
inline bool should_monitor_runout() { return did_pause_print || marlin.printingIsActive(); }
template<class RESPONSE_T, class SENSOR_T>
class TFilamentMonitor;

View file

@ -112,7 +112,7 @@ void SpindleLaser::init() {
const millis_t duration = (float(SPEED_POWER_MAX) * (60000.f / 2550.f) / float(acceleration_spindle_deg_per_s2)) * abs_diff;
millis_t next_ocr_change = millis() + duration;
while (current_ocr != ocr) {
while (PENDING(millis(), next_ocr_change)) idle();
while (PENDING(millis(), next_ocr_change)) marlin.idle();
current_ocr += diff > 0 ? 1 : -1;
hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), current_ocr ^ SPINDLE_LASER_PWM_OFF);
next_ocr_change += duration;

View file

@ -31,7 +31,6 @@
*/
#include "tmc_util.h"
#include "../MarlinCore.h"
#include "../module/stepper/indirection.h"
#include "../module/printcounter.h"
@ -283,7 +282,7 @@
if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit");
TERN_(TMC_DEBUG, tmc_report_all());
TERN_(SOVOL_SV06_RTS, rts.gotoPage(ID_DriverError_L, ID_DriverError_D));
kill(F("Driver error"));
marlin.kill(F("Driver error"));
}
#endif

View file

@ -105,7 +105,6 @@
#include "../gcode.h"
#include "../../feature/bedlevel/bedlevel.h"
#include "../../MarlinCore.h"
#include "../../module/planner.h"
#include "../../module/motion.h"
#include "../../module/tool_change.h"

View file

@ -25,7 +25,6 @@
#if HAS_MESH
#include "../gcode.h"
#include "../../MarlinCore.h" // for IsRunning()
#include "../../module/motion.h"
#include "../../feature/bedlevel/bedlevel.h"

View file

@ -759,7 +759,7 @@ G29_TYPE GcodeSuite::G29() {
for (;;) {
pos = planner.get_axis_position_mm(axis);
if (inInc > 0 ? (pos >= cmp) : (pos <= cmp)) break;
idle_no_sleep();
marlin.idle_no_sleep();
}
//if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM_P(axis == Y_AXIS ? PSTR("Y=") : PSTR("X=", pos);
@ -803,7 +803,7 @@ G29_TYPE GcodeSuite::G29() {
#endif
abl.reenable = false; // Don't re-enable after modifying the mesh
idle_no_sleep();
marlin.idle_no_sleep();
} // inner
} // outer

View file

@ -96,7 +96,7 @@
void GcodeSuite::G76() {
auto report_temps = [](millis_t &ntr, millis_t timeout=0) {
idle_no_sleep();
marlin.idle_no_sleep();
const millis_t ms = millis();
if (ELAPSED(ms, ntr)) {
ntr = ms + 1000;

View file

@ -28,8 +28,6 @@
#include "../queue.h"
#include "../../libs/hex_print.h"
#include "../../MarlinCore.h" // for idle()
/**
* M100: Free Memory Watcher
*
@ -178,7 +176,7 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
SERIAL_EOL();
start_free_memory += 16;
serial_delay(25);
idle();
marlin.idle();
}
}
@ -209,12 +207,12 @@ inline int check_for_free_memory_corruption(FSTR_P const title) {
if (end_free_memory < start_free_memory) {
SERIAL_ECHOPGM(" end_free_memory < Heap ");
//SET_INPUT_PULLUP(63); // if the developer has a switch wired up to their controller board
//safe_delay(5); // this code can be enabled to pause the display as soon as the
//while ( READ(63)) // malfunction is detected. It is currently defaulting to a switch
// idle(); // being on pin-63 which is unassigend and available on most controller
//safe_delay(20); // boards.
//safe_delay(5); // this code can be enabled to pause the display as soon as the
//while ( READ(63)) // malfunction is detected. It is currently defaulting to a switch
// marlin.idle(); // being on pin-63 which is unassigend and available on most controller
//safe_delay(20); // boards.
//while ( !READ(63))
// idle();
// marlin.idle();
serial_delay(20);
#if ENABLED(M100_FREE_MEMORY_DUMPER)
M100_dump_routine(F(" Memory corruption detected with end_free_memory<Heap\n"), (const char*)0x1B80, 0x0680);

View file

@ -25,7 +25,6 @@
#if ENABLED(PINS_DEBUGGING)
#include "../gcode.h"
#include "../../MarlinCore.h" // for pin_is_protected, wait_for_user
#include "../../pins/pinsDebug.h"
#include "../../module/endstops.h"
@ -64,7 +63,7 @@ inline void toggle_pins() {
for (uint8_t i = start; i <= end; ++i) {
pin_t pin = GET_PIN_MAP_PIN_M43(i);
if (!isValidPin(pin)) continue;
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
if (M43_NEVER_TOUCH(i) || (!ignore_protection && marlin.pin_is_protected(pin))) {
printPinStateExt(pin, ignore_protection, true, F("Untouched "));
SERIAL_EOL();
}
@ -328,7 +327,7 @@ void GcodeSuite::M43() {
for (uint8_t i = first_pin; i <= last_pin; ++i) {
pin_t pin = GET_PIN_MAP_PIN_M43(i);
if (!isValidPin(pin)) continue;
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
if (M43_NEVER_TOUCH(i) || (!ignore_protection && marlin.pin_is_protected(pin))) continue;
can_watch = true;
pinMode(pin, INPUT_PULLUP);
delay(1);
@ -358,7 +357,7 @@ void GcodeSuite::M43() {
#if HAS_RESUME_CONTINUE
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
marlin.wait_start();
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(F("M43 Waiting...")));
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired(F("M43 Waiting..."));
@ -371,7 +370,7 @@ void GcodeSuite::M43() {
for (uint8_t i = first_pin; i <= last_pin; ++i) {
const pin_t pin = GET_PIN_MAP_PIN_M43(i);
if (!isValidPin(pin)) continue;
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
if (M43_NEVER_TOUCH(i) || (!ignore_protection && marlin.pin_is_protected(pin))) continue;
const byte val =
/*
isAnalogPin(pin)
@ -387,7 +386,7 @@ void GcodeSuite::M43() {
#if HAS_RESUME_CONTINUE
ui.update();
if (!wait_for_user) break;
if (!marlin.wait_for_user) break;
#endif
safe_delay(200);

View file

@ -25,7 +25,6 @@
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
#include "../gcode.h"
#include "../../MarlinCore.h"
#include "../../lcd/marlinui.h"
/**
@ -39,20 +38,20 @@ void GcodeSuite::M550() {
bool did_set = true;
if (parser.seenval('P'))
machine_name = parser.value_string();
marlin.machine_name = parser.value_string();
else if (TERN(GCODE_QUOTED_STRINGS, false, parser.seen('P')))
machine_name = parser.string_arg[0] == 'P' ? &parser.string_arg[1] : parser.string_arg;
marlin.machine_name = parser.string_arg[0] == 'P' ? &parser.string_arg[1] : parser.string_arg;
else if (parser.has_string())
machine_name = parser.string_arg;
marlin.machine_name = parser.string_arg;
else
did_set = false;
if (did_set) {
machine_name.trim();
marlin.machine_name.trim();
ui.reset_status(false);
}
else
SERIAL_ECHOLNPGM("RepRap name: ", &machine_name);
SERIAL_ECHOLNPGM("RepRap name: ", &marlin.machine_name);
}

View file

@ -25,22 +25,20 @@
#if DISABLED(EMERGENCY_PARSER)
#include "../gcode.h"
#include "../../MarlinCore.h" // for wait_for_heatup, kill, M112_KILL_STR
#include "../../module/motion.h" // for quickstop_stepper
/**
* M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
*/
void GcodeSuite::M108() {
TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
wait_for_heatup = false;
marlin.end_waiting();
}
/**
* M112: Full Shutdown
*/
void GcodeSuite::M112() {
kill(FPSTR(M112_KILL_STR), nullptr, true);
marlin.kill(FPSTR(M112_KILL_STR), nullptr, true);
}
/**

View file

@ -25,7 +25,6 @@
#if ENABLED(DIRECT_PIN_CONTROL)
#include "../gcode.h"
#include "../../MarlinCore.h" // for pin_is_protected and idle()
#include "../../module/planner.h"
void protected_pin_err();
@ -40,7 +39,7 @@ void GcodeSuite::M226() {
const pin_t pin = GET_PIN_MAP_PIN(pin_number);
if (WITHIN(pin_state, -1, 1) && pin > -1) {
if (pin_is_protected(pin))
if (marlin.pin_is_protected(pin))
protected_pin_err();
else {
int target = LOW;
@ -51,7 +50,7 @@ void GcodeSuite::M226() {
case 0: target = LOW; break;
case -1: target = !extDigitalRead(pin); break;
}
while (int(extDigitalRead(pin)) != target) idle();
while (int(extDigitalRead(pin)) != target) marlin.idle();
}
} // pin_state -1 0 1 && pin > -1
} // parser.seen('P')

View file

@ -37,8 +37,6 @@
#define OUTPUT_OPEN_DRAIN OUTPUT_OPEN_DRAIN
#endif
bool pin_is_protected(const pin_t pin);
void protected_pin_err() {
SERIAL_ERROR_MSG(STR_ERR_PROTECTED_PIN);
}
@ -63,7 +61,7 @@ void GcodeSuite::M42() {
const pin_t pin = GET_PIN_MAP_PIN(pin_index);
if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err();
if (!parser.boolval('I') && marlin.pin_is_protected(pin)) return protected_pin_err();
bool avoidWrite = false;
if (parser.seenval('T')) {

View file

@ -93,7 +93,7 @@ void GcodeSuite::M81() {
safe_delay(1000); // Wait 1 second before switching off
#if ENABLED(CONFIGURABLE_MACHINE_NAME)
ui.set_status(&MString<30>(&machine_name, ' ', F(STR_OFF), '.'));
ui.set_status(&MString<30>(&marlin.machine_name, ' ', F(STR_OFF), '.'));
#else
LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
#endif
@ -125,6 +125,6 @@ void GcodeSuite::M81() {
#if ENABLED(PSU_CONTROL)
powerManager.power_off_soon();
#elif HAS_SUICIDE
suicide();
marlin.suicide();
#endif
}

View file

@ -23,7 +23,7 @@
#include "../gcode.h"
#include "../../lcd/marlinui.h" // for ui.reset_alert_level
#include "../../MarlinCore.h" // for marlin_state
#include "../../MarlinCore.h" // for setState
#include "../queue.h" // for flush_and_request_resend
/**
@ -36,7 +36,7 @@
* existing command buffer.
*/
void GcodeSuite::M999() {
marlin_state = MarlinState::MF_RUNNING;
marlin.setState(MarlinState::MF_RUNNING);
ui.reset_alert_level();
if (parser.boolval('S')) return;

View file

@ -31,10 +31,6 @@
millis_t chdk_timeout; // = 0
#endif
#if defined(PHOTO_POSITION) && PHOTO_DELAY_MS > 0
#include "../../../MarlinCore.h" // for idle()
#endif
#ifdef PHOTO_RETRACT_MM
#define _PHOTO_RETRACT_MM (PHOTO_RETRACT_MM + 0)
@ -185,7 +181,7 @@ void GcodeSuite::M240() {
#ifdef PHOTO_POSITION
#if PHOTO_DELAY_MS > 0
const millis_t timeout = millis() + parser.intval('P', PHOTO_DELAY_MS);
while (PENDING(millis(), timeout)) idle();
while (PENDING(millis(), timeout)) marlin.idle();
#endif
do_blocking_move_to(old_pos, fr_mm_s);
#ifdef PHOTO_RETRACT_MM

View file

@ -26,7 +26,6 @@
#include "../../../feature/filwidth.h"
#include "../../../module/planner.h"
#include "../../../MarlinCore.h"
#include "../../gcode.h"
/**

View file

@ -25,7 +25,6 @@
#if HAS_POWER_MONITOR
#include "../../../feature/power_monitor.h"
#include "../../../MarlinCore.h"
#include "../../gcode.h"
/**

View file

@ -252,7 +252,7 @@ void GcodeSuite::get_destination_from_command() {
*/
void GcodeSuite::dwell(const millis_t time) {
const millis_t start_ms = millis();
while (PENDING(millis(), start_ms, time)) idle();
while (PENDING(millis(), start_ms, time)) marlin.idle();
}
/**
@ -286,7 +286,7 @@ void GcodeSuite::dwell(const millis_t time) {
#ifdef ACTION_ON_CANCEL
hostui.cancel();
#endif
kill(GET_TEXT_F(MSG_LCD_PROBING_FAILED));
marlin.kill(GET_TEXT_F(MSG_LCD_PROBING_FAILED));
#endif
}

View file

@ -58,7 +58,7 @@ void GcodeSuite::D(const int16_t dcode) {
break;
case 10:
kill(F("D10"), F("KILL TEST"), parser.seen_test('P'));
marlin.kill(F("D10"), F("KILL TEST"), parser.seen_test('P'));
break;
case 1: {

View file

@ -28,7 +28,6 @@
#include "../../module/motion.h"
#include "../../lcd/marlinui.h"
#include "../../libs/buzzer.h"
#include "../../MarlinCore.h"
/**
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y

View file

@ -33,8 +33,8 @@
*/
void GcodeSuite::M16() {
if (TERN(CONFIGURABLE_MACHINE_NAME, strcmp(parser.string_arg, machine_name), strcmp_P(parser.string_arg, PSTR(MACHINE_NAME))))
kill(GET_TEXT_F(MSG_KILL_EXPECTED_PRINTER));
if (TERN(CONFIGURABLE_MACHINE_NAME, strcmp(parser.string_arg, marlin.machine_name), strcmp_P(parser.string_arg, PSTR(MACHINE_NAME))))
marlin.kill(GET_TEXT_F(MSG_KILL_EXPECTED_PRINTER));
}

View file

@ -26,7 +26,6 @@
#include "../../feature/host_actions.h"
#include "../gcode.h"
#include "../../MarlinCore.h"
/**
* M876: Handle Prompt Response

View file

@ -29,7 +29,6 @@
#include "../gcode.h"
#include "../../module/planner.h" // for synchronize()
#include "../../MarlinCore.h" // for wait_for_user_response()
#if HAS_MARLINUI_MENU
#include "../../lcd/marlinui.h"
@ -93,7 +92,7 @@ void GcodeSuite::M0_M1() {
hostui.continue_prompt(parser.codenum ? F("M1 Stop") : F("M0 Stop"));
#endif
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms));
TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response(ms));
TERN_(HAS_MARLINUI_MENU, ui.reset_status());
}

View file

@ -25,7 +25,6 @@
#if HAS_MULTI_LANGUAGE
#include "../gcode.h"
#include "../../MarlinCore.h"
#include "../../lcd/marlinui.h"
/**

View file

@ -321,7 +321,7 @@ void plan_arc(
const millis_t ms = millis();
if (ELAPSED(ms, next_idle_ms)) {
next_idle_ms = ms + 200UL;
idle();
marlin.idle();
}
#if N_ARC_CORRECTION > 1

View file

@ -39,7 +39,6 @@
*/
#include "../gcode.h"
#include "../../MarlinCore.h" // for IsRunning()
/**
* G5: Cubic B-spline

View file

@ -44,7 +44,14 @@ inline void G38_single_probe(const uint8_t move_value) {
sync_plan_position();
}
inline bool G38_run_probe() {
/**
* Handle G38.N where N is the sub-code for the type of probe:
* 2 - Probe toward workpiece, stop on contact, signal error if failure
* 3 - Probe toward workpiece, stop on contact
* 4 - Probe away from workpiece, stop on contact break, signal error if failure
* 5 - Probe away from workpiece, stop on contact break
*/
FORCE_INLINE bool G38_run_probe() {
bool G38_pass_fail = false;

View file

@ -30,7 +30,6 @@
#include "../gcode.h"
#include "../../feature/bedlevel/bdl/bdl.h"
#include "../../MarlinCore.h" // for printingIsActive
/**
* M102: Configure the Bed Distance Sensor
@ -53,7 +52,7 @@ void GcodeSuite::M102() {
const int8_t command = parser.value_int();
if (command == BDS_READ_MM)
SERIAL_ECHOLNPGM("Bed Distance:", bdl.read(), "mm");
else if ((command < BDS_IDLE) && printingIsActive())
else if ((command < BDS_IDLE) && marlin.printingIsActive())
return;
else
bdl.config_state = command;

View file

@ -191,8 +191,8 @@ bool GCodeQueue::process_injected_command() {
* Enqueue and return only when commands are actually enqueued.
* Never call this from a G-code handler!
*/
void GCodeQueue::enqueue_one_now(const char * const cmd) { while (!enqueue_one(cmd)) idle(); }
void GCodeQueue::enqueue_one_now(FSTR_P const fcmd) { while (!enqueue_one(fcmd)) idle(); }
void GCodeQueue::enqueue_one_now(const char * const cmd) { while (!enqueue_one(cmd)) marlin.idle(); }
void GCodeQueue::enqueue_one_now(FSTR_P const fcmd) { while (!enqueue_one(fcmd)) marlin.idle(); }
/**
* Attempt to enqueue a single G-code command
@ -520,7 +520,7 @@ void GCodeQueue::get_serial_commands() {
// Movement commands give an alert when the machine is stopped
//
if (IsStopped()) {
if (marlin.isStopped()) {
char* gpos = strchr(command, 'G');
if (gpos) {
switch (strtol(gpos + 1, nullptr, 10)) {
@ -538,8 +538,8 @@ void GCodeQueue::get_serial_commands() {
#if DISABLED(EMERGENCY_PARSER)
// Process critical commands early
if (command[0] == 'M') switch (command[3]) {
case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } break;
case '2': if (command[2] == '1' && command[1] == '1') kill(FPSTR(M112_KILL_STR), nullptr, true); break;
case '8': if (command[2] == '0' && command[1] == '1') { marlin.end_waiting(); } break;
case '2': if (command[2] == '1' && command[1] == '1') marlin.kill(FPSTR(M112_KILL_STR), nullptr, true); break;
case '0': if (command[1] == '4' && command[2] == '1') quickstop_stepper(); break;
}
#endif

View file

@ -27,10 +27,9 @@
#include "../gcode.h"
#include "../../module/scara.h"
#include "../../module/motion.h"
#include "../../MarlinCore.h" // for IsRunning()
inline bool SCARA_move_to_cal(const uint8_t delta_a, const uint8_t delta_b) {
if (IsRunning()) {
if (marlin.isRunning()) {
forward_kinematics(delta_a, delta_b);
do_blocking_move_to_xy(cartes);
return true;

View file

@ -43,7 +43,6 @@
#endif
#if HAS_LEDS_OFF_FLAG
#include "../../MarlinCore.h" // for wait_for_user_response()
#include "../../feature/leds/printer_event_leds.h"
#endif
@ -100,7 +99,7 @@ void GcodeSuite::M1001() {
printerEventLEDs.onPrintCompleted();
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE)));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_PRINT_DONE)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30))));
TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30))));
printerEventLEDs.onResumeAfterWait();
}
#endif

View file

@ -45,8 +45,6 @@
#include "../../lcd/extui/dgus/DGUSDisplayDef.h"
#endif
#include "../../MarlinCore.h" // for startOrResumeJob
/**
* M24: Start or Resume Media Print
*
@ -76,7 +74,7 @@ void GcodeSuite::M24() {
if (card.isFileOpen()) {
card.startOrResumeFilePrinting(); // SD card will now be read for commands
startOrResumeJob(); // Start (or resume) the print job timer
marlin.startOrResumeJob(); // Start (or resume) the print job timer
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
}

View file

@ -28,8 +28,6 @@
#include "../../sd/cardreader.h"
#include "../../module/planner.h" // for synchronize()
#include "../../MarlinCore.h" // for startOrResumeJob
/**
* M32: Select file and start SD Print
*
@ -52,7 +50,7 @@ void GcodeSuite::M32() {
card.startOrResumeFilePrinting();
// Procedure calls count as normal print time.
if (!call_procedure) startOrResumeJob();
if (!call_procedure) marlin.startOrResumeJob();
}
}

View file

@ -40,7 +40,7 @@
* included in the command, print it in the header.
*/
void GcodeSuite::M75() {
startOrResumeJob(); // ... ExtUI::onPrintTimerStarted()
marlin.startOrResumeJob(); // ... ExtUI::onPrintTimerStarted()
#if ENABLED(DWIN_LCD_PROUI)
// TODO: Remove if M75 <string> is never used
if (!card.isStillPrinting()) dwinPrintHeader(parser.has_string() ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));

View file

@ -52,6 +52,7 @@
#include "../core/mstring.h"
#include "../core/serial.h"
#include "../core/endianness.h"
#include "../MarlinCore.h"
#endif

View file

@ -850,7 +850,7 @@ void MarlinUI::draw_status_message(const bool blink) {
#if ENABLED(SHOW_REMAINING_TIME)
void MarlinUI::drawRemain() {
if (printJobOngoing()) {
if (marlin.printJobOngoing()) {
char buffer[8];
const duration_t remaint = get_remaining_time();
#if LCD_INFO_SCREEN_STYLE == 0
@ -873,7 +873,7 @@ void MarlinUI::draw_status_message(const bool blink) {
#if ENABLED(SHOW_INTERACTION_TIME)
void MarlinUI::drawInter() {
const duration_t interactt = interaction_time;
if (printingIsActive() && interactt.value) {
if (marlin.printingIsActive() && interactt.value) {
char buffer[8];
#if LCD_INFO_SCREEN_STYLE == 0
const uint8_t timepos = TPOFFSET - interactt.toDigital(buffer);
@ -894,7 +894,7 @@ void MarlinUI::draw_status_message(const bool blink) {
#if ENABLED(SHOW_ELAPSED_TIME)
void MarlinUI::drawElapsed() {
if (printJobOngoing()) {
if (marlin.printJobOngoing()) {
char buffer[8];
const duration_t elapsedt = print_job_timer.duration();
#if LCD_INFO_SCREEN_STYLE == 0
@ -1072,7 +1072,7 @@ void MarlinUI::draw_status_screen() {
#else // !HAS_DUAL_MIXING
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive()));
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive()));
if (show_e_total) {
#if ENABLED(LCD_SHOW_E_TOTAL)

View file

@ -607,7 +607,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
#endif
#if ENABLED(SHOW_REMAINING_TIME)
void MarlinUI::drawRemain() {
if (printJobOngoing()) {
if (marlin.printJobOngoing()) {
const duration_t remaint = ui.get_remaining_time();
char buffer[10];
const uint8_t timepos = TPOFFSET - remaint.toDigital(buffer);
@ -620,7 +620,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
#if ENABLED(SHOW_INTERACTION_TIME)
void MarlinUI::drawInter() {
const duration_t interactt = ui.interaction_time;
if (printingIsActive() && interactt.value) {
if (marlin.printingIsActive() && interactt.value) {
char buffer[10];
const uint8_t timepos = TPOFFSET - interactt.toDigital(buffer);
lcd_moveto(timepos, 1);
@ -631,7 +631,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
#endif
#if ENABLED(SHOW_ELAPSED_TIME)
void MarlinUI::drawElapsed() {
if (printJobOngoing()) {
if (marlin.printJobOngoing()) {
const duration_t elapsedt = print_job_timer.duration();
char buffer[10];
const uint8_t timepos = TPOFFSET - elapsedt.toDigital(buffer);

View file

@ -506,19 +506,19 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
#endif
#if ENABLED(SHOW_REMAINING_TIME)
void MarlinUI::drawRemain() {
if (printJobOngoing() && get_remaining_time() != 0)
if (marlin.printJobOngoing() && get_remaining_time() != 0)
prepare_time_string(get_remaining_time(), 'R');
}
#endif
#if ENABLED(SHOW_INTERACTION_TIME)
void MarlinUI::drawInter() {
if (printingIsActive() && interaction_time)
if (marlin.printingIsActive() && interaction_time)
prepare_time_string(interaction_time, 'C');
}
#endif
#if ENABLED(SHOW_ELAPSED_TIME)
void MarlinUI::drawElapsed() {
if (printJobOngoing())
if (marlin.printJobOngoing())
prepare_time_string(print_job_timer.duration(), 'E');
}
#endif
@ -549,7 +549,7 @@ void MarlinUI::draw_status_screen() {
static char wstring[5], mstring[4];
#endif
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive()));
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive()));
#if HAS_PRINT_PROGRESS
static u8g_uint_t progress_bar_solid_width = 0;

View file

@ -611,7 +611,7 @@ void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool
// If position is unknown, flash the labels.
const unsigned char alt_label = position_trusted ? 0 : (ui.get_blink() ? ' ' : 0);
if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) {
if (TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive())) {
#if ENABLED(LCD_SHOW_E_TOTAL)
char tmp[15];
const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm
@ -694,7 +694,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
void MarlinUI::drawRemain() { lightUI.drawRemain(); }
void ST7920_Lite_Status_Screen::drawRemain() {
const duration_t remaint = TERN0(SET_REMAINING_TIME, ui.get_remaining_time());
if (printJobOngoing() && remaint.value) {
if (marlin.printJobOngoing() && remaint.value) {
draw_progress_string(PPOS, prepare_time_string(remaint, 'R'));
}
}
@ -703,7 +703,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
void MarlinUI::drawInter() { lightUI.drawInter(); }
void ST7920_Lite_Status_Screen::drawInter() {
const duration_t interactt = ui.interaction_time;
if (printingIsActive() && interactt.value) {
if (marlin.printingIsActive() && interactt.value) {
draw_progress_string(PPOS, prepare_time_string(interactt, 'C'));
}
}
@ -711,7 +711,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
#if ENABLED(SHOW_ELAPSED_TIME)
void MarlinUI::drawElapsed() { lightUI.drawElapsed(); }
void ST7920_Lite_Status_Screen::drawElapsed() {
if (printJobOngoing()) {
if (marlin.printJobOngoing()) {
const duration_t elapsedt = print_job_timer.duration();
draw_progress_string(PPOS, prepare_time_string(elapsedt, 'E'));
}

View file

@ -68,8 +68,8 @@ EncoderState encoderReceiveAnalyze() {
ui.refresh_brightness();
return ENCODER_DIFF_NO;
}
const bool was_waiting = wait_for_user;
wait_for_user = false;
const bool was_waiting = marlin.wait_for_user;
marlin.user_resume();
return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
}
else return ENCODER_DIFF_NO;

View file

@ -312,7 +312,7 @@ void iconResume() {
}
void iconResumeOrPause() {
if (printingIsPaused() || hmiFlag.pause_flag || hmiFlag.pause_action)
if (marlin.printingIsPaused() || hmiFlag.pause_flag || hmiFlag.pause_action)
iconResume();
else
iconPause();
@ -1982,11 +1982,11 @@ void hmiSDCardUpdate() {
if (checkkey == ID_SelectFile) {
redrawSDList();
}
else if (checkkey == ID_PrintProcess || checkkey == ID_Tune || printingIsActive()) {
else if (checkkey == ID_PrintProcess || checkkey == ID_Tune || marlin.printingIsActive()) {
// TODO: Move card removed abort handling
// to CardReader::manage_media.
card.abortFilePrintSoon();
wait_for_heatup = wait_for_user = false;
marlin.end_waiting();
dwin_abort_flag = true; // Reset feedrate, return to Home
}
}
@ -2389,7 +2389,7 @@ void hmiPauseOrStop() {
else if (select_print.now == PRINT_STOP) {
if (hmiFlag.select_flag) {
checkkey = ID_BackMain;
wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user
marlin.end_waiting(); // Stop waiting for heating/user
card.abortFilePrintSoon(); // Let the main loop handle SD abort
dwin_abort_flag = true; // Reset feedrate, return to Home
#ifdef ACTION_ON_CANCEL
@ -4141,15 +4141,15 @@ void eachMomentUpdate() {
dwinDrawRectangle(1, COLOR_BG_BLACK, 0, 250, DWIN_WIDTH - 1, STATUS_Y);
dwinIconShow(ICON, hmiIsChinese() ? ICON_Confirm_C : ICON_Confirm_E, 86, 283);
}
else if (hmiFlag.pause_flag != printingIsPaused()) {
else if (hmiFlag.pause_flag != marlin.printingIsPaused()) {
// print status update
hmiFlag.pause_flag = printingIsPaused();
hmiFlag.pause_flag = marlin.printingIsPaused();
iconResumeOrPause();
}
}
// pause after homing
if (hmiFlag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) {
if (hmiFlag.pause_action && marlin.printingIsPaused() && !planner.has_blocks_queued()) {
hmiFlag.pause_action = false;
#if ENABLED(PAUSE_HEAT)
TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.degTargetHotend(0));

View file

@ -4595,7 +4595,7 @@ void JyersDWIN::printScreenControl() {
case PRINT_PAUSE_RESUME:
if (paused) {
if (sdprint) {
wait_for_user = false;
marlin.user_resume();
#if ENABLED(PARK_HEAD_ON_PAUSE)
card.startOrResumeFilePrinting();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
@ -4780,15 +4780,15 @@ void JyersDWIN::confirmControl() {
break;
case Popup_FilInsert:
popupHandler(Popup_FilChange);
wait_for_user = false;
marlin.user_resume();
break;
case Popup_HeaterTime:
popupHandler(Popup_Heating);
wait_for_user = false;
marlin.user_resume();
break;
default:
redrawMenu(true, true, false);
wait_for_user = false;
marlin.user_resume();
break;
}
}
@ -4935,7 +4935,7 @@ void JyersDWIN::stateUpdate() {
if (process == Proc_Print) printScreenIcons();
if (process == Proc_Wait && !paused) redrawMenu(true, true);
}
if (wait_for_user && !(process == Proc_Confirm) && !print_job_timer.isPaused())
if (marlin.wait_for_user && !(process == Proc_Confirm) && !print_job_timer.isPaused())
confirmHandler(Popup_UserInput);
#if ENABLED(ADVANCED_PAUSE_FEATURE)
if (process == Proc_Popup && popup == Popup_PurgeMore) {

View file

@ -308,7 +308,7 @@ void MarlinUI::draw_status_screen() {
// Axis values
const xyz_pos_t lpos = current_position.asLogical();
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive()));
const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive()));
constexpr int16_t cpy = TERN(DWIN_MARLINUI_PORTRAIT, 195, 117);
if (show_e_total) {

View file

@ -39,7 +39,6 @@
#include "../../utf8.h"
#include "../../marlinui.h"
#include "../../extui/ui_api.h"
#include "../../../MarlinCore.h"
#include "../../../module/temperature.h"
#include "../../../module/printcounter.h"
#include "../../../module/motion.h"
@ -294,7 +293,7 @@ MenuItem *fanSpeedItem = nullptr;
MenuItem *mMeshMoveZItem = nullptr;
MenuItem *editZValueItem = nullptr;
bool isPrinting() { return printingIsActive() || printingIsPaused(); }
bool isPrinting() { return marlin.printingIsActive() || marlin.printingIsPaused(); }
bool sdPrinting() { return isPrinting() && card.isStillPrinting(); }
bool hostPrinting() { return isPrinting() && !card.isStillPrinting(); }
@ -668,7 +667,7 @@ void drawPrintDone() {
}
void gotoPrintDone() {
wait_for_user = true;
marlin.wait_start();
if (checkkey != ID_PrintDone) {
checkkey = ID_PrintDone;
drawPrintDone();
@ -1214,7 +1213,7 @@ void hmiPrinting() {
switch (select_print.now) {
case PRINT_SETUP: drawTuneMenu(); break;
case PRINT_PAUSE_RESUME:
if (printingIsPaused()) { // If printer is already in pause
if (marlin.printingIsPaused()) { // If printer is already in pause
ExtUI::resumePrint();
break;
}
@ -1275,7 +1274,7 @@ void hmiWaitForUser() {
hmiReturnScreen();
return;
}
if (!wait_for_user) {
if (!marlin.wait_for_user) {
switch (checkkey) {
case ID_PrintDone: select_page.reset(); gotoMainMenu(); break;
default: ui.reset_status(true); hmiReturnScreen(); break;
@ -1366,8 +1365,8 @@ void eachMomentUpdate() {
dwinPrintFinished();
}
if ((hmiFlag.pause_flag != printingIsPaused()) && !hmiFlag.home_flag) {
hmiFlag.pause_flag = printingIsPaused();
if ((hmiFlag.pause_flag != marlin.printingIsPaused()) && !hmiFlag.home_flag) {
hmiFlag.pause_flag = marlin.printingIsPaused();
if (hmiFlag.pause_flag)
dwinPrintPause();
else if (hmiFlag.abort_flag)
@ -1517,14 +1516,14 @@ void hmiSaveProcessID(const uint8_t id) {
TERN_(HAS_BED_PROBE, case ID_Leveling:)
TERN_(HAS_ESDIAG, case ID_ESDiagProcess:)
TERN_(PROUI_ITEM_PLOT, case ID_PlotProcess:)
wait_for_user = true;
marlin.wait_start();
default: break;
}
}
void hmiReturnScreen() {
checkkey = last_checkkey;
wait_for_user = false;
marlin.user_resume();
drawMainArea();
}
@ -1823,7 +1822,7 @@ void dwinPrintFinished() {
TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel());
hmiFlag.abort_flag = false;
hmiFlag.pause_flag = false;
wait_for_heatup = false;
marlin.heatup_done();
planner.finish_and_disable();
thermalManager.cooldown();
gotoPrintDone();
@ -1960,9 +1959,9 @@ void MarlinUI::update() {
void MarlinUI::_set_brightness() {
dwinLCDBrightness(backlight ? brightness : 0);
if (!backlight)
wait_for_user = true;
marlin.wait_start();
else if (checkkey != ID_PrintDone)
wait_for_user = false;
marlin.user_resume();
}
#endif
@ -2133,7 +2132,7 @@ void gotoConfirmToPrint() {
// Reset Printer
void rebootPrinter() {
wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user
marlin.end_waiting(); // Stop waiting for heating/user
thermalManager.disable_all_heaters();
planner.finish_and_disable();
dwinRebootScreen();

View file

@ -79,7 +79,7 @@ void gotoPopup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nu
}
void hmiPopup() {
if (!wait_for_user) {
if (!marlin.wait_for_user) {
if (popupClick) popupClick();
return;
}

View file

@ -191,7 +191,7 @@ bool Preview::hasPreview() {
void Preview::drawFromSD() {
if (!hasPreview()) {
hmiFlag.select_flag = 1;
wait_for_user = false;
marlin.user_resume();
return;
}

View file

@ -612,7 +612,7 @@ void ChironTFT::panelAction(uint8_t req) {
break;
case 12: // A12 Kill printer
kill(); // from marlincore.h
marlin.kill(); // from MarlinCore.h
break;
case 13: // A13 Select file

View file

@ -627,7 +627,7 @@ void AnycubicTFT::getCommandFromTFT() {
break;
case 12: // A12 kill
kill(F(STR_ERR_KILLED));
marlin.kill(F(STR_ERR_KILLED));
break;
case 13: // A13 SELECTION FILE

View file

@ -213,7 +213,7 @@ void DGUSScreenHandler::handleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed);
queue.enqueue_one_now(buf);
}
//while (!enqueue_and_echo_command(buf)) idle();
//while (!enqueue_and_echo_command(buf)) marlin.idle();
if (!old_relative_mode) queue.enqueue_now(F("G90"));
}

Some files were not shown because too many files have changed in this diff Show more