Skip to content

Commit cf57de8

Browse files
committed
Ender-5 S1 modified code
1 parent 37d0f24 commit cf57de8

35 files changed

+1427
-93
lines changed

Marlin/src/MarlinCore.cpp

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
#include "MarlinCore.h"
3232

33+
#define DEBUG_OUT ENABLED(MARLIN_DEV_MODE)
34+
#include "core/debug_out.h"
35+
3336
#include "HAL/shared/Delay.h"
3437
#include "HAL/shared/esp_wifi.h"
3538
#include "HAL/shared/cpu_exception/exception_hook.h"
@@ -77,6 +80,10 @@
7780
#endif
7881
#endif
7982

83+
#if ENABLED(CREALITY_RTS)
84+
#include "lcd/rts/lcd_rts.h"
85+
#endif
86+
8087
#if HAS_ETHERNET
8188
#include "feature/ethernet.h"
8289
#endif
@@ -376,7 +383,11 @@ void startOrResumeJob() {
376383
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
377384

378385
#ifdef EVENT_GCODE_SD_ABORT
379-
queue.inject(F(EVENT_GCODE_SD_ABORT));
386+
DEBUG_ECHOLNPGM("abortSDPrinting");
387+
//queue.inject(F(EVENT_GCODE_SD_ABORT));
388+
queue.enqueue_now(F(EVENT_GCODE_SD_ABORT));
389+
report_current_position();
390+
TERN_(CREALITY_RTS, RTS_UpdatePosition());
380391
#endif
381392

382393
TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
@@ -385,6 +396,9 @@ void startOrResumeJob() {
385396
inline void finishSDPrinting() {
386397
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
387398
marlin_state = MF_RUNNING; // Signal to stop trying
399+
#ifdef EVENT_GCODE_SD_DONE
400+
gcode.process_subcommands_now(F(EVENT_GCODE_SD_DONE));
401+
#endif
388402
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
389403
TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
390404
}
@@ -422,7 +436,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
422436
SERIAL_ERROR_START();
423437
SERIAL_ECHOPGM(STR_KILL_PRE);
424438
SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr);
425-
kill();
439+
TERN(CREALITY_RTS, RTS_StepperTimeout(), kill());
426440
}
427441

