Przeglądaj źródła

Fix Anycubic Chiron "Ready" detection (#19880)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Nick 4 lat temu
rodzic
commit
311b65b225
No account linked to committer's email address

+ 62
- 76
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp Wyświetl plik

@@ -40,6 +40,7 @@
40 40
 #include "../../../../sd/cardreader.h"
41 41
 #include "../../../../libs/numtostr.h"
42 42
 #include "../../../../MarlinCore.h"
43
+
43 44
 namespace Anycubic {
44 45
 
45 46
   printer_state_t  ChironTFT::printer_state;
@@ -87,7 +88,7 @@ namespace Anycubic {
87 88
 
88 89
     // Enable levelling and Disable end stops during print
89 90
     // as Z home places nozzle above the bed so we need to allow it past the end stops
90
-    injectCommands_P(AC_cmnd_enable_levelling); //M211 S0\n"));
91
+    injectCommands_P(AC_cmnd_enable_levelling);
91 92
 
92 93
     // Startup tunes are defined in Tunes.h
93 94
     //PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1);
@@ -179,7 +180,7 @@ namespace Anycubic {
179 180
     #endif
180 181
     switch (printer_state) {
181 182
       case AC_printer_pausing: {
182
-        if ( (strcmp_P(msg, MARLIN_msg_print_paused) == 0 ) || (strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0 ) ) {
183
+        if (strcmp_P(msg, MARLIN_msg_print_paused) == 0 || strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) {
183 184
           SendtoTFTLN(AC_msg_paused); // enable continue button
184 185
           printer_state = AC_printer_paused;
185 186
         }
@@ -189,18 +190,18 @@ namespace Anycubic {
189 190
       case AC_printer_printing:
190 191
       case AC_printer_paused: {
191 192
         // Heater timout, send acknowledgement
192
-        if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0 ) {
193
+        if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) {
193 194
           pause_state = AC_paused_heater_timed_out;
194 195
           SendtoTFTLN(AC_msg_paused); // enable continue button
195 196
           PlayTune(BEEPER_PIN,Heater_Timedout,1);
196 197
         }
197 198
         // Reheat finished, send acknowledgement
198
-        else if (strcmp_P(msg, MARLIN_msg_reheat_done) == 0 ) {
199
+        else if (strcmp_P(msg, MARLIN_msg_reheat_done) == 0) {
199 200
           pause_state = AC_paused_idle;
200 201
           SendtoTFTLN(AC_msg_paused); // enable continue button
201 202
         }
202 203
         // Filament Purging, send acknowledgement enter run mode
203
-        else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0 ) {
204
+        else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) {
204 205
           pause_state = AC_paused_purging_filament;
205 206
           SendtoTFTLN(AC_msg_paused); // enable continue button
206 207
         }
@@ -221,14 +222,15 @@ namespace Anycubic {
221 222
     switch (printer_state) {
222 223
       case AC_printer_probing: {
223 224
         // If probing completes ok save the mesh and park
224
-        if (strcmp_P(msg, MARLIN_msg_ready) == 0 ) {
225
+        // Ignore the custom machine name
226
+        if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) {
225 227
           injectCommands_P(PSTR("M500\nG27"));
226 228
           SendtoTFTLN(AC_msg_probing_complete);
227 229
           printer_state = AC_printer_idle;
228 230
           msg_matched = true;
229 231
         }
230 232
         // If probing fails dont save the mesh raise the probe above the bad point
231
-        if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0 ) {
233
+        if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) {
232 234
           PlayTune(BEEPER_PIN, BeepBeepBeeep, 1);
233 235
           injectCommands_P(PSTR("G1 Z50 F500"));
234 236
           SendtoTFTLN(AC_msg_probing_complete);
@@ -238,14 +240,14 @@ namespace Anycubic {
238 240
       } break;
239 241
 
240 242
       case AC_printer_printing: {
241
-        if (strcmp_P(msg, MARLIN_msg_reheating) == 0 ) {
243
+        if (strcmp_P(msg, MARLIN_msg_reheating) == 0) {
242 244
           SendtoTFTLN(AC_msg_paused); // enable continue button
243 245
           msg_matched = true;
244 246
          }
245 247
       } break;
246 248
 
247 249
       case AC_printer_pausing: {
248
-        if (strcmp_P(msg, MARLIN_msg_print_paused) == 0 ) {
250
+        if (strcmp_P(msg, MARLIN_msg_print_paused) == 0) {
249 251
           SendtoTFTLN(AC_msg_paused);
250 252
           printer_state = AC_printer_paused;
251 253
           pause_state = AC_paused_idle;
@@ -254,7 +256,7 @@ namespace Anycubic {
254 256
       } break;
255 257
 
256 258
       case AC_printer_stopping: {
257
-        if (strcmp_P(msg, MARLIN_msg_print_aborted) == 0 ) {
259
+        if (strcmp_P(msg, MARLIN_msg_print_aborted) == 0) {
258 260
           SendtoTFTLN(AC_msg_stop);
259 261
           printer_state = AC_printer_idle;
260 262
           msg_matched = true;
@@ -289,7 +291,7 @@ namespace Anycubic {
289 291
       serialprintPGM(str);
290 292
     #endif
291 293
     while (const char c = pgm_read_byte(str++)) TFTSer.print(c);
292
-    }
294
+  }
293 295
 
294 296
   void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) {
295 297
     if (str != nullptr) {
@@ -300,22 +302,22 @@ namespace Anycubic {
300 302
       #if ACDEBUG(AC_SOME)
301 303
         SERIAL_EOL();
302 304
       #endif
303
-   }
304
-   TFTSer.println("");
305
+    }
306
+    TFTSer.println("");
305 307
   }
306 308
 
307 309
   bool ChironTFT::ReadTFTCommand() {
308 310
     bool command_ready = false;
309
-    while( (TFTSer.available() > 0) && (command_len < MAX_CMND_LEN) ) {
311
+    while(TFTSer.available() > 0 && command_len < MAX_CMND_LEN) {
310 312
       panel_command[command_len] = TFTSer.read();
311
-      if(panel_command[command_len] == '\n') {
313
+      if (panel_command[command_len] == '\n') {
312 314
         command_ready = true;
313 315
         break;
314 316
       }
315 317
       command_len++;
316 318
     }
317 319
 
318
-    if(command_ready) {
320
+    if (command_ready) {
319 321
       panel_command[command_len] = 0x00;
320 322
       #if ACDEBUG(AC_ALL)
321 323
         SERIAL_ECHOLNPAIR("< ", panel_command);
@@ -333,56 +335,45 @@ namespace Anycubic {
333 335
   }
334 336
 
335 337
   int8_t ChironTFT::Findcmndpos(const char * buff, char q) {
336
-    bool found = false;
337 338
     int8_t pos = 0;
338
-    do {
339
-      if (buff[pos] == q) {
340
-        found = true;
341
-        break;
342
-      }
343
-      pos ++;
344
-    } while(pos < MAX_CMND_LEN);
345
-    if (found) return pos;
339
+    do { if (buff[pos] == q) return pos; } while(++pos < MAX_CMND_LEN);
346 340
     return -1;
347 341
   }
348 342
 
349 343
   void ChironTFT::CheckHeaters() {
350
-    uint8_t faultDuration = 0; float temp = 0;
344
+    uint8_t faultDuration = 0;
345
+    float temp = 0;
351 346
 
352 347
     // if the hotend temp is abnormal, confirm state before signalling panel
353 348
     temp = getActualTemp_celsius(E0);
354
-    if ( (temp <= HEATER_0_MINTEMP) || (temp >= HEATER_0_MAXTEMP) ) {
355
-      do {
356
-        faultDuration ++;
357
-        if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
358
-          SendtoTFTLN(AC_msg_nozzle_temp_abnormal);
359
-          SERIAL_ECHOLNPAIR("Extruder temp abnormal! : ", temp);
360
-          break;
361
-        }
362
-        delay_ms(500);
363
-        temp = getActualTemp_celsius(E0);
364
-      } while ((temp <= HEATER_0_MINTEMP) || (temp >= HEATER_0_MAXTEMP) );
349
+    while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) {
350
+      faultDuration++;
351
+      if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
352
+        SendtoTFTLN(AC_msg_nozzle_temp_abnormal);
353
+        SERIAL_ECHOLNPAIR("Extruder temp abnormal! : ", temp);
354
+        break;
355
+      }
356
+      delay_ms(500);
357
+      temp = getActualTemp_celsius(E0);
365 358
     }
366 359
 
367
-    // if the hotbed temp is abnormal, confirm state before signalling panel
360
+    // If the hotbed temp is abnormal, confirm state before signaling panel
368 361
     faultDuration = 0;
369 362
     temp = getActualTemp_celsius(BED);
370
-    if ( (temp <= BED_MINTEMP) || (temp >= BED_MAXTEMP) ) {
371
-      do {
372
-        faultDuration ++;
373
-        if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
374
-          SendtoTFTLN(AC_msg_nozzle_temp_abnormal);
375
-          SERIAL_ECHOLNPAIR_P("Bed temp abnormal! : ", temp);
363
+    while (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) {
364
+      faultDuration++;
365
+      if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
366
+        SendtoTFTLN(AC_msg_nozzle_temp_abnormal);
367
+        SERIAL_ECHOLNPAIR_P("Bed temp abnormal! : ", temp);
376 368
         break;
377
-        }
378
-        delay_ms(500);
379
-        temp = getActualTemp_celsius(E0);
380
-      } while ((temp <= BED_MINTEMP) || (temp >= BED_MAXTEMP) );
369
+      }
370
+      delay_ms(500);
371
+      temp = getActualTemp_celsius(E0);
381 372
     }
382 373
 
383 374
     // Update panel with hotend heater status
384 375
     if (hotend_state != AC_heater_temp_reached) {
385
-      if ( WITHIN( getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -1, 1 ) ) {
376
+      if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -1, 1)) {
386 377
         SendtoTFTLN(AC_msg_nozzle_heating_done);
387 378
         hotend_state = AC_heater_temp_reached;
388 379
       }
@@ -390,7 +381,7 @@ namespace Anycubic {
390 381
 
391 382
     // Update panel with bed heater status
392 383
     if (hotbed_state != AC_heater_temp_reached) {
393
-      if ( WITHIN( getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -0.5, 0.5 ) ) {
384
+      if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -0.5, 0.5)) {
394 385
         SendtoTFTLN(AC_msg_bed_heating_done);
395 386
         hotbed_state = AC_heater_temp_reached;
396 387
       }
@@ -398,7 +389,7 @@ namespace Anycubic {
398 389
   }
399 390
 
400 391
   void ChironTFT::SendFileList(int8_t startindex) {
401
-    // respond to panel request for 4 files starting at index
392
+    // Respond to panel request for 4 files starting at index
402 393
     #if ACDEBUG(AC_INFO)
403 394
       SERIAL_ECHOLNPAIR("## SendFileList ## ", startindex);
404 395
     #endif
@@ -408,8 +399,8 @@ namespace Anycubic {
408 399
   }
409 400
 
410 401
   void ChironTFT::SelectFile() {
411
-    strncpy(selectedfile,panel_command+4,command_len-4);
412
-    selectedfile[command_len-5] = '\0';
402
+    strncpy(selectedfile, panel_command + 4, command_len - 4);
403
+    selectedfile[command_len - 5] = '\0';
413 404
     #if ACDEBUG(AC_FILE)
414 405
       SERIAL_ECHOLNPAIR_F(" Selected File: ",selectedfile);
415 406
     #endif
@@ -493,7 +484,6 @@ namespace Anycubic {
493 484
         if (isPrintingFromMedia()) {
494 485
           SendtoTFT(PSTR("A6V "));
495 486
           TFTSer.println(ui8tostr2(getProgress_percent()));
496
-
497 487
         }
498 488
         else
499 489
           SendtoTFTLN(PSTR("A6V ---"));
@@ -552,7 +542,7 @@ namespace Anycubic {
552 542
         }
553 543
         else {
554 544
           if (printer_state == AC_printer_resuming_from_power_outage)
555
-            injectCommands_P(PSTR("M1000 C\n")); // Cancel recovery
545
+            injectCommands_P(PSTR("M1000 C")); // Cancel recovery
556 546
           SendtoTFTLN(AC_msg_stop);
557 547
           printer_state = AC_printer_idle;
558 548
         }
@@ -569,7 +559,7 @@ namespace Anycubic {
569 559
       case 14: { // A14 Start Printing
570 560
         // Allows printer to restart the job if we dont want to recover
571 561
         if (printer_state == AC_printer_resuming_from_power_outage) {
572
-          injectCommands_P(PSTR("M1000 C\n")); // Cancel recovery
562
+          injectCommands_P(PSTR("M1000 C")); // Cancel recovery
573 563
           printer_state = AC_printer_idle;
574 564
         }
575 565
         #if ACDebugLevel >= 1
@@ -587,8 +577,7 @@ namespace Anycubic {
587 577
         if (printer_state == AC_printer_resuming_from_power_outage)
588 578
           // Need to home here to restore the Z position
589 579
           injectCommands_P(AC_cmnd_power_loss_recovery);
590
-
591
-          injectCommands_P(PSTR("M1000\n"));  // home and start recovery
580
+          injectCommands_P(PSTR("M1000"));  // home and start recovery
592 581
         break;
593 582
 
594 583
       case 16: { // A16 Set HotEnd temp  A17 S170
@@ -631,10 +620,10 @@ namespace Anycubic {
631 620
       case 21:   // A21 Home Axis  A21 X
632 621
         if (!isPrinting()) {
633 622
           switch ((char)panel_command[4]) {
634
-            case 'X': injectCommands_P(PSTR("G28 X\n")); break;
635
-            case 'Y': injectCommands_P(PSTR("G28 Y\n")); break;
636
-            case 'Z': injectCommands_P(PSTR("G28 Z\n")); break;
637
-            case 'C': injectCommands_P(PSTR("G28\n")); break;
623
+            case 'X': injectCommands_P(PSTR("G28 X")); break;
624
+            case 'Y': injectCommands_P(PSTR("G28 Y")); break;
625
+            case 'Z': injectCommands_P(PSTR("G28 Z")); break;
626
+            case 'C': injectCommands_P(PSTR("G28")); break;
638 627
           }
639 628
         }
640 629
         break;
@@ -729,7 +718,7 @@ namespace Anycubic {
729 718
           // If the same meshpoint is selected twice in a row, move the head to that ready for adjustment
730 719
           if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) {
731 720
             if (!isPositionKnown())
732
-              injectCommands_P(PSTR("G28\n")); // home
721
+              injectCommands_P(PSTR("G28")); // home
733 722
 
734 723
             if (isPositionKnown()) {
735 724
               #if ACDEBUG(AC_INFO)
@@ -769,17 +758,15 @@ namespace Anycubic {
769 758
         switch (panel_command[3]) {
770 759
           case 'C':   // Restore and apply original offsets
771 760
             if (!isPrinting()) {
772
-              injectCommands_P(PSTR("M501\nM420 S1\n"));
773
-              selectedmeshpoint.x = 99;
774
-              selectedmeshpoint.y = 99;
761
+              injectCommands_P(PSTR("M501\nM420 S1"));
762
+              selectedmeshpoint.x = selectedmeshpoint.y = 99;
775 763
             }
776 764
           break;
777 765
           case 'D':   // Save Z Offset tables and restore levelling state
778 766
             if (!isPrinting()) {
779 767
               setAxisPosition_mm(1.0,Z);
780
-              injectCommands_P(PSTR("M500\n"));
781
-              selectedmeshpoint.x = 99;
782
-              selectedmeshpoint.y = 99;
768
+              injectCommands_P(PSTR("M500"));
769
+              selectedmeshpoint.x = selectedmeshpoint.y = 99;
783 770
             }
784 771
           break;
785 772
           case 'G':   // Get current offset
@@ -790,8 +777,7 @@ namespace Anycubic {
790 777
               TFTSer.println(live_Zoffset);
791 778
             else {
792 779
               TFTSer.println(getZOffset_mm());
793
-              selectedmeshpoint.x = 99;
794
-              selectedmeshpoint.y = 99;
780
+              selectedmeshpoint.x = selectedmeshpoint.y = 99;
795 781
             }
796 782
           break;
797 783
           case 'S': { // Set offset (adjusts all points by value)
@@ -859,8 +845,7 @@ namespace Anycubic {
859 845
       case 34: {  // A34 Adjust single mesh point A34 C/S X1 Y1 V123
860 846
         if (panel_command[3] == 'C') { // Restore original offsets
861 847
           injectCommands_P(PSTR("M501\nM420 S1"));
862
-          selectedmeshpoint.x = 99;
863
-          selectedmeshpoint.y = 99;
848
+          selectedmeshpoint.x = selectedmeshpoint.y = 99;
864 849
           //printer_state = AC_printer_idle;
865 850
         }
866 851
         else {
@@ -876,9 +861,10 @@ namespace Anycubic {
876 861
           #endif
877 862
           // Update Meshpoint
878 863
           setMeshPoint(pos,newval);
879
-          if ( (printer_state == AC_printer_idle) || (printer_state == AC_printer_probing) ) {//!isPrinting()) {
880
-            // if we are at the current mesh point indicated on the panel Move Z pos +/- 0.05mm ( The panel changes the mesh value by +/- 0.05mm on each button press)
881
-            if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) {
864
+          if (printer_state == AC_printer_idle || printer_state == AC_printer_probing /*!isPrinting()*/) {
865
+            // if we are at the current mesh point indicated on the panel Move Z pos +/- 0.05mm
866
+            // (The panel changes the mesh value by +/- 0.05mm on each button press)
867
+            if (selectedmeshpoint.x == pos.x && selectedmeshpoint.y == pos.y) {
882 868
               setSoftEndstopState(false);
883 869
               float currZpos = getAxisPosition_mm(Z);
884 870
               #if ACDEBUG(AC_INFO)

+ 1
- 1
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h Wyświetl plik

@@ -88,7 +88,7 @@
88 88
 
89 89
 #define MARLIN_msg_start_probing       PSTR("Probing Point 1/25")
90 90
 #define MARLIN_msg_probing_failed      PSTR("Probing Failed")
91
-#define MARLIN_msg_ready               PSTR("3D Printer Ready.")
91
+#define MARLIN_msg_ready               PSTR(" Ready.")
92 92
 #define MARLIN_msg_print_paused        PSTR("Print Paused")
93 93
 #define MARLIN_msg_print_aborted       PSTR("Print Aborted")
94 94
 #define MARLIN_msg_extruder_heating    PSTR("E Heating...")

Ładowanie…
Anuluj
Zapisz