Move some MarlinCore and MarlinUI code (#20832)
This commit is contained in:
@ -33,7 +33,6 @@
|
||||
|
||||
// External references
|
||||
extern bool wait_for_user, wait_for_heatup;
|
||||
void quickstop_stepper();
|
||||
|
||||
class EmergencyParser {
|
||||
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
I2CPositionEncodersMgr I2CPEM;
|
||||
|
||||
void I2CPositionEncoder::init(const uint8_t address, const AxisEnum axis) {
|
||||
encoderAxis = axis;
|
||||
i2cAddress = address;
|
||||
|
@ -137,10 +137,7 @@ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=P
|
||||
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, active_extruder);
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
lcd_pause_show_message(PAUSE_MESSAGE_HEATING, mode);
|
||||
#endif
|
||||
UNUSED(mode);
|
||||
ui.pause_show_message(PAUSE_MESSAGE_HEATING, mode); UNUSED(mode);
|
||||
|
||||
if (wait) return thermalManager.wait_for_hotend(active_extruder);
|
||||
|
||||
@ -181,19 +178,13 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
DEBUG_SECTION(lf, "load_filament", true);
|
||||
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", int(max_beep_count), " showlcd:", int(show_lcd), " pauseforuser:", int(pause_for_user), " pausemode:", int(mode) DXC_SAY);
|
||||
|
||||
UNUSED(show_lcd);
|
||||
|
||||
if (!ensure_safe_temperature(false, mode)) {
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS, mode);
|
||||
#endif
|
||||
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_STATUS, mode);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pause_for_user) {
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_INSERT, mode);
|
||||
#endif
|
||||
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_INSERT, mode);
|
||||
SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_INSERT));
|
||||
|
||||
first_impatient_beep(max_beep_count);
|
||||
@ -217,9 +208,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
}
|
||||
}
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_LOAD, mode);
|
||||
#endif
|
||||
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_LOAD, mode);
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
const int8_t saved_ext = active_extruder;
|
||||
@ -250,9 +239,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
|
||||
#endif
|
||||
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE);
|
||||
|
||||
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR));
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging...")));
|
||||
@ -266,9 +253,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
do {
|
||||
if (purge_length > 0) {
|
||||
// "Wait for filament purge"
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
|
||||
#endif
|
||||
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE);
|
||||
|
||||
// Extrude filament to get into hotend
|
||||
unscaled_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
|
||||
@ -281,7 +266,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
|
||||
// Show "Purge More" / "Resume" menu and wait for reply
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
wait_for_user = false;
|
||||
lcd_pause_show_message(PAUSE_MESSAGE_OPTION);
|
||||
ui.pause_show_message(PAUSE_MESSAGE_OPTION);
|
||||
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle_no_sleep();
|
||||
}
|
||||
#endif
|
||||
@ -330,22 +315,16 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
|
||||
#endif
|
||||
);
|
||||
|
||||
UNUSED(show_lcd);
|
||||
|
||||
#if !BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
|
||||
constexpr float mix_multiplier = 1.0;
|
||||
#endif
|
||||
|
||||
if (!ensure_safe_temperature(false, mode)) {
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
|
||||
#endif
|
||||
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_STATUS);
|
||||
return false;
|
||||
}
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, mode);
|
||||
#endif
|
||||
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_UNLOAD, mode);
|
||||
|
||||
// Retract filament
|
||||
unscaled_e_move(-(FILAMENT_UNLOAD_PURGE_RETRACT) * mix_multiplier, (PAUSE_PARK_RETRACT_FEEDRATE) * mix_multiplier);
|
||||
@ -479,7 +458,7 @@ void show_continue_prompt(const bool is_reload) {
|
||||
DEBUG_SECTION(scp, "pause_print", true);
|
||||
DEBUG_ECHOLNPAIR("... is_reload:", int(is_reload));
|
||||
|
||||
TERN_(HAS_LCD_MENU, lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING));
|
||||
ui.pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
|
||||
SERIAL_ECHO_START();
|
||||
serialprintPGM(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n"));
|
||||
}
|
||||
@ -520,7 +499,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
|
||||
// Wait for the user to press the button to re-heat the nozzle, then
|
||||
// re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
|
||||
if (nozzle_timed_out) {
|
||||
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_HEAT));
|
||||
ui.pause_show_message(PAUSE_MESSAGE_HEAT);
|
||||
SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_HEAT));
|
||||
|
||||
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT)));
|
||||
@ -614,7 +593,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
|
||||
thermalManager.wait_for_hotend(active_extruder, false);
|
||||
}
|
||||
|
||||
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_RESUME));
|
||||
ui.pause_show_message(PAUSE_MESSAGE_RESUME);
|
||||
|
||||
// Check Temperature before moving hotend
|
||||
ensure_safe_temperature();
|
||||
@ -653,7 +632,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
|
||||
// Write PLR now to update the z axis value
|
||||
TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
|
||||
|
||||
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
|
||||
ui.pause_show_message(PAUSE_MESSAGE_STATUS);
|
||||
|
||||
#ifdef ACTION_ON_RESUMED
|
||||
host_action_resumed();
|
||||
|
@ -101,4 +101,8 @@ bool unload_filament(const float &unload_length, const bool show_lcd=false, cons
|
||||
#endif
|
||||
);
|
||||
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
#else // !ADVANCED_PAUSE_FEATURE
|
||||
|
||||
constexpr uint8_t did_pause_print = 0;
|
||||
|
||||
#endif // !ADVANCED_PAUSE_FEATURE
|
||||
|
@ -59,6 +59,7 @@ bool FilamentMonitorBase::enabled = true,
|
||||
// Filament Runout event handler
|
||||
//
|
||||
#include "../MarlinCore.h"
|
||||
#include "../feature/pause.h"
|
||||
#include "../gcode/queue.h"
|
||||
|
||||
#if ENABLED(HOST_ACTION_COMMANDS)
|
||||
@ -71,7 +72,7 @@ bool FilamentMonitorBase::enabled = true,
|
||||
|
||||
void event_filament_runout() {
|
||||
|
||||
if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return; // Action already in progress. Purge triggered repeated runout.
|
||||
if (did_pause_print) return; // Action already in progress. Purge triggered repeated runout.
|
||||
|
||||
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
|
||||
if (migration.in_progress) {
|
||||
|
@ -118,9 +118,7 @@ class TFilamentMonitor : public FilamentMonitorBase {
|
||||
|
||||
// Give the response a chance to update its counter.
|
||||
static inline void run() {
|
||||
if ( enabled && !filament_ran_out
|
||||
&& (printingIsActive() || TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print))
|
||||
) {
|
||||
if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) {
|
||||
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here
|
||||
response.run();
|
||||
sensor.run();
|
||||
@ -343,9 +341,7 @@ class FilamentSensorBase {
|
||||
}
|
||||
|
||||
static inline void block_completed(const block_t* const b) {
|
||||
if (b->steps.x || b->steps.y || b->steps.z
|
||||
|| TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print) // Allow pause purge move to re-trigger runout state
|
||||
) {
|
||||
if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state
|
||||
// Only trigger on extrusion with XYZ movement to allow filament change and retract/recover.
|
||||
const uint8_t e = b->extruder;
|
||||
const int32_t steps = b->steps.e;
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
TWIBus i2c;
|
||||
|
||||
TWIBus::TWIBus() {
|
||||
#if I2C_SLAVE_ADDRESS == 0
|
||||
Wire.begin(); // No address joins the BUS as the master
|
||||
@ -155,6 +157,14 @@ void TWIBus::flush() {
|
||||
reset();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#if ENABLED(DEBUG_TWIBUS)
|
||||
|
@ -31,6 +31,17 @@
|
||||
typedef void (*twiReceiveFunc_t)(int bytes);
|
||||
typedef void (*twiRequestFunc_t)();
|
||||
|
||||
/**
|
||||
* For a light i2c protocol that runs on two boards running Marlin see:
|
||||
* See https://github.com/MarlinFirmware/Marlin/issues/4776#issuecomment-246262879
|
||||
*/
|
||||
#if I2C_SLAVE_ADDRESS > 0
|
||||
|
||||
void i2c_on_receive(int bytes); // Demo i2c onReceive handler
|
||||
void i2c_on_request(); // Demo i2c onRequest handler
|
||||
|
||||
#endif
|
||||
|
||||
#define TWIBUS_BUFFER_SIZE 32
|
||||
|
||||
/**
|
||||
@ -238,3 +249,5 @@ class TWIBus {
|
||||
static inline void debug(const char[], uint8_t) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
extern TWIBus i2c;
|
||||
|
Reference in New Issue
Block a user