Add a command to make moves blocking if desired
This commit is contained in:
parent
165f619869
commit
83aa9c113a
1 changed files with 29 additions and 1 deletions
|
|
@ -16,12 +16,14 @@ const int min_step_delay_eeprom = sizeof(long) * n_motors;
|
|||
long ramp_time;
|
||||
const int ramp_time_eeprom = sizeof(long) * (n_motors + 1);
|
||||
const int axis_max_eeprom = sizeof(long) * (n_motors + 2);
|
||||
const int blocking_moves_eeprom = sizeof(long) * (n_motors + 3);
|
||||
Stepper *motors[n_motors];
|
||||
signed long current_pos[n_motors];
|
||||
long steps_remaining[n_motors];
|
||||
|
||||
bool stage_moving = false;
|
||||
bool notify_on_stop = false;
|
||||
bool blocking_moves = false;
|
||||
|
||||
void stage_setup()
|
||||
{
|
||||
|
|
@ -49,6 +51,8 @@ void stage_setup()
|
|||
ramp_time = 0;
|
||||
EEPROM.put(ramp_time_eeprom, ramp_time);
|
||||
}
|
||||
EEPROM.get(blocking_moves_eeprom, blocking_moves);
|
||||
// TODO: do we need to do something to initialise this?
|
||||
|
||||
register_module(stage_commands, stage_loop);
|
||||
}
|
||||
|
|
@ -111,7 +115,13 @@ void start_move(long displ[n_motors])
|
|||
move_start_time = micros();
|
||||
final_scaled_t = (float)max_steps * min_step_delay; //NB total time taken will be final_scaled_t + 2*ramp_time
|
||||
stage_moving = true;
|
||||
if (blocking_moves){
|
||||
notify_on_stop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("done.");
|
||||
}
|
||||
}
|
||||
|
||||
void stage_loop()
|
||||
|
|
@ -260,6 +270,23 @@ void stage_ramp_time(String command)
|
|||
free(args[0]);
|
||||
}
|
||||
|
||||
void update_blocking_moves(String command)
|
||||
{
|
||||
char * args[1];
|
||||
parse_arguments(args, command, 1);
|
||||
if (args[0][0] == '?')
|
||||
{
|
||||
Serial.print("blocking_moves ");
|
||||
Serial.println(blocking_moves ? "true" : "false");
|
||||
}
|
||||
else
|
||||
{
|
||||
blocking_moves = args[0][0] == 't';
|
||||
EEPROM.put(blocking_moves_eeprom, blocking_moves);
|
||||
Serial.println("done.");
|
||||
}
|
||||
}
|
||||
|
||||
void stage_zero(String command)
|
||||
{
|
||||
EACH_MOTOR current_pos[i] = 0;
|
||||
|
|
@ -307,4 +334,5 @@ extern const Command stage_commands[] = {
|
|||
{"stop", stage_stop},
|
||||
{"moving", is_stage_moving},
|
||||
{"notify_on_stop", activate_notify_on_stop},
|
||||
{"blocking_moves", update_blocking_moves},
|
||||
END_COMMAND};
|
||||
Loading…
Add table
Add a link
Reference in a new issue