123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
-
-
- #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;
- double filamentUsed;
- };
-
- class PrintCounter: public Stopwatch {
- private:
- typedef Stopwatch super;
-
- printStatistics data;
-
-
-
- const uint16_t address = 0x32;
-
-
-
- const uint16_t updateInterval = 10;
-
-
-
- const uint16_t saveInterval = 3600;
-
-
-
- millis_t lastDuration;
-
-
-
- bool loaded = false;
-
- protected:
-
-
- millis_t deltaDuration();
-
- public:
-
-
- PrintCounter();
-
-
-
- bool isLoaded();
-
-
-
- void incFilamentUsed(double const &amount);
-
-
-
- void initStats();
-
-
-
- void loadStats();
-
-
-
- void saveStats();
-
-
-
- void showStats();
-
-
-
- printStatistics getStats() { return this->data; }
-
-
-
- void tick();
-
-
-
- bool start();
- bool stop();
- void reset();
-
- #if ENABLED(DEBUG_PRINTCOUNTER)
-
-
-
- static void debug(const char func[]);
-
- #endif
- };
-
- #endif
|