소스 검색

Fix and tweak POWER_LOSS_RECOVERY (#11151)

Scott Lahteine 7 년 전
부모
커밋
fbf1c9b496
No account linked to committer's email address
4개의 변경된 파일37개의 추가작업 그리고 29개의 파일을 삭제
  1. 25
    14
      Marlin/src/feature/power_loss_recovery.cpp
  2. 2
    1
      Marlin/src/feature/power_loss_recovery.h
  3. 1
    5
      Marlin/src/lcd/ultralcd.cpp
  4. 9
    9
      Marlin/src/sd/cardreader.cpp

+ 25
- 14
Marlin/src/feature/power_loss_recovery.cpp 파일 보기

@@ -53,30 +53,39 @@ static char sd_filename[MAXPATHNAMELENGTH];
53 53
     SERIAL_PROTOCOLLNPAIR(" valid_foot:", (int)job_recovery_info.valid_foot);
54 54
     if (job_recovery_info.valid_head) {
55 55
       if (job_recovery_info.valid_head == job_recovery_info.valid_foot) {
56
-        SERIAL_PROTOCOLPGM("current_position");
57
-        LOOP_XYZE(i) SERIAL_PROTOCOLPAIR(": ", job_recovery_info.current_position[i]);
56
+        SERIAL_PROTOCOLPGM("current_position: ");
57
+        LOOP_XYZE(i) {
58
+          SERIAL_PROTOCOL(job_recovery_info.current_position[i]);
59
+          if (i < E_AXIS) SERIAL_CHAR(',');
60
+        }
58 61
         SERIAL_EOL();
59 62
         SERIAL_PROTOCOLLNPAIR("feedrate: ", job_recovery_info.feedrate);
60
-        SERIAL_PROTOCOLPGM("target_temperature");
61
-        HOTEND_LOOP() SERIAL_PROTOCOLPAIR(": ", job_recovery_info.target_temperature[e]);
63
+        SERIAL_PROTOCOLPGM("target_temperature: ");
64
+        HOTEND_LOOP() {
65
+          SERIAL_PROTOCOL(job_recovery_info.target_temperature[e]);
66
+          if (e < HOTENDS - 1) SERIAL_CHAR(',');
67
+        }
62 68
         SERIAL_EOL();
63
-        SERIAL_PROTOCOLPGM("fanSpeeds");
64
-        for(uint8_t i = 0; i < FAN_COUNT; i++) SERIAL_PROTOCOLPAIR(": ", job_recovery_info.fanSpeeds[i]);
69
+        SERIAL_PROTOCOLPGM("fanSpeeds: ");
70
+        for (uint8_t i = 0; i < FAN_COUNT; i++) {
71
+          SERIAL_PROTOCOL(job_recovery_info.fanSpeeds[i]);
72
+          if (i < FAN_COUNT - 1) SERIAL_CHAR(',');
73
+        }
65 74
         SERIAL_EOL();
75
+        #if HAS_HEATED_BED
76
+          SERIAL_PROTOCOLLNPAIR("target_temperature_bed: ", job_recovery_info.target_temperature_bed);
77
+        #endif
66 78
         #if HAS_LEVELING
67 79
           SERIAL_PROTOCOLPAIR("leveling: ", int(job_recovery_info.leveling));
68 80
           SERIAL_PROTOCOLLNPAIR(" fade: ", int(job_recovery_info.fade));
69 81
         #endif
70
-        #if HAS_HEATED_BED
71
-          SERIAL_PROTOCOLLNPAIR("target_temperature_bed: ", job_recovery_info.target_temperature_bed);
72
-        #endif
73 82
         SERIAL_PROTOCOLLNPAIR("cmd_queue_index_r: ", job_recovery_info.cmd_queue_index_r);
74 83
         SERIAL_PROTOCOLLNPAIR("commands_in_queue: ", job_recovery_info.commands_in_queue);
75 84
         if (recovery)
76 85
           for (uint8_t i = 0; i < job_recovery_commands_count; i++) SERIAL_PROTOCOLLNPAIR("> ", job_recovery_commands[i]);
77 86
         else
78 87
           for (uint8_t i = 0; i < job_recovery_info.commands_in_queue; i++) SERIAL_PROTOCOLLNPAIR("> ", job_recovery_info.command_queue[i]);
79
-        SERIAL_PROTOCOLLNPAIR("sd_filename: ", sd_filename);
88
+        SERIAL_PROTOCOLLNPAIR("sd_filename: ", job_recovery_info.sd_filename);
80 89
         SERIAL_PROTOCOLLNPAIR("sdpos: ", job_recovery_info.sdpos);
81 90
         SERIAL_PROTOCOLLNPAIR("print_job_elapsed: ", job_recovery_info.print_job_elapsed);
82 91
       }
@@ -125,13 +134,15 @@ void do_print_job_recovery() {
125 134
           #endif
126 135
         ));
127 136
 
137
+        char str_1[16], str_2[16];
138
+
128 139
         #if HAS_LEVELING
129 140
           // Restore leveling state before G92 sets Z
130 141
           // This ensures the steppers correspond to the native Z
131
-          sprintf_P(job_recovery_commands[ind++], PSTR("M420 S%i Z%s"), int(job_recovery_info.leveling), job_recovery_info.fade);
142
+          dtostrf(job_recovery_info.fade, 1, 1, str_1);
143
+          sprintf_P(job_recovery_commands[ind++], PSTR("M420 S%i Z%s"), int(job_recovery_info.leveling), str_1);
132 144
         #endif
133 145
 
134
-        char str_1[16], str_2[16];
135 146
         dtostrf(job_recovery_info.current_position[Z_AXIS] + 2, 1, 3, str_1);
136 147
         dtostrf(job_recovery_info.current_position[E_AXIS]
137 148
           #if ENABLED(SAVE_EACH_CMD_MODE)
@@ -156,7 +167,7 @@ void do_print_job_recovery() {
156 167
           debug_print_job_recovery(true);
157 168
         #endif
158 169
 
159
-        card.openFile(sd_filename, true);
170
+        card.openFile(job_recovery_info.sd_filename, true);
160 171
         card.setIndex(job_recovery_info.sdpos);
161 172
       }
162 173
       else {
@@ -223,7 +234,7 @@ void save_job_recovery_info() {
223 234
     job_recovery_info.print_job_elapsed = print_job_timer.duration() * 1000UL;
224 235
 
225 236
     // SD file position
226
-    card.getAbsFilename(sd_filename);
237
+    card.getAbsFilename(job_recovery_info.sd_filename);
227 238
     job_recovery_info.sdpos = card.getIndex();
228 239
 
229 240
     #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)

+ 2
- 1
Marlin/src/feature/power_loss_recovery.h 파일 보기

@@ -56,7 +56,8 @@ typedef struct {
56 56
   uint8_t cmd_queue_index_r, commands_in_queue;
57 57
   char command_queue[BUFSIZE][MAX_CMD_SIZE];
58 58
 
59
-  // SD File position
59
+  // SD Filename and position
60
+  char sd_filename[MAXPATHNAMELENGTH];
60 61
   uint32_t sdpos;
61 62
 
62 63
   // Job elapsed time

+ 1
- 5
Marlin/src/lcd/ultralcd.cpp 파일 보기

@@ -875,11 +875,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
875 875
       lcd_return_to_status();
876 876
 
877 877
       #if ENABLED(POWER_LOSS_RECOVERY)
878
-        card.openJobRecoveryFile(false);
879
-        job_recovery_info.valid_head = job_recovery_info.valid_foot = 0;
880
-        (void)card.saveJobRecoveryInfo();
881
-        card.closeJobRecoveryFile();
882
-        job_recovery_commands_count = 0;
878
+        card.removeJobRecoveryFile();
883 879
       #endif
884 880
     }
885 881
 

+ 9
- 9
Marlin/src/sd/cardreader.cpp 파일 보기

@@ -937,11 +937,7 @@ void CardReader::printingHasFinished() {
937 937
     sdprinting = false;
938 938
 
939 939
     #if ENABLED(POWER_LOSS_RECOVERY)
940
-      openJobRecoveryFile(false);
941
-      job_recovery_info.valid_head = job_recovery_info.valid_foot = 0;
942
-      (void)saveJobRecoveryInfo();
943
-      closeJobRecoveryFile();
944
-      job_recovery_commands_count = 0;
940
+      removeJobRecoveryFile();
945 941
     #endif
946 942
 
947 943
     #if ENABLED(SD_FINISHED_STEPPERRELEASE) && defined(SD_FINISHED_RELEASECOMMAND)
@@ -1016,10 +1012,14 @@ void CardReader::printingHasFinished() {
1016 1012
   }
1017 1013
 
1018 1014
   void CardReader::removeJobRecoveryFile() {
1019
-    if (jobRecoveryFile.remove(&root, job_recovery_file_name))
1020
-      SERIAL_PROTOCOLLNPGM("Power-loss file deleted.");
1021
-    else
1022
-      SERIAL_PROTOCOLLNPGM("Power-loss file delete failed.");
1015
+    job_recovery_info.valid_head = job_recovery_info.valid_foot = job_recovery_commands_count = 0;
1016
+    const bool success = jobRecoveryFile.remove(&root, job_recovery_file_name);
1017
+    #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
1018
+      SERIAL_PROTOCOLPGM("Power-loss file delete");
1019
+      serialprintPGM(success ? PSTR("d.") : PSTR(" failed."))
1020
+    #else
1021
+      UNUSED(success);
1022
+    #endif
1023 1023
   }
1024 1024
 
1025 1025
 #endif // POWER_LOSS_RECOVERY

Loading…
취소
저장