Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
937fd2ed
Commit
937fd2ed
authored
May 22, 2016
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix printcounter
parent
b9104098
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
75 deletions
+125
-75
Configuration_Store.cpp
MK/Configuration_Store.cpp
+1
-2
MK_Main.cpp
MK/module/MK_Main.cpp
+0
-16
MK_Main.h
MK/module/MK_Main.h
+0
-5
endstops.cpp
MK/module/motion/endstops.cpp
+3
-3
printcounter.cpp
MK/module/printcounter/printcounter.cpp
+57
-11
printcounter.h
MK/module/printcounter/printcounter.h
+25
-7
stopwatch.cpp
MK/module/printcounter/stopwatch.cpp
+26
-20
stopwatch.h
MK/module/printcounter/stopwatch.h
+13
-10
temperature.cpp
MK/module/temperature/temperature.cpp
+0
-1
No files found.
MK/Configuration_Store.cpp
View file @
937fd2ed
...
...
@@ -950,7 +950,6 @@ void ConfigSD_ResetDefault() {
card
.
closeFile
();
card
.
setlast
();
config_last_update
=
millis
();
unset_sd_dot
();
}
...
...
@@ -1008,9 +1007,9 @@ void ConfigSD_ResetDefault() {
}
}
print_job_counter
.
loaded
=
true
;
card
.
closeFile
();
card
.
setlast
();
config_readed
=
true
;
unset_sd_dot
();
}
...
...
MK/module/MK_Main.cpp
View file @
937fd2ed
...
...
@@ -270,10 +270,6 @@ bool software_endstops = true;
#if ENABLED(SDSUPPORT)
static
bool
fromsd
[
BUFSIZE
];
#if ENABLED(SD_SETTINGS)
millis_t
config_last_update
=
0
;
bool
config_readed
=
false
;
#endif
#endif
#if ENABLED(IDLE_OOZING_PREVENT)
...
...
@@ -8997,18 +8993,6 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
}
#endif
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
if
(
IS_SD_INSERTED
&&
!
IS_SD_PRINTING
)
{
if
(
!
config_readed
)
{
ConfigSD_RetrieveSettings
(
true
);
ConfigSD_StoreSettings
();
}
else
if
((
millis
()
-
config_last_update
)
>
SD_CFG_SECONDS
*
1000UL
)
{
ConfigSD_StoreSettings
();
}
}
#endif
#if ENABLED(TEMP_STAT_LEDS)
handle_status_leds
();
#endif
...
...
MK/module/MK_Main.h
View file @
937fd2ed
...
...
@@ -240,11 +240,6 @@ extern int fanSpeed;
extern
int
laser_ttl_modulation
;
#endif
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
extern
millis_t
config_last_update
;
extern
bool
config_readed
;
#endif
// Print job timer
extern
PrintCounter
print_job_counter
;
...
...
MK/module/motion/endstops.cpp
View file @
937fd2ed
...
...
@@ -35,9 +35,9 @@ Endstops endstops;
Endstops
::
Endstops
()
{
enable_globally
(
#if ENABLED(ENDSTOPS_ONLY_FOR_HOMING)
true
#else
false
#else
true
#endif
);
enable
(
true
);
...
...
@@ -159,7 +159,7 @@ void Endstops::report_state() {
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
if
(
abort_on_endstop_hit
)
{
card
.
sdprinting
=
false
;
card
.
close
f
ile
();
card
.
close
F
ile
();
quickStop
();
disable_all_heaters
();
// switch off all heaters.
}
...
...
MK/module/printcounter/printcounter.cpp
View file @
937fd2ed
...
...
@@ -45,6 +45,32 @@ void PrintCounter::initStats() {
this
->
data
=
{
0
,
0
,
0
,
0
,
0.0
};
}
void
PrintCounter
::
loadStats
()
{
#if ENABLED(DEBUG_PRINTCOUNTER)
PrintCounter
::
debug
(
PSTR
(
"loadStats"
));
#endif
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
// Checks if the SDCARD is inserted
if
(
IS_SD_INSERTED
&&
!
IS_SD_PRINTING
)
{
ConfigSD_RetrieveSettings
(
true
);
}
#endif
}
void
PrintCounter
::
saveStats
()
{
#if ENABLED(DEBUG_PRINTCOUNTER)
PrintCounter
::
debug
(
PSTR
(
"saveStats"
));
#endif
// Refuses to save data is object is not loaded
if
(
!
this
->
loaded
)
return
;
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
ConfigSD_StoreSettings
();
#endif
}
void
PrintCounter
::
showStats
()
{
char
temp
[
30
];
uint32_t
day
,
hours
,
minutes
;
...
...
@@ -81,7 +107,7 @@ void PrintCounter::showStats() {
void
PrintCounter
::
tick
()
{
static
uint32_t
update_before
=
millis
(),
eeprom_befor
e
=
millis
();
config_last_updat
e
=
millis
();
uint32_t
now
=
millis
();
...
...
@@ -100,27 +126,47 @@ void PrintCounter::tick() {
PrintCounter
::
debug
(
PSTR
(
"tick"
));
#endif
}
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
if
(
!
this
->
loaded
)
{
this
->
loadStats
();
this
->
saveStats
();
}
else
if
(
now
-
config_last_update
>=
this
->
saveInterval
)
{
config_last_update
=
now
;
this
->
saveStats
();
}
#endif
}
void
PrintCounter
::
start
()
{
bool
PrintCounter
::
start
()
{
#if ENABLED(DEBUG_PRINTCOUNTER)
PrintCounter
::
debug
(
PSTR
(
"start"
));
#endif
if
(
!
this
->
isPaused
())
this
->
data
.
numberPrints
++
;
super
::
start
();
bool
paused
=
this
->
isPaused
();
if
(
super
::
start
())
{
if
(
!
paused
)
{
this
->
data
.
numberPrints
++
;
this
->
lastDuration
=
0
;
}
return
true
;
}
else
return
false
;
}
void
PrintCounter
::
stop
()
{
bool
PrintCounter
::
stop
()
{
#if ENABLED(DEBUG_PRINTCOUNTER)
PrintCounter
::
debug
(
PSTR
(
"stop"
));
#endif
if
(
!
this
->
isRunning
())
return
;
super
::
stop
();
this
->
data
.
completePrints
++
;
this
->
data
.
printTime
+=
this
->
deltaDuration
();
if
(
super
::
stop
())
{
this
->
data
.
completePrints
++
;
this
->
data
.
printTime
+=
this
->
deltaDuration
();
this
->
saveStats
();
}
else
return
false
;
}
void
PrintCounter
::
reset
()
{
...
...
@@ -128,8 +174,8 @@ void PrintCounter::reset() {
PrintCounter
::
debug
(
PSTR
(
"stop"
));
#endif
this
->
lastDuration
=
0
;
super
::
reset
();
this
->
lastDuration
=
0
;
}
#if ENABLED(DEBUG_PRINTCOUNTER)
...
...
MK/module/printcounter/printcounter.h
View file @
937fd2ed
...
...
@@ -47,6 +47,12 @@
*/
const
uint16_t
updateInterval
=
10
;
/**
* @brief Interval in seconds between SDCARD saves
* @details This const value defines what will be the time between each
*/
const
uint32_t
saveInterval
=
SD_CFG_SECONDS
*
1000
;
/**
* @brief Timestamp of the last call to deltaDuration()
* @details Stores the timestamp of the last deltaDuration(), this is
...
...
@@ -73,11 +79,11 @@
PrintCounter
();
/**
* @brief
Checks if Print Statistics has been loaded
* @details
Returns true if the statistical data has been loaded.
*
@return bool
* @brief
Stats were loaded from SDCARD
* @details
If set to true it indicates if the statistical data was already
*
loaded from the SDCARD.
*/
bool
isLoaded
()
;
bool
loaded
=
false
;
/**
* @brief Resets the Print Statistics
...
...
@@ -86,6 +92,18 @@
*/
void
initStats
();
/**
* @brief Loads the Print Statistics
* @details Loads the statistics from SDCARD
*/
void
loadStats
();
/**
* @brief Saves the Print Statistics
* @details Saves the statistics to SDCARD
*/
void
saveStats
();
/**
* @brief Serial output the Print Statistics
* @details This function may change in the future, for now it directly
...
...
@@ -96,15 +114,15 @@
/**
* @brief Loop function
* @details This function should be called at loop, it will take care of
* periodically save the statistical data to
EEPROM
and do time keeping.
* periodically save the statistical data to
SDCARD
and do time keeping.
*/
void
tick
();
/**
* The following functions are being overridden
*/
void
start
();
void
stop
();
bool
start
();
bool
stop
();
void
reset
();
#if ENABLED(DEBUG_PRINTCOUNTER)
...
...
MK/module/printcounter/stopwatch.cpp
View file @
937fd2ed
...
...
@@ -27,40 +27,46 @@ Stopwatch::Stopwatch() {
this
->
reset
();
}
void
Stopwatch
::
stop
()
{
bool
Stopwatch
::
stop
()
{
#if ENABLED(DEBUG_STOPWATCH)
Stopwatch
::
debug
(
PSTR
(
"stop"
));
#endif
if
(
!
this
->
isRunning
())
return
;
this
->
state
=
STPWTCH_STOPPED
;
this
->
stopTimestamp
=
millis
();
if
(
this
->
isRunning
()
||
this
->
isPaused
())
{
this
->
state
=
STOPWATCH_STOPPED
;
this
->
stopTimestamp
=
millis
();
return
true
;
}
else
return
false
;
}
void
Stopwatch
::
pause
()
{
bool
Stopwatch
::
pause
()
{
#if ENABLED(DEBUG_STOPWATCH)
Stopwatch
::
debug
(
PSTR
(
"pause"
));
#endif
if
(
!
this
->
isRunning
())
return
;
this
->
state
=
STPWTCH_PAUSED
;
this
->
stopTimestamp
=
millis
();
if
(
this
->
isRunning
())
{
this
->
state
=
STOPWATCH_PAUSED
;
this
->
stopTimestamp
=
millis
();
return
true
;
}
else
return
false
;
}
void
Stopwatch
::
start
()
{
bool
Stopwatch
::
start
()
{
#if ENABLED(DEBUG_STOPWATCH)
Stopwatch
::
debug
(
PSTR
(
"start"
));
#endif
if
(
this
->
isRunning
())
return
;
if
(
this
->
isPaused
())
this
->
accumulator
=
this
->
duration
();
else
this
->
reset
();
if
(
!
this
->
isRunning
())
{
if
(
this
->
isPaused
())
this
->
accumulator
=
this
->
duration
();
else
this
->
reset
();
this
->
state
=
STPWTCH_RUNNING
;
this
->
startTimestamp
=
millis
();
this
->
state
=
STOPWATCH_RUNNING
;
this
->
startTimestamp
=
millis
();
return
true
;
}
else
return
false
;
}
void
Stopwatch
::
reset
()
{
...
...
@@ -68,18 +74,18 @@ void Stopwatch::reset() {
Stopwatch
::
debug
(
PSTR
(
"reset"
));
#endif
this
->
state
=
ST
PW
TCH_STOPPED
;
this
->
state
=
ST
OPWA
TCH_STOPPED
;
this
->
startTimestamp
=
0
;
this
->
stopTimestamp
=
0
;
this
->
accumulator
=
0
;
}
bool
Stopwatch
::
isRunning
()
{
return
(
this
->
state
==
ST
PW
TCH_RUNNING
)
?
true
:
false
;
return
(
this
->
state
==
ST
OPWA
TCH_RUNNING
)
?
true
:
false
;
}
bool
Stopwatch
::
isPaused
()
{
return
(
this
->
state
==
ST
PW
TCH_PAUSED
)
?
true
:
false
;
return
(
this
->
state
==
ST
OPWA
TCH_PAUSED
)
?
true
:
false
;
}
uint16_t
Stopwatch
::
duration
()
{
...
...
MK/module/printcounter/stopwatch.h
View file @
937fd2ed
...
...
@@ -27,9 +27,9 @@
//#define DEBUG_STOPWATCH
enum
StopwatchState
{
ST
PW
TCH_STOPPED
,
ST
PW
TCH_RUNNING
,
ST
PW
TCH_PAUSED
ST
OPWA
TCH_STOPPED
,
ST
OPWA
TCH_RUNNING
,
ST
OPWA
TCH_PAUSED
};
/**
...
...
@@ -54,22 +54,25 @@
* @brief Stops the stopwatch
* @details Stops the running timer, it will silently ignore the request if
* no timer is currently running.
* @return true is method was successful
*/
void
stop
();
bool
stop
();
/**
* @brief Pauses the stopwatch
* @details Pauses the running timer, it will silently ignore the request if
* no timer is currently running.
* @return true is method was successful
*/
void
pause
();
bool
pause
();
/**
* @brief Starts the stopwatch
* @details Starts the timer, it will silently ignore the request if the
* timer is already running.
* @return true is method was successful
*/
void
start
();
bool
start
();
/**
* @brief Resets the stopwatch
...
...
@@ -80,21 +83,21 @@
/**
* @brief Checks if the timer is running
* @details Returns true if the timer is currently running, false otherwise.
* @return
bool
* @return
true if stopwatch is running
*/
bool
isRunning
();
/**
* @brief Checks if the timer is paused
* @details Returns true if the timer is currently paused, false otherwise.
* @return
bool
* @return
true if stopwatch is paused
*/
bool
isPaused
();
/**
* @brief Gets the running time
* @details Returns the total number of seconds the timer has been running.
* @return
uint16_t
* @return
the delta since starting the stopwatch
*/
uint16_t
duration
();
...
...
@@ -108,4 +111,4 @@
#endif
};
#endif //STOPWATCH_H
#endif //
STOPWATCH_H
MK/module/temperature/temperature.cpp
View file @
937fd2ed
...
...
@@ -1402,7 +1402,6 @@ void disable_all_heaters() {
return
(
int
)
max6675_temp
;
}
#endif // HEATER_0_USES_MAX6675
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment