From 9d913810137ed31d9bef92e8cae9d8dde1c6b2ae Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 7 Nov 2024 15:13:05 +0100 Subject: [PATCH 1/3] Add Set Statistics --- Firmware/ConfigurationStore.cpp | 3 +++ Firmware/Marlin_main.cpp | 38 +++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 5826b0ae4b..b72cc463cb 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -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 diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 2009923eea..95fb93f730 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5241,16 +5241,42 @@ void process_commands() } /*! - ### M78 - Show statistical information about the print jobs M78: Show statistical information about the print jobs + ### M78 - Get/set statistics M78: Show statistical information about the print jobs + + #### 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; } From f93de6c662618707d82ed1ed6d7ee62077c9965e Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 11 Nov 2024 15:47:38 +0100 Subject: [PATCH 2/3] EEPROM_FILAMENTUSED is in centimeter and not meter Fix few things --- Firmware/Marlin_main.cpp | 7 +++---- Firmware/eeprom.h | 2 +- Firmware/ultralcd.cpp | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 95fb93f730..ad9860012b 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5253,7 +5253,6 @@ void process_commands() */ case 78: { - // @todo useful for maintenance notifications const char *_m_fil; const char *_m_time; uint32_t _cm = 0; @@ -5262,8 +5261,8 @@ void process_commands() 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); + _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()); @@ -9179,7 +9178,7 @@ void setPwmFrequency(uint8_t pin, int val) #endif //FAST_PWM_FAN void save_statistics() { - uint32_t _previous_filament = eeprom_init_default_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); //_previous_filament unit: meter + uint32_t _previous_filament = eeprom_init_default_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); //_previous_filament unit: centimeter uint32_t _previous_time = eeprom_init_default_dword((uint32_t *)EEPROM_TOTALTIME, 0); //_previous_time unit: min uint32_t time_minutes = print_job_timer.duration() / 60; diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 6e65716e16..3adc221e2c 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -108,7 +108,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | fah 250 | ^ | needs XYZ calibration | ^ | ^ | ^ | ^ | ^ | 00h 0 | ^ | Unknown (legacy) | ^ | ^ | 0x0FF5 4085 | uint16 | _EEPROM_FREE_NR12_ | ??? | ff ffh 65535 | _Free EEPROM space_ | _free space_ | D3 Ax0ff5 C2 -| 0x0FF1 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in meters | ??? | D3 Ax0ff1 C4 +| 0x0FF1 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in cenitmeters | ??? | D3 Ax0ff1 C4 | 0x0FED 4077 | uint32 | EEPROM_TOTALTIME | ??? | 00 00 00 00h 0 __S/P__| Total print time in minutes | ??? | D3 Ax0fed C4 | 0x0FE5 4069 | float | EEPROM_BED_CALIBRATION_CENTER | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fe5 C8 | 0x0FDD 4061 | float | EEPROM_BED_CALIBRATION_VEC_X | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fdd C8 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index f9a2b4fcce..86127c4bed 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2367,7 +2367,7 @@ void lcd_menu_statistics() } else { - uint32_t _filament = eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED); // in meters + uint32_t _filament = eeprom_read_dword((uint32_t *)EEPROM_FILAMENTUSED); // in centimeters uint32_t _time = eeprom_read_dword((uint32_t *)EEPROM_TOTALTIME); // in minutes uint8_t _hours, _minutes; uint32_t _days; From 1cf0f8c3afbffd402649a252603b48e26e04a3e6 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 14 Nov 2024 07:55:44 +0100 Subject: [PATCH 3/3] Fix typo --- Firmware/eeprom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 3adc221e2c..e2775d1574 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -108,7 +108,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | fah 250 | ^ | needs XYZ calibration | ^ | ^ | ^ | ^ | ^ | 00h 0 | ^ | Unknown (legacy) | ^ | ^ | 0x0FF5 4085 | uint16 | _EEPROM_FREE_NR12_ | ??? | ff ffh 65535 | _Free EEPROM space_ | _free space_ | D3 Ax0ff5 C2 -| 0x0FF1 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in cenitmeters | ??? | D3 Ax0ff1 C4 +| 0x0FF1 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in centimeters | ??? | D3 Ax0ff1 C4 | 0x0FED 4077 | uint32 | EEPROM_TOTALTIME | ??? | 00 00 00 00h 0 __S/P__| Total print time in minutes | ??? | D3 Ax0fed C4 | 0x0FE5 4069 | float | EEPROM_BED_CALIBRATION_CENTER | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fe5 C8 | 0x0FDD 4061 | float | EEPROM_BED_CALIBRATION_VEC_X | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fdd C8