Merge pull request #1176 from mkbel/fix_print_time_overflow

Fix print time overflow
This commit is contained in:
PavelSindler 2018-09-19 18:29:12 +02:00 committed by GitHub
commit e5ede602b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,5 @@
//! @file
#include "temperature.h" #include "temperature.h"
#include "ultralcd.h" #include "ultralcd.h"
#include "fsensor.h" #include "fsensor.h"
@ -2462,28 +2464,45 @@ static void lcd_LoadFilament()
} }
} }
//! @brief Show filament used a print time
//!
//! If printing current print statistics are shown
//!
//! @code{.unparsed}
//! |01234567890123456789|
//! |Filament used: |
//! | 00.00m |
//! |Print time: |
//! | 00h 00m 00s |
//! ----------------------
//! @endcode
//!
//! If not printing, total statistics are shown
//!
//! @code{.unparsed}
//! |01234567890123456789|
//! |Total filament : |
//! | 000.00 m |
//! |Total print time : |
//! | 00d :00h :00 m |
//! ----------------------
//! @endcode
void lcd_menu_statistics() void lcd_menu_statistics()
{ {
if (IS_SD_PRINTING) if (IS_SD_PRINTING)
{ {
float _met = ((float)total_filament_used) / (100000.f); const float _met = ((float)total_filament_used) / (100000.f);
int _cm = (total_filament_used - (_met * 100000)) / 10; const uint32_t _t = (millis() - starttime) / 1000ul;
int _t = (millis() - starttime) / 1000; const int _h = _t / 3600;
int _h = _t / 3600; const int _m = (_t - (_h * 3600ul)) / 60ul;
int _m = (_t - (_h * 3600)) / 60; const int _s = _t - ((_h * 3600ul) + (_m * 60ul));
int _s = _t - ((_h * 3600) + (_m * 60));
//|01234567890123456789|
//|Filament used: |
//| 000m 00.000cm |
//|Print time: |
//| 00h 00m 00s |
//----------------------
lcd_printf_P(_N( lcd_printf_P(_N(
ESC_2J ESC_2J
"%S:" "%S:"
ESC_H(6,1) "%8.2fm \n" ESC_H(6,1) "%8.2fm \n"
"%S :" "%S :"
ESC_H(8,3) "%2dh %02dm %02d" ESC_H(8,3) "%2dh %02dm %02ds"
), ),
_i("Filament used"), _i("Filament used"),
_met, _met,
@ -2504,12 +2523,7 @@ void lcd_menu_statistics()
_days = _time / 1440; _days = _time / 1440;
_hours = (_time - (_days * 1440)) / 60; _hours = (_time - (_days * 1440)) / 60;
_minutes = _time - ((_days * 1440) + (_hours * 60)); _minutes = _time - ((_days * 1440) + (_hours * 60));
//|01234567890123456789|
//|Total filament : |
//| 000.00 m |
//|Total print time : |
//| 00d :00h :00 m |
//----------------------
lcd_printf_P(_N( lcd_printf_P(_N(
ESC_2J ESC_2J
"%S :" "%S :"