A simple stepper motor driver library, supporting micro-stepping drivers.
Dependents: Test_LCDTS_UI_StepperMove
Diff: Table.cpp
- Revision:
- 2:97b1bc1f0b5f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Table.cpp Sat Nov 14 11:44:18 2020 +0000 @@ -0,0 +1,28 @@ +#include "Table.h" + +table::table(table_pins tablepin):stepper_X(0),steppers_Y(0) +{ + stepper_X = new stepper(tablepin.X_en,tablepin.X_stepPin,tablepin.X_dir); + steppers_Y = new steppers(tablepin.Y_en,tablepin.Y_stepPin,tablepin.Y_dirG,tablepin.Y_dirD); +} + +void table::move(position pos_current, position pos_togo, float speed) +{ + while (pos_current == pos_togo) + { + if (pos_current.X > pos_togo.X) { + stepper_X->step(1,speed); + pos_current.X = pos_current.X - 0.25; + } else if (pos_current.X < pos_togo.X) { + stepper_X->step(0,speed); + pos_current.X = pos_current.X + 0.25; + } + if (pos_current.Y > pos_togo.Y) { + steppers_Y->step(1,speed); + pos_current.Y = pos_current.Y - 0.25; + } else if (pos_current.Y < pos_togo.Y) { + steppers_Y->step(0,speed); + pos_current.Y = pos_current.Y + 0.25; + } + } +} \ No newline at end of file