Move restore_file_from_sd out of power panic file

This function is not specific to power panic. Some printer models
do not have power panic enabled.

This change fixes a build failure

No change in memory
This commit is contained in:
gudnimg 2023-12-30 12:19:17 +00:00
parent ceec54f026
commit 9bd043c83b
5 changed files with 31 additions and 32 deletions

View File

@ -380,6 +380,7 @@ void refresh_print_state_in_ram();
void refresh_saved_feedrate_multiplier_in_ram();
void clear_print_state_in_ram();
extern void stop_and_save_print_to_ram(float z_move, float e_move);
void restore_file_from_sd();
void restore_extruder_temperature_from_ram();
extern void restore_print_from_ram_and_continue(float e_move);
extern void cancel_saved_printing();

View File

@ -10859,6 +10859,36 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
}
}
/// @brief Read saved filename from EEPROM and send g-code command: M23 <filename>
void restore_file_from_sd()
{
char filename[FILENAME_LENGTH];
char dir_name[9];
char extension_ptr[5];
uint8_t depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH);
for (uint8_t i = 0; i < depth; i++) {
eeprom_read_block(dir_name, (const char *)EEPROM_DIRS + 8 * i, 8);
dir_name[8] = '\0';
card.chdir(dir_name, false);
}
// Recover DOS 8.3 filename without extension.
// Short filenames are always null terminated.
eeprom_read_block(filename, (const char *)EEPROM_FILENAME, 8);
// Add null delimiter in case all 8 characters were not NULL
filename[8] = '\0';
// Add extension to complete the DOS 8.3 filename e.g. ".gco" or ".g"
extension_ptr[0] = '.';
eeprom_read_block(&extension_ptr[1], (const char *)EEPROM_FILENAME_EXTENSION, 3);
extension_ptr[4] = '\0';
strcat(filename, extension_ptr);
enquecommandf_P(MSG_M23, filename);
}
void restore_extruder_temperature_from_ram() {
if ((uint16_t)degTargetHotend(active_extruder) != saved_extruder_temperature)
{

View File

@ -413,36 +413,6 @@ bool recover_machine_state_after_power_panic() {
return mbl_was_active;
}
/// @brief Read saved filename from EEPROM and send g-code command: M23 <filename>
void restore_file_from_sd()
{
char filename[FILENAME_LENGTH];
char dir_name[9];
char extension_ptr[5];
uint8_t depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH);
for (uint8_t i = 0; i < depth; i++) {
eeprom_read_block(dir_name, (const char *)EEPROM_DIRS + 8 * i, 8);
dir_name[8] = '\0';
card.chdir(dir_name, false);
}
// Recover DOS 8.3 filename without extension.
// Short filenames are always null terminated.
eeprom_read_block(filename, (const char *)EEPROM_FILENAME, 8);
// Add null delimiter in case all 8 characters were not NULL
filename[8] = '\0';
// Add extension to complete the DOS 8.3 filename e.g. ".gco" or ".g"
extension_ptr[0] = '.';
eeprom_read_block(&extension_ptr[1], (const char *)EEPROM_FILENAME_EXTENSION, 3);
extension_ptr[4] = '\0';
strcat(filename, extension_ptr);
enquecommandf_P(MSG_M23, filename);
}
void restore_print_from_eeprom(bool mbl_was_active) {
int feedrate_rec;
int feedmultiply_rec;

View File

@ -18,4 +18,3 @@ enum PrintType : uint8_t {
void uvlo_();
void recover_print(uint8_t automatic);
void setup_uvlo_interrupt();
void restore_file_from_sd();

View File

@ -11,7 +11,6 @@
#include "fancheck.h"
#include "stepper.h"
#include "ConfigurationStore.h"
#include "power_panic.h"
#include "printers.h"
#include <string.h>
#include "stopwatch.h"