* SD Status auto-report feature Feature Request #9751
This commit is contained in:
committed by
Scott Lahteine
parent
7bdb98c946
commit
eb079959fb
@ -536,7 +536,7 @@ void CardReader::getStatus(
|
||||
const int8_t port/*= -1*/
|
||||
#endif
|
||||
) {
|
||||
if (cardOK) {
|
||||
if (cardOK && sdprinting) {
|
||||
SERIAL_PROTOCOLPGM_P(port, MSG_SD_PRINTING_BYTE);
|
||||
SERIAL_PROTOCOL_P(port, sdpos);
|
||||
SERIAL_PROTOCOLCHAR_P(port, '/');
|
||||
@ -947,4 +947,24 @@ void CardReader::printingHasFinished() {
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
uint8_t CardReader::auto_report_sd_interval = 0;
|
||||
millis_t CardReader::next_sd_report_ms;
|
||||
#if NUM_SERIAL > 1
|
||||
int8_t CardReader::serialport;
|
||||
#endif
|
||||
|
||||
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(
|
||||
#if NUM_SERIAL > 1
|
||||
serialport
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif // AUTO_REPORT_SD_STATUS
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
@ -99,6 +99,23 @@ public:
|
||||
FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
|
||||
|
||||
Sd2Card& getSd2Card() { return card; }
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
void auto_report_sd_status(void);
|
||||
FORCE_INLINE void set_auto_report_interval(uint8_t v
|
||||
#if NUM_SERIAL > 1
|
||||
, int8_t port
|
||||
#endif
|
||||
) {
|
||||
#if NUM_SERIAL > 1
|
||||
serialport = port;
|
||||
#endif
|
||||
NOMORE(v, 60);
|
||||
auto_report_sd_interval = v;
|
||||
next_sd_report_ms = millis() + 1000UL * v;
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
bool saving, logging, sdprinting, cardOK, filenameIsDir;
|
||||
char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH];
|
||||
@ -183,6 +200,14 @@ 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;
|
||||
#if NUM_SERIAL > 1
|
||||
static int8_t serialport;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
#if PIN_EXISTS(SD_DETECT)
|
||||
|
Reference in New Issue
Block a user