Skip to content

Commit f597206

Browse files
committed
Merge branch 'bugfix-2.0.x' into 2.0.x-Sapphire-Pro
2 parents ffb372e + 747b964 commit f597206

28 files changed

+478
-245
lines changed

Marlin/Configuration_adv.h

+4
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,10 @@
10491049

10501050
#define EVENT_GCODE_SD_STOP "G28XY" // G-code to run on Stop Print (e.g., "G28XY" or "G27")
10511051

1052+
#if ENABLED(PRINTER_EVENT_LEDS)
1053+
#define PE_LEDS_COMPLETED_TIME (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination
1054+
#endif
1055+
10521056
/**
10531057
* Continue after Power-Loss (Creality3D)
10541058
*

Marlin/src/MarlinCore.cpp

+21-48
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,24 @@ bool wait_for_heatup = true;
210210
// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
211211
#if HAS_RESUME_CONTINUE
212212
bool wait_for_user; // = false;
213+
214+
void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
215+
#if DISABLED(ADVANCED_PAUSE_FEATURE)
216+
UNUSED(no_sleep);
217+
#endif
218+
KEEPALIVE_STATE(PAUSED_FOR_USER);
219+
wait_for_user = true;
220+
if (ms) ms += millis(); // expire time
221+
while (wait_for_user && !(ms && ELAPSED(millis(), ms))) {
222+
idle(
223+
#if ENABLED(ADVANCED_PAUSE_FEATURE)
224+
no_sleep
225+
#endif
226+
);
227+
}
228+
wait_for_user = false;
229+
}
230+
213231
#endif
214232

215233
// Inactivity shutdown
@@ -418,53 +436,8 @@ void startOrResumeJob() {
418436
}
419437

420438
inline void finishSDPrinting() {
421-
422-
bool did_state = true;
423-
switch (card.sdprinting_done_state) {
424-
425-
case 1:
426-
if (print_job_timer.duration() > 60)
427-
did_state = queue.enqueue_one_P(PSTR("M31"));
428-
break;
429-
430-
case 2:
431-
did_state = queue.enqueue_one_P(PSTR("M77"));
432-
break;
433-
434-
case 3:
435-
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
436-
ui.set_progress_done();
437-
#endif
438-
break;
439-
440-
case 4: // Display "Click to Continue..."
441-
#if HAS_LEDS_OFF_FLAG // 30 min timeout with LCD, 1 min without
442-
did_state = queue.enqueue_one_P(
443-
print_job_timer.duration() < 60 ? PSTR("M0Q1P1") : PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60"))
444-
);
445-
#endif
446-
break;
447-
448-
case 5:
449-
#if ENABLED(POWER_LOSS_RECOVERY)
450-
recovery.purge();
451-
#endif
452-
453-
#if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
454-
planner.finish_and_disable();
455-
#endif
456-
457-
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
458-
ui.reselect_last_file();
459-
#endif
460-
461-
SERIAL_ECHOLNPGM(STR_FILE_PRINTED);
462-
463-
default:
464-
did_state = false;
465-
card.sdprinting_done_state = 0;
466-
}
467-
if (did_state) ++card.sdprinting_done_state;
439+
if (queue.enqueue_one_P(PSTR("M1001")))
440+
marlin_state = MF_RUNNING;
468441
}
469442

470443
#endif // SDSUPPORT
@@ -1209,7 +1182,7 @@ void loop() {
12091182
#if ENABLED(SDSUPPORT)
12101183
card.checkautostart();
12111184
if (card.flag.abort_sd_printing) abortSDPrinting();
1212-
if (card.sdprinting_done_state) finishSDPrinting();
1185+
if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
12131186
#endif
12141187

12151188
queue.advance();

Marlin/src/MarlinCore.h

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ enum MarlinState : uint8_t {
8383
MF_PAUSED = _BV(1),
8484
MF_WAITING = _BV(2),
8585
MF_STOPPED = _BV(3),
86+
MF_SD_COMPLETE = _BV(4),
8687
MF_KILLED = _BV(7)
8788
};
8889

@@ -98,6 +99,7 @@ extern bool wait_for_heatup;
9899

99100
#if HAS_RESUME_CONTINUE
100101
extern bool wait_for_user;
102+
void wait_for_user_response(millis_t ms=0, const bool no_sleep=false);
101103
#endif
102104

103105
// Inactivity shutdown timer

Marlin/src/core/boards.h

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
#define BOARD_LEAPFROG_XEED2015 1321 // Leapfrog Xeed 2015
145145
#define BOARD_PICA_REVB 1322 // PICA Shield (original version)
146146
#define BOARD_PICA 1323 // PICA Shield (rev C or later)
147+
#define BOARD_INTAMSYS40 1324 // Intamsys 4.0 (Funmat HT)
147148

148149
//
149150
// ATmega1281, ATmega2561

Marlin/src/feature/mmu2/mmu2.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -707,14 +707,13 @@ void MMU2::filament_runout() {
707707
if (recover) {
708708
LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER);
709709
BUZZ(200, 404);
710-
wait_for_user = true;
711710
#if ENABLED(HOST_PROMPT_SUPPORT)
712711
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR);
713712
#endif
714713
#if ENABLED(EXTENSIBLE_UI)
715714
ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"));
716715
#endif
717-
while (wait_for_user) idle();
716+
wait_for_user_response();
718717
BUZZ(200, 404);
719718
BUZZ(200, 404);
720719

Marlin/src/feature/pause.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
184184
#endif
185185

186186
KEEPALIVE_STATE(PAUSED_FOR_USER);
187-
wait_for_user = true; // LCD click or M108 will clear this
188187
#if ENABLED(HOST_PROMPT_SUPPORT)
189188
const char tool = '0'
190189
#if NUM_RUNOUT_SENSORS > 1
@@ -246,13 +245,13 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
246245
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
247246
#endif
248247

249-
wait_for_user = true;
250248
#if ENABLED(HOST_PROMPT_SUPPORT)
251249
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR);
252250
#endif
253251
#if ENABLED(EXTENSIBLE_UI)
254252
ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging..."));
255253
#endif
254+
wait_for_user = true; // A click or M108 breaks the purge_length loop
256255
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
257256
do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
258257
wait_for_user = false;
@@ -508,13 +507,13 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
508507

509508
// Wait for filament insert by user and press button
510509
KEEPALIVE_STATE(PAUSED_FOR_USER);
511-
wait_for_user = true; // LCD click or M108 will clear this
512510
#if ENABLED(HOST_PROMPT_SUPPORT)
513511
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Nozzle Parked"), CONTINUE_STR);
514512
#endif
515513
#if ENABLED(EXTENSIBLE_UI)
516514
ExtUI::onUserConfirmRequired_P(PSTR("Nozzle Parked"));
517515
#endif
516+
wait_for_user = true; // LCD click or M108 will clear this
518517
while (wait_for_user) {
519518
#if HAS_BUZZER
520519
filament_change_beep(max_beep_count);
@@ -540,8 +539,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
540539
ExtUI::onUserConfirmRequired_P(PSTR("HeaterTimeout"));
541540
#endif
542541

543-
// Wait for LCD click or M108
544-
while (wait_for_user) idle_no_sleep();
542+
wait_for_user_response(0, true); // Wait for LCD click or M108
545543

546544
#if ENABLED(HOST_PROMPT_SUPPORT)
547545
host_prompt_do(PROMPT_INFO, PSTR("Reheating"));

Marlin/src/feature/twibus.cpp

+17-39
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,27 @@ void TWIBus::address(const uint8_t adr) {
4949

5050
addr = adr;
5151

52-
#if ENABLED(DEBUG_TWIBUS)
53-
debug(PSTR("address"), adr);
54-
#endif
52+
debug(PSTR("address"), adr);
5553
}
5654

5755
void TWIBus::addbyte(const char c) {
5856
if (buffer_s >= COUNT(buffer)) return;
5957
buffer[buffer_s++] = c;
60-
#if ENABLED(DEBUG_TWIBUS)
61-
debug(PSTR("addbyte"), c);
62-
#endif
58+
debug(PSTR("addbyte"), c);
6359
}
6460

6561
void TWIBus::addbytes(char src[], uint8_t bytes) {
66-
#if ENABLED(DEBUG_TWIBUS)
67-
debug(PSTR("addbytes"), bytes);
68-
#endif
62+
debug(PSTR("addbytes"), bytes);
6963
while (bytes--) addbyte(*src++);
7064
}
7165

7266
void TWIBus::addstring(char str[]) {
73-
#if ENABLED(DEBUG_TWIBUS)
74-
debug(PSTR("addstring"), str);
75-
#endif
67+
debug(PSTR("addstring"), str);
7668
while (char c = *str++) addbyte(c);
7769
}
7870

7971
void TWIBus::send() {
80-
#if ENABLED(DEBUG_TWIBUS)
81-
debug(PSTR("send"), addr);
82-
#endif
72+
debug(PSTR("send"), addr);
8373

8474
Wire.beginTransmission(I2C_ADDRESS(addr));
8575
Wire.write(buffer, buffer_s);
@@ -89,47 +79,41 @@ void TWIBus::send() {
8979
}
9080

9181
// static
92-
void TWIBus::echoprefix(uint8_t bytes, const char prefix[], uint8_t adr) {
82+
void TWIBus::echoprefix(uint8_t bytes, const char pref[], uint8_t adr) {
9383
SERIAL_ECHO_START();
94-
serialprintPGM(prefix);
84+
serialprintPGM(pref);
9585
SERIAL_ECHOPAIR(": from:", adr, " bytes:", bytes, " data:");
9686
}
9787

9888
// static
99-
void TWIBus::echodata(uint8_t bytes, const char prefix[], uint8_t adr) {
100-
echoprefix(bytes, prefix, adr);
89+
void TWIBus::echodata(uint8_t bytes, const char pref[], uint8_t adr) {
90+
echoprefix(bytes, pref, adr);
10191
while (bytes-- && Wire.available()) SERIAL_CHAR(Wire.read());
10292
SERIAL_EOL();
10393
}
10494

105-
void TWIBus::echobuffer(const char prefix[], uint8_t adr) {
106-
echoprefix(buffer_s, prefix, adr);
95+
void TWIBus::echobuffer(const char pref[], uint8_t adr) {
96+
echoprefix(buffer_s, pref, adr);
10797
LOOP_L_N(i, buffer_s) SERIAL_CHAR(buffer[i]);
10898
SERIAL_EOL();
10999
}
110100

111101
bool TWIBus::request(const uint8_t bytes) {
112102
if (!addr) return false;
113103

114-
#if ENABLED(DEBUG_TWIBUS)
115-
debug(PSTR("request"), bytes);
116-
#endif
104+
debug(PSTR("request"), bytes);
117105

118106
// requestFrom() is a blocking function
119107
if (Wire.requestFrom(addr, bytes) == 0) {
120-
#if ENABLED(DEBUG_TWIBUS)
121-
debug("request fail", addr);
122-
#endif
108+
debug("request fail", addr);
123109
return false;
124110
}
125111

126112
return true;
127113
}
128114

129115
void TWIBus::relay(const uint8_t bytes) {
130-
#if ENABLED(DEBUG_TWIBUS)
131-
debug(PSTR("relay"), bytes);
132-
#endif
116+
debug(PSTR("relay"), bytes);
133117

134118
if (request(bytes))
135119
echodata(bytes, PSTR("i2c-reply"), addr);
@@ -141,9 +125,7 @@ uint8_t TWIBus::capture(char *dst, const uint8_t bytes) {
141125
while (count < bytes && Wire.available())
142126
dst[count++] = Wire.read();
143127

144-
#if ENABLED(DEBUG_TWIBUS)
145-
debug(PSTR("capture"), count);
146-
#endif
128+
debug(PSTR("capture"), count);
147129

148130
return count;
149131
}
@@ -156,16 +138,12 @@ void TWIBus::flush() {
156138
#if I2C_SLAVE_ADDRESS > 0
157139

158140
void TWIBus::receive(uint8_t bytes) {
159-
#if ENABLED(DEBUG_TWIBUS)
160-
debug(PSTR("receive"), bytes);
161-
#endif
141+
debug(PSTR("receive"), bytes);
162142
echodata(bytes, PSTR("i2c-receive"), 0);
163143
}
164144

165145
void TWIBus::reply(char str[]/*=nullptr*/) {
166-
#if ENABLED(DEBUG_TWIBUS)
167-
debug(PSTR("reply"), str);
168-
#endif
146+
debug(PSTR("reply"), str);
169147

170148
if (str) {
171149
reset();

Marlin/src/feature/twibus.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ class TWIBus {
223223
#endif
224224

225225
#if ENABLED(DEBUG_TWIBUS)
226-
227226
/**
228227
* @brief Prints a debug message
229228
* @details Prints a simple debug message "TWIBus::function: value"
@@ -233,6 +232,10 @@ class TWIBus {
233232
static void debug(const char func[], char c);
234233
static void debug(const char func[], char adr[]);
235234
static inline void debug(const char func[], uint8_t v) { debug(func, (uint32_t)v); }
236-
235+
#else
236+
static inline void debug(const char[], uint32_t) {}
237+
static inline void debug(const char[], char) {}
238+
static inline void debug(const char[], char[]) {}
239+
static inline void debug(const char[], uint8_t) {}
237240
#endif
238241
};

Marlin/src/gcode/calibrate/G28.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -255,28 +255,28 @@ void GcodeSuite::G28() {
255255
#define HAS_HOMING_CURRENT (HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2))
256256

257257
#if HAS_HOMING_CURRENT
258-
auto debug_current = [](const char * const s, const int16_t a, const int16_t b){
259-
DEBUG_ECHO(s); DEBUG_ECHOLNPAIR(" current: ", a, " -> ", b);
258+
auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b){
259+
serialprintPGM(s); DEBUG_ECHOLNPAIR(" current: ", a, " -> ", b);
260260
};
261261
#if HAS_CURRENT_HOME(X)
262262
const int16_t tmc_save_current_X = stepperX.getMilliamps();
263263
stepperX.rms_current(X_CURRENT_HOME);
264-
if (DEBUGGING(LEVELING)) debug_current("X", tmc_save_current_X, X_CURRENT_HOME);
264+
if (DEBUGGING(LEVELING)) debug_current(PSTR("X"), tmc_save_current_X, X_CURRENT_HOME);
265265
#endif
266266
#if HAS_CURRENT_HOME(X2)
267267
const int16_t tmc_save_current_X2 = stepperX2.getMilliamps();
268268
stepperX2.rms_current(X2_CURRENT_HOME);
269-
if (DEBUGGING(LEVELING)) debug_current("X2", tmc_save_current_X2, X2_CURRENT_HOME);
269+
if (DEBUGGING(LEVELING)) debug_current(PSTR("X2"), tmc_save_current_X2, X2_CURRENT_HOME);
270270
#endif
271271
#if HAS_CURRENT_HOME(Y)
272272
const int16_t tmc_save_current_Y = stepperY.getMilliamps();
273273
stepperY.rms_current(Y_CURRENT_HOME);
274-
if (DEBUGGING(LEVELING)) debug_current("Y", tmc_save_current_Y, Y_CURRENT_HOME);
274+
if (DEBUGGING(LEVELING)) debug_current(PSTR("Y"), tmc_save_current_Y, Y_CURRENT_HOME);
275275
#endif
276276
#if HAS_CURRENT_HOME(Y2)
277277
const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps();
278278
stepperY2.rms_current(Y2_CURRENT_HOME);
279-
if (DEBUGGING(LEVELING)) debug_current("Y2", tmc_save_current_Y2, Y2_CURRENT_HOME);
279+
if (DEBUGGING(LEVELING)) debug_current(PSTR("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME);
280280
#endif
281281
#endif
282282

@@ -345,12 +345,8 @@ void GcodeSuite::G28() {
345345
#endif
346346

347347
// Home Y (before X)
348-
#if ENABLED(HOME_Y_BEFORE_X)
349-
350-
if (doY || (doX && ENABLED(CODEPENDENT_XY_HOMING)))
351-
homeaxis(Y_AXIS);
352-
353-
#endif
348+
if (ENABLED(HOME_Y_BEFORE_X) && (doY || (ENABLED(CODEPENDENT_XY_HOMING) && doX)))
349+
homeaxis(Y_AXIS);
354350

355351
// Home X
356352
if (doX || (doY && ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X))) {

0 commit comments

Comments
 (0)