Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to configure or disable PRINTCOUNTER save interval #20856

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b8a32cb
Printcounter Fix (issue #20785)
ConstantijnCrijnen Jan 21, 2021
671cfe6
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into PRR/Printco…
sjasonsmith Jan 24, 2021
7c675fa
Add pc.abort method
thinkyhead Jan 25, 2021
2e3ab97
fixups
thinkyhead Jan 25, 2021
977eaa0
comments
thinkyhead Jan 25, 2021
2bf7c36
fixups
thinkyhead Jan 25, 2021
a0a94d3
synchronize is not sensible here
thinkyhead Jan 25, 2021
75c65df
Apply SEC_TO_MS
thinkyhead Jan 25, 2021
f6d2847
Use original save interval
thinkyhead Jan 25, 2021
71a4294
Longer interval
thinkyhead Jan 25, 2021
fd903e4
better
thinkyhead Jan 25, 2021
211aeb8
sync instead of disabling
thinkyhead Jan 25, 2021
2ac4108
.stop needed for non-sd
thinkyhead Jan 25, 2021
9e61b9a
Sync on any write
thinkyhead Jan 25, 2021
f39e2d9
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/20856
thinkyhead Jan 25, 2021
02d267f
etc
thinkyhead Jan 25, 2021
07c701b
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/20856
thinkyhead Jan 25, 2021
a5571df
Merge branch 'Printcounter-Fix-(issue-#20785)' of https://github.com/…
ConstantijnCrijnen Jan 25, 2021
57a6665
Revert "Merge branch 'Printcounter-Fix-(issue-#20785)' of https://git…
ConstantijnCrijnen Jan 25, 2021
8533b62
Merge branch 'bugfix-2.0.x' into Printcounter-Fix-(issue-#20785)
thinkyhead Jan 26, 2021
47b7dcb
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/20856
thinkyhead Jan 26, 2021
051944f
Update Configuration.h
thinkyhead Jan 26, 2021
6b9482d
fix spacing
thinkyhead Jan 26, 2021
112568a
Get back to known good state
thinkyhead Jan 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,9 @@
* View the current statistics with M78.
*/
//#define PRINTCOUNTER
#if ENABLED(PRINTCOUNTER)
#define PRINTCOUNTER_SAVE_INTERVAL 1 // (seconds) EEPROM save interval during print
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
#endif

/**
* Password
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/HAL/LPC1768/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@
#elif EITHER(I2C_EEPROM, SPI_EEPROM)
#define USE_SHARED_EEPROM 1
#endif

// LPC1768 boards seem to lose steps when saving to EEPROM during print (issue #20785)
// TODO: Which other boards are incompatible?
#if defined(MCU_LPC1768) && PRINTCOUNTER_SAVE_INTERVAL > 0
#undef PRINTCOUNTER_SAVE_INTERVAL
#warning "PRINTCOUNTER_SAVE_INTERVAL causes print artifacts! Disabling auto-save."
#endif
8 changes: 6 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ void startOrResumeJob() {
card.endFilePrint(TERN_(SD_RESORT, true));
queue.clear();
quickstop_stepper();
print_job_timer.stop();
#if DISABLED(SD_ABORT_NO_COOLDOWN)
thermalManager.disable_all_heaters();
#endif
Expand All @@ -379,6 +378,9 @@ void startOrResumeJob() {
queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT));
#endif

planner.synchronize();
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
print_job_timer.abort(); // Wait for planner before calling!

TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
}

Expand Down Expand Up @@ -783,7 +785,9 @@ void minkill(const bool steppers_off/*=false*/) {
*/
void stop() {
thermalManager.disable_all_heaters(); // 'unpause' taken care of in here
print_job_timer.stop();

planner.synchronize();
print_job_timer.stop(); // Wait for planner before calling

#if ENABLED(PROBING_FANS_OFF)
if (thermalManager.fans_paused) thermalManager.set_fans_paused(false); // put things back the way they were
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
#define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V))
#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
#define _DO_15(W,C,A,V...) (_##W##_1(A) C _DO_14(W,C,V))
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
#define DO(W,C,V...) (_DO_N(W,C,NUM_ARGS(V),V))
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/gcode/control/M80_M81.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@
*/
void GcodeSuite::M81() {
thermalManager.disable_all_heaters();
print_job_timer.stop();
planner.finish_and_disable();

print_job_timer.stop(); // Wait for planner before calling

#if HAS_FAN
thermalManager.zero_fan_speeds();
#if ENABLED(PROBING_FANS_OFF)
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,6 @@ void MarlinUI::update() {
host_action_cancel();
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), DISMISS_STR));
print_job_timer.stop();
LCD_MESSAGEPGM(MSG_PRINT_ABORTED);
TERN_(HAS_LCD_MENU, return_to_status());
}
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/libs/stopwatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Stopwatch {
* @return true on success
*/
static bool stop();
static inline bool abort() { return stop(); } // Alias by default

/**
* @brief Pause the stopwatch
Expand Down
33 changes: 17 additions & 16 deletions Marlin/src/module/printcounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,13 @@ void PrintCounter::tick() {
update_next = now + updateInterval * 1000;
}

static uint32_t eeprom_next; // = 0
if (ELAPSED(now, eeprom_next)) {
eeprom_next = now + saveInterval * 1000;
saveStats();
}
#if PRINTCOUNTER_SAVE_INTERVAL > 0
static millis_t eeprom_next; // = 0
if (ELAPSED(now, eeprom_next)) {
eeprom_next = now + saveInterval * 1000;
saveStats();
}
#endif
}

// @Override
Expand All @@ -267,21 +269,20 @@ bool PrintCounter::start() {
return false;
}

// @Override
bool PrintCounter::stop() {
bool PrintCounter::_stop(const bool completed) {
TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("stop")));

if (super::stop()) {
data.finishedPrints++;
const bool did_stop = super::stop();
if (did_stop) {
data.printTime += deltaDuration();

if (duration() > data.longestPrint)
data.longestPrint = duration();

saveStats();
return true;
if (completed) {
data.finishedPrints++;
if (duration() > data.longestPrint)
data.longestPrint = duration();
}
}
else return false;
saveStats();
return did_stop;
}

// @Override
Expand Down
21 changes: 13 additions & 8 deletions Marlin/src/module/printcounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ class PrintCounter: public Stopwatch {
*/
static constexpr uint16_t updateInterval = 10;

/**
* @brief Interval in seconds between EEPROM saves
* @details This const value defines what will be the time between each
* EEPROM save cycle, the development team recommends to set this value
* no lower than 3600 secs (1 hour).
*/
static constexpr uint16_t saveInterval = 3600;
#if PRINTCOUNTER_SAVE_INTERVAL > 0
/**
* @brief Interval in seconds between EEPROM saves
* @details This const value defines what will be the time between each
* EEPROM save cycle, the development team recommends to set this value
* no lower than 3600 secs (1 hour).
*/
static constexpr uint16_t saveInterval = PRINTCOUNTER_SAVE_INTERVAL;
#endif

/**
* @brief Timestamp of the last call to deltaDuration()
Expand Down Expand Up @@ -176,7 +178,10 @@ class PrintCounter: public Stopwatch {
* The following functions are being overridden
*/
static bool start();
static bool stop();
static bool _stop(const bool completed);
static inline bool stop() { return _stop(true); }
static inline bool abort() { return _stop(false); }

static void reset();

#if HAS_SERVICE_INTERVALS
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,6 @@ void Temperature::disable_all_heaters() {

#endif


#if ENABLED(PROBING_HEATERS_OFF)

void Temperature::pause(const bool p) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/lpc1768/pins_MKS_SBASE.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#if defined(MKS_HAS_LPC1769) && NOT_TARGET(MCU_LPC1769)
#error "Oops! Make sure you have the LPC1769 environment selected in your IDE."
#elif NOT_TARGET(MKS_HAS_LPC1769, MCU_LPC1768)
#elif !defined(MKS_HAS_LPC1769) && NOT_TARGET(MCU_LPC1768)
#error "Oops! Make sure you have the LPC1768 environment selected in your IDE."
#endif

Expand Down