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

🚧 PFW-1206:Inital M75-M78 #4458

Closed
wants to merge 1 commit into from
Closed
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
77 changes: 76 additions & 1 deletion Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5850,7 +5850,62 @@ SERIAL_PROTOCOLPGM("\n\n");
}
break;
}
/*!

/*!

### M75 - Start the print job timer <a href="https://reprap.org/wiki/G-code#M75:_Start_the_print_job_timer">M75: Start the print job timer</a>
*/
case 75: //M75 Start/Resume the print job timer
{
if ((!isPrintPaused) || (pause_time = 0)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think || here should be && otherwise pause_time is always 0

When I run M75 when resuming a paused print, then pause_time is never given a value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And ofcourse pause_time = 0 should be pause_time == 0 :)

starttime=_millis();
SERIAL_ECHOPGM("STATS starttime " ); //DEBUG Stats
SERIAL_ECHOLN(starttime); //DEBUG Stats
} else {
pause_time += (_millis() - start_pause_print);
SERIAL_ECHOPGM("STATS pause_time " ); //DEBUG Stats
SERIAL_ECHO(_millis()); //DEBUG Stats
SERIAL_ECHOPGM(" - "); //DEBUG Stats
SERIAL_ECHO(start_pause_print); //DEBUG Stats
SERIAL_ECHOPGM(" = "); //DEBUG Stats
SERIAL_ECHOLN(pause_time); //DEBUG Stats
}
break;
}
/*!
### M76 - Pause the print job timer <a href="https://reprap.org/wiki/G-code#M76:_Pause_the_print_job_timer">M76: Pause the print job timer</a>
*/
case 76: //M76 Pause the print job timer
{
pause_time = 0;
start_pause_print = _millis();
SERIAL_ECHOPGM("STATS start_pause_print "); //DEBUG Stats
SERIAL_ECHOLN(start_pause_print); //DEBUG Stats
break;
}
/*!
### M77 - Stop the print job timer <a href="https://reprap.org/wiki/G-code#M77:_Stop_the_print_job_timer">M77: Stop the print job timer</a>
*/
case 77: //M77 Stop the print job timer
{
uint32_t t = (_millis() - starttime - pause_time) / 60000;
pause_time = 0;
save_statistics(total_filament_used, t);
break;
}
/*!
### M78 - Show statistical information about the print jobs <a href="https://reprap.org/wiki/G-code#M78:_Show_statistical_information_about_the_print_jobs">M78: Show statistical information about the print jobs</a>
*/
case 78: //M78 Show statistical information about the print jobs
{
SERIAL_ECHOPGM("STATS ");
SERIAL_ECHO(eeprom_read_dword((uint32_t *)EEPROM_TOTALTIME));
SERIAL_ECHOPGM(" min ");
SERIAL_ECHO(eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED));
SERIAL_ECHOLNPGM(" cm.");
break;
}
/*!
### M104 - Set hotend temperature <a href="https://reprap.org/wiki/G-code#M104:_Set_Extruder_Temperature">M104: Set Extruder Temperature</a>
#### Usage

Expand Down Expand Up @@ -9633,6 +9688,26 @@ void save_statistics(uint32_t _total_filament_used, uint32_t _total_print_time)
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, _previous_time + _total_print_time); // EEPROM_TOTALTIME unit: min
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, _previous_filament + (_total_filament_used / 1000));

SERIAL_ECHOPGM("STATS total_print_time "); //DEBUG Stats
SERIAL_ECHO(_total_print_time); //DEBUG Stats
SERIAL_ECHOPGM(" previous_time "); //DEBUG Stats
SERIAL_ECHOLN(_previous_time); //DEBUG Stats

char stats[20];
// uint32_t t = (_millis() - starttime - pause_time) / 60000;
int hours, minutes;
hours = _total_print_time / 60;
minutes = _total_print_time % 60;
uint32_t cms = _total_filament_used / 1000;
sprintf_P(stats, PSTR("Stats:%ih%im %ucm"),hours, minutes, cms);
SERIAL_ECHO_START;
// SERIAL_ECHOPGM("Print stats: ");
// SERIAL_ECHO(_total_filament_used / 1000);
// SERIAL_ECHOPGM(" cm ");
SERIAL_ECHOLN(stats);
lcd_setstatus(stats);

pause_time = 0;
total_filament_used = 0;

if (MMU2::mmu2.Enabled()) {
Expand Down
2 changes: 1 addition & 1 deletion Firmware/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void CardReader::getStatus(bool arg_P)
SERIAL_PROTOCOL(sdpos);
SERIAL_PROTOCOL('/');
SERIAL_PROTOCOLLN(filesize);
uint16_t time = ( _millis() - starttime ) / 60000U;
uint32_t time = ( _millis() - starttime ) / 60000U;
SERIAL_PROTOCOL((int)(time / 60));
SERIAL_PROTOCOL(':');
SERIAL_PROTOCOLLN((int)(time % 60));
Expand Down
18 changes: 9 additions & 9 deletions Firmware/cmdqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,17 +657,17 @@ void get_command()
card.closefile();

SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED
char time[30];
// char time[30];
uint32_t t = (_millis() - starttime - pause_time) / 60000;
pause_time = 0;
int hours, minutes;
minutes = t % 60;
hours = t / 60;
// pause_time = 0;
// int hours, minutes;
// minutes = t % 60;
// hours = t / 60;
save_statistics(total_filament_used, t);
sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes);
SERIAL_ECHO_START;
SERIAL_ECHOLN(time);
lcd_setstatus(time);
// sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes);
// SERIAL_ECHO_START;
// SERIAL_ECHOLN(time);
// lcd_setstatus(time);
card.printingHasFinished();
card.checkautostart(true);

Expand Down
2 changes: 1 addition & 1 deletion Firmware/mmu2_reporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ struct _menu_tune_data_t
};

static_assert(sizeof(_menu_tune_data_t) == 18);
static_assert(sizeof(menu_data)>= sizeof(_menu_tune_data_t),"_menu_tune_data_t doesn't fit into menu_data");
static_assert(sizeof(menu_data) >= sizeof(_menu_tune_data_t),"_menu_tune_data_t doesn't fit into menu_data");

void tuneIdlerStallguardThresholdMenu() {
static constexpr _menu_tune_data_t * const _md = (_menu_tune_data_t*)&(menu_data[0]);
Expand Down
10 changes: 5 additions & 5 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ void lcdui_print_time(void)
print_t = print_tr;
suff = 'R';
} else
print_t = (_millis() - starttime) / 60000;
print_t = (_millis() - starttime - pause_time) / 60000;

if (feedmultiply != 100 && (print_t == print_tr || print_t == print_tc)) {
suff_doubt = '?';
Expand Down Expand Up @@ -2297,10 +2297,10 @@ void lcd_AutoLoadFilament() {
void lcd_menu_statistics()
{
lcd_timeoutToStatus.stop(); //infinite timeout
if (IS_SD_PRINTING)
if (printJobOngoing())
{
const float _met = ((float)total_filament_used) / (100000.f);
const uint32_t _t = (_millis() - starttime) / 1000ul;
const uint32_t _t = (_millis() - starttime - pause_time) / 1000ul;
const uint32_t _h = (_t / 60) / 60;
const uint8_t _m = (_t / 60) % 60;
const uint8_t _s = _t % 60;
Expand Down Expand Up @@ -5292,9 +5292,9 @@ static void lcd_main_menu()
if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_CALIBRATION), lcd_calibration_menu);
}

if (!usb_timer.running()) {
//if (!usb_timer.running()) {
MENU_ITEM_SUBMENU_P(_i("Statistics"), lcd_menu_statistics);////MSG_STATISTICS c=18
}
//}

#if defined(TMC2130) || defined(FILAMENT_SENSOR)
MENU_ITEM_SUBMENU_P(_i("Fail stats"), lcd_menu_fails_stats);////MSG_FAIL_STATS c=18
Expand Down
Loading