remove one global variable

This commit is contained in:
Guðni Már Gilbert 2023-01-29 10:13:13 +00:00 committed by DRracer
parent 768319f1e7
commit ee39cb4e90
4 changed files with 13 additions and 23 deletions

View File

@ -306,8 +306,9 @@ extern float retract_recover_length_swap;
extern uint8_t host_keepalive_interval; extern uint8_t host_keepalive_interval;
extern unsigned long starttime; extern uint32_t starttime; // milliseconds
extern unsigned long stoptime; extern uint32_t pause_time; // milliseconds
extern uint32_t start_pause_print; // milliseconds
extern ShortTimer usb_timer; extern ShortTimer usb_timer;
extern bool processing_tcode; extern bool processing_tcode;
extern bool homing_flag; extern bool homing_flag;
@ -328,11 +329,6 @@ extern int fan_speed[2];
// We may even remove the references to it wherever possible in the future // We may even remove the references to it wherever possible in the future
#define active_extruder 0 #define active_extruder 0
//Long pause
extern unsigned long pause_time;
extern unsigned long start_pause_print;
extern unsigned long t_fan_rising_edge;
extern bool mesh_bed_leveling_flag; extern bool mesh_bed_leveling_flag;
// save/restore printing // save/restore printing

View File

@ -173,9 +173,7 @@ int extrudemultiply=100; //100->1 200->2
bool homing_flag = false; bool homing_flag = false;
unsigned long pause_time = 0; static uint32_t t_fan_rising_edge;
unsigned long start_pause_print = _millis();
unsigned long t_fan_rising_edge = _millis();
LongTimer safetyTimer; LongTimer safetyTimer;
static LongTimer crashDetTimer; static LongTimer crashDetTimer;
@ -306,8 +304,9 @@ unsigned long max_inactive_time = 0;
static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l; static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
static unsigned long safetytimer_inactive_time = DEFAULT_SAFETYTIMER_TIME_MINS*60*1000ul; static unsigned long safetytimer_inactive_time = DEFAULT_SAFETYTIMER_TIME_MINS*60*1000ul;
unsigned long starttime=0; uint32_t starttime;
unsigned long stoptime=0; uint32_t pause_time;
uint32_t start_pause_print;
ShortTimer usb_timer; ShortTimer usb_timer;
bool Stopped=false; bool Stopped=false;
@ -5490,12 +5489,11 @@ void process_commands()
*/ */
case 31: //M31 take time since the start of the SD print or an M109 command case 31: //M31 take time since the start of the SD print or an M109 command
{ {
stoptime=_millis();
char time[30]; char time[30];
unsigned long t=(stoptime-starttime)/1000; uint32_t t = (_millis() - starttime) / 1000;
int sec,min; int16_t sec, min;
min=t/60; min = t / 60;
sec=t%60; sec = t % 60;
sprintf_P(time, PSTR("%i min, %i sec"), min, sec); sprintf_P(time, PSTR("%i min, %i sec"), min, sec);
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLN(time); SERIAL_ECHOLN(time);

View File

@ -638,9 +638,8 @@ void get_command()
card.closefile(); card.closefile();
SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED
stoptime=_millis();
char time[30]; char time[30];
uint32_t t = (stoptime-starttime-pause_time) / 60000; uint32_t t = (_millis() - starttime - pause_time) / 60000;
pause_time = 0; pause_time = 0;
int hours, minutes; int hours, minutes;
minutes = t % 60; minutes = t % 60;

View File

@ -5670,11 +5670,8 @@ static void lcd_sd_updir()
// continue stopping the print from the main loop after lcd_print_stop() is called // continue stopping the print from the main loop after lcd_print_stop() is called
void lcd_print_stop_finish() void lcd_print_stop_finish()
{ {
// save printing time
stoptime = _millis();
// Convert the time from ms to minutes, divide by 60 * 1000 // Convert the time from ms to minutes, divide by 60 * 1000
uint32_t t = (stoptime - starttime - pause_time) / 60000; uint32_t t = (_millis() - starttime - pause_time) / 60000;
save_statistics(total_filament_used, t); save_statistics(total_filament_used, t);
// lift Z // lift Z