Merge remote-tracking branch 'upstream/edge' into upstream-master
[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 #ifndef EXTURDER_MODULE_H
11 #define EXTRUDER_MODULE_H
12
13 #include "Tool.h"
14 #include "Pin.h"
15
16 class StepperMotor;
17 class Block;
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, bool single= false);
23 virtual ~Extruder();
24
25 void on_module_loaded();
26 void on_config_reload(void* argument);
27 void on_gcode_received(void*);
28 void on_gcode_execute(void* argument);
29 void on_block_begin(void* argument);
30 void on_block_end(void* argument);
31 void on_halt(void* argument);
32 void on_speed_change(void* argument);
33 void acceleration_tick(void);
34 uint32_t stepper_motor_finished_move(uint32_t dummy);
35 Block* append_empty_block();
36
37 private:
38 void on_get_public_data(void* argument);
39 void on_set_public_data(void* argument);
40 uint32_t rate_increase() const;
41 float check_max_speeds(float target, float isecs);
42
43 StepperMotor* stepper_motor;
44 Pin step_pin; // Step pin for the stepper driver
45 Pin dir_pin; // Dir pin for the stepper driver
46 Pin en_pin;
47 float target_position; // End point ( in mm ) for the current move
48 float unstepped_distance; // overflow buffer for requested moves that are less than 1 step
49 Block* current_block; // Current block we are stepping, same as Stepper's one
50
51 // kept together so they can be passed as public data
52 struct {
53 float steps_per_millimeter; // Steps to travel one millimeter
54 float filament_diameter; // filament diameter
55 float extruder_multiplier; // flow rate 1.0 == 100%
56 float acceleration; // extruder accleration SOLO setting
57 float retract_length; // firmware retract length
58 float current_position; // Current point ( in mm ) for the current move, incremented every time a move is executed
59 };
60
61 float saved_current_position;
62 float volumetric_multiplier;
63 float feed_rate; // default rate mm/sec for SOLO moves only
64 float milestone_last_position; // used for calculating volumemetric rate, last position in mm³
65 float max_volumetric_rate; // used for calculating volumetric rate in mm³/sec
66
67 float travel_ratio;
68 float travel_distance;
69
70 // for firmware retract
71 float retract_feedrate;
72 float retract_recover_feedrate;
73 float retract_recover_length;
74 float retract_zlift_length;
75 float retract_zlift_feedrate;
76
77 struct {
78 char mode:3; // extruder motion mode, OFF, SOLO, or FOLLOW
79 bool absolute_mode:1; // absolute/relative coordinate mode switch
80 bool saved_absolute_mode:1;
81 bool single_config:1;
82 bool retracted:1;
83 bool cancel_zlift_restore:1; // hack to stop a G11 zlift restore from overring an absolute Z setting
84 bool milestone_absolute_mode:1;
85 };
86
87
88 };
89
90 #endif