Fix AutoReporter implementation (#20959)
This commit is contained in:
@ -23,14 +23,14 @@
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
template<serial_index_t AR_PORT_INDEX>
|
||||
class AutoReporter {
|
||||
public:
|
||||
template <typename Helper>
|
||||
struct AutoReporter {
|
||||
millis_t next_report_ms;
|
||||
uint8_t report_interval;
|
||||
|
||||
// Override this method
|
||||
inline void auto_report() { }
|
||||
#if HAS_MULTI_SERIAL
|
||||
serial_index_t report_port_mask;
|
||||
AutoReporter() : report_port_mask(SERIAL_ALL) {}
|
||||
#endif
|
||||
|
||||
inline void set_interval(uint8_t seconds, const uint8_t limit=60) {
|
||||
report_interval = _MIN(seconds, limit);
|
||||
@ -42,8 +42,8 @@ public:
|
||||
const millis_t ms = millis();
|
||||
if (ELAPSED(ms, next_report_ms)) {
|
||||
next_report_ms = ms + SEC_TO_MS(report_interval);
|
||||
PORT_REDIRECT(AR_PORT_INDEX);
|
||||
auto_report();
|
||||
TERN_(HAS_MULTI_SERIAL, PORT_REDIRECT(report_port_mask));
|
||||
Helper::report();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -3123,8 +3123,8 @@ void Temperature::tick() {
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_REPORT_TEMPERATURES)
|
||||
Temperature::AutoReportTemp Temperature::auto_reporter;
|
||||
void Temperature::AutoReportTemp::auto_report() {
|
||||
AutoReporter<Temperature::AutoReportTemp> Temperature::auto_reporter;
|
||||
void Temperature::AutoReportTemp::report() {
|
||||
print_heater_states(active_extruder);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
@ -798,8 +798,8 @@ class Temperature {
|
||||
#endif
|
||||
);
|
||||
#if ENABLED(AUTO_REPORT_TEMPERATURES)
|
||||
class AutoReportTemp : public AutoReporter<SERIAL_ALL> { void auto_report(); };
|
||||
static AutoReportTemp auto_reporter;
|
||||
struct AutoReportTemp { static void report(); };
|
||||
static AutoReporter<AutoReportTemp> auto_reporter;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1226,9 +1226,7 @@ void CardReader::fileHasFinished() {
|
||||
}
|
||||
|
||||
#if ENABLED(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(); }
|
||||
AutoReporter<CardReader::AutoReportSD> CardReader::auto_reporter;
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
|
@ -179,13 +179,8 @@ public:
|
||||
//
|
||||
// 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;
|
||||
struct AutoReportSD { static void report() { report_status(); } };
|
||||
static AutoReporter<AutoReportSD> auto_reporter;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user