2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie 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.
4 Smoothie 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.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
8 #include "ExtruderMaker.h"
9 #include "libs/Module.h"
10 #include "libs/Kernel.h"
13 #include "ToolManager.h"
14 #include "checksumm.h"
15 #include "ConfigValue.h"
16 #include "StreamOutputPool.h"
22 #define extruder_checksum CHECKSUM("extruder")
23 #define enable_checksum CHECKSUM("enable")
25 void ExtruderMaker::load_tools(){
27 // Get every "declared" extruder module
28 vector
<uint16_t> modules
;
29 THEKERNEL
->config
->get_module_list( &modules
, extruder_checksum
);
31 if(modules
.size() == 0) {
32 THEKERNEL
->streams
->printf("NOTE: No extruders configured\n");
36 // count number of enabled extruders
38 for(auto cs
: modules
) {
39 if( THEKERNEL
->config
->value(extruder_checksum
, cs
, enable_checksum
)->as_bool() ){
45 THEKERNEL
->streams
->printf("NOTE: No extruders enabled\n");
49 ToolManager
*toolmanager
= nullptr;
51 // ONLY do this if multitool enabled and more than one tool is defined
52 toolmanager
= new ToolManager();
53 THEKERNEL
->add_module( toolmanager
);
56 // only one extruder so no tool manager required
57 THEKERNEL
->streams
->printf("NOTE: One extruder configured and enabled\n");
61 // For every extruder found, setup the enabled ones
62 for(auto cs
: modules
){
63 // If module is enabled
64 if( THEKERNEL
->config
->value(extruder_checksum
, cs
, enable_checksum
)->as_bool() ){
66 // Make a new extruder module
67 Extruder
* extruder
= new Extruder(cs
);
69 // Add the Extruder module to the kernel
70 THEKERNEL
->add_module( extruder
);
72 if(toolmanager
!= nullptr) {
73 // Add the extruder module to the ToolsManager if it was created
74 toolmanager
->add_tool( extruder
);
77 // if not managed by toolmanager we need to enable the one extruder
84 THEKERNEL
->streams
->printf("NOTE: %d extruders enabled out of %d\n", cnt
, modules
.size());