Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Creality Ender-5 S1 #25382

Open
wants to merge 4 commits into
base: bugfix-2.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ jobs:
- Opulo_Lumen_REV3
- rumba32
- STM32F401RC_creality
- STM32F401RE_creality
- STM32F407VE_black
- I3DBEEZ9_V1

Expand Down
13 changes: 13 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3118,6 +3118,15 @@
//
//#define CR10_STOCKDISPLAY

// Resistive touch screen
//#define CREALITY_RTS

// Creality Cloud-based Printing
//#define CREALITY_CLOUD

// Over-the-air Firmware Update with M936
//#define OTA_FIRMWARE_UPDATE

//
// Ender-2 OEM display, a variant of the MKS_MINI_12864
//
Expand Down Expand Up @@ -3689,3 +3698,7 @@

// Disable servo with M282 to reduce power consumption, noise, and heat when not in use
//#define SERVO_DETACH_GCODE

// Creality WiFi
//#define CREALITY_WIFI
//#define MENU_RESET_WIFI
3 changes: 3 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@
#define BLTOUCH_HS_EXTRA_CLEARANCE 7 // Extra Z Clearance
#endif

// Add a Z limit
//#define BLTOUCH_AND_Z_LIMIT

#endif // BLTOUCH

// @section calibrate
Expand Down
60 changes: 52 additions & 8 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

#include "MarlinCore.h"

#define DEBUG_OUT ENABLED(MARLIN_DEV_MODE)
#include "core/debug_out.h"

#include "HAL/shared/Delay.h"
#include "HAL/shared/esp_wifi.h"
#include "HAL/shared/cpu_exception/exception_hook.h"
Expand Down Expand Up @@ -84,6 +87,10 @@
#endif
#endif

#if ENABLED(CREALITY_RTS)
#include "lcd/rts/lcd_rts.h"
#endif

#if HAS_ETHERNET
#include "feature/ethernet.h"
#endif
Expand Down Expand Up @@ -380,7 +387,11 @@ void startOrResumeJob() {
TERN_(POWER_LOSS_RECOVERY, recovery.purge());

#ifdef EVENT_GCODE_SD_ABORT
queue.inject(F(EVENT_GCODE_SD_ABORT));
DEBUG_ECHOLNPGM("abortSDPrinting");
//queue.inject(F(EVENT_GCODE_SD_ABORT));
queue.enqueue_now(F(EVENT_GCODE_SD_ABORT));
report_current_position();
TERN_(CREALITY_RTS, RTS_UpdatePosition());
#endif

TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
Expand Down Expand Up @@ -426,7 +437,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
SERIAL_ERROR_START();
SERIAL_ECHOPGM(STR_KILL_PRE);
SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr);
kill();
TERN(CREALITY_RTS, RTS_StepperTimeout(), kill());
}

