M77: Save statistics when timer is stopped
For remote hosts, when the timer is stopped, then also save the statistics. Slightly refactored save_statistics function by removing the parameters. The function parameters are always the same. Change in memory: Flash: -40 bytes SRAM: 0 bytes
This commit is contained in:
parent
a2e6cda37e
commit
331ceaf044
|
|
@ -268,9 +268,7 @@ extern bool homing_flag;
|
|||
extern uint32_t total_filament_used; // mm/100 or 10um
|
||||
|
||||
/// @brief Save print statistics to EEPROM
|
||||
/// @param _total_filament_used has unit mm/100 or 10um
|
||||
/// @param _total_print_time has unit minutes, for example 123 minutes
|
||||
void save_statistics(uint32_t _total_filament_used, uint32_t _total_print_time);
|
||||
void save_statistics();
|
||||
|
||||
extern int fan_edge_counter[2];
|
||||
extern int fan_speed[2];
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ static LongTimer crashDetTimer;
|
|||
|
||||
bool mesh_bed_leveling_flag = false;
|
||||
|
||||
uint32_t total_filament_used;
|
||||
uint32_t total_filament_used; // unit mm/100 or 10um
|
||||
HeatingStatus heating_status;
|
||||
int fan_edge_counter[2];
|
||||
int fan_speed[2];
|
||||
|
|
@ -5897,6 +5897,7 @@ Sigma_Exit:
|
|||
case 77:
|
||||
{
|
||||
print_job_timer.stop();
|
||||
save_statistics();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -9803,12 +9804,13 @@ void setPwmFrequency(uint8_t pin, int val)
|
|||
}
|
||||
#endif //FAST_PWM_FAN
|
||||
|
||||
void save_statistics(uint32_t _total_filament_used, uint32_t _total_print_time) {
|
||||
void save_statistics() {
|
||||
uint32_t _previous_filament = eeprom_init_default_dword((uint32_t *)EEPROM_FILAMENTUSED, 0); //_previous_filament unit: meter
|
||||
uint32_t _previous_time = eeprom_init_default_dword((uint32_t *)EEPROM_TOTALTIME, 0); //_previous_time unit: min
|
||||
|
||||
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));
|
||||
uint32_t time_minutes = print_job_timer.duration() / 60;
|
||||
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, _previous_time + time_minutes); // EEPROM_TOTALTIME unit: min
|
||||
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, _previous_filament + (total_filament_used / 1000));
|
||||
|
||||
print_job_timer.reset();
|
||||
total_filament_used = 0;
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ void get_command()
|
|||
int hours, minutes;
|
||||
minutes = t % 60;
|
||||
hours = t / 60;
|
||||
save_statistics(total_filament_used, t);
|
||||
save_statistics();
|
||||
sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes);
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLN(time);
|
||||
|
|
|
|||
|
|
@ -5579,9 +5579,7 @@ static void lcd_sd_updir()
|
|||
// continue stopping the print from the main loop after lcd_print_stop() is called
|
||||
void lcd_print_stop_finish()
|
||||
{
|
||||
// Convert the time from ms to minutes, divide by 60 * 1000
|
||||
uint32_t t = print_job_timer.duration() / 60;
|
||||
save_statistics(total_filament_used, t);
|
||||
save_statistics();
|
||||
|
||||
// lift Z
|
||||
raise_z(10);
|
||||
|
|
|
|||
Loading…
Reference in New Issue