Prusa3d Marlin fork
stopwatch.h
1 
25 #pragma once
26 
27 #include "Timer.h"
28 #include "macros.h"
29 
35 class Stopwatch {
36  private:
37  enum State : char { STOPPED, RUNNING, PAUSED };
38 
39  static Stopwatch::State state;
40  static uint32_t accumulator;
41  static uint32_t startTimestamp;
42  static uint32_t stopTimestamp;
43 
44  public:
48  FORCE_INLINE static void init() { reset(); }
49 
56  static bool stop();
57  static bool abort() { return stop(); } // Alias by default
58 
65  static bool pause();
66 
73  static bool start();
74 
79  static void resume(const uint32_t with_time);
80 
85  static void reset();
86 
92  FORCE_INLINE static bool isRunning() { return state == RUNNING; }
93 
99  FORCE_INLINE static bool isPaused() { return state == PAUSED; }
100 
106  static uint32_t duration();
107 };
108 
109 extern Stopwatch print_job_timer;
Stopwatch class.
Definition: stopwatch.h:35
static FORCE_INLINE void init()
Initialize the stopwatch.
Definition: stopwatch.h:48
static FORCE_INLINE bool isPaused()
Check if the timer is paused.
Definition: stopwatch.h:99
static void reset()
Reset the stopwatch.
Definition: stopwatch.cpp:73
static bool start()
Start the stopwatch.
Definition: stopwatch.cpp:56
static FORCE_INLINE bool isRunning()
Check if the timer is running.
Definition: stopwatch.h:92
static void resume(const uint32_t with_time)
Resume the stopwatch.
Definition: stopwatch.cpp:68
static bool stop()
Stop the stopwatch.
Definition: stopwatch.cpp:38
static uint32_t duration()
Get the running time.
Definition: stopwatch.cpp:80
static bool pause()
Pause the stopwatch.
Definition: stopwatch.cpp:47