428442
const bool has_blocks = planner.has_blocks_queued(); // Any moves in the planner?
@@ -453,7 +467,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
453467
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled());
454468
}
455469
}
456-
else
470+
else // if (!parked_or_ignoring && gcode.stepper_inactive_timeout() && !card.isPrinting() && !IS_SD_PAUSED()) // rock_20220815
457471
already_shutdown_steppers = false;
458472
}
459473
#endif
@@ -827,7 +841,10 @@ void idle(bool no_stepper_sleep/*=false*/) {
827841
#endif
828842

829843
// Handle SD Card insert / remove
830-
TERN_(SDSUPPORT, card.manage_media());
844+
#if ENABLED(SDSUPPORT)
845+
if (TERN1(CREALITY_RTS, !home_flag && !G29_flag)) // Avoid the problem of leveling and returning to zero, plugging and unplugging the card will affect the probe and report error 203
846+
card.manage_media();
847+
#endif
831848

832849
// Handle USB Flash Drive insert / remove
833850
TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle());
@@ -842,7 +859,17 @@ void idle(bool no_stepper_sleep/*=false*/) {
842859
TERN_(HAS_BEEPER, buzzer.tick());
843860

844861
// Handle UI input / draw events
845-
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
862+
#if ENABLED(DWIN_CREALITY_LCD)
863+
DWIN_Update();
864+
#elif ENABLED(CREALITY_RTS)
865+
RTS_Update();
866+
#else
867+
ui.update();
868+
#endif
869+
870+
#if ENABLED(PROBE_ACTIVATION_SWITCH)
871+
endstops.enable_z_probe(TERN1(CREALITY_RTS, (home_flag || G29_flag)) && (LOW == READ(PROBE_ACTIVATION_SWITCH_PIN)));
872+
#endif
846873

847874
// Run i2c Position Encoders
848875
#if ENABLED(I2C_POSITION_ENCODERS)
@@ -878,6 +905,24 @@ void idle(bool no_stepper_sleep/*=false*/) {
878905
// Direct Stepping
879906
TERN_(DIRECT_STEPPING, page_manager.write_responses());
880907

908+
#if ENABLED(MENU_RESET_WIFI)
909+
static uint32_t wifi_recordms = 0;
910+
911+
if (WIFI_STATE == PRESSED) {
912+
wifi_recordms = millis();
913+
wifi_recordms += 7000;
914+
WIFI_STATE = RECORDTIME;
915+
}
916+
917+
if (WIFI_STATE == RECORDTIME) {
918+
if (wifi_recordms == millis()) {
919+
OUT_WRITE(RESET_WIFI_PIN, HIGH);
920+
WIFI_STATE = INITIAL;
921+
SERIAL_ECHOPGM("wifi is reset");
922+
}
923+
}
924+
#endif
925+
881926
// Update the LVGL interface
882927
TERN_(HAS_TFT_LVGL_UI, LV_TASK_HANDLER());
883928

@@ -1281,13 +1326,14 @@ void setup() {
12811326

12821327
// Identify myself as Marlin x.x.x
12831328
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
1329+
SERIAL_EOL();
12841330
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
12851331
SERIAL_ECHO_MSG(
12861332
" Last Updated: " STRING_DISTRIBUTION_DATE
12871333
" | Author: " STRING_CONFIG_H_AUTHOR
12881334
);
12891335
#endif
1290-
SERIAL_ECHO_MSG(" Compiled: " __DATE__);
1336+
SERIAL_ECHO_MSG(" Compiled: " __DATE__ " " __TIME__);
12911337
SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
12921338

12931339
// Some HAL need precise delay adjustment
@@ -1596,6 +1642,8 @@ void setup() {
15961642

15971643
#if HAS_DWIN_E3V2_BASIC
15981644
SETUP_RUN(DWIN_InitScreen());
1645+
#elif ENABLED(CREALITY_RTS)
1646+
SETUP_RUN(rtscheck.RTS_Init());
15991647
#endif
16001648

16011649
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
@@ -1688,3 +1736,13 @@ void loop() {
16881736

16891737
} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
16901738
}
1739+
1740+
//void HardFault_Handler(void) {
1741+
// SERIAL_ECHO_MSG("HardFault_Handler");
1742+
// OUT_WRITE(E0_AUTO_FAN_PIN, LOW);
1743+
// OUT_WRITE(FAN_PIN, LOW);
1744+
// for (int i = 0; i < 0xFFFF; i++) OUT_WRITE(FAN_PIN, HIGH);
1745+
// OUT_WRITE(E0_AUTO_FAN_PIN, HIGH);
1746+
// OUT_WRITE(FAN_PIN, HIGH);
1747+
// while(1);
1748+
//}

Marlin/src/feature/pause.cpp

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666

6767
#include "../lcd/marlinui.h"
6868

69+
#if ENABLED(CREALITY_RTS)
70+
#include "../lcd/rts/lcd_rts.h"
71+
#endif
72+
6973
#if HAS_SOUND
7074
#include "../libs/buzzer.h"
7175
#endif
@@ -150,11 +154,13 @@ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=P
150154

151155
if (wait) return thermalManager.wait_for_hotend(active_extruder);
152156

153-
// Allow interruption by Emergency Parser M108
154-
wait_for_heatup = TERN1(PREVENT_COLD_EXTRUSION, !thermalManager.allow_cold_extrude);
155-
while (wait_for_heatup && ABS(thermalManager.wholeDegHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > (TEMP_WINDOW))
156-
idle();
157-
wait_for_heatup = false;
157+
#if DISABLED(CREALITY_RTS)
158+
// Allow interruption by Emergency Parser M108
159+
wait_for_heatup = TERN1(PREVENT_COLD_EXTRUSION, !thermalManager.allow_cold_extrude);
160+
while (wait_for_heatup && ABS(thermalManager.wholeDegHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > (TEMP_WINDOW))
161+
idle();
162+
wait_for_heatup = false;
163+
#endif
158164

159165
#if ENABLED(PREVENT_COLD_EXTRUSION)
160166
// A user can cancel wait-for-heating with M108
@@ -410,6 +416,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
410416
#endif
411417

412418
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR)));
419+
TERN_(CREALITY_RTS, RTS_PausedPrint());
413420

414421
// Indicate that the printer is paused
415422
++did_pause_print;
@@ -440,7 +447,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
440447
// Wait for buffered blocks to complete
441448
planner.synchronize();
442449

443-
#if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN
450+
#if BOTH(ADVANCED_PAUSE_FANS_PAUSE, HAS_FAN)
444451
thermalManager.set_fans_paused(true);
445452
#endif
446453

@@ -458,8 +465,26 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
458465
TERN_(AUTO_BED_LEVELING_UBL, set_bed_leveling_enabled(leveling_was_enabled)); // restore leveling
459466
}
460467

461-
// If axes don't need to home then the nozzle can park
462-
if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
468+
#if ENABLED(CREALITY_RTS)
469+
470+
while (planner.movesplanned() < 2 && destination != current_position) idle();
471+
472+
queue.clear();
473+
delay(20);
474+
if (!planner.has_blocks_queued()) {
475+
if (axis_is_trusted(X_AXIS) && axis_is_trusted(Y_AXIS)) {
476+
//if (!axes_need_homing())
477+
nozzle.park(0, park_point);
478+
}
479+
}
480+
481+
#else
482+
483+
// If axes don't need to home then the nozzle can park
484+
if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
485+
486+
#endif
487+
463488
TERN_(DWIN_LCD_PROUI, if (!do_park) ui.set_status(GET_TEXT_F(MSG_PARK_FAILED)));
464489

465490
#if ENABLED(DUAL_X_CARRIAGE)
@@ -468,15 +493,19 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
468493
set_duplication_enabled(false, DXC_ext);
469494
#endif
470495

471-
// Unload the filament, if specified
472-
if (unload_length)
473-
unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
496+
#if DISABLED(CREALITY_RTS)
497+
// Unload the filament, if specified
498+
if (unload_length)
499+
unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
500+
#endif
474501

475502
TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext));
476503

