|
@@ -45,6 +45,8 @@
|
45
|
45
|
|
46
|
46
|
#if ENABLED(MALYAN_LCD)
|
47
|
47
|
|
|
48
|
+#define DEBUG_MALYAN_LCD
|
|
49
|
+
|
48
|
50
|
#include "extensible_ui/ui_api.h"
|
49
|
51
|
|
50
|
52
|
#include "ultralcd.h"
|
|
@@ -62,6 +64,9 @@
|
62
|
64
|
#define LONG_FILENAME_LENGTH 0
|
63
|
65
|
#endif
|
64
|
66
|
|
|
67
|
+#define DEBUG_OUT ENABLED(DEBUG_MALYAN_LCD)
|
|
68
|
+#include "../core/debug_out.h"
|
|
69
|
+
|
65
|
70
|
// On the Malyan M200, this will be Serial1. On a RAMPS board,
|
66
|
71
|
// it might not be.
|
67
|
72
|
#define LCD_SERIAL Serial1
|
|
@@ -119,13 +124,13 @@ void process_lcd_c_command(const char* command) {
|
119
|
124
|
LIMIT(feedrate_percentage, 10, 999);
|
120
|
125
|
break;
|
121
|
126
|
|
122
|
|
- case 'T': thermalManager.setTargetHotend(atoi(command + 1), 0); break;
|
|
127
|
+ case 'T': ExtUI::setTargetTemp_celsius(atoi(command + 1), ExtUI::extruder_t::E0); break;
|
123
|
128
|
|
124
|
129
|
#if HAS_HEATED_BED
|
125
|
|
- case 'P': thermalManager.setTargetBed(atoi(command + 1)); break;
|
|
130
|
+ case 'P': ExtUI::setTargetTemp_celsius(atoi(command + 1), ExtUI::heater_t::BED); break;
|
126
|
131
|
#endif
|
127
|
132
|
|
128
|
|
- default: SERIAL_ECHOLNPAIR("UNKNOWN C COMMAND", command);
|
|
133
|
+ default: DEBUG_ECHOLNPAIR("UNKNOWN C COMMAND ", command);
|
129
|
134
|
}
|
130
|
135
|
}
|
131
|
136
|
|
|
@@ -163,9 +168,7 @@ void process_lcd_eb_command(const char* command) {
|
163
|
168
|
write_to_lcd(message_buffer);
|
164
|
169
|
} break;
|
165
|
170
|
|
166
|
|
- default:
|
167
|
|
- SERIAL_ECHOLNPAIR("UNKNOWN E/B COMMAND", command);
|
168
|
|
- return;
|
|
171
|
+ default: DEBUG_ECHOLNPAIR("UNKNOWN E/B COMMAND ", command);
|
169
|
172
|
}
|
170
|
173
|
}
|
171
|
174
|
|
|
@@ -180,32 +183,18 @@ void process_lcd_eb_command(const char* command) {
|
180
|
183
|
* X, Y, Z, A (extruder)
|
181
|
184
|
*/
|
182
|
185
|
void process_lcd_j_command(const char* command) {
|
183
|
|
- static bool steppers_enabled = false;
|
184
|
|
- char axis = command[0];
|
185
|
|
-
|
186
|
|
- switch (axis) {
|
187
|
|
- case 'E':
|
188
|
|
- // enable or disable steppers
|
189
|
|
- // switch to relative
|
190
|
|
- queue.enqueue_now_P(PSTR("G91"));
|
191
|
|
- queue.enqueue_now_P(steppers_enabled ? PSTR("M18") : PSTR("M17"));
|
192
|
|
- steppers_enabled = !steppers_enabled;
|
193
|
|
- break;
|
194
|
|
- case 'A':
|
195
|
|
- axis = 'E';
|
196
|
|
- // fallthru
|
197
|
|
- case 'Y':
|
198
|
|
- case 'Z':
|
199
|
|
- case 'X': {
|
200
|
|
- // G0 <AXIS><distance>
|
201
|
|
- // The M200 class UI seems to send movement in .1mm values.
|
202
|
|
- char cmd[20], pos[6];
|
203
|
|
- sprintf_P(cmd, PSTR("G1 %c%s"), axis, dtostrf(atof(command + 1) / 10.0, -5, 3, pos));
|
204
|
|
- queue.enqueue_one_now(cmd);
|
205
|
|
- } break;
|
206
|
|
- default:
|
207
|
|
- SERIAL_ECHOLNPAIR("UNKNOWN J COMMAND", command);
|
208
|
|
- return;
|
|
186
|
+ auto move_axis = [](const auto axis) {
|
|
187
|
+ const float dist = atof(command + 1) / 10.0;
|
|
188
|
+ ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(axis) + dist, axis);
|
|
189
|
+ }
|
|
190
|
+
|
|
191
|
+ switch (command[0]) {
|
|
192
|
+ case 'E': break;
|
|
193
|
+ case 'A': move_axis(ExtUI::extruder_t::E0); break;
|
|
194
|
+ case 'Y': move_axis(ExtUI::axis_t::Y); break;
|
|
195
|
+ case 'Z': move_axis(ExtUI::axis_t::Z); break;
|
|
196
|
+ case 'X': move_axis(ExtUI::axis_t::X); break;
|
|
197
|
+ default: DEBUG_ECHOLNPAIR("UNKNOWN J COMMAND ", command);
|
209
|
198
|
}
|
210
|
199
|
}
|
211
|
200
|
|
|
@@ -234,29 +223,20 @@ void process_lcd_j_command(const char* command) {
|
234
|
223
|
void process_lcd_p_command(const char* command) {
|
235
|
224
|
|
236
|
225
|
switch (command[0]) {
|
|
226
|
+ case 'P':
|
|
227
|
+ ExtUI::pausePrint();
|
|
228
|
+ write_to_lcd_P(PSTR("{SYS:PAUSED}"));
|
|
229
|
+ break;
|
|
230
|
+ case 'R':
|
|
231
|
+ ExtUI::resumePrint();
|
|
232
|
+ write_to_lcd_P(PSTR("{SYS:RESUMED}"));
|
|
233
|
+ break;
|
237
|
234
|
case 'X':
|
238
|
|
- #if ENABLED(SDSUPPORT)
|
239
|
|
- // cancel print
|
240
|
235
|
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
241
|
|
- last_printing_status = false;
|
242
|
|
- card.stopSDPrint(
|
243
|
|
- #if SD_RESORT
|
244
|
|
- true
|
245
|
|
- #endif
|
246
|
|
- );
|
247
|
|
- queue.clear();
|
248
|
|
- quickstop_stepper();
|
249
|
|
- print_job_timer.stop();
|
250
|
|
- thermalManager.disable_all_heaters();
|
251
|
|
- thermalManager.zero_fan_speeds();
|
252
|
|
- wait_for_heatup = false;
|
|
236
|
+ ExtUI::stopPrint();
|
253
|
237
|
write_to_lcd_P(PSTR("{SYS:STARTED}"));
|
254
|
|
- #endif
|
255
|
|
- break;
|
256
|
|
- case 'H':
|
257
|
|
- // Home all axis
|
258
|
|
- queue.enqueue_now_P(PSTR("G28"));
|
259
|
|
- break;
|
|
238
|
+ break;
|
|
239
|
+ case 'H': queue.enqueue_now_P(PSTR("G28")); break; // Home all axes
|
260
|
240
|
default: {
|
261
|
241
|
#if ENABLED(SDSUPPORT)
|
262
|
242
|
// Print file 000 - a three digit number indicating which
|
|
@@ -338,9 +318,7 @@ void process_lcd_s_command(const char* command) {
|
338
|
318
|
#endif
|
339
|
319
|
} break;
|
340
|
320
|
|
341
|
|
- default:
|
342
|
|
- SERIAL_ECHOLNPAIR("UNKNOWN S COMMAND", command);
|
343
|
|
- return;
|
|
321
|
+ default: DEBUG_ECHOLNPAIR("UNKNOWN S COMMAND ", command);
|
344
|
322
|
}
|
345
|
323
|
}
|
346
|
324
|
|
|
@@ -354,34 +332,22 @@ void process_lcd_command(const char* command) {
|
354
|
332
|
|
355
|
333
|
current++; // skip the leading {. The trailing one is already gone.
|
356
|
334
|
byte command_code = *current++;
|
357
|
|
- if (*current != ':') {
|
358
|
|
- SERIAL_ECHOLNPAIR("UNKNOWN COMMAND FORMAT", command);
|
359
|
|
- return;
|
360
|
|
- }
|
361
|
|
-
|
362
|
|
- current++; // skip the :
|
363
|
|
-
|
364
|
|
- switch (command_code) {
|
365
|
|
- case 'S':
|
366
|
|
- process_lcd_s_command(current);
|
367
|
|
- break;
|
368
|
|
- case 'J':
|
369
|
|
- process_lcd_j_command(current);
|
370
|
|
- break;
|
371
|
|
- case 'P':
|
372
|
|
- process_lcd_p_command(current);
|
373
|
|
- break;
|
374
|
|
- case 'C':
|
375
|
|
- process_lcd_c_command(current);
|
376
|
|
- break;
|
377
|
|
- case 'B':
|
378
|
|
- case 'E':
|
379
|
|
- process_lcd_eb_command(current);
|
380
|
|
- break;
|
381
|
|
- default:
|
382
|
|
- SERIAL_ECHOLNPAIR("UNKNOWN COMMAND", command);
|
383
|
|
- return;
|
|
335
|
+ if (*current == ':') {
|
|
336
|
+
|
|
337
|
+ current++; // skip the :
|
|
338
|
+
|
|
339
|
+ switch (command_code) {
|
|
340
|
+ case 'S': process_lcd_s_command(current); break;
|
|
341
|
+ case 'J': process_lcd_j_command(current); break;
|
|
342
|
+ case 'P': process_lcd_p_command(current); break;
|
|
343
|
+ case 'C': process_lcd_c_command(current); break;
|
|
344
|
+ case 'B':
|
|
345
|
+ case 'E': process_lcd_eb_command(current); break;
|
|
346
|
+ default: DEBUG_ECHOLNPAIR("UNKNOWN COMMAND ", command);
|
|
347
|
+ }
|
384
|
348
|
}
|
|
349
|
+ else
|
|
350
|
+ DEBUG_ECHOLNPAIR("UNKNOWN COMMAND FORMAT ", command);
|
385
|
351
|
}
|
386
|
352
|
|
387
|
353
|
/**
|
|
@@ -405,8 +371,7 @@ namespace ExtUI {
|
405
|
371
|
/**
|
406
|
372
|
* The Malyan LCD actually runs as a separate MCU on Serial 1.
|
407
|
373
|
* This code's job is to siphon the weird curly-brace commands from
|
408
|
|
- * it and translate into gcode, which then gets injected into
|
409
|
|
- * the command queue where possible.
|
|
374
|
+ * it and translate into ExtUI operations where possible.
|
410
|
375
|
*/
|
411
|
376
|
inbound_count = 0;
|
412
|
377
|
LCD_SERIAL.begin(500000);
|
|
@@ -455,13 +420,13 @@ namespace ExtUI {
|
455
|
420
|
// If there was a print in progress, we need to emit the final
|
456
|
421
|
// print status as {TQ:100}. Reset last percent done so a new print will
|
457
|
422
|
// issue a percent of 0.
|
458
|
|
- const uint8_t percent_done = IS_SD_PRINTING() ? card.percentDone() : last_printing_status ? 100 : 0;
|
|
423
|
+ const uint8_t percent_done = (ExtUI::isPrinting() || ExtUI::isPrintingFromMediaPaused()) ? ExtUI::getProgress_percent() : last_printing_status ? 100 : 0;
|
459
|
424
|
if (percent_done != last_percent_done) {
|
460
|
425
|
char message_buffer[16];
|
461
|
426
|
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), percent_done);
|
462
|
427
|
write_to_lcd(message_buffer);
|
463
|
428
|
last_percent_done = percent_done;
|
464
|
|
- last_printing_status = IS_SD_PRINTING();
|
|
429
|
+ last_printing_status = ExtUI::isPrinting();
|
465
|
430
|
}
|
466
|
431
|
#endif
|
467
|
432
|
}
|