From 07cf75883f125d569cb2013594a7519074eb34e4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 18 Sep 2017 01:05:44 -0500 Subject: [PATCH] Move T (tool change) to cpp --- Marlin/src/Marlin.cpp | 18 +++++------------- Marlin/src/gcode/control/{T.h => T.cpp} | 7 ++++++- Marlin/src/gcode/gcode.cpp | 6 +----- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/module/tool_change.cpp | 9 +++++++++ Marlin/src/module/tool_change.h | 2 ++ 6 files changed, 24 insertions(+), 20 deletions(-) rename Marlin/src/gcode/control/{T.h => T.cpp} (91%) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 7d6231423b..a5bc0d2433 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -54,10 +54,6 @@ #include "libs/buzzer.h" #endif -#if (ENABLED(SWITCHING_EXTRUDER) && !DONT_SWITCH) || ENABLED(SWITCHING_NOZZLE) - #include "module/tool_change.h" -#endif - #if ENABLED(DIGIPOT_I2C) #include "feature/digipot/digipot.h" #endif @@ -138,6 +134,10 @@ #include "feature/caselight.h" #endif +#if (ENABLED(SWITCHING_EXTRUDER) && !DONT_SWITCH) || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER) + #include "module/tool_change.h" +#endif + bool Running = true; /** @@ -320,8 +320,6 @@ void quickstop_stepper() { SYNC_PLAN_POSITION_KINEMATIC(); } -#include "gcode/control/T.h" - #if ENABLED(USE_CONTROLLER_FAN) void controllerFan() { @@ -932,13 +930,7 @@ void setup() { #endif #if ENABLED(PARKING_EXTRUDER) - #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT) - pe_activate_magnet(0); - pe_activate_magnet(1); - #else - pe_deactivate_magnet(0); - pe_deactivate_magnet(1); - #endif + pe_magnet_init(); #endif } diff --git a/Marlin/src/gcode/control/T.h b/Marlin/src/gcode/control/T.cpp similarity index 91% rename from Marlin/src/gcode/control/T.h rename to Marlin/src/gcode/control/T.cpp index e45af907eb..24cd62c701 100644 --- a/Marlin/src/gcode/control/T.h +++ b/Marlin/src/gcode/control/T.cpp @@ -20,15 +20,20 @@ * */ +#include "../gcode.h" #include "../../module/tool_change.h" +#if ENABLED(DEBUG_LEVELING_FEATURE) || HOTENDS > 1 + #include "../../module/motion.h" +#endif + /** * T0-T3: Switch tool, usually switching extruders * * F[units/min] Set the movement feedrate * S1 Don't move the tool in XY after change */ -void gcode_T(uint8_t tmp_extruder) { +void GcodeSuite::T(const uint8_t tmp_extruder) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c3a1597c06..aa8cfd6dfc 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -116,8 +116,6 @@ void GcodeSuite::dwell(millis_t time) { // // Placeholders for non-migrated codes // -extern void gcode_T(uint8_t tmp_extruder); - #if ENABLED(M100_FREE_MEMORY_WATCHER) extern void M100_dump_routine(const char * const title, const char *start, const char *end); #endif @@ -690,9 +688,7 @@ void GcodeSuite::process_next_command() { } break; - case 'T': - gcode_T(parser.codenum); - break; + case 'T': T(parser.codenum); break; // Tn: Tool Change default: parser.unknown_command_error(); } diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index f74ccef26f..4bf97f79c8 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -722,7 +722,7 @@ private: static void M999(); - static void T(uint8_t tmp_extruder); + static void T(const uint8_t tmp_extruder); }; diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 68b8d82eaa..7363e68f51 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -84,6 +84,15 @@ #if ENABLED(PARKING_EXTRUDER) + void pe_magnet_init() { + for (uint8_t n = 0; n <= 1; ++n) + #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT) + pe_activate_magnet(n); + #else + pe_deactivate_magnet(n); + #endif + } + void pe_set_magnet(const uint8_t extruder_num, const uint8_t state) { switch (extruder_num) { case 1: OUT_WRITE(SOL1_PIN, state); break; diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index cfd1c1605d..a464085d44 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -46,6 +46,8 @@ inline void pe_activate_magnet(const uint8_t extruder_num) { pe_set_magnet(extruder_num, PE_MAGNET_ON_STATE); } inline void pe_deactivate_magnet(const uint8_t extruder_num) { pe_set_magnet(extruder_num, !PE_MAGNET_ON_STATE); } + void pe_magnet_init(); + #endif // PARKING_EXTRUDER /**