const bool has_blocks = planner.has_blocks_queued(); // Any moves in the planner?
Expand Down Expand Up @@ -457,7 +468,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled());
}
}
else
else // if (!parked_or_ignoring && gcode.stepper_inactive_timeout() && !card.isPrinting() && !IS_SD_PAUSED()) // rock_20220815
already_shutdown_steppers = false;
}
#endif
Expand Down Expand Up @@ -812,7 +823,10 @@ void idle(const bool no_stepper_sleep/*=false*/) {
#endif

// Handle SD Card insert / remove
TERN_(HAS_MEDIA, card.manage_media());
#if HAS_MEDIA
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
card.manage_media();
#endif

// Handle USB Flash Drive insert / remove
TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle());
Expand All @@ -827,12 +841,16 @@ void idle(const bool no_stepper_sleep/*=false*/) {
TERN_(HAS_BEEPER, buzzer.tick());

// Handle UI input / draw events
#if ENABLED(SOVOL_SV06_RTS)
#if ANY(SOVOL_SV06_RTS, CREALITY_RTS)
RTS_Update();
#else
ui.update();
#endif

#if ENABLED(PROBE_ACTIVATION_SWITCH)
endstops.enable_z_probe(TERN1(CREALITY_RTS, (home_flag || G29_flag)) && (LOW == READ(PROBE_ACTIVATION_SWITCH_PIN)));
#endif

// Run i2c Position Encoders
#if ENABLED(I2C_POSITION_ENCODERS)
{
Expand Down Expand Up @@ -876,6 +894,22 @@ void idle(const bool no_stepper_sleep/*=false*/) {
// Direct Stepping
TERN_(DIRECT_STEPPING, page_manager.write_responses());

#if ENABLED(MENU_RESET_WIFI)
static millis_t wifi_record_ms = 0;
if (rts_wifi_state == PRESSED) {
rts_wifi_state = RECORDTIME;
wifi_record_ms = millis() + 7000UL;
}
else if (rts_wifi_state == RECORDTIME) {
if (wifi_record_ms && ELAPSED(millis(), wifi_record_ms)) {
OUT_WRITE(RESET_WIFI_PIN, HIGH);
rts_wifi_state = INITIAL;
SERIAL_ECHOPGM("wifi is reset");
wifi_record_ms = 0;
}
}
#endif

// Update the LVGL interface
TERN_(HAS_TFT_LVGL_UI, LV_TASK_HANDLER());

Expand Down Expand Up @@ -1297,13 +1331,13 @@ void setup() {

// Identify myself as Marlin x.x.x
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
#ifdef STRING_DISTRIBUTION_DATE
#if defined(STRING_DISTRIBUTION_DATE) && (DISABLED(CREALITY_RTS) || defined(STRING_CONFIG_H_AUTHOR))
SERIAL_ECHO_MSG(
" Last Updated: " STRING_DISTRIBUTION_DATE
" | Author: " STRING_CONFIG_H_AUTHOR
);
#endif
SERIAL_ECHO_MSG(" Compiled: " __DATE__);
SERIAL_ECHO_MSG(" Compiled: " __DATE__ " " __TIME__);
SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));

// Some HAL need precise delay adjustment
Expand Down Expand Up @@ -1624,7 +1658,7 @@ void setup() {

#if ENABLED(DWIN_CREALITY_LCD)
SETUP_RUN(dwinInitScreen());
#elif ENABLED(SOVOL_SV06_RTS)
#elif ANY(SOVOL_SV06_RTS, CREALITY_RTS)
SETUP_RUN(rts.init());
#endif

Expand Down Expand Up @@ -1732,3 +1766,13 @@ void loop() {

} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
}

//void HardFault_Handler(void) {
// SERIAL_ECHO_MSG("HardFault_Handler");
// OUT_WRITE(E0_AUTO_FAN_PIN, LOW);
// OUT_WRITE(FAN_PIN, LOW);
// for (int i = 0; i < 0xFFFF; i++) OUT_WRITE(FAN_PIN, HIGH);
// OUT_WRITE(E0_AUTO_FAN_PIN, HIGH);
// OUT_WRITE(FAN_PIN, HIGH);
// while(1);
//}
71 changes: 53 additions & 18 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@

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

#if ENABLED(CREALITY_RTS)
#include "../lcd/rts/lcd_rts.h"
#endif

#if HAS_SOUND
#include "../libs/buzzer.h"
#endif
Expand Down Expand Up @@ -159,11 +163,13 @@ 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;
#if DISABLED(CREALITY_RTS)
// 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;
#endif

#if ENABLED(PREVENT_COLD_EXTRUSION)
// A user can cancel wait-for-heating with M108
Expand Down Expand Up @@ -433,6 +439,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
#endif

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

// Indicate that the printer is paused
++did_pause_print;
Expand Down Expand Up @@ -481,25 +488,48 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
TERN_(AUTO_BED_LEVELING_UBL, set_bed_leveling_enabled(leveling_was_enabled)); // restore leveling
}

// If axes don't need to home then the nozzle can park
if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
if (!do_park) LCD_MESSAGE(MSG_PARK_FAILED);
#if ENABLED(CREALITY_RTS)

while (planner.movesplanned() < 2 && destination != current_position) idle();

queue.clear();
delay(20);
if (!planner.has_blocks_queued()) {
if (axis_is_trusted(X_AXIS) && axis_is_trusted(Y_AXIS)) {
//if (!axes_need_homing())
nozzle.park(0, park_point);
}
}

#else

// If axes don't need to home then the nozzle can park
if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move
if (!do_park) LCD_MESSAGE(MSG_PARK_FAILED);

#endif

TERN_(DWIN_LCD_PROUI, if (!do_park) ui.set_status(GET_TEXT_F(MSG_PARK_FAILED)));

#if ENABLED(DUAL_X_CARRIAGE)
const int8_t saved_ext = active_extruder;
const bool saved_ext_dup_mode = extruder_duplication_enabled;
set_duplication_enabled(false, DXC_ext);
#endif

// Unload the filament, if specified
if (unload_length)
unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
#if DISABLED(CREALITY_RTS)
// Unload the filament, if specified
if (unload_length)
unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
#endif

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

// Disable the Extruder for manual change
disable_active_extruder();

TERN_(CREALITY_RTS, RTS_ReheatHotend(170));

return true;
}

Expand Down Expand Up @@ -613,6 +643,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
nozzle_timed_out = false;
first_impatient_beep(max_beep_count);
}
TERN_(CREALITY_RTS, wait_for_user = false);
idle_no_sleep();
}
TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext));
Expand Down Expand Up @@ -698,13 +729,17 @@ void resume_print(
unscaled_e_move(-(PAUSE_PARK_RETRACT_LENGTH), feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));

if (!axes_should_home()) {
// Move XY back to saved position
destination.set(resume_position.x, resume_position.y, current_position.z, current_position.e);
prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE);

// Move Z back to saved position
destination.z = resume_position.z;
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
#if ENABLED(CREALITY_RTS)
destination.set(resume_position.x, resume_position.y, resume_position.z, current_position.e);
#else
// Move XY back to saved position
destination.set(resume_position.x, resume_position.y, current_position.z, current_position.e);
prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE);

// Move Z back to saved position
destination.z = resume_position.z;
prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE);
#endif
}

#if ENABLED(AUTO_BED_LEVELING_UBL)
Expand Down
Loading