AutoReport class (Temperature, Cardreader) (#20913)
This commit is contained in:
@ -1226,21 +1226,10 @@ void CardReader::fileHasFinished() {
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
uint8_t CardReader::auto_report_sd_interval = 0;
|
||||
millis_t CardReader::next_sd_report_ms;
|
||||
#if HAS_MULTI_SERIAL
|
||||
serial_index_t CardReader::auto_report_port;
|
||||
#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;
|
||||
PORT_REDIRECT(auto_report_port);
|
||||
report_status();
|
||||
}
|
||||
}
|
||||
#endif // AUTO_REPORT_SD_STATUS
|
||||
TERN_(HAS_MULTI_SERIAL, serial_index_t CardReader::auto_report_port);
|
||||
CardReader::AutoReportSD CardReader::auto_reporter;
|
||||
void CardReader::AutoReportSD::auto_report() { report_status(); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
|
||||
|
@ -59,6 +59,10 @@ typedef struct {
|
||||
;
|
||||
} card_flags_t;
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
#include "../libs/autoreport.h"
|
||||
#endif
|
||||
|
||||
class CardReader {
|
||||
public:
|
||||
static card_flags_t flag; // Flags (above)
|
||||
@ -172,13 +176,16 @@ public:
|
||||
static Sd2Card& getSd2Card() { return sd2card; }
|
||||
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
static void auto_report_sd_status();
|
||||
static inline void set_auto_report_interval(uint8_t v) {
|
||||
TERN_(HAS_MULTI_SERIAL, auto_report_port = multiSerial.portMask);
|
||||
NOMORE(v, 60);
|
||||
auto_report_sd_interval = v;
|
||||
next_sd_report_ms = millis() + 1000UL * v;
|
||||
}
|
||||
//
|
||||
// SD Auto Reporting
|
||||
//
|
||||
#if HAS_MULTI_SERIAL
|
||||
static serial_index_t auto_report_port;
|
||||
#else
|
||||
static constexpr serial_index_t auto_report_port = 0;
|
||||
#endif
|
||||
class AutoReportSD : public AutoReporter<auto_report_port> { void auto_report(); };
|
||||
static AutoReportSD auto_reporter;
|
||||
#endif
|
||||
|
||||
private:
|
||||
@ -260,17 +267,6 @@ private:
|
||||
static char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
||||
#endif
|
||||
|
||||
//
|
||||
// SD Auto Reporting
|
||||
//
|
||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||
static uint8_t auto_report_sd_interval;
|
||||
static millis_t next_sd_report_ms;
|
||||
#if HAS_MULTI_SERIAL
|
||||
static serial_index_t auto_report_port;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Directory items
|
||||
//
|
||||
|
Reference in New Issue
Block a user