477504
// Disable the Extruder for manual change
478505
disable_active_extruder();
479506

507+
TERN_(CREALITY_RTS, RTS_ReheatHotend(170));
508+
480509
return true;
481510
}
482511

@@ -576,6 +605,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
576605
nozzle_timed_out = false;
577606
first_impatient_beep(max_beep_count);
578607
}
608+
TERN_(CREALITY_RTS, wait_for_user = false);
579609
idle_no_sleep();
580610
}
581611
TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext));
@@ -643,13 +673,17 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
643673
unscaled_e_move(-(PAUSE_PARK_RETRACT_LENGTH), feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));
644674

645675
if (!axes_should_home()) {
646-
// Move XY back to saved position
647-
destination.set(resume_position.x, resume_position.y, current_position.z, current_position.e);
648-
prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE);
649-
650-
// Move Z back to saved position
651-
destination.z = resume_position.z;
652-
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
676+
#if ENABLED(CREALITY_RTS)
677+
destination.set(resume_position.x, resume_position.y, resume_position.z, current_position.e);
678+
#else
679+
// Move XY back to saved position
680+
destination.set(resume_position.x, resume_position.y, current_position.z, current_position.e);
681+
prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE);
682+
683+
// Move Z back to saved position
684+
destination.z = resume_position.z;
685+
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
686+
#endif
653687
}
654688

655689
#if ENABLED(AUTO_BED_LEVELING_UBL)

0 commit comments

Comments
 (0)