DFU: increase detach timeout to 2 seconds
[clinton/Smoothieware.git] / src / libs / StepperMotor.h
CommitLineData
7b49793d 1/*
feb204be
AW
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.
7b49793d 5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
feb204be
AW
6*/
7
8#ifndef STEPPERMOTOR_H
9#define STEPPERMOTOR_H
10
11#include "libs/Kernel.h"
12#include "libs/Hook.h"
13
14class StepTicker;
15
16class StepperMotor {
17 public:
18 StepperMotor();
19 StepperMotor(Pin* step, Pin* dir, Pin* en);
21254749 20 void tick();
bd0f7508 21 void move_finished();
feb204be 22 void move( bool direction, unsigned int steps );
bd0f7508 23 void signal_move_finished();
feb204be 24 void set_speed( double speed );
672298b2 25 void update_exit_tick();
83ecfc46
AW
26 void pause();
27 void unpause();
feb204be
AW
28
29 template<typename T> void attach( T *optr, uint32_t ( T::*fptr )( uint32_t ) ){
7b49793d 30 Hook* hook = new Hook();
feb204be
AW
31 hook->attach(optr, fptr);
32 this->end_hook = hook;
33 }
34
2f7d3dba
AW
35
36 template<typename T> void attach_signal_step(uint32_t step, T *optr, uint32_t ( T::*fptr )( uint32_t ) ){
37 this->step_signal_hook->attach(optr, fptr);
38 this->signal_step_number = step;
7b49793d 39 this->signal_step = true;
2f7d3dba
AW
40 }
41
42
feb204be 43 Hook* end_hook;
2f7d3dba
AW
44 Hook* step_signal_hook;
45
46 bool signal_step;
47 uint32_t signal_step_number;
feb204be
AW
48
49 StepTicker* step_ticker;
50 Pin* step_pin;
51 Pin* dir_pin;
52 Pin* en_pin;
53
54 double steps_per_second;
55
56 bool moving;
57 bool paused;
58
f6c04440 59 //bool direction_bit;
bd0f7508 60 //bool step_bit;
feb204be
AW
61
62 uint32_t steps_to_move;
63 uint32_t stepped;
64 uint64_t fx_counter;
65 uint64_t fx_ticks_per_step;
7b49793d 66
bd0f7508
AW
67 //bool exit_tick;
68 bool remove_from_active_list_next_reset;
813727fb 69
bd0f7508 70 bool is_move_finished; // Whether the move just finished
feb204be
AW
71};
72
73
74
75#endif
76