|
@@ -2,7 +2,7 @@
|
2
|
2
|
* anycubic_i3mega_lcd.cpp --- Support for Anycubic i3 Mega TFT
|
3
|
3
|
* Created by Christian Hopp on 09.12.17.
|
4
|
4
|
* Improved by David Ramiro
|
5
|
|
- * Converted to ext_iu by John BouAntoun 21 June 2020
|
|
5
|
+ * Converted to ExtUI by John BouAntoun 21 June 2020
|
6
|
6
|
*
|
7
|
7
|
* This library is free software; you can redistribute it and/or
|
8
|
8
|
* modify it under the terms of the GNU Lesser General Public
|
|
@@ -32,44 +32,46 @@
|
32
|
32
|
#include "../../../../inc/MarlinConfig.h"
|
33
|
33
|
|
34
|
34
|
// command sending macro's with debugging capability
|
35
|
|
-#define SEND_PGM(x) send_P(PSTR(x))
|
36
|
|
-#define SENDLINE_PGM(x) sendLine_P(PSTR(x))
|
37
|
|
-#define SEND_PGM_VAL(x,y) (send_P(PSTR(x)), sendLine(i16tostr3rj(y)))
|
38
|
|
-#define SEND(x) send(x)
|
39
|
|
-#define SENDLINE(x) sendLine(x)
|
|
35
|
+#define SEND_PGM(x) send_P(PSTR(x))
|
|
36
|
+#define SENDLINE_PGM(x) sendLine_P(PSTR(x))
|
|
37
|
+#define SEND_PGM_VAL(x,y) (send_P(PSTR(x)), sendLine(i16tostr3rj(y)))
|
|
38
|
+#define SEND(x) send(x)
|
|
39
|
+#define SENDLINE(x) sendLine(x)
|
40
|
40
|
#if ENABLED(ANYCUBIC_LCD_DEBUG)
|
41
|
|
- #define SENDLINE_DBG_PGM(x,y) (sendLine_P(PSTR(x)), SERIAL_ECHOLNPGM(y))
|
42
|
|
- #define SENDLINE_DBG_PGM_VAL(x,y,z) (sendLine_P(PSTR(x)), SERIAL_ECHOPGM(y), SERIAL_ECHOLN(z))
|
|
41
|
+ #define SENDLINE_DBG_PGM(x,y) (sendLine_P(PSTR(x)), SERIAL_ECHOLNPGM(y))
|
|
42
|
+ #define SENDLINE_DBG_PGM_VAL(x,y,z) (sendLine_P(PSTR(x)), SERIAL_ECHOPGM(y), SERIAL_ECHOLN(z))
|
43
|
43
|
#else
|
44
|
|
- #define SENDLINE_DBG_PGM(x,y) sendLine_P(PSTR(x))
|
45
|
|
- #define SENDLINE_DBG_PGM_VAL(x,y,z) sendLine_P(PSTR(x))
|
|
44
|
+ #define SENDLINE_DBG_PGM(x,y) sendLine_P(PSTR(x))
|
|
45
|
+ #define SENDLINE_DBG_PGM_VAL(x,y,z) sendLine_P(PSTR(x))
|
46
|
46
|
#endif
|
47
|
47
|
|
48
|
48
|
AnycubicTFTClass AnycubicTFT;
|
49
|
49
|
|
50
|
|
-static void sendNewLine(void) {
|
51
|
|
- LCD_SERIAL.write('\r');
|
52
|
|
- LCD_SERIAL.write('\n');
|
53
|
|
-}
|
54
|
|
-
|
55
|
|
-static void send(const char *str) {
|
56
|
|
- LCD_SERIAL.print(str);
|
57
|
|
-}
|
58
|
|
-
|
59
|
|
-static void sendLine(const char *str) {
|
60
|
|
- send(str);
|
61
|
|
- sendNewLine();
|
62
|
|
-}
|
63
|
|
-
|
|
50
|
+char AnycubicTFTClass::TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE];
|
|
51
|
+int AnycubicTFTClass::TFTbuflen = 0,
|
|
52
|
+ AnycubicTFTClass::TFTbufindr = 0,
|
|
53
|
+ AnycubicTFTClass::TFTbufindw = 0;
|
|
54
|
+char AnycubicTFTClass::serial3_char;
|
|
55
|
+int AnycubicTFTClass::serial3_count = 0;
|
|
56
|
+char* AnycubicTFTClass::TFTstrchr_pointer;
|
|
57
|
+uint8_t AnycubicTFTClass::SpecialMenu = false;
|
|
58
|
+AnycubicMediaPrintState AnycubicTFTClass::mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
|
|
59
|
+AnycubicMediaPauseState AnycubicTFTClass::mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
|
|
60
|
+
|
|
61
|
+char AnycubicTFTClass::SelectedDirectory[30];
|
|
62
|
+char AnycubicTFTClass::SelectedFile[FILENAME_LENGTH];
|
|
63
|
+
|
|
64
|
+// Serial helpers
|
|
65
|
+static void sendNewLine(void) { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); }
|
|
66
|
+static void send(const char *str) { LCD_SERIAL.print(str); }
|
64
|
67
|
static void send_P(PGM_P str) {
|
65
|
68
|
while (const char c = pgm_read_byte(str++))
|
66
|
69
|
LCD_SERIAL.write(c);
|
67
|
70
|
}
|
|
71
|
+static void sendLine(const char *str) { send(str); sendNewLine(); }
|
|
72
|
+static void sendLine_P(PGM_P str) { send_P(str); sendNewLine(); }
|
68
|
73
|
|
69
|
|
-static void sendLine_P(PGM_P str) {
|
70
|
|
- send_P(str);
|
71
|
|
- sendNewLine();
|
72
|
|
-}
|
|
74
|
+using namespace ExtUI;
|
73
|
75
|
|
74
|
76
|
AnycubicTFTClass::AnycubicTFTClass() {}
|
75
|
77
|
|
|
@@ -80,7 +82,7 @@ void AnycubicTFTClass::OnSetup() {
|
80
|
82
|
LCD_SERIAL.begin(LCD_BAUDRATE);
|
81
|
83
|
|
82
|
84
|
SENDLINE_DBG_PGM("J17", "TFT Serial Debug: Main board reset... J17"); // J17 Main board reset
|
83
|
|
- ExtUI::delay_ms(10);
|
|
85
|
+ delay_ms(10);
|
84
|
86
|
|
85
|
87
|
// initialise the state of the key pins running on the tft
|
86
|
88
|
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
|
@@ -95,13 +97,13 @@ void AnycubicTFTClass::OnSetup() {
|
95
|
97
|
|
96
|
98
|
// DoSDCardStateCheck();
|
97
|
99
|
SENDLINE_DBG_PGM("J12", "TFT Serial Debug: Ready... J12"); // J12 Ready
|
98
|
|
- ExtUI::delay_ms(10);
|
|
100
|
+ delay_ms(10);
|
99
|
101
|
|
100
|
102
|
DoFilamentRunoutCheck();
|
101
|
103
|
SelectedFile[0] = 0;
|
102
|
104
|
|
103
|
105
|
#if ENABLED(STARTUP_CHIME)
|
104
|
|
- ExtUI::injectCommands_P(PSTR("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831"));
|
|
106
|
+ injectCommands_P(PSTR("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831"));
|
105
|
107
|
#endif
|
106
|
108
|
#if ENABLED(ANYCUBIC_LCD_DEBUG)
|
107
|
109
|
SERIAL_ECHOLNPGM("TFT Serial Debug: Finished startup");
|
|
@@ -119,8 +121,8 @@ void AnycubicTFTClass::OnCommandScan() {
|
119
|
121
|
#endif
|
120
|
122
|
mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
|
121
|
123
|
mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
|
122
|
|
- ExtUI::injectCommands_P(PSTR("M84\nM27")); // disable stepper motors and force report of SD status
|
123
|
|
- ExtUI::delay_ms(200);
|
|
124
|
+ injectCommands_P(PSTR("M84\nM27")); // disable stepper motors and force report of SD status
|
|
125
|
+ delay_ms(200);
|
124
|
126
|
// tell printer to release resources of print to indicate it is done
|
125
|
127
|
SENDLINE_DBG_PGM("J14", "TFT Serial Debug: SD Print Stopped... J14");
|
126
|
128
|
}
|
|
@@ -224,8 +226,8 @@ bool AnycubicTFTClass::CodeSeen(char code) {
|
224
|
226
|
}
|
225
|
227
|
|
226
|
228
|
bool AnycubicTFTClass::IsNozzleHomed() {
|
227
|
|
- const float xPosition = ExtUI::getAxisPosition_mm((ExtUI::axis_t) ExtUI::X);
|
228
|
|
- const float yPosition = ExtUI::getAxisPosition_mm((ExtUI::axis_t) ExtUI::Y);
|
|
229
|
+ const float xPosition = getAxisPosition_mm((axis_t) X);
|
|
230
|
+ const float yPosition = getAxisPosition_mm((axis_t) Y);
|
229
|
231
|
return WITHIN(xPosition, X_MIN_POS - 0.1, X_MIN_POS + 0.1) &&
|
230
|
232
|
WITHIN(yPosition, Y_MIN_POS - 0.1, Y_MIN_POS + 0.1);
|
231
|
233
|
}
|
|
@@ -246,48 +248,48 @@ void AnycubicTFTClass::HandleSpecialMenu() {
|
246
|
248
|
switch (SelectedDirectory[2]) {
|
247
|
249
|
case '1': // "<01ZUp0.1>"
|
248
|
250
|
SERIAL_ECHOLNPGM("Special Menu: Z Up 0.1");
|
249
|
|
- ExtUI::injectCommands_P(PSTR("G91\nG1 Z+0.1\nG90"));
|
|
251
|
+ injectCommands_P(PSTR("G91\nG1 Z+0.1\nG90"));
|
250
|
252
|
break;
|
251
|
253
|
|
252
|
254
|
case '2': // "<02ZUp0.02>"
|
253
|
255
|
SERIAL_ECHOLNPGM("Special Menu: Z Up 0.02");
|
254
|
|
- ExtUI::injectCommands_P(PSTR("G91\nG1 Z+0.02\nG90"));
|
|
256
|
+ injectCommands_P(PSTR("G91\nG1 Z+0.02\nG90"));
|
255
|
257
|
break;
|
256
|
258
|
|
257
|
259
|
case '3': // "<03ZDn0.02>"
|
258
|
260
|
SERIAL_ECHOLNPGM("Special Menu: Z Down 0.02");
|
259
|
|
- ExtUI::injectCommands_P(PSTR("G91\nG1 Z-0.02\nG90"));
|
|
261
|
+ injectCommands_P(PSTR("G91\nG1 Z-0.02\nG90"));
|
260
|
262
|
break;
|
261
|
263
|
|
262
|
264
|
case '4': // "<04ZDn0.1>"
|
263
|
265
|
SERIAL_ECHOLNPGM("Special Menu: Z Down 0.1");
|
264
|
|
- ExtUI::injectCommands_P(PSTR("G91\nG1 Z-0.1\nG90"));
|
|
266
|
+ injectCommands_P(PSTR("G91\nG1 Z-0.1\nG90"));
|
265
|
267
|
break;
|
266
|
268
|
|
267
|
269
|
case '5': // "<05PrehtBed>"
|
268
|
270
|
SERIAL_ECHOLNPGM("Special Menu: Preheat Bed");
|
269
|
|
- ExtUI::injectCommands_P(PSTR("M140 S65"));
|
|
271
|
+ injectCommands_P(PSTR("M140 S65"));
|
270
|
272
|
break;
|
271
|
273
|
|
272
|
274
|
case '6': // "<06SMeshLvl>"
|
273
|
275
|
SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling");
|
274
|
|
- ExtUI::injectCommands_P(PSTR("G29S1"));
|
|
276
|
+ injectCommands_P(PSTR("G29S1"));
|
275
|
277
|
break;
|
276
|
278
|
|
277
|
279
|
case '7': // "<07MeshNPnt>"
|
278
|
280
|
SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point");
|
279
|
|
- ExtUI::injectCommands_P(PSTR("G29S2"));
|
|
281
|
+ injectCommands_P(PSTR("G29S2"));
|
280
|
282
|
break;
|
281
|
283
|
|
282
|
284
|
case '8': // "<08HtEndPID>"
|
283
|
285
|
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID");
|
284
|
286
|
// need to dwell for half a second to give the fan a chance to start before the pid tuning starts
|
285
|
|
- ExtUI::injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1"));
|
|
287
|
+ injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1"));
|
286
|
288
|
break;
|
287
|
289
|
|
288
|
290
|
case '9': // "<09HtBedPID>"
|
289
|
291
|
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid");
|
290
|
|
- ExtUI::injectCommands_P(PSTR("M303 E-1 S65 C6 U1"));
|
|
292
|
+ injectCommands_P(PSTR("M303 E-1 S65 C6 U1"));
|
291
|
293
|
break;
|
292
|
294
|
|
293
|
295
|
default:
|
|
@@ -299,12 +301,12 @@ void AnycubicTFTClass::HandleSpecialMenu() {
|
299
|
301
|
switch (SelectedDirectory[2]) {
|
300
|
302
|
case '0': // "<10FWDeflts>"
|
301
|
303
|
SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults");
|
302
|
|
- ExtUI::injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108"));
|
|
304
|
+ injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108"));
|
303
|
305
|
break;
|
304
|
306
|
|
305
|
307
|
case '1': // "<11SvEEPROM>"
|
306
|
308
|
SERIAL_ECHOLNPGM("Special Menu: Save EEPROM");
|
307
|
|
- ExtUI::injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661"));
|
|
309
|
+ injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661"));
|
308
|
310
|
break;
|
309
|
311
|
|
310
|
312
|
default:
|
|
@@ -316,38 +318,38 @@ void AnycubicTFTClass::HandleSpecialMenu() {
|
316
|
318
|
switch (SelectedDirectory[2]) {
|
317
|
319
|
case '1': // "<01PrehtBed>"
|
318
|
320
|
SERIAL_ECHOLNPGM("Special Menu: Preheat Bed");
|
319
|
|
- ExtUI::injectCommands_P(PSTR("M140 S65"));
|
|
321
|
+ injectCommands_P(PSTR("M140 S65"));
|
320
|
322
|
break;
|
321
|
323
|
|
322
|
324
|
case '2': // "<02ABL>"
|
323
|
325
|
SERIAL_ECHOLNPGM("Special Menu: Auto Bed Leveling");
|
324
|
|
- ExtUI::injectCommands_P(PSTR("G29N"));
|
|
326
|
+ injectCommands_P(PSTR("G29N"));
|
325
|
327
|
break;
|
326
|
328
|
|
327
|
329
|
case '3': // "<03HtendPID>"
|
328
|
330
|
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID");
|
329
|
331
|
// need to dwell for half a second to give the fan a chance to start before the pid tuning starts
|
330
|
|
- ExtUI::injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1"));
|
|
332
|
+ injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1"));
|
331
|
333
|
break;
|
332
|
334
|
|
333
|
335
|
case '4': // "<04HtbedPID>"
|
334
|
336
|
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid");
|
335
|
|
- ExtUI::injectCommands_P(PSTR("M303 E-1 S65 C6 U1"));
|
|
337
|
+ injectCommands_P(PSTR("M303 E-1 S65 C6 U1"));
|
336
|
338
|
break;
|
337
|
339
|
|
338
|
340
|
case '5': // "<05FWDeflts>"
|
339
|
341
|
SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults");
|
340
|
|
- ExtUI::injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108"));
|
|
342
|
+ injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108"));
|
341
|
343
|
break;
|
342
|
344
|
|
343
|
345
|
case '6': // "<06SvEEPROM>"
|
344
|
346
|
SERIAL_ECHOLNPGM("Special Menu: Save EEPROM");
|
345
|
|
- ExtUI::injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661"));
|
|
347
|
+ injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661"));
|
346
|
348
|
break;
|
347
|
349
|
|
348
|
350
|
case '7': // <07SendM108>
|
349
|
351
|
SERIAL_ECHOLNPGM("Special Menu: Send User Confirmation");
|
350
|
|
- ExtUI::injectCommands_P(PSTR("M108"));
|
|
352
|
+ injectCommands_P(PSTR("M108"));
|
351
|
353
|
break;
|
352
|
354
|
|
353
|
355
|
default:
|
|
@@ -373,11 +375,11 @@ void AnycubicTFTClass::RenderCurrentFileList() {
|
373
|
375
|
uint16_t selectedNumber = 0;
|
374
|
376
|
SelectedDirectory[0] = 0;
|
375
|
377
|
SelectedFile[0] = 0;
|
376
|
|
- ExtUI::FileList currentFileList;
|
|
378
|
+ FileList currentFileList;
|
377
|
379
|
|
378
|
380
|
SENDLINE_PGM("FN "); // Filelist start
|
379
|
381
|
|
380
|
|
- if (!ExtUI::isMediaInserted() && !SpecialMenu) {
|
|
382
|
+ if (!isMediaInserted() && !SpecialMenu) {
|
381
|
383
|
SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to render Current File List... J02");
|
382
|
384
|
|
383
|
385
|
SENDLINE_PGM("<Special_Menu>");
|
|
@@ -462,7 +464,7 @@ void AnycubicTFTClass::RenderSpecialMenu(uint16_t selectedNumber) {
|
462
|
464
|
}
|
463
|
465
|
|
464
|
466
|
void AnycubicTFTClass::RenderCurrentFolder(uint16_t selectedNumber) {
|
465
|
|
- ExtUI::FileList currentFileList;
|
|
467
|
+ FileList currentFileList;
|
466
|
468
|
uint16_t cnt = selectedNumber;
|
467
|
469
|
uint16_t max_files;
|
468
|
470
|
uint16_t dir_files = currentFileList.count();
|
|
@@ -514,7 +516,7 @@ void AnycubicTFTClass::OnPrintTimerStarted() {
|
514
|
516
|
|
515
|
517
|
void AnycubicTFTClass::OnPrintTimerPaused() {
|
516
|
518
|
#if ENABLED(SDSUPPORT)
|
517
|
|
- if (ExtUI::isPrintingFromMedia()) {
|
|
519
|
+ if (isPrintingFromMedia()) {
|
518
|
520
|
mediaPrintingState = AMPRINTSTATE_PAUSED;
|
519
|
521
|
mediaPauseState = AMPAUSESTATE_PARKING;
|
520
|
522
|
}
|
|
@@ -558,38 +560,38 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
558
|
560
|
|
559
|
561
|
switch (a_command) {
|
560
|
562
|
case 0: { // A0 GET HOTEND TEMP
|
561
|
|
- float hotendActualTemp = ExtUI::getActualTemp_celsius((ExtUI::extruder_t) (ExtUI::extruder_t) ExtUI::E0);
|
|
563
|
+ float hotendActualTemp = getActualTemp_celsius((extruder_t) (extruder_t) E0);
|
562
|
564
|
SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5));
|
563
|
565
|
}
|
564
|
566
|
break;
|
565
|
567
|
|
566
|
568
|
case 1: { // A1 GET HOTEND TARGET TEMP
|
567
|
|
- float hotendTargetTemp = ExtUI::getTargetTemp_celsius((ExtUI::extruder_t) (ExtUI::extruder_t) ExtUI::E0);
|
|
569
|
+ float hotendTargetTemp = getTargetTemp_celsius((extruder_t) (extruder_t) E0);
|
568
|
570
|
SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5));
|
569
|
571
|
}
|
570
|
572
|
break;
|
571
|
573
|
|
572
|
574
|
case 2: { // A2 GET HOTBED TEMP
|
573
|
|
- float heatedBedActualTemp = ExtUI::getActualTemp_celsius((ExtUI::heater_t) ExtUI::BED);
|
|
575
|
+ float heatedBedActualTemp = getActualTemp_celsius((heater_t) BED);
|
574
|
576
|
SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5));
|
575
|
577
|
}
|
576
|
578
|
break;
|
577
|
579
|
|
578
|
580
|
case 3: { // A3 GET HOTBED TARGET TEMP
|
579
|
|
- float heatedBedTargetTemp = ExtUI::getTargetTemp_celsius((ExtUI::heater_t) ExtUI::BED);
|
|
581
|
+ float heatedBedTargetTemp = getTargetTemp_celsius((heater_t) BED);
|
580
|
582
|
SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5));
|
581
|
583
|
} break;
|
582
|
584
|
|
583
|
585
|
case 4: { // A4 GET FAN SPEED
|
584
|
|
- float fanPercent = ExtUI::getActualFan_percent(ExtUI::FAN0);
|
|
586
|
+ float fanPercent = getActualFan_percent(FAN0);
|
585
|
587
|
fanPercent = constrain(fanPercent, 0, 100);
|
586
|
588
|
SEND_PGM_VAL("A4V ", int(fanPercent));
|
587
|
589
|
} break;
|
588
|
590
|
|
589
|
591
|
case 5: { // A5 GET CURRENT COORDINATE
|
590
|
|
- const float xPosition = ExtUI::getAxisPosition_mm(ExtUI::X),
|
591
|
|
- yPosition = ExtUI::getAxisPosition_mm(ExtUI::Y),
|
592
|
|
- zPosition = ExtUI::getAxisPosition_mm(ExtUI::Z);
|
|
592
|
+ const float xPosition = getAxisPosition_mm(X),
|
|
593
|
+ yPosition = getAxisPosition_mm(Y),
|
|
594
|
+ zPosition = getAxisPosition_mm(Z);
|
593
|
595
|
SEND_PGM("A5V X: "); LCD_SERIAL.print(xPosition);
|
594
|
596
|
SEND_PGM( " Y: "); LCD_SERIAL.print(yPosition);
|
595
|
597
|
SEND_PGM( " Z: "); LCD_SERIAL.print(zPosition);
|
|
@@ -598,10 +600,10 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
598
|
600
|
|
599
|
601
|
case 6: // A6 GET SD CARD PRINTING STATUS
|
600
|
602
|
#if ENABLED(SDSUPPORT)
|
601
|
|
- if (ExtUI::isPrintingFromMedia()) {
|
|
603
|
+ if (isPrintingFromMedia()) {
|
602
|
604
|
SEND_PGM("A6V ");
|
603
|
|
- if (ExtUI::isMediaInserted())
|
604
|
|
- SENDLINE(ui8tostr3rj(ExtUI::getProgress_percent()));
|
|
605
|
+ if (isMediaInserted())
|
|
606
|
+ SENDLINE(ui8tostr3rj(getProgress_percent()));
|
605
|
607
|
else
|
606
|
608
|
SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to return printing status... J02");
|
607
|
609
|
}
|
|
@@ -611,7 +613,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
611
|
613
|
break;
|
612
|
614
|
|
613
|
615
|
case 7: { // A7 GET PRINTING TIME
|
614
|
|
- const uint32_t elapsedSeconds = ExtUI::getProgress_seconds_elapsed();
|
|
616
|
+ const uint32_t elapsedSeconds = getProgress_seconds_elapsed();
|
615
|
617
|
SEND_PGM("A7V ");
|
616
|
618
|
if (elapsedSeconds != 0) { // print time
|
617
|
619
|
const uint32_t elapsedMinutes = elapsedSeconds / 60;
|
|
@@ -634,14 +636,14 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
634
|
636
|
|
635
|
637
|
case 9: // A9 pause sd print
|
636
|
638
|
#if ENABLED(SDSUPPORT)
|
637
|
|
- if (ExtUI::isPrintingFromMedia())
|
|
639
|
+ if (isPrintingFromMedia())
|
638
|
640
|
PausePrint();
|
639
|
641
|
#endif
|
640
|
642
|
break;
|
641
|
643
|
|
642
|
644
|
case 10: // A10 resume sd print
|
643
|
645
|
#if ENABLED(SDSUPPORT)
|
644
|
|
- if (ExtUI::isPrintingFromMediaPaused())
|
|
646
|
+ if (isPrintingFromMediaPaused())
|
645
|
647
|
ResumePrint();
|
646
|
648
|
#endif
|
647
|
649
|
break;
|
|
@@ -656,7 +658,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
656
|
658
|
|
657
|
659
|
case 13: // A13 SELECTION FILE
|
658
|
660
|
#if ENABLED(SDSUPPORT)
|
659
|
|
- if (ExtUI::isMediaInserted()) {
|
|
661
|
+ if (isMediaInserted()) {
|
660
|
662
|
starpos = (strchr(TFTstrchr_pointer + 4, '*'));
|
661
|
663
|
if (TFTstrchr_pointer[4] == '/') {
|
662
|
664
|
strcpy(SelectedDirectory, TFTstrchr_pointer + 5);
|
|
@@ -685,7 +687,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
685
|
687
|
|
686
|
688
|
case 14: // A14 START PRINTING
|
687
|
689
|
#if ENABLED(SDSUPPORT)
|
688
|
|
- if (!ExtUI::isPrinting() && strlen(SelectedFile) > 0)
|
|
690
|
+ if (!isPrinting() && strlen(SelectedFile) > 0)
|
689
|
691
|
StartPrint();
|
690
|
692
|
#endif
|
691
|
693
|
break;
|
|
@@ -698,13 +700,13 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
698
|
700
|
unsigned int tempvalue;
|
699
|
701
|
if (CodeSeen('S')) {
|
700
|
702
|
tempvalue = constrain(CodeValue(), 0, 275);
|
701
|
|
- ExtUI::setTargetTemp_celsius(tempvalue, (ExtUI::extruder_t) ExtUI::E0);
|
|
703
|
+ setTargetTemp_celsius(tempvalue, (extruder_t) E0);
|
702
|
704
|
}
|
703
|
|
- else if (CodeSeen('C') && !ExtUI::isPrinting()) {
|
704
|
|
- if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10)
|
705
|
|
- ExtUI::injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS
|
|
705
|
+ else if (CodeSeen('C') && !isPrinting()) {
|
|
706
|
+ if (getAxisPosition_mm(Z) < 10)
|
|
707
|
+ injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS
|
706
|
708
|
tempvalue = constrain(CodeValue(), 0, 275);
|
707
|
|
- ExtUI::setTargetTemp_celsius(tempvalue, (ExtUI::extruder_t) ExtUI::E0);
|
|
709
|
+ setTargetTemp_celsius(tempvalue, (extruder_t) E0);
|
708
|
710
|
}
|
709
|
711
|
}
|
710
|
712
|
break;
|
|
@@ -713,7 +715,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
713
|
715
|
unsigned int tempbed;
|
714
|
716
|
if (CodeSeen('S')) {
|
715
|
717
|
tempbed = constrain(CodeValue(), 0, 100);
|
716
|
|
- ExtUI::setTargetTemp_celsius(tempbed, (ExtUI::heater_t)ExtUI::BED);
|
|
718
|
+ setTargetTemp_celsius(tempbed, (heater_t)BED);
|
717
|
719
|
}
|
718
|
720
|
}
|
719
|
721
|
break;
|
|
@@ -723,18 +725,18 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
723
|
725
|
if (CodeSeen('S')) {
|
724
|
726
|
fanPercent = CodeValue();
|
725
|
727
|
fanPercent = constrain(fanPercent, 0, 100);
|
726
|
|
- ExtUI::setTargetFan_percent(fanPercent, ExtUI::FAN0);
|
|
728
|
+ setTargetFan_percent(fanPercent, FAN0);
|
727
|
729
|
}
|
728
|
730
|
else
|
729
|
731
|
fanPercent = 100;
|
730
|
732
|
|
731
|
|
- ExtUI::setTargetFan_percent(fanPercent, ExtUI::FAN0);
|
|
733
|
+ setTargetFan_percent(fanPercent, FAN0);
|
732
|
734
|
SENDLINE_PGM("");
|
733
|
735
|
}
|
734
|
736
|
break;
|
735
|
737
|
|
736
|
738
|
case 19: // A19 stop stepper drivers - sent on stop extrude command and on turn motors off command
|
737
|
|
- if (!ExtUI::isPrinting()) {
|
|
739
|
+ if (!isPrinting()) {
|
738
|
740
|
quickstop_stepper();
|
739
|
741
|
disable_all_steppers();
|
740
|
742
|
}
|
|
@@ -750,23 +752,23 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
750
|
752
|
break;
|
751
|
753
|
|
752
|
754
|
case 21: // A21 all home
|
753
|
|
- if (!ExtUI::isPrinting() && !ExtUI::isPrintingFromMediaPaused()) {
|
|
755
|
+ if (!isPrinting() && !isPrintingFromMediaPaused()) {
|
754
|
756
|
if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) {
|
755
|
757
|
if (CodeSeen('X'))
|
756
|
|
- ExtUI::injectCommands_P(PSTR("G28X"));
|
|
758
|
+ injectCommands_P(PSTR("G28X"));
|
757
|
759
|
if (CodeSeen('Y'))
|
758
|
|
- ExtUI::injectCommands_P(PSTR("G28Y"));
|
|
760
|
+ injectCommands_P(PSTR("G28Y"));
|
759
|
761
|
if (CodeSeen('Z'))
|
760
|
|
- ExtUI::injectCommands_P(PSTR("G28Z"));
|
|
762
|
+ injectCommands_P(PSTR("G28Z"));
|
761
|
763
|
}
|
762
|
764
|
else if (CodeSeen('C')) {
|
763
|
|
- ExtUI::injectCommands_P(G28_STR);
|
|
765
|
+ injectCommands_P(G28_STR);
|
764
|
766
|
}
|
765
|
767
|
}
|
766
|
768
|
break;
|
767
|
769
|
|
768
|
770
|
case 22: // A22 move X/Y/Z or extrude
|
769
|
|
- if (!ExtUI::isPrinting()) {
|
|
771
|
+ if (!isPrinting()) {
|
770
|
772
|
float coorvalue;
|
771
|
773
|
unsigned int movespeed = 0;
|
772
|
774
|
char commandStr[30];
|
|
@@ -819,38 +821,38 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
819
|
821
|
SERIAL_ECHOPGM("TFT Serial Debug: A22 Move final request with gcode... ");
|
820
|
822
|
SERIAL_ECHOLN(fullCommandStr);
|
821
|
823
|
#endif
|
822
|
|
- ExtUI::injectCommands(fullCommandStr);
|
|
824
|
+ injectCommands(fullCommandStr);
|
823
|
825
|
}
|
824
|
826
|
}
|
825
|
827
|
SENDLINE_PGM("");
|
826
|
828
|
break;
|
827
|
829
|
|
828
|
830
|
case 23: // A23 preheat pla
|
829
|
|
- if (!ExtUI::isPrinting()) {
|
830
|
|
- if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10)
|
831
|
|
- ExtUI::injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS
|
|
831
|
+ if (!isPrinting()) {
|
|
832
|
+ if (getAxisPosition_mm(Z) < 10)
|
|
833
|
+ injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS
|
832
|
834
|
|
833
|
|
- ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (ExtUI::heater_t) ExtUI::BED);
|
834
|
|
- ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (ExtUI::extruder_t) ExtUI::E0);
|
|
835
|
+ setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (heater_t) BED);
|
|
836
|
+ setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (extruder_t) E0);
|
835
|
837
|
SENDLINE_PGM("OK");
|
836
|
838
|
}
|
837
|
839
|
break;
|
838
|
840
|
|
839
|
841
|
case 24:// A24 preheat abs
|
840
|
|
- if (!ExtUI::isPrinting()) {
|
841
|
|
- if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10)
|
842
|
|
- ExtUI::injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS
|
|
842
|
+ if (!isPrinting()) {
|
|
843
|
+ if (getAxisPosition_mm(Z) < 10)
|
|
844
|
+ injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS
|
843
|
845
|
|
844
|
|
- ExtUI::setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (ExtUI::heater_t) ExtUI::BED);
|
845
|
|
- ExtUI::setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (ExtUI::extruder_t) ExtUI::E0);
|
|
846
|
+ setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (heater_t) BED);
|
|
847
|
+ setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (extruder_t) E0);
|
846
|
848
|
SENDLINE_PGM("OK");
|
847
|
849
|
}
|
848
|
850
|
break;
|
849
|
851
|
|
850
|
852
|
case 25: // A25 cool down
|
851
|
|
- if (!ExtUI::isPrinting()) {
|
852
|
|
- ExtUI::setTargetTemp_celsius(0, (ExtUI::heater_t) ExtUI::BED);
|
853
|
|
- ExtUI::setTargetTemp_celsius(0, (ExtUI::extruder_t) ExtUI::E0);
|
|
853
|
+ if (!isPrinting()) {
|
|
854
|
+ setTargetTemp_celsius(0, (heater_t) BED);
|
|
855
|
+ setTargetTemp_celsius(0, (extruder_t) E0);
|
854
|
856
|
|
855
|
857
|
SENDLINE_DBG_PGM("J12", "TFT Serial Debug: Cooling down... J12"); // J12 cool down
|
856
|
858
|
}
|
|
@@ -858,9 +860,9 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
858
|
860
|
|
859
|
861
|
case 26: // A26 refresh SD
|
860
|
862
|
#if ENABLED(SDSUPPORT)
|
861
|
|
- if (ExtUI::isMediaInserted()) {
|
|
863
|
+ if (isMediaInserted()) {
|
862
|
864
|
if (strlen(SelectedDirectory) > 0) {
|
863
|
|
- ExtUI::FileList currentFileList;
|
|
865
|
+ FileList currentFileList;
|
864
|
866
|
if ((SelectedDirectory[0] == '.') && (SelectedDirectory[1] == '.')) {
|
865
|
867
|
currentFileList.upDir();
|
866
|
868
|
}
|
|
@@ -914,7 +916,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
|
914
|
916
|
|
915
|
917
|
void AnycubicTFTClass::DoSDCardStateCheck() {
|
916
|
918
|
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
917
|
|
- bool isInserted = ExtUI::isMediaInserted();
|
|
919
|
+ bool isInserted = isMediaInserted();
|
918
|
920
|
if (isInserted)
|
919
|
921
|
SENDLINE_DBG_PGM("J00", "TFT Serial Debug: SD card state changed... isInserted");
|
920
|
922
|
else
|
|
@@ -925,12 +927,12 @@ void AnycubicTFTClass::DoSDCardStateCheck() {
|
925
|
927
|
|
926
|
928
|
void AnycubicTFTClass::DoFilamentRunoutCheck() {
|
927
|
929
|
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
928
|
|
- // NOTE: ExtUI::getFilamentRunoutState() only returns the runout state if the job is printing
|
|
930
|
+ // NOTE: getFilamentRunoutState() only returns the runout state if the job is printing
|
929
|
931
|
// we want to actually check the status of the pin here, regardless of printstate
|
930
|
932
|
if (READ(FIL_RUNOUT1_PIN)) {
|
931
|
933
|
if (mediaPrintingState == AMPRINTSTATE_PRINTING || mediaPrintingState == AMPRINTSTATE_PAUSED || mediaPrintingState == AMPRINTSTATE_PAUSE_REQUESTED) {
|
932
|
934
|
// play tone to indicate filament is out
|
933
|
|
- ExtUI::injectCommands_P(PSTR("\nM300 P200 S1567\nM300 P200 S1174\nM300 P200 S1567\nM300 P200 S1174\nM300 P2000 S1567"));
|
|
935
|
+ injectCommands_P(PSTR("\nM300 P200 S1567\nM300 P200 S1174\nM300 P200 S1567\nM300 P200 S1174\nM300 P2000 S1567"));
|
934
|
936
|
|
935
|
937
|
// tell the user that the filament has run out and wait
|
936
|
938
|
SENDLINE_DBG_PGM("J23", "TFT Serial Debug: Blocking filament prompt... J23");
|
|
@@ -944,30 +946,30 @@ void AnycubicTFTClass::DoFilamentRunoutCheck() {
|
944
|
946
|
|
945
|
947
|
void AnycubicTFTClass::StartPrint() {
|
946
|
948
|
#if ENABLED(SDSUPPORT)
|
947
|
|
- if (!ExtUI::isPrinting() && strlen(SelectedFile) > 0) {
|
|
949
|
+ if (!isPrinting() && strlen(SelectedFile) > 0) {
|
948
|
950
|
#if ENABLED(ANYCUBIC_LCD_DEBUG)
|
949
|
951
|
SERIAL_ECHOPGM("TFT Serial Debug: About to print file ... ");
|
950
|
|
- SERIAL_ECHO(ExtUI::isPrinting());
|
|
952
|
+ SERIAL_ECHO(isPrinting());
|
951
|
953
|
SERIAL_ECHOPGM(" ");
|
952
|
954
|
SERIAL_ECHOLN(SelectedFile);
|
953
|
955
|
#endif
|
954
|
956
|
mediaPrintingState = AMPRINTSTATE_PRINTING;
|
955
|
957
|
mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
|
956
|
|
- ExtUI::printFile(SelectedFile);
|
|
958
|
+ printFile(SelectedFile);
|
957
|
959
|
}
|
958
|
960
|
#endif // SDUPPORT
|
959
|
961
|
}
|
960
|
962
|
|
961
|
963
|
void AnycubicTFTClass::PausePrint() {
|
962
|
964
|
#if ENABLED(SDSUPPORT)
|
963
|
|
- if (ExtUI::isPrintingFromMedia() && mediaPrintingState != AMPRINTSTATE_STOP_REQUESTED && mediaPauseState == AMPAUSESTATE_NOT_PAUSED) {
|
|
965
|
+ if (isPrintingFromMedia() && mediaPrintingState != AMPRINTSTATE_STOP_REQUESTED && mediaPauseState == AMPAUSESTATE_NOT_PAUSED) {
|
964
|
966
|
mediaPrintingState = AMPRINTSTATE_PAUSE_REQUESTED;
|
965
|
967
|
mediaPauseState = AMPAUSESTATE_NOT_PAUSED; // need the userconfirm method to update pause state
|
966
|
968
|
SENDLINE_DBG_PGM("J05", "TFT Serial Debug: SD print pause started... J05"); // J05 printing pause
|
967
|
969
|
|
968
|
970
|
// for some reason pausing the print doesn't retract the extruder so force a manual one here
|
969
|
|
- ExtUI::injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90"));
|
970
|
|
- ExtUI::pausePrint();
|
|
971
|
+ injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90"));
|
|
972
|
+ pausePrint();
|
971
|
973
|
}
|
972
|
974
|
#endif
|
973
|
975
|
}
|
|
@@ -996,14 +998,14 @@ void AnycubicTFTClass::ResumePrint() {
|
996
|
998
|
// SENDLINE_DBG_PGM("J05", "TFT Serial Debug: Resume called with heater timeout... J05"); // J05 printing pause
|
997
|
999
|
|
998
|
1000
|
// reheat the nozzle
|
999
|
|
- ExtUI::setUserConfirmed();
|
|
1001
|
+ setUserConfirmed();
|
1000
|
1002
|
}
|
1001
|
1003
|
else {
|
1002
|
1004
|
mediaPrintingState = AMPRINTSTATE_PRINTING;
|
1003
|
1005
|
mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
|
1004
|
1006
|
|
1005
|
1007
|
SENDLINE_DBG_PGM("J04", "TFT Serial Debug: SD print resumed... J04"); // J04 printing form sd card now
|
1006
|
|
- ExtUI::resumePrint();
|
|
1008
|
+ resumePrint();
|
1007
|
1009
|
}
|
1008
|
1010
|
#endif
|
1009
|
1011
|
}
|
|
@@ -1015,8 +1017,8 @@ void AnycubicTFTClass::StopPrint() {
|
1015
|
1017
|
SENDLINE_DBG_PGM("J16", "TFT Serial Debug: SD print stop called... J16");
|
1016
|
1018
|
|
1017
|
1019
|
// for some reason stopping the print doesn't retract the extruder so force a manual one here
|
1018
|
|
- ExtUI::injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90"));
|
1019
|
|
- ExtUI::stopPrint();
|
|
1020
|
+ injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90"));
|
|
1021
|
+ stopPrint();
|
1020
|
1022
|
#endif
|
1021
|
1023
|
}
|
1022
|
1024
|
|