My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stopwatch.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. enum StopwatchStatus {
  25. STPWTCH_STOPPED = 0x0,
  26. STPWTCH_RUNNING = 0x1,
  27. STPWTCH_PAUSED = 0x2
  28. };
  29. /**
  30. * @brief Stopwatch class
  31. * @details This class acts as a timer proving stopwatch functionality including
  32. * the ability to pause the running time counter.
  33. */
  34. class Stopwatch {
  35. private:
  36. StopwatchStatus status;
  37. uint16_t accumulator;
  38. uint32_t startTimestamp;
  39. uint32_t stopTimestamp;
  40. public:
  41. /**
  42. * @brief Class constructor
  43. */
  44. Stopwatch();
  45. /**
  46. * @brief Stops the stopwatch
  47. * @details Stops the running timer, it will silently ignore the request if
  48. * no timer is currently running.
  49. */
  50. void stop();
  51. /**
  52. * @brief Pauses the stopwatch
  53. * @details Pauses the running timer, it will silently ignore the request if
  54. * no timer is currently running.
  55. */
  56. void pause();
  57. /**
  58. * @brief Starts the stopwatch
  59. * @details Starts the timer, it will silently ignore the request if the
  60. * timer is already running.
  61. */
  62. void start();
  63. /**
  64. * @brief Resets the stopwatch
  65. * @details Resets all settings to their default values.
  66. */
  67. void reset();
  68. /**
  69. * @brief Checks if the timer is running
  70. * @details Returns true if the timer is currently running, false otherwise.
  71. * @return bool
  72. */
  73. bool isRunning();
  74. /**
  75. * @brief Checks if the timer is paused
  76. * @details Returns true if the timer is currently paused, false otherwise.
  77. * @return bool
  78. */
  79. bool isPaused();
  80. /**
  81. * @brief Gets the running time
  82. * @details Returns the total number of seconds the timer has been running.
  83. * @return uint16_t
  84. */
  85. uint16_t duration();
  86. };
  87. #endif //STOPWATCH_H