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

Add Set parameter in M78 Statistics gcode #4809

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
3d-gussner marked this conversation as resolved.
Show resolved Hide resolved
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);
3d-gussner marked this conversation as resolved.
Show resolved Hide resolved
_min = (print_job_timer.duration() / 60);
3d-gussner marked this conversation as resolved.
Show resolved Hide resolved
} else {
if (code_seen('S')) {
eeprom_update_dword_notify((uint32_t *)EEPROM_FILAMENTUSED, code_value());
3d-gussner marked this conversation as resolved.
Show resolved Hide resolved
}
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
Loading