Skip to content

Commit

Permalink
Add Set Statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
3d-gussner committed Nov 7, 2024
1 parent ef3527e commit 9d91381
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Firmware/ConfigurationStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ void Config_PrintSettings(uint8_t level)
#ifdef THERMAL_MODEL
thermal_model_report_settings();
#endif
printf_P(PSTR(
"%SStatistics:\n%S M78 S%lu T%lu\n"),
echomagic, echomagic, eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED), eeprom_read_dword((uint32_t *)EEPROM_TOTALTIME));
}
#endif

Expand Down
38 changes: 32 additions & 6 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5241,16 +5241,42 @@ void process_commands()
}

/*!
### 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>
### M78 - Get/set statistics <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>
#### Usage
M78 [ S | T ]
#### Parameters
- `S` - Set used filament length in cm
- `T` - Set total print time in minutes
*/
case 78:
{
// @todo useful for maintenance notifications
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.");
const char *_m_fil;
const char *_m_time;
uint32_t _cm = 0;
uint32_t _min = 0;

if (printJobOngoing()) {
_m_fil = _O(MSG_FILAMENT_USED);
_m_time = _O(MSG_PRINT_TIME);
_cm = ((uint32_t)total_filament_used) / (1000);
_min = (print_job_timer.duration() / 60);
} else {
if (code_seen('S')) {
eeprom_update_dword_notify((uint32_t *)EEPROM_FILAMENTUSED, code_value());
}
if (code_seen('T')) {
eeprom_update_dword_notify((uint32_t *)EEPROM_TOTALTIME, code_value());
}
_m_fil = _O(MSG_TOTAL_FILAMENT);
_m_time = _O(MSG_TOTAL_PRINT_TIME);
_cm = eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED);
_min = eeprom_read_dword((uint32_t *)EEPROM_TOTALTIME);
}
printf_P(_N("%S:%lu cm\n%S:%lu min\n"),_m_fil,_cm,_m_time,_min);
break;
}

Expand Down

0 comments on commit 9d91381

Please sign in to comment.