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
8ee235df
Commit
8ee235df
authored
May 08, 2016
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix
parent
a2c58bb2
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
766 additions
and
614 deletions
+766
-614
Configuration_Basic.h
MK/Configuration_Basic.h
+0
-31
Configuration_Feature.h
MK/Configuration_Feature.h
+44
-3
base.h
MK/base.h
+1
-0
MK_Main.cpp
MK/module/MK_Main.cpp
+129
-126
conditionals.h
MK/module/conditionals.h
+15
-0
language.h
MK/module/language/language.h
+11
-66
ultralcd.h
MK/module/lcd/ultralcd.h
+2
-2
macros.h
MK/module/macros.h
+2
-0
endstops.cpp
MK/module/motion/endstops.cpp
+362
-0
endstops.h
MK/module/motion/endstops.h
+105
-0
planner.cpp
MK/module/motion/planner.cpp
+1
-1
stepper.cpp
MK/module/motion/stepper.cpp
+61
-366
stepper.h
MK/module/motion/stepper.h
+21
-7
stopwatch.cpp
MK/module/stopwatch/stopwatch.cpp
+10
-10
stopwatch.h
MK/module/stopwatch/stopwatch.h
+2
-2
No files found.
MK/Configuration_Basic.h
View file @
8ee235df
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
* - Extruders number
* - Extruders number
* - Thermistor type
* - Thermistor type
* - Temperature limits
* - Temperature limits
* - UI Language
*
*
* Mechanisms-settings can be found in Configuration_Xxxxxx.h (where Xxxxxx can be: Cartesian - Delta - Core - Scara)
* Mechanisms-settings can be found in Configuration_Xxxxxx.h (where Xxxxxx can be: Cartesian - Delta - Core - Scara)
* Feature-settings can be found in Configuration_Feature.h
* Feature-settings can be found in Configuration_Feature.h
...
@@ -239,34 +238,4 @@
...
@@ -239,34 +238,4 @@
#define GUM_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
#define GUM_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
/*****************************************************************************************************/
/*****************************************************************************************************/
/***********************************************************************
*************************** UI Language ******************************
***********************************************************************
* *
* Select the language that you prefer and change LANGUAGE_CHOICE *
* *
* 1 English *
* 2 Polish *
* 3 French *
* 4 German *
* 5 Spanish *
* 6 Russian *
* 7 Italian *
* 8 Portuguese *
* 9 Finnish *
* 10 Aragonese *
* 11 Dutch *
* 12 Danish *
* 13 Catalan *
* 14 Basque-Euskera *
* 15 Portuguese (Brazil) *
* 16 Bulgarian *
* 17 Japanese *
* 18 Japanese utf *
* 19 Chinese *
* *
***********************************************************************/
#define LANGUAGE_CHOICE 1
/***********************************************************************/
#endif
#endif
MK/Configuration_Feature.h
View file @
8ee235df
...
@@ -50,9 +50,11 @@
...
@@ -50,9 +50,11 @@
* - Filament diameter sensor
* - Filament diameter sensor
* - Filament Runout sensor
* - Filament Runout sensor
* - Power consumption sensor
* - Power consumption sensor
* - RFID card sensor
* ADDON FEATURES:
* ADDON FEATURES:
* - EEPROM
* - EEPROM
* - SDCARD
* - SDCARD
* - LCD Language
* - LCD
* - LCD
* - Canon RC-1 Remote
* - Canon RC-1 Remote
* - Camera trigger
* - Camera trigger
...
@@ -1045,6 +1047,29 @@
...
@@ -1045,6 +1047,29 @@
/**************************************************************************/
/**************************************************************************/
/**************************************************************************
*********************** RIFD module card reader **************************
**************************************************************************
* *
* Support RFID module card reader width UART interface. *
* This module mount chip MFRC522 designed to communicate with *
* ISO/IEC 14443 A/MIFARE cards and transponders without additional *
* active circuitry *
* *
* New command for this system is: *
* M522 T<extruder> R<read> or W<write> *
* *
* Define if you used and Serial used. *
* *
**************************************************************************/
//#define RFID_MODULE
#define RFID_SERIAL 1
/**************************************************************************/
//===========================================================================
//===========================================================================
//============================= ADDON FEATURES ==============================
//============================= ADDON FEATURES ==============================
//===========================================================================
//===========================================================================
...
@@ -1101,9 +1126,25 @@
...
@@ -1101,9 +1126,25 @@
/*****************************************************************************************/
/*****************************************************************************************/
/************************************************************************************************
/***********************************************************************
********************************************* LCD **********************************************
*************************** LCD Language ******************************
************************************************************************************************/
***********************************************************************
* *
* Here you may choose the language used by MK or MK4due *
* on the LCD menus, the following *
* *
* list of languages are available: *
* en, pl, fr, de, es, ru, it, pt, fi, an, nl, ca, eu *
* pt-br, bg, kana, kana_utf8, cn *
* *
***********************************************************************/
#define LCD_LANGUAGE en
/***********************************************************************/
/***********************************************************************
******************************* LCD ***********************************
***********************************************************************/
//Charset type
//Charset type
//Choose ONE of these 3 charsets. This has to match your hardware.
//Choose ONE of these 3 charsets. This has to match your hardware.
...
...
MK/base.h
View file @
8ee235df
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
#include "module/motion/planner.h"
#include "module/motion/planner.h"
#include "module/motion/stepper_indirection.h"
#include "module/motion/stepper_indirection.h"
#include "module/motion/stepper.h"
#include "module/motion/stepper.h"
#include "module/motion/endstops.h"
#include "module/motion/vector_3.h"
#include "module/motion/vector_3.h"
#include "module/motion/qr_solve.h"
#include "module/motion/qr_solve.h"
#include "module/motion/cartesian_correction.h"
#include "module/motion/cartesian_correction.h"
...
...
MK/module/MK_Main.cpp
View file @
8ee235df
This diff is collapsed.
Click to expand it.
MK/module/conditionals.h
View file @
8ee235df
...
@@ -368,6 +368,17 @@
...
@@ -368,6 +368,17 @@
#define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
#define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS))
#define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
#define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS))
/**
* CoreXY or CoreYX or CoreXZ or CoreZX
*/
#if MECH(COREXY) || MECH(COREYX)
#define CORE_AXIS_2 B_AXIS
#define CORE_AXIS_3 Z_AXIS
#elif MECH(COREXZ) || MECH(COREZX)
#define CORE_AXIS_2 C_AXIS
#define CORE_AXIS_3 Y_AXIS
#endif
/**
/**
* SCARA
* SCARA
*/
*/
...
@@ -740,6 +751,10 @@
...
@@ -740,6 +751,10 @@
#define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS))
#define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS))
#define HAS_TEMP_HOTEND (HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675))
#define HAS_THERMALLY_PROTECTED_BED (HAS_TEMP_BED && HAS_HEATER_BED && ENABLED(THERMAL_PROTECTION_BED))
/**
/**
* Shorthand for filament sensor and power sensor for ultralcd.cpp, dogm_lcd_implementation.h, ultralcd_implementation_hitachi_HD44780.h
* Shorthand for filament sensor and power sensor for ultralcd.cpp, dogm_lcd_implementation.h, ultralcd_implementation_hitachi_HD44780.h
*/
*/
...
...
MK/module/language/language.h
View file @
8ee235df
...
@@ -23,32 +23,9 @@
...
@@ -23,32 +23,9 @@
#ifndef LANGUAGE_H
#ifndef LANGUAGE_H
#define LANGUAGE_H
#define LANGUAGE_H
// NOTE: IF YOU CHANGE LANGUAGE FILES OR MERGE A FILE WITH CHANGES
#ifndef LCD_LANGUAGE
//
#define LCD_LANGUAGE en
// ==> ALWAYS TRY TO COMPILE MARLIN WITH/WITHOUT "ULTIPANEL" / "ULTRALCD" / "SDSUPPORT" #define IN "Configuration_Basic.h"
#endif
// ==> ALSO TRY ALL AVAILABLE "LANGUAGE_CHOICE" OPTIONS
// See also documentation/LCDLanguageFont.md
// Languages
// 1 English // Language base
// 2 Polish
// 3 French
// 4 German
// 5 Spanish
// 6 Russian
// 7 Italian
// 8 Portuguese
// 9 Finnish
// 10 Aragonese
// 11 Dutch
// 12 Danish
// 13 Catalan
// 14 Basque-Euskera
// 15 Portuguese (Brazil)
// 16 Bulgarian
// 17 Japanese
// 18 Japanese utf
// 19 Chinese
#define PROTOCOL_VERSION "2.0"
#define PROTOCOL_VERSION "2.0"
...
@@ -251,45 +228,13 @@
...
@@ -251,45 +228,13 @@
#define SERIAL_BED_LEVELLING_Y " Y: "
#define SERIAL_BED_LEVELLING_Y " Y: "
#define SERIAL_BED_LEVELLING_Z " Z: "
#define SERIAL_BED_LEVELLING_Z " Z: "
#if LANGUAGE_CHOICE == 1 // English
// LCD Menu Messages
#include "language_en.h"
#elif LANGUAGE_CHOICE == 2 // Polish
#define LANGUAGE_INCL_(M) STRINGIFY_(language_##M.h)
#include "language_pl.h"
#define LANGUAGE_INCL(M) LANGUAGE_INCL_(M)
#elif LANGUAGE_CHOICE == 3 // French
#define INCLUDE_LANGUAGE LANGUAGE_INCL(LCD_LANGUAGE)
#include "language_fr.h"
#elif LANGUAGE_CHOICE == 4 // German
#include "language_en.h"
#include "language_de.h"
#include INCLUDE_LANGUAGE
#elif LANGUAGE_CHOICE == 5 // Spanish
#include "language_es.h"
#elif LANGUAGE_CHOICE == 6 // Russian
#define MAPPER_D0D1 // For Cyrillic
#include "language_ru.h"
#elif LANGUAGE_CHOICE == 7 // Italian
#include "language_it.h"
#elif LANGUAGE_CHOICE == 8 // Portuguese
#include "language_pt.h"
#elif LANGUAGE_CHOICE == 9 // Finnish
#include "language_fi.h"
#elif LANGUAGE_CHOICE == 10 // Aragonese
#include "language_an.h"
#elif LANGUAGE_CHOICE == 11 // Dutch
#include "language_nl.h"
#elif LANGUAGE_CHOICE == 12 // Danish
#include "language_da.h"
#elif LANGUAGE_CHOICE == 13 // Catalan
#include "language_ca.h"
#elif LANGUAGE_CHOICE == 14 // Basque-Euskera
#include "language_eu.h"
#elif LANGUAGE_CHOICE == 15 // Portuguese - Brasil
#include "language_pt-br.h"
#elif LANGUAGE_CHOICE == 16 // Bulgarian
#include "language_bg.h"
#elif LANGUAGE_CHOICE == 17 // Japanese
#include "language_kana.h"
#elif LANGUAGE_CHOICE == 18 // Japanese utf
#include "language_kana_utf8.h"
#elif LANGUAGE_CHOICE == 19 // Chinese
#include "language_cn.h"
#endif
#endif //__LANGUAGE_H
#endif //__LANGUAGE_H
MK/module/lcd/ultralcd.h
View file @
8ee235df
...
@@ -195,8 +195,8 @@
...
@@ -195,8 +195,8 @@
FORCE_INLINE
void
lcd_reset_alert_level
()
{}
FORCE_INLINE
void
lcd_reset_alert_level
()
{}
FORCE_INLINE
bool
lcd_detected
(
void
)
{
return
true
;
}
FORCE_INLINE
bool
lcd_detected
(
void
)
{
return
true
;
}
#define LCD_MESSAGEPGM(x)
do{}while(0)
#define LCD_MESSAGEPGM(x)
NOOP
#define LCD_ALERTMESSAGEPGM(x)
do{}while(0)
#define LCD_ALERTMESSAGEPGM(x)
NOOP
#endif //ULTRA_LCD
#endif //ULTRA_LCD
...
...
MK/module/macros.h
View file @
8ee235df
...
@@ -76,4 +76,6 @@
...
@@ -76,4 +76,6 @@
#define NOOP do{}while(0)
#define NOOP do{}while(0)
#define _AXIS(AXIS) AXIS ##_AXIS
#endif //__MACROS_H
#endif //__MACROS_H
MK/module/motion/endstops.cpp
0 → 100644
View file @
8ee235df
This diff is collapsed.
Click to expand it.
MK/module/motion/endstops.h
0 → 100644
View file @
8ee235df
/**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* endstops.h - manages endstops
*/
#ifndef ENDSTOPS_H
#define ENDSTOPS_H
enum
EndstopEnum
{
X_MIN
=
0
,
Y_MIN
=
1
,
Z_MIN
=
2
,
Z_PROBE
=
3
,
X_MAX
=
4
,
Y_MAX
=
5
,
Z_MAX
=
6
,
Z2_MIN
=
7
,
Z2_MAX
=
8
,
E_MIN
=
9
};
class
Endstops
{
public
:
volatile
char
endstop_hit_bits
;
// use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
#if ENABLED(Z_DUAL_ENDSTOPS)
uint16_t
current_endstop_bits
=
0
,
old_endstop_bits
=
0
;
#else
byte
current_endstop_bits
=
0
,
old_endstop_bits
=
0
;
#endif
bool
enabled
=
true
;
bool
enabled_globally
=
#if ENABLED(ENDSTOPS_ONLY_FOR_HOMING)
false
#else
true
#endif
;
Endstops
();
/**
* Initialize the endstop pins
*/
void
init
();
/**
* Update the endstops bits from the pins
*/
void
update
();
/**
* Print an error message reporting the position when the endstops were last hit.
*/
void
report_state
();
//call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
/**
* Report endstop positions in response to M119
*/
void
M119
();
// Enable / disable endstop checking globally
FORCE_INLINE
void
enable_globally
(
bool
onoff
=
true
)
{
enabled_globally
=
enabled
=
onoff
;
}
// Enable / disable endstop checking
FORCE_INLINE
void
enable
(
bool
onoff
=
true
)
{
enabled
=
onoff
;
}
// Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
FORCE_INLINE
void
not_homing
()
{
enabled
=
enabled_globally
;
}
// Clear endstops (i.e., they were hit intentionally) to suppress the report
FORCE_INLINE
void
hit_on_purpose
()
{
endstop_hit_bits
=
0
;
}
// Enable / disable endstop z-probe checking
#if ENABLED(HAS_Z_PROBE)
volatile
bool
z_probe_enabled
=
false
;
FORCE_INLINE
void
enable_z_probe
(
bool
onoff
=
true
)
{
z_probe_enabled
=
onoff
;
}
#endif
private
:
#if ENABLED(Z_DUAL_ENDSTOPS)
void
test_dual_z_endstops
(
EndstopEnum
es1
,
EndstopEnum
es2
);
#endif
};
extern
Endstops
endstops
;
#endif // ENDSTOPS_H
MK/module/motion/planner.cpp
View file @
8ee235df
...
@@ -992,7 +992,7 @@ float junction_deviation = 0.1;
...
@@ -992,7 +992,7 @@ float junction_deviation = 0.1;
// Compute and limit the acceleration rate for the trapezoid generator.
// Compute and limit the acceleration rate for the trapezoid generator.
float
steps_per_mm
=
block
->
step_event_count
/
block
->
millimeters
;
float
steps_per_mm
=
block
->
step_event_count
/
block
->
millimeters
;
unsigned
long
bsx
=
block
->
steps
[
X_AXIS
],
bsy
=
block
->
steps
[
Y_AXIS
],
bsz
=
block
->
steps
[
Z_AXIS
],
bse
=
block
->
steps
[
E_AXIS
];
long
bsx
=
block
->
steps
[
X_AXIS
],
bsy
=
block
->
steps
[
Y_AXIS
],
bsz
=
block
->
steps
[
Z_AXIS
],
bse
=
block
->
steps
[
E_AXIS
];
if
(
bsx
==
0
&&
bsy
==
0
&&
bsz
==
0
)
{
if
(
bsx
==
0
&&
bsy
==
0
&&
bsz
==
0
)
{
block
->
acceleration_st
=
ceil
(
retract_acceleration
[
extruder
]
*
steps_per_mm
);
// convert to: acceleration steps/sec^2
block
->
acceleration_st
=
ceil
(
retract_acceleration
[
extruder
]
*
steps_per_mm
);
// convert to: acceleration steps/sec^2
}
}
...
...
MK/module/motion/stepper.cpp
View file @
8ee235df
This diff is collapsed.
Click to expand it.
MK/module/motion/stepper.h
View file @
8ee235df
...
@@ -34,11 +34,14 @@
...
@@ -34,11 +34,14 @@
* A_AXIS and C_AXIS are used by COREXZ or COREZX printers
* A_AXIS and C_AXIS are used by COREXZ or COREZX printers
* X_HEAD and Y_HEAD and Z_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
* X_HEAD and Y_HEAD and Z_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
*/
*/
enum
AxisEnum
{
X_AXIS
=
0
,
A_AXIS
=
0
,
Y_AXIS
=
1
,
B_AXIS
=
1
,
Z_AXIS
=
2
,
C_AXIS
=
2
,
E_AXIS
=
3
,
X_HEAD
=
4
,
Y_HEAD
=
5
,
Z_HEAD
=
5
};
enum
AxisEnum
{
X_AXIS
=
0
,
A_AXIS
=
0
,
Y_AXIS
=
1
,
B_AXIS
=
1
,
Z_AXIS
=
2
,
C_AXIS
=
2
,
E_AXIS
=
3
,
X_HEAD
=
4
,
Y_HEAD
=
5
,
Z_HEAD
=
5
};
enum
EndstopEnum
{
X_MIN
=
0
,
Y_MIN
=
1
,
Z_MIN
=
2
,
Z_PROBE
=
3
,
X_MAX
=
4
,
Y_MAX
=
5
,
Z_MAX
=
6
,
Z2_MIN
=
7
,
Z2_MAX
=
8
,
E_MIN
=
9
};
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
extern
bool
abort_on_endstop_hit
;
#if ENABLED(ABORT_ON_ENDSTOP_HIT_INIT)
bool
abort_on_endstop_hit
=
ABORT_ON_ENDSTOP_HIT_INIT
;
#else
bool
abort_on_endstop_hit
=
false
;
#endif
#endif
#endif
// Initialize and start the stepper motor subsystem
// Initialize and start the stepper motor subsystem
...
@@ -69,10 +72,20 @@
...
@@ -69,10 +72,20 @@
//
//
void
report_positions
();
void
report_positions
();
void
checkHitEndstops
();
//call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
//
void
endstops_hit_on_purpose
();
//avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops();
// Handle a triggered endstop
//
void
endstop_triggered
(
AxisEnum
axis
);
//
// Triggered position of an axis in mm (not core-savvy)
//
float
triggered_position_mm
(
AxisEnum
axis
);
void
enable_endstops
(
bool
check
);
// Enable/disable endstop checking
//
// The direction of a single motor
//
bool
motor_direction
(
AxisEnum
axis
);
void
checkStepperErrors
();
//Print errors detected by the stepper
void
checkStepperErrors
();
//Print errors detected by the stepper
...
@@ -91,6 +104,7 @@
...
@@ -91,6 +104,7 @@
void
digipot_current
(
uint8_t
driver
,
int
current
);
void
digipot_current
(
uint8_t
driver
,
int
current
);
void
microstep_init
();
void
microstep_init
();
void
microstep_readings
();
void
microstep_readings
();
void
kill_current_block
();
#if ENABLED(Z_DUAL_ENDSTOPS)
#if ENABLED(Z_DUAL_ENDSTOPS)
void
In_Homing_Process
(
bool
state
);
void
In_Homing_Process
(
bool
state
);
...
...
MK/module/stopwatch/stopwatch.cpp
View file @
8ee235df
...
@@ -29,29 +29,29 @@ Stopwatch::Stopwatch() {
...
@@ -29,29 +29,29 @@ Stopwatch::Stopwatch() {
void
Stopwatch
::
stop
()
{
void
Stopwatch
::
stop
()
{
#if ENABLED(DEBUG_STOPWATCH)
#if ENABLED(DEBUG_STOPWATCH)
debug
(
PSTR
(
"stop"
));
Stopwatch
::
debug
(
PSTR
(
"stop"
));
#endif
#endif
if
(
!
this
->
isRunning
())
return
;
if
(
!
this
->
isRunning
())
return
;
this
->
stat
us
=
STPWTCH_STOPPED
;
this
->
stat
e
=
STPWTCH_STOPPED
;
this
->
stopTimestamp
=
millis
();
this
->
stopTimestamp
=
millis
();
}
}
void
Stopwatch
::
pause
()
{
void
Stopwatch
::
pause
()
{
#if ENABLED(DEBUG_STOPWATCH)
#if ENABLED(DEBUG_STOPWATCH)
debug
(
PSTR
(
"pause"
));
Stopwatch
::
debug
(
PSTR
(
"pause"
));
#endif
#endif
if
(
!
this
->
isRunning
())
return
;
if
(
!
this
->
isRunning
())
return
;
this
->
stat
us
=
STPWTCH_PAUSED
;
this
->
stat
e
=
STPWTCH_PAUSED
;
this
->
stopTimestamp
=
millis
();
this
->
stopTimestamp
=
millis
();
}
}
void
Stopwatch
::
start
()
{
void
Stopwatch
::
start
()
{
#if ENABLED(DEBUG_STOPWATCH)
#if ENABLED(DEBUG_STOPWATCH)
debug
(
PSTR
(
"start"
));
Stopwatch
::
debug
(
PSTR
(
"start"
));
#endif
#endif
if
(
this
->
isRunning
())
return
;
if
(
this
->
isRunning
())
return
;
...
@@ -59,27 +59,27 @@ void Stopwatch::start() {
...
@@ -59,27 +59,27 @@ void Stopwatch::start() {
if
(
this
->
isPaused
())
this
->
accumulator
=
this
->
duration
();
if
(
this
->
isPaused
())
this
->
accumulator
=
this
->
duration
();
else
this
->
reset
();
else
this
->
reset
();
this
->
stat
us
=
STPWTCH_RUNNING
;
this
->
stat
e
=
STPWTCH_RUNNING
;
this
->
startTimestamp
=
millis
();
this
->
startTimestamp
=
millis
();
}
}
void
Stopwatch
::
reset
()
{
void
Stopwatch
::
reset
()
{
#if ENABLED(DEBUG_STOPWATCH)
#if ENABLED(DEBUG_STOPWATCH)
debug
(
PSTR
(
"reset"
));
Stopwatch
::
debug
(
PSTR
(
"reset"
));
#endif
#endif
this
->
stat
us
=
STPWTCH_STOPPED
;
this
->
stat
e
=
STPWTCH_STOPPED
;
this
->
startTimestamp
=
0
;
this
->
startTimestamp
=
0
;
this
->
stopTimestamp
=
0
;
this
->
stopTimestamp
=
0
;
this
->
accumulator
=
0
;
this
->
accumulator
=
0
;
}
}
bool
Stopwatch
::
isRunning
()
{
bool
Stopwatch
::
isRunning
()
{
return
(
this
->
stat
us
==
STPWTCH_RUNNING
)
?
true
:
false
;
return
(
this
->
stat
e
==
STPWTCH_RUNNING
)
?
true
:
false
;
}
}
bool
Stopwatch
::
isPaused
()
{
bool
Stopwatch
::
isPaused
()
{
return
(
this
->
stat
us
==
STPWTCH_PAUSED
)
?
true
:
false
;
return
(
this
->
stat
e
==
STPWTCH_PAUSED
)
?
true
:
false
;
}
}
uint16_t
Stopwatch
::
duration
()
{
uint16_t
Stopwatch
::
duration
()
{
...
...
MK/module/stopwatch/stopwatch.h
View file @
8ee235df
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
// Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM)
// Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM)
//#define DEBUG_STOPWATCH
//#define DEBUG_STOPWATCH
enum
StopwatchStat
us
{
enum
StopwatchStat
e
{
STPWTCH_STOPPED
,
STPWTCH_STOPPED
,
STPWTCH_RUNNING
,
STPWTCH_RUNNING
,
STPWTCH_PAUSED
STPWTCH_PAUSED
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
*/
*/
class
Stopwatch
{
class
Stopwatch
{
private
:
private
:
StopwatchStat
us
status
;
StopwatchStat
e
state
;
uint16_t
accumulator
;
uint16_t
accumulator
;
uint32_t
startTimestamp
;
uint32_t
startTimestamp
;
uint32_t
stopTimestamp
;
uint32_t
stopTimestamp
;
...
...
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