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

Allow stopwatch and printcounter to go over 18:12:15 #4287

Merged
merged 6 commits into from
Jul 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 14 additions & 12 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,14 +1169,6 @@ inline void get_serial_commands() {
) {
if (card_eof) {
SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
print_job_timer.stop();
char time[30];
millis_t t = print_job_timer.duration();
int hours = t / 60 / 60, minutes = (t / 60) % 60;
sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes);
SERIAL_ECHO_START;
SERIAL_ECHOLN(time);
lcd_setstatus(time, true);
card.printingHasFinished();
card.checkautostart(true);
}
Expand Down Expand Up @@ -3949,12 +3941,22 @@ inline void gcode_M17() {
*/
inline void gcode_M31() {
millis_t t = print_job_timer.duration();
int min = t / 60, sec = t % 60;
char time[30];
sprintf_P(time, PSTR("%i min, %i sec"), min, sec);
int d = int(t / 60 / 60 / 24),
h = int(t / 60 / 60) % 60,
m = int(t / 60) % 60,
s = int(t % 60);
char time[18]; // 123456789012345678
if (d)
sprintf_P(time, PSTR("%id %ih %im %is"), d, h, m, s); // 99d 23h 59m 59s
else
sprintf_P(time, PSTR("%ih %im %is"), h, m, s); // 23h 59m 59s

lcd_setstatus(time);

SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_PRINT_TIME " ");
SERIAL_ECHOLN(time);
lcd_setstatus(time);

thermalManager.autotempShutdown();
}

