123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- #ifndef PRINTCOUNTER_H
- #define PRINTCOUNTER_H
- #include "macros.h"
- #include "language.h"
- #include "stopwatch.h"
- #include <avr/eeprom.h>
- struct printStatistics {
-
- uint16_t totalPrints;
- uint16_t finishedPrints;
- uint32_t printTime;
- uint32_t longestPrint;
- float filamentUsed;
- };
- class PrintCounter: public Stopwatch {
- private:
- typedef Stopwatch super;
- #if ENABLED(I2C_EEPROM) || ENABLED(SPI_EEPROM)
- typedef uint32_t promdress;
- #else
- typedef uint16_t promdress;
- #endif
- static printStatistics data;
-
- static const promdress address;
-
- static const uint16_t updateInterval;
-
- static const uint16_t saveInterval;
-
- static millis_t lastDuration;
-
- static bool loaded;
- protected:
-
- static millis_t deltaDuration();
- public:
-
- static inline void init() {
- super::init();
- loadStats();
- }
-
- FORCE_INLINE static bool isLoaded() { return loaded; }
-
- static void incFilamentUsed(float const &amount);
-
- static void initStats();
-
- static void loadStats();
-
- static void saveStats();
-
- static void showStats();
-
- static printStatistics getStats() { return data; }
-
- static void tick();
-
- static bool start();
- static bool stop();
- static void reset();
- #if ENABLED(DEBUG_PRINTCOUNTER)
-
- static void debug(const char func[]);
- #endif
- };
- #if ENABLED(PRINTCOUNTER)
- extern PrintCounter print_job_timer;
- #else
- extern Stopwatch print_job_timer;
- #endif
- #endif
|