Skip to content
Snippets Groups Projects
Commit 29b20f38 authored by Malaurie Bernard's avatar Malaurie Bernard
Browse files

Adding a few methods in motor.cpp to have the distinction between move and...

Adding a few methods in motor.cpp to have the distinction between move and moveTo from the Accelstepper librairie. In fact I created same methods using moveTo but using move and I change comments t explin how it works.

I think it would be useful to see later if we are using all these methods
or if some of them can be deleted.
parent 81954b6b
No related branches found
No related tags found
1 merge request!17Malaurie's work on UI + CLI interface + AccelStepper interface
......@@ -97,9 +97,9 @@ float Motor :: step_to_mm (int step) const
//MOVEMENTS
void Motor :: move_to_step_limit_switch (int step)
/***
-Argument : Number of step.
-Argument : Final position in steps.
-Return : /
-Action : Move the number of step required.
-Action : Move to the number of step required to go to the final position. Can manage the emergency.
***/
{
#if !CORE_MOCK
......@@ -114,9 +114,9 @@ void Motor :: move_to_step_limit_switch (int step)
void Motor :: move_to_mm_limit_switch (float mm)
/***
-Argument : distance in mm
-Argument : Final position in mm.
-Return : /
-Action : Move to the distance required.
-Action : Move to the distance required to go to the final position. Can manage the emergency.
***/
{
Serial.printf("# moving to %g mm / %g steps\n",
......@@ -127,9 +127,10 @@ void Motor :: move_to_mm_limit_switch (float mm)
void Motor :: move_to_step (int step)
/***
-Argument : Number of step.
/***
-Argument : Final position in steps.
-Return : /
-Action : Move the number of step required.
-Action : Move to the number of step required to go to the final position.
***/
{
#if !CORE_MOCK
......@@ -143,9 +144,9 @@ void Motor :: move_to_step (int step)
void Motor :: move_to_mm (float mm)
/***
-Argument : distance in mm
-Argument : Final position in mm.
-Return : /
-Action : Move to the distance required.
-Action : Move to the distance required to go to the final position.
***/
{
Serial.printf("# moving to %g mm / %g steps\n",
......@@ -154,7 +155,6 @@ void Motor :: move_to_mm (float mm)
move_to_step(mm_to_step(mm));
}
void Motor :: stop ()
/***
-Argument : /
......@@ -186,6 +186,67 @@ void Motor :: stay_here ()
sei();
#endif
}
//////////////////
void Motor :: move_step_limit_switch (int step)
/***
-Argument : Mouvement required in steps.
-Return : /
-Action : Move the number of step asked. Can manage the emergency.
***/
{
#if !CORE_MOCK
cli();
set_retain_acceleration_mm_per_sec_per_sec(_retain_acceleration_mm_per_sec_per_sec);
if (_mm_per_revolution > 0 && _steps_per_revolution > 0)
stepper.move(_clockwise_equals_forward? step: -step);
sei();
#endif
Serial.printf("# move to: %d step %g mm\n", step, step_to_mm(step));
}
void Motor :: move_mm_limit_switch (float mm)
/***
-Argument : Mouvement required in distance in mm.
-Return : /
-Action : Move the distance asked. Can manage the emergency.
***/
{
Serial.printf("# moving to %g mm / %g steps\n",
mm,
mm_to_step(mm));
move_step_limit_switch(mm_to_step(mm));
}
void Motor :: move_step (int step)
/***
-Argument : Mouvement required in steps.
-Return : /
-Action : Move to the number of step.
***/
{
#if !CORE_MOCK
cli();
if (_mm_per_revolution > 0 && _steps_per_revolution > 0)
stepper.move(_clockwise_equals_forward? step: -step);
sei();
#endif
Serial.printf("# move to: %d step %g mm\n", step, step_to_mm(step));
}
void Motor :: move_mm (float mm)
/***
-Argument : Mouvement required in distance in mm.
-Return : /
-Action : Move the distance asked.
***/
{
Serial.printf("# moving to %g mm / %g steps\n",
mm,
mm_to_step(mm));
move_step(mm_to_step(mm));
}
//////////////////////
bool Motor :: motor_is_running () //return true if the motor is currently running
/***
......
......@@ -67,8 +67,16 @@ public:
void move_to_mm_limit_switch (float mm);
void move_to_step (int step);
void move_to_mm (float mm);
void stop ();
void stay_here ();
void stay_here ();
void move_step_limit_switch (int step);
void move_mm_limit_switch (float mm);
void move_step (int step);
void move_mm (float mm);
bool motor_is_running ();
//POSITION
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment