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/>.
11 #include "libs/Hook.h"
20 StepperMotor(Pin
& step
, Pin
& dir
, Pin
& en
);
22 // Called a great many times per second, to step if we have to now
24 // increase the ( fixed point ) counter by one tick 11t
25 fx_counter
+= (uint32_t)(1<<16);
27 // if we are to step now 10t
28 if (fx_counter
>= fx_ticks_per_step
)
33 inline void unstep() { step_pin
.set(0); };
35 inline void enable(bool state
) { en_pin
.set(!state
); };
38 void move( bool direction
, unsigned int steps
);
39 void signal_move_finished();
40 void set_speed( float speed
);
41 void update_exit_tick();
45 void change_steps_per_mm(float);
46 void change_last_milestone(float);
48 int steps_to_target(float);
50 template<typename T
> void attach( T
*optr
, uint32_t ( T::*fptr
)( uint32_t ) ){
51 Hook
* hook
= new Hook();
52 hook
->attach(optr
, fptr
);
53 this->end_hook
= hook
;
56 template<typename T
> void attach_signal_step(uint32_t step
, T
*optr
, uint32_t ( T::*fptr
)( uint32_t ) ){
57 this->step_signal_hook
->attach(optr
, fptr
);
58 this->signal_step_number
= step
;
59 this->signal_step
= true;
63 Hook
* step_signal_hook
;
66 uint32_t signal_step_number
;
68 StepTicker
* step_ticker
;
73 float steps_per_second
;
81 int32_t last_milestone_steps
;
82 float last_milestone_mm
;
84 uint32_t steps_to_move
;
87 uint32_t fx_ticks_per_step
;
92 bool remove_from_active_list_next_reset
;
94 bool is_move_finished
; // Whether the move just finished