Expand Down
6 changes: 3 additions & 3 deletions Marlin/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,19 +602,19 @@ void CardReader::updir() {

void CardReader::printingHasFinished() {
stepper.synchronize();
file.close();
if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure.
file.close();
file_subcall_ctr--;
openFile(proc_filenames[file_subcall_ctr], true, true);
setIndex(filespos[file_subcall_ctr]);
startFileprint();
}
else {
file.close();
sdprinting = false;
if (SD_FINISHED_STEPPERRELEASE)
enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
thermalManager.autotempShutdown();
print_job_timer.stop();
enqueue_and_echo_commands_P(PSTR("M31"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/dogm_lcd_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static void lcd_implementation_status_screen() {
}

u8g.setPrintPos(80,48);
uint16_t time = print_job_timer.duration() / 60;
millis_t time = print_job_timer.duration() / 60;
if (time != 0) {
lcd_print(itostr2(time/60));
lcd_print(':');
Expand Down
12 changes: 6 additions & 6 deletions Marlin/language_cz.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@
#define MSG_INFO_BAUDRATE "Rychlost"
#define MSG_INFO_PROTOCOL "Protokol"
#if LCD_WIDTH > 19
#define MSG_INFO_PRINT_COUNT "Pocet tisku "
#define MSG_INFO_FINISHED_PRINTS "Dokonceno "
#define MSG_INFO_PRINT_TIME "Celkovy cas "
#define MSG_INFO_PRINT_COUNT "Pocet tisku"
#define MSG_INFO_COMPLETED_PRINTS "Dokonceno "
#define MSG_INFO_PRINT_TIME "Celkovy cas"
#else
#define MSG_INFO_PRINT_COUNT "Tisky "
#define MSG_INFO_FINISHED_PRINTS "Hotovo "
#define MSG_INFO_PRINT_TIME "Cas "
#define MSG_INFO_PRINT_COUNT "Tisky "
#define MSG_INFO_COMPLETED_PRINTS "Hotovo"
#define MSG_INFO_PRINT_TIME "Cas "
#endif
#define MSG_INFO_MIN_TEMP "Teplota min"
#define MSG_INFO_MAX_TEMP "Teplota max"
Expand Down
13 changes: 10 additions & 3 deletions Marlin/language_de.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,16 @@
#define MSG_INFO_EXTRUDERS "Extruders"
#define MSG_INFO_BAUDRATE "Baud"
#define MSG_INFO_PROTOCOL "Protokol"
#define MSG_INFO_TOTAL_PRINTS "Gesamte Drucke"
#define MSG_INFO_FINISHED_PRINTS "Beendete Drucke"
#define MSG_INFO_PRINT_TIME "Gesamte Druckzeit"

#if LCD_WIDTH > 19
#define MSG_INFO_TOTAL_PRINTS "Gesamte Drucke "
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that MSG_INFO_PRINT_COUNT is right.

#define MSG_INFO_COMPLETED_PRINTS "Beendete Drucke "
#define MSG_INFO_PRINT_TIME "Gesamte Druckzeit"
#else
#define MSG_INFO_PRINT_COUNT "Prints "
#define MSG_INFO_COMPLETED_PRINTS "Completed"
#define MSG_INFO_PRINT_TIME "Duration "
#endif
#define MSG_INFO_MIN_TEMP "Min Temp"
#define MSG_INFO_MAX_TEMP "Max Temp"
#define MSG_INFO_PSU "Stromversorgung"
Expand Down
63 changes: 36 additions & 27 deletions Marlin/language_el.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
#define MSG_DELTA_CALIBRATE_Y "Βαθμονόμηση Y"
#define MSG_DELTA_CALIBRATE_Z "Βαθμονόμηση Z"
#define MSG_DELTA_CALIBRATE_CENTER "Βαθμονόμηση κέντρου"

#define MSG_INFO_MENU "About Printer"
#define MSG_INFO_PRINTER_MENU "Printer Info"
#define MSG_INFO_STATS_MENU "Printer Stats"
Expand All @@ -206,42 +207,50 @@
#define MSG_INFO_EXTRUDERS "Extruders"
#define MSG_INFO_BAUDRATE "Baud"
#define MSG_INFO_PROTOCOL "Protocol"
#define MSG_INFO_TOTAL_PRINTS "Total Prints"
#define MSG_INFO_FINISHED_PRINTS "Finished Prints"
#define MSG_INFO_PRINT_TIME "Total Print Time"

#if LCD_WIDTH > 19
#define MSG_INFO_PRINT_COUNT "Print Count"
#define MSG_INFO_COMPLETED_PRINTS "Completed "
#define MSG_INFO_PRINT_TIME "Total Time "
#else
#define MSG_INFO_PRINT_COUNT "Prints "
#define MSG_INFO_COMPLETED_PRINTS "Completed"
#define MSG_INFO_PRINT_TIME "Duration "
#endif
#define MSG_INFO_MIN_TEMP "Min Temp"
#define MSG_INFO_MAX_TEMP "Max Temp"
#define MSG_INFO_PSU "Power Supply"

#define MSG_FILAMENT_CHANGE_HEADER "CHANGE FILAMENT"
#define MSG_FILAMENT_CHANGE_OPTION_EXTRUDE "Extrude more"
#define MSG_FILAMENT_CHANGE_OPTION_RESUME "Resume print"

#if LCD_HEIGHT >= 4
#define MSG_FILAMENT_CHANGE_INIT_1 "Wait for start"
#define MSG_FILAMENT_CHANGE_INIT_2 "of the filament"
#define MSG_FILAMENT_CHANGE_INIT_3 "change"
#define MSG_FILAMENT_CHANGE_UNLOAD_1 "Wait for"
#define MSG_FILAMENT_CHANGE_UNLOAD_2 "filament unload"
#define MSG_FILAMENT_CHANGE_UNLOAD_3 ""
#define MSG_FILAMENT_CHANGE_INSERT_1 "Insert filament"
#define MSG_FILAMENT_CHANGE_INSERT_2 "and press button"
#define MSG_FILAMENT_CHANGE_INSERT_3 "to continue..."
#define MSG_FILAMENT_CHANGE_LOAD_1 "Wait for"
#define MSG_FILAMENT_CHANGE_LOAD_2 "filament load"
#define MSG_FILAMENT_CHANGE_LOAD_3 ""
#define MSG_FILAMENT_CHANGE_EXTRUDE_1 "Wait for"
#define MSG_FILAMENT_CHANGE_EXTRUDE_2 "filament extrude"
#define MSG_FILAMENT_CHANGE_EXTRUDE_3 ""
#define MSG_FILAMENT_CHANGE_RESUME_1 "Wait for print"
#define MSG_FILAMENT_CHANGE_RESUME_2 "to resume"
#define MSG_FILAMENT_CHANGE_RESUME_3 ""
#define MSG_FILAMENT_CHANGE_INIT_1 "Wait for start"
#define MSG_FILAMENT_CHANGE_INIT_2 "of the filament"
#define MSG_FILAMENT_CHANGE_INIT_3 "change"
#define MSG_FILAMENT_CHANGE_UNLOAD_1 "Wait for"
#define MSG_FILAMENT_CHANGE_UNLOAD_2 "filament unload"
#define MSG_FILAMENT_CHANGE_UNLOAD_3 ""
#define MSG_FILAMENT_CHANGE_INSERT_1 "Insert filament"
#define MSG_FILAMENT_CHANGE_INSERT_2 "and press button"
#define MSG_FILAMENT_CHANGE_INSERT_3 "to continue..."
#define MSG_FILAMENT_CHANGE_LOAD_1 "Wait for"
#define MSG_FILAMENT_CHANGE_LOAD_2 "filament load"
#define MSG_FILAMENT_CHANGE_LOAD_3 ""
#define MSG_FILAMENT_CHANGE_EXTRUDE_1 "Wait for"
#define MSG_FILAMENT_CHANGE_EXTRUDE_2 "filament extrude"
#define MSG_FILAMENT_CHANGE_EXTRUDE_3 ""
#define MSG_FILAMENT_CHANGE_RESUME_1 "Wait for print"
#define MSG_FILAMENT_CHANGE_RESUME_2 "to resume"
#define MSG_FILAMENT_CHANGE_RESUME_3 ""
#else // LCD_HEIGHT < 4
#define MSG_FILAMENT_CHANGE_INIT_1 "Please wait..."
#define MSG_FILAMENT_CHANGE_UNLOAD_1 "Ejecting..."
#define MSG_FILAMENT_CHANGE_INSERT_1 "Insert and Click"
#define MSG_FILAMENT_CHANGE_LOAD_1 "Loading..."
#define MSG_FILAMENT_CHANGE_EXTRUDE_1 "Extruding..."
#define MSG_FILAMENT_CHANGE_RESUME_1 "Resuming..."
#define MSG_FILAMENT_CHANGE_INIT_1 "Please wait..."
#define MSG_FILAMENT_CHANGE_UNLOAD_1 "Ejecting..."
#define MSG_FILAMENT_CHANGE_INSERT_1 "Insert and Click"
#define MSG_FILAMENT_CHANGE_LOAD_1 "Loading..."
#define MSG_FILAMENT_CHANGE_EXTRUDE_1 "Extruding..."
#define MSG_FILAMENT_CHANGE_RESUME_1 "Resuming..."
#endif

#endif // LANGUAGE_EL_H
19 changes: 13 additions & 6 deletions Marlin/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,18 @@
#ifndef MSG_PLEASE_RESET
#define MSG_PLEASE_RESET "Please reset"
#endif
#ifndef MSG_END_DAY
#define MSG_END_DAY "days"
#endif
#ifndef MSG_END_HOUR
#define MSG_END_HOUR "hours"
#endif
#ifndef MSG_END_MINUTE
#define MSG_END_MINUTE "minutes"
#endif
#ifndef MSG_PRINT_TIME
#define MSG_PRINT_TIME "Print time"
#endif
#ifndef MSG_HEATING
#define MSG_HEATING "Heating..."
#endif
Expand Down Expand Up @@ -521,6 +527,7 @@
#ifndef MSG_DELTA_CALIBRATE_CENTER
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center"
#endif

#ifndef MSG_INFO_MENU
#define MSG_INFO_MENU "About Printer"
#endif
Expand Down Expand Up @@ -548,20 +555,20 @@

#if LCD_WIDTH > 19
#ifndef MSG_INFO_PRINT_COUNT
#define MSG_INFO_PRINT_COUNT "Print Count "
#define MSG_INFO_PRINT_COUNT "Print Count"
#endif
#ifndef MSG_INFO_FINISHED_PRINTS
#define MSG_INFO_FINISHED_PRINTS "Finished "
#ifndef MSG_INFO_COMPLETED_PRINTS
#define MSG_INFO_COMPLETED_PRINTS "Completed "
#endif
#ifndef MSG_INFO_PRINT_TIME
#define MSG_INFO_PRINT_TIME "Total Time "
#define MSG_INFO_PRINT_TIME "Total Time "
#endif
#else
#ifndef MSG_INFO_PRINT_COUNT
#define MSG_INFO_PRINT_COUNT "Prints "
#endif
#ifndef MSG_INFO_FINISHED_PRINTS
#define MSG_INFO_FINISHED_PRINTS "Finished "
#ifndef MSG_INFO_COMPLETED_PRINTS
#define MSG_INFO_COMPLETED_PRINTS "Completed"
#endif
#ifndef MSG_INFO_PRINT_TIME
#define MSG_INFO_PRINT_TIME "Duration "
Expand Down
17 changes: 8 additions & 9 deletions Marlin/printcounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ PrintCounter::PrintCounter(): super() {
this->loadStats();
}

uint16_t PrintCounter::deltaDuration() {
millis_t PrintCounter::deltaDuration() {
#if ENABLED(DEBUG_PRINTCOUNTER)
PrintCounter::debug(PSTR("deltaDuration"));
#endif

uint16_t tmp = this->lastDuration;
millis_t tmp = this->lastDuration;
this->lastDuration = this->duration();
return this->lastDuration - tmp;
}
Expand Down Expand Up @@ -88,12 +88,12 @@ void PrintCounter::showStats() {
SERIAL_ECHO(this->data.totalPrints - this->data.finishedPrints
- ((this->isRunning() || this->isPaused()) ? 1 : 0)); // Removes 1 from failures with an active counter

uint32_t t = this->data.printTime / 60;
millis_t t = this->data.printTime / 60; // minutes from seconds
SERIAL_ECHOPGM(", Total print time: ");
SERIAL_ECHO(t / 60);
SERIAL_ECHO(t / 60); // hours

SERIAL_ECHOPGM("h ");
SERIAL_ECHO(t % 60);
SERIAL_ECHO(t % 60); // minutes

SERIAL_ECHOPGM("min");

Expand All @@ -110,10 +110,10 @@ void PrintCounter::showStats() {
void PrintCounter::tick() {
if (!this->isRunning()) return;

static uint32_t update_before = millis(),
static millis_t update_before = millis(),
eeprom_before = millis();

uint32_t now = millis();
millis_t now = millis();

// Trying to get the amount of calculations down to the bare min
const static uint16_t i = this->updateInterval * 1000;
Expand All @@ -128,8 +128,7 @@ void PrintCounter::tick() {
}

// Trying to get the amount of calculations down to the bare min
const static uint32_t j = this->saveInterval * 1000;

const static millis_t j = this->saveInterval * 1000;
if (now - eeprom_before >= j) {
eeprom_before = now;
this->saveStats();
Expand Down
8 changes: 4 additions & 4 deletions Marlin/printcounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct printStatistics { // 13 bytes
//const uint8_t magic; // Magic header, it will always be 0x16
uint16_t totalPrints; // Number of prints
uint16_t finishedPrints; // Number of complete prints
uint32_t printTime; // Total printing time
uint32_t longestPrint; // Longest print job - not in use
millis_t printTime; // Total printing time
millis_t longestPrint; // Longest print job - not in use
};

class PrintCounter: public Stopwatch {
Expand Down Expand Up @@ -74,7 +74,7 @@ class PrintCounter: public Stopwatch {
* @details Stores the timestamp of the last deltaDuration(), this is
* required due to the updateInterval cycle.
*/
uint16_t lastDuration;
millis_t lastDuration;

/**
* @brief Stats were loaded from EERPROM
Expand All @@ -90,7 +90,7 @@ class PrintCounter: public Stopwatch {
* used internally for print statistics accounting is not intended to be a
* user callable function.
*/
uint16_t deltaDuration();
millis_t deltaDuration();

public:
/**
Expand Down
4 changes: 2 additions & 2 deletions Marlin/stopwatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ bool Stopwatch::isPaused() {
return (this->state == STOPWATCH_PAUSED) ? true : false;
}

uint16_t Stopwatch::duration() {
millis_t Stopwatch::duration() {
return (((this->isRunning()) ? millis() : this->stopTimestamp)
- this->startTimestamp) / 1000 + this->accumulator;
- this->startTimestamp) / 1000UL + this->accumulator;
}

#if ENABLED(DEBUG_STOPWATCH)
Expand Down
8 changes: 4 additions & 4 deletions Marlin/stopwatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ enum StopwatchState {
class Stopwatch {
private:
StopwatchState state;
uint16_t accumulator;
uint32_t startTimestamp;
uint32_t stopTimestamp;
millis_t accumulator;
millis_t startTimestamp;
millis_t stopTimestamp;

public:
/**
Expand Down Expand Up @@ -101,7 +101,7 @@ class Stopwatch {
* @details Returns the total number of seconds the timer has been running.
* @return the delta since starting the stopwatch
*/
uint16_t duration();
millis_t duration();

#if ENABLED(DEBUG_STOPWATCH)

Expand Down
12 changes: 6 additions & 6 deletions Marlin/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,13 +1967,13 @@ void kill_screen(const char* lcd_msg) {
print_job_counter.loadStats();
printStatistics stats = print_job_counter.getStats();

char printTime[6];
sprintf(printTime, "%02d:%02d", int(stats.printTime / 3600), int(stats.printTime / 60) % 60);
char timeString[8];
sprintf_P(timeString, PSTR("%i:%02i"), int(stats.printTime / 60 / 60), int(stats.printTime / 60) % 60);

START_SCREEN();
STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints)); // Print Count : 999
STATIC_ITEM(MSG_INFO_FINISHED_PRINTS ": ", false, false, itostr3left(stats.finishedPrints)); // Finished : 666
STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", false, false, printTime); // Total Time : 12:34
START_SCREEN(); // 12345678901234567890
STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints)); // Print Count: 999
STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, itostr3left(stats.finishedPrints)); // Completed : 666
STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", false, false, timeString); // Total Time : 123:45
END_SCREEN();
}
#endif // PRINTCOUNTER
Expand Down