Merge branch 'edge' into button
[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 "libs/Module.h"
14 #include "libs/Kernel.h"
15 #include "modules/robot/Block.h"
16
17 #define microseconds_per_step_pulse_checksum CHECKSUM("microseconds_per_step_pulse")
18 #define extruder_module_enable_checksum CHECKSUM("extruder_module_enable")
19 #define extruder_steps_per_mm_checksum CHECKSUM("extruder_steps_per_mm")
20 #define extruder_acceleration_checksum CHECKSUM("extruder_acceleration")
21 #define extruder_step_pin_checksum CHECKSUM("extruder_step_pin")
22 #define extruder_dir_pin_checksum CHECKSUM("extruder_dir_pin")
23 #define extruder_en_pin_checksum CHECKSUM("extruder_en_pin")
24 #define extruder_max_speed_checksum CHECKSUM("extruder_max_speed")
25
26 // default_feed_rate_checksum defined by Robot.h
27
28 #define OFF 0
29 #define SOLO 1
30 #define FOLLOW 2
31
32 class Extruder : public Module{
33 public:
34 Extruder();
35 void on_module_loaded();
36 void on_config_reload(void* argument);
37 void on_gcode_received(void*);
38 void on_gcode_execute(void* argument);
39 void on_block_begin(void* argument);
40 void on_block_end(void* argument);
41 void on_play(void* argument);
42 void on_pause(void* argument);
43 void on_speed_change(void* argument);
44 uint32_t acceleration_tick(uint32_t dummy);
45 uint32_t stepper_motor_finished_move(uint32_t dummy);
46
47 Pin step_pin; // Step pin for the stepper driver
48 Pin dir_pin; // Dir pin for the stepper driver
49 Pin en_pin;
50
51 double target_position; // End point ( in steps ) for the current move
52 double current_position; // Current point ( in steps ) for the current move, incremented every time a step is outputed
53 int current_steps;
54 Block* current_block; // Current block we are stepping, same as Stepper's one
55 int microseconds_per_step_pulse; // Pulse duration for step pulses
56 double steps_per_millimeter; // Steps to travel one millimeter
57 double feed_rate; //
58 double acceleration; //
59 double max_speed;
60
61 int counter_increment;
62 int step_counter;
63
64 bool solo_mode;
65 double travel_ratio;
66 double travel_distance;
67 bool absolute_mode;
68
69 bool debug;
70 int debug_count;
71
72 char mode;
73
74 bool paused;
75
76 StepperMotor* stepper_motor;
77
78 };
79
80 #endif