Merge pull request #715 from OskarLinde/zhomeofs_precision
[clinton/Smoothieware.git] / src / modules / robot / Stepper.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 #ifndef STEPPER_H
9 #define STEPPER_H
10
11 #include "libs/Module.h"
12 #include <stdint.h>
13
14 class Block;
15 class StepperMotor;
16
17 class Stepper : public Module
18 {
19 public:
20 Stepper();
21 void on_module_loaded();
22 void on_config_reload(void *argument);
23 void on_block_begin(void *argument);
24 void on_block_end(void *argument);
25 void on_gcode_received(void *argument);
26 void on_gcode_execute(void *argument);
27 void on_play(void *argument);
28 void on_pause(void *argument);
29 void on_halt(void *argument);
30 uint32_t main_interrupt(uint32_t dummy);
31 void trapezoid_generator_reset();
32 void set_step_events_per_second(float);
33 void trapezoid_generator_tick(void);
34 uint32_t stepper_motor_finished_move(uint32_t dummy);
35 int config_step_timer( int cycles );
36 void turn_enable_pins_on();
37 void turn_enable_pins_off();
38
39 float get_trapezoid_adjusted_rate() const { return trapezoid_adjusted_rate; }
40 const Block *get_current_block() const { return current_block; }
41
42 private:
43 Block *current_block;
44 float trapezoid_adjusted_rate;
45 StepperMotor *main_stepper;
46
47 struct {
48 bool enable_pins_status:1;
49 bool force_speed_update:1;
50 bool paused:1;
51 bool halted:1;
52 };
53
54 };
55
56
57
58
59 #endif