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.

printcounter.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 PRINTCOUNTER_H
  23. #define PRINTCOUNTER_H
  24. #include "macros.h"
  25. #include "stopwatch.h"
  26. // Print debug messages with M111 S2
  27. #define DEBUG_PRINTCOUNTER
  28. struct printStatistics { // 12 bytes
  29. uint16_t successPrints; // Total number of prints
  30. uint16_t failedPrints; // Total number of aborted prints - not in use
  31. uint32_t printTime; // Total time printing
  32. uint32_t longestPrint; // Longest print job - not in use
  33. };
  34. class PrintCounter: public Stopwatch {
  35. private:
  36. typedef Stopwatch super;
  37. printStatistics data;
  38. /**
  39. * @brief EEPROM address
  40. * @details Defines the start offset address where the data is stored.
  41. */
  42. const uint16_t addr = 60;
  43. /**
  44. * @brief Interval in seconds between counter updates
  45. * @details This const value defines what will be the time between each
  46. * accumulator update. This is different from the EEPROM save interval
  47. * which is user defined at the Configuration.h file.
  48. */
  49. const uint16_t updateInterval = 2;
  50. /**
  51. * @brief Interval in seconds between EEPROM saves
  52. * @details This const value defines what will be the time between each
  53. * EEPROM save cycle, the development team recommends to set this value
  54. * no lower than 3600 secs (1 hour).
  55. */
  56. const uint16_t saveInterval = PRINTCOUNTER_SAVE_INTERVAL;
  57. public:
  58. /**
  59. * @brief Class constructor
  60. */
  61. PrintCounter();
  62. void tick();
  63. void save();
  64. void load();
  65. void addToTimeCounter(uint16_t const &minutes);
  66. void addToPrintCounter(uint8_t const &prints);
  67. void start();
  68. void stop();
  69. #if ENABLED(DEBUG_PRINTCOUNTER)
  70. /**
  71. * @brief Prints a debug message
  72. * @details Prints a simple debug message "PrintCounter::function"
  73. */
  74. static void debug(const char func[]);
  75. #endif
  76. };
  77. #endif // PRINTCOUNTER_H