My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

stopwatch.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef STOPWATCH_H
  23. #define STOPWATCH_H
  24. #include "macros.h"
  25. // Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM)
  26. //#define DEBUG_STOPWATCH
  27. /**
  28. * @brief Stopwatch class
  29. * @details This class acts as a timer proving stopwatch functionality including
  30. * the ability to pause the running time counter.
  31. */
  32. class Stopwatch {
  33. private:
  34. enum State {
  35. STOPPED,
  36. RUNNING,
  37. PAUSED
  38. };
  39. Stopwatch::State state;
  40. millis_t accumulator;
  41. millis_t startTimestamp;
  42. millis_t stopTimestamp;
  43. public:
  44. /**
  45. * @brief Class constructor
  46. */
  47. Stopwatch();
  48. /**
  49. * @brief Stops the stopwatch
  50. * @details Stops the running timer, it will silently ignore the request if
  51. * no timer is currently running.
  52. * @return true is method was successful
  53. */
  54. bool stop();
  55. /**
  56. * @brief Pause the stopwatch
  57. * @details Pauses the running timer, it will silently ignore the request if
  58. * no timer is currently running.
  59. * @return true is method was successful
  60. */
  61. bool pause();
  62. /**
  63. * @brief Starts the stopwatch
  64. * @details Starts the timer, it will silently ignore the request if the
  65. * timer is already running.
  66. * @return true is method was successful
  67. */
  68. bool start();
  69. /**
  70. * @brief Resets the stopwatch
  71. * @details Resets all settings to their default values.
  72. */
  73. void reset();
  74. /**
  75. * @brief Checks if the timer is running
  76. * @details Returns true if the timer is currently running, false otherwise.
  77. * @return true if stopwatch is running
  78. */
  79. bool isRunning();
  80. /**
  81. * @brief Checks if the timer is paused
  82. * @details Returns true if the timer is currently paused, false otherwise.
  83. * @return true if stopwatch is paused
  84. */
  85. bool isPaused();
  86. /**
  87. * @brief Gets the running time
  88. * @details Returns the total number of seconds the timer has been running.
  89. * @return the delta since starting the stopwatch
  90. */
  91. millis_t duration();
  92. #if ENABLED(DEBUG_STOPWATCH)
  93. /**
  94. * @brief Prints a debug message
  95. * @details Prints a simple debug message "Stopwatch::function"
  96. */
  97. static void debug(const char func[]);
  98. #endif
  99. };
  100. #endif // STOPWATCH_H