Add AUTO_REPORT_SD_STATUS feature
For parity with 2.0.x ahead of 1.1.9 release.
This commit is contained in:
parent
b935bc948a
commit
fb9de6e787
@ -1410,6 +1410,11 @@
|
||||
*/
|
||||
#define AUTO_REPORT_TEMPERATURES
|
||||
|
||||
/**
|
||||
* Auto-report SdCard status with M27 S<seconds>
|
||||
*/
|
||||
//#define AUTO_REPORT_SD_STATUS
|
||||
|
||||
/**
|
||||
* Include capabilities in M115 output
|
||||
*/
|
||||
|
@ -89,7 +89,7 @@
|
||||
* M24 - Start/resume SD print. (Requires SDSUPPORT)
|
||||
* M25 - Pause SD print. (Requires SDSUPPORT)
|
||||
* M26 - Set SD position in bytes: "M26 S12345". (Requires SDSUPPORT)
|
||||
* M27 - Report SD print status. (Requires SDSUPPORT)
|
||||
* M27 - Report SD print status. (Requires SDSUPPORT) Or, with 'S<seconds>' sets the SD status auto-report interval. (Requires AUTO_REPORT_SD_STATUS)
|
||||
* M28 - Start SD write: "M28 /path/file.gco". (Requires SDSUPPORT)
|
||||
* M29 - Stop SD write. (Requires SDSUPPORT)
|
||||
* M30 - Delete file from SD: "M30 /path/file.gco"
|
||||
@ -6886,9 +6886,17 @@ inline void gcode_M17() {
|
||||
}
|
||||
|
||||
/**
|
||||
* M27: Get SD Card status
|
||||
* M27: Get SD Card status or set the SD status auto-report interval.
|
||||
|
||||
*/
|
||||
inline void gcode_M27() { card.getStatus(); }
|
||||
inline void gcode_M27() {
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
if (parser.seenval('S'))
|
||||
card.set_auto_report_interval(parser.value_byte());
|
||||
else
|
||||
#endif
|
||||
card.getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* M28: Start SD Write
|
||||
@ -8636,6 +8644,13 @@ inline void gcode_M115() {
|
||||
#endif
|
||||
);
|
||||
|
||||
// AUTOREPORT_SD_STATUS (M27 extension)
|
||||
cap_line(PSTR("AUTOREPORT_SD_STATUS")
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
, true
|
||||
#endif
|
||||
);
|
||||
|
||||
#endif // EXTENDED_CAPABILITIES_REPORT
|
||||
}
|
||||
|
||||
@ -13467,6 +13482,10 @@ void idle(
|
||||
i2cpem_next_update_ms = millis() + I2CPE_MIN_UPD_TIME_MS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
card.auto_report_sd_status();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -911,4 +911,17 @@ void CardReader::printingHasFinished() {
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
uint8_t CardReader::auto_report_sd_interval = 0;
|
||||
millis_t CardReader::next_sd_report_ms;
|
||||
|
||||
void CardReader::auto_report_sd_status() {
|
||||
millis_t current_ms = millis();
|
||||
if (auto_report_sd_interval && ELAPSED(current_ms, next_sd_report_ms)) {
|
||||
next_sd_report_ms = current_ms + 1000UL * auto_report_sd_interval;
|
||||
getStatus();
|
||||
}
|
||||
}
|
||||
#endif // AUTO_REPORT_SD_STATUS
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
@ -90,10 +90,19 @@ public:
|
||||
FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
|
||||
FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
|
||||
|
||||
public:
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
void auto_report_sd_status(void);
|
||||
FORCE_INLINE void set_auto_report_interval(uint8_t v) {
|
||||
NOMORE(v, 60);
|
||||
auto_report_sd_interval = v;
|
||||
next_sd_report_ms = millis() + 1000UL * v;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool saving, logging, sdprinting, cardOK, filenameIsDir;
|
||||
char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH];
|
||||
int autostart_index;
|
||||
|
||||
private:
|
||||
SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH];
|
||||
uint8_t workDirDepth;
|
||||
@ -170,6 +179,11 @@ private:
|
||||
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||
void flush_presort();
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
static uint8_t auto_report_sd_interval;
|
||||
static millis_t next_sd_report_ms;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if PIN_EXISTS(SD_DETECT)
|
||||
|
Loading…
Reference in New Issue
Block a user