|
|
@ -41,6 +41,10 @@ Stopwatch print_job_timer; // Global Print Job Timer instance
|
|
|
|
#include "../libs/buzzer.h"
|
|
|
|
#include "../libs/buzzer.h"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if PRINTCOUNTER_SYNC
|
|
|
|
|
|
|
|
#include "../module/planner.h"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Service intervals
|
|
|
|
// Service intervals
|
|
|
|
#if HAS_SERVICE_INTERVALS
|
|
|
|
#if HAS_SERVICE_INTERVALS
|
|
|
|
#if SERVICE_INTERVAL_1 > 0
|
|
|
|
#if SERVICE_INTERVAL_1 > 0
|
|
|
@ -160,6 +164,8 @@ void PrintCounter::saveStats() {
|
|
|
|
// Refuses to save data if object is not loaded
|
|
|
|
// Refuses to save data if object is not loaded
|
|
|
|
if (!isLoaded()) return;
|
|
|
|
if (!isLoaded()) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TERN_(PRINTCOUNTER_SYNC, planner.synchronize());
|
|
|
|
|
|
|
|
|
|
|
|
// Saves the struct to EEPROM
|
|
|
|
// Saves the struct to EEPROM
|
|
|
|
persistentStore.access_start();
|
|
|
|
persistentStore.access_start();
|
|
|
|
persistentStore.write_data(address + sizeof(uint8_t), (uint8_t*)&data, sizeof(printStatistics));
|
|
|
|
persistentStore.write_data(address + sizeof(uint8_t), (uint8_t*)&data, sizeof(printStatistics));
|
|
|
@ -244,11 +250,13 @@ void PrintCounter::tick() {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t eeprom_next; // = 0
|
|
|
|
#if PRINTCOUNTER_SAVE_INTERVAL > 0
|
|
|
|
|
|
|
|
static millis_t eeprom_next; // = 0
|
|
|
|
if (ELAPSED(now, eeprom_next)) {
|
|
|
|
if (ELAPSED(now, eeprom_next)) {
|
|
|
|
eeprom_next = now + saveInterval * 1000;
|
|
|
|
eeprom_next = now + saveInterval;
|
|
|
|
saveStats();
|
|
|
|
saveStats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// @Override
|
|
|
@ -268,21 +276,20 @@ bool PrintCounter::start() {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
bool PrintCounter::_stop(const bool completed) {
|
|
|
|
bool PrintCounter::stop() {
|
|
|
|
|
|
|
|
TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("stop")));
|
|
|
|
TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("stop")));
|
|
|
|
|
|
|
|
|
|
|
|
if (super::stop()) {
|
|
|
|
const bool did_stop = super::stop();
|
|
|
|
data.finishedPrints++;
|
|
|
|
if (did_stop) {
|
|
|
|
data.printTime += deltaDuration();
|
|
|
|
data.printTime += deltaDuration();
|
|
|
|
|
|
|
|
if (completed) {
|
|
|
|
|
|
|
|
data.finishedPrints++;
|
|
|
|
if (duration() > data.longestPrint)
|
|
|
|
if (duration() > data.longestPrint)
|
|
|
|
data.longestPrint = duration();
|
|
|
|
data.longestPrint = duration();
|
|
|
|
|
|
|
|
|
|
|
|
saveStats();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
saveStats();
|
|
|
|
|
|
|
|
return did_stop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// @Override
|
|
|
|