solved the block end problem, commiting mostly to save all those neat debug statement...
[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 42333
18 #define extruder_module_enable_checksum 6183
19 #define extruder_steps_per_mm_checksum 58088
20 #define default_feed_rate_checksum 53183
21 #define extruder_acceleration_checksum 60356
22
23 #define OFF 0
24 #define SOLO 1
25 #define FOLLOW 2
26
27 class Extruder : public Module{
28 public:
29 Extruder();
30 void on_module_loaded();
31 void on_config_reload(void* argument);
32 void on_gcode_execute(void* argument);
33 void on_block_begin(void* argument);
34 void on_block_end(void* argument);
35 void on_play(void* argument);
36 void on_pause(void* argument);
37 void on_speed_change(void* argument);
38 uint32_t acceleration_tick(uint32_t dummy);
39 uint32_t stepper_motor_finished_move(uint32_t dummy);
40
41 Pin* step_pin; // Step pin for the stepper driver
42 Pin* dir_pin; // Dir pin for the stepper driver
43 Pin* en_pin;
44
45 double target_position; // End point ( in steps ) for the current move
46 double current_position; // Current point ( in steps ) for the current move, incremented every time a step is outputed
47 int current_steps;
48 Block* current_block; // Current block we are stepping, same as Stepper's one
49 int microseconds_per_step_pulse; // Pulse duration for step pulses
50 double steps_per_millimeter; // Steps to travel one millimeter
51 double feed_rate; //
52 double acceleration; //
53
54 int counter_increment;
55 int step_counter;
56
57 bool solo_mode;
58 double travel_ratio;
59 double travel_distance;
60 bool absolute_mode;
61
62 bool debug;
63 int debug_count;
64
65 char mode;
66
67 bool paused;
68
69 StepperMotor* stepper_motor;
70
71 };
72
73 #endif