Browse Source

🐛 Fix Chiron new TFT SD print after reset (#23855)

Nick 2 years ago
parent
commit
9c9300ff9d
No account linked to committer's email address

+ 4
- 2
Marlin/src/gcode/bedlevel/mbl/G29.cpp View File

@@ -118,9 +118,11 @@ void GcodeSuite::G29() {
118 118
       // For each G29 S2...
119 119
       if (mbl_probe_index == 0) {
120 120
         // Move close to the bed before the first point
121
-        do_blocking_move_to_z(0.4f
121
+        do_blocking_move_to_z(
122 122
           #ifdef MANUAL_PROBE_START_Z
123
-            + (MANUAL_PROBE_START_Z) - 0.4f
123
+            MANUAL_PROBE_START_Z
124
+          #else
125
+            0.4f
124 126
           #endif
125 127
         );
126 128
       }

+ 2
- 2
Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp View File

@@ -155,7 +155,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
155 155
 
156 156
     if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder
157 157
       // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them.
158
-      if (paneltype == AC_panel_new) {
158
+      if (paneltype <= AC_panel_new) {
159 159
         TFTSer.println("<<.GCO");
160 160
         Chiron.SendtoTFTLN(F("..                  .gcode"));
161 161
       }
@@ -177,7 +177,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
177 177
   void FileNavigator::sendFile(panel_type_t paneltype) {
178 178
     if (filelist.isDir()) {
179 179
       // Add mandatory tags for new panel otherwise lines are ignored.
180
-      if (paneltype == AC_panel_new) {
180
+      if (paneltype <= AC_panel_new) {
181 181
         TFTSer.print(filelist.shortFilename());
182 182
         TFTSer.println(".GCO");
183 183
         TFTSer.print(filelist.shortFilename());

+ 16
- 14
Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp View File

@@ -442,7 +442,7 @@ void ChironTFT::SendFileList(int8_t startindex) {
442 442
 }
443 443
 
444 444
 void ChironTFT::SelectFile() {
445
-  if (panel_type == AC_panel_new) {
445
+  if (panel_type <= AC_panel_new) {
446 446
     strncpy(selectedfile, panel_command + 4, command_len - 3);
447 447
     selectedfile[command_len - 4] = '\0';
448 448
   }
@@ -465,7 +465,7 @@ void ChironTFT::SelectFile() {
465 465
       break;
466 466
     default:   // enter sub folder
467 467
       // for new panel remove the '.GCO' tag that was added to the end of the path
468
-      if (panel_type == AC_panel_new)
468
+      if (panel_type <= AC_panel_new)
469 469
         selectedfile[strlen(selectedfile) - 4] = '\0';
470 470
       filenavigator.changeDIR(selectedfile);
471 471
       SendtoTFTLN(AC_msg_sd_file_open_failed);
@@ -478,8 +478,8 @@ void ChironTFT::ProcessPanelRequest() {
478 478
   // Break these up into logical blocks // as its easier to navigate than one huge switch case!
479 479
   int8_t tpos = FindToken('A');
480 480
   // Panel request are 'A0' - 'A36'
481
-  if (tpos != -1) {
482
-    const int8_t req = atoi(&panel_command[tpos+1]);
481
+  if (tpos >= 0) {
482
+    const int8_t req = atoi(&panel_command[tpos + 1]);
483 483
 
484 484
     // Information requests A0 - A8 and A33
485 485
     if (req <= 8 || req == 33) PanelInfo(req);
@@ -495,16 +495,18 @@ void ChironTFT::ProcessPanelRequest() {
495 495
       // This may be a response to a panel type detection query
496 496
       if (panel_type == AC_panel_unknown) {
497 497
         tpos = FindToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320'
498
-        if (tpos != -1) {
499
-          if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') {
498
+        if (tpos >= 0) {
499
+          if (panel_command[tpos + 1] == 'X' && panel_command[tpos + 2] =='Y') {
500 500
             panel_type = AC_panel_standard;
501 501
             SERIAL_ECHOLNF(AC_msg_old_panel_detected);
502 502
           }
503 503
         }
504 504
         else {
505
-          tpos = FindToken('['); // new panel will respond to 'J200' with '[0]=0'
506
-          if (tpos != -1) {
507
-            if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') {
505
+          // new panel will respond to 'J200' with '[0]=0'
506
+          // it seems only after a power cycle so detection assumes a new panel
507
+          tpos = FindToken('[');
508
+          if (tpos >= 0) {
509
+            if (panel_command[tpos + 1] == '0' && panel_command[tpos + 2] ==']') {
508 510
               panel_type = AC_panel_new;
509 511
               SERIAL_ECHOLNF(AC_msg_new_panel_detected);
510 512
             }
@@ -811,7 +813,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
811 813
     } break;
812 814
 
813 815
     case 30:     // A30 Auto leveling
814
-      if (FindToken('S') != -1) { // Start probing New panel adds spaces..
816
+      if (FindToken('S') >= 0) { // Start probing New panel adds spaces..
815 817
         // Ignore request if printing
816 818
         if (isPrinting())
817 819
           SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
@@ -828,7 +830,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
828 830
     case 31:   // A31 Adjust all Probe Points
829 831
       // The tokens can occur in different places on the new panel so we need to find it.
830 832
 
831
-      if (FindToken('C') != -1) { // Restore and apply original offsets
833
+      if (FindToken('C') >= 0) { // Restore and apply original offsets
832 834
         if (!isPrinting()) {
833 835
           injectCommands(F("M501\nM420 S1"));
834 836
           selectedmeshpoint.x = selectedmeshpoint.y = 99;
@@ -836,7 +838,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
836 838
         }
837 839
       }
838 840
 
839
-      else if (FindToken('D') != -1) { // Save Z Offset tables and restore leveling state
841
+      else if (FindToken('D') >= 0) { // Save Z Offset tables and restore leveling state
840 842
         if (!isPrinting()) {
841 843
           setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made
842 844
           injectCommands(F("M500"));
@@ -845,7 +847,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
845 847
         }
846 848
       }
847 849
 
848
-      else if (FindToken('G') != -1) { // Get current offset
850
+      else if (FindToken('G') >= 0) { // Get current offset
849 851
         SendtoTFT(F("A31V "));
850 852
         // When printing use the live z Offset position
851 853
         // we will use babystepping to move the print head
@@ -859,7 +861,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
859 861
 
860 862
       else {
861 863
         int8_t tokenpos = FindToken('S');
862
-        if (tokenpos != -1) { // Set offset (adjusts all points by value)
864
+        if (tokenpos >= 0) { // Set offset (adjusts all points by value)
863 865
           float Zshift = atof(&panel_command[tokenpos+1]);
864 866
           setSoftEndstopState(false);  // disable endstops
865 867
           // Allow temporary Z position nudging during print

+ 7
- 3
Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h View File

@@ -89,6 +89,10 @@
89 89
 #define AC_msg_mesh_changes_saved      F("Mesh changes saved.")
90 90
 #define AC_msg_old_panel_detected      F("Standard TFT panel detected!")
91 91
 #define AC_msg_new_panel_detected      F("New TFT panel detected!")
92
+#define AC_msg_auto_panel_detection    F("Auto detect panel type (assuming new panel)")
93
+#define AC_msg_old_panel_set           F("Set for standard TFT panel.")
94
+#define AC_msg_new_panel_set           F("Set for new TFT panel.")
95
+
92 96
 #define AC_msg_powerloss_recovery      F("Resuming from power outage! select the same SD file then press resume")
93 97
 // Error messages must not contain spaces
94 98
 #define AC_msg_error_bed_temp          F("Abnormal_bed_temp")
@@ -161,10 +165,10 @@ namespace Anycubic {
161 165
     AC_menu_change_to_file,
162 166
     AC_menu_change_to_command
163 167
   };
164
-  enum panel_type_t : uint8_t {
168
+  enum panel_type_t : uint8_t { // order is important here as we assume new panel if type is unknown
165 169
     AC_panel_unknown,
166
-    AC_panel_standard,
167
-    AC_panel_new
170
+    AC_panel_new,
171
+    AC_panel_standard
168 172
   };
169 173
   enum last_error_t : uint8_t {
170 174
     AC_error_none,

Loading…
Cancel
Save