FIx suspend/pause and saving/restoring Extruder state, this is complex due to possibl...
[clinton/Smoothieware.git] / src / modules / tools / extruder / Extruder.h
1 /*
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/>.
6 */
7
8
9
10 #pragma once
11
12 #include "Tool.h"
13 #include "Pin.h"
14
15 #include <tuple>
16
17 class StepperMotor;
18
19 // NOTE Tool is also a module, no need for multiple inheritance here
20 class Extruder : public Tool {
21 public:
22 Extruder(uint16_t config_identifier);
23 virtual ~Extruder();
24
25 void on_module_loaded();
26 void on_gcode_received(void*);
27
28 void select();
29 void deselect();
30
31 private:
32 void config_load();
33 void on_get_public_data(void* argument);
34 void on_set_public_data(void* argument);
35 float check_max_speeds(float target, float isecs);
36
37 StepperMotor *stepper_motor;
38
39 // kept together so they can be passed as public data
40 struct {
41 float filament_diameter; // filament diameter
42 float extruder_multiplier; // flow rate 1.0 == 100%
43 float retract_length; // firmware retract length
44 };
45
46 float volumetric_multiplier;
47 float max_volumetric_rate; // used for calculating volumetric rate in mm³/sec
48
49 // for firmware retract
50 float retract_feedrate;
51 float retract_recover_feedrate;
52 float retract_recover_length;
53 float retract_zlift_length;
54 float retract_zlift_feedrate;
55
56 // for saving and restoring extruder position
57 std::tuple<float, float, int32_t> saved_position;
58
59 struct {
60 uint8_t motor_id:8;
61 bool retracted:1;
62 bool cancel_zlift_restore:1; // hack to stop a G11 zlift restore from overring an absolute Z setting
63 bool selected:1;
64 bool saved_selected:1;
65 };
66 };