From 51c9c3fe2c56a7bf89cceb08779b377225f8e83f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 9 Jul 2016 16:51:12 -0700 Subject: [PATCH 1/6] Indentation in MarlinSerial.cpp --- Marlin/MarlinSerial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/MarlinSerial.cpp b/Marlin/MarlinSerial.cpp index 114ec1105a..bf7675426d 100644 --- a/Marlin/MarlinSerial.cpp +++ b/Marlin/MarlinSerial.cpp @@ -243,8 +243,8 @@ void MarlinSerial::flush(void) { // register empty flag ourselves. If it is set, pretend an // interrupt has happened and call the handler to free up // space for us. - if(TEST(M_UCSRxA, M_UDREx)) - _tx_udr_empty_irq(); + if (TEST(M_UCSRxA, M_UDREx)) + _tx_udr_empty_irq(); } else { // nop, the interrupt handler will free up space for us } From 315b4c2153e9ab6c6d29e46ff72e1f9b25033034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Zahradn=C3=ADk=20junior?= Date: Fri, 8 Jul 2016 15:00:39 +0200 Subject: [PATCH 2/6] Runout sensor without SD Card --- Marlin/Marlin_main.cpp | 27 +++++++++++++++++++-------- Marlin/SanityCheck.h | 4 ++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8b419b9e7e..0c3d6aab95 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -4403,6 +4403,8 @@ inline void gcode_M104() { #if ENABLED(PRINTJOB_TIMER_AUTOSTART) /** + * Stop the timer at the end of print, starting is managed by + * 'heat and wait' M109. * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot * stand by mode, for instance in a dual extruder setup, without affecting * the running print timer. @@ -4411,12 +4413,6 @@ inline void gcode_M104() { print_job_timer.stop(); LCD_MESSAGEPGM(WELCOME_MSG); } - /** - * We do not check if the timer is already running because this check will - * be done for us inside the Stopwatch::start() method thus a running timer - * will not restart. - */ - else print_job_timer.start(); #endif if (temp > thermalManager.degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING); @@ -4701,7 +4697,22 @@ inline void gcode_M109() { LCD_MESSAGEPGM(MSG_BED_HEATING); bool no_wait_for_cooling = code_seen('S'); - if (no_wait_for_cooling || code_seen('R')) thermalManager.setTargetBed(code_value_temp_abs()); + if (no_wait_for_cooling || code_seen('R')) { + thermalManager.setTargetBed(code_value_temp_abs()); + #if ENABLED(PRINTJOB_TIMER_AUTOSTART) + if(code_value_temp_abs() > BED_MINTEMP) { + /** + * We start the timer when 'heating and waiting' command arrives, LCD + * functions never wait. Cooling down managed by extruders. + * + * We do not check if the timer is already running because this check will + * be done for us inside the Stopwatch::start() method thus a running timer + * will not restart. + */ + print_job_timer.start(); + } + #endif + } #if TEMP_BED_RESIDENCY_TIME > 0 millis_t residency_start_ms = 0; @@ -8112,7 +8123,7 @@ void idle( void manage_inactivity(bool ignore_stepper_queue/*=false*/) { #if ENABLED(FILAMENT_RUNOUT_SENSOR) - if (IS_SD_PRINTING && !(READ(FIL_RUNOUT_PIN) ^ FIL_RUNOUT_INVERTING)) + if ((IS_SD_PRINTING || print_job_timer.isRunning()) && !(READ(FIL_RUNOUT_PIN) ^ FIL_RUNOUT_INVERTING)) handle_filament_runout(); #endif diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 3200982a0e..475d4a8faa 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -111,12 +111,12 @@ #endif /** - * Filament Runout needs a pin and SD Support + * Filament Runout needs a pin and either SD Support or Auto print start detection */ #if ENABLED(FILAMENT_RUNOUT_SENSOR) #if !HAS_FIL_RUNOUT #error "FILAMENT_RUNOUT_SENSOR requires FIL_RUNOUT_PIN." - #elif DISABLED(SDSUPPORT) + #elif DISABLED(SDSUPPORT) && DISABLED(PRINTJOB_TIMER_AUTOSTART) #error "FILAMENT_RUNOUT_SENSOR requires SDSUPPORT." #endif #endif From a2159cfbc38e56b9788993246fb69db493826f6d Mon Sep 17 00:00:00 2001 From: Petr Zahradnik Date: Sat, 9 Jul 2016 11:34:42 +0200 Subject: [PATCH 3/6] Error message change in SanityCheck.h --- Marlin/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 475d4a8faa..17d6cff5f9 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -117,7 +117,7 @@ #if !HAS_FIL_RUNOUT #error "FILAMENT_RUNOUT_SENSOR requires FIL_RUNOUT_PIN." #elif DISABLED(SDSUPPORT) && DISABLED(PRINTJOB_TIMER_AUTOSTART) - #error "FILAMENT_RUNOUT_SENSOR requires SDSUPPORT." + #error "FILAMENT_RUNOUT_SENSOR requires SDSUPPORT or PRINTJOB_TIMER_AUTOSTART." #endif #endif From e282d69f63b3ea4625a7041946d5e5e95e42c97e Mon Sep 17 00:00:00 2001 From: Petr Zahradnik Date: Sat, 9 Jul 2016 11:38:18 +0200 Subject: [PATCH 4/6] Print job timer comment changed --- Marlin/Configuration.h | 5 ++++- Marlin/example_configurations/Cartesio/Configuration.h | 5 ++++- Marlin/example_configurations/Felix/Configuration.h | 5 ++++- Marlin/example_configurations/Hephestos/Configuration.h | 5 ++++- Marlin/example_configurations/Hephestos_2/Configuration.h | 5 ++++- Marlin/example_configurations/K8200/Configuration.h | 5 ++++- Marlin/example_configurations/K8400/Configuration.h | 5 ++++- .../RepRapWorld/Megatronics/Configuration.h | 5 ++++- Marlin/example_configurations/RigidBot/Configuration.h | 5 ++++- Marlin/example_configurations/SCARA/Configuration.h | 5 ++++- Marlin/example_configurations/TAZ4/Configuration.h | 5 ++++- Marlin/example_configurations/WITBOX/Configuration.h | 5 ++++- .../example_configurations/adafruit/ST7565/Configuration.h | 5 ++++- Marlin/example_configurations/delta/biv2.5/Configuration.h | 5 ++++- Marlin/example_configurations/delta/generic/Configuration.h | 5 ++++- .../example_configurations/delta/kossel_mini/Configuration.h | 5 ++++- .../example_configurations/delta/kossel_pro/Configuration.h | 5 ++++- .../example_configurations/delta/kossel_xl/Configuration.h | 5 ++++- Marlin/example_configurations/makibox/Configuration.h | 5 ++++- Marlin/example_configurations/tvrrug/Round2/Configuration.h | 5 ++++- 20 files changed, 80 insertions(+), 20 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index aa1733cc26..947c9245ea 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -790,7 +790,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index 2fd390eed2..1a78e0b5d4 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -789,7 +789,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index d8495eb840..b6d798cb44 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -773,7 +773,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index a047e59c55..0e9bf234af 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -782,7 +782,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 4704fa8227..c4bd607791 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -784,7 +784,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 5267edcbd2..ddf6f7d6c6 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -807,7 +807,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/K8400/Configuration.h b/Marlin/example_configurations/K8400/Configuration.h index a7c61de56b..550f9bd3ea 100644 --- a/Marlin/example_configurations/K8400/Configuration.h +++ b/Marlin/example_configurations/K8400/Configuration.h @@ -790,7 +790,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index e394b6b2af..3de1f0540b 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -790,7 +790,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index ad5c408500..367cfcb48a 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -788,7 +788,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 1c23794d01..c63171354f 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -798,7 +798,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index e5a7dd8443..7c50aa0f3b 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -811,7 +811,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index d3012dbfb1..0b9a6a80d5 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -782,7 +782,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index 9c4f23d181..c7592bc8d8 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -790,7 +790,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index 3dfd2dd93f..aca2d8b498 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -885,7 +885,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 396a406710..38798fc9a5 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -879,7 +879,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 53f0310b0b..fef003f0af 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -882,7 +882,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index ec37272def..f8685d5f32 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -882,7 +882,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index 1d17d17f1f..2dc46f30c9 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -884,7 +884,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 6543925582..0b33f909b1 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -793,7 +793,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 8d14edadfb..2771c366e6 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -784,7 +784,10 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // Print job timer // // Enable this option to automatically start and stop the -// print job timer when M104 and M109 commands are received. +// print job timer when M104/M109/M190 commands are received. +// M104 (extruder without wait) - high temp = none, low temp = stop timer +// M109 (extruder with wait) - high temp = start timer, low temp = stop timer +// M190 (bed with wait) - high temp = start timer, low temp = none // // In all cases the timer can be started and stopped using // the following commands: From a8538bd7ce25c2febad6866bc9d2f1bdae8bd984 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 9 Jul 2016 17:53:49 -0700 Subject: [PATCH 5/6] General cleanup, code reduction in Marlin_main.cpp --- Marlin/Marlin_main.cpp | 110 ++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 61 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 0c3d6aab95..679c56adc9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1323,7 +1323,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; } float code_value_temp_diff() { return code_value_float(); } #endif -inline millis_t code_value_millis() { return code_value_ulong(); } +FORCE_INLINE millis_t code_value_millis() { return code_value_ulong(); } inline millis_t code_value_millis_from_seconds() { return code_value_float() * 1000; } bool code_seen(char code) { @@ -3219,7 +3219,6 @@ inline void gcode_G28() { } int8_t px, py; - float z; switch (state) { case MeshReport: @@ -3317,24 +3316,22 @@ inline void gcode_G28() { return; } if (code_seen('Z')) { - z = code_value_axis_units(Z_AXIS); + mbl.z_values[py][px] = code_value_axis_units(Z_AXIS); } else { SERIAL_PROTOCOLLNPGM("Z not entered."); return; } - mbl.z_values[py][px] = z; break; case MeshSetZOffset: if (code_seen('Z')) { - z = code_value_axis_units(Z_AXIS); + mbl.z_offset = code_value_axis_units(Z_AXIS); } else { SERIAL_PROTOCOLLNPGM("Z not entered."); return; } - mbl.z_offset = z; break; case MeshReset: @@ -3866,15 +3863,12 @@ inline void gcode_G92() { #if ENABLED(ULTIPANEL) /** - * M0: // M0 - Unconditional stop - Wait for user button press on LCD - * M1: // M1 - Conditional stop - Wait for user button press on LCD + * M0: Unconditional stop - Wait for user button press on LCD + * M1: Conditional stop - Wait for user button press on LCD */ inline void gcode_M0_M1() { char* args = current_command_args; - uint8_t test_value = 12; - SERIAL_ECHOPAIR("TEST", test_value); - millis_t codenum = 0; bool hasP = false, hasS = false; if (code_seen('P')) { @@ -4096,35 +4090,34 @@ inline void gcode_M31() { * S Pin status from 0 - 255 */ inline void gcode_M42() { - if (code_seen('S')) { - int pin_status = code_value_int(); - if (pin_status < 0 || pin_status > 255) return; + if (!code_seen('S')) return; - int pin_number = code_seen('P') ? code_value_int() : LED_PIN; - if (pin_number < 0) return; + int pin_status = code_value_int(); + if (pin_status < 0 || pin_status > 255) return; - for (uint8_t i = 0; i < COUNT(sensitive_pins); i++) - if (pin_number == sensitive_pins[i]) return; + int pin_number = code_seen('P') ? code_value_int() : LED_PIN; + if (pin_number < 0) return; - pinMode(pin_number, OUTPUT); - digitalWrite(pin_number, pin_status); - analogWrite(pin_number, pin_status); + for (uint8_t i = 0; i < COUNT(sensitive_pins); i++) + if (pin_number == sensitive_pins[i]) return; - #if FAN_COUNT > 0 - switch (pin_number) { - #if HAS_FAN0 - case FAN_PIN: fanSpeeds[0] = pin_status; break; - #endif - #if HAS_FAN1 - case FAN1_PIN: fanSpeeds[1] = pin_status; break; - #endif - #if HAS_FAN2 - case FAN2_PIN: fanSpeeds[2] = pin_status; break; - #endif - } - #endif + pinMode(pin_number, OUTPUT); + digitalWrite(pin_number, pin_status); + analogWrite(pin_number, pin_status); - } // code_seen('S') + #if FAN_COUNT > 0 + switch (pin_number) { + #if HAS_FAN0 + case FAN_PIN: fanSpeeds[0] = pin_status; break; + #endif + #if HAS_FAN1 + case FAN1_PIN: fanSpeeds[1] = pin_status; break; + #endif + #if HAS_FAN2 + case FAN2_PIN: fanSpeeds[2] = pin_status; break; + #endif + } + #endif } #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) @@ -5534,11 +5527,9 @@ inline void gcode_M220() { * M221: Set extrusion percentage (M221 T0 S95) */ inline void gcode_M221() { - if (code_seen('S')) { - int sval = code_value_int(); - if (get_target_extruder_from_command(221)) return; - extruder_multiplier[target_extruder] = sval; - } + if (get_target_extruder_from_command(221)) return; + if (code_seen('S')) + extruder_multiplier[target_extruder] = code_value_int(); } /** @@ -5590,28 +5581,27 @@ inline void gcode_M226() { #if HAS_SERVOS /** - * M280: Get or set servo position. P S + * M280: Get or set servo position. P [S] */ inline void gcode_M280() { - int servo_index = code_seen('P') ? code_value_int() : -1; - int servo_position = 0; - if (code_seen('S')) { - servo_position = code_value_int(); - if (servo_index >= 0 && servo_index < NUM_SERVOS) - MOVE_SERVO(servo_index, servo_position); + if (!code_seen('P')) return; + int servo_index = code_value_int(); + if (servo_index >= 0 && servo_index < NUM_SERVOS) { + if (code_seen('S')) + MOVE_SERVO(servo_index, code_value_int()); else { - SERIAL_ERROR_START; - SERIAL_ERROR("Servo "); - SERIAL_ERROR(servo_index); - SERIAL_ERRORLN(" out of range"); + SERIAL_ECHO_START; + SERIAL_ECHOPGM(" Servo "); + SERIAL_ECHO(servo_index); + SERIAL_ECHOPGM(": "); + SERIAL_ECHOLN(servo[servo_index].read()); } } - else if (servo_index >= 0) { - SERIAL_ECHO_START; - SERIAL_ECHOPGM(" Servo "); - SERIAL_ECHO(servo_index); - SERIAL_ECHOPGM(": "); - SERIAL_ECHOLN(servo[servo_index].read()); + else { + SERIAL_ERROR_START; + SERIAL_ERROR("Servo "); + SERIAL_ERROR(servo_index); + SERIAL_ERRORLN(" out of range"); } } @@ -5864,11 +5854,9 @@ inline void gcode_M303() { * M365: SCARA calibration: Scaling factor, X, Y, Z axis */ inline void gcode_M365() { - for (int8_t i = X_AXIS; i <= Z_AXIS; i++) { - if (code_seen(axis_codes[i])) { + for (int8_t i = X_AXIS; i <= Z_AXIS; i++) + if (code_seen(axis_codes[i])) axis_scaling[i] = code_value_float(); - } - } } #endif // SCARA From 4cd045791c0b64f36e0bf8110c92f89e845d7f65 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 9 Jul 2016 16:25:48 -0700 Subject: [PATCH 6/6] Reduce code size by trusting the compiler --- Marlin/Marlin_main.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 679c56adc9..6fe94a4221 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1338,16 +1338,15 @@ bool code_seen(char code) { */ bool get_target_extruder_from_command(int code) { if (code_seen('T')) { - uint8_t t = code_value_byte(); - if (t >= EXTRUDERS) { + if (code_value_byte() >= EXTRUDERS) { SERIAL_ECHO_START; SERIAL_CHAR('M'); SERIAL_ECHO(code); - SERIAL_ECHOPAIR(" " MSG_INVALID_EXTRUDER " ", t); + SERIAL_ECHOPAIR(" " MSG_INVALID_EXTRUDER " ", code_value_byte()); SERIAL_EOL; return true; } - target_extruder = t; + target_extruder = code_value_byte(); } else target_extruder = active_extruder; @@ -2576,10 +2575,8 @@ void gcode_get_destination() { else destination[i] = current_position[i]; } - if (code_seen('F')) { - float next_feedrate = code_value_linear_units(); - if (next_feedrate > 0.0) feedrate = next_feedrate; - } + if (code_seen('F') && code_value_linear_units() > 0.0) + feedrate = code_value_linear_units(); } void unknown_command_error() { @@ -4387,11 +4384,10 @@ inline void gcode_M104() { #endif if (code_seen('S')) { - float temp = code_value_temp_abs(); - thermalManager.setTargetHotend(temp, target_extruder); + thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder); #if ENABLED(DUAL_X_CARRIAGE) if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0) - thermalManager.setTargetHotend(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset, 1); + thermalManager.setTargetHotend(code_value_temp_abs() == 0.0 ? 0.0 : code_value_temp_abs() + duplicate_extruder_temp_offset, 1); #endif #if ENABLED(PRINTJOB_TIMER_AUTOSTART) @@ -4402,13 +4398,13 @@ inline void gcode_M104() { * stand by mode, for instance in a dual extruder setup, without affecting * the running print timer. */ - if (temp <= (EXTRUDE_MINTEMP)/2) { + if (code_value_temp_abs() <= (EXTRUDE_MINTEMP)/2) { print_job_timer.stop(); LCD_MESSAGEPGM(WELCOME_MSG); } #endif - if (temp > thermalManager.degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING); + if (code_value_temp_abs() > thermalManager.degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING); } } @@ -4566,11 +4562,10 @@ inline void gcode_M109() { bool no_wait_for_cooling = code_seen('S'); if (no_wait_for_cooling || code_seen('R')) { - float temp = code_value_temp_abs(); - thermalManager.setTargetHotend(temp, target_extruder); + thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder); #if ENABLED(DUAL_X_CARRIAGE) if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0) - thermalManager.setTargetHotend(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset, 1); + thermalManager.setTargetHotend(code_value_temp_abs() == 0.0 ? 0.0 : code_value_temp_abs() + duplicate_extruder_temp_offset, 1); #endif #if ENABLED(PRINTJOB_TIMER_AUTOSTART) @@ -4579,7 +4574,7 @@ inline void gcode_M109() { * stand by mode, for instance in a dual extruder setup, without affecting * the running print timer. */ - if (temp <= (EXTRUDE_MINTEMP)/2) { + if (code_value_temp_abs() <= (EXTRUDE_MINTEMP)/2) { print_job_timer.stop(); LCD_MESSAGEPGM(WELCOME_MSG); } @@ -4693,7 +4688,7 @@ inline void gcode_M109() { if (no_wait_for_cooling || code_seen('R')) { thermalManager.setTargetBed(code_value_temp_abs()); #if ENABLED(PRINTJOB_TIMER_AUTOSTART) - if(code_value_temp_abs() > BED_MINTEMP) { + if (code_value_temp_abs() > BED_MINTEMP) { /** * We start the timer when 'heating and waiting' command arrives, LCD * functions never wait. Cooling down managed by extruders. @@ -5241,13 +5236,12 @@ inline void gcode_M200() { if (get_target_extruder_from_command(200)) return; if (code_seen('D')) { - float diameter = code_value_linear_units(); // setting any extruder filament size disables volumetric on the assumption that // slicers either generate in extruder values as cubic mm or as as filament feeds // for all extruders - volumetric_enabled = (diameter != 0.0); + volumetric_enabled = (code_value_linear_units() != 0.0); if (volumetric_enabled) { - filament_size[target_extruder] = diameter; + filament_size[target_extruder] = code_value_linear_units(); // make sure all extruders have some sane value for the filament size for (int i = 0; i < EXTRUDERS; i++) if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;