Skip to content

Commit 9c9300f

Browse files
authored
🐛 Fix Chiron new TFT SD print after reset (MarlinFirmware#23855)
1 parent e354cd1 commit 9c9300f

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

Marlin/src/gcode/bedlevel/mbl/G29.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ void GcodeSuite::G29() {
118118
// For each G29 S2...
119119
if (mbl_probe_index == 0) {
120120
// Move close to the bed before the first point
121-
do_blocking_move_to_z(0.4f
121+
do_blocking_move_to_z(
122122
#ifdef MANUAL_PROBE_START_Z
123-
+ (MANUAL_PROBE_START_Z) - 0.4f
123+
MANUAL_PROBE_START_Z
124+
#else
125+
0.4f
124126
#endif
125127
);
126128
}

Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
155155

156156
if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder
157157
// 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) {
159159
TFTSer.println("<<.GCO");
160160
Chiron.SendtoTFTLN(F(".. .gcode"));
161161
}
@@ -177,7 +177,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
177177
void FileNavigator::sendFile(panel_type_t paneltype) {
178178
if (filelist.isDir()) {
179179
// Add mandatory tags for new panel otherwise lines are ignored.
180-
if (paneltype == AC_panel_new) {
180+
if (paneltype <= AC_panel_new) {
181181
TFTSer.print(filelist.shortFilename());
182182
TFTSer.println(".GCO");
183183
TFTSer.print(filelist.shortFilename());

Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ void ChironTFT::SendFileList(int8_t startindex) {
442442
}
443443

444444
void ChironTFT::SelectFile() {
445-
if (panel_type == AC_panel_new) {
445+
if (panel_type <= AC_panel_new) {
446446
strncpy(selectedfile, panel_command + 4, command_len - 3);
447447
selectedfile[command_len - 4] = '\0';
448448
}
@@ -465,7 +465,7 @@ void ChironTFT::SelectFile() {
465465
break;
466466
default: // enter sub folder
467467
// 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)
469469
selectedfile[strlen(selectedfile) - 4] = '\0';
470470
filenavigator.changeDIR(selectedfile);
471471
SendtoTFTLN(AC_msg_sd_file_open_failed);
@@ -478,8 +478,8 @@ void ChironTFT::ProcessPanelRequest() {
478478
// Break these up into logical blocks // as its easier to navigate than one huge switch case!
479479
int8_t tpos = FindToken('A');
480480
// 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]);
483483

484484
// Information requests A0 - A8 and A33
485485
if (req <= 8 || req == 33) PanelInfo(req);
@@ -495,16 +495,18 @@ void ChironTFT::ProcessPanelRequest() {
495495
// This may be a response to a panel type detection query
496496
if (panel_type == AC_panel_unknown) {
497497
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') {
500500
panel_type = AC_panel_standard;
501501
SERIAL_ECHOLNF(AC_msg_old_panel_detected);
502502
}
503503
}
504504
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] ==']') {
508510
panel_type = AC_panel_new;
509511
SERIAL_ECHOLNF(AC_msg_new_panel_detected);
510512
}
@@ -811,7 +813,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
811813
} break;
812814

813815
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..
815817
// Ignore request if printing
816818
if (isPrinting())
817819
SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
@@ -828,15 +830,15 @@ void ChironTFT::PanelProcess(uint8_t req) {
828830
case 31: // A31 Adjust all Probe Points
829831
// The tokens can occur in different places on the new panel so we need to find it.
830832

831-
if (FindToken('C') != -1) { // Restore and apply original offsets
833+
if (FindToken('C') >= 0) { // Restore and apply original offsets
832834
if (!isPrinting()) {
833835
injectCommands(F("M501\nM420 S1"));
834836
selectedmeshpoint.x = selectedmeshpoint.y = 99;
835837
SERIAL_ECHOLNF(AC_msg_mesh_changes_abandoned);
836838
}
837839
}
838840

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
840842
if (!isPrinting()) {
841843
setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made
842844
injectCommands(F("M500"));
@@ -845,7 +847,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
845847
}
846848
}
847849

848-
else if (FindToken('G') != -1) { // Get current offset
850+
else if (FindToken('G') >= 0) { // Get current offset
849851
SendtoTFT(F("A31V "));
850852
// When printing use the live z Offset position
851853
// we will use babystepping to move the print head
@@ -859,7 +861,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
859861

860862
else {
861863
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)
863865
float Zshift = atof(&panel_command[tokenpos+1]);
864866
setSoftEndstopState(false); // disable endstops
865867
// Allow temporary Z position nudging during print

Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
#define AC_msg_mesh_changes_saved F("Mesh changes saved.")
9090
#define AC_msg_old_panel_detected F("Standard TFT panel detected!")
9191
#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+
9296
#define AC_msg_powerloss_recovery F("Resuming from power outage! select the same SD file then press resume")
9397
// Error messages must not contain spaces
9498
#define AC_msg_error_bed_temp F("Abnormal_bed_temp")
@@ -161,10 +165,10 @@ namespace Anycubic {
161165
AC_menu_change_to_file,
162166
AC_menu_change_to_command
163167
};
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
165169
AC_panel_unknown,
166-
AC_panel_standard,
167-
AC_panel_new
170+
AC_panel_new,
171+
AC_panel_standard
168172
};
169173
enum last_error_t : uint8_t {
170174
AC_error_none,

0 commit comments

Comments
 (0)