|
@@ -77,6 +77,10 @@
|
77
|
77
|
// Track incoming command bytes from the LCD
|
78
|
78
|
int inbound_count;
|
79
|
79
|
|
|
80
|
+// For sending print completion messages
|
|
81
|
+bool last_printing_status = false;
|
|
82
|
+uint8_t last_percent_done = 100;
|
|
83
|
+
|
80
|
84
|
// Everything written needs the high bit set.
|
81
|
85
|
void write_to_lcd_P(const char * const message) {
|
82
|
86
|
char encoded_message[MAX_CURLY_COMMAND];
|
|
@@ -106,22 +110,23 @@ void write_to_lcd(const char * const message) {
|
106
|
110
|
* {C:P050}
|
107
|
111
|
* Set temp for bed to 50
|
108
|
112
|
*
|
|
113
|
+ * {C:S09} set feedrate to 90 %.
|
|
114
|
+ * {C:S12} set feedrate to 120 %.
|
|
115
|
+ *
|
109
|
116
|
* the command portion begins after the :
|
110
|
117
|
*/
|
111
|
118
|
void process_lcd_c_command(const char* command) {
|
112
|
119
|
switch (command[0]) {
|
|
120
|
+ case 'C': {
|
|
121
|
+ int raw_feedrate = atoi(command + 1);
|
|
122
|
+ feedrate_percentage = raw_feedrate * 10;
|
|
123
|
+ feedrate_percentage = constrain(feedrate_percentage, 10, 999);
|
|
124
|
+ } break;
|
113
|
125
|
case 'T': {
|
114
|
|
- // M104 S<temperature>
|
115
|
|
- char cmd[20];
|
116
|
|
- sprintf_P(cmd, PSTR("M104 S%s"), command + 1);
|
117
|
|
- enqueue_and_echo_command_now(cmd);
|
|
126
|
+ thermalManager.setTargetHotend(atoi(command + 1), 0);
|
118
|
127
|
} break;
|
119
|
|
-
|
120
|
128
|
case 'P': {
|
121
|
|
- // M140 S<temperature>
|
122
|
|
- char cmd[20];
|
123
|
|
- sprintf_P(cmd, PSTR("M140 S%s"), command + 1);
|
124
|
|
- enqueue_and_echo_command_now(cmd);
|
|
129
|
+ thermalManager.setTargetBed(atoi(command + 1));
|
125
|
130
|
} break;
|
126
|
131
|
|
127
|
132
|
default:
|
|
@@ -240,6 +245,7 @@ void process_lcd_p_command(const char* command) {
|
240
|
245
|
#if ENABLED(SDSUPPORT)
|
241
|
246
|
// cancel print
|
242
|
247
|
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
|
248
|
+ last_printing_status = false;
|
243
|
249
|
card.stopSDPrint(
|
244
|
250
|
#if SD_RESORT
|
245
|
251
|
true
|
|
@@ -280,7 +286,7 @@ void process_lcd_p_command(const char* command) {
|
280
|
286
|
}
|
281
|
287
|
else {
|
282
|
288
|
char message_buffer[MAX_CURLY_COMMAND];
|
283
|
|
- sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.filename);
|
|
289
|
+ sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.longest_filename());
|
284
|
290
|
write_to_lcd(message_buffer);
|
285
|
291
|
write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
286
|
292
|
card.openAndPrintFile(card.filename);
|
|
@@ -321,7 +327,7 @@ void process_lcd_s_command(const char* command) {
|
321
|
327
|
|
322
|
328
|
case 'H':
|
323
|
329
|
// Home all axis
|
324
|
|
- enqueue_and_echo_command("G28");
|
|
330
|
+ enqueue_and_echo_command("G28", false);
|
325
|
331
|
break;
|
326
|
332
|
|
327
|
333
|
case 'L': {
|
|
@@ -338,7 +344,7 @@ void process_lcd_s_command(const char* command) {
|
338
|
344
|
uint16_t file_count = card.get_num_Files();
|
339
|
345
|
for (uint16_t i = 0; i < file_count; i++) {
|
340
|
346
|
card.getfilename(i);
|
341
|
|
- sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.filename);
|
|
347
|
+ sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.longest_filename());
|
342
|
348
|
write_to_lcd(message_buffer);
|
343
|
349
|
}
|
344
|
350
|
|
|
@@ -395,7 +401,7 @@ void process_lcd_command(const char* command) {
|
395
|
401
|
/**
|
396
|
402
|
* UC means connected.
|
397
|
403
|
* UD means disconnected
|
398
|
|
- * The stock firmware considers USB initialied as "connected."
|
|
404
|
+ * The stock firmware considers USB initialized as "connected."
|
399
|
405
|
*/
|
400
|
406
|
void update_usb_status(const bool forceUpdate) {
|
401
|
407
|
static bool last_usb_connected_status = false;
|
|
@@ -433,14 +439,28 @@ void lcd_update() {
|
433
|
439
|
}
|
434
|
440
|
|
435
|
441
|
#if ENABLED(SDSUPPORT)
|
436
|
|
- // If there's a print in progress, we need to emit the status as
|
437
|
|
- // {TQ:<PERCENT>}
|
|
442
|
+ // The way last printing status works is simple:
|
|
443
|
+ // The UI needs to see at least one TQ which is not 100%
|
|
444
|
+ // and then when the print is complete, one which is.
|
438
|
445
|
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);
|
|
446
|
+ if (card.percentDone() != last_percent_done) {
|
|
447
|
+ char message_buffer[10];
|
|
448
|
+ last_percent_done = card.percentDone();
|
|
449
|
+ sprintf_P(message_buffer, PSTR("{TQ:%03i}"), last_percent_done);
|
|
450
|
+ write_to_lcd(message_buffer);
|
|
451
|
+
|
|
452
|
+ if (!last_printing_status) last_printing_status = true;
|
|
453
|
+ }
|
|
454
|
+ }
|
|
455
|
+ else {
|
|
456
|
+ // If there was a print in progress, we need to emit the final
|
|
457
|
+ // print status as {TQ:100}. Reset last percent done so a new print will
|
|
458
|
+ // issue a percent of 0.
|
|
459
|
+ if (last_printing_status) {
|
|
460
|
+ last_printing_status = false;
|
|
461
|
+ last_percent_done = 100;
|
|
462
|
+ write_to_lcd_P(PSTR("{TQ:100}"));
|
|
463
|
+ }
|
444
|
464
|
}
|
445
|
465
|
#endif
|
446
|
466
|
}
|