Commit 9c6f57b2 authored by MagoKimbra's avatar MagoKimbra

Merge remote-tracking branch 'refs/remotes/origin/master' into dev

parents 1e3fc326 744b1137
...@@ -52,9 +52,14 @@ ...@@ -52,9 +52,14 @@
//#define FIRMWARE_TEST //#define FIRMWARE_TEST
// Some particular clients re-start sending commands only after receiving a 'wait' when there is a bad serial-connection. // Some particular clients re-start sending commands only after receiving a 'wait' when there is a bad serial-connection.
//#define NO_TIMEOUTS //#define NO_TIMEOUTS 1000 // Milliseconds
// Uncomment to include more info in ok command // Uncomment to include more info in ok command
//#define ADVANCED_OK //#define ADVANCED_OK
// By default MarlinKimbra will send a busy status message to the host
// every couple of seconds when it can't accept commands.
// Enable this option if your host doesn't like keepalive messages.
//#define DISABLE_HOST_KEEPALIVE
/***********************************************************************/ /***********************************************************************/
...@@ -192,11 +197,16 @@ ...@@ -192,11 +197,16 @@
/*********************************************************************** /***********************************************************************
************************* Temperature limits *************************** ************************* Temperature limits ***************************
***********************************************************************/ ***********************************************************************/
// Actual temperature must be close to target for this long before M109 returns success // Hotend temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 10 // (seconds) #define TEMP_RESIDENCY_TIME 10 // (seconds)
#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one #define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
#define TEMP_WINDOW 1 // (degC) Window around target to start the residency timer x degC early. #define TEMP_WINDOW 1 // (degC) Window around target to start the residency timer x degC early.
// Bed temperature must be close to target for this long before M190 returns success
#define TEMP_BED_RESIDENCY_TIME 0 // (seconds)
#define TEMP_BED_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
#define TEMP_BED_WINDOW 1 // (degC) Window around target to start the residency timer x degC early.
// When temperature exceeds max temp, your heater will be switched off. // When temperature exceeds max temp, your heater will be switched off.
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure! // This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
// You should use MINTEMP for thermistor short/failure protection. // You should use MINTEMP for thermistor short/failure protection.
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
// //
// C, Y-axis // C, Y-axis
// | // |
// DELTA_ALPHA_CA=120° | DELTA_ALPHA_CB=120° // DELTA_ALPHA_CA=120° | DELTA_ALPHA_CB=120°
// | // |
// |______ X-axis // |______ X-axis
// / \ // / \
......
/** /**
* MK Firmware * MK 3D Printer Firmware
* *
* Based on Marlin, Sprinter and grbl * Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "Configuration_Store.h" #include "Configuration_Store.h"
#include "module/language/language.h" #include "module/language/language.h"
#include "module/stopwatch/stopwatch.h"
#include "module/MK_Main.h" #include "module/MK_Main.h"
#include "module/motion/planner.h" #include "module/motion/planner.h"
#include "module/motion/stepper_indirection.h" #include "module/motion/stepper_indirection.h"
......
This diff is collapsed.
...@@ -9,16 +9,17 @@ ...@@ -9,16 +9,17 @@
void get_command(); void get_command();
void idle(bool ignore_stepper_queue = false); void idle(
#if ENABLED(FILAMENTCHANGEENABLE)
bool no_stepper_sleep=false // pass true to keep steppers from disabling on timeout
#endif
);
void manage_inactivity(bool ignore_stepper_queue = false); void manage_inactivity(bool ignore_stepper_queue = false);
void FlushSerialRequestResend(); void FlushSerialRequestResend();
void ok_to_send(); void ok_to_send();
bool setTargetedExtruder(int code);
bool setTargetedHotend(int code);
#if MECH(DELTA) #if MECH(DELTA)
float probe_bed(float x, float y); float probe_bed(float x, float y);
void set_delta_constants(); void set_delta_constants();
...@@ -63,25 +64,27 @@ void Stop(); ...@@ -63,25 +64,27 @@ void Stop();
* Debug flags - with repetier * Debug flags - with repetier
*/ */
enum DebugFlags { enum DebugFlags {
DEBUG_ECHO = _BV(0), DEBUG_NONE = 0,
DEBUG_INFO = _BV(1), DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed
DEBUG_ERRORS = _BV(2), DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output
DEBUG_DRYRUN = _BV(3), DEBUG_ERRORS = _BV(2), ///< Not implemented
DEBUG_COMMUNICATION = _BV(4), DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting
DEBUG_DEBUG = _BV(5) DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
DEBUG_DEBUG = _BV(5) ///< Print Debug
}; };
extern uint8_t mk_debug_flags;
#define DEBUGGING(F) (mk_debug_flags & (DEBUG_## F))
void clamp_to_software_endstops(float target[3]); void clamp_to_software_endstops(float target[3]);
extern uint8_t debugLevel;
extern bool Running; extern bool Running;
inline bool IsRunning() { return Running; } inline bool IsRunning() { return Running; }
inline bool IsStopped() { return !Running; } inline bool IsStopped() { return !Running; }
extern bool Printing; extern bool Printing;
bool enqueuecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full bool enqueue_and_echo_command(const char* cmd, bool say_ok = false); // put a single ASCII command at the end of the current buffer or return false when it is full
void enqueuecommands_P(const char *cmd); //put one or many ASCII commands at the end of the current buffer, read from flash void enqueue_and_echo_command_now(const char* cmd); // enqueue now, only return when the command has been enqueued
void enqueue_and_echo_commands_P(const char* cmd); // put one or many ASCII commands at the end of the current buffer, read from flash
void prepare_arc_move(char isclockwise); void prepare_arc_move(char isclockwise);
void clamp_to_software_endstops(float target[3]); void clamp_to_software_endstops(float target[3]);
...@@ -139,11 +142,15 @@ extern double printer_usage_filament; ...@@ -139,11 +142,15 @@ extern double printer_usage_filament;
extern float extrude_min_temp; extern float extrude_min_temp;
#endif #endif
#if ENABLED(HOST_KEEPALIVE_FEATURE)
extern uint8_t host_keepalive_interval;
#endif
extern int fanSpeed; extern int fanSpeed;
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)
extern int ValvePressure; extern int baricuda_valve_pressure;
extern int EtoPPressure; extern int baricuda_e_to_p_pressure;
#endif #endif
#if ENABLED(FAN_SOFT_PWM) #if ENABLED(FAN_SOFT_PWM)
...@@ -202,8 +209,8 @@ extern int fanSpeed; ...@@ -202,8 +209,8 @@ extern int fanSpeed;
extern bool config_readed; extern bool config_readed;
#endif #endif
extern millis_t print_job_start_ms; // Print job timer
extern millis_t print_job_stop_ms; extern Stopwatch print_job_timer;
// Handling multiple extruders pins // Handling multiple extruders pins
extern uint8_t active_extruder; extern uint8_t active_extruder;
......
...@@ -2,15 +2,16 @@ ...@@ -2,15 +2,16 @@
#define COMMUNICATION_H #define COMMUNICATION_H
#define START "start" // start for host #define START "start" // start for host
#define OK "ok " // ok answer for host #define OK "ok" // ok answer for host
#define ER "Error: " // error for host #define ER "Error:" // error for host
#define WT "Wait" // wait for host #define WT "wait" // wait for host
#define DB "Echo: " // message for user #define DB "Echo:" // message for user
#define DEB "Debug: " // message for debug #define DEB "Debug:" // message for debug
#define CFG "Config: " // config for host #define CFG "Config:" // config for host
#define INFO "Info: " // info for host #define INFO "Info:" // info for host
#define RESEND "Resend: " // resend for host #define BUSY "busy:" // buys for host
#define WARNING "Warning: " // warning for host #define RESEND "Resend:" // resend for host
#define WARNING "Warning:" // warning for host
#define TNAN "NAN" // NAN for host #define TNAN "NAN" // NAN for host
#define TINF "INF" // INF for host #define TINF "INF" // INF for host
#define PAUSE "//action:pause" // command for host that support action #define PAUSE "//action:pause" // command for host that support action
......
This diff is collapsed.
...@@ -101,6 +101,9 @@ ...@@ -101,6 +101,9 @@
#define SERIAL_COUNT_X " Count X: " #define SERIAL_COUNT_X " Count X: "
#define SERIAL_ERR_KILLED "Printer halted. kill() called!" #define SERIAL_ERR_KILLED "Printer halted. kill() called!"
#define SERIAL_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)" #define SERIAL_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
#define SERIAL_BUSY_PROCESSING "processing"
#define SERIAL_BUSY_PAUSED_FOR_USER "paused for user"
#define SERIAL_BUSY_PAUSED_FOR_INPUT "paused for input"
#define SERIAL_UNKNOWN_COMMAND "Unknown command: \"" #define SERIAL_UNKNOWN_COMMAND "Unknown command: \""
#define SERIAL_ACTIVE_DRIVER "Active Driver: " #define SERIAL_ACTIVE_DRIVER "Active Driver: "
#define SERIAL_ACTIVE_EXTRUDER "Active Extruder: " #define SERIAL_ACTIVE_EXTRUDER "Active Extruder: "
......
This diff is collapsed.
...@@ -490,7 +490,7 @@ static void lcd_main_menu() { ...@@ -490,7 +490,7 @@ static void lcd_main_menu() {
*/ */
void lcd_set_home_offsets() { void lcd_set_home_offsets() {
// M428 Command // M428 Command
enqueuecommands_P(PSTR("M428")); enqueue_and_echo_commands_P(PSTR("M428"));
lcd_return_to_status(); lcd_return_to_status();
} }
...@@ -513,9 +513,9 @@ void lcd_set_home_offsets() { ...@@ -513,9 +513,9 @@ void lcd_set_home_offsets() {
static void lcd_tune_fixstep() { static void lcd_tune_fixstep() {
#if MECH(DELTA) #if MECH(DELTA)
enqueuecommands_P(PSTR("G28 B")); enqueue_and_echo_commands_P(PSTR("G28 B"));
#else #else
enqueuecommands_P(PSTR("G28 X Y B")); enqueue_and_echo_commands_P(PSTR("G28 X Y B"));
#endif #endif
} }
...@@ -1654,7 +1654,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01) ...@@ -1654,7 +1654,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01)
lcd_move_y(); lcd_move_y();
} }
static void reprapworld_keypad_move_home() { static void reprapworld_keypad_move_home() {
enqueuecommands_P((PSTR("G28"))); // move all axis home enqueue_and_echo_commands_P((PSTR("G28"))); // move all axis home
} }
#endif // REPRAPWORLD_KEYPAD #endif // REPRAPWORLD_KEYPAD
...@@ -1706,7 +1706,7 @@ void lcd_quick_feedback() { ...@@ -1706,7 +1706,7 @@ void lcd_quick_feedback() {
*/ */
static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); } static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); } static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); } static void menu_action_gcode(const char* pgcode) { enqueue_and_echo_commands_P(pgcode); }
static void menu_action_function(menuFunc_t func) { (*func)(); } static void menu_action_function(menuFunc_t func) { (*func)(); }
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
...@@ -1716,8 +1716,8 @@ static void menu_action_function(menuFunc_t func) { (*func)(); } ...@@ -1716,8 +1716,8 @@ static void menu_action_function(menuFunc_t func) { (*func)(); }
char* c; char* c;
sprintf_P(cmd, PSTR("M23 %s"), longFilename); sprintf_P(cmd, PSTR("M23 %s"), longFilename);
for (c = &cmd[4]; *c; c++) *c = tolower(*c); for (c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd); enqueue_and_echo_command(cmd);
enqueuecommands_P(PSTR("M24")); enqueue_and_echo_commands_P(PSTR("M24"));
lcd_return_to_status(); lcd_return_to_status();
} }
...@@ -2482,7 +2482,7 @@ char* ftostr52(const float& x) { ...@@ -2482,7 +2482,7 @@ char* ftostr52(const float& x) {
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_6)); LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_6));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(" ")); LCD_Printpos(0, 1); lcd_printPGM(PSTR(" "));
HAL::delayMilliseconds(5000); HAL::delayMilliseconds(5000);
enqueuecommands_P(PSTR("G28")); enqueue_and_echo_commands_P(PSTR("G28"));
lcd_goto_menu(lcd_prepare_menu); lcd_goto_menu(lcd_prepare_menu);
} }
break; break;
...@@ -2491,7 +2491,7 @@ char* ftostr52(const float& x) { ...@@ -2491,7 +2491,7 @@ char* ftostr52(const float& x) {
static void config_lcd_level_bed() { static void config_lcd_level_bed() {
ECHO_EM(MSG_MBL_SETTING); ECHO_EM(MSG_MBL_SETTING);
enqueuecommands_P(PSTR("G28 M")); enqueue_and_echo_commands_P(PSTR("G28 M"));
pageShowInfo = 0; pageShowInfo = 0;
lcd_goto_menu(lcd_level_bed); lcd_goto_menu(lcd_level_bed);
} }
......
...@@ -726,11 +726,11 @@ static void lcd_implementation_status_screen() { ...@@ -726,11 +726,11 @@ static void lcd_implementation_status_screen() {
#endif // LCD_WIDTH > 19 && SDSUPPORT #endif // LCD_WIDTH > 19 && SDSUPPORT
lcd.setCursor(LCD_WIDTH - 6, 2); lcd.setCursor(LCD_WIDTH - 6, 2);
if(print_job_start_ms != 0) { uint16_t time = print_job_timer.duration() / 60;
if(time != 0) {
#if HAS(LCD_POWER_SENSOR) #if HAS(LCD_POWER_SENSOR)
if (millis() < print_millis + 1000) { if (millis() < print_millis + 1000) {
lcd.print(LCD_STR_CLOCK[0]); lcd.print(LCD_STR_CLOCK[0]);
uint16_t time = millis()/60000 - print_job_start_ms/60000;
lcd.print(itostr2(time/60)); lcd.print(itostr2(time/60));
lcd.print(':'); lcd.print(':');
lcd.print(itostr2(time%60)); lcd.print(itostr2(time%60));
...@@ -741,7 +741,6 @@ static void lcd_implementation_status_screen() { ...@@ -741,7 +741,6 @@ static void lcd_implementation_status_screen() {
} }
#else #else
lcd.print(LCD_STR_CLOCK[0]); lcd.print(LCD_STR_CLOCK[0]);
uint16_t time = millis()/60000 - print_job_start_ms/60000;
lcd.print(itostr2(time/60)); lcd.print(itostr2(time/60));
lcd.print(':'); lcd.print(':');
lcd.print(itostr2(time%60)); lcd.print(itostr2(time%60));
......
...@@ -25,11 +25,18 @@ ...@@ -25,11 +25,18 @@
// Macros to support option testing // Macros to support option testing
#define ENABLED defined #define ENABLED defined
#define DISABLED !defined #define DISABLED !defined
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0) #define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
#define HAS(FE) (HAS_##FE) #define HAS(FE) (HAS_##FE)
#define HASNT(FE) (!(HAS_##FE)) #define HASNT(FE) (!(HAS_##FE))
#define PENDING(NOW,SOON) ((long)(NOW-(SOON))<0)
#define ELAPSED(NOW,SOON) (!PENDING(NOW,SOON))
// Macros to contrain values // Macros to contrain values
#define NUMERIC(a) ((a) >= '0' && '9' >= (a))
#define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-')
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0) #define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0) #define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
#define COUNT(a) (sizeof(a)/sizeof(*a)) #define COUNT(a) (sizeof(a)/sizeof(*a))
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
//=========================================================================== //===========================================================================
void ZWobble::setSample(float zRod, float zActual) { void ZWobble::setSample(float zRod, float zActual) {
if (debugLevel & DEBUG_DEBUG) { if (DEBUGGING(DEBUG)) {
ECHO_SMV(DB, "New sample Rod: ", zRod); ECHO_SMV(DB, "New sample Rod: ", zRod);
ECHO_EMV(" Act: ", zActual); ECHO_EMV(" Act: ", zActual);
} }
...@@ -446,7 +446,7 @@ ...@@ -446,7 +446,7 @@
if (originZ < ZWOBBLE_MIN_Z || targetZ < ZWOBBLE_MIN_Z) return; if (originZ < ZWOBBLE_MIN_Z || targetZ < ZWOBBLE_MIN_Z) return;
if (debugLevel & DEBUG_DEBUG) { if (DEBUGGING(DEBUG)) {
ECHO_SMV(DB, "Origin: ", originZ); ECHO_SMV(DB, "Origin: ", originZ);
ECHO_MV(" Target: ", targetZ); ECHO_MV(" Target: ", targetZ);
} }
...@@ -461,18 +461,18 @@ ...@@ -461,18 +461,18 @@
else else
originZRod = findZRod(originZ); originZRod = findZRod(originZ);
if (debugLevel & DEBUG_DEBUG) if (DEBUGGING(DEBUG))
ECHO_MV(" Origin rod: ", originZRod); ECHO_MV(" Origin rod: ", originZRod);
float targetZRod = findZRod(targetZ); float targetZRod = findZRod(targetZ);
if (debugLevel & DEBUG_DEBUG) if (DEBUGGING(DEBUG))
ECHO_MV(" Target Rod: ", targetZRod); ECHO_MV(" Target Rod: ", targetZRod);
// difference in steps between the correct movement (originZRod->targetZRod) and the planned movement // difference in steps between the correct movement (originZRod->targetZRod) and the planned movement
long stepDiff = lround((targetZRod - originZRod) * axis_steps_per_unit[Z_AXIS]) - (lround(targetZ * axis_steps_per_unit[Z_AXIS]) - position[Z_AXIS]); long stepDiff = lround((targetZRod - originZRod) * axis_steps_per_unit[Z_AXIS]) - (lround(targetZ * axis_steps_per_unit[Z_AXIS]) - position[Z_AXIS]);
if (debugLevel & DEBUG_DEBUG) if (DEBUGGING(DEBUG))
ECHO_EMV(" stepDiff: ", stepDiff); ECHO_EMV(" stepDiff: ", stepDiff);
lastZ = targetZ; lastZ = targetZ;
......
...@@ -552,7 +552,7 @@ float junction_deviation = 0.1; ...@@ -552,7 +552,7 @@ float junction_deviation = 0.1;
if (extruder != 1) if (extruder != 1)
#endif #endif
{ {
if (degHotend(extruder) < extrude_min_temp && !(debugLevel & DEBUG_DRYRUN)) { if (degHotend(extruder) < extrude_min_temp && !(DEBUGGING(DRYRUN))) {
position[E_AXIS] = target[E_AXIS]; //behave as if the move really took place, but ignore E part position[E_AXIS] = target[E_AXIS]; //behave as if the move really took place, but ignore E part
de = 0; // no difference de = 0; // no difference
ECHO_LM(ER, SERIAL_ERR_COLD_EXTRUDE_STOP); ECHO_LM(ER, SERIAL_ERR_COLD_EXTRUDE_STOP);
......
...@@ -636,7 +636,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -636,7 +636,7 @@ ISR(TIMER1_COMPA_vect) {
current_block = NULL; current_block = NULL;
plan_discard_current_block(); plan_discard_current_block();
#if ENABLED(SD_FINISHED_RELEASECOMMAND) #if ENABLED(SD_FINISHED_RELEASECOMMAND)
if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif #endif
cleaning_buffer_counter--; cleaning_buffer_counter--;
OCR1A = 200; OCR1A = 200;
......
...@@ -276,8 +276,8 @@ ...@@ -276,8 +276,8 @@
char* c; char* c;
sprintf_P(cmd, PSTR("M23 %s"), filename); sprintf_P(cmd, PSTR("M23 %s"), filename);
for(c = &cmd[4]; *c; c++) *c = tolower(*c); for(c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd); enqueue_and_echo_command(cmd);
enqueuecommands_P(PSTR("M24")); enqueue_and_echo_commands_P(PSTR("M24"));
setpageInfo(); setpageInfo();
} }
...@@ -428,14 +428,14 @@ ...@@ -428,14 +428,14 @@
void sethotPopCallback(void *ptr) { void sethotPopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
set1.getText(buffer, sizeof(buffer)); set1.getText(buffer, sizeof(buffer));
enqueuecommands_P(buffer); enqueue_and_echo_commands_P(buffer);
setpageInfo(); setpageInfo();
} }
void setgcodePopCallback(void *ptr) { void setgcodePopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
Tgcode.getText(buffer, sizeof(buffer)); Tgcode.getText(buffer, sizeof(buffer));
enqueuecommands_P(buffer); enqueue_and_echo_commands_P(buffer);
Pmenu.show(); Pmenu.show();
} }
...@@ -453,9 +453,9 @@ ...@@ -453,9 +453,9 @@
void setmovePopCallback(void *ptr) { void setmovePopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
movecmd.getText(buffer, sizeof(buffer)); movecmd.getText(buffer, sizeof(buffer));
enqueuecommands_P(PSTR("G91")); enqueue_and_echo_commands_P(PSTR("G91"));
enqueuecommands_P(buffer); enqueue_and_echo_commands_P(buffer);
enqueuecommands_P(PSTR("G90")); enqueue_and_echo_commands_P(PSTR("G90"));
} }
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
...@@ -647,7 +647,7 @@ ...@@ -647,7 +647,7 @@
NPlay.setPic(17); NPlay.setPic(17);
// Estimate End Time // Estimate End Time
uint16_t time = (millis() - print_job_start_ms) / 60000; uint16_t time = print_job_timer.duration() / 60;
uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone(); uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
if (end_time > (60 * 23)) { if (end_time > (60 * 23)) {
lcd_setstatus("End --:--"); lcd_setstatus("End --:--");
......
...@@ -320,7 +320,7 @@ void CardReader::printingHasFinished() { ...@@ -320,7 +320,7 @@ void CardReader::printingHasFinished() {
sdprinting = false; sdprinting = false;
if (SD_FINISHED_STEPPERRELEASE) { if (SD_FINISHED_STEPPERRELEASE) {
//finishAndDisableSteppers(); //finishAndDisableSteppers();
enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
} }
autotempShutdown(); autotempShutdown();
} }
......
/**
* MK 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/>.
*
*/
#include "../../base.h"
#include "stopwatch.h"
Stopwatch::Stopwatch() {
this->reset();
}
void Stopwatch::stop() {
#if ENABLED(DEBUG_STOPWATCH)
debug(PSTR("stop"));
#endif
if (!this->isRunning()) return;
this->status = STPWTCH_STOPPED;
this->stopTimestamp = millis();
}
void Stopwatch::pause() {
#if ENABLED(DEBUG_STOPWATCH)
debug(PSTR("pause"));
#endif
if (!this->isRunning()) return;
this->status = STPWTCH_PAUSED;
this->stopTimestamp = millis();
}
void Stopwatch::start() {
#if ENABLED(DEBUG_STOPWATCH)
debug(PSTR("start"));
#endif
if (this->isRunning()) return;
if (this->isPaused()) this->accumulator = this->duration();
else this->reset();
this->status = STPWTCH_RUNNING;
this->startTimestamp = millis();
}
void Stopwatch::reset() {
#if ENABLED(DEBUG_STOPWATCH)
debug(PSTR("reset"));
#endif
this->status = STPWTCH_STOPPED;
this->startTimestamp = 0;
this->stopTimestamp = 0;
this->accumulator = 0;
}
bool Stopwatch::isRunning() {
return (this->status == STPWTCH_RUNNING) ? true : false;
}
bool Stopwatch::isPaused() {
return (this->status == STPWTCH_PAUSED) ? true : false;
}
uint16_t Stopwatch::duration() {
return (((this->isRunning()) ? millis() : this->stopTimestamp)
- this->startTimestamp) / 1000 + this->accumulator;
}
#if ENABLED(DEBUG_STOPWATCH)
void Stopwatch::debug(const char func[]) {
if (DEBUGGING(INFO)) {
ECHO_MT("Stopwatch::", func);
ECHO_EM("()");
}
}
#endif
/**
* MK 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/>.
*
*/
#ifndef STOPWATCH_H
#define STOPWATCH_H
// Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM)
//#define DEBUG_STOPWATCH
enum StopwatchStatus {
STPWTCH_STOPPED,
STPWTCH_RUNNING,
STPWTCH_PAUSED
};
/**
* @brief Stopwatch class
* @details This class acts as a timer proving stopwatch functionality including
* the ability to pause the running time counter.
*/
class Stopwatch {
private:
StopwatchStatus status;
uint16_t accumulator;
uint32_t startTimestamp;
uint32_t stopTimestamp;
public:
/**
* @brief Class constructor
*/
Stopwatch();
/**
* @brief Stops the stopwatch
* @details Stops the running timer, it will silently ignore the request if
* no timer is currently running.
*/
void stop();
/**
* @brief Pauses the stopwatch
* @details Pauses the running timer, it will silently ignore the request if
* no timer is currently running.
*/
void pause();
/**
* @brief Starts the stopwatch
* @details Starts the timer, it will silently ignore the request if the
* timer is already running.
*/
void start();
/**
* @brief Resets the stopwatch
* @details Resets all settings to their default values.
*/
void reset();
/**
* @brief Checks if the timer is running
* @details Returns true if the timer is currently running, false otherwise.
* @return bool
*/
bool isRunning();
/**
* @brief Checks if the timer is paused
* @details Returns true if the timer is currently paused, false otherwise.
* @return bool
*/
bool isPaused();
/**
* @brief Gets the running time
* @details Returns the total number of seconds the timer has been running.
* @return uint16_t
*/
uint16_t duration();
#if ENABLED(DEBUG_STOPWATCH)
/**
* @brief Prints a debug message
* @details Prints a simple debug message "Stopwatch::function"
*/
static void debug(const char func[]);
#endif
};
#endif //STOPWATCH_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment