Prusa MINI Firmware overview
|
#include <printcounter.h>
◆ deltaDuration()
millis_t PrintCounter::deltaDuration |
( |
| ) |
|
|
staticprotected |
dT since the last call
Return the elapsed time in seconds since the last call, this is used internally for print statistics accounting is not intended to be a user callable function.
73 #if ENABLED(DEBUG_PRINTCOUNTER)
74 debug(
PSTR(
"deltaDuration"));
79 return lastDuration - tmp;
◆ init()
static void PrintCounter::init |
( |
| ) |
|
|
static |
Initialize the print counter.
◆ isLoaded()
Check if Print Statistics has been loaded.
Return true if the statistical data has been loaded.
- Returns
- bool
◆ incFilamentUsed()
void PrintCounter::incFilamentUsed |
( |
float const & |
amount | ) |
|
|
static |
Increment the total filament used.
The total filament used counter will be incremented by "amount".
- Parameters
-
amount | The amount of filament used in mm |
83 #if ENABLED(DEBUG_PRINTCOUNTER)
84 debug(
PSTR(
"incFilamentUsed"));
◆ initStats()
void PrintCounter::initStats |
( |
| ) |
|
|
static |
Reset the Print Statistics.
Reset the statistics to zero and saves them to EEPROM creating also the magic header.
94 #if ENABLED(DEBUG_PRINTCOUNTER)
95 debug(
PSTR(
"initStats"));
99 data = { 0, 0, 0, 0, 0.0
101 #if SERVICE_INTERVAL_1 > 0
102 , SERVICE_INTERVAL_SEC_1
104 #if SERVICE_INTERVAL_2 > 0
105 , SERVICE_INTERVAL_SEC_2
107 #if SERVICE_INTERVAL_3 > 0
108 , SERVICE_INTERVAL_SEC_3
◆ loadStats()
void PrintCounter::loadStats |
( |
| ) |
|
|
static |
Load the Print Statistics.
Load the statistics from EEPROM
132 #if ENABLED(DEBUG_PRINTCOUNTER)
133 debug(
PSTR(
"loadStats"));
147 #if HAS_SERVICE_INTERVALS
149 #if SERVICE_INTERVAL_1 > 0
150 if (
data.nextService1 == 0) doBuzz = _service_warn(
PSTR(
" " SERVICE_NAME_1));
152 #if SERVICE_INTERVAL_2 > 0
153 if (
data.nextService2 == 0) doBuzz = _service_warn(
PSTR(
" " SERVICE_NAME_2));
155 #if SERVICE_INTERVAL_3 > 0
156 if (
data.nextService3 == 0) doBuzz = _service_warn(
PSTR(
" " SERVICE_NAME_3));
158 #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0
159 if (doBuzz)
for (
int i = 0;
i < SERVICE_WARNING_BUZZES;
i++)
BUZZ(200, 404);
163 #endif // HAS_SERVICE_INTERVALS
◆ saveStats()
void PrintCounter::saveStats |
( |
| ) |
|
|
static |
Save the Print Statistics.
Save the statistics to EEPROM
167 #if ENABLED(DEBUG_PRINTCOUNTER)
168 debug(
PSTR(
"saveStats"));
179 #if ENABLED(EXTENSIBLE_UI)
◆ showStats()
void PrintCounter::showStats |
( |
| ) |
|
|
static |
Serial output the Print Statistics.
This function may change in the future, for now it directly prints the statistical data to serial.
207 #if ENABLED(DEBUG_PRINTCOUNTER)
215 #if ENABLED(DEBUG_PRINTCOUNTER)
224 #if SERVICE_INTERVAL_1 > 0
225 _service_when(buffer,
PSTR(SERVICE_NAME_1), data.nextService1);
227 #if SERVICE_INTERVAL_2 > 0
228 _service_when(buffer,
PSTR(SERVICE_NAME_2), data.nextService2);
230 #if SERVICE_INTERVAL_3 > 0
231 _service_when(buffer,
PSTR(SERVICE_NAME_3), data.nextService3);
◆ getStats()
Return the currently loaded statistics.
Return the raw data, in the same structure used internally
◆ tick()
void PrintCounter::tick |
( |
| ) |
|
|
static |
Loop function.
This function should be called at loop, it will take care of periodically save the statistical data to EEPROM and do time keeping.
240 static uint32_t update_next;
241 if (
ELAPSED(now, update_next)) {
242 #if ENABLED(DEBUG_PRINTCOUNTER)
248 #if SERVICE_INTERVAL_1 > 0
249 data.nextService1 -=
_MIN(delta, data.nextService1);
251 #if SERVICE_INTERVAL_2 > 0
252 data.nextService2 -=
_MIN(delta, data.nextService2);
254 #if SERVICE_INTERVAL_3 > 0
255 data.nextService3 -=
_MIN(delta, data.nextService3);
258 update_next = now + updateInterval * 1000;
261 static uint32_t eeprom_next;
262 if (
ELAPSED(now, eeprom_next)) {
263 eeprom_next = now + saveInterval * 1000;
◆ start()
bool PrintCounter::start |
( |
| ) |
|
|
static |
The following functions are being overridden
270 #if ENABLED(DEBUG_PRINTCOUNTER)
271 debug(
PSTR(
"start"));
◆ stop()
bool PrintCounter::stop |
( |
| ) |
|
|
static |
289 #if ENABLED(DEBUG_PRINTCOUNTER)
◆ reset()
void PrintCounter::reset |
( |
| ) |
|
|
static |
308 #if ENABLED(DEBUG_PRINTCOUNTER)
char * toString(char *const buffer) const
Formats the duration as a string.
Definition: duration_t.h:123
#define SERIAL_CHAR(x)
Definition: serial.h:69
static FORCE_INLINE bool isRunning()
Check if the timer is running.
Definition: stopwatch.h:93
float filamentUsed
Definition: printcounter.h:44
static void saveStats()
Save the Print Statistics.
Definition: printcounter.cpp:166
static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc)
#define MSG_STATS
Definition: language.h:159
#define SERIAL_ECHOPAIR(V...)
Definition: serial.h:114
static bool access_finish()
uint8_t data[8]
Definition: masstorage.h:49
static bool access_start()
uint8_t i
Definition: screen_test_graph.c:72
#define _MIN(V...)
Definition: macros.h:333
uint32_t millis(void)
Definition: wiring_time.c:29
static bool stop()
Stop the stopwatch.
Definition: stopwatch.cpp:36
static FORCE_INLINE bool isLoaded()
Check if Print Statistics has been loaded.
Definition: printcounter.h:130
uint32_t longestPrint
Definition: printcounter.h:43
uint16_t finishedPrints
Definition: printcounter.h:41
static millis_t deltaDuration()
dT since the last call
Definition: printcounter.cpp:72
#define PSTR(str)
Definition: pgmspace.h:31
uint32_t printTime
Definition: printcounter.h:42
void onConfigurationStoreWritten(bool success)
Definition: marlin_server.cpp:937
static millis_t duration()
Get the running time.
Definition: stopwatch.cpp:108
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
Definition: printcounter.h:38
static bool start()
Start the stopwatch.
Definition: stopwatch.cpp:68
#define SERIAL_ECHOLNPAIR(V...)
Definition: serial.h:144
static void reset()
Reset the stopwatch.
Definition: stopwatch.cpp:97
static void loadStats()
Load the Print Statistics.
Definition: printcounter.cpp:131
#define ELAPSED(NOW, SOON)
Definition: millis_t.h:29
const uint8_t[]
Definition: 404_html.c:3
static FORCE_INLINE bool isPaused()
Check if the timer is paused.
Definition: stopwatch.h:100
static bool read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing=true)
uint16_t totalPrints
Definition: printcounter.h:40
#define SERIAL_EOL()
Definition: serial.h:181
#define HAS_SERVICE_INTERVALS
Definition: Conditionals_LCD.h:534
static FORCE_INLINE void init()
Initialize the stopwatch.
Definition: stopwatch.h:50
PersistentStore persistentStore
Definition: persistent_store_api.cpp:28
Definition: duration_t.h:26
static void initStats()
Reset the Print Statistics.
Definition: printcounter.cpp:93
#define UNUSED(X)
Definition: stm32f4xx_hal_def.h:74
uint32_t millis_t
Definition: millis_t.h:26
#define BUZZ(d, f)
Definition: buzzer.h:126