mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-01-07 07:07:42 -07:00
Merge 81d7e39660 into 4fccfa14e9
This commit is contained in:
commit
d7a8be310e
9 changed files with 69 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
|
@ -4807,3 +4808,11 @@
|
|||
|
||||
// Shrink the build for smaller boards by sacrificing some serial feedback
|
||||
//#define MARLIN_SMALL_BUILD
|
||||
|
||||
#if ALL(HAS_MEDIA, HAS_MARLINUI_MENU) && DISABLED(SDCARD_READONLY)
|
||||
#define EXPORT_SETTINGS // Export memory settings to file M503.gc in SD card root for replay
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXPORT_SETTINGS)
|
||||
#define SERIAL_2_FILE // Dump serial output to file, needed for export settings
|
||||
#endif
|
||||
|
|
@ -144,3 +144,29 @@ void print_xyze(LOGICAL_AXIS_ARGS_(const float) FSTR_P const prefix/*=nullptr*/,
|
|||
#endif
|
||||
if (suffix) SERIAL_ECHO(suffix); else SERIAL_EOL();
|
||||
}
|
||||
|
||||
#if ENABLED(SERIAL_2_FILE)
|
||||
#include <src/sd/SdFile.h>
|
||||
#include <src/sd/cardreader.h>
|
||||
|
||||
MediaFile sr_dump_file;
|
||||
size_t sr_write_res;
|
||||
|
||||
bool sr_file_open(const char * filename)
|
||||
{
|
||||
sr_write_res = 0;
|
||||
MediaFile root = card.getroot();
|
||||
return sr_dump_file.open(&root, filename, O_CREAT | O_WRITE | O_TRUNC);
|
||||
}
|
||||
|
||||
void serial2file(uint8_t c)
|
||||
{
|
||||
if (sr_dump_file.isOpen() && sr_write_res != -1)
|
||||
sr_write_res = sr_dump_file.write(c);
|
||||
}
|
||||
|
||||
bool sr_file_close()
|
||||
{
|
||||
return sr_dump_file.close();
|
||||
}
|
||||
#endif
|
||||
|
|
@ -250,6 +250,10 @@ inline void print_xyze(const xyze_pos_t &xyze, FSTR_P const prefix=nullptr, FSTR
|
|||
print_xyze(LOGICAL_AXIS_ELEM_LC_(xyze) prefix, suffix);
|
||||
}
|
||||
|
||||
bool sr_file_open(const char * filename);
|
||||
bool sr_file_close();
|
||||
extern size_t sr_write_res;
|
||||
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
|
||||
#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(V, F(PREFIX)); }while(0)
|
||||
|
||||
|
|
|
|||
|
|
@ -200,6 +200,8 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public Seria
|
|||
#define _S_CLASS(N) class Serial##N##T,
|
||||
#define _S_NAME(N) Serial##N##T,
|
||||
|
||||
void serial2file(uint8_t c);
|
||||
|
||||
template < REPEAT(NUM_SERIAL, _S_CLASS) const uint8_t offset=0, const uint8_t step=1 >
|
||||
struct MultiSerial : public SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME) offset, step > > {
|
||||
typedef SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME) offset, step > > BaseClassT;
|
||||
|
|
@ -227,6 +229,9 @@ struct MultiSerial : public SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME)
|
|||
#define _S_WRITE(N) if (portMask.enabled(output[N])) serial##N.write(c);
|
||||
REPEAT(NUM_SERIAL, _S_WRITE);
|
||||
#undef _S_WRITE
|
||||
#if ENABLED(SERIAL_2_FILE)
|
||||
serial2file(c);
|
||||
#endif
|
||||
}
|
||||
NO_INLINE void msgDone() {
|
||||
#define _S_DONE(N) if (portMask.enabled(output[N])) serial##N.msgDone();
|
||||
|
|
|
|||
|
|
@ -2779,6 +2779,8 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
|
|||
#error "Either disable SDCARD_READONLY or disable BINARY_FILE_TRANSFER."
|
||||
#elif ENABLED(SDCARD_EEPROM_EMULATION)
|
||||
#error "Either disable SDCARD_READONLY or disable SDCARD_EEPROM_EMULATION."
|
||||
#elif ENABLED(EXPORT_SETTINGS)
|
||||
#error "Either disable SDCARD_READONLY or disable EXPORT_SETTINGS."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -520,6 +520,7 @@ namespace LanguageNarrow_en {
|
|||
LSTR MSG_STORE_EEPROM = _UxGT("Store Settings");
|
||||
LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings");
|
||||
LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults");
|
||||
LSTR MSG_EXPORT_SETTINGS = _UxGT("Export Settings");
|
||||
LSTR MSG_INIT_EEPROM = _UxGT("Initialize EEPROM");
|
||||
LSTR MSG_EEPROM_INITIALIZED = _UxGT("EEPROM Initialized");
|
||||
LSTR MSG_ERR_EEPROM_CRC = _UxGT("Err: EEPROM CRC");
|
||||
|
|
|
|||
|
|
@ -2020,6 +2020,16 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind,
|
|||
zoffset_overlay(dir);
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(EXPORT_SETTINGS)
|
||||
void MarlinUI::export_settings(const char* filename) {
|
||||
if (sr_file_open(filename)) {
|
||||
settings.report(true);
|
||||
completion_feedback(sr_file_close() && sr_write_res != -1);
|
||||
} else
|
||||
completion_feedback(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // HAS_MARLINUI_MENU
|
||||
|
||||
|
|
|
|||
|
|
@ -796,6 +796,14 @@ public:
|
|||
static void eeprom_alert(const EEPROM_Error) TERN_(EEPROM_AUTO_INIT, {});
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXPORT_SETTINGS)
|
||||
static void export_settings();
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXPORT_SETTINGS)
|
||||
static void export_settings(const char* filename);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Special handling if a move is underway
|
||||
//
|
||||
|
|
|
|||
|
|
@ -818,6 +818,10 @@ void menu_advanced_settings() {
|
|||
);
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXPORT_SETTINGS)
|
||||
ACTION_ITEM(MSG_EXPORT_SETTINGS, []{ui.export_settings("M503.GC");});
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue