0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-02-18 15:21:25 +00:00

🐛 Fix M105 (MString append TS) and EEPROM ver

Followup to #24390
This commit is contained in:
Scott Lahteine 2023-07-01 16:50:42 -05:00
parent 4985acafad
commit 1a241e6e86
3 changed files with 13 additions and 8 deletions

View file

@ -112,10 +112,9 @@ public:
MString& set(const char *s) { return set(const_cast<char*>(s)); }
MString& set_P(PGM_P const s) { strncpy_P(str, s, SIZE); debug(F("pstring")); return *this; }
MString& set(FSTR_P const f) { return set_P(FTOP(f)); }
MString& set(const MString &s) { strncpy(str, s.str, SIZE); debug(F("MString")); return *this; }
MString& set(const bool &b) { return set(b ? F("true") : F("false")); }
MString& set(const char c) { str[0] = c; if (1 < SIZE) str[1] = '\0'; debug(F("char")); return *this; }
MString& set(const int8_t &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("int8_t")); return *this; }
MString& set(const int8_t &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("int8_t")); return *this; }
MString& set(const short &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("short")); return *this; }
MString& set(const int &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("int")); return *this; }
MString& set(const long &l) { SNPRINTF_P(str, SIZE, PSTR("%ld"), l); debug(F("long")); return *this; }
@ -130,6 +129,9 @@ public:
MString& set(const xyz_pos_t &v) { set(); return append(v); }
MString& set(const xyze_pos_t &v) { set(); return append(v); }
template <int S>
MString& set(const MString<S> &m) { strncpy(str, &m, SIZE); debug(F("MString")); return *this; }
MString& setn(char *s, int len) { int c = _MIN(len, SIZE); strncpy(str, s, c); str[c] = '\0'; debug(F("string")); return *this; }
MString& setn(const char *s, int len) { return setn(const_cast<char*>(s), len); }
MString& setn_P(PGM_P const s, int len) { int c = _MIN(len, SIZE); strncpy_P(str, s, c); str[c] = '\0'; debug(F("pstring")); return *this; }
@ -157,7 +159,6 @@ public:
MString& append(const char *s) { return append(const_cast<char *>(s)); }
MString& append_P(PGM_P const s) { int sz = length(); if (sz < SIZE) strncpy_P(str + sz, s, SIZE - sz); debug(F("pstring")); return *this; }
MString& append(FSTR_P const f) { return append_P(FTOP(f)); }
MString& append(const MString &s) { return append(s.str); }
MString& append(const bool &b) { return append(b ? F("true") : F("false")); }
MString& append(const char c) { int sz = length(); if (sz < SIZE) { str[sz] = c; if (sz < SIZE - 1) str[sz + 1] = '\0'; } return *this; }
#if ENABLED(FASTER_APPEND)
@ -186,6 +187,9 @@ public:
MString& append(const xyz_pos_t &v) { LOOP_NUM_AXES(i) { if (i) append(' '); append(AXIS_CHAR(i), v[i]); } debug(F("xyz")); return *this; }
MString& append(const xyze_pos_t &v) { LOOP_LOGICAL_AXES(i) { if (i) append(' '); append(AXIS_CHAR(i), v[i]); } debug(F("xyze")); return *this; }
template<int S>
MString& append(const MString<S> &m) { return append(&m); }
// Append only if the given space is available
MString& appendn(char *s, int len) { int sz = length(), c = _MIN(len, SIZE - sz); if (c > 0) { strncpy(str + sz, s, c); str[sz + c] = '\0'; } debug(F("string")); return *this; }
MString& appendn(const char *s, int len) { return appendn(const_cast<char *>(s), len); }
@ -227,7 +231,7 @@ public:
MString(T arg1, Args... more) { set(arg1); append(more...); }
// Catch unhandled types to prevent infinite recursion
template<typename T> MString& append(T) { return append('?'); }
template<typename T> MString& append(T) { return append(TERN(MSTRING_DEBUG, typeid(T).name(), '?')); }
// Take a list of any number of arguments and append them to the string
template<typename T, typename... Args>
@ -313,4 +317,5 @@ public:
#ifndef TS_SIZE
#define TS_SIZE 63
#endif
#define TS(V...) MString<TS_SIZE>(V)
typedef MString<TS_SIZE, DISABLED(UNSAFE_MSTRING)> TString;
#define TS(V...) TString(V)

View file

@ -814,14 +814,14 @@ void MarlinSettings::postprocess() {
*/
bool MarlinSettings::save() {
float dummyf = 0;
MString<4> ver(F("ERR"));
MString<3> ver(F("ERR"));
if (!EEPROM_START(EEPROM_OFFSET)) return false;
EEPROM_Error eeprom_error = ERR_EEPROM_NOERR;
// Write or Skip version. (Flash doesn't allow rewrite without erase.)
TERN(FLASH_EEPROM_EMULATION, EEPROM_SKIP, EEPROM_WRITE)(&ver);
TERN(FLASH_EEPROM_EMULATION, EEPROM_SKIP, EEPROM_WRITE)(ver);
#if ENABLED(EEPROM_INIT_NOW)
EEPROM_SKIP(build_hash); // Skip the hash slot which will be written later

View file

@ -4185,7 +4185,7 @@ void Temperature::isr() {
SString<50> s(' ', k);
if (TERN0(HAS_MULTI_HOTEND, e >= 0)) s += char('0' + e);
s += TS(':', p_float_t(c, SFP));
s += ':'; s += p_float_t(c, SFP);
if (show_t) { s += F(" /"); s += p_float_t(t, SFP); }
#if ENABLED(SHOW_TEMP_ADC_VALUES)
// Temperature MAX SPI boards do not have an OVERSAMPLENR defined