|
@@ -45,8 +45,6 @@
|
45
|
45
|
|
46
|
46
|
#if ENABLED(MALYAN_LCD)
|
47
|
47
|
|
48
|
|
-#include "../sd/cardreader.h"
|
49
|
|
-#include "../sd/SdFatConfig.h"
|
50
|
48
|
#include "../module/temperature.h"
|
51
|
49
|
#include "../module/planner.h"
|
52
|
50
|
#include "../module/stepper.h"
|
|
@@ -60,6 +58,13 @@
|
60
|
58
|
|
61
|
59
|
#include "../Marlin.h"
|
62
|
60
|
|
|
61
|
+#if ENABLED(SDSUPPORT)
|
|
62
|
+ #include "../sd/cardreader.h"
|
|
63
|
+ #include "../sd/SdFatConfig.h"
|
|
64
|
+#else
|
|
65
|
+ #define LONG_FILENAME_LENGTH 0
|
|
66
|
+#endif
|
|
67
|
+
|
63
|
68
|
// On the Malyan M200, this will be Serial1. On a RAMPS board,
|
64
|
69
|
// it might not be.
|
65
|
70
|
#define LCD_SERIAL Serial1
|
|
@@ -135,8 +140,6 @@ void process_lcd_c_command(const char* command) {
|
135
|
140
|
void process_lcd_eb_command(const char* command) {
|
136
|
141
|
char elapsed_buffer[10];
|
137
|
142
|
duration_t elapsed;
|
138
|
|
- bool has_days;
|
139
|
|
- uint8_t len;
|
140
|
143
|
switch (command[0]) {
|
141
|
144
|
case '0': {
|
142
|
145
|
elapsed = print_job_timer.duration();
|
|
@@ -147,9 +150,17 @@ void process_lcd_eb_command(const char* command) {
|
147
|
150
|
PSTR("{T0:%03.0f/%03i}{T1:000/000}{TP:%03.0f/%03i}{TQ:%03i}{TT:%s}"),
|
148
|
151
|
thermalManager.degHotend(0),
|
149
|
152
|
thermalManager.degTargetHotend(0),
|
150
|
|
- thermalManager.degBed(),
|
151
|
|
- thermalManager.degTargetBed(),
|
152
|
|
- card.percentDone(),
|
|
153
|
+ #if HAS_HEATED_BED
|
|
154
|
+ thermalManager.degBed(),
|
|
155
|
+ thermalManager.degTargetBed(),
|
|
156
|
+ #else
|
|
157
|
+ 0, 0,
|
|
158
|
+ #endif
|
|
159
|
+ #if ENABLED(SDSUPPORT)
|
|
160
|
+ card.percentDone(),
|
|
161
|
+ #else
|
|
162
|
+ 0,
|
|
163
|
+ #endif
|
153
|
164
|
elapsed_buffer);
|
154
|
165
|
write_to_lcd(message_buffer);
|
155
|
166
|
} break;
|
|
@@ -226,51 +237,55 @@ void process_lcd_p_command(const char* command) {
|
226
|
237
|
|
227
|
238
|
switch (command[0]) {
|
228
|
239
|
case 'X':
|
229
|
|
- // cancel print
|
230
|
|
- write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
231
|
|
- card.stopSDPrint(
|
232
|
|
- #if SD_RESORT
|
233
|
|
- true
|
|
240
|
+ #if ENABLED(SDSUPPORT)
|
|
241
|
+ // cancel print
|
|
242
|
+ write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
|
243
|
+ card.stopSDPrint(
|
|
244
|
+ #if SD_RESORT
|
|
245
|
+ true
|
|
246
|
+ #endif
|
|
247
|
+ );
|
|
248
|
+ clear_command_queue();
|
|
249
|
+ quickstop_stepper();
|
|
250
|
+ print_job_timer.stop();
|
|
251
|
+ thermalManager.disable_all_heaters();
|
|
252
|
+ #if FAN_COUNT > 0
|
|
253
|
+ for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
|
234
|
254
|
#endif
|
235
|
|
- );
|
236
|
|
- clear_command_queue();
|
237
|
|
- quickstop_stepper();
|
238
|
|
- print_job_timer.stop();
|
239
|
|
- thermalManager.disable_all_heaters();
|
240
|
|
- #if FAN_COUNT > 0
|
241
|
|
- for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
|
|
255
|
+ wait_for_heatup = false;
|
|
256
|
+ write_to_lcd_P(PSTR("{SYS:STARTED}"));
|
242
|
257
|
#endif
|
243
|
|
- wait_for_heatup = false;
|
244
|
|
- write_to_lcd_P(PSTR("{SYS:STARTED}"));
|
245
|
258
|
break;
|
246
|
259
|
case 'H':
|
247
|
260
|
// Home all axis
|
248
|
261
|
enqueue_and_echo_commands_now_P(PSTR("G28"));
|
249
|
262
|
break;
|
250
|
263
|
default: {
|
251
|
|
- // Print file 000 - a three digit number indicating which
|
252
|
|
- // file to print in the SD card. If it's a directory,
|
253
|
|
- // then switch to the directory.
|
254
|
|
-
|
255
|
|
- // Find the name of the file to print.
|
256
|
|
- // It's needed to echo the PRINTFILE option.
|
257
|
|
- // The {S:L} command should've ensured the SD card was mounted.
|
258
|
|
- card.getfilename(atoi(command));
|
259
|
|
-
|
260
|
|
- // There may be a difference in how V1 and V2 LCDs handle subdirectory
|
261
|
|
- // prints. Investigate more. This matches the V1 motion controller actions
|
262
|
|
- // but the V2 LCD switches to "print" mode on {SYS:DIR} response.
|
263
|
|
- if (card.filenameIsDir) {
|
264
|
|
- card.chdir(card.filename);
|
265
|
|
- write_to_lcd_P(PSTR("{SYS:DIR}"));
|
266
|
|
- }
|
267
|
|
- else {
|
268
|
|
- char message_buffer[MAX_CURLY_COMMAND];
|
269
|
|
- sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.filename);
|
270
|
|
- write_to_lcd(message_buffer);
|
271
|
|
- write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
272
|
|
- card.openAndPrintFile(card.filename);
|
273
|
|
- }
|
|
264
|
+ #if ENABLED(SDSUPPORT)
|
|
265
|
+ // Print file 000 - a three digit number indicating which
|
|
266
|
+ // file to print in the SD card. If it's a directory,
|
|
267
|
+ // then switch to the directory.
|
|
268
|
+
|
|
269
|
+ // Find the name of the file to print.
|
|
270
|
+ // It's needed to echo the PRINTFILE option.
|
|
271
|
+ // The {S:L} command should've ensured the SD card was mounted.
|
|
272
|
+ card.getfilename(atoi(command));
|
|
273
|
+
|
|
274
|
+ // There may be a difference in how V1 and V2 LCDs handle subdirectory
|
|
275
|
+ // prints. Investigate more. This matches the V1 motion controller actions
|
|
276
|
+ // but the V2 LCD switches to "print" mode on {SYS:DIR} response.
|
|
277
|
+ if (card.filenameIsDir) {
|
|
278
|
+ card.chdir(card.filename);
|
|
279
|
+ write_to_lcd_P(PSTR("{SYS:DIR}"));
|
|
280
|
+ }
|
|
281
|
+ else {
|
|
282
|
+ char message_buffer[MAX_CURLY_COMMAND];
|
|
283
|
+ sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.filename);
|
|
284
|
+ write_to_lcd(message_buffer);
|
|
285
|
+ write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
|
286
|
+ card.openAndPrintFile(card.filename);
|
|
287
|
+ }
|
|
288
|
+ #endif
|
274
|
289
|
} break; // default
|
275
|
290
|
} // switch
|
276
|
291
|
}
|
|
@@ -295,34 +310,40 @@ void process_lcd_s_command(const char* command) {
|
295
|
310
|
char message_buffer[MAX_CURLY_COMMAND];
|
296
|
311
|
sprintf_P(message_buffer, PSTR("{T0:%03.0f/%03i}{T1:000/000}{TP:%03.0f/%03i}"),
|
297
|
312
|
thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
|
298
|
|
- thermalManager.degBed(), thermalManager.degTargetBed()
|
|
313
|
+ #if HAS_HEATED_BED
|
|
314
|
+ thermalManager.degBed(), thermalManager.degTargetBed()
|
|
315
|
+ #else
|
|
316
|
+ 0, 0
|
|
317
|
+ #endif
|
299
|
318
|
);
|
300
|
319
|
write_to_lcd(message_buffer);
|
301
|
320
|
} break;
|
302
|
321
|
|
303
|
322
|
case 'H':
|
304
|
323
|
// Home all axis
|
305
|
|
- enqueue_and_echo_commands_P(PSTR("G28"));
|
|
324
|
+ enqueue_and_echo_command("G28");
|
306
|
325
|
break;
|
307
|
326
|
|
308
|
327
|
case 'L': {
|
309
|
|
- if (!card.cardOK) card.initsd();
|
310
|
|
-
|
311
|
|
- // A more efficient way to do this would be to
|
312
|
|
- // implement a callback in the ls_SerialPrint code, but
|
313
|
|
- // that requires changes to the core cardreader class that
|
314
|
|
- // would not benefit the majority of users. Since one can't
|
315
|
|
- // select a file for printing during a print, there's
|
316
|
|
- // little reason not to do it this way.
|
317
|
|
- char message_buffer[MAX_CURLY_COMMAND];
|
318
|
|
- uint16_t file_count = card.get_num_Files();
|
319
|
|
- for (uint16_t i = 0; i < file_count; i++) {
|
320
|
|
- card.getfilename(i);
|
321
|
|
- sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.filename);
|
322
|
|
- write_to_lcd(message_buffer);
|
323
|
|
- }
|
324
|
|
-
|
325
|
|
- write_to_lcd_P(PSTR("{SYS:OK}"));
|
|
328
|
+ #if ENABLED(SDSUPPORT)
|
|
329
|
+ if (!card.cardOK) card.initsd();
|
|
330
|
+
|
|
331
|
+ // A more efficient way to do this would be to
|
|
332
|
+ // implement a callback in the ls_SerialPrint code, but
|
|
333
|
+ // that requires changes to the core cardreader class that
|
|
334
|
+ // would not benefit the majority of users. Since one can't
|
|
335
|
+ // select a file for printing during a print, there's
|
|
336
|
+ // little reason not to do it this way.
|
|
337
|
+ char message_buffer[MAX_CURLY_COMMAND];
|
|
338
|
+ uint16_t file_count = card.get_num_Files();
|
|
339
|
+ for (uint16_t i = 0; i < file_count; i++) {
|
|
340
|
+ card.getfilename(i);
|
|
341
|
+ sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.filename);
|
|
342
|
+ write_to_lcd(message_buffer);
|
|
343
|
+ }
|
|
344
|
+
|
|
345
|
+ write_to_lcd_P(PSTR("{SYS:OK}"));
|
|
346
|
+ #endif
|
326
|
347
|
} break;
|
327
|
348
|
|
328
|
349
|
default:
|
|
@@ -382,7 +403,7 @@ void update_usb_status(const bool forceUpdate) {
|
382
|
403
|
// appears to use the usb discovery status.
|
383
|
404
|
// This is more logical.
|
384
|
405
|
if (last_usb_connected_status != Serial || forceUpdate) {
|
385
|
|
- last_usb_connected_status = Serial;
|
|
406
|
+ last_usb_connected_status = Serial;
|
386
|
407
|
write_to_lcd_P(last_usb_connected_status ? PSTR("{R:UC}\r\n") : PSTR("{R:UD}\r\n"));
|
387
|
408
|
}
|
388
|
409
|
}
|
|
@@ -411,15 +432,17 @@ void lcd_update() {
|
411
|
432
|
}
|
412
|
433
|
}
|
413
|
434
|
|
414
|
|
- // If there's a print in progress, we need to emit the status as
|
415
|
|
- // {TQ:<PERCENT>}
|
416
|
|
- if (card.sdprinting) {
|
417
|
|
- // We also need to send: T:-2538.0 E:0
|
418
|
|
- // I have no idea what this means.
|
419
|
|
- char message_buffer[10];
|
420
|
|
- sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
|
421
|
|
- write_to_lcd(message_buffer);
|
422
|
|
- }
|
|
435
|
+ #if ENABLED(SDSUPPORT)
|
|
436
|
+ // If there's a print in progress, we need to emit the status as
|
|
437
|
+ // {TQ:<PERCENT>}
|
|
438
|
+ if (card.sdprinting) {
|
|
439
|
+ // We also need to send: T:-2538.0 E:0
|
|
440
|
+ // I have no idea what this means.
|
|
441
|
+ char message_buffer[10];
|
|
442
|
+ sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
|
|
443
|
+ write_to_lcd(message_buffer);
|
|
444
|
+ }
|
|
445
|
+ #endif
|
423
|
446
|
}
|
424
|
447
|
|
425
|
448
|
